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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


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

  ll n; cin >> n;
  map<ll,ll> odd, even;
  vll a(n);

  rep(i, n) {
    cin >> a[i];
    if (i % 2) ++odd[a[i]];
    else ++even[a[i]];
  }

  ll x = n/2;
  if (si(odd) == si(even) && si(odd) == 1) {
    if (a[0] == a[1]) cout << x << endl;
    else cout << 0 << endl;
  } else if (si(odd) == 1) {
    ll mx = 0;
    for (auto e : even) chmax(mx, e.se);
    
    cout << x - mx << endl;
  } else if (si(even) == 1) {
    ll mx = 0;
    for (auto o : odd) chmax(mx, o.se);

    cout << x - mx << endl;
  } else {
    vpi e, o;
    for (auto a : even) e.eb(a.se, a.fi);
    for (auto b : odd) o.eb(b.se, b.fi);

    sort(all(e),greater<pii>());
    sort(all(o),greater<pii>());

    ll ans = inf;
    rep(i, 2) rep(j, 2) {
      if (e[i].se == o[j].se) continue;
      ll score = 0;

      rep(k, n) {
        if (k % 2 && o[j].se != a[k]) ++score;
        else if (k % 2 == 0 && e[i].se != a[k]) ++score;
      }

      chmin(ans, score);
    }

    cout << ans << endl;
  }

}


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

using namespace std;

#define fastio ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;

ll mult(ll a, ll b)
{
	ll mod = 1000000007;
	return (a % mod * b % mod) % mod;
}

int main()
{
	#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin); 
	freopen("output.txt", "w", stdout); 
	#endif	
	
	fastio;

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll maxi = 0;

	ll ans1 = a * c;
	ll ans2 = a * d;
	ll ans3 = b * c;
	ll ans4 = b * d;
	maxi = max(max(ans1, ans2), max(ans3, ans4));

	cout << maxi;

	return 0;

}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int a = sc.nextInt();

		int ans = (int)Math.ceil((double)h/a);

		System.out.println(ans);

		return;

	}

}



Measured memory_bytes: 21844
#coding: utf-8

def clacSumN(n):
    sum_n = 0
    for i in reversed(range(9)):
        sum_n += int(n / (10 ** i))
        n = n % (10 ** i)
    return sum_n

def check(n,sum_n):
    flag = not (n % sum_n)
    if flag == True:
        result = "Yes"
    else:
        result = "No"

    return result 

if __name__ == "__main__":
    n = int(input())
    sum_n = clacSumN(n)
    
    print(check(n,sum_n))

Measured memory_bytes: 3060
import sys

x,y=map(int,input().split())
T=x+y
MOD=10**9+7

def nCmMOD(A,B,Mod):
    num,den=1,1
    for i in range(B):
        num*=(A-i)
        den*=(i+1)
        num%=Mod
        den%=Mod
    return (num*pow(den,Mod-2,Mod))%Mod

if T%3!=0 or y/x<1/2 or y/x>2:
    print(0)
    sys.exit()
else:
    n=(2*y-x)//3
    m=(2*x-y)//3
    l=min(n,m)
    print(nCmMOD(n+m,l,MOD))

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

typedef long l;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define mp make_pair

const int DX[] = {1, 0, -1, 0, 1, 1, -1, -1}, DY[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

  int k;
  string s;

  cin >> k >> s;
  if (s.size() <= k) {
    cout << s;
  } else {
    REP(i, k) {
      cout << s[i];
    }
    cout << "...";
  }

  cout << endl;
}



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

using namespace std;
 
#define debug(s) cerr << #s << " = " << s << '\n'
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define ff first
#define ss second
typedef long long ll;

const int N = 10;
char g[N][N];
int n, m, k;
int row[N], col[N];

