akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
//YESNO

using namespace std;

int K, N;
int A[1000010];

signed main()
{
	cin >> K >> N;
	REP(i, N) cin >> A[i];

	int max_l = (K - A[N - 1]) + A[0];
	for (int i = 1; i < N; i++)
	{
		int l = A[i] - A[i - 1];
		max_l = max(l, max_l);
	}

	cout << (K - max_l) << endl;
}


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

using namespace std;

int main() {
  
  int n, k1 = 0, k2 = 0, k3 = 0, k4 = 0;
  cin >> n;
  
  for(int i = 0; i < n; i++) {
     string s;
     cin >> s;
     
     if (s == "AC") {
        k1++;
     }
     if (s == "WA") {
        k2++;
     }
     if (s == "TLE") {
        k3++;
     }
     if (s == "RE") {
        k4++;
     }
  }
  
  cout << "AC x " << k1 << '\n';
  cout << "WA x " << k2 << '\n';
  cout << "TLE x " << k3 << '\n';
  cout << "RE x " << k4;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod(a) (a % MOD + MOD) % MOD
const int N = 1e6 + 10, MOD = 1e9 + 7;
int a[N], fac[N], inv[N];

int mul(int a, int b) {return mod(a * b);}

int Pow(int a, int b)
{
    int res = 1;
    for (; b; b>>=1, a = mul(a, a)) if (b & 1) res = mul(res, a);
    return res;
}

int C(int n, int k)
{
    if (k < 0 || n < 0 || k > n) return 0;
    return mul(fac[n], mul(inv[k], inv[n - k]));
}

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k; cin >> n >> k;

    fac[0] = 1;
    for (int i = 1; i <= n; i++) fac[i] = mul(fac[i - 1], i);
    inv[n] = Pow(fac[n], MOD - 2);
    for (int i = n - 1; i >= 0; i--) inv[i] = mul(inv[i + 1], i + 1);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    int ans = 0;
    for (int i = 0; i < n; i++)
        ans = (ans - mul(a[i], C(n - i - 1, k - 1)) + MOD) % MOD;
    for (int i = n - 1; i >= 0; i--)
        ans = (ans + mul(a[i], C(i, k - 1)) + MOD) % MOD;
    cout << ans << "\n";
}


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

#include <boost/multiprecision/cpp_dec_float.hpp>

using namespace std;
namespace mp = boost::multiprecision;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  // int64_t a, ans;
  // mp::cpp_dec_float_50 b;
  // cin >> a >> b;

  // b *= a;
  // ans = (int64_t)b;

  int64_t a, ans;
  double b;
  cin >> a >> b;
  ans = (a * (int64_t)round(b * 100)) / 100;

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3788
n, a, b = [int(s) for s in input().split()]

def main(): 
    if a == 0:
        print(0)
        return
    if b == 0:
        print(n)
        return
    r = n % (a+b)
    d = int(n // (a+b))
    ans = a * d + min(r, a)
    print(ans)
main()


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

int main(){
    long N,Q,a;
    map<long,long>A;
    cin >> N;
    long long sum=0;
    for(long i=0; i<N; i++){
        cin >> a;
        if(A.find(a)==A.end()){
            A[a]=1;
        }
        else{
            A[a]++;
        }
        sum+=a;
    }
    cin >> Q;
    long B,C;
    for(long i=0; i<Q; i++){
        cin >> B;
        cin >> C;
        if(A.find(B)==A.end()){
            cout << sum << endl;
        }
        else{
            sum-=A[B]*B;
            sum+=A[B]*C;
            if(A.find(C)==A.end()){
                A[C]=A[B];
            }
            else{
                A[C]+=A[B];
            }
            A.erase(B);
            cout << sum << endl;
        }
    }
}


Measured memory_bytes: 7504
#include <stdio.h>

int main(void){
	char str[256];
	int i;
	while(gets(str)!=NULL){
		int num[256]={0};
		for(i=0;i<strlen(str);i++){
			if(str[i]=='I')  num[i]=1;
			if(str[i]=='V')	 num[i]=5;
			if(str[i]=='X')  num[i]=10;
			if(str[i]=='L')  num[i]=50;
			if(str[i]=='C')  num[i]=100;
			if(str[i]=='D')	 num[i]=500;
			if(str[i]=='M')	 num[i]=1000;
		}
		int sum=0;
		for(i=0;num[i]!=0;i++){
			if(num[i]<num[i+1]){
				sum+=(num[i+1]-num[i]);
				i++;
			}
			else if(num[i]>=num[i+1])	sum+=num[i];
		}
	printf("%d\n",sum);
	}
	return 0;
}

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

using namespace std;

#define int long long

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k, s;
    cin >> n >> k >> s;
    if (s == 1000 * 1000 * 1000) {
        for (int j = 1; j <= k; ++j) cout << s << " ";
        for (int j = k + 1; j <= n; ++j) cout << s - 1 << " ";
        return 0;
    }
    for (int i = 1; i <= k; ++i) cout << s << " ";
    for (int j = k + 1; j <= n; ++j) cout << s + 1 << " ";
    return 0;
}



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

