akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;
#define prin(num) cout << num << endl;
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 100000000000
#define MOD 1000000007LL
#define MAX_V 10005
#define MAX_E 30005
#define NIL -1
#define WHITE 0
#define BLACK 1
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll N, K, L;


class DisjoingSet {
public:
    vector<ll> rank, p;
    
    DisjoingSet() {};
    DisjoingSet(ll size) {
        rank.resize(size, 0);
        p.resize(size, 0);
        for(ll i=0; i<size; i++) makeSet(i);
    }
    
    void makeSet(ll x) {
        p[x]=x;
        rank[x]=0;
    }
    
    bool same(ll x, ll y) {
        return findSet(x)==findSet(y);
    }
    
    void unite(ll x, ll y) {
        link(findSet(x), findSet(y));
    }
    
    void link(ll x, ll y) {
        if(rank[x]>rank[y]) {
            p[y]=x;
        }else {
            p[x]=y;
            if(rank[x]==rank[y]) {
                rank[y]++;
            }
        }
    }
    
    ll findSet(ll x) {
        if(x!=p[x]) {
            p[x]=findSet(p[x]);
        }
        return p[x];
    }
    
};

int main(void) {
    cin >> N >> K >> L;
    DisjoingSet ds=DisjoingSet(N);
    DisjoingSet es=DisjoingSet(N);
    ll p, q, r, s, i;
    
    for(i=0; i<K; i++) {
        cin >> p >> q;
        p--; q--;
        ds.unite(p, q);
    }
    
    for(i=0; i<L; i++) {
        cin >> r >> s;
        r--; s--;
        es.unite(r, s);
    }
    
    map<P, ll> mp;
    vector<P> com(N);
    
    for(i=0; i<N; i++) {
        com[i].first=ds.findSet(i);
        com[i].second=es.findSet(i);
        mp[com[i]]++;
    }
    
    for(i=0; i<N; i++) {
        if(i>0) cout << " " << mp[com[i]];
        else cout << mp[com[i]];
    }
    cout << endl;
}

Measured memory_bytes: 21120
#include <cstdio>
#include <cstring>
#define int long long 
char c[500005]; 
int val[500005]; 
inline int min(int a,int b){
	return a<b?a:b;
}
inline int max(int a,int b){
	return a>b?a:b;
}
signed main(){
	memset(val,0x3f,sizeof(val));
	scanf("%s",&c);
	int len = strlen(c);
	for(int i=0;i<len;++i){
		if((!i) && c[i] == '<')val[i] = 0; 
		else if(i == len-1 && c[i] == '>')val[i+1] = 0;
		else if(i >= 1 && c[i-1] == '>' && c[i] == '<')val[i] = 0;
	}
	for(int i=0;i<=len;++i){
		if(!val[i]){
			int j=i-1;
			while(j >= 0 && (c[j] == c[i-1])){
				val[j] = val[j] == 0x3f3f3f3f3f3f3f3f?val[j+1]+1:max(val[j],val[j+1]+1);
				--j;
			}
			j = i;
			while(j <= len && c[j] == c[i])val[++j] = val[j]==0x3f3f3f3f3f3f3f3f?val[j-1] + 1:max(val[j],val[j-1]+1); 
		}
	}
	int sum=0;
	for(int i=0;i<=len;++i)sum += val[i]; 
	printf("%lld",sum);
	return 0;
} 
/*
<>>><<><<<<<>>><
*/

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;
const ll inf = 1e18;




void spa(vector<vector<pair<ll,int>>> g, vector<ll>& dist, int src) {
    int n = g.size();
    for (int i=0; i<n; i++) {
	dist[i] = inf;
    }
    dist[src] = 0;
    priority_queue<pair<ll,int>> pq;
    pq.emplace(0,src);
    while (!pq.empty()) {
	auto cur = pq.top();
	pq.pop();
	ll wei = -cur.first;
	int at = cur.second;
	if (wei > dist[at]) continue;
	for (auto ed: g[at]) {
	    ll d = ed.first;
	    int to = ed.second;
	    if (wei+d < dist[to]) {
		dist[to] = wei+d;
		pq.emplace(-dist[to], to);
	    }
	}
    }
}


int n, m, s, t;
vector<vector<pair<ll,int>>> gy, gs;
vector<ll> dy, ds;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n>>m>>s>>t;
    --s; --t;
    
    gy.resize(n);
    gs.resize(n);

    for (int i=0; i<m; i++) {
	int u,v,yc,sc;
	cin>>u>>v>>yc>>sc;
	--u; --v;
	
	gy[u].push_back({yc,v});
	gy[v].push_back({yc,u});

	gs[u].push_back({sc,v});
	gs[v].push_back({sc,u});
    }

    dy.resize(n);
    ds.resize(n);


    spa(gy, dy, s);
    spa(gs, ds, t);

    multiset<ll> ms;
    for (int i=0; i<n; i++) {
	ms.insert(dy[i]+ds[i]);
    }

    //for (ll x: ms) watch(x);

    for (int i=0; i<n; i++) {
	ll lo = *ms.begin();
	ll res = ll(1e15) - lo;
	cout<<res<<"\n";
	ms.erase(ms.find(dy[i]+ds[i]));
    }

    
    
    return 0;
}


