akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);



signed main(){
  string str;cin >> str;
  int n = str.size();
  map<char, int> mp;
  rep(i,n){
    mp[str[i]-'A']++;
  }
  for(auto x: mp){
    if(mp.size() != 2 or x.se != 2){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}






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

#ifdef INPUT
#include <sstream>
stringstream input(R"(
6 6
#####.
#.#.##
####.#
.#..#.
#.##..
#.#...
)");
#define cin input
#endif

int main()
{
	int h, w;
	cin >> h >> w;

	string str_a, str_b, str_c;
	cin >> str_b >> str_c;
	str_a = string(w+2,'.');
	str_b = "." + str_b + ".";
	str_c = "." + str_c + ".";

	for (int i=1; i<=h; i++)
	{
		for (int j=1; j<=w; j++)
		{
			if (str_b[j] != '#')
			{
				int sum = 0;
				if (str_a[j-1] == '#')
					sum++;
				if (str_a[j] == '#')
					sum++;
				if (str_a[j+1] == '#')
					sum++;
				if (str_b[j-1] == '#')
					sum++;
				if (str_b[j+1] == '#')
					sum++;
				if (str_c[j-1] == '#')
					sum++;
				if (str_c[j] == '#')
					sum++;
				if (str_c[j+1] == '#')
					sum++;
				
				str_b[j] = '0' + sum;
			}
		}
		cout << str_b.substr(1,w) << endl;

		str_a = str_b;
		str_b = str_c;

		if(i < h-1)
		{
			cin >> str_c;
			str_c = "." + str_c + ".";
		}
		else
			str_c = string(w+2,'.');
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<int, int> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };


int main() {

	int a, b;
	cin >> a >> b;

	for (int i = 1; i < 1001; i++) {
		int ei = i * 0.08;
		int ten = i * 0.1;
		if (ei == a && ten == b) {
			cout << i << endl;
			break;
		}
		if (i == 1000) {
			cout << -1 << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
a, b, c, k = map(int, input().split())
if k % 2 == 0:
    if abs(a-b) >= 10**18:
        print('Unfair')
    else:
        print(a-b)
else:
    if abs(b-a) >= 10**18:
        print('Unfair')
    else:
        print(b-a)


Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1000000007LL;
vector<int> G[5000];
ll dp[5000][5001][2];
ll dp2[2][5001][2];
int subtree[5000];
ll fact[5001];
void calc(int v, int p) {
	subtree[v] = 1;
	for (int to : G[v]) {
		if (to == p) continue;
		calc(to, v);
		subtree[v] += subtree[to];
	}
}
void solve(int v, int p) {
	int size = 1;
	int idx = 0;
	for (int to : G[v]) {
		if (to == p) continue;
		solve(to, v);
	}
	memset(dp2, 0, sizeof(dp2));
	dp2[0][1][0] = 1;
	for (int to : G[v]) {
		if (to == p) continue;
		for (int i = 1; i <= size; i++) {
			for (int j = 1; j <= subtree[to]; j++) {
				ll add = (dp2[idx][i][0] * dp[to][j][0]) % MOD;
				(add += (dp2[idx][i][1] * dp[to][j][1]) % MOD) %= MOD;
				(dp2[idx ^ 1][i][1] += (add*fact[j]) % MOD) %= MOD;
				add = (dp2[idx][i][0] * dp[to][j][1]) % MOD;
				(add += (dp2[idx][i][1] * dp[to][j][0]) % MOD) %= MOD;
				(dp2[idx ^ 1][i][0] += (add*fact[j]) % MOD) %= MOD;
				(dp2[idx ^ 1][i + j][0] += (dp2[idx][i][0] * dp[to][j][0]) % MOD) %= MOD;
				(dp2[idx ^ 1][i + j][0] += (dp2[idx][i][1] * dp[to][j][1]) % MOD) %= MOD;
				(dp2[idx ^ 1][i + j][1] += (dp2[idx][i][1] * dp[to][j][0]) % MOD) %= MOD;
				(dp2[idx ^ 1][i + j][1] += (dp2[idx][i][0] * dp[to][j][1]) % MOD) %= MOD;
			}
		}
		for (int i = 1; i <= size; i++) dp2[idx][i][0] = dp2[idx][i][1] = 0;
		size += subtree[to];
		idx ^= 1;
	}
	for (int i = 1; i <= size; i++) {
		dp[v][i][0] = dp2[idx][i][0];
		dp[v][i][1] = dp2[idx][i][1];
	}
}
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	fact[2] = 1;
	for (int i = 4; i <= N; i += 2) {
		fact[i] = (fact[i - 2] * (i - 1)) % MOD;
	}
	calc(0, -1);
	solve(0, -1);
	ll ans = 0;
	for (int i = 1; i <= subtree[0]; i++) {
		(ans += (dp[0][i][0] * fact[i]) % MOD) %= MOD;
		(ans += ((MOD - dp[0][i][1])*fact[i]) % MOD) %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 389888
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll A[110100];
ll diff[110100];
int main(){
    int N;
    cin >> N;
    ll asum = 0;
    ll ok = true;
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
        asum += a;
    }

    ll n = N*(N+1LL)/2;
    if(asum % n != 0) ok = false;
    ll K = asum / n;


    ll difsum = 0;
    REP(i,N-1){
        diff[i] = A[i+1] - A[i] - K;
        //if(diff[i] > 0) ok = false;
        //if(diff[i] % N != 0) ok = false;
        difsum += diff[i];
    }
    diff[N-1] = A[0] - A[N-1] - K;
    difsum += diff[N-1];

    if(difsum != -N*K) ok = false;

    for(int k = 0; k < N; k++){
        if(diff[k] == 0) continue;
        if(diff[k] > 0 || diff[k] % N != 0){
            ok = false;
            break;
        } 
    }


    if(ok)
        cout << "YES" << endl;
    else{
        cout << "NO" << endl;
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
vector<ll> divisor(ll x){
	vector<ll> div;
	for(int i=1;i*i<=x;i++){
		if(i*i!=x && x%i==0){
			div.pb(i);
			div.pb(x/i);
		}
		else if(x%i==0) div.pb(i);
	}
	return div;
}
vector<ll> vectorprime(ll x){
	vector<bool> is_prime(x+1);
	vector<ll> prime;
	rep(i,x+1) is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=x;i++){
		if(is_prime[i]){
			prime.pb(i);
		}
		for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
	}
	return prime;
}

//a,b x
int main(){
	ll N,H,W; cin>>N>>H>>W;
	ll cnt=0;
	rep(i,N){
		ll A,B; cin>>A>>B;
		if(A>=H && B>=W) cnt++;
	}
	cout<<cnt;
}

Measured memory_bytes: 256
W,H,N=map(int,input().split())

ans = [[0 for i in range(W)] for j in range(H)]

field=[]
for i in range(N):
    array = list(map(int,input().split()))
    field.append(array)

for i in range(N):
    state = field[i][2]

    if state == 1:
        for j in range(0,H):
            for k in range (0,field[i][0]):
                ans[j][k]=1
    if state == 2:
        for j in range(0,H):
            for k in range (field[i][0],W):
                ans[j][k]=1
    if state == 3:
        for j in range(H-field[i][1],H):
            for k in range (0,W):
                ans[j][k]=1
    if state == 4:
        for j in range(0,H-field[i][1]):
            for k in range (0,W):
                ans[j][k]=1
    
result=0
for i in range(H):
    result += str(ans[i]).count("0")

print(result)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define REP_R(i, n) for (int i = (n) - 1; (i) >= 0; -- (i))
#define ALL(x) begin(x), end(x)
using namespace std;
template <class T> inline void chmax(T & a, T const & b) { a = max(a, b); }

template <class Monoid>
struct segment_tree {
    typedef typename Monoid::underlying_type underlying_type;
    int n;
    vector<underlying_type> a;
    Monoid mon;
    segment_tree() = default;
    segment_tree(int a_n, underlying_type initial_value = Monoid().unit(), Monoid const & a_mon = Monoid()) : mon(a_mon) {
        n = 1; while (n < a_n) n *= 2;
        a.resize(2 * n - 1, mon.unit());
        fill(a.begin() + (n - 1), a.begin() + ((n - 1) + a_n), initial_value); // set initial values
        REP_R (i, n - 1) a[i] = mon.append(a[2 * i + 1], a[2 * i + 2]); // propagate initial values
    }
    void point_set(int i, underlying_type z) { // 0-based
        a[i + n - 1] = z;
        for (i = (i + n) / 2; i > 0; i /= 2) { // 1-based
            a[i - 1] = mon.append(a[2 * i - 1], a[2 * i]);
        }
    }
    underlying_type range_concat(int l, int r) { // 0-based, [l, r)
        underlying_type lacc = mon.unit(), racc = mon.unit();
        for (l += n, r += n; l < r; l /= 2, r /= 2) { // 1-based loop, 2x faster than recursion
            if (l % 2 == 1) lacc = mon.append(lacc, a[(l ++) - 1]);
            if (r % 2 == 1) racc = mon.append(a[(-- r) - 1], racc);
        }
        return mon.append(lacc, racc);
    }
};
struct plus_monoid {
    typedef int underlying_type;
    int unit() const { return 0; }
    int append(int a, int b) const { return a + b; }
};

int policy_1(int n, vector<int> const & a, vector<int> const & b) {
    int b_max = *max_element(ALL(b));
    segment_tree<plus_monoid> l(b_max + 1);
    segment_tree<plus_monoid> r(b_max + 1);
    REP (i, n) {
        l.point_set(b[i], l.range_concat(b[i], b[i] + 1) + 1);
        r.point_set(a[i], r.range_concat(a[i], a[i] + 1) + 1);
    }
    int result = 0;
    REP (i, n) {
        chmax(result, n - l.range_concat(0, a[i] + 1) - r.range_concat(b[i], b_max + 1));
    }
    return result;
}

int policy_2(int n, vector<int> const & a, vector<int> const & b) {
    int b_max = *max_element(ALL(b));
    vector<int> imos(b_max + 1);
    REP (i, n) {
        imos[a[i]] += 1;
        imos[b[i]] -= 1;
    }
    REP (x, b_max) {
        imos[x + 1] += imos[x];
    }
    return *max_element(ALL(imos));
}

int main() {
    // input
    int n; scanf("%d", &n);
    vector<int> a(n), b(n);
    REP (i, n) scanf("%d%d", &a[i], &b[i]);
    // solve
    int s1 = policy_1(n, a, b);
    int s2 = policy_2(n, a, b);
    // output
    printf("%d %d\n", s1, s2);
    return 0;
}

Measured memory_bytes: 6500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
/*
string S_str[H];
cins(S_str, S_str + H);
S_str[i][j];
*/
inline int at(ll x, int k){ return (x >> k) & 1; }
#define rep(i, n) for(ll i = 0; i < n; i++)


int main(){
  int n,m;
  cin >> n>>m;
  vector<int> a;
  rep(i,n){
    int temp;
  cin >> temp;
  a.push_back(temp);
}
  sort(a.begin(),a.end());
  if(a[n-m]*4*m<accumulate(a.begin(), a.end(), 0)){
    cout << "No"<< endl;
  }
  else{
    cout <<"Yes"<< endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        Integer l[] = new Integer[N];
        for (int i = 0; i < N; i++) {
            l[i] = sc.nextInt();
        }
        Arrays.sort(l, Comparator.reverseOrder());
        Integer maxLen = 0;
        for (int i = 0; i < K; i++) {
            maxLen += l[i];
        }
        System.out.println(maxLen);
    }
}

Measured memory_bytes: 22740
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b[ohara], c, d, tmp, m, h, w, x, y, sum[ohara], k, q;
ll sum2[ohara];
ll now_a, now_b;

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

  cin >> n >> m >> k;
  rep(i, n) cin >> a[i], sum[i] = a[i];
  rep(i, m) cin >> b[i], sum2[i] = b[i];
  rrep(i, 1, n) sum[i] += sum[i - 1];
  rrep(i, 1, m) sum2[i] += sum2[i - 1];
  rep(i, n + 1) {
    ll time = 0, yok;
    if (i >= 1) time = sum[i - 1];
    yok = k;
    yok -= time;
    if (yok < 0) continue;
    ll le = 0, ri = m - 1, mid;
    while (ri - le > 1) {
      mid = (le + ri) / 2;
      if (sum2[mid] < yok)
        le = mid;
      else
        ri = mid;
    }
    // debug(yok);
    cnt = i;
    cnt += le;
    rrep(j, le, ri + 1) {
      if (yok - sum2[j] < 0) break;
      cnt++;
    }
    ans = max(ans, cnt);
  }
  Cout(ans);
  return 0;
}


Measured memory_bytes: 9864
using System;

namespace beginer
{
    class Program
    {
        static void Main(string[] args)
        {
            int K=int.Parse(Console.ReadLine());
            string res="";
            for(int i=0;i<K;i++){
                res+="ACL";
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 27464
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  int n;
  cin >> n;
  int d[1024]={};
  REP(i,n) cin >> d[i];
  int exist[10240]={};
  REP(i,n) ++exist[d[i]];
  REP(i,n-1) ++exist[d[i]*10+d[i+1]];
  REP(i,n-2) ++exist[d[i]*100+d[i+1]*10+d[i+2]];

  int answer=0;
  while(exist[answer]) answer++;
  cout << answer << endl;
  return 0;

}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

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

int main(){
    ll n,ans=0;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        if(a[i]%2==1&&i%2==0) ans++;
    }
    cout << ans << endl;

    return 0;
}











Measured memory_bytes: 3596
K, S = list(map(int,input().split()))
count = 0
#ZはXとYが決まった時点で自動的に決まる。
for X in range(K+1):
  for Y in range(K+1):
    Z = S - X - Y 
#範囲が条件ないならOK
    if 0 <= Z and Z <= K:
        count += 1
print(count)

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

int main() {
  // ここにプログラム
  string sss;
  int ans = 0;
  cin >> sss;
  if (sss.at(0) == '2') {
    ans++;
  }
    if (sss.at(1) == '2') {
    ans++;
  }
    if (sss.at(2) == '2') {
    ans++;
  }
    if (sss.at(3) == '2') {
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

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

//素因数分解
map<ll, ll> prime_factor(ll n)
{
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++)
	{
		while (n % i == 0)
		{
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1)
		ret[n] = 1;
	return ret;
}

int main() {
	int n;cin>>n;
	ll ans = 0;
	vector<int> v(n);
	rep(i,n){
		cin>>v[i];
	}
	sort(all(v));
	rep(i,n){
		for(int k = i+1; k < n; k++){
			for(int l = n-1; l > k; l--){
				if(v[i]+v[k] <= v[l])
					continue;
				ans += l-k;
				break;
			}
		}
	}
	cout << ans << endl;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//----------------------------------------------

string s;


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

	cin >> s;
	int n = s.size();
	s = "#" + s;
	if (s[1] == '0' || s[n] == '1') {
		cout << -1 << endl;
		return 0;
	}
	int l = 1, r = n - 1;
	while(l < r) {
		if (s[l] != s[r]) {
			cout << -1 << endl;
			return 0;
		}
		l++, r--;
	}
	int joint = 1;
	FOR(i, 1, n) {
		if (s[i] == '1') {
			cout << joint << ' ' << i + 1 << endl;
			joint = i + 1;
		}
		else {
			cout << joint << ' ' << i + 1 << endl;
		}
	}


    return 0;
}




Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int s; cin >> s;
    int ans = 753;
    for(s; s>100; s/=10) chmin(ans,abs(s%1000-753));
    out(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

stack<ll> st;

int main()
{
    cin >> s;
    s[3]='8';
    cout << s << Endl;
}

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

    int n, y, a, b, k;
    scanf("%d %d", &n, &y);

    y /= 1000;
    for(a = 0; a <= n; a++){ // 10000円の枚数を 0 〜 N で調べる
        for(b = 0; b <= n - a; b++){ // 5000円の枚数を 0 〜 N-a で調べる
            k = n - a - b; // 1000円の枚数は決まる
            if(10 * a + 5 * b + k == y){
                printf("%d %d %d\n", a, b, k);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string.h>

using namespace std;

int main() {

	int a, b;

	while (cin >> a >> b, a != 0 && b != 0) {

		int dp[17][17] = { 0 };

		memset(dp, 0, sizeof dp);

		int n;

		cin >> n;

		dp[1][1] = 1;

		for (int i = 1; i <= n; i++) {

			int x, y;

			cin >> x >> y;
			dp[x][y] = -1;
		}

		for (int i = 1; i <= a; i++) {
			for (int j = 1; j <= b; j++) {

				if (dp[i][j] != -1) {
					if (j != 1 && dp[i][j - 1] != -1) {
						dp[i][j] += dp[i][j - 1];
					}

					if (i != 1 && dp[i - 1][j] != -1) {
						dp[i][j] += dp[i - 1][j];
					}
				}
			}
		}

		cout << dp[a][b] << endl;

	}

	return 0;

}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int a[100];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string w;cin>>w;
    for(char c : w){
        a[c-'a']++;
    }
    bool isok = true;
    for(int i=0; i<100; i++){
        if(a[i]%2 == 1) isok = false;
    }
    cout<<(isok ? "Yes":"No")<<endl;
    return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int l = a + b, r = c + d;
  if (l > r) cout << "Left" << endl;
  else if (l == r) cout << "Balanced" << endl;
  else cout << "Right" << endl;
  return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n; cin >> n;
	vector<LL> a(n);

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

	sort(a.begin(), a.end());

	vector<LL> s(n+1);
	s[0] = 0;

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

	LL ans = 1;

	for (int i = n-2; i >=0; i--) {
		if (s[i+1] * 2 >= a[i + 1])ans++;
		else {
			cout << ans << endl;
			return 0;
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC087_A();
        }

        static void ABC087_A()
        {
            var X = int.Parse(Console.ReadLine());
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            Console.WriteLine(X - A - ((int)((X - A) / B) * B));
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int n,m;cin>>n>>m;
	int a;bool chk=1;
	for(int i=0;i<m;i++){
		cin>>a;
		n-=a;
		if(n<0){
			chk=0;
			break;
		}
	}
	if(chk) cout<<n<<endl;
	else cout<<-1<<endl;
}
	


Measured memory_bytes: 3620
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    out(a << " " << b << " " << c);
}

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

using namespace std;

double calc(double va,double vb,double ta,double tb){
  return (ta*va+tb*vb)/(va+vb);
}

int main(){
  double T,D,ta,tb,da,db;
  cin >> T >> D >> ta >> tb >> da >> db;
  double res = 1e9;
  for(int i = 0 ; i < 1010 ; i++){
    for(int j = 0 ; j < 1010 ; j++){
      double va = da*i, vb = db*j;
      if(i == 0 && j == 0){ continue; }
      if(va + vb > D){ continue; }
      res = min(res,abs(T-calc(va,vb,ta,tb)));
    }
  }
  printf("%.10f\n",res);
  return 0;
}

Measured memory_bytes: 1240
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);

		long n=sc.nextLong();		//N個のボール
		long a=sc.nextLong();		//青いボール
		long b=sc.nextLong();		//赤いボール

		long sum=n / (a+b)*a;
		long result=n % (a+b);

		if(result>=a) {
			sum+=a;
		}else {
			sum+=result;
		}
		System.out.println(sum);
		sc.close();
	}
}


Measured memory_bytes: 24020
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    a = list(map(int, input().split()))

    count = 0
    ball = [0] * (N+1)

    for i in range(N, 0, -1):
        tmp = 0
        for j in range(i*2, N+1, i):
            tmp += ball[j]
        if tmp%2 != a[i-1]:
            ball[i] = 1
            count += 1
    
    print(count)
    if count > 0:
        for i in range(1, N+1):
            if ball[i] == 1:
                print(i, end=" ")
        print()


if __name__ == "__main__":
    main()


Measured memory_bytes: 7120
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_coins(void) {
	int a, b, c,x;
	cin >> a >> b >> c>>x;

	int cnt = 0;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			int k = x - 500 * i - 100 * j;
			if (k < 0) break;
			if (k % 50 == 0) {
				if (k / 50 <= c) cnt++;
			}
		}
	}

	cout << cnt << endl;

}

int main()
{
	b_coins();
    return 0;
}

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

bool check(int i,int j,int n,int m){
	if(i>=0 && i<n && j>=0 && j<m)
		return false;
	return true;
}


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


	int p,q,x,y;
	cin >> x >> y;
	p=x;
	q=y;

	string s1,s2;
	cin >> s1 >> s2;

	for(int i=0;i<l;i++){
		if(s1[i]=='U'){
			p--;
		}

		if(p<=0){
			cout << "NO" << "\n";
		//	cout << "%\n";
			return 0;
		}

		if(s2[i]=='D'){
			if(p<n)
			p++;
		}
		
	}
	p=x;
	q=y;

	for(int i=0;i<l;i++){
		if(s1[i]=='L'){
			q--;
		}


		if(q<=0){
			cout << "NO" << "\n";
		//	cout << "4%\n";

			
			return 0;
		}

		if(s2[i]=='R'){
			if(q<m)
			q++;
		}
	}
	p=x;
	q=y;

	for(int i=0;i<l;i++){
		if(s1[i]=='R'){
			q++;
		}

		if(q>m){
			cout << "NO" << "\n";
		//	cout << "1%\n";
			
			return 0;
		}

		if(s2[i]=='L'){
			if(q>1)
				q--;
		}
		
	}
	p=x;
	q=y;

	for(int i=0;i<l;i++){
		if(s1[i]=='D'){
			p++;
		}

		if(p>n){
			cout << "NO" << "\n";
		//	cout << "22%\n";

			return 0;
		}
		
		if(s2[i]=='U'){
			if(p>1)
				p--;
		}
		
	}

	cout << "YES" << "\n";



	return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	
	vector<int> x(n);
	for(int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	
	long long ans = 0;
	if(x[0] >= 0)
	{
		cout << x[k - 1] << endl;
	}
	else if(x[n - 1] <= 0)
	{
		cout << -x[n - k] << endl;
	}
	else
	{
		for(int i = 0; i < n - k + 1; i++)
		{
			long long minus = x[i] <= 0 ? x[i] : 0;
			long long plus = 0 < x[i + k - 1] ? x[i + k - 1] : 0;
			
			long long tmp = abs(minus) * 2 + plus < abs(minus) + plus * 2 ? abs(minus) * 2 + plus : abs(minus) + plus * 2;
			if(i == 0)
			{
				ans = tmp;
			}
			else
			{
				if(ans > tmp)
				{
					ans = tmp;
				}
			}
		}
		
		cout << ans << endl;
	}
	
    return 0;
}

Measured memory_bytes: 640
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val s = next().toList()
    println(s.map { if (it == '+') 1 else -1 }.sum())
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 31996
N=int(input())
A=list(map(int,input().split()))


x=[0]*N
y=[0]*N
z=[0]*N
for i in range(N):
     j=A[i]
     x[j-1] += 1

for i in range(N):
    j=i
    y[i]=(x[j]*(x[j]-1))//2
    if x[j]==0:
        z[i]=0
    else:
        z[i]=((x[j]-2)*(x[j]-1))//2

yy=sum(y)
zz=sum(z)


for i in range(N):
    j=A[i]
    print(yy-y[j-1]+z[j-1])


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

int diff( int a, int b )
{
    int c = a - b;
    return c < 0 ? -c : c;
}

int main()
{
    int n;
    bitset<20> b;

    while( cin >> n )
    {
        if( !n )
            break;

        int* a = new int[n];

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

        int limit = 1;
        for( int i = 0; i < n; i++ )
            limit *= 2;

        int min = 1000000000;
        for( int i = 1; i < limit; i++ )
        {
            b = i;
            int s = 0;
            for( int i = 0; i < n; i++ )
                if( b[i] )
                    s += a[i];
            int d = diff( s, sum - s );
            if( min > d )
                min = d;
        }
        
        cout << min << endl;
        delete a;
    }
    return 0;
}


Measured memory_bytes: 3084
import statistics

N = int(input())
A = input().split()
A = list(map(int,A))
sa = 0
sa_list = []

for i in range(1,N+1):
	sa = A[i-1]-i
	sa_list.append(sa)

sa_list.sort()
if(len(sa_list)%2 != 0):
	b = statistics.median(sa_list)
	sum_As = 0
	for p in range(1,len(A)+1):
		sum_As += abs(A[p-1]-(b+p))
	print(sum_As)
else:
	b = statistics.median_low(sa_list)
	sum_As = 0
	for p in range(1,len(A)+1):
		sum_As += abs(A[p-1]-(b+p))
	
	b2 = statistics.median_high(sa_list)
	sum_As2 = 0
	for p in range(1,len(A)+1):
		sum_As2 += abs(A[p-1]-(b2+p))
	
	print(max(sum_As,sum_As2))

Measured memory_bytes: 27244
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r, g;
    cin >> r >> g;
    cout << 2 * g - r;
}


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

const int MAX = 300000;

using namespace std;
using namespace atcoder;

int op(int a, int b) { return max(a, b); }
int e() { return 0;}

int main() {
  int N, K;
  cin >> N >> K;
  
  segtree<int, op, e> seg(MAX + 1);
  
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    seg.set(A, seg.prod(max(A - K, 0), min(MAX, A + K) + 1) + 1);
  }
  
  cout << seg.all_prod() << endl;
  
  return 0;
}

Measured memory_bytes: 8560
#include <stdio.h>
#include <string.h>
#define N 1010
char T[N];
char P[N];
int main(){
    scanf("%s %s", T, P);
    int a = strlen(T);
    int b = strlen(P);
    for(int i = 0; i < a; i++){
        int flag = 1;
        if(i + b > a) break;
        for(int j = 0; j < b; j++){
            if(T[i + j] != P[j]){
                flag = 0;
                break;
            }
        }
        if(flag){
            printf("%d\n", i);
        }
    }
    return 0;
}


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

int comp(const void *p1,const void *p2);

int main(void){
  FILE *fp;
  int n,i;
  int t[10000];
  long long s=0;
  
  fp=stdin;//fopen("data.txt","r");
  while(fscanf(fp,"%d",&n) && n>0){
    s=0;
    for(i=0;i<n;i++) fscanf(fp,"%d",&t[i]);
    //fclose(fp);
    qsort(t,n,sizeof(int),comp);
  
    for(i=1;i<n;i++) s+=(n-i)*t[i-1];
    printf("%lld\n",s);
  }
  return 0;
}

int comp(const void *p1,const void *p2){
  int n1,n2;
  n1=*(const int *)p1;
  n2=*(const int *)p2;
  return n1-n2;
}

Measured memory_bytes: 724
// 2017/07/03 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int E, Y;
	cin >> E >> Y;

	switch(E){
	case 0:
		if(1868<=Y && Y<=1911){
			cout << 'M' << Y-1867 << endl;
		}
		else if(1912<=Y && Y<=1925){
			cout << 'T' << Y-1911 << endl;
		}
		else if(1926<=Y && Y<=1988){
			cout << 'S' << Y-1925 << endl;
		}
		else if(1989<=Y && Y<=2016){
			cout << 'H' << Y-1988 << endl;
		}
		break;
	case 1:
		cout << Y+1867 << endl;
		break;
	case 2:
		cout << Y+1911 << endl;
		break;
	case 3:
		cout << Y+1925 << endl;
		break;
	case 4:
		cout << Y+1988 << endl;
		break;
	}

	return 0;
}

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

#define en "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fs first
#define sc second
#define size(a) (int) a.size()
#define deb(x) cerr << #x << " => " << x << en
#define debp(a) cerr << #a << " => " <<"("<<a.fs<<", "<<a.sc<<") " << en;
#define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en;
#define debpa(x) cerr << #x << en; for (auto a : x)cerr<<"("<<a.fs<<", "<<a.sc<<") "; cerr << en;
#define debm(x) cerr << #x << en; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << en;}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m;
while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2)
#define mul(a, b) ((a % HELL) * (b % HELL)) % HELL

int32_t main() { fastio;
	int n; cin >> n;
	vector<pii> arr(n);
	vector<pii> events;
	for (int i = 0; i < n; i++) {
		cin >> arr[i].fs >> arr[i].sc;
		events.pb({ arr[i].fs, 1 });
		events.pb({ arr[i].sc, 2 });
	}
	sort(events.begin(), events.end());
	int res = 0;
	if (n & 1) {
		int ins = (n + 1) / 2;
		int start = -1, stop = -1;
		int curr = 0, rem = 0;
		for (auto e : events) {
			if (e.sc == 1) {
				curr++;
			} else {
				rem++;
			}
			if (start == -1 and curr == ins) {
				start = e.fs;
			}
			if (stop == -1 and rem == ins) {
				stop = e.fs;
			}
		}
		res = stop - start + 1;
	} else {
		int ins = n / 2;
		int curr = 0, rem = 0;
		int astart = -1, astop = -1, bstart = -1, bstop = -1;
		for (auto e : events) {
			if (e.sc == 1) {
				curr++;
			} else {
				rem++;
			}
			if (astart == -1 and curr == ins) {
				astart = e.fs;
			}
			if (bstart == -1 and curr == (ins + 1)) {
				bstart = e.fs;
			}
			if (astop == -1 and rem == ins) {
				astop = e.fs;
			}
			if (bstop == -1 and rem == (ins + 1)) {
				bstop = e.fs;
			}
		}
		res = bstop - bstart + 1 + astop - astart;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 14748
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

sum_A1 = sum(A1)
sum_A2 = sum(A2)

ans = 0

for i in range(N - 1):
    A1[i+1] += A1[i]

A2[0] += A1[0]

for i in range(N - 1):
    A2[i+1] += max(A1[i+1], A2[i])

print(A2[N - 1])

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

def dfs(s):
  if int(s) > n:
    return 0
  ret = 1 if all(s.count(c) > 0 for c in "753") else 0 # 数値に753が入っているか？
  for c in "753":
    ret += dfs(s+c)
  return ret
print(dfs("0"))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
//#define INF (1LL<<31)-1
//#define MOD 998244353
#define MOD 1000000007

int main(){
    string sa,sb,sc;
    cin>>sa>>sb>>sc;
    int ia=sa.length(),ib=sb.length(),ic=sc.length();
    int na=0,nb=0,nc=0;
    int t=0;//0,1,2
    while(1){
        if(t==0){//'a'=97;
            if(na==ia){
                cout<<"A"<<endl;
                break;
            }
            t=sa[na]-97;
            na++;
        }else if(t==1){
            if(nb==ib){
                cout<<"B"<<endl;
                break;
            }
            t=sb[nb]-97;
            nb++;
        }else{
            if(nc==ic){
                cout<<"C"<<endl;
                break;
            }
            t=sc[nc]-97;
            nc++;
        }
    }
}

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

int main()
{
  int N,W;scanf("%d %d",&N,&W);
  vector<int> v(N),w(N);
  vector<vector<int>> dp(N+1,vector<int>(W+1,0));
  for(int i=0;i<N;i++)scanf("%d %d\n",&v[i],&w[i]);
  for(int i=0;i<N;i++)for(int j=0;j<W+1;j++)
  {
    if(j-w[i]<0)dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
    else dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
  }
  printf("%d\n",dp[N][W]);
}


Measured memory_bytes: 6816
H,N = map(int,input().split())
A = list(map(int,input().split()))

A.sort()
#print(A)

MOVES = len(A)
NUM = MOVES
#print(MOVES)

count = 0
flag = 0

while(MOVES > 0):
  H -= A[MOVES-1]
  MOVES -= 1
  if(H < 1):
    print('Yes')
    flag = 1
    break

if(flag == 0):
  print('No')


Measured memory_bytes: 53188
S = input()
bit = 0
sum = 0
while bit < (1<<len(S)-1):
    b = 0
    keta = 0
    for i in range(len(S)):
        if bit & (1<<i):
            sum += b + int(S[len(S)-1-i])*(10**keta)
            b = 0
            keta = 0
        else:
            b += int(S[len(S)-1-i])*(10**keta)
            keta += 1
            if i == len(S) - 1:
                sum += b
    bit += 1
print(sum)


Measured memory_bytes: 3060
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>


using namespace std;

int main(void){
    string A, B;

    cin >> A >> B;

    A = A + B;

    int a = stoi(A);

    for(int i=0;i<=a;i++){
        if(i*i==a){
            cout << "Yes" << endl;
            return 0;
        }
        if(i*i > a){
            cout << "No" << endl;
            return 0;
        }
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int64_t N, P;
	cin >> N >> P;

	vector<pair<int64_t, int64_t>> v;
	for (int64_t i = 2; i * i <= P; i++) {
		if (P % i) continue;
		int64_t c = 0;
		while (P % i == 0) {
			c++;
			P /= i;
		}
		pair<int64_t, int64_t> p = { i,c };
		v.push_back(p);
	}
	if (P != 1) {
		pair<int64_t, int64_t> p = { P,1 };
		v.push_back(p);
	}

	int64_t ans = 1;
	for (int64_t i = 0; i < v.size(); i++) {
		int64_t p, c;
		tie(p, c) = v.at(i);
		//cout << p << ' ' << c << endl;
		for (int64_t j = 0; j < c / N; j++) ans *= p;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3628
# arc 100 D

def ruiseki(n,array):
    res = [0]*(n)
    for i in range(n):
        res[i] = res[i-1] + array[i]
    return res

n = int(input())
A = list(map(int,input().split()))
sa = ruiseki(n,A)

ans = 10**15
left_c = 0
right_c = 2
for center in range(1,n-1):
    while left_c+1 < center:
        if abs(sa[center]-2*sa[left_c]) > abs(sa[center]-2*sa[left_c+1]):
            left_c+=1
        else:
            break

    right_c = max(right_c, center+1)
    while right_c+1 < n-1:
        if abs(sa[-1] + sa[center] - 2*sa[right_c]) > abs(sa[-1] + sa[center] - 2*sa[right_c+1]):
            right_c+=1
        else:
            break
    
    x = max(sa[left_c], sa[center]-sa[left_c], sa[right_c]-sa[center], sa[-1]-sa[right_c])
    y = min(sa[left_c], sa[center]-sa[left_c], sa[right_c]-sa[center], sa[-1]-sa[right_c])
    ans = min(ans, x-y)

print(ans)


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n, d;
  cin >> n >> d;

  cout << (n+ 2*d)/(2*d +1) << "\n";

}


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

#define pb push_back
#define ll long long
#define maxn 100005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const ll mod =1e9+7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int cur[n+5] = {};
    vector<int>v[n+5];
    f1(n){
        fr(j,0,n-1){
            int add;
            cin >> add;
            v[i].pb(add);
        }
    }
    int d = 1;
    while(1){
        int f = 0;
        vector<pair<int,int> >st;
        f1(n){
            if(cur[i]==n-1)continue;
            int nxt = v[i][cur[i]];
            int nnxt = v[nxt][cur[nxt]];
            if(nnxt == i&&nxt<nnxt){
                st.pb({nxt,nnxt});
            }
        }
        if(!st.size()){
            cout<<-1<<endl;
            exit(0);
        }
        for(auto i:st){
            cur[i.F]++;
            cur[i.S]++;
        }
        f1(n){
            if(cur[i]!=n-1){
                f = 1;
                break;
            }
        }
        if(!f){
            cout<<d<<endl;
            exit(0);
        }
        d++;
    }
}

Measured memory_bytes: 6400