akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int INF=1000100010;
string s[21];
int dp[1<<11][11];
int x[11],y[11],d[11][11];
bool used[21][21];
const int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
int w,h,cnt;
void bfs(int sr){
    memset(used,0,sizeof(used));
    queue<pair<pint,int> > q;
    q.push({{x[sr],y[sr]},0});
    used[y[sr]][x[sr]]=true;
    while(!q.empty()){
        pair<pint,int> pi=q.front();q.pop();
        rep(i,4){
            int tx=pi.first.first+dx[i],ty=pi.first.second+dy[i];
            if(tx>=0&&ty>=0&&tx<w&&ty<h&&s[ty][tx]!='x'&&!used[ty][tx]){
                if(s[ty][tx]=='*'){
                    rep(j,cnt){
                        if(ty==y[j]&&tx==x[j]){
                            d[sr][j]=pi.second+1;
                            if(sr==0) d[j][sr]=pi.second+1;
                            break;
                        }
                    }
                }
                q.push({{tx,ty},pi.second+1});
                used[ty][tx]=true;
            }
        }
    }
}
int main(){  
    while(cin>>w>>h,w|h){
        cnt=1;
        rep(i,h){
            cin>>s[i];
            rep(j,w){
                if(s[i][j]=='o') x[0]=j,y[0]=i;
                if(s[i][j]=='*') x[cnt]=j,y[cnt]=i,++cnt;
            }
        }
        memset(d,-1,sizeof(d));
        rep(i,cnt) bfs(i);
        rep(i,cnt)rep(j,1<<cnt) dp[j][i]=INF;
        dp[(1<<cnt)-1][0]=0;
        for(int i=(1<<cnt)-2;i>=0;--i){
            rep(j,cnt)rep(k,cnt)if(!((i>>k)&1)&&d[j][k]!=-1){
                dp[i][j]=min(dp[i][j],dp[i|1<<k][k]+d[j][k]);
            }
        }
        int mn=INF;
        FOR(i,1,cnt) mn=min(mn,dp[1<<i][i]);
        if(mn!=INF){
            cout<<mn<<endl;
        }
        else cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3216
import bisect,sys
from itertools import *
n=range(50001);a=list(n);a[1]=0
for i in range(2,224):a[i*2::i]=[0]*len(a[i*2::i])
for x in map(int,sys.stdin):
 if x:y=x//2+1;print(sum(1 for d in compress(n[:y],a[:y])if a[x-d]))


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

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

    vector<int> a(n);

    int sumValue = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
        sumValue += a.at(i);
    }

    if (h - sumValue > 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <fstream>
#include <stdio.h>
#include <math.h>

using namespace std;

int main(int argc, const char * argv[]) {
   int K,T;
   int tt;
   cin>>K>>T;
   int max=0;
   for (int i=0;i<T;i++) {
    cin>>tt;
    if (tt>max) max=tt;
   }
   int other=max-(K-max)-1;
   if (other<0) other=0;
   cout<<other<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = [0]*n
sum = 0
for i in range(n):
    if i%2 == 0:
        sum += a[i]
    else:
        sum -= a[i]

ans[0] = sum
for i in range(1,n):
    ans[i] = 2 * a[i-1] - ans[i-1]

print(*ans)

Measured memory_bytes: 14092
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=1e5+50;

int n, anc[N], sze[N];
struct E {
	int x,y;
	E() {}
	E(int _x,int _y)  {
		x=min(_x,_y);
		y=max(_x,_y);
	}
	friend inline bool operator <(const E &a,const E &b) {return a.x<b.x || (a.x==b.x && a.y<b.y);}
};

set <int> *be[N], *re[N];
set <E> all;
typedef set <int> ::iterator it_si;
typedef set <E> :: iterator it_se;
inline it_si nxt(it_si p) {return ++p;}
inline int ga(int x) {return (anc[x]==x) ? x : (anc[x]=ga(anc[x]));}
inline int inc_b(int x,int y) {
	be[x]->insert(y); be[y]->insert(x);
	if(re[x]->find(y)!=re[x]->end()) all.insert(E(x,y)); 
}
inline int dec_b(int x,int y) {
	be[x]->erase(y); be[y]->erase(x);
	it_se t=all.find(E(x,y));
	if(t!=all.end()) all.erase(t);
}
inline int inc_r(int x,int y) {
	re[x]->insert(y); re[y]->insert(x);
	if(be[x]->find(y)!=be[x]->end()) all.insert(E(x,y));
}
inline int dec_r(int x,int y) {
	re[x]->erase(y); re[y]->erase(x);
	it_se t=all.find(E(x,y));
	if(t!=all.end()) all.erase(t);
}
int main() {
	n=rd();
	for(int i=1;i<=n;i++) sze[i]=1, anc[i]=i, be[i]=new set<int>, re[i]=new set<int>;
	for(int i=1;i<n;i++) {
		int x=rd(), y=rd();
		inc_b(x,y);
	}
	for(int i=1;i<n;i++) {
		int x=rd(), y=rd();
		inc_r(x,y);
	}
	int cnt=0;
	while((all.size())&&(++cnt)) {
		int x=all.begin()->x, y=all.begin()->y;
		all.erase(all.begin());
		if(sze[x] < sze[y]) swap(x,y);
		sze[x]+=sze[y]; dec_b(x,y); dec_r(x,y);
		for(it_si it=be[y]->begin(); it!=be[y]->end(); ) {
			int t=*it; it=nxt(it);
			dec_b(y,t); 
			inc_b(x,t);
		}
		for(it_si it=re[y]->begin(); it!=re[y]->end(); ) {
			int t=*it; it=nxt(it);
			dec_r(y,t); 
			inc_r(x,t); 
		}
		delete be[y]; delete re[y];
	}
	puts((cnt==n-1)?"YES":"NO");
}

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long int li;

const ll mod = 1000000007;
const ll inf = 1000000000000000000;

typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vli> vvli;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef map<ll, ll> mll;
typedef map<ll, string> mls;
typedef map<string, ll> msl;
typedef pair<ll, ll> pll;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#pragma GCC optimize("-O3")
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(), v.end()
#define mini(a) *min_element(all(a))
#define maxi(a) *max_element(all(a))
#define tol(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define tou(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define FOR(i, j, k, in) for (ll i = j; i < k; i += in)
#define RFOR(i, j, k, de) for (ll i = j; i >= k; i -= de)
#define rep(i, j, k) FOR(i, j, k, 1)
#define rrep(i, j, k) RFOR(i, j, k, 1)
#define repc(v) for (auto it = v.begin(); it != v.end(); it++)
#define rrepc(v) for (auto it = v.rbegin(); it != v.rend(); it--)
#define T     \
    ll t;     \
    cin >> t; \
    while (t--)

ll gen()
{
    ll temp;
    cin >> temp;
    return temp;
}

ll power(ll a, ll b, ll m)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res = (res * a) % m;
            b--;
        }
        a = (a * a) % m;
        b = b >> 1;
    }
    return res;
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    else
        return gcd(b % a, a);
}
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