Measured memory_bytes: 27964
#include <iostream>
#include <algorithm>
#include <cstring>
#include <fstream>
using namespace std;
using ll = long long;

constexpr ll nlim = 1e5, clim = 1e14;

ll n, c;
ll x[nlim+2], v[nlim+2];
ll f[nlim+2];
ll cum[nlim+2];

ll solve(){
  cum[0] = 0;
  for(int i=1; i<=n+1; i++) cum[i] = cum[i-1] + v[i];

  for(int i=1; i<=n+1; i++){
    f[i] = cum[i] - x[i];
    f[i] = max(f[i-1], f[i]);
  }
  
  ll res = 0;
  for(int b=1; b<=n+1; b++){
    res = max(res, f[b-1] + (cum[n] - cum[b-1]) - 2*(c-x[b]));
  }

  return res;
}

int main(){
  cin >> n >> c;
  for(int i=1; i<=n; i++){
    cin >> x[i] >> v[i];
  }
  x[n+1] = c;   
  
  ll ans = 0;
  ans = max(ans, solve());

  reverse(x, x+n+2);
  reverse(v, v+n+2);
  for(int i=0; i<=n+1; i++){
    x[i] = c - x[i];
  }

  ans = max(ans, solve());

  cout << ans << endl;

  return 0;
}


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

 
int main() {


    int64_t n;
    cin>>n;

    vector<int64_t> L(n);
    for(int i=0;i<n;i++){
        cin>>L.at(i);
    }


    sort(L.begin(), L.end(), greater<int64_t>());

    // a < b + c
    int cnt=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(L.at(i)<L.at(j)+L.at(k))
                    cnt++;
            }
        }
    }

    cout<<cnt<<endl;

 	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
using namespace std;

long long inf = (1 << 30);
long long mod = 1e9;

