akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
    static tree[] wd;
	public static void main(String[] args) {
	    int x,i,j,n,pn,swi=0,root = 0,hz;
	// TODO Auto-generated method stub
     Scanner sca = new Scanner(System.in);
     n=sca.nextInt();
     wd=new tree[n];
    for(j=0;j<n;j++){
    	x=sca.nextInt();
	if(j==0)root=x;
    	pn=sca.nextInt();
	wd[x]=new tree(x,pn);
    	for(i=0;i<pn;i++) {
	    hz=sca.nextInt();
	    if(hz==root) root=x;
	    wd[x].setchil(hz,i);
    	}
    	if(swi==0&&pn!=0){
    		swi=-1;
    		root=x;
    	}
    }
    chain(root,-1);
     for(i=0;i<n;i++){
    	 System.out.print("node "+i+": parent = "+ wd[i].getpar()+", depth = "+serdepth(i,0)+", ");
	 if(wd[i].getpar()==-1){
    	System.out.print("root, [");
	 }else if(wd[i].getn()==0){
    	 System.out.print("leaf, [");
    	}else{
    		System.out.print("internal node, [");
    	}
	 for(j=0;j<wd[i].getn();j++){
	     System.out.print(wd[i].getchil(j));
	     if(j+1<wd[i].getn()){
    			System.out.print(", ");
    		}
    	}
	   System.out.println("]");	   
   
     }
	}
    public static void chain(int chi,int p){
	int i;
	wd[chi].setpar(p);
	if(wd[chi].getn()==0)return;
	for(i=0;i<wd[chi].getn();i++){
	    chain(wd[chi].getchil(i),chi);
	}
	}
	public static int serdepth(int x,int cnt){
	    if(wd[x].getpar()==-1)return cnt;
		cnt++;
		return serdepth(wd[x].getpar(),cnt);
	}
    
}
class tree{
    int node,par,n,i;
    int[]children;
    tree(int node,int n){
	this.n=n;
	this.node=node;
	children= new int[n];
    }
    public void setchil(int c,int p){
	children[p]=c;
    }
    public int getchil(int c){
	return children[c];
    }
    public void setpar(int p){
	par=p;
    }
    public int getpar(){
	return par;
    }
    public int getn(){
	return n;
    }
    
}


Measured memory_bytes: 135348
a_list=[1,3,5,7,8,10,12]
b_list=[4,6,9,11]
c_list=[2]
x,y=map(int,input().split())
print("Yes" if (x in a_list and y in a_list) or (x in b_list and y in b_list) or (x in c_list and y in c_list) else "No")

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


int a, b, c; 

int main() { 
  scanf("%d %d %d", &a, &b, &c);
  if (a % 2 && b % 2) {
    cout << "Yes"; 
  } else {
    cout << "No";
  }
  return 0;
} 

Measured memory_bytes: 256
//Airplane.cpp



#include <iostream>
#include <vector>
#include <math.h>
#include <string>

using namespace std;

int main()
{
    int P,Q,R;

    cin >> P >> Q >> R;

    int max = 0;

    max = P > Q ? P : Q;
    max = max > R ? max : R;

    int result = P + Q + R - max;

    cout << result << endl;

    return 0;
}

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

