akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

struct Edge { int to, id; };

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c = -1, int p = -1) {
	int k = 1;
	rep(i, g[v].size()) {
		int u = g[v][i].to, ei = g[v][i].id;
		if (u == p) continue;
		if (k == c) ++k;
		ans[ei] = k; ++k;
		dfs(u, ans[ei], v);
	}
}

int main() {
	int n;
	cin >> n;
	g.resize(n);
	ans = vi(n - 1);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		Edge tmp1 = { b, i };
		Edge tmp2 = { a, i };
		g[a].push_back(tmp1);
		g[b].push_back(tmp2);
	}
	dfs(0);
	int mx = 0;
	rep(i, n) mx = max(mx, int(g[i].size()));
	cout << mx << endl;
	rep(i, n - 1) {
		cout << ans[i] << endl;
	}
	return 0;
}

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

struct SegmentTree {
private:
    vector<ll> tree, lazy;
    ll n, root, size;
public:
    SegmentTree(){}
    SegmentTree(int _n) : n(_n), root(1) {
        ll x = (ll)(ceil(log2(n)));
        size = 2*(ll)pow(2, x);
        tree.resize(size);
        lazy.resize(size);
    }
    void pendingUpdate(ll node, ll start, ll end) {
        if(lazy[node]) {
            tree[node] += lazy[node];
            if(start != end) {
                lazy[2*node] += lazy[node];
                lazy[2*node+1] += lazy[node];
            }
            lazy[node] = 0;
        }
    }
    void updateRange(ll l, ll r, ll diff) { updateRange(root, 0, n-1, l, r, diff);}
    void updateRange(ll node, ll start, ll end, ll l, ll r, ll diff) {
        pendingUpdate(node, start, end);
        if(start > end || start > r || end < l) return;
        if(start >= l && end <= r) {
            tree[node] += diff;
            if(start != end) {
                lazy[2*node] += diff;
                lazy[2*node+1] += diff;
            }
            return;
        }
        ll mid = (start + end) / 2;
        updateRange(2*node, start, mid, l, r, diff);
        updateRange(2*node+1, mid+1, end, l, r, diff);
        tree[node] = max(tree[2*node], tree[2*node+1]);
    }
    ll query(ll l, ll r) { return query(root, 0, n-1, l, r);}
    ll query(ll node, ll start, ll end, ll l, ll r) {
        if(r < start || end < l) return 0;
        pendingUpdate(node, start, end);
        if(l <= start && end <= r) return tree[node];
        ll mid = (start+end)/2;
        return max(query(2*node, start, mid, l, r), query(2*node+1, mid+1, end, l, r));
    }
};

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    SegmentTree st(n);
    vector<int> height(n);
    for(int i = 0; i < n; ++i) {
        cin >> height[i];
    }
    vector<int> value(n);
    for(int i = 0; i < n; ++i) {
        cin >> value[i];
    }
    int res = 0;
    for(int i = 0; i < n; ++i) {
        int currMax = value[i] + st.query(0, height[i]-1);
        res = max(res, currMax);
        st.updateRange(height[i], height[i], currMax);
    }
    cout << res << '\n';
    return 0;
}


























Measured memory_bytes: 11648
let () =
  let s = Scanf.scanf "%s\n" @@ fun s -> s in
  let len = String.length s in
  let ans = ref true in
  for i = 0 to len - 1 do
    if (i mod 2 = 0 && s.[i] = 'h') || (i mod 2 = 1 && s.[i] = 'i')
    then ans := !ans && true
    else ans := !ans && false
  done;
  Printf.printf "%s\n" (if !ans && len mod 2 = 0 then "Yes" else "No")

Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}


int main(){
	int n;
	cin >> n;
	set<int> s;
	rep(i, n) {
		int a;
		cin >> a;
		s.insert(a);
	}
	int q;
	cin >> q;
	int ans = 0;
	rep(i, q)
	{
		int a;
		cin >> a;
		ans += s.count(a);
	}
	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 3144
#include<iostream>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, x, n) for (int i = x; i < (n); ++i)
using namespace std;

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

    int A[110];
    rep(i, N) cin >> A[i];

    int max_diff = 0; // 差分の最大値
    // 0 〜 N-2
    rep(i, N-1) {
        rep2(j, i+1, N) {
            int diff = abs(A[i] - A[j]);
            if (diff > max_diff) max_diff = diff;
        }
    }

    cout << max_diff << endl;
    return 0;
}


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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int H,W; cin >> H >> W;
  vector<string> v(H);
  vector<vector<int>> dist;
  for(int i = 0; i < H; i++){
    cin >> v[i];
  }


  int max_val = 0;

  auto check = [&v,&H,&W](int x, int y){
    if(x < 0 || x >= H) return false;
    if(y < 0 || y >= W) return false;
    if(v[x][y] == '#')  return false;

    return true;
  };

  int dx[4] = {0,1,0,-1};
  int dy[4] = {1,0,-1,0};
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      int tmp_val = 0;
      // i,jをスタートとして、最も遠いところを探す
      if(v[i][j] == '#') continue;

      queue<pii> q;
      q.push(make_pair(i,j));
      dist.assign(H, vector<int>(W,-1));
      dist[i][j] = 0;

      while(!q.empty()){
        auto now = q.front();
        q.pop();
        int now_x = now.first;
        int now_y = now.second;
        for(int k = 0; k < 4; k++){
          int next_x = now_x + dx[k];
          int next_y = now_y + dy[k];
          if(check(next_x, next_y)){
            if(dist[next_x][next_y] == -1){
              dist[next_x][next_y] = dist[now_x][now_y] + 1;
              tmp_val = max(tmp_val, dist[next_x][next_y]);
              q.push(make_pair(next_x, next_y));
            }
          }
        }
      }
      max_val = max(max_val, tmp_val);
    }
  }
  cout << max_val << endl;
}


