akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

const int MAXN=100005;
const int INF=0x3f3f3f3f;

ll sum[MAXN];
ll tot,ans=-INF;
int n,a[MAXN];
bool flag[MAXN];
char s[5];

int main(){
    scanf("%d%d",&n,&a[1]);
    for(int i=2;i<=n;i++){
        scanf("%s%d",s,&a[i]);
        if(s[0]=='-') flag[i]=1;
    }
    for(int i=n;i>=1;i--)
        sum[i]=sum[i+1]+a[i];
    int last=1;
    while(flag[last]==0&&last<=n){
        tot+=a[last];
        last++;
    }
    while(last<=n){
        int last1=last+1;
        ll tot1=0;
        while(flag[last1]==0&&last1<=n){
            tot1+=a[last1];
            last1++;
        }
        if(last1<=n)
            ans=max(ans,tot-tot1-a[last]+sum[last1]);
        tot-=a[last];
        last=last1;
        tot+=tot1;
    }
    ans=max(ans,tot);
    printf("%lld",ans);
}


Measured memory_bytes: 1408
#include <math.h>
#include <iomanip>
#include <iostream>
#include <cstdlib>

using namespace std;

const int MIN = 0;
const int MAX = 20000;

bool isRange(double v)
{
    if ((MIN <= v) && (v <= MAX))
    {
        return true;
    }
    return false;
}

int main()
{
    int a, b, ans;
    char op;

    while (cin >> a >> op >> b)
    {
        if (isRange(a) && isRange(b))
        {
            switch (op)
            {
            case '+':
                ans = a + b;
                 break;
            case '-':
                ans = a - b;
                break;
            case '*':
                ans = a * b;
                break;
            case '/':
                if (b != 0)
                {
                    ans = a / b;
                    break;
                }
                else
                {
                    continue;
                }
            case '?':
                return (0);
            }
            cout << ans << endl;
        }
    }
}

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

#define ran 2022

int n, m;
char s[ran][ran];
int lef[ran][ran], rig[ran][ran], up[ran][ran], down[ran][ran];

int main() {
	scanf("%d%d", &n, &m);
	for(int i=1;i<=n;i++) {
		scanf("%s", s[i]);
		for(int j=m;j>0;j--) s[i][j] = s[i][j-1];
	}
	
	for(int i=1;i<=n;i++) {
		lef[i][0] = 0;
		for(int j=1;j<=m;j++)
			if(s[i][j]=='#') lef[i][j] = j;
			else lef[i][j] = lef[i][j-1];
		rig[i][m+1] = m+1;
		for(int j=m;j>0;j--)
			if(s[i][j]=='#') rig[i][j] = j;
			else rig[i][j] = rig[i][j+1];
	}
	
	for(int j=1;j<=m;j++) {
		up[0][j] = 0;
		for(int i=1;i<=n;i++)
			if(s[i][j]=='#') up[i][j] = i;
			else up[i][j] = up[i-1][j];
			
		down[n+1][j] = n+1;
		for(int i=n;i>0;i--)
			if(s[i][j]=='#') down[i][j] = i;
			else down[i][j] = down[i+1][j];
	}
	
	int ans = 1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(s[i][j]=='.') {
				int x = rig[i][j]-lef[i][j]-1 + down[i][j]-up[i][j]-1;
				ans = max(ans, x);
				// printf("%d %d %d %d %d %d\n", i, j, lef[i][j], rig[i][j], up[i][j], down[i][j]);
			}
	printf("%d\n", ans-1);
	
	return 0;
}

Measured memory_bytes: 67968
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,ss;cin>>s>>ss;
  vector<char>ans(s.size()+ss.size());
  for(int i=0;i<ans.size();i+=2)
    ans[i]=s[i/2];
  for(int i=1;i<ans.size();i+=2)
    ans[i]=ss[i/2];
  for(auto a:ans)cout<<a;
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	s := IOInitialize()
	N := Int(s)
	X := Int(s)
	nums := scanNums(s, N)
	nums = append(nums, X)
	sort.Ints(nums)
	prevNum := nums[0]
	prevN := nums[1] - nums[0]
	for i := 2; i < len(nums); i++ {
		prevN = yuklid(prevN, nums[i]-prevNum)
	}
	fmt.Println(prevN)
}

func yuklid(m, n int) int {
	if n == 0 {
		return m
	}
	return yuklid(n, m%n)
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanNums(s *bufio.Scanner, len int) (nums []int) {
	for i := 0; i < len; i++ {
		num := Int(s)
		nums = append(nums, num)
	}
	return
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		strs = append(strs, str)
	}
	return
}


