akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0 ; i < (n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using p = pair<int, int>;

int main()
{
    double L,ans;
    cin >> L;
    ans = L * L * L / 27;
    printf("%.12f", ans);
    //cout << ans << endl;
    return 0;
}

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

int main()
{
	map<char,int> roman;
	roman['I'] = 1;
    roman['V'] = 5;
    roman['X'] = 10;
    roman['L'] = 50;
    roman['C'] = 100;
    roman['D'] = 500;
    roman['M'] = 1000;

	string s;
	while(cin >> s)
	{
		int ans = 0;
		for(int i=0;i<s.size()-1;i++)
		{
			if(roman[s[i]] >= roman[s[i+1]]) ans += roman[s[i]];
			else ans -= roman[s[i]];	
		}
		ans += roman[s[s.size()-1]];
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int n,x,y;
  cin >> n >> x >> y;
  int d[n][n];
  vector<int>ans(n,0);
  rep(i,n) rep(j,n) d[i][j] = abs(i-j);
  x--;y--;
  rep(i,n)rep(j,n){
    d[i][j] = min(d[i][j],d[i][x]+d[y][j]+1);
    d[i][j] = min(d[i][j],d[i][y]+d[x][j]+1);
  }
  rep(i,n)rep(j,n) ans[d[i][j]]++;
  rep(i,n-1) cout << ans[i+1]/2 << endl;
}


Measured memory_bytes: 15872
from collections import defaultdict
N, C = map(int, input().split())
D = [[int(i) for i in input().split()] for _ in range(C)]

color = [[int(i) for i in input().split()] for _ in range(N)]
M = [defaultdict(int) for _ in range(3)]
for i in range(N):
    for j in range(N):
        M[(i+j) % 3][color[i][j]] += 1

ans = 10**20
for Y0 in range(C):
    for Y1 in range(C):
        for Y2 in range(C):
            if Y0 != Y1 and Y1 != Y2 and Y2 != Y0:
                Y = (Y0, Y1, Y2)
                d = 0
                for i in range(3):
                    for X, v in M[i].items():
                        d += D[X-1][Y[i]]*v
                ans = min(ans, d)
print(ans)


Measured memory_bytes: 71308
D, G = map(int, input().split())
A = [tuple(map(int, input().split())) for _ in range(D)]

ans = 10**9
for i in range(2**D):
    pt = 0
    tmp = 0
    qmax = -1
    for j, k in enumerate('{0:0{1}b}'.format(i, D)[::-1]):
        if k == '1':
            pt += A[j][0] * (j+1)*100 + A[j][1]
            tmp += A[j][0]
        else:
            qmax = j
    if pt >= G:
        ans = min(ans, tmp)
    elif qmax >= 0:
        for l in range(A[qmax][0]-1):
            pt += 100*(qmax+1)
            tmp += 1
            if pt >= G:
                ans = min(ans, tmp)
                break
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
int n;
 
int main(){
	cin>>n;
	int ans = 0;
	rep(i,8){
		int k = pow(2,i);
		if(k<=n){
		chmax(ans ,k);
		}
	}
	cout<<ans<<endl;
}
 

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1e9+7;
//ll mod = 998244353;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	//t %= mod;
	if (n % 2 == 1)t *= a;
	return t /*% mod*/;
}

//const int INF = 1001001001;
const ll INF = 1e18;

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

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}

vector<pair<ll, ll>> prime_factorize(ll N) {
	vector<pair<ll, ll>> res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0;
		while (N % a == 0) {
			++ex;
			N /= a;
		}
		res.push_back({ a, ex });
	}
	if (N != 1) res.push_back({ N, 1 });
	return res;
}


int main() {
	int n;
	cin >> n;
	int res;
	if (n >= 400 && n < 600)res = 8;
	else if (n < 800)res = 7;
	else if (n < 1000)res = 6;
	else if (n < 1200)res = 5;
	else if (n < 1400)res = 4;
	else if (n < 1600)res = 3;
	else if (n < 1800)res = 2;
	else if (n < 2000)res = 1;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3628
/*
ID: dorijan1
TASK: tu napisi ime zadatka molim te molim te ali samo ako si na usaco training
LANG: C++11
*/
#include <bits/stdc++.h>

using namespace std;

const int MOD=1000000007;
typedef long long int ll;
const ll LLINF=1ll<<60;
const char en='\n';

void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}