Measured memory_bytes: 3620
def func():
    pass


def main():
    o = input()
    e = input()

    ans = ""
    for i in range(len(e)):
        ans += o[i] + e[i]

    if len(o) > len(e):
        ans += o[-1]

    print(ans)


def main2():
    o = input()
    e = input()
    ans = ""

    for i in range(len(o)):
        ans += o[i]
        if i < len(e):
            ans += e[i]
            
    print(ans)
        

if __name__ == '__main__':
    main2()


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

using namespace std;
typedef long long ll;

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

int main(void){
	
	ll A,B;
	
	cin >> A >> B;
	
	ll g = gcd(A, B);
	ll cnt = 0;
	
	for(ll i = 2 ; i * i <= g; i++){
		if(g % i == 0){
			cnt++;
			while(g % i == 0)
				g /= i;
		}
	}
	
	if(g > 1)
		cnt++;
	
	cout << cnt + 1 << endl;
	
	return 0;
}


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

using namespace std;

int main(){

    long long int n,k;
    cin >> n >> k;

    long long int m = pow(10,9)+7;

    long long int s=0;

    for(int i=k;i<n+2;i++){
        s += (i%m)*((n-i+1)%m)+1;
        s = s%m;
    }


    cout << s << endl;


}

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

using namespace std;

const int mod = int(1e9) + 7;
const int N = 1100;
int dp[N][N];

int main(){
	int n, m; cin >> n >> m;
	string a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	
	dp[0][0] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(a[i][j] == '.'){
				if(i-1 >= 0) dp[i][j] += dp[i-1][j];
				if(j-1 >= 0) dp[i][j] += dp[i][j-1];
				dp[i][j] %= mod;
			}
		}
	}
	
	cout << dp[n-1][m-1];
	return 0;
}

Measured memory_bytes: 5632
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		System.out.println(canChangebill());

	}

	private static int canChangebill() {
		Scanner sc = new Scanner(System.in);
		int[] c = new int[] {1, 5, 10, 50, 100, 500};
		int sum = 0;
			for (int i = 0; i < c.length; i++) {
				sum += sc.nextInt() * c[i];
			}

		sc.close();
		if (sum >= 1000) {
			return 1;
		} else {
			return 0;
		}

	}
}


Measured memory_bytes: 26384
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll K,A,B;
    cin >> K >> A >> B;
    ll out = 1;
    if(B-A<2) out += K;
    else{
        if(K-A<1) out += K;
        else{
            ll k = K-A+1;
            ll i = k/2;
            out += A-1+(B-A)*i;
            if(k%2==1) out++;
        }
    }
    cout << out << endl;
    return 0;
}


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

int main(){

    int n;
    cin >> n;
    int a[n+2];

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

    int total = 0;
    for(int i=0; i<n+1; i++){
        total += abs(a[i+1] - a[i]);
    }

    for(int i=1; i<=n; i++){
        int temp = total - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i+1] - a[i-1]);
        cout << temp << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(); in.nextLine();
		int total = 0;
		int a = 0;
		int b = 0;
		for ( int i = 0; i < n; i++ ) {
			a = in.nextInt();
			b = in.nextInt(); in.nextLine();
			total += (b-a+1);
		}
		
		System.out.println(total);
	}
}

Measured memory_bytes: 28764
#include <stdio.h>
#include <string.h>
 
#define MAX 244140625
 
int Hash[MAX];
char s[13];
 
int getChar(char);
int getKey();
int find();
void insert();
 
int main(){
  int n;
  char com[7];
 
  scanf("%d" ,&n);
  while(n--){
    scanf("%s %s" ,com ,s);
 
    if(com[0] == 'i'){
      insert();
    }else{
      if(find()){
    puts("yes");
      }else{
    puts("no");
      }
    }
  }
 
  return 0;
}
 
