akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, u, v; cin>>n>>u>>v; --u, --v;
  vector<vector<int>> g(n);
  for (int i = 0; i < n-1; i++) {
    int a, b; cin>>a>>b; --a, --b;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }

  vector<int> dt(n, 1e9), da(n, 1e9);
  da[v] = 0, dt[u] = 0;

  queue<int> q;
  q.push(v);
  while (!q.empty()) {
    int cur = q.front(); q.pop();
    for (auto nx: g[cur]) {
      if (da[cur] + 1 < da[nx]) {
        da[nx] = da[cur] + 1;
        q.push(nx);
      }
    }
  }
  q.push(u);
  while (!q.empty()) {
    int cur = q.front(); q.pop();
    for (auto nx: g[cur]) {
      if (dt[cur] + 1 < dt[nx] and da[nx] > dt[cur] + 1) {
        dt[nx] = dt[cur] + 1;
        q.push(nx);
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (dt[i] != 1e9) {
      ans = max(ans, da[i] - 1);
    }
  }
  cout << ans << endl;

  return 0;
}

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    double ans = 0.0;
    REP(i, n) {
        double x;
        string u;
        cin >> x >> u;
        if(u == "JPY") ans += x;
        else ans += x * 380000.0;
    }
    cout << fixed << setprecision(8) << ans << endl;
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == 'o') {++counter;
	}
   if (s[1] == 'o') {++counter;
	}
  if (s[2] == 'o') {++counter;
	}
    cout << 700+100*counter << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 2e5 + 10;
int N;
LL K;
LL A[MAX];

bool calc(LL max_height) {
    LL cnt = 0;
    REP(i, N) {
        if (A[i] <= max_height) continue;
        cnt += (A[i] + max_height - 1) / max_height - 1;
    }

    return cnt <= K;
}

