akhauriyash/Code-Regression huggingface dataset:
n, a, b = map(int, input().split())
s = 0
for i in range(1, n+1):
  str_i = str(i)
  sum_digit = sum(map(ord, list(str_i))) - ord("0")*len(str_i)
  if a <= sum_digit <= b:
    s += i
print(s)

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

#define INF 1000000000000
#define MOD 10000007
#define int ll

void YesNo(bool b) { b ? cout << "Yes" << endl : cout << "No" << endl; return; }
void YESNO(bool b) { b ? cout << "YES" << endl : cout << "NO" << endl; return; }
void yesno(bool b) { b ? cout << "yes" << endl : cout << "no" << endl; return; }

signed main() {

	int n, m;
	vector<int>al;
	int a;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> a;
		al.push_back(a);
	}
	int sum = 0;
	for (auto& x : al) {
		sum += x;
	}
	int p = n - sum;
	if (p < 0) {
		cout << -1 << endl;
	}
	else {
		cout << p << endl;
	}
}

Measured memory_bytes: 3756
A = int(input())

a = 10**9 - A % (10**9)
b = A // (10**9) + 1


if b > 10**9:
    print(0, 0, 10**9, 0, 0, 10**9)
else:
    print(0, 0, 10**9, 1, a, b)

Measured memory_bytes: 38384
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   string s;
   cin >> s;
   string t = "";

   for (int i = 0;  i < (int)s.size(); i++) {
      if (s[i] == 'A') t += "A";
      else if (s[i] == 'B' && i + 1 < (int)s.size() && s[i + 1] == 'C') {
         t += 'D';
         i++;
      } else t += s[i];
   }
   ll ans = 0;
   ll tmp = 0;
   ll cntA = 0;
   for (int i = 0; i < (int)t.size(); i++) {
      if (t[i] == 'A') cntA++;
      else if (t[i] == 'D') tmp += cntA;
      else {
         ans += tmp;
         cntA = 0;
         tmp = 0;
      }
   }
   ans += tmp;
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    for (int i=0; i<n; i++) cout << "x";
    cout << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(c) begin(c), end(c)
using namespace std;

template <class T>
void scrib_impl(char const* title, T v){
    cout << title << " ...... " << v << endl;
}
#define SCRIB(EXPR) (scrib_impl(#EXPR, (EXPR)))

