akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

# たこ焼き器の価値
N = [0] + list(map(int, tuple(input().rstrip("\n"))))
# 支払額
Ncopy = N.copy()

def main():
    # 紙幣の枚数
    ans = 0

    # 繰り上げ発生時に変更
    flag = False
    for i in range(len(N)-1, 0, -1):
        # 繰り上げしない場合
        if (Ncopy[i] <= 4) or (Ncopy[i] == 5 and N[i-1] <= 4):
            ans += Ncopy[i]
            flag = False
        # 繰り上げする場合
        else:
            Ncopy[i-1] += 1
            if not flag:
                ans += 10 - N[i]
            else:
                ans += 9 - N[i]
            Ncopy[i] = 0
            flag = True

    if Ncopy[0] == 1:
        ans += 1

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 20452
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int n,sum=0;
struct Sort{
	int num;
	int index;
	int sindex;
}a[100010];
bool cmp(Sort c,Sort d)
{
	return c.num<d.num;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {cin>>a[i].num;a[i].index=i;}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		a[i].sindex=i;
	}
	for(int i=1;i<=n;i++)
	{
		if(abs(a[i].sindex-a[i].index)%2==1) sum++;
	}
	sum/=2;
	printf("%d",sum);
	return 0;
}

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

bool isPalindrome(string s) {
  string t=s;
  reverse(t.begin(),t.end());
  return s==t;
}

int main() {
  string s;
  cin >> s;
  bool ans=true;
  if(!isPalindrome(s)) ans=false;
  if(!isPalindrome(s.substr(0,s.size()/2))) ans=false;
  puts(ans?"Yes":"No");
  return 0;
}
  


Measured memory_bytes: 256
M, D = map(int, input().split())
dstr = ''
ans = 0

if D < 20:
  print(0)
  exit()

for m in range(1, M+1):
  for d in range(20, D+1):
    dstr = str(d)
    if int(dstr[1]) < 2:
      continue
    if int(dstr[0]) * int(dstr[1]) == m:
      ans += 1

print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <set>
#include <utility>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>

const int CMax = 102;

using namespace std;

int main()
{
   string S;
   int cnt = 0;

   cin >> S;
   int n = S.length();

    for (int i = 0; i < n / 2; i++) {
        if (S[i] != S[n - 1 - i]) cnt++;
    }

    printf("%d\n", cnt);

    return 0;
}



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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
//const int INF = 1 << 30;
const int INF = 1e9 + 10;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

int H, W;
ll c[10][10];
ll A[210][210];
ll ans;

int V = 10;

void warshall_floyd() {
	for (int k = 0; k < V; k++)
		for (int i = 0; i < V; i++)
			for (int j = 0; j < V; j++) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
}

int main(void){
	cin>>H>>W;
	for (int i = 0; i < V; i++)
		for (int j = 0; j < V; j++) cin>>c[i][j];

	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++) cin>>A[i][j];

	warshall_floyd();

	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++) ans += c[A[i][j]][1];

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

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
const int MAX_N=1e5;

signed main(){
    int N,K;cin>>N>>K;
    vector<pair<int,int>>A(N);
    REP(i,N){
        int a,b;cin>>a>>b;
        A[i]=mp(a,b);
    }
    sort(A.begin(),A.end());
    REP(i,N){
        K-=A[i].second;
        if(K<=0){
            cout<<A[i].first<<endl;
            break;
        }
    }
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(){
    int n,m,x,y,a[31];
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)a[i]=i;
    for(int i=0;i<m;i++){
        scanf("%d,%d",&x,&y);
        a[0]=a[x];
        a[x]=a[y];
        a[y]=a[0];
    }
    for(int i=1;i<=n;i++){
        printf("%d\n",a[i]);
    }
}

