akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		int n; scanf("%d", &n); if (n == 0) break;
		ll W, H; scanf("%lld %lld", &W, &H);
		vector<vector<ll>> sum(H + 1, vector<ll>(W + 1));
		for (int i = 0; i < n; i++) {
			ll w, h; scanf("%lld %lld", &w, &h);
			sum[h][w]++;
		}
		for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) sum[i + 1][j + 1] += sum[i + 1][j] + sum[i][j + 1] - sum[i][j];
		ll S, T; scanf("%lld %lld", &S, &T);
		ll res = 0;
		for (int i = 0; i <= H - T; i++) for (int j = 0; j <= W - S; j++) chmax(res, sum[i + T][j + S] - sum[i + T][j] - sum[i][j + S] + sum[i][j]);
		cout << res << "\n";
	}
	return 0;

}


Measured memory_bytes: 3200
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int digits(int n) {
    return n.to!string.map!(c => c - '0').sum;
}

int calc(int n) {
    int ans = int.max;
    for (int a = 1; a < n; a++) {
        int b = n - a;
        ans = min(ans, digits(a) + digits(b));
    }
    return ans;
}

void main() {
    int n = readint;
    auto ans = calc(n);
    writeln(ans);
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  if(c-a<=b&&c-a>=0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }  
  return 0;
}

Measured memory_bytes: 256
<?php
$numbers = fgets(STDIN);
$n = intval($numbers);
// print $n;

$array = [];
for ($i=0; $i < $n; $i++) {
    $numbers = preg_split("/[\s,]+/", rtrim(fgets(STDIN)));
    $o = $numbers[0];
    $p = $numbers[1]; // color
    if ($o == 0){
        $q = $numbers[2]; // delete
        // [$p]がredであれば、１になる。
        $array[$p] = $q;
        // print_r($array);
    } 
    else if ($o == 1){
        if (isset($array[$p])){
            echo $array[$p];
        } else {
            echo 0;

        }
        echo PHP_EOL;
    } 
    else { // 2の場合
        unset($array[$p]);
    }
}


Measured memory_bytes: 47788
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const llint big=2e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
vector<pair<int,int>> seiya[304];//制約
int dp[304][304][304]={0};
int n,m;
llint solve(int R,int G,int B){
	int r=max(R,max(G,B));
	int b=min(R,min(G,B));
	int g=R+B+G-r-b;
	//r>g>b
	if((r==g&&g!=0)||(g==b&&b!=0)){return mod;}
	if(dp[r][g][b]!=0){return dp[r][g][b];}
	//cout<<r<<" "<<g<<" "<<b<<endl;
	for(int i=0;i<seiya[r].size();i++){
		int mx=1;
		if(g>=seiya[r][i].fir){mx++;}
		if(b>=seiya[r][i].fir){mx++;}
		if(seiya[r][i].sec!=mx){dp[r][g][b]=mod;return mod;}//0ではない,どうせ後でmodとる
	}
	if(r>g+1){return dp[r][g][b]=solve(r-1,g,b);}//1つ前を考える
	llint ans=0;
	for(int i=0;i<r;i++){ans+=solve(i,g,b);}
	ans%=mod;if(ans==0){ans=mod;}
	return dp[r][g][b]=ans;
}
int main(void){
	dp[0][0][0]=1;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int l,r,x;cin>>l>>r>>x;
		seiya[r].pub(mp(l,x));
	}
	cout<<solve(n+3,n+2,n+1)%mod<<endl;
	return 0;
}


Measured memory_bytes: 107264
import java.util.*;

class Main{

    @SuppressWarnings("unchecked")
    Main(){
        Scanner SC = new Scanner(System.in);
        int N = Integer.parseInt(SC.next());
        char[] S = SC.next().toCharArray();

        TreeSet<Integer>[] alfabet = (TreeSet<Integer>[]) new TreeSet<?>[26];
        for(int i=0;i<26;i++){
            alfabet[i] = new TreeSet<Integer>();
        }

        for(int i=0;i<N;i++){
            alfabet[S[i]-'a'].add(i);
        }

        int Q = Integer.parseInt(SC.next());
        for(int i=0;i<Q;i++){
            if(SC.nextInt() == 1){
                int index = Integer.parseInt(SC.next()) - 1;
                char c    = SC.next().charAt(0);
                char p    = S[index];
                if(p != c){
                    alfabet[p-'a'].remove(new Integer(index));
                    alfabet[c-'a'].add(index);
                    S[index] = c;
                }
            } else {
                int left  = SC.nextInt()-1;
                int right = SC.nextInt()-1;
                int n = 0;
                for(int j=0;j<26;j++){
                    Integer h = alfabet[j].higher(left-1);
                    if(h != null && h <= right){
                        n++;
                    }
                }
                System.out.println(n);
            }
        }
    }