#define inpt(v) generate(all(v), gen)
#define sum(v) accumulate(all(v), 0LL)
#define vpll vector<pll>
#define umap unordered_map
#define uset unordered_set
#define print(v, n) rep(i, 0, n) cout << v[i] << " ";

int main()
{
    //   freopen("in.txt", "r", stdin);
    //   freopen("out.txt", "w", stdout);

    string s;
    cin >> s;
    ll n = s.length();
    if (s[n - 1] == 's')
        cout << s << "es";
    else
        cout << s << "s";

    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void){
	
	int n,m;
	
	while(1){
		scanf("%d", &n);
		scanf("%d", &m);
		
		if(n==0 && m==0){
			break;
		}
		
		if(n<m){
			printf("%d %d\n", n, m);
		}else{
			printf("%d %d\n", m, n);
		}
		 
	}
	
	return 0;
}

Measured memory_bytes: 2588
N, M = map(int,input().split())
G = [[0]*N for _ in range(N)]
edge = []
for i in range(M) :
    a, b = map(int,input().split())
    edge.append([a-1, b-1])
    G[a-1][b-1] = G[b-1][a-1] = 1

ans = 0
for i in range(M) :
    a, b = edge[i]
    G[a][b] = G[b][a] = 0
    visited = [0]*N
    stuck = [0]
    while stuck :
        next = stuck.pop()
        visited[next] = 1
        for i in range(N) :
            if G[next][i] == 1 :
                if visited[i] == 1 :
                    continue
                if i in stuck :
                    continue
                stuck.append(i)
    G[a][b] = G[b][a] = 1
    if 0 in visited :
        ans += 1

print(ans)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		int week = Integer.parseInt(input);
		int loan = 100000;
		for(int i = 1;i <= week;i++){
			loan *= 1.05;
			if(loan % 1000 != 0){
				loan += 1000 - loan % 1000;
			}
		}
		System.out.println(loan);
	}
}

Measured memory_bytes: 24092
#include <iostream>

using namespace std;