void solve() {
    cin >> N >> K;
    REP(i, N) cin >> A[i];
    sort(A, A + N);

    LL ng = 0, ok = A[N - 1];
    while (ok - ng > 1) {
        const auto mid = (ng + ok) / 2;

        if (calc(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << ok << endl;
}

int main(void) {
#ifndef ONLINE_JUDGE
    const auto in_stream = freopen("../in.txt", "r", stdin);
    if (in_stream == nullptr) {
        cerr << "ERROR!" << endl;
        return 1;
    }
#endif

    solve();

#ifndef ONLINE_JUDGE
    fclose(in_stream);
#endif
}


Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <functional>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>

using namespace std;
using ll = long long;

int main()
{
	ll funi = 1e12;
	int a,b,q;
	cin >> a >> b >>q;

	vector <ll> jinja(a + 2);
	vector <ll> tera(b + 2);

	jinja[0] = -funi;
	jinja[a + 1] = funi;
	tera[0] = -funi;
	tera[b + 1] = funi;

	for (int i = 1; i <= a; i++)
	{
		cin >> jinja[i];
	}

	for (int i = 1; i <= b; ++i)
		cin >> tera[i];

	sort(jinja.begin(), jinja.end());
	sort(tera.begin(), tera.end());

	for (int i = 0; i < q; ++i)
	{
		ll basyo;
		cin >> basyo;
		auto jinja_u = lower_bound(jinja.begin(), jinja.end(), basyo);
		auto jinja_l = jinja_u - 1;
		auto tera_u = lower_bound(tera.begin(), tera.end(), basyo);
		auto tera_l = tera_u - 1;

		ll cnt = max(*tera_u, *jinja_u) - basyo;
		cnt = min(cnt, basyo - min(*tera_l, *jinja_l));

		cnt = min(cnt, *tera_u - basyo + *tera_u - *jinja_l);
		cnt = min(cnt, *jinja_u - basyo + *jinja_u - *tera_l);
		cnt = min(cnt, basyo - *tera_l + *jinja_u - *tera_l);
		cnt = min(cnt, basyo - *jinja_l + *tera_u - *jinja_l);

		cout << cnt << endl;
	}

	
	return 0;
}

Measured memory_bytes: 2944
import java.util.*;

class Main{

    char[] in;
    int p;

    void solve(){
        Scanner sc = new Scanner(System.in);

        in = sc.next().toCharArray();
        p = 0;

        boolean boo = cat();
        if(boo && p>=in.length) System.out.println("Cat");
        else System.out.println("Rabbit");
    }

    boolean cat(){
        if(p<in.length && in[p]=='m'){
            p++;
            if(p<in.length && in[p]!='e'){
                if(!cat()) return false;
            }
        }

        if(p<in.length && in[p]=='e'){
            p++;
            if(p<in.length && in[p]!='w'){
                if(!cat()) return false;
            }
        }
        
        if(p<in.length && in[p]=='w'){
            p++;
            return true;
        }
        return false;
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 17292
#include <bits/stdc++.h>
using namespace std;
int memo[101];

int main() {
  int n, c;
  bool f = true;
  cin >> n;
  stack<int> stk;
  for (int i = 0; i < n; i++) {
    cin >> c;
    if (c > 0) {
      if (memo[c]) {
        cout << i + 1 << "\n";
        f = false;
        break;
      } else {
        stk.push(c);
        memo[c] = 1;
      }
    } else {
      if (stk.empty() || stk.top() != -c) {
        cout << i + 1 << "\n";
        f = false;
        break;
      } else {
        stk.pop();
        memo[-c] = 0;
      }
    }
  }
  if (f) cout << "OK\n";
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) a.size()
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) rep(ghf,SZ(a)){rep(kjh,SZ(a[ghf])){cout<<(a[ghf][kjh]<10?" ":"")<<a[ghf][kjh]<<" ";}ENDL;}
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,m;
  cin>>n>>m;
  V a(n);
  rep(i,n)cin>>a[i];
  map<ll,ll> map;
  int sum=0;
  map[sum%m]++;
  rep(i,n){
    sum+=a[i];
    map[sum%m]++;
  }
  int res=0;
  for(const auto&num:map)
    res+=(num.se*(num.se-1))/2;
  
  out(res);
  
  
  return 0;
}



Measured memory_bytes: 4992
#include <stdio.h>

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left, int mid, int right) {
  int i, j, k;
  int n1 = mid -left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i=0, j=0;
  for(k=left; k<right; k++) {
    cnt++;
    if(L[i]<=R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right) {
  int mid;
  if(left+1 < right) {
    mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int main(void) {
  int A[MAX], n, i;
  cnt = 0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  mergeSort(A, n, 0, n);
  for(i=0;i<n;i++) {
    if(i) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",cnt);

  return 0;
}


Measured memory_bytes: 5692
#include <iostream>
#include <sstream>
#include <vector>

int main()
{
    std::string s;
    while (1) {
        std::cin >> s;
        if (s == "#") {
            break;
        }

        bool ok = 0;
        std::stringstream ss{s};        
        while (std::getline(ss, s, '|')) {
            std::string t = s.substr(1, s.size() - 2);
            std::stringstream tt{t};
            
            std::vector<int> v(256, 0);
            while (std::getline(tt, s, '&')) {
                if (s[0] == '~') {
                    v[s[1]] |= 2;
                } else {
                    v[s[0]] |= 1;
                }
            }
            
            bool f = 1;
            for (int i = 0; i < 256; i++) {
                if (v[i] == 3) {
                    f = 0;
                }
            }
            ok |= f;
        }
        std::cout << (ok ? "yes" : "no") << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
using namespace std;
int a,d[100010],b[100],j=0;
int dp(int a){
	if(a<=0) return 1000000;
	if(d[a]!=0) return d[a];
	d[a]=1000000;
	for(int i=0;i<j;i++){
		if(b[i]>a) continue;
		d[a]=min(d[a],1+dp(a-b[i]));
	}
	return d[a];
}
int main(){
 cin>>a;
 for(int i=1;i<100000;i*=6,j++) d[i]=1,b[j]=i;
 for(int i=9;i<100000;i*=9,j++) d[i]=1,b[j]=i;
 cout<<dp(a)<<endl;
}

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

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

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

const int N = 1000010, mod = 998244353;

int n, x, cnt[N], dp[N], ans;
void add(int &x, int y){
	x += y;
	if(x >= mod)
		x -= mod;
}
ll binpow(ll x, ll p){
	ll res = 1;
	while(p){
		if(p & 1)
			res = res * x % mod;
		x = x * x % mod;
		p >>= 1;
	}
	return res;
}
ll inv(ll x){
	return binpow(x, mod - 2);
}
int main()
{
	scanf("%d", &n);
	while(n--){
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}
	for(int i = N - 1; i > 0; i--){
		int dd = 0;
		int sum = 0;
		int prod = 0;
		for(int j = i; j < N; j += i){
			add(dd, dp[j]);
			for(int q = 0; q < cnt[j]; q++){
				prod = (prod + 1ll * sum * j) % mod;
            	add(sum, j);
			}
		}
		dp[i] = (prod - dd + mod) % mod;
		ans = (ans + dp[i] * inv(i)) % mod; 
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long k,ind;
  ind=0;
  string s;
  cin>>s>>k;
  int a=s.length();
  for(int i=0;i<a;i++){
    if(s.at(i)!='1'){ind=i;break;}
  }
  if(k==1){cout<<s.at(0)<<endl; return 0;}
  else if(k<ind+1){cout<<1<<endl;return 0;}
  else{cout<<s.at(ind);return 0;}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	ll n,a,b;cin >> n >> a >> b;
	vector<ll> v;
	REP(i,n)
	{
		ll tmp;cin >> tmp;v.PB(tmp);
	}
	
	ll ans = 0;
	REP(i,n-1)
	{
		ans += min(a*(v[i+1]-v[i]),b);
	}
	
	cout << ans << endl;
	
	
	return 0;
}

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

int main()
{
    int a,b,tmp;
    std::cin >> a >> b;

    if (a < b) {
            tmp = a; a = b; b = tmp;
    }

    for (int i = 0; i < a; i++)
        std::cout << b;
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int a = in.ni();
        out.println(a+a*a+a*a*a);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 33000
MOVE_LIST = [
    [1, 4],
    [0, 2, 5],
    [1, 3, 6],
    [2, 7],
    [0, 5],
    [1, 4, 6],
    [2, 5, 7],
    [3, 6]
]

goal = '01234567'
step_hash = { goal => 0 }
queue = [[goal, 0]]

def swap(str, a, b)
  tmp = str.dup
  tmp[a], tmp[b] = tmp[b], tmp[a]
  tmp
end

loop do
  figure, step_count = queue.shift
  break if figure.nil? || step_count.nil?

  current_idx = figure.index('0')
  MOVE_LIST[current_idx].each do |new_idx|
    new_figure = swap(figure, current_idx, new_idx)
    next if step_hash[new_figure]

    step_hash[new_figure] = step_count + 1
    queue << [new_figure, step_count + 1]
  end
end

loop do
  str = gets.to_s.split(' ').join('')
  break if str.length <= 0
  puts step_hash[str]
end

Measured memory_bytes: 12412
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>


int main()

{
	long double r;
	cin>>r;
	long double k = 3.141592653589;
	k = 2*r*k;
	cout<<k<<endl;
	return 0;
}

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

#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define INF 1e9
int n;
string s[51];
int t_alpha[30];
int alpha[30];
signed main(){
  cin>>n;
  rep(i,n)cin>>s[i];

  rep(i,30)alpha[i]=INF;


  for(int i=0;i<n;i++){
    for(int j=0;j<s[i].size();j++){
      for(int k=0;k<26;k++){
        if(s[i][j]-'a'==k)t_alpha[k]++;
      }
    }

    for(int p=0;p<30;p++){
      alpha[p]=min(alpha[p],t_alpha[p]);
    }
    rep(i,30)t_alpha[i]=0;

  }

  string ans="";
  for(int i=0;i<30;i++){
    if(alpha[i]>0 && alpha[i]!=INF){
      rep(j,alpha[i])ans+='a'+i;
    }
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
from collections import defaultdict

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

r = defaultdict(int)
l = defaultdict(int)

for i,a in enumerate(A):
    r[i-a] += 1
    l[i+a] += 1

ans = 0
for i in r.keys():
    ans += r[i]*l[i]

print(ans)  


Measured memory_bytes: 73748
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
int main(){
  int n;
  cin>>n;
  int sum=0;
  REP(i,n){
    int temp;
    cin>>temp;
    if(temp!=i+1){
      sum++;
    }
  }

  if(sum==0||sum==2){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}


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.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final int N = sc.nextInt();
			int[] cs = new int[N - 1];
			int[] ss = new int[N - 1];
			int[] fs = new int[N - 1];
			
			for(int i = 0; i < N - 1; i++){
				cs[i] = sc.nextInt();
				ss[i] = sc.nextInt();
				fs[i] = sc.nextInt();
			}
			
			for(int start = 0; start < N; start++){
				int time = 0;
				
				for(int station = start; station < N - 1; station++){
					time = Math.max(time, ss[station]);
					
					final int diff = time - ss[station];
					final int ceil = (diff + fs[station] - 1) / fs[station] * fs[station];
					//System.out.println(diff + " " + ceil);
					
					time = ss[station] + ceil;
					time += cs[station];
					
					//System.out.println(start + " " + station + " " + time);
				}
				
				System.out.println(time);
			}
			
		}
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 25940
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>
#include <stdlib.h>
# include <map>

using namespace std;

int main(){
int n;
cin >> n;
if (n % 1000 == 0){
    cout << 0 << endl;
}
else{
    cout << 1000- (n % 1000) << endl;
}

}

Measured memory_bytes: 3632
var
  a,a1,a2:array[0..200000] of longint;
  b,c,i,j,k,t,n,m,x,y,xx,yy,x1,y1:longint;
function max(xxx,yyy:longint):longint;
begin
  if xxx>yyy then max:=xxx else max:=yyy;
end;
begin
  readln(n);
  for i:=1 to n do
  begin
    read(a[i]);
    if i mod 2=1 then inc(a1[a[i]]);
    if i mod 2=0 then inc(a2[a[i]]);
  end;
  x:=0; y:=0;
  xx:=0; yy:=0;
  b:=0; c:=0;
  t:=0;
  for i:=1 to 100000 do
  begin
    if a1[i]>b then begin x:=i; b:=a1[i]; end;
    if a2[i]>c then begin y:=i; c:=a2[i]; end;
  end;
  x1:=a1[x]; y1:=a2[y];
  a1[x]:=0; b:=0;
  a2[y]:=0; c:=0;
  for i:=1 to 100000 do
  begin
    if a1[i]>b then begin xx:=i; b:=a1[i]; end;
    if a2[i]>c then begin yy:=i; c:=a2[i]; end;
  end;
  if x=y then t:=max(x1+a2[yy],a1[xx]+y1) else t:=x1+y1;
  writeln(n-t);
end.


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

using namespace std;

int main()
{
    int n, min = INT_MAX, minIdx = -1;
    scanf("%d\n", &n);

    vector<long long int> r(n);
    long long int ans = INT_MIN;

    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &(r[i]));
        if (i > 0)
            ans = max(ans, r[i] - r[minIdx]);
        if (min > r[i])
        {
            min = r[i];
            minIdx = i;
        }
    }

    printf("%lld\n", ans);

    return 0;
}



Measured memory_bytes: 4408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main(){
    int x=0;
    cin >> x ;
    int ans = 1;
    int tmp = 1;
    for(int i =2;i<=x/2;i++){
        tmp = i*i;
        if(tmp>x) break;
        while(tmp<=x){
            if(tmp>ans){
                ans = tmp;
            }
            tmp *= i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())

a = []

for i in range(n):
    a.append(int(input()))

a.sort(reverse=True)

ans = 0
if n % 2 == 1:
    ans1 = 0
    for i in range(n):
        if i <= n // 2:
            ans1 += 2 * a[i]
            if i == (n // 2) or (i == n // 2 - 1):
                ans1 -= a[i]
        else:
            ans1 -= 2 * a[i]

    ans2 = 0
    for i in range(n):
        if i < n // 2:
            ans2 += 2 * a[i]
        else:
            if i == (n // 2) or (i == n // 2 + 1):
                ans2 -= a[i]
            else:
                ans2 -= 2*a[i]

    ans = max(ans1, ans2)

else:
    ans = 0
    for i in range(n):
        if i < n // 2:
            if i==(n//2-1):
                ans += a[i]
            else:
                ans += 2*a[i]
        else:
            if i== n//2:
                ans -= a[i]
            else:
                ans -=2*a[i]

print(ans)


Measured memory_bytes: 80864
#include<iostream>
#include<string>
#include<vector>

int main() {
	int N, K;
	std::cin >> N >> K;
	std::vector<int> p(N);
	for (int i = 0; i < N; i++) {
		std::cin >> p.at(i);
	}

	int yen = 1001;
	int bango = 0;
	int ans = 0;
	for (int j = 0; j < K; j++) {
		yen = 1001;
		bango = 0;
		for (int i = 0; i < N; i++) {
			if (p.at(i) < yen && p.at(i) != 0) {
				yen = p.at(i);
				bango = i;
			}
		}
		ans += yen;
		p.at(bango) = 0;
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
const ll inf=0x3f3f3f3f;

using namespace std;
unordered_map <ll,ll> mp;
ll n,a,b,c,d;
ll dfs(ll n)
{
    if(n==0) return 0;
    if(n==1) return d;
    if(mp[n]) return mp[n];
    ll ans=1e18;
    if(n<ans/d) ans=n*d;
    ans=min(ans,a+(n%2)*d+dfs(n/2));
    ans=min(ans,a+(2-n%2)*d+dfs((n+1)/2));
    ans=min(ans,b+(3-n%3)*d+dfs((n+2)/3));
    ans=min(ans,b+(n%3)*d+dfs(n/3));
    ans=min(ans,c+(n%5)*d+dfs(n/5));
    ans=min(ans,c+(5-n%5)*d+dfs((n+4)/5));
    mp[n]=ans;
    return ans;
}
int main()
{
    ll T;cin>>T;
    while(T--)
    {
        mp.clear();
        cin>>n>>a>>b>>c>>d;
        cout<<dfs(n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 4060
X, N = map(int,input().split())


if N == 0:
    print(X)
else:
    P = list(map(int,input().split()))
    i = 0
    while(True):
        # print(X-i)
        if X-i not in P:
            print(X-i)
            break
        elif X+i not in P:
            print(X+i)
            break
        if i > 120:
            break
        i +=1
        

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

int n;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    long long ans=0;
    for(int i=1;i<=n;i++){
        ans+=(long long)(n-i+1)*i;
    }
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(a>b)swap(a,b);
        ans-=(long long)a*(n-b+1);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3592
#include <string>

#include <iostream>

#include <stack>

#include <queue> // priority_queue も入ってる

#include <set>   // 要素数は size() で取得 multisetもある

#include <map>

#include <array> // sizeはコンパイル時定数で固定

#include <vector>

#include <numeric>   // accumulate, gcd

#include <algorithm> // count_ifに必要

#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定

#include <tuple>

#include <utility> //pair

#include <cmath>

#include <random>

using namespace std;

// 問題が起こるまでintは使用禁止2020-04-13

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)

template <class InputIterator, class T>

bool contains_itr(InputIterator iterator, const T &value)

{

    if (find(iterator.begin(), iterator.end(), value) == iterator.end())

        return false;

    else

        return true;

}

template <class T>

bool contains_set(set<T> st, const T &value)

{

    if (st.find(value) == st.end())

    {

        return false;

    }

    else

    {

        return true;

    }

}

template <class InputIterator>

auto sum(InputIterator iterator)

{

    return accumulate(iterator.begin(), iterator.end(), 0);

}

// endは排他的(exclusive)なので注意

vector<ll> range(ll begin, ll end)

{

    vector<ll> result;

    for (ll i = begin; i < end; ++i)

    {

        result.push_back(i);

    }

    return result;

}

random_device seed_gen;

mt19937 engine(seed_gen());

// 0, 1, 2 のどれかが得られる一様分布

// uniform_int_distribution<> dist(0, 2);

// cout << dist(engine) << endl;

// みたいに、先に確率分布を宣言して、そこにengineを与えて使う。

// =========ここまでテンプレ============

int main()

  {

    string s;

cin >> s;

if(s[s.size()-1]=='s')

  {

  s.push_back('e');

  }

s.push_back('s');

cout << s << endl;

   

 

    

  

   

    return 0;

}



Measured memory_bytes: 3056
import numpy as np
def solve(n, k, a):
    lb = 0
    ub = np.max(a)
    while ub - lb > 1:
        cur = (lb + ub) // 2
        cnt = np.sum(np.ceil(a/cur)) - n
        if cnt > k:
            lb = cur
        else:
            ub = cur
    return int(np.ceil((lb+ub) / 2))

n, k = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, k, a))

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 1e5 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;


ll cnt[MAXN];
vector<pll> V;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	ll SA = 0;
	ll SB = 0;
	ll a, b;
	for(int i = 0; i < n; i++){
		cin >> a >> b;
		SA += a; SB += b;
		V.pb({a, i});
		V.pb({b, i});
	}
	ll ans = min(SA, SB);
	sort(all(V));
	ll s = 0, fl = 0;
	for(int i = 0;i<n;i++){
		s += V[i].F;
		cnt[V[i].S] ++;
		if(cnt[V[i].S] == 2) fl = 1;
	}
	if(fl) ans = min(ans, s);
	else ans = min(ans, s + (V[n - 1].S == V[n].S ?  min( V[n + 1].F - V[n - 1].F, V[n].F - V[n - 2].F) : V[n].F - V[n - 1].F ) );
	cout << ans;
	return 0;
}


/*
                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/



Measured memory_bytes: 6512
#include <stdio.h>

int main(){

  int a,b,d,r;
  double f;
  
  scanf("%d %d",&a,&b);
  d=a/b;
  r=a%b;
  f=(double)a/(double)b;

  printf("%d %d %lf\n",d,r,f);
  return 0;
}

Measured memory_bytes: 636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    public static void Main( )
    {
        int N = int.Parse( Console.ReadLine( ) );
        var A = Console.ReadLine( ).Split( ).Select( int.Parse ).ToArray( );
        int other = 0;
        int multipulsOf2 = 0;
        int multipulsOf4 = 0;

        for ( int i = 0; i < A.Length; i++ )
        {
            if ( A[ i ] % 4 == 0 ) multipulsOf4++;
            else if ( A[ i ] % 2 == 0 ) multipulsOf2++;
            else other++;
        }

        bool isOk;
        if ( multipulsOf2%2==0 )
        {
            isOk =  multipulsOf4 >= other - 1 ;

        }
        else
        {
            isOk = multipulsOf4 - other >= 0;
        }
        Console.WriteLine(isOk ? "Yes" : "No");

    }




}

Measured memory_bytes: 38508
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int x;
	cin >> x;
	str ans = "NO";
	switch (x)
	{
	case 3:
	case 5:
	case 7:
		ans = "YES";
		break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class AApplePie {
public:
        int a,p;
void solve(std::istream& cin, std::ostream& cout) {
    cin >> a >> p;
    cout << (3*a+p)/2 << endl;
}
};


#undef int
int main() {
	AApplePie solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d" ,&W,&H,&x,&y,&r);
	if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
	printf("Yes\n");
	}
	else{
	printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
   std::vector<int> A(3);
   std::cin >> A[0] >> A[1] >> A[2];

   std::sort(A.begin(),A.end());
   
   int ans = 0;
   if((A[2]-A[0])%2!=(A[2]-A[1])%2) {
      ++A[2];
      ++A[1];
      ans += 1;
   }
   ans += A[2] - A[1];
   ans += (A[1] - A[0]) / 2;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t n;
    cin >> n;

    int64_t c = 0;
    for (auto i : irange(0L, n)) {
        int64_t p;
        cin >> p;

        if (p != i + 1) {
            ++c;
        }
    }

    if (c <= 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

int _runtimeTerror_()
{
    ll n;
    cin>>n;
    ll ans=0;
    ll val=0;
    for(ll i=1;i<=n;++i)
        val+=i*(i+1)/2;
    for(ll i=1;i<=n-1;++i)
    {
        ll u,v;
        cin>>u>>v;
        if(u>v)
            swap(u,v);
        val-=u*(n-v+1);
    }
    cout<<val;
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    string s; cin >> s;
    int k; cin >> k;
    char c = '1';
    rep(i,k){
        c = s[i];
        if(c != '1') break;
    }
    cout << c << endl;
}

Measured memory_bytes: 256
import collections

n = int(input())
#a = list(map(int,input().split()))
a = list( input().split() )

dict = collections.Counter(a)

#print(n)
#print(a)
#print(dict)
#print(dic[str(1)])

x_max = 0
mem_key = ""

for key in dict.keys():
  k = int( key )
  l = dict[str(k-1)]
  m = dict[str(k)]
  n = dict[str(k+1)]
  #print(k,m,l,n)
  #print(l+m+n)
  if l+m+n >= x_max:
    x_max = l+m+n
    mem_key = key
    
print(x_max)
#print(mem_key)

Measured memory_bytes: 56300
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  vector<i64> a(n);
  for (i64 i = 0; i < n; i++)
    cin >> a[i];
  i64 ans[2] = {}, sum[2] = {};
  for (i64 i = 0; i < n; i++)
    if (i % 2 == 0)
    {
      sum[0] += a[i];
      if (sum[0] < 1)
      {
        ans[0] += -sum[0] + 1;
        sum[0] = 1;
      }
      sum[1] += a[i];
      if (-1 < sum[1])
      {
        ans[1] += sum[1] + 1;
        sum[1] = -1;
      }
    }
    else
    {
      sum[0] += a[i];
      if (-1 < sum[0])
      {
        ans[0] += sum[0] + 1;
        sum[0] = -1;
      }
      sum[1] += a[i];
      if (sum[1] < 1)
      {
        ans[1] += -sum[1] + 1;
        sum[1] = 1;
      }
    }
  cout << min(ans[0], ans[1]) << endl;
  return 0;
}


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

cnta, cntb = 0, 0
for i in range(N):
  a, b = A[i], B[i]
  if a > b :
    cntb += a-b
    continue
  if (b-a)%2 > 0:
    cntb += 1
    b += 1
    
  cnta += (b-a) // 2
  
#print(cnta, cntb)
print('Yes' if cnta >= cntb else 'No')
         

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

int main(){

 double r, are, circ;

 cin >> r;

 are = r * r * 3.141592653589;
 circ = r * 2 * 3.141592653589;

 cout << fixed << are << " " << circ << "\n";

 return 0;
}

Measured memory_bytes: 1288
#include<iostream>
#include<algorithm>
using namespace std;
int n,num,maxn,minn;
int a[100001];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n);
	minn=a[1],maxn=a[n];
	if(minn<maxn-1||maxn>=n) {cout<<"No";return 0;}
	if(maxn==minn) 
	{
		if(minn+1==n) cout<<"Yes";
		else
		{
			if(minn*2>n) cout<<"No";
			else cout<<"Yes";
		}
		return 0;
	}
	for(int i=1;i<=n;i++) if(a[i]==minn) num++;
	n-=num; maxn-=num;
	if(minn<num) cout<<"No";
	else if(maxn*2>n) cout<<"No";
	else cout<<"Yes";
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int a,b,c,n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		if(a*a==b*b+c*c||b*b==a*a+c*c||c*c==b*b+a*a)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 576
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class EDoubleFactorial {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            long n = s.nextLong();
            if ((n & 1) == 1) {
                w.println(0);
                return;
            }
            long[] cnt = new long[26];
            long cur = 10, ans = 0;
            for (int i = 1; i < 26; i++, cur *= 5) cnt[i] = n / cur;
            for (int i = 25; i > 0; i--) {
                for (int j = 25; j > i; j--) cnt[i] -= cnt[j];
                ans += i * cnt[i];
            }
            w.println(ans);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public long nextLong() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            long res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }

            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
  int i=0,num,data[100],k=0;
  char N[10];

  while( scanf("%s",N)!=EOF){
      

      
 

    if(atoi(N)>0&&atoi(N)<=1000000){
      data[i]= atoi(N);
    
      i++;
    }  

    else {switch (N[0]){
      case '+':
	num=data[i-2]+data[i-1];
	data[i-2]=num;
	i--;
	break;

    
      case '-':
	num=data[i-2]-data[i-1];
	data[i-2]=num;
	i--;
	break;

      case '*':
	num=data[i-2]*data[i-1];
	data[i-2]=num;
	i--;
	break;
      }}

    
  }
    
  printf("%d\n",data[0]);
  return 0;
}

Measured memory_bytes: 548
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n, k) for (int i = n; i < k; i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(24) << fixed << p << endl;
#define vi vector<int>
#define printv(v)                      \
    for (int i = 0; i < v.size(); i++) \
        P(v[i]);
#define printt(a, b) cout << a << " " << b << endl;
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int MOD = 1e9 + 7;

ll gcd(ll a, ll b)
{
    return a % b == 0 ? b : gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b; //先に割り算をして掛けられる数を小さくして掛け算を行う
}

bool pairCompare(const pair<int, int> &firstElof, const pair<int, int> &secondElof)
{
    return firstElof.second < secondElof.second;
}

void solve()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll cdlcm = lcm(c, d);
    ll cm = (b / c) - (a / c), dm = (b / d) - (a / d), cdm = (b / cdlcm) - (a / cdlcm);
    if (a % c == 0)
        cm++;
    if (a % d == 0)
        dm++;
    if (a % cdlcm == 0)
        cdm++;
    P((b - a + 1) - (cm + dm - cdm));
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int dx[]={-1,0,1,-1,1,-1,0,1};
const int dy[]={-1,-1,-1,0,0,1,1,1};
const char type[]={'o','x'};
char fld[10][10];
int cnt(int y,int x,int ds,int ty,int cn){
    if(y<0||y>=8||x<0||x>=8)return 0;
    if(fld[y][x]==type[ty])return cn;
    if(fld[y][x]=='.')return 0;
    return cnt(y+dy[ds],x+dx[ds],ds,ty,cn+1);
}
bool dlt(int y,int x,int ds,int ty){
    if(y<0||y>=8||x<0||x>=8)return false;
    if(fld[y][x]==type[ty])return true;
    if(fld[y][x]=='.')return false;
    if(dlt(y+dy[ds],x+dx[ds],ds,ty)==false)return false;
    fld[y][x]=type[ty];
    return true;
}
int main(){
    for(int i=0;i<8;i++)scanf("%s",fld[i]);

    for(int turn=0;turn<64;turn++){
        int mx,my,mc=0;
        for(int i=0;i<8;i++){
            int y=((turn&1)?7-i:i);
            for(int j=0;j<8;j++){
                int x=((turn&1)?7-j:j);
                if(fld[y][x]!='.')continue;
                int val=0;
                for(int k=0;k<8;k++){
                    val+=cnt(y+dy[k],x+dx[k],k,turn&1,0);
                }
                if(mc<val){
                    mc=val;
                    mx=x;
                    my=y;
                }
                //if(val)printf("%d:%d %d %d\n",turn,y,x,val);
            }
        }
        if(mc==0)continue;
        fld[my][mx]=type[turn&1];
        for(int i=0;i<8;i++){
            dlt(my+dy[i],mx+dx[i],i,turn&1);
        }
        //printf("%d %d\n",my,mx);
        //for(int i=0;i<8;i++)printf("%s\n",fld[i]);
    }
    for(int i=0;i<8;i++)printf("%s\n",fld[i]);

    return 0;
}

Measured memory_bytes: 948
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

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

    int cals[101];
    for( int iii=0; iii<n; ++iii ) {
        cin >> cals[iii];
    }

    sort( cals, cals + n, greater<int>() );

    int cost = a;
    int cal = c;
    double cpd = static_cast<double>( cal ) / cost;    
    for( int ii=0; ii<n; ++ii ) {
        double const r = static_cast<double>( cal + cals[ii] ) / ( cost + b );
        if ( r >= cpd ) {
            cal += cals[ii];
            cost += b;
            cpd = r;
        }
    }

    cout << floor( cpd ) << endl;
}

Measured memory_bytes: 1252
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m; cin >> n >> m;
    vector<int64_t> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    
    priority_queue<pair<int64_t, int>> pque; // c & b
    for (int i = 0; i < m; i++) {
        int b;
        int64_t c;
        cin >> b >> c;
        pque.push(make_pair(c, b));
    }
    
    int ind = 0;
    bool finished = false;
    while (ind < n && !pque.empty()) {
        int b = pque.top().second;
        int64_t c = pque.top().first;
        pque.pop();
        
        for (; b > 0; b--) {
            if (a[ind] < c) {
                a[ind] = c;
                ind++;
            } else {
                finished = true;
                break;
            }
        }
        if (finished) break;
    }
    
    int64_t ans = 0;
    for (int i = 0; i < n; i++) ans += a[i];
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3188