int main() {
    string a, b, c;
    cin >> a >> b >> c;

    int A = a.length();
    int B = b.length();
    int C = c.length();

    int M = 8000;
    vector<bool> ab(M + 1, false);
    for (int i = -4000; i <= 4000; i++) {
        bool ok = true;
        for (int j = 0; j < A; j++) {
            if (0 <= j - i && j - i < B) {
                if (!(a[j] == '?' || b[j - i] == '?' || a[j] == b[j - i])) {
                    ok = false;
                    break;
                }
            }
        }
        ab[i + 4000] = ok;
    }
    vector<bool> ac(M + 1, false);
    for (int i = -4000; i <= 4000; i++) {
        bool ok = true;
        for (int j = 0; j < A; j++) {
            if (0 <= j - i && j - i < C) {
                if (!(a[j] == '?' || c[j - i] == '?' || a[j] == c[j - i])) {
                    ok = false;
                    break;
                }
            }
        }
        ac[i + 4000] = ok;
    }
    vector<bool> bc(M + 1, false);
    for (int i = -4000; i <= 4000; i++) {
        bool ok = true;
        for (int j = 0; j < B; j++) {
            if (0 <= j - i && j - i < C) {
                if (!(b[j] == '?' || c[j - i] == '?' || b[j] == c[j - i])) {
                    ok = false;
                    break;
                }
            }
        }
        bc[i + 4000] = ok;
    }

    int ans = 8000;
    for (int i = -4000; i <= 4000; i++) {
        for (int j = -4000; j <= 4000; j++) {
            if (0 <= j - i + 4000 && j - i + 4000 <= 8000) {
                if (ab[i + 4000] && ac[j + 4000] && bc[j - i + 4000]) {
                    int l = min({0, i, j});
                    int r = max({A, i + B, j + C});
                    ans = min(ans, r - l);
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
A = [int(i) for i in input().split()]
A.sort()

if ((A[2]-A[1]) + (A[2]-A[0])) % 2 == 0:
    print(int(((A[2]-A[1]) + (A[2]-A[0])) / 2))
else:
    print(int((((A[2]-A[1]) + (A[2]-A[0]) + 1) / 2) + 1))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,a,b) for(int(i)=(a);(i)<(b);++(i))
#define RREP(i,a,b) for(int(i)=(a)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main()
{
  int N;
  cin >> N;
  vector<int> W(N);
  REP(i,0,N) cin >> W[i];
  int S1 = 0; //左
  int S2 = 0; //右
  REP(i,0,N) S2 += W[i];

  int ans = INF;  // 差の絶対値の最小値
  REP(T,0,N) {
    S1 += W[T];
    S2 -= W[T];
    chmin(ans, abs(S1-S2));
  }
  cout << ans << endl;

  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  cout << (h%a == 0? h/a:h/a+1) << endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb push_back
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int nxt[200020], A[200020], now[200020];
int L[50][200020];

int main() {
	int N; ll K;
	scanf("%d%lld", &N, &K);
	for(int i=1;i<=N;i++) scanf("%d", A + i);
	rep(i, 200020) now[i] = N + 1;
	nxt[N + 1] = -1;
	for(int i=N;i;i--) {
		int t = now[A[i]];
		if(t == N + 1) nxt[i] = A[i];
		else nxt[i] = nxt[t + 1];
		now[A[i]] = i;
	}
	for(int i=1;i<=N;i++) {
		if(nxt[i] == -1) nxt[i] = 1;
		else {
			nxt[i] = now[nxt[i]] + 1;
		}
	}
	nxt[N+1] = 1;
	for(int i=1;i<=N+1;i++) L[0][i] = nxt[i];
	for(int i=1;i<50;i++) {
		for(int j=1;j<=N+1;j++) L[i][j] = L[i-1][ L[i-1][j] ];
	}
	int t = 1;
	rep(i, 50) if(1LL<<i & (K-1)) {
		t = L[i][t];
	}
	int ok[200020] = {};
	vector <int> ans;
	for(int i=t;i<=N;i++) {
		if(ok[A[i]] == 0) {
			ok[A[i]] = 1;
			ans.pb(A[i]);
		}
		else {
			while(szz(ans)) {
				int t = ans.back();
				ok[t] = 0;
				ans.pop_back();
				if(t == A[i]) break;
			}
		}
	}
	for(int e : ans) printf("%d ", e); puts("");
	return 0;
}

Measured memory_bytes: 44660
A,B = map(int, input().split())
 
def F0(n):
    if n%4 == 1:
        return 1
    if n%4 == 2:
        return n + 1
    if n%4 == 3:
        return 0
    if n%4 == 0:
        return n
    if n == 0:
        return 0
 
 
print(F0(A-1)^F0(B))

Measured memory_bytes: 3444
able = list()
for i in range(103):
    able.insert(i, i-1)

X,N = map(int,input().split())
p = list(map(int,input().split()))
for i in range(len(p)):
    able.remove(p[i])

target = 1000
ans = 1000
for i in range(len(able)):
    
    if (target > abs(X - able[i])):
        # if (target == abs(X - able[i])): 
        #     ans = min(target, able[i])
        # else:
        target = abs(X - able[i])
        ans = able[i]
    
    # print(able[i], abs(X - able[i]), ans)

print(ans)


Measured memory_bytes: 61972
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var s = t.ConvertIntList(t.ReadInput());
            if(s[0] < s[1])
            {
                Console.WriteLine("a < b");
            }else if(s[0] > s[1])
            {
                Console.WriteLine("a > b");
            }
            else
            {
                Console.WriteLine("a == b");
            }
           
        }


        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }


        public List<int> ConvertIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }
}
}