int main() {
    int64_t a,b;
    cin >> a >> b;
    
    int64_t p = a*b;
    for(int64_t t=a; t <= p; t+=a) {
        if (t%b == 0) {
            cout << t << endl;
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
//Dijkstra
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef pair<int, int> P;
int n, dis[101], n_left;
vector< vector<P> > G(101);
priority_queue< P, vector<P>, greater<P> > heap;
bool visited[101];

int main(){
    int u, v, k, w;

    scanf("%d", &n);
    n_left = n;
    for(int i=0; i<n; i++){
        scanf("%d %d", &u, &k);
        for(int j=0; j<k; j++){
            scanf("%d %d", &v, &w);
            G[u].push_back(P(w, v));
        }
    }
    memset(visited, 0, sizeof(visited));
    memset(dis, 127, sizeof(dis));

    dis[0] = 0;
    heap.push(P(0, 0));
    while(!heap.empty() && n_left>0){
        P top = heap.top();
        heap.pop();
        if(!visited[top.second]){
            u = top.second;
            visited[u] = true;
            --n_left;
            for(int i=0; i<G[u].size(); i++){
                v = G[u][i].second;
                w = dis[u] + G[u][i].first;
                if(!visited[v] && w < dis[v]){
                    heap.push(P(w, v));
                    dis[v] = w;
                }
            }
        }
    } 
    for(int i=0; i<n; i++){
        printf("%d %d\n", i, dis[i]);
    }
    return 0;
}


Measured memory_bytes: 2740
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(readline().rstrip())
pl = list(map(int, readline().split()))

min_ = pl[0]
ans = 0
for x in pl:
    if x <= min_:
        ans += 1
    if x < min_:
        min_ = x

print(ans)

Measured memory_bytes: 69616
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
#define MOD (1e9+7)
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
vector<int> tre[100010];

int T[100010];//1-indexed
int A[100010];//1-indexed
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  int N,u,v;cin>>N>>u>>v;
  for(int i = 0; N-1 > i; i++){
    //uからvの直線距離を求める
    int a,b;cin>>a>>b;
    tre[a].push_back(b);
    tre[b].push_back(a);
  }

  queue<P> t;
  t.push({u,1});
  while(!t.empty()){
    P k = t.front();
    t.pop();
    if(T[k.first]){
      continue;
    }
    T[k.first] = k.second;
    k.second++;
    for(int i = 0; tre[k.first].size() > i; i++){
      t.push({tre[k.first][i],k.second});
    }
  }
  queue<P> a;
  a.push({v,1});
  while(!a.empty()){
    P k = a.front();
    a.pop();
    if(A[k.first]){
      continue;
    }
    A[k.first] = k.second;
    k.second++;
    for(int i = 0; tre[k.first].size() > i; i++){
      a.push({tre[k.first][i],k.second});
    }
  }

  int ans = 0;
  for(int i = 1; N >= i; i++){
    if(T[i] < A[i]){
      ans = max(ans,A[i]-1);
    }
  }
  //距離が偶数の場合
  cout << ans-1 << endl;
}


Measured memory_bytes: 6912
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

const ll N=22,M=(1<<22);
ll n,dp[N][M],grid[N][N];

inline ll add(ll a,ll b)
{
    a += b;
    if(a >= mod)a -= mod;
    return a;
}

ll men(ll node,ll mask)
{
    if(node<0)return mask==0;
    if(dp[node][mask]!=-1)return dp[node][mask];
    dp[node][mask]=0;
        rep(j,0,n-1)
        {
            if((grid[node][j])&&(mask & (1<<j)))
                dp[node][mask]=add(dp[node][mask],men(node-1,mask^(1<<j)));
        }    
    return dp[node][mask];
}

int main()
{   ios;
    ll i,j,k;
    cin>>n;
    rep(i,0,n-1)rep(j,0,n-1)cin>>grid[i][j];
    rep(i,0,n-1)
        rep(j,0,(1<<n)-1)
            dp[i][j]=-1;
    cout<<men(n-1,(1<<n)-1)<<en;
    return 0;
}


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

int main(){
    int x;
    for (int i = 0; i < 10010; i++)
    {
        cin >> x;
        if(x == 0) break;
        cout << "Case " << i+1 << ": " << x << endl;
    }
    
}


Measured memory_bytes: 3092
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int cnt=0;
		int tyo=0;
		int don=0;
		int ei=0;
		for(;;)
		{
			int a=in.nextInt();
			int b=in.nextInt();
			int c=in.nextInt();
			if(!(Math.abs(a-b)<c)||!(c<a+b))
				break;
			int A=Math.min(a, b);
			int B=Math.max(a, b);
			int C=0;
			++cnt;
			if(B>c)
			{
				C=B;
				B=c;
			}
			else
				C=c;

			if(C*C>A*A+B*B)
				++don;
			else if(C*C<A*A+B*B)
				++ei;
			else
				++tyo;
		}
		System.out.println(cnt+" "+tyo+" "+ei+" "+don);
	}


	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 20324
#include<stdio.h>
int main(void){
  char s[3],t[3];
  int a=0;
  scanf("%s%s",&s,&t);
  for(int i=0;i<3;i++){
    if(s[i]==t[i]){
      a=a+1;
    }
  }
  printf("%d",a);
  return 0;
}
  


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

int main(){
  int K,S;
  cin >> K >> S;
  int cnt = 0;
  for(int i=0; i<=K; i++){
    for(int j=0; j<=K; j++){
      int z = S-i-j;
      if(z >= 0 && z <= K){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define INF 1000000000000000000
#define all(x) (x).begin(), (x).end()

int main() {
    int N;
    cin >> N;
    vector<ll> L(N);
    rep(i, N) { cin >> L[i]; }
    sort(all(L));
    int res = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int iter = lower_bound(all(L), L[i] + L[j]) - L.begin();

            res += max(iter - (j + 1), 0);
        }
    }

    cout << res << endl;
}

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

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define grt() greater<int> ()
#define grtl() greater<long long> ()

int main () {
    int k;
    cin >> k;
    int a, b;
    cin >> a >> b;

    bool ans = false;
    for (int i = a; i <= b; i++)
    {
        if(i%k == 0) {
            ans = true;
        }
    }

    if(ans) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(void)
{
 int sec,h,m,s;
 scanf("%d",&sec);
 h = sec / 3600;
 m = (sec - (3600 * h)) / 60;
 s = sec - (3600 * h) - (60 * m);
 printf("%d:%d:%d\n",h,m,s);
 return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

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

  cout << min(a, b) << " " << max(0, a + b - n) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define per(i,n) for ((i)=n;(i)>=(1);(i)--)
using namespace std;
int n,m,i,j,fa[200005],vis[200005];
int rd[200005],cd[200005];
int fnd(int x)
{
	if(fa[x]==x) return x;
	return fa[x]=fnd(fa[x]); 
}
int main()
{
	cin>>n>>m;m++;
	rep(i,m+m)fa[i]=i;
	rep(i,n)
	{
		int a,b,c,d,l,r;
		cin>>a>>b>>c>>d;
		if(c) l=m+c; else l=m-a;
		if(d) r=m-d; else r=m+b;
		rd[r]++;cd[l]++;
		fa[fnd(l)]=fnd(r);
	}
	rep(i,m) if(rd[i]>cd[i]) {puts("NO");return 0;}
	rep(i,m) if(rd[i+m]<cd[i+m]) {puts("NO");return 0;}
	rep(i,m+m) if(rd[i]!=cd[i]) vis[fnd(i)]=1;
	rep(i,m+m) if(cd[i]&&!vis[fnd(i)]) {puts("NO");return 0;}
	puts("YES");
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
p1=0
p2=0
p3=0
for x in p:
  if x<=a:
    p1+=1
  elif x<=b:
    p2+=1
  else:
    p3+=1
print(min(p1,p2,p3))

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    int h, w; cin >> h >> w;
    vector<string> a(h+2);
    rep(i, h) rep(j, w) {
        char x; cin >> x;
        a.at(i) += x;
    }

//    dump(a.at(0));

    vector<string> b;
    string t = "";
    rep(i, w) t += '.';
    rep(i, h){
        if(t==a.at(i)) continue;
        else b.push_back(a.at(i));
    }

    rep(i, b.size()) dump(b.at(i));

    vector<string> c(b.size(), "");
    bool skip = false;
    rep(i, w){
        rep(j, b.size()){
            if(b.at(j).at(i)=='#'){
                break;
            }

            if(j==b.size()-1){
               skip = true; 
            }
        }

        if(skip) {
            skip = false;
            continue;
        }
        else{
            rep(j, b.size()){
                c.at(j) += b.at(j).at(i);
            }
        }
    }

    rep(i, c.size()) cout << c.at(i) << endl;

}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)
#define dep(i, s, t) for(i = s; i >= t; --i)

using namespace std;

typedef long long LL;
const int N = 16010, M = 210, G = 131072;
const int P = 998244353;
int n, m; LL ans;
LL fac[G], inv[G];
LL w[G], iw[G], a[G], b[G]; int r[G], L, tot;
LL f[N];

LL lp(LL a, LL b) {
	LL c = 1;
	for(; b; b >>= 1, a = a * a % P)
		if(b & 1) c = c * a % P;
	return c;
}

void excel() {
	int i; LL base, inv_base;
	base = lp(3, (P-1) / tot);
	inv_base = lp(base, P-2);
	w[0] = iw[0] = 1;
	rep(i, 1, tot-1) {
		w[i] = w[i-1] * base % P;
		iw[i] = iw[i-1] * inv_base % P;
	}
}

LL C(int a, int b) {return fac[a] * inv[b] % P * inv[a-b] % P;}

LL inc(LL a, LL b) {
	a += b; return a >= P? a-P: a;
}

LL dec(LL a, LL b) {
	a -= b; return a < 0? a+P: a;
}

void ntt(LL *a, LL *b){
	int i, j, k;
	LL x, y;
	for(i = 0; i < L; ++i)
		if(i < r[i]) swap(a[i], a[r[i]]);
	for(i = 1; i < L; i <<= 1){
		for(j = 0; j < L; j += i<<1){
			for(k = 0; k < i; ++k){
				x = a[j+k]; y = b[tot/i/2*k] * a[j+k+i] % P;
				a[j+k] = inc(x, y); a[j+k+i] = dec(x, y);
			}
		}
	}
}

int main() {
	int i, t = 0, k, p, q; LL fei;
	scanf("%d%d", &n, &m);
	for(L = 1; L <= (n<<1); L <<= 1) ++t;
	fei = lp(L, P-2);
	rep(i, 0, L-1) r[i] = (r[i>>1]>>1) | ((i&1)<<t-1);
	
	fac[0] = 1;
	rep(i, 1, n+2) fac[i] = fac[i-1] * i % P;
	inv[n+2] = lp(fac[n+2], P-2);
	dep(i, n+2, 1) inv[i-1] = inv[i] * i % P;
	tot = 65536; excel();	
	rep(p, 0, n) f[p] = 1;
	rep(k, 2, m) {
		rep(q, 0, n) a[q] = f[q] * inv[q] % P; fill(a+n+1, a+L, 0);
		rep(q, 1, n) b[q] = inv[q+2]; b[0] = 0; fill(b+n+1, b+L, 0); 
		//rep(q, n+1, L-1) a[q] = b[q] = 0;
		ntt(a, w); ntt(b, w);
		rep(q, 0, L-1) a[q] = a[q] * b[q] % P;
		ntt(a, iw);
		rep(q, 0, L-1) a[q] = a[q] * fei % P;
		rep(q, 0, n) f[q] = (f[q]*(q*(q+1)/2+1)%P + a[q]*fac[q+2]%P) % P;
		//printf("%d\n", k);
	}
	rep(p, 0, n) ans = (ans + C(n, p) * f[p] % P) % P;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4608
fun main(arr:Array<String>) {
    val (h,w) = readLine()!!.split(" ").map { it.toInt() }
    val pic = (1..h).map { readLine()!! }
    println((1..w + 2).joinToString("") { "#" })
    pic.forEach { println("#$it#") }
    println((1..w + 2).joinToString("") { "#" })
}

Measured memory_bytes: 38528
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())
rlt = 0
c = collections.Counter(prime_factorize(N))

for i in c:
  k = 0
  j = 1
  while k <= c[i]:
    k += j
    j += 1
  rlt += (j-2)
  
print(rlt)

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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;

int n;
int value[101] , weight[101];


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    int w;
   	cin>>n>>w;
   	int i;
   	f1(i,0,n)
   	cin>>weight[i]>>value[i];
   	int ans[100001];
   	f1(i,0,100001)
   	{
   		ans[i]=mod;
   	}
   	ans[0]=0;
   	f1(i,0,n)
   	{
   		for(int j=100000-value[i];j>=0;j--)
   		{
   			ans[j+value[i]]=min(ans[j]+weight[i],ans[j+value[i]]);
   			
   		}
   	}
   	int sum=0;
   	f1(i,0,100001)
   	{
   		if(ans[i]<=w)
   			sum=i;
   	}
   	cout<<sum;

    return 0;
}

Measured memory_bytes: 1024
while True:
  h,w = map(int, input().split())
  if h == 0 and w == 0:
    break
  else:
    for j in range(h):
      for i in range(w):
        if (i+j)%2 == 0:
          print("#", end="")
        else:
          print(".", end="")
      print()
    print()


Measured memory_bytes: 7004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  int N; cin >> N;
  vector<int> d(N);
  rep(i,N) cin >> d[i];

  sort(all(d));

  cout << d[N/2] - d[N/2-1] << endl;
}

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

int main()
  {
  int A , B;
  cin >> A;
  cin >> B;
if (A-B >= 1){
  cout << A*2-1 << endl;
  }
  
else if (B-A >= 1){
  cout << B*2-1 << endl;
  }
  
else{
  cout << A+B <<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct record{
	string name;
	int score;
	int id;
}arr[101];

bool cmp(record r1, record r2){
	if(r1.name.compare(r2.name) ==0) return r1.score > r2.score;
	return r1.name < r2.name;
}
void swap(record *r1, record *r2) { 
     record tmp = *r1; 
    *r1 = *r2; 
    *r2 = tmp; 
} 

void bubbleSort(record arr[], int n) { 
   int i, j; 
   for (i = 0; i < n-1; i++)       
	// Last i elements are already in place    
       for (j = 0; j < n-i-1; j++)  
           if (!cmp(arr[j],arr[j+1])) //if arr[j] not less than arr[j+1] , then swap them 
              swap(&arr[j], &arr[j+1]); 
} 
int main(){
	int n; cin>>n;
	 
	for(int i=0;i<n;i++){
		cin>>arr[i].name>>arr[i].score;
		arr[i].id = i;
	}
	bubbleSort(arr,n);
	for(int i=0;i<n;i++) printf("%d\n", arr[i].id+1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<string,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())

using namespace std;
int main() {
  ll N,K;
  cin>>N>>K;
  repr(i,0,N) {
    if(pow(K,i)>N) {
      cout<<i<<endl;
      break;
    }
  }

}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    map<int,int> A;
    REP(i,N){
        int a; cin >> a;
        A[a]++;
    }

    int ans = 0;
    for(auto a: A){
        if(a.second%2==1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8168
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int ans = 0;


            if (a <= 12 && a >= 6) ans = b / 2;
            if (a >= 13) ans = b;
            if (a <= 5) ans = 0;

            // 出力
            out.println(ans);
        }

    }
}



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

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let A: Vec<usize> = sc.vec(N+1);
    // 深さiにおける頂点数の上限
    let mut vmax = vec![0; N+1];
    vmax[N] = A[N];
    // 深さiにおける頂点数の下限
    let mut vmin = vec![0; N+1];
    vmax[N] = A[N];
    vmin[N] = A[N];
    for i in (0..N).rev() {
        vmax[i] = vmax[i+1] + A[i];
        vmin[i] = (vmin[i+1]+1)/2 + A[i];
    }
    if vmin[0] != 1 {
        println!("-1");
        return;
    }
    dbg!(&vmax);
    let mut v = vec![0; N+1];
    v[0] = 1;
    for i in 0..N {
        v[i+1] = min((v[i] - A[i]) * 2, vmax[i+1]);
    }
    dbg!(&v);
    let ans: usize = v.into_iter().sum();
    println!("{}", ans);
}


Measured memory_bytes: 7204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s="CODEFESTIVAL2016";
  string t;
  cin >> t;
  int ans=0;
  for(int i=0;i<t.size();i++){
   if(t.at(i) !=s.at(i)){
     ans++;
  }
  }
  cout << ans<<endl;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int MAX_N = (1 << 21) - 1;
const ll inf = numeric_limits<ll>::max()/3;

string s,t;

bool ok(string u){
  int p;
  for(int i = 0;i < (int)s.size();++i){
    if(p == (int)u.size())
      return true;
    if(s[i] == u[p])
      ++p;
  }
  return p == (int)u.size();
}

int main(void){
  cin >> s >> t;
  string now = t;
  int res = 0;
  ll sz = (ll)t.size();
  while(true){
    if(!ok(now))break;
    ++res;
    ll sznow = (ll)now.size();
    if(sznow*(sz+1) + sz > (ll)s.size())break;
    string tmp = now;
    for(int i = 0;i < (int)t.size();++i){
      now += string(1,t[i]);
      now += tmp;
    }
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 3356
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANNOT ASSIGN A VALUE OF 10^18 IT WILL ASSIGN A LOWER VALUE THAN THAT!!!
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
 #define ll long long
 #define int long long
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
//ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}

void solve()
{
    ll n;cin>>n;
    ll a[n],b[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];b[i]=a[i];
    }
    
    sort(b,b+n);
    ll ans=0;
    for(ll i=0;i<n;i++)
        if(a[i]!=b[i])ans++;
    if(ans<=2)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}
signed main()
{
 
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//    }

 solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  f first
#define s second
#define vi vector<int>
#define pb emplace_back
#define ll long long int
#define vll vector<long long int>
#define vpi vector<pair<int,int>>
#define bit(x) __builtin_popcount(x)
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i=0 ; i<n ; ++i)
#define deb(x) cout << #x << " - " << x << endl;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll MOD = 1e9 + 7;
const ll INF = 1 << 29;
const ll MAX_N = 1e5 + 7;

using namespace std;

int main() {
    IOS;
    int n; cin>>n;
    set<string>s;
    string st;
    
    rep(i,n){
        cin>>st;
        s.insert(st);
    }
    cout<<(int)s.size();
    return 0;
}

Measured memory_bytes: 19144
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=2e5+5;
ll func(ll n){
    ll sum = 0;
    while(n){
        sum+=n%10;
        n/=10;
    }
    return sum;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,ans=LLONG_MAX;cin>>n;
    for(ll i=1;i<n;i++){
        ll a = i , b=n-i;
        ans = min(ans , func(a) + func(b) );
    }
    cout<<ans;
}


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

Measured memory_bytes: 256
program abc110d
  implicit none
  integer(8), parameter :: modulo = 10**9 + 7
  integer(8) :: ans = 1, i = 2
  integer(8) n, m, count

  read *, n, m
  do
     if (m < i * i) exit
     if (mod(m, i) == 0) then
        count = 0
        do
           m = m / i;
           count = count + 1
           if (mod(m, i) /= 0) exit
        end do
        ans = mod(ans * comb(n + count - 1, count, modulo), modulo)
     end if
     i = i + 1
  end do
  if (m /= 1) then
     ans = mod(ans * n, modulo)
  end if
  print '(i0)', ans

contains

  recursive integer(8) function comb(n, k, m) result(r)
    integer(8), intent(in) :: n, k, m
    integer(8) i, nume, deno

    if (n - k < k) then
       r = comb(n, n - k, m)
    else
       nume = 1
       deno = 1
       do i = 0, k - 1
          nume = mod(nume * (n - i), m)
          deno = mod(deno * (i + 1), m)
       end do
       r = mod(nume * modpow(deno, m - 2, m), m)
    end if
  end function comb

  recursive integer(8) function modpow(a, p, m) result(r)
    integer(8), intent(in) :: a, p, m
    integer(8) h

    if (p == 0) then
       r = 1
    else if (mod(p, 2) == 0) then
       h = modpow(a, p / 2, m)
       r = mod(h * h, m)
    else
       r = mod(a * modpow(a, p - 1, m), m)
    end if
  end function modpow

end program abc110d


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
        int n,l,i;
        char s[10000];

        scanf("%d",&n);
        scanf("%s",s);

        l=strlen(s);

        for(i=0;i<l;i++){
                s[i]='A'+(s[i]-'A'+n)%26;
        }

        printf("%s",s);
        return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()

using namespace std;

typedef long long ll;

ll N, K;

ll g(ll n, ll k) {
  if (k == 0) return n*n;
  ll res = 0;
  for (int i = k+1; i <= n; i++) {
    ll q = n/i, r = n%i;
    res += q * (i-k);
    if (r != 0 && r >= k) res += r-k+1;
  }
  return res;
}

int main() {
  
  scanf("%lld %lld", &N, &K);
  
  printf("%lld\n", g(N, K));
  
  return 0;
}
 


Measured memory_bytes: 256
N=int(input())
A=[0]*N; B=[0]*N;
for i in range(N):
  A[i]=int(input())
  B[i]=A[i]
B.sort(reverse=True)
for j in range(N):
  if A[j]==B[0] :
    print(B[1])
  else :
    print(B[0])

Measured memory_bytes: 18976
n = int(input())
cards = list(map(str, input().split()))


def bubble(a):
    num = [int(i[1]) for i in a]
    char = [i[0] for i in a]
    for i in range(n):
        for j in range(n-1, i, -1):
            if num[j] < num[j-1]:
                num[j], num[j-1] = num[j-1], num[j]
                char[j], char[j-1] = char[j-1], char[j]
    else:
        a_new = [char[i] + str(num[i]) for i in range(n)]
        return a_new


def selection(a):
    num = [int(i[1]) for i in a]
    char = [i[0] for i in a]
    minj = 0
    stay = True
    same_exi = False
    for i in range(n):
        minj = i
        for j in range(i, n):
            if num[minj] > num[j]:
                minj = j
                if same_exi:
                    stay = False
            if num[i] == num[j]:
                same_exi = True
        else:
            num[i], num[minj] = num[minj], num[i]
            char[i], char[minj] = char[minj], char[i]
    else:
        a_new = [char[i] + str(num[i]) for i in range(n)]
        return a_new, stay


def print_space(li):
    for i in range(len(li)-1):
        print(li[i], end=' ')
    else:
        print(li[-1])



cards_bu = bubble(cards)
cards_sl = selection(cards)

sl_list = cards_sl[0]
sl_stay = cards_sl[1]

print_space(cards_bu)
print('Stable')

print_space(sl_list)
if sl_list == cards_bu:
    print('Stable')
else:
    print('Not stable')
    





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

int main() {
  int N;
  cin >> N;
  int r = N % 10;
  if (r == 3) {
    cout << "bon" << endl;
  } else if (r == 0 || r == 1 || r == 6 || r == 8) {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
}

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

using namespace std;

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  for(int i=0;i<k;i++){
    if(a>=b)b*=2;
    else if(b>=c)c*=2;
  }
  cout << (a<b&&b<c?"Yes" : "No") << endl;
}



Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    ll ans = 0;
    auto f = [](ll a) -> ll {
        ll s = 0;
        while (a % 2 == 0)
        {
            s++;
            a /= 2;
        }
        return s;
    };
    repi(i, n, 0)
    {
        ll a;
        cin >> a;
        ans += f(a);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
bool vis[1000002];

int dfs(int x){
	vis[x] = true;
	for(int j = 100 ; j <= 105 ; j ++){
		if((x - j) >= 0){
			if(!vis[x-j]) dfs(x-j);
		}
	}
}

int32_t main(){
	int x;
	cin>>x;
	dfs(x);
	if(vis[0]){
		cout<<1 << endl;
	}
	else cout<<0<<endl;
}

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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  deque<int>k;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i%2==0){k.push_back(a[i]);}
    else{k.push_front(a[i]);}
  }
  if(n%2!=0){reverse(k.begin(),k.end());}
  for(int i=0;i<n;i++){
    cout<<k[i];
    if(i<n-1){cout<<" ";}
  }cout<<endl;

  return 0;
}

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

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

    int a[32] = { 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 << a[K-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
void Main()
{
    ll X;
    cin >> X;

    // 1 + 2 + 3 + ... n = n(n+1) / 2
    ll n = 0;
    while (true) {
        if (n * (n + 1) / 2 >= X) {
            break;
        }
        n++;
    }
    put(n);
}
signed main(){ Main();return 0;}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

string Ten2Four(int a){
  string s = "";
  do{
    s += to_string(a%4);
    a /= 4;
  }while(a);
  reverse(all(s));
  return s;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin >>n && n >= 0){
    cout << Ten2Four(n) << endl;
  }
  return 0;
}

Measured memory_bytes: 3252
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int 			long long int
#define pll 			pair<ll , ll>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007

ll mod_pow(ll a,ll b) {
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) {
	return mod_pow(a , mod-2);
}

void solve() {
    
    int h , n , x;
    
    int sm = 0;
    
    cin >> h >> n;
    
    for(int i = 0; i < n; ++i) {
    	cin >> x;
    	
    	sm += x;
    }
    
    if(sm >= h) {
    	cout << "Yes";
    }
    else {
    	cout << "No";
    }
}       

signed main() {
    fast;
    
    int t = 1;
    
    //cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 3660
main=do
 [a,b,c,x,y]<-map read.words<$>getLine
 print(((if a+b>c*2 then(c*2)else(a+b))*(min x y))+(if (min x y)==x then(if b>c*2 then(c*2)else b)else(if a>c*2 then(c*2)else a))*(abs(x-y)))

Measured memory_bytes: 508
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");
        StringJoiner sj = new StringJoiner("");
        for (int i = 1; i <= s.length; i++) {
            if (i % 2 == 1) {
                sj.add(s[i - 1]);
            }
        }
        System.out.println(sj.toString());
    }

}


Measured memory_bytes: 30740
#include <bits/stdc++.h>
const int MOD = 1e9+7;
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define ll long long
#define ar array
using namespace std;
using P = pair<int,int>;

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

	string S;
	cin >> S;

	if (S=="2019/04/30" || S<="2019/04/30") {
		cout << "Heisei" << endl;
	} else {
		cout << "TBD" << endl;
	}
	return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
#include<math.h>
using namespace std;
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p){ return Point(x + p.x, y + p.y); }
    Point operator - (Point p){ return Point(x - p.x, y - p.y); }
    Point operator * (Point p){ return Point(x * p.x, y * p.y); }
    Point operator / (Point p){ return Point(x / p.x, y / p.y); }

    double abs() { return sqrt(norm()); }
    double norm() { return x * x + y * y; }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
    }
};

