akhauriyash/Code-Regression huggingface dataset:
using System;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(ReadLine());
        string[] w = new string[n];
        w[0] = ReadLine();

        for (int i = 1; i < n; i++)
        {
            w[i] = ReadLine();
            if(w[i][0] != w[i - 1][w[i - 1].Length - 1])
            {
                WriteLine("No");
                Environment.Exit(0);
            }
        }
        Array.Sort(w);

        for (int i = 1; i < n; i++)
        {
            if (w[i] == w[i - 1])
            {
                WriteLine("No");
                Environment.Exit(0);
            }
        }

        WriteLine("Yes");
    }
}


Measured memory_bytes: 11360
if __name__=="__main__":
    n = int(input())
    f = [int(1e10) for i in range(n)]
    h = [int(i) for i in input().split(' ')]
    f[0] = 0
    for i in range(n):
        if (i > 0):
            f[i] = f[i - 1] + abs(h[i] - h[i - 1])
            if i != 1:
                f[i] = min(f[i], f[i - 2] + abs(h[i] - h[i - 2]))
    print(f[n - 1])

Measured memory_bytes: 17808
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define two ios_base::sync_with_stdio(0)
#define powerofn cin.tie(0)
using namespace std;

ll const MOD = 998244353;

int const max_n = 3 * 1e5 + 10;

void yes(){
    cout<<"YES"<<'\n';
}

void no(){
    cout<<"NO"<<'\n';
}

ll fact(int n){
    ll ans = 1;
    for(int i=2;i<=n;i++){
        ans = (ans*i)%MOD;
    }

    return ans;
}

ll powM(int n, int x){
    if(x==0){
        return 1;
    }
    if(x==1){
        return n%MOD;
    }

    if(x%2==0){
        ll a = powM(n,x/2);
        return (a*a)%MOD;
    }else{
        return (n*powM(n,x-1))%MOD;
    }
}

ll C(int n, int k){
    return (fact(n) * powM((fact(k)*fact(n-k))%MOD,MOD-2))%MOD;
}

ll A(int n, int k){
    return (fact(n) * powM(fact(n-k)%MOD,MOD-2))%MOD;
}

void add_self(int &a, int b){
    a += b;
    if(a>=MOD){
        a-=MOD;
    }
}

void sub_self(int &a, int b){
    a -= b;
    if(a<0){
        a+=MOD;
    }
}


struct segtree {

    vl tree;
    int size;

    void init(int n){
        size = 1;
        while(size < n) size*=2;
        tree.assign(2*size-1,0);
    }
    void build(vi &a,int x, int lx, int rx){
        if(rx-lx == 1){
            if(lx<a.size())
                tree[x] = a[lx];
        }else{
            int m = (lx+rx)/2;
            build(a,2*x+1,lx,m);
            build(a,2*x+2,m,rx);
            tree[x] = tree[2*x+1]+tree[2*x+2];
        }
    }

    void build(vi &a){
        init(a.size());
        build(a,0,0,size);
    }

    void set(int i, int v, int x, int lx, int rx){
        if(rx-lx==1){
            tree[x] = v;
            return;
        }
        int m = (lx+rx)/2;
        if(i<m){
            set(i,v,2*x+1,lx,m);
        }else{
            set(i,v,2*x+2,m,rx);
        }
        tree[x] = tree[2*x+1] + tree[2*x+2];
    }

    void set(int i, int v){
        set(i,v,0,0,size);
    }

    ll sum(int l, int r, int x, int lx, int rx){
        if(l>=rx || lx>=r){
            return 0;
        }
        if(lx>=l && rx<=r){
            return tree[x];
        }
        int m = (rx+lx)/2;
        ll s1 = sum(l,r,2*x+1,lx,m);
        ll s2 = sum(l,r,2*x+2,m,rx);
        return s1+s2;
    }

    ll sum (int l,int r){
        return sum(l,r,0,0,size);
    }

};

int a[max_n];
map<string, int> aa;

void solve(){

    int n;
    cin >> n;

    string s;

    for(int i=0; i<n; i++){
        cin >> s;
        aa[s]++;
    }

    cout << "AC" << " x " << aa["AC"] << endl;
    cout << "WA" << " x " << aa["WA"] << endl;
    cout << "TLE" << " x " << aa["TLE"] << endl;
    cout << "RE" << " x " << aa["RE"] << endl;

}