    public static void main(String[] args){
        Main main = new Main();
    }
}


Measured memory_bytes: 104752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll mo = 1000000007;
auto mod = [](ll modx) {modx%=mo;modx+=mo;modx%=mo;return modx; };
const ll MAX = 510000;
const ll MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(ll n, ll k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<ll> factorial(ll n)
{
  vector<ll> fac;
  fac.push_back(1);
  for (ll i = 1; i < n + 10; i++)
  {
    fac.push_back((fac[i - 1] * i) % mo);
  }
  return fac;
}
auto modmul = [](auto... modx) {
  ll res = 1;
  for (auto modx_ : {modx...})
  {
    res *= modx_;
    res %= mo;
    res += mo;
    res %= mo;
  }
  return res;
};
int main()
{
ll n , m ;
cin >> n >> m ;
COMinit();
vector<ll> fac = factorial(510000);
rep(i,n+1)ans=mod(ans+(i%2?-1:1)*modmul(COM(n,i),COM(m,i),fac[i],COM(m-i,n-i),fac[n-i],COM(m-i,n-i),fac[n-i]));
cout << ans << endl;
return 0;
}

Measured memory_bytes: 19388
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
const ll inf = 1LL << 60;

/*bool is_prime(int N){ //Nは奇数
bool flag = true; //false: 素数じゃない
    for(int k = 2; k*k <= N; k++){
        if(N % k == 0){
            flag = false; break;
        }
    }
    return flag;
}*/

int main(){
    //cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int N;
    cin>>N;
    cout << N << ":";
    vector<bool> is_prime(100001,true);
    vector<int> prime;
    //prime.reserve(100000);
    is_prime[0] = false; is_prime[1] = false;
    int itr = 0;
    for(int i = 2; i <= 100000; i++){
        if(is_prime[i]){
            //int push = i;
            prime.push_back(i);
            itr++;//ここで時間食う？？？？  push_backはアホほど時間食う
            //cout<<prime[itr]<<endl;
            for(int k = 2*i; k<= 100000; k += i){
                is_prime[k] = false;
            }
        }
    }
    //cout << prime.size() << endl;
    /*REP(i,prime.size()){
        cout << prime[i] << endl;
    }*/
    vector<int> ans;
    REP(i,prime.size()){
        while(N % prime[i] == 0){  //ここのループでアホ時間かかってる
            ans.push_back(prime[i]);
            N /= prime[i];
        }
        if(N == 1) break;
    }
    if(N != 1){
        ans.push_back(N);
    }
    
    REP(i,ans.size()){
        cout << " " << ans[i];
    }
    cout << endl;
    return 0;

}


Measured memory_bytes: 3292
//
// Created by David Sarpong on 5/30/20.
//

#include <iostream>
using namespace std;

int main(int argc, char** argv) {
    string S, T;
    int A, B;

    cin >> S >> T >> A >> B;

    string U;
    cin >> U;

    if (U == S) {
        A--;
    }
    else {
        B--;
    }

    cout << A << " " << B << "\n";

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n),q(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  vector<int> a(n);
  rep(i,n) a[i]=i+1;//nまで並べたものを用意
  
  map<vector<int>, int> mp;
  do {
    mp[a]=mp.size();//keyに順列を代入。aが何番目かが書かれたmapが作れる。
  }
  //next_permutationは、指定された配列(又はコンテナクラス)の順列を全て並べたときに、その配列を辞書順で次のものに置き換えるということをやってリウ
  while (next_permutation(a.begin(),a.end()));//次の順列が見つからなかったらfalseを返すからdo whileを使うとうまいこと書ける
  
  int ans = abs(mp[p]-mp[q]);
  cout << ans << endl;
  return 0; 
}


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

int main() {
  int N,Y;
  cin >> N >> Y;
  
  for(int x=0;x<=N;x++){
    for(int y=0;y<=N-x;y++){
      int z = N-x-y;
      if(10000*x+5000*y+1000*z==Y){
        cout << x << " " << y << " " << z << endl;
        return 0;
      }
    }
  }
  
  cout << "-1 -1 -1" << endl;
  return 0;
}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

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

  vector<ll> p(n);
  for (auto &x : p) {
    cin >> x;
  }

  vector<ll> q(n);
  for (auto &x : q) {
    cin >> x;
  }

  vector<ll> tmp = p;

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

  ll ip = 0;
  ll iq = 0;
  ll index = 0;
  do {
    if (p == tmp) {
      ip = index;
    }
    if (q == tmp) {
      iq = index;
    }
    index++;

  } while (next_permutation(tmp.begin(), tmp.end()));

  cout << abs(ip - iq) << endl;
}


