akhauriyash/Code-Regression huggingface dataset:
#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>;
const int MAX = 100000;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)
ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}
#define MAX_N 15
int A[MAX_N+1][MAX_N+1];
int main() {
	memset(A, -1, sizeof(A));
	int N; cin >> N;
	for (int i = 1; i <= N; i++) {
		int cnt; cin >> cnt;
		rep(j, cnt) {
			int tmp; cin >> tmp;
			cin >> A[i][tmp];
		}
	}
	int p = mod_pow(2, N, MOD);
	int ans = 0;
	for (int i = 1; i < p; i++) {
		int NG_flg = 0;
		for (int j = 0; (1 << j) < p; j++ ) {
			if (NG_flg == 1) break;
			if (!(i & (1 << j))) continue;
			for (int k = 1; k <= N; k++ ) {
				if (A[j+1][k] == -1) continue;
				if ( (A[j+1][k] == 1 && (i & (1 << (k-1))) == 0) ||
				     (A[j+1][k] == 0 && (i & (1 << (k-1))) > 0) ) {
					NG_flg = 1; break;
				}
			}
		}
		if (NG_flg == 0) {
			int cnt = 0;
			rep(j, 16) {
				if (i & (1 << j)) cnt++;
			}
			ans = max(ans, cnt);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3608
from queue import Queue
H, W = map(int, input().split())
MAP = []
for h in range(H):
    MAP.append(input())
MAXIMUM = 0
arrows = [(1, 0), (0, 1), (-1, 0), (0, -1)]
for h in range(H):
    for w in range(W):
        MAX = 0
        Q = Queue()
        CNTS = [[0] * W for h in range(H)]
        RIREKI = [['W'] * W for h in range(H)]
        if MAP[h][w] == '.':
            Q.put((h, w))
        else:
            continue
        while not Q.empty():
            T = Q.get()
            y, x = T[0], T[1]
            # print(x,y)
            for arrow in arrows:

                if not ((0 <= y + arrow[0] < H) and (0 <= x + arrow[1] < W)):
                    continue
                # print(x + arrow[1], y + arrow[0])
                if MAP[y + arrow[0]][x + arrow[1]] == '.' and RIREKI[y + arrow[0]][x + arrow[1]] == 'W':
                    # print(x,y)
                    CNTS[y + arrow[0]][x + arrow[1]] = CNTS[y][x] + 1
                    if MAX < CNTS[y + arrow[0]][x + arrow[1]]:
                        MAX = CNTS[y + arrow[0]][x + arrow[1]]
                    RIREKI[y + arrow[0]][x + arrow[1]] = 'G'
                    Q.put((y + arrow[0], x + arrow[1]))
                else:
                    continue
                RIREKI[y][x] = 'B'
        if MAXIMUM < MAX:
            MAXIMUM = MAX
print(MAXIMUM)

Measured memory_bytes: 58964
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int k, n;
    cin >> k >> n;
    vector<long long> a(n);
    for (auto &e : a) cin >> e;
    
    vector<int> dist;
    for (int i = 0; i+1 < n; i++) {
        dist.push_back(a[i+1] - a[i]);
    }
    dist.push_back(a[0] + k - a[n-1]);
    
    long long ans = accumulate(dist.begin(), dist.end(), 0LL);
    ans -= *max_element(dist.begin(), dist.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2936
#a=int(input())
#b,c=int(input()),int(input())
# c=[]
#  for i in b:
#     c.append(i)
A,B,C = map(int,input().split())
# f = list(map(int,input().split()))
# j = [input() for _ in range(a)]
# h = []
# for i in range(e1):
#     h.append(list(map(int,input().split()))
ans="No"
if A<=C<=B:
    ans="Yes"

print(ans)

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

using namespace std;

#define endl            "\n"
#define sz(x)          (int) (x.size())
#define all(v)          v.begin(), v.end()
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;



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

    int x; cin >> x;
    cout << (!x);
    return 0;
}


Measured memory_bytes: 3648
// Problem : 
// 			B - Making Triangle
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define int long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define mod 998244353
#define bug cout<<"HY"<<endl
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define numize(A) A.numize(unique(A.begin(), A.end()) - A.begin())
typedef pair<int,int> P;
int power(int a,int b)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return (power((a*a)%mod,b/2))%mod;
    return (a*(power((a*a)%mod,b/2))%mod)%mod;
}
int modInv(int n)
{
    return power(n, MOD-2);
}
int nCr(int n, int r, int p=MOD)
{
   if (r==0)
      return 1;
    int Fact[n+1];
    Fact[0] = 1;
    for (int i=1 ; i<=n; i++)
    {
        Fact[i] = (Fact[i-1]*i)%p;
    }
    return (((Fact[n]* modInv(Fact[r])) % MOD) *(modInv(Fact[n-r]) % MOD)) % MOD;
}
double PI=3.14159265359;
void solve()
{
	int n,i,j,k,cnt=0;
	cin>>n;
	int A[n];
	for(i=0;i<n;i++)
		cin>>A[i];
	sort(A,A+n);
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			for(k=j+1;k<n;k++)
			{
				if(A[k]<A[i]+A[j] && A[i]!=A[j] && A[j]!=A[k])
				{
					// trace(A[i],A[j],A[k]);
					cnt++;
				}
			}
		}
	}
	cout<<cnt<<endl;
}
int32_t main()
{
    boost;
    int  t=1;
    // cin>>t;
    while(t--)
    {
    	solve();
    }
}


Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>