int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf(" %c", &g[i][j]);
    }
  }
  int ans = 0;
  for (int msk1 = 0; msk1 < (1 << n); ++msk1) {
    for (int i = 0; i < n; ++i) {
      if (msk1 & (1 << i)) row[i] = 1;
      else row[i] = 0;
    }
    for (int msk2 = 0; msk2 < (1 << m); ++msk2) {
      for (int j = 0; j < m; ++j) {
        if (msk2 & (1 << j)) col[j] = 1;
        else col[j] = 0;
      }
      int cnt = 0;
      for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
          if (!row[i] && !col[j]) {
            if (g[i][j] == '#') ++cnt;
          }
        }
      }
      if (cnt == k) ++ans;
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 3820
import sys
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))

dp = [0] * n

dp[0] = 0
dp[1] = dp[0] + abs(arr[1] - arr[0])

for i in range(2, len(arr)):
	dp[i] = min(dp[i - 1] + abs(arr[i - 1] - arr[i]), dp[i - 2] + abs(arr[i - 2] - arr[i]))

print(dp[len(arr) - 1])

Measured memory_bytes: 50288
// B.

#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, char *argv[])
{
	string a, b, c;
	cin >> a >> b;
	for (int i = 0; i < (int)b.length(); ++i) {
		c += a[i];
		c += b[i];
	}
	if (a.length() != b.length()) {
		c += a.back();
	}
	cout << c << endl;
	return 0;
}


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

ll mod = 1e9 + 7;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    ll cnt1 = 0, cnt2 = 0;
    for(int i=0; i<n; i++) {
        for(int j=i+1; j<n; j++) {
            if(a[i] > a[j]) cnt1++;
        }
    }
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            if(a[i] > a[j]) cnt2++;
        }
    }
    ll m1 = k;
    ll m2 = (k * (k - 1) / 2) % mod;
    cout << (cnt1 * m1 + cnt2 * m2) % mod<< endl;
}

Measured memory_bytes: 3600
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T, class U> void _W(const pair<T, U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
#define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
#define DEBUG(...)
#endif
int MOD = 1e9 + 7;
void ADD(LL& x, LL v) {x = (x + v) % MOD; if (x < 0)x += MOD;}
/*}}}*/
void solve() {
	LL N, K;
	R(N, K);
	N %= K;
	W(min(N, K - N));
}

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

#define MULTITEST 0
#if MULTITEST
	CASET {
		solve();
	}
#else
	solve();
#endif
	return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

string s;
int n;

bool solve(vector<int> v,int a,int b,int c){

    REP(i,n){
        if(v[a]==0)return false;

        v[a]--;
        int use =a;
        a=c;
        c=b;
        b=use;
    }
    return true;
}
int main(){
    cin>>s;
    n=s.size();
    vector<int> cnt(3,0);
    for(auto &c:s){
        cnt[c-'a']++;
    }
    if(solve(cnt,0,1,2)||solve(cnt,0,2,1)
       ||solve(cnt,1,2,0)||solve(cnt,1,0,2)
       ||solve(cnt,2,0,1)||solve(cnt,2,1,0)){
        cout<<"YES"<<endl;    
    }else cout<<"NO"<<endl;
    
    return 0;
}


Measured memory_bytes: 512
n, k = map(int, input().split())
mod = 998244353
d = [0] * (n + 1)
d[1] = 1
LR =[list(map(int, input().split())) for _ in range(k)]

for i in range(2, n+1):
  d[i] = d[i - 1]
  for l, r in LR:
    if i - l <= 0:
      continue
    d[i] = (d[i] + (d[i-l] - d[max(0,i-r-1)])) % mod
print((d[-1] - d[-2])%mod)

Measured memory_bytes: 75144
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve(){
    int n, q;
    cin >> n;
    int s[n];//array型
    rep(i, 0, n) cin >> s[i];
    cin >> q;
    ll ans = 0;
    rep(i, 0, q){
        int t;
        cin >> t;
        // STLのlower_boundを使う
        if(*lower_bound(s, s+n, t) == t) ans++;
        // lower_bound(配列先頭のイテレータ、配列最後のイテレータ、key)
        // 配列内で初めてkey以上となる要素のイテレータを返す
        // *をつけることで要素にアクセス
        // 見つからなければ一番右側を返す
    }
    cout << ans << endl;
}


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

    solve();
    return 0;
}



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

using vi = std::vector<int>;

