akhauriyash/Code-Regression huggingface dataset:
N, L, T = list(map(int, input().split(" ")))

# N,L,T = 3,10,6
# a = [1,2,3]
# b = [2,1,1]

a = []
b = []
for i in range(N):
    an, ve = map(int, input().split(" "))
    a.append(an)
    b.append(ve)

crash = 0

for i in range(1, N):
    if b[0] != b[i]:
        if b[0] == 1:
            crash += (T - ((a[i] - a[0]) / 2)) // (L / 2) + 1
        else:
            crash += (T - (L - (a[i] - a[0])) / 2) // (L / 2) + 1

for i in range(N):
    if b[i] == 1:
        a[i] += T
    else:
        a[i] -= T
    a[i] %= L


if b[0] == 1:
    where = int(crash) % N
else:
    where = int(-crash) % N

nowplace = a[0]

a.sort()

if b[0] == 1:
	where0 = max([i for i in range(N) if a[i] == nowplace])
else:
	where0 = min([i for i in range(N) if a[i] == nowplace])

where0 = (where0 - where) % N

res = a[where0:] + a[:where0]
res = map(str, res)

for i in res:
    print(i)


Measured memory_bytes: 9664
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ab = []
for a in A:
	for b in B:
		ab += [a + b]

ab3000 = sorted(ab)[::-1][:3000]

abc = []
for ab in ab3000:
	for c in C:
		abc += [ab + c]

abc.sort(reverse=True)

for k in range(K):
	print(abc[k])


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

int main(){
  long long int H, W;
  cin >> H >> W;
  if(H==1 || W==1) cout << 1 << endl;
  else{
    if(H%2!=0 && W%2!=0){
        cout << (H+1)/2*(W+1)/2+(H-1)/2*(W-1)/2 << endl;
    }
    else
    {
      cout << H*W/2 << endl;
    }
  }
}

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

#define vi vector<int>
#define ll long long int
#define vll vector<ll>

int getParent(int N, int v) {
    if (v%N > 1) {
        return v/N + 1;
    }
    else {
        return v/N;
    }
}


int main() {

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

    int v, w;
    for (int i = 0; i < Q; i++) {
        cin >> v >> w;
        if (N == 1) {
            cout << min(v, w) << endl;
        }
        else {
            if (v == 1 || w == 1) {
                cout << 1 << endl;
            }
            else {
                while (v != w) {
                    if (v > w) {
                        v = getParent(N, v);
                    }
                    else {
                        w = getParent(N, w);
                    }
                }
                cout << v << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 1280
s = input()

a = []
for i in range(3):
  if s[i:i+1] == '1':
    a.append('9')
  elif s[i:i+1] == '9':
    a.append('1')
  else:
    a.append(s[i:i+1])

print(a[0]+a[1]+a[2])

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    if (s[0]==s[1] && s[1]==s[2]){
        cout<<"No\n";
    }else{
        cout<<"Yes\n";
    }
    return 0;
}


Measured memory_bytes: 256
def main():
  X, Y, Z, K = list(map(int, input().split()))
  A = list(map(int, input().split()))
  B = list(map(int, input().split()))
  C = list(map(int, input().split()))

  A.sort(reverse = True)
  B.sort(reverse = True)
  C.sort(reverse = True)
  A += [-1e10]
  B += [-1e10]
  C += [-1e10]

  memo = [A[i] + B[0] + C[0] for i in range(X + 1)]
  L = [[0 for i in range(Y + 1)] for j in range(X + 1)]

  for i in range(K):
    ma = 0
    for j in range(X):
      if memo[ma] < memo[j]:
        ma = j
    print(memo[ma])
    mb = 0
    mn = 0
    for j in range(Y):
      x = B[j] + C[L[ma][j]]
      if mb < x:
        mb = x
        mn = j
    L[ma][mn] += 1
    n = 0
    for j in range(Y):
      n = max(n, B[j] + C[L[ma][j]])
    memo[ma] = A[ma] + n
 
main()

Measured memory_bytes: 14196
// AtCoder.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <math.h>
#include <cmath>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int total = 0;
    for(int i = 0; i < m; i++){
        int k;
        cin >> k;
        total += k;
    }
    if(total > n) cout << -1 << endl;
    else cout << n- total << endl;
    return 0;
}

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

int main() {
	int n, x, t;
	cin >> n >> x >> t;
	int res = 0;
	if (n % x == 0) {
		res = n / x * t;
	}
	else {
		res = (n / x + 1) * t;
	}
	cout << res;
}


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

template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
const int INF=1e9;
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int a,b;cin>>a>>b;
  for(int i=0;i<=10000000;i++)if((i*108)/100==i+a&&(i*110)/100==i+b)fin(i);
  fin(-1);
}


Measured memory_bytes: 256
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
a = li()

ans = [0] * n
for i in range(n-1):
    ans[a[i]-1] += 1

for i in range(n):
    print(ans[i])
    

Measured memory_bytes: 32376
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int N = sc.nextInt();
		int[] T = new int[N];
		int sum = 0;
		
		for (int i = 0; i < N; i++) {
			T[i] = sc.nextInt();
			sum += T[i];
		}
		
		int M = sc.nextInt();
		int[] P = new int[M];
		int[] X = new int[M];
		
		for (int i = 0; i < M; i++) {
			P[i] = sc.nextInt();
			X[i] = sc.nextInt();
		}
		int s = 0;
		for (int i = 0; i < M; i++) {
			s = sum - (T[(P[i]-1)] - X[i]);
			System.out.println(s);
		}

		sc.close();
	}
}


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