Measured memory_bytes: 2608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main() {
    ll N;
    cin >>N;
    ll ans=INF;
    const auto &res = enum_divisors(N);
    for (int i = 0; i < res.size(); ++i){
        ll a=res[i];
        ll b=N/res[i];

        ll d1=0,d2=0;
        while(a){
            d1++;
            a/=10;
        }
         while(b){
            d2++;
            b/=10;

        }
        chmin(ans,max(d1,d2));
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std; typedef long long int ll;
#define all(a) a.begin() , a.end()
#define print(x)   cout<<x<<"\n";
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; if (i != v.size() - 1) os << ", "; } os << "]\n"; return os;}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{os << "["; for (auto it : v) {os << it; if (it != *v.rbegin())os << ", ";} os << "]\n"; return os;}
template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{for (auto it : v)os << it.first << " : " << it.second << "\n"; return os;}
template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{os << "("; os << v.first << ", " << v.second << ")"; return os;}
/*******************************************************************************/
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);    freopen("output.txt", "w", stdout);
#endif
    int k;
    cin >> k;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
        if (i + 1 <= k)
            cout << s[i];
        else {
            cout << "...";
            break;
        }
}

Measured memory_bytes: 3652
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
	int[] P=new int[N];
    int min=0;
    int count=0;
    
    for(int i=0;i<N;i++){
      P[i]=sc.nextInt();
    }
    min=P[0];
    
    for(int i=0;i<N;i++){
	  if(min>=P[i]){
        min=P[i];
        count++;
      }
    }
    System.out.println(count);
    
  }
}


Measured memory_bytes: 87148
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long int ll;

struct A
{
    int id;
    int st;
    int ed;
};
vector<A>V;
bool operator<(A a,A b)
{
    if(a.st!=b.st)
    return a.st<b.st;
    return a.ed<b.ed;
}
char arr[1005];
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin >> a >>  b;
	int c=a+b;
	if(a % 3 == 0 || b % 3 == 0||c % 3==0){
		cout << "Possible\n";
		return 0;
	}
	cout << "Impossible\n";
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var A, B, K int
	fmt.Scan(&A, &B, &K)

	list := make([]int, 0)
	for i := A; i > 0; i-- {
		if A%i == 0 && B%i == 0 {
			list = append(list, i)
		}
	}
	fmt.Println(list[K-1])
}

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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n;
int a[N];
int mn[4002][4002];

int main () {
    int x;
    cin >> n >> x;
    ll ans = INF;
    For (i, 1, n) {
        cin >> a[i];
        a[i + n] = a[i];
    }
   
    for (int i = 1; i <= n + n; i ++) {
        mn[i][i] = a[i];
        for (int j = i + 1; j <= n + n; j++)
            mn[i][j] = min (mn[i][j - 1], a[j]);
    }
    
    For (t, 0, n) {
        ll cur = 1ll * t * x;
        For (i, n + 1, n + n) {
        //    cout << mn[i - t][i] << '\n';
            cur += mn[i - t][i];
        }
        //cout << '\n';
        
        ans = min(ans, cur);
    }
    cout << ans << '\n';
	return Accepted;
}

// Coded By OB

Measured memory_bytes: 63744
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>
#include <cstring>


int main() {
    int n, y; std::cin >> n >> y;
    std::vector<std::bitset<20002>> b(n + 1);
    b[0][0] = 1;
    for (int i = 0; i < n; i++) {
        b[i + 1] |= (b[i] << 1) | (b[i] << 5) | (b[i] << 10);
    }
    if (!b[n][y / 1000]) {
        std::cout << -1 << " " << -1 << " " << -1 << std::endl;
        return 0;
    }
    int cnt1 = 0, cnt5 = 0, cnt10 = 0;
    int pos = y / 1000, t = n;
    while (pos > 0) {
        if (b[t - 1][pos - 1]) cnt1++, pos--, t--;
        if (t > 0 && pos >= 5 && b[t - 1][pos - 5]) cnt5++, pos -= 5, t--;
        if (t > 0 && pos >= 10 && b[t - 1][pos - 10]) cnt10++, pos -= 10, t--;
    }
    std::cout << cnt10 << " " << cnt5 << " " << cnt1 << std::endl;
    return 0;
}

Measured memory_bytes: 5120
import bisect

n, m, k = map(int, input().split())
a, b = [0], [0]
for i, x in enumerate(input().split()):
    a.append(a[i] + int(x))
for i, x in enumerate(input().split()):
    b.append(b[i] + int(x))

res = 0
a_ = 0
for i in range(n+1):
    if a[i] > k:
        break
    j = bisect.bisect(b, k-a[i]) - 1
    res = max(res, i+j)

print(res)


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

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

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

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }
    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}