int main()
{
	std::string s, t;
	std::cin >> s >> t;
	std::vector<vi> length_max(s.size() + 1, vi(t.size() + 1));
	for (unsigned int s_i{}; s_i < s.size(); s_i++)
		for (unsigned int t_i{}; t_i < t.size(); t_i++)
		{
			if (s[s_i] == t[t_i])
				length_max[s_i + 1][t_i + 1] = length_max[s_i][t_i] + 1;
			else
				length_max[s_i + 1][t_i + 1] = std::max(length_max[s_i][t_i + 1], length_max[s_i + 1][t_i]);
		}
	std::string ans;
	int s_i{(int)s.size()}, t_i{(int)t.size()};
	while (length_max[s_i][t_i])
	{
		if (s[s_i - 1] == t[t_i - 1])
		{
			ans.push_back(s[s_i - 1]);
			s_i--; t_i--;
		}
		else if (length_max[s_i][t_i] == length_max[s_i - 1][t_i])
			s_i--;
		else
			t_i--;
	}
	for (auto it{ans.rbegin()}; it != ans.rend(); it++)
		putchar(*it);
	putchar('\n');

	return 0;
}

Measured memory_bytes: 35584
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()
    
    n = int(input())
    s = input()
    ans= 0
    for i in range(1,n):
        ans = max(ans, len(set(s[:i]) & set(s[i:])))
    print(ans)

            



if __name__ == '__main__':
    main()

Measured memory_bytes: 9144
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(Number);
  buildMaxHeap(arr, n);
  console.log(arr.reduce((s, e) => s += ` ${e}`, ''));
})();

function buildMaxHeap(arr, n) {
  const maxHeapify = (i) => {
    let left, right, largest;
    left = 2 * i + 1;
    right = 2 * i + 2;
    largest = left < n && arr[left] > arr[i] ? left : i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(n / 2); i >= 0; i--) maxHeapify(i);
}



Measured memory_bytes: 140164
// ref. https://ei1333.github.io/luzhiled/snippets/dp/largest-rectangle.html

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

template<typename T>
ll largest_rectangle(vector<T> height)
{
  stack<ll> st;
  height.push_back(0);
  vector<ll> left(height.size());
  ll ret = 0;
  rep(i, height.size()) {
    while(!st.empty() && height[st.top()] >= height[i]) {
      ret = max(ret, (i - left[st.top()] - 1) * height[st.top()]);
      st.pop();
    }
    left[i] = st.empty() ? -1 : st.top();
    st.emplace(i);
  }
  return (ret);
}


int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<ll> h(n);
  rep(i,n) {
    cin >> h[i];
  }

  ll ans = largest_rectangle(h);
  cout << ans << endl;
}



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

using namespace std;
typedef long long ll;
typedef pair<int,ll> pil;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int maxN = 100010;
const int maxC = 1e6 + 10;
const int INF = 1e9; 
int n;
pli a[maxN];
pli b[maxN];
int vis[maxN];
char d[4];
pli c[maxN];
int main()
{
 
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		a[i].second = i;
		b[i].second = i;
		scanf("%lld%lld",&a[i].first,&b[i].first);
		c[i].second = i;
		c[i].first = a[i].first + b[i].first;
	}
	sort(c+1,c+1+n);
	reverse(c+1,c+1+n);
	ll acnt = 0;
	for(int i=1;i<=n;i+=2)
	{
		int p = c[i].second;
		acnt += a[p].first;
	}
	ll bcnt = 0;
	for(int i=2;i<=n;i+=2)
	{
		int p = c[i].second;
		bcnt += b[p].first;
	}
	cout<<acnt - bcnt <<endl;
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>

using namespace std;