int main(){
  string s;
  cin >> s;
  int N = s.size();

  int ans = 0;
  int sv = 0;
  for(int i=0;i<N;i++){
    if(s[i] == 'g' && sv == 0){
      sv++;
    }
    else if(s[i] == 'g' && sv > 0){
      ans++;
      sv--;
    }
    else if(s[i] == 'p' && sv == 0){
      ans--;
      sv++;
    }
    else if(s[i] == 'p' && sv > 0){
      sv--;
    }
  }

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


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include <iomanip>
using namespace std;

int main() {

	int  L;
	cin >> L;

	double volume;
	volume = (L*L*L) / (3.0f*3.0f*3.0f);
	cout <<fixed<<setprecision(15)<< volume;

}

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

int main(){
  double N,K;
  double ans=0;
  cin >> N >> K;
  for(double i=1;i<=N;i++){
    double a=(double)ceil(log2(K/i));
    if(a<0) a=0;
    ans += pow(0.5,a)/N;
  }
  cout << std::setprecision(11) << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
 int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
		if(x>=r&&y>=r&&W>=x+r&&H>=y+r){
			cout<<"Yes"<<endl;
		}
		else{
		cout<<"No"<<endl;		
		}
return 0;
}

Measured memory_bytes: 1160
(defun kakuritu ()
  (let ((n (read))
        (k 0))
    (if (= (mod n 2) 0) (setf k (/ 1 2.0))
        (if (= n 1) (setf k 1.0) 
            (setf k (/ (1+ (/ (1- n) 2)) n))))
    (format t "~a" (float k))))

(kakuritu)

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

int main()
{
	int a;
	int b;
	int c;
	cin >> a >> b >> c;
	if (a == b && a != c)
	{
		cout << "Yes";
	}
	else if (a == c && a != b)
	{
		cout << "Yes";
	}
	else if (b == c && a != b)
	{
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  string s;
  cin >> s;
  int n = s.size();

  ll dp[n + 1][13];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;

  rep(i, n) {
    int c;
    if (s[i] == '?') c = -1;
    else c = s[i] - '0';

    rep(j, 10) {
      if (c != -1 && c != j) continue;
      rep(k, 13) {
        dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
      }
    }

    rep(j, 13) dp[i + 1][j] %= mod;
  }

  cout << dp[n][5] << endl;

  
  return 0;
}

Measured memory_bytes: 10624
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

S = input()
T = input()

ans = INF
for i in range(len(S)):
    cnt = 0
    if i + len(T) > len(S):
        break
    for j in range(i, i + len(T)):
        if S[j] != T[j - i]:
            cnt += 1
    ans = min(ans, cnt)
print(ans)
        

Measured memory_bytes: 68144
// https://atcoder.jp/contests/abc124/tasks/abc124_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

// 参考
// https://atcoder.jp/contests/abc124/submissions/4964169
void solve() {
    int n, k, ans = 0, l = 0, r = 0;
    string s;
    cin >> n >> k >> s;
    while (r < n) {
        // 連続する1と0を探す
        while (r < n && s[r] == '1')
            ++r;
        ans = max(ans, r - l);
        while (r < n && s[r] == '0')
            ++r;
        --k;
        // 連続する0がK回繰り返されるまでは左側を移動しない
        if (k < 0) {
            while (l < n && s[l] == '1')
                ++l;
            while (l < n && s[l] == '0')
                ++l;
        }
        // 右側の1と左側の1の長さが最大値なら更新
        ans = max(ans, r - l);
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3640
import java.util.Scanner;

class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();
            
            if(h == 0 && w == 0) break;
            
            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++){
                	
                	if((i+j)%2==0){
                		System.out.print("#");
                	}else{
                		System.out.print(".");
                	}
                
                    //System.out.print(i == 0 || i + 1 == h || j == 0 || j + 1 == w ? '#' : '.');
                }
                System.out.println();
            }
            
            System.out.println();
        }
    }
}