int main(){

    string s;
    cin >> s;

    cout << s.front() << s.size() - 2 << s.back() << endl;

    return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
A = list(map(int,input().split()))
c = 0
from collections import Counter
d = Counter()
d[0] = 1
ans = 0
r = [0]*(n+1)
for i,x in enumerate(A):
    if i>=k-1:
        d[r[i-(k-1)]]-=1#ここで範囲kからはみ出たものの数を減らす
    c = (c+x-1)%k
    ans += d[c]
    d[c] += 1
    r[i+1] = c
print(ans)

Measured memory_bytes: 125300
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  std::vector<int> a(n),b(n),c(n);
  for(auto&& e: a) 
  {
    cin>>e;
  }
  for(auto&& e: b) 
  {
    cin>>e;
  }
  for(auto&& e: c) 
  {
    cin>>e;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  ll ans=0;
  for (int i = 0; i < n; ++i)
  {
    ll a_kouho=lower_bound(a.begin(), a.end(),b[i])-a.begin();
    ll c_kouho=c.end()-upper_bound(c.begin(), c.end(),b[i]);
    ans+=a_kouho*c_kouho;
  }
  cout<<ans<<endl;
}

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

#define ll long long

int main(){
    string s;
    cin >> s;
    vector<int> hash(26, 0);
    for(int i=0; i<(int)s.length(); ++i){
        hash[s[i]-'a']++;
    }

    for(int i=0; i<26; ++i){
        if(hash[i] == 0){
            char c = 'a'+i;
            cout << c;
            return 0;
        }
    }
    cout << "None";
    return 0;
}


Measured memory_bytes: 3732
use proconio::{input,fastout};

#[fastout]
fn main() {
  input! {
    n: usize,
    m: usize,
    c: isize,
    b: [isize; m],
  }
  let mut ans: usize = 0;
  for _ in 0..n {
    input! {
      a: [isize; m],
    }
    let mut tmp: isize = 0;
    for i in 0..m {
      tmp += a[i] * b[i];
    }
    tmp += c;
    if tmp > 0 {
      ans += 1;
    }
  }
  
  println!("{}",ans);
}


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

int main(){
  int64_t N;
  cin >> N;

  unordered_map<int64_t, int64_t> data;
  int64_t sum= 0;
  int64_t buf;
  for(int i=0; i<N; i++){
    cin >> buf;
    sum+= buf;
    if(data.count(buf)){ data.at(buf)++; }
    else               { data[buf]= 1; }
  }
  
  int Q;
  cin >> Q;
  int64_t from,to;
  for(int q=0; q<Q; q++){
    cin >> from >> to;
    if(!data.count(from)){
      cout << sum << endl;
    }
    else{
      int64_t freq= data.at(from);
      data.erase(from);

      sum+= (to- from)* freq;

      if(data.count(to)){ data.at(to)+= freq; }
      else              { data[to]= freq; }

      cout << sum << endl;
    }
  }
}

Measured memory_bytes: 6600
n=input()
if len(n)==1:
  print(int(n))
elif len(n)==2:
  print(9)
elif len(n)==3:
  print(int(n)-90)
elif len(n)==4:
  print(909)
elif len(n)==5:
  print(int(n)-9090)
else:
  print(90909)

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

struct com {
  int a, b, c;
  bool operator<(const com &that) const {
    if (a != that.a) return a < that.a;
    if (b != that.b) return b < that.b;
    if (c != that.c) return c < that.c;
    return false;
  }
};

void solve() {
  int N, Q;
  cin >> N >> Q;
  vector<com> v;
  rep(i, N) {
    int s, t, x;
    cin >> s >> t >> x;
    v.push_back({ s - x, 1, x });
    v.push_back({ t - x, -1, x });
  }
  sort(all(v));
  set<int> se;
  int j = 0;
  rep(i, Q) {
    int d; cin >> d;
    while (j < (int) v.size() && v[j].a <= d) {
      if (v[j].b == 1) {
        se.insert(v[j].c);
      } else {
        se.erase(v[j].c);
      }
      j++;
    }
    if (se.size()) {
      cout << *se.begin() << '\n';
    } else {
      cout << -1 << '\n';
    }
  }
}


Measured memory_bytes: 16364
#! /usr/bin/env python
#coding utf-8
import numpy as np

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

heights = list(map(int, input().split()))
temps = [T - height * 0.006 for height in heights]
rank = np.array([abs(A - temp) for temp in temps])

print(rank.argmin() + 1)


Measured memory_bytes: 12452
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N=2e3+50,mod=924844033;
int n,k,dp[N][N][4],f[2][N],fac[N],ans;
inline int add(int x,int y)
{
    return (x+y>=mod)?x+y-mod:x+y;
}
inline int mul(int x,int y)
{
    return (long long)x*y%mod;
}

int main()
{
    cin>>n>>k;fac[0]=1;
    for(int i=1;i<=n;i++)fac[i]=mul(fac[i-1],i);
    for(int i=1;i<=n;i++)
    {
        if(i<=k){
            dp[i][0][0]=1;
            if(i+k<=n)dp[i][1][2]=1;
        }else{
            for(int j=0;j<=i&&j<=n;j++){
                for(int s=0;s<=3;++s)
                    dp[i][j][s>>1]=add(dp[i][j][s>>1], dp[i-k][j][s]);
                if(!j)continue;
                dp[i][j][0]=add(dp[i][j][0], dp[i-k][j-1][0]);
                dp[i][j][1]=add(dp[i][j][1], dp[i-k][j-1][2]);
                if(i+k<=n)
                {
                    dp[i][j][2]=add(dp[i][j][2], dp[i-k][j-1][0]);
                    dp[i][j][2]=add(dp[i][j][2], dp[i-k][j-1][1]);
                    dp[i][j][3]=add(dp[i][j][3], dp[i-k][j-1][2]);
                    dp[i][j][3]=add(dp[i][j][3], dp[i-k][j-1][3]);
                }
            }
        }
    }
    int now=0;f[now][0]=1;
    for(int i=n;i>n-k&&i;i--)
    {
        now^=1;
        for(int j=0;j<=n;j++)f[now][j]=0;
        for(int j=0;j<=n/k+1;++j){
            int rs=0;
            for(int s=0;s<=3;s++)rs=add(rs, dp[i][j][s]);
            if(!rs)continue;
            for(int k=n;k>=j;k--)
                f[now][k]=add(f[now][k], mul(f[now^1][k-j], rs));
        }
    }
    for(int i=0;i<=n;i++)
    {
        if(i&1)ans=add(ans, mod-mul(f[now][i],fac[n-i]));
        else ans=add(ans, mul(f[now][i],fac[n-i]));
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 64000
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

data = l()

od = 0
ev = 0

for i in range(n):
    if data[i] % 2 == 0:
        ev += 1
    else:
        od += 1

if od == 0:
    od = 1

print(pow(3,n) - pow(2,ev))

Measured memory_bytes: 65448
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=998244353;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(b==1) return a;else if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n,k);
    vector<pair<int,int>> step(k);
    int l,r;
    rep(i,k){
        in(l,r);
        step[i]=make_pair(l,r);
    }
    sort(all(step));
    vector<ll> dp(n+1,0),dpsum(n+1,0);
    dp[1]=1;
    dpsum[1]=1;
    int left,right;
    for(int i=2;i<=n;i++){
        for(int j=0;j<k;j++){
            left=max(i-step[j].second-1,0);
            right=max(i-step[j].first,0);
            dp[i]+=dpsum[right]-dpsum[left];
            if(dp[i]<0)dp[i]+=MOD;
            else dp[i]%=MOD;
        }
        dpsum[i]=dpsum[i-1]+dp[i];
        dpsum[i]%=MOD;
    }
    out(dp[n]);
}

Measured memory_bytes: 6448
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	fmt.Print(lucasNumber(N))
}