int main(){
    two;
    powerofn;

    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 3668
#!/usr/bin/env python
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
Acum = A.cumsum()
cache = {}
cnt = 0
for i in range(N):
    if Acum[i]==0:
        cnt += 1
    c = cache.get(Acum[i], 0)
    cnt += c
    cache[Acum[i]] = c+1
print(cnt)

Measured memory_bytes: 39632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    cout << (n >= 1000 ? "ABD" : "ABC") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

template<typename T>
class P2 {
public:
	T x, y;
	P2(T x = 0, T y = 0) : x(x), y(y){}
	bool operator < (const P2<T>& p) const { return make_pair(x, y) < make_pair(p.x, p.y); }
	T length() const { return sqrt(x*x+y*y); }
	void sub(const P2<T>& p){ x -= p.x; y -= p.y; }
	void scale(T s){ x *= s; y *= s; }
};

template<typename T>
auto dot(const P2<T>& a, const P2<T>& b, const P2<T>& c){
	auto dx1 = b.x - a.x;
	auto dy1 = b.x - a.x;
	auto dx2 = c.x - b.x;
	auto dy2 = c.y - b.y;
	return dx1*dx2 + dy1*dy2;
}

template<typename T>
auto cross(const P2<T>& a, const P2<T>& b, const P2<T>& c){
	auto dx1 = b.x - a.x;
	auto dy1 = b.y - a.y;
	auto dx2 = c.x - b.x;
	auto dy2 = c.y - b.y;
	return dx1*dy2 - dy1*dx2;
}

template<typename T>
vector<P2<T>> convexHull(const vector<P2<T>>& ps){
	if(ps.size() <= 2) return ps;
	vector<P2<T>> pt = ps;
	sort(pt.begin(), pt.end());
	vector<P2<T>> res;
	for(int i=0;i<pt.size();i++){
		while(res.size() >= 2){
			int k = res.size();
			long long cr = cross(res[k-2], res[k-1], pt[i]);
			long long dt = dot(res[k-2], res[k-1], pt[i]);
			if(cr < 0 || (cr == 0 && dt >= 0)){
				res.pop_back();
			} else {
				break;
			}
		}
		res.push_back(pt[i]);
	}
	for(int i=pt.size()-2, t=res.size()+1;i>=0;i--){
		while(res.size() >= t){
			int k = res.size();
			long long cr = cross(res[k-2], res[k-1], pt[i]);
			long long dt = dot(res[k-2], res[k-1], pt[i]);
			if(cr < 0 || (cr == 0 && dt >= 0)){
				res.pop_back();
			} else {
				break;
			}
		}
		res.push_back(pt[i]);
	}
	res.pop_back();
	return res;
}

int main(){
	int N;
	while(cin >> N){
		using P2L = P2<long long>;
		vector<P2L> p(N);
		for(auto& t : p) cin >> t.x >> t.y;
		vector<P2L> hull = convexHull(p);
		vector<double> res(N, 0.0);
		int m = hull.size();
		for(int i=0;i<m;i++){
			P2<double> a(hull[i].x - hull[(i+m-1)%m].x, hull[i].y - hull[(i+m-1)%m].y);
			P2<double> b(hull[(i+1)%m].x - hull[i].x, hull[(i+1)%m].y - hull[i].y);
			a.scale(1/a.length());
			b.scale(1/b.length());
			int idx = 0;
			for(int j=0;j<N;j++){
				if(p[j].x == hull[i].x && p[j].y == hull[i].y) idx = j;
			}
			res[idx] = 0.5 * acos(a.x*b.x+a.y*b.y) / acos(-1.0);
		}
		for(auto t : res) printf("%.10lf\n", t);
	}
}


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

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

using namespace std;

int main(){
    int a,b;
    cin >>a>>b;;
    cout <<max(a,b)-min(a,b)<<endl;
    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

int main() {
  int N;
  string S;
  cin >> N >> S;
  vector<string> vec = {"SS", "SW", "WS", "WW"};
  for (int i = 0; i < 4; i++) {
    string w = vec[i];
    for (int j = 1; j < N; j++) {
      if (S[j] == 'o') {
        if (w[j] == 'S') {
          w += (w[j - 1] == 'S' ? 'S' : 'W');
        } else {
          w += (w[j - 1] == 'S' ? 'W' : 'S');
        }
      } else {
        if (w[j] == 'S') {
          w += (w[j - 1] == 'S' ? 'W' : 'S');
        } else {
          w += (w[j - 1] == 'S' ? 'S' : 'W');
        }
      }
    }
    if (w[0] != w[N]) {
      continue;
    }
    if (S[0] == 'o') {
      if (w[0] == 'S') {
        if(w[N-1] != w[1]) {
          continue;
        }
      } else {
        if (w[N-1] == w[1]) {
          continue;
        }
      }
    } else {
      if (w[0] == 'S') {
        if(w[N-1] == w[1]) {
          continue;
        }
      } else {
        if (w[N-1] != w[1]) {
          continue;
        }
      }
    }
    for (int j = 0; j < N; j++) {
      cout << w[j];
    }
    cout << endl;
    return 0;
  }
  cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 816
// Created by new_sm
//
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int n,h,w;
cin>>n>>h>>w;
int cnt=0;
while(n--)
{
	int x,y;
	cin>>x>>y;
	if(x<h||y<w)
	continue;
	else
	cnt++;
}
cout<<cnt;
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}



Measured memory_bytes: 3640
//package atcoder;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String [] args)  {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		String S[] = new String[(int) N];
		int count1=0;
		int count2=0;
		int count3=0;
		int count4=0;
		
		for(int i=0;i<N;i++) {
			S[i] = sc.next();
			
		}
		//System.out.println(S[1]);
		
		
		for(int j=0;j<N;j++) {
			if(S[j].equals("AC")) {
				count1 ++;
			}
			if(S[j].equals("WA")) {
				count2 ++;
			}
			if(S[j].equals("TLE")) {
				count3 ++;
			}
			if(S[j].equals("RE")) {
				count4 ++;
			}
		}
		//System.out.println(count1);
		System.out.println("AC x " + count1);
		System.out.println("WA x " + count2);
		System.out.println("TLE x " + count3);
		System.out.println("RE x " + count4);
		
		
	}
}