Measured memory_bytes: 3596
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
A,B,C = map(int,input().split())
K = int(input())
flag = 0
while K > 0:
    if A < B and B < C:
        flag = 1
        break
    if A >= B:
        B *= 2
        K -= 1
    elif B >= C:
        C *= 2
        K -= 1
if flag == 1:
    print("Yes")
else:
    if A < B and B < C:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 10576
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a=sc.nextInt();
        int[] nums=new int[n];
        for(int i=0;i<n;i++){
            nums[i]=sc.nextInt();
        }
        long[][][] ans=new long[n][n+1][2501];//何個目まで見たか、何個使ったか、和
        ans[0][0][0]=ans[0][1][nums[0]]=1;
        for(int i=1;i<n;i++){
            for(int j=0;j<n+1;j++){
                for(int k=0;k<2501;k++){
                    ans[i][j][k]=ans[i-1][j][k]+(j>0&&k>=nums[i]?ans[i-1][j-1][k-nums[i]]:0);
                }
            }
        }
        long finalans=0;
        for(int i=1;i<n+1;i++){
            finalans+=ans[n-1][i][a*i];
        }
        System.out.println(finalans);
    }
    
    
}

Measured memory_bytes: 85076
#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double

#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
const ll MOD = 1000 * 1000 * 1000 + 7;
using namespace std;



ll dp[100][100005];
ll N,W;



ll seno(ll idx, ll w, ll C[][2])
{

ll Q,R;

if (idx==N)
{
  return 0;
  
}  

if (dp[idx][w]!=INT_MAX)
return dp[idx][w];  



if (w+C[idx][0]<=W)
Q=seno(idx+1,w+C[idx][0], C)+C[idx][1];
else
Q=0;

R=seno(idx+1,w,C);


return dp[idx][w]=max(Q,R);
}




int main() 
{ 



fastio();



cin>>N>>W;


ll A[N][2];


              
for (int i=0;i<N;i++)
{
  for(int j=0;j<2;j++)
  cin>>A[i][j];  
}





for(int i=0;i<100;i++)
{
for (int j=0;j<=100004;j++)
dp[i][j]=INT_MAX;
}

ll x=seno(0, 0,A);


cout<<x;




return 0;
} 




Measured memory_bytes: 78336
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 30) - 1;
int MOD = 1e9+7;
ll search(ll x,vector<ll> A){
    ll sum = 0;
    rep(i,0,A.size())sum += abs(A[i] - (x + i + 1));
    return sum;
}
main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,0,N)cin >> A[i];
    /*
    rep(i,-10,10){
        cout << search((ll)i,A) << endl;
    }
    */
    ll lo = -INF, hi = INF;
    while (abs(hi - lo) > 1)
    {
        ll mid = (hi + lo) / 2;
        (search(mid,A) - search(mid - 1,A) < 0 ? lo : hi) = mid;
    }
    /*
    ll ok = INF,ng = -INF;
    ll ans = INF*INF;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        ll num = search(mid,A);
        if(ans > num){ok = mid;ans = num;}
        else         ng = mid;
    }
    */
    cout << search(lo,A) << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a[7],ans=0;
	for(int i=0;i<7;i++)
		scanf("%lld",&a[i]);
	printf("%lld\n",(a[0]/2)*2+a[1]+(a[3]/2)*2+(a[4]/2)*2+(a[0]&a[3]&(a[4]>0)&1)+(a[0]&a[4]&(a[3]>0)&1)+(a[3]&a[4]&(a[0]>0)&1));
	return 0;
}

Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
q = [tuple(map(int, input().split())) for i in range(q)]

ans = 0
t = [0]
for i in range(1, n):
    if s[i - 1:i + 1] == "AC":
        t.append(t[i - 1] + 1)
    else:
        t.append(t[i - 1])
# print(t)
for l, r in q:
    print(t[r - 1] - t[l - 1])


Measured memory_bytes: 19820
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

bool is_prime(int n)
{
    if(n<=1)
        return false;
    for(int i=2; i*i<=n; i++){
        if(n%i==0)
            return false;
    }
    return true;
}

int gcd(int a, int b)
{
    if(b==0)
        return a;

    return gcd(b, a%b);
}