int getChar(char ch){
  if(ch == 'A'){
    return 1;
  }else if(ch == 'C'){
    return 2;
  }else if(ch == 'G'){
    return 3;
  }
  return 4;
}
 
int getKey(){
  int sum = 0, p = 1, i;
 
  for(i = 0 ; i < strlen(s) ; i++){
    sum += p*(getChar(s[i]));
    p *= 5;
  }
  return sum;
}
 
int find(){
  int key = getKey();
 
  if(Hash[key]){
    return 1;
  }
 
  return 0;
}
 
void insert(){
  Hash[getKey()] = 1;
}


Measured memory_bytes: 18628
#include <stdio.h>
int main(void){
    int N,M,c[50]={},a,b,i;
    scanf("%d %d",&N,&M);
    for(i=0;i<M;i++){
        scanf("%d %d",&a,&b);
        c[a-1] +=1; c[b-1] +=1;
    }
    for(i=0;i<N;i++){
        printf("%d\n",c[i]);}
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << endl
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll A, B;
  cin >> A >> B;
  COUT((A + B + 1) / 2);
  return 0;
}

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

#define mp make_pair
#define pb push_back
#define f first
#define s second 
#define sz(s) (int)s.size()
#define int long long
#define all(s) s.begin(), s.end()
#define forn(i, x, y) for(int i = x; i <= y; i++)
#define forev(i, y, x) for(int i = y; i >= x; i--)

using namespace std;

const int maxn = (int)4e5 + 100;
const int mod = (int)1e9 + 7;
const int P = (int)1e6 + 7;
const int inf = (int)1e9 + 7;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef long double ld;

int n, k, a[maxn], nxt[maxn], lst[maxn], was[maxn], f[maxn], up[maxn][66];

int convert(int x){
  return (x - 1) % n + 1;
}
main () {
  cin >> n >> k;
  forn(i, 1, n){
    cin >> a[i];
    if(!f[a[i]]) f[a[i]] = i;
  }
  forev(i, n, 1){
    if(!lst[a[i]]){
      nxt[i] = n - i + 1 + f[a[i]];
    }else{
      nxt[i] = lst[a[i]] - i + 1;
    }
    lst[a[i]] = i;
  }
  forn(i, 1, n) up[i][0] = nxt[i];
  forn(lvl, 1, 60){
    forn(i, 1, n){
      int x = convert(up[i][lvl - 1] + i);
      up[i][lvl] = min(200000000000000001ll, up[i][lvl - 1] + up[x][lvl - 1]);
      //cout << i << " " << lvl << " " << up[i][lvl] << " " << x << " " << endl;
    }
  }
  int cur = 1, pos = 1;
  forev(i, 60, 0){
    if(cur + up[pos][i] <= n * k){
      cur += up[pos][i];
      pos = convert(pos + up[pos][i] % n);
    }
  }
  vi v;
  forn(i, cur, n * k){
    int x = a[convert(i)];
    if(was[x]){
      while(v.back() != x) was[v.back()] = 0, v.pop_back();
      v.pop_back();
      was[x] = 0;
    }else{
      was[x] = 1;
      v.pb(x);
    }
  }
  for(auto x : v) cout << x << " ";
}

