akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
vector<int> a;
vector<int> b;
int c[100001];
int main(){
    int n;cin >> n;
    a.resize(n);
    
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    
    for(auto &i:a) c[i]++;
    for(int i=1;i<100001;i++){
        c[i] = c[i]+c[i-1];
    }
    b.resize(n);
    
    for(int j=n-1;j>=0;j--){
        
        b[c[a[j]]-1] = a[j];
        c[a[j]]--;
    }
    for(int i=0;i<b.size();i++){
        cout << b[i];
        if(i!=n-1) cout << " ";
        else cout << endl;
    }
}




Measured memory_bytes: 18872
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf
import Debug.Trace

import Control.Monad.ST
import Data.Array.ST

primeFactors = f 2
	where
		f p n
			| n <= 1 = []
			| p > n = [ n ]
			| n `mod` p == 0 = p : f p ( n `div` p )
			| otherwise = f ( p + 1 ) n

readInt = ( readLn :: IO Int )
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readLn >>= print . foldl ( \a b -> ( a * b ) `mod` 1000000007 ) 1 . map ( fromIntegral . succ . length ) .  group . sort . concatMap primeFactors . flip take [ 1 .. ]

Measured memory_bytes: 1916
#include <iostream>

int main(){
   int N, K;
   std::cin >> N >> K;
   int x[N];
   for(int i=0; i<N; ++i){
      std::cin >> x[i];
   }
   
   int ans = (abs(x[N-1])+abs(x[0]))*2;
   for(int i=0; i<=N-K; ++i){
      int d = abs(x[i]) + abs(x[i+K-1]-x[i]);
      if(ans>d) ans = d;
      d = abs(x[i+K-1]) + abs(x[i+K-1]-x[i]);
      if(ans>d) ans = d;
   }

   std::cout << ans << std::endl;
   return 0;

}


Measured memory_bytes: 640
N = int(input())
S = input()

ans = float('inf')

W = {'W':0, 'E':0}
n = S.count('E')
E = {'W':N-n, 'E':n}

for s in S:
  E[s] -= 1

  ans = min(ans, E['E'] + W['W'])

  W[s] += 1

print(ans)

Measured memory_bytes: 3700
def m():
    n, k = map(int, input().split())
    a = [0] + list(map(int, input().split()))
    visited = [[] for _ in range(n + 1)]
    visited[1].append(0)
    cur = 1
    i = 1
    while True:
        cur = a[cur]
        visited[cur].append(i)
        i += 1
        if len(visited[cur]) >= 2:
            break

    if k <= visited[cur][0]:
        now = 1
        for p in range(1, k+1):
            now = a[now]
        return now
    else:
        tmp = k - visited[cur][0]
        MOD = visited[cur][1] - visited[cur][0]
        count = tmp % MOD
        now = 1
        for p in range(1, count+1+visited[cur][0]):
            now = a[now]
        return now


print(m())


Measured memory_bytes: 43516
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

template<typename T>
struct Monoid {
  T id;
  fn<T(T, T)> op;
  Monoid(T e, fn<T(T, T)> f)
    : id(e), op(f) {
  }
};

template<typename T>
class SegT {
private:
  vector<T> data;
  Monoid<T> monoid;
  int size = 1;

public:
  SegT(const int &n, const Monoid<T> &m = Monoid<int>(INF, [](int a, int b) { return min(a, b); }))
    : monoid(m) {
    while (size < n) size *= 2;
    data = vector<T>(2 * size, monoid.id);
  }

  void update(int i, const T &x) {
    i += size;
    data[i]                = x;
    while (i /= 2) data[i] = monoid.op(data[i * 2], data[i * 2 + 1]);
  }

  // fold [a, b) by monoid.op
  T fold(const int &a, const int &b, const int &k = 1, const int &l = 0, int r = -1) {
    if (r == -1) r = size;
    if (r <= a || b <= l) return monoid.id;
    if (a <= l && r <= b) return data[k];
    return monoid.op(fold(a, b, k * 2, l, (l + r) / 2),
                     fold(a, b, k * 2 + 1, (l + r) / 2, r));
  }

  const T &operator[](const int &i) const {
    return data[i + size];
  }
};

void solve() {
  int n, q;
  cin >> n >> q;
  SegT<int> t(n, Monoid<int>(0, plus<int>()));
  while (q--) {
    int com, x, y;
    cin >> com >> x >> y;
    x--;
    if (com) {
      cout << t.fold(x, y) << endl;
    } else {
      t.update(x, t[x] + y);
    }
  }
}

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

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