int main(){
    long long n,x, a[100009], cnt=0;
    cin >> n >> x;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i+1<n;i++){
        if(a[i]+a[i+1]>x){
            if(a[i]>x){
                cnt+=a[i]-x;
                a[i]-=a[i]-x;
            }
            cnt += a[i]+a[i+1]-x;
            a[i+1] -= a[i]+a[i+1]-x;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
{-# LANGUAGE MultiParamTypeClasses,FlexibleContexts,FlexibleInstances,TypeSynonymInstances,BangPatterns,RankNTypes,TupleSections #-}
import Control.Monad
import Control.Monad.ST
import Control.Applicative
import Control.Arrow
import Debug.Trace
import Text.Printf

import Data.List
import Data.Int
import Data.Bits
import Data.Maybe
import Data.Monoid
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.Base
import Data.Function(on)
import Data.Tuple(swap)
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
    [sx,sy,tx,ty] <- readInts
    let w = tx - sx
        h = ty - sy
        go ch l = [ ch | _ <- [1..l] ]
    putStrLn $ go 'R' w ++ go 'U' h ++
               go 'L' w ++ go 'D' h ++
               "D" ++ go 'R' (w+1) ++ go 'U' (h+1) ++ "L" ++
               "U" ++ go 'L' (w+1) ++ go 'D' (h+1) ++ "R"

-- IO
readInt :: B.ByteString -> Int
readInt = fromJust . fmap fst . B.readInt
readInts :: IO [Int]
readInts = map readInt . B.words <$> B.getLine
readIntPair :: IO (Int,Int)
readIntPair = l2p . map readInt . take 2 . B.words <$> B.getLine
readAllInts :: IO [[Int]]
readAllInts = map (map readInt . B.words) . B.lines <$> B.getContents
readLns :: Read a => IO [a]
readLns = map read . words <$> getLine

-- Utilities
l2p :: [a] -> (a,a)
l2p (a:b:_) = (a,b)
l2p _ = error "l2p: the input list is too short"
p2l :: (a,a) -> [a]
p2l (a,b) = [a,b]
itof :: Int -> Double
itof = fromIntegral
inf :: Int
inf = maxBound `div` 2

-- Monad
stepM_ :: Monad m => a -> (a -> Bool) -> (a -> a) -> (a -> m ()) -> m ()
stepM_ i0 judge incr step = sub i0 where 
    sub i | judge i = step i >> sub (incr i) 
          | otherwise = return ()
rep_ :: Monad m => Int -> (Int -> m ()) -> m ()
rep_ n = stepM_ 0 (<n) (+1)
thru :: Monad m => (v -> m ()) -> v -> m v
thru m v = m v >> return v
memoize :: (Monad m) => (k -> m (Maybe v)) -> (k -> v -> m ()) -> k -> m v -> m v
memoize getter setter key action = do
    mv <- getter key
    case mv of
        Just v -> return v
        Nothing -> action >>= thru (setter key)

-- Array
newUArray :: (MArray (STUArray s) e (ST s),Ix i) => 
             (i,i) -> e -> ST s (STUArray s i e)
newUArray = newArray
newBArray :: (Ix i) => (i,i) -> e -> ST s (STArray s i e)
newBArray = newArray
defaultArray :: (IArray a e,Ix i) => e -> (i,i) -> [(i,e)] -> a i e
defaultArray = accumArray $ curry snd
fromEdges :: Ix i => (i,i) -> [(i,e)] -> Array i [e]
fromEdges = accumArray (flip (:)) []


Measured memory_bytes: 1020
from enum import Enum
import sys

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


class Type(Enum):
    win_Taro = 0
    win_Hanako = 1
    EVEN = 2

def comp_str(A,B):
    if A > B:
        return Type.win_Taro
    elif A < B:
        return Type.win_Hanako
    else:
        return Type.EVEN

N = int(input())

point_Taro = 0
point_Hanako = 0

for loop in range(N):
    line = str(input()).split()
    ret_type = comp_str(line[0],line[1])
    if ret_type == Type.win_Taro:
        point_Taro += 3
    elif ret_type == Type.win_Hanako:
        point_Hanako += 3
    else:
        point_Taro += 1
        point_Hanako += 1

print("%d %d"%(point_Taro,point_Hanako))


Measured memory_bytes: 6344
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, k;
int main() {
	read(n), read(k);
	int ans = 1;
	n -= k;
	ans += n / (k - 1);
	n %= (k - 1);
	if (n != 0) ans++;
	writeln(ans);
	return 0;
}


Measured memory_bytes: 256
var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    input += chunk;
});
process.stdin.on('end', function() {
    main(input)
});

function main(input){
    var args = input.trim().split('\n');
    var dataSetCount = parseInt(args[0]);
    args = args.slice(1, dataSetCount + 1);
    args.forEach(function(set){
        set = set.split(' ').map(Number);
        console.log( solve(set) );
    })
}

function solve(set){
    var right = 0;
    var left = 0;
    for(var i = 0; i < set.length; i+=1){
        var ball = set[i];
        if(ball > right){ right = ball; }
        else if(ball > left){ left = ball; }
        else return "NO";
    }
    return "YES";
}

Measured memory_bytes: 15312
using System;

namespace Application
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			var n=int.Parse(Console.ReadLine());
			for(int i=0; i<n; i++) {	
				var a = Array.ConvertAll(Console.ReadLine().Split(), x => int.Parse(x));
				Array.Sort(a);
				if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2]) Console.WriteLine ("YES");
				else Console.WriteLine ("NO");
			}
		}
	}
}


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