void solve(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << c - (d-b) <<" " <<  d+(c-a)<< " " << a - (d-b)<< " "<< b+(c-a);
}


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


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


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

  double b=a/3. ;
  //cout << setprecision(20) << b << endl;
  printf("%.10g\n", b*b*b);
  //cout << b*b*b << endl;
  return 0;
}

Measured memory_bytes: 256
a, b, c, x = map(int, [input() for i in range(4)])
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            total = 500 * i + 100 * j + 50 * k
            if total == x:
                count = count + 1
print(count)



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

int main(){
    int n;
    cin >> n;
    string v;
    cin >> v;
    int sum = 0;
    rep(i, 1000){
        int s[3] = {i/100, (i/10)%10, i%10};
        int f = 0;
        rep(j, n){
            if(v[j] == ('0' + s[f])){
                f++;
            }
            if(f == 3){
                sum++;
                break;
            }
        }
    }
    
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3672
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

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

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

long long GCD(long long a, long long b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    if (b == 0) return a;
    else return GCD(b, a % b);
}

ll dp0[100100];
ll dp1[100100];

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    dp0[0] = a[0];
    for (int i = 1; i<=n; ++i) dp0[i] = GCD(dp0[i-1],a[i]);

    dp1[0] = a[n-1];
    for (int i = 1; i<n; ++i) dp1[i] = GCD(dp1[i-1],a[n-1-i]);
    

    ll ans = 0;
    
    rep(i,n) {
        if (i == 0) ans = max(ans, dp1[n-2]);
        else if (i == n-1) ans = max(ans, dp0[n-2]);
        else ans = max(ans,GCD(dp0[i-1],dp1[n-1-(i+1)]));
    }
    cout << ans << endl;
    return 0;
}





















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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++) cin >> a[i];
  int max_val = a[0];
  int min_val = a[0];

  for(int i = 0; i < N; i++){
    chmax(max_val, a[i]);
    chmin(min_val, a[i]);
  }

  if(max_val - min_val > 1){
    cout << "No" << endl;
  }else if(min_val == N-1){
    cout << "Yes" << endl;
  }
  else{

    int cnt_max = 0;
    int cnt_min = 0;
    for(int i = 0; i < N; i++){
      if(a[i] == max_val){
        cnt_max++;
      }else{
        cnt_min++;
      }
    }

    // 残り N - cnt_minで、max_val分割できるか判定

    if((max_val - cnt_min) == 0){
      cout <<"No" << endl;
    }else if((N-cnt_min)/(max_val-cnt_min) >= 2){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }


  return 0;
}


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