long long int N, M, a, b;
bool flag1[200001] = {}, flag2[200001] = {};

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> a >> b;
		if (a == 1) {
			flag1[b] = true;
		}
		if (a == N) {
			flag2[b] = true;
		}
		if (b == 1) {
			flag1[a] = true;
		}
		if (b == N) {
			flag2[a] = true;
		}
	}
	for (int i = 2; i <= N - 1; i++) {
		if (flag1[i] && flag2[i]) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e6;
const ll inf = 1e9;
const double pi = acos(-1);
ll sieve[maxn+5] = {0};
int main(){
    ll n;
    cin>>n;
    sieve[1] = 1;
    sieve[0] = 1;
    loop(i,2,maxn){
        if(sieve[i]){
            continue;
        }
        for(ll j =2;j*i<=maxn;j++){
            sieve[j*i] = 1;
        }
    }
    if(n==0 || n==1){
        cout<<0<<endl;
        return 0;
    }
    ll ans = 0;
    ll i = 2;
    while(i<=n || n==1){
        if(i>maxn){
            break;
        }
        if(n%i || sieve[i]==1){
            i++;
            continue;
        }
        ll count = 0;
        ll tar = 1;
        while(n%i==0){
            n/=i;
            count++;
            if(count==tar){
                count=0;
                ans++;
                tar++;
            }
        }
        i++;
    }
    if(n>maxn){
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11452
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
int C[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
vector<int> A;
string ans;

void loop(int a, vi vec, int cnt) {
	// debug(a, vec, cnt);
	int n = C[A[0]];
	if(a == sz(A)) {
		if(cnt <= N && (N - cnt) % n == 0) {
			vec[A[0]] = (N - cnt) / n;
			string tmp;
			rer(i, 10, 0) {
				while(vec[i]) {
					tmp += char(i + '0');
					vec[i]--;
				}
			}
			if(sz(tmp) > sz(ans)) {
				ans = tmp;
			}
			else if(sz(tmp) == sz(ans)) {
				bool ok = false;
				rep(i, 0, sz(tmp)) {
					if(tmp[i] > ans[i]) {
						ok = true; break;
					}
					else if(tmp[i] < ans[i]) break;
				}
				if(ok) ans = tmp;
			}
		}
		return;
	}
	rep(i, 0, n) {
		vec[A[a]] = i;
		loop(a + 1, vec, cnt + C[A[a]] * i);
	}
}

void solve() {
	cin >> N >> M;
	map<int, int> D;
	rep(i, 0, M) {
		int a; cin >> a;
		MAX(D[C[a]], a);
	}
	for(auto p: D) A.pb(p.sec);
	ans = "0";
	loop(1, vi(10, 0), 0);
	cout << ans << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

#define INF 1<<25

int main(){
  int cost[101][101];
  int times[101][101];
  int n,m;
  int a,b,c,t;
  while(cin>>n>>m,n|m){
    for(int i=0;i<101;i++){
      for(int j=0;j<101;j++){
	cost[i][j]=times[i][j]=INF;
      }
    }
    for(int i=0;i<n;i++){
      cin>>a>>b>>c>>t;
      cost[a][b]=cost[b][a]=c;
      times[a][b]=times[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]);
	  times[j][k]=min(times[j][k],times[j][i]+times[i][k]);
	}
      }
    }
    int k,p,q,r;
    cin>>k;
    for(int i=0;i<k;i++){
      cin>>p>>q>>r;
      cout<<(r==0 ? cost[p][q] : times[p][q] ) <<endl;
    }
  }
} 
    

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

const int mod = 1e9 + 7;


int h, w, k;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> h >> w >> k;
  
  vector<ll> x(w + 1); // x[i] := when there's i vertical-lines, how many ways to make pairs?
  // O(W^2)
  x[0] = x[1] = 1;
  for(int i = 2; i <= w; i++) {
    x[i] += x[i-1] + x[i-2];
    if(x[i] > mod)
    	x[i]-= mod;
  }
  vector<ll> dp(w);
  dp[0] = 1;

  vector<ll> dp2(w);
  // O(WH)
  for(int i = 0; i < h; i++) {
    dp2.assign(w, 0);
    for(int a = 0; a < w; a++) {
      dp2[a] += dp[a] * x[w - 1 - a] % mod * x[a] % mod;
      // after = a - 1
      if(a - 1 >= 0) dp2[a-1] += dp[a] * x[w - 1 - a] % mod * x[a - 1] % mod;
      // after = a + 1
      if(a + 1 < w) dp2[a+1] += dp[a] * x[w - 1 - a - 1] % mod * x[a] % mod;
    }
    for(auto &e : dp2) e %= mod;
    swap(dp, dp2);
  }

  cout << dp[k-1] << endl;
  
  return 0;
}


Measured memory_bytes: 3624
from random import random
from sys import setrecursionlimit

setrecursionlimit(10 ** 5)


class TreapNode:
    _value = None
    _priority = None
    _count = None
    _left = None
    _right = None

    def __init__(self, value):
        self._value = value
        self._priority = random()
        self._count = 1


def treap_rotate_right(n):
    l = n._left
    n._left = l._right
    l._right = n
    return l


def treap_rotate_left(n):
    r = n._right
    n._right = r._left
    r._left = n
    return r


def treap_insert(n, v):
    if n is None:
        return TreapNode(v)
    if v == n._value:
        n._count += 1
        return n
    if v < n._value:
        n._left = treap_insert(n._left, v)
        if n._priority > n._left._priority:
            n = treap_rotate_right(n)
    else:
        n._right = treap_insert(n._right, v)
        if n._priority > n._right._priority:
            n = treap_rotate_left(n)
    return n


def treap_delete(n, v):
    if n is None:
        return None
    if n._value > v:
        n._left = treap_delete(n._left, v)
        return n
    if n._value < v:
        n._right = treap_delete(n._right, v)
        return n

    # n._value == v
    if n._count > 1:
        n._count -= 1
        return n

    if n._left is None and n._right is None:
        return None

    if n._left is None:
        n = treap_rotate_left(n)
    elif n._right is None:
        n = treap_rotate_right(n)
    else:
        # n._left is not None and n._right is not None
        if n._left._priority < n._right._priority:
            n = treap_rotate_right(n)
        else:
            n = treap_rotate_left(n)
    return treap_delete(n, v)


def treap_size(n):
    if n is None:
        return 0
    return n._count + treap_size(n._left) + treap_size(n._right)


def treap_str(n):
    if n is None:
        return ""
    result = []
    if n._left is not None:
        result.append(treap_str(n._left))
    result.append("%d:%d" % (n._value, n._count))
    if n._right is not None:
        result.append(treap_str(n._right))
    return ' '.join(result)


def treap_search(n, v):
    # x 未満で最大のノードを検索する. n 未満のノードがなければ nil を返す
    if n is None:
        return None
    if n._value >= v:
        if n._left is None:
            return None
        return treap_search(n._left, v)
    # n._value < v
    if n._right is None:
        return n
    r = treap_search(n._right, v)
    if r is None:
        return n
    return r


class Treap:
    _root = None

    def insert(self, v):
        self._root = treap_insert(self._root, v)

    def delete(self, v):
        self._root = treap_delete(self._root, v)

    def __len__(self):
        return treap_size(self._root)

    def __str__(self):
        return treap_str(self._root)

    def search(self, v):
        return treap_search(self._root, v)


N = int(input())
A = [int(input()) for _ in range(N)]

t = Treap()
for a in A:
    n = t.search(a)
    if n is not None:
        t.delete(n._value)
    t.insert(a)
print(len(t))


Measured memory_bytes: 44324
n = int(str(input())[-1])
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

h = [2,4,5,7,9]
p = [0,1,6,8]
b = [3]

if n in h:
    print("hon")
elif n in p:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vec;

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

int calc(const vec& v){
  int res=0;
  for(int i=0;i<9;i++){
    if(v[i]==0)continue;
    int id=v[i]-1;
    res+= abs(id/3 - i/3) + abs(id%3 - i%3);
  }
  return res;
}

int main(){
  vec A(9);
  for(int i=0;i<9;i++)cin>>A[i];

  queue< vec > Q;
  map< vec , int > d;
  d[A]=0;
  Q.push(A);
  while(!Q.empty()){
    vec p=Q.front();
    Q.pop();
    
    if( calc(p)==0){
      cout<<d[p]<<endl;
      break;
    }
    
    int py=0,px=0;
    for(int i=0;i<9;i++){
      if(p[i]==0){
        py=i/3;
        px=i%3;
        break;
      }
    }

    for(int i=0;i<4;i++){
      int ny=py+dy[i];
      int nx=px+dx[i];
      if(ny<0 || ny>=3 || nx<0 || nx>=3)continue;
      vec np=p;
      swap( np[ny*3+nx] , np[py*3+px] );
      if( d.count(np) == 0 ){
        Q.push(np);
        d[np]=d[p]+1;
      }
    }
    
  }
  return 0;
}



Measured memory_bytes: 26164
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	ll n,m,ans=0,a,b,x;
	cin >> n >> m;
	for(ll i=1;i<=n;i++){
		cin >> a >> b;
		x=a*a+b*b;
		if(sqrt(x)<=m){
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3572
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:268435456")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifndef _MSC_VER
#pragma GCC target ("sse4.2")
#endif
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <random>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	string s, t;
	cin >> s >> t;
	if (t.substr(0, sz(s)) == s && sz(s) + 1 == sz(t))
	{
		cout << "Yes";
	}
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 3648
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>
#include <cmath>
#include <iomanip>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////
int N;
double cache[301][301][301];

double Rec (int a, int b, int c) {
    double & res = cache[a][b][c];
    if (res > -0.5)
        return res;
    res = 0;
    if (a + b + c == 0)
        return 0;

    // roll for a
    if (a)
        res += 1.0 * a / N * (Rec(a - 1, b, c) + 1);
    if (b)
        res += 1.0 * b / N * (Rec(a + 1, b - 1, c) + 1);
    if (c)
        res += 1.0 * c / N * (Rec(a, b + 1, c - 1) + 1);
    


    double miss_prob = 1.0 * (N - a - b - c) / N;
    
    res = (res + miss_prob) / (1 - miss_prob);

    //cerr << a << " " << b << " " << c << " = " << cache[a][b][c] << "\n";
    return res;
}

// E[X] = A + miss * (E[X] + 1)
// E[x] (1 - miss) = E + miss
// E[x] = (E + miss) / (1 - miss)

// X (1 - miss) = E
// X = E / (1 - miss)

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

    vector<int> cnt(4);

    cin >> N;
    for (int i = 0; i < N; i++) {
        int val;
        cin >> val;
        cnt[val]++;
    }

    memset(cache, -1, sizeof(cache));

    cout << std::fixed << std::setprecision(10) << Rec(cnt[1], cnt[2], cnt[3]) << "\n";

    return 0;
}


Measured memory_bytes: 213376
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	void solve() throws IOException {
		long n = nl();
		long k = nl();

		long ans = (n - 1 + k - 2) / (k - 1);
		out.println(ans);
	}

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}

Measured memory_bytes: 24404
n,k = map(int,input().split())
mod = 10**9 + 7
ans = 0
for i in range(k,n+2):
    minx = (i*(i-1))//2
    maxx = (i*(2*n-i+1))//2
    ans += (maxx - minx + 1)
print(ans%mod)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
int n,dp[2003][2003],a[6003],ans,tg,MX[2003],cur;
int A[100004],B[100004],C[100004],t;
void init(){t=0;}
void add(int x,int y,int z){A[t]=x,B[t]=y,C[t++]=z;}
int main(){
	cin>>n;
	for(int i=1;i<=3*n;i++)cin>>a[i]; 
	memset(dp,-1,sizeof(dp));
	memset(MX,-1,sizeof(MX));
	dp[a[1]][a[2]]=dp[a[2]][a[1]]=MX[a[1]]=MX[a[2]]=cur=0;
	for(int i=3;i<3*n;i+=3){
		if(a[i]==a[i+1]&&a[i]==a[i+2]){tg++;continue;}
		init();
		if(a[i]>a[i+1])swap(a[i],a[i+1]);
		if(a[i+1]>a[i+2])swap(a[i+1],a[i+2]);
		if(a[i]>a[i+1])swap(a[i],a[i+1]);
		for(int j=1;j<=n;j++){
		if(a[i]==a[i+1])if(dp[j][a[i]]>=0)add(j,a[i+2],dp[j][a[i]]+1);
		if(a[i+1]==a[i+2])if(dp[j][a[i+1]]>=0)add(j,a[i],dp[j][a[i+1]]+1);
		}
		if(dp[a[i]][a[i]]>=0)add(a[i+1],a[i+2],dp[a[i]][a[i]]+1);
		if(dp[a[i+1]][a[i+1]]>=0)add(a[i],a[i+2],dp[a[i+1]][a[i+1]]+1);
		if(dp[a[i+2]][a[i+2]]>=0)add(a[i],a[i+1],dp[a[i+2]][a[i+2]]+1);
		add(a[i],a[i+1],cur),add(a[i+1],a[i+2],cur),add(a[i],a[i+2],cur);
		for(int j=i;j<i+3;j++)for(int k=1;k<=n;k++)if(MX[k]>=0)add(a[j],k,MX[k]);
		for(int j=0;j<t;j++)if(dp[A[j]][B[j]]<C[j])
			dp[A[j]][B[j]]=dp[B[j]][A[j]]=C[j],MX[A[j]]=max(MX[A[j]],C[j]),MX[B[j]]=max(MX[B[j]],C[j]),cur=max(cur,C[j]);
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++)if(dp[i][j]>=0)ans=max(ans,dp[i][j]);
		if(dp[i][i]>=0)if(i==a[3*n])ans=max(ans,dp[i][i]+1);
	}
	printf("%d",ans+tg);
}


