akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		boolean ans = C - (A - B) > 0;
		int value = C - (A - B);
		if(ans){
			System.out.println(value);
		}
		else{
			System.out.println(0);

		}
	}
}


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

const int maxn = 707;

int n, m;
int g[maxn][maxn];
int col[maxn];
vector<int> cur;
vector<int> s, t;
int vis[maxn];

void dfs(int u) {
	vis[u] = 1;
	cur.emplace_back(u);
	for(int i = 1; i <= n; i++) if(i != u and !g[u][i]) {
		int v = i;
		if(!vis[v]) {
			col[v] = 1 ^ col[u];
			dfs(v);
		} else {
			if(col[u] == col[v]) {
				cout << "-1" << endl;
				exit(0);
			}
		}
	}
}

int dp[maxn][maxn];

int main(int argc, char const *argv[])
{
	// freopen("in", "r", stdin);
	cin >> n >> m;
	for(int i = 1; i <= m; i++) {
		int u, v; cin >> u >> v;
		g[u][v] = g[v][u] = 1;
	}
	for(int i = 1; i <= n; i++) {
		if(!vis[i]) {
			cur.clear();
			dfs(i);
			int x = 0, y = 0;
			for(int u : cur) {
				x += col[u];
				y += 1 ^ col[u];
			}
			s.emplace_back(x);
			t.emplace_back(y);
		}
	}
	s.insert(s.begin(), 0);
	t.insert(t.begin(), 0);
	for(int i = 0; i <= n; i++) {
		dp[0][i] = i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2;
	}
	for(int i = 1; i < s.size(); i++) {
		for(int j = 0; j + s[i] <= n or j + t[i] <= n; j++) {
			dp[i][j] = INT_MAX;
			if(j + s[i] <= n) dp[i][j] = dp[i - 1][j + s[i]];
			if(j + t[i] <= n) dp[i][j] = min(dp[i][j], dp[i - 1][j + t[i]]);
		}
	}
	cout << dp[s.size() - 1][0] << endl;
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);

ll N; ll dis[5];
int input()
{
    cin>>N;
    for(int i=0;i<5;++i){
        cin>>dis[i];
    }
}

int solve()
{
    ll mi=1e16;
    for(int i=0;i<5;++i) mi=min(mi,dis[i]);
    ll ans=N/mi+5ll;
    if(N%mi==0) ans--;
    cout<<ans<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

ll inv(ll a, ll b){
    return (a > 1 ? b - inv(b%a, a)*b/a : 1);
}

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))
#define N 100010

const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL<<62);
const int iinf = (1<<30);
//CLOCKS_PER_SEC

int n, ans[N];
string s;
bool u[N];