int main(){
    bool is_prime[1000000];

    is_prime[0] = is_prime[1] = false;

    for(int i=2; i<1000000; i++){
        is_prime[i] = true;
    }

    for(int i=2; i*i<1000000; i++){
        if(is_prime[i]){
            for(int j=i*i; j<1000000; j+=i){
                is_prime[j] = false;
            }
        }
    }

    while(true){
        int n;
        cin >> n;
        if(n != 0){
            int count=0;
            for(int i=2;i<=n/2;i++){
                if(is_prime[i] && is_prime[n-i]) count++;
            }
            cout << count << endl;
        }else{
            break;
        }
    }
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 100100100100100;
const ll mod = 1000000007;
int main(){
    int n,m;
   while(cin>>n>>m){
    if(n==0||m==0) return 0;
    ll ans=0;
    vector<vector<int>> a(m,vector<int>(n,0));
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            cin>>a.at(i).at(j);
        }
    }
    for(int i=0;i<n;i++){
        ll tmp=0;
        for(int j=0;j<m;j++){
            tmp+=a.at(j).at(i);
        }
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
   }
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

bool sort_fn(Pll &a, Pll &b) {
  if (a.first == b.first) {
    return a.second > b.second;
  }
  return a.first > b.first;
}

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

  vector<ll> x(n);
  vector<ll> y(n);
  for (ll i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
  }

  map<Pll, ll> m;
  for (ll i = 0; i < n; ++i) {
    for (ll j = 0; j < n; ++j) {
      if (i == j) continue;
      Pll k = mkp(x[i]-x[j], y[i]-y[j]);
      m[k]++;
    }
  }

  ll cnt = 0;
  each (i, m) {
    cnt = max(cnt, i.second);
  }
  cout << n-cnt << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, -1, 0, 1 , 1,  1, -1, -1 };

int page;
string word;
map<string, VI> mp;

int main() {
	while ( !!( cin >> word >> page ) ) {
		mp[ word ].push_back( page );
	}
	for( map<string, VI>::iterator it = mp.begin(); it != mp.end(); ++it ) {
		printf( "%s\n", it->first.c_str() );
		VI pages = it->second;
		sort( pages.begin(), pages.end() );
		for ( int i = 0; i < pages.size() - 1; i++ ) {
			printf( "%d ", pages[ i ] );
		}
		printf( "%d\n", pages[ pages.size() - 1 ] );
	}
	return 0;
}

Measured memory_bytes: 1256
n = int(input()) # 入力を受け付ける
match = 0

if 100 <= n and n <= 111:
    match = 111
elif 112 <= n and n <= 222:
    match = 222
elif 223 <= n and n <= 333:
    match = 333
elif 334 <= n and n <= 444:
    match = 444
elif 445 <= n and n <= 555:
    match = 555
elif 556 <= n and n <= 666:
    match = 666
elif 667 <= n and n <= 777:
    match = 777
elif 778 <= n and n <= 888:
    match = 888
elif 889 <= n and n <= 999:
    match = 999

print(match)

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

int main() {
   int H,W,K;
   cin >> H >> W >> K;
   vector<vector<char>> C(H,vector<char>(W));
   int count=0;
   for (int i=0; i<H; i++) {
       for (int j=0; j<W; j++) {
           cin >> C.at(i).at(j);
           if (C.at(i).at(j)=='#') count++;
       }
   }
   int total=0;
   for (int tmp=0; tmp<(1<<12); tmp++) {
       bitset<12> s(tmp);
       int count2=0;
       for (int i=0; i<H; i++) {
           for (int j=0; j<W; j++) {
               if (s.test(i) || s.test(j+6)) {
                   if (C.at(i).at(j)=='#') count2++;
               }
           }
       }
       if (count-count2==K) total++;
   }
   cout << total/pow(2,12-H-W) << endl;
}

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


//INSERT ABOVE HERE
signed main(){
  int n,k;
  cin>>n>>k;
  for(int b=0;b<(1<<n);b++){
    if(__builtin_popcount(b)!=k) continue;
    cout<<b<<":";
    for(int i=0;i<n;i++)
      if((b>>i)&1) cout<<" "<<i;
    cout<<"\n";
  }
  cout<<flush;
  return 0;
}


Measured memory_bytes: 3120
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  int scan; // scanf result
  int k; // to input 
  char s[102]; // to input 

  scan = scanf("%d", &k);
  scan = scanf("%s", s);

  int slen;
  slen = strlen(s);

  char answer[105];

  if (slen <= k) {
    printf("%s", s);
  } else {
    for (int n = 0; n < k; n++) {
      answer[n] = s[n];
    }
    answer[k] = '.';
    answer[k + 1] = '.';
    answer[k + 2] = '.';
    printf("%s", answer);
  }

  return (0);
}