Measured memory_bytes: 19568
//Chandigarh University
//author:- shivamkr21
#include<bits/stdc++.h>
#define tmc long long int
using namespace std;
int main()
{
  tmc n;
  cin>>n;
  tmc v[n],c[n],sum=0;
  for(tmc i=0;i<n;i++)
  {
    cin>>v[i];
  }
  for(tmc i=0;i<n;i++)
  {
    cin>>c[i];
  }
  for(tmc i=0;i<n;i++)
  {
    if(v[i]>c[i])
    {
      sum+=v[i]-c[i];
    }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    char c;
    while(cin>>a>>c>>b)
    {
        if(c=='+') cout<<a+b<<endl;
        else if(c=='-') cout<<a-b<<endl;
        else if(c=='*') cout<<a*b<<endl;
        else if(c=='/') cout<<a/b<<endl;
        else if(c=='?') continue;
    }
    return 0;
}


Measured memory_bytes: 3104
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")



#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <memory>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iomanip>
#include <ctime>
#include <sstream>  
#include <deque>
#include <unordered_set>
#include <stack>
#include <functional>
#include <memory.h>
#include <bitset>
#include <numeric>

using namespace std;

#define int long long

signed main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n, p;
    cin >> n >> p;
    if (n == 1) {
        cout << p << endl;
        return 0;
    }
    int ans = 1;
    for (int i = 2; ; ++i) {
        int cur = i;
        for (int j = 1; j <= n - 1; ++j) {
            cur *= i;
            if (cur > p) {
                break;
            }
        }
        if (cur > p) {
            break;
        }
        if (p % cur == 0) {
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int a, b;
  cin >> a >> b;
  if(a + b == 15) cout << "+" << endl;
  else if(a * b == 15) cout << "*" << endl;
  else cout << "x" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;


char s[100011];
int n;
int k;
int main()
{
	int i,j;
	
	cin>>s;
	n=strlen(s);
	cin>>k;
	
	for(i=0;i<n;i++)
	{
		if(s[i]=='a')continue;
		
		if((int)'z'-s[i]+1<=k)
		{
			k-=(int)'z'-s[i]+1;
			s[i]='a';
		}
	}
	
	k%=26;
	s[n-1]+=k;
	
	cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
      char str1[50],str2[50],str3[50];
      scanf("%s %s %s",str1,str2,str3);
      if(str1[strlen(str1)-1] == str2[0] && str2[strlen(str2)-1]==str3[0]) printf("YES\n");
      else printf("NO\n");
      return 0;
}


Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), N = ip[0], K = ip[1];
	auto h = N.iota.map!(_ => ri).array;
	h.sort();
	int res = int.max;
	foreach(i; 0..N-K+1) {
		res = min(res, h[i+K-1] - h[i]);
	}
	res.writeln;
}

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

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int max = 0, max2 = 0;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    if (A.at(i) >= max) {
      max2 = max;
      max = A.at(i);
    }
    else if (max2 < A.at(i)) {
      max2 = A.at(i);
    }
  }
  for (int i = 0; i < N; i++) {
    if (A.at(i) < max) {
      cout << max << endl;
    }
    else {
      cout << max2 << endl;
    }
  }
}