Measured memory_bytes: 124016
"use strict";
const Main = function(input){
	let xs = input.trim().split(' ');
    let a =xs[0].charAt(xs[0].length-1);
    let b =xs[1].charAt(0);
    let c =xs[1].charAt(xs[1].length-1);
    let d =xs[2].charAt(0);
    
    if(a == b && c == d){
      console.log('YES');
    }else{
      console.log('NO');
    }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
N = int(input())
A = []
for i in range(N):
    temp = int(input())
    A.append((temp, i))
A.sort(key = lambda x: -x[0])

for i in range(N):
    if i == A[0][1]:
        print(str(A[1][0]))
    else:
        print(str(A[0][0]))

Measured memory_bytes: 80984
//FA専用
#include <bits/stdc++.h>
using namespace std;
#define int long long
const long long LINF=1e18;
int a,b,c,d,e,f,n,m,ans;
string s,t,u;
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
template<typename T,typename U>
void fin(T a,U b){
  cout<<a<<" "<<b<<endl;
  exit(0);
}
template<typename T,typename U,typename S>
void fin(T a,U b,S c){
  cout<<a<<" "<<b<<" "<<c<<endl;
  exit(0);
}

signed main(){
  int h;cin>>h;int cnt=1;
  while(h){
    ans+=cnt;
    h/=2;
    cnt*=2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

void solve(){
    int x;
    cin >> x;
    if(x <= 599){
        cout << 8 << "\n";
    }
    else if(x <= 799){
        cout << 7 << "\n";
    }
    else if(x <= 999){
        cout << 6 << "\n";
    }
    else if(x <= 1199){
        cout << 5 << "\n";
    }
    else if(x <= 1399){
        cout << 4 << "\n";
    }
    else if(x <= 1599){
        cout << 3 << "\n";
    }
    else if(x <= 1799){
        cout << 2 << "\n";
    }
    else if(x <= 1999){
        cout << 1 << "\n";
    }
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 100000;

LL dp[110][110][2][2];

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

  LL W, H;
  while(cin>>W>>H,W){
	fill((LL*)dp, (LL*)dp+110*110*2*2, 0);
	dp[0][0][0][0] = dp[0][0][1][0] = 1;
	REP(y,H) REP(x,W){
	  (dp[y+1][x][0][1] += dp[y][x][0][0]) %= MOD;
	  (dp[y+1][x][0][1] += dp[y][x][0][1]) %= MOD;
	  (dp[y][x+1][1][0] += dp[y][x][0][1]) %= MOD;
	  
	  (dp[y][x+1][1][1] += dp[y][x][1][0]) %= MOD;
	  (dp[y][x+1][1][1] += dp[y][x][1][1]) %= MOD;
	  (dp[y+1][x][0][0] += dp[y][x][1][1]) %= MOD;
	}
	LL ans = 0;
	REP(i,2) REP(j,2)
	  ans += dp[H-1][W-1][i][j];
	cout << ans % MOD << endl;
  }

  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin >> n;
  vector<ll> a(n);
  ll sum=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum+=a[i];
  }
  ll ans=1e18,t=0;
  if(sum%2==0){
    for(int i=0;i<n;i++){
      t+=a[i];
      ans=min(ans,2*abs(sum/2-t));
    }
  }
  else{
    for(int i=0;i<n;i++){
      t+=a[i];
      ans=min(ans,1+min(2*abs(sum/2-t),2*abs((sum+1)/2-t)));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String t = sc.nextLine();
    char[] sChar = s.toCharArray();
    char[] tChar = t.toCharArray();
    int ans = t.length();
    int searchN = s.length() - (t.length() - 1);
    for (int cnt = 0; cnt < searchN; cnt++) {
      int diffC = 0;
      for (int cnt2 = 0; cnt2 < t.length(); cnt2++) {
        if (sChar[cnt2 + cnt] != tChar[cnt2]) {
          diffC++;
        }
      }
      ans = Math.min(diffC, ans);
    }
    System.out.println(ans);
    sc.close();
  }
}

Measured memory_bytes: 35660
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(n);
    cii(m);
    auto ans = (n == m)
            ?"Yes"
            :"No";
    co(ans);
    return 0;
}

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

using namespace std;

typedef long long ll;

int n;
vector<vector<int> > adj;
map<pair<int, int>, ll> dp, sz;
vector<ll> nsz, mer, full;

ll MOD = 1e9+7, LIM = 3e5;
vector<ll> fact(LIM), invfact(LIM);

ll choose(int n, int c) {
  return (((fact[n] * invfact[c]) % MOD) * invfact[n-c]) % MOD;
}

ll invchoose(int n, int c) {
  return (((invfact[n] * fact[c]) % MOD) * fact[n-c]) % MOD;
}

ll inv(ll x) {
  ll x_b = x;
  ll ret = 1;
  ll pow = MOD - 2;
  while(pow) {
    if(pow % 2 == 1) ret = (ret * x) % MOD;
    x = (x * x) % MOD;
    pow /= 2;
  }
  assert((x_b * ret) % MOD == 1);
  return ret;
}

void dfs1(int curr, int p) {
  nsz[curr] = 0;
  mer[curr] = 1;
  for(int i = 0; i<adj[curr].size(); ++i) {
    if(adj[curr][i] != p) {
      dfs1(adj[curr][i], curr);

      nsz[curr] += nsz[adj[curr][i]];
      sz[make_pair(curr, adj[curr][i])] = nsz[adj[curr][i]];
      dp[make_pair(curr, adj[curr][i])] = mer[adj[curr][i]];
    }
  }
  ll backup_nsz = nsz[curr];
  for(int i = 0; i<adj[curr].size(); ++i) {
    if(adj[curr][i] != p) {
      ll mult = (choose(nsz[curr], nsz[adj[curr][i]]) * mer[adj[curr][i]]) % MOD;
      nsz[curr] -= nsz[adj[curr][i]];
      mer[curr] = (mer[curr] * mult) % MOD;
    }
  }
  nsz[curr] = backup_nsz;
  nsz[curr]++;
}

void dfs2(int curr, int p) {
  //cout << curr << " " << p << endl;
  full[curr] = mer[curr];
  if(p == -1) {
    //
  }
  else {
    full[curr] = (((full[curr] * choose(n-1, nsz[curr]-1)) % MOD) * mer[p]) % MOD;
  }
  for(int i = 0; i<adj[curr].size(); ++i) {
    if(adj[curr][i] != p) {
      ll mult = (invchoose(n-1, nsz[adj[curr][i]]) * inv(mer[adj[curr][i]])) % MOD;
      //ll mult = (invchoose(nsz[curr]-1, nsz[adj[curr][i]]) * inv(mer[adj[curr][i]])) % MOD;
      mer[curr] = (full[curr] * mult) % MOD;
      //cout << curr << " " << full[curr] << " " << mult << endl;
      dfs2(adj[curr][i], curr);
    }
  }
}

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  ll* inv = new ll[LIM] - 1; inv[1] = 1;
  for(int i = 2; i<LIM; ++i)
    inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;

  fact[0] = 1;
  fact[1] = 1;
  invfact[0] = 1;
  invfact[1] = 1;
  for(int i = 2; i<LIM; ++i) {
    fact[i] = (fact[i-1] * i) % MOD;
    invfact[i] = (invfact[i-1] * inv[i]) % MOD;
  }

  cin >> n;
  adj.resize(n);
  nsz.resize(n);
  mer.resize(n);
  full.resize(n);
  for(int i = 0; i<n-1; ++i) {
    int u, v; cin >> u >> v;
    u--; v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  dfs1(0, -1);
  dfs2(0, -1);
  for(int i = 0; i<n; ++i) {
    cout << full[i] << "\n";
  }
}


Measured memory_bytes: 50676
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ____Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int x = int.Parse(input[0]);
            int t = int.Parse(input[1]);

            Console.WriteLine(Math.Max(x - t, 0));

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    char c;
    cin>>c;
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 3648
n,q = map(int,input().split())
m = [[] for i in range(n)]
for _ in range(n-1):
   a,b = map(int,input().split())
   m[a-1].append(b-1)
   m[b-1].append(a-1)

from collections import defaultdict
dic = defaultdict(int)
for _ in range(q):
   p,x = map(int,input().split())
   dic[p-1] += x

ans = [0 for i in range(n)]
ans[0] = dic[0]

used = [0 for i in range(n)]
used[0] = 1
quu = [0]
while quu:
   k = quu.pop()
   for l in m[k]:
      if used[l] == 0:
         used[l] = 1
         quu.append(l)
         ans[l] = ans[k] + dic[l]

for i in ans:
   print(i)

Measured memory_bytes: 120524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		
		String board [][] = new String [H+1][W+1];
		
		for (int i=0; i<H; i++) {
			String S = sc.next();
			board [i] = S.split("");
		}
		
		
		
		int dx [] = new int [] {1, 0, -1, 0, 1, -1, -1, 1};
		int dy [] = new int [] {0, 1, 0, -1, 1, 1, -1, -1};
		
		
		for (int i = 0; i < H; i++) {
			
			for (int j = 0; j < W; j++) {
				if (board[i][j].equals("#")){
					System.out.print('#');
					continue;
				}
			
				int num = 0;
				for (int d = 0; d < 8; d++) {
					int ni = i + dx[d];
					int nj = j + dy[d];
			
					if (ni<0 || H<=ni)
						continue;
					
					if (nj<0 || W<=nj)
						continue;
					
					if (board[ni][nj].equals("#"))
						num++;
				}
				
				//System.out.println(i+ " : " + j+ " : " + num);
				System.out.print(num);
			
			}
			System.out.println();
		}
		
		sc.close();
	}
}


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

