akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(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, InputReader in, PrintWriter out) {
            long n = in.nextLong();

            if (n % 2 == 1) {
                out.println(0);
                return;
            }

            n /= 2;

            long answer = 0;
            while (n > 0) {
                n /= 5;
                answer += n;
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 23380
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define pb push_back
#define eps 1e-8
#define PI 3.1415926535898
using namespace std;
const ll maxn = 1e6 + 5;
ll num[maxn],n,m,a,b,c,t,k;
string str;
int main()
{
    cin >> k;
    ll ans = 0,res = 100;
    while(res < k){
        res += res / 100;
        ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3632
N = int(input())
A=[]; B= []
for i in range(N):
  a,b = map(int,input().split())
  A.append((a+b))
  B.append((a-b))
A.sort()
B.sort()
ans = max(A[-1]-A[0],B[-1]-B[0])
print(ans)


Measured memory_bytes: 104696
#include "bits/stdc++.h"
using namespace std;
 
using ll = long long;
 
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int N = 1 << 21;

ll n;
ll res;
ll a[N];
std::vector<ll> v[22];
ll dp[22][N];
ll go(ll idx, ll mask){
	if(idx == n){
		if(mask == (1LL << n) - 1) return 1;
		return 0;
	}
	if(dp[idx][mask] + 1) return dp[idx][mask];
	ll xx = 0;
	for (int i = 0; i < v[idx].size(); ++i){
		if(v[idx][i] && !(mask & (1LL << i))){
			xx += go(idx + 1, mask | (1LL << i));
			xx %= mod;
		}
	}
	return dp[idx][mask] = xx;
}

void solve(){
	cin >> n;
	for (int i = 0; i < n; ++i){
		for (int j = 0; j < n; ++j){
			cin >> res;
			v[i].push_back(res);
		}
	}
	memset(dp, -1, sizeof dp);
	cout << go(0, 0);
}
 
int main(int argc, char const *argv[]){
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
    	solve();
    }
}
// smf

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

bn = [1]
pn = [1]
for i in range(N):
  bn.append(2*bn[i]+3)
  pn.append(2*pn[i]+1)

def p_eat(N,X):
  if X == 0:
    return 0
  elif X == bn[N]:
    return pn[N]
  elif bn[N-1]+1 < X:
    return pn[N-1]+1+p_eat(N-1, X-bn[N-1]-2)
  else:
    return p_eat(N-1, X-1)

print(p_eat(N,X))

Measured memory_bytes: 3064
n=int(input())
a = [int(a) for a in input().split()]
b = [int(a) for a in input().split()]
c = [int(a) for a in input().split()]
ans=0
l=-1
for i in range (n):
  ans += b[a[i]-1]
  if a[i] == l+1:
    ans += c[a[i]-2]
  l=a[i]
print(ans)
  

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

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

    int N;
    cin >> N;

    vector<string> S(N);
    string s;

    for (int n = 0; n < N; n++) {
        cin >> s;
        sort(s.begin(), s.end());
        S[n] = s;
    }

    sort(S.begin(), S.end());
    int count = 0;
    long ans = 0;

    for (int n = 0; n < N - 1; n++) {
        if (S[n] == S[n + 1]) {
            count++;
            ans += count;
        } else {
            count = 0;
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
class Main{
  public static void main(String args[]) throws IOException{
   
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   String[] token = br.readLine().split(" ");
   int r = Integer.parseInt(token[0]);      
   int c = Integer.parseInt(token[1]);   
   int[] Columnsum = new int[c];
   int totalsum = 0;  
   for(int k = 0;k < c; k++){      
        Columnsum[k] = 0;
   }
   
  
   for(int i = 0;i < r; i++){
      String[] token2 = br.readLine().split(" ");
      int sum = 0;
      for(int j = 0;j < c; j++){      
        System.out.print(token2[j] + " ");
        Columnsum[j] += Integer.parseInt(token2[j]);
        sum += Integer.parseInt(token2[j]);
      }
      totalsum += sum;
      System.out.println(sum);
   }

   for(int l = 0;l < c; l++){      
        System.out.print(Columnsum[l] + " ");
   }
   System.out.println(totalsum);

    
  }
}

Measured memory_bytes: 31884
#include <iostream>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <stdio.h> 
#include <map>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <deque>
#include <sstream>
#include <vector>
#include <algorithm>

typedef long long ll;
using namespace std;

int main() {
	ll n,a,b;
	cin>>n>>a>>b;
	ll s = (a+b);
	
	long long sum=(n/s)*a;
	long long rem = n%s; 
		
	sum+=min(rem, a);
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	A, B, C := sc.nextIntSlice(N), sc.nextIntSlice(N), sc.nextIntSlice(N)
	sort.Ints(A)
	sort.Ints(C)
	count := 0
	for i := 0; i < N; i++ {
		// x < upper
		upper := sort.Search(N, func(index int) bool {
			return A[index] >= B[i]
		})
		countA := upper
		// lower <= x
		lower := sort.Search(N, func(index int) bool {
			return C[index] > B[i]
		})
		countC := N - lower
		count += countA * countC
	}
	fmt.Println(count)
}


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

int main(){
  int H1,M1,H2,M2,K; cin >>  H1 >> M1 >> H2 >> M2 >> K;
  int mm1=H1*60+M1;
  int mm2=H2*60+M2;
  cout << mm2-mm1-K << endl;
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = long.Parse(ReadLine());
        var A = ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();

        var money = 1000L;
        var stock = 0L;

        var diff = new long[N];

        for(long i = 0; i < N; i++)
        {
            if (i < N - 1)
                diff[i] = A[i + 1] - A[i];
            else
                diff[i] = -1;
        }

        for (long i = 0; i < N; i++)
        {
            // buy
            if (diff[i] > 0L)
            {
                var count = money / A[i];
                money -= A[i] * count;
                stock += count;
            }
            // sell
            else if (diff[i] < 0L)
            {
                money += A[i] * stock;
                stock = 0;
            }
        }

        WriteLine(money);
    }
}


Measured memory_bytes: 28176
import Foundation

var input_lines = [String]()
input_lines.append(readLine()!)
let strings = input_lines[0].componentsSeparatedByString(" ")

let K = (Int)(strings[0])!
let S = (Int)(strings[1])!

var counter = 0

for i in 0...K {
    if (S - i) > (K * 2) {
        continue
    }
    for j in 0...K {
        if (S - i - j) > K {
            continue
        }
        if (S - i - j) >= 0 {
            counter += 1
        }
    }
}

print(counter)


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

using namespace std;
using ll = long long;
using ld = long double;

int main () {
	string s;
	cin >> s;
	int n = (int) s.size();
	if (s[n - 1] == 's') {
		cout << s << "es" << '\n';
	} else {
		cout << s << 's' << '\n';
	}
}


Measured memory_bytes: 3624
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define INF 1e9+7
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288

int main(){
    int n;
    cin>>n;
    vector<int>a(n),b(n),c(n);
    rep(i,n)cin>>a[i]>>b[i]>>c[i];
    rep(i,n){
        if(i==0)continue;
        a[i]=a[i]+max(b[i-1],c[i-1]);
        b[i]=b[i]+max(a[i-1],c[i-1]);
        c[i]=c[i]+max(a[i-1],b[i-1]);
    }
    int ans=max(max(a[n-1],b[n-1]),c[n-1]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vll &a){sort(a.begin(),a.end()) ;}
//void myrev(vll &a){reverse(a.begin(),a.end()) ;}

int main(){
	string s ; cin >> s ;
	ll n = s.size() ;
	vector<string> vec ;
	string t = "" ;
	for(int i=0;i<n;i++){
		if(s.at(i)=='A') t += 'A' ;
		else if(s.at(i)=='C'){
			vec.push_back(t) ;
			t = "" ;
		}else{
			if(i==n-1||s.at(i+1)!='C'){
				vec.push_back(t) ;
				t = "" ;
			}else{
				t += 'D' ;
				i++ ;
			}
		}
	}
	vec.push_back(t) ;
	ll ans = 0 ;
	for(int i=0;i<vec.size();i++){
		ll cnt = 0 ;
		for(int j=0;j<vec.at(i).size();j++){
			if(vec.at(i).at(j)=='A') cnt++ ;
			else ans += cnt ;
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 5368
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。

int main(){
    int a,b,t;
    cin>>a>>b>>t;
    cout<<(t/a)*b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

void dfs(const vector<vector<int>>& nodes, map<pair<int, int>, ll>& costs, const int& s, vector<ll>& d) {
  for (auto& t : nodes[s]) {
    if (d[t] != INFL) continue;
    d[t] = d[s] + costs[{min(s, t), max(s, t)}];
    dfs(nodes, costs, t, d);
  }
}

int main(int argc, char* argv[])
{
  int n;
  cin >> n;

  vector<vector<int>> nodes(n);
  map<pair<int, int>, ll> costs;  // {node,node}, cost
  rep(i, n-1) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    nodes[a].emplace_back(b);
    nodes[b].emplace_back(a);
    costs[{min(a, b), max(a, b)}] = c;
  }

  int q, k;
  cin >> q >> k;
  k--;

  vector<ll> d(n, INFL);  // k からの最短距離
  d[k] = 0;

  dfs(nodes, costs, k, d);

  rep(i, q) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    cout << d[x] + d[y] << endl;
  }
  return 0;
}


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

int main(){
   string s;
   int q,k,u;
   char c;
   cin>>s>>q;
   int flag=0;
   while(q--){
    cin>>u;
    if(u==1){
        flag++;
    }
    else{
        cin>>k>>c;
        if(flag%2==0){
            if(k==1) s.insert(s.begin(),c);
            else s.insert(s.end(),c);
        }
        else{
            if(k==1) s.insert(s.end(),c);
            else s.insert(s.begin(),c);
        }
      }
   }
   if(flag%2==1) reverse(s.begin(),s.end());
   cout<<s;
   return 0;
}

Measured memory_bytes: 1028
import Data.List

substrings s = concat [substrings' s i | i<-[1..(min 5 (length s))]]
  where
    substrings' s@(x:xs) i
      | length s == i = [s]
      | otherwise = (take i s) : (substrings' xs i)

main = do
  s <- getLine
  k <- readLn :: IO Int

  putStrLn $ (solve [] (substrings s)) !! (k-1)
  
  where
    solve :: [String] -> [String] -> [String]
    solve sorted [] = sorted
    solve sorted (x:xs) = solve s xs
      where s = sort' sorted x

    sort' sorted x
      | elem x sorted = sorted
      | length sorted < 5 = sort $ x:sorted
      | last sorted <= x = sorted
      | otherwise = init (sort $ x:sorted)


Measured memory_bytes: 1148
import java.util.Scanner;

/**
 * 高橋君は、全
N
 ページから成る書類を両面印刷します。両面印刷では、
1
 枚の紙に
2
 ページ分のデータを印刷することが出来ます。

最小で何枚の紙が必要か求めてください。
 * @author nkyy0
 *
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 数値の入力
        int s = sc.nextInt();
        int answer=0;
        // 出力用
        if(s%2 > 0 ) {
            answer = s/2 + 1;
        }
        else {
            answer = s/2;
        }
        // 出力
        System.out.println(answer);
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>

#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;


int main() {
    int h,w,k;
    cin >> h >> w >> k;
    char c[h][w];
    rep(i,h) rep(j,w) cin >> c[i][j];

    int ans = 0, cnt;
    rep(is,1<<h){rep(js,1<<w){
        cnt = 0;
        rep(i,h){rep(j,w){
            if(is & (1<<i)) continue;
            if(js & (1<<j)) continue;
            if(c[i][j] == '#') cnt++;
        }
        }
        if(cnt == k) ans++;
    }
    }
    cout << ans << endl;
}

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

const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
    int n,k;
    cin >> n >> k;
    vector<mint> amari(k+1,0);
    vector<mint> num(k+1,0);
    mint res=0;
    for(int i=k; i>=1; --i){
        int group;
        group = k/i;
        mint temp = mint(group).pow(n);
        temp -= amari[i];
        num[i]=temp;
        res += temp*i;
        for(int j=1;j*j<=i; ++j){
            if(i%j==0){
                //cout << "j: " << j << endl;
                amari[j]+=num[i];
                if(j*j != i){
                    amari[i/j]+=num[i];
                }
            }
        }
    }
    cout << res.x << endl;

    /*
    rep(i,num.size()){
        cout << "i: " << i << " " << num[i].x << endl;
    }
    rep(i,amari.size()){
        cout << "i: " << i << " " << amari[i].x << endl;
    }*/

}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

ll n;
ll a[101010];
ll sum[101010];

int main(){
	cin.sync_with_stdio(false);
  cin>>n;
  rep(i,n)cin>>a[i];
  sort(a,a+n);
  rep(i,n)sum[i+1]=sum[i]+a[i];
  ll minn=n-1;
  for(int i=n-2;i>=0;i--){
    if(a[i+1]<=sum[i+1]*2)minn--;
    else break;
  }
  cout<<n-minn<<endl;
	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Linq;

class D
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		var n = h[0];
		var pq = new int[h[1]].Select(_ => Read()).ToArray();
		var rs = new int[h[2]].Select(_ => Read()).ToArray();

		var uf1 = new UF(n);
		var uf2 = new UF(n);
		foreach (var x in pq) uf1.Unite(x[0], x[1]);
		foreach (var x in rs) uf2.Unite(x[0], x[1]);

		var r = new int[n + 1];
		var q = Enumerable.Range(1, n).Select(i => (i, g: (uf1.GetRoot(i), uf2.GetRoot(i)))).GroupBy(x => x.g).Select(g => g.ToArray());
		foreach (var g in q)
			foreach (var (i, _) in g)
				r[i] = g.Length;
		Console.WriteLine(string.Join(" ", r.Skip(1)));
	}
}

class UF
{
	int[] p;
	public UF(int n) { p = Enumerable.Range(0, n + 1).ToArray(); }

	public void Unite(int a, int b) { if (!AreUnited(a, b)) p[p[b]] = p[a]; }
	public bool AreUnited(int a, int b) => GetRoot(a) == GetRoot(b);
	public int GetRoot(int a) => p[a] == a ? a : p[a] = GetRoot(p[a]);
	public int[][] ToGroups() => Enumerable.Range(0, p.Length).GroupBy(GetRoot).Select(g => g.ToArray()).ToArray();
}


Measured memory_bytes: 62448
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long H,W;
  cin >> H >> W;
  long long ans = 0;
  long long sq = H*W;
  if (W == 1 || H ==1){
    ans = 1;
  }
  else{
  if(sq%2LL ==0){
    ans = H*W/2;
  }
  else{
    ans = (H*W/2)+1;
  }
}
cout << ans << endl;
}

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


int main()
{
    int n;
    while(scanf("%d", &n) && n != 0)
    {
        int daruma[n];

        rep(i,0,n)
            cin >> daruma[i];

        bool interval[n][n];
        memset(interval, 0, sizeof(interval));

        rep(i,0,n-1)
            if(abs(daruma[i]-daruma[i+1]) <= 1)
                interval[i][i+1] = true; 
            
        rep(i,0,n)
            rep(j,0,n-i)
                if((interval[j+1][j+i-1] && abs(daruma[j]-daruma[j+i]) <= 1))  
                    interval[j][j+i] = true;
                else
                    rep(k,j,j+i)
                        if(interval[j][k] && interval[k+1][j+i])
                            interval[j][j+i] = true;

        int dp[n][n];
        memset(dp,0,sizeof(dp));

        rep(i,0,n-1)
            rep(j,i+1,n)
                if(interval[i][j])
                    dp[i][j] = j-i+1;

        rep(j,0,n)
            rep(k,0,j)
               dp[0][j] = max(dp[0][j], dp[0][k] + dp[k+1][j]);

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


Measured memory_bytes: 3588
import scala.io.StdIn.{readLine,readInt}

object Main {

  def main(args: Array[String]) = {
    val n = readInt
    val a = Array.ofDim[Int](4,3,10)

    1 to n foreach { _ =>
      val Array(b,f,r,v) = readLine.split(" ").map(_.toInt)
      a(b-1)(f-1)(r-1) += v
    }

    for(i <- 0 to 3) {
      for(j <- 0 to 2) {
        for(k <- 0 to 9) {
          print(" ")
          print(a(i)(j)(k))
        }
        println()
      }
      if(i<3) {
        println("####################")
      }
    }
  }
}

Measured memory_bytes: 44192
items = list()
time = 0
for _ in range(5):
    menu = int(input())
    items.append((menu, 10-menu%10 if menu%10 != 0 else 0))

items = sorted(items, key=lambda x:x[1])
worst_item = items[-1]
items.pop()
items = sorted(items, key=lambda x: abs(x[1] - 5), reverse=True)
items.append(worst_item)

for i, (item, _) in enumerate(items):
    time += (item + 9) // 10 * 10 if i != len(items)-1 else item

print(time)



Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>

#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORN(i, a, b) for (int i = a; i <= b; i++)
#define P(s) cout << s << endl
#define PC(condition, _true, _false) if (condition) _true; else _false;

using namespace std;
//
// Created by karayuu on 2019-3-28.
//

int main() {
    int a[26] = {0};
    char c;

    while (cin >> c) {
        if (c == EOF) break;
        if (c == ' ' || c == '.') continue;
        c = (char) tolower(c);
        a[c - 'a'] += 1;
    }
    //アルファベットは26文字
    FOR(i, 0, 26) {
        char d = static_cast<char>('a' + i);
        cout << d << " : " << a[i] << endl;
    }
}


Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007
#define ll long long
#define db double
#define pb push_back
#define F first
#define S second
#define vl vector<ll>
#define vvl vector<vl>
#define pii pair<int,int>
#define mkp make_pair

int main()
{
	ll n,k; cin >> n >> k;
	if(n%2==0)
	{
		if(k<=(n/2)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	else
	{
		n++;
		if(k<=(n/2)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#include <stack>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <numeric>
#include <random>
#include <memory>
#include <chrono>
#include <iterator>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define mp make_pair
#define pb push_back
#define sz(x) int((x).size())


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int S = 2e5 + 7;
const int inf = INT_MAX / 3;
const ll INF = LLONG_MAX / 3;
const int MOD = 1e9 + 7;

ll f(ll a, ll b, ll n) {
	ll a1 = ceil((ld)a / n) * n;
	ll b1 = floor((ld)b / n) * n;

	return b - a - (b1 - a1) / n;
}

signed main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(9);
	ios::sync_with_stdio(false);
	cin.tie();
	cout.tie();

	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	cout << f(a, b, c) + f(a, b, d) - f(a, b, c * d / __gcd(c, d));
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int read(){
	int x=0;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
const int N=100005;
int n,m;
int cnt[N];
int main(){
	n=read(),m=read();
	while (m--){
		cnt[read()]^=1;
		cnt[read()]^=1;
	}
	int ans=0;
	for (int i=1;i<=n;i++)
		ans+=cnt[i];
	puts(ans?"NO":"YES");
	return 0;
}

Measured memory_bytes: 640
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;

int N, X, Y, T;

int main() {
    int i, lastT = 0, lastX = 0, lastY = 0;
    scanf("%d", &N);
    for(i = 1; i <= N; i++) {
        scanf("%d%d%d", &T, &X, &Y);

        int delta = abs(X - lastX) + abs(Y - lastY), dT = T - lastT;
        if((delta > dT) || ((dT - delta) & 1)) { printf("No"); return 0; }
        lastT = T; lastX = X; lastY = Y;
    }
    printf("Yes");
}

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

int main(){
	int n;
	std::vector<int> a;
	std::cin >> n;
	for(int i = 0; i < n; i++){
		int temp;
		std::cin >> temp;
		a.push_back(temp);
	}
	
	int count = 0;
	for(int i = 0; i < n; i++){
		for(int j = n - 1; j > i; j--){
			if(a[j] < a[j-1]){
				int temp = a[j];
				a[j] = a[j-1];
				a[j-1] = temp;
				count++;
			}
		}
	}
	
	for(int i = 0; i < n; i++){
		std::cout << a[i];
		if(i == n - 1)
			std::cout << std::endl;
		else
			std::cout << ' ';
	}
	std::cout << count << std::endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) {
        cin >> p[i];
    }

    int cnt = 0;
    int tmp = p[0];
    for (auto x : p) {
        if (x <= tmp) cnt++;
        tmp = min(tmp, x);
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
s = input()
ct = 0
if n % 2:
    print("No")
    exit()
else:
    m = n//2
    for i in range(m):
        if s[i] != s[i+m]:
            ct +=1
if ct == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9156
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);
int main() {
int n,m,x;
cin >> n >> m >> x;
vector<vector<int>> a(n,vector<int>(m+1));
rep(i,n)rep(j,m+1)cin >> a.at(i).at(j);
vector<int> b;
for(int tmp = 0; tmp < (1 << n); tmp++){
  bitset<12> s(tmp);
  int sum = 0;
  vector<int> d(m);
  rep(i,n)if(s.test(i)){
      sum += a.at(i).at(0);
      rep(j,m) d.at(j)+=a.at(i).at(j+1);
    }
  //条件を満たすかどうかの確認
  bool flag = true;
  rep(i,m)if(d.at(i) < x) flag = false;
  //満たすならbに入れる
  if(flag) b.push_back(sum);
  
}
  if(b.size() == 0){
    cout << -1 << endl;
    return 0;
  }
sort(b.begin(),b.end());
cout << b.at(0) << endl;

} 

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    vector<pii> A(n);
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        A[i] = pii(a, i+1);
    }
    sort(all(A));
    for (int i = 0; i < n; ++i) {
        cout << A[i].second << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4012
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;

int main() {

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

	int a, b, q;
	cin >> a >> b >> q;
	vector<long long>s(a), t(b), x(q);
	for (int i = 0; i < a; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < b; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < q; i++) {
		cin >> x[i];
	}


	for (int i = 0; i < q; i++) {
		long long ans = LLONG_MAX;
		vector<long long>::iterator s_b = lower_bound(s.begin(), s.end()-1, x[i]);
		vector<long long>::iterator s_a = s_b != s.begin() ? s_b - 1 : s_b;
		vector<long long>::iterator t_b = lower_bound(t.begin(), t.end()-1, x[i]);
		vector<long long>::iterator t_a = t_b != t.begin() ? t_b - 1 : t_b;
		ans = min(ans, abs(x[i] - *s_a) + abs(*s_a - *t_a));
		ans = min(ans, abs(x[i] - *s_a) + abs(*s_a - *t_b));
		ans = min(ans, abs(x[i] - *s_b) + abs(*s_b - *t_a));
		ans = min(ans, abs(x[i] - *s_b) + abs(*s_b - *t_b));
		ans = min(ans, abs(x[i] - *t_a) + abs(*t_a - *s_a));
		ans = min(ans, abs(x[i] - *t_a) + abs(*t_a - *s_b));
		ans = min(ans, abs(x[i] - *t_b) + abs(*t_b - *s_a));
		ans = min(ans, abs(x[i] - *t_b) + abs(*t_b - *s_b));

		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define ll long long
#define _for(a,b,i) for(int i=a;i<=b;i++)
#define for1(a,b,i) for(int i=a;i<b;i++)
using namespace std;
ll ma=0x80000000;
ll mi=0x7fffffff;
const ll zfc=0xffffffff;
const ll mod=1e9+7;
string st;
ll s,n,m;
string a="snuke",b="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>st;
			if(st==a)
			{
				cout<<b[j]<<i<<endl;
				return 0;
			}
		}
	}
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int agency();
int main(){agency();}
int agency(){
	string a[100];
	int h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++){
		cin>>a[i];
	}
	for(int i=0;i<w+2;i++){
		cout<<"#";
	}
	cout<<endl;
	for(int i=0;i<h;i++){
		cout<<"#"<<a[i]<<"#"<<endl;
	}
	for(int i=0;i<w+2;i++){
		cout<<"#";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 100020
using namespace std;

char a[N];

int main(void)
{
    int n;
    int i, j, o;

    scanf("%d %s", &n, a);
    for(i = o = 0; i < n; i = j, o ++)
        for(j = i; j < n && a[i] == a[j]; j ++)
            ;
    printf("%d\n", o);

    return 0;
}


Measured memory_bytes: 384
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>

using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	int w = 0;
	for (int i = 0; i < n-1; i++)
	{
		w +=a.at(i);
	}
	if (w > a.at(n - 1))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	

}

Measured memory_bytes: 256
from itertools import product

X,Y,Z,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

BC = [i+j for i,j in list(product(B,C))]
BC.sort(reverse=True)

ans = [i+j for i,j in list(product(BC[:min(3000, X*Y*Z)], A))]
ans.sort(reverse=True)

[print(ans[i]) for i in range(K)]


Measured memory_bytes: 274052
import math

a, b, h, m = map(int, input().split())

minute = h * 60 + m

hourx = a * math.cos(minute / (12 * 60) * 2 * math.pi)
houry = a * math.sin(minute / (12 * 60) * 2 * math.pi)
minx = b * math.cos(minute / 60 * 2 * math.pi)
miny = b * math.sin(minute / 60 * 2 * math.pi)

print(math.sqrt((hourx - minx) ** 2 + (houry - miny) ** 2))

Measured memory_bytes: 9524
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let n: u64 = input();
    if n % 2 == 0 {
        println!("{}", n);
    } else {
        println!("{}", n * 2);
    }
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ka = a + b;
		int gen = a - b;
		int jo = a * b;
		int [] vls = {ka, gen, jo};
		int ans = vls[0];
		for (int i = 1; i < 3; i++ ) {
			ans = Math.max(ans, vls[i]);
		}
		System.out.println(ans);
	}
}


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

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr <<"at line "<< __LINE__<<": [" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

const int mx=1e5+5;

int color[mx],dis[mx];
vector<int>g[mx];

vector<int>topo;

void dfs(int u)
{
	color[u]=1;
	
	for(int v: g[u]) 
	{
		if(!color[v]) dfs(v);
	}
	
	topo.push_back(u);
}

void solve()
{
	int n,m;
	cin>>n>>m;
	
	for(int i=0;i<m;i++) 
	{
		int u,v;
		cin>>u>>v;
		
		g[u].push_back(v);
	}
	
	for(int i=1;i<=n;i++) if(!color[i]) dfs(i);
	
	reverse(topo.begin(),topo.end());
	
	for(int u: topo)
	{
		for(int v: g[u]) dis[v]=max(dis[v],dis[u]+1);
	}
	
	cout<<*max_element(dis+1,dis+n+1);
	
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int t=1;
	//cin>>t;
	
	for(int i=1;i<=t;i++)
	{
		//cout<<"Case "<<i<<": ";
		solve();
	}
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


Measured memory_bytes: 11912
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  long n;  
  cin >> n;
  if(n % 2 == 1){
    cout << 0 << endl;
    return 0;
  }
  long ans = 0;
  for(int i=1;i<=18;i++){
    long tmp = pow(10,i);
    ans += (n / tmp) ;
  }
  /*for(int i=1;i<=17;i++){
    long tmp = pow(10,i)*5;
    ans += (n / tmp) ;
  }
  cout << ans << endl;
  for(int i=1;i<=25;i++){
    long tmp = pow(5,i)*10;
    ans += ((n / tmp) + 1)/2;
  }*/
  for(int i=1;i<=17;i++){
    long tmp = pow(10,i)*5;
    while(tmp <= 1e18){
      ans += (n/tmp + 1)/2;
      tmp *= 5;
    }
  }
  cout << ans << endl;
  //cout << pow(5,25)*10 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int kind = 26;
  int inf = std::numeric_limits<int>::max();
  std::vector< int > min(kind, inf);
  int n; std::cin >> n;
  loop(n) {
    std::string s; std::cin >> s;
    std::vector<int> now(kind,0);
    for (char c : s) {
      int x = c - 'a';
      now.at(x)++;
    }
    rep(i,0,kind) {
      cmn(min.at(i), now.at(i));
    }
  }
  std::string ans;
  rep(i,0,kind) {
    loop(min.at(i)) {
      ans.push_back('a' + i);
    }
  }
  std::sort(all(ans));
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
A,B,C,X,Y = map(int,input().split())
ans = 0
if A+B >= 2*C:
    sub = min(X,Y)
    ans += 2*C * sub
    X -= sub
    Y -= sub
    left = max(X,Y)
    yen = [A,B][X<Y]
    if yen >= 2*C:
        ans += 2*C*left
        X=Y=0
ans += A*X+B*Y
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 h, w, k;
vector<string> s;
vector<vector<int>> bs;
int main() {
  cin >> h >> w >> k;
  read_n(s, h);

  vector<vector<int>> ps(h + 1);
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (s[i][j] == '#') ps[i + 1].push_back(j + 1);
    }
  }

  bs.assign(h + 1, vector<int>(w + 1));
  int x = 0;
  for (int i = 1; i <= h; ++i) {
    if (ps[i].empty()) {
      for (int j = 1; j <= w; ++j) {
        bs[i][j] = bs[i - 1][j];
      }
    } else {
      ++x;
      for (int j = 1, c = 0; j <= w; ++j) {
        if (s[i - 1][j - 1] == '#') {
          ++c;
          if (c >= 2) ++x;
        }
        bs[i][j] = x;
      }
    }
  }

  for (int i = h; i > 0; --i) {
    for (int j = 1; j <= w; ++j) {
      if (bs[i][j] == 0) bs[i][j] = bs[i + 1][j];
    }
  }

  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <= w; ++j) {
      cout << bs[i][j] << ' ';
    }
    cout << '\n';
  }
  return 0;
}

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

using namespace std;

int main(){
    string S;
    cin >> S;
    long long int ans = 0;
    vector<vector<long long int>> dp(S.size()+1,vector<long long int>(13,0));

    dp[0][0] = 1;

    for(int i=0;i<S.size();i++){
        int now;

        if(S[i]=='?'){
            now = -1;
        }else{
            now = S[i]-'0';
        }

        for(int j=0;j<10;j++){
            if(now!=-1 && now!=j){
                continue;
            }

            for(int k=0;k<13;k++){
                dp[i+1][(k*10+j)%13] += dp[i][k];
            }
        }

        for(int j=0;j<13;j++){
            dp[i+1][j] %= 1000000007;
        }
    }

    cout << dp[dp.size()-1][5] << endl;
}

Measured memory_bytes: 13696
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using ll = long long;
using namespace std;
int main() {
    int r,D; cin >> r >> D;
    vector<long long int> X(11);
    cin >> X[0];
    for (int i=1;i<11;i++){
        X[i] = r*X[i-1] - D;
    }
    for (int i=1;i<11;i++){
        cout << X[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

const int64_t di[] = {-1, 0, 1, 0};  // Left, Up, Right, Down
const int64_t dj[] = {0, -1, 0, 1};  // Left, Up, Right, Down

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

  int64_t H, W;
  cin >> H >> W;
  vector<vector<bool>> grid(H, vector<bool>(W, false));
  for (int64_t r = 0; r < H; ++r) {
    string s;
    cin >> s;
    for (int64_t c = 0; c < W; ++c) {
      grid[r][c] = (s[c] == '.');
    }
  }
  int64_t max_distance = 0;
  for (int64_t start_r = 0; start_r < H; ++start_r) {
    for (int64_t start_c = 0; start_c < W; ++start_c) {
      if (!grid[start_r][start_c]) {
        continue;
      }
      vector<vector<int64_t>> distances(H, vector<int64_t>(W, kInf));
      queue<Pair> q;
      distances[start_r][start_c] = 0;
      q.emplace(start_r, start_c);
      while (!q.empty()) {
        const Pair target = q.front();
        q.pop();
        const int64_t t_distance = distances[target.first][target.second];
        for (int64_t n = 0; n < 4; ++n) {
          const Pair next(target.first + di[n], target.second + dj[n]);
          if (next.first >= 0 && next.first < H && next.second >= 0 && next.second < W) {
            if (grid[next.first][next.second] && t_distance + 1 < distances[next.first][next.second]) {
              distances[next.first][next.second] = t_distance + 1;
              q.emplace(next.first, next.second);
            }
          }
        }
      }
      for (int64_t r = 0; r < H; ++r) {
        for (int64_t c = 0; c < W; ++c) {
          if (grid[r][c]) {
            if (distances[r][c] != kInf) {
              max_distance = max(max_distance, distances[r][c]);
              if (distances[r][c] == 7) {
                cerr << start_r << ", " << start_c << ", " << r << ", " << c << endl;
              }
            }
          }
        }
      }
    }
  }
  cout << max_distance << endl;
  return 0;
}


Measured memory_bytes: 3668