Measured memory_bytes: 1720
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) REP(i, 0, n)

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

    vector<ll> a(N);

    rep(i, N) cin >> a[i];

    sort(a.begin(), a.end(), greater<ll>());

    ll alice = 0, bob = 0;
    rep(i, N)
    {
        if (i % 2 == 0)
        {
            alice += a[i];
        }
        else
        {
            bob += a[i];
        }
    }

    cout << alice - bob << endl;
}


Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int a, b, m;
    cin >> a >> b >> m;
    vector<int> as(a); cin >> as;
    vector<int> bs(b); cin >> bs;
    int ans = *min_element(as.begin(), as.end()) + *min_element(bs.begin(), bs.end());
    for(int i = 0; i < m; i++){
        int x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        int cand = as[x] + bs[y] - c;
        ans = min(ans, cand);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

vi a;
vvi g;
vi par;

ll evaluation(int u) {
  if ((int)g[u].size() == 1) {
    return a[u];
  }
  ll sum_childs = 0;
  vll childs;
  for (int v : g[u]) {
    if (v == par[u]) {
      continue;
    }
    ll tmp = evaluation(v);
    childs.push_back(tmp);
    sum_childs += tmp;
  }
  sort(all(childs));
  ll min_a, max_a;
  max_a = sum_childs;

  if (childs.back() * 2 >= sum_childs) {
    min_a = childs.back();
  } else {
    min_a = (sum_childs + 1) / 2;
  }

  if (a[u] < min_a || max_a < a[u]) {
    printf("NO\n");
    exit(0);
  }
  return sum_childs - (sum_childs - a[u]) * 2;
}

void search_main(int root) {
  ll sum_child = 0;
  vll childs;
  for (int u : g[root]) {
    ll tmp = evaluation(u);
    childs.push_back(tmp);
    sum_child += tmp;
  }
  if (a[root] * 2 != sum_child) {
    printf("NO\n");
    exit(0);
  }
  sort(all(childs));
  if (childs.back() * 2 > sum_child) {
    printf("NO\n");
    exit(0);
  }
}

int main() {
  int n;
  scanf("%d", &n);
  a.resize(n);
  rep (i, n) {
    scanf("%d", &a[i]);
  }
  g.resize(n);
  rep (i, n-1) {
    int u, v;
    scanf("%d %d", &u, &v);
    u -= 1;
    v -= 1;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  if (n == 2) {
    if (a[0] == a[1]) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
    return 0;
  }
  int root = 0;
  rep (i, n) {
    if (g[root].size() < g[i].size()) {
      root = i;
    }
  }
  par.resize(n);
  par[root] = root;
  deque<int> st;
  for (int u : g[root]) {
    par[u] = root;
    st.push_back(u);
  }
  while (!st.empty()) {
    int u = st.front();
    st.pop_front();
    for (int v : g[u]) {
      if (v == par[u]) {
        continue;
      }
      par[v] = u;
      st.push_back(v);
    }
  }
  search_main(root);
  printf("YES\n");

  return 0;
}


Measured memory_bytes: 15872
package main

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

func main() {
	sc := NewScanner()
	S := sc.NextLine()

	mp := map[byte]int{}
	for _, v := range S {
		mp[byte(v)]++
	}
	if len(mp) == 2 {
		for _, v := range mp {
			if v != 2 {
				fmt.Println("No")
				return

			}
		}
		fmt.Println("Yes")

		return
	}
	fmt.Println("No")

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep2(i,st,ed) for(int i = st; i <= ed; ++i)
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
const ll mod = 1e9 + 7;
const ll N = 2e5 + 200;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;



int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll tmp = a * c;
	tmp = max(tmp, a * d);
	tmp = max(tmp, b * c);
	tmp = max(tmp, b * d);
	cout << tmp << endl;

	return 0;
}

Measured memory_bytes: 3644
s = str(input())
k = int(input())
lis = []
for u in range(6):
	for i in range(len(s)):
		try:
			if s[i:i+u] == "":
				continue
			if s[i:i+u] not in lis:
				lis.append(s[i:i+u])
		except:
			continue
lis.sort()
print(lis[k-1])


Measured memory_bytes: 3932
#include<bits/stdc++.h>
using namespace std;
int a,b,o;
string s;
int main()
{
	cin>>a>>b;
	cin>>s;
	s=' '+s;
	for(int i=1;i<=a+b+1;i++)
	    if(i!=a+1 && (s[i]<'0' || s[i]>'9'))
		    o=1;
	if(s[a+1]!='-') o=1;
    if(o==1) cout<<"No"<<endl;
	else cout<<"Yes"<<endl; 
	return 0;
}

Measured memory_bytes: 256
/*input

*/
/*
Contest: 
Problem: 
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#define F first
#define S second
#define mp make_pair
#define append push_back
#define vi vector<ll>
#define pii pair<ll,ll>
#define qi queue<ll>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define print(a) cout<<a<<endl
#define sorted(a) sort(arr.begin(), arr.end())
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define read(a) scanf("%d", &a)
#define int long long int
 
const int MOD = 1e9 + 7, MAXN = 1e2 + 10, MAXW = 1e5 + 10;

int N, W;
vector<int> value, weight;
int dp[MAXN][MAXW];

int solve(int i, int we){
    if(i < 0)
        return 0;
    if(dp[i][we] != -1)
        return dp[i][we];
    if(weight[i] > we)
        return dp[i][we] = solve(i - 1, we);
    else
        return dp[i][we] = max(solve(i - 1, we), value[i] + solve(i - 1, we - weight[i]));
}

signed main(){
    
    cin>> N >> W;

    value.resize(N);
    weight.resize(N);

    for(int i = 0; i < N; i++)
        cin>> weight[i] >> value[i];

    mem(dp, -1);

    print(solve(N-1, W));

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

Measured memory_bytes: 86144
n, d = gets.split.map(&:to_i)
x = []
n.times do
  x << gets.split.map(&:to_r)
end

cnt = 0
x.each_with_index do |y, yi|
  x.each_with_index do |z, zi|
    next if yi == zi
    cnt += 1 if ( y.zip(z).map{|(yy,zz)|(yy-zz)**2}.inject(:+) )**(1/2.0) % 1 == 0
  end
end
p cnt/2



Measured memory_bytes: 1788
n=gets.to_i
l=gets.split.map(&:to_i).sort
c=0
n.times do |i|
  j=i-1
  k=0
  while k<j
    if l[i]>=l[j]+l[k]
      k+=1
    else
      c+=j-k
      j-=1
    end
  end
end
puts c


Measured memory_bytes: 1912
#include <stdio.h>

int main(void)
{
	int a, i;
	char s[7] = {};
	
	scanf("%s", s);
	a = 0;
	for(i = 0; i < 6; i++)
	{
		a += (s[i] == '1');
	}
	
	printf("%d\n", a);
	
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

ll func(ll a, ll b, ll c) {
	ll smax, smin;
	smax = max(a, b);
	smax = max(smax, c);
	smin = min(a, b);
	smin = min(smin, c);
	return smax - smin;
}
bool bColor[8];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N,a[110],r = 0,c = 0;
	scanf("%d", &N);
	REP(i, N) {
		scanf("%d", &a[i]);
		bColor[a[i] / 400] = true;
		if (a[i] >= 3200)r++;
	}
	REP(i, 8) if (bColor[i])c++;
	cout << max(c,1) << " " << c+r << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
        scanf("%d", &n);
        double ara[n+1];
        int j = 1, i;
        for(i = 0; i < n; i++)cin>>ara[i];
        sort(ara, ara+n);
        for(i = 0; i < n; i++)
        {
            ara[i+1] = (ara[i] + ara[i+1])/2;
        }
        cout<<ara[i-1]<<endl;
}


Measured memory_bytes: 256
class UseTime
  def initialize login
    @login = login
    @logout = -1
    @pc_num = 1
  end
  attr_accessor :login, :logout, :pc_num
end

def main
  loop do
    pc_num,student_num = gets.chomp.split(' ').map(&:to_i)
    break if (pc_num|student_num) == 0

    log_num = gets.chomp.to_i

    log_list = Array.new(student_num + 1).map{Array.new()}
    log_num.times do
      time,pc,student,action = gets.chomp.split(' ').map(&:to_i)
      case action
      when 1
        if log_list[student].size == 0 \
          or log_list[student][-1].logout != -1
          log_list[student] << UseTime.new(time)
          next
        end
        log_list[student][-1].pc_num += 1
      when 0
        log_list[student][-1].pc_num -= 1
        if log_list[student][-1].pc_num == 0
          log_list[student][-1].logout = time
        end
      end
    end

    question_num = gets.chomp.to_i
    question_num.times do
      start_time,end_time,student = gets.chomp.split(' ').map(&:to_i)

      total = 0
      log_list[student].each do |record|
        if record.logout < start_time
          next
        end

        if record.login > end_time
          break
        end

        s = (record.login < start_time) ? start_time : record.login
        e = (record.logout > end_time) ? end_time : record.logout
        total += e - s
      end
      puts total
    end
  end
end

main

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

int main(){
	int l;
	int mx,mxt;
	int now;
	int t,t1;
	while(cin >> l && l){
		int now=0,mxt=0;
		for(int i=1;i<=12;i++){
			cin >> t1 >> t;
			now += t1-t;
			if(now>=l && !mxt){
				mxt = i;
			}
		}
		if(mxt){
			cout << mxt << endl;
		}else{
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int	
#define INF					1e5+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(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; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }


int main()
{
	int n, a;
	cin >> n >> a;
	int ans = 0;
	if (n < a)
		ans = 0;
	else
		ans = 10;
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import Counter
from pprint import pprint
from math import gcd
from functools import reduce

def myinput():
    return map(int,input().split())

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

k = int(input())

def gcd3(*numbers):
    return reduce(gcd, numbers)

ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans += gcd3(a,b,c)
print(ans)

Measured memory_bytes: 70372
#include<iostream>
#include<algorithm>
using namespace std;
long A,B,C,D,N;
main()
{
  cin>>A>>B>>C>>D>>N;
  B=min(B,2*A);
  C=min(C,2*B);
  D=min(D,2*C);
  cout<<N/2*D+N%2*C<<endl;
}

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

using namespace std;

int main(){
    long N, K;
    long R, S, P;
    string T;
    cin>>N>>K;
    cin>>R>>S>>P;
    cin>>T;

    long ans = 0;

    for(int i=0; i<K; ++i){
        int a=0, b=0, c=0; // 一個前がそれぞれグーチョキパー
        int aa, bb, cc;
        int j=0;
        while(i+j*K<N){
            if(T[i+j*K] == 'r'){
                aa = c;
                bb = c;
                cc = max(a, b)+P;
            }else if(T[i+j*K] == 's'){
                aa = max(b, c)+R;
                bb = a;
                cc = a;
            }else if(T[i+j*K] == 'p'){
                aa = b;
                bb = max(a, c)+S;
                cc = b;
            }

            a=aa;
            b=bb;
            c=cc;

            ++j;
        }

        ans += max(a, max(b, c));
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 512
/*2020/03/15 ABC 050*/

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;  


int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0; i<n; i++) cin >> vec[i];
    sort(vec.begin(), vec.end());
    int j=-1, k=0;
    if(n%2==0) {
        for(int i=0; i<n; i++) {
            if(i%2==0) j+=2;
            if(vec[i]!=j) {
                cout << 0 << endl;
                return 0;
            }
        }
    } else {
        for(int i=0; i<n; i++) {
            if(i%2!=0) k+=2;
            if(vec[i]!=k) {
                cout << 0 << endl;
                return 0;
            }
        } 
    }
    int ans=1;
    for(long i=0; i<n/2; i++){
            ans *= 2;
            ans %= (1000000000+7);
        }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


int main(){
	
	int n;
	while(cin>>n){
		if(n==0)break;
		
		int t=0;
		int f=0;
		
		int cn = n;
		while(cn!=0){
			cn/=2;
			t+=cn;
		}
		
		int dn = n;
		while(dn!=0){
			dn/=5;
			f+=dn;
		}
		
		printf("%d\n",min(t,f));
	}
}

Measured memory_bytes: 1132
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

A, B, C = map(int, readline().split())

x = 0
visited = set()
while True:
    x += 1
    tmp = B * x + C
    div = tmp % A
    if div == 0:
        print('YES')
        quit()
    if div in visited:
        print('NO')
        quit()
    visited.add(div)

Measured memory_bytes: 3064
#include<stdio.h>

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


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

int main () {
  int N; cin >> N;
  
  vector<int>A= {1,2,4,8,16,32,64};
  int max =64;
  for (int i=0; i<A.size(); i++) {
    if (A.at(i) <= N) 
      max = A.at(i);
  }
  cout << max << endl;
}

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

int cnt;

int gcd(int w,int m){
  if ( m ==0)return w;
  cnt++;
  return gcd(m,w%m);
}

int solve(int *a){
  cnt=0;
  int g = gcd(a[0],a[1]);
  cout << g<<" " << cnt << endl;
}

main(){
  int a[2];
  while(cin>>a[0]>>a[1]){
    if ( a[0]==0&&a[1]==0)break;
    if ( a[0]<a[1])swap(a[0],a[1]);

    solve(a);
  }
}

Measured memory_bytes: 0
import java.util.*;
import java.awt.geom.*;

public class Main{
	double EPS = 1.0e-08;
	
	//1755 start
	//1831 sample match
	private void doit() {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			Point2D [] plist = new Point2D[n];
			for(int i = 0; i < n; i++){
				plist[i] = new Point2D.Double(sc.nextDouble(), sc.nextDouble());
			}
			Line2D [] lineList = new Line2D[n];
			for(int i = 0; i < n; i++){
				Point2D from = plist[i], to = plist[(i+1) % n];
				Line2D nowSegment = new Line2D.Double(from, to);
				lineList[i] = segmentToLine(nowSegment);
			}
			
			ArrayList<Point2D> polygon = new ArrayList<Point2D>();
			for(int i = 0; i < n; i++){
				polygon.add(plist[i]);
			}
			boolean ansflg = true;
			for(int i = 0; i < n; i++){
				polygon = polygoncut(polygon, lineList[i]);
				if(polygon.size() == 0){
					ansflg = false;
					break;
				}
			}
			System.out.println(ansflg ? 1:0);
		}

	}
	private ArrayList<Point2D> polygoncut(ArrayList<Point2D> polygon, Line2D l) {
		ArrayList<Point2D> res = new ArrayList<Point2D>();
		int n = polygon.size();
		for(int i = 0; i < n; i++){
			Point2D from = polygon.get(i), to = polygon.get((i+1) % n);
			if(l.relativeCCW(from) <= 0){
				res.add(from);
			}
			
			int temp1 = l.relativeCCW(from);
			int temp2 = l.relativeCCW(to);
			if(temp1 * temp2 < 0){
				Line2D l2 = new Line2D.Double(from, to);
				Point2D intersectpt = intersectPtSS(l,l2);
				res.add(intersectpt);
			}
		}
		
		return res;
	}
	private Point2D intersectPtSS(Line2D l, Line2D m) {
		Point2D lV = sub(l.getP2(), l.getP1());
		Point2D mV = sub(m.getP2(), m.getP1());
		Point2D m1l1V = sub(m.getP1(), l.getP1());
		double a = cross(m1l1V, lV);
		double b = cross(lV, mV);
		if(Math.abs(a) < EPS && Math.abs(b) < EPS){
			return l.getP1();
		}
		double t = a / b;
		double x = m.getX1() + t * mV.getX();
		double y = m.getY1() + t * mV.getY();
		return new Point2D.Double(x, y);
	}
	private double cross(Point2D p1, Point2D p2) {
		double res = p1.getX() * p2.getY() - p1.getY() * p2.getX();
		return res;
	}
	private Line2D segmentToLine(Line2D l) {
		final int K = 10000;
		Point2D Vec = sub(l.getP2(), l.getP1());
		Point2D p1 = new Point2D.Double(K * Vec.getX() + l.getX1(), K * Vec.getY() + l.getY1());
		Point2D p2 = new Point2D.Double(-K * Vec.getX() + l.getX1(), -K * Vec.getY() + l.getY1());
		return new Line2D.Double(p2, p1);
	}
	private Point2D sub(Point2D p1, Point2D p2) {
		double x = p1.getX() - p2.getX();
		double y = p1.getY() - p2.getY();
		return new Point2D.Double(x, y);
	}
	public static void main(String [] args){
		new Main().doit();
	}
}

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

