akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

void solve(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    //いつか限界が来る
    if(b>d){
        cout<<"No"<<endl;
        return ;
    }
    //最初から無理やん
    if(a<b){
        cout<<"No"<<endl;
        return ;
    }
    //b>dをふまえると超余裕
    if(b<=c+1){
        cout<<"Yes"<<endl;
        return ;
    }

    //c<x<bかつx=A+gcd(b,d)となるようなxが存在するか
    ll g=gcd(b,d);
    ll x=b+a%g-g;
    if(x>c){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}

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

    int q;cin>>q;
    while(q--) solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
int main() {
	ll f=0;
	
	string N;
	cin >> N;
	rep(i, N.size()) {
		f += ctoi(N[i]);
	}
	if (stoi(N) % f == 0) {

		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

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

#define printl(s) cout << s << endl;
#define print(s) cout << s << endl; return 0;
#define printFix(n,i) cout << fixed << setprecision(i) << n << endl; return 0;
#define yes cout << "Yes" << endl; return 0;
#define no cout << "No" << endl; return 0;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n)+1; ++i)
#define bitrep(i,n) for (int i = 0; i < (1<<(n));i++)
#define isOne(bit,i) (bit & (1 << i))
using ll = long long;
using pii = pair<int, int>;
using si = set<int>;

const ll modSeed = pow(10,9) + 7;
const int INF = 100'000'000;

template <typename T>
vector<T> getValues(ll num){
    vector<T> values(num);
    for(ll i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

template <typename T>
vector<T> getSumVec(vector<T> vec){
    vector<T> values(vec.size()+1,0);
    for(ll i=0;i<values.size()-1;i++){
      values.at(i+1) = values.at(i) + vec.at(i);
    }
    return values;
}

string S;
ll N,cnt,ans;

int main(){
  cin >>N;
  auto inputs = getValues<ll>(N);
  ll height = 0;
  rep(i,N){
      if(i==0){
        height = inputs.at(i);
      }
      if(inputs.at(i)<height){
        ll step = height - inputs.at(i);
        ans +=step;
      }else{
        height = inputs.at(i);
      }
  }
  printl(ans);
}


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

using namespace std;

int main(){
    string s;
    cin>>s;
    
    int a=s.size()-1;
    int b=0;
    for(int i=0;i<a+1;i++){
        if(s[a-i]=='m'&&s[a-i-1]=='a'&&s[a-i-2]=='e'&&s[a-i-3]=='r'&&s[a-i-4]=='d'){
            i+=4;
            b=1;
            continue;
        }else b=0;
        if(s[a-i]=='r'&&s[a-i-1]=='e'&&s[a-i-2]=='m'&&s[a-i-3]=='a'&&s[a-i-4]=='e'&&s[a-i-5]=='r'&&s[a-i-6]=='d'){
            i+=6;
            b=1;
            continue;
        }else b=0;
        if(s[a-i]=='e'&&s[a-i-1]=='s'&&s[a-i-2]=='a'&&s[a-i-3]=='r'&&s[a-i-4]=='e'){
            i+=4;
            b=1;
            continue;
        }else b=0;
        if(s[a-i]=='r'&&s[a-i-1]=='e'&&s[a-i-2]=='s'&&s[a-i-3]=='a'&&s[a-i-4]=='r'&&s[a-i-5]=='e'){
            i+=5;
            b=1;
            continue;
        }else b=0;
        
        if(b==0){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 1000005;
bool is_prime[N+5];
int d[N+5]; //d[i]=iの最小の素因数
int mp[N+5];
int main(){
  for(int i = 0; i < N; i++) is_prime[i]=true; //エラトステネス
  for(int i = 2; i < N; i++){
    if(is_prime[i]) d[i] = i;
    for(int j = i + i; j < N; j += i){
      is_prime[j] = false;
      if(is_prime[i] && d[j]==0) d[j] = i;
    }
  }

  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)cin >> a[i];
  vector<int> p;
  for(int i = 0; i < n; i++){
    while(a[i]>1){
      int m = d[a[i]];
      a[i] /= m;
      if(a[i]%m != 0) p.push_back(m);
    }
  }
for(auto x : p) mp[x]++;
int ans = 0;
for(int i = 1; i < N+5; i++){
  if(mp[i] >= 2 && mp[i] <= n-1) ans = 1;
  if(mp[i] == n){
    ans = 2;
    break;
  }
}
if(ans == 0)cout << "pairwise coprime" << endl;
if(ans == 1)cout << "setwise coprime" << endl;
if(ans == 2)cout << "not coprime" << endl;
return 0;
}  


Measured memory_bytes: 44812
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int N;cin>>N;
    ll ans=0;
    for(int i=1;i<=N;i++){
        if(i%3==0 || i%5==0){
            continue;
        }else{
            ans+=i;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3600
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		long A = Long.parseLong(sc.get());
		long B = Long.parseLong(sc.get());
		long C = Long.parseLong(sc.get());
		long[] L = new long[N];
		Arrays.setAll(L, $ -> Long.parseLong(sc.get()));

		System.out.println(dfs(A, B, C, L, 0, false, false, false));
	}

	long dfs(long a, long b, long c, long[] L, int index, boolean aflag, boolean bflag, boolean cflag) {
		long minCost = aflag && bflag && cflag ? Math.abs(a) + Math.abs(b) + Math.abs(c) : Integer.MAX_VALUE;
		if (index == L.length) {
			return minCost;
		}
		minCost = Math.min(minCost, dfs(a - L[index], b, c, L, index + 1, true, bflag, cflag) + (aflag ? 10 : 0));
		minCost = Math.min(minCost, dfs(a, b - L[index], c, L, index + 1, aflag, true, cflag) + (bflag ? 10 : 0));
		minCost = Math.min(minCost, dfs(a, b, c - L[index], L, index + 1, aflag, bflag, true) + (cflag ? 10 : 0));
		minCost = Math.min(minCost, dfs(a, b, c, L, index + 1, aflag, bflag, cflag));
		return minCost;
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

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

using namespace std;

int vacation(const vector<vector<int>> &mat, int N)
{
    int fa_prev = mat[0][0],fb_prev=mat[0][1],fc_prev=mat[0][2];
    int fa_cur,fb_cur,fc_cur;
    for (size_t i = 1; i < N; ++i)
    {
        fa_cur = mat[i][0] + max(fb_prev, fc_prev);
        fb_cur = mat[i][1] + max(fa_prev, fc_prev);
        fc_cur = mat[i][2] + max(fa_prev, fb_prev);

        fa_prev = fa_cur;
        fb_prev = fb_cur;
        fc_prev = fc_cur;
    }

    return max(fa_prev, max(fb_prev, fc_prev));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N;
    cin >> N;
    vector<vector<int>> mat;
    int e;
    for (size_t i = 0; i < N; ++i)
    {
        vector<int> row;
        for (size_t j = 0; j < 3; ++j)
        {
            cin >> e;
            row.push_back(e);
        }
        mat.push_back(row);
    }

    cout << vacation(mat, N) << "\n";
}


Measured memory_bytes: 6708
import math
while True:
    n = int(input())
    if n == 0:
        break
    else:
        s = list(map(int, input().split()))
        m = sum(s)/n
        a = 0
        for i in range(n):
            a += (s[i]-m)**2
        b = a/n
        print(math.sqrt(b))


Measured memory_bytes: 5696
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int N;
    long long K;
    cin>>N>>K;
    vector<int> A(N);
    for (int &a: A)
        cin>>a, a--;

    vector<long long> T(N, -1);
    int p = 0;
    for (long long k=0; k<K; k++)
    {
        if (T[p]!=-1)
        {
            long long d = k-T[p];
            k += (K-k)/d*d;
            if (k>=K)
                break;
        }

        if (T[p]==-1)
            T[p] = k;
        p = A[p];
    }
    cout<<p+1<<endl;
}


Measured memory_bytes: 5260
n = int(input())

d = {}
for _ in range(n):
  s = input()
  d[s] = d.get(s, 0) + 1

m = max(d.values())
ans = []
for s in d:
  if d[s] == m:
    ans.append(s)
    
ans.sort()
for a in ans:
  print(a)

Measured memory_bytes: 32096
X = input()
X1 = X[::-1]
y1 = (len(X)-1)/2
X2 = X[:int(y1)]
X21 = X2[::-1]
y2 = (len(X)+3)/2
X3 = X[int(y2)-1:]
X31 = X3[::-1]
if X==X1 and X2==X21 and X3==X31:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
//#define P pair<ll, ll>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;


int main() {
  int N; cin >> N;
  vector<pair<int, int>> red(N);
  rep(i, 0, N) cin >> red[i].first >> red[i].second;
  vector<pair<int, int>> blue(N);
  rep(i, 0, N) cin >> blue[i].first >> blue[i].second;

  sort(blue.begin(), blue.end(), [](auto a, auto b) {
    return a.first < b.first;
  });

  int ans = 0;
  rep(i, 0, N){
    pair<int, int> maxiy = {-1, -1};
    rep(k, 0, N){
      if(blue[i].first > red[k].first && blue[i].second > red[k].second && maxiy.second < red[k].second) maxiy.first = k, maxiy.second = red[k].second;
    }
    if(maxiy.second != -1) red[maxiy.first].second = 10000, ++ans;
  }

  cout << ans << endl;

}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
	
typedef long long ll;
typedef unsigned long long ull;
typedef long double db;
	
#define MOD 1000000007
#define mi 18446744073709551615
#define ff first
#define ss second
#define pb push_back
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T=1;
	// cin>>T;
	while(T--)
	{
		int n;
		cin>>n;
		int a[n];
		ll ans=0;
		for(int i=0;i<n;i++)
			cin>>a[i];
		for(int i=1;i<n;i++)
		{
			if(a[i]<a[i-1])
			{
				ans=ans+a[i-1]-a[i];
				a[i]=a[i-1];
			}
		}
		cout<<ans;
	}  
	return 0;
}

Measured memory_bytes: 4368
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll INF = 0x1fffffffffffffff;
template<class T, class U> bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; }

ll n, m, x, cost, ans = INF;
vector<ll> c, understand;
vector<vector<ll>> a;
void dfs(ll i){
    // 判定
    if(i == n){
        if(all_of(understand.begin(), understand.end(), [&](ll a){ return a >= x; })) chmin(ans, cost);
        return;
    }
    // 買わない
    dfs(i + 1);
    // 買う
    cost += c[i];
    for(int j = 0; j < m; j++) understand[j] += a[i][j];
    dfs(i + 1);
    cost -= c[i];
    for(int j = 0; j < m; j++) understand[j] -= a[i][j];
}
int main(){
    cin >> n >> m >> x;
    c.resize(n);
    a.assign(n, vector<ll>(m));
    for(int i = 0; i < n; i++){
        cin >> c[i];
        for(auto& j : a[i]) cin >> j;
    }
    understand.resize(m);
    dfs(0);
    if(ans == INF) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll a,b;
  cin >> a >> b;
  REP(i,1,1111) {
    ll x=i*0.08,y=i*0.1;
    if(x==a&&y==b) {
      pr(i);
      return;
    }
  }
  pr(-1);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;
typedef long long  ll;

template <typename T>
using ordered_set = tree<T, null_type, less<T> , rb_tree_tag, tree_order_statistics_node_update>;

const double EPS = 1e-9;
const double pi = acos(-1.0);

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


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

    vector<int> v(n + 1 , 0);
    for(int i = 1 ; i <= n ; ++i){
        if(i == k)v[i] = 1;
    }

    for(int j = n , cnt = 1 ; j > 0 ; --j , cnt++){
        if(v[j] == 1)cout << cnt;
    }
}


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

int main(void){
	
	char A[27] = "abcdefghijklmnopqrstuvwxyz";
	char w[100];
	int count = 0, NO = 0;
	int len;

	scanf("%s", w);

	len = strlen(w);

	for (int i = 0; i < 27; i++) {
		for (int j = 0; j <len; j++) {
			if (A[i] == w[j])count++;
		}
		if (count % 2 != 0)NO++;
		else count = 0;
	}

	if (NO != 0)printf("No\n");
	else printf("Yes\n");

	return 0;

}



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

class Coord{
public:
	const double x, y;
	
	Coord(double x, double y):x(x), y(y){}
	Coord(const Coord& c):x(c.x),y(c.y){}
	
	Coord operator-(const Coord& rhs) const{
		/*Coord temp;
		temp.x = this->x - rhs.x;
		temp.y = this->y - rhs.y;*/
		Coord temp(this->x - rhs.x, this->y - rhs.y);
		return temp;
	}
	/*
	Coord& operator=(const Coord& rhs){
		this->x = rhs.x;
		this->y = rhs.y;
		return *this;
	}
	*/
};

typedef Coord Vector2D;

class Square{
	std::vector<Coord*> points;

public:
	Square(double xa, double ya, double xb, double yb, double xc, double yc, double xd, double yd){
		points.push_back(new Coord(xa, ya));
		points.push_back(new Coord(xb, yb));
		points.push_back(new Coord(xc, yc));
		points.push_back(new Coord(xd, yd));
	}
	bool isInTriangle(Coord* A, Coord* B, Coord* C, Coord* P){
	// 点と三角形の当たり判定( 内外判定 )
	// http://www.sousakuba.com/Programming/gs_hittest_point_triangle.html
	
		Vector2D AB(*B - *A);
		Vector2D BP(*P - *B);
		
		Vector2D BC(*C - *B);
		Vector2D CP(*P - *C);
		
		Vector2D CA(*A - *C);
		Vector2D AP(*P - *A);
		
		//外積    Z成分だけ計算すればよいです
		double c1 = AB.x * BP.y - AB.y * BP.x;
		double c2 = BC.x * CP.y - BC.y * CP.x;
		double c3 = CA.x * AP.y - CA.y * AP.x;
		
		if( ( c1 > 0 && c2 > 0 && c3 > 0 ) || ( c1 < 0 && c2 < 0 && c3 < 0 ) ) {
		    //三角形の内側に点がある
		    return true;
		}
		
		//三角形の外側に点がある
		return false;
	}
	bool isConvex(void){
		for(int i=0; i<points.size(); i++){
			std::vector<Coord*> triangle;
			for(int j=0; j<points.size(); j++){
				if(j != i){
					triangle.push_back(points[j]);
				}
			}
			if( isInTriangle(triangle[0], triangle[1], triangle[2], points[i]) ){
				return true;
			}
		}
		return false;
	}
};

int main(void){
	double xa, ya, xb, yb, xc, yc, xd, yd;
	char c;//cammma
	while (std::cin >> xa >> c >> ya >> c >> xb >> c >> yb >> c >> xc >> c >> yc >> c >> xd >> c >> yd) {
		Square* s = new Square(xa, ya, xb, yb, xc, yc, xd, yd);
		if( s->isConvex() ){
			std::cout << "NO" << std::endl;//凹みがあれば NO
		}else{
			std::cout << "YES" << std::endl;//凹みがなければ YES
		}
	}
	
	return 0;
}



Measured memory_bytes: 3160
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 4
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	h := getNextInt(scanner)
	w := getNextInt(scanner)
	ss := make([]string, h)
	for i := 0; i < h; i++ {
		ss[i] = getNextString(scanner)
	}
	g := makeInts(h, w)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			g[i][j] = math.MaxInt32
		}
	}
	g[0][0] = 0
	if ss[0][0] == '#' {
		g[0][0]++
	}
	dy := [2]int{0, 1}
	dx := [2]int{1, 0}
	q := make([][2]int, 0)
	q = append(q, [2]int{
		0,
		0,
	})
	for len(q) > 0 {
		y := q[0][0]
		x := q[0][1]
		q = q[1:]
		for i := 0; i < 2; i++ {
			yy := y + dy[i]
			xx := x + dx[i]
			if yy < 0 || yy >= h {
				continue
			}
			if xx < 0 || xx >= w {
				continue
			}
			d := g[y][x]
			if ss[y][x] != ss[yy][xx] && ss[yy][xx] == '#' {
				d++
			}
			if g[yy][xx] > d {
				g[yy][xx] = d
				q = append(q, [2]int{
					yy,
					xx,
				})
			}
		}
	}
	fmt.Fprintln(writer, g[h-1][w-1])
}
func makeInts(h, w int) [][]int {
	index := make([][]int, h, h)
	data := make([]int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}


Measured memory_bytes: 1280
#include <stdio.h>

using namespace std;

int main(){
	int n,x;
	scanf("%d",&n);

	for(int i = 1; i<= n; i++)
	{
		if(i%3 == 0){
			printf(" %d",i);
		}else{
			x = i;
			do{
				if(x%10 == 3){
					printf(" %d",i);
					break;
				}
				x /=10;
			}while(x);
		}
	}
	printf("\n");
}


Measured memory_bytes: 2680
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    #print('i =', i)
    ans += b[a[i]-1]
    #print('b[a[i]-1] = ', b[a[i]-1])
    if i > 0 and a[i] == a[i-1] + 1:
        ans += c[a[i]-2]
        #print('c[a[i]-2]', c[a[i]-2])
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n;
    cin >> n;
    int a[n];
    rep (i, n) cin >> a[i];
    int mn = a[0], ans = -inf;
    rep (i, n) {
        if (i == 0) continue;
        ans = max (ans, a[i] - mn);
        if (mn > a[i]) {
            mn = a[i];
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3872
#include<iostream>
#include<vector>
#include<cassert>
using namespace std;
#define rep(i, n) for ( int i = 0; i < (int)n; i++ )
static const int N_MAX = 100000;
static const int NINF = -1000000000;
int N, P[N_MAX], ans;
int dp[N_MAX][3]; // 0:1p, 1:0p, 2:2p
vector<int> T[N_MAX];
bool V[N_MAX];

void dfs(int u){
  V[u] = true;
  vector<int> C;
  rep (i, T[u].size()){
    int v = T[u][i];
    if ( !V[v] ) {
      C.push_back(v);
      dfs(v);
    }
  }
  // 子Cが全て訪問・決定済み

  if ( C.size() == 0 ){
    rep(i, 3) dp[u][i] = P[u]; // 葉の場合はノードの得点
  } else if ( C.size() == 1 ){
    int v = C[0];
    dp[u][0] = max(dp[v][0] - 1 + P[u], P[u]); //
    dp[u][1] = max(dp[v][1] - 2 + P[u], P[u]); //
    dp[u][2] = max(dp[v][2] - 2 + P[u], P[u]); //


    //    dp[u][0] = max(dp[u][0], dp[v][1] - 2 + P[u]); // not need
    //    dp[u][2] = max(dp[u][2], dp[v][1] - 2 + P[u]); // not need
    //    dp[u][2] = max(dp[u][2], dp[v][0] - 1 + P[u]); // not need
  } else {
    int a1, a2, c1; // candidate child
    a1 = a2 = c1 = C[0];
    rep (i, C.size()){
      int v = C[i];
      if ( dp[a1][0] - 1 - max(dp[a1][1] -  2, 0) <= dp[v][0] - 1 - max(dp[v][1] - 2, 0) ) a1 = v;
      if ( dp[c1][2] - 2 - max(dp[c1][1] -  2, 0) <= dp[v][2] - 2 - max(dp[v][1] - 2, 0) ) c1 = v;
    }
    rep(i, C.size()) if ( C[i] != a1 ) { a2 = C[i]; break; }
    rep(i, C.size()){
      int v = C[i];
      if ( v == a1 ) continue;
      if ( dp[a2][0] - 1 - max(dp[a2][1] -  2, 0) <= dp[v][0] - 1 - max(dp[v][1]  - 2, 0) ) a2 = v;
    }
    int sumA1 = 0; // bbbbab
    int sumB1 = 0; // bbbbbb
    int sumC1 = 0; // bbbcbb
    int sumC2 = 0; // abbabb
    for ( int i = 0; i < C.size(); i++ ){
      int v = C[i];
      sumA1 += (v == a1) ? (dp[v][0] - 1) : max(dp[v][1] - 2, 0);
      sumB1 += max(dp[v][1] - 2, 0);
      sumC1 += (v == c1) ? (dp[v][2] - 2) : max(dp[v][1] - 2, 0);
      sumC2 += (v == a1 || v == a2) ? (dp[v][0] - 1) : max(dp[v][1] - 2, 0);
    }
    //    int sumA = max(sumA1, sumB1);
    int sumA = sumA1;
    //int sumC = max(sumA, max(sumC1, sumC2));
    int sumC = max(sumC1, sumC2);
    int sumB = sumB1;
    dp[u][0] = max(P[u], sumA + P[u]);
    dp[u][1] = max(P[u], sumB + P[u]);
    dp[u][2] = max(P[u], sumC + P[u]);
  }
  rep(i, 3) ans = max(ans, dp[u][i]);
}

int solve(int s){
  rep(i, N) rep(j, 3) dp[i][j] = NINF;
  rep(i, N) V[i] = false;
  ans = NINF;
  dfs(s);
  return ans;
}

int main(){
  cin >> N;
  for ( int i = 0; i < N; i++ ) cin >> P[i];
  for ( int i = 0; i < N - 1; i++ ) {
    int s, t; cin >> s >> t;
    s--; t--;
    T[s].push_back(t);
    T[t].push_back(s);
  }

  int a = solve(0);
  //  for ( int i = 0; i < N; i++ ) assert(a == solve(i)); // safety check
  cout << a << endl;

  return 0;
}


Measured memory_bytes: 25920
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  vector<vector<int>> dp(1 << n, vector<int>(n, INF));
  for (int i = 0; i < n; i++) dp[1 << i][i] = i;
  for (int mask = 0; mask < (1 << n); mask++) for (int last = 0; last < n; last++) {
    if (dp[mask][last] == INF) continue;
    int last_pos = __builtin_popcount(mask) - 1;
    int last_val = ((last_pos & 1) ^ (last & 1) ? b[last] : a[last]);
    int inv = 0;
    for (int add = 0; add < n; add++) {
      if (mask & (1 << add)) continue;
      int add_val = (((last_pos + 1) & 1) ^ (add & 1) ? b[add] : a[add]);
      if (last_val <= add_val) dp[mask | (1 << add)][add] = min(dp[mask | (1 << add)][add], dp[mask][last] + inv);
      inv++;
    }
  }
  int ans = INF;
  for (int i = 0; i < n; i++) ans = min(ans, dp[(1 << n) - 1][i]);
  cout << (ans == INF ? -1 : ans) << '\n';
  return 0;
}

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

int main(){
    ll n;
    cin>> n;
     
    char alphabet[26];
    for (char i = 'a'; i <= 'z'; i ++) {
        alphabet[i - 'a'] = i;
    }
 
    string res;
     
    while (1)
 
    {
        n -= 1;
        res = alphabet[n % 26] + res;
        n /= 26;
        if (n == 0)
            break;
    }
     cout << res;
     return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    priority_queue<double, vector<double>, greater<double>> q;
    REP(i, N){
        double a;
        cin >> a;
        q.push(a);
    }
    while(q.size() != 1){
        double a = q.top();q.pop();
        double b = q.top();q.pop();
        q.push((a+b)/2);
    }
    pr(q.top());
}

Measured memory_bytes: 256
N=10**6
p=10**9+7
f,finv,inv=[0]*(N*5),[0]*(N*5),[0]*(N*5)

def nCr_init(L,p):
    for i in range(L+1):
        if i<=1:
            f[i],finv[i],inv[i]=1,1,1
        else:
            f[i]=(f[i-1]*i)%p
            inv[i]=(p-inv[p%i]*(p//i))%p
            finv[i]=(finv[i-1]*inv[i])%p

def nPr(n,r,p):
    if 0<=r<=n and 0<=n:
        return (f[n]*finv[n-r])%p
    else:
        return 0
    
nCr_init(N,p)

N,M,K=map(int,input().split())

print((nPr(N*M,K,p)*((M+N)*inv[6]*finv[K-2])%p)%p)

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

int main(){
  char A,B;
  cin >>A>>B;
  if(A>B){
    cout<<">"<<endl;
    return 0;
  }
  if(A<B){
    cout<<"<"<<endl;
  return 0;
  }
  cout<<"="<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i=0;i<n;++i) list.add(sc.nextInt());

        for (int i=0;i<n;++i)
        {
            int pi = list.get(i);
            if (i == 0)
            {
                ++count;
            }
            else if (pi <= min)
            {
                ++count;
            }

            if (min > pi) min = pi;

            //System.out.println("pi="+pi + " min = "+min);
        }
        System.out.println(count);
        sc.close();
    }
}

Measured memory_bytes: 82972
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int[]a;
		a=new int[100];
		Scanner sc=new java.util.Scanner(System.in);
		int n=sc.nextInt();
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		int max,min;
		max=min=a[0];
		for(int i=1;i<n;i++) {
			max=Math.max(max,a[i]);
			min=Math.min(min,a[i]);
		}
		System.out.println(max-min);
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    map<int, int> m;
    for (int i = 0; i < 28; ++i) {
        int k;
        cin >> k;
        m[k]++;
    }
    for (int i = 1; i <= 30; ++i) {
        if(!m[i]) cout << i << "\n";
    }
    return 0;
}



Measured memory_bytes: 3120
#include<stdio.h>

int main(){
  int a, b, c, t;
  scanf("%d%d%d", &a, &b, &c);
  if(b > a){
    t = a;
    a = b;
    b = t;
  }
  if(c > a){
    t = a;
    a = c;
    c = t;
  }

  if(a == b + c){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
const int inf = 1e9;
int dx[4] = {0, -1, 0, 1};
int dy[4] = {-1, 0, 1, 0};

int h,w;
int y,x, d=0,ans=0;
char field[50][50];
bool used[50][50][4][1001];
string str;
bool check_condition(int p){
	bool t = true;
	bool f = false;
	if(str[p]=='~'){
		swap(t, f);
		p++;
	}
	switch(str[p]){
		case 'N': return d==0? t: f;
		case 'W': return d==1? t: f;
		case 'S': return d==2? t: f;
		case 'E': return d==3? t: f;
		case 'C': return (field[y+dy[d]][x+dx[d]] == '#')? t: f;
		default : return t;
	}
}
int getnext(int p){
	if(str[p]=='~') return p+2;
	if(str[p]!='{' && str[p]!='[') return p+1;
	int depth = 1;
	while(depth > 0){
		p++;
		if(str[p]=='{' || str[p]=='[') depth++;
		if(str[p]=='}' || str[p]==']') depth--;
	}
	return p+1;
}
int program_if(int p);
int program_while(int p);
int execute(int p){
	while(1){
		if(used[y][x][d][p]) return -1;
		used[y][x][d][p] = true;
		if(field[y][x] == 'g') return 1;
		if(p >= (int)str.length() || str[p]=='}' || str[p]==']') break;
		if(str[p]=='['){
			int res = program_if(p);
			if(res != 0) return res;
		}else if(str[p] == '{'){
			int res = program_while(p);
			if(res != 0) return res;
		}else{
			if(str[p]=='^' && field[y+dy[d]][x+dx[d]]!='#'){
				y+=dy[d]; x+=dx[d];
			}
			if(str[p]=='v' && field[y+dy[(d+2)%4]][x+dx[(d+2)%4]]!='#'){
				y+=dy[(d+2)%4]; x+=dx[(d+2)%4];
			}
			if(str[p]=='<') d = (d+1)%4;
			if(str[p]=='>') d = (d+3)%4;
			ans++;
		}
		p = getnext(p);
	}
	return 0;
}

int program_if(int p){
	if(check_condition(p+1)){
		return execute(getnext(p+1));
	}
	return 0;
}
int program_while(int p){
	while(check_condition(p+1)){
		int res = execute(getnext(p+1));
		if(res != 0) return res;
	}
	return 0;
}


int main(){
	cin >> h >> w;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cin >> field[i][j];
			if(field[i][j] == 's'){
				y = i; x = j;
			}
		}
	}
	cin >> str;
	memset(used, 0, sizeof(used));
	if(execute(0) == 1){
		cout << ans << endl;
	}else{
		cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 12984
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;


int main()
{
	FAST;
	char in[51][51];
	char out[51][51];

	int r,c;
	cin >> r >> c;
	for(int i=0 ; i<r ; i++)
		cin >> in[i];

	for(int i=0 ; i<r ; i++)
	{
		for(int j=0 ; j<c ; j++)
		{
			if(in[i][j] == '#')
				cout << "#";
			else
			{
			    int count = 0;
			    if(i+1 < r && j+1 < c)
			    {
			        if(in[i+1][j+1] == '#') count++;
			    }
			    if(i-1 >= 0 &&& j-1 >= 0)
			    {
			        if(in[i-1][j-1] == '#') count++;
			    }
			    if(i+1 < r && j < c)
			    {
			        if(in[i+1][j] == '#')   count++;
			    }
			    if(i < r && j+1 < c)
			    {
			        if(in[i][j+1] == '#')   count++;
			    }
			    if(i-1 >= 0 && j < c)
			    {
			        if(in[i-1][j] == '#')   count++;
			    }
			    if(i < r && j-1 >=0)
			    {
			        if(in[i][j-1] == '#')   count++;
			    }
			    if(i+1 < r && j-1 >= 0)
			    {
			        if(in[i+1][j-1] == '#') count++;
			    }
			    if(i-1>=0 && j+1 < c)
			    {
			        if(in[i-1][j+1] == '#') count++;
			    }
			    cout << count;
			}
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
// B - Kleene Inversion
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define MOD 1000000007

int main(){
	ll N,K; cin>>N>>K;
	ll a = 0, b = 0;

	vector<ll> A(N);
	for(int i=0; i<N; i++){
		cin>>A[i];
		for(int j=0; j<i; j++) a += A[i]<A[j];
	}

	for(int i=0; i<N; i++)
		for(int j=0; j<N; j++) b += A[i]>A[j];

	ll kC2 = K*(K-1)/2 % MOD;
	a = a * K % MOD;
	b = b * kC2 % MOD;
	cout<< (a+b) % MOD << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define MN 201000
#define mod 998244353

int n; 
int s[MN], mi[MN];
int g[MN], f[MN];
int lst[MN];

void check(int x)
{
	for(int i = 0; i < n; i++)
	{
		if(s[i] == 1)
		{
			if(i < x || lst[i % x] == 1)
			{
				if(i < x) g[x] = (g[x] + mi[x - i - 1]) % mod;
				else g[x] = (g[x] + 1) % mod;
			}
		}
		if(i == n - 1)
		{
			if(i < x || s[i] != lst[i % x]) g[x] = (g[x] + 1) % mod;
			continue;
		}
		if(i >= x)
		{
			if(s[i] == lst[i % x]) return;
		}
		lst[i % x] = s[i];
	}
}

int main()
{
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%1d", &s[i]);
	mi[0] = 1; for(int i = 1; i <= n; i++) mi[i] = mi[i - 1] * 2 % mod;
	for(int i = 1; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			if(n / i % 2 == 1) check(i);
			if(i != n / i && (i & 1)) check(n / i); 
		}
	}
	for(int i = 1; i <= n; i++)
	{
		if(n % i == 0 && n / i % 2 == 1)
		{
			f[i] = g[i];
			for(int j = 1; j * j <= i; j++)
			{
				if(i % j == 0)
				{
					if(j != i) f[i] = (f[i] - f[j] + mod) % mod;
					if(i / j != j && i / j != i) f[i] = (f[i] - f[i / j] + mod) % mod;
				}
			}
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		ans = (ans + 1ll * i * 2 * f[i]) % mod;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string x; cin >> x;
  ll ans = 0;
  ll stock = 0;
  for (ll i = 0; i < (ll)x.size(); i++) {
    if (x[i] == 'S') {
      stock++;
    }else {
      if (stock > 0) {
	stock--;
	ans++;
      }
    }
  }
  cout << x.size() - 2 * ans << endl;

  return 0;
}



Measured memory_bytes: 3752
N = int(input())
P = list(map(int, input().split()))

sortedP = sorted(P)
idx = []
for i in range(N):
    if P[i] != sortedP[i]:
        idx.append(i)
if len(idx) == 0:
    print("YES")
elif len(idx) == 2:
    P[idx[0]], P[idx[1]] = P[idx[1]], P[idx[0]]
    if P == sortedP:
        print("YES")
    else:
        print("NO")
else:
    print("NO")


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

int main(){
  int N;
  cin >> N;
  vector<int> data1(N);
  for(int i=0; i<N; i++){
    cin >> data1[i];
  }
  vector<int> data2(N);
  for(int i=0; i<N; i++){
    data2[i]=data1[i];
  }
  sort(data2.begin(),data2.end());
  
  int mi = data2[(N-1)/2];
  int ma = data2[N/2];
  
  for(int i=0; i<N; i++){
    if(data1[i]<=mi){
      cout << ma << endl;
    }
    else cout << mi << endl;
  }
}

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

char* to_code(char c) {
	switch(c) {
		case ' ': return "101";
		case '\'': return "000000";
		case ',': return "000011";
		case '-': return "10010001";
		case '.': return "010001";
		case '?': return "000001";
		case 'A': return "100101";
		case 'B': return "10011010";
		case 'C': return "0101";
		case 'D': return "0001";
		case 'E': return "110";
		case 'F': return "01001";
		case 'G': return "10011011";
		case 'H': return "010000";
		case 'I': return "0111";
		case 'J': return "10011000";
		case 'K': return "0110";
		case 'L': return "00100";
		case 'M': return "10011001";
		case 'N': return "10011110";
		case 'O': return "00101";
		case 'P': return "111";
		case 'Q': return "10011111";
		case 'R': return "1000";
		case 'S': return "00110";
		case 'T': return "00111";
		case 'U': return "10011100";
		case 'V': return "10011101";
		case 'W': return "000010";
		case 'X': return "10010010";
		case 'Y': return "10010011";
		case 'Z': return "10010000";
	}
	return "";
}

char to_char(char* s) {
	int i, n;
	for(i = 0, n = 0; i < 5; i++) {
		n <<= 1;
		n += s[i] - '0';
	}

	if(n < 26)
		return 'A' + n;

	switch(n) {
		case 26: return ' ';
		case 27: return '.';
		case 28: return ',';
		case 29: return '-';
		case 30: return '\'';
		case 31: return '?';
	}
	return '\0';
}

int main() {
	int c;
	char in[32];
	int head = 0, tail = 0;
	int i;

	while(1) {
		head = tail = 0;
		while((c = getchar()) != '\n') {
			char* code;
			int len;

			if(c == EOF)
				return 0;

			code = to_code(c);
			len = strlen(code);

			for(i = 0; i < len; i++) {
				in[tail] = code[i];
				tail = (tail + 1) % 32;
			}

			while(((tail < head ? 32 : 0) + tail - head) / 5) {
				char tmp[8];
				for(i = 0; i < 5; i++) {
					tmp[i] = in[head];
					head = (head + 1) % 32;
				}
				tmp[5] = '\0';

				putchar(to_char(tmp));
			}
		}

		while(((tail < head ? 32 : 0) + tail - head) % 5) {
			in[tail] = '0';
			tail = (tail + 1) % 32;
		}

		while(((tail < head ? 32 : 0) + tail - head) / 5) {
			char tmp[8];
			for(i = 0; i < 5; i++) {
				tmp[i] = in[head];
				head = (head + 1) % 32;
			}
			tmp[5] = '\0';

			putchar(to_char(tmp));
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 524
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
			
		if (A >= 1 && A <= 9 && B >= 1 && B <= 9) {
			System.out.println(A * B);
		} else {
			System.out.println(-1);
		}
		
	}

}






Measured memory_bytes: 21844
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;

int main(){
  long long a, b, x; cin >> a >> b >> x;
  if(a != 0) cout << b / x - (a - 1) / x << endl;
  else cout << b / x + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) (v).begin(), (v).end()
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)


signed main()
{
    int n;
    cin >> n;
    vector<ll> v(n), u(n, 0);
    rep(i, 0, n)
    {
        cin >> v[i];
        u[i] = v[i];
    }
    sort(all(u));

    ll ind = 0, mx = 0;
    rep(i, 0, n)
    {
        if (v[i] <= mx)
        {
            cout << 0 << endl;
        }
        else
        {
            ll sum=0;
            while (ind<n && u[ind] < v[i])
            {
                sum+=u[ind]-mx;
                ind++;
            }
            sum+=(n-ind)*(v[i]-mx);
            cout<<sum<<endl;
            mx=v[i];
        }
    }
}

Measured memory_bytes: 2688
n = int(input())
a = [list(map(int,input().split())) for _ in range(2)]
dp = [[1000]*(2**n) for _ in range(51)]
dp[0][0] = 0
for S in range(2**n):
  j = bin(S).count("1")
  cnt = 0
  for i in range(n):
    if not (S & 1<<i):
      k = a[(i+j)%2][i]
      for l in range(k+1):
        dp[k][S|1<<i] = min(dp[k][S|1<<i],dp[l][S]+cnt)
    if not (S&1<<i):
      cnt += 1
ans = min(dp[i][-1] for i in range(51))
if ans == 1000:
  print(-1)
else:
  print(ans)

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

int main() {
    int n;
    while (cin >> n, n) {
        int m; string s;
        cin >> m >> s;

        int c = 0, res = 0;
        for (int i=0; i<m; ++i) {
            if (s[i] == 'I') {
                if (i == 0 || s[i-1] != 'O') {
                    c = 1;
                } else {
                    c ++;
                    if (n < c) res ++;
                }
            } else {
                if (i == 0 || s[i-1] != 'I') {
                    c = 0;
                }
            }
        }
        cout << res << endl;
    }
    return 0;
}

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

#define ll long long
#define rep(i, l, r) for (int i = l; i <= r; ++ i)

using namespace std;

inline int read()
{
	int cnt = 0; bool opt = false; char ch = getchar();
	
	for (; ! isdigit(ch); ch = getchar())
		if (ch == '-') opt = true;
	for (; isdigit(ch); ch = getchar())
		cnt = (cnt << 3) + (cnt << 1) + (ch ^ 48);
		
	return opt ? -cnt : cnt;
}

int main()
{
	int n, l, r;
	
	cin >> n >> l >> r;
	
	int p = r / n;
	
	if (p * n >= l && p * n <= r)
		cout << "OK";
	else cout << "NG";
}

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

int main() {
    int n,k;
    cin >> n >> k;
    
    vector<int> a(n);
    rep(i,n) {
    cin >> a.at(i);
    }
    
    sort(a.begin(),a.end());
    
    int sum = 0;
    rep(i,k) {
    sum += a.at(i);
    }
    
    cout << sum;
    
    
    
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int n,m,a[N],c;
vector<int>e[N];
void dfs(int u)
{
	a[u]=1;
	for(auto v:e[u])
		if(!a[v])
			dfs(v);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	for(int i=1;i<=n;i++)
	{
		if(!a[i])
		{
			c++;
			dfs(i);
		}
	}
	printf("%d\n",c-1);
	return 0;
}


Measured memory_bytes: 10128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, S, answer = 0;
  cin >> K >> S;
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      answer += (S-X-Y >= 0 && S-X-Y <= K);
    }
  }
  cout << answer;
}

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

using namespace std;

//#define endl '\n'
#define all(v) (v).begin(),v.end()
#define rall(v) (v).rbegin(),v.rend()
#define sz(v) (int)(v).size()
#define oo 1e15

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<string> vs;

int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#ifdef LOCAL
  freopen("test.in", "rt", stdin);
//  freopen("o.txt", "wt", stdout);
#endif
  int n, k;
  cin >> n >> k;
  vi v(n);
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  for (int i = k; i < n; ++i) {
    cout << ((v[i] > v[i - k]) ? "Yes" : "No") << endl;
  }
  return 0;
}


Measured memory_bytes: 3988
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> arr[0] >> arr[1] >> arr[2];
    sort(arr, arr + 3);
    cout << arr[0] + arr[1] << "\n";
    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3552
#include <iostream>
#include <algorithm>
#include <iterator>

#include <vector>
#include <queue>
#include <unordered_map>

using namespace std;

int main(){
    string S, T;
    cin >> S;
    cin >> T;
    int answer = 0;
    for(int i=0; i<3; i++)
    {
        if(S[i]==T[i])
            answer++;
    }

    cout<<answer<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque
n, m = map(int, input().split())
li = [[] for _ in range(n)]
check = [-1] * (n)
check[0] = 0
que = deque([1])
memo = defaultdict(int)
for i in range(m):
    a, b = map(int, input().split())
    li[a-1].append(b)
    li[b-1].append(a)
while que:
    now = que.popleft()
    for l in li[now-1]:
        if check[l-1] != -1: continue
        check[l-1] = now
        que.append(l)

if -1 in check:
    print('No')
else:
    print('Yes')
    print(*check[1:], sep='\n')


Measured memory_bytes: 35464