using namespace std;
#define ll long long

ll INF = 1e18;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> c(10, vector<int>(10));
    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }
    vector<vector<int>> A(H, vector<int>(W));
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }
    for(int k = 0; k < 10; k++) {
        for(int i = 0; i < 10; i++) {
            for(int j = 0; j < 10; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(A[i][j] != -1 && A[i][j] != 1) {
                ans += c[A[i][j]][1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3776
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define int long long
int x,k,d;

void test_case(){
	cin >> x >> k >> d;
	int r1 = abs(x)%d;
	int r2 = d-r1;
	int stp = abs(x)/d;

	if(k<=stp){
		cout << abs(x)-k*d << endl;
	}
	else{
		if((k-stp)&1){
			cout << r2 << endl;
		}
		else{
			cout << r1 << endl;
		}
	}

}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	int t=1;
	// cin >> t;

	while(t--) test_case();
	
	return 0;
}














//     	 __       _   __  _     _   _______   __
//	    /  \     | | / / | |   | | |__   __| |  |
//	   / /\ \    | |/ /  | |___| |    | |    |  |
//	  / /__\ \   |   <   |  ___  |    | |    |  |
//	 / ______ \  | |\ \  | |   | |  __| |__  |  |_____
//	/_/      \_\ |_| \_\ |_|   |_| |_______| |________|




Measured memory_bytes: 3636
using System;

    class Program
    {
        static void Main()
        {
            double[] num = Console.ReadLine().Split(' ').toDoubleArray();
            double radian = num[2] / 180 * Math.PI;
            double h = num[1] * Math.Sin(radian);
            double L = num[0] + num[1] + Math.Sqrt(num[0] * num[0] + num[1] * num[1] - 2 * num[0] * num[1] * Math.Cos(radian));
            double S = num[0] * h / 2;

            Console.Write(S.ToString() + "\n" + L.ToString() + "\n" + h.ToString() + "\n");
        }
    }

    static class Extensions_strArray
    {
        static public double[] toDoubleArray(this string[] array)
        {
            return Array.ConvertAll<string, double>(array,
                delegate(string value)
                {
                    return double.Parse(value);
                }
            );
        }
    }

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

int main() {
  int N;
  int A[22], B[22], C[22];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  for (int i = 0; i < N - 1; i++) cin >> C[i];

  int ans = 0;

  for (int i = 0; i < N; i++) {
    ans += B[A[i] - 1];
    if (i != 0 && A[i] == A[i - 1] + 1) {
      ans += C[A[i] - 2];
    }
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int K; cin >> K;
	string S; cin >> S;

	if(S.length() <= K) cout << S << endl;
	else cout << S.substr(0, K) << "..." << endl;



	return 0;

}


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

int map[100][100];
int w=0,h=0;

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

void dfs(int x,int y);

int main(){
  while(1){
    cin>>w>>h;

    if(w==0&&h==0)
      break;

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin>>map[i][j];
      }
    }

    int result=0;

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(map[i][j]==1){
	  result++;
	  dfs(j,i);
	}
      }
    }
    cout<<result<<endl;
  }
    
  return 0;
}

void dfs(int x,int y){
  map[y][x]=0;
  for(int i=0;i<8;i++){
    int nx=x+dx[i];
    int ny=y+dy[i];
    if(nx>=0&&nx<w&&ny>=0&&ny<h&&map[ny][nx]==1){
      dfs(nx,ny);
    }
  }
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> 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.begin(), ret.end());
    return ret;
}
int main(){
    ll N;
    cin>>N;
    
    VEC(ll,A,N);
    VEC(ll,As,N);
    
    REP(i,N){
        cin>>A[i];
        As[i]=A[i];
    }
    sort(ALL(As),greater<ll>());
    
    REP(i,N){
        cout<<(As[0]==A[i]?As[1]:As[0])<<endl;
    }
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 4736
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    N = int(input())
    X = [0] * N
    Y = [0] * N
    H = [0] * N
    idxes = []

    for i in range(N):
        X[i], Y[i], H[i] = MI()
        idxes.append((H[i], i))

    idxes.sort(reverse=True)

    for cx in range(101):
        for cy in range(101):
            ans = None
            zero_arr = []
            if H[0] != 0:
                ans = H[0] + abs(X[0] - cx) + abs(Y[0] - cy)
            else:
                tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                zero_arr.append(tmp)
            counter = 1
            for _, i in idxes:
                if H[i] == 0:
                    tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                    zero_arr.append(tmp)
                else:
                    tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                    if ans is not None and ans != tmp:
                        break
                    ans = tmp
                counter += 1

            if counter >= N:
                # print(ans, zero_arr)
                if ans is not None and len(zero_arr) == 0:
                    print(cx, cy, ans)
                    return
                elif ans is not None and len(zero_arr) != 0 and min(zero_arr) >= ans:
                    print(cx, cy, ans)
                    return
                elif ans is None and len(zero_arr) != 0:
                    a = X[0] + Y[0]
                    for i in range(1, N):
                        a = min(a, X[i] + Y[i])
                    print(cx, cy, a)
                    return


if __name__ == '__main__':
    main()


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:
// Description: グラフの型定義
// Verifyed: Many Diffrent Problem

//Appropriately Changed
using edge = struct {int to; ll cost;};
using G = vector<vector<edge>>;

void add_edge(G &graph, int from, int to,ll cost) {
	graph[from].push_back({to,cost});
	graph[to].push_back({from,cost});
}

const int limit = 100010;

// 0: t - a  val[v][0] = a
// 1: b - t  val[v][1] = b

bool visited[limit][2];
ll val[limit][2];

bool ok = true;

void dfs(const G &graph,int v,int idx,ll cur){
	visited[v][idx] = true;
	val[v][idx] = cur;

	for(auto &e:graph[v]){
		if(visited[e.to][idx^1]) 
			ok &= (val[e.to][idx^1] == (e.cost - cur));
		else
			dfs(graph,e.to,idx^1, e.cost - cur);	
	}
}


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

	G graph(n);

	rep(i,m){
		int u,v;
		ll s;
		cin >> u >> v >> s;
		u--,v--;
		add_edge(graph,u,v,s);
	}

	dfs(graph,0,0,0LL);

	ll tmin = 1LL, tmax = 1LL << 60; 	
	
	rep(i,n){
		if(visited[i][0] and visited[i][1]){
			const ll tmp = val[i][1] - val[i][0];
			if(tmp % 2 == 1) ok = false;
			chmax(tmin,tmp/2);
			chmin(tmax,tmp/2);
		}
		if(visited[i][0]){
			chmax(tmin,1 - val[i][0]);
		}
		if(visited[i][1]){
			chmin(tmax,val[i][1] - 1);
		}
		//cerr << tmin << " " << tmax << endl;
	}

	if(ok)
		cout <<  max(0LL,tmax - tmin + 1) << endl;
	else
		cout << 0 << endl;

	return 0;
}


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