Measured memory_bytes: 35112
t=int(input())

res='No'

#if t>3:
#	if t%4==0 or t%7==0 or t%11==0 or t%4==3 or t%7==4 or t%11==1:
#		res='Yes'

if t>3:
	for i in range(26):
		for j in range(16):
			if t==4*i+7*j:
				res='Yes'

print(res)

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

int main(void){
  char s[10];
  scanf("%s", s);

  int ans = 1;
  if(strlen(s) < 4) ans = 0;
  else{
    if(s[0] != 'Y') ans = 0;
    if(s[1] != 'A') ans = 0;
    if(s[2] != 'K') ans = 0;
    if(s[3] != 'I') ans = 0;
  }

  if(ans) printf("Yes\n");
  else printf("No\n");

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  string s, t;
  cin >> s >> t;
  // cout << s << endl;
  sort(all(s));
  sort(all(t),greater<char>());
  cout << ((s < t)? "Yes": "No")<< endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int aoki = c;
    int taka = a;

    for (int i = 1; i < 101; i++)
    {       
        while (aoki > b && taka > d)
        {
            aoki = aoki - b;
            taka = taka - d;
        }
        
    }
    
    if (aoki == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        if ((aoki - b) <= 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
        
    }
    
    
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, k, a[250000];
ll cnt, ans;
set<int> S; 
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> k;
    rep(i, 0, n) {
        int t; cin >> t;
        S.insert(t);
        a[t]++;
    }
    cnt = S.size();
    sort(a, a+250000);
    rep(i, 0, 250000) {
        if (cnt <= k) break;
        if (a[i] > 0) {
            ans += a[i];
            cnt--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif
  
  int n; cin >> n;
  vector<int> xs(n);
  for (int& x: xs) cin >> x;
  
  int ans = 1e9;
  for (int p = 1; p <= 100; p++) {
    int cur = 0;
    for (int x: xs) cur += (p - x) * (p - x);
    ans = min(ans, cur);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var sc = new Scanner();

            int N = sc.NextInt();
            int L = sc.NextInt();

            int min = int.MaxValue;
            int absMin = int.MaxValue;
            
            int sum = 0;

            for (int i = 1; i <= N; i++)
            {
                var apple = L + i - 1;

                sum += apple;

                if (absMin > Math.Abs(apple))
                {
                    absMin = Math.Abs(apple);
                    min = apple;
                }
            }
            Console.WriteLine(sum - min);
        }
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}


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

using namespace std;

const int N = 1e5 + 5 , MOD = 1e9 + 7;
bool bad[N];
int memo[N];

int solve (int n) {
    if (n <= 0) return n == 0;
    int &ret = memo[n];
    if (~ret) return ret;
    return ret = (solve(n - 2) + solve(n - 1)) % MOD;
}

int main() {

    int n , m;
    cin >> n >> m;

    vector<int> a(m);
    for (int i = 0 ;i < m ;i++) {
        cin >> a[i];
        bad[a[i]] = 1;
    }

    sort(a.begin() , a.end());

    bool can = !bad[0] && !bad[n];
    for (int i = 1 ;i <= n ;i++)
        if (bad[i] && bad[i - 1])
            can = 0;

    if (!can) {
        cout << 0;
        return 0;
    }

    a.push_back(n + 1);

    memset(memo , -1 , sizeof memo);

    int ans = 1 , prev = -1;
    for (int i = 0 ;i < a.size() ;i++) {
        ans = ans * 1ll * solve(a[i] - prev - 2) % MOD;
        prev = a[i];
    }

    cout << ans;
}


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

int n, ans;
string s;
map<string,bool>ada;

int main() {
	cin >> n;
	while(n--){
		cin >> s;
		if(ada[s]!=1)ans++;
		ada[s]=1;
	}
	cout << ans << '\n';
}
//avrs,0r

Measured memory_bytes: 19224
#include "bits/stdc++.h"

using namespace std;

int main() {
    string s;
    int n;
    cin >> n >> s;
    int N = s.size();
    for(int i = 0; i < N; i++){
        s.at(i) += n;
        if(s.at(i) > 'Z') s.at(i) -= 26;
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	while(true){
		cin >> N;
		if(N==0){return 0;}

		int* x = new int[N];
		int* y = new int[N];
		x[0]=0; y[0]=0;
		int n, d;

		for(int i=1; i<N; i++){
			cin >> n >> d;
			if(d==0){ x[i] = x[n]-1; y[i] = y[n]; }
			else if(d==1){ x[i] = x[n]; y[i] = y[n]-1; }
			else if(d==2){ x[i] = x[n]+1; y[i] = y[n]; }
			else { x[i] = x[n]; y[i] = y[n]+1; }
		}
		int* x_max = max_element(x,x+N);
		int* x_min = min_element(x,x+N);
		int* y_max = max_element(y,y+N);
		int* y_min = min_element(y,y+N);

		cout << *x_max - *x_min + 1 << " " << *y_max - *y_min + 1 << endl;

		delete[] x; delete[] y;
	}
}

Measured memory_bytes: 1200
#pragma gcc optimize(2)
#include<bits/stdc++.h>
using namespace std;
int n,q,x,y,l=1,r,t,num,a[666666],p[2333333],ans[666666],dv;
struct node{int l,r,bel;}ls[666666];
int cmp(node a,node b){
    if(a.l/dv!=b.l/dv)return a.l/dv<b.l/dv;
    return a.r/dv<b.r/dv;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>q;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=q;i++)
        cin>>x>>y,ls[i]=(node){x,y,i};
    dv=(int)(sqrt(n));
    sort(ls+1,ls+q+1,cmp);
    for(int i=1;i<=q;i++){
        while(ls[i].l<l)num+=!p[a[--l]]++;
        while(ls[i].l>l)num-=!--p[a[l++]];
        while(ls[i].r>r)num+=!p[a[++r]]++;
        while(ls[i].r<r)num-=!--p[a[r--]];
        ans[ls[i].bel]=num;
    }
    for(int i=1;i<=q;i++)cout<<ans[i]<<endl;
}

Measured memory_bytes: 15452
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
//26

signed main(){
	int n;
	scanf("%lld", &n);
	if(n >= 1000)printf("ABD\n");
	else printf("ABC\n");
	return 0;
}





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

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(void){
  int n, i, deathBlow;
  scanf("%d %d", &n, &deathBlow);
  long int attack;
  long int enemies[n];
  for(i=0; i<n; i++){
    scanf("%ld", &enemies[i]);
  }
  qsort(enemies, n, sizeof(long int), compare_int);
  
  attack=0;
  for(i=deathBlow; i<n; i++){
    attack += enemies[i];
  }
  
  printf("%ld", attack);
  
  return 0;
  
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    vector<int> x(3);
    REP(i,3) cin>>x[i];
    sort(ALL(x));
    for (int i=1;i<3;i++) {
        if (x[i] != x[i-1]) {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int [N];
        for (int i = 0; i < N; ++i) {
                A[i] = sc.nextInt();
        }
        Arrays.sort(A);

        System.out.println(A[A.length - 1] - A[0]);
	}
}


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

using namespace std;

typedef long long I64;
const I64 NMAX = 2e5;

I64 v[NMAX+2], N;
I64 ans = 0;

int main()
{
    cin >> N;
    for( I64 i = 1;  i <= N;  ++i ) cin >> v[i];
    vector<I64> events;
    for( I64 i = 1;  i <= N;  ++i ) {
        events.push_back(v[i] - i);
    }
    sort( events.begin(), events.end() );
    I64 cost = 0, start = events[0];
    for( I64 i = 1;  i <= N;  ++i ) {
        cost += abs(v[i] - (start + i));
    }
    ans = cost;
    for( I64 i = 1;  i < events.size();  ++i ) {
        I64 delta = events[i] - events[i - 1];
        cost += i * delta;
        cost -= (N - i) * delta;
        ans = min(ans, cost);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3956
#include <cstdio>

int main()
{
  long long w, h, x, y;
  scanf("%lld %lld %lld %lld", &w, &h, &x, &y);
  printf("%f %d\n", w * h / 2., (x + x == w && y + y == h ? 1 : 0));
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
 
int main(){
    int n; cin >> n;
    int ans = 0;
    rep(i, n){
        rep(j, n){
            rep(k, n){
                ans += gcd(i, gcd(j, k));
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
const int maxx=1e5+10;
string a,b;
int n;
int main()
{
    cin>>n;
    cin>>a>>b;
    for(int i=0;i<n;i++)
    {
        cout<<a[i]<<b[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
stat = {'A':True, 'B':False,'C':False }

while True:
    try:
        x,y = input().strip().split(',')
        z = stat[x]
        stat[x] = stat[y]
        stat[y] = z
    except EOFError:
        break
for i in stat.keys():
    if stat[i]:
        print(i)

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

int main() {
    int N;
    cin >> N;
    int p[N];
    rep (i, N) cin >> p[i];

    int ans = 0;
    rep (i, N) {
        if (p[i] == i + 1) {
            ans ++;
            if (p[i + 1] == i + 2) i++;
        }
    }

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

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


void solve() {
  int N,A,B;
  cin >>N >>A >> B;

  cout << min(N*A,B) << "\n";
}

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


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

int main()
{
    long l, r;
    cin >> l >> r;

    long ans = 2018;
    r = min(r, l + 2019 * 2);
    for (long i = l; i < r; i++) {
        for (long j = i + 1; j <= r; j++) {
            ans = min(ans, i * j % 2019);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
#include <atcoder/mincostflow>

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<std::string> S(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> S[i];
  }
  const int offset = N * M;
  const int source = offset + N * M;
  const int sink = source + 1;
  atcoder::mcf_graph<int, int> graph(sink + 1);
  const int kInfinity = N + M;
  int num_stones = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      const auto node = M * i + j;
      if (S[i][j] == '.') {
        graph.add_edge(offset + node, sink, 1, 0);
      } else if (S[i][j] == 'o') {
        ++num_stones;
        graph.add_edge(offset + node, sink, 1, 0);
        graph.add_edge(source, node, 1, 0);
        std::vector<std::vector<bool>> seen(N, std::vector<bool>(M));
        std::queue<std::tuple<int, int>> queue;
        queue.emplace(i, j);
        while (!queue.empty()) {
          auto [y, x] = queue.front();
          queue.pop();
          graph.add_edge(node, offset + M * y + x, 1, kInfinity - (y - i) - (x - j));
          ++y;
          if (y < N && !seen[y][x] && S[y][x] != '#') {
            queue.emplace(y, x);
            seen[y][x] = true;
          }
          --y;
          ++x;
          if (x < M && !seen[y][x] && S[y][x] != '#') {
            queue.emplace(y, x);
            seen[y][x] = true;
          }
        }
      }
    }
  }
  const auto [capacity, cost] = graph.flow(source, sink);
  std::cout << (kInfinity * num_stones - cost) << std::endl;
  return 0;
}


Measured memory_bytes: 7188
#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>;

int main() {
  int D;
  cin >> D;
  
  vector<int> c(27), tmp(27);
  vector<vector<int>> s(D+1 , vector<int>(27));
  for (int i = 1; i <= 26; i++)  cin >> c.at(i);
  for (int i = 1; i <= D; i++)  for(int j = 1; j <= 26; j++)  {
    cin >> s.at(i).at(j);
  }
  
  vector<int> last(27);//最終開催日
  for (int i = 1; i <= 26; i++) last.at(i) = 0;
  
  vector<int> t(D+1);//開催テストタイプ
  for (int i = 1; i <= D; i++)  cin >> t.at(i);
  
  
  //初期計算
  for(int i = 1; i <= D; i++) {
    int typ = 0;
    int smax = 0,stf;
    for(int j = 1; j <= 26; j++) {
      stf = s.at(i).at(j) + (i-last.at(j)) * c.at(j);
      if (stf > smax) {
        smax = stf;
        typ = j;
      }
    }
    
    last.at(typ) = i;
    
    t.at(i) = typ;   
  }
  
  vector<int> stf(D+1);
  int sf = 0;
  for (int i = 1; i <= D; i++) {
    sf += s.at(i).at(t.at(i));
    last.at(t.at(i)) = i;
    
    for (int j = 1; j <= 26; j++) {
      sf -=c.at(j)*(i-last.at(j));
    }
    stf.at(i) = sf;
  }
  
  
  vector<int> dmaxtyp(D+1);
  for (int i = 1; i <= D; i++) {
    int mmax = 0, tmp;
    for (int j = 1; j <= 26; j++) {
      if (mmax < s.at(i).at(j)) {
        tmp = j;
        mmax = s.at(i).at(j);
      }
    }
    dmaxtyp.at(i) = tmp;
    
  }
  
  //局所探索?
  for (int k = 1; k <= D; k++) {
    int oldsf = sf;
    int oldtyp = t.at(k);
    sf = 0;
    t.at(k) = dmaxtyp.at(k);
    for (int i = 1; i <= 26; i++) last.at(i) = 0;
    
    for (int i = 1; i <= D; i++) {
      sf += s.at(i).at(t.at(i));
      last.at(t.at(i)) = i;

      for (int j = 1; j <= 26; j++) {
        sf -=c.at(j)*(i-last.at(j));
      }

    }
    if (oldsf > sf) {
      t.at(k) = oldtyp;
      sf = oldsf;
    }
  }
  //cout << sf << endl;
  for (int i = 1; i <= D; i++) cout << t.at(i) << endl;
}

Measured memory_bytes: 3644
import java.util.Scanner;
public class Main{
    int niti;
	int purune;
	int hurone;
	int purumai;
	int huromai;
	int ryo;
	int gokei;
	int wgokei;
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		niti = sc.nextInt();
		for(int i=0;i<niti;i++){
			hurone = sc.nextInt();
			purune = sc.nextInt();
			huromai = sc.nextInt();
			purumai = sc.nextInt();
			gokei = hurone*huromai+purune*purumai;
			if(huromai<5){
				huromai = 5;
			}
			if(purumai<2){
				purumai = 2;
			}
			wgokei = (hurone*huromai+purune*purumai)/10*8;
			if(gokei > wgokei){
				System.out.println(wgokei);
			}else{
				System.out.println(gokei);
			}
		}
	}
    
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 23448
N = int(input())
arr = [input() for _ in range(N)]
ans_list =[0]*4

for i in range(N):
    if arr[i] == "AC":
        ans_list[0] += 1
    if arr[i] == "WA":
        ans_list[1] += 1
    if arr[i] == "TLE":
        ans_list[2] += 1
    if arr[i] == "RE":
        ans_list[3] += 1

print('AC'+' '+'x'+' '+str(ans_list[0]))
print('WA'+' '+'x'+' '+str(ans_list[1]))
print('TLE'+' '+'x'+' '+str(ans_list[2]))
print('RE'+' '+'x'+' '+str(ans_list[3]))

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

int main(){
    int a;
    cin >> a;
    cout << (a / 100) + ((a / 10) - ((a / 100) * 10)) + ((a / 1) - ((a / 100) * 100) - ((a / 10) - ((a / 100) * 10)) * 10) << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  int ans = 0;
  rep(i, n - 2) {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<char,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
const double PI=acos(-1);
const ll INF=1000005;
using namespace std;

int main( ) {
    ll N;
    cin>>N;
    vec A(N);
    vec B(INF);
    rep(i,0,N) {
        cin>>A[i];
    }
    sort(A);
    rep(i,0,N) {
        
            if(B[A[i]]!=0) {
                B[A[i]]=2;
                continue;
                }
        
        for(ll j=A[i];j<INF;j+=A[i]) {
            
            B[j]+=1;
        }
    }
    ll count=0;
    rep(i,0,A.size()) {
        if(B[A[i]]==1) count+=1;
    }
   
    cout<<count<<endl;
    }

Measured memory_bytes: 12736
n = int(input())
if n < 2:
    print('0')
elif n == 2:
    print('2')
else:

    zero = 10 ** n - 9 ** n
    nine = 10 ** n - 9 ** n
    zq = 10 ** n - 8 ** n
    ans = zero + nine - zq
    print(ans % (10 ** 9 + 7))
    

Measured memory_bytes: 11452
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>

typedef long double ld;
typedef long long ll;

using namespace std;

int a, b, c, k;

int main() {
	cin >> a >> b >> c >> k;

	int ret = 0;
	for (int i = 0; i < k; i++) {
		if (i < a) {
			ret++;
		} else if (i < a + b) {
		} else if (i < a + b + c) {
			ret--;
		}
	}
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 3636
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

A = sorted(X)

med1 = A[N // 2 - 1] 
med2 = A[N // 2]

for i, x in enumerate(X):
    if x <= med1:
        print(med2)
    else:
        print(med1)

Measured memory_bytes: 32424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

// 遅延セグ木

ll segnodenum;
vector<ll> segnode;
vector<ll> seglazy;

ll init_num=pow(2,31)-1;
ll func(ll x,ll y){
    return min(x,y);
}

void eval(ll k){    //seglazy[k]の遅延評価
    if(seglazy[k]==init_num)return;
    if(k<segnodenum-1){  //葉でなければ子に伝搬
        seglazy[2*k+1]=seglazy[k];
        seglazy[2*k+2]=seglazy[k];
    }
    //自分を更新
    segnode[k]=seglazy[k];
    seglazy[k]=init_num;
}

void init(vector<ll> v){
    segnodenum=1;
    while(v.size()>segnodenum)segnodenum*=2;
    segnode.resize(2*segnodenum-1,init_num);
    seglazy.resize(2*segnodenum-1,init_num);
    rep(i,segnodenum-1,segnodenum*2-2){
        if(i-(segnodenum-1)<v.size()){
            segnode[i]=segnode[i-(segnodenum-1)];
        }else{
            segnode[i]=init_num;
        }
    }
    for(ll i=segnodenum-2;i>=0;i--){
        segnode[i]=func(segnode[2*i+1],segnode[2*i+2]);
    }
}


void update(ll i,ll j,ll x,ll k,ll l,ll r){
    eval(k);
    if(i<=l && r<=j) {  // 完全に内側の時
        seglazy[k]=x;
        eval(k);
    }else if(i<r && l<j){                     // 一部区間が被る時
        update(i,j,x,k*2+1,l,(l+r)/2);  // 左の子
        update(i,j,x,k*2+2,(l+r)/2,r);  // 右の子
        segnode[k]=func(segnode[k*2+1],segnode[k*2+2]);
    }
}

void update(ll i,ll j,ll x){    //v[[i,j)]をxにupdate //[i,j)であることに注意
    update(i,j,x,0,0,segnodenum);
}

ll find(ll i,ll j,ll x,ll y,ll z){  //segnode[x]着目//segnode[x]が担当する範囲が[y,z)
    eval(x);
    if(j<=y || z<=i)return init_num;
    if(i<=y && z<=j)return segnode[x];
    return func(find(i,j,2*x+1,y,(y+z)/2),find(i,j,2*x+2,(y+z)/2,z));
}

ll find(ll i,ll j){             //v[[i,j)]でのfunc結果出力//[i,j)であることに注意
    return find(i,j,0,0,segnodenum);
}

int main(){fastio
    ll n,q;cin>>n>>q;
    vector<ll> v;rep(i,0,n-1)v.pb(init_num);
    init(v);
    rep(i,0,q-1){
        ll com;
        cin>>com;
        if(com==0){
            ll s,t,x;cin>>s>>t>>x;
            update(s,t+1,x);
        }else{
            ll s,t;cin>>s>>t;
            cout<<find(s,t+1)<<endl;
        }
    }
    
    return 0;
}








Measured memory_bytes: 8712
import sys
# import sympy

# 約数計算


def divisor(num):
    cnt = 0
    for i in range(1, n+1):
        if(num % i == 0):
            cnt += 1
    return cnt


n = int(input())
ans = 0

"""if n <= 105:
    if n == 105:
        print(1)
    else:
        print(0)
    sys.exit()"""

for i in range(1, n+1):
    if (divisor(i) == 8 and i % 2 == 1):
        ans += 1
print(ans)


Measured memory_bytes: 63612
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Objects;
import java.util.Scanner;
import java.util.HashMap;

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

    static class DHandstand2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            HashMap<DHandstand2.Pair, Integer> map = new HashMap<>();
            for (int i = 1; i <= n; i++) {
                DHandstand2.Pair p = f(i);
                Integer count = map.putIfAbsent(p, 1);
                if (count != null) {
                    map.put(p, count + 1);
                }
            }

            long ans = 0;
            for (int i = 1; i <= n; i++) {
                DHandstand2.Pair p = f(i);
                DHandstand2.Pair q = new DHandstand2.Pair(p.second, p.first);
                ans += map.getOrDefault(q, 0);
            }

            out.println(ans);
        }

        public DHandstand2.Pair f(int x) {
            int b = x % 10;
            int a = 0;

            while (x > 0) {
                a = x;
                x /= 10;
            }

            return new DHandstand2.Pair(a, b);
        }

        private static class Pair {
            public int first;
            public int second;

            public Pair(int first, int second) {
                this.first = first;
                this.second = second;
            }

            public boolean equals(Object o) {
                if (this == o) return true;
                if (o == null || getClass() != o.getClass()) return false;
                DHandstand2.Pair pair = (DHandstand2.Pair) o;
                return first == pair.first &&
                        second == pair.second;
            }

            public int hashCode() {
                return Objects.hash(first, second);
            }

        }

    }
}



Measured memory_bytes: 43140
import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


int A, B, C;

void main() {
  try {
    for (; ; ) {
      A = readInt();
      B = readInt();
      C = readInt();
      writeln((A == B && A == C) ? "Yes" : "No");
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
	string a, b;
	cin >> a >> b;

	int jud = 3;
	if(a.size() > b.size()) jud = 1;
	else if(a.size() < b.size()) jud = 2;
	else{
		REP(i, a.size()){
			if(a[i] > b[i]){
				jud = 1;
				break;
			} else if(a[i] < b[i]){
				jud = 2;
				break;
			}
		}
	}

	if(jud == 1) cout << "GREATER" << endl;
	else if(jud == 2) cout << "LESS" << endl;
	else cout << "EQUAL" << endl;

	return 0;
}

Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-24 15:27:01
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int64 n; cin >> n;

  // f(2n) = (2 ^ n) * n!

  //n /= 2;

  if (n & 1) {
    cout << 0 << endl;
  } else {
    n /= 2;
    int64 ans = 0;
    while (n > 0) {
      ans += n / 5;
      n /= 5;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

if __name__ == "__main__":
    X, Y, A, B, C = MI()
    p = LI()
    p.sort(reverse=True)
    q = LI()
    q.sort(reverse=True)
    pq = p[:X] + q[:Y] + LI()
    pq.sort(reverse=True)
    print(sum(pq[:X+Y]))

Measured memory_bytes: 23968
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())
#define bitcnt(x) __builtin_popcount(x)

typedef long long ll;

const int MAX = 100010;

ll hs[MAX], N, A, B;

bool check(ll x) {
    vector <ll> h(N);
    ll magic = A-B;
    rep(N, i) h[i] = hs[i]-B*x;
    sort(all(h));
    reverse(all(h));
    ll cnt = 0LL;
    rep(N, i) {
        if (h[i] <= 0) break;
        cnt += (h[i]-1)/magic + 1;
    }
    return cnt <= x;
}

void solve(void){
    cin >> N >> A >> B;
    rep(N, i) scanf("%lld\n", &hs[i]);
    ll ok = 1e9, ng = 0LL;
    while(abs(ok-ng)>1) {
        ll mid = (ok + ng) / 2LL;
        if (check(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 1792
#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> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//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 fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll k,s ;
	cin >> k >> s ;
	ll ans = 0 ;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			ll c = s-i-j ;
			if(c>=0&&c<=k) ans++ ;
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int ln,i;
string st,ts;

int main()
{
    cin>>st;
    ln=st.size();
    for(i=0; i<ln; i++)
    {
        if(st[i]=='b')
            ts='d'+ts;
        if(st[i]=='d')
            ts='b'+ts;
        if(st[i]=='p')
            ts='q'+ts;
        if(st[i]=='q')
            ts='p'+ts;        
    }
    if(st==ts)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 512