using namespace std;

int main(){
  long long n;
  cin >> n;
  long long ans = 0;
  //int num[100000000000/2 + 1] = {};
  for(long long i = 1 ; i <= n/2 && n/i - 1 > i ; i++){
    if(n%i == 0) ans += n/i - 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n, w = map(int, input().strip().split())
  Ws, Vs = numpy.array([[int(x) for x in input().strip().split()] for _ in range(n)]).T
  v_max = 10**5
  dp = numpy.full((n, v_max+1), 10**9+1, dtype=numpy.int)
  dp[0, 1:Vs[0]+1] = Ws[0]
  dp[:, 0] = 0
  for i in range(1, n):
    dp[i, :Vs[i]+1] = numpy.minimum(dp[i-1, :Vs[i]+1], Ws[i])
    if v_max - Vs[i] + 1 > 0:
      dp[i, Vs[i]:v_max+1] = numpy.minimum(dp[i-1, Vs[i]:v_max+1], dp[i-1,:v_max-Vs[i]+1]+Ws[i])
  print(numpy.max(numpy.where(dp[n-1] <= w)))


if __name__=='__main__':
  main()

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long unsigned int
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define sp << ' ' << 
#define sps << ' '
#define nl "\n"
// #define nl endl
// #define fat 1000000007
#define fat 2019
// #define fat 998244353

ll power(ll base, ll exp, ll mod) // O(logn) time
{
    ll ans=1LL;
    while(exp){
        if(exp&1LL) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exp>>=1LL;
    }
    return ans%mod;
}

int main()
{
    boost;
    ll tt = 1, n, m, i, j, x, y, a ,b , c ,d;
    bool poss = true;
    string s;

    // cin >> tt;
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> s;
        n = sz(s);

        map<ll, ll> mp;
        ll num = 0;
        ll ans = 0LL;
        mp[0] = 1;

        int i = n - 1;
        for(i = n - 1; i >= 0; i--){
            // cout << i << endl;
            num = (power(10, n - 1 - i, 2019)*(s[i] - '0') + num)%2019;
            // cout << num sp i << endl;
            mp[num]++;
        }

        // cout << n << endl;
        loop(z, mp){
            ans += ((z.S)*(z.S - 1)) >> 1;
        }

        cout << ans << nl;
    }   
    return 0;
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

ll l,r;
int main(){
  cin >> l >> r;
  ll ans = 2020;
  r = min(r, l+2019);
  for(ll i = l; i <= min(r, l+2019); i++){
    for(ll j = i+1; j <= min(r, l+2019); j++){
      ll tmp = (i*j)%2019;
      ans = min(ans, tmp);
    }
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;

ll n;

ll dig(ll x){
	ll res = 0;
	while(x > 0){
		res++;
		x /= 10;
	}

	return res;
}

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

	ll fRes = 0;
	for(int i = 1; i <= n; i++){
		fRes += (dig(i) % 2 != 0);
	}

	cout << fRes << '\n';

	return 0;
}

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

struct P {
	int x, y, r;
	P(){}
	P(int a, int b, int c = 0):x(a), y(b), r(c){}
	double dis(P &o) {
		double dx = x - o.x, dy = y - o.y;
		double an = sqrt(dx * dx + dy * dy);
		an -= r + o.r;
		return max(an, 0.0);
	}
}cr[1002];

double dis[1002][1002];
bool vis[1002];

int main() {
	int a, b, n;
	f(i, 0, 2)scanf("%d%d", &a, &b), cr[i] = P(a, b);
	scanf("%d", &n);
	f(i, 2, n + 2) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		cr[i] = P(a, b, c);
	}
	f(i, 0, n + 1)f(j, i + 1, n + 2)dis[i][j] = dis[j][i] = cr[i].dis(cr[j]);
	priority_queue < pair<double, int> > q;
	q.push(make_pair(0.0, 0));
	while (true) {
		double d = -q.top().first;
		int v = q.top().second;
		q.pop();
		if (vis[v])continue;
		vis[v] = true;
		if (v == 1)printf("%.10lf\n", d), exit(0);
		f(i, 0, n + 2)if (i != v && !vis[i])q.push(make_pair(-(d + dis[v][i]), i));
	}
}

Measured memory_bytes: 16364
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    ll s = 0;
    map<int, int> counter;
    for(int x : a) {
        counter[x]++;
        s += x;
    }
    int q;
    cin >> q;
    while(q--) {
        int b, c;
        cin >> b >> c;
        s += (c - b) * counter[b];
        counter[c] += counter[b];
        counter[b] = 0;
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 7960
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    getLine
    ps <- getIntList
    putStrLn $ if solve ps <= 2 then "YES" else "NO"

solve ps = sum $ zipWith check ps (sort ps)
    where check p q | p == q = 0
                    | otherwise = 1

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

string s[200];
int cnt=0;

void dfs(string str,int a,int b,int j,int y){
  if(a==j && b==y){
    bool flag=0;
    for(int i=0; i<cnt; i++){
      if(s[i]==str){
        flag++;
      }
    }
    if(flag==0){
      s[cnt]=str;
      cnt++;
    }
  }

  string str1=str;
  string str2=str;

  if(a>=4 && b>=4){
    if(a<j){
      str1.push_back('A');
      dfs(str1,a+1,b,j,y);
    }
    if(b<y){
      str2.push_back('B');
      dfs(str2,a,b+1,j,y);
    }
  }else{
    if(a==4 && b<y){
      str1.push_back('B');
      dfs(str1,a,b+1,j,y);
    }else if(a<j){
      str1.push_back('A');
      dfs(str1,a+1,b,j,y);
    }
    if(b==4 && a<j){
      str2.push_back('A');
      dfs(str2,a+1,b,j,y);
    }else if(b<y){
      str2.push_back('B');
      dfs(str2,a,b+1,j,y);
    }
  }
}

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

  string str;

  dfs(str,0,0,j,y);

  for(int i=0; i<cnt; i++){
    cout << s[i] << '\n';
  }

  return 0;
}



Measured memory_bytes: 3208
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007


int main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 15)cout << "+" << endl;
	else if (a*b == 15)cout << "*" << endl;
	else cout << "x" << endl;
	return 0;
}

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