Measured memory_bytes: 4028
#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 main()
{
	int N;
	cin >> N;
	string S;
	cin >> S;
	int cntw = 0, cntb = 0;
	rep(i,S.size())
	{
		if (S[i] == '.') cntw++;
		else cntb++;
	}
	/*
	int cntlw = 0, cntrb = 0;
	rep(i,S.size())
	{
		if (S[i] == '.') cntlw++;
		else break;
	}
	for (int i = S.size()-1; i >= 0; --i)
	{
		if (S[i] == '#') cntrb++;
		else break;
	}
	*/
	//cout << cntw << " " << cntb << " " << cntlw << " " << cntrb << endl;
	int ans = cntw;
	int now = cntw;
	rep(i,S.size())
	{
		if (S[i] == '.')
		{
			now--;
		}
		else
		{
			now++;
		}
		ans = min(ans,now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

double total;
string s;
int n;

int main()
{
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		double val;
		cin >> val >> s;
		if(s == "JPY") total += val;
		else total += val * 380000.0;
	}

	printf("%.6f\n", total);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int N,M;
  int count=0;
  int SUM=0;
  float line;
  scanf("%d",&N);
  scanf("%d",&M);
  int array[N];
  for(int i=0;i<N;i++){
    scanf("%d",&array[i]);
  }
   for(int i=0;i<N;i++){
    SUM+=array[i];
  }
     for(int i=0;i<N;i++){
    if(array[i]*(4*M)>=SUM)count++;
     }
  if(count>=M)printf("Yes\n");
   else printf("No\n");
}

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

int main()
{
	long long A,B,C,D,E,F;
	cin >> A >> B >> C >> D >> E >> F;

	long long sugar = 0;
	long long sugar_water = 0;

	long long iMax = 30 / A;
	long long jMax = 30 / B;
	long long kMax = F*E / (C*(100+E));
	long long lMax = F*E / (D*(100+E));
	long double concentrationMax = (long double) E / (100+E);
	long double concentration = 0;
	for(long long i=0;i<=iMax;i++){
		for(long long j=0;j<=jMax;j++){
			for(long long k=0;k<=kMax;k++){
				for(long long l=0;l<=lMax;l++){
					long long tmp_sugar, tmp_sugar_water;
					tmp_sugar = C*k + D*l;
					tmp_sugar_water = tmp_sugar + 100*A*i + 100*B*j;
					long double tmp_concentration = (long double) tmp_sugar / tmp_sugar_water;
					if(tmp_concentration <= concentrationMax && tmp_sugar_water <= F){
						if(tmp_concentration >= concentration){
							concentration = tmp_concentration;
							sugar = tmp_sugar;
							sugar_water = tmp_sugar_water;
						}
					}
				}
			}
		}
	}

  cout << sugar_water << " " << sugar << "\n";
	return 0;
}


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

#define PB              push_back
#define MP              make_pair
#define xx              first
#define yy              second
#define abs(x)          ((x)<0?-(x):(x))
#define D(x)            cout << #x << ": " << x << endl
#define un(v)           (v).erase(unique((v).begin(),(v).end()),(v).end())
#define ITERATE(it, v)  for(__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)

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

const LL oo = 2147383647;
const double pi = 2 * acos (0.0);
const double eps = 1e-9;

inline LL gcd(LL a, LL b) {
    a = abs(a); b = abs(b);
    while (b) { a = a % b; swap (a, b); } return a;
}

LL ext_gcd(LL A, LL B, LL *X, LL *Y) {
    LL x2, y2, x1, y1, x, y, r2, r1, q, r;
    x2 = 1; y2 = 0;
    x1 = 0; y1 = 1;
    for(r2 = A, r1 = B; r1 != 0; r2 = r1, r1 = r, x2 = x1, y2 = y1, x1 = x, y1 = y ) {
        q = r2 / r1;
        r = r2 % r1;
        x = x2 - (q * x1);
        y = y2 - (q * y1);
    }
    *X = x2; *Y = y2;
    return r2;
}

inline LL modInv(LL a, LL m) {
    LL x, y;
    ext_gcd(a, m, &x, &y);
    x %= m;
    if ( x < 0 ) x += m; //modInv is never negative
    return x;
}

inline LL power(LL a, LL p) {
    LL res = 1, x = a;
    while (p) {
        if (p & 1) res = (res * x);
        x = (x * x); p >>= 1;
    }
    return res;
}

inline LL bigmod(LL a, LL p, LL m) {
    LL res = 1 % m, x = a % m;
    while (p) {
        if (p & 1) res = (res * x) % m;
        x = (x * x) % m; p >>= 1;
    }
    return res;
}

///<-------------------------------------------------END OF TEMPLATE-------------------------------------------------->

const int N = 100001;
int A[N], cnt[N];

int main() {
    int n;
    scanf("%d", &n);
    memset(cnt, 0, sizeof cnt);
    for(int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);
        cnt[x]++;
    }
    if(cnt[0] > 1) {
        printf("0\n");
        exit(0);
    }
    else {
        int x = 0;
        for(int i = 0; i < N; i++) {
            if(cnt[i] == 0) continue;
            if(cnt[i] > 2) {
                printf("0\n");
                exit(0);
            }
            if(cnt[i] == 2) x++;
        }
        printf("%lld\n", bigmod(2, x, 1e9 + 7));
    }
    return 0;
}


Measured memory_bytes: 640
def m(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


N = int(input())
A = list(map(int, input().split()))

if N == 2:
    print(max(A))
else:
    AF = [1] * (N - 1)
    AB = [1] * (N - 1)

    AF[0] = A[0]
    AB[0] = A[-1]

    for i in range(1, N - 1):
        AF[i] = m(AF[i - 1], A[i])
        AB[i] = m(AB[i - 1], A[- (i + 1)])
    L = max(AF[-1], AB[-1], max([m(AF[i], AB[N - 3 - i]) for i in range(N - 2)]))

    print(L)


Measured memory_bytes: 14584
n = int(input())
nums = map(int, input().split())

def valid(x):
    if x % 2 == 0:
        return (x % 3 == 0) or (x % 5 == 0)
    else:
        return True

if all(map(valid, nums)):
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
#include "vector"
#include "set"
#include "map"
#include "unordered_map"
#include "string"
#include "iostream"
#include "algorithm"
#include "queue"

using namespace std;

#define ll long long
#define INF 2e9
#define MOD 1000000007

typedef vector<int> vi;
typedef pair<int, int> pii;

struct v {
    int x;
    int i;
    int closed;
};

bool comp(const v& x, const v& y) {
    return (x.x < y.x) || (x.x == y.x && x.closed < y.closed);
};

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    bool first = true;
    for (const auto& x : v) {
        if (!first) {
            os << " ";
        }
        first = false;
        os << x;
    }
    return os;
}

template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& elem : v) {
        is >> elem;
    }
    return is;
}