#define ll long long
#define ar array

struct op {
	char c;
	int i, j, k;
};

const int A=30;
vector<op> ans;
bool debug=0;
ll a[200000];

void add(int i, int j, int k) {
	if(debug)
		a[k]=a[i]+a[j];
	else
		ans.push_back({'+', i, j, k});
}

void cmp(int i, int j, int k) {
	if(debug)
		a[k]=a[i]<a[j];
	else
		ans.push_back({'<', i, j, k});
}

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

	if(debug)
		cin >> a[0] >> a[1];
	cmp(2, 0, 3);
	cmp(2, 1, 4);
	add(3, 4, 5);
	cmp(2, 5, 3);
	for(int i=1; i<A; ++i) {
		add(3+i-1, 3+i-1, 3+i);
		//cout << a[3+i] << endl;
	}
	for(int i=A-1; ~i; --i) {
		add(33, 3+i, 34);
		//a[34] <= a[0]
		cmp(0, 34, 35);
		//a[35] should be 0 if add
		cmp(35, 3, 36);
		//a[36] should be 1 if add
		add(36, 6969, 37);
		//update a so far
		for(int k=0; k<i; ++k)
			add(37, 37, 37);
		add(33, 37, 33);
		//need a[<=33], a[36]
		//used up to 37
		//a[38]=0 b so far
		cmp(3, 6969, 38);
		for(int j=A-1; ~j; --j) {
			add(38, 3+j, 39);
			//a[39] <= a[1]
			cmp(1, 39, 40);
			//a[40] should be 0 if add
			cmp(40, 36, 41);
			//a[41] should be 1 if add for both a and b
			add(41, 6969, 42);
			//update b so far
			for(int k=0; k<j; ++k)
				add(42, 42, 42);
			add(38, 42, 38);
			for(int k=0; k<i; ++k)
				add(42, 42, 42);
			add(2, 42, 2);
		}
	}
	if(debug)
		cout << a[2];
	else {
		cout << ans.size() << "\n";
		for(op o : ans)
			cout << o.c << " " << o.i << " " << o.j << " " << o.k << "\n";
	}
}

Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <cstring>
#include <iomanip>


