akhauriyash/Code-Regression huggingface dataset:
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1];}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const objvs =(a)=>{const b=[];for(const v in a){b.push(a[v])}return b};
const main=()=>{
  let [a,b,c,d]=tnn(4)
  let x=c-a
  let y=d-b
  to((c-y)+' '+(d+x)+' '+(a-y)+' '+(b+x))

}
main()


Measured memory_bytes: 7372
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import  java.io.*;
import  java.math.*;
import java.nio.Buffer;
import java.sql.SQLSyntaxErrorException;
import  java.util.*;
import  java.text.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;


public class Main {
    public static boolean gcd(int a,int b){
        if(a==1||b==1){
            return false;
        }
        while(1>0){
            int t = a%b;
            if(t == 0){
                break;
            }
            else{
                a=b;
                b=t;
            }

        }
        if(b>1)	return true;
        else{
            return  false;
        }
    }

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        long n=cin.nextLong();
        long k=cin.nextLong();
        if(n<k){
            HashMap<Long,Integer> p = new HashMap<Long,Integer>();
            long x=n%k;
            long minn=x;
            while(true){
                x=Math.abs(x-k);
                if(!p.containsKey(x)){
                    p.put(x, 1);
                    minn = Math.min(x, minn);
                }
                else break;
            }
            System.out.println(minn);
        }
        else if(n%k==0){
            System.out.println("0");
        }
        else{
            System.out.println(Math.abs(n%k-k));
        }

    }
}

Measured memory_bytes: 23892
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(void) {
	int L, R, d;
	scanf("%d %d %d", &L, &R, &d);
	int ans = 0;
	for (int i = L; i <= R; i++) {
		if (i % d == 0) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3732
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        int c = input.nextInt();
        System.out.println(a<b&&b<c?"Yes":"No");
    }
}

Measured memory_bytes: 17352
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

int main()
{
    input in;
    output out;

    out << 6 - in.read<int>() - in.read<int>();

    return 0;
}


Measured memory_bytes: 256
N = int(raw_input())
s = raw_input()
def opp(a):
	return 'S' if a == 'W' else 'W'
def det(a0, a1):
	ap = a0
	ac = a1
	ans = a0

	for c in s[1:]+s[:2]:
		ans += ac
		if (c == 'o' and ac == 'S') or (c == 'x' and ac == 'W'):
			an = ap
		else:
			an = opp(ap)
		ap = ac
		ac = an
	if ans[-2:] == ans[:2]:
		return ans[:-2]
	else:
		return None
for pref in ["SS", "SW", "WW", "WS"]:
	ans = det(pref[0], pref[1])
	if ans:
		break
print -1 if not ans else ans

Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  VI a(n);
  for (int& x: a) cin >> x;

  vector<vector<ll>> score(n, vector<ll>(n));
  for (int i = 0; i < n; i++) {
    score[i][i] = a[i];
  }
  for (int len = 2; len <= n; len++) {
    for (int l = 0; l + len <= n; l++) {
      int r = l + len - 1;
      score[l][r] = max(a[l] - score[l + 1][r], a[r] - score[l][r - 1]);
    }
  }
  cout << score[0][n - 1] << endl;

  return 0;
}


Measured memory_bytes: 73664
#include <iostream>
using namespace std;
int main()
{
 string array[5]={"a","e","u","i","o"};
 string c;
 cin>> c;
 if(c=="a"||c=="e"||c=="u"||c=="i"||c=="o")
    cout<<"vowel"<<endl;
 else
    cout<<"consonant"<< endl;
}

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

int main(){
    int n, m; cin >> n >> m;
    vector<int> c(m);
    vector<int> dp(n+1, INT_MAX); // コインを使う枚数

    for(int i = 0; i < m; ++i)
        cin >> c[i];

    dp[0] = 0;
    for(int i = 0; i <= n; ++i){ // 価格
        for(int j = 0; j < c.size(); ++j){
            if(i - c[j] >= 0){
                dp[i] = min(dp[i - c[j]] + 1, dp[i]);
            }
        }
    }

    cout << dp[n] << endl;

    return EXIT_SUCCESS;
}



Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, n) for(long long (i) = (a); (i) < (n); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define GET(v) cin >> (v)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b , c) cin >> (a) >> (b) >> (c)
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