int main()
{
    int W, H, x, y;
    cin >> W >> H >> x >> y;

    cout << (double) W*H/2 << endl;
    if(W%2 == 0 and x == W/2 and H%2 == 0 and y == H/2) cout << 1 << endl;
    else cout << 0 << endl;
    
    return 0;
}

Measured memory_bytes: 256
T1, T2 = [int(i) for i in input().split()]
A1, A2 = [int(i) for i in input().split()]
B1, B2 = [int(i) for i in input().split()]

d1 = T1*(A1-B1)
d2 = T2*(B2-A2)

if d1 == d2:
    print('infinity')

if d1 * (d2 - d1) < 0:
    print(0)

if d1 * (d2 - d1) > 0:
    if d1 % (d2 - d1) != 0:
        print(d1 // (d2 - d1) * 2+ 1)
    else:
        print(d1 // (d2 - d1) * 2)

Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9 + 7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int N;
string S;

inline vector<int> Z_algorithm(string S) {
	vector<int> Z(S.size());
	Z[0] = S.size();
	int i = 1, j = 0;
	while(i < S.size()){
		while(i + j < S.size() && S[j] == S[i + j]) j++;
		Z[i] = j;

		if(j == 0){
			i++;
			continue;
		}
		int k = 1;
		while(k + Z[k] < j){
			Z[i + k] = Z[k];
			k++;
		}
		i += k;
		j -= k;
	}
	return Z;
}

signed main() {
	cin >> N >> S;
	ll ans = 0;
	rep(i, N) {
		string T = S.substr(i, N - i);
		vector<int> v = Z_algorithm(T);
		for (int j = 1; j < v.size(); j++) {
			if(v[j] <= j) ans = max(ans, (ll)v[j]);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
	double x, y, x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	x = fabs(x2 - x1);
	y = fabs(y2 - y1);
	if( x == 0 ) {
		cout << fixed << setprecision(5) << y << "\n";
		return 0;
	} else if( y == 0 ) {
		cout << fixed << setprecision(5) << x << "\n";
		return 0;
	}

	int c = 0;

	double v = x*x + y*y,
	       d = max(x, y),
		   eps = 0.00001;
	do
	{
		d = (d + v / d ) / 2.0L;
		++c;
	}
	while( c < 5 );

	cout << fixed << setprecision(5) << d << "\n";

	return 0;
}

Measured memory_bytes: 1288
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <bitset>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 + 100, INF = 1e9 * 1e4 + 10, MOD = 1e9 + 7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll dist[SIZE];

void sol(ll k) {
    deque<ll> q;

    for (int i = 0; i < k; i++) dist[i] = INF;
    dist[1] = 0;
    q.push_back(1);
    while (!q.empty()) {
        ll v = q.front();
        q.pop_front();

        ll to = (v + 1) % k;
        if (dist[to] > dist[v] + 1) {
            dist[to] = dist[v] + 1;
            q.push_back(to);
        }

        to = (v * 10) % k;
        if (dist[to] > dist[v]) {
            dist[to] = dist[v];
            q.push_front(to);
        }
    }

    cout << dist[0] + 1;
}

int main()
{
    fastInp;

    ll t = 1;

    while (t--) {
        ll k;
        cin >> k;
        sol(k);
    }

    return 0;
}

Measured memory_bytes: 4712
import java.util.Scanner;

public class Main {
	public static void main (String[] args){
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
      
		if(s.equals("AAA") || s.equals("BBB")){
        	System.out.println("No"); 
        } else {
        	System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include "memory.h"
#include <map>
#include <vector>
#include "algorithm"
using namespace std;
bool cmp(const pair<char,int> &a, const pair<char,int> &b)
{
	return a.second < b.second;
}
int main(int argc, char *argv[])
{
	string a,b;
	while(cin>>a>>b)
	{
		map<char,int> ma,mb;
		int i,j;
		for(i = 0;i < a.length();i++)
		{
			ma[a[i]] +=1;
		}
		for(i = 0;i < b.length();i++)
		{
			mb[b[i]] +=1;
		}
		vector< pair<char,int> > va(ma.begin(),ma.end());
		vector< pair<char,int> > vb(mb.begin(),mb.end());
		
		sort(va.begin(),va.end(), cmp);
		sort(vb.begin(),vb.end(), cmp);
		
		int flag = 0;
		if (va.size() != vb.size())
		{
			flag = 1;
		}
		for(i = 0;i<va.size();i++)
		{
			if (va[i].second!= vb[i].second)
			{
				flag = 1;
				break;
			}
		}
		if (flag)
		{
			cout<<"No"<<endl;	
		}
		else
		{
			cout<<"Yes"<<endl;
		}
	} 
	return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
using namespace std;
int W,H;
char maps[222][222];
int vis[222][222];
int ans;
void dfs(int x,int y,char ch)
{
    if(x < 0 || x >= H|| y < 0 || y >= W)
        return;
    if(vis[x][y] || maps[x][y] != ch)
        return;
    vis[x][y] = 1;
    dfs(x - 1, y,ch);
    dfs(x , y - 1,ch);
    dfs(x + 1,y,ch);
    dfs(x , y + 1,ch);
}
int main()
{
    while(scanf("%d%d",&H,&W) != EOF)
    {
        if(!W && !H)
            break;
        int begx,begy;
        ans = 0;
        for(int i =  0;i < H;i++)
        {
            for(int j = 0 ;j < W;j++)
            {
                vis[i][j] = 0;
                scanf(" %c",&maps[i][j]);
            }
        }
        for(int i = 0;i < H;i++)
        {
            for(int j = 0;j < W;j++)
            {
                if(!vis[i][j])
                {
                    ans++;
                    dfs(i,j,maps[i][j]);
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<pair<int,int>>>;
using pp=pair<int,pair<int,int>>;
#define MOD 1000000007
#define INF 1000000000

int main(){
  int N;
  cin>>N;
  vector<ll> a(3*N);
  for(int i=0;i<3*N;i++){
    cin>>a[i];
  }

  priority_queue<ll,vector<ll>,greater<ll>> pq;
  vector<ll> M(N+1,0);
  for(int i=0;i<N;i++){
    M[0]+=a[i];
    pq.push(a[i]);
  }
  for(int i=0;i<N;i++){
    M[i+1]=M[i];
    pq.push(a[i+N]);
    M[i+1]+=a[i+N];
    ll x=pq.top();
    pq.pop();
    M[i+1]-=x;
  }

  priority_queue<ll> pq2;
  vector<ll> m(N+1,0);
  for(int i=0;i<N;i++){
    m[N]+=a[i+2*N];
    pq2.push(a[i+2*N]);
  }
  for(int i=0;i<N;i++){
    m[N-i-1]=m[N-i];
    pq2.push(a[2*N-i-1]);
    m[N-i-1]+=a[2*N-i-1];
    ll x=pq2.top();
    pq2.pop();
    m[N-i-1]-=x;
  }

  ll ans=M[N]-m[N];
  for(int i=0;i<N;i++){
    ans=max(ans,M[i]-m[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 9492
n, a, b = [int(i) for i in input().split()]
mod = 10**9+7

def func_156d(n, r):
    r =min(r, n-r)
    numerator = 1
    denominator = 1
    
    for i in range(n-r+1, n+1):
        numerator = numerator * i % mod
        
    for i in range(1, r+1):
        denominator = denominator * i % mod
        
    return numerator * pow(denominator, mod-2, mod) %mod

print((pow(2, n, mod) -1 - func_156d(n,a) - func_156d(n,b) + 2*mod) %mod )

Measured memory_bytes: 3064
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#define MOD 998244353

int dp[305][305][305];
int n[305];
int main() {
    string S;
    int K;
    cin >> S >> K;

    int i,j,k;
    dp[S.size()][S.size()][0] = 1;
    n[S.size()] = S.size();
    for (i = S.size()-1; i >= 0; i--) {
        if (S[i] == '0') n[i] = i;
        else n[i] = n[i+1];
    }
    for (i = S.size()-1; i >= 0; i--) {
        if (S[i] == '0') break;
        dp[i][S.size()][0] = 1;
    }
    for (i = S.size()-1; i >= 0; i--) {
        for (j = S.size()-1; j >= i; j--) {
            for (k = 0; k <= S.size(); k++) {
                if (S[i] == '0') {
                    dp[i][j][k] = dp[i+1][j+1][k];
                    if (k > 0) dp[i][j][k] += dp[i][j+1][k-1];
                }
                else {
                    dp[i][j][k] = dp[i+1][j+1][k];
                    dp[i][j][k] += dp[n[i]+1][j+1][k];
                }
                dp[i][j][k] %= MOD;
                //cout<<i<<","<<j<<","<<k<<": "<<dp[i][j][k]<<endl;
            }
        }
    }
    int ans = 0;
    for (i = 0; i <= min((int) S.size(),K); i++) ans += dp[0][0][i],ans %= MOD;
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 58644
#include<iostream>
using namespace std;
int main()
{
  int a,b; cin>>a>>b;
  if(b==1)
  {
    cout<<0<<endl; return 0;
  }
  int i=1;
  while(a+(i-1)*(a-1)<b)
    	i++;
  cout<<i<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    ll s;
    cin >> s;
    ll X,Y;
    X = sqrtl(static_cast<long double>(s));
    if (X * X != s)
    {
        ++X;
    }
    Y = X;
    ll xy = X * X - s, x = 0, y = 0;
    if (xy != 0)
    {
        for (ll i = 1; i * i <= X*X; ++i)
        {
            if (xy % i == 0)
            {
                if (xy/i <= X && i <= X){
                    x = xy / i;
                    y = i;
                    break;
                }
            }
        }
        while (x*y + s != X*Y){
            ++X;
            xy = X * Y - s;
            for (ll i = 1; i * i <= X * X; ++i)
            {
                if (xy % i == 0)
                {
                    if (xy / i <= X && i <= X)
                    {
                        x = xy / i;
                        y = i;
                        break;
                    }
                }
            }
        }
    }else{
        x = y = 0;
    }
    cout << 0 << " " << 0 << " " << X << " " << y << " " << x << " " << Y << endl;
}

Measured memory_bytes: 256
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#include <cassert>
#include <chrono>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    int n;
    cin >> n;
    vi a(n);
    for (auto &x : a)
        cin >> x;
    vll prefix(n+1);
    prefix[0] = 0;
    for (int i = 1; i <= n; i++) {
        prefix[i] = prefix[i-1] + a[i-1];
        prefix[i] %= mod;
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += prefix[i-1]*a[i-1];
        ans %= mod;
    }
    cout << ans << "\n";
}

int main() {
    #ifdef LOCAL
    auto t1 = std::chrono::high_resolution_clock::now();
    #endif

    io;
    solve();

    #ifdef LOCAL
    auto t2 = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();

    std::cout << "Time Taken: " << duration << "\n";
    #endif

}
// check for edge cases in limits
// printing double may print 1.223232e9 like values, beware of that
// carefully observe simulation of test cases
// multiset erase is does not do what it is supposed to


Measured memory_bytes: 5572
A = int(input())
B = int(input())
C = int(input())
X = int(input())

c = 0
for i in range(A + 1):
    if 500 * i > X:
        break
    for j in range(B + 1):
        if 500 * i + 100 * j > X:
            break
        K = X - 500 * i - 100 * j
        if K % 50 == 0:
            k = K / 50
            if k <= C:
                c += 1
print(c)

Measured memory_bytes: 9192
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int n, p;

	void run(){
		for(;;){
			n=sc.nextInt();
			p=sc.nextInt();
			if(n==-1){
				break;
			}
			solve();
		}
	}

	int max=200000;
	int[] prime, is;

	void solve(){
		if(prime==null){
			prime=new int[max];
			fill(prime, INF);
			boolean[] isPrime=new boolean[max];
			fill(isPrime, true);
			isPrime[0]=isPrime[1]=false;
			int at=0;
			for(int j=0; j<max; j++){
				if(!isPrime[j]){
					continue;
				}
				prime[at++]=j;
				for(int i=j*2; i<max; i+=j){
					isPrime[i]=false;
				}
			}
			is=new int[40000];
		}
		int k=binarySearch(prime, n);
		if(k<0){
			k=-k-1;
		}
		if(prime[k]<=n){
			k++;
		}
		fill(is, INF);
		for(int i=0; i<200; i++){
			for(int j=i; j<200; j++){
				is[i+j*200]=prime[k+i]+prime[k+j];
			}
		}
		sort(is);
		println(is[p-1]+"");
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

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

int main() {
  int N, a, b, sum;
  cin >> N;
  
  for (int i = 1; i <= N; i++) {
    cin >> a >> b;
    sum += b - a + 1;
  }
  cout << sum << endl;
  
  return 0;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < (n); i++)
#define forr(i,a,b) for (int i = (a); i <= (b); i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ii> vii;

int n, m;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> m;
	cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        if b[0][0] == a[i][j]:
            cnt = 0
            for x in range(m):
                flag = True
                if flag == False:
                    break
                for y in range(m):
                    if b[x][y] == a[i+x][j+y]:
                        cnt += 1
                        pass
                    else:
                        flag = False
                        break
                    if cnt == m**2:
                        print("Yes")
                        exit()
print("No")

Measured memory_bytes: 9164
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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 main() {
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<pair<ll,ll>> p(n);
    REP(i,n){
        cin >> a[i] >> b[i];
        p[i].first = -(a[i]+b[i]);
        p[i].second = i;
    }
    sort(p.begin(),p.end());
    ll res = 0;
    REP(i,n){
        if(i%2==0){
            res+=a[p[i].second];
        }else{
            res-=b[p[i].second];
        }
    }
    put(res);
    return 0;
}




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

int N;
vector< int > graph[1001];
string M[1001];

void rec(int idx, int depth)
{
  cout << string(depth, '.') << M[idx] << endl;
  for(int to : graph[idx]) rec(to, depth + 1);
}

int main()
{
  cin >> N;
  for(int i = 1; i <= N; i++) {
    int k;
    cin >> k >> M[i];
    graph[k].push_back(i);
  }
  rec(1, 0);
}

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

char m[55][55];

int bombCount(int x, int y, int w, int h){
    int count = 0;
    for(int i = -1; i <= 1; ++i){
        for(int j = -1; j <= 1; ++j){
            if(i == 0 && j == 0) continue;

            int dy = y + i;
            int dx = x + j;

            if(dx < 0 || dx > w || dy < 0 || dy > h){
                continue;
            }

            if(m[dy][dx] == '#'){
                count++;
            }
        }
    }

    return count;
}

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

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

    for (int i = 0; i < h; ++i){
        for (int j = 0; j < w; ++j){
            if(m[i][j] == '#') {
                cout << m[i][j];
                continue;
            }
            cout << char(bombCount(j, i, w, h) + '0');
        }
        cout << endl;
    }
}

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

int main(){
  //input 入力
  int n,r;cin >> n >> r;

  //solve 処理
  if(n >= 10)cout << r << endl;
  else cout << r+1000-100*n << endl;
  
  //output 出力
  
  return 0;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int k;
    cin>>k;
    vector<int> s{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 
    cout<<s[k-1]<<endl;
}

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

int gcd(int a,int b){
  if(a > b) return gcd(b,a);
  int r;
  while((r = a%b)){
    a = b;
    b = r;
  }
  return b;
}

int main(void){
  int n; cin >> n;
  int a[n];
  rep(i,n){
    cin >> a[i];
  }
  int euclid = gcd(a[0],a[1]);
  for(int i = 1; i < n; i++){
    euclid = gcd(euclid,a[i]);
  }
  cout << euclid << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,t,a[200001];
  cin>>n>>t;
  for(int i=0;i<n;i++)cin>>a[i];
  int p=__gcd(a[0],a[1]);
  for(int i=2;i<n;i++)p=__gcd(p,a[i]);
  sort(a,a+n);
  if(t%p==0&&a[n-1]>=t)cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

struct hoge {
	int p, A;
};

int cmp(const void* x, const void* y) {
	int a = ((const struct hoge*)x)->A, b = ((const struct hoge*)y)->A;
	return a > b ? -1 : a < b;
}


int N;
int A[2222];

struct hoge h[2222];

int64_t memo[2222][2222];

int64_t search(int lput, int rput) {
	int cur = lput + rput;
	int64_t answer = 0;
	int64_t candidate;
	if (cur >= N) return 0;
	if (memo[lput][rput]) return ~memo[lput][rput];
	/* 左 */
	candidate = search(lput + 1, rput) + (int64_t)h[cur].A * abs(h[cur].p - lput);
	if (candidate > answer) answer = candidate;
	/* 右 */
	candidate = search(lput, rput + 1) + (int64_t)h[cur].A * abs(h[cur].p - (N - 1 - rput));
	if (candidate > answer) answer = candidate;

	return ~(memo[lput][rput] = ~answer);
}

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
		h[i].p = i;
		h[i].A = A[i];
	}
	qsort(h, N, sizeof(*h), cmp);
	printf("%" PRId64 "\n", search(0, 0));
	return 0;
}


Measured memory_bytes: 25204
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int a[10000000],b,n;
long long ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		a[i]-=i;
	}
	sort(a+1,a+1+n);
	b=a[(n+1)/2];
	for(int i=1;i<=n;i++)
	ans+=abs(a[i]-b);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1024
def main(n,r):
    _dp = [-float('INF')]*n
    _dp[0]=r[1]-r[0]
    _min =r[0]
    for i in range(1,n):
        _min = min(_min, r[i-1])
        _dp[i] = max(_dp[i-1], r[i]-_min)
    print(_dp[-1])

n = int(input())
r = [int(input()) for _ in range(n)]
main(n,r)


Measured memory_bytes: 15248
def main():
    n, m, k = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    nid = m-1
    s = sum(B)
    cnt = m
    while s > k:
        s -= B[nid]
        cnt -= 1
        nid -= 1

    ans = cnt
    for a in A:
        s += a
        cnt += 1
        while s > k and nid >= 0:
            s -= B[nid]
            cnt -= 1
            nid -= 1
        if s <= k:
            ans = max(cnt, ans)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40556
N,C = map(int,input().split())
D = [list(map(int,input().split())) for _ in range(C)]
Grid = [list(map(int,input().split())) for _ in range(N)]

SumCost = [[0 for _ in range(C)] for _ in range(3)]
for c in range(1,C+1):
  for i in range(N):
    for j in range(N):
      g = ((i+1)+(j+1))%3
      SumCost[g][c-1] += D[Grid[i][j]-1][c-1]

ans = 10**18
for c1 in range(1,C+1):
  for c2 in range(1,C+1):
    for c3 in range(1,C+1):
      if c1 == c2 or c2 == c3 or c3 == c1:
        continue
      ans = min(ans,SumCost[0][c1-1]+SumCost[1][c2-1]+SumCost[2][c3-1])
print(ans)

Measured memory_bytes: 44892
#include<stdio.h>
int main(void)
{
  int a,b;
  char c;
  while(c != '?'){
    scanf("%d %c %d",&a,&c,&b);
    switch(c){
    case '+':printf("%d\n",a+b);break;
    case '-':printf("%d\n",a-b);break;
    case '*':printf("%d\n",a*b);break;
    case '/':printf("%d\n",a/b);break;
    }
  }
  return 0;
}

Measured memory_bytes: 600
def main():
    height, width, leave_black = [int(x) for x in input().split()]
    table = [input() for _ in range(height)]

    def bit_patterns(height, width):
        for num_h in range(2 ** height):
            for num_w in range(2 ** width):
                yield num_h, num_w

    def count_black(height, width, num_h, num_w):
        for bit_h in range(height):
            for bit_w in range(width):
                if num_h >> bit_h & 1 or num_w >> bit_w & 1:
                    continue
                yield table[bit_h][bit_w] == '#'

    def black_matched(height, width):
        for ii, jj in bit_patterns(height, width):
            yield sum(count_black(height, width, ii, jj)) == leave_black

    print(sum(black_matched(height, width)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 75392
n, y = gets.split.map(&:to_i)

(0..n).each do |i|
  (0..n-i).each do |j|
    k = n - i - j
    if 10000 * i + 5000 * j + 1000 * k == y
      puts [i,j,k].join(" ")
      exit
    end
  end
end
puts "-1 -1 -1"


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

ll divisor=1e9+7;
int main(){
	int n;
	cin>>n;
	int a[n];
	rep(i,n){
		cin>>a[i];
	}
	ll coun=1;
	ll ans=1;
	rep(i,n){
		if(a[i]%2==0)coun*=2;
		ans*=3;
	}
	puts(ans-coun);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

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

// const int C ;
// const int M = 1000000007;

int main () {
  ll A[3];
  cin >> A[0] >> A[1] >> A[2];
  for (auto i = 0; i < 3; i++) {
    if (A[i]%2 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = A[0] * A[1];
  for (auto i = 0; i < 3; i++) {
    ans = min(A[i] * A[(i+1)%3], ans);
  }
  cout << ans << endl;
}


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

typedef long long ll;

int main(){
  int D;
  cin >> D;
  
  if(D == 25){
    cout << "Christmas" << endl;
  }else if(D == 24){
    cout << "Christmas Eve" << endl;
  }else if(D == 23){
    cout << "Christmas Eve Eve" << endl;
  }else if(D == 22){
    cout << "Christmas Eve Eve Eve" << endl;
  }
}

Measured memory_bytes: 256
import sys

s = input()

sinv = s[::-1]

n = len(sinv)

s1 = s[0:n//2]
s1inv = s1[::-1]


s2 = s[n//2+1:n]

s2inv = s2[::-1]

n1 = len(s2)

##print(s1,s1inv,s2,s2inv)

for i in range(n):
    if s[i]!=sinv[i]:
        print("No")
        sys.exit()

for i in range(n1):
    if s1[i]!=s1inv[i] or s2[i]!=s2inv[i]:
        print("No")
        sys.exit()

print("Yes")


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        System.out.println(solve(s));
    }
    public static int solve(String s) {
        char[] data = s.toCharArray();
        int answer = 0;
        for(char c : data) {
            answer += c == '+' ? 1 : -1;
        }
        return answer;
    }
}


Measured memory_bytes: 23636
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int mod=(int)1e9+7,N=105;
int a[N],p[N],f[N][N];
void upd(int &x,int y){x=(x+y)%mod;}
int ksm(int x,int y){
    int tmp=x,ans=1;
    while(y){
        if(y&1) ans=(ll)ans*tmp%mod;
        tmp=(ll)tmp*tmp%mod;
        y>>=1;
    }
    return ans;
}
int main(){
    int n,i,len,j,k,ans=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]),p[i]=a[i];
    p[n+1]=1;
    sort(p+1,p+n+2);
    len=unique(p+1,p+n+2)-p-1;
    for(i=1;i<=n;i++) a[i]=lower_bound(p+1,p+len+1,a[i])-p;
    j=1;
    for(j=1;j<a[1];j++)
        f[1][j]=(ll)(ksm(2,p[j+1]-p[j])-1)*ksm(2,p[a[1]]-p[j+1])%mod*2%mod;
    f[1][a[1]]=2;
    for(i=1;i<n;i++)
        for(j=1;j<=a[i];j++){
            if(a[i+1]<=a[i]){
                if(j>=a[i+1]) upd(f[i+1][a[i+1]],f[i][j]*2%mod);
                else upd(f[i+1][j],f[i][j]);
            }
            else{
                if(j==a[i]){
                    for(k=a[i];k<a[i+1];k++)
                        upd(f[i+1][k],(ll)f[i][j]*2*(ksm(2,p[k+1]-p[k])-1)%mod*ksm(2,p[a[i+1]]-p[k+1])%mod);
                    upd(f[i+1][a[i+1]],f[i][j]*2%mod);
                }
                else upd(f[i+1][j],(ll)f[i][j]*ksm(2,p[a[i+1]]-p[a[i]])%mod);
            }
        }
    for(j=1;j<=a[n];j++) upd(ans,f[n][j]);
    printf("%d",ans);
    return 0;
}


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

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

    int P[102] = {0};
    int num;
    for (int i = 0; i < N; i++)
    {
        cin >> num;
        P[num] = 1;
    }

    int diff = 101;
    int answer = 101;
    for (int i = 0; i < 102; i++)
    {
        if (P[i] == 1)
        {
            continue;
        }

        if (abs(X - i) >= diff)
        {
            continue;
        }

        diff = abs(X - i);
        answer = i;
    }

    cout << answer << endl;
    return 0;
}

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

int main(){
    int n, m;
    while(cin >> n >> m, n!=0 && m!=0){
        int cost[101][101];
        int time[101][101];
        for(int i=0; i<101; ++i){
            for(int j=0; j<101; ++j) time[i][j] = cost[i][j] = (i==j)?0:100000000;
        }
        for(int i=0; i<n; ++i){
            int a, b, c, t;
            cin >> a >> b >> c >> t;
            cost[a][b] = c;
            cost[b][a] = c;
            time[a][b] = t;
            time[b][a] = t;
        }
        for(int i=1; i<=m; ++i){
            for(int j=1; j<=m; ++j){
                for(int k=1; k<=m; ++k){
                    cost[j][k] = min(cost[j][k], cost[j][i]+cost[i][k]);
                    time[j][k] = min(time[j][k], time[j][i]+time[i][k]);
                }
            }
        }
        int k;
        cin >> k;
        for(int i=0; i<k; ++i){
            int p, q, r;
            cin >> p >> q >> r;
            cout << ((r==0)?cost[p][q]:time[p][q]) << endl;
        }
    }
    return 0;
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;



ll rec1(vi & v , int k , ll n){
	ll mn = ((n + v[k] - 1) / v[k]) * v[k];
	if(k == 0) return mn;
	return rec1(v , k - 1 , mn);
}

ll rec2(vi & v , int k , ll n){
	ll mx = n - (n % v[k]);
	if(k == 0) return mx + v[k] - 1;
	return rec2(v , k - 1 , mx + v[k] - 1);
}

bool ck(vi & v , ll n){
	rep(i , sz(v)){
		n = (n / v[i]) * v[i];
	}
	return n == 2ll;
}

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

	int n;
	cin >> n;
	
	vi v(n);
	rep(i , n){
		cin >> v[i];
	}
	

	
	ll l = rec1(v , n - 1 , 2);
	ll r = rec2(v , n - 1 , 2);

	
	if(ck(v , l) && ck(v , r)){
		cout << l << " " << r << nl;
	}else{
		cout << -1;
	}

	

	return 0;
}

Measured memory_bytes: 640
N = int(input())
A = tuple(map(int, input().split()))

i, j = 0, 0
s = 0
ans = 0
while i < N:
    if s | A[i] != s + A[i]:
        s -= A[j]
        j += 1
    else:
        s += A[i]
        i += 1
        ans += i - j
print(ans)


Measured memory_bytes: 25940
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int n, num, sum, Max;

int main() {
    cin >> n;
    rep(i, n) {
        cin >> num;
        sum += num;
        Max = max(Max, num);
    }
    sum -= Max / 2;
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> C(H);
    REP(i, H) cin >> C[i];
    REP(i, H)
    {
        cout << C[i] << endl;
        cout << C[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector <int> p(N);
	for (int ii = 0; ii < N; ++ii){
		cin >> p[ii];
	}

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

	int ans = 0;
	int dif = abs(X - ans);
	for (int ii = 0; ii < 102; ++ii){
		bool ok = true;
		for (int jj = 0; jj < N; ++jj){
			if (ii == p[jj]){
				ok = false;
				break;
			}
		}
		if (ok){
			if (abs(X-ii) < dif ){
				ans = ii;
				dif = abs(X-ii);
			}
		}
	}


		cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 3632
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	static Set<Integer> set= new HashSet<>();
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		for (int i = 0; i < k; i++) {
			int d = sc.nextInt();
			set.add(d);
		}
		
		int pay = n;
		while (isDislike(pay)) {
			pay++;
		}
		System.out.println(pay);
	}
	
	static boolean isDislike(int n) {
		while (n > 0) {
			if (set.contains(n % 10)) {
				return true;
			}
			n /= 10;
		}
		return false;
	}
}


Measured memory_bytes: 21716
#最小領域木
#ABC065D - Built?
#https://atcoder.jp/contests/abc065/tasks/arc076_b

#自己考察TLE

import sys

n = int(input())
cad = []
lst = []
for i in range(n):
    x, y =  list(map(int,input().split()))
    lst.append([x,y,i])
lstx = lst.sort(key = lambda x: x[0])
for i in range(n-1):
    cad.append([lst[i+1][0] - lst[i][0],lst[i+1][2],lst[i][2]])
lsty = lst.sort(key = lambda x: x[1])
for i in range(n-1):
    cad.append([lst[i+1][1] - lst[i][1],lst[i+1][2],lst[i][2]])

cad.sort()

class UnionFind():
    
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):
        return '\n'.join('{}: {}'.format(r,self.members(r)) for r in self.roots())

h = UnionFind(n)
cost = 0
count = 0
for i in range(len(cad)):
    a = cad[i][1]
    b = cad[i][2]
    c = cad[i][0]
    if  not h.same(a,b):
        h.union(a,b)
        cost += c
        count += 1
    if count == n-1:
        print(cost)
        sys.exit()

Measured memory_bytes: 127908
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    lint a, b;
    cin >> a >> b;
    
    int ans = 0;
    while (a <= b) {
        a *= 2;
        ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}
// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}


#pragma endregion

//ABC 163 -B
int main(void) {
	int  i, n,m, a,sum=0;
	
	scanf("%d %d", &m,&n);
	for (i = 0; i < n; i++) {
		scanf("%d",&a);
		sum+= a;
	}
	
	(sum>m) ? printf("-1\n") : printf("%d\n",m-sum);

	return 0;
}

Measured memory_bytes: 2132
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	int a, b;
	cin >> a >> b;
	if(a>9 || b>9) {
		cout << -1 << endl;
	} else {
		cout << a*b << endl;
	}

	return 0;
}

Measured memory_bytes: 256
/*
    Problem 3
    https://atcoder.jp/contests/abc106/tasks/abc106_b
*/
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;
/* typedef */
typedef long long ll;
/* constant */
/* global variables */
vector<char> C = {'A', 'C', 'T', 'G'};
/* function */
/* main */
int main(){
    string S;
    cin >> S;

    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < S.size(); i++) {
        if (count(C.begin(), C.end(), S[i])) {
            cnt++;
        }
        else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    if (cnt > 0) ans = max(ans, cnt);

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    int n;
    cin>>n;
    int high=0;
    int ans=0;
    rep(i,n){
        int h;
        cin>>h;
        if(high<=h)ans++;
        if(h>=high)high=h;
    }
    cout<<ans<<endl;

    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>

int main(int argc, char *argv[]){
    std::string S;
    std::cin >> S;
    int startWith0 = 0, startWith1 = 0;
    int N = S.size();
    for(int i=0; i<N; ++i){
        startWith0 += (i&1)^(S[i]-'0');
        startWith1 += ((~i)&1)^(S[i]-'0');
    }
    std::cout << std::min(startWith0,startWith1) << std::endl;
    return 0;
}


Measured memory_bytes: 512