int main(){
    //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    //ios_base::sync_with_stdio(0); cin.tie(0);
    //ifstream cin ("test.in");
    cin >> s;
    n = s.length();
    for (int i=1; i<n; i++){
        if (s[i-1] == 'R' && s[i] == 'L'){
            int lcnt = 0, rcnt = 0;
            for (int j=i-1; j>=0 && s[j] == 'R'; j--) lcnt++;
            for (int j=i; j<n && s[j] == 'L'; j++) rcnt++;
            //cout << i << ' ' << lcnt << ' ' << rcnt << '\n';
            ans[i-1] = (lcnt + 1) / 2 + rcnt / 2;
            ans[i] = (rcnt + 1) / 2 + lcnt / 2;
        }
    }
    for (int i=0; i<n; i++) cout << ans[i] << ' ';
    return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

const static int N = 100000;
int visit[N + 1] = {}, sum_cost[N + 1] = {};
vector<vector<pair<int, int> > > G(N + 1);

int dfs(int x) {
    visit[x] = 1;

    for(size_t i = 0; i < G[x].size(); i++) {
        if (visit[G[x][i].first]) {
            if (sum_cost[G[x][i].first] != sum_cost[x] + G[x][i].second) return 0;
        } else {
            sum_cost[G[x][i].first] = sum_cost[x] + G[x][i].second;
            if (dfs(G[x][i].first) == 0) return 0;
        }
    }
    return 1;
}

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

    int n, m;
    cin >> n >> m;
    int l, r, d;
    rep(i, m) {
        cin >> l >> r >> d;
        G[l].push_back(make_pair(r, d));
        G[r].push_back(make_pair(l, -d));
    }

    for (int i = 1; i <= n; ++i) {
        if (visit[i]) {
            continue;
        }

        if (dfs(i) == 0) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

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

final class Main {

    private Main() {
    }

    public static void main(final String[] argv) throws IOException {
        final BufferedReader inputReader =
                new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String input = inputReader.readLine();
            if (input == null) {
                break;
            }
            String[] inputs = input.split(",");
            int[] v = {Integer.parseInt(inputs[10]),
                       Integer.parseInt(inputs[11])};
            int[] l = new int[10];
            for (int i = 0; i < 10; i++) {
                l[i] = Integer.parseInt(inputs[i]) * v[0] * v[1];
            }
            int sumA = 0;
            int sumB = 0;
            for (int i : l) {
                sumB += i;
            }
            while (true) {
                if (sumA >= sumB) {
                    break;
                }
                sumA += v[0];
                sumB -= v[1];
            }
            for (int i = 0; i < l.length; i++) {
                sumA -= l[i];
                sumB -= l[i];
                if (sumA <= 0 || sumB <= 0) {
                    System.out.println(i + 1);
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 9376
# 2019 12/01
# B Tax Rate

import math

N = int(input())

X1 = int(N / 1.08)
X2 = X1 + 1

if math.floor(X1 * 1.08) == N:
    print(X1)
elif math.floor(X2 * 1.08) == N:
    print(X2)
else:
    print(":(")

Measured memory_bytes: 3060
#!/usr/bin/env python3
n, a, b = map(lambda x: int(x) - 1, input().split())
if (b - a) % 2 == 0:
    print((b - a) // 2)
else:
    m = min(a, n - b)
    print(m + (b - a + 1) // 2)


Measured memory_bytes: 2940
#!/usr/bin/env python3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	n = int(sys.stdin.readline())
	x = 100
	# n = 1.1x
	cnt = 0
	while x < n:
		x = int(x * 1.01)
		cnt += 1
	print(cnt)

main()

Measured memory_bytes: 9960
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int cost[n+1];
    cost[1]=0;
    cost[2]=abs(a[2]-a[1]);
    for(int i=3;i<=n;i++)
    {
        int x=cost[i-1]+abs(a[i]-a[i-1]);
        int y=cost[i-2]+abs(a[i]-a[i-2]);
        cost[i]=min(x,y);
    }
    cout<<cost[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n,T;
  cin>>n>>T;
  
  int c,t;
  int mi=1e9;
  rep(i,n){
    cin>>c>>t;
    if(t<=T && c<mi) mi=c;
  }
  
  if(mi==1e9) cout<<"TLE"<<endl;
  else cout<<mi<<endl;
  
  return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main(void)
{
	int b1,b2,b3,c;
	scanf("%d %d %d",&b1,&b2,&b3);
	c=b1+b2;
	if(c==2 || b3==1){
		printf("Open\n");
	}
	else printf("Close\n");
	return 0;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ll long long
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}

const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i>n || i < 0) return 0; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){ans *=(n+1-j); ans /= j; ans %= MOD;} }return ans;}
template<typename T> T gcd(T a, T b){if(b == 0) return a;else return gcd(b, a%b);}
template<typename T> T lcm(T a, T b){if(b > a) swap(a, b); T g = gcd(a, b);return a / g * b;}

void solve(){
  string s, t; cin >> s >> t;
  int match = 1000000;
  int n = s.size();
  int tsize = t.size();
  for(int i= 0; i < n-tsize + 1; i++) {
    int cnt = 0;
    for(int j = 0; j < tsize; j++){
      if(s[i + j] != t[j])cnt++;
    }
    match = min(match, cnt);
  }
  cout << match << endl;
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#include <set>
#include <map>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

char c;

int main(){
    cin>>c;
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int  //comment for large arrays
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define INF 10000000000000001
#define all(x) (x).begin(),(x).end()
#define LB(v,x) (lower_bound(all(v),x) - v.begin()) 
#define UB(v,x) (upper_bound(all(v),x) - v.begin())
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vec(dt) vector<dt>
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v)) 
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || click to see test details "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(int i=s;i<n;i++)
#define print(v) for(auto it:v) cout<<it<<" "; cout<<endl 
using namespace std;

int n,dpb[100001],dpw[100001],vis[100001];
vec(int) adj[100001];

void f(int node)
{
	vis[node] = 1;
	dpw[node] = dpb[node] = 1;
	for(auto it:adj[node])
		if(!vis[it])
		{
			f(it);
			dpw[node] = (dpw[node] * (dpw[it] + dpb[it]))%mod;
			dpb[node] = (dpb[node] * dpw[it])%mod;
		}
}


signed main()
{
	fastio(0);
	cin>>n;
	loop(i,1,n)
	{
		int x,y;
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	f(1);
	cout<<(dpw[1] + dpb[1])%mod<<endl;
	return 0;		
}

Measured memory_bytes: 12288
import math
from functools import reduce
n, m = input().split()
a = list(map(int, input().split()))
b =[0]*int(n)
for i in range(len(a)):
  b[i] = a[i]//2

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
c = 0

x = lcm_list(b)
for i in range(int(n)):
  if (x // b[i]) % 2 == 0:
    c = -1
    break
  else:
    continue
    
if c == -1:
  print(0)
else:
  print(math.floor(((int(m)/x)+1)/2))



Measured memory_bytes: 21236
#include <iostream>
#include <unordered_map>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


int H, W, N;
int a, b;
unordered_map<long, long> mp;
long cnt[10];

bool isin(int h, int w) {
  return 1 <= h && h <= H - 2 && 1 <= w && w <= W - 2;
}

long hs(int a, int b) {
  return (long) a * W + b;
}

int main(void) {
  cin >> H >> W >> N;

  REP(i, 0, N) {
    cin >> a >> b;

    if(isin(a - 2, b - 2)) mp[hs(a - 2, b - 2)]++;
    if(isin(a - 2, b - 1)) mp[hs(a - 2, b - 1)]++;
    if(isin(a - 2, b    )) mp[hs(a - 2, b    )]++;
    if(isin(a - 1, b - 2)) mp[hs(a - 1, b - 2)]++;
    if(isin(a - 1, b - 1)) mp[hs(a - 1, b - 1)]++;
    if(isin(a - 1, b    )) mp[hs(a - 1, b    )]++;
    if(isin(a    , b - 2)) mp[hs(a    , b - 2)]++;
    if(isin(a    , b - 1)) mp[hs(a    , b - 1)]++;
    if(isin(a    , b    )) mp[hs(a    , b    )]++;
  }

  cnt[0] = (long) (H - 2) * (W - 2);
  REP(i, 1, 10) cnt[i] = 0;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    cnt[0]--;
    cnt[itr->second]++;
  }

  REP(i, 0, 10) {
    cout << cnt[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 36624
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

const long long MOD = 1000000007LL;

int main(){
  int N;
  cin >> N;
  ll T[N],A[N];
  for(int i=0;i<N;i++) cin >> T[i];
  for(int i=0;i<N;i++) cin >> A[i];

  ll mn[N], mx[N];
  for(int i=0;i<N;i++){
    if(i == 0){
      mn[i] = T[i];
      mx[i] = T[i];
    }
    else if(T[i] > T[i-1]){
      mn[i] = T[i];
      mx[i] = T[i];
    }
    else{
      mn[i] = 1LL;
      mx[i] = T[i];
    }
  }

  for(int i=N-1; i>=0; i--){
    if(i == N - 1){
      mn[i] = max(mn[i], A[i]);
      mx[i] = min(mx[i], A[i]);
    }
    else if(A[i] > A[i+1]){
      mn[i] = max(mn[i], A[i]);
      mx[i] = min(mx[i], A[i]);
    }
    else{
      mn[i] = max(mn[i], 1LL);
      mx[i] = min(mx[i], A[i]);
    }
  }

  ll ans = 1LL;
  for(int i=0;i<N;i++){
    if(mn[i] > mx[i]){
      cout << 0 << endl;
      return 0;
    }
    else{
      ans *= (mx[i] - mn[i] + 1);
      ans %= MOD;
    }
  }

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


Measured memory_bytes: 3328
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>
#include <bitset>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int const TREE_SIZE = (1 << 20);

class SegTree{
	public:
	// コンストラクタ
	SegTree(std::function<long long int(long long int, long long int)> monoidFunc_, long long int invalidValue_){
		monoidFunc = monoidFunc_;
		invalidValue = invalidValue_;
	}
	// 値の初期化
	void init(long long int initValue){
		for(int i = 0; i < TREE_SIZE; i++){
			segTree[i] = initValue;
		}
	}
	// a番目(0-indexed)をwに変更する O(log N)
	void change(int a, long long int w){
		change_(a + 1, w);
	}
	// 区間 [a, b] (0-indexed)の値を求める O(log N)
	long long int query(int a, int b){
		return query_(a + 1, b + 2, 1, 0, TREE_SIZE / 2);
	}
	private:
	function<long long int(long long int, long long int)> monoidFunc;
	long long int invalidValue;
	long long int segTree[TREE_SIZE]; // 1-indexed

	// a番目をwに変更する O(log N)
	void change_(int a, long long int w){
		a += TREE_SIZE / 2;
		segTree[a] = w;
		for(int x = a / 2; x > 0; x /= 2){
			segTree[x] = monoidFunc(segTree[2 * x], segTree[2 * x + 1]);
		}
	}
	// 区間 [a, b) の値を求める O(log N)
	// query(a, b, 1, 0, TREE_SIZE / 2) のように呼ぶ
	long long int query_(int a, int b, int index, int l, int r){
		if(r <= a || b <= l){
			return invalidValue;
		}
		if(a <= l && r <= b){
			return segTree[index];
		}
		return monoidFunc(query_(a, b, index * 2, l, (l + r) / 2), query_(a, b, index * 2 + 1, (l + r) / 2, r));
	}
};

long long int func(long long int a, long long int b){
	return (a + b) % MOD;
}
SegTree segTree(func, 0);

long long int rev_mod(long long int num){
	long long int pow_num = MOD - 2;
	long long int mod_num = MOD;
	long long int pow_cur = num;
	long long int ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= mod_num;
		}
		pow_cur *= pow_cur;
		pow_cur %= mod_num;
		pow_num /= 2;
	}
	return ret;
}

long long int X[110000];

int main(){
	segTree.init(0);
	int N;
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> X[i];
		segTree.change(i, X[i]);
	}
	long long int ans = 0;
	for(int i = 1; i < N; i++){
		ans += rev_mod(i) * rev_mod(i + 1) % MOD * segTree.query(N - i - 1, N - 2) % MOD;
		ans -= rev_mod(i) * rev_mod(i + 1) % MOD * segTree.query(0, i - 1) % MOD;
		ans += MOD;
		ans %= MOD;
	}
	for(int i = 0; i < N - 1; i++){
		ans += rev_mod(N - i - 1) * X[N - 1] % MOD;
		ans -= rev_mod(N - i - 1) * X[i] % MOD;
		ans += MOD;
		ans %= MOD;
	}
	for(int i = 1; i < N; i++){
		ans *= i;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9216
import sys
l = sys.stdin.readline().strip()
 
a, b, c = map(int, l.split())
right = (c-a-b)
if right < 2:
    print("No")
else:
    right *= right
    left = 4 * a *b
    if left < right:
        print ("Yes")
    else:
        print("No")

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

const int L=1e6;

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

  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N) cin>>A[i];

  vector<int> num(L+1,0);
  vector<int> used(L+1,0);
  for(int i=0;i<N;i++){
    if(used[A[i]]){
      num[A[i]]++;
      continue;
    }
    used[A[i]]=1;
    for(int j=1;A[i]*j<=L;j++) num[A[i]*j]++;
  }

  int ans=0;
  rep(i,N) if(num[A[i]]==1) ans++;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 11908
#include <iostream>
using namespace std;
int memo[51];

int main() {
    for (int a = 0; a < 10; a++) {
        for (int b = 0; b < 10; b++) {
            for (int c = 0; c < 10; c++) {
                for (int d = 0; d < 10; d++) {
                    memo[a + b + c + d]++;
                }
            }
        }
    }
    int n;
    while (cin >> n) {
        cout << memo[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N;
  cin >> N;
  ll sum = 0;
  REP(i, 1, N+1) {
    if(i % 3 != 0 && i % 5 != 0) sum += i;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3624
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: u64
    };

    let res = n * (n - 1) / 2;
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int a;
	cin>>a;
	int out=a*(a+1)/2;
	vi used(10000010);

	loop(i,2,10000010)if(used[i]==0){
		int t=1;
		while(1){
			t*=i;
			if(t>a)break;
			used[t]=1;
			int c=a/t;
			out+=c*(c+1)/2*t;
		}
	}

	cout<<out<<endl;
}


Measured memory_bytes: 81324
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int nagasa;
  string str,answer;
  cin>>str;
  nagasa=str.size();
  answer="Yes";
  for(int i=0; i<nagasa; i++){
    if(i%2==0){
      if(str.at(i)=='L'){
        answer="No";
        break;
      }
    }
    else{
      if(str.at(i)=='R'){
        answer="No";
        break;
      }
    }
  }
  cout<<answer;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(3);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    while(n--){
        double x1,x2,x3,y1,y2,y3;
        cin>>x1>>y1>>x2>>y2>>x3>>y3;
        double a=2*(x2-x1),b=2*(y2-y1),c=sq(x2)-sq(x1)+sq(y2)-sq(y1);
        double d=2*(x3-x2),e=2*(y3-y2),f=sq(x3)-sq(x2)+sq(y3)-sq(y2);
        double x=(c*e-b*f)/(a*e-b*d);
        double y=(c*d-a*f)/(b*d-a*e);
        if(x==-0)x=0;
        if(y==-0)y=0;
        double r=sqrt(sq(x-x1)+sq(y-y1));
        cout<<x<<" "<<y<<" "<<r<<endl;
    }
}
        


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

using namespace std;

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    vector<int> deg(4, 0);
    for (int i = 0; i < 3; ++i) {
        int a, b;
        cin >> a >> b;
        ++deg[a - 1];
        ++deg[b - 1];
    }
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < 4; ++i) {
        cnt1 += deg[i] == 1;
        cnt2 += deg[i] == 2;
    }
    if (cnt1 == 2 && cnt2 == 2) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n, x;
    do
    {
        int count = 0;
        scanf("%d %d", &n, &x);
        if (n != 0 || x != 0)
        {

            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    for (int k = 1; k <= n; k++)
                    {
                        if (i < j && j < k && i + j + k == x)
                            count++;
                    }
                }
            }
            printf("%d\n", count);
        }
    } while (n != 0 || x != 0);
    return 0;
}


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

long long N, K;
int A[500];
int sum_A = 0;



// sum(resid_A[:idx]) == (N - idx) * cand - sum(resid_A[idx:])
// sum(resid_A) == (N - idx) * cand
// N - idx == sum(resid_A) / cand
// idx = N - sum(resid_A) / cand
bool is_ok(int cand){
    int resid_A[500];
    int resid_A_sum = 0;
    for(int i = 0; i < N; i++){
        resid_A[i] = A[i] % cand;
        resid_A_sum += resid_A[i];
    }
    sort(resid_A, resid_A + N);
    int ops = 0;
    for(int i = 0; i < N - resid_A_sum / cand; i++){
        ops += resid_A[i];
    }
    return ops <= K;
}


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

    int ans = 1;
    for(int cand = 1; cand * cand <= sum_A; cand++){
        if(sum_A % cand == 0){
            if(is_ok(cand)){
                ans = max(ans, cand);
            }
            if(is_ok(sum_A / cand)){
                ans = max(ans, sum_A / cand);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
	int n, d;
	scanf("%d%d", &n, &d);
	vector<vector<int>> x(n, vector<int>(d));
	rep(i, n)
	{
		rep(j, d)
		{
			scanf("%d", &x[i][j]);
		}
	}

	int ans = 0;
	rep(i, n)
	{
		for (int j = i + 1; j < n; j++) //重複しないようにi+1
		{
			int norm = 0;
			for (int k = 0; k < d; k++)
			{
				int diff = abs(x[i][k] - x[j][k]);
				norm += diff * diff;
			}
			
			bool flag = false;
			for (int k = 0; k <= norm; k++)
			{
				if (k * k == norm)
				{
					flag = true;
				}
			}
			if (flag) ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
using namespace std;
/// age ye mosh dp ro baze dashti dp tedad baz shodeye baste nashode yadet nare !!
/// joooob zadam
const int N=2e5+100,mod=998244353;
vector < pii > g[N];
ll dis[N];
ll par[N];
set <pii> s;
ll inf=1e14;
ll dijkstra(){
    while (s.size()){
        ll v=s.begin()->S;
        ll d=s.begin()->F;
        s.erase({d,v});
        for (int i=0;i<g[v].size();i++){
            ll u=g[v][i].F;
            ll w=g[v][i].S;
            if (dis[u]>dis[v]+w){
                s.erase({dis[u],u});
                dis[u]=dis[v]+w;
                //par[n][u]=par[v][n];
                s.insert({dis[u],u});
            }
        }
    }
}
int32_t main(){
    ll n,m;
    cin >> n >> m;
    for (int i=2;i<=n;i++){
        g[i].pb({i-1,0});
       // g[i-1].pb({i,0});
    }
    for (int i=0;i<m;i++){
        ll l,r,w;
        cin >> l >> r >> w;
        g[l].pb({r,w});
        g[r].pb({l,w});
    }
    memset(dis,69,sizeof dis);
    dis[1]=0;
    s.insert({0,1});
    dijkstra();
    if (dis[n]>1e16){
        cout << -1;
        return 0;
    }
    cout << dis[n];
}


Measured memory_bytes: 17408
s = list(input())

n = len(s)
for i in range(n-1):
    if s[i] == s[i+1]:
        print(i+1, i+2)
        exit()

for i in range(n-2):
    if s[i] == s[i+2]:
        print(i+1, i+3)
        exit()

print(-1, -1)

Measured memory_bytes: 3956
package main

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

func main() {
	n := readi()
	tmp := make(map[int]int, n-1)
	for i := 1; i < n; i++ {
		in := readi()
		tmp[in-1] = tmp[in-1] + 1
	}

	for i := 0; i < n; i++ {
		fmt.Println(tmp[i])
	}
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

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

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 10332
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

x,y,z,k = MAP()
a = MAP()
b = MAP()
c = MAP()

a.sort()
b.sort()

l = []
for i in a:
    for j in b:
        l.append(i+j)

l.sort()
c.sort()
l2 = []
for i in l[-k:]:
    for j in c[-k:]:
        l2.append(i+j)

l2.sort(reverse = True)
for i in l2[:k]:
    print(i)

Measured memory_bytes: 137308
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
  int n;
  string s;
  cin>>n>>s;

  vector<set<char> > left(n), right(n);
  for(int i=0; i<n; i++) {
    if(i!=0)
      left[i] = left[i-1];
    left[i].insert(s[i]);
  }

  for(int i=n-1; i>=0; i--) {
    if(i!=n-1)
      right[i] = right[i+1];
    right[i].insert(s[i]);
  }

  int maxCount = 0;
  for(int i=0; i<n-1; i++) {
    set<char> inter;
    set_intersection(left[i].begin(), left[i].end(),
                     right[i+1].begin(), right[i+1].end(),
                     inserter(inter, inter.begin()));
    maxCount=max(maxCount, (int)inter.size());
  }
  cout<<maxCount<<endl;
}


Measured memory_bytes: 512
s = input()
diff = [0] * len(s)
ans = [0] * len(s)

for i in range(len(s) - 1):
    if s[i] == "R" and s[i + 1] == "L":
        diff[i] = 1
        diff[i + 1] = 1

for i in range(1, len(s)):
    if s[i] == "L" and s[i - 1] == "L":
        diff[i] = diff[i - 1] + 1

for i in range(len(s)-1, 0, -1):
    if s[i] == "R" and s[i - 1] == "R":
        diff[i - 1] = diff[i] + 1

for i in range(len(s)):
    if diff[i] % 2 == 0:
        if s[i] == "R":
            ans[i + diff[i]] += 1
        if s[i] == "L":
            ans[i - diff[i]] += 1
    else:
        if s[i] == "R":
            ans[i + diff[i] - 1] += 1
        if s[i] == "L":
            ans[i - diff[i] + 1] += 1

print(" ".join(map(str, ans)))

Measured memory_bytes: 14472
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int N,K,Q;cin>>N>>K>>Q;
    vector <long long int> A(N+1,K);//点数箱
    int tmp;
    for(int i=1;i<=Q;i++){
        cin>>tmp;
        A[tmp]++;
    }
    for(int i=1;i<=N;i++){
        if((A[i]-Q)>0){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include <set>
#include <cstdio>
int main(){
	std::set<int> s;
	int n,ans=0,tmp;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&tmp);
		if(s.count(tmp))
			s.erase(tmp);
		else
			s.insert(tmp);
	}
	printf("%d\n",int(s.size()));
	return 0;
}

Measured memory_bytes: 4864
//https://atcoder.jp/contests/abc175/tasks/abc175_a
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<char> lis;
	lis.resize(3);
	ll cnt=0;
	ll i;
	for(i=0;i<3;i++)
	{
		cin>>lis[i];
	}
	if((lis[0]=='R')&&(lis[1]=='R')&&(lis[2]!='R'))
		{
			cnt=2;
		}
		else if((lis[0]!='R')&&(lis[1]=='R')&&(lis[2]=='R'))
		{
			cnt=2;
		}
		else if((lis[0]=='R')&&(lis[1]=='R')&&(lis[2]=='R'))
		{
			cnt=3;
		}
		else if((lis[0]=='R')&&(lis[1]!='R')&&(lis[2]=='R'))
		{
			cnt=1;
		}
		else if((lis[0]=='R')&&(lis[1]!='R')&&(lis[2]!='R'))
		{
			cnt=1;
		}
		else if((lis[0]!='R')&&(lis[1]=='R')&&(lis[2]!='R'))
		{
			cnt=1;
		}
		else if((lis[0]!='R')&&(lis[1]!='R')&&(lis[2]=='R'))
		{
			cnt=1;
		}
		else
		{
			cnt=0;
		}
	cout<<cnt<<"\n";
	return 0;
}

Measured memory_bytes: 3536
#include <stdio.h>
int main()
{
    long int a, b, c;
    long int ans = 0;
    scanf("%ld%ld%ld", &a, &b, &c);
    if (c <= a + b + 1)
    {
        ans = b + c;
    }
    else
    {
        ans = b + a + b + 1;
    }
    printf("%ld", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/math/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os, &vc](T value) {
    os << value;
    if (value != vc.back())
      os << '\n';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream&
operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  //ui N{}, K{}; cin >> N >> K;

  string S{}; std::cin >> S;
  string first = S.substr(0, 2);
  string second = S.substr(2, 2);

  auto judgeMM = [](string str) {
    int num = std::stoi(str, nullptr, 10);
    return 0 < num && num < 13;
  };

  auto fisMM = judgeMM(first);
  auto sisMM = judgeMM(second);

  using std::cout;
  cout << (
    fisMM && sisMM 
    ? "AMBIGUOUS" 
    : (!fisMM && !sisMM)
      ? "NA"
      : (fisMM)
        ? "MMYY"
        : "YYMM") << '\n';
  
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
  int width, height, x, y, radius;
  std::cin >> width >> height >> x >> y >> radius;

  const bool in_range = 
    (x >= radius) && (x <= (width - radius)) &&
    (y >= radius) && (y <= (height - radius));

  std::cout << (in_range ? "Yes" : "No") << std::endl;

  return 0;
}

Measured memory_bytes: 1156
x, y, a, b, c = map(int, input().split())
red = list(map(int, input().split()))
gre = list(map(int, input().split()))
ino = list(map(int, input().split()))

red = sorted(red)[::-1]
gre = sorted(gre)[::-1]
ino = sorted(ino)[::-1]

eat = sorted(red[:x] + gre[:y])
ans = sum(eat)

for i in range(min(len(eat), len(ino))):
  if eat[i] < ino[i]:
    ans = ans - eat[i] + ino[i]
  else:
    break

print(ans)

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

ll dp[110][100010];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,W;
    cin >> N >> W;
    VI w(N), v(N);
    rep(i,N){
        cin >> w[i] >> v[i];
    }
    rep(i,N){
        for(int j = W; j >= 0; j--){
            if(j+w[i] <= W) dp[i+1][j+w[i]] = max(dp[i][j+w[i]],  dp[i][j] + v[i]);
            dp[i+1][j] = max(dp[i][j],dp[i+1][j]);
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) if (scanf("%d", &v)<1);
#define out(v) printf("%d\n", v)

int main() {
  int X; in(X);

  int x = 0;
  rep(i, (int)1e6) {
    x += i;
    if (x >= X) {
      out(i);
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
n=int(input())
if n==1:
  print(0)
else:
  ct=0
  for i in range(1,int(n**0.5)):
    if (n-i)%i==0:
      ct+=(n-i)//i
  if (n-int(n**0.5))%int(n**0.5)==0:
    x=(n-int(n**0.5))//int(n**0.5)
    if n//x==n%x:ct+=x
  print(ct)

Measured memory_bytes: 3060
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
	cini(x);
	int doub = x / 500;
	int sing = x - (doub * 500);
	sing = (sing / 5) * 5;
	cout << doub * 1000 + sing << endl;
}

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=min(n,9);i++){
		ans++;
	}
	for(int i=100;i<=min(n,999);i++){
		ans++;
	}
	for(int i=10000;i<=min(n,99999);i++){
		ans++;
	}
	cout<<ans;
	return 0;
}

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

int N, K, tmp;
map<int, int> m;

int main()
{
    cin >> N >> K;
    for (int i=0; i<N; i++)
    {
        cin >> tmp;
        m[tmp]++;
    }
    vector<int> s;
    for (auto v : m) s.push_back(v.second);
    sort(s.begin(), s.end(), greater<int>());

    int ans = 0;
    for (auto itr = s.begin()+K; itr<s.end(); itr++) ans += *itr;

    cout << ans << endl;
}


Measured memory_bytes: 10748
#include <iostream>
#include <vector>

using namespace std;

long long calc(long long N, int i)
{
	if (N == 0) {
		return 0;
	}
	else {
		long long P = 1LL << (i + 1);
		long long Q = (N + 1) / P;
		long long R = (N + 1) % P;
		long long ans = Q * (P / 2);
		if (R > P / 2) {
			ans += R - P / 2;
		}
		return ans;
	}
}

int main()
{
	long long A, B;
	cin >> A >> B;

	long long D = B - A + 1;

	long long ans = 0;
	for (int i = 0; i < 50; ++i) {
		ans += ((calc(B, i) - calc(A - 1, i)) & 1) << i;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> vp;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        vp.push_back(make_pair(b, a));
    }

    sort(vp.begin(), vp.end());
    int t = 0;
    for (int i = 0; i < n; i++) {
        t += vp[i].second;
        if (t > vp[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 5344
#include<iostream>
#include<sstream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<stack>
#define debug(a) cout << "*" << a << "*" << endl
using namespace std;
typedef long long ll;
ll n, d, a, bot, top, s, ans1, ans2;
struct node{
	ll x, h;
	friend bool operator<(node a, node b)
	{
		return a.x < b.x;
	}
}monst[200005], que[400005];
int main()
{	
	while (~scanf("%lld%lld%lld", &n, &d, &a))
	{
		d *= 2;
		ans1 = ans2 = s = bot = top = 0;
		for (int i = 0; i < n; i++)
		{
			scanf("%lld%lld", &monst[i].x, &monst[i].h);
		}
		sort(monst, monst + n);
		for (int i = 0; i < n; i++)
		{
			if (bot != top)
			{
				while (que[bot].x + d < monst[i].x && bot != top)
				{
					s -= que[bot].h;
					bot++;	
				}	
			}
			ll num = (monst[i].h - 1) / a + 1 - s;
			if (num > 0)
			{
				ans1 += num;
				que[top].x = monst[i].x;
				que[top].h = num;
				top++;
				s += num;	
			}
		} 
		s = bot = top = 0;
		for (int i = n - 1; i >= 0; i--)
		{
			if (bot != top)
			{
				while (que[bot].x - d > monst[i].x && bot != top)
				{
					s -= que[bot].h;
					bot++;	
				}	
			}
			ll num = (monst[i].h - 1) / a + 1 - s;
			if (num > 0)
			{
				ans2 += num;
				que[top].x = monst[i].x;
				que[top].h = num;
				top++;	
				s += num;
			}
		}
		printf("%lld\n", min(ans1, ans2));
	}
}

Measured memory_bytes: 7552
from collections import deque
def calculate_area(lines):
    q = deque()
    partial_area = 0
    areas = []
    total_area = 0
    for i, line in enumerate(lines):
        if line == "\\":
            q.append(i)
        elif line == "/":
            if q:
                num = q.pop()
                partial_area = i - num
                total_area += partial_area
                for p_area in areas[::-1]:
                    if p_area[0] > num:
                        partial_area += areas.pop()[1]
                    else:
                        break
                areas.append([num, partial_area])
    areas_strigified = [str(v) for i, v in areas]
    print(total_area)
    if total_area:
        print("{} {}".format(len(areas), ' '.join(areas_strigified)))
    else:
        print(0)
                    

if __name__ == "__main__":
    data = input()
    calculate_area(data)


Measured memory_bytes: 6568
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main(){
    int N;
    cin >> N;
    int c;
    int i;
    for(i=2;i<N+1;i++){
        cin >> c;
        a[c]++;
    }
    for(i=1;i<N+1;i++)cout << a[i] << endl;
}

Measured memory_bytes: 4364
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <math.h> 

using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, n) for (i = 0; i < n; i++)
#define FOR(i, a, b) for (i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())

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

int main()
{

    std::cin.tie(0);

    int k;
    string s;

    cin >> k >> s;

    int length = s.length();
    if(length <= k){
        cout << s << endl;
        return 0;
    }

    if(length > k){
        cout << s.substr(0,k) + "..." << endl;
        return 0;
    }


}



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

int main()
{
  int a, b;
  char s[10], t[10], u[10];

  scanf("%s %s", s, t);
  scanf("%d %d", &a, &b);
  scanf("%s", u);

  if (strcmp(s, u) == 0)
  {
    a--;
  }
  else if (strcmp(t, u) == 0)
  {
    b--;
  }
  printf("%d %d\n", a, b);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int count = 0;
  for (int i = 0; i < 3; i++){
  if (S.at(i) == '1'){
  count += 1;
  }
  }
  cout << count;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a = I()
    s = S()
    if a >= 3200:
        print(s)
    else:
        print("red")
    return

#B
def B():
    n = I()
    a = LI()
    ans = 0
    for i in a:
        ans += 1/i
    print(1/ans)
    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    B()


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

int main(){
	double N,D;
	int	count = 0;
	double X = 0;
	double Y = 0;
    
  scanf("%lf %lf",&N,&D);
  
    for(int i=0;i<N;i++){
       scanf("%lf %lf",&X,&Y);
       if(sqrt(X*X+Y*Y) <= D) count++;
    }
  
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 2216
#include<iostream>
#include<math.h>
#include<string>

using namespace std;

int main(){
    string a;
    cin>>a;
    
    int b[30]={0};
    bool flag=false;
    for(int i=0;i<27;++i){
        for(int j=0;j<a.size();++j){
            if(a[j] == 'a'+i)++b[i];
        }
        if(b[i] % 2 != 0){
            flag=true;
            break;
        }
    }
    if(!flag)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256