Measured memory_bytes: 16000
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#define int long long
#define lowbit(x) (x &(-x))
#define me(ar) memset(ar, 0, sizeof ar)
#define mem(ar,num) memset(ar, num, sizeof ar)
#define rp(i, n) for(int i = 0, i < n; i ++)
#define rep(i, a, n) for(int i = a; i <= n; i ++)
#define pre(i, n, a) for(int i = n; i >= a; i --)
#define IOS ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int way[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const int  INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double EXP = 1e-8;
const ll   MOD = 1e9 + 7;
const int  N = 2e5 + 5;
int a, b, a1, a2, b1, b2, ans;
signed main()
{
    IOS;
    cin >> a >> b;
    a1 = a / 0.08; a2 = (a + 1) / 0.08 + 1;
    b1 = b * 10; b2 = (b + 1) * 10 + 1;
    a1 = max(a1, b1); b1 = min(a2, b2);
    for(int i = a1; i <= b1; i ++){
        a2 = i * 0.08;
        b2 = i * 0.1;
        if(a2 == a && b2 == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int MOD = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,n;
	cin >> a >> b >> n;

	int x;

	if(b<=n){
		x = b-1;
	} else {
		x = n;
	}

	int ans = a*x/b;
	cout << ans << endl;
	
}


Measured memory_bytes: 3668
#include<bits/stdc++.h> 
#define Re register
#define fo(i, a, b) for (Re int i = (a); i <= (b); ++i)
#define fd(i, a, b) for (Re int i = (a); i >= (b); --i)
#define edge(i, u) for (Re int i = head[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define pb push_back
#define F first
#define S second
#define ll long long
#define inf 1000000007
#define mp std::make_pair
#define lowbit(x) (x & -x)
#define eps 1e-4
#define itset std::set<node>::iterator
#define lb lower_bound
#define N 100005
#define M 4000005
#define mod 1000000007
ll n, m, k, a[N], ans, b[N], x;
inline void search (int d)
{
    if (d == 0) {++ans, --x; return;}
    if (a[d] <= x)
    {
        x -= a[d];
        ans += b[d];
        return;
    }
    --x;
    if (x == 0) return;
    search(d - 1);
    if (x == 0) return;
    ++ans, --x;
    if (x == 0) return;
    search(d - 1);
    if (x == 0) return;
    --x;
    return;
}
int main ()
{
    scanf("%lld %lld", &n, &x);
    a[0] = b[0] = 1;
    fo (i, 1, n)
    {
        a[i] = 2 * a[i - 1] + 3;
        b[i] = 2 * b[i - 1] + 1;
    }
    search(n);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline
H, W = map(int, input().split())
S = [(input()) for _ in range(H)]
T = [[0 for _ in range(W)] for _ in range(H)]

for h in range(H):
    for w in range(W):
        for i in range(h - 1, h + 2):
            for j in range(w - 1, w + 2):
                if i < 0 or j < 0 or i >= H or j >= W:
                    continue
                else:
                    if S[h][w] == '#':
                        T[h][w] = -1
                    elif S[i][j] == '#':
                        T[h][w] += 1

for t in T:
    print((''.join(map(str, t))).replace('-1', '#'))

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

//.define
// #define FILE_IN_OUT
#define RET(_x)    return cout << (_x) << '\n', 0;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename P, typename Q>
P CeilDiv(P _dividend, Q _divider) {
    return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n, m;
    cin >> n >> m;
    map<int, int> from;
    map<int, int> cnt;
    for (int i = 0; i < m; ++i) {
        from[i] = i;
    }
    cnt[0] = m;
    bool ok = true;
    loop(n) {
        int l, r;
        cin >> l >> r;
        if (!ok) {
            cout << -1 << endl;
            continue;
        }
        --l; --r;
        int maxc = -1;
        for (auto it = from.lower_bound(l); it != from.end() && it->first <= r + 1; it = from.erase(it)) {
            if (--cnt[it->first - it->second] == 0) {
                cnt.erase(it->first - it->second);
            }
            maxc = max(maxc, it->second);
        }
        if (maxc != -1 && r + 1 < m) {
            from[r + 1] = maxc;
            ++cnt[r + 1 - maxc];
        }
        if (empty(cnt)) {
            ok = false;
            cout << -1 << endl;
            continue;
        }
        cout << i + 1 + cnt.begin()->first << endl;
    }

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 12984
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    void solve() {
        String input = in.nextToken();
        out.println((input.contains("9")? "Yes" : "No"));
    }


    FastScanner in;
    PrintWriter out;

    void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

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

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

}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,double> P;
int main(){
  int n,m,p,a,b;
  while(cin>>n>>m>>p>>a>>b,n){
    a--,b--;

    double t[8],tp;
    vector<P> e[31];

    for(int i=0;i<n;i++)cin>>t[i];
    for(int j=0,x,y;j<p;j++){
      cin>>x>>y>>tp;
      x--,y--;
      e[x].push_back(P(y,tp)),e[y].push_back(P(x,tp));
    }

    double dp[1<<8][30];
    for(int i=0;i<1<<n;i++)
	for(int j=0;j<m;j++)dp[i][j]=1e4;
    dp[0][a]=0;

    for(int i=0;i<n;i++)
      for(int j=0;j<1<<n;j++)
	for(int k=0;k<m;k++)
	  for(int l=0;l<n;l++)
	    if(!(j&1<<l))
	      for(int w=0;w<e[k].size();w++)
		dp[j+(1<<l)][e[k][w].first]
	   =min(dp[j+(1<<l)][e[k][w].first],dp[j][k]+e[k][w].second/t[l]);

    double ans=1e4;
    for(int i=0;i<1<<n;i++)ans=min(ans,dp[i][b]);
    if(ans==1e4)cout<<"Impossible"<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3324
#include <iostream>

using namespace std;

int main(){
	int N;
	int A[30], B[30], C[30] = {0};	
	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	for (int i = 1; i <= N; i++) {
		cin >> B[i];
	}
	for (int i = 1; i <= N - 1; i++) {
		cin >> C[i];
	}

	int ans = 0;
	int c;
	for (int i = 1; i <= N; i++) {
		ans += B[A[i]];
		if (A[i] == A[i - 1] + 1) {
			ans += C[A[i - 1]];
		}
	}

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


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>

using namespace std;
typedef long long int ll;

int n,cx[200],cy[200],ch[200],kx,ky,kh,q;
bool r;

int mht(ll xp,ll yp,ll xtp,ll ytp){
    return abs(xp-xtp)+abs(yp-ytp);
}


int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d %d %d",&cx[i],&cy[i],&ch[i]);
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            r=true;
            //while()q=mht(i,j,cx[0],cy[0])+ch[0];
            for(int m=0;m<n;m++){
                if(ch[m]==0)continue;
                else{
                    q=mht(i,j,cx[m],cy[m])+ch[m];
                    break;
                }
                //r=r and q==mht(i,j,cx[m],cy[m])+ch[m];
            }
            for(int m=0;m<n;m++){
                r=r and max(q-mht(i,j,cx[m],cy[m]),0)==ch[m];
            }
            
            if(r){
                kx=i;
                ky=j;
                kh=q;
                break;
            }
        }
        if(r)break;
    }
    printf("%d %d %d\n",kx,ky,kh);
    
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
 
 
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
 
typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;
 
 
 
int main() {
 
 int n;
 cin>>n;
 VI p(n);
 REP(i,n)cin>>p[i];
 VI v=p;
 sort(ALL(v));
 
 if(p==v){
     cout<<"YES"<<endl;
     return 0;
 }
 
 REP(i,n){
     REP(j,n){
         swap(p[i],p[j]);
         if(p==v){
             cout<<"YES"<<endl;
             return 0;
         }
         swap(p[i],p[j]);
     }
 }
 
 cout<<"NO"<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define ll long long

int comp(const void *a, const void *b) //昇順
{
    return *(ll *)a - *(ll *)b;
}

int compr(const void *a, const void *b) //降順
{
    return *(ll *)b - *(ll *)a;
}

int main(void)
{
    ll p[120000] = {0};
    ll q[120000] = {0};
    ll r[120000] = {0};
    int X, Y, A, B, C;
    int n, m, i;
    ll max = 0, t;
    scanf("%d%d%d%d%d", &X, &Y, &A, &B, &C);
    for (i = 0; i < A; i++)
    {
        scanf("%lld", &t);
        p[i] = t;
    }
    for (i = 0; i < B; i++)
    {
        scanf("%lld", &t);
        q[i] = t;
    }
    for (i = 0; i < C; i++)
    {
        scanf("%lld", &t);
        r[i] = t;
    }

    qsort(p, A, sizeof(ll), compr);
    qsort(q, B, sizeof(ll), compr);
    qsort(r, C, sizeof(ll), compr);

    int x = X - 1;
    int y = Y - 1;
    int j = 0;

    while (j < C)
    {
        if (x >= 0 && y >= 0 && p[x] < r[j] && q[y] < r[j])
        {
            if (p[x] < q[y])
            {
                x--;
            }
            else
            {
                y--;
            }
        }
        else if (x >= 0 && p[x] < r[j])
        {
            x--;
        }
        else if (y >= 0 && q[y] < r[j])
        {
            y--;
        }
        else
        {
            break;
        }
        j++;
    }
    /*
    while (j < C)
    {
        if ((p[x] < q[y]) && (p[x] < r[j]) && x >= 0)
        {
            //p[x] = r[j];
            x--;
        }
        else if ((p[x] > q[y]) && (q[y] < r[j]) && y >= 0)
        {
            //q[y] = r[j];
            y--;
        }
        else
        {
            break;
        }
        j++;
    }*/
    for (i = 0; i <= x; i++)
    {
        max += p[i];
    }
    for (i = 0; i <= y; i++)
    {
        max += q[i];
    }
    for (i = 0; i < j; i++)
    {
        max += r[i];
    }
    printf("%lld\n", max);
    return 0;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int c(int i) {
    cout << i << endl;
    string s;
    cin >> s;
    if (s == "Male") return -1;
    if (s == "Female") return 1;
    exit(0);
}

int main(){
    int N;
    string s;
    
    cin >> N;
    vector<int> v(N, 0);
    v[0] = c(0);

    int l = 0, r = N;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        v[mid] = c(mid);

        if ((mid - l) % 2 == 0) {
            if (v[l] == v[mid]) {
                l = mid;
            } else {
                r = mid;
            }
        } else {
            if (v[l] == v[mid]) {
                r = mid;
            } else {
                l = mid;
            }
        }
    }
}

Measured memory_bytes: 1236
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<tuple>
#include<cassert>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
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;}

const int mod = pow(10, 9) + 7;

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, n)   cin >> l[i];
    ll ans = 0;
    sort(l.begin(), l.end());
    for(int a = 0; a < n; ++a){
        for(int b = a + 1; b < n; ++b){
            auto top = lower_bound(l.begin(), l.end(), l[a] + l[b]);
            ans += max((ll)(top - l.begin()) - (b + 1), (ll)0);
        }
    }
    cout << ans << endl;
}

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

int main() {
    int N, ans = 1, max_count = 0;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        int div_count = 0, tmp = i;
        while (tmp % 2 == 0) {
            div_count++;
            tmp /= 2;
        }
        if (div_count > max_count) {
            ans = i;
            max_count = div_count;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int n, rate, c[13] = { 0 };
	int min = 0, max = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &rate);
		c[rate / 400]++;
	}
	for (int i = 0; i < 8; i++)
	{
		if (c[i] > 0) min++;
	}
	max = min + c[8] + c[9] + c[10] + c[11] + c[12];
	if (min == 0) min++;
	printf("%d %d", min, max);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>


using namespace std;


int main() {
	int A,B,C,D;
	cin>>A>>B>>C>>D;

	int asw=0;
	for(int i=0;i<=100;++i){
		if(i>A&&i<=B&&i>C&&i<=D){
			++asw;
		}
	}

	cout<<asw;
	return 0;
}


Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
    a=list(map(int,input().split()))
    sum=c
    for j in range(m):
        sum+=a[j]*b[j]
    if sum>0: ans+=1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
using namespace std;
int main() {
    string x;
    cin >> x;
    bool flag1, flag2;
    int t =stoi(x.substr(0, 2));
    if (t <= 12 && t > 0)
        flag1 = true;
    else
        flag1 = false;
    t =stoi(x.substr(2, 4));
    if (t <= 31 && t > 0)
        flag2 = true;
    else
        flag2 = false;
    if(flag1 && flag2)
        cout << "AMBIGUOUS";
    else if (flag2)
        cout << "YYMM";
    else if (flag1)
        cout << "MMYY";
    else
        cout << "NA";
    return 0;
}


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

namespace GreedyTakahashi
{
    class Program
    {
        static void Main(string[] args)
        {
            var abk = Console.ReadLine().Split();
            long A = long.Parse(abk[0]);
            long B = long.Parse(abk[1]);
            long K = long.Parse(abk[2]);

            if (K > A)
            {
                K -= A;
                A = 0;
            } else 
            {
                A -= K;
                K = 0;
            }
            if (K > B)
            {
                K -= B;
                B = 0;
            }
            else
            {
                B -= K;
                K = 0;
            }
            Console.WriteLine(A.ToString() + " " + B.ToString());
        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s= sc.next();
		String buff= "";
		//double n = sc.nextInt()/1000.0;
		int m = sc.nextInt();
		int k = sc.nextInt();
		//String s=sc.next();
		long count=1,flag=0;
		long count1=0,count2=0;
		int count3=9999999;
		int[] array1 = new int[m];
		int[] array2 = new int[m];
		int[] array3 = new int[m-1];
		/*array[0]=n-m;
		array[1]=n*m;
		array[2]=n+m;*/
		//Arrays.sort(array);

		for(int i=0;i<1000;i++) {
			if(k==1) {
				count=0;
				break;
			}
			if(m>=k) {
				count=1;
				break;
			}
			if(count>=k) {
				count=i;
				break;
			}
			count+=m-1;
			//System.out.println(count+" "+i);
		}

		/*if(count==0) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}*/

		System.out.println(count);
	}
}




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

#define x first
#define y second

#ifdef ONLINE_JUDGE
#define DEBUG(x)
#else
#define DEBUG(x) cerr << #x << ": " << x << endl;
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

bool a[200000],b[200000];
int N,M;

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

	cin >> N >> M;
	for (int i=0;i<M;i++) {
		int u,v;cin >> u >> v;u--;v--;
		if (u==0) a[v]=1;
		if (v+1==N) b[u]=1;
	}
	for (int i=0;i<N;i++) if (a[i]&&b[i]) {
		cout << "POSSIBLE\n";
		return 0;
	}
	cout << "IMPOSSIBLE\n";
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int n, m;
    cin >> n >> m;
    string a[n];
    rep(i, n) { cin >> a[i]; }

    string b[m];
    rep(i, m) { cin >> b[i]; }

    rep(l0, n - m + 1) {
        rep(l1, n - m + 1) {
            bool temp = true;
            rep(m1, m) {
                rep(m2, m) {
                    if (a[m1 + l0][m2 + l1] != b[m1][m2]) {
                        temp = false;
                    }
                }
            }

            if (temp) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100005];

    ll jump(ll i,ll n,ll a[],ll k)
    {
        if(i==n-1)
            return 0;
            
        if(dp[i]!=-1)
            return dp[i];
        ll p=1e10;    
        for(ll j=i+1;j<=min(i+k,n-1);j++)
            p=min(abs(a[j]-a[i])+jump(j,n,a,k),p);
        
        return dp[i]=p;    
            
    }
    int main()
    {
        ll i,n,test=1,k;
        cin>>n>>k;
        ll a[n];
        
        for(i=0;i<n;i++)
            cin>>a[i];
            
        memset(dp,-1,sizeof dp);
        
        cout<<jump(0,n,a,k)<<"\n";    
        
        return 0;
    }

Measured memory_bytes: 11136
import sys
input = sys.stdin.readline

from itertools import combinations_with_replacement as cwr

def main():
    N, M, Q = map(int, input().split())
    I = [list(map(int, input().split())) for _ in range(Q)]
    J = cwr(range(1, M+1), N)
    ans = []

    for j in J:
        tmp = 0
        for i in I:
            a, b, c, d = i
            tmp += d if j[b-1] - j[a-1] == c else 0
        ans.append(tmp)

    print(max(ans))

    
if __name__  == '__main__':
    main()

Measured memory_bytes: 12656
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
int main() {
	LL n, m; scanf("%lld%lld",&n,&m);
	LL ans = min(n, m / 2);
	n -= ans, m -= 2 * ans;
	ans += m / 4;
	cout <<ans<<endl;	
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    ll a,b;
    cin >> a >> b;
    a = a-1;
    int tmp =a%4;
    if(tmp==1)a=1;
    else if(tmp==2)a++;
    else if(tmp==3)a=0;
    else if(tmp==-1) a=0;

    tmp =b%4;
    if(tmp==1)b=1;
    else if(tmp==2)b++;
    else if(tmp==3)b=0;

    
    ll res = a^b;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
c = 0
A = []
for i in range(N):
  a = int(input())
  if a > i:
    c = 1
  if i >=1 and a > A[i-1]+1:
    c = 1
  A.append(a)

ans = 0
if c == 1:
  ans = -1
else:
  for i in range(1,N):
    if A[i] == A[i-1]+1:
      if i == N-1:
        ans += A[i]
      continue
    else:
      ans += A[i-1]  
      if i == N-1:
        ans += A[i]
      continue      
print(ans)  

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

int main(){
	ll n,k,i,h; cin >> n >> k;
	vector<ll> hs;
	rep(i, n){
		cin >> h;
		if(h >= k){
			hs.push_back(h);
		}
	}
	cout << hs.size() << endl;
	return 0;
}

Measured memory_bytes: 1400
import sys
readline = sys.stdin.buffer.readline

if __name__ == "__main__":
    k,s = map(int,readline().split())
    ans = 0
    for i in range(k+1):
        for j in range(k+1):
            if s-i-j <= k and i+j <= s:
                ans += 1
    print(ans)

Measured memory_bytes: 41068
#include<stdio.h>
#include<string.h>
int main(void)
{
    char s;
    int i,j,k[26] = {0},a = 0;
    while(scanf("%c",&s) != EOF){
        for(j = 0;j < 26;j++){
            if(s == 'a' + j || s == 'A' + j){
                k[j]++;
            }
        }
    }
    for(i = 0;i < 26;i++){
        printf("%c : %d\n",'a' + i,k[i]);
    }
 
 
    return 0;
}


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

using namespace std;

int a[4][4];
int main(){
    for(int i = 1; i<= 3;i++) {
        for(int j = 1;j <= 3;j ++) {
            cin>>a[i][j];
        }
    }
    for(int k = -1000;k <= 1000;k++) {
        int a2,a3,b1,b2,b3;
        int a1 = k;
        b1 = a[1][1] - k;
        b2 = a[1][2] - k;
        b3 = a[1][3] - k;
        a2 = a[2][1] - b1;
        a3 = a[3][1] - b1;
        bool flg = false;
        if(a[2][2] != a2 + b2) flg = true;
        if(a[2][3] != a2 + b3) flg = true;
        if(a[3][2] != a3 + b2) flg = true;
        if(a[3][3] != a3 + b3) flg = true;
        if(!flg) {
            cout<<"Yes"<<endl;return 0;
        }

    }
    cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    Int(n);
    int2(d, x);
    vvi table(d, vi(n, 0));
    rep(i, d) {
        rep(j, n) {
            cin >> table[i][j];
        }
    }
    vi dp(100001, 0);
    rep(i, d-1) {
        rep(j, x+1) {
            dp[j] = j;
        }
        int nxt = x;
        rep(j, n) {
            rep(k, x+1) {
                if (k < table[i][j]) continue;
                dp[k] = max(dp[k], dp[k-table[i][j]]+table[i+1][j]);
                nxt = max(nxt, dp[k]);
            }
        }
//        rep(i, x+1) { cout << dp[i] << " ";}cout << endl;
        x = nxt;
    }

    cout << x << endl;


    return 0;
}

Measured memory_bytes: 3716
#define TASK_NAME

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

struct Restaurant {
    string name;
    int score;
    int id;
};

struct Comparator {
    bool operator() (const Restaurant a, const Restaurant b) {

        if (a.name == b.name)
            return a.score > b.score;
        else
            return a.name < b.name;

    }
};

void solve() {
    int n;
    cin >> n;
    set<Restaurant, Comparator> rests;
    for (int i = 0; i < n; i++) {
        string s; int r;
        cin >> s >> r;
        rests.insert({s, r, i});
    }

    for (const Restaurant& r : rests)
        cout << r.id + 1 << endl;

}

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

Measured memory_bytes: 256
/* ***********************************************
Author        :ACagain
Created Time  :2018/4/21 11:50:24
File Name     :dong.cpp
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define pii pair<int,int>
#define mp make_pair
#define ll long long
#define INF 0x3f3f3f3f
const int maxn=105;
char s[maxn],t[maxn];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
   	cin>>s;
	sort(s,s+3);
	if(s[0]=='a'&&s[1]=='b'&&s[2]=='c')
	  cout<<"Yes"<<endl;
	else
	  cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bitset>
#include <algorithm>

using namespace std;

int main()
{
	const int MAX_VALUES = 101;
	bitset<MAX_VALUES> bits;
	bitset<MAX_VALUES> reversed;
	bits.flip();
	reversed.flip();
	int x, n, t;
    scanf("%d %d", &x, &n);
	if (n == 0) {
		printf("%d", x);
		exit(0);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d ", &t);
		bits.reset(t);
		reversed.reset(MAX_VALUES - 1 - t);
	}
	if (bits[x]) {
        printf("%d", x);
		exit(0);
	}
	int rV = bits._Find_next(x);
	int lV = MAX_VALUES - 1 - reversed._Find_next(MAX_VALUES - 1 - x);
 	int d1 = abs(rV - x);
	int d2 = abs(lV - x);
	if (d1 < d2) {
        printf("%d", rV);
	}
	else if (d2 < d1) {
		printf("%d", lV);
	}
	else {
		printf("%d", min(rV, lV));
	}
	return 0;
}

Measured memory_bytes: 3244
while true do
    n = gets.to_i
    f = 0
    if n == 0
        break
    end
    
    for i in 1..n do
        if i % 5 == 0
            f += 1
        end
        if i % 25 == 0
            f += 1
        end
        if i % 125 == 0
            f += 1
        end
        if i % 625 == 0
            f += 1
        end
        if i % 3125 == 0
            f += 1
        end
        if i % 15625 == 0
            f += 1
        end
    end
    
    puts f
end



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

int selection_sort(int A[], int N){
  int t, sw = 0, minj;
  for(int i = 0; i< N-1; i++){
    minj = i;
    for(int j = i; j < N; j++){
      if (A[j] < A[minj]) {
        minj = j;
      }
    }
    t = A[i];
    A[i] = A[minj];
    A[minj] = t;

    if (i != minj) {
      sw++;
    }
  }
  return sw;
}


int main(int argc, char const *argv[]) {
  int A[100], N, sw = 0;
  cin >> N;
  for(int i=0; i < N; i++){
    cin >> A[i];
  }

  sw = selection_sort(A, N);

  for(int i=0; i < N; i++){
    if (i) {
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;

  return 0;
}

Measured memory_bytes: 3100
// https://atcoder.jp/contests/abc133/tasks/abc133_d

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
// ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// ll lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll l, r, ans = INFL;
    cin >> l >> r;
    r = min(r, l + 2019 * 2);
    for (ll i = l; i <= r; i++) {
        for (ll j = i + 1; j <= r; j++) {
            ans = min(ans, (i * j) % 2019LL);
            if (ans == 0) {
                break;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

using ll = long long;

const int N = 100005;
const ll M = ll(1e9) + 7;

int n, p[N], a, b, c;
ll fa[N], fi[N];

ll pw(ll n, ll k){
    if(!k) return 1;
    return pw(n * n % M, k / 2) * (k % 2 ? n : 1) % M;
}

ll f(ll n, ll r){
    if(r < 0 || r > n) return 0;
    return fa[n] * fi[r] % M * fi[n - r] % M;
}

int main(){
    scanf("%d", &n); n++;
    fa[0] = 1;
    for(int i = 1; i <= n; i++) fa[i] = fa[i - 1] * i % M;
    fi[n] = pw(fa[n], M - 2);
    for(int i = n - 1; i >= 0; i--) fi[i] = fi[i + 1] * (i + 1) % M;
    for(int i = 1, x; i <= n; i++){
        scanf("%d", &x);
        if(p[x]){
            a = p[x] - 1;
            b = i - p[x] - 1;
            c = n - i;
            break;
        }
        p[x] = i;
    }
    for(int i = 1; i <= n; i++){
        printf("%lld\n", (f(a + b + c, i) + f(a + b + c, i - 2) +
            2 * f(a + b + c, i - 1) - f(a + c, i - 1) + M) % M);
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
ll mod = 1000000007;
template <class _T> inline bool chmax (_T& a,_T b){if(a<b){a=b;return true;}return false;}
template <class _T> inline bool chmin (_T& a,_T b){if(a>b){a=b;return true;}return false;}
const int inf = 2147483647;
const long long INF = 1LL << 60;
const int MAX_N = 11000;
const int MAX_W = 10100;


int main(void){
    string s;cin >> s;
    if(s[s.size()-1]=='s') cout << s << "es" << endl;
    else cout << s << 's' << endl;
	return 0;
}

Measured memory_bytes: 3620
N, A, B, C = map(int, input().split(' '))
L = [int(input()) for i in range(N)]
# 上限
MAX = 10 ** 9
#再帰関数
def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else MAX
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + L[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + L[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + L[cur]) + 10
  return min(ret0,ret1,ret2,ret3)
print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
def a():
    N,M = map(int,input().split())
    B = list(map(lambda x: int(x)//2,input().split()))

    def gcd(n,m):
        while n:
            m,n = [n,m%n]
        return m

    su = 1
    for b in B:
        su *= b // gcd(su,b)
        if su > M:
            return 0

    for _ in filter(lambda x:(su//x)%2==0,B):
        return 0

    return M//su - M//(su*2)

print(a())

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

char move(char s,int n){
  if (s+n>90) return char(s+n-26);
  else return char(s+n);
}
main(){
  int N;
  string s;
  cin>>N;
  cin>>s;
  for(int i =0;i<s.size();i++){
    cout<<move(s[i],N);
  }
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>  
#include <cstdio>  
#include <cstring>  
#include <algorithm>  
#include <cmath>
#include <cstdlib>
#include <map>

using namespace std;  
typedef long long ll;
int main()
{
	ll x, y;
	while(~scanf("%lld %lld", &x, &y))
	{
		int k = 1;
		while((x * 2) <= y)
		{
			x = x * 2; 
			k++;
	
		}
		printf("%d\n", k);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll unsigned long long int
#define pb push_back
using namespace std;
ll cnt,mini=1e9,maxi=-1;
ll n,m,k,x,a,b,c;
ll mini1=1e9,maxi1=-1,cnt1,cnt2,cnt3,ans,sum;
int main(){
ios_base::sync_with_stdio(0);
	// freopen (" .txt", "r", stdin);
	// freopen (" .txt", "w", stdout);
	string s;
	cin>>s;
	for(int i=0; i<s.size(); i++){
		if(s[i]=='A'){
			cnt++;
		}
	}
	if(cnt==3 || cnt==0){
		cout<<"No";
	return 0;
	}
	cout<<"Yes";
}
//     *    *  *  ****    *    *   *
//    *	*   * *   *      * *   *   *
//   *****  **    ****  *****  *****
//   *   *  * *      *  *   *      *
//   *   *  *  *  ****  *   *  *****
 
//   ****  ****  *       *
//   *      **   *      * *
//   ****   **   *     *****
//      *   **   *     *   *
//   ****  ****  ****  *   *


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

int main() {
    int x,y;
    cin >> x >> y;
    int n1=0,n2=0,n3=0;
    int num1[7]={1,3,5,7,8,10,12};
    int num2[4]={4,6,9,11};
    for(int i=0;i<7;i++){
        if(x==num1[i]) n1++;
        if(y==num1[i]) n1++;
    }
    for(int i=0;i<4;i++){
        if(x==num2[i]) n2++;
        if(y==num2[i]) n2++;
    }
    if(n1==2 || n2==2 ||(n1==0 && n2==0)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 384