ll raand()
{
   return rand()*RAND_MAX+rand();
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

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

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

ll mult(ll a,ll b)
{
	return (a*b)%MOD;
}

ll pot(ll n,ll k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

ll divide(ll a,ll b)
{
	return mult(a,pot(b,MOD-2));
}

ll sub(ll a,ll b)
{
	return (a-b+MOD)%MOD;
}

ll add(ll a,ll b)
{
	return (a+b)%MOD;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

ll a,b,c,n;

int main()
{
	ios_base::sync_with_stdio(false);
	cin>>a>>b>>c>>n;
	if (n%2==0) cout<<a-b;
	else cout<<b-a;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

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

int main() {
    int n;
    cin >> n;
    vector<int> s(n), d(n), v(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d %d %d", &s[i], &d[i], &v[i]);
    }
    vector<int> S(1 << n, 7);
    for (int i = 0; i < 1 << n; ++i) {
        for (int j = 0; j < n; ++j) {
            if(i & (1 << j)) S[i] += 2*v[j];
        }
    }
    auto dp = make_v(n, 1 << n, INF<ll>);
    auto prv = make_v(n, 1 << n, 0);
    for (int i = 0; i < n; ++i) {
        dp[i][1 << i] = 0;
    }
    for (int j = 0; j < 1 << n; ++j) {
        for (int i = 0; i < n; ++i) {
            if(dp[i][j] == INF<ll>) continue;
            for (int k = 0; k < n; ++k) {
                if(!(j & (1 << k))) {
                    if(chmin(dp[k][j^(1 << k)], dp[i][j]+S[j]*abs(d[i]-d[k]))){
                        prv[k][j^(1 << k)] = i;
                    }
                }
            }
        }
    }
    stack<int> ans;
    int b = 0, a = (1 << n)-1;
    for (int i = 0; i < n; ++i) if(dp[i][a] < dp[b][a]) b = i;
    while(a){
        ans.emplace(b);
        int x = prv[b][a];
        a -= 1 << b; b = x;
    }
    while(!ans.empty()){
        printf("%d", s[ans.top()]);
        ans.pop();
        if(!ans.empty()) printf(" ");
    }
    puts("");
    return 0;
}


Measured memory_bytes: 8852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  string s; cin>>s;
  int N = s.size();
  int r = 0;
  char c = s[0];
  char d;
  for(int i=1;i<N;i++){
    d = s[i];
    if(c!=d){ r++; c = d;}
  }
  cout << r;
}

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

#define ll long long int

using namespace std;

ll solve(ll x, map<ll,ll> & memo) {
    if (x == 0LL) return 0LL;
    if (memo.find(x) != memo.end()) {
        return memo.at(x);
    }
    ll p = 0;
    for (ll tmp = x; tmp > 0; tmp = tmp>>1) {
        if (tmp & 1LL != 0LL) {
            ++p;
        }
    }
    if (p == 1) {
        memo[x] = 1;
    } else {
        if (x%p == 0) {
            memo[x] = 1;
        } else {
            ll ret = solve(x%p, memo);
            memo[x] = ret + 1;
        }
    }
    return memo[x];
}

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

    ll p = 0;
    for (ll i = 0; i < n; ++i) {
        if (s[i] == '1') ++p;
    }
    vector<ll> modUp(n);
    vector<ll> modDown(n);

    ll pUp = p + 1;
    ll pDown = p - 1;
    ll fallUp = 0;
    ll fallDown = 0;
    ll curUp = 1%pUp;
    ll curDown = 1;
    if (pDown == 0) {
        curDown = 0;
    }
    for (ll i = n - 1; i >= 0; --i) {
        modUp[i] = curUp;
        modDown[i] = curDown;
        if (s[i] == '1') {
            fallUp += curUp;
            fallDown += curDown;
            fallUp %= pUp;
            if (pDown != 0) fallDown %= pDown;
        }
        curUp *= 2;
        curUp %= pUp;
        curDown *= 2;
        if (pDown != 0) curDown %= pDown;
    }

    map<ll,ll> memo;
    memo[0] = 0LL;
    for (ll i = 0; i < n; ++i) {
        ll x;
        if (s[i] == '1') {
            if (pDown == 0) {
                x = 0;
                cout << 0 << endl;
                continue;
            } else {
                x = fallDown - modDown[i];
                x = (x + pDown) % pDown;
            }
        } else {
            x = fallUp + modUp[i];
            x = (x + pUp) % pUp;
        }

        ll ret = solve(x, memo);
        cout << ret + 1 << endl;
    }
}


Measured memory_bytes: 7880
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n,m;
int lft,rit;
int l=0,r=1e9;
int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        scanf("%d%d",&lft,&rit);
        l=max(l,lft);
        r=min(r,rit);
    }
    cout<<max(r-l+1,0)<<endl;
    return 0;
}

Measured memory_bytes: 256
N, D = map(int, input().split())
point = []
for i in range(N):
    point.append(list(map(int, input().split())))

ct = 0
D2 = D * D
for i in point:
    if (i[0]**2 + i[1]**2) <= D2:
        ct += 1

print(ct)