using namespace std;

template<unsigned mod>
struct RollingHash {
    vector<unsigned> hashed, power;

    inline unsigned mul(unsigned a, unsigned b) const {
        unsigned long long x = (unsigned long long) a * b;
        unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
        asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
        return m;
    }

    //RollingHash(s,base):文字列sのハッシュテーブルを構築
    explicit RollingHash(const string &s, unsigned base = 10007) {
        int sz = (int) s.size();
        hashed.assign(sz + 1, 0);
        power.assign(sz + 1, 0);
        power[0] = 1;
        for (int i = 0; i < sz; ++i) {
            power[i + 1] = mul(power[i], base);
            hashed[i + 1] = mul(hashed[i], base) + s[i];
            if (hashed[i + 1] >= mod) hashed[i + 1] -= mod;
        }
    }

    //区間[l,r)のハッシュ値を求める
    unsigned get(int l, int r) const {
        unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
        if (ret >= mod) ret -= mod;
        return ret;
    }

    //ハッシュ値h1と長さh2lenのハッシュ値h2を結合
    unsigned connect(unsigned h1, int h2, int h2len) const {
        unsigned ret = mul(h1, power[h2len]) + h2;
        if (ret >= mod) ret -= mod;
        return ret;
    }

    //区間[l1,r1)とハッシュテーブルがbからなる区間[l2,r2)の文字列の最長共通接頭辞の長さを求める
    int LCP(const RollingHash<mod> &b, int l1, int r1, int l2, int r2) {
        int len = min(r1 - l1, r2 - l2);
        int low = -1, high = len + 1;
        while (high - low > 1) {
            int mid = (low + high) / 2;
            if (get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
            else high = mid;
        }
        return (low);
    }
};

const auto MOD = (int) 1e9 + 7;

int main() {
    string s, t;
    cin >> s >> t;

    RollingHash<MOD> rh_s(s), rh_t(t);
    auto rolling_hash_t = rh_t.get(0, (int) t.size());

    for (int i = 0; i + t.size() <= s.size(); ++i) {
        if (rh_s.get(i, i + (int) t.size()) == rolling_hash_t) {
            cout << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 11920
#include<stdio.h>

int main(void){
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a>b) printf("a > b\n");
	else if(a<b) printf("a < b\n");
	else printf("a == b\n");
	
	return 0;
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}



signed main(){
   cin.tie(0);ios::sync_with_stdio(false);
   cout<<fixed<<setprecision(20);
   int n;cin>>n;
   cout<<((n-1)/111 +1) *111<<endl;


}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
int INF=1000000007;
using ll=long long;

int main(){
	int ans=0,ans2=0;
	string s;
	cin>>s;
	rep(i,0,s.size()){
		if(i%2==1){
			if(s[i]=='1')ans++;
			if(s[i]=='0')ans2++;
		}
		if(i%2==0){
			if(s[i]=='0')ans++;
			if(s[i]=='1')ans2++;
		}
	}
	ans=min(ans,ans2);
	cout<<ans<<endl;
}


Measured memory_bytes: 512