typedef Point Vector;

struct Segment {
    Point p1, p2;
};

typedef Segment Line;

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
};

double cross(Vector a, Vector b) {
    return a.x*b.y - a.y*b.x;
};

bool isOtrhgonal(Vector a, Vector b) {
    return equals(dot(a, b), 0.0);
};

bool isParellel(Vector a, Vector b) {
    return equals(cross(a,b), 0.0);
};

int main() {
    int n, x0, x1, x2, x3, y0, y1, y2, y3;
    Line l1, l2;
    scanf("%d", &n);

    for (int i=0; i<n; i++) {
        scanf("%d %d %d %d %d %d %d %d", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3);
        l1.p1.x = x0, l1.p1.y = y0;
        l1.p2.x = x1, l1.p2.y = y1;
        l2.p1.x = x2, l2.p1.y = y2;
        l2.p2.x = x3, l2.p2.y = y3;
        if (isParellel(l1.p1-l1.p2, l2.p1-l2.p2)) printf("2\n");
        else if (isOtrhgonal(l1.p1-l1.p2, l2.p1-l2.p2)) printf("1\n");
        else printf("0\n");
    }

    return 0;
}


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

int main()
{
    int score1[4];
    int score2[2];
    int sum = 0;

    for (int i = 0; i < 4; i++){
        cin >> score1[i];
    }
    for (int j = 0; j < 2; j++){
        cin >> score2[j];
    }

    sort (score1, score1 + 4);
    sort (score2, score2 + 2);

    for (int l = 3; l > 0; l--){
        sum += score1[l];
    }
    sum += score2[1];

    cout << sum << endl;

    return (0);
}