Measured memory_bytes: 45308
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c=0,d=0;
    cin>>a;

    vector<int>v;
    for(int i=1;i<=a;i++)
    {
        cin>>b;
        v.push_back(b);
        c+=b;
    }
        if(a==1)
    {
        cout<<"0\n";
    }
    else{
    if(c%a==0)
    {

    c=c/a;
    }
    else
    {
        if(c%a>a/2)
        c=c/a+1;
        else
            c=c/a;
    }
    //cout<<c<<endl;
    sort(v.begin(),v.end());

   for(int i=0;i<a;i++)
   {
      d+=abs((v[i]-c)*(v[i]-c));
   }
    cout<<d<<endl;}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
int main(){
 int a,b;
 cin>>a>>b;
 cout<<b*2-a; 
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int K,S;
	scan(K);scan(S);
	int ans=0;
	rep(i,K+1){
		rep(j,K+1){
			int k=S-i-j;
			if(k>=0&&k<=K) ans++;
		}
	}
	prin(ans);
	return 0;
}


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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ll N;
    ld D;
    cin >> N >> D;
    ll ans = 0;
    for(i = 0; i < N; i++) {
        ld x, y;
        cin >> x >> y;
        if(sqrt(x * x + y * y) <= D)
            ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; 
typedef long long int ll;
#define ull unsigned long long int
#define all(a) a.begin(),a.end()s
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define hell 1000000007
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define pb push_back
#define MAX 10000001
int main()
{
    ll n,m;
    cin>>n>>m;
    ll ans=0;
    ans = (n*(n-1))/2;
    ans+= (m*(m-1))/2;
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
      int n; cin>>n;
      vector<vector<int>> info(n-1,vector<int>(3,0));
      rep(i,0,n-1) cin>>info[i][0]>>info[i][1]>>info[i][2];
      rep(i,0,n-1){
            int time=info[i][1]+info[i][0];
            rep(j,i+1,n-1){
                  time=max(info[j][1],(int)ceil((double)time/info[j][2])*info[j][2])+info[j][0];
            }
      cout<<time<<endl;
      }
      cout<<0<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
string s;
int main(){
	cin>>s;
	for(int i=0;i<s.size()-8;i++)cout<<s[i];
	cout<<endl;
}

Measured memory_bytes: 256
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
S = sys.stdin.readline().rstrip()
Q = int(sys.stdin.readline())
K = list(map(int, sys.stdin.readline().split()))

S = np.array(list(S), dtype='S1')
SD = S == b'D'
SM = S == b'M'
SC = S == b'C'
RD = SD.cumsum()
RM = SM.cumsum()


def solve(k):
    D = RD.copy()
    D[k:] -= RD[:-k]
    M = RM.copy()
    M[k:] -= RM[:-k]

    DM = D * SM
    DM[k:] -= M[k - 1:-1] * SD[:-k]
    DM = DM.cumsum()
    return (DM * SC).sum()


for k in K:
    ans = solve(k)
    print(ans)


Measured memory_bytes: 65392
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll n,X;
  cin>>n>>X;
  ll p[n+1]={};
  ll b[n+1]={};
  ll w[n+1]={};
  p[0]=1;
  w[0]=1;
  for(int i=1;i<=n;i++){
    p[i]=p[i-1]*2+1;
    b[i]=b[i-1]*2+2;
    w[i]=p[i]+b[i];
    //cout<<i<<" "<<p[i]<<" "<<b[i]<<endl;
  }

  ll ans=0;
  ll sum=0;
  ll x=X;
  for(int i=n;i>=0;i--){
    //cout<<i<<" "<<w[i]<<" "<<x<<" "<<ans<<endl;
    if(x==w[i]-1){
      ans=ans+p[i];
      break;
    }else if(x==w[i]){
      ans=ans+p[i];
      break;
    }else if(x==w[i]+1){
      ans=ans+p[i]+1;
      break;
    }else if(w[i]<x){
      x=x-w[i]-1;
      ans=ans+p[i]+1;
      i++;
    }else if(x<w[i]){
      x--;
    }

    if(x<=0) break;
  }

  cout<<ans<<endl;


  return 0;
}


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

#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cerr << #v "=" << (v) << endl;
#define ppa(v) cerr << "- " << #v << endl; rep(i,v.size()) cerr << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define INF 0x3f3f3f3f
#define LLINF 1000111000111000111LL
#define MOD 1000000007
#define TIME system("date +%M:%S.%N")
using Graph = vector<vector<int>>;
using ll = long long;
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// ABC107C 方針
// 区間の[i,i+k-1]のうち、最小値を求める
// 原点から両端への最小距離を加える

int main() {
  int n,k;cin>>n>>k;
  vector<int> x(n);rep(i,n) cin>>x[i];

  int ans = INF;
  rep(i,n-k+1) {
    int L = i, R = i+k-1;
    int dist = x[R] - x[L] + min(abs(x[L]), abs(x[R]));
    ans = min(ans, dist);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    K=int(input())
    c=1
    for _ in range(N):
        if c>K:
            c+=K
        else:
            c*=2
    print(c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
while True:
    a,op,b = input().split()
    if (op == "+"):
            print(int(a)+int(b))
    elif (op == "-"):
            print(int(a)-int(b))
    elif (op == "*"):
            print(int(a)*int(b))
    elif (op == "/"):
            print(int(int(a)/int(b)))
    elif (op == "?"):
            break


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

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

using namespace std;
using lint=long long;

int main(){
	lint n; cin>>n; n--;

	int len=0;
	lint k=1;
	while(1){
		len++;
		k*=26;
		if(n<k){
			string ans(len,'?');
			rep(i,len){
				ans[len-1-i]='a'+n%26;
				n/=26;
			}
			cout<<ans<<'\n';
			break;
		}
		n-=k;
	}

	return 0;
}


Measured memory_bytes: 3588
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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
















int main(){
    ll n, r;
    cin >> n >> r;
    if(n >= 10){
        cout << r << endl;
    }
    else{
        cout << r + 100 * (10 - n) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long int a=0,b=0;
	int c;
	cin>>a>>b>>c;
	for(int i=0;i<c;i++)
	{
		if(i%2==0){
				if(a%2==1){a=(a-1)/2;b=b+a;}
			else if(a%2==0){a=a/2;b=b+a;}
		}
		else if(i%2==1){
			if(b%2==1){b=(b-1)/2;a=a+b;}
			else if(b%2==0){b=b/2;a=a+b;}
		}	
	}
	cout<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int n , m , X , Y ;
    cin >> n >> m >> X >> Y ;

    int x[n] ;
    int y[m] ;
    for(int i =  0 ; i < n ; i++){
        cin >> x[i] ;
    }
    for(int j = 0 ; j < m ; j++){
        cin >> y[j] ;
    }

    sort(x , x+ n) ;
    sort(y , y + m ) ;
    
    bool flag = false ;
    
    if(X>=Y){
        flag = true ;
    }
    int now = x[n-1] +1;
    for(int k = 0 ; k < x[n-1] - y[0] ; k++ ){
         if(now <= X || now > Y){
            flag = true ;
         }
         now ++ ;
    }
    
     if(x[n-1] < y[0] && x[n-1] < Y && y[0] > X) cout << "No War" << endl;
    else cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h;
    int w;
    while(cin>>h>>w){
        if(h == 0 && w == 0)
            break;

        for(int j = 0; j < h; j++){
            for(int i = 0; i < w; i++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3112
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        if (a < 1200) {
            System.out.println("ABC");
        } else if (a < 2800) {
            System.out.println("ARC");
        } else {
            System.out.println("AGC");
        }
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

const Int MO = 1000000007;
int A[200050], B[200050];
Int dp[4096][4096], inv[8192], fact[8192], finv[8192];
const int Z = 2048;

Int comb(int n, int r) {
  return fact[n] * finv[r] % MO * finv[n - r] % MO;
}

Int func(int u, int v) {
  return comb(A[u] + A[v] + B[u] + B[v], A[u] + A[v]);
}

int main() {
  inv[1] = 1;
  for (int i = 2; i < 8192; ++i) {
    inv[i] = MO - MO / i * inv[MO % i] % MO;
  }

  fact[0] = finv[0] = 1;
  for (int i = 1; i < 8192; ++i) {
    fact[i] = (fact[i - 1] * i) % MO;
    finv[i] = (finv[i - 1] * inv[i]) % MO;
  }

  int N = in();
  for (int i = 0; i < N; ++i) {
    A[i] = in();
    B[i] = in();
    dp[Z - A[i]][Z - B[i]] += 1;
  }

  for (int a = 0; a < 4096; ++a) {
    for (int b = 0; b < 4096; ++b) {
      if (a > 0) dp[a][b] += dp[a - 1][b];
      if (b > 0) dp[a][b] += dp[a][b - 1];
      dp[a][b] %= MO;
    }
  }

  Int res = 0;
  for (int i = 0; i < N; ++i) {
    (res += dp[Z + A[i]][Z + B[i]]) %= MO;
    (res += MO - func(i, i)) %= MO;
  }
  (res *= inv[2]) %= MO;

  printf("%lld\n", res);

  return 0;
}


Measured memory_bytes: 133120
#include <stdio.h>

#define ll long long

int main(void){
    ll x, i = 0;
    ll sum = 100;

    scanf("%lld", &x);

    while(1){
        sum += sum * 0.01;
        i++;
        if(sum >= x) break;
    }

    printf("%lld\n", i);

    return 0;

}

Measured memory_bytes: 1700
#include<bits/stdc++.h>
using namespace std;
/*
2019/05/25
*/
int main(){
  int n,m;
  cin>>n>>m;
  int l[m];
  int r[m];
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    l[i]=a;r[i]=b;
  }
  
  int min=l[0];int max=r[0];
  /*i番目のゲートで使えるカードの条件
  l[i],k,r[i]
  */
  for(int i=1;i<m;i++){
    if(min<l[i])min=l[i];
    if(max>r[i])max=r[i];      
  }
  int ans=max-min;
  if(ans<0)ans=0;
  else ans++;
  
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
x1, y1, x2, y2 = map(int, input().split())

if x1 <= x2:
    if y1 < y2:
        print(x2 - (y2 - y1), y2 + (x2 - x1), x1 - (y2 - y1), y1 + (x2 - x1))
    else:
        print(x2 + (y1 - y2), y2 + (x2 - x1), x1 + (y1 - y2), y1 + (x2 - x1))
else:
    if y1 < y2:
        print(x2 - (y2 - y1), y2 - (x1 - x2), x1 - (y2 - y1), y1 - (x1 - x2))
    else:
        print(x2 + (y1 - y2), y2 - (x1 - x2), x1 + (y1 - y2), y1 - (x1 - x2))


Measured memory_bytes: 3064
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, A, B, S int
	var C float64
	fmt.Scan(&N)

	for i := 0; i < N; i++ {
		fmt.Scan(&A, &B)
		if abs(A-B) <= 1 {
			fmt.Println((min(A, B) - 1) * 2)
		} else {
			S = A * B
			C = math.Sqrt(float64(S))
			if isFloatInt(C) {
				C--
			}
			ic := int(C)
			if ic*(ic+1) >= S {
				fmt.Println((ic - 1) * 2)
			} else {
				fmt.Println(ic*2 - 1)
			}
		}
	}
}

func abs(x int) int {
	if x < 0 {
		return -x
	} else {
		return x
	}
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func isFloatInt(floatValue float64) bool {
	return math.Mod(floatValue, 1.0) == 0
}


Measured memory_bytes: 512
#include<stdio.h>

int main(){
  
  int n;
  int A[1000];
  int a,i=0,j,v,k;

  scanf("%d",&n);
  if((n<1)||(100<n)){
    fprintf(stderr,"error n\n");
    return 0;
  }

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  for(k=0;k<n;k++){
    if(k==n-1) printf("%d",A[k]);
    else printf("%d ",A[k]);
  }
  printf("\n");
  

  for(i=1;i<n;i++){
    v=A[i];
    j=i-1;
    while((j>=0)&&(A[j]>v)){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    
 for(k=0;k<n;k++){
   if(k==n-1) printf("%d",A[k]);
   else printf("%d ",A[k]);
    
  }
 printf("\n");

  }



  
  return 0;
}

      



Measured memory_bytes: 2128
//A

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

#define MAX 102

string s;
set<char> ss;
int main(){
	cin >> s;
	for (int i = 0; i < s.size(); i++){
		ss.insert(s[i]);
	}
	if (ss.size() == 1){
		puts("0");
		return 0;
	}
	int ans = INT_MAX;
	for (auto it = ss.begin(); it != ss.end(); it++){
		char target = (*it);
		string tmp = s;
		bool ng = true;
		int op = 0;
		while (ng){
			ng = false;
			op++;
			for (int i = 0; i + 1 < tmp.size(); i++){
				if (tmp[i] == target || tmp[i + 1] == target){
					tmp[i] = target;
				}
				else{
					ng = true;
				}
			}
			tmp.pop_back();
		}
		ans = min(ans, op);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<iostream>
#include<fstream>
#include<iomanip>

using namespace std;

int W, H, N;
int data[100];

int main(){
	scanf("%d%d%d", &W, &H, &N);
	for (int i = 0; i < N; ++i){
		scanf("%d", &data[i]);
	}

	int cnt = 0;
	int curAx = 1, curAy = 1;
	int curBx = 1, curBy = 2;
	for (int i = 0; i < N; ++i) {
		if (data[i] == 0) {
			if (curAy == 1 && curAx != W)  {
				curAx++;
			}
			else if (curAx == W && curAy < H) {
				curAy++;
			}
			else if (curAy == H) {
				curAx--;
			}
		}
		else {
			if (curBy == 2 && curBx != W - 1) {
				curBx++;
			}
			else if (curBx == W - 1 && curBy < H - 1) {
				curBy++;
			}
			else if (curBy == H - 1) {
				curBx--;
			}
		}

		if (curAx == curBx && ((curAy == 1 && curBy == 2) || (curAy == H && curBy == H-1))) {
			++cnt;
		}
		else if (curAy == curBy && curAx - curBx == 1) {
			++cnt;
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 1192
i=61,f[9],c,m,s;main(y){for(;s?++f[y*12+*f+"=>?2J13IK <@V&"[--s]]:~scanf("%d,%d,%d",f,&y,&s)?s*=5:++i<180?i%12>1?(y=f[i])?y>m?m=y:1:++c:1:!printf("%d\n%d\n",c,m););}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define re register
using namespace std;
#define N 100002
struct data{
	int bel,year,id;
	bool operator < (const data &tmp) const{
		return year<tmp.year;
	}
}a[N];
int n,m,ans1[N],ans2[N],tot[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i)
		scanf("%d%d",&a[i].bel,&a[i].year),a[i].id=i;
	sort(a+1,a+m+1);
	for(int i=1;i<=m;++i){
		int r1=++tot[a[i].bel];
		ans1[a[i].id]=a[i].bel;
		ans2[a[i].id]=r1;
	}
	for(int i=1;i<=m;++i){
		for(int j=10;j*ans1[i]<1000000;j*=10) printf("0");
		printf("%d",ans1[i]);
		for(int j=10;j*ans2[i]<1000000;j*=10) printf("0");
		printf("%d\n",ans2[i]);
	}
	return 0;
}

Measured memory_bytes: 3840
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0

if x == sum(a):
    print(N)
    exit()

for i in range(N):
    x -= a[i]
    if x < 0:
        print(i)
        exit()
else:
    print(N - 1)

Measured memory_bytes: 3060
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        n: usize, k: usize,
        p_vec: [usize; n],
        c_vec: [isize; n],
    }
    // loopが起こるので、それをキャッチする
    // loopが正なら繰り返すだけ繰り返す、端数を処理する、負ならloop内で最も大きい値で止まる
    // 1..=nのすべてのスタートでそれを見る。ループを記憶しておいてそれがあるとそのループを計算すると早いとは思う

    let mut ans = -1e10 as isize ;

    for s in 0..n {
        // println!("----0-----");
        let mut start = p_vec[s] - 1;
        let mut sum = c_vec[start];
        let mut values = vec![sum];
        // println!("---1----");
        loop {
            start = p_vec[start] - 1;
            sum += c_vec[start];
            values.push(sum);
            if start == s { break; }
        } 
        // println!("{}: {:?}", s, values);

        if values.len() > k {
            ans = std::cmp::max(ans, *values[..k].iter().max().unwrap());
            continue;
        }

        if values[values.len() - 1] < 0 {
            ans = std::cmp::max(ans, *values.iter().max().unwrap());
            continue;
        }

        if k % values.len() == 0 {
            let tmp_ans_1 = values[values.len() - 1] * ( k / values.len() ) as isize;
            let tmp_ans_2 = tmp_ans_1 - values[values.len() - 1] + values.iter().max().unwrap();
            let tmp_ans = std::cmp::max(tmp_ans_1, tmp_ans_2);
            ans = std::cmp::max(ans, tmp_ans)
        } else {
            let mut tmp_ans_1 = values[values.len() - 1] * ( k / values.len() ) as isize;
            let tmp_ans_2 = tmp_ans_1 - values[values.len() - 1] + values.iter().max().unwrap();
            tmp_ans_1 += values[..(k - values.len() * (k / values.len()))].iter().max().unwrap();
            let tmp_ans = std::cmp::max(tmp_ans_1, tmp_ans_2);
            ans = std::cmp::max(ans, tmp_ans)
        }
    }
    println!("{}", ans);
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


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

typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;

set <ll> st ;

int main()
{
    ll n, x ;
    cin >> n ;
    for (int i = 0; i < n; i++) {
        cin >> x ;
        st.insert(x) ;
    }
    if (st.size() == n) cout << "YES" << endl ;
    else    cout << "NO" << endl ;
}


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

int main(void){
    int n; cin >> n;
    int ans=pow(10,9);
    for(int i=0;i<n;i++){
        int a; cin >> a;
        int cnt=0;
        while(a%2==0) cnt++,a/=2;
        if (cnt < ans) ans = cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
S = [int(input()) for i in range(n)]
S.sort()
x = sum(S)
if x % 10 == 0:
    for i in range(n):
        if S[i] % 10 != 0:
            x -= S[i]
            print(x)
            exit()
    print(0)
else:
    print(x)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int n,m;cin >> n >> m;
    vector<int> G[n];
    vector<double> dp(n,0);
    for (int i = 0; i < m; i++) {
        int s,t;cin >> s >> t;
        s--,t--;
        G[s].pb(t);
    }
    for (int i = n-2; i >= 0; i--) {
        for (int j = 0; j < G[i].size(); j++) {
            dp[i] += dp[G[i][j]] + 1;
        }
        dp[i] /= G[i].size();
    }
    double ans = dp[0];
    for (int i = 0; i < n-1; i++) {
        if(G[i].size()==1) continue;
        vector<double> dp1 = dp;
        double mx = 0;
        double t = 0;
        for (int j = 0; j < G[i].size() ; j++) {
            mx = max(mx,dp1[G[i][j]]+1);
        }
        dp1[i] = (dp[i] * G[i].size() - mx) / (G[i].size() - 1);
        for (int j = i-1; j >= 0; j--) {
            double sum = 0;
            for (int k = 0; k < G[j].size(); k++) {
                sum += dp1[G[j][k]]+1;
            }
            dp1[j] = sum / G[j].size();
        }
        ans = min(ans,dp1[0]);
    }
    cout << setprecision(30) << fixed<<ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int a, b, c, d; cin >> a >> b >> c >> d;
    int time[101] = {0};
    int ans = 0;
    for(int i = a; i < b; ++i)time[i] = 1;
    for(int i = c; i < d; ++i)if(time[i])++ans;
    cout << ans << endl; return 0;
}

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

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

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

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

int main(void)
{
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    rep(i, k, n + 1)
    {
        ans += (n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2) - (i * (i - 1) / 2) + 1;
        ans %= MOD;
    }
    cout << (ans + 1) % MOD << endl;
}

Measured memory_bytes: 3560
using System;
using System.Collections.Generic;
 
namespace ALDS1_3
{
    class Program
    {
        static int Calc(string[] a)
        {
            var stack = new Stack<int>();
            foreach(var e in a)
            {
                if ("+-*/".Contains(e))
                {
                    var y = stack.Pop();
                    var x = stack.Pop();
                    var aque = e == "+" ? x + y:
                               e == "-" ? x - y:
                               e == "*" ? x * y:
                                          x / y;
                    stack.Push(aque);
                }
                else
                    stack.Push(int.Parse(e));
            }
            return stack.Pop();
        }

        static void Main()
        {
            Console.WriteLine(Calc(Console.ReadLine().Split()));
        }
    }
}

Measured memory_bytes: 10676
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int n,x,y,ans[N];
int dis(int x,int y){return abs(x-y);}
int getdis(int i,int j)
{
    int ans=dis(i,j);
    ans=min(dis(i,x)+1+dis(y,j),ans);
    ans=min(dis(i,y)+dis(x,j)+1,ans);
    return ans;
}
int main()
{
    scanf("%d%d%d",&n,&x,&y);
    if(x>y) swap(x,y);
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
        ans[getdis(i,j)]++;
    for(int i=1;i<n;i++) printf("%d\n",ans[i]);
}


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

#define ll long long
#define pb push_back
#define an "\n"

using namespace std;


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	string a=s;
	transform(a.begin(), a.end(), a.begin(), ::toupper);
	if(s==a) {
		cout << "A";
	}
	else {
		cout << "a";
	}
}



Measured memory_bytes: 3604
N,K=map(int,input().split())

bin_k=format(K,'b')
bin_len_k=len(bin_k)

def f(x):
    bin_x=format(x,'b')
    sa=bin_len_k-len(bin_x)
    if sa<1: sa=0

    bin_x_=bin_x+'0'*sa
    if int(bin_x_,2)<int(bin_k,2):
        return sa+1
    else:
        return sa

ans=0
for i in range(1,N+1):
    ans+=(1/N)*(1/2)**f(i)


print(ans)

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

typedef long long ll;
int a[10];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int x,n;
	cin>>x>>n;
	set<int> st;
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		st.insert(t);
	}
	
	if(!st.count(x)){
		cout<<x;
	}
	else{
		int a=x-1,b=x+1;
		while(true){
			if(!st.count(a)){
				cout<<a;
				return 0;
			}
			if(!st.count(b)){
				cout<<b;
				return 0;
			}
			a--;
			b++;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll mod = 1e9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;};


int main() {
    ll n, k;
    cin >> n >> k;
    vector<int> as(n);
    rep(i, n) cin >> as[i]; 
    ll cnt1 = 0, cnt2 = 0;
    rep(i, n) {
        rep(j, n) {
            if (as[i] > as[j]) {
                cnt1++; 
                if (i < j) cnt2++;
            }
        }
    }
   	
    ll kk = k * (k - 1);
	kk /= 2;
	kk %= mod;
    ll ans = (kk*cnt1)%mod + k*cnt2%mod;
    cout << ans%mod << endl;
    return 0;
}

Measured memory_bytes: 256
import random
import time
start=time.time()
h,w,m=map(int,input().split())
hh=[[0,i]for i in range(h)]
ww=[[0,i]for i in range(w)]
hw=set()
for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  hh[a][0]+=1
  ww[b][0]+=1
  hw.add((a,b))
ww.sort(reverse=1)
s=ww[0][0]
w=[]
for x,j in ww:
  if x==s:w.append(j)
hh.sort(reverse=1)
t=hh[0][0]
hhh=[]
for x,i in hh:
  if x==t:hhh.append((x,i))
ans=[]
random.shuffle(w)
for j in w:
  for x,i in hhh:
    if (i,j) in hw:
      ans.append(s+x-1)
    else:
      exit(print(s+x))
  if time.time()-start>=1.7:
    m=ans[0]
    if h-100000<=len(hhh)<=h-random.randint(100,1000):m+=1
    exit(print(m))
print(ans[0])

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int n;
	std::cin >> n;
	std::vector<int> b(n-1);
	std::vector<int> a(n);
	for (size_t i = 0; i < b.size(); i++) {
		std::cin >> b[i];
	}
	a[0] = b[0];
	a[n-1] = b[n-2];

	for (int i = n-2; i > 0; i--) {
		a[i] = min(b[i], b[i-1]);
	}

	int ans = 0;
	for (size_t i = 0; i < a.size(); i++) {
		// std::cout << a[i] << '\n';
		ans += a[i];
	}


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	cout << 0 << endl;
	vector<string> res(n,"a");
	cin >> res[0];

	int l = 0, r = n;
	rep(_,19){
		int mid = (l + r) / 2;
		if(mid == l) mid = r;
		//cout << l << ' ' << r << ' ' << res[l] << endl;;
		cout << mid << endl;

		cin >> res[mid];
		if(res[mid][0] == 'V') break;

		bool f = res[mid] == res[l];
		if((mid - l) % 2 == 1) f ^= 1;

		if(f){
			l = mid;
		}else{
			r = mid;
		}
	}
}


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

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> // Include for built in treap
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
const int MOD = 1e9 + 7;
#define ll long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define si set<int>
#define mpii map<int, int>
#define prq priority_queue
#define sz(s) (int) s.size()
#define pf(a) printf("%d\n",a)
#define sc1(a) scanf("%d",&a)
#define sc2(a, b) scanf("%d%d",&a,&b)
#define pi 2 * acos (0.0)
#define inf 1e9
#define dbg cout<<"ok"<<endl;
#define FOR(i, j, k) for(int i=(j); i<(k); i++)
#define REV(i, j, k) for(int i=(n-1); i>=k; i--)
#define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define mem(x, y) memset(x, y, sizeof(x))
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_ds;
const double EPS = 1e-9;
const int MXX = 1e5 + 5;

int main()
{
    int ar[100002];
    int ar1[100002];
    int n;
    scanf("%d",&n);
    for(int i=0;i<=n-1;i++)
    {
        scanf("%d",&ar[i]);
    }
    for(int i=1;i<=n-1;i++)
    {
        if(i==1)
        {
          ar1[i]=abs(ar[i]-ar[i-1]);
        }
        else if(i==2)
        {
            ar1[i]=min(abs(ar[i]-ar[i-2]),ar1[i-1]+abs(ar[i]-ar[i-1]));
        }

        else
        ar1[i] =min(ar1[i-2]+abs(ar[i]-ar[i-2]),ar1[i-1]+abs(ar[i]-ar[i-1]));
       }

      printf("%d",ar1[n-1]);

       return 0;
}


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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
using vi  = vector<int>;
using vvi = vector<vi>;
constexpr double inf = 1e10;
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

vvi data;

#define maxLoop 100
double f(double x, double y){
  double minv = inf;
  rep(i,data.size()){
    double nrm1 = pow(x-data[i][0],2) + pow(y-data[i][1],2);
    double nrm2 = pow(data[i][2],2) - nrm1;
    chmin(minv, nrm2);
  }
  // dump(x,y,minv);
  return minv;
}

double searchy(double x, double left = -100, double right = 100){
  for(int loop = 0; loop < maxLoop; ++loop){
    if(f(x, (left*2+right)/3) > f(x, (left+right*2)/3)){
      right = (left + right * 2) / 3;
    }else{
      left = (left * 2 + right) / 3;
    }
  }
  return f(x,(right + left) * 0.5);
}
double searchx(double left = -100, double right = 100){
  for(int loop = 0; loop < maxLoop; ++loop){
    //dump(left, right, searchy((left*2+right)/3), searchy((left+right*2)/3));
    if( searchy((left*2+right)/3) > searchy((left+right*2)/3) ){
      right = (left + right * 2) / 3;
    }else{
      left = (left * 2 + right) / 3;
    }
  }
  //dump((right+left)/2);
  return searchy((right+left)*0.5, -100, 100);
}

signed main(){
  int n;
  while(cin >> n, n){
    data.clear();
    data.resize(n,vi(3));
    rep(i,n) rep(j,3) cin >> data[i][j];
    printf("%.10lf\n", sqrt(searchx()));
  }
}


Measured memory_bytes: 3068