akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "test"
using namespace std;
const ll N = 500 + 9;
const ll inf = 1e9 + 7;
typedef pair<ll,ll> LL;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll n,a[N*N],i,lab[N][N],j,minn;
bool chk[N][N];
bool check(ll x,ll y){
    return (x <= n&&y <= n&&x >= 1&&y >= 1);
}
ll trans(ll x,ll y){
    return (x - 1)*n + y;
}
void dfs(ll x,ll y){
    ll z = lab[x][y] + chk[x][y];
    for (ll i = 0;i < 4;i++){
        ll u = x + dx[i],v = y + dy[i];
        if (check(u,v)&&lab[u][v] > z){
            lab[u][v] = z;
            dfs(u,v);
        }
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>n;
    for (i = 1;i <= n*n;i++) cin>>a[i];
    for (i = 1;i <= n;i++){
        for (j = 1;j <= n;j++){
            chk[i][j] = true;
            ll x = min(min(abs(i - 1),abs(i - n)),min(abs(j - 1),abs(j - n)));
            lab[i][j] = x;
        }
    }
    ll ans = 0;
    for (i = 1;i <= n*n;i++){
        ll p = a[i];
        ll x = ceil((ld) p/n),y = p - (x - 1)*n;
        chk[x][y] = false;
        ans += lab[x][y];
        dfs(x,y);
    }
    cout<<ans;
}


Measured memory_bytes: 26852
#include <iostream>
#include <cmath>

int main()
{
	int x,y;
	std::cin >> x>>y;
	auto abs_y = std::abs(y), abs_x = std::abs(x);
	int res = 0;
	if(abs_x < abs_y){
		if(x < 0){
			++res;
		}
		res += abs_y - abs_x;
		if(y < 0){
			++res;
		}
	}
	else if(abs_x == abs_y){
		if(x != y){++res;}
	}
	else{
		if(x > 0){
			++res;
		}
		res += abs_x - abs_y;
		if(y > 0){
			++res;
		}
	}
	std::cout << res << std::endl;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b==10 && b+c==12 && c+a==12){
    cout << "YES" << endl;
  }else if(a+b==12 && b+c==10 && c+a==12){
    cout << "YES" << endl;
  }else if(a+b==12 && b+c==12 && c+a==10){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

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

#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

using namespace std;

unsigned long long clp(unsigned long long x) {
    x -= 1;
    x = x | (x >>  1);
    x = x | (x >>  2);
    x = x | (x >>  4);
    x = x | (x >>  8);
    x = x | (x >> 16);
    x = x | (x >> 32);
    return x + 1;
}

template <class T>
class segment_tree {
private:
    const size_t n;
    const std::function<T(const T&, const T&)> f;
    const T UNIT;
    std::vector<T> a;
public:
    segment_tree(size_t size, std::function<T(const T&, const T&)> f, T UNIT) : n(clp(size)), UNIT(UNIT), f(f) {
        a.resize(2 * n - 1, UNIT);
    }

    template <class Iterator>
    segment_tree(Iterator first, Iterator last, std::function<T(const T&, const T&)> f, T UNIT) : n(clp(std::distance(first, last))), f(f), UNIT(UNIT) {
        size_t size = std::distance(first, last);
        a.resize(2 * n - 1, UNIT);
        for (size_t i = n - 1; first != last; ++i) {
            a[i] = *(first++);
        }
        for (int i = n - 2; i >= 0; --i) {
            a[i] = f(a[2 * i + 1], a[2 * i + 2]);
        }
    }

    void update(size_t i, const T &x) {
        i += n - 1;
        a[i] = x;
        while (i) {
            i = (i - 1) / 2;
            a[i] = f(a[2 * i + 1], a[2 * i + 2]);
        }
    }

    T query(size_t query_first, size_t query_last, size_t k = 0, size_t node_first = 0, size_t node_last = 0) const {
        if (k == 0) {
            node_last = n;
        }
        if (node_last <= query_first || query_last <= node_first) {
            return UNIT;
        }
        if (query_first <= node_first && node_last <= query_last) {
            return a[k];
        } else {
            size_t node_mid = (node_first + node_last) / 2;
            T vl = query(query_first, query_last, k * 2 + 1, node_first, node_mid);
            T vr = query(query_first, query_last, k * 2 + 2, node_mid, node_last);
            return f(vl, vr);
        }
    }
};

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

    int N, Q;
    cin >> N >> Q;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    segment_tree<int> st(all(A), [](int x, int y) { return max(x, y); }, -1);
    REP(_, Q) {
        int T;
        cin >> T;
        if (T == 1) {
            int X, V;
            cin >> X >> V;
            --X;
            st.update(X, V);
        } else if (T == 2) {
            int L, R;
            cin >> L >> R;
            --L;
            cout << st.query(L, R) << '\n';
        } else if (T == 3) {
            int X, V;
            cin >> X >> V;
            --X;
            int first = X;
            int last = N + 1;
            while (first < last) {
                int mid = (first + last) / 2;
                if (st.query(X, mid) >= V) {
                    last = mid;
                } else {
                    first = mid + 1;
                }
            }
            --first;
            cout << (first + 1) << '\n'; // 1-based indexing
        }
    }
    cout << flush;

    return 0;
}


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

char prime[1000000];

int main(void)
{
	int n;
	int i;
	int j;
	
	for (i = 2; i < 999999; i++){
		prime[i] = 1;
	}
	
	while (scanf("%d", &n) != EOF){
		int count = 0;
		
		if (n > 1){
			count++;
		}
		for (i = 2; i <= (int)sqrt(n); i++){
			if (prime[i] == 0){
				continue;
			}
			for (j = i * 2; j <= n; j += i){
				prime[j] = 0;
			}
		}
		for (i = 3; i <= n; i++){
			if (prime[i] == 1){
				count++;
			}
		}
		printf("%d\n", count);
	}
	
	return 0;
}

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

int main(){
  int N, K, cnt;
  cin >> N >> K;
  cnt = 0;
  vector<int> vec(N);
  for(int i = 0; i < K; i++){
    int k;
    cin >> k;
    for(int j = 0; j < k; j++){
      int person;
      cin >> person;
      vec.at(person-1)++;
    }
  }
  for(int i = 0; i < N; i++){
    if(vec.at(i) == 0){
      cnt++;
    }
  }
  cout << cnt;
}
    
    





Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

int main(){
    int n,m;
    cin >> n >> m;
    cout << (n)*(n-1)/2 + m*(m-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
# Date [ 2020-09-13 21:00:11 ]
# Problem [ a.py ]
# Author Koki_tkg

import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    x = read_int()
    if x == 0:
        print(1)
    else:
        print(0)

if __name__ == '__main__':
    Main()

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    cin >> N;
    vector<ll> A;
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        ll a; cin >> a;
        A.pb(a);
        sum += a;
    }
    long double avg = (long double)((long double)sum / (long double)N);
    ll num = 0;
    for (int i = 1; i < N; i++) {
        if(abs(avg-A[num]) > abs(avg-A[i])){
            num = i;
        }
    }
    cout << num << endl;
}

Measured memory_bytes: 3580
a, b, c = map(int, input().split())
if a <= b <= c:
    print(a, b, c)
elif a <= c <= b:
    print(a, c, b)
elif b <= a <= c:
    print(b, a, c)
elif b <= c <= a:
    print(b, c, a)
elif c <= a <= b:
    print(c, a, b)
elif c <= b <= a:
    print(c, b, a)

Measured memory_bytes: 6724
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <math.h>


using namespace std;

int main() {
    string str1, str2, str3;
    cin >> str1 >> str2 >> str3;
    cout << str1.at(0) << str2.at(0) << str3.at(0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#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 <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int main()
{
  long double L, a, b, c, ans;
  ans = 0;
  cin >> L;
  a = L / 3;
  b = L / 3;
  c = L / 3;
  ans = a * b * c;
  std::cout << std::fixed;
  cout << setprecision(12) << ans << endl;

  return 0;
}


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

int main() {
	int n, h, m, ans = 0;
	scanf("%d %d", &n, &h);
	for(int i = 0; i < n; i++) {
		scanf("%d", &m);
		ans += (m >= h);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x ;
    cin>>x ;
    cout<<"Christmas";
    if(x <= 24)
        cout<<" Eve";
    if(x <= 23)
        cout<<" Eve";
    if(x <= 22)
        cout<<" Eve";
    cout<<"\n";
    return 0 ;
}


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

int main() {
	int N,S,T,M,s,e,best;
	while(true){
	cin>>N;
	if(N==0){
	break;
	}
	else{
		cin>>S>>T;
		cin>>M;
	int a[1000][1000];
	int b[10000][2];
	for (int k=0;k<N;k++){
		for (int l=0;l<N;l++){
			a[k][l]=1e7;
		}
		a[k][k]=0;
	}
	for (int k=0;k<M;k++){
		cin>>s>>e;
		b[k][0]=e-1;b[k][1]=s-1;
		a[s-1][e-1]=min(a[s-1][e-1],1);
	}
  	for (int i = 0; i < N; i++)      // ?????±????????????
    	for (int j = 0; j < N; j++)    // ????§???????
      		for (int k = 0; k < N; k++)  // ??????
        		a[j][k] = min(a[j][k], a[j][i] + a[i][k]);
	int ans=a[S-1][T-1];
	best=0;
	for (int k=0;k<M;k++){
		s=b[k][0];e=b[k][1];
		if (ans>a[S-1][s]+1+a[e][T-1]){
			ans=a[S-1][s]+1+a[e][T-1];
			best=k+1;
		}
	}
	cout<<ans<<" "<<best<<endl;
		/*
	for( int i=0; i<M; i++ ) {
	    delete[] b[i];
	}
	delete[] b;
	for( int i=0; i<N; i++ ) {
	    delete[] a[i];
	}
	delete[] a;
	}
		*/
	}
}
	return 0;
}

Measured memory_bytes: 5148
#include<iostream>

#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) cout << s << endl;
# define printStr(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;

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

    Yes((abs(a-c)<=d) || (abs(a-b)<=d && abs(b-c)<=d))
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

vi p;
vvi r;

int getp(int v) {
  if (p[v] == v) return v;
  return p[v] = getp(p[v]);
}

bool join(int a, int b) {
  a = getp(a), b = getp(b);
  if (a == b) return false;
  if (r[a].size() > r[b].size()) {
    swap(a, b);
  }
  p[a] = b;
  for (int x : r[a]) r[b].push_back(x);
  return true;
}

const int N = 1 << 18;

pii mi[2][2 * N];

pii getmi(int l, int r, int t) {
  l += N;
  r += N;
  pii res(1e18, 0);
  while (l <= r) {
    if (l & 1) {
      res = min(res, mi[t][l]);
      ++l;
    }
    if (!(r & 1)) {
      res = min(res, mi[t][r]);
      --r;
    }
    l /= 2;
    r /= 2;
  }
  return res;
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  ll n, d;
  cin >> n >> d;
  vl a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    mi[0][i + N] = pii(a[i] + d * i, i);
    mi[1][i + N] = pii(a[i] - d * i, i);
  }
  for (int i = n; i < N; ++i) {
    mi[0][i + N] = mi[1][i + N] = pii(1e18, i);
  }
  for (int i = N - 1; i > 0; --i) for (int t = 0; t < 2; ++t) {
    mi[t][i] = min(mi[t][2*i], mi[t][2*i+1]);
  }
  p.resize(n);
  r.resize(n);
  for (int i = 0; i < n; ++i) {
    p[i] = i;
    r[i] = vi(1, i);
  }
  int sz = n;
  ll res = 0;
  while (sz > 1) {
    cerr << sz << endl;
    vector<array<ll, 3>> todo;
    for (int i = 0; i < n; ++i) if (p[i] == i) {
      sort(r[i].begin(), r[i].end());
      array<ll, 3> cur = {(ll)1e18, 0LL, 0LL};
      vii le(r[i].size() + 1, pii(1e18, 0)), ri(r[i].size() + 1, pii(1e18, 0));
      for (int j = 0; j < r[i].size(); ++j) {
        le[j + 1] = min(le[j], pii(a[r[i][j]] - d * r[i][j], r[i][j]));
      }
      for (int j = r[i].size() - 1; j >= 0; --j) {
        ri[j] = min(ri[j + 1], pii(a[r[i][j]] + d * r[i][j], r[i][j]));
      }
      for (int j = 0; j <= r[i].size(); ++j) {
        int L = j == 0 ? 0 : r[i][j - 1] + 1;
        int R = j == r[i].size() ? n - 1 : r[i][j] - 1;
        if (L > R) continue;
        pii mil = getmi(L, R, 0), mir = getmi(L, R, 1);
/*        if (getp(mil.second) == i || getp(mir.second) == i) {
          cerr << L << ' ' << R << ' ' << mil.second << ' ' << mir.second << endl;
          assert(0);
        }*/
        array<ll, 3> cl = {le[j].first + mil.first, mil.second, le[j].second};
        array<ll, 3> cr = {ri[j].first + mir.first, mir.second, ri[j].second};
        cur = min(cur, cl);
        cur = min(cur, cr);
      }
      //cerr << i << ' ' << cur[0] << ' ' << cur[1] << ' ' << cur[2] << endl;
      todo.push_back(cur);
    }
    sort(todo.begin(), todo.end());
    for (const auto& v : todo) {
      assert(v[1] >= 0 && v[2] >= 0 && v[1] < n && v[2] < n);
      if (join(v[1], v[2])) {
        res += v[0];
        --sz;
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 43440
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(1000001); //n!(mod M)
vector<ll> ifac(1000001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
void setcomb() {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 1000000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
	}
	ifac[1000000] = mpow(fac[1000000], M - 2);
	for (ll i = 1000000; i > 0; i--) {
		ifac[i - 1] = ifac[i] * i%M;
	}
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
ll perm(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	return fac[a] * ifac[a - b] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

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

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;

int main() {
    int n, k; cin >> n >> k;
    int ans = 0;
    rep(i, n) {
        int tmp; cin >> tmp;
        if (tmp>=k) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int H, W;
	cin >> H >> W;
    vector<vector<int>> s(H,vector<int>(W));
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            char c;
            cin >> c;
            s[i][j]=(c=='.' ? 1 : 0);
        }
    } 
    
    int ans=0;
    vector<vector<int>> v(H,vector<int>(W,0));
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            if(s[i][j]==0) continue;
            int cnt=1, lf=W;
            for(int k=j+1; k<W; ++k){
                if(s[i][k]==0){
                    lf=k;
                    break;
                }
                ++cnt;
            }
            for(int l=j; l<lf; ++l) v[i][l]=cnt;
            j += cnt-1;
        }
    }
    for(int i=0; i<W; ++i){
        for(int j=0; j<H; ++j){
            if(s[j][i]==0) continue;
            int cnt=1, lf=H;
            for(int k=j+1; k<H; ++k){
                if(s[k][i]==0){
                    lf=k;
                    break;
                }
                ++cnt;
            }
            for(int l=j; l<lf; ++l) ans = max(ans,v[l][i]+cnt-1);
            j += cnt-1;
        }
    }
	cout << ans << endl;
}

Measured memory_bytes: 31616
import itertools

weights = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
combo = []
for i in xrange(len(weights)):
    combo += itertools.combinations(weights, i + 1)
sums = map(sum, combo)

while 1:
    try:
        print " ".join(map(str, combo[sums.index(input())]))
    except:
        break

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

using namespace std;

const int N = 310;
const long long INF = 1e18;

int n, k;
int h[N];
long long dp[N][N][N];
vector<int> vals;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    vals.push_back(0);
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
        vals.push_back(h[i]);
    }
    sort(vals.begin(), vals.end()); vals.resize(unique(vals.begin(), vals.end()) - vals.begin());
    for (int i = 1; i <= n; i++) h[i] = lower_bound(vals.begin(), vals.end(), h[i]) - vals.begin();
    for (int i = 0; i <= n; i++) for (int j = 0; j <= k; j++) for (int x = 0; x < vals.size(); x++) dp[i][j][x] = INF;
    dp[0][0][0] = 0;
    long long res = INF;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= k; j++) {
            for (int x = 0; x < vals.size(); x++) {
                // not use
                dp[i][j][h[i]] = min(dp[i][j][h[i]], dp[i - 1][j][x] + max(0, vals[h[i]] - vals[x]));
                // use
                if (j < k) {
                    dp[i][j + 1][x] = min(dp[i][j + 1][x], dp[i - 1][j][x]);
                    dp[i][j + 1][0] = min(dp[i][j + 1][0], dp[i - 1][j][x]);
                }
            }
        }
    }
    for (int j = 0; j <= k; j++) {
        for (int x = 0; x < vals.size(); x++) {
            res = min(res, dp[n][j][x]);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 227584
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


int solve(){    
    int n,m;cin>>n>>m;
    // int ans=__gcd(n,m);
    // cout<<ans<<endl;
    int z=n%m;
    int ans=min(z,m-z);
    cout<<ans<<endl;



    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n, q; cin >> n >> q;
    vector<ll> a(n-1), b(n-1);
    vector<ll> p(q), x(q);
    vector<vector<ll>> g(n);
    REP(i, n-1) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }
    REP(i, q) {
        cin >> p[i] >> x[i];
        p[i]--;
    }

    vector<ll> dans(n, 0);
    REP(j, q) {
        dans[p[j]] += x[j];
    }

    deque<ll> que = {0};
    vector<ll> ans(n, 0);
    vector<bool> vst(n, false);
    vst[0] = true;
    ans[0] = dans[0];
    while (que.size()) {
        ll v = que.front(); que.pop_front();
        for (ll u : g[v]) {
            if (!vst[u]) {
                que.push_back(u);
                vst[u] = true;
                ans[u] += ans[v] + dans[u];
            }
        }
    }

    REP(i, n) cout << ans[i] << " \n"[i==n-1];
    
}

Measured memory_bytes: 25712
#include <iostream>

using namespace std;

typedef long long ll;

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

  ll sum = 0;
  ll start = 0;
  ll befStart = 0;
  
  for(int i = 0; i < n; i++)
  {
	ll t;
	cin >> t;
	if(t <= befStart + T)
	{
	  befStart = t;
	}
	else
	{
	  sum += befStart + T - start;
	  start = befStart = t;
	}	
  }
  sum += befStart + T - start;
  cout << sum << endl;  
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){

	int count[4][3][10]={0};	/* 4?£? 3??¨?±? 10????????? */
	int n, b, f, r, v, i, j, k;
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%d %d %d %d", &b, &f, &r, &v);	/* 4????????´??°b f r v?????\???(b?£?f??????r???????????¨?±????v??????????????\?±?) */
		count[b-1][f-1][r-1]+=v;
	}
	for(i=0; i<4; i++){
		for(j=0; j<3; j++){
			for(k=0; k<10; k++){
				printf(" %d",count[i][j][k]);	/* ????£??????? ?????? ?????????????????\?±??????°????????? */
			}
			printf("\n");	/* ??????????¬????????????¢?????? */
		}
		if(i<3){
			printf("####################\n");	/* ????£??????????????????????20??????#???????????? */
		}
	}

return 0;
}

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

int main() {
  int K, X;

  cin >> K >> X;
  
  for (int i = X-(K-1); i <= X+(K-1); i++) {
    if (i < -1000000) continue;
    if (i > 1000000) continue;
    cout << i;
    if ((i == 1000000) || (i == X+(K-1))) {
      break;
    }
    else {
      cout << " ";
    }
  }
  cout << endl;
  
}

Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans;
vector<vector<int>> vc(ms);
pi dp[ms];
void solve()
{
    ll n,m;cin>>n>>m;ll ar[n+1];ll mp[n+1];
    for(int i=1;i<=n;i++)
    {
        mp[i]=-1;
        cin>>ar[i];
    }
    int a=1;
    //map<ll,ll>mp;
    ll k=1;
    while(mp[(a)]==-1)
    {
        mp[a]=k++;
        a=ar[a];
    }
    ll modval=k-mp[a];
    if(m<mp[a])
    {
        a=1;
        while(m)
        {
            m--;
            a=ar[a];
        }
        cout<<a<<endl;return;
    }
    m-=mp[a]-1;
    m%=modval;
    while(m)
    {
        a=ar[a];m--;
    }
    cout<<a<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 11100
#include<bits/stdc++.h>
using namespace std;
string S[50],T[50];int n,m;
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>S[i];
	for(int i=0;i<m;i++)cin>>T[i];
	for(int i=0;i<=n-m;i++){
		for(int j=0;j<=n-m;j++){
			bool OK=true;
			for(int k=i;k<i+m;k++){
				if(T[k-i]!=S[k].substr(j,m))OK=false;
			}
			if(OK==true){cout<<"Yes"<<endl;return 0;}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i,n,N) for(ll i=(n);i<(N);i++)
#define RREP(i,n,N) for(ll i=(N-1);i>=(n);i--)
#define p(s) cout<<(s)<<endl
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll N, K;
ll M[101], l[101];
ll P[101][101];
int main(){
    while(cin>>N, N){
        REP(i, 0, N){
            cin>>M[i];
            REP(j, 0, M[i]) cin>>P[i][j];
            sort(P[i], P[i]+M[i]);
        }
        cin>>K;
        REP(i, 0, K) cin>>l[i];
        sort(l, l+K);

        /*
        REP(i, 0, N){
            REP(j, 0, M[i]){
                cout<<P[i][j]<<" ";
            }
            cout<<endl;
        }
        REP(i, 0, K){
            cout<<l[i]<<" ";
        }
        cout<<endl;
         */


        ll cnt=0, ans=-1;
        REP(i, 0, N){
            ll idxa=0, idxb=0;
            bool flag=false;
            while(idxa<M[i]){
                if(P[i][idxa]==l[idxb]){
                    idxb++;
                }
                idxa++;

                if(idxb>=K){
                    flag=true;
                    cnt++;
                    ans=i+1;
                    break;
                }
            }
        }

        if(cnt==1) cout<<ans<<endl;
        else cout<<-1<<endl;

    }
    return 0;
}


Measured memory_bytes: 3236
#include <stdio.h>

int main () {
    int L;
    int R;
    scanf("%d", &L);
    scanf("%d", &R);

    int min = 2020;
    for (int i = L; i < R; i++) {
        for (int j = L + 1; j <= R; j++) {
            int v = i % 2019;
            int w = j % 2019;
            if (min > ((v * w) % 2019))
                min = (v * w) % 2019;
            if (min == 0) {
                printf("%d\n", min);
                return 0;
            }
        }
    }

    printf("%d\n", min);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    
    while(a > 0 && c > 0)
    {
        a -= d;
        c -= b;
    }
    printf("%s\n",(c > 0 && a <= 0)? "No":"Yes");
}


Measured memory_bytes: 3688
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cassert>
#define maxn 
#define maxm 
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
//#define DEBUG
using namespace std;

int main(){
	int x, y;
	scanf("%d%d", &x, &y);
	if (x == y) printf("%d", x + y);
	else printf("%d", max(x, y) + max(x, y) - 1);
	return 0;
}

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

int n, k;
int dp[100005], v[100005];

int main(){
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i++)
        scanf("%d", &v[i]);
    for(int i = 2; i <= n; i++)
        dp[i] = 1e9+5;
        
    for(int i = 2; i <= n; i++)
        for(int j = i-1, cnt = 0; j >= 1 and cnt < k; j--, cnt++)
            dp[i] = min(dp[i], dp[j] + abs(v[j] - v[i]));
    printf("%d\n", dp[n]);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(it,st,en) for(int it=(st);it<(int)(en);++it)
#define all(c) (c).begin(), (c).end()
#define debug(x) //cerr << #x << " = " << x << endl
#define eb emplace_back
#define X first
#define Y second
typedef long long int ll; 
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  vi a(n);
  rep(i,0,n) cin>>a[i];

  auto works = [&](int q) {
    debug(q);
    vector<pii> s = {{0,a[0]}};
    auto crop = [&](int sz) {
      while(s.size() >= 2 && s[s.size()-2].Y >= sz) s.pop_back();
      s.back().Y = sz;
      if(sz == 0) s.clear();
    };
    auto extend = [&](int val, int sz) {
      if(s.size() && s.back().X == val) s.back().Y = sz;
      else s.eb(val, sz);
    };
    rep(i,1,n) {
      if(a[i] > a[i-1]) {
        extend(0, a[i]);
      }
      else {
        crop(a[i]);
        if(s.back().X < q) {
          // s does not end with q
          int k = s.back().X;
          crop(a[i]-1);
          extend(k+1, a[i]);
        }
        else {
          s.pop_back();
          if(s.empty()) return false; // s = q^n cannot increase
          // s = ...kq^n -> ...(k+1)a^n
          int sz = s.back().Y;
          int k = s.back().X;
          crop(sz-1);
          extend(k+1, sz);
          extend(0, a[i]);
        }
      }
      //int k = 0;
      //for(pii p:s) while(k < p.Y) {
      //  cerr << char(p.X+'a');
      //  ++k;
      //}
      //cerr << endl;
      ////for(pii p:s) cerr << p.X << " " << p.Y << endl;
      //assert(s.back().Y == a[i]);
      //rep(i,1,s.size()) {
      //  assert(s[i-1].X != s[i].X);
      //  assert(s[i-1].Y < s[i].Y);
      //}
    }
    debug("works");
    return true;
  };

  int l = -1, r = 2*n;
  while(l+1 < r){
    int q = (l+r)/2;
    if(works(q)) r = q;
    else l = q;
  }
  cout << r+1 << endl;
  return 0;
}
/*
 * First is always: a^v[0]
 * Second is a^(v[1]-1) b
 *
 * aaa
 * ab
 * b
 *
 *
 * aa
 * aaa
 * ab
 * b
 * ba
 *
 * => binary search
 * => longer: pad a's
 * => not longer: a^n b^m a^k => either change a to b
 *
 *
 *
 */


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

using namespace std;

int main(){
    string S;
    cin >> S;
    if (S == "SUN") cout << 7 << endl;
    if (S == "MON") cout << 6 << endl;
    if (S == "TUE") cout << 5 << endl;
    if (S == "WED") cout << 4 << endl;
    if (S == "THU") cout << 3 << endl;
    if (S == "FRI") cout << 2 << endl;
    if (S == "SAT") cout << 1 << endl;
    
}

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

int main() {
    string s;
    cin>>s;

    if(s=="SAT") cout<<1<<endl;
    else if(s=="FRI") cout<<2<<endl;
    else if(s=="THU") cout<<3<<endl;
    else if(s=="WED") cout<<4<<endl;
    else if(s=="TUE") cout<<5<<endl;
    else if(s=="MON") cout<<6<<endl;
    else if(s=="SUN") cout<<7<<endl;
}


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

void fnInput(vector<int>& rvnMaxHeap)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  rvnMaxHeap.resize(nMaxSiz + 1);

  for (int i = 1; i < nMaxSiz + 1; ++i)
    cin >> rvnMaxHeap[i];
}

void fnMaxHeapify(vector<int>& rvnMaxHeap, int nx)
{
  int nLeft = nx * 2;
  int nRigt = nLeft + 1;
  int nLarg = nx;

  if (nLeft < rvnMaxHeap.size()  &&
      rvnMaxHeap[nLarg] < rvnMaxHeap[nLeft])  
    nLarg = nLeft;
  if (nRigt < rvnMaxHeap.size()  &&
      rvnMaxHeap[nLarg] < rvnMaxHeap[nRigt])
    nLarg = nRigt;

  swap(rvnMaxHeap[nx], rvnMaxHeap[nLarg]);
  if (nx != nLarg)
    fnMaxHeapify(rvnMaxHeap, nLarg);
}

void fnMaximumHeap(vector<int>& rvnMaxHeap)
{
  for (int i = (rvnMaxHeap.size() - 1) / 2; i > 0; --i)
    fnMaxHeapify(rvnMaxHeap, i);
}

void fnResult(const vector<int>& cnrvnMaxHeap)
{
  for (int i = 1; i < cnrvnMaxHeap.size(); ++i)
    cout << " " << cnrvnMaxHeap[i];

  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnMaxHeap; 

  fnInput(vnMaxHeap);
  fnMaximumHeap(vnMaxHeap);
  fnResult(vnMaxHeap);
  return 0;
}

Measured memory_bytes: 4488
#include <cstdio>
#include <cmath>
#include <iostream>

using namespace std;

unsigned long long p[55], nlen[55];

unsigned long long solve(unsigned long long n, unsigned long long x)
{
    if(x <= n) return 0;
    if(x >= nlen[n] - 1) return p[n];
    if(x == nlen[n] / 2 + 1) return (p[n] / 2 + 1);
    else if(x < nlen[n] / 2 + 1)
    {
        return solve(n - 1, x - 1);
    }
    else
    {
        return p[n] / 2 + 1 + solve(n - 1, x - nlen[n] / 2 - 1);
    }
}

int main()
{
    for(int i = 0; i <= 50; ++i)
    {
        p[i] = pow(2, i + 1) - 1;
        nlen[i] = pow(2, i - 1) * 8 - 3;
    }
    unsigned long long n, x;
    cin>>n>>x;
    cout<<solve(n, x)<<endl;
    return 0;
}


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

int main() {
	int N; cin >> N;
  float sum = 0.0;
  for (int i = 0; i < N; ++i) {
  	int A_i; cin >> A_i;
    sum += 1.0 / A_i;
  }
  cout << 1.0 / sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    sort(all(b));

    ll ans;
    if(n%2==1){
        ll meda = a[n/2];
        ll medb = b[n/2];
        ans = medb - meda + 1;
    }else{
        ll meda2 = (a[n/2-1] + a[n/2]);
        ll medb2 = (b[n/2-1] + b[n/2]);
        ans = (ll)(medb2 - meda2 + 1);
    }

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


Measured memory_bytes: 6340
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x, y, xp=0, yp=0, ans=0;
 	cin >> x >> y;
	if(x <=3){
      xp = (4-x)*100000;
      ans += xp;
    }
  	if(y <=3){
      yp = (4-y)*100000;
      ans += yp;
    }
  	if(x==1 && y==1){
      ans += 400000;
    }
  	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
    static BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
    public static void main(String[] args) throws IOException {
        int x = ReadInt();
        int res = x * x * x;
        System.out.println(res);
    }
    static int ReadInt() throws IOException {
        String s = buf.readLine();
        return Integer.parseInt(s);
    }
}

Measured memory_bytes: 24324
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;
#define  LL long long
const int N = 1e5+55;
const int mod = 20020219;


char s1[N],s2[N];

int gcd(int x,int y)
{
	return y==0?x:gcd(y,x%y);
}

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	scanf("%s%s",s1+1,s2+1);
	int d=gcd(n,m);
	int a=n/d;
	int b=m/d;
	int x=1,y=1;
	for(int i=1;i<=d;i++){
		if(s1[x]!=s2[y]){
			printf("-1\n");
			return 0;
		}
		x+=a;
		y+=b;
	}
	printf("%lld\n",1LL*n/d*m);


}


Measured memory_bytes: 384
import bisect

n=int(input())
a=[int(x) for x in input().split()]
a.sort()

i=bisect.bisect_left(a,(a[n-1]+1)//2)
print(a[n-1], a[i-1] if ((a[n-1]+1)//2)*2<=a[i]+a[i-1] else a[i])


Measured memory_bytes: 14052
import collections
n,q = map(int, input().split())
queue = collections.deque(maxlen=100000)

for i in range(n):
    p,t = input().split()
    queue.append([p, int(t)])

time = 0
while queue:
    p,t = queue.popleft()
    if t<=q:
        time += t
        print(p,time)
    else:
        time += q
        queue.append([p,t-q])

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

using namespace std;
long long a[100005],b[100005];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n+1;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		cin>>b[i];
	}
	long long ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]+a[i+1]<=b[i]){
			ans=ans+a[i]+a[i+1];
//			cout<<a[i]<<" "<<a[i+1]<<endl;
			a[i]=0;
			a[i+1]=0;
		}
		else{
//			cout<<a[i]<<" "<<endl;
			ans+=b[i];
//			cout<<b[i]<<" ";
			if(a[i]<=b[i]){
				a[i+1]-=(b[i]-a[i]); 
				a[i]=0;
			}
			else{
				a[i]-=b[i];
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.SortedMap;
import java.util.TreeMap;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int H = sc.nextInt();
        final int W = sc.nextInt();
        
        final int[][] range = new int[H][2];
        
        for (int i = 0; i < H; i++) {
            range[i][0] = sc.nextInt() - 1;
            range[i][1] = sc.nextInt();
        }
        
        SortedMap<Integer, Integer> currToOrigin = new TreeMap<>();
        for (int j = 0; j < W; j++) {
            currToOrigin.put(j, j);
        }
        
        int[] gaps = new int[W];
        gaps[0] = W;
        int minGapIdx = 0;
        int maxGapIdx = 0;
        
        StringBuilder result = new StringBuilder();
        final String BR = System.lineSeparator();
        
        int i = 0;
        for (; i < H && !currToOrigin.isEmpty(); i++) {
            int left = range[i][0];
            int right = range[i][1];
            SortedMap<Integer, Integer> subMap = currToOrigin.subMap(left, right);
            
            if (!subMap.isEmpty()) {
                int biggestOrigin = subMap.get(subMap.lastKey());
                
                subMap.forEach((curr, orig) -> gaps[curr - orig]--);
                subMap.clear();
                
                if (right < W && !currToOrigin.containsKey(right)) {
                    currToOrigin.put(right, biggestOrigin);
                    gaps[right - biggestOrigin]++;
                    if (maxGapIdx < right - biggestOrigin) {
                        maxGapIdx = right - biggestOrigin;
                    }
                }
                
                while (minGapIdx <= maxGapIdx && gaps[minGapIdx] == 0) {
                    minGapIdx++;
                }
            }
            result.append(minGapIdx <= maxGapIdx ? minGapIdx + i + 1 : -1).append(BR);
        }
        for (; i < H; i++) {
            result.append(-1).append(BR);
        }
        System.out.println(result);
    }
}


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

using namespace std;

int main()
{
    int N, K;
    int h[100001];
    long long dp[100001];
    long long INF = 1LL << 60;

    cin >> N >> K;

    for (int i = 1; i <= N; i++) {
        cin >> h[i];
    }

    dp[1] = 0;
    dp[2] = abs(h[1] - h[2]);

    // ループごとにdp[i]を計算
    for (int i = 3; i <= N; i++) {
        long long min_cost = INF;

        // j = ジャンプの距離
        for (int j = 1; j <= K; j++) {
            // ジャンプの開始点は1以上
            if (i - j < 1) {
                continue;
            }

            long long cost = dp[i - j] + abs(h[i - j] - h[i]);
            min_cost = min(cost, min_cost);
        }
        dp[i] = min_cost;
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1408
N = int(input())
X,Y,H = [],[],[]
for i in range(N):
    x,y,h = map(int,input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
hAns = [0]*N

# x=i, y=jでは条件を満たすか?
for i in range(101):
    for j in range(101):
        # k番目のデータで"頂点の高さ"を計算
        for k in range(N):
            hAns[k] = H[k]+abs(X[k]-i)+abs(Y[k]-j)
        # 入力データが同じ答えを出したら,その座標と高さが答えになる
        # H[l]==0のときのみ、違う値になっているかもしれない
        for l in range(N):
            if H[l] == 0:
                hAns[l] = min(hAns)
        if all(hAns[c]==hAns[c+1] for c in range(len(hAns)-1)):
            print(i,j,hAns[0])
            break


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

int main(void)
{ 
  int a,b,c,t;
  cin>>a>>b>>c;
  if(a>b){
    t=a;a=b;b=t;
  }
  if(b>c){
    t=b;b=c;c=t;
  }
  if(a>b){
    t=a;a=b;b=t;
  }
  cout<<a<<' '<<b<<' '<<c<<endl;
  return 0;
}


Measured memory_bytes: 3084
#include<stdio.h>

int main(void){
	int n;
	int a[100002];
	int b[100000];

	int i;
	double c;

	c = 0; 

	scanf("%d",&n);


	for(i=0;i<n+1;i++){
		scanf("%d",&a[i]);
	}

	for(i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	a[n+2] = 0;
	for(i=0;i<n;i++){
		if(b[i] <= a[i]){
			c += b[i];
		}else if(b[i] > a[i]){
			c += a[i];
			b[i] -= a[i];

			// 次の町の計算
			if(b[i] <= a[i+1]){
				c+= b[i];
				a[i+1] -= b[i];
			}else{
				c+= a[i+1];
				a[i+1] = 0;
			}
		}
	}

	printf("%1.0lf\n",c);

	return 0;
}

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

int main(){
	int tmp,n,su[101]={0},minn=999999999;
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>tmp;
		su[i]=su[i-1]+tmp;
	}
	for(int i=1;i<=n;++i)
		if(minn>abs(2*su[i]-su[n]))
			minn=abs(2*su[i]-su[n]);
	cout<<minn;
}

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

struct edge{
  int from,to,cost;
  bool operator < (const edge &p)const{
   return cost < p.cost;
  }
};

int pa[1000],ra[1000];
void init(){
  for(int i=0;i<1000;i++){
    pa[i]=i;
    ra[i]=0;
  }
}

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

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

void unite(int x,int y){
  x=find(x),y=find(y);
  if(ra[x]<ra[y])swap(x,y);
  pa[y]=x;
  if(ra[x]==ra[y])ra[x]++;
}

int N,M;
int a,b,c;
int flg[100000];
vector<edge> t;

int solve(int id){
  int sum=0;
  for(int i=0;i<(int)t.size();i++){
    if(i==id)continue;
    edge e=t[i];
    if(same(e.from,e.to))continue;
    unite(e.from,e.to);
    sum+=e.cost;
    if(id==-1)flg[i]=true;
  }
  if(id!=-1){
    edge e=t[id];
    if(same(e.from,e.to))return sum;
    else return 1e9;
  }
  return sum;
}

int main(){
  cin>>N>>M;
  init();
  t.clear();
  for(int i=0;i<M;i++){
    scanf("%d %d %d",&a,&b,&c);
    t.push_back((edge){a,b,c});
  }
  sort(t.begin(),t.end());
  int base=solve(-1);  
  

  int ans=0,ans2=0;
  for(int i=0;i<M;i++){
    if(flg[i]==false)continue;
    init();
    int b=solve(i);

    if(base==b)continue;
    ans++;
    ans2+=t[i].cost;
  }
  cout<<ans<<' '<<ans2<<endl;
  return 0;
}

Measured memory_bytes: 2068