akhauriyash/Code-Regression huggingface dataset:
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, M, L;
    scan(N, M, L);
    auto G1 = new long[][](N, N);
    foreach (i; 0 .. N)
        G1[i][] = long.max >> 2;
    foreach (i; 0 .. N)
        G1[i][i] = 0;
    foreach (_; 0 .. M)
    {
        long a, b, c;
        scan(a, b, c);
        a--, b--;
        G1[a][b] = G1[b][a] = c;
    }
    foreach (k; 0 .. N)
        foreach (i; 0 .. N)
            foreach (j; 0 .. N)
                if (G1[i][k] + G1[k][j] < G1[i][j])
                    G1[i][j] = G1[i][k] + G1[k][j];
    auto G2 = new long[][](N, N);
    foreach (i; 0 .. N)
        G2[i][] = long.max >> 2;
    foreach (i; 0 .. N)
        G2[i][i] = 0;
    foreach (i; 0 .. N)
        foreach (j; 0 .. N)
            if (G1[i][j] <= L)
            {
                G2[i][j] = min(G2[i][j], 1);
            }
    foreach (k; 0 .. N)
        foreach (i; 0 .. N)
            foreach (j; 0 .. N)
                if (G2[i][k] + G2[k][j] < G2[i][j])
                    G2[i][j] = G2[i][k] + G2[k][j];
    long Q = lread();
    foreach (_; 0 .. Q)
    {
        long s, t;
        scan(s, t);
        s--, t--;
        writeln(G2[s][t] == long.max >> 2 ? -1 : G2[s][t] - 1);
    }
}


Measured memory_bytes: 8828
n, a, b = map(int, input().split())
ans = 0

for num in range(1, n+1):
  bits = list()
  numm = num
  while num > 0:
    tmp = num % 10
    bits.append(tmp)
    num -= tmp
    num /= 10
  if a <= sum(bits) <= b:
    ans += numm

print(ans)