Measured memory_bytes: 3092
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int n, t;
  cin >> n >> t;
  int res = inf;
  for(int i = 0; i < n; i++){
    int a, b;
    cin >> a >> b;
    if(b <= t)res = min(res, a);
  }
  if(res == inf)cout << "TLE" << endl;
  else cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
fn main() {
    let mut c: Vec<Vec<i32>> = Vec::new();
    for _ in 0..3 {
        c.push(read_vec());
    }
    let d0 = c[0][1] - c[0][0];
    let d1 = c[0][2] - c[0][1];
    if c[1][1] - c[1][0] == d0 && c[2][1] - c[2][0] == d0
        && c[1][2] - c[1][1] == d1 && c[2][2] - c[2][1] == d1
    {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read_line() -> String {
    let stdin = std::io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}

fn read_vec<T>() -> Vec<T>
    where T: std::str::FromStr, T::Err: std::fmt::Debug
{
    read_line()
        .split(' ')
        .map(|a| a.trim().parse().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n,m;
    cin >> n >> m; 
    vector<int> t(n,-1);
    bool flag=1;
    rep(i,m) {
        int s,c;
        cin >> s >> c;
        if (t[s-1]!=-1 && c!=t[s-1]) flag=0;
        else t[s-1]=c;
    }
    if (t[0]==0 && n>1) flag=0;
    if (flag) {
        if (t[0]==-1 && n>1) t[0]=1;
        rep(i,n) {
            if (t[i]==-1) t[i]=0;
            cout << t[i];
        }
        cout << endl;
    } else cout << -1 << endl;
    
   
    return 0;  
}

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

#define ll long long
#define vec vector<ll>
#define sortv(a); sort(a.begin(), a.end());
#define rev(a); reverse(a.begin(), a.end());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)

ll MOD = 1000000007;
ll INF = 1LL << 60;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	ll x;cin>>x;
	ll out=x/500;
	out*=1000;
	x=x-(x/500)*500;
	out+=(x/5)*5;
	cout<<out;
}

Measured memory_bytes: 256