Measured memory_bytes: 5504
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define MEM(x) memset(x,0,sizeof(x))
#define vc vector<int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define inf 0x3f3f3f3f
#define t_case int tt; cin>>tt; while (tt--)
#define lnginf 9223372036854775807
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define For(i,j,k) for (int i=(int)(j);i<(int)(k);i++)
#define rFor(i,j,k) for (int i=(int)(k-1);i>=(int)(j);i--)
#define ins insert
#define in(x); { for (auto &i : x) cin >> i; }
#define out(x); { for (auto i : x) cout<<i<<' ' ; }
#define pi  pair<int,int>
#define ti tuple<int,int,int>
#define PI 3.14159265359
#define des(x) setprecision(x)
const long long LL_INF = (long long) 2e18 + 5;
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...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
const int N=2e5+10,mod=1e9+7;
vector<int> adj[N];
bitset<N> vis;
set<pi> chk;
int ct=0;
void dfs(int v){
  vis[v]=1;
  ct++;
  for(auto u:adj[v]){
    if(!vis[u])dfs(u);
  }
}
void solve(){
  int n,m; cin>>n>>m;
  For(i,0,m){
    int u,v; cin>>u>>v;
    u--,v--;
    if(chk.count({min(u,v),max(u,v)}))continue;
    chk.ins({min(u,v),max(u,v)});
    adj[u].pb(v),adj[v].pb(u);
  }
  int ans=0;
  For(i,0,n){
    if(!vis[i]){
      ct=0;
      dfs(i);
      ans=max(ans,ct);
    }
  }
  cout<<ans<<'\n';
  
  
}
int32_t main() {

#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
   fastio
   //t_case
    solve();



}

Measured memory_bytes: 36364
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[5];
        for (int i = 0; i < 5; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        int max = 0;
        int sum = 0;
        for (int i = 0; i < 5; i++) {
            int b = ((a[i] / 10) + 1) * 10;
            if (a[i] % 10 == 0) b -= 10;
            sum += b;
            max = Math.max(max, b - a[i]);
        }

        System.out.println(sum - max);

    }
}


Measured memory_bytes: 21840
import sys
sys.setrecursionlimit(10**9)

N, M = map(int, input().split())
inputs = [int(input()) for _ in range(M)]

set_inputs = set(inputs)
mod = 10 ** 9 + 7
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(1, N+1):
    if i in set_inputs:
        continue
    if i == 1:
        dp[i] = dp[i-1]
    else:
        if i - 1 not in set_inputs:
            dp[i] += dp[i-1]
        if i - 2 not in set_inputs:
            dp[i] += dp[i-2]

print(dp[-1] % mod)


Measured memory_bytes: 462744
def set_format(name: int):
    """6桁に揃える"""
    formated_name = "{:0=6}".format(name)
    return formated_name

def main():
    N, M = [int(c) for c in input().split()]
    lists = []
    for i in range(M):
        city = i
        prefecture, year = [int(c) for c in input().split()]
        id_ = ""
        lists.append([city, prefecture, year, id_])

    prefectures = [0] * (N + 1)

    #年のソート
    lists.sort(key=lambda x: x[2])

    for i in range(M):
        # 県名
        prefecture_name = lists[i][1]
        lists[i][3] = set_format(prefecture_name) + set_format(prefectures[prefecture_name] + 1)
        prefectures[prefecture_name] += 1

    lists.sort(key=lambda x: x[0])

    for i in range(M):
        print(lists[i][3])

if __name__ =='__main__':
    main()

Measured memory_bytes: 33028
from collections import deque

H, W, K = map(int, input().split())

mp = [input() for _ in range(H)]
h = deque([[[0],[0]], [[0],[1]], [[1],[0]], [[1],[1]]])

rlt = 0
while h:
  l = h.pop()
  if len(l[0]) == H and len(l[1]) == W:
    k = 0
    for i in range(H):
      if l[0][i] == 1:
        continue
      for j in range(W):
        if mp[i][j] == '#' and l[1][j] == 0:
          k += 1
    if k == K:
      rlt += 1
  else:
    if len(l[0]) < H and len(l[1]) < W: 
      for m in [0,1]:
        for n in [0,1]:
          h.append([l[0] + [m],l[1]+[n]])
    elif len(l[0]) == H:
      for n in [0,1]:
        h.append([l[0],l[1]+[n]])
    else:
      for m in [0,1]:
        h.append([l[0]+[m],l[1]])
        
print(rlt)

Measured memory_bytes: 68864
#include<stdio.h>
int prev[ 200000 + 1 ] ,next[ 200000 + 1 ] ;
int main()
{
	int n ,m ,q ;
	int a , r ,p = 0 ;
	int i ,j ;
	scanf( "%d %d %d", &n , &m , &q ) ;
	for( i = 0 ; i < n ; i++ )
	{
		prev[ i ] = ( i - 1 + n ) % n ;
		next[ i ] = ( i + 1 ) % n ;
	}
	for( i = 0 ; i < m ; i++ )
	{
		scanf( "%d", &a ) ;
		for( j = 0 ; j < a ; j++ )
		{
			p = a % 2 == 0 ? next[ p ] : prev[ p ] ;
		}
		r = p ;
		next[ prev[ p ] ] = next[ p ] ;
		prev[ next[ p ] ] = prev[ p ] ;
		p = next[ p ] ;
		next[ r ] = -1 ;
		prev[ r ] = -1 ;
	}
	for( i = 0 ; i < q ; i++ )
	{
		scanf( "%d", &a ) ;
		if( prev[ a ] == -1 )
		{
			printf( "0\n" ) ;
		}
		else
		{
			printf( "1\n" ) ;
		}
	}
	return 0 ;
}