Measured memory_bytes: 3060
#include <iostream>
#define ll long long
using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;
	int num = 1;
	while(n--)
	{
		if(num*2 < num+k)
		num = num * 2 ;
		else num = num + k;
	}
	cout<<num<<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 < (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 1e9
constexpr int maxd = 50*50+100;
ll dp[51][51][maxd];

int main(){
  int N, A;
  cin >> N >> A;
  vector<int> x(N);
  REP(i, N){
    cin >> x[i];
  }
  dp[0][0][0] = 1;
  REP(i, N){
    REP(j, i+1){
      REP(k, A*N+1){
        dp[i+1][j][k] += dp[i][j][k];
        dp[i+1][j+1][k+x[i]] += dp[i][j][k];
      }
    }
  }
  ll ans = 0;
  for(int k = 1; k <= N; k++){
    ans += dp[N][k][A*k];
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 51072
import java.util.*;
import java.io.*;

class Main {
    static class State implements Comparable<State> {
        int d;
        String r;
        State(int d, String r) {
            this.d = d;
            this.r = r;
        }
        public boolean equals(Object s) {
            if(s instanceof State) {
                return compareTo((State)s) == 0;
            }
            return false;
        }
        public int hashCode() {
            return 1023 * d + r.hashCode();
        }
        public int compareTo(State s) {
            int dd = d - s.d;
            return dd < 0 ? -1 : (dd > 0 ? 1 : r.compareTo(s.r));
        }
    }
    public static void main(String [] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        String [] cs = new String[n];
        HashSet<String> edges2 = new HashSet<String>();
        for(int i = 0; i < n; i++) {
            cs[i] = br.readLine();
            edges2.add(cs[i]);
        }
        HashMap<String,ArrayList<String>> edges = new HashMap<String,ArrayList<String>>();
        for(String c : cs) {
            final int l = c.length();
            for(int i = 0; i < l; i++) {
                String pre = c.substring(0, l - i);
                String suf = c.substring(l - i);
                if(edges.get(pre) == null) {
                    edges.put(pre, new ArrayList<String>());
                }
                edges.get(pre).add(suf);
            }
        }
        PriorityQueue<State> que = new PriorityQueue<State>();
        for(String c : cs) {
            for(String d : cs) {
                if(c.equals(d)) continue;
                if(c.startsWith(d)) {
                    int rr = d.length();
                    que.add(new State(rr, c.substring(rr)));
                }
            }
        }
        HashSet<String> done = new HashSet<String>();
        while(que.size() > 0) {
            State s = que.poll();
            //System.out.println("pop " + s.r + " at " + s.d);
            if(s.r.length() == 0) {
                System.out.println(s.d);
                return;
            }
            if(done.contains(s.r)) continue;
            done.add(s.r);
            final int srl = s.r.length();
            for(int i = 1; i < srl; i++) {
                String sri = s.r.substring(0,i);
                if(edges2.contains(sri) && !done.contains(sri)) {
                    que.add(new State(s.d + i, s.r.substring(i)));
                }
            }
            ArrayList<String> es = edges.get(s.r);
            if(es == null) continue;
            for(String q : es) {
                if(done.contains(q)) continue;
                que.add(new State(s.d + srl, q));
            }
        }
        System.out.println(0);
    }
}



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

using namespace std;

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

  long N,A,B; cin>>N>>A>>B;
  if ((B-A)%2 == 0) {
    auto ans = (B-A)/2;
    cout << ans << endl;
  } else {
    auto ans = min(A-1, N-B)+1+(B-A)/2;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
#define N 200100

struct node {
	ll num;
	int id;
	bool operator < (const node& x) const {
		return x.num<num;
	}
}g[N];
ll c,ans,now;
ll f[N],x[N];
int n,v[N];

/*ll read()
{
	int c=getchar(); ll x=0;
	while (c<'0' || c>'9') c=getchar();
	while (c>='0' && c<='9') x=x*10+c-'0',c=getchar();
	return x;
}*/

int main()
{
	scanf("%d%lld",&n,&c);
	for (int i=1;i<=n;i++) scanf("%lld%d",&x[i],&v[i]); x[n+1]=c;
	for (int i=n;i;i--) g[i].num=g[i+1].num+v[i]-(x[i+1]-x[i]),g[i].id=i;
	//g[n+1].num=0; g[n+1].id=n+1;
	sort(g+1,g+n+1);
	int cur=1;
	ans=max(ans,g[1].num);
	for (int i=1;i<=n;i++)
	{
		while (g[cur].id<=i && cur<=n) cur++;
		now+=v[i]-2*(x[i]-x[i-1]);
		ans=max(ans,now+max(0ll,g[cur].num));
	}
	
	for (int i=1;i<=n;i++) g[i].num=g[i-1].num+v[i]-(x[i]-x[i-1]),g[i].id=i;
	sort(g+1,g+n+1);
	cur=1; now=0;
	ans=max(ans,g[1].num);
	for (int i=n;i;i--)
	{
		while (g[cur].id>=i && cur<=n) cur++;
		now+=v[i]-2*(x[i+1]-x[i]);
		ans=max(ans,now+max(0ll,g[cur].num));
	}
	
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<long long> A(N + 2, 0);
    vector<long long> sum(N + 2, 0);
    for(int i = 1; i <= N; i++)cin >> A[i];
    for(int i = 0; i < N + 1; i++){
        sum[i + 1] = sum[i] + abs(A[i + 1] - A[i]);
    }
    
    for(int i = 1; i <= N; i++){
        long long cost = sum[i - 1] + abs(A[i + 1] - A[i - 1]) + sum[N + 1] - sum[i + 1];
        cout << cost << endl;
    }
    return 0;
}


Measured memory_bytes: 2816
#include<stdio.h>
int main(void){
	char all[10];
	int a,cnt=0,max=0;
	scanf("%s",all);
	for(a=0;a<10;a++){
		if(all[a]=='A'){
			cnt++;
			if(a==9){
				if(max<cnt){
					max=cnt;
				}
			}
		}
		else if(all[a]=='T'){
			cnt++;
			if(a==9){
				if(max<cnt){
					max=cnt;
				}
			}
		}
		else if(all[a]=='G'){
			cnt++;
			if(a==9){
				if(max<cnt){
					max=cnt;
				}
			}
		}
		else if(all[a]=='C'){
			cnt++;
			if(a==9){
				if(max<cnt){
					max=cnt;
				}
			}
		}
		else{
			if(max<cnt){
				max=cnt;
				cnt=0;
			}else{
				cnt=0;
			}
		}
	}
	printf("%d",max);
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <utility>

using namespace std;
using P = pair<int,int>;

int main() {
    int h,w,d;
    cin >> h >> w >> d;

    vector<P> p(h*w+1);
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            int a;
            cin >> a;
            p[a] = {i,j};
        }
    }

    vector<long> csum(h*w+1, 0);
    for (int i=1; i<=h*w; i++) {
        if (i+d > h*w) break;
        int dist = abs(p[i].first - p[i+d].first) + abs(p[i].second - p[i+d].second);
        csum[i+d] += csum[i];
        csum[i+d] += dist;
    }

    int q;
    cin >> q;
    for (int i=0; i<q; i++) {
        int l,r;
        cin >> l >> r;
        cout << csum[r] - csum[l] << endl;
    }
}


Measured memory_bytes: 4200
#include<stdio.h>
int main(void)
{
	int i,a,b,c,d=0,p=0;
	scanf("%d %d %d\n",&a,&b,&c);
	for(i=a;i<=b;i++){
		p=c%i;
		if(p==0)
		d++;
	}
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 1852
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <stdio.h>
#include<string.h>

using namespace std;
int main() {
	long long N, ans = 0,a=0;
	cin >> N;
	char s[1000000] = {};
		cin >> s;
  for(int i=0;i<=strlen(s);i++){
      a=0;
      if(s[i]>=65&&s[i]+N<=90) s[i]=s[i]+N;
      else if(s[i]+N>90){
        a=90-s[i]+1;
        s[i]=65;
        s[i]=s[i]+N-a;
  }
  }

printf("%s\n", s);
}

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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define STDIO
#define MP make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define PF push_front 
#define PB push_back
#define PP push
#define lb lower_bound 
#define ub upper_bound

inline void checkmin(int &x, int y){x = min(x, y);}
inline void checkmax(int &x, int y){x = max(x, y);}

int main() 
{
	#ifndef STDIO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    int x;
    cin>>x;
    int a=x/500*500;
    x-=a;
    int b=x/5*5;
    cout<<a*2+b<<endl;
    /* end code */
	return 0;
}

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


def judge(x, y):
    p2, q2 = 4 * x - y, y - 2 * x
    return p2 % 2 == 0 and q2 % 2 == 0 and p2 >= 0 and q2 >= 0


def main():
    x, y = (int(z) for z in input().split())
    if judge(x, y):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
#include <numeric>
#include <iostream>
#include <array>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>


using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vi>;
const ll MOD = 1e9 + 7;
vi alphabet = { 'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z' };



int main() {
	int N;
	cin >> N;
	vvi F(N, vi(10));
	rep(i, N) {
		rep(j, 10) {
			cin >> F[i][j];
		}
	}
	vvi P(N, vi(11));
	rep(i, N) {
		rep(j, 11) {
			cin >> P[i][j];
		}
	}
	vi ans;
	for (int bit = 1; bit < (1 << 10); ++bit) {
		vi c(N);
		int sum = 0;
		rep(i, 10) {
			if (bit & (1 << i)) {
				rep(j, N) {
					if (F[j][i] == 1) {
						c[j]++;
					}
				}
			}
		}
		rep(i, N) {
			sum += P[i][c[i]];
		}
		ans.push_back(sum);
	}
	sort(ans);
	riverse(ans);
	cout << ans[0] << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
LOCAL = len(sys.argv) > 1 and sys.argv[1] == 'LOCAL'


def dprint(*args):
  if LOCAL:
    print(*args)


MOD = 10**9 + 7

n = int(input())
a = list(map(int, input().split()))

# https://note.nkmk.me/python-gcd-lcm/

import math
from functools import reduce
import fractions


def lcm_base(x, y):
  return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
  return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)


lcm = lcm_list(a)
dprint(lcm)

ans = 0
for x in a:
  ans += lcm // x
print(ans % MOD)


Measured memory_bytes: 5608
import math

N, K = map(int, input().split())
ans = []

for i in range(1, N+1):
    ans.append(math.ceil(math.log(max(1, K/i), 2)))

ans2 = 0

for i in ans:
    ans2 += 1 / 2**i / N

print(ans2)


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

using namespace std;

#define allof(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define exists(s, e) (s.find(e)!=s.end())
#define INF 0x3f3f3f3f
#define endl '\n'
#define mp make_pair
#define watch(x) cout << (#x) << " is " << (x) << endl;

typedef pair<int, int> pii;
typedef long long ll;

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

void solve() {
    int n; cin >> n;
    bool check = true;
    for(int i=0; i<n; i++) {
        ll a, b, c; cin >> c >> a >> b;
        if(a+b>c) check = false;
        else if(a+b<c) {
            if(abs(c-a-b)%2!=0) check = false;
        }
    }
    if(check) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

int main()
{
    int x,y;
    cin >> x >> y;

    for(int t=0;t<=x;t++){
        int k = x-t;
        if(y == (2*t)+(4*k)){cout << "Yes" << endl; return 0;}
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
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; }

int main() {
	int n;
	cin >> n;
	vector<int>d(n);
	rep(i, n) {
		cin >> d[i];
	}
	int ans = 0;
	for (int i = 0;i < n;++i) {
		for (int j = i + 1;j < n;++j) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(void)
{
    int r, g, b, n;
    cin >> r;
    cin >> g;
    cin >> b;
    cin >> n;
    int cnt = 0;
    for (int i = 0; i < n / r + 1; i++)
    {
        for (int j = 0; j < (n - i * r) / g + 1; j++)
        {
            if ((n - i * r - j * g) % b == 0)
                cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort()
amax = a[-1]
isok = [True]*(amax+1)
ans = 0
if n == 1:
    print(1)
    exit()
for i in range(n):
    x = a[i]
    if isok[x]:
        if i == 0 and a[i] != a[i+1]:
            ans += 1
        elif i == n-1 and a[i] != a[i-1]:
            ans += 1
        elif a[i] != a[i+1] and a[i] != a[i-1]:
            ans += 1
        orix = x
        while x<=amax:
            isok[x]=False
            x+=orix
print(ans)


Measured memory_bytes: 92692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    string s="MARCH";
    vector<ll> c(5,0);

    int N;
    cin >> N;
    //入力した文字列tの1文字目がsのどれか(MARCH)ならcのカウントを増やす
    for(int i=0;i<N;i++){
        string t;
        cin >> t;
        for(int j=0; j<5; j++){
            if(t[0]==s[j]){
                c[j] ++;
            }
        }
    }

    //先頭の文字は異なっていなければいけない
    //ci*cj*ckを全てのi,j,kについて足し合わせれば良い
    ll ans=0;
    for(int i=0; i<3;i++){
        for(int j=i+1; j<4; j++){
            for(int k=j+1; k<5; k++){
                ans += c[i]*c[j]*c[k];
            }
        }
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3604
#200412C
K = int(input())
import math

ans = 0
for i in range(K):
    for k in range(K):
        x = math.gcd(i+1,k+1)
        if x==1:
            ans +=K
        else:
            for l in range (K):
                ans += math.gcd(x, l+1)
            
print(int(ans))

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
 
#define rep for(int i = 0;i<n;i++)
const int MOD = 1000000007;
 
int main(){
    int n;cin >> n;
    int a[n];rep{
        cin >> a[i];
    }
    int ans = 1;
    int frag = 0;
    for(int i = 1;i<n;i++){
        if(a[i-1] < a[i] and frag != -1){
            frag = 1;
        }else if(a[i-1]>a[i] and frag != 1){
            frag = -1;
        }else if(a[i-1]==a[i]){
            
        }else{
            ans += 1;
            frag = 0;
        }
        //cout << ans << endl;
    }
    cout << ans << endl;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, m;
    cin >> n >> m;
    vll a(n), c(m);
    rep(i, n) cin >> a[i];
    vi b(m);
    rep(i, m) cin >> b[i] >> c[i];
    map<ll, int> cnt;
    rep(i, n) cnt[a[i]]++;
    rep(i, m) cnt[c[i]] += b[i];
    ll ans = 0;
    for (auto it=cnt.rbegin(); it!=cnt.rend(); ++it) {
        if (n==0) break;
        int num = it->second;
        if (n < num) {
            ans += n * it->first;
            break;
        }
        else {
            ans += num * it->first;
            n -= num;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define int long long

signed main(){
    int N;
    cin >> N;
    
    int a[N];
    set<string> color;
    int cnt = 0;
    for(int i=0;i<N;i++){
        cin >> a[i];
        
        if(a[i]<=399) color.insert("ash");
        else if(a[i]<=799) color.insert("brown");
        else if(a[i]<=1199) color.insert("green");
        else if(a[i]<=1599) color.insert("lightblue");
        else if(a[i]<=1999) color.insert("blue");
        else if(a[i]<=2399) color.insert("yellow");
        else if(a[i]<=2799) color.insert("orange");
        else if(a[i]<=3199) color.insert("red");
        else cnt++;
    }
    
    if(color.size()==0){
        cout << 1 << " " << cnt << endl;
        return 0;
    }
    
    cout << color.size() << " " << color.size()+cnt << endl;
    
    return 0;
}


Measured memory_bytes: 256
/***
	chauhan176's code

	DO WHATEVER IT TAKES!!!
	Nothing happens , nothing happens and then everything happens.
	But the thing is nothing happens in air:)-
***/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long int
#define fi first
#define se second
#define mod 1000000007
#define maxn 200005
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define stringio cin.ignore(256, '\n')  //to take string input after taking integer inputs
#define go_t int t;cin>>t;while(t--)
#define go_pt int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef pair<ll,ll>pii;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int infi = 100005;
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    //freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    //freopen("output.txt", "w", stdout);
    #endif

    fastio;
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int mx=1;
    int cur=1;
    for(int i=1;i<n;i++)
    {
        if(a[i]<=a[i-1])
            cur++;
        else
            cur=1;
        mx = max(cur,mx);
    }
    cout<<mx-1<<endl;
    return 0;
}


Measured memory_bytes: 1024
import collections
N=int(input())
A=list(map(int,input().split()))
l=[]
c=collections.Counter(A)
a=[]
values=list(c.values())
key=list(c.keys())
b=[]
for i in range(len(key)):
    l.append([key[i],values[i]])
l.sort(key=lambda x:x[1],reverse=True)
for i in range(len(l)):
    if l[i][1]>=2:
        num=l[i][0]
        b=[num]*((l[i][1])//2)
        a.extend(b)
if len(a)<2:
    print("0")
else:
    a.sort(reverse=True)
    print(a[0]*a[1])

Measured memory_bytes: 81688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
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; }


int main(){
    string str;
    cin >> str;
    int n = str.length();
    vector<vector<int> > alphabet(27);
    rep(i, n) {
        alphabet[(char)str[i] - 'a'].push_back(i);
    }
    int ans = 10000;
    rep(i, 26) {
        if(alphabet[i].size() == 0) continue;
        else {
            //　二分探索法
            int lb = -1, ub = 101;
            while(ub - lb > 1) {
                int mid = (lb + ub) / 2;
                bool ok = true;
                rep(j, alphabet[i].size()) {
                    if(j == 0) {
                        if(alphabet[i][j] - 0 > mid) {
                            ok = false;
                        }
                    }
                    if(alphabet[i].size() - 1 - j > 0) {
                        if(alphabet[i][j+1] - alphabet[i][j] - 1 > mid) {
                            ok = false;
                        }
                    }
                    if(j == alphabet[i].size()-1) {
                        if(n - 1 - alphabet[i][j] > mid) {
                            ok = false;
                        }
                    }
                    if(!ok) {
                        break;
                    }
                }
                if(ok) {
                    ub = mid;
                }
                else {
                    lb = mid;
                }
            }
            chmin(ans, ub);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    String a, b;

    AtCoder(FastScanner sc) {
        a = sc.next();
        b = sc.next();
    }

    void solve(PrintWriter out) {
        out.println(a.equals(b) ? "H" : "D");
    }

}

class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22868
# ABC127 D
from bisect import bisect_left as bl

f=lambda:map(int,input().split())
N,M=f()
A=list(f())
A.sort()
BC=[]
for _ in [0]*M:
    BC.append(tuple(f()))
BC.sort(key=lambda x:x[1])
res=0
num=0
def compare():
    # True => Aが大きい
    if not A:
        return False
    if not BC:
        return True
    return A[-1]>BC[-1][1]

while 1:
    if compare():
        res+=A.pop()
        num+=1
    else:
        b,c=BC.pop()
        if b+num<=N:
            res+=c*b
            num+=b
        else:
            res+=c*(N-num)
            num+=(N-num)
    if num==N:
        break
print(res)

Measured memory_bytes: 96744
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    while (1) {
        int H;
        cin >> H;
        if (H == 0) break;
        int puzzle[H][5];
        rep(i, H) {
            rep(j, 5) cin >> puzzle[H - i - 1][j];
        }
        bool flag = true;
        int ans = 0;
        while (flag) {
            int step1 = 0;
            // step1
            rep(i, H) {
                int cnt = 0;
                int s = -1;
                rep(j, 4) {
                    if (puzzle[i][j] == puzzle[i][j + 1] && puzzle[i][j] != -1) cnt++;
                    else cnt = 0;
                    if (cnt >= 2) {
                        s = j - 1;
                        break;
                    }
                }
                if (s == -1) {
                    step1++;
                    continue;
                }
                int ct = puzzle[i][s];
                cnt = 0;
                repd(j, s, 5) {
                    if (ct != puzzle[i][j]) break;
                    puzzle[i][j] = -1;
                    cnt++;
                }
                ans += cnt * ct;
            }

            if (step1 == H) {
                flag = false;
                continue;
            }

            // step2
            bool step2 = true;
            while (step2) {
                step2 = false;
                repd(i, 1, H) {
                    rep(j, 5) {
                        if (puzzle[i][j] != -1 && puzzle[i - 1][j] == -1) {
                            puzzle[i - 1][j] = puzzle[i][j];
                            puzzle[i][j] = -1;
                            step2 = true;
                        }
                    }
                }
            }
        }

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


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

int main() {
	int n, t = 0, h = 0; cin >> n;
	rep(i, n) {
		string s, w; cin >> s >> w;
		if (s > w)t += 3;
		else if (s < w)h += 3;
		else t++, h++;
	}
	cout << t << ' ' << h << endl;
}

Measured memory_bytes: 3144
from collections import Counter

N = int(input())
A = [int(x) for x in input().split()]

d = Counter(A)

if len(d) > 3:
    print('No')

else:
    k = list(d.keys())
    v = list(d.values())
    
    # a1 ^ a2 ^ a3 = 0 and an: N/3
    if len(d) == 3 and k[0]^k[1]^k[2] == 0 and v[0]==v[1]==v[2]:
        print('Yes')
    
    # a1: 2N/3, 0: N/3
    elif len(d) == 2 and ((k[0] == 0 and v[1] == 2*v[0]) or (k[1] == 0 and v[0] == 2*v[1])):
        print('Yes')
    
    # 0: N
    elif len(d) == 1 and k[0] == 0:
        print('Yes')
    
    else:
        print('No')

Measured memory_bytes: 20632
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <map>
#include <queue>
#include <unordered_set>
using namespace std;

int main() {
	string s1;
	string s2 = "CODEFESTIVAL2016";
	cin >> s1;
	int x = 0;
	for (int i = 0; i < 16; i++) {
		if (s1[i] != s2[i]) {
			x++;
		}
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
local MOD = 1000000007
local N, M = io.read("n", "n")
local broken = {}
for i=1,N do
    broken[i] = false
end
for i=1,M do
    local a = io.read("n")
    broken[a] = true
end

local dp = {}
dp[-1] = 0
dp[0] = 1
for i=1,N do
    if broken[i] then
        dp[i] = 0
    else
        dp[i] = (dp[i-1] + dp[i-2]) % MOD
    end
end
print(dp[N])

Measured memory_bytes: 4472
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

int h,w,n;
string s[333];
int a[333][333];
int cnt=1;

main(){
	cin>>h>>w>>n;
	r(i,h)cin>>s[i];
	r(i,h){
		int pre=0;
		r(j,w){
			if(s[i][j]=='#'){
				for(int k=j;k>=pre;k--){
					a[i][k] = cnt;
					//cout<<i<<' '<<
				}
				cnt++;
				pre=j+1;
			}
		}
		//cout<<a[1][0]<<endl;
		for(int j=w-1;j>=1;j--){
			if(a[i][j]==0 && s[i][j-1]=='#'){
				int t=a[i][j-1];
				for(int k=j;k<w;k++){
					if(a[i][k]!=0)break;
					a[i][k]=t;
				}
			}
		}
	}
	r(p,300){
		for(int i=1;i<h;i++){
			r(j,w){
				if(a[i][j]==0){
					a[i][j] = a[i-1][j];
				}
			}
		}
	}
	r(p,300){
		for(int i=0;i<h-1;i++){
			r(j,w){
				if(a[i][j]==0){
					a[i][j] = a[i+1][j];
				}
			}
		}
	}
	r(i,h){
		r(j,w){
			if(j)cout<<' ';
			cout<<a[i][j];
		}
		cout<<endl;
	}
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>
static const int MAX_N = 1000;

struct Node{
	int data;
	struct Node *under;
};
struct Stack{
	struct Node *top;
};

struct Stack *CreateStack(){
	struct Stack *S = malloc(sizeof(struct Stack));
	S->top = NULL;
	return S;
}
void push(struct Stack *S, int x){
	if(S->top == NULL){
		S->top = malloc(sizeof(struct Node));
		S->top->data = x;
		S->top->under = NULL;
	}else{
		struct Node *bf = malloc(sizeof(struct Node));
		bf->under = S->top;
		bf->data = x;
		S->top = bf;
	}
}
void top(struct Stack *S){
	if(S->top == NULL) return;
	printf("%d\n", S->top->data);
}
void pop(struct Stack *S){
	if(S->top == NULL) return;
	if(S->top->under == NULL){
		free(S->top);
		S->top = NULL;
		return;
	}
	struct Node *bf = S->top->under;
	free(S->top);
	S->top = bf;
}
void deleteStack(struct Stack *S){
	if(S->top == NULL) return;
	struct Node *cur = S->top;
	for(;;){
		if(cur->under == NULL){
			free(cur);
			break;
		}
		struct Node *bf = cur->under;
		free(cur);
		cur = bf;
	}
	free(S);
}

int main(){
	int n, q;
	scanf("%d %d", &n, &q);
	struct Stack *S[MAX_N];
	for(int i = 0; i < n; i++) S[i] = CreateStack();
	for(int i = 0; i < q; i++){
		int op, t;
		scanf("%d %d", &op, &t);
		if(op == 0){
			int x;
			scanf("%d", &x);
			push(S[t], x);
		}else if(op == 1){
			top(S[t]);
		}else if(op == 2){
			pop(S[t]);
		}
	}
	for(int i = 0; i < n; i++) deleteStack(S[i]);
	return 0;
}



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

const int MAXN = 1e5 + 10;

int n, a[MAXN];
vector<int> con[MAXN];

void dfs(int x, int pre) {
	if (con[x].size() == 1) return;
	long long sum = 0, max_val = 0;
	for (int _i = 0; _i < con[x].size(); ++_i) {
		int y = con[x][_i];
		if (y != pre) {
			dfs(y, x);
			sum += a[y];
			max_val = max(max_val, (long long)a[y]);
		}
	}
	if (a[x] > sum || sum > 2 * a[x]) {
		puts("NO");
		exit(0);
	}
	int k = sum - a[x];
	if (k > sum - max_val) {
		puts("NO");
		exit(0);
	}
	a[x] -= k;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) scanf("%d", a + i);
	for (int i = 1; i < n; ++i) {
		int x, y;
		scanf("%d%d", &x, &y), --x, --y;
		con[x].push_back(y);
		con[y].push_back(x);
	}
	if (n == 2) {
		puts(a[0] == a[1] ? "YES" : "NO");
		return 0;
	}
	int root = 0;
	while (con[root].size() == 1) ++root;
	dfs(root, -1);
	puts(a[root] == 0 ? "YES" : "NO");
}

Measured memory_bytes: 12800
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    ll k, a, b;
    cin >> k >> a >> b;
    if(b<=a) cout << k+1 << endl;
    else{
        ll l=(k-a+1)/2;
        cout << max(k+1, a+l*(b-a)+((k-a+1)%2)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,k,q = map(int,input().split(" "))
ar = [k-q for i in range(n)]
for i in range(q):
    l = int(input())
    ar[l-1] += 1
count = 0
for r in ar:
    if r >= 1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 7848
w=str(input())
t=list(input().split())
while True:
    try:
        a=str(input())
        if a!=("END_OF_TEXT"):
            a=a.split()
            t=a+t
    except EOFError:
        break
count=0
for i in range(len(t)):
    t[i]=t[i].lower()
    if t[i]==w:
        count +=1
print(count)


Measured memory_bytes: 5564
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using vv = vector<V<T>>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  string s;
  cin >> s;
  int ans = 0;
  REP(i,4){
    if(s[i]=='+') ans++;
    else ans--;
  }
  cout << ans << endl;
}


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 1e9
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

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

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

signed main() {
    int N;
    vector<int> h;
    cin >> N;
    rep(i, N) {
        int a;
        cin >> a;
        h.push_back(a);
    }
    int V = 0;
    int E = 0;
    for (int i = 0; i < N; i++) {
        V += h[i];
    }
    for (int i = 1; i < N; i++) {
        E += min(h[i - 1], h[i]);
    }
    cout << V - E << endl;
}


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

void solve () {
    int n;
    cin >> n;
    long long ans;
    long long t;
    cin >> t;
    ans += t;
    for (int i = 1; i < n - 1; i++) {
        long long x;
        cin >> x;
        ans += min (x, t);
        t = x;
    }
    ans += t;
    cout << ans;
}

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


Measured memory_bytes: 3612
#include<stdio.h>
int main(){
    int n,b,i,j;
    while(scanf("%d",&n),n){
        int a[100010]={};
        int c[100010]={};
        for(i=1;i<n;i++)a[i*i%n]=1;
        for(i=0;i<n;i++){
            if(a[i]==0)continue;
            for(j=0;j<n;j++){
                if(a[j]==0)continue;
                b=(i-j+n)%n;
                if(b>n/2)b=n-b;
                c[b]++;
            }
        }
        for(i=1;i*2<n;i++)printf("%d\n",c[i]);
    }
    return 0;
}

Measured memory_bytes: 2476
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int d_s;
	int tmp=n;
	while(tmp)
	{
		d_s+=tmp%10;
		tmp/=10;
	}
	if(n%d_s==0)
	{
		cout<<"Yes";
	}
	else
	cout<<"No";
	return 0;
}

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

using namespace std;

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

  int diff=a-b;

  if(diff>=0){
    puts("delicious");
  }else if(diff<0 && abs(diff)<=x){
    puts("safe");
  }else{
    puts("dangerous");
  }
}

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

int main()
{
	int w;

	while (cin >> w){
		for (int i = 1; i <= 512; i *= 2){
			if (w % (i * 2) != 0){
				cout << i;
				w -= i;
				if (w != 0){
					cout << " ";
				}
			}
			if (w == 0){
				cout << endl;
				break;
			}
		}
	}

	return (0);
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main() {
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n;
  cin >> n;
  ll d=2*5;
  ll n10=0;
  ll temp=n;
  if(n%2!=0){
    cout << 0 << endl;
    return 0;
  }
  while(n/d>0){
    n10+=n/d;
    d*=5;
  }
  temp=n;
  d = 2;
  ll n2=0;
  while(n/d>0){
    n2+=n/d;
    d*=2;
  }
  // debug(n10, n2);
  cout << min(n10,n2) << endl;


  return 0;
}


Measured memory_bytes: 256
using System;

class B
{

	static void Main(string[] args)
	{
		var input1Line = Console.ReadLine().Split(' ');
		var n = int.Parse(input1Line[0]);
		var d = long.Parse(input1Line[1]);
		long pow2d = d * d;

		var count = 0;
		for (int i = 0; i < n; i++)
		{
			var inputLine = Console.ReadLine().Split(' ');
			var x = long.Parse(inputLine[0]);
			var y = long.Parse(inputLine[1]);
			if (x * x + y * y <= pow2d)
			{
				count++;
			}
		}

		Console.WriteLine(count);
	}
}

Measured memory_bytes: 40592
#include<stdio.h>

int main(void)
{
	int a,b,c,d,i;
	int t=0;

	scanf("%d %d %d %d",&a,&b,&c,&d);

	while(1){
		if(t){
			a=a-d;
			if(a<=0) break;
			t=0;
		}
		else{
			c=c-b;
			if(c<=0) break;
			t=1;
		}
	}

	if(t){
		puts("No");
	}
	else puts("Yes");

	return 0;
}


Measured memory_bytes: 1620
#include<stdio.h>

int main(){

  int data[100], in, i, j;

  i = 0;


  while(scanf("%d",&in) != EOF){
    if(in != 0){
      data[i] = in;
      i++;
    }else{
      i--;
      printf("%d\n",data[i]);
    }
  }


  return 0;

}

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

long long A(int x){
  long long n=2;
  for(int i=0;i<x;i++){
    n*=5;
  }
  return n;
}


int main() {
 long long N,ans=0;
  cin>>N;
  for(int i=1;i<26;i++){
    ans+=N/A(i);
  }
  if(N%2==1){
    cout<<0;
  }
  else{
  cout<<ans;
  }
  
 
}


Measured memory_bytes: 256
from itertools import product

n = int(input())
s = input()

bl = False
for ef, el in product([1, -1], repeat=2):
    zoo = [0] * n
    zoo[0] = ef
    zoo[-1] = el
    for i, e in enumerate(s):
        if e == "o":
            if zoo[i] == 1:
                nxt = zoo[i-1]
            else:
                nxt = -zoo[i-1]

        else:
            if zoo[i] == 1:
                nxt = -zoo[i-1]
            else:
                nxt = zoo[i-1]

        if i < n - 2:
            zoo[i+1] = nxt

        elif nxt != zoo[(i+1)%n]:
            break

    else:
        bl = True
        break

if bl:
    ans = ["S" if e == 1 else "W" for e in zoo]
    print(*ans, sep="")

else:
    print(-1)


Measured memory_bytes: 8400
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase

#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

n=I()
s=input()
c=0
mm=0
for i in s:
    if i=='(':
        c+=1
    else:
        c-=1
    mm=min(mm,c)

print('('*-mm+s+')'*(c-mm))





Measured memory_bytes: 38640
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a;
  cin>>a;
  string b[a];
  double c[a];
    double d=0.0;
  rep(i,a){
    cin>>c[i]>>b[i];
    if(b[i]=="JPY")d+=c[i];
    else d+=c[i]*380000;
  }
  cout<<d;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX_N 100

int main(){
    int i,j,k,a,b,array1[MAX_N][MAX_N],array2[MAX_N],array3[MAX_N]={0};
    cin>>a>>b;
    for(i=0;i<a;i++){
        for(j=0;j<b;j++){
            cin>>array1[i][j];
        }
    }
    for(k=0;k<j;k++){
        cin>>array2[k];
    }
    for(i=0;i<a;i++){
        for(j=0;j<b;j++){
            array3[i]+=array1[i][j]*array2[j];
        }
    }
    for(i=0;i<a;i++){
        cout<<array3[i]<<endl;
    }
}


Measured memory_bytes: 3136
A = input()
B = input()
if len(A) > len(B):
    print("GREATER")
elif len(B) > len(A):
    print("LESS")
else:
    for i in range(len(A)):
        if int(A[i]) > int(B[i]):
            print("GREATER")
            break
        elif int(A[i]) < int(B[i]):
            print("LESS")
            break
        if i == len(A) - 1:
            print("EQUAL")

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using vi = vector<int>;
using graph = vector<vi>;
const int MAXN = 1123;
const int mod = 1000000007;
int dp[MAXN][MAXN];
char mat[MAXN][MAXN];
int main() {
    int n, m, k;
    scanf("%d %d", &n, &m);
    for (int i = 1; i<=n; ++i) {
        for (int j = 1; j<=m; ++j) {
            scanf(" %c", &mat[i][j]);
        }
    }
    dp[1][1] = 1;
    int ans = 0;
    for (int i = 1; i<=n; ++i) {
        for (int j = 1; j<=m; ++j) {
            if (mat[i][j] == '.') {
                ans = dp[i][j];
                ans += dp[i][j-1];
                if (ans >= mod) ans -= mod;
                ans += dp[i-1][j];
                if (ans >= mod) ans -= mod;
                dp[i][j] = ans;
            }
        }
    }
    printf("%d\n", ans);
}



Measured memory_bytes: 6272