Measured memory_bytes: 64832
#include<bits/stdc++.h>
using namespace std;
int main(){ 
    int N;
    string s;
    cin >> N >> s;
    int ma = 0;
    for(int i = 1; i < N; i++){
        string s_1 = s.substr(0,i), s_2 = s.substr(i);
        int c = 0;
        bool alph1[30], alph2[30];
        for(int j = 0; j < 30; j++){
            alph1[j] = false; alph2[j] = false; 
        }
        for(int j =  0; j < i; j++){
            alph1[s_1[j]- 'a'] = true;
        }
        for(int j =  0; j < N-i; j++){
            alph2[s_2[j]- 'a'] = true;
        }
        for(int j = 0; j < 30; j++){
            if(alph1[j]&&alph2[j]) c++;
        }
        
        ma = max(ma,c);
    }
    cout << ma << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = [int(input()) for i in range(6)]
k = n[5]
ret = "Yay!"
for i in range(5):
    x = n[i]
    for j in range(1,5-i):
        y = n[i+j]
        if(y-x>k):
            ret = ":("
            break
    else:
        continue
    break

print(ret)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
  int i,j,H,W;
  while(true){
    cin >> H >> W;
    if(H==0 && W==0)break;
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
}



Measured memory_bytes: 3104
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
ll XY[200000], tmp[200000];
void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	int saidai = 0;
	int saishou = 1e9;
	int saidai2 = 0;
	int saishou2 = 1e9;
	rep(i, N) {
		int x = getint();
		int y = getint();
		if (x > y) swap(x, y);
		chmax(saidai, y);
		chmax(saidai2, x);
		chmin(saishou, x);
		chmin(saishou2, y);
		XY[i] = ((ll)y << 32) + x;
	}
	ll kotae = 1ll * (saidai - saishou2) * (saidai2 - saishou);

	pakuri_sort(N, XY);

	int m = (1 << 31) - 1;
	int saishou3 = 1e9;
	ll haba = saidai - saishou;
	rep(i, N) {
		int x = XY[i] & m;
		int y = XY[i] >> 32;
		if (saishou3 < x) break;
		chmin(kotae, haba * (saidai2 - x));
		chmin(saishou3, y);
		chmax(saidai2, y);
	}
	chmin(kotae, haba* (saidai2 - saishou3));
	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const int MAXS = 50;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);

int n,m;
int a[MAXS],b[MAXS];
bool G[MAXS][MAXS];
bool visited[MAXS];

void dfs(int v){
    visited[v]=true;
    for(int v2 = 0;v2<n;v2++){
        if(!G[v][v2])continue;
        if(visited[v2])continue;
        dfs(v2);
    }
}