func lucasNumber(N int) int {
	L0 := 2
	L1 := 1
	var L int

	switch N {
	case 0:
		L = L0
	case 1:
		L = L1
	default:
		for i := 0; i < N-1; i++ {
			L = L1 + L0
			L0 = L1
			L1 = L
		}
	}
	return L
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a==b&&b==c){
    printf("%d",1);
  }else if(a==b||b==c||c==a){
    printf("%d",2);
  }else{
    printf("%d",3);
  }
}

Measured memory_bytes: 128
from itertools import combinations_with_replacement
n, m, k = map(int, input().split())
arr = [x for x in range(1, m + 1)]
p = list(combinations_with_replacement(arr, n))
query = []
for i in range(k):
    a, b, c, d = map(int, input().split())
    pp = [a, b, c, d]
    query.append(pp)
m = []
summ = 0

for j in p:

    for k in query:
        a1, b1, c1, d1 = k[0]-1, k[1]-1, k[2], k[3]
        if j[b1] - j[a1] == c1:

            summ += d1

    m.append(summ)

    summ = 0
print(max(m))


Measured memory_bytes: 25184
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline

using namespace std;

int main(void) {
    string s;
    cin >> s;
    int n = s.size();
    int score = n%2 ? (n - 1)/2 : n/2;
    int detractions = 0;
    for (int i = 0; i < n; ++i)
        if (s[i] == 'p')
            ++detractions;
    cout << score - detractions << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

int n;

void solve() {
	cin >> n;
	int ans = 0;
	ans += 1000 * (n / 500);
	n %= 500;
	ans += 5 * (n/5);
	cout << ans;
}

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

 	solve();

  	return 0;
}



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

#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl            "\n"
#define sq(x)           ((x)*(x))
#define pi              acos(-1.0)
#define NUM             1000005

typedef long long ll;


int main()
{
    FastRead
    
    ll n;
    
    cin >> n;
    
    vector<ll> v(n);
    
    ll cnt = 0;
    
    for (ll i = 0; i < n; i++)
    {
        cin >> v[i];
        if (v[i] != i+1)
            cnt++;
    }
    
    if (cnt > 2)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;

}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n),b(200001,0);
  rep(i,n){
    cin >> a.at(i);
    b.at(a.at(i))++;
  }
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  ll ans=0;
  rep(i,k){
    ans+=b.at(i);
  }
  cout << n-ans;
}
  
  
                

Measured memory_bytes: 6364
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <ctime>
#include <queue>
#include <sstream>
#include <utility>
#include <bitset>

using namespace std;

#define MP make_pair 
#define PB push_back 
#define INF (1000000007) 
#define eps 1e-8
#define MOD (1000000007)

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

int n,m;
set<int> s1[200005],s2[200005];

int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		s1[a].insert(b);
		s2[b].insert(a);
	}
	for(int i=1;i<=n;i++)
	{
		if(s1[i].count(n) && s2[i].count(1)) 
		{
			cout<<"POSSIBLE";
			return 0;
		}
	}
	cout<<"IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 37760
from collections import defaultdict

def main():
    high, width = map(int, input().split())
    data = [list(input()) for i in range(high)]


    move = [[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]]

    for i in range(high):
        for j in range(width):
            if data[i][j] == '#':
                continue
            bakudan = 0
            for x, y in move:
                if 0 <= x + i < high and 0 <= y + j < width:
                    if data[x + i][y + j] == '#':
                        bakudan += 1

            data[i][j] = str(bakudan)

    for i in range(high):
        print(''.join(data[i]))





if __name__ == '__main__':
    main()

Measured memory_bytes: 40176
#define M_PI 3.14159265358979323846
#include <stdio.h>
#include <math.h>
 
 
int main(void){
    double PI=M_PI;
    double po=PI*2/1000000;
    int N;
    scanf("%d",&N);
    double x[N],y[N];
    for(int i=0;i<N;i++)scanf("%lf %lf",&x[i],&y[i]);
    int kakuritu[N];
    for(int i=0;i<N;i++)kakuritu[i]=0;
    for(int i=0;i<1000000;i++){
        double max=cos(i*po)*x[0]+sin(i*po)*y[0];
        int maxj=0;
        for(int j=0;j<N;j++){
            if(max<cos(i*po)*x[j]+sin(i*po)*y[j]){max=cos(i*po)*x[j]+sin(i*po)*y[j];maxj=j;}
        }
        kakuritu[maxj]++;
    }
    for(int i=0;i<N;i++){
        printf("%.10f\n",(double)kakuritu[i]/1000000.0f);
    }
    return 0;
}

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

int main(int argc, char *argv[])
{
  int a, b, C;
  double S, L, h;
  double c;

  scanf("%d %d %d", &a, &b, &C);

  S = (a * b * sin((C * M_PI)/180)) / 2;
  c = sqrt(a*a + b*b - 2*a*b*cos((C * M_PI)/180));
  L = a + b + c;
  h = b * sin((C * M_PI)/180);

  printf("%.8lf\n", S);
  printf("%.8lf\n", L);
  printf("%.8lf\n", h);

  return 0;
}