using namespace std;

int n;

int main() {
  cin >> n;

  int count[3] = {0,0,0};
  for(int i = 0; i < n; i++) {
    int s;
    cin >> s;
    count[s-1]++;
  }

  double dp_prev[n+1][n+1];
  double dp[n+1][n+1];

  for(int k = 0; k <= count[2]; k++) {
    memset(dp, 0, sizeof(dp));
  for(int j = 0; j <= n; j++) {
  for(int i = 0; i <= n; i++) {
    double trays = i+j+k;
    if(trays == 0.0) {
      dp[i][j] = 0.0;
      continue;
    }
    dp[i][j] = (1.0*n)/trays;
    if(i > 0) {dp[i][j] += (1.0*i)/trays*dp[i-1][j];}
    if(j > 0) {dp[i][j] += (1.0*j)/trays*dp[i+1][j-1];}
    if(k > 0) {dp[i][j] += (1.0*k)/trays*dp_prev[i][j+1];}
  }}
    std::copy(&dp[0][0], &dp[0][0]+sizeof(dp)/sizeof(dp[0][0]),&dp_prev[0][0]);
  }

  std::cout << std::fixed;
  std::cout << std::setprecision(10);

  cout << dp_prev[count[0]][count[1]] << endl;
}


Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC85_2
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] d = new int[N];
            for(int i = 0; i < N; ++i)
            {
                d[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(d);
            int c = 1;
            for (int i = 1; i < N; ++i)
            {
                if (d[i] != d[i - 1])
                {
                    c++;
                }
            }
            Console.WriteLine(c);
        }
    }
}


Measured memory_bytes: 11220
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e3 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	cin >> str;
	sort(str.begin(), str.end());
	if (str[0] == str[1] && str[2] == str[3] && str[1] != str[2]) puts("Yes");
	else puts("No");
	return 0;
}

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

int main(){
	char str1[51];
	char str2[51];

	for(int i = 0; i < 51; ++i){
		str1[i] = 0;
		str2[i] = 0;
	}

	cin >> str1;
	cin >> str2;

	for(int i = 0; i < 51; ++i){
		if(str2[i] != 0){
			cout << str1[i];
			cout << str2[i];
		}else{
			if(str1[i] != 0){
				cout << str1[i];
			}else{}
			break;
		}
	}

	cout << "\n";
	
	return 0;
}
			

Measured memory_bytes: 256
//File Name: code_festival_2017_quala_c.cpp
  //Created Time: 2017年09月30日 星期六 21时42分35秒
                                   
#include <bits/stdc++.h>
using namespace std;
int a[26];
char str[105];

bool solve(int n,int m){
	if(n % 2 == 0 && m % 2 == 0){
		for(int i(0);i<26;++i){
			if(a[i] % 4)
				return false;
		}
	}
	else if(n % 2 && m % 2){
		int mod2(0),mod1(0);
		for(int i(0);i<26;++i){
			if(a[i] % 4 == 2) ++mod2;
			else if(a[i] % 4 == 1) ++mod1;
			else if(a[i] % 4 == 3) ++mod1,++mod2;
		}
		if(mod1 == 1 && mod2 <= (n / 2 + m / 2))
			return true;
		else 
			return false;
	}
	else{
		if(n % 2) swap(n,m);
		int mod2(0),mod13(0);
		for(int i(0);i<26;++i){
			if(a[i] % 4 == 2) ++mod2;
			else if(a[i] % 4 != 0) ++mod13;
		}
		if(mod13 == 0 && mod2 <= n / 2) 
			return true;
		return false;
	}
}
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i(0);i<n;++i){
		scanf("%s",str);
		for(int j(0);j<m;++j)
			++a[str[j] - 'a'];
	}
	if(solve(n,m)) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    int N, A;
    double T;
    cin >> N;
    cin >> T >> A;
    double H[1000];
    double pans = 10000000;
    int ans = 0;
    for(int i=0;i<N;i++){
        cin >> H[i];
        if(pans >= abs(T - H[i]*0.006-A)){
            ans = i+1;
        }
        pans = min(pans, abs(T - H[i]*0.006-A));
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int x = 0, y = 0, i = 0;

    while(1)
    {
        cin >> x >> y;
        if(((x == 0) && (y == 0)) || (i >= 3000))
        {
            break;
        }
        else
        {
            if(x > y)
            {
                cout << y << " " << x << endl;
            }
            else
            {
                cout << x << " " << y << endl;
            }
            i++;
        }
    }

    return 0;
}