const int mod = 1000000007;

struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
 
  // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
    mint P(int n, int k){
        return fact[n] * ifact[n-k];
    }
};

int main(){
    int n;
    cin >> n;
    ve<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    ve<mint> two(n+1);
    two[0] = 1;
    rep(i,n) two[i+1] = two[i] * 2;
    mint ans = mint(0);
    rep(i,n){
        int l = i, r = n-1-i;
        mint now = two[r];
        if(r != 0) now += two[r-1] * r;
        now *= two[l];
        now *= a[i];
        ans += now;
    }
    ans *= two[n];
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 5540
#include <cstdio>
#include <cstdlib>
using namespace std;
int main() {
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(abs(a-c)<=d)
        printf("Yes\n");
    else{
        if(abs(a-b)<=d&&abs(b-c)<=d)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


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

using namespace std;

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

  vector<double> x(n);
  vector<double> y(n);

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

  int ans = 0;
  for(int i = 0; i < n; i++){
    double l = sqrt(x[i]*x[i] + y[i]*y[i]);

    if(l <= d){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

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

#define st              first
#define nd              second
#define pb              push_back
#define pf              push_front
#define all(a)          (a).begin(), (a).end()
#define lwb             lower_bound
#define upb             upper_bound
#define vvll            vector<vector<ll> >
#define Reset(s, n)      memset(s, n, sizeof(s))
#define Sz(a)           int((a).size())
#define Max(a, b, c)    max(max((ll)(a), (ll)(b)), (ll)(c))
#define Min(a, b, c)    min(min((ll)(a), (ll)(b)), (ll)(c))
#define Unique(a)       (a).resize(unique(all(a)) - (a).begin())
#define bit(n, i)       (((n) >> (i)) & 1)
#define onbit(n, i)     ((n) |= (1LL << (i)))
#define offbit(n, i)    onbit((n), (i)), ((n) -= (1LL << (i)))
#define bitcount(n)     __builtin_popcountll(n)

using namespace std;

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

const ll MOD = 1e9 + 7;
const ll oo = 2e9;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline bool isPrime (ll x){ if(x <= 1) return 0; if(x <= 3) return 1; if (!(x % 2) || !(x % 3)) return 0; ll s = sqrt(1.0 * x) + EPS; for(ll i = 5; i <= s; i += 6){if (!(x % i) || !(x % (i + 2))) return 0;}return 1;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}

const int N = 3e5 + 5;

ll n, m, k;
ll a[N];

void Solve(){
    map<string, int> mp;
    cin >> n;
    int mx = 0;
    for(int i = 1; i <= n; i++){
        string s;
        cin >> s;
        mp[s]++;
        if(mp[s] > mx) mx = mp[s];
    }
    for(auto it: mp){
        if(it.nd == mx){
            cout << it.st << "\n";
        }
    }

}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int query = 1;
//    cin >> query;
    int start = 1000 * clock() / CLOCKS_PER_SEC;
    while(query--) Solve();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC  - start << "ms\n";
}


Measured memory_bytes: 23808
#include<iostream>

int main() {
	int n;
	std::cin >> n;
	long long int ans = 0;
	
	int temp[2];
	std::cin >> temp[0];
	int sum = 0;

	for (int i = 0; i < n-1; i++) {
		std::cin >> temp[1];
		if (temp[0] >= temp[1])sum++;
		else sum = 0;

		temp[0] = temp[1];

		if (ans < sum)ans++;
	}

	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
   string S;
   cin >> S;
   int ptr = S.length() - 1; // 最後の文字位置

   vector<string> pattens;
   pattens.pb("dream");
   pattens.pb("dreamer");
   pattens.pb("erase");
   pattens.pb("eraser");

   bool isMatch = true;
   while (ptr >= 0 || isMatch) {
       isMatch = false;
       // DEBUG(ptr);

       rep(i, 4) {
         string p = pattens[i];
         // DEBUG(p);
         int len = p.length();
         bool isSame = true;
         rep (j, len) {
            if (p[len - 1 - j] != S[ptr - j]) {
                isSame = false;
            }
         }
         if (isSame) {
             isMatch = true;
             ptr = ptr - len;
             break;
         }
       }

       if (!isMatch) break;
   }

   if(ptr < 0) {
     cout << "YES" << endl;
    } else {
     cout << "NO" << endl;
    }
}

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

n, m = list(map(int, input().rstrip().split()))
ans = [""] * m
arr = []
cnt = 1
for i in range(m):
    p, y = map(int, input().split())
    arr += [(p, y, i)]
arr = sorted(arr)

ans[arr[0][2]] = "{:06}{:06}".format(arr[0][0], cnt)
for i in range(1, m):
    if arr[i - 1][0] == arr[i][0]:
        cnt += 1
    else:
        cnt = 1
    ans[arr[i][2]] = "{:06}{:06}".format(arr[i][0], cnt)

print(*ans, sep="\n")

Measured memory_bytes: 30580
// B - Coins
#include <stdio.h>
#include <stdlib.h>

// 標準入力から改行かスペースまで読み取り、数字として返す
int get_num() {
    // 10文字+区切り文字までしか受け付けられない
    char s[11];
    int i, n;
    for (i = 0; i < sizeof(s); i++) {
        s[i] = getchar();
        if (s[i] == ' ' || s[i] == '\n') {
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}

int main(void) {
    int a, b, c, x;
    int count = 0;
    int A, B, C;

    A = get_num();
    B = get_num();
    C = get_num();
    x = get_num();

    for (a = 0; a <= A; a++) {
        for (b = 0; b <= B; b++) {
            for (c = 0; c <= C; c++) {
                if (a * 500 + b * 100 + c * 50 == x) {
                    count++;
                }
            }
        }
    }
    
    printf("%d\n", count);
    
    return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,x,y;
	while(cin>>W>>H>>x>>y) {
		cout<<(double)W*H/2<<" "<<(x*2==W&&y*2==H?"1":"0")<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

n = readInt()
d,x = readInts()
a = []
for i in range(n):
	a.append(readInt())

ans = 0
for i in range(n):
	for j in range(d):
		if 1+a[i]*j<=d:
			ans+=1
		else:
			break

print(x+ans)

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

int toDigit(char ch)
{
    return (ch - '0');
}

int main( )
{
    string s;
    int first, last;
    int is_first_month, is_last_month;
    is_first_month = is_last_month = 0;
    cin >> s;
    first = toDigit(s[0]) * 10 + toDigit(s[1]);
    last = toDigit(s[2]) * 10 + toDigit(s[3]);
    if (first >= 1 && first <= 12) {
        is_first_month = 1;
    }
    if (last >= 1 && last <= 12) {
        is_last_month = 1;
    }
    if (is_first_month == 0 && is_last_month == 0) {
        cout << "NA\n";
    }
    else if (is_first_month == 1 && is_last_month == 1) {
        cout << "AMBIGUOUS\n";
    }
    else if (is_first_month == 1) {
        cout << "MMYY\n";
    }
    else {
        cout << "YYMM\n";
    }
    return 0;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

// GCD : greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

// LCM : find Least Common Multiple (LCM) via GCD
func LCM(a, b int, integers ...int) int {
	result := a / GCD(a, b) * b

	for i := 0; i < len(integers); i++ {
		result = LCM(result, integers[i])
	}

	return result
}

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

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

func x2(n int) int {
	ret := 0
	for n%2 == 0 {
		ret++
		n /= 2
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M := getInt(), getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}

	//
	for i := 0; i < N; i++ {
		// if a[i]%2 == 1 {
		// 	out(0)
		// 	return
		// }
		a[i] /= 2
	}

	t := x2(a[0])
	// out(t)
	a[0] >>= uint(t)
	for i := 1; i < N; i++ {
		if x2(a[i]) != t { // 偶数なので必要ないのでは
			out(0)
			return
		}
		a[i] >>= uint(t)
	}

	M >>= uint(t)

	// out(a)

	l := LCM(1, 1, a...)

	//	out(l)

	//　out(l, M)
	M /= l
	out((M + 1) / 2)
}


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

Measured memory_bytes: 3060
import java.util.*

fun main(args : Array<String>) {
    val scanner = Scanner(System.`in`)
    val S = scanner.nextLine()
    var i = 0
    var j = 0
    var max = 0
    while(j < S.length) {
      if(S[j] == 'S') {
        i = j + 1
      }
      max = Math.max(max, j - i + 1)
      j++
    }
    println(max)
}

Measured memory_bytes: 36348
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

#define PI 3.1415926535897932384626433832795
int a, b, x;

int main() {

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

	if (x * 2 >= a * a * b) {
		double y = (a * b - (double)x / a) * 2.0 / a;
		printf("%.20f", atan2(y, a) / PI * 180);
	}
	else {
		double y = (double)x / a * 2.0 / b;
		printf("%.20f", 90.0 - atan2(y, b) / PI * 180);
	}

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int a,b;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b;
	if (a>=1 && a<=9 && b<=9 && b>=1) cout<<a*b;
	else cout<<"-1";
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string s; cin >> s;
    deque<char> x;
    rep(i, s.size()){
        if (s[i] == '1'){
            x.push_back('1');
        } else if (s[i] == '0'){
            x.push_back('0');
        } else {
            if (x.size() > 0){x.pop_back();}
        }
    }
    for (auto a: x){cout << a;}
}

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


Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;
int main(){
    char ch='A',x='A';
    int k=0;
    while(k<1200){
        
        scanf("%c",&ch);
        if(ch== '\n')break;
        if(isalpha(ch)){
            if(islower(ch)){
                x=toupper(ch);
            }else{
                x=tolower(ch);
            }
            printf("%c",x);
        }else{
            printf("%c",ch);
        }
        k+=1;
        
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3144
//#pragma comment(linker,"/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rep(i, a, b) for (int i = (a); i <= b; ++i)
const int max_number = 1000000;

int main()
{
    int a,b,c,count;
    count=0;
    scanf("%d%d%d", &a, &b, &c);
    for (int i = a; i <= b;i++)
    {
        if(c%i==0)
            count++;
    }

    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 3228
import numpy as np
import sys
readlines = sys.stdin.readlines()

N, M, Q = map(int, readlines[0].split())
city = np.zeros((N + 1, N + 1), dtype=int)
L, R = np.array([i.split() for i in readlines[1:M + 1]], dtype=int).T
p, q = np.array([i.split() for i in readlines[M + 1:]], dtype=int).T

np.add.at(city, (L, R), 1)
np.cumsum(city, axis=0, out=city)
np.cumsum(city, axis=1, out=city)

p -= 1
answer = city[q, q] - city[p, q] - city[q, p] + city[p, p]
print('\n'.join(answer.astype(str)))

Measured memory_bytes: 99824
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int h, w, n;
    cin >> h >> w >> n;
    h = max(h, w);
    cout << (n + h - 1) / h << endl;
}

int main()
{
    solve();
    return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int ctoi(const char c)
{
    if ('0' <= c && c <= '9')
        return (c - '0');
    return -1;
}

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    int year = ctoi(s[0]) * 1000 + ctoi(s[1]) * 100 + ctoi(s[2]) * 10 + ctoi(s[3]);
    int month = ctoi(s[5]) * 10 + ctoi(s[6]);
    int day = ctoi(s[8]) * 10 + ctoi(s[9]);
    if (year <= 2019 && month <= 4 && day <= 30)
        cout << "Heisei" << endl;
    else
        cout << "TBD" << endl;
    return 0;
}


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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const ll INF = 2e18;
const int MOD = 1e9 + 7;
const int MAXN = 3e5 + 5;

int N, M;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N >> M;
	int cnt = 1;
	for(int i=(N-1)/2; i>=1; i-=2) {
		if(M == 0) break;
		cout << cnt << ' ' << cnt + i << endl;
		M--; cnt++;
	}
	cnt = 1 + (N-1)/2 + 1;
	for(int i=(N-1)/2-1; i>=1; i-=2) {
		if(M == 0) break;
		cout << cnt << ' ' << cnt + i << endl;
		M--; cnt++;
	}
}


Measured memory_bytes: 3652
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;

ll binary_search(function<bool(ll)> func, ll start, ll end) {
    /*      func:int ->bool
            returns smallest int x where func(x) evaluates to true, searches in [start,end), it is assumed the values are false, .. , false, true ...
             */
    if (end <= start) {   return end;  }   // has to be here, otherwise func(end-1) in next line could be a problem
    if (!func(end-1)) {  return end;  }
    while (end-start>1) {
        ll mid = (start+end)/2;
        if (func(mid)) {  end = mid;  } else { start = mid;   }
    }
    if (func(start)) {  return start;  } else {  return end;   }
};


template<class T>
T fastpower(T a, long long n) {  // n must be >= 1
  if (n==0) {return 1;}
  if (n % 2 == 0) {  
      T halfpower = fastpower<T>(a, n/2);
      return (halfpower*halfpower) % modd;
  } else {
      if (n == 1) {  return a; } else {  
          T halfpower = fastpower<T>(a, n/2);
          return (((halfpower*halfpower)%modd)*a)%modd;
      }
  }
};


int how_many_below(vector<ll>& a, ll y) {
   return (lower_bound(a.begin(), a.end(), y) - a.begin());
}

int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
 
//    auto start = chrono::steady_clock::now();
  
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(n);
        vector<ll> a, b;

        forr(i,0,n+1) {
            readll(kk); a.push_back(kk);
        }
        forr(i,0,n) {
            readll(kk); b.push_back(kk);
        }

        ll sum = 0;
        forr(i,0,n) {
            ll k1 = min(a[i], b[i]);
            a[i] -= k1;
            b[i] -= k1;
            sum += k1;
            ll k2 = min(a[i+1], b[i]);
            a[i+1] -= k2;
            sum += k2;
        }

        cout << sum << endl;


    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;
 
    return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

using namespace std;

int mh[] = {0,1,0,-1};
int mw[] = {1,0,-1,0};
int H,W;
char Map[102][102];
bool check[102][102];
void dfs(int h,int w,char c){
    for(int i = 0;i < 4;i++){
        int movew = mw[i] + w;
        int moveh = mh[i] + h;
        if(movew >= 0 && moveh >= 0
           && movew < W && moveh < H){
            if(Map[moveh][movew] == c && check[moveh][movew] == false){
                check[moveh][movew] = true;
                dfs(moveh,movew,c);
            }
        }
    }
}
int main(){
    while(true){
        scanf("%d %d",&H,&W);
        if(H+W == 0)break;
        for(int i = 0;i < 102;i++){
            for(int j = 0;j < 102;j++){
                check[i][j] = false;
            }
        }
        for(int i = 0;i < H;i++){
            for(int j = 0;j < W;j++){
                char c;
                do { c=getchar(); } while (c!='@' && c!='#' && c!='*');
                Map[i][j] = c;
            }
        }
//        for(int i = 0;i < H;i++){
//            for(int j = 0;j < W;j++){
//                printf("%c",Map[i][j]);
//            }
//            printf("\n");
//        }
        int cnt = 0;
        for(int i = 0;i < H;i++){
            for(int j = 0;j < W;j++){
                if(!check[i][j]){
                    check[i][j] = true;
                    dfs(i,j,Map[i][j]);
                    cnt++;
                }
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}

Measured memory_bytes: 1680
#include <bits/stdc++.h>
typedef long long int ll;
#define f(i,o,n) for(i=o;i<n;i++)
#define pb push_back
#define vll vector<ll>
#define s(x) sort(x.begin(),x.end())
using namespace std;

int main() {
    ll n,i,j,ans=0;
    cin>>n;
    ll a[n];
    f(i,0,n)    cin>>a[i];
    ll lmx[n];
    lmx[0]=a[0];
    f(i,1,n)
    lmx[i]=max(lmx[i-1],a[i]);
    f(i,0,n)
    ans+=lmx[i]-a[i];
    cout<<ans;
    
}

Measured memory_bytes: 6736
//==========//============================================================================
// Name        : Hello5.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;//<key,value>


int main() {
int a,b;
cin>>a>>b;
int s=a-1;
int t=b-1;
int ans=(t+s-1)/s;//t/sの切り上げ
cout<<ans<<endl;
return 0;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n; cin >> n;
  cout << n/3 << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


ll gcd(ll x, ll y) {
  if (x < y) swap(x, y);
  return y ? gcd(y, x%y) : x;
}

ll a[MAX];
int main(void) {
  cin >> n >> m;
  rep(i, n) scan(a[i]);
  rep(i, n) a[i] = llabs(a[i] - m);
  ll cur = a[0];
  FOR(i, 1, n) {
	if (!a[i]) continue;
	cur = gcd(cur, a[i]);
  }

  cout << cur << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

int main(){
    ll n,a[100010],s=-10000000000,t=10000000000,ans=0,c=0;
    cin>>n;
    fr(i,n){
        cin>>a[i];
        ans+=abs(a[i]);
        if(a[i]>0) t=min(t,a[i]);
        if(a[i]<=0){
            c++;
            s=max(s,a[i]);
        }
    }
    if(c%2){
        ans=max(ans+2*s,ans-2*t);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024