akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	vi h(n);
	rep(i, n)cin >> h[i];
	int mx = 0, ans = 0;
	rep(i, n) {
		if (mx <= h[i]) {
			mx = h[i];
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3624
let _ =
    let [n; k] = List.map int_of_string (Str.split (Str.regexp " ") (read_line ())) in
    let ls = List.map int_of_string (Str.split (Str.regexp " ") (read_line ())) in
    let rec drop l = function 0 -> l | n -> drop (List.tl l) (n-1) in
    print_int (List.fold_left (+) 0 (drop (List.sort compare ls) (n-k)))

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

using ll=long long;

const ll inf=1LL<<60;

int main(void){
	ll a,b,n;
	cin >> a >> b >> n;

	ll ans=inf;

	rep(i,n)rep(j,n){
		ll ai=i+1,bi=j+1;

		ll cur=ai*b;
		if(cur%bi==0) ans=min(ans,abs(cur/bi-a));
	}

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

Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
ll mod_pow(ll x,ll n,ll mod){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
ll high_order_bit(ll n){
    ll tmp=1,i=-1;
    while(tmp<=n){
        tmp*=2;
        i++;
    }
    if(n==0) return 0;
    else return i;
}
// 6 -> vec[0] [1] [2]
//          0   1   1
//vec[i]:2^iの位
vector<ll> binary_expansion(ll n){
    vector<ll> B(high_order_bit(n)+1);
    ll tmp=n;
    for(ll i=high_order_bit(n);i>=0;i--){
        B[i]=tmp/pw2[i];
        tmp%=pw2[i];
    }
    return B;
}

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,C; cin>>N>>C;
    vector<vector<ll> > D(C+1,vector<ll>(C+1,0));
    vector<vector<ll> > c(N,vector<ll>(N,0));
    rep1(i,C)rep1(j,C) cin>>D[i][j];
    rep(i,N)rep(j,N) cin>>c[i][j];
    
    //cost[i][j]:あまりiを色jに変えるコスト
    vector<vector<ll> > cost(3,vector<ll>(31,0));
    
    rep(i,3)rep1(j,C){
        ll tmp=0;
        rep(x,N)rep(y,N){
            if((x+y)%3==i && c[x][y]!=j) tmp+=D[c[x][y]][j];
        }
        cost[i][j]=tmp;
    }
    
    ll ans=INF;
    rep1(i,C)rep1(j,C)rep1(k,C){
        if(i!=j && j!=k && k!=i){
            chmin(ans,cost[0][i]+cost[1][j]+cost[2][k]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5484
//Code by ASIM FOIZE AIMON
//CSE'19;CUET
//avoid copy paste//Hit the frined button
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise cout.precision(10); cout << fixed;
#define endl "\n"
#define int int64_t
#define ll long long
#define yes printf("YES\n")
#define no printf("NO\n")
#define pi acos(-1)
int32_t main()
{
    /*#ifndef ONLINE_JUDGE
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/input.txt", "r", stdin);
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/output.txt", "w", stdout);
    #endif*/
    ll a[10001],n,i,j,c=0,d,e,f=1,g,h,s=0,t,x,y,k;
    double p,z=2,m;
    cin>>m;
    p=z*pi*m;
    cout<<fixed<<setprecision(20)<<p<<endl;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int n;
    string s;
    cin >> n >> s;
    int maxv = -100,cnt = 0;
    rep(i,n){
        maxv = max(cnt,maxv);
        if(s[i] == 'I') cnt++;
        else cnt--;
    }   
    cout << max(maxv,cnt) << '\n';
    return 0;
}


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

int main(){

  int N = 0;
  cin >> N;

  int cnt = 0;
  int flg = -1;
  int a = 0;
  int tmp = 1;

  for (int i = 1; i <= N; i++) {
    cin >> a;
    if (tmp == a) {
      tmp++;
      flg = 1;
    } else {
      cnt++;
    }
  }

  if (flg == 1) {
    cout << cnt << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import math as mt
K = input().split(" ")
A = int(K[0])
B = int(K[1])
a = float(A*12.5)
t = float((A+1)*12.5)
t1 = mt.ceil(t)
b = B*10
a1 = mt.ceil(a)
A_data = []
B_data = []
for i in range(b,b+10):
    A_data.append(i)
for i in range(a1,t1):
    B_data.append(i)
A_set = set(A_data)
B_set = set(B_data)
AB_set = A_set & B_set
if AB_set:
    P = min(AB_set)
    print(P)
else:
    print(-1)
    



Measured memory_bytes: 3188
#include <set>
#include <map>
#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>
using namespace std;
using ll = long long;

typedef long long ll;
#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 INF 999999999

priority_queue<ll> q;

ll N,M;
ll a[100010];
int main(){
  cin >> N>>M;
  REP(i,N){
    ll a;
    scanf("%lld",&a);
    q.push(a);
  }
  REP(i,M){
    ll p=q.top();q.pop();
    q.push(p/2);
  }
  ll ans=0;
  REP(i,N){
    ans+=q.top();q.pop();
  }
  cout << ans<<endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    double A, B; cin >> A >> B;
    for(int i = 1; i < 10000; i++)
    {
        if(floor(i*0.08) == A && floor(i*0.1) == B)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp


vector<vector<pair<ll, ll>>> to;
vector<bool> seen;
vector<ll> ans;
ll ans_max = 0;

void dfs(ll v, ll color = -1, ll p = -1){
    seen[v] = true;
    ll k = 1;
    for(ll i = 0; i < to[v].size(); i++){
        ll next_node = to[v][i].first;
        ll edge_id = to[v][i].second;
        
        if(seen[next_node] == true){
            continue;
        }else{
            if(color == k){
                k++;
            }
            ans[edge_id] = k;
            if(k > ans_max){
                ans_max = k;
            }
            k++;
            
            dfs(next_node, ans[edge_id], v);
        }
    }

}

int main() {
    ll n;
    cin >> n;
    to.resize(n);
    ans.resize(n);

    rep(i,n-1){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        to[a].pb(make_pair(b, i));
        to[b].pb(make_pair(a, i));
    }
    
    seen.assign(n,false);
    dfs(0);
    
    cout << ans_max << endl;
    rep(i,n-1){
        cout << ans[i] << endl;
    }
    
    

}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(v)  (v).begin() (v).end()

ll get(ll n)
{
    if(n % 7 == 0) n /= 7;
    ll cur=0,ans=-1;
    for(int i=0;i<1e6;i++)
    {
        cur=cur*10+1;
        cur%=n;
        if(cur==0)
        {
            return i+1;
        }


    }
    return ans;



}
void solve()
{
    ll n;
    cin >> n;
    if(n & 1)
    {
        cout<<get(n)<<endl;
    }
    else
    {
        cout << "-1\n";
    }

}



int main()
{


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1;
    // cin >> t;
    for(int i = 0; i < t; i++)
    {
        solve();
    }

}

Measured memory_bytes: 3584
#include <stdio.h>
#include <string.h>
#define SENTENCE_STR_MAX 1200
#define WORD_STR_MAX 40

int main(void){
	int i,j;
	int len;
	int lenmax = 0;
	int appmax = 0;
	char lenmaxWord[WORD_STR_MAX];
	char appmaxWord[WORD_STR_MAX];
	char str[SENTENCE_STR_MAX][WORD_STR_MAX];
	int strCounter[SENTENCE_STR_MAX];
	for(i = 0; i < SENTENCE_STR_MAX; i++){
		strCounter[i] = 0;
	}
	for(i = 0; ; i++){
		if(scanf("%s",str[i]) == EOF){break;}
	
		/*check length*/
		len = strlen(str[i]);
		if(len > lenmax){
			lenmax = len;
			sprintf(lenmaxWord,"%s",str[i]);
		}
	
		for(j = 0; j <= i; j++){
			if(!strcmp(str[i],str[j])){
				strCounter[j]++;
				break;
			}
		}

	}
	for(j = 0; j < i; j++){
		if(strCounter[j] > appmax){
			appmax = strCounter[j];
			sprintf(appmaxWord,"%s",str[j]);
		}

	}
	printf("%s %s\n",appmaxWord,lenmaxWord);
	
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#pragma GCC optimize "Ofast,omit-frame-pointer,inline"
using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define rep(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;


int main() {

	int x, n;
	cin >> x >> n;

	VI p(n);
	REP(i, n) {
		cin >> p[i];
	}
	sort(ALL(p));
	int i = 0;
	while (true) {
		if (!binary_search(ALL(p), x - i)) {
			cout << x - i << endl;
			return 0;
		}
		if (!binary_search(ALL(p), x + i)) {
			cout << x + i << endl;
			return 0;
		}


		i++;
	}



}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll h,w;
cin>>h>>w;
ll a,b;
cin>>a>>b;
cout<<(h-a)*(w-b)<<endl;
}









Measured memory_bytes: 256
n=int(input())
s = ""
cons = 96

if n%26:
    s+=chr(cons + n%26)
else:
    n-=1
    s+="z"
n = n//26

while n:
    if n%26:
        s+=chr(cons + n%26)
    else:
        n-=1
        s+="z"
    n = n//26
    
print(s[::-1])

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

#define   ll     long long int

int ara[111];
vector<int> v;

int main( )
{
    int n, i, j, k, s = 0;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> ara[i];
        s += ara[i];
        if (ara[i] % 10) v.push_back(ara[i]);
    }
    if (s % 10 == 0) {
        sort(v.begin(), v.end());
        int ss = s;
        for (i = 0; s % 10 == 0 && i < (int) v.size(); i++) {
            s -= v[i];
        }
        if (s % 10 == 0) {
            s = 0;
        }
        cout << s << '\n';
    }
    else {
        cout << s << '\n';
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<stack>
#include<set>
#include <cmath>
using namespace std;
const long long N = 105;
long long M = 1000000007;
set<int>d;
bool q(int n) {
	while (n) {
		if (d.find(n % 10) != d.end()) {
			return 0;
		}
		n /= 10;
	}
	return 1;
}
int main() {
	int n,k;
	cin>>n >> k;
	
	for (int i = 0; i < k; i++) {
		int a;
		cin >> a;
		d.insert(a);
	}
	for (int i = n;; i++) {
		if (q(i)) {
			cout << i;
			return 0;
		}
		else continue;
	}

}

Measured memory_bytes: 256
"""
author : halo2halo
date : 16, Jan, 2020
"""

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

T, X = map(int, readline().decode('utf8').split())
print(T/X)


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

int main(){
	int a, b;
	cin >> a;
	int day[a];
	for(int i=1 ;i<=a; i++){
		cin >> b;
		day[i]=b;
	}
	for(int ii=a ;ii>1; ii--){
		cout << day[ii] << " ";
	}
	cout << day[1] << endl;
	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  string s;
  while (cin >> n >> s) {
    while (true) {
      int x = 0;
      bool f = true;
      each (c, s) {
        if (c == '(') ++x;
        if (c == ')') --x;
        if (x < 0) {
          s = '(' + s;
          f = false;
          break;
        }
      }
      if (f) break;
    }
    cout << s + string(count(s.begin(), s.end(), '(') - count(s.begin(), s.end(), ')'), ')') << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
MOD = 1000000007
N = int(input())

E = [list(map(int, input().split())) for i in range(N)]

T1 = []
T2 = []
T0 = 0

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

for i in range(N): #第一象限、第二象限だけを考える
    if E[i][0] <= 0 and E[i][1] <= 0:
        E[i][0] = -E[i][0]
        E[i][1] = -E[i][1]
    elif E[i][0] >= 0 and E[i][1] < 0:
        E[i][0] = -E[i][0]
        E[i][1] = -E[i][1]

for i in range(N):
    if E[i][0] == E[i][1] == 0:
        T0 += 1
    elif E[i][0] > 0:
        if E[i][1] > 0:
            g = gcd(E[i][0], E[i][1])
            T1.append([E[i][0]//g, E[i][1]//g])
        else:
            T1.append([1, 0])
    else:
        if E[i][0] < 0:
            a, b = E[i][0], E[i][1]
            g = gcd(-a, b)
            T2.append([E[i][1]//g, ((-E[i][0])//g)])
        else:
            T2.append([1, 0])

from collections import defaultdict

D = defaultdict(lambda :[0, 0])

for i in range(len(T1)):
    D[(T1[i][0], T1[i][1])][0] += 1

for i in range(len(T2)):
    D[(T2[i][0], T2[i][1])][1] += 1

res = 1

for x, y in D.values():

    if x > 0 and y > 0:
        res *= (1 + pow(2, x, MOD) - 1 + pow(2, y, MOD) - 1)
        res %= MOD
    elif x > 0:
        res *= pow(2, x, MOD)
        res %= MOD
    elif y > 0:
        res *= pow(2, y, MOD)
        res %= MOD

print((res - 1 + T0) % MOD)

Measured memory_bytes: 173324
import java.util.Scanner;

public class Main {
	static int top = 1;
	static int[] stack = new int[200];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			if (sc.hasNextInt()) {
				int tmpNum = sc.nextInt();
				pop(tmpNum);

			} else {
				String opr = sc.next();
				int a = push();
				int b = push();

				switch (opr) {
				case "+":
					pop(b + a);
					break;
				case "-":
					pop(b - a);
					break;
				case "*":
					pop(b * a);
					break;

				}

			}
		}
		System.out.println(push());

	}

	static void pop(int x) {
		if (top == stack.length - 1) {
			System.err.println("スタックが満杯です");
			return;
		}
		stack[top] = x;
		top++;
	}

	static int push() {
		if (top == 0) {
			System.err.println("スタックが空っぽです");
			return -1;
		}
		top--;
		int ret = stack[top];
		return ret;
	}

}



Measured memory_bytes: 26772
#include <bits/stdc++.h>
using namespace std;
#define loop1(i, start, end) for (int i = start; i < end; i++)
#define loop2(i, start, end) for (int i = end; i >= start; i--)

const int mod = 1000000007;
inline int add(int a, int b)
{
    return a + b >= mod ? a + b - mod : a + b;
}
inline int multi(int a, int b) { return int(a * 1ll * b % mod); }
typedef long long ll;
typedef long double lld;
void solve()
{
    ll n, k;
    cin >> n >> k;
    ll a[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    ll sum = 0;
    for (ll i = 0; i < k; i++)
    {
        sum = sum + a[i];
    }
    cout << sum;
}
int main()
{
    int t;
    solve();
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[202020];

int ok(int ma) {
	int x;
	vector<pair<int,int>> V;
	V.push_back({1,A[1]});
	int i;
	for(i=2;i<=N;i++) {
		if(A[i]>A[i-1]) {
			if(V.back().first!=1) V.push_back({1,0});
			V.back().second+=A[i]-A[i-1];
		}
		else {
			int dif=A[i-1]-A[i];
			while(dif) {
				x=min(dif,V.back().second);
				
				dif-=x;
				V.back().second-=x;
				if(V.back().second==0) V.pop_back();
			}
			
			int del=0;
			while(V.size() && V.back().first==ma) {
				del+=V.back().second;
				V.pop_back();
			}
			
			if(V.empty()) return 0;
			int cur=V.back().first;
			V.back().second--;
			if(V.back().second==0) V.pop_back();
			if(V.empty() || V.back().first!=cur+1) V.push_back({cur+1,0});
			V.back().second++;
			if(del) V.push_back({1,del});
		}
	}
	return 1;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	
	int ma=0;
	for(i=1;i<=N;i++) cin>>A[i];
	int ret=1<<30;
	for(j=29;j>=0;j--) if(ok(ret-(1<<j))) ret-=1<<j;
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1024
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

struct UnionFind {
  vector<ll> par, sizes;
  ll cnt;
  UnionFind(ll N) : par(N), sizes(N, 1), cnt(N) {
    for (ll i = 0; i < N; i++) par[i] = i;
  }

  ll find(ll x) { return par[x] == x ? x : par[x] = find(par[x]); }

  bool same(ll x, ll y) { return find(x) == find(y); }

  ll size(ll x) { return sizes[find(x)]; }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
    cnt--;
  }

  ll count() const { return cnt; }
};

int main() {
  ll n, m, k;
  cin >> n >> m >> k;

  UnionFind uf(n);
  vll ans(n, 0);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a, b);
    ans[a]--;
    ans[b]--;
  }

  rep(i, n) ans[i] += uf.size(uf.find(i));

  rep(i, k) {
    ll c, d;
    cin >> c >> d;
    c--;
    d--;
    bool candcd = uf.same(c, d);
    if (candcd) {
      ans[c]--;
      ans[d]--;
    }
  }

  rep(i, n) cout << --ans[i] << " ";
  cout << endl;

  return 0;
}


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

#define MAX_M 120
#define MAX_N 60

int x[MAX_N][6];
int y[MAX_N][6];
int z[MAX_M][3];
long long int a[MAX_M][MAX_M][MAX_M];
bool b[MAX_M][MAX_M][MAX_M];

int main() {
	memset(b, false, sizeof(b));
	int n, m;
	int MAXX[3] = { 0,0,0 };
	int SUMX[3] = { 0,0,0 };
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 6; j++) {
			cin >> x[i][j];
			MAXX[j % 3] = max(MAXX[j % 3], x[i][j]);
		}
	}

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j <= MAXX[i]; j++) {
			for (int k = 0; k < n; k++) {
				if (x[k][i] == j) {
					y[k][i] = SUMX[i];
					z[SUMX[i]][i] = j;
					SUMX[i] += 1;
				}
				if (x[k][i + 3] == j) {
					y[k][i + 3] = SUMX[i];
					z[SUMX[i]][i] = j;
					SUMX[i] += 1;
				}
			}
		}
	}

	for (int i = 0; i < SUMX[0]; i++) {
		for (int j = 0; j < SUMX[1]; j++) {
			for (int k = 0; k < SUMX[2]; k++){
				a[i][j][k] = z[i + 1][0] - z[i][0];
				a[i][j][k] *= z[j + 1][1] - z[j][1];
				a[i][j][k] *= z[k + 1][2] - z[k][2];
			}
		}
	}

	int p;
	long long int sum = 0;

	for (int i = 0; i < SUMX[0]; i++) {
		for (int j = 0; j < SUMX[1]; j++) {
			for (int k = 0; k < SUMX[2]; k++) {
				p = 0;
				for (int l = 0; l < n; l++) {
					if (((y[l][0] <= i && y[l][3]>i) && (y[l][1] <= j && y[l][4]>j)) && (y[l][2] <= k && y[l][5]>k)) {
						p++;
					}
				}
				if (p >= m) {
					sum += a[i][j][k];
					b[i][j][k] = true;
				}
			}
		}
	}

	cout << sum << endl;

	return 0;
}

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

int main() {
  int x,y;
  cin>>x>>y;
  while(max(x,y)%min(x,y)!=0){
    if(x>y){
      x=x%y;
    }
    else{
      y=y%x;
    }
  }
  cout<<min(x,y)<<endl;
  return 0;
}



Measured memory_bytes: 3084
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		int N, time = 0;
		int[] C = new int[500];
		int[] S = new int[500];
		int[] F = new int[500];

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		for (int i = 0; i < N - 1; i++) {
			C[i] = sc.nextInt();
			S[i] = sc.nextInt();
			F[i] = sc.nextInt();
		}
		int[] ans = new int[N];

		for (int i = 0; i < N - 1; i++) {
			time = 0;
			for (int j = i; j < N - 1; j++) {
				time += calcTime(time, C[j], S[j], F[j]);
			}
			ans[i] = time;
		}

		for (int i : ans) {
			System.out.println(i);
		}
	}

	private static int calcTime(int ft, int C, int S, int F) {
		int tt;

		if (ft < S) tt = S;
		else if (ft % F == 0) tt = ft;
		else tt = ft + F - ft % F;

		return tt + C - ft;
	}
}


Measured memory_bytes: 28804
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1e15
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e5 + 2;
ll i,n,m,cur;
ll a[N],b[N],p[N],sz[N],ans[N];
ll find(ll v){
    return v == p[v] ? v : p[v] = find(p[v]);
}
void merge(ll a,ll b)
{
    a = find(a); b = find(b);
    if(a != b){
        if(sz[b] > sz[a]) swap(a,b);
        cur -= sz[a] * sz[b];
        sz[a] += sz[b];
        p[b] = a;
    }
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>m;
    rep(i,1,n + 1){
        p[i] = i;
        sz[i] = 1;
    }
    rep(i,0,m) cin>>a[i]>>b[i];
    cur = (n * (n - 1)) / 2;
    revrep(i,m - 1,0){
        ans[i] = cur;
        merge(a[i],b[i]);
    }
    rep(i,0,m) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <cmath>
using namespace std;
long long n,k,i,x,y,s;
int main()
{
	cin >> n >> k;
	for ( i = 0 ; i < n ; i++ )
	{
		cin >> x >> y;
		if ( sqrt(x*x+y*y) <= k ) s++;
	}
	cout << s;
}

Measured memory_bytes: 3184
N = int(input())
A = list(map(int,input().split()))

A = list(sorted(A))#ソート
flag = 0#判定のフラグ
for i in range(N//2-1):
    if N % 2 == 1:#奇数
        if A[2*i+1]==A[2*i+2] and A[2*i+1] == 2*i+2 and A[0] == 0:
            pass;
        else:
            flag = -1
            break;
    if N % 2 == 0:
        if A[2*i]==A[2*i] and A[2*i+1] == 2*i+1:
            pass;
        else:
            flag = -1
            break;
if flag == 0:
    ans = 2**(N//2)%(10**9+7)
    print (ans)
else:
    print(0)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

  ll n,a,b;
  cin>>n>>a>>b;
  ll d=b-a;
  if(d%2==0)cout<<d/2<<endl;
  else{
  	ll res=9e18;
  	{
  		minch(res,a+(b-a-1)/2);
  	}
  	{
  		minch(res,n-b+1+(b-a-1)/2);
  	}
  	cout<<res<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
import numpy as np
c=[]
for i in range(3):
    c.append(list(map(lambda x: int(x), input().split())))
c=np.array(c)
ans='Yes'
tmp=c[:,0]-c[:,1]
if np.min(tmp) != np.max(tmp):
    ans='No'
tmp=c[:,0]-c[:,2]
if np.min(tmp) != np.max(tmp):
    ans='No'
tmp=c[0,:]-c[1,:]
if np.min(tmp) != np.max(tmp):
    ans='No'
tmp=c[0,:]-c[2,:]
if np.min(tmp) != np.max(tmp):
    ans='No'
print(ans)

Measured memory_bytes: 12504
#include <iostream>
#include <map>
using namespace std;
using ll = long long;
static const ll MOD = 998244353;
ll mod_pow(ll x, ll n, const ll &p) {
  ll ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}
ll solve() {
    map<ll, ll> count;
    ll N, D1;
    cin >> N >> D1;
    if (D1 != 0) return 0;
    for (ll i = 1, D; i < N; i++) {
        cin >> D;
        if (D == 0) return 0;
        if (count.find(D) == count.end()) count[D] = 1;
        else count[D]++;
    }
    ll ans = 1;
    auto&& prev = make_pair(0LL, 1LL);
    for (const auto& p : count) {
        if (p.first != prev.first + 1) return 0;
        ans  = (ans * mod_pow(prev.second, p.second, MOD)) % MOD;
        prev = p;
    }
    return ans;
}
int main() {
    cout << solve() << endl;
}


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

int main()
{
    int a[33] = {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};
    int k;
    cin >> k;
    printf("%d\n", a[k - 1]);
    return 0;
}


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	string s; cin >> s;
	sort(s.begin(), s.end());
	if(s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(1) != s.at(2)) cout << "Yes" << endl;
	else cout << "No" << endl;
} 


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int count = 0;
		for(int i = 0; i < N; i++) {
			if(sc.nextInt() >=K)count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 48576
s1 = input()
s2 = input()
l1 = len(s1)
l2 = len(s2)
mat = [[l1 + l2 for _ in range(l1 + 1)] for _ in range(l2 + 1)]

for i in range(l1+1):
    mat[0][i] = i
for j in range(l2+1):
    mat[j][0] = j

for j in range(l2):
    for i in range(l1):
        m = mat[j][i] + 1 if s1[i] != s2[j] else mat[j][i]
        mat[j+1][i+1] = min(m, mat[j][i+1] + 1, mat[j+1][i] + 1)
print(mat[l2][l1])


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

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

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

    sort(A.begin(), A.end());
    int cnt = 1, min = A[0];
    for(int i = 1; i < N; i++){
        if (A[i] == min)
            cnt++;
        else
            break;
    }
    
    int ans;
    if((N - cnt) % (K - 1) == 0)
        ans = (N - cnt) / (K - 1);
    else
        ans = ((N - cnt) / (K - 1)) + 1;

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int const N=3e3+5;
int arr[N];
bool check(int a,int b,int c)
{
    if(a+b>c)
    {
        if(a+c>b)
        {
            if(b+c>a)
                return true;
        }
    }
    return false;
}
int solved (int sum,int a,int b,int ind,int n)
{
    int st=ind+1,ed=n-1;
    int ans=0;

    while(st<=ed)
    {
        //cout<<ans<<endl;
        int mid=(st+ed)/2;
       // cout<<arr[mid]<<" "<<a<<" "<<b<<endl;
        if(check(arr[mid],a,b))
        {
            ans=mid-ind;
            st=mid+1;
        }
        else
            ed=mid-1;
//cout<<"HH";
    }
    return ans;
}
int main()
{

int n;
cin>>n;
for(int i=0;i<n;i++)
{
    cin>>arr[i];

}
int sum=0;
sort(arr,arr+n);
for(int i=0;i<n;i++)
{
    //cout<<sum;
    for(int j=i+1;j<n;j++)
    {
        int x=arr[i]+arr[j];
        sum+=solved(x,arr[i],arr[j],j,n);
     //   co'ut<<sum;
    }
}
cout<<sum;
}


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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(i=(a);i<(b);i++)
#define ROF(i,a,b) for(i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector< vi > vii;
typedef vector<string> vs;
typedef pair<int,int> pii;

template < typename T > string to_string(T& n){
  ostringstream stm ;
  stm << n ;
  return stm.str() ;
}

main(){
  int a,b;
cin >> a >> b;
cout << (a+b+1)/2 << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

double kaizyou(int n) {
	int i;
	double ans = 1;
	for (i = 1; i <= n; i++) {
		ans = ans * i;
	}

	return ans;
}
int main() {
	int k=0;
	int ec=0, oc=0;
	int i = 0;
	int ans;
	cin >> k;
	for (i = 1; i <= k; i++) {
		if (i % 2 == 0) {
			ec++;
		}
		else {
			oc++;
		}
	}
	
	ans = (kaizyou(ec) / kaizyou(ec - 1))*(kaizyou(oc) / kaizyou(oc - 1));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <set>
#include <queue>
#include <assert.h>
#include <cmath>
#include <map>


using std::cerr;
using std::cin;
using std::cout;
using std::pair;
using std::string;
using std::vector;
//region
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (b); i >= (b); --i)
#define rep(i, n) for (unsigned i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define repr(i, n) for (int i = (n)-1; i >= 0; --i)
#define repr1(i, n) for (int i = (n); i > 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define sz(x) (int((x).size()))
#define mset(v, n) std::memset((v), n, sizeof(v))
#define BIT(N) (1LL << (N))
#define each(i, v) for (auto&& i : (v))
#define unless(f) if(!(f))
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using vint = vector<int>;
using vlong = vector<ll>;
using vstr = vector<string>;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpll = vector<pll>;
using vvi = vector<vint>;
using vvl = vector<vlong>;
vector<string> split(const string &s, const string &delim) {
  vector<string> res;
  uint pos = 0;
  while (true) {
    const size_t found = s.find(delim, pos);
    if (found < 0) {
      res.push_back(s.substr(pos));
      break;
    }
    res.push_back(s.substr(pos, found - pos));
    pos = found + delim.size();
  }
  return res;
}
template<typename T> string join(vector<T> &vec, const string &sep) {
  size_t size = vec.size();
  if (!size) return "";
  std::stringstream ss;
  for (int i = 0; i < size - 1; i++)
    ss << vec[i] << sep;
  ss << vec[size - 1];
  return ss.str();
}
template<typename T> std::istream &operator>>(std::istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template<typename Iter> inline void print(const Iter &first, const Iter &last, const std::string &d, bool endline) {
  cout << *first;
  for (Iter iter = first + 1; iter < last; ++iter) {
    cout << d << *iter;
  }
  if (endline) cout << "\n";
}
constexpr ll powmod(ll a, ull b, uint p) {
  ll res = 1;
  while (b > 0) {
    if (b % 2) res = res * a % p;
    a = a * a % p;
    b >>= 1u;
  }
  return res;
}
template<class T> bool chmax(T &a, const T &b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, const T &b) { return a > b ? (a = b, true) : false; }
template <typename T> void bsort(vector<T>& v) { std::sort(v.begin(), v.end()); }
template <typename T> void rsort(vector<T>& v) { std::sort(v.begin(), v.end(), std::greater<T>()); }
struct iii {
    iii() {
      cin.tie(nullptr); cout.tie(nullptr);
      std::ios::sync_with_stdio(false);
      cout << std::fixed << std::setprecision(16);
    }
} init;
//endregion

void solve();

int main() {
  int t = 1;
  // scanf("%d", &t);
  // cin >> t;
  rep(i, t) solve();
  return 0;
}

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

  int ans = 0;
  ans += (X / 500) * 1000;
  X %= 500;
  ans += (X / 5) * 5;
  printf("%d\n", ans);

  return;
}


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

#define int long long

int knapsack(int w, int wt[], int val[], int n) {
    int dp[n + 1][w + 1];
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= w; ++j) {
            if (i == 0 || j == 0) dp[i][j] = 0;
            else if (wt[i - 1] <= j) {
                dp[i][j] = max(val[i - 1] + dp[i - 1][j - wt[i - 1]], dp[i - 1][j]);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    return dp[n][w];
}

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

    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }

    int n, w;
    cin >> n >> w;
    int val[n], wt[n];
    for (int i = 0; i < n; ++i) cin >> wt[i] >> val[i];
    cout << knapsack(w, wt, val, n);

    return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//


    // input
    cout << fixed << setprecision(10);
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i, N){
        ll a; cin >> a;
        A.push_back(a);
    }

    reverse(ALL(A));

    pair<ll, ll> ans = {2, 3};
    if(A[0] != 2){
        cout << -1 << endl;
        return 0;
    }
    else{
        rep2(i, 1, N){
            ll mi = ans.first / A[i] * A[i];
            if(ans.first % A[i] != 0) mi+= A[i];
            if(mi > ans.second){
                // print(i);
                // print(mi, ans.second);
                cout << -1 << endl;
                return 0;
            }

            ll ma = ans.second / A[i] * A[i];
            ma += A[i] -1;
            ans.first = mi;
            ans.second = ma;
        }
    }

    cout << ans.first << " " << ans.second << endl;
    
    
    return 0;
}


Measured memory_bytes: 1792
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

seg_unit = 0


def seg_f(x, y):
    return x | y


def build(seg, raw_data):
    N = len(seg) // 2
    seg[N:] = raw_data
    for i in range(N - 1, 0, -1):
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1])


def set_val(seg, i, x):
    N = len(seg) // 2
    i += N
    seg[i] = x
    while i > 1:
        i >>= 1
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1])


def fold(seg, l, r):
    vl = vr = 0
    N = len(seg) // 2
    l, r = l + N, r + N
    while l < r:
        if l & 1:
            vl = seg_f(vl, seg[l])
            l += 1
        if r & 1:
            r -= 1
            vr = seg_f(seg[r], vr)
        l, r = l >> 1, r >> 1
    return seg_f(vl, vr)

def main(N, S, query):
    seg = np.zeros(N + N, np.int64)
    build(seg, 1 << S)
    for q in query:
        t, a, b = q.split()
        if t == b'1':
            a, b = int(a) - 1, ord(b) - ord('a')
            set_val(seg, a, 1 << b)
        else:
            a, b = int(a) - 1, int(b)
            x = fold(seg, a, b)
            print(bin(x).count('1'))

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    seg_f = cc_export(seg_f, (i8, i8))
    build = cc_export(build, (i8[:], i8[:]))
    set_val = cc_export(set_val, (i8[:], i8, i8))
    fold = cc_export(fold, (i8[:], i8, i8))
    cc.compile()

from my_module import seg_f, build, set_val, fold

N = int(readline())
S = np.array(list(readline().rstrip()), np.int64) - ord('a')
query = readlines()[1:]

main(N, S, query)

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

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

int lcm(int a, int b){
  return a*b / gcd(a, b);
}

int main(){
  int n;
  cin>>n;
  int ans=1;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    ans=lcm(ans,a);
  }
  cout<<ans<<'\n';
}


Measured memory_bytes: 3120
using System;
using System.Collections;

namespace ABC049D
{
    class Program
    {
        // After reading editorial

        static void Main(string[] args)
        {
            string[] bufs = Console.ReadLine().Split(' ');
            int N = int.Parse(bufs[0]);
            int K = int.Parse(bufs[1]);
            int L = int.Parse(bufs[2]);

            int[] roads = new int[N + 1];
            int[] rails = new int[N + 1];

            for (int i = 1; i <= N; i++)
            {
                roads[i] = i;
                rails[i] = i;
            }
            // end Initialize

            // begin Road Analyze
            for (int k = 0; k < K; k++)
            {
                bufs = Console.ReadLine().Split(' ');
                int p = int.Parse(bufs[0]);
                int q = int.Parse(bufs[1]);

                p = FindRoot(roads, p);
                q = FindRoot(roads, q);
                if (p != q)
                {
                    roads[p] = q;
                }
            }

            // begin Rail Analyze
            for (int l = 0; l < L; l++)
            {
                bufs = Console.ReadLine().Split(' ');
                int r = int.Parse(bufs[0]);
                int s = int.Parse(bufs[1]);

                r = FindRoot(rails, r);
                s = FindRoot(rails, s);
                if (r != s)
                {
                    rails[r] = s;
                }
            }

            Hashtable table = new Hashtable(K + L);
            for (int i = 1; i <= N; i++)
            {
                long key = (long)FindRoot(roads, i) * (N + 1) + FindRoot(rails, i);
                if (table.Contains(key))
                {
                    table[key] = (int)table[key] + 1;
                }
                else
                {
                    table.Add(key, 1);
                }
            }

            long key0 = (long)FindRoot(roads, 1) * (N + 1) + FindRoot(rails, 1);
            Console.Write(table[key0]);

            for (int i = 2; i <= N; i++)
            {
                long key = (long)FindRoot(roads, i) * (N + 1) + FindRoot(rails, i);
                Console.Write(" {0}", table[key]);
            }

            Console.WriteLine();
        }

        static int FindRoot(int[] union, int pos)
        {
            int root = pos;
            if (root != union[pos])
            {
                root = FindRoot(union, union[pos]);
                union[pos] = root;
            }

            return root;
        }
    }
}


Measured memory_bytes: 34968