namespace ABC124B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var H = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var count = 1;

            for (int i = 1; i < N; i++)
            {
                count++;
                for (int j = 0; j < i; j++)
                {
                    if (H[j] > H[i])
                    {
                        count--;
                        break;
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11348
package main

import (
	"fmt"
	"sort"
)

func COM(n, k int64) int64 {
	r := int64(1)
	for i := int64(0); i < k; i++ {
		r = ModMul(r, n-i)
		r = ModDiv(r, i+1)
	}

	return r
}

const (
	MOD = 1000000000 + 7
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	value int
	index int
	A, B  int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int64) int64 {
	return a * b / GCD(a, b)
}

func main() {
	var N int
	fmt.Scanf("%d\n", &N)
	m := map[string][]int{}
	idxMap := map[int]int{}
	city := []string{}

	for i := 0; i < N; i++ {
		var s string
		var p int
		fmt.Scanf("%s %d\n", &s, &p)
		if _, e := m[s]; !e {
			city = append(city, s)
		}
		m[s] = append(m[s], p)
		idxMap[p] = i + 1
	}
	sort.Strings(city)
	for _, c := range city {
		scores := m[c]
		sort.Sort(sort.Reverse(sort.IntSlice(scores)))
		for _, score := range scores {
			fmt.Println(idxMap[score])
		}
	}
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> x(n);
  for(int i=0;i<n;i++)
    cin>>x.at(i);
  int s=-1;
  for(int p=0;p<100;p++){
    int sp=0;
    for(int i=0;i<n;i++)
      sp+=(x.at(i)-p)*(x.at(i)-p);
    s=(s==-1?sp:min(s,sp));
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
const long long N = 10e9+7;
int fil, col;
char arr [1001][1001];
long long formas [1001][1001];

long long f(int fi, int co)
{
    long long dev;
    if(formas[fi][co] != -1)
        dev= formas[fi][co];

    else
    {if(fi==0 && co==0)
    {
        formas[0][0] = 1;
        dev= 1;
    }
    else if( (fi==0 || arr[fi-1][co]=='#') && (co==0 || arr[fi][co-1]=='#'))
    {
        //cout<<"HEY"<<endl;
        formas[fi][co] = 0;
        dev= formas[fi][co];
    }

    else if(fi-1 >= 0 && arr[fi-1][co]!='#')
    {
        if(co-1 >= 0 && arr[fi][co-1]!='#')
        {
            formas[fi][co] = f(fi-1, co) + f(fi, co-1);
            dev= formas[fi][co];
        }
        else
        {
            formas[fi][co] = f(fi-1, co);
            dev= formas[fi][co];
        }
    }
    else
    {
        formas[fi][co] = f(fi, co-1);
        dev= formas[fi][co];
    }
    }
    if(dev >= 1000000007)
        return dev%1000000007;
    else
        return dev;
}

int main()
{
    cin>>fil>>col;
    for(int i = 0; i < fil; i++)
    {
        for(int j = 0; j < col; j++)
        {
            cin>>arr[i][j];
        }
    }
    memset(formas, -1, sizeof formas);
    long long res = f(fil-1, col-1);
   // if (res >= N)
    cout<<res<<endl;
    //cout<<res%(N)<<endl;
    //else
     //   cout<<res<<endl;
    
    /*for(int i = 0; i < fil; i++)
    {
        for(int j = 0; j < col; j++)
        {
            cout<<formas[i][j]<<" ";
        }
        cout<<endl;
    }*/
}

Measured memory_bytes: 12028
#include<iostream>

#define endl '\n'

using namespace std;

const int MAXN=21,MOD=1e9+7;
bool check[MAXN][MAXN];
int dp[(1<<MAXN)+3];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        for(int i2=0;i2<n;++i2){
            cin>>check[i][i2];
        }
    }
    dp[0]=1;
    for(int mask=0;mask<(1<<n)-1;++mask){
        int men=__builtin_popcount(mask);
        for(int women=0;women<n;++women){
            if(check[men][women] and !(mask & (1<<women))){
                int new_mask=(mask | (1<<women));
                dp[new_mask]=(dp[new_mask]+dp[mask])%MOD;
            }
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
#include <string>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define f first
#define s second

const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0);
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}

int main() { _
  int a, b, m; cin >> a >> b >> m;
  vector<int> ref(a), mic(b);
  int minr = __INT32_MAX__, minm = __INT32_MAX__;
  for (int i = 0; i < a; i++) { cin >> ref[i]; minr = min(minr, ref[i]); }
  for (int i = 0; i < b; i++) { cin >> mic[i]; minm = min(minm, mic[i]); }
  int ans = minr + minm;
  for (int i = 0; i < m; i++) {
    int x,y, dis; cin >> x >> y >> dis;
    ans = min(ans, ref[x-1] + mic[y-1] - dis);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define index Index
#define Line pll
typedef long long LL;
int main(){
    int n;
    scanf("%d",&n);
    int a[100005];
    int b[100005];
    LL sum=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    for(int i=0;i<n;i++){
        scanf("%d",&b[i]);
        a[i]-=b[i];
        sum-=b[i];
    }
    if(sum<0){
        printf("-1\n");
        return 0;
    }
    sort(a,a+n);
    int ori=a[n-1];
    int r=n-1;
    for(int i=0;i<n;i++){
        if(a[i]>=0){
            if(a[r]==ori)
            printf("%d\n",n-(r-i+1));
            else
            printf("%d\n",n-(r-i));
            break;
        }
        while(a[i]<0){
            a[i]+=a[r];
            if(a[i]<0){
                r--;
                ori=a[r];
            }
            else{
                a[r]=a[i];
            }
        }
    }

}

Measured memory_bytes: 1024
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
long long n,a,sum,ans;
map <long long,long long> mp;
int main()
{
	cin>>n;
	mp[0]++;
	for (long long i=0;i<n;i++){
		cin>>a;
		sum+=a;
		ans+=mp[sum];
		mp[sum]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12800
using System;
namespace DynammicProgramming {
  class Knapsack1 {
    public static void Main(String[] args) {
      String[] first = Console.ReadLine().Split(' ');
      int noItems = Int32.Parse(first[0]); // number of items
      int maxWeight = Int32.Parse(first[1]);
      int[] weights = new int[noItems];
      int[] values = new int[noItems];
      for(int i = 0; i < noItems; i++) {
        String[] item = Console.ReadLine().Split(' ');
        weights[i] = Int32.Parse(item[0]);
        values[i] = Int32.Parse(item[1]);
      }
      long[] answer = new long[maxWeight+1];
      for(int i = 0; i <= maxWeight; i++) {
        answer[i] = -1;
      }
      answer[0] = 0;
      for(int eleTaken = 0; eleTaken < noItems; eleTaken++) {
        for(int currentWeight = maxWeight; currentWeight >= 0; currentWeight--) {
          int pos = currentWeight + weights[eleTaken];
          if (pos <= maxWeight && answer[currentWeight] > -1) {
            answer[pos] = Math.Max(answer[pos], (answer[currentWeight] == -1  ? 0 : answer[currentWeight]) +values[eleTaken]);
          }
        }
      }
      long finalAnswer = 0;
      for(int i = 0; i <= maxWeight; i++) {
        if (answer[i] > finalAnswer) finalAnswer = answer[i];
      }
      Console.WriteLine(finalAnswer);
    }
  }
}

Measured memory_bytes: 11616
n, d = map(int, input().split())
xy = []
for i in range(n):
    xy.append(list(map(int, input().split())))
cnt = 0
for i in range(n):
    if (xy[i][0]**2 + xy[i][1]**2) <= d**2:
        cnt += 1
print(cnt)

Measured memory_bytes: 45208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
#define sort(a) sort(a.begin(),a.end());
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define F first
#define S second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define nl "\n"
const int MOD = 1e9+7;
const ld PI = 3.1415926535898;
const ll LLMAX = LLONG_MAX;
#define N (int)1e6+1

int main()
{
	ios
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int price[n+1]={0};
	price[2]=abs(a[2]-a[1]);
	for(int i=3;i<=n;i++)
	{
		price[i]=min(price[i-2]+abs(a[i]-a[i-2]),price[i-1]+abs(a[i]-a[i-1]));
	}
	cout<<price[n]<<nl;
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Linq.Expressions;
using System.Xml.XPath;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var n = Sarray()[0];
            var pi = Sarray();
            var cnt = 0L;
            for (var i = 0; i < n - 2; ++i)
            {
                if (pi[i + 1] == pi.Skip(i).Take(3).OrderBy(p => p).ToArray()[1])
                    ++cnt;
            }
            WriteLine(cnt);
        }

        static long Gcd(long x, long y) => y == 0 ? x : Gcd(y, x % y);
        static long Lcm(long x, long y) => x / Gcd(x, y) * y;

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 28488
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cstdio>
#include <string>
using namespace std;
#define loop(i,n) for(int i = 0; i < (n); i++)
#define loops(i,f,n) for(int i = (f); i < (n); i++)
#define VEC vector<int>
#define INF INT_MAX
#define debug(a) cout<<a
// vector<VEC> v (n, VEC(n))
//loop(i,n)loop(j,n)dp[i][j]=-1;
//printf("%d\n", n);
int main()
{
	char n;
	int c=0;
	loop(i,6)
	{
		cin >> n;
		if (n == '1')c++;
		else continue;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main(){
  long long a,b,k;
  cin >> a >> b >> k;
  if(a >= k) a -= k;
  else{
    if(b >= k-a){
     b = b-(k-a); 
     a = 0;
    }
    else {
      a=0;
      b=0;
    }
  }
  cout << a << " "<< b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  sort(v.begin(),v.end());
  int ans=0;
  for(int i=0;i<k;i++)
    ans+=v[i];
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3552
s = input()
if s[0] == "A" and s[2:-1].count("C") == 1:
    count = 0
    for c in s:
        if c.capitalize() == c:
            count += 1
    if count != 2:
        print("WA")
    else:
        print("AC")
else:
    print("WA")

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

int main() {
  int n, o = 0, t;
  cin >> n;
  vector<int> a(n), c(n - 1), bn;
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
    if(i > 0)
      if(a.at(i - 1) == a.at(i) - 1)
        bn.push_back(a.at(i - 1) - 1);
  }
  for(int i = 0; i < n; i++) {
    cin >> t;
    o += t;
  }
  for(int i = 0; i < n - 1; i++)
    cin >> c.at(i);
  for(int i = 0; i < bn.size(); i++)
    o += c.at(bn.at(i));
  cout << o << endl;
}

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

int main(){
	ll X, Y;
	cin >> X >> Y;
	int ans = 0, k = 1;
	ll a = X;
	while (a<=Y) {
		a *= 2;
		ans++;
		k += 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3604
A, B, C, D = map(int, list(input()))

def add(x, y):
    return x + y
def sub(x, y):
    return x - y

fs = [add, sub]

for i in range(2):
    for j in range(2):
        for k in range(2):
            if fs[k](fs[j](fs[i](A, B), C), D) == 7:
                print(A, '+' if i == 0 else '-',
                      B, '+' if j == 0 else '-',
                      C, '+' if k == 0 else '-',
                      D, '=7', sep='')
                exit()


Measured memory_bytes: 3064
import math


def read():
    N, D = list(map(int, input().strip().split()))
    X = [[] for _ in range(N)]
    for i in range(N):
        X[i] = list(map(int, input().strip().split()))
    return N, D, X


def is_close(x, eps):
    e = math.fmod(x, 1)
    return e < eps


def solve(N, D, X):
    count = 0
    for i in range(N):
        for j in range(N):
            if i < j:
                distance = 0
                for y, z in zip(X[i], X[j]):
                    distance += ((y - z) ** 2)
                if is_close(math.sqrt(distance), 1e-7):
                    count += 1
    return count


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

map<ll,ll> memo;

ll f(ll N) {
    if (found(memo,N)) return memo[N];

    for (ll i=0,p=1LL;p<=N;++i,p<<=1LL) {
        ll d = N - p;
        if (d < p) {
            // ll a = f(d) + pow(3,i) - f(p*2-1-N); //d*2-N);
            ll a = SUB(ADD(f(d), POW(3,i)), f(p*2-1-N));
#ifdef DEBUG
            fprintf(stderr, "f(%lld) = %lld; d=%lld,i=%lld,p=%g\n", N, a, d,i,pow(3,i));
#endif
            memo[N] = a;
            return a;
        }
    }
}

int main() {
    memo[0] = 0LL;
    memo[1] = 1LL;

    ll N; cin >> N;
    cout << f(N+1) << endl;
    // cout << (solve(N,a) ? "Yes":"No") << endl;
    return 0;
}


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

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<bool> have(N, false);
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++){
            int A;
            cin >> A;
            have[A - 1] = true;
        }
    }

    int count = 0;
    for (int i = 0; i < N; i++) {
        if (!have[i]) {
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
int i, n, m, k, ans;
int a[1000];
string s;

int main() {
    cin >> s;
    if (s == "ABC") printf("ARC\n");
    else printf("ABC\n");
}

Measured memory_bytes: 3592
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [A, B] = string_to_int(inputs[0])
    ret = []
    ret.append(A+B)
    ret.append(A-B)
    ret.append(A*B)
    return max(ret)


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3060
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=0;
		String t=sc.next();

		while(sc.hasNext()){
			String a=sc.next();
			if(a.equalsIgnoreCase(t)){
				n++;
			}else if(a.equals("END_OF_TEXT")){
				break;
			}
		}
		System.out.println(n);


	}



}


Measured memory_bytes: 26232
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

signed main(){
  int n;
  cin>>n;
  int tk=1,ao=1;
  rep(i,n){
    int t,a;
    cin>>t>>a;
    int tmp=max((tk+t-1)/t,(ao+a-1)/a);
    tk=t*tmp;
    ao=a*tmp;
  }
  cout<<tk+ao<<endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()

D = ['AAGC', 'GAGC', 'CAGC', 'TAGC', 'AGGC', 'ACGC', 'ATGC', 'AGCA', 'AGCG', 'AGCC', 'AGCT', 'AGAC', 'AGGC', 'AGTC']
D += ['ACGA', 'ACGG', 'ACGC', 'ACGT', 'AACG', 'GACG', 'CACG', 'TACG']
D += ['GACA', 'GACG', 'GACC', 'GACT', 'AGAC', 'GGAC', 'CGAC', 'TGAC']
m = {}
for a, b, c in it.product('AGCT', repeat = 3):
    S = a + b + c
    if not S in ['AGC', 'ACG', 'GAC']:
        m[S] = 1
cnt = 0
for _ in range(3, N):
    m2 = {}
    for key in m:
        for c in 'AGCT':
            S = key + c
            if not S in D:
                cnt += 1
                if S[1:] in m2:
                    m2[S[1:]] += m[key]
                    m2[S[1:]] %= MOD
                else:
                    m2[S[1:]] = m[key]
    m = m2
ans = 0
for key in m:
    ans += m[key]
    ans %= MOD
print ans

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

int main() {
    ll N; cin>>N;
    if(N%2==1){
        cout<<0<<endl;
        return 0;
    }
    N/=2;
    ll ans=0;
    ll x=5;
    while(N/x>0){
        ans+=N/x;
        x*=5;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3604
unittest
{
	assert( [ "aab", "xyz" ].parse.expand.solve == "No" );		// 追加ケース
	assert( [ "xyz", "aab" ].parse.expand.solve == "No" );		// 追加ケース

	assert( [ "azzel", "apple" ].parse.expand.solve == "Yes" );
	assert( [ "chokudai", "redcoder" ].parse.expand.solve == "No" );
	assert( [ "abcdefghijklmnopqrstuvwxyz", "ibyhqfrekavclxjstdwgpzmonu" ].parse.expand.solve == "Yes" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ss = input.front.strip.to!( dchar[] );
	input.popFront;
	auto ts = input.front.strip.to!( dchar[] );
	return tuple( ss, ts );
}

auto solve( dchar[] ss, dchar[] ts )
{
	// 自分の中の文字に対応する位置の相手の文字を収集（つまり変換元⇔変換先の対応表を作る）
	dchar[ dchar ] sts;
	dchar[ dchar ] tss;
	foreach( s, t; lockstep( ss, ts ) )
	{
		if( s in sts && sts[ s ] != t ) return "No";		// Sの中に同じ文字が複数あって、それぞれに対応するTの文字が揃ってなかったら、もう無理
		sts[ s ] = t;
		if( t in tss && tss[ t ] != s ) return "No";		// Tの中に同じ文字が複数あって、それぞれに対応するSの文字が揃ってなかったら、もう無理
		tss[ t ] = s;
	}
	
	return "Yes";
}


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

using namespace std;

const double PI = acos(-1);

int main() {
	int a, b, h, m; cin >> a >> b >> h >> m;
	double x = 2 * PI * m / 60 - 2 * PI * (h * 60 + m) / (12 * 60);
	printf("%.9f\n", sqrt(a * a + b * b - 2 * a * b * cos(2 * PI - x)));
	return 0;
}


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

int main(){
	int N,k,ans;
	bool flag;
	while(true){
		cin >> N;
		if(N == 0)
			break;
		flag = false;
		ans = 0;
		for(int i=0; i<N; i++){
			cin >> k;
			if(k > 0)
				ans++;
			if(k >= 2)
				flag = true;
		}
		if(flag)
			cout << ans+1 << endl;
		else
			cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
/*
 * あみだくじ問題
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2001
 */
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#include<sstream>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define ALL(c) (c).begin(), (c).end()
#define dump(a) cerr << #a << "=" << (a) << endl
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } //t=min
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } //t=max
using namespace std;

int main() {
	int N,M,A,H,P,Q;
	int amida[101][1001]; //幅，高さ
	int now_amida;

	while(cin >> N >> M >> A) {
		if (N==0&&M==0&&A==0) break;
		fill_n((int *) amida,sizeof(amida)/sizeof(int),0);
		rep(m,M) {
			cin >> H >> P >> Q;
			amida[P][H] = Q;
			amida[Q][H] = P;
		}

		/*
		rep(h,7) {
			rep(w,7) {
				cout << amida[w][h] << " ";
			}
			cout << endl;
		} */

		now_amida = A;
		for(int h = 1000; h >= 1; h--) {
			if (amida[now_amida][h] > 0) { //次の網だがあるとき
				//dump(now_amida);
				now_amida = amida[now_amida][h]; //今の網だを更新する
			}
		}
		cout << now_amida << endl;
	}

	return 0;
}

Measured memory_bytes: 1552
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m,p=map(int,input().split())
E=[]
for i in range(m):
	a,b,c=map(int,input().split())
	a-=1; b-=1; c-=p; c*=-1
	E.append((a,b,c))

def BellmanFord(edges,n,s):
	#edgesは有向グラフの辺集合で辺は(始点,終点,コスト)
  #グラフの初期化
  dist=[inf for i in range(n)]
  dist[s]=0
  
  #辺の緩和
  for i in range(2*n):
    for u,v,cost in edges:
      if dist[u] != inf and dist[v] > dist[u] + cost:
        dist[v] = dist[u] + cost
        if i>=n: dist[v]=-inf
  return dist

dist = BellmanFord(E,n,0)
if dist[n-1] == -inf:
	print(-1)
else:
	print(max(0,-dist[n-1]))

	

Measured memory_bytes: 43484
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)

#define X(x) ((x) % 1000000)
#define Y(x) ((x) / 1000000)
#define XY(x, y) ((y) * 1000000 + (x))


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, M, A, B;

  std::cin >> N >> M;

  std::vector<std::vector<int>> G(N + 1);

  for (int i = 0; i < M; i ++) {

    std::cin >> A >> B;

    G[A].push_back(B);
    G[B].push_back(A);
  }

  bool visit[111111][2];

  memset(visit, 0, sizeof(visit));

  visit[1][0] = true;

  std::queue<int> queue;

  queue.push(XY(1, 0));

  while (! queue.empty()) {
    int p = queue.front(), x = X(p), y = Y(p);

    queue.pop();

    for (const auto& k : G[x]) {
      if (visit[k][1 - y])
        continue;

      visit[k][1 - y] = true;

      queue.push(XY(k, 1 - y));
    }
  }

  for (int i = 1; i <= N; i ++)
    std::cerr << "  i=" << i << " visit[i][1]=" << visit[i][1] << std::endl;

  long long c = 0;

  for (int i = 1; i <= N; i ++)
    if (! visit[i][1])
      c ++;

  long long d = N - c;

  std::cerr << "c=" << c << ' ' << N * (N - 1) / 2 << ' ' << c * (c - 1) / 2 << ' ' << M << ' ' << d * (d - 1) / 2 << std::endl;

  if (c) {
    std::cout << 1LL * N * (N - 1) / 2 - c * (c - 1) / 2 - d * (d - 1) / 2 - M << std::endl;
  }
  else {
    std::cout << 1LL * N * (N - 1) / 2 - c * (c - 1) / 2 - M << std::endl;
  }

  return 0;
}


Measured memory_bytes: 6016
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
ll n,k,l,o,s;
cin >> n;
l=n;
ll p[3];
ll i=2;
while(1){
	if(n==0) break;
	k=n%10;
	n/=10;
	p[i]=k;
	i--;
}
if((p[0]==p[1])&&(p[1]==p[2])){
	cout << l<<endl;
	return 0;
}
if(p[0]==9){
	cout <<999<<endl;
	return 0;
}
o=(p[0]+1)*100+(p[0]+1)*10+(p[0]+1);
s=p[0]*100+p[0]*10+p[0];
//cout <<o<<endl;cout <<l<<endl;
if(s>=l) cout <<s<<endl;
else cout << o<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int h,w;
    while(cin>>h>>w,1){
        if(h==0&&w==0)return 0;
        for(int i=1;i<=h;i++){
            for(int n=1;n<=w;n++){
                if((i+n)%2==0)cout<<"#";
                else cout<<".";
            }cout<<endl;
        }cout<<endl;
    }
}


Measured memory_bytes: 3084
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let k: i32 = read();
    let n: i32 = read();

    let ans = if k % n == 0 { 0 } else { k % n };

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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



int main() {
  long long M = 1000000007;
  int N;
  long long K=0;
  long long ans = 0;
  cin >> N;
  vector<long> A(N); cin >> A.at(0);
  for(int i=1;i<N;++i){
    cin >> A.at(i);
    K += A.at(i);
  }

  for(int i=0;i<N-1;++i){
    ans += ((K % M) * A.at(i)) % M;
    K -= A.at(i+1);
  }
  cout << ans % M << endl;
  return 0;
}


Measured memory_bytes: 4836