Measured memory_bytes: 664
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

#define N 200010
int n;
vii G(N, vi());
vi p(N);
vector<bool> used(N, false);
vi a(N, -1);
vector<set<int> > st;
int s;

int search_loop(int now) {
	used[now] = true;
	if (used[p[now]]) {
		return p[now];
	}
	else {
		return search_loop(p[now]);
	}
}

int dfs(int now) {
	if (G[now].size() == 0) {
		a[now] = 0;
		return 0;
	}
	for (int i = 0; i < G[now].size(); i++) {
		if (G[now][i] == s) {
			continue;
		}
		st[now].insert(dfs(G[now][i]));
	}
	for (int i = 0; i < n; i++) {
		if (st[now].count(i) == 0) {
			a[now] = i;
			return i;
		}
	}
}

int main() {
	int i, j;
	cin >> n;
	a.resize(n);
	p.resize(n);
	st.resize(n);
	for (i = 0; i < n; i++) {
		cin >> p[i];
		p[i]--;
		G[p[i]].push_back(i);
	}
	int leaf = -1;
	for (i = 0; i < n; i++) {
		if (G[i].size() == 0) {
			leaf = i;
			break;
		}
	}
	

	if (leaf == -1) {
		if (n % 2) {
			cout << "IMPOSSIBLE" << endl;
		}
		else {
			cout << "POSSIBLE" << endl;
		}
		return 0;
	}

	int firsts = search_loop(leaf);
	s = firsts;
	int m = inf;
	int mi = -1;
	do {
		if (m > G[s].size()) {
			m = G[s].size();
			mi = s;
		}
		s = p[s];
	} while (s != firsts);
	s = mi;
	for (i = 0; i <= G[s].size(); i++) {
		for (j = 0; j < n; j++) {
			st[j].clear();
		}
		st[p[s]].insert(i);
		if (dfs(s) == i) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 39936
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
inline int readint(){
    register int x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}

inline long long readlong() {
	register long long x = 0, flag = 1;
	register char ch;
	while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}
template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define ri readint
#define rl readlong

const int maxn = 2e6 + 20;
string s;
char a[maxn];
int K = 200010;
int tou, wei, rev;
int main() {
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		a[i + 1 + K] = s[i];
	}
	tou = K + 1, wei = s.size() - 1  + 1 + K;
	int Q;
	Q = ri();
	for (int i = 1; i <= Q; i++) {
		int opt = ri();
		if (opt == 1) {
			rev ^= 1;
		}
		else {
			opt = ri();
			char c;
			cin >> c;
			if (opt == 1) {
				if (rev == 0) a[--tou] = c;
				else a[++wei] = c;
			}
			if (opt == 2) {
				if (rev == 0) a[++wei] = c;
				else a[--tou] = c;
			}
		}
	}
	if (rev == 0) {
		for (int i = tou; i <= wei; i++) {
			printf("%c", a[i]);
		}
	}
	else for (int i = wei; i >= tou; i--) {
		printf("%c", a[i]);
	}
	return 0;
}


Measured memory_bytes: 4016
#include <iostream>
#include <ctype.h>
 
int main(int argc, const char * argv[]) {
    std::string line;
    getline(std::cin, line);
    for (size_t i = 0; i < line.length(); i++) {
        if (islower(line[i])) {
            line[i] = toupper(line[i]);
        } else if (isupper(line[i])) {
            line[i] = tolower(line[i]);
        }
    }
    std::cout << line.c_str() << std::endl;
    return 0;
}

Measured memory_bytes: 3096
from collections import deque

n = int(input())

g = [[] for _ in range(n)]
# 0indexに直している
for i in range(n - 1):
    u, v, w = map(int, input().split())
    g[u - 1].append((v - 1, w))
    g[v - 1].append((u - 1, w))

"""
根から各頂点への距離をd_iとする
2頂点u,vについて、その最小共通祖先をwとすると
uとvの距離=d_u+d_v-2d_w
第3項は常に偶数
d_uとd_vの偶奇が等しければ全体は偶数、偶奇が異なれば全体は奇数
例えば、d_iが偶数なら白に、奇数なら黒に塗るとすれば条件を満たす
"""

dq = deque([0])

# 各頂点について、根からの距離
# 頂点0を根とする
dist_list = [-1] * n
dist_list[0] = 0

# BFS
while dq:
    now = dq.popleft()
    # tと繋がっている各頂点について
    for info in g[now]:
        next = info[0]
        d = info[1]
        if dist_list[next] == -1:
            # 根からtまでの距離 + tから次への距離
            dist_list[next] = dist_list[now] + d
            dq.append(next)

# 偶数なら白、奇数なら黒とする。白黒は逆でも良い。
for i in dist_list:
    if i % 2 == 0:
        print(0)
    else:
        print(1)


Measured memory_bytes: 95244
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := getInt()
	ans := 0
	for i := 1; i <= n/2; i++ {
		a, b := i, n-i
		if a == b {
			continue
		}

		ans++
	}

	fmt.Fprintln(wr, ans)
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 640
// Problem : C - Sum of product of pairs
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
const long long int  modu=1e9+7;
#define endl '\n'
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define inp(x)  for(auto &t:x) cin>>t;
#define itr     vector<int>::iterator
#define debug(a) cout << #a << "=" << a << ' '<<endl;
#define out(x)  for(auto &t:x) cout<<t<<" "; cout<<endl;
#define ff first
#define ss second
#define pb push_back
#define initialize(a,v)  for(int i=0;i<a.size();++i) a[i]=v;
#define all(x) x.begin(),x.end()
#define mpt(mp) for(auto it=mp.begin();it!=mp.end();it++)
#define trav(x) for(int i=0;i<(int)x.size();++i)
#define mkp(a,b) make_pair(a,b)
#define sz(x)  (int)x.size()

int noofdig(int N)
{
	return floor(log10(N))+1;
}


ll f(ll a)
{

return 0;

}



void pre()
{

}



void solve()
{
	ll n;
	cin>>n;
	
	vl a(n);
	inp(a)
	
	
	ll res=0,sum=0;
	for(int i=0;i<n;++i)
	{
		res=(res+sum*a[i])%modu;
		sum=(sum+a[i])%modu;
	}
    
    
	cout<<(res)%modu<<endl;
	
   
	
	






}



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

	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 4724
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 str = br.readLine();

		if (str.equals("AAA") || str.equals("BBB")) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 32664
#include "bits/stdc++.h"
#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 FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define ALL(v) v.begin(), v.end()
#define FS first
#define SC second
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using namespace std;
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<bool> VB;
typedef vector<vector<int> > VVI;
typedef vector<vector<bool> > VVB;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const LL MOD=1000000007ll;
const LL INF=2000000000ll;

long power(long a,long b){return b?power(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;}
long comb(int N,int K)
{
	long x=1,y=1;
	for(int i=1;i<=K;i++)
	{
		x=x*(N-i+1)%MOD;
		y=y*i%MOD;
	}
	return x*power(y,MOD-2)%MOD;
}

long hcomb(int N, int K){
    return comb(N+K-1, N-1);
}

void dfs(const vector<vector<int> > &G, int v, vector<int> &seen, VI &cnt) {
    seen[v] = true;

    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        cnt[next_v] += cnt[v];
        dfs(G, next_v, seen, cnt);
    }
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);

    int N, Q;
    cin >> N >> Q;

    VVI T(N);
    VI a(N-1), b(N-1);
    REP(i,N-1) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        T[a[i]].push_back(b[i]);
        T[b[i]].push_back(a[i]);
    }

    VI p(Q), x(Q);
    VI cnt(N,0);
    REP(i,Q) {
        cin >> p[i] >> x[i];
        p[i]--;
        cnt[p[i]] += x[i];
    }

    VI seen(N,false);

    dfs(T,0,seen,cnt);

    REP(i,N-1) cout << cnt[i] << " ";
    cout << cnt[N-1] << endl;
}