signed main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
        G[a[i]][b[i]]=true;
        G[b[i]][a[i]]=true;
    }
    int res = 0;
    for(int i=0;i<m;i++){
        G[a[i]][b[i]]=false;
        G[b[i]][a[i]]=false;
        for(int j=0;j<n;j++)visited[j]=false;
        dfs(0);
        bool can = false;
        for(int j=0;j<n;j++){
            if(visited[j]==false)can=true;
        }
        if(can)res++;
        G[a[i]][b[i]]=true;
        G[b[i]][a[i]]=true;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(System.in);
    try {
      String S = scanner.next();
      String T = scanner.next();
      int n = S.length();
      
      for (int i = 0; i < n; i++) {
        if (valid(S,T,n,i)) {
          System.out.println("Yes");
          return;
        }
      }
      System.out.println("No");
    }
    finally {
      scanner.close();
    }
  }

  private static boolean valid(String s, String t, int n, int offset) {
    for (int i = 0; i < n; i++) {
      if (s.charAt(i) != t.charAt((i+offset)%n)) return false;
    }
    return true;
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using u64 = uint64_t;

int main() {
	u64 X;
	cin >> X;
	
	u64 t = 100;
	u64 ans = 0;
	double r = 1.01;
	
	while(X > t) {
		t = r * (double)t;
		ans++;
	}
	
	cout << ans;
	return 0;
}


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

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	string S;
	cin >> S;
	int count = 0, countB = 0;
	rep(i, N) {
		if (S.at(i) == 'c') {
			cout << "No" << endl;
			continue;
		}
		if (S.at(i) == 'a') {
			if (A + B > count) {
				cout << "Yes" << endl;
				count++;
			}
			else {
				cout << "No" << endl;
			}
			continue;
		}
		if (S.at(i) == 'b') {
			if (A + B > count && B > countB) {
				cout << "Yes" << endl;
				count++;
				countB++;
			}
			else {
				cout << "No" << endl;
			}
			continue;
		}

	}
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define All(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

struct UnionFind {
    vector<int> par;
    vector<int> rnk;

    UnionFind(int n) {
        par.assign(n, 0);
        rnk.assign(n, 1);
        for(int i=0; i<n; i++) {
            par[i] = i;
        }
    }

    void unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return;
        if(rnk[x] < rnk[y]) swap(x, y);
        rnk[x] += rnk[y];
        par[y] = x;
    }

    int find(int x) {
        if(par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return rnk[find(x)];
    }
};

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

    UnionFind uf(500050);

    vi xa(m), ya(m);

    rep(i, m) {
        int x, y, z;
        cin >> x >> y >> z;
        uf.unite(x, y);
        xa[i] = x;
        ya[i] = y;
    }
    

    vi cnts;
    V(bool) did(500050, false);
    rep(i, m) {
        //cout << uf.size(xa[i]) << endl;
        if(!did[uf.find(xa[i])]) {
            cnts.pb(uf.size(xa[i]));
            did[uf.find(xa[i])] = true;
        }     
    }

    int res = 0;
    int sum = 0;
    int i = 0;
    GSORT(cnts);
    while(sum < n && i<cnts.size()) {
        sum += cnts[i++];
        res++;
    }

    if(sum < n) res += n-sum;

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 9728
import sys

class Node():
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left, self.right = None, None
        
    def __str__(self):
        return self.key

root = None
def insert(z):
    global root
    x, y = root, None
    while x:
        y = x
        if z < x.key:
            x = x.left
        else:
            x = x.right
    
    if y == None:
        root = Node(z)
    elif z < y.key:
        y.left = Node(z)
    else:
        y.right = Node(z)
        
def preorder(x):
    return f" {x.key}" + preorder(x.left) + preorder(x.right) if x else ""

def inorder(x):
    return inorder(x.left) + f" {x.key}" + inorder(x.right) if x else ""
        
input()
node = {}
for s in sys.stdin:
    if s[0] == "p":
        pass
        print(inorder(root))
        print(preorder(root))
    else:
        insert(int(s[7:]))


Measured memory_bytes: 63480
#include <bits/stdc++.h>
using namespace std;
int main(){
  string alphabet;
  alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int N;
  cin >> N;
  string S;
  cin >> S;
  int M;
  M = S.length();
  string ans="";
  for(int i = 0; i<M; i++){
    for(int j=0; j<26; j++){
      if(S.at(i) == alphabet.at(j)){
        ans.push_back(alphabet.at(j+N));
      }
    }
  }
  cout << ans << endl;
}

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

#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;
typedef long long int lli;

int main(void)
{
	int N, K; cin >> N >> K;
	vector<lli> x(N);
	rep(i, 0, N)cin >> x[i];
	lli ans = 1LL << 60;
	rep(i, 0, (N - K + 1)) {
		lli tmp = min(abs(x[i]), abs(x[i + K - 1])) + abs(x[i] - x[i + K - 1]);
		ans = min(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/python3
# abc121_c

"""
Energy Drink Collector
"""
test = False


def main():
    """
    とにかく安い方からM本になるまで買い続ける。
    """
    N, M = map(int, input().split())
    l = []
    bottle = 0
    cost = 0

    for _ in range(N):
        # [値段, 在庫本数] の2xNリストをつくる。
        l.append(list(map(int, input().split())))

    # 安い順に並べる
    l.sort()
    # 安い店の在庫を全部買って、M本を超えたら中断

    for i in range(N):
        bottle += l[i][1]
        cost += l[i][0] * l[i][1]
        # 買いすぎた分を返品
        if bottle >= M:
            cost -= (bottle - M) * l[i][0]
            break

    # 合計金額を出力
    print(cost)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27880
#include <bits/stdc++.h>
#define pi acos(-1)
#define maxn 100001
using namespace std;
typedef long long ll;
const int mx=200005;
//ll a[mx];
//ll tree[mx*4];
//ll n;
//ll solve(ll arr[], ll x, ll n)
//{
//  ll *low = lower_bound(arr, arr+n, x);
//  if (low == (arr + n) || *low != x)
//     return 0;
//  ll *high = upper_bound(low, arr+n, x);
//  return high - low;
//}
//void init(int node, int b, int e)
//{
//    if (b == e)
//    {
//        tree[node] = a[b];
//        return;
//    }
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    init(Left, b, mid);
//    init(Right, mid + 1, e);
//    ll x= max(tree[Left],tree[Right]);
//    tree[node]=solve(a,x,n);
//}
//int query(int node, int b, int e, int i, int j)
//{
//    if (i > e || j < b)
//        return 0;
//    if (b >= i && e <= j)
//        return tree[node];
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    int p1 = query(Left, b, mid, i, j);
//    int p2 = query(Right, mid + 1, e, i, j);
//    ll x= max(p1,p2);
//    return solve(a,x,n);
//}
//void update(int node, int b, int e, int i, int newvalue)
//{
//    if (i > e || i < b)
//        return;
//    if (b >= i && e <= i) {
//        tree[node] = newvalue;
//        return;
//    }
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    update(Left, b, mid, i, newvalue);
//    update(Right, mid + 1, e, i, newvalue);
//    tree[node] = __gcd(tree[Left] , tree[Right]);
//}
//void euiler()
//{
//    for(int i=1;i<maxn;i++)phi[i]=i;
//    for(int p=2;p<maxn;p++){
//        if(phi[p]==p){
//            phi[p]=p-1;
//            for(int i=2*p;i<maxn;i+=p){
//                phi[i]=(phi[i]/p)*(p-1);
//            }
//        }
//    }
//}
//void update(ll idx,ll val)
//{
//    while(idx<=n){
//        tree[idx]=max(tree[idx],val);
//        idx+=(idx&-idx);
//    }
//}
//ll query(ll idx)
//{
//    ll sum=0;
//    while(idx>0){
//        sum=max(sum,tree[idx]);
//        idx-=(idx&-idx);
//    }
//    return sum;
//}

int main()
{
   ll n,k;
   cin>>n>>k;
   ll a[k+2];
   for(int i=0;i<k;i++){
    cin>>a[i];
   }
   sort(a,a+k);
   ll mx=LONG_MIN;
   for(int i=0;i<k-1;i++){
    mx=max(mx,a[i+1]-a[i]);
   }
   cout<<abs(n-max(mx,a[0]-a[k-1]+n))<<endl;
}


Measured memory_bytes: 1792
A, B, C, D, E, F = map(int, input().split())

ans = -1
sugar = 0
sugar_water = 0
for a in range(F // (A * 100) + 1):
    for b in range((F - 100 * A * a) // (B * 100) + 1):
        for c in range((F - 100 * A * a - 100 * B * b) // C + 1):
            for d in range((F - 100 * A * a - 100 * B * b - C * c) // D + 1):
                x = a * A + b * B
                y = c * C + d * D
                if x == 0:
                    continue
                if x * E >= y and ans < (100 * y)/(x*100+y):
                    ans = (100 * y)/(x*100+y)
                    sugar = y
                    sugar_water = 100 * x + y
print(sugar_water,sugar)


Measured memory_bytes: 42348
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
const int maxn = 200005;

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    for(int i = 0; i < (int)s.size(); i += 2){
        cout << s[i];
    }
    //how much time has elapsed
    //cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << endl;
    return 0;
    
}


Measured memory_bytes: 592
spots_and_people = input().split()
spot_values = input().split()

N_spot = int(spots_and_people[1])
N_people = int(spots_and_people[0])

spot_values = [ int(value) for value in spot_values ]
spot_values.sort()

line_length = [ spot_values[i+1] - spot_values[i] for i in range(N_spot-1) ]
line_length.sort()


if N_spot <= N_people:
	travel = 0

else:
	for i in range(N_people-1):
  		line_length.pop(-1)
  

	travel = sum(line_length)

print(travel)

Measured memory_bytes: 13840
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}


void Main()
{
	ll N,A,B;
	ll res=0;
	string sres;
	cin>>N;
	cin>>A>>B;
	for (int k = A; k<=B; ++k) {
		if(k%N==0){ COUT("OK"); return;}

	}
	COUT("NG");
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 3656
N, M = map(int, input().split())
X = [0]*N
for _ in range(M):
    a, b = map(int, input().split())
    if a==1 or a==N: X[b-1]+=1
    if b==1 or b==N: X[a-1]+=1

print('POSSIBLE' if max(X)>=2 else 'IMPOSSIBLE')


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b;
	string s;
	cin>>n>>a>>b>>s;
	int cnt1=0, cnt2=0;
	REP(i, s.size()){
		bool ok=false;
		if(s[i]=='a'){
			if(++cnt1<=a+b){
				ok=true;
			}
		}
		else if(s[i]=='b'){
			if(++cnt2<=b && cnt1<a+b){
				ok=true;
				++cnt1;
			}
		}
		cout<<(ok ? "Yes" : "No")<<'\n';
	}
	return 0;
}


Measured memory_bytes: 848
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (int argc, char const *argv[])
{
    intmax_t P, Q, R;
    intmax_t ans = 0;

    scanf("%jd%jd%jd", &P, &Q, &R);

    ans += P + Q + R;
    ans -= P < Q ? ((Q < R) ? R : Q) : ((P < R) ? R : P);

    printf("%jd\n", ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A , B , C;
  cin >> A >> B >> C;
  
  if(A == 5 && B == 7 && C == 5) {
    cout << "YES" << endl;
  }
  
  else if(A == 5 && B == 5 && C == 7) {
    cout << "YES" << endl;
  }
  
  else if (A == 7 && B == 5 && C == 5) {
    cout << "YES" << endl;
  }
  
  else { cout << "NO" << endl; }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int out = 700;
        for(int i = 0; i < 3; i++) if(s.charAt(i) == 'o') out += 100;
        System.out.println(out);
        scan.close();
    }

    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 35608
/*input
codefestival
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	IOS;
	string s;
	cin>>s;
	REP(i,4) cout<<s[i];
	cout<<' ';
	REP(i,8) cout<<s[4+i];
	cout<<'\n';
	return 0;
}


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

using namespace std;

const int maxn = 100010;
string s;

int read(){
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*w;
}

signed main()
{
    #ifndef ONLINE_JUDGE
  	freopen("test.in", "r", stdin);
	freopen("test.out", "w", stdout);
    #endif  

    cin>>s;
	if(s[s.size() - 1] == 's') s += "es";
	else s += "s";
	cout<<s;

    return 0;
}

Measured memory_bytes: 3632
N, Q, S, T = map(int, input().split())
A = [int(input()) for i in range(N + 1)]
diff = [A[i + 1] - A[i] for i in range(N)]

def calc(v):
    if v > 0:
        return -S * v
    else:
        return -T * v

ret = 0
for i in range(N):
    ret += calc(diff[i])
    
for i in range(Q):
    a, b, c = map(int, input().split())
    ret -= calc(diff[a - 1])
    diff[a - 1] += c
    ret += calc(diff[a - 1])
    if b != N:
        ret -= calc(diff[b])
        diff[b] -= c
        ret += calc(diff[b])
    print(ret)

Measured memory_bytes: 23684
import sys
input=sys.stdin.readline
from collections import deque

def main():
    h,w=map(int,input().split())
    MAP=[['#']*(w+2)]
    for _ in range(h):
        S=list(input().strip())
        S=['#']+S+['#']
        MAP.append(S)
    MAP.append(['#']*(w+2))
    #print(MAP)
    ans=0
    
    def Dist(k,l):
        delta=[[1,0],[0,1],[-1,0],[0,-1]]
        Dist=[[float('inf')]*(w+2) for _ in range(h+2)]
        Dist[k][l]=0
        Visited=[[False]*(w+2) for _ in range(h+2)]
        Visited[k][l]=True
        q=deque()
        q.append((k,l))
        while q:
            y,x=q.popleft()
            for dx,dy in delta:
                #print(y+dy,x+dx)
                if Dist[y+dy][x+dx]==float('inf') and MAP[y+dy][x+dx]=='.':
                    q.append((y+dy,x+dx))
                    Dist[y+dy][x+dx]=Dist[y][x]+1
        ret=0
        for i in range(h+2):
            for j in range(w+2):
                if Dist[i][j]==float('inf'):
                    continue
                ret=max(ret,Dist[i][j])
        return ret
        
    for i in range(1,h+1):
        for j in range(1,w+1):
            if MAP[i][j]=='#':
                continue
            dist=Dist(i,j)
            ans=max(ans,dist)
    print(ans)
    
if __name__=='__main__':
    main()

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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if ((c-1)/b + 1 <= (a-1)/d + 1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3576
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = sorted([A[i]-B[i] for i in range(N)],reverse=True)
cp = 0
cm = 0
cnt = 0
for i in range(N):
    if C[i]>0:
        cp += C[i]
    elif C[i]<0:
        cnt += 1
        cm += -C[i]
if cm>cp:
    print(-1)
elif cnt==0:
    print(0)
else:
    cur = 0
    tot = C[cur]
    for i in range(N):
        if C[i]<0:
            while tot-abs(C[i])<0:
                tot += C[cur+1]
                cur += 1
            tot += C[i]
    print(cur+1+cnt)  

Measured memory_bytes: 98660
#include<bits/stdc++.h>
#define int long long int
#define nitro ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define pb push_back
#define pi 3.1415926535897932384626
#define mod 1000000007
#define endl '\n'
#define F first
#define S second

using namespace std;

int minimumChar(string S1, string S2) 
{ 
    // Get the sizes of both strings 
    int n = S1.size(), m = S2.size(); 
  
    int ans = INT_MAX; 
  
    // Traverse the string S2 
    for (int i = 0; i < m - n + 1; i++) { 
        int minRemovedChar = 0; 
  
        // From every index in S2, check the number of 
        // mis-matching characters in substring of 
        // length of S1 
        for (int j = 0; j < n; j++) { 
            if (S1[j] != S2[i + j]) { 
                minRemovedChar++; 
            } 
        } 
  
        // Take minimum of prev and current mis-match 
        ans = min(minRemovedChar, ans); 
    } 
  
    // return answer 
    return ans; 
}

int32_t main()
{
 nitro;
 /*#ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
 #endif*/
 int tt=1;
 //cin>>tt;
 while(tt--)
 {
     string s,t;
     cin>>s>>t;
     cout<<minimumChar(t,s);
 }
return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	int x,y;
	cin>>x>>y;
	int res = 0;
	int z = 1e5;
	if(x<=3)
		res += (4-x)*(z);
	if(y<=3)
		res += (4-y)*(z);
	if(x==1 && y==1)
		res += 4*z;
	cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define int long long 
signed main()
{
	// freopen ("input.txt","r",stdin);
	// freopen ("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,x,y;
    cin>>n>>x>>y;
    int i,j,p,lev[n+1],out[n+1]={0};queue<int>q;vector<int>vec[n+1];bool vis[n+1]={0};
    for(i=1;i<n;i++)
    {
        vec[i].push_back(i+1);
        vec[i+1].push_back(i);
    }
    vec[x].push_back(y);
    vec[y].push_back(x);
    // for(i=1;i<=n;i++)
    // cout<<vec[i].size();
    for(i=1;i<=n;i++)
    {
        q.push(i);lev[i]=0;
        while(!q.empty())
        {
            
            p=q.front();
            q.pop();
            vis[p]=true;
            for(j=0;j<vec[p].size();j++)
            {
                if(vis[vec[p][j]]==false)
                {
                q.push(vec[p][j]);
                lev[vec[p][j]]=lev[p]+1;
                vis[vec[p][j]]=true;
                }
            }
        }
        for(j=1;j<=n;j++)
        vis[j]=false;
        for(j=1;j<=n;j++)
        out[lev[j]]++;
    }
    
   for(i=1;i<n;i++)
    cout<<out[i]/2<<"\n";
}

Measured memory_bytes: 384
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define pii pair<ll,ll>

struct BIT
{
    std::vector<int> bit;
    
    BIT(int size) : bit(size, 0){ }
    
    void add(int k, int x) {
        while (k < bit.size()) {
            bit[k] += x;
            k += k &-k;
        }
    }
    int sum(int k) {
        int res = 0;
        while (k > 0) {
            res += bit[k];
            k -= k&-k;
        }
        return res;
    }
};

struct UnionFind {
    vector<int> data;
    
    UnionFind(int size) : data(size, -1) { }
    
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y)
        {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};


using namespace std;

int main(void)
{
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    
    vector<ll> v(n);
    bool odd = n % 2 == 1;
    for(int i = 0;i < n;i++)
    {
        int c = n/2;
        int p = (i+1)/2;
        if(i == 0)
        {
            p = 0;
        }
        bool codd = i % 2 == 1;
        if(codd ^ odd)
        {
            p *= -1;
        }
        //cout << c + p << " " << a[i] << endl;
        v[c+p] = a[i];
    }
    for(auto e : v)
    {
        cout << e << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5248
import numpy as np

def spaceinput():
    return list(map(int,input().split(" ")))


N,K=spaceinput()

res=0

for i in range(1,N+1):
    if K>i:
        tmp=np.ceil(np.log2(K/i))
        res+=(0.5**tmp)/N
    else:
        res+=1/N

    


print(res)


Measured memory_bytes: 12424
# include <cstdio>
# include <iostream>
# include <vector>
# include <map>
# include <set> 
# include <algorithm> 
# include <string>
# include <cstring>
# include <queue> 
# include <stack> 
# include <cstdlib> 

using namespace std ; 

int main()
{
	int x, N ; 
	set< int > S ;  
	cin >> x >> N ; 

	// vector< int > p(N) ; 

	for(int i = 0 ;i < N ; ++i)
	{
		int t ; 
		cin >> t ; 
		S.insert(t) ; 
	}
	if(N==0){
		cout << x << "\n";
		return 0 ; 
	}
	if(S.find(x) == S.end())
	{
		cout << x << "\n" ;
		return 0 ; 
	}

	for(int d = 1 ; d <= 100 ; ++d)
	{
		int op1 = x + d ; 
		int op2 = x - d ; 

		if(S.find(op2)==S.end()){
			cout << op2 << "\n";
			return 0; 
		}
		if(S.find(op1)==S.end())
		{
			cout << op1 << "\n";
			return 0 ; 
		}


	}

		
	

	// cout << "Hello World\n" ; 
	return 0 ; 
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

ll modpow(ll a,ll n,ll mod){
  if(n == 0) return 1LL;
  if(n % 2 == 0){
    ll d = modpow(a,n/2,mod) % mod;
    return (d*d) % mod;
  }
  return (a % mod) * (modpow(a,n-1,mod) % mod) % mod;
}

int main(){
  ll n; cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  ll sum = 0;
  ll times = 0;
  while(times < 65){
    ll cnt1 = 0,cnt0 = 0;
    ll b_sum = 0;
    for(int i = 0; i < n; i++){
      if(a[i] % 2 == 1) cnt1++;
    }
    cnt0 = n-cnt1;
    for(int i = 0; i < n; i++){
      if(a[i] % 2 == 1){
        cnt1--;
        b_sum += cnt0;
      }else{
        cnt0--;
        b_sum += cnt1;
      }
      a[i] /= 2;
    }
    b_sum%=MOD;
    ll res = modpow(2,times,MOD)*b_sum;
    sum += res%MOD;
    sum %= MOD;
    times++;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 5544
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main(){

    int A,B,X;

    cin >> A>>B>>X;

    if(X>=A&&X<=(A+B)){
        cout << "YES" <<endl;
    }else{
        cout << "NO"<<endl;
    }

    return 0;

}


Measured memory_bytes: 764
# -*- coding: utf-8 -*-
# 標準入力を取得
N = int(input())
A = list(map(int, input().split()))

# 求解処理
ans = 0
highest = 0
for n in range(N):
    highest = max(highest, A[n])
    ans += max(highest - A[n], 0)

# 結果出力
print(ans)


Measured memory_bytes: 32224
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

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

    int sum = 1900 * M + 100 * (N - M);

    int ans = sum * pow(2, M);
    cout << ans << endl;
}


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

int main() {
int N,X ;
  cin >> N >> X ;
  vector <int> A(N);
  for (int i=0; i<N; i++){
  cin >> A[i];
  }
  int sum=0;
   for (int i=0; i<N; i++){
  sum+=A[i];
  }
  int Y=X-sum;
  int light=A[0];
  for (int i=0;i<N; i++){
  if (light>A[i]) light=A[i];
  }
  
  cout << N+Y/light << endl;  
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;


int main()
{
    ll N,K;
    cin >> N >> K;
    vector<ll> S(N+1);
    S[0]=0;
    for(int i=1; i<=N; i++){
        ll ai;
        cin >> ai;
        S[i]=(S[i-1]+ai)%K;
    }
    ll ans=0;
    map<ll, ll> cnt;//キーが(i-S[i])%K、値がその個数
    for(int i=0; i<=N; i++){
        if(i>=K) cnt[(i+K-S[i-K])%K]--;//区間の左端を捨てる
        ll tmp=(i+K-S[i])%K;
        ans+=cnt[tmp];
        cnt[tmp]++;//追加
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <stdio.h>
using namespace std;
int s[26];
int b[3];
int main(void){
     int h,w;
     cin>>h>>w;
     for(int i=0;i<h*w;i++){
         char x;
         scanf(" %c",&x);
         s[x-'a']++;
     }
     b[0]=h*w%2;
     b[1]=(h%2)*(w/2)+(w%2)*(h/2);
     b[2]=(h/2)*(w/2);
     
     int l=4;
     for(int j=2;j>=0;j--,l/=2){
     for(int i=0;i<='z'-'a';i++){
         while(s[i]>=l&&b[j]){
             s[i]-=l;
             b[j]--;
         }
     }
     if(b[j]){
         cout<<"No"<<endl;
         return 0;
     }
     }
     cout<<"Yes"<<endl;
}


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

int main(void)
{
	double x,h;
	double sokumen;
	
	while(scanf("%lf%lf",&x,&h))
	{
		if(x==0&&h==0)
		break;
		sokumen = (x*(sqrt(((x/2)*(x/2))+(h*h))))/2;
		printf("%lf\n",(x*x)+4*(sokumen));
	}
	return 0;
}

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

int main(){
  long long a,b,c,k;
  cin >> a >> b >> c >> k;
  long long ans = a;
  if(ans >= k){
    ans=k;
    cout << ans << endl;
    return 0;
  }
  long long x = k-ans;
  x-=b;
  if(x<=0){
    cout << ans << endl;
    return 0;
  }
  else{
    cout << ans - x << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
N = int(input())
N_bit = len(str(N))
ans=0
if N_bit%2==0:
  if N_bit==6:
    ans=90909
  elif N_bit==4:
    ans=909
  elif N_bit==2:
    ans=9
else:
  if N_bit==5:
    ans+=909
    ans+=N-10000+1
  elif N_bit==3:
    ans+=9
    ans+=N-100+1
  elif N_bit==1:
    ans+=N-1+1
print(ans)
    

Measured memory_bytes: 3060