const long long mod = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	vector<int> T(N), A(N);
	
	for(int i = 0; i < N; ++i) 
		cin >> T[i];
	for(int i = 0; i < N; ++i)
		cin >> A[i];

	if(N == 1)
	{
		if(T[0] != A[0])
			cout << 0 << endl;
		else
			cout << 1 << endl;
		return 0;
	}
	vector<pair<int, bool>> real1(N, {0, false}), real2(N, {0, false});

	real1[0] = {T[0], true};
	real2[N-1] = {A[N-1], true};

	for(int i = 1; i < N; ++i)
	{
		if(T[i] > T[i-1])
		{
			real1[i] = {T[i], true};
		}
		else
		{
			real1[i] = {T[i], false};
		}
		if(A[N-i-1] > A[N-i])
		{
			real2[N-i-1] = {A[N-i-1], true};
		}
		else
		{
			real2[N-i-1] = {A[N-i-1], false};
		}
	}
	long long res = 1;
	for(int i = 0; i < N; ++i)
	{
		//cout << real1[i].first << (real1[i].second ? "T" : "F") << '\t' << real2[i].first << (real2[i].second ? "T" : "F") << endl;
		if(real1[i].second == true)
		{
			if(real2[i].second == true)
			{
				if(real1[i].first != real2[i].first)
				{
					//cout << "first" << endl;
					cout << 0 << endl;
					return 0;
				}
			}
			else
			{
				if(real2[i].first < real1[i].first)
				{
					//cout << "second" << endl;
					cout << 0 << endl;
					return 0;
				}
			}
		}
		else if(real2[i].second == true)
		{
			if(real1[i].first < real2[i].first)
			{
				//cout << "third" << endl;
				cout << 0 << endl;
				return 0;
			}
		}
		else
		{
			long long val = min(real1[i].first, real2[i].first);
			res = (res * val) % mod;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2688
n=int(input())
a=[0]*(n)
b=[0]*(n)
c=[0]*(n)
for _ in range(n):
    a[_],b[_],c[_]=map(int,input().split())

dp=[[0]*3 for _ in range(n)]

dp[0] = [a[0],b[0],c[0]]

for i in range(n-1):
    dp[i+1][0]=max(dp[i][1]+a[i+1], dp[i][2]+a[i+1])
    dp[i+1][1]=max(dp[i][0]+b[i+1], dp[i][2]+b[i+1])
    dp[i+1][2]=max(dp[i][0]+c[i+1], dp[i][1]+c[i+1])
print(max(dp[n-1]))

Measured memory_bytes: 61272
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	vector<vector<int> > graph(10001);
	int connectNum[10001] = {};
	for(int i = 0; i < n - 1; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
		connectNum[a]++;
		connectNum[b]++;
	}
	int c[10001];
	for(int i = 0; i < n; i++){
		cin >> c[i];
	}
	sort(c, c + n);

	queue<int> qu;
	int cnt = 0;
	vector<int> ans(10001, -1);
	for(int i = 0; i < n; i++){
		if(connectNum[i] == 1){
			qu.push(i);
			ans[i] = c[cnt];
			cnt++;
		}
	}

	while(!qu.empty()){
		int now = qu.front();
		qu.pop();
		for(int j = 0; j < graph[now].size(); j++){
			int next = graph[now][j];
			connectNum[next]--;
			if(connectNum[next] == 1){
				ans[next] = c[cnt];
				cnt++;
				qu.push(next);

			}
		}
	}
	cout << accumulate(c, c + n - 1, 0) << endl;
	for(int i = 0; i < n; i++){
		cout << ans[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 1024
k, s = map(int, input().split())
ans = 0

for x in range(k+1):
    for y in range(x, k+1):
        z = s - x - y
        l = {x, y, z}
        if y <= z <= k:
            if len(l) == 3:
                ans += 6
            elif len(l) == 2:
                ans += 3
            else:
                ans += 1

print(ans)

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

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}

template<typename S>
void print(S a){
    cout<<a<<endl;
}


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

    int a;cin>>a;
    fin(a+a*a+a*a*a);



}




Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define Mod 1000000007
#define Max 1000001
#define vt vector<long long>


void func(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll i=0;
    ll j=n-1;
    ll ans=0;
    while(true){
        
        while(s[i]=='R'){
            i++;
        }
        
        while(s[j]=='W'){
            j--;
        }
        
        if(i<j){
            s[i]='R';
            s[j]='W';
            ans++;
        }
        else 
            break;
    }
    cout<<ans<<endl;
}   
 
int main(){
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
 
// 
//int t;
//cin >> t;
//for(ll i=1; i<=t; i++)
//{
    
    func();
//    cout<<endl;
//cout<<func()<<endl;
 
//if(func())
//    cout<<"Yes"<< endl;
//else
//    cout <<"No"<<endl; 
//cout<<"Case"<<" "<<"#"<<i<<":"<<" "<<func()<<endl;
//}
return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, q; cin >> n >> q;
	string s; cin >> s;
	vector<char> t(q), d(q);
	vector<int> e(q);
	for(int i=0;i<q;i++){
		cin >> t[i] >> d[i];
		if(d[i]=='L'){
			e[i] = -1;
		}else{
			e[i] = 1;
		}
	}
	if(n==1){
		for(int i=0;i<q;i++){
			if(s[0]==t[i]){
				cout << 0 << endl;
				return 0;
			}
		}
		cout << 1 << endl;
		return 0;
	}
	int ok = -1;
	int ng = n;
	while(ng-ok>1){
		int c = (ok+ng)/2;
		int now = c;
		for(int i=0;i<q;i++){
			if(s[now]==t[i]){
				now += e[i];
			}
			if(now<0) break;
		}
		if(now<0){
			ok = c;
		}else{
			ng = c;
		}	
	}
	int left = ng;

	ng = -1;
	ok = n;
	while(ok-ng>1){
		int c = (ok+ng)/2;
		int now = c;
		for(int i=0;i<q;i++){
			if(s[now]==t[i]){
				now += e[i];
			}
			if(now>n-1) break;
		}
		if(now>n-1){
			ok = c;
		}else{
			ng = c;
		}	
	}
	int right = ng;
	cout << right-(left-1) << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
int a[252521];

int u[252521];

int main(){
    scanf("%d",&n);
    REP(i,n)scanf("%d",a+i);
    FORR(i,0,n){
        int v = i+1;
        int sm = 0;
        int it = v+v;
        while(it<=n){
            sm += u[it-1];
            it += v;
        }
        u[i] = (sm+a[i])%2;
    }
    vi v;
    REP(i,n)if(u[i])v.push_back(i+1);
    printf("%d\n",(int)v.size());
    int m = v.size();
    REP(i,m)printf("%d%c",v[i]," \n"[i==m-1]);
    return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <iomanip>
using ll = long long;
using namespace std;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r) { return l.second < r.second; }
bool greaterPair(const ipair& l, const ipair& r) { return l.second > r.second; }

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define irep(i, n) for (int i = 0; i <= (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rirep(i, n) for (int i = n; i >= 0; --i)
int factorical(int n) {
	int sum = 1;
	for (int i = 1; i <= n; ++i)
	{
		sum *= i;
	}
	return sum;
}

vector<int> divisors(int n) {
	vector<int> res;
	for (int i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}
vector<ll> divisors_ll(ll n) {
	vector<ll> res;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}


void printVector(const vector<int>& vec) {
	for (int value : vec) {
		cout << value << " ";
	}
	cout << endl;
}

bool pal(string s) {
	int n = s.length() / 2;
			rep(i, n) {
			if (s[i] != s[s.length() - 1 - i]) return false;
		}
			return true;
}

int euclidean_gcd(int a, int b) {
	if (a < b) return euclidean_gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

vector <string> vec_sort_and_del(vector<string> s) {
	std::sort(s.begin(), s.end());
	s.erase(std::unique(s.begin(), s.end()), s.end());
	return s;
}

int GetDigit(int num) {
	int digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

int main() {
	string n;
	string ans = "No";
	cin >> n;
	rep(i, n.length()) {
		if (n[i] == '7') {
			ans = "Yes";
		};
	};
	cout << ans;

	return 0;
}




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

int main(){
	int a, b;
 		 a = b = 0;
  	long long x;
 		 cin >> x;
 	 
  rep(i, 150){
    long long y = pow(i, 5);
    for(int j = -150; j <= i; j++){
    	long long z = pow(j, 5);
      if( y - z == x ){
        a = i, b = j;
        break;
      }
    }
  }
  
  cout << a << " " << b << endl;

    return 0;
  }


Measured memory_bytes: 3984
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	ll n;
	cin >> n;
	for (ll i = 1; i <= 9; i++) {
		if (n % i == 0 && n / i <= 9)return cout << "Yes" << endl,0;
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <float.h>
using namespace std;
int main(){
     int k,n;
     cin >> k >> n;
     int a[n],l[n];
     for(int i=0;i<n;i++){
         cin >> a[i];
     }
     for(int i=0;i<n-1;i++){
         l[i]=a[i+1]-a[i];
     }
     l[n-1]=k+a[0]-a[n-1];

     for(int i=0;i<n-1;i++){
        if(l[i]>l[i+1]){
            int pre =l[i];
            l[i]=l[i+1];
            l[i+1]=pre;
        }
    }
     
    cout << k-l[n-1];


}

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

int main(){
    int N; cin >> N;
    vector<int> X(N);
    int sum=0;
    for(int i=0; i<N; i++){
        cin >> X.at(i);
        sum=sum+X.at(i);
    }
    int P=sum/N;
    int ans1=0;
    for(int i=0; i<N; i++){
        ans1=ans1+(X.at(i)-P)*(X.at(i)-P);
    }
    int ans2=0;
    P=P+1;
    for(int i=0; i<N; i++){
        ans2=ans2+(X.at(i)-P)*(X.at(i)-P);
    }
    cout << min(ans1,ans2) << endl;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main(void) {
  char s[12];
  int len, count = 0;

  if(scanf("%s", s) == 1);

  len = strlen(s);

  if(s[0] == 'A' && islower(s[1]) && islower(s[len-1])) {
    for(int i = 2; i < len; i++) {
      if(i == len - 1) {
        if(isupper(s[i])) {
          printf("WA");
          return 0;
        }
      } else if(s[i] == 'C') {
        if(count == 1) {
          printf("WA");
          return 0;
        }
        count++;
      } else if(isupper(s[i])) {
        printf("WA");
        return 0;
      }
    }
  } else {
    printf("WA");
    return 0;
  }

  if(count == 0) {
    printf("WA");
    return 0;
  }

  printf("AC");

  return 0;
}


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

#define endl '\n'

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

    long long n;
    cin >> n;

    long long x = 100, ans=0;
    while(x < n){
        x += (x/100LL);
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define ll long long 
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << endl;    
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) 
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << ' ';
    cout << endl;
}
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
ll modulo = 1e9 + 7;

ll fpow(ll a, ll n) 
{
    ll ans = 1;
    while (n) 
    {
        if (n&1) ans = (ans*a)%modulo;
        a = (a*a)%modulo; n = n >> 1;
    }
    return ans;
}

void solve() 
{
    int n; cin >> n;
    int arr[n];
    For(i,0,n) {
        cin >> arr[i];
    }   
    For(i,0,n) {
        if (arr[i]&1) {
            continue;
        }
        if (arr[i]%3 and arr[i]%5) {
            cout << "DENIED" << endl;
            return;
        }
    }
    cout << "APPROVED" << endl;
}

int main() 
{
    fast_io();
    int t = 1;
    // cin >> t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
	"sort"
)

func run() int {
	var n int
	fmt.Scanf("%d\n", &n)
	cnt := make(map[string]int, 0)
	var s string
	var max int
	for i := 0; i < n; i++ {
		fmt.Scanf("%s\n", &s)
		_, ok := cnt[s]
		if ok {
			cnt[s]++
		} else {
			cnt[s] = 1
		}
		if cnt[s] > max {
			max = cnt[s]
		}
	}

	keys := make([]string, 0)
	for k, v := range cnt {
		if max == v {
			keys = append(keys, k)
		}
	}

	sort.Strings(keys)

	for _, v := range keys {
		fmt.Println(v)
	}

	return 0
}

func main() {
	os.Exit(run())
}


Measured memory_bytes: 33536
#include<iostream>
#include<vector>
#include<algorithm>
int main(void){
    int n, m;
    std::cin >> n >> m;
    std::vector<long long > a(n);
    std::vector<std::pair<long long ,long long >> bc(m);
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
    }
    for(int i = 0; i < m; i++){
        int b, c;
        std::cin >> b >> c;
        bc[i] = std::make_pair(c, b);
    }
    std::sort(bc.rbegin(), bc.rend());
    std::sort(a.begin(), a.end());
    int ai = 0;
    int bi = 0;
    int cnt = 0;
    long long ans = 0;
    while(ai < n){
        if(cnt == bc[bi].second){
            cnt = 0;
            bi++;
        }
        if(a[ai] < bc[bi].first){
            ans += bc[bi].first - a[ai];
            cnt++;
        }else{
            break;
        }
        ai++;
    }
    for(int i = 0; i < n; i++){
        ans += a[i];
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 5568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int ans=0;
    string s,t;
    cin >> s >> t;
    int n = s.size();
    rep(i,n){
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3848
#include <stdio.h>

#define MAX 101
#define INF 10000000
#define NIL -1

#define WHITE 0
#define BLACK 1 

int n;
int Graph[MAX][MAX];

void prim(void);

int main(){

  int i, j, k, u, v, w;

  scanf("%d", &n);

  for(i = 0; i < n; i++){

    for(j = 0; j < n; j++){

      Graph[i][j] = INF;

    }

  }

  for(i = 0; i < n; i++){
    
    scanf("%d %d", &u, &k);

    for(j = 0; j < k; j++){

      scanf("%d %d", &v, &w);

      Graph[u][v] = w;

    }

  }

  prim();

  return 0;

}

void prim(){

  int u, v, mincost, i, sum;
  int d[MAX];
  int pi[MAX];
  int color[MAX];

  sum = 0;

  for(u = 0; u < n; u++){

    d[u] = INF;
    
    pi[u] = NIL;

    color[u] = WHITE;

  }

  d[0] = 0;

  while(1){

    mincost = INF;

    for(i = 0; i < n; i++){

      if((color[i] != BLACK) && (d[i] < mincost)){

	mincost = d[i];

	u = i;

      }

    }

    if(mincost == INF)
      break;

    color[u] = BLACK;

    for(v = 0; v < n; v++){

      if(d[v] > d[u] + Graph[u][v]){

	d[v] = d[u] + Graph[u][v];

	pi[v] = u;

      }

    }

  }

  for(i = 0; i < n; i++){

    printf("%d %d\n", i, d[i]);

  }

}

Measured memory_bytes: 640
#include <complex>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef double number;
 
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<number> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
 
typedef vector<P> G;
 
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define diff(P, i) (next(P, i) - curr(P, i))
number convex_diameter(const G &pt) {
  const int n = pt.size();
  int is = 0, js = 0;
  for (int i = 1; i < n; ++i) {
    if (imag(pt[i]) > imag(pt[is])) is = i;
    if (imag(pt[i]) < imag(pt[js])) js = i;
  }
  number maxd = norm(pt[is]-pt[js]);
 
  int i, maxi, j, maxj;
  i = maxi = is;
  j = maxj = js;
  do {
    if (cross(diff(pt,i), diff(pt,j)) >= 0) j = (j+1) % n;
    else i = (i+1) % n;
    if (norm(pt[i]-pt[j]) > maxd) {
      maxd = norm(pt[i]-pt[j]);
      maxi = i; maxj = j;
    }
  } while (i != is || j != js);
  return maxd; /* farthest pair is (maxi, maxj). */
}
 
int main(){
    G poly;
    P p;
    int n;
    double x,y;
    for(scanf("%d",&n);n--;poly.push_back(p))scanf("%lf%lf",&x,&y),p=P(x,y);
    printf("%f\n",sqrt(convex_diameter(poly)));
}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();
			var k = firstLine[0];
			var s = firstLine[1];

			var count = 0;

			for(int x = 0; x <= k; x++)
			{
				for(int y = x; y <= k; y++)
				{
					for(int z = y; z <= k; z++)
					{
						if(x + y + z == s)
						{
							if (x == y && y == z)
							{
								count++;
							}
							else if(x == y || y == z)
							{
								count += 3;
							}
							else
							{
								count += 6;
							}
						}
					}
				}
			}
			
			Console.WriteLine(count);
		}
	}
}


Measured memory_bytes: 13268
#include <stdio.h>

int main(){
   int S, h, m, s;
   scanf("%d",&S);
   h=S/3600;
   m=(S-3600*h)/60;
   s=(S-3600*h-60*m);
   printf("%d:%d:%d\n",h,m,s);
   return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n;
vl v;
double x[10],y[10];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    double f=1,ans=0;
    rep(i,0,n)
    {
        cin>>x[i]>>y[i];
        v.pb(i);
        f/=(i+1);
    }  
    do
    {
        rep(i,1,n)
            ans+=sqrt((x[v[i]]-x[v[i-1]])*(x[v[i]]-x[v[i-1]])+(y[v[i]]-y[v[i-1]])*(y[v[i]]-y[v[i-1]]));
    } 
    while(next_permutation(all(v)));
    ans*=f;
    printf("%0.10lf\n",ans );
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

ll n, t[10000], dp[2][10010];

int main() {
  scanf("%lld", &n);
  for (ll i = 0; i < n-1; i++) scanf("%lld", &t[i]);
  for (ll i = 0; i <= n; i++) dp[0][i] = INF;
  dp[0][1] = 0;
  for (ll i = 1; i < n; i++) {
    ll now = i & 1, before = (i+1) & 1;
    for (ll j = 1; j <= i; j++) dp[now][j+1] = dp[before][j];
    dp[now][1] = INF;
    for (ll j = 1; j <= i; j++) dp[now][j] = min(dp[now][j], dp[before][i+1-j] + t[i-1]);
    //for (ll j = 1; j <= i+1; j++) printf("%lld ", dp[now][j]); printf("\n");
  }
  printf("%lld\n", dp[(n+1)&1][n/2]);
}



Measured memory_bytes: 2988
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;

void solve()
{ll t,n,m,x,y,z,d,p=0,b=0,q,l=INT_MAX,k,mini=0,prev;
  cin>>n;
  ll a[n][3],v[n][3];
  memset(v,0,sizeof(v));
  for(ll i=0;i<n;i++)
  for(ll j=0;j<3;j++)
  cin>>a[i][j];
  for(ll j=0;j<3;j++)
  v[0][j]=a[0][j];
  for(ll i=1;i<n;i++)
  {
  	for(ll j=0;j<3;j++)
  	{
  		for(ll k=0;k<3;k++)
  		{
  			if(k!=j)
  			v[i][j]=max(v[i][j],v[i-1][k]+a[i][j]);
		}
	}
  }
  for(ll j=0;j<3;j++)
  p=max(p,v[n-1][j]);
  cout<<p;
}

int main()
{

ll t=1;

while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <math.h>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;

///////////////////////////
////Prime Creator//////////
///////////////////////////
//bool Prime[100001] = {};
//void createPrime() {
//	ll n = 100001;
//	rep(i, 0, n) Prime[i] = true;
//	Prime[0] = false;
//	Prime[1] = false;
//	rep(i, 2, n) {
//		if (Prime[i]) {
//			rep(j, 2, n) {
//				if (j*i >= n)break;
//				Prime[j*i] = false;
//			}
//		}
//	}
//}
///////////////////////////
///////////////////////////

ll x[1001] = {};
ll y[1001] = {};
ll z[1001] = {};

ll sign[3] = {};

void setSign(ll i) {
	ll t = i;

	ll d = 0;
	while (d < 3) {
		sign[d++] = (t % 2 == 1) ? 1 : -1;
		t /= 2;
	}
}

int main() {
	ll N, M; cin >> N >> M;
	rep(i, 0, N)cin >> x[i] >> y[i] >> z[i];

	ll MaxS = 0;
	rep(i, 0, 1 << 3)
	{
		setSign(i);
		ll S[1000] = {};
		ll Sp = 0;

		rep(j, 0, N) {
			S[Sp++] = sign[0] * x[j] + sign[1] * y[j] + sign[2] * z[j];
		}

		sort(S, S + N);
		reverse(S, S + N);

		ll s = 0;
		rep(j, 0, M)s += S[j];

		MaxS = max(MaxS, abs(s));
	}

	cout << MaxS << endl;

	return 0;
}

Measured memory_bytes: 256
X = int(input())
a = 0
b = 0
ans = 0

if(X >= 500):
    a = X//500
    if(X-500*a >= 5):
        b = (X-500*a)//5
else :
    b = X // 5
	
ans = 1000*a + 5*b
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////




int main() {
	
	double b = 380000;

	ll N;
	cin >> N;

	double ans = 0;

	repn(i, N) {
		double x;
		cin >> x;
		string s;
		cin >> s;
		if (s == "JPY") { ans += x; }
		else { ans += x * b; }
	}

	cout << fixed << setprecision(10);
	cout << ans;

	system("PAUSE");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define F first
#define S second
#define pb push_back
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
void solve()
{
	ll a,b,c,d;cin>>a>>b>>c>>d;
	ll ans=max(a*c,max(a*d,max(b*c,b*d)));
	cout<<ans<<'\n';
}
int main()
{	Fast;
//	int t;cin>>t;
//	while(t--)
	solve();
}

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

int main()
{
	int n;
	cin >> n;
	map<string, int> M;
	string in;
	for (int i = 0; i < n; ++i)
	{
		cin >> in;
		++M[in];
	}
	int m;
	cin >> m;
	for (int i = 0; i < m; ++i)
	{
		cin >> in;
		--M[in];
	}
	int ans = 0;
	for (auto o : M)
	{
		ans = max(ans, o.second);
	}
	cout << ans << endl;
	return 0;
}

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

const int mod = 1e9 + 7, mxN = 3010;
int N;
string S;
int dp[mxN][mxN];

int main()
{
	ios_base::sync_with_stdio(false);

	cin >> N >> S;
	dp[1][1] = 1;
	for (int i = 2; i <= N; i++)
	{
		ll pref[i];
		pref[0] = dp[i - 1][0];
		for (int j = 1; j < i; j++)
		{
			pref[j] = pref[j - 1] + dp[i - 1][j];
			if (pref[j] >= mod) pref[j] -= mod;
		}
		for (int j = 1; j <= i; j++)
		{
			int l, r;
			if (S[i - 2] == '>') l = 1, r = j - 1;
			else l = j, r = i - 1;
			dp[i][j] = pref[r] - pref[l - 1] + mod;
			if (dp[i][j] >= mod) dp[i][j] -= mod;
		}
	}
	ll answer = 0;
	for (int i = 1; i <= N; i++)
	{
		answer += dp[N][i];
		if (answer >= mod) answer -= mod;
	}
	cout << answer;

	return 0;
}

Measured memory_bytes: 31244
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<numeric>
#define INF 1e+8
#define EPS 1e-8
#define PB push_back
#define fi first
#define se second
#define rep(i,j) for(int  i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < k; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
int main(){
    int n,m;
    int list[1024];
    int get[1024]={0};
    scanf("%d%d",&n,&m);
    rep(i,n){
        scanf("%d",&list[i]);
    }
    rep(i,m){
        int tmp;
        scanf("%d",&tmp);
        rep(i,n){
            if(list[i] <= tmp){
                get[i]++;
                break;
            }
        }
    }
    int ma = -10000;
    int index = 0;
    rep(i,m){
        if(ma < get[i]){
            ma = get[i];
            index = i;
        }
    }
    printf("%d\n",index+1);
    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

        vector<int> x(n);
        REP(i, n) cin >> x[i];

        constexpr int m = 100;
        int ans = 1e8;

        FOR(i, -(m+1), m+2) {
                int d = 0;

                REP(j, n) {
                        d += (x[j] - i) * (x[j] - i);
                }

                ans = min(ans, d);
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pll pair<ll,ll>
#define F first
#define S second
#define ll long long
using namespace std;
const int N=405;
long long n,m;char c;
long long ans;
bool a[N][N],f[N][N],o;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
bool ok(int x2,int y2){return (x2>=0&&y2>=0&&x2<n&&y2<m);}
pll arrive(int x,int y,bool black)
{
	pll p;
	if(black)p.F++;
	else p.S++;
	for(int i=0;i<4;i++)
	{
		int x2=x+dx[i];
		int y2=y+dy[i];
		if(ok(x2,y2)&&!f[x2][y2]&&black!=a[x2][y2])
		{
			f[x2][y2]=true;
			pll j=arrive(x2,y2,!black);
			p.F+=j.F;
			p.S+=j.S;
		}
	}
	return p;
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>c;
			a[i][j]=(c=='#'?true:false);
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(f[i][j])continue;
			pll p=arrive(i,j,a[i][j]);
			if(a[i][j])p.F--;
			else p.S--;
			ans+=p.F*p.S;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 13056
import java.util.*;
import java.util.Comparator;

public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);       
        String s=sc.next();
        int l=s.length();
        String o="";
        for(int i=0;i<l;i++){
        	o=o+"x";
        }
      System.out.println(o);
    }
}

Measured memory_bytes: 22608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)


int main(){
    ll n, k;
    cin >> n >> k;
    vector<pll> dt(n);
    for(int i = 0; i < n; i++){
        cin >> dt[i].second >> dt[i].first;
    }

    sort(dt.begin(),dt.end());
    reverse(dt.begin(),dt.end());

    map<ll,ll> eat;
    ll val = 0;
    for(int i = 0; i < k; i++){
        eat[dt[i].second]++;
        val += dt[i].first;
    }
    ll pd = k;
    ll pu = k-1;
    ll diverse = ll(eat.size());

    ll ans = val + diverse*diverse;
    while(pu!=-1 && pd!=n){
        while(eat[dt[pd].second] > 0){
            pd++;
            if(pu==-1 || pd==n){break;}
        }
        while(eat[dt[pu].second] == 1){
            pu--;
            if(pu==-1 || pd==n){break;}
        }
        if(pu==-1 || pd==n){break;}
        val += dt[pd].first;
        eat[dt[pd].second]++;
        val -= dt[pu].first;
        eat[dt[pu].second]--;
        diverse++;

        ans = max(ans, val + diverse*diverse);
        pu--;
    }
    cout << ans << endl;


    return 0;

}


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

const int MAXV = 100010;
const long long INF = 0xfffffffffffff;

bool cmp(long long a, long long b){return a < b;}

int main(int argc, char *argv[])
{
   
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    long long N, M, K;
    
    cin >> N >> M >> K;
    
    vector<long long> A(N), B(M);
    
    cin >> A[0];
    for (long long i = 1; i < N; i++) {
        cin >> A[i];
        A[i] += A[i - 1];
    }
    
    cin >> B[0];
    for (long long i = 1; i < M; i++) {
        cin >> B[i];
        B[i] += B[i - 1];
    }
    
    
    auto upa = A.begin();
    auto upb = B.begin();
    upa = upper_bound(A.begin(), A.end(), K);
    
    int max_cnt = 0;
    for (auto it = A.begin(); it <= upa; it++) {
        if (it == A.begin()) {
            upb = upper_bound(B.begin(), B.end(), K);
        } else {
            upb = upper_bound(B.begin(), B.end(), K - A[it - A.begin() -1]);
        }
        int cnt = it - A.begin() + upb - B.begin();
        max_cnt = max(max_cnt, cnt);
    }
    
    upb = upper_bound(B.begin(), B.end(), K);
    
    for (auto it = B.begin(); it <= upb; it++) {
        if (it == B.begin()) {
            upa = upper_bound(A.begin(), A.end(), K);
        } else {
            upa = upper_bound(A.begin(), A.end(), K - B[it - B.begin() -1]);
        }
        int cnt = it - B.begin() + upa - A.begin();
        max_cnt = max(max_cnt, cnt);
    }
    
    cout << max_cnt << endl;
    
    
    return 0;
}


Measured memory_bytes: 6352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D, L, R ;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  
  if (L > R) {
    cout << "Left" << endl;
  } else if (L==R) {
    cout << "Balanced" << endl;
  } else {
  	cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var w, h, n int
	fmt.Scan(&w, &h, &n)
	ichi := make([]int, w)
	for i := 0; i < w; i++ {
		ichi[i] = 1
	}
	zero := make([]int, w)
	for i := 0; i < w; i++ {
		zero[i] = 0
	}
	m := make([][]int, h)
	for y := 0; y < h; y++ {
		m[y] = make([]int, w)
		copy(m[y], ichi)
	}

	// ここからmを書き換えていく
	for k := 0; k < n; k++ {
		var x, y, t int
		fmt.Scan(&x, &y, &t)
		// 全部やってるとW*H*Nで10000000で間に合うんだけどダルいのでちょと省く
		switch t {
		case 1:
			// 0<j<xまで潰す
			for i := 0; i < h; i++ {
				for j := 0; j < x; j++ {
					m[i][j] = 0
				}
			}
		case 2:
			// x<=j<wまで潰す
			for i := 0; i < h; i++ {
				for j := x; j < w; j++ {
					m[i][j] = 0
				}
			}
		case 3:
			// 0<=i<yまで潰す
			for i := 0; i < y; i++ {
				copy(m[i], zero)
			}
		case 4:
			// y<=i<hまで潰す
			for i := y; i < h; i++ {
				copy(m[i], zero)
			}
		}

		// テスト
		/*
			fmt.Println("-----------")
			for y := 0; y < h; y++ {
				fmt.Println(m[y])
			}
		*/
	}

	// 最後に残った1を計算しておわり
	ans := 0
	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			ans += m[y][x]
		}
	}
	fmt.Println(ans)
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long x;
  cin >> x;
  long long cur = 100;
  int cnt = 0;
  while (cur < x) {
    cur += cur * 0.01;
    cnt++;
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<cstdio>
#include<algorithm>
using namespace std;
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define rep(i,n) REP(i,1,n)
#define rep0(i,n) REP(i,0,n-1)
#define repG(i,x) for(ll i=pos[x];~i;i=e[i].next)
#define ll long long
#define db double
const ll N=2007;
const ll mod=998244353;
const ll INF=1e9+7;
ll f[N][N],g[N],ans[N],fac[N*2],inv[N*2];
ll n,k;
ll Pow(ll x,ll y){
	ll ans=1,now=x;
	while(y){
		if(y&1)ans=ans*now%mod;
		now=now*now%mod;
		y>>=1;
	}
	return ans;
}
ll C(ll x,ll y){
	if(!y)return 1;
	if(x<0)return 0;
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main(){
	scanf("%lld%lld",&k,&n);
	fac[0]=1;
	rep(i,n+k)fac[i]=fac[i-1]*i%mod;
	inv[n+k]=Pow(fac[n+k],mod-2);
	for(ll i=n+k;i;i--)inv[i-1]=inv[i]*i%mod;
	f[0][0]=1;
	rep(i,n){
		g[0]=f[i-1][0];
		rep(j,k)g[j]=(f[i-1][j]+g[j-1])%mod;
		rep(j,k){
			f[i][j]=(f[i][j]+f[i-1][j])%mod;
			f[i][j]=(g[j-1]*2%mod+f[i][j])%mod;
		}
	}
	rep0(i,n+1)rep(j,k)f[i][j]=(f[i][j]+f[i][j-1])%mod;
	REP(i,2,k+1){
		ans[i]=0;
		if(i&1)rep0(j,n+1)ans[i]=(ans[i]+f[j][i/2]*C(n-j+k-i,n-j))%mod;
		else{
			rep0(j,n+1)ans[i]=(ans[i]+f[j][i/2-1]*C(n-j+k-i,n-j))%mod;
			rep(j,n)ans[i]=(ans[i]+f[j-1][i/2-1]*C(n-j+k-i,n-j))%mod;
		}
		printf("%lld\n",ans[i]);
	}
	REP(i,k+2,k*2)printf("%lld\n",ans[k*2+2-i]);
	return 0;
}


Measured memory_bytes: 31744
// Problem : E - Double Factorial
// Contest : AtCoder - AtCoder Beginner Contest 148
// URL : https://atcoder.jp/contests/abc148/tasks/abc148_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n;
    cin>>n;
    if(n%2) cout<<0<<endl;
    else{
        int ans = 0;
        int cur = 10;
        while(n/cur > 0){
            ans += n/cur;
            cur *= 5;
        }
        cout<<ans<<endl;
    }
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3616
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
unsigned long long int a = 0, b = 0, c = 0,d=0,e=0, ans = 0, x = 0, y = 0, z = 0, n = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100001], sec[100001];
long long int iremono2[100001], check[100001];
std::vector<long long int>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
std::string output, output2, input, input2;
char rev[100001];



unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int H, W;//はんい

int main()
{
	cin >> a >> b >> c >> d;
	if (a + b > c + d) {
		cout << "Left" << endl;
	}
	else if (a + b == c + d) {
		cout << "Balanced" << endl;
	}
	else {
		cout << "Right" << endl;
	}
}


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

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

int main()
{
  int W, H;
  while (cin >> W >> H) {
    if ((W|H) == 0)
      break;

    vector<string> maze(H);
    for (int i = 0; i < H; ++i) {
      cin >> maze[i];
      for (int j = 0; j < W; ++j) {
	if (maze[i][j] == 'E')
	  maze[i][j] = '0';
	else if (maze[i][j] == 'N')
	  maze[i][j] = '1';
	else if (maze[i][j] == 'W')
	  maze[i][j] = '2';
	else if (maze[i][j] == 'S')
	  maze[i][j] = '3';
      }
    }

    int ans = -1;
    for (int t = 1; t <= 181; ++t) {
      // change dir
      for (int i = 0; i < H; ++i) {
	for (int j = 0; j < W; ++j) {
	  if (maze[i][j] == 'X' || maze[i][j] == '.' || maze[i][j] == '#')
	    continue;

	  bool change = false;
	  int dir = maze[i][j] - '0', next_dir;
	  for (int d = 0; d < 4; ++d) {
	    next_dir = (dir+d+3) % 4;
	    int x = j + dx[next_dir];
	    int y = i + dy[next_dir];
	    if (x < 0 || W <= x || y < 0 || H <= y ||
		maze[y][x] != '.' && maze[y][x] != 'X')
	      continue;
	    change = true;
	    break;
	  }

	  if (change)
	    maze[i][j] = static_cast<char>(next_dir + '0');
	}
      }

      vector<string> cpy = maze;
      // move
      for (int i = 0; i < H; ++i) {
	for (int j = 0; j < W; ++j) {
	  if (maze[i][j] != 'X' && maze[i][j] != '.')
	    continue;

	  for (int d = 0; d < 4; ++d) {
	    int x = j + dx[d];
	    int y = i + dy[d];
	    
	    if (x < 0 || W <= x || y < 0 || H <= y ||
		maze[y][x] == '#' || maze[y][x] == 'X' || maze[y][x] == '.')
	      continue;

	    int dir = maze[y][x] - '0';
	    int xx = x+dx[dir], yy = y+dy[dir];
	    if (j != xx || i != yy)
	      continue;
	    
	    if (maze[i][j] == 'X') {
	      cpy[y][x] = '.';
	      maze[y][x] = '#';
	    } else {
	      cpy[i][j] = maze[y][x];
	      cpy[y][x] = '.';
	      maze[i][j] = maze[y][x] = '#';
	    }
	    ans = t;
	    break;
	  }
	}
      }

      maze = cpy;
    }

    if (ans == 181)
      cout << "NA" << endl;
    else
      cout << ans << endl;
  }
  return 0;
}

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							 \
			cout.tie(0);

using namespace std;

using ll = long long;
const int MOD = 1e9 + 7;
const ll INF = 5e18 + 9;
#define PI 3.141592654

ll powmod(ll base, ll exp, const ll MOD) { ll ans = 1; while (exp) { if (exp & 1)	ans = (ans * base) % MOD; base = (base * base) % MOD; exp >>= 1; }return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }

void test_case() {

}

int main() {
	fastio;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	int n;
	cin >> n;
	string s;
	cin >> s;
	for (int i = 0; i < min(n, (int)s.size()); ++i) {
		cout << s[i];
	}
	if (n < (int)s.size())
		cout << "...";
	return 0;
}



Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	long long sum=0;
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		if(t<k-t)
			sum+=(2*t);
		else
			sum+=(2*(k-t));
	}
	cout<<sum<<endl;
}


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

int main() {
    int n, a, b;
    long long int res = 0;
    cin >> n >> a >> b;

    cout << min(a, b) << " " << ((a+b-n>0)?a+b-n:0) << "\n";
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while((*x).left != NIL)
    {
      x = (*x).left;
    }
  return x;
  
}

Node treeSearch(Node u,int k){
  while(u != NIL && k != (*u).key)
    {
      if(k < (*u).key)
	u = (*u).left;
      else 
	u = (*u).right;
    }
  return u; 
}

Node treeSuccessor(Node x){
  Node y;
  if((*x).right != NIL)
    return treeMinimum((*x).right);
  y = (*x).parent;
  while((y != NIL) && (x == (*y).right))
    {
      x = y;
      y = (*y).parent;
    }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if((*z).left == NIL || (*z).right == NIL)
    y = z;
  else
    y = treeSuccessor(z);
  
  if((*y).left != NIL)
    x = (*y).left;
  else 
    x = (*y).right;
  
  if(x != NIL)
    (*x).parent = (*y).parent;
  
  if((*y).parent == NIL)
    root = x;
  else if(y == (y->parent)->left)
    (y->parent)->left = x;
  else 
    (y->parent)->right = x;
  
  if(y != z)
    {
      (*z).key = (*y).key;
      z = y;
    }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    if((*z).key < (*x).key)
      x = (*x).left;
    else x = (*x).right;
    (*z).parent = y;
  }
  if(y == NIL)
    root = z;
  else if( (*z).key < (*y).key )
    (*y).left = z;
  else (*y).right = z; 
}

void inorder(Node u){
  if(u != NIL)
   {
     inorder((*u).left);
     
     printf(" %d",(*u).key);
  
     inorder((*u).right);
   }
}

void preorder(Node u){
  if(u != NIL)
    {   
      printf(" %d",(*u).key);

      preorder((*u).left);
      
      preorder((*u).right);
    }
}


int main(){
  int n,i,x;
  char com[20];
  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    scanf("%s",com);
    if(com[0] == 'f'){
      scanf("%d",&x);
      Node t = treeSearch(root,x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(com[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if (com[0] == 'd'){
      scanf("%d",&x);
      treeDelete(treeSearch(root,x));
    }
  }
  
  return 0;
  
}

Measured memory_bytes: 19360
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> cum(n+1,0);
  vector<vector<ll>> dp(n+1,vector<ll>(n+1,INF));
  for (int i = 0; i < n; i++) dp[i][i + 1] = 0;
  for (int i = 0; i < n; i++) cum[i + 1] = cum[i] + a[i];
  for (int len = 1; len <= n; len++) {
    for (int l = 0; l + len <= n; l++) {
      int r = l + len;
      ll cost = cum[r] - cum[l];
      for (int k = l; k <= r; k++) {
        dp[l][r] = min(dp[l][k] + dp[k][r] + cost, dp[l][r]);
      }
    }
  }
  cout << dp[0][n] << endl;
  return 0;
} 

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	int tt[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int K;
	cin >> K;
	cout << tt[K-1];
	return 0;
}


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

int main(int argc, char const* argv[])
{
    std::string in_str;
    std::cin >> in_str;

    auto is_odd = true;
    for(auto c: in_str)
    {
        if(is_odd)
        {
            std::cout << c;
        }
        is_odd = !is_odd;
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 512