Measured memory_bytes: 4112
#include<stdio.h>
#define min(x,y) (x<y?x:y)
int c11,c12,c13,c21,c22,c23,c31,c32,c33,a1,a2,a3,b1,b2,b3;
main()
{
	scanf("%d%d%d%d%d%d%d%d%d",&c11,&c12,&c13,&c21,&c22,&c23,&c31,&c32,&c33);
	for(a1=0;a1<=min(c11,min(c12,c13));++a1)
	{
		b1=c11-a1;
		b2=c12-a1;
		b3=c13-a1;
		for(a2=0;a2<=min(c21,min(c22,c23));++a2)
		{
			if(a2+b1!=c21)continue;
			if(a2+b2!=c22)continue;
			if(a2+b3!=c23)continue;
			for(a3=0;a3<=min(c31,min(c32,c33));++a3)
			{
				if(a3+b1!=c31)continue;
				if(a3+b2!=c32)continue;
				if(a3+b3!=c33)continue;
				puts("Yes");return 0;
			}
		}
	}
	puts("No");
}/**/

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int adj[101][101];
int d[101][101];

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(i == j) adj[i][j] = 0;
			else adj[i][j] = INF;
		}
	}
	vector<int> e1;
	vector<int> e2;
	for(int i=0; i<m; i++){
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		adj[a][b] = adj[b][a] = c;
		e1.push_back(a);
		e2.push_back(b);
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			d[i][j] = adj[i][j];
		}
	}

	for(int k=0; k<n; k++){
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}


	int ans = 0;
	for(int i=0; i<m; i++){
		int es = e1[i];
		int ee = e2[i];
		for(int j=0; j<n; j++){
			for(int k=0; k<n; k++){
				if(d[j][es] + adj[es][ee] + d[ee][k] == d[j][k]){
					ans++;
					j = n;
					break;
				}
			}
		}
	}

	cout << m - ans << endl;

	
	return 0;
}


Measured memory_bytes: 384
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)

main() {
    int n = 0;
    char c;
    while(1) {
        c = getchar_unlocked();
        if(c!='\n')
            n = n * 10 + c - '0';
        else
            break;
    }
    int sqrtN = sqrt(n);
    ll ans = 0;
    ll d = (ll)(sqrtN) * (sqrtN + 1) * (2 * sqrtN + 1) / 6;
    rep2(i, 1, sqrtN) { ans += (i * (i + (n / i)) * ((n / i) + 1 - i)); }
    ans -= d;
    char wr[15];
    char *w = wr;
    while(ans) {
        *w = ans % 10 + '0';
        ans /= 10;
        w++;
    }
    while(1) {
        w--;
        putchar_unlocked(*w);
        if(w == wr) break;
    }
}

Measured memory_bytes: 3660
#include <cstdio>
#include <string>
#include <vector>
using namespace std;

int m, n, k;
vector<string> v;
char t[1001];
int dp[1000][1000][3];

void solve(int a, int b, int c, int d){
	int j=0, o=0, i=0;
	for(int x=a-1; x<c; x++){
		for(int y=b-1; y<d; y++){
			if(v[x][y] == 'J') j++;
			else if(v[x][y] == 'O') o++;
			else i++;
		}
	}
	printf("%d %d %d\n", j, o, i);
}

int main(){
	scanf("%d %d %d", &m, &n, &k);
	for(int i=0; i<m; i++){
		scanf("%s", t);
		v.push_back(t);
	}
/*	int a, b, c, d;
	for(int i=0; i<k; i++){
		scanf("%d %d %d %d", &a, &b, &c, &d);
		solve(a, b, c, d);
	}
*/	if(v[0][0] == 'J') dp[0][0][0] = 1;
	else if(v[0][0] == 'O') dp[0][0][1] = 1;
	else dp[0][0][2] = 1;
	for(int i=1; i<n; i++){
		for(int j=0; j<3; j++){
			dp[i][0][j] += dp[i-1][0][j];
		}
		if(v[0][i] == 'J') dp[i][0][0] += 1;
		else if(v[0][i] == 'O') dp[i][0][1] += 1;
		else dp[i][0][2] += 1;
	}
	for(int i=1; i<m; i++){
		for(int j=0; j<3; j++){
			dp[0][i][j] += dp[0][i-1][j];
		}
		if(v[i][0] == 'J') dp[0][i][0] += 1;
		else if(v[i][0] == 'O') dp[0][i][1] += 1;
		else dp[0][i][2] += 1;
	}
	for(int i=1; i<n; i++){
		for(int j=1; j<m; j++){
			for(int l=0; l<3; l++){
				dp[i][j][l] = dp[i-1][j][l] + dp[i][j-1][l] - dp[i-1][j-1][l];
			}
			if(v[j][i] == 'J') dp[i][j][0] += 1;
			else if(v[j][i] == 'O') dp[i][j][1] += 1;
			else dp[i][j][2] += 1;
		}
	}
/*
	for(int i=0; i<m; i++){
		for(int j=0; j<n; j++){
			printf("%d\t", dp[j][i][0]);
		}
		printf("\n");
	}
*/
	int a, b, c, d;
	for(int i=0; i<k; i++){
		scanf("%d %d %d %d", &a, &b, &c, &d);
		int ans[3];
		if(a == 1 && b == 1)
			for(int j=0; j<3; j++)
				ans[j] = dp[d-1][c-1][j];
		else if(a == 1 && b != 1)
			for(int j=0; j<3; j++)
				ans[j] = dp[d-1][c-1][j] - dp[b-2][c-1][j];
		else if(a != 1 && b == 1)
			for(int j=0; j<3; j++)
				ans[j] = dp[d-1][c-1][j] - dp[d-1][a-2][j];
		else
			for(int j=0; j<3; j++)
				ans[j] = dp[d-1][c-1][j] - dp[d-1][a-2][j] - dp[b-2][c-1][j] + dp[b-2][a-2][j];
		printf("%d %d %d\n", ans[0], ans[1], ans[2]);
	}
	return 0;
}