void Array_Print(int N, int A[]){
	for(int i=0; i<N; i++){
		if(i==N-1) printf("%d", A[i]);
		else 	   printf("%d ", A[i]);
	}
	printf("\n");
}

int Selection_Sort(int N, int A[]){
	int counter = 0;
	for(int i=0; i<N-1; i++){
		int min = i;
		for(int j=i+1; j<N; j++){
			if(A[j] < A[min]) min = j;
		}
		if(min != i){
			counter++;
			int k = A[min];
			A[min] = A[i];
			A[i] = k;
		}
	}
	Array_Print(N,A);
	return counter;
}

int main(int argc, char const *argv[])
{
	// Input the total number of elements
	int N;
	scanf("%d", &N);
	// Input elements in the list
	int A[N];
	for(int i=0; i<N; i++){
		scanf("%d", &A[i]);
	}
	// Bubble Sort
	int counter = Selection_Sort(N,A);
	printf("%d\n", counter);
	return 0;
}


Measured memory_bytes: 2064
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}



signed main(){
	char C;
	cin>>C;
	cout<<char(C+1)<<endl;
	return 0;
}


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

int main(){
  int N,answer=0;
  cin>>N;
  for(int i=0;i<N;i++){
    int a,count=0;
    cin>>a;
    while(a%2==0){
      a=a/2;
      count++;
    }
    if(i==0||answer>count)
      answer=count;
  }
  cout<<answer<<endl;
}


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

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int[] result = new int[500];
        int resultcnt=0;

        while(true){
            int n = sc.nextInt();
            int r = sc.nextInt();
            if(n==0 && r==0)
                break;
            int[] hana = new int[n];
            int[] copy = new int[n];
            for(int i=0; i<n; i++){
                hana[n-1-i] = i+1;
                
            }
            
            for(int i=0; i<r; i++){
                int p = sc.nextInt();
                int c = sc.nextInt();
                int cnt=0;
                if(i==0){
                    for(int j=p-1; j<p+c-1; j++){
                        copy[cnt] = hana[j];
                        cnt++;
                    }
                    for(int k=0; k<p-1; k++){
                        copy[cnt] = hana[k];
                        cnt++;
                    }
                    for(int m=p+c-1; m<n;m++){
                        copy[cnt] = hana[m];
                        cnt++;
                    }    
                }else{
                    for(int a=0; a<n; a++)
                        hana[a] = copy[a];
                    for(int j=p-1; j<p+c-1; j++){
                        copy[cnt] = hana[j];
                        cnt++;
                    }
                    for(int k=0; k<p-1; k++){
                        copy[cnt] = hana[k];
                        cnt++;
                    }
                    for(int m=p+c-1; m<n;m++){
                        copy[cnt] = hana[m];
                        cnt++;
                    }
                }
            }
            result[resultcnt] = copy[0];
            resultcnt++;
        }

        for(int i=0; i<resultcnt; i++){
            System.out.println(result[i]);
        }

        sc.close();

    }
}