Measured memory_bytes: 30592
def temp(T,A,x):
    return abs(A-(T - x * 0.006))

n = int(input())
T,A= map(int,input().split())
H = list(map(int,input().split()))

m = temp(T,A,H[0])
idx = 1
for i in range(1,len(H)):
    if m > temp(T, A, H[i]):
        m = temp(T, A, H[i])
        idx = i + 1
print(idx)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int A, B;
  cin >> A >> B;
  int ans = A + B;
  if (ans >= 10)
  {
    cout << "error" << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws Exception {
    Code code = new A();
    code.execute();
  }

  public static interface Code {
    void execute() throws IOException;
  }

  static class A implements Code {
    @Override
    public void execute() throws IOException {
      try (IO io = new IO(System.in)) {
        long[] ll = io.nextLong();
        long N = ll[0];
        long i = ll[1];
        System.out.println(solve(N, i));
      }
    }

    public long solve(long N, long i) {
      return N - i + 1;
    }
  }

  public static class IO implements Closeable {
    private BufferedReader buf;

    public IO(InputStream in) {
      buf = new BufferedReader(new InputStreamReader(in));
    }

    public String nextLine() throws IOException {
      return buf.readLine();
    }

    public String[] nextString() throws IOException {
      return nextLine().split(" ");
    }

    public int[] nextInt() throws IOException {
      return Arrays.stream(nextString()).mapToInt(Integer::parseInt).toArray();
    }

    public long[] nextLong() throws IOException {
      return Arrays.stream(nextString()).mapToLong(Long::parseLong).toArray();
    }

    @Override
    public void close() throws IOException {
      buf.close();
    }
  }
}


Measured memory_bytes: 27732
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
long long arr[n];
for(int i =0; i < n; i++)
    cin>>arr[i];