Measured memory_bytes: 15100
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>arr(n);
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	vector<int>dp(n,0);
	dp[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
  
using namespace std;
  
int main()
{
    int d;
  
    while (~scanf("%d", &d)) {
        int ans = 0;
        for (int a = d; a <= 600 - d; a += d) ans += a * a * d;
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 1188
#include<iostream>
#include<algorithm>
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<cctype>
#include<cmath>
#include<vector>
#include<climits>
#include<queue>

using namespace std;


int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        if(n<1200)
            printf("ABC\n");
        else if(n>=1200&&n<2800)
            printf("ARC\n");
        else
            printf("AGC\n");
    }
    return 0;
}


Measured memory_bytes: 256
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    char C;
    cin >> C;
    C = (char)C + 1;

    cout << C << endl;
}

Measured memory_bytes: 256
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>


using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
const string FILENAME = "input";
const int MAXN = 200228;


int h, w, n;
string s, t;
int sx, sy;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//read(FILENAME);
	cin >> h >> w >> n;
	cin >> sx >> sy;
	cin >> s >> t;
	int cur = 0;
	int cur1 = 0;
	int cur2 = 0;
	int cur3 = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'L') {
			cur++;
		} else if (s[i] == 'R') {
			cur1++;
		}
		if (sy - cur + cur2 < 1 || sy + cur1 - cur3 > w) {
			cout << "NO\n";
			return 0;
		}
		if (t[i] == 'L') {
			cur3++;
			chkmin(cur3, sy + cur1 - 1);
		} else if (t[i] == 'R') {
			cur2++;
			chkmin(cur2, w - sy + cur);
		}
	}
	cur = 0;
	cur1 = 0;
	cur2 = 0;
	cur3 = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'U') {
			cur++;
		} else if (s[i] == 'D') {
			cur1++;
		}
		if (sx - cur + cur2 < 1 || sx + cur1 - cur3 > h) {
			cout << "NO\n";
			return 0;
		}
		if (t[i] == 'U') {
			cur3++;
			chkmin(cur3, sx + cur1 - 1);
		} else if (t[i] == 'D') {
			cur2++;
			chkmin(cur2, h - sx + cur);
		}
	}
	cout << "YES\n";
	return 0; 	
}

Measured memory_bytes: 920
#include <bits/stdc++.h>
using namespace std;
int main(){
  double a,b;
  cin >> a >> b;
  int u=(a+b+1)/2;
  int l=(a+b)/2;
  int m=(u-l)%1;
  int r=(a+b+1 - m)/2;
  cout << r << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

void solve() {
    std::string s, t;
    std::cin >> t >> s;

    int n = s.length(),
        m = t.length();

    int ans = n;
    for (int l = 0; l + n <= m; ++l) {
        int cnt = 0;
        for (int i = 0; i < n; ++i) {
            if (s[i] != t[l + i]) ++cnt;
        }
        ans = std::min(ans, cnt);
    }

    std::cout << ans << "\n";
}

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

    solve();

    return 0;
}


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

using namespace std;

int main()
{
  int n,c=0;
  string s;
  cin >> n >> s;
  if (n%2 !=0)
  {
    cout << "No";
  }
  else
  {
    for (int i=0;i<n/2;i++)
      {
        if (s[i] != s[n/2 + i])
        {
          c++;
        }
      }
    if (c==0)
     {
       cout << "Yes";
     }
    else
     {
       cout << "No";
     }
   } 
}  
  
    

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

int main() {
  string str;
  string res;
  int len;
  cin >> len;
  cin >> str;
  
  for (int i = 0; i < str.size();i++){
    if (i >= len){
     res += "...";
       break;
    }
    res += str.at(i);
  }
  cout << res << endl;
}

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

int main(){
    int N;
    scanf("%d", &N);
    set<long long> S;
    for(int i = 0; i < N; i++){
        long long A;
        scanf("%lld", &A);
        if(S.count(A))S.erase(A);
        else S.insert(A);
    }
    printf("%lld\n", S.size());
    return 0;
}