int main()
{
    ll a, b;
    int k;
    GET3(a, b, k);
    
    for(int i = 0; i < k; i++) {
        if(i % 2 == 0) {
            if(a % 2 == 1) {
                a--;
            }
            
            a /= 2;
            b += a;
        }
        else {
            if(b % 2 == 1) {
                b--;
            }
            
            b /= 2;
            a += b;
        }
    }
    
    SHOW2(a, b);
    
    return 0;
}


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

int main() {
	string S;
	bool b = true;
	int index = -1;
	cin >> S;
	if (S[0] != 'A')
		b = false;
	if (b) {
		int c = 0;
		for (int i = 2; i < S.length()-1; i++) {
			if (S[i] == 'C') {
				index = i;
				c++;
			}
		}
		if (c != 1)
			b = false;
	}
	if (b) {
		for (int i = 1; i < S.length(); i++) {
			if (i != index && 'A' <= S[i] && S[i] <= 'Z') {
				b = false;
			}
		}
	}
	if (b)
		cout << "AC\n";
	else
		cout << "WA\n";
}


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

const int MAX_N = 1000010;
const int INF = (1LL << 31) - 1;

class MinSeg {
	int n, dat[2 * MAX_N - 1];
public:
	void init(int n_) {
		n = 1;
		while(n < n_) n *= 2;
		for(int i = 0; i < 2 * n - 1; i++) {
			dat[i] = INF;
		}
	}

	void update(int k, int a) {
		k += n - 1;
		dat[k] = a;
		while(k > 0) {
			k = (k - 1) / 2;
			dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}

	int query(int a, int b) {
		return query(a, b, 0, 0, n);
	}

	int query(int a, int b, int k, int l, int r) {
		if(r <= a || b <= l) return INF;
		if(a <= l && r <= b) return dat[k];
		else {
			int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return min(vl, vr);
		}
	}
};

MinSeg st;

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

	int n, q;
	cin >> n >> q;

	st.init(n);

	while(q--) {
		int c, x, y;
		cin >> c >> x >> y;
		if(c == 0) {
			st.update(x, y);
		}
		else {
			cout << st.query(x, y + 1) << endl;;
		}
	}
}

Measured memory_bytes: 4200
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(S: str):
    elms = ['dream', 'dreamer', 'erase', 'eraser']
    while S:
        found = False
        for e in elms:
            if S[-len(e):] == e:
                found = True
                S = S[:-len(e)]
                break
        if not found:
            print(NO)
            return
    print(YES)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

int64_t solve(int64_t x) {
    int64_t dp[22][2][2][10] = {0};
    dp[0][0][0][0] = 1;
    rep(i, to_string(x).size()) rep(s, 2) rep(nz, 2) rep(last, 10) for(int d = (nz ? max(0, last - 1) : 0); d <= (nz ? min((s ? 9 : to_string(x)[i] - '0'), last + 1) : (s ? 9 : to_string(x)[i] - '0')); ++d) dp[i + 1][s || d < (s ? 9 : to_string(x)[i] - '0')][nz || d > 0][d] += dp[i][s][nz][last];
    int64_t res = 0;
    rep(j, 2) rep(l, 10) res += dp[to_string(x).size()][j][1][l];
    return res;
}

int main() {
    int K; cin >> K;
    int64_t l = 0, r = 1e18;
    while(r - l > 1) {
        int64_t c = (l + r) / 2;
        if(solve(c) < K) l = c;
        else r = c;
    }
    cout << r << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
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; }

int N;
int a[100010][3];
int dp[100010][3];