int c=0;
for(int i =0; i < n-2; i++)
    {
        for(int j = i +1; j < n-1; j++)
        {

            for(int k = j + 1; k < n; k++)
               {if((arr[j] + arr[k]> arr[i] &&arr[j] + arr[i]> arr[k]&&arr[i] + arr[k]> arr[j]) && arr[i] != arr[j] && arr[i] != arr[k] && arr[k] != arr[j])
               c++;
               //cout<<arr[i]<<" "<<arr[j]<<" "<<arr[k]<<endl;
            }}

    }cout<<c<<endl;


}






Measured memory_bytes: 3588
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int start = max(a, c);
    int end = min(b, d);
    int len = max(end-start, 0);
    cout << len << endl;
}


Measured memory_bytes: 256
# Your code here!
strArr = gets.chop.split(" ")
cntArr = gets.chop.split(" ")
strHash = {}
for i in 0..1 do
    strHash.store(strArr[i], cntArr[i].to_i)
end
declementStr = gets.chop
strHash[declementStr] = strHash[declementStr] - 1
outputArr = []
strHash.map do |k, v|
    outputArr.push(v)
end
puts outputArr.join(" ")

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

 int main() {
      int a,b,c;
      cin >> a >> b >> c;
      int s=100*a + 10*b +c;
      if (s % 4 ==0) cout << "YES" ;
         else cout << "NO";

      return 0;
}

Measured memory_bytes: 256
'use strict';

function Main(input) {
    const N = Number(input.trim().split('\n')[0]);

    let divisors = new Array(N + 1).fill(0);

    for (let i = 1; i <= N; i++) {
        for (let j = i; j <= N; j += i) {
            divisors[j]++;
        }
    }

    // console.log(divisors);
    let result = divisors.reduce((sum, v, i) => sum + v * i);

    console.log(String(result));
    

    return;
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 113240
#include <iostream>
#include <vector>
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];
    vector<int> memo0(1, 0), memo1(1, 0);
    {
        int pstart = 0;
        for(; a[pstart] < 0; pstart++);
        for(int i = 0; i+pstart < n; i++) memo1.push_back(a[i+pstart]);
        for(int i = 1; pstart-i >= 0; i++) memo0.push_back(-a[pstart-i]);
    }

    int ans = 1001001001;
    for(int i = 0; i <= k; i++){
        if(i < memo1.size() && k-i < memo0.size()){
            if(ans > memo1[i]*2 + memo0[k-i]) ans = memo1[i]*2 + memo0[k-i];
            if(ans > memo1[i] + memo0[k-i]*2) ans = memo1[i] + memo0[k-i]*2;
        }
    }

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

Measured memory_bytes: 1404
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int sum = 0;
	int N; cin >> N;
	eFOR(i, 1, N) {
		if (i % 3 && i % 5)sum += i;
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 3652
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        long p = Long.parseLong(sc.next());
        sc.close();
        if (p == 1) {
            System.out.println(1);
        } else if (n == 1) {
            System.out.println(p);
        } else {
            HashMap<Long, Long> h = factorization(p);
            long ans = 1;
            for (long k : h.keySet()) {
                long v = h.get(k);
                while (v >= n) {
                    ans *= k;
                    v -= n;
                }
            }
            System.out.println(ans);
        }
    }

    static HashMap<Long, Long> factorization(long p) {
        HashMap<Long, Long> h = new HashMap<>();
        while (p % 2 == 0) {
            if (h.containsKey(2L)) {
                h.put(2L, h.get(2L) + 1);
            } else {
                h.put(2L, 1L);
            }
            p /= 2;
        }
        for (long i = 3; i * i <= p; i += 2) {
            while (p % i == 0) {
                if (h.containsKey(i)) {
                    h.put(i, h.get(i) + 1);
                } else {
                    h.put(i, 1L);
                }
                p /= i;
            }
        }
        if (p > 0)
            h.put(p, 1L);
        return h;
    }
}

Measured memory_bytes: 23892
#include <iostream>

int main() {
    std::string s; std::cin >> s;
    int k; std::cin >> k;
    for (size_t i = 0; i < s.size(); i++) {
        if (s[i] == 'a') {
            continue;
        }
        int d = 26 - (s[i] - 'a');
        if (k >= d) {
            s[i] = 'a';
            k-= d;
        }
        if (k < 0) {
            break;
        }
    }
    if (k > 0) {
        k = k % 26;
    }
    s.back() += k;
    if (s.back() > 'z') {
        s.back() -= 'z';
    }

    std::cout << s << std::endl;
    return 0;
}

Measured memory_bytes: 576
def main():
    X = int(input())


    def isOK(A, B):
        eq = A**5 - B**5
        if X <= eq:
            return True
        else:
            False
    
    def bin_search(B):
        # search A
        left = -1
        right = 10 ** 4 * 2

        while right - left > 1:
            mid = left + (right - left) // 2
            if isOK(mid, B):
                right = mid
            else:
                left = mid

        return right
    

    for B in range(-10**4, 10**4+1):
        A = bin_search(B)

        if A**5 - B**5 == X:
            print(A, B)
            exit()