Measured memory_bytes: 37160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

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

  string str;
  cin >> str;

  int ten,one;
  ten=str[5]-'0';
  one=str[6]-'0';

  int month=ten*10+one;

  if(month <= 4) cout <<"Heisei" << endl;
  else cout << "TBD" << endl;
  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> dp(45);
    for(int i=0; i<45; i++){
        if(i==0 || i==1){
            dp[i]=1;
        }
        else{
            dp[i]=dp[i-1]+dp[i-2];
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
ll sum=0;
ll work(ll n){
	if(n==1){
		return 1; 
	}
	else{
		
		return 2*work(n/2)+1;
	}
}
int main(){
	fast;
	ll n;
	cin>>n;
	cout<<work(n)<<endl; 
}/*『你强归你强，Siyuan比你强』*/





Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static final int  UNIT =                  17;
    private static final long DIV  = 100000000000000000L;

    public static void main(String[] args) {

        //input
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        for(int i=0;i<n;i++){
        	String ans = add(sc.next(),sc.next());

           	//output
        	if  (ans.length() > 80){System.out.println("overflow");}
        	else                   {System.out.println(ans);       }
        }
    }

    private static String add(String a,String b){

    	//initialization
    	String[] a_div,
    	         b_div;
        String   ans = "";

    	for(long buf,carry = 0;!(a.equals("") && b.equals("") && carry == 0);){

    		//division
    		a_div = splitStr(a);
    		b_div = splitStr(b);

    		//calculation
    		buf = Long.parseLong(a_div[1].equals("")?"0":a_div[1]) +
    			  Long.parseLong(b_div[1].equals("")?"0":b_div[1]) +
    			  carry;

    		//update
    		carry = buf / DIV;
   			ans = String.valueOf(String.format("%1$017d",buf%DIV)) + ans;
    		a = a_div[0];
    		b = b_div[0];
    	}

    	return zeroSprs(ans);
    }

    //divide string.
    private static String[] splitStr(String s){

    	//initialization
    	int len   = s.length();
    	int split = len - UNIT;
    	String[] s_ar = new String[2];

    	//division
    	if(split > 0){
    		s_ar[0] = s.substring(0,split);
    		s_ar[1] = s.substring(split);
   		} else {
    		s_ar[0] = "";
    		s_ar[1] = s;
   		}

    	return s_ar;
    }

    //zero suppress.
    private static String zeroSprs(String s){
    	char[] c_ar = s.toCharArray();
    	String ret = "";
    	boolean zeroSprsFlg = true;
    	for(char c:c_ar){
    		if(c != '0')    {zeroSprsFlg = false;}
    		if(!zeroSprsFlg){ret += String.valueOf(c);}
    	}
    	if(ret.equals("")){ret = "0";}
    	return ret;
    }
}

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

int	main()
{
  int	N;
  int	A;
  
  cin >> N;
  cin >> A;
  
  if (N % 500 <= A)
  {
    cout << "Yes" << endl;
  	return (0);
  }
  cout << "No" << endl;
  
  return (0);
}
  


Measured memory_bytes: 256
#include<stdio.h>

#define TMIN 2
#define TMAX 200000
#define nMIN 1
#define nMAX 1000000


int main(){
int n[nMAX],Time,i,max=0,sub;

scanf("%d",&Time);
if(TMIN<=Time&&Time<=TMAX){
for(i=0;i<Time;i++){
scanf("%d",&n[i]);
}
max=n[i-1];
sub=n[i-1]-n[i-2];
for(i=Time-2;i>=0;i--){

if(max<n[i]&&i!=0){
max=n[i];
}
if(sub<max-n[i]&&n[i]!=max){
sub=max-n[i];
}
}
}
 else return 0;

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



Measured memory_bytes: 2636
using static System.Math;
using static System.Console;
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        var a = ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
        int i = 0;
        while (true) {
            if (a.Max() == a.Min()) {
                break;
            }
            if (a.Max() - a.Min() >= 2) {
                a[0] += 2;
            } else {
                a[0]++;
                a[1]++;
            }
            i++;
            Array.Sort(a);
        }
        WriteLine(i);
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    string OR;
    int A,B,ans;
    cin >> A >> OR >> B;
    if (OR[0] == '-') {
        ans =A-B;
    }else{
        ans = A+B;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    rep(i, 0, n) cin >> c[i];

    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);

    ll ans = 0;
    rep(i, 0, n) {
        ll x = lower_bound(a, a + n, b[i]) - a;
        ll y = c + n - (upper_bound(c, c + n, b[i]));
        ans += x * y;
    }

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


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll l(n);
    REP(i, n){
        cin >> l[i];
    }
    VSORT(l);
    ll res = 0;
    REP(i, n){
        REP(j, n){
            // i 番目 と j 番目の棒を採用する(i < j)
            if(j <= i) continue;
            // 3 本目として k 番目の棒が使えるための条件:
            // 全体 n 本から使えないものを引き算する
            // k > j : 小さい方から j + 1 コは使えない
            // k < l[i] + l[j] : 大きい方から p コは使えない
            // p : l[i] + l[j] 以上の長さの棒の数
            // 小さい方から j + 1 コの棒は長さ l[i] + l[j] 以上にならないので両方引くだけでOK
            ll p = l.end() - lower_bound(ALL(l), l[i] + l[j]);
            res += n - (j + 1 + p);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256