int main() {
    cin >> N;
    rep(i, N) {
        rep(j, 3) {
            cin >> a[i][j];
        }
    }

    rep(i, N) {
        rep(j, 3) {
            rep(k, 3) {
                if(j == k) {
                    continue;
                }
                chmax(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    int ans = 0;
    rep(j, 3) {
        chmax(ans, dp[N][j]);
    }
    
    cout << ans;
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 2560
def main():
    n = int(input())
    a = list(map(int, input().split()))
    c = 0
    m = 1000
    for i in range(n-1):
        if a[i] < a[i+1]:
            c += m//a[i]
            m -= (m//a[i])*a[i]
        elif a[i] > a[i+1]:
            m += a[i]*c
            c = 0
    m += a[n-1]*c
    print(m)


main()


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vpl vector<pair<long long,long long>>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
long long MOD = 1000000007;
const long double pi = 3.1415926535897932;
#define pb push_back
#define mp make_pair
#define mt make_tuple
using Grid = vector<vector<char>>;
#define vc vector<char>
//(mod m)でのaの逆元を計算する
//a/b(mod m)=a(mod m)*modinv(b,m)
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long 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;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
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;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll H,W;
    cin>>H>>W;
    Grid G(W,vc(H));
    rep(i,H)rep(j,W)cin>>G[j][i];
    ll Ans=0;
    queue<pll> q;
    rep(i,H){
        rep(j,W){
            if(G[j][i]=='#'){
                pll a=mp(j,i);
                q.push(a);
            }
        }
    }
    if(q.size()==H*W){
        cout<<0<<endl;
        return 0;
    }
    queue<pll> memo;
    while(!q.empty()){
        Ans++;
        while(!q.empty()){
            ll x,y;
            tie(x,y)=q.front();
            q.pop();
            if(x-1>=0&&G[x-1][y]=='.'){
                pll k=mp(x-1,y);
                memo.push(k);
                G[x-1][y]='#';
            }
            if(y-1>=0&&G[x][y-1]=='.'){
                pll k=mp(x,y-1);
                memo.push(k);
                G[x][y-1]='#';
            }
            if(x+1<=W-1&&G[x+1][y]=='.'){
                pll k=mp(x+1,y);
                memo.push(k);
                G[x+1][y]='#';
            }
            if(y+1<=H-1&&G[x][y+1]=='.'){
                pll k=mp(x,y+1);
                memo.push(k);
                G[x][y+1]='#';
            }
        }
        swap(q,memo);
    }
    cout<<Ans-1<<endl;
}

Measured memory_bytes: 17588
//=====================================================================================================================================//
//Al_Qatil 
#include <bits/stdc++.h>
//g++ code.cpp -o /x
using namespace std;
#define ll long long
using ii=tuple<ll, ll>;
#define pb push_back
#define For(i,n) for(ll  i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(a,b,c) for(ll a=b;a<c;a++)
#define M 1000000007
#define vi vector<ll> 
#define vvi vector<vi>
#define int long long
#define rl(t) ll t;cin>>t;
#define rs(t) string t;cin>>t;

//=====================================================================================================================================//
//set <ll> :: iterator itr;
// if (b.find(a[i]) != b.end())
//Multiset
//multiset<int, greater<int>> h;
//auto it = h.lower_bound(x);
//if (it == h.end()) cout << "-1\n";
// priority queue .. queue in des order  :-> priority_queue<tuple<int, bool>> q;
const int N = 2e5 + 10, inf = 1e9 + 42;
//=====================================================================================================================================//

signed main() 
{   
    fast;
    ll n;
    cin>>n;
    ll a[n][3],m[n][3];
    For(i,n)
    {
        For(j,3)
        {
            cin>>a[i][j];
        }
    }
    For(i,3)
    {
        m[0][i]=a[0][i];
    }
    f(i,1,n)
    {
        For(j,3)
        {
            m[i][j]=a[i][j]+max(m[i-1][(j+1)%3],m[i-1][(j+2)%3]);
        }
    }
    ll x=0;
    For(i,3)
    {
        x=max(x,m[n-1][i]);
    }
    cout<<x<<endl;
}

//======================================================================================================================================//

Measured memory_bytes: 4992
def segfunc(x,y):return x+y
ide_ele=0
class segtree():
  def __init__(self,init_val,segfunc=segfunc,ide_ele=ide_ele):
    n=len(init_val)
    self.segfunc=segfunc
    self.ide_ele=ide_ele
    self.num=1<<(n-1).bit_length()
    self.tree=[ide_ele]*2*self.num
    for i in range(n):
      self.tree[self.num+i]=init_val[i]
    for i in range(self.num-1,0,-1):
      self.tree[i]=self.segfunc(self.tree[2*i], self.tree[2*i+1])
  def update(self,k,x):
    k+=self.num
    self.tree[k]=x
    while k>1:
      self.tree[k>>1]=self.segfunc(self.tree[k],self.tree[k^1])
      k>>=1
  def query(self,l,r):
    l+=self.num
    res=self.ide_ele
    r+=self.num+1
    while l<r:
      if l&1:
        res=self.segfunc(res,self.tree[l])
        l+=1
      if r&1:
        res=self.segfunc(res,self.tree[r-1])
      l>>=1
      r>>=1
    return res
mod=998244353
n,k=map(int,input().split())
l,r=[0]*k,[0]*k
for i in range(k):
  l[i],r[i]=map(int,input().split())
dp=[0]*(n+1)
dp[1]=1
st=segtree(dp)
for i in range(2,n+1):
  s=0
  for j in range(k):
    lj=max(i-r[j],0)
    rj=max(i-l[j],0)
    s+=st.query(lj,rj)
    s%=mod
  st.update(i,s)
print(s)

Measured memory_bytes: 86380
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <numeric>
using namespace std;
 
#define LOCAL  1
#define UPLOAD 2
 
#define ll long long
const long long INF = 1LL << 60;
 
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
#define REP(i,M) for(int i=0;i<M;i++)
 
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  ll N = input();
  ll A = input();
  ll B = input();
 
  ll count = N/(A+B);
  ll nokori = N - (A+B)*count;
 
  ll blue = count*A + min(A, nokori);
 
  output(blue);
  
 
  return 0;
}

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

int main() {
    long long A, B, K;
    cin >> A >> B >> K;
    long long a = max(0LL, A - K);
    long long b = max(0LL, B - abs(A - K));
    if(A >= K) b = B;

    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int maxn=2e5+5;
int n,a[maxn],b[maxn];
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		b[i]=read();
	}
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	if(n&1) printf("%d\n",b[(n+1)>>1]-a[(n+1)>>1]+1);
	else printf("%d\n",b[(n+2)>>1]+b[n>>1]-a[(n+2)>>1]-a[n>>1]+1);
	return 0;
}


Measured memory_bytes: 5304
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
//typedef long long int;
//typedef long long ll;
//typedef pair<int, int> P;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;

int main()
{
    int a;
    cin >> a;
    if(a == 3 || a == 5 || a == 7){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#pragma warning( disable:4996 )
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	int n, k;
	scanf("%d %d", &n, &k);
	if (k == 1) {

		printf("%d\n", 0);
	}
	else {
		printf("%d\n", n - k);
	}
	
	return 0;
}

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

int main() {
  int l, r, d, counter = 0;

  cin >> l >> r >> d;

  for (int i = l; i <= r; i++) {
    if (i % d == 0) {
      counter++;
    }
  }
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
vvi E(222222);
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  vi H(n);
  for(auto &a:H)cin>>a;
  for(int i=0;i<m;i++){
    ll a,b;cin>>a>>b;
    E[--a].pb(--b);
    E[b].pb(a);
  }
  ll ans = 0;
  for(int i=0;i<n;i++){
    bool fl = true;
    for(auto e:E[i]){
      if(H[i] <= H[e])fl = false;
    }
    ans += fl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 12700
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	REP(i, s.size()-1){
		if(s.substr(i, 2) == "AC"){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 764
N = int(input())
# 初期状態t=0,(x,y)=(0,0)を入れて置く
t, x, y = [0], [0], [0]
for i in range(N):
    tmp_t, tmp_x, tmp_y = map(int, input().split())
    t.append(tmp_t), x.append(tmp_x), y.append(tmp_y)
#print(t,x,y)

can = True
for i in range(N):
    dt = t[i+1] - t[i]
    dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if dt < dist:
        can = False
        break
    if dist % 2 != dt % 2:
        can = False
        break

if can:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 11816
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
long long n,m,k,v[3005][3005],a,b,dp[3005][3005][4];//到了第i行，第j列，这一列已经选了k个时最大的总和 
int main(){
	cin>>n>>m>>k;
	for(int i=1;i<=k;i++)
		cin>>a>>b,cin>>v[a][b];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			dp[i][j][0]=dp[i][j][1]=dp[i][j][2]=dp[i][j][3]=-6666666666;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			dp[i][j][0]=max(max(max(dp[i-1][j][0],dp[i-1][j][1]),max(dp[i-1][j][2],dp[i-1][j][3])),dp[i][j-1][0]);
			dp[i][j][1]=max(max(max(dp[i-1][j][0],dp[i-1][j][1]),max(dp[i-1][j][2],dp[i-1][j][3]))+v[i][j],max(dp[i][j-1][1],dp[i][j-1][0]+v[i][j]));
			dp[i][j][2]=max(dp[i][j-1][1]+v[i][j],dp[i][j-1][2]);
			dp[i][j][3]=max(dp[i][j-1][2]+v[i][j],dp[i][j-1][3]);
		}
	cout<<max(max(dp[n][m][0],dp[n][m][1]),max(dp[n][m][2],dp[n][m][3]));
	return 0;
}

Measured memory_bytes: 355252
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int T = sc.nextInt();
		int S = sc.nextInt();
		sc.close();

		if (Math.ceil(D * 1.0 / S) <= T) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35616
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    int cnt = 0;
    int mause = 1;
    while(mause < b){
        mause += a-1;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

string siin(char a){
  if(a=='1')return "";
  else if(a=='2')return "k";
  else if(a=='3')return "s";
  else if(a=='4')return "t";
  else if(a=='5')return "n";
  else if(a=='6')return "h";
  else if(a=='7')return "m";
  else if(a=='8')return "y";
  else if(a=='9')return "r";
  else if(a=='0')return "w";
}
 
string boin(char a){
  if(a=='T')return "a";
  else if(a=='L')return "i";
  else if(a=='U')return "u";
  else if(a=='R')return "e";
  else if(a=='D')return "o";
}
 
int main(){
  string s;
  cin >> s;

  for(int i=0;i<s.size();i+=2){
    if(s[i]!='0'){
      cout << siin(s[i]) << boin(s[i+1]);
    }else{
      if(s[i+1]!='U')
        cout << siin(s[i]) << boin(s[i+1]);
      else cout << "nn";
    }
  }
  
  cout << endl;
}



Measured memory_bytes: 3224
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use maplit::*;
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        n: usize,
        arr: [i64; n],
    }
    let acc: Vec<_> = arr.into_iter().scan(0, |acc, a| {
        *acc += a;
        Some(*acc)
    }).collect();
    let s = *acc.last().unwrap();
    eprintln!("{:?}", acc);
    println!("{}",
        acc.into_iter().fold(i64::MAX, |m, a| min(m, (s - 2 * a).abs()))
    );
}


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

int main(void)
{
    int M,D;
    cin >> M >> D;
    int ans = 0;
    Rep(i, 1, M+1){
        Rep(j, 22, D+1){
            if((j%10)>1 && i == (j%10)*(j/10)){
                // pr((j%10),(j/10),(j%10)*(j/10));
                ans++;
            }
        }
    }
    pr(ans);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from itertools import permutations
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
a, b = 0, 0
for i, x in enumerate(permutations(range(1, n + 1))):
    if x == p:
        a = i
    if x == q:
        b = i
print(abs(a - b))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
#define fori(i,a,b) for(int i=(a);i<(int)(b);i++)
#define repi(i,n) fori(i,0,n)
#define forr(i,a,b) for(int i=int(b-1);i>=int(a);i--)
#define repr(i,n) forr(i,0,n)
#define all(x) (x).begin(),(x).end()
#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mp make_pair
#define pcnt __builtin_popcount
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

#define N 200010
ll a[N];
void solve(){
    ll n;cin>>n;
    repi(i,n)cin>>a[i];
    ll cur=1;
    repi(i,n){
        if(a[i]==cur)cur++;
    }
    if(cur==1){
        cout<<-1<<endl;
        return;
    }
    cout<<n-cur+1<<endl;
}

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


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

bool L[200005];

int main()
{
    ll N;
    string S;
    cin >> N >> S;
    memset(L, 0, sizeof(L));
    ll l = 0;
    REP(i, 2 * N)
    {
        if (l % 2 == 0 && S[i] == 'B')
        {
            L[i] = true;
            l++;
        }
        else if (l % 2 == 1 && S[i] == 'W')
        {
            L[i] = true;
            l++;
        }
        else
            l--;
    }
    if (l != 0)
    {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    ll r = 0;
    REP(i, 2 * N)
    {
        if (!L[2 * N - 1 - i])
            r++;
        else
            ans = (ans * r--) % MOD;
    }
    REP(i, N)
    {
        ans = (ans * (i + 1)) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 772
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI  3.14159265358979323846
#define M   1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }
    }
}
ll f(ll x,ll y)
{
    ll pro=1;
    for(ll i=x;i<=y;i++)
    {
        pro=((pro%M)*(i%M))%M;
    }
    return pro;
}
int main()
{
  ll n,a,b;
  cin>>n>>a>>b;
  ll res=fast(n,2,1e9+7);
  res--;
  ll p=1,q=1,r=1,s=1;
  p=f(n-a+1,n);
  q=f(n-b+1,n);
  r=f(1,a);
  s=f(1,b);
  r=fast(1e9+5,r,1e9+7);
  s=fast(1e9+5,s,1e9+7);
  p=((p%M)*(r%M))%M;
  q=((q%M)*(s%M))%M;
  res-=p;
  if(res<0)
  {
      res+=M;
      res%=M;
  }
  res-=q;
  if(res<0)
  {
      res+=M;
      res%=M;
  }
  cout<<res;

}












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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	string s;
	ll k;
	vector<string> v;

	cin >> s >> k;

	REP(i, k) {
		REP(j, s.size() - i) {
			v.push_back(s.substr(j, i + 1));
		}
	}

	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());

	cout << v[k - 1] << endl;
}

Measured memory_bytes: 1660
from itertools import groupby

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

C = {"s" : R, "r" : P, "p" : S}

ans = 0
for i in range(K):
    A = T[i::K]
    ans += sum((len(tuple(v)) + 1) // 2 * C[k] for k, v in groupby(A))

print(ans)

Measured memory_bytes: 4340
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a+c==2*b){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 22868
#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int n;
int head[maxn], to[maxn*2], nxt[maxn*2], tot;

inline void add_edge(int u, int v) {
    ++tot; to[tot]=v; nxt[tot]=head[u]; head[u]=tot;
    ++tot; to[tot]=u; nxt[tot]=head[v]; head[v]=tot;
}

int cnt[maxn], vis[maxn];
int son[maxn], c[maxn], sz[maxn];
ll ans[maxn];

void dfs0(int u, int f) {
    sz[u]=1;
    for(int i=head[u]; i; i=nxt[i]) {
        int v=to[i]; if(v==f) continue;
        dfs0(v,u); sz[u]+=sz[v];
        if(sz[v]>sz[son[u]]) son[u]=v;
    }
}

void dfs1(int u, int f, int ff) {
    if(!vis[c[u]]) cnt[c[u]]+=ff?sz[u]:-sz[u];
    vis[c[u]]++;
    for(int i=head[u]; i; i=nxt[i]) {
        int v=to[i]; if(v==f) continue;
        dfs1(v,u,ff);
    }
    vis[c[u]]--;
}

void dfs(int u, int f, int ff) {
    for(int i=head[u]; i; i=nxt[i]) {
        int v=to[i]; if(v==f||v==son[u]) continue;
        dfs(v,u,0);
    }
    if(son[u]) dfs(son[u],u,1);
    vis[c[u]]++;
    cnt[c[u]]=sz[u];
    for(int i=head[u]; i; i=nxt[i]) {
        int v=to[i]; if(v==f||v==son[u]) continue;
        dfs1(v,u,1);
    }
    vis[c[u]]--;
    if(f) {
        ll b=sz[u]-cnt[c[f]];
        ans[c[f]]-=b+b*(b-1)/2;
    }
    if(!ff) {
        for(int i=head[u]; i; i=nxt[i]) {
            int v=to[i]; if(v==f) continue;
            dfs1(v,u,0);
        }
        cnt[c[u]]=0;
    }
}

int main() {
    n=read();
    for(int i=1; i<=n; ++i) c[i]=read();
    for(int i=1; i<n; ++i) add_edge(read(),read());
    dfs0(1,0); dfs(1,0,1);
    for(int i=1; i<=n; ++i) {
        ll b=n-cnt[i];
        ans[i]-=b+b*(b-1)/2;
    }
    ll total=n+ll(n)*(n-1)/2;
    for(int i=1; i<=n; ++i) printf("%lld\n", total+ans[i]);
}

Measured memory_bytes: 28696
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n,y;cin>>n>>y;
    int a1=0,a5=0,a10=0;
    for(a1=0;a1<=n;a1++){
        for(a5=0;a5<=n-a1;a5++){
            a10=n-a1-a5;
            if(a1*1000+a5*5000+a10*10000==y&&a1+a5+a10==n){
                cout<<a10<<" "<<a5<<" "<<a1<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const long INF=1e9;
int main(){
	int N,T;cin>>N>>T;
	int A[N];int B[N];int temp=INF+1;
	int res=0,ans;
	rep(i,0,N){
		cin>>A[i];
		temp=min(temp,A[i]);B[i]=temp;
		if(res<A[i]-B[i]){ ans=1;res=A[i]-B[i]; }
		else if(res==A[i]-B[i]) ans++;
	}cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define si scanf
#define so printf
#define N 
#define M 
#define INF  
template<typename TP>inline bool rd(TP& r)
{
	r=0;
	char tmp=getchar();
	while(tmp<'0'||tmp>'9')
	{
		if(tmp==EOF)
			return 0;
		tmp=getchar();
	}
	while('0'<=tmp&&tmp<='9')
	{
		r=(r<<3)+(r<<1)+tmp-'0';
		tmp=getchar();
	}
	return 1;
	
} 
long long x,y;
int main()
{
	rd(x),rd(y); 
	int ans=1;
	while(x*2<=y)
	{
		++ans;
		x=x*2;
	}
	so("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll a,p;
  cin>>a>>p;
  ll ans=a*3+p;
  ans/=2;
  cout<<ans<<endl;
}


Measured memory_bytes: 888
// AOJ 1341 Longest Chain
// 2018.3.20 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// 高速数値入出力
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()   // 整数の入力（負数に対応）
{
	int n = 0, c = gc();
	if (c == '-') {
		c = gc();
		do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define MAX 1000000
typedef struct { int x, y, z, id; } T;
T t[300005], s[300005];
int dp[300005];
int c[2][1000005];
int m, n;
int a, b, C = ~(1 << 31), M = (1 << 16) - 1;

#define lowbit(x) (x & (-x))
void update(int f, int x, int v)
{
	while (x <= MAX) {
		if (c[f][x] < v) c[f][x] = v;
		x += lowbit(x);
	}
}

int getmax(int f, int x)
{
	int a = 0;
	while (x > 0) {
		if (a < c[f][x]) a = c[f][x];
		x -= lowbit(x);
	}
	return a;
}

void clear(int f, int x)
{
	while (x <= MAX) {
		c[f][x] = 0;
		x += lowbit(x);
	}
}

int cmp2(const void *a, const void *b)
{
	int t = ((T *)a)->y - ((T *)b)->y; if (t) return t;
	return ((T *)b)->z - ((T *)a)->z;
}

void cdq(int l, int r)
{
	int i, k, a, tx, m;

	if (l == r) { if (dp[l] == 0) dp[l] = 1; return; }
	m = (l + r) >> 1;
	tx = t[m + 1].x;
	cdq(l, m);
	k = 0;  for (i = l; i <= r; i++) s[k] = t[i], s[k++].id = i;
	qsort(s, k, sizeof(T), cmp2);
	for (i = 0; i < k; i++) {
		if (s[i].id <= m) {
			update(1, s[i].z, dp[s[i].id]);
			if (s[i].x != tx) update(0, s[i].z, dp[s[i].id]);
		}
		else
		{
			if (s[i].x == tx) a = getmax(0, s[i].z - 1);
			else a = getmax(1, s[i].z - 1);
			if (dp[s[i].id] < a + 1) dp[s[i].id] = a + 1;
		}
	}
	for (i = 0; i < k; i++) {
		if (s[i].id <= m) {
			clear(1, s[i].z);
			if (s[i].x != tx) clear(0, s[i].z);
		}
	}
	cdq(m + 1, r);
}

int r()
{
	a = 36969 * (a & M) + (a >> 16);
	b = 18000 * (b & M) + (b >> 16);
	return (C & ((a << 16) + b)) % MAX;
}

int cmp(const void *a, const void *b) { return ((T *)a)->x - ((T *)b)->x; }

int main()
{
	int i, ans;

	while (1) {
		m = in(), n = in() + m;
		if (m + n == 0) break;
		a = in(), b = in();
		for (i = 1; i <= m; i++) t[i].x = in() + 1, t[i].y = in() + 1, t[i].z = in() + 1;
		for (; i <= n; i++) t[i].x = r() + 1, t[i].y = r() + 1, t[i].z = r() + 1;
		qsort(t + 1, n, sizeof(T), cmp);
		memset(c, 0, sizeof(c));
		memset(dp, 0, sizeof(dp));
		cdq(1, n);
		ans = 0; for (i = 1; i <= n; i++) if (dp[i] > ans) ans = dp[i];
		printf("%d\n", ans);
	}
	return (0);
}



Measured memory_bytes: 24812
# [T, U, R, D, L, B]
T, U, R, D, L, B = *0..5
def top d
    d[0]
end
def roll d, w
    case w
    when U; d.values_at(D, T, R, B, L, U)
    when R; d.values_at(L, U, T, D, B, R)
    when D; d.values_at(U, B, R, T, L, D)
    when L; d.values_at(R, U, B, D, T, L)
    end
end
$r_data = [
        [0, 3, 5, 2, 4, 0],
        [4, 0, 1, 6, 0, 3],
        [2, 6, 0, 0, 1, 5],
    ]
$r_data += $r_data.map(&:reverse).reverse
$r_data
$r_data[5][3]
def init_d t, d
    r = $r_data[t-1][d-1]
    [t, 7 - d, r, d, 7 - r , 7 - t]
end

def board_near board, x, y
    [board[x][y + 1], board[x + 1][y], board[x][y - 1], board[x - 1][y]]
end

def get_sides d
    d[1..4]
end

loop do
    n = readline.to_i
    break if n == 0
    board = Array.new(300){Array.new(300){[]}}

    n.times do
        x = y = 150
        f, d = readline.split.map(&:to_i)
        c_d = init_d f, d
        loop do
            c_h = board[x][y].size
            near = board_near(board, x, y).map{|d| d.size() < c_h }
            sides = get_sides c_d
            res = near.zip(sides,1..4).select{|d, x, w| d}
            res = res.map{|x, s, w| [s, w]}.sort.reverse
            num, way = res[0]
            break unless !res.empty?  and num > 3
            
            dx = [0, 1, 0, -1]
            dy = [1, 0, -1, 0]
            x += dx[way - 1]
            y += dy[way - 1]
            c_d = roll c_d, way
        end
        board[x][y] << c_d
    end
            
        m = board.flatten(1).reject{|ds|ds.empty?}.map{|ds| top ds.last}
        res = m.reduce(Array.new(6){0}){|a, r| a[r-1] += 1; a}
        puts res.join(" ")
end

Measured memory_bytes: 24400
#include<bits/stdc++.h>
/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

// end of #define 

// define globals ...


//write function from here ...



int Main(){


long long num =7;
int check =1;
long long cnt ;
cin>>cnt;

set < long long > st ;
st.insert(7);

bool flag= false;


if(cnt%2==0)
{
	cout<<-1<<endl;
	return 0;
}
while(num%cnt!=0){
	num = (num%cnt) *10 +7;
	if(st.find(num) !=st.end())
	{
		flag = true;
		break;
	}
	st.insert(num);
	
	check++;
	
}
if(flag == true)
{
	cout<<-1<<endl;
	return 0;
}
cout<<check<<endl;



return 0;

}

















int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 50420
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var [h,w,k] = nexts(3);
  var c = nexts(h,1);
  var ans = 0;
  for(var y = 0; y < 1 << h; y++)for(var x = 0; x < 1 << w; x++){
    var sum = 0;
    for(var y2 = 0; y2 < h; y2++){
      if((y >> y2) & 1)continue;
      for(var x2 = 0; x2 < w; x2++){
        if((x >> x2) & 1)continue;
        if(c[y2][x2] === "#")sum++;
      }
    }
    if(sum === k)ans++;
  }
  return ans;
}

Measured memory_bytes: 32396