ll pw(ll x, int n) {
    if (n == 1) {
        return x;
    }
    if (n%2 == 0) {
        return pw((x*x) % MOD, n/2);
    }
    return (pw(x, n-1) * x) % MOD;
}

int get_min(map<int, set<int> >& m) {
    return m.begin()->first;
}

int get_min(set<int>& m) {
    return *m.begin();
}

int get_max(map<int, set<int> >& m) {
    auto it = m.end();
    it--;
    return it->first;
}

int get_max(set<int>& m) {
    auto it = m.end();
    it--;
    return *it;
}

void solve() {
    int x;
    cin >> x;

    cout << 1000 * (x/500) + 5 * ((x % 500) / 5);
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

    if (0) {
        int tests;
        cin >> tests;
        while (tests--) {
            solve();
            cout << endl;
        }
    } else {
        solve();
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <iostream>
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,a) repi(i,0,a)
using namespace std;
 
using ll = long long;
int p[100];
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  rep(i, n) cin >> p[i];
  sort(p, p+n);
  int i = 0;
  int mn = 0;
  int mi = 0;
  int mx = 0;
  while(p[i]<= a && i < n){
    i++;
    mn++;
  }
  while(p[i]<= b && i < n) {
    i++;
    mi++;
  }
  mx = n - i; 
  cout << min(mn, min(mi, mx)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <atcoder/modint>
#include <atcoder/lazysegtree>

namespace ac = atcoder;
using mint = ac::modint998244353;

struct Data {
    mint x;
    int len;

    Data() = default;
    Data(mint x, int len) : x(x), len(len) {}

    static Data op(Data lhs, Data rhs) {
        return Data(lhs.x + rhs.x, lhs.len + rhs.len);
    }
    static Data id() { return Data(0, 0); }
};

struct Ope {
    mint a, b;

    Ope() = default;
    Ope(mint a, mint b) : a(a), b(b) {}

    static Ope op(Ope lhs, Ope rhs) {
        return Ope(lhs.a * rhs.a, lhs.a * rhs.b + lhs.b);
    }
    static Ope id() { return Ope(1, 0); }
};

Data apply(Ope ope, Data data) {
    return Data(data.x * ope.a + ope.b * data.len, data.len);
}

void solve() {
    int n, q;
    std::cin >> n >> q;

    std::vector<Data> ds(n);
    for (auto& d : ds) {
        int a;
        std::cin >> a;
        d.x = mint::raw(a);
        d.len = 1;
    }

    ac::lazy_segtree<Data, Data::op, Data::id,
                     Ope, apply, Ope::op, Ope::id>
        seg(ds);

    while (q--) {
        int t;
        std::cin >> t;

        switch (t) {
            case 0: {
                int l, r, _a, _b;
                std::cin >> l >> r >> _a >> _b;
                mint a = mint::raw(_a),
                     b = mint::raw(_b);
                seg.apply(l, r, Ope(a, b));
                break;
            };
            case 1: {
                int l, r;
                std::cin >> l >> r;
                std::cout << seg.prod(l, r).x.val() << "\n";
                break;
            };
        }
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 19552
#include <bits/stdc++.h>
#define rep(i , x , y) for(register int i = (x) , _## i = ((y) + 1) ; i < _## i ; i ++)
#define Rep(i , x , y) for(register int i = (x) , _## i = ((y) - 1) ; i > _## i ; i --)
using namespace std ;
#define int long long
using ll = long long ;
using pii = pair < int , int > ;
const static int _ = 1 << 20 ;
char fin[_] , * p1 = fin , * p2 = fin ;
inline char gc() { return (p1 == p2) && (p2 = (p1 = fin) + fread(fin , 1 , _ , stdin) , p1 == p2) ? EOF : * p1 ++ ; }
inline int read() {
	bool sign = 1 ; char c = 0 ; while(c < 48) ((c = gc()) == 45) && (sign = 0) ;
	int x = (c & 15) ; while((c = gc()) > 47) x = (x << 1) + (x << 3) + (c & 15) ;
	return sign ? x : -x ;
}
template < class T > void print(T x , char c = '\n') {
	(x == 0) && (putchar(48)) , (x < 0) && (putchar(45) , x = -x) ;
	static char _st[100] ; int _stp = 0 ;
	while(x) _st[++ _stp] = x % 10 ^ 48 , x /= 10 ;
	while(_stp) putchar(_st[_stp --]) ; putchar(c) ;
}
template < class T > void cmax(T & x , T y) { (x < y) && (x = y) ; }
template < class T > void cmin(T & x , T y) { (x > y) && (x = y) ; }
signed main() {
#ifdef _WIN64
	freopen("testdata.in" , "r" , stdin) ;
#endif
	int n ;
	cin >> n ;
	string s , t ;
	cin >>s >> t ;
	string ans ;
	for(int i = 0 ; i < n ; i ++) {
		ans += s[i] ;
		ans += t[i] ;
	} 
	cout << ans << '\n' ;
	return 0 ;
}

Measured memory_bytes: 256
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 4500000;
char reader[sz];
char *pos = reader;
int nn, now, ans;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos) n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos) a[i + 1] = a[i + 1] * 10 + *pos++ - '0';
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos) pos++;
                pos++;
            }
            break;
        }
    }
    while(*pos and *pos <= 32) pos++;
    rep(i, m) {
        while('0' <= *pos) b[i + 1] = b[i + 1] * 10 + *pos++ - '0';
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = ans = nn;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7904
A,B,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = min(a) + min(b)
for i in range(m):
	sum = 0
	x,y,c = map(int,input().split())
	sum = a[x-1] + b[y-1] - c
	ans = min(ans,sum)
print(ans)

Measured memory_bytes: 18736
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vint A(N);
    rep(i, N) cin >> A[i];
    vector<int> exist_num(1000001, 0);
    rep(i, N) exist_num[A[i]]++;
    int ans = 0;
    rep(i, N) {
        bool is_exist = false;
        for (int x = 2; x * x <= A[i]; x++) {
            if (A[i] % x == 0){
                if (exist_num[x] >= 1 || exist_num[A[i]/x] >= 1) {
                    is_exist = true;
                    break;
                }
            }
            
        }
        if (A[i] == 1) {
            if (exist_num[1] >= 2) is_exist = true;
        }
        else if (exist_num[1] >= 1) is_exist = true;

        if (exist_num[A[i]] >= 2) is_exist = true;
        //if (exist_num[A[i]] >= 2) is_exist = false;
        if (is_exist == false) ans++;
    }


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

Measured memory_bytes: 7936