if __name__ == "__main__":
    main()

Measured memory_bytes: 9212
#include<cstdio>
#include<algorithm>
using namespace std;const int N=1e5+10;typedef long long ll;
struct data
{
	int val;int pos;
	friend bool operator <(data a,data b)
		{return (a.val==b.val)?a.pos<b.pos:a.val<b.val;}
}a[N],b[N];int n;ll tot;int sum[N];
struct treearray
{
	int ta[2*N];
	inline void clear(){for(int i=1;i<=2*n+10;i++)ta[i]=0;}
	inline void c(int x){for(;x<=2*n+10;x+=x&(-x))ta[x]++;}
	inline int q(int x){int r=0;for(;x>0;x-=x&(-x))r+=ta[x];return r;}
}ta;
inline bool jud(int x)
{
	ll ret=0;ta.clear();
	for(int i=1;i<=n;i++)sum[i]=(a[x]<a[i])?-1:1;
	//for(int i=1;i<=n;i++)printf("%d ",sum[i]);printf("\n");
	for(int i=1;i<=n;i++)sum[i]+=sum[i-1];ta.c(n+1);
	for(int i=1;i<=n;i++){ret+=ta.q(sum[i]+n);ta.c(sum[i]+n+1);}
	//printf("jud(%d)=%lld\n",a[x].val,ret);
	return ret>=(tot/2)+1;
}
int main()
{
	scanf("%d",&n);tot=(ll)n*(n-1)/2+n;
	for(int i=1;i<=n;i++)scanf("%d",&a[i].val),a[i].pos=i;
	for(int i=1;i<=n;i++)b[i]=a[i];sort(b+1,b+n+1);int l=1;int r=n;
	while(l!=r){int mid=(l+r)/2;if(jud(b[mid].pos))r=mid;else l=mid+1;}
	printf("%d",b[l].val);return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e8
#define EPS 1e-9

#define rep2(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) rep2(i,0,n)
#define ll long long
#define P pair<int,int>
#define pb push_back

int m,n,b[100];

int main(){
	while(cin>>m>>n&&m){
		rep(i,n)cin>>b[i];
		int l=0,u=15000000;
		while(l<u-1){
			int M=(l+u)/2,x=0,y=0,cur=0;
			for(;;){
				if(x+b[cur]<=M)x+=b[cur++];
				else{y++;x=0;}
				if(cur==n||y==m)break;
			}
			if(cur==n)u=M;
			else l=M;
		}
		cout<<u<<endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
const int maxn=1e5+10;
ll fac[maxn],inv[maxn];
vector <int> G[maxn];
struct node
{
    int sz,cs;
}a[maxn];

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

void init(int p)
{
    fac[0]=1;
    for(int i=1;i<=p;i++)
        fac[i]=(fac[i-1]*i)%mod;
    inv[p]=quickpow(fac[p],mod-2);
    for(int i=p-1;i>=0;i--)
    {
        inv[i]=(inv[i+1]*(i+1))%mod;
    }
}

ll A(ll n,ll m)
{
    if(m>n)
        return 0;
    return fac[n]%mod*inv[n-m]%mod;
}

void dfs(int x,int fa,int cs)
{
    a[x].cs=cs;
    for(int i=0;i<G[x].size();i++)
    {
        int v=G[x][i];
        if(v==fa) continue;
        dfs(v,x,cs+1);
        a[x].sz++;
    }
}

int main()
{
    init(100001);
    int n,u,v;
    ll k;
    scanf("%d%lld",&n,&k);
    for(int i=1;i<n;i++)
    {
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }

    dfs(1,0,1);
    ll ans=k;
    //cout<<ans<<endl;
    for(int i=1;i<=n;i++)
    {
        if(a[i].cs==1)
        {
            ans=ans*A(k-1,a[i].sz)%mod;
           // cout<<A(k-1,a[i].sz)<<endl;
        }
        else
        {
            ans=ans*A(k-2,a[i].sz)%mod;
            //cout<<A(k-2,a[i].sz)<<endl;
        }
    }
    ans%=mod;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 13952
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    cin>>str;
    if(str.length()<n) n=str.length();
    rep(i,n)cout<<str[i];
    if(str.length()>n) cout<<"..."<<endl;
    //else cout<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    int ans = 0;
    cin >> s;
    if (s == "SUN") ans = 7;
    else if (s == "MON") ans = 6;
    else if (s == "TUE") ans = 5;
    else if (s == "WED") ans = 4;
    else if (s == "THU") ans = 3;
    else if (s == "FRI") ans = 2;
    else if (s == "SAT") ans = 1;
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
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);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    string s;
    cin >> s;

    if(s == "ABC") cout << "ARC\n";
    else cout << "ABC\n";


  
    return 0;
}



Measured memory_bytes: 3668