Measured memory_bytes: 3064
MAX = 1000000
SQRT = 1000     # sqrt(MAX)
 
prime = [0] * MAX
 
def sieve():
    for i in range(3, MAX, 2):
        prime[i] = 1
    for i in range(3, SQRT, 2):
        if prime[i] == 1:
            for j in range(i*i, MAX, i):
                prime[j] = 0
 
sieve()
cnt = [0] * (MAX+1)
cnt[2] = f = 1
for i in range(3, MAX, 2):
    if prime[i]:
        f += 1;
    cnt[i] = cnt[i+1] = f
     
while True:
    try:
        print(cnt[int(input())])
    except EOFError:
        break


Measured memory_bytes: 23440
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

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

using namespace std;
typedef long long ll;

int main() {

    ll N;
    cin >> N;
    double a = 0.5;
    if(N%2 == 1) a = (N/2+1)/double(N);
    cout << fixed << setprecision(6) << a << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a, b, ans;
	char c;
	while (1)
	{
		scanf("%d %c %d", &a, &c, &b);
		if (c == '+') {
			ans = a + b;
		}
		else if (c == '-') {
			ans = a - b;
		}
		else if (c == '*') {
			ans = a*b;
		}
		else if (c == '/') {
			ans = a / b;
		}
		else if (c == '?') {
			return 0;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2672
n, k = map(int, input().split())

ans = 0

for i in range(n - k + 2):
    ans += (2 * n - k - i + 1) * (k + i) / 2 - (k + i - 1) * (k + i) / 2 + 1
    ans %= 1e9 + 7

print(int(ans))


Measured memory_bytes: 9180
#include <iostream>
#include <cctype>
#include <stdio.h>
#include <string>

int main()
{
	char ch;
	std::string str;
	while (1)
	{
		scanf("%c", &ch);
		if (ch == '\n')
		{
			str += '\n';
			break;
		}
		if (islower(ch))
		{
			str += (char)toupper(ch);
		}
		else if (isupper)
		{
			str += (char)tolower(ch);
		}
	}
	printf("%s", str.c_str());
	return 0;
}

Measured memory_bytes: 3304
import math
N, M = map(int, input().split())
ans = 1
for i in range(int(math.sqrt(M))):
    a = i+1
    if M%a != 0:
        continue
    b = M // a
    if M >= N * a:
        ans = max(ans, a)
    if M >= N * b:
        ans = max(ans ,b)
print(ans)

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

int main() {
  int A;
  cin >> A;
  int B;
  cin >> B;
  int C;
  cin >> C;
  
  if(A==5 && B==5 && C==7) cout << "YES" << endl;
  else if(A==5 && B==7 && C==5) cout << "YES" << endl;
  else if(A==7 && B==5 && C==5) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

using namespace std;
using Long = unsigned long;

Long gcd(Long a,  Long b) {
    if (b == 0)
        return a;

    return gcd(b, a % b);
}

Long lcm(Long a, Long b) {
    return a * b / gcd(a, b);
}


int main()
{
    Long A, B;
    Long C, D;
    Long L;
    Long minc, maxc, diffc;
    Long mind, maxd, diffd;
    Long minl, maxl, diffl;
    Long count;



    cin >> A >> B >> C >> D;
 
    if (A%C == 0) {
        minc = A/C;
    } else {
        minc = A/C+1;
    }
    //cout << A/C << " " << Long(ceil(A/C)) << endl;
    maxc = B/C;
    if (minc-1 == maxc) {
        diffc = 0;
    } else {
        diffc = maxc - minc + 1;
    }

   
    
    //cout << maxc << " " << minc << endl;
    
    if (A%D == 0) {
        mind = A/D;
    } else {
        mind = A/D+1;
    }
    maxd = B/D;
    if (mind-1 == maxd) {
        diffd = 0;
    } else {
        diffd = maxd - mind + 1;
    }
    //cout << "mind " << mind << " " << "maxd: " << maxd << endl;

    L = lcm(C, D);
    //cout << "L " << L << endl;
    if (A%L == 0) {
        minl = A/L;
    } else {
        minl = A/L+1;
    }
        maxl = B/L;
        if (minl-1 == maxl) {
            diffl = 0;
        } else {
            diffl = maxl - minl + 1;
        }
  
    count = (B-A+1) - (diffc+diffd-diffl);

    //cout << diffc << " " << diffd << " " << diffl << endl;
    cout << count << endl;


    return 0;



    
}

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

int main(void) {
	int N;
	vector<int> A;
	cin >> N;
	A.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];

	int sum = accumulate(A.begin(), A.end(), 0);
	int ans = sum - N;

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};
//vector<int> dy = {1, 1, 1, 0, -1, -1, -1, 0};
//vector<int> dx = {1, 0, -1, -1, -1, 0, 1, 1};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

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


int main(){
  ll N; cin >> N;
  vector<ll> d(N); rep(i, N) cin >> d[i];
  sort(d.begin(), d.end());

  ll l = d[N/2-1], r = d[N/2];
  cout << r - l << endl;



}


Measured memory_bytes: 1024
// {{{
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

ll N, X;

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

void init()
{
}

void solve()
{
    ll d = gcd(N, X);
    cout << 3*d*(X/d) + 3*(N-X-d) << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> X;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
int main(void){
	//端に追加することで行ける
	int n;cin>>n;
	string ue;
	string st;
	string emp=".",use="#";
	string c;
	while(-1){
		cout<<'.'<<ue<<endl;
		cout<<'.'<<st<<endl;
		cin>>c;if(c=="T"){ue=emp+ue;st=emp+st;continue;}
		if(c=="end"){RE;}
		cout<<'.'<<ue<<endl;
		cout<<'#'<<st<<endl;
		cin>>c;if(c=="T"){ue=emp+ue;st=use+st;continue;}
		if(c=="end"){RE;}
		cout<<'#'<<ue<<endl;
		cout<<'.'<<st<<endl;
		cin>>c;if(c=="T"){ue=use+ue;st=emp+st;continue;}
		if(c=="end"){RE;}
		cout<<'#'<<ue<<endl;
		cout<<'#'<<st<<endl;
		cin>>c;if(c=="T"){ue=use+ue;st=use+st;continue;}
		if(c=="end"){RE;}
		break;
	}
	while(-1){
		cout<<ue<<'.'<<endl;
		cout<<st<<'.'<<endl;
		cin>>c;if(c=="T"){ue=ue+emp;st=st+emp;continue;}
		if(c=="end"){RE;}
		cout<<ue<<'.'<<endl;
		cout<<st<<'#'<<endl;
		cin>>c;if(c=="T"){ue=ue+emp;st=st+use;continue;}
		if(c=="end"){RE;}
		cout<<ue<<'#'<<endl;
		cout<<st<<'.'<<endl;
		cin>>c;if(c=="T"){ue=ue+use;st=st+emp;continue;}
		if(c=="end"){RE;}
		cout<<ue<<'#'<<endl;
		cout<<st<<'#'<<endl;
		cin>>c;if(c=="T"){ue=ue+use;st=st+use;continue;}
		if(c=="end"){RE;}
		break;
	}
	return 0;
}

Measured memory_bytes: 1612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		if(N<=M) {
			pl(N);		//燐寸が潤沢にあるときは、人が来るたびにつけて消せばいい
		}
		else {		//燐寸が少ない時は効率的にやらないといけない
			M--;	//開始時に着ける
			int[] hito=new int[N];
			int time=0;
			for(int i=0; i<N; i++) {
				hito[i]=sc.nextInt();
			}
			time=hito[N-1]+1-hito[0];
			int[] diff=new int[N-1];
			for(int i=0; i<N-1; i++) {
				diff[i]=hito[i+1]-hito[i];
			}
			Arrays.sort(diff);
			for(int i=0; i<M; i++) {
				time-=diff[N-2-i];
				time++;
			}
			pl(time);
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 44152
/*
 * FileName:     naive_string_search
 * CreatedDate:  2020-04-03 01:25:12 +0900
 * LastModified: 2020-04-03 01:40:36 +0900
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
    int i,j;
    char P[1000];
    char T[1000];
    scanf("%s",T);
    scanf("%s",P);
    for(i=0;i<strlen(T);i++){
        for(j=0;j<strlen(P);j++){
            if(T[i+j]!=P[j]){
                break;
            }
        }
        if(j==strlen(P)){
            printf("%d\n",i);
        }
    }

    return 0;
}



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

int main() {
    int K, T; cin >> K >> T;
    vector<int> a(T);
    rep(i, T){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    int total = 0;
    rep(i, T-1){
        total += a[i];
    }

    if(total < a[T-1] - 1){
        cout << a[T-1] - 1 - total << endl; 
    } else {
        cout << 0 << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3604