Measured memory_bytes: 4864
#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>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 262144
#define REP(i,n) for(long long i = 0;i < n;++i)
long long dp[300000] = {};
long long M[300000] = {};
int main() {
	int n, m;
	cin >> n >> m;
	long long summer = 0;
	REP(i, n) {
		int a;
		cin >> a;
		summer += a;
		dp[a]++;
	}
	for (int i = 200000; i >= 0; --i) {
		dp[i] += dp[i + 1];
	}
	REP(i, m) {
		int a;
		cin >> a;
		M[a]++;
	}
	long long ans = 0;
	for (int i = 2; i <= 200000; ++i) {
		if (M[i] == 0) continue;
		ans += summer * M[i];
		for (int q = 1; i * q <= 200000; ++q) {
			ans -= i * dp[i * q] * M[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6200
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

using namespace std;
typedef long long unsigned int ll;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22)cout << "bust";
	else cout << "win";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const ll 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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main(){
  ll n,k;
  cin >>n>>k;
  mint sum=0;
  vector<mint> v(k+1);  
  rep1(i,k){
    mint s=k/i;
    v[i]=s.pow(n);
  }
  
  for(int i=k; i>=1;--i){
    int maxM=k/i;   
    for(int j=2;j<=maxM;++j){
        v[i]-=v[j*i];
    }
    sum+=v[i]*i;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3968
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>

#include <tuple>
#include <functional>
#include <map>
using namespace std;

int n; string s;
vector<int> d;

// j, j+1
tuple<int, int, int , int > cnt(int j) {
    int lw = d[j];
    int le = j-lw;
    int rw = d[n] - d[j];
    int re = n-j-rw;
    return make_tuple(lw,le,rw, re);
}

int main() {
    cin >> n>>s;
    d.resize(n+1);
    d[0] = 0;
    for (int i = 1; i <= n; ++i) {
        int p = 0;
        if (s[i-1] == 'W') p = 1;
        d[i] = d[i-1] + p;
    }
    int m = INT_MAX/3;
    for (int j = 1; j <=n ; ++j) {
        int ans = get<0>(cnt(j-1)) + get<3>(cnt(j));
        m = min(m, ans);
    }
    cout << m <<endl;

    return 0;
}


Measured memory_bytes: 1924
"use strict"

function main(input) {
  let dataList = input.split("\n");
  dataList.shift();
  dataList.pop();
  let restaurants = dataList.map((data, index) => {
    const tmp = data.split(" ")
    return { index: index + 1, city: tmp[0], score: parseInt(tmp[1]) }
  });
  restaurants.sort(function (a, b) {
    if (a.city < b.city) return -1
    if (a.city > b.city) return 1
    if (a.score < b.score) return 1
    if (a.score > b.score) return -1
  });
  restaurants.forEach(restaurant => {
    console.log(restaurant.index);
  });
} 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,M;
  cin >> N >> M;
  string S;
  cin >> S;
  int now = N;
  stack<int> q;
  rep(i,P)
  {
    if(now<=M)
    {
      q.push(now);
      break;
    }
    rep(j,M)
    {
      if(S[now-M+j]=='0')
      {
        now -= M;
        now += j;
        q.push(M-j);
        break;
      }
      else if(j==M-1)
      {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  while(!q.empty())
  {
    cout << q.top();
    q.pop();
    if(!q.empty())
    {
      cout << " " ;
    }
    else
    {
      cout << endl;
    }
  }
  return 0;
}


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

int x(int a){
  if(a>0) return 1;
  else return 0;
}

int main(){
  string s;
  cin >> s;
  int N=0,W=0,S=0,E=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='N') N++;
    if(s.at(i)=='W') W++;
    if(s.at(i)=='S') S++;
    if(s.at(i)=='E') E++;
  }
  int ans=1;
  ans*=((x(N)+x(S)+1)%2);
  ans*=((x(W)+x(E)+1)%2);
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i=0;i<t;i++)
#define ll long long int
#define ld long double
#define umpl unordered_map<ll,ll> 
#define vl vector<ll>
#define vld vector<ld>
#define vvl vector<vl>
#define pb push_back
#define mod 998244353
#define inf 1e18
#define pcout(x,p) cout<<fixed<<setprecision(p)<<x
#define all(a) a.begin(),a.end()
#define endl "\n"

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}

struct comp { 
    template<class T1,class T2,class T3,class T4>
    bool operator()(const pair<T1,T2> &p1,const pair<T3,T4> &p2){
        return p1.first<p2.first;
    }
}; 


int main(){
	ll a,b,c;cin>>a>>b>>c;
	ll k;cin>>k;
	while(b<=a && k>0){
		b=b*2;k--;
	}		
	if(b<=a){
		cout<<"No"<<endl;
	}else{
		while(c<=b && k>0){
			c=c*2;k--;
		}
		if(c<=b){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
		}
	}
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n,m,q;
  int dst[501][501]={};
  int x,y;
  cin>>n>>m>>q;
  for(int i=0;i<m;i++){
    cin>>x>>y;
    dst[x][y]++;
  }
  // i行j列更新
  for(int i=1;i<=n;i++){
    for(int j=i;j<=n;j++){
      dst[i][j]+=dst[i][j-1];
    }
  }
  for(int i=n-1;i>0;i--){
    for(int j=i;j<=n;j++){
      dst[i][j]+=dst[i+1][j];
    }
  }
  for(int i=0;i<q;i++){
    cin>>x>>y;
    cout<<dst[x][y]<<endl;
  }
}


Measured memory_bytes: 1920
#include <stdio.h>
int a,b,c,d;
int myabs(int i){ return ( i < 0)? -i : i; }
int main(void){
    // Your code here!
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(myabs(a-c) > d && (myabs(b-c) > d || myabs(a-b) > d) ){
        puts("No");
    }else puts("Yes");
}

Measured memory_bytes: 128
import collections
import math

S = list(input())

count = dict(collections.Counter(S))
m = list(count.values())

if len(m) == 1 and len(S) == 1: # 文字1種類のとき
    print("YES")
elif len(m) == 1 and len(S) > 1:
    print("NO")
elif len(m) == 2 and len(S) == 2:
    print("YES")
elif len(m) == 2 and len(S) > 2:
    print("NO")
elif (max(m) - min(m)) <= 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 4340
#include<stdio.h>

int main()
{
	char *w[]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
	int day[12]={31,29,31,30,31,30,31,31,30,31,30,31},m,d,i,t,x;
	while(1)
	{
		t=0;
		scanf("%d%d",&m,&d);
		if(m==0)
			return 0;
		for(i=0;i<m-1;i++)
			t+=day[i];
		x=(t+d)%7-1;
		printf("%s\n",w[x>=0?x:6]);
	}
	return 0;
}

Measured memory_bytes: 584
#include <stdio.h>
#include <string.h>
  
int main(void)
{
    char str[400];
    int count[100];
    int n,i,j=0;
     
    while(1){
        scanf("%s",str);
        if(str[0]=='-'){
            break;
        }
        scanf("%d",&n);
        for(i=0;i<n;i++){
            scanf("%d",&count[i]);
        }
        for(i=0;i<n;i++){
            strncat(str,str,count[i]);
            int j=0;
            while(str[j] != '\0'){
                str[j] = str[j + count[i]];
                j++;
            }
        }
        printf("%s\n",str);
    }
    return 0;
}

Measured memory_bytes: 592
#include <stdio.h>

int main(){
    int i, N;
    
    scanf("%d",&N);
    for(i = 1 ; i <2000000 ; i = i*2){
        if (N - i< 0) printf("%d\n",i/2); 
        if (N - i< 0) break;
    }
    return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<bool>	vb;



void solve(){
	ll n;
	cin >> n;
	vll f(n + 1,0);
	rep(i,1,100){
		rep(j,1,100){
			rep(k,1,100){
				ll x = ((i + j)*(i + j) + (k + j)*(k + j) + (i + k)*(i + k))/2;
				if(x <= n) f[x]++;
			}
		}
	}
	rep(i,1,n + 1){
		cout << f[i] << endl;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t = 1;
	// cin >> t;
	rep(i,0,t){
		solve();
	}

}

Measured memory_bytes: 3684
#include <iostream>

using namespace std;

int main()
{
  while (true)
  {
    int x, y;
    cin >> x >> y;
    if (x || y)
      if (x < y)
        cout << x << " " << y << endl;
      else
        cout << y << " " << x << endl;
    else
      return 0;
  }
}

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

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<pll> vpll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef unordered_map<ll,ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false);cout<<fixed;cout<<setprecision(0);
#define sqr(x) ((ll)(x) * (x))
#define reset(a, b) memset(a, b, sizeof(a))
#define FOR(i,a,b,c) for(ll i=a;i<b;i+=c)
#define FORD(i,a,b,c) for(ll i=a;i>b;i-=c)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define allr(arr, r) arr, arr + r
#define showv(v) for(auto it: (v))cout<<it<<" ";newl;
#define showvp(v) for(auto it: (v)){cout<<it.F<<" "<<it.S;newl;}
#define show2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define printv(v) for(auto it: (v)) {cout<<it;newl;}
#define newl cout<<"\n"
#define N 100000


const ll MAXN=1e+2+7;
const ll MOD=1e+9+7, INF=0x7f7f7f7f7f7f7f7f;const int INFi=0x7f7f7f7f;
double EPS = 1e-9;
double PI = acos(-1);
/*
vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/

//<<-----Declare Variables Here------->>//;
ll n,temp;
vvll dp;
vll v;
//<<-----Define Functions Here------->>//;
//<<-----Start of Main--------------->>//
int main()
{
	fastio;
	cin>>n;

	FOR(i,0,n,1)
	{
	    cin>>temp;
	    v.pb(temp);
	}

	if(n==2)
    {
        cout<<abs(v[0]-v[1]);return 0;
    }
    else
    {
        dp.resize(n-1,vll(2,-1));
        dp[n-2][0]=abs(v[n-2]-v[n-1]);

        FORD(i,n-3,-1,1)
        {
            FOR(j,0,2,1)
            {
                dp[i][j]=abs(v[i]-v[i+j+1]);
                if(i+j+1<n-1)
                {
                    if(dp[i+j+1][1]==-1)
                        dp[i][j]+=dp[i+j+1][0];
                    else
                        dp[i][j]+=min(dp[i+j+1][0],dp[i+j+1][1]);
                }
            }
        }
    }
	cout<<min(dp[0][0],dp[0][1]);
}

Measured memory_bytes: 6516
using System.Linq;
using System.Collections.Generic;
using System;

public class S : IComparable
{
    public int from { get; set; }
    public int to { get; set; }
    public int id { get; set; }
    public int CompareTo(object obj)
    {
        var x = (S)obj;
        if (this.from > x.from) return 1;
        else if (this.from == x.from) return 0;
        else return -1;
    }
}

public class Hello
{
    public static void Main()
    {
        var first = true;  
        while (true)
        {
            if (first) first = false;
            else Console.WriteLine();
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var ss = new List<S>();
            ss.Add(new S { from = 0, to = 1000000000 ,id = -1});
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                var cmd = line[0];
                if (cmd == "W")
                {
                    var id = int.Parse(line[1]);
                    var a = int.Parse(line[2]);
                    cmdW(ss, id, a);
                }
                else if (cmd == "D")
                {
                    var id = int.Parse(line[1]);
                    cmdD(ss, id);
                }
                else
                {
                    var p = int.Parse(line[1]);
                    Console.WriteLine(cmdR(ss,p ));
                }
            }
        }
    }
    public static int cmdR (List<S> ss, int p )
    {
        var a = ss.Where(x => x.from <= p && x.to >= p).First();
        return a.id;
    }
    public static void cmdD (List<S> ss, int id)
    {
        foreach (var x in ss.Where(y => y.id == id))
            x.id = -1;
    }
    public static void cmdW (List<S> ss , int id , int a)
    {
        var w = new S();
        var write = false;
        foreach (var x in ss.Where(y =>y.id == -1))
        {
            if (x.to - x.from + 1 > a)
            {
                w.to = x.to;
                x.to = x.from + a - 1;
                w.id = x.id;
                x.id = id;
                w.from = x.to + 1;
                write = true;
                break;
            }
            else if (x.to - x.from + 1 == a) { x.id = id; break; }
            else { x.id = id; a -= x.to - x.from + 1; }
        }
        if (write) ss.Add(w);
        ss.Sort();
    }
}




Measured memory_bytes: 10124
fun main(args: Array<String>) {
    val N = readLine()!!.toLong()

    if (N % 2 == 1L) {
        println(0)
        return
    }

    if (N == 0L) {
        println(0)
        return
    }

    val a = func(N, 2L)
    val b = func2(N, 5L)

    println(Math.min(a, b))
}

private fun func(N: Long, p: Long): Long {
    var res = 0L
    var a = p

    while (a <= N) {
        res += N / a
        a *= p
    }
    return res
}

private fun func2(N: Long, p: Long): Long {
    var res = 0L
    var a = p * 2L

    while (a <= N) {
        res += N / a
        a *= p
    }
    return res
}


Measured memory_bytes: 33660
#include <iostream>
#include <queue>

using namespace std;

int n;
int m;

priority_queue <int> que;
vector <int> t[100005];

int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1, c, v; i <= n; ++i) {
    cin >> c >> v;
    if (m - c + 1 >= 1) {
      t[m - c + 1].push_back(v);
    }
  }


  int ans = 0;
  for (int i = m; i >= 1; --i) {
    for (int j = 0; j < (int)t[i].size(); ++j) {
      que.push(t[i][j]);
    }
    if (!que.empty()) {
      ans += que.top();
      que.pop();
    }
  }

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

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

int main()
{
    uint64_t n;
    cin >> n;

    if (n % 2 == 1)
    {
        cout << 0 << endl;
        return 0;
    }

    n /= 2;
    uint64_t ans = 0;
    while (n > 0)
    {
        ans += n / 5;

        n /= 5;
    }

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

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static String I = "IMPOSSIBLE";
	public static String B = "Bad";
	public static String G = "Good";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		long x = nl();
		long y = nl();

		long xx = x;

		int i = 0;

		for (i = 1;; i++) {
			xx = xx * 2;
			if (xx > y) {
				break;
			}
		}

		out(i);
	}

	public static int count(String search, String text) {
		int nsearch = search.length();
		int ntext = text.length();
		int count = 0;

		for (int i = 0; i <= ntext - nsearch + 1; i++) {
			for (int j = i + nsearch - 1; j < ntext; j++) {
				if (search.equals(text.substring(i, j + 1))) {
					count++;
				}
			}
		}

		return count;
	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

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

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

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 21844
# ABC093 C - Same Integers
abc = list(map(int, input().split()))
m = max(abc)
abc = [m-x for x in abc] 

abc.sort()
m = max(abc)
ans = 0

while m > 0:
    abc.sort()
    if m >= 2:
        abc[2] -= 2
        ans += 1
        m = max(abc)
    elif m == 1:
        if abc.count(1)==3:
            ans += 1
            print(ans)
            exit()
        elif abc.count(1)==2:
            abc[2] -= 1
            abc[1] -= 1
            ans += 1
            m = max(abc)
        elif abc.count(1)==1:
            ans += 2
            print(ans)
            exit()
print(ans)


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

void algorithm() {
    int n, a, alice=0, bob=0;
    vector<int> cards;
    cin >> n;
    while(cin >> a) {
        auto j = cards.begin();
        for(auto i=cards.begin(); i < cards.end() && *i > a; i++) j=i+1;
        cards.insert(j, a);
    }
    for(int i=0; i<cards.size(); i++){
        if(i%2==0) alice+=cards[i];
        else bob += cards[i];
    }
    cout << alice - bob << endl;
}

int main()
{   
    algorithm();
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <map>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

typedef int Weight;
struct Edge {
  int src;
  int dest;
  Weight weight;
  Edge(int src, int dest, Weight weight) : src(src), dest(dest), weight(weight) {;}
  bool operator<(const Edge &rhs) const {
    if (weight != rhs.weight) { return weight > rhs.weight; }
    if (src != rhs.src) { return src < rhs.src; }
    return dest < rhs.dest;
  }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void PrintMatrix(const Matrix &matrix) {
  for (int y = 0; y < (int)matrix.size(); y++) {
    for (int x = 0; x < (int)matrix[y].size(); x++) {
      printf("%d ", matrix[y][x]);
    }
    puts("");
  }
}


Weight Dijkstra(const Graph &g, int s, int t) {
  const int n = g.size();
  vector<bool> visit(n, false);
  Array dist(n, 2000000000LL);
  priority_queue<Edge> que;
  que.push(Edge(s, s, 0));
  Weight ans = -1;
  dist[s] = 0;
  while (!que.empty()) {
    Edge edge = que.top();
    que.pop();
    int from = edge.dest;
    if (visit[from]) { continue; }
    visit[from] = true;
    if (from == t) {
      ans = edge.weight;
      break;
    }   
    for (int i = 0; i < (int)g[from].size(); i++) {
      int to = g[from][i].dest;
      Weight ncost = edge.weight + g[from][i].weight;
      if (visit[to] || ncost >= dist[to]) { continue; }
      dist[to] = ncost;
      que.push(Edge(from, to, ncost));
    }   
  }
  return ans;
}

int n, m;
int main() {
  while (cin >> n >> m, n|m) {
    int k = 0;
    Graph g(n);
    map<string, int> mapto;
    {
      string from, mid, to;
      cin >> from >> mid >> to;
      mapto[from] = k++;
      mapto[mid] = k++;
      mapto[to] = k++;
    }
    REP(i, m) {
      string from, to;
      int dist, t;
      cin >> from >> to >> dist >> t;
      if (!mapto.count(from)) { mapto[from] = k++; }
      if (!mapto.count(to)) { mapto[to] = k++; }
      int f = mapto[from];
      int d = mapto[to];
      dist = dist / 40 + t;
      g[f].push_back(Edge(f, d, dist));
      g[d].push_back(Edge(d, f, dist));
    }
    printf("%d\n", Dijkstra(g, 0, 1) + Dijkstra(g, 1, 2));
  }
}

Measured memory_bytes: 1164
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if(w == 0 && h == 0) break;
			else calc(w,h);
		}
	}
	public void calc(int w, int h){
		int[][] map = new int[w][h];
		int[][] blacks = new int[w][h];
		int[][] whites = new int[w][h];
		ArrayList<int[]> wList = new ArrayList<int[]>();
		ArrayList<int[]> bList = new ArrayList<int[]>();
		for(int i = 0; i < h; i++){
			String next = sc.next();
			for(int j = 0; j < w; j++){
				char c = next.charAt(j);
				if(c == 'W'){
					map[j][i] = 1;
					blacks[j][i] = 1;
					wList.add(new int[]{j, i});
				}
				else if(c == 'B'){
					map[j][i] = -1;
					bList.add(new int[]{j, i});
					whites[j][i] = 1;
				}
			}
		}
		
		
		while(!wList.isEmpty()){
			int nowW = wList.get(0)[0];
			int nowH = wList.get(0)[1];
			wList.remove(0);
			
			if(nowW > 0 && map[nowW-1][nowH] == 0 &&  whites[nowW-1][nowH] == 0){
				whites[nowW-1][nowH] = 1;
				wList.add(new int[]{nowW-1, nowH});
			}
			if(nowW < w-1 && map[nowW+1][nowH] == 0 && whites[nowW+1][nowH] == 0){
				whites[nowW+1][nowH] = 1;
				wList.add(new int[]{nowW+1, nowH});
			}
			if(nowH > 0 && map[nowW][nowH-1] == 0 &&  whites[nowW][nowH-1] == 0){
				whites[nowW][nowH-1] = 1;
				wList.add(new int[]{nowW, nowH-1});
			}
			if(nowH < h-1 && map[nowW][nowH+1] == 0 && whites[nowW][nowH+1] == 0){
				whites[nowW][nowH+1] = 1;
				wList.add(new int[]{nowW, nowH+1});
			}
			
		}
		while(!bList.isEmpty()){
			int nowW = bList.get(0)[0];
			int nowH = bList.get(0)[1];
			bList.remove(0);
			
			if(nowW > 0 && map[nowW-1][nowH] == 0 &&  blacks[nowW-1][nowH] == 0){
				blacks[nowW-1][nowH] = 1;
				bList.add(new int[]{nowW-1, nowH});
			}
			if(nowW < w-1 && map[nowW+1][nowH] == 0 && blacks[nowW+1][nowH] == 0){
				blacks[nowW+1][nowH] = 1;
				bList.add(new int[]{nowW+1, nowH});
			}
			if(nowH > 0 && map[nowW][nowH-1] == 0 &&  blacks[nowW][nowH-1] == 0){
				blacks[nowW][nowH-1] = 1;
				bList.add(new int[]{nowW, nowH-1});
			}
			if(nowH < h-1 && map[nowW][nowH+1] == 0 && blacks[nowW][nowH+1] == 0){
				blacks[nowW][nowH+1] = 1;
				bList.add(new int[]{nowW, nowH+1});
			}
			
		}
		
		
		int black = 0;
		int white = 0;
		for(int i = 0; i < w; i++){
			for(int j = 0; j < h; j++){
				if(map[i][j] == 0 && 
						((blacks[i][j] == 1 && whites[i][j] == 0) || (blacks[i][j] == 0 && whites[i][j] == 1)) ){
					if(blacks[i][j] == 1) black++;
					else white++;
				}
			}
		}
		System.out.println(black + " "+ white);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 32192