akhauriyash/Code-Regression huggingface dataset:
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(1e15+100)
#define N 1000050

int n, m;
vector<int> vec; 
int dp[(1<<12) + 1][1005][2];
int cost[1005];

int fun(int mask, int ind, int stage)
{
    if(ind>m-1)
    {
        if(mask == (1<<n) - 1)
            return 0;
        return MAXI;
    }

    int ans = dp[mask][ind][stage];
    if(ans!=-1)
        return ans;

    ans = MAXI;
    int x = vec[ind] | mask;
    if(x > mask)
        ans = min(ans, cost[ind] + fun(x, ind + 1, 1));

    ans = min(ans, fun(mask, ind + 1, 0));
    return dp[mask][ind][stage] = ans;
} 
 
// Driver code to test above functions
int32_t main()
{
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    cin >> n >> m;
    for(int i=0;i<m;i++)
    {
        cin >> cost[i];
        int sz;
        cin >> sz;
        int mask = 0;
        for(int j=0;j<sz;j++)
        {
            int temp;
            cin >> temp;
            temp--;
            mask |= (1 << temp);
        } 
        vec.push_back(mask);
    }

    memset(dp, -1, sizeof dp);

    int x = fun(0, 0, 0);
    if(x==MAXI)
        cout << -1;
    else
        cout << x;

    return 0;
} 

Measured memory_bytes: 64640
import java.util.Scanner;

/**
 * Created by User on 2017/02/18.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        System.out.println(getPower(n));

    }

    public static long getPower(int n) {
        long ans = n;
        while (n > 1) {
            n = ((n + 1000000007) - 1) % 1000000007;
            ans = (ans % 1000000007) * (n % 1000000007);
        }
        return ans;
    }
}


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

int main() {
    string n;
    bool f = false;
    cin >> n;
    for(int i = 0; i < 3; ++i) {
        if(n[i] == '7') f = true; 
    }
    if(f) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;


int main() {
	int n;
	cin >> n;
	map<int, int> mpev;
	map<int, int> mpod;
	int a;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		if (i % 2)mpod[a]++;
		else mpev[a]++;
	}
	mpev[0] = 0;
	mpod[0] = 0;
	auto mxe = mpev.begin()->first;auto smxe = 0;
	auto mxo = mpod.begin()->first;auto smxo = 0;
	int cnt = 0;
	for (auto itr:mpev) {
		if (itr.second > mpev[mxe]) {
			smxe = mpev[smxe]<mpev[mxe]?mxe:smxe;
			mxe = itr.first;
		}
		else if (itr.second > mpev[smxe]) {
			smxe = itr.first;
		}
	}
	for (auto itr : mpod) {
		if (itr.second > mpod[mxo]) {
			smxo = mpod[smxo]<mpod[mxo]?mxo:smxo;
			mxo = itr.first;
		}else if (itr.second > mpod[smxo]) {
			smxo = itr.first;
		}
	}
	if (mxo == mxe) {
		cout << n - max(mpod[smxo] + mpev[mxe], mpev[smxe]+mpod[mxo]) << endl;
		return 0;
	}
	cout << n - mpod[mxo] - mpev[mxe] << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  double N, K; cin >> N >> K;
  vector<double> prob(18);
  prob[0] = 1;
  for(int i=1; i<18; i++){
    prob[i] = prob[i-1]/2;
  }
  int loop;
  if (N<=K-1){
    loop = N;
  }else {
    loop = K-1;
  }
  
  int nocoin = max(0, (int)N-(int)K+1);

  int j, tmp, maxj;
  maxj = 0;
  vector<int> cnt(18, 0);
  for (int i=1; i<=loop; i++){
    j = 0;
    tmp = i;
    while (tmp<K){
      j++;
      tmp *= 2;
    }
    cnt[j] ++;
    maxj = max(maxj, j);
  }
  int numerator, enumrator;
  enumrator = (1<<maxj) * N;
  numerator = nocoin * (1<<maxj);
  for(int i=0; i<maxj; i++){
    numerator += cnt[maxj-i] * (1<<i);
  }
  
  double ans;
  ans = (double)numerator/enumrator;
  cout << fixed << setprecision(20) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstring>
#include <numeric>
#include <set>
#include <queue>
#include <deque>
#include <array>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <map>
#include <functional>
#include <bitset>
#include <complex>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i > 0) {
			a[i] += a[i - 1];
		}
	}
	const ll inf = 1e18 + 228;
	vector<vector<ll>> dp(n, vector<ll>(n, inf));
	for (int i = 0; i < n; i++) {
		dp[i][i] = 0;
	}
	for (int l = n - 1; l >= 0; l--) {
		for (int r = l + 1; r < n; r++) {
			for (int m = l; m < r; m++) {
				dp[l][r] = min(dp[l][r], dp[l][m] + dp[m + 1][r] + (a[r] - (l ? a[l - 1] : 0)));
			}
		}
	}
	cout << dp[0][n - 1];
}


Measured memory_bytes: 1536
import numpy as np
from numba import njit, i8

n, k = map(int, input().split())
arr = np.array(list(map(int, input().split())))


@njit(i8[:](i8, i8, i8[:]), cache=True)
def solve(n, k, arr):
    for i in range(min(k, 50)):
        tmp_arr = np.zeros(n + 1, np.int64)
        for i, power in enumerate(arr):
            tmp_arr[max(0, i - power)] += 1
            tmp_arr[min(n, i + power + 1)] -= 1
        arr = np.cumsum(tmp_arr)[:-1]
    return arr


print(*solve(n, k, arr))

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

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

int main(){
  ll k;
  cin >> k;
  ll ans = 0;
  for(ll i = 1; i <= k; i++) {
    for(ll j = 1; j <= k; j++) {
      for(ll l = 1; l <= k; l++) {
        ans += gcd(i,gcd(j,l));
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(int argc, char *argv[])
{
    int n, p, m;
    bool flg;
    vector<int>::iterator itr;
    while (cin >> n >> p && n != -1) {
        vector<int> prime, sums;
        for (int i = n + 1;; ++i) {
            flg = true;
            if (i == 2) {
                prime.push_back(i);
            } else if (i % 2 == 0 || i < 2) {
                continue;
            } else {
                for (int j = 3; j * j <= i; j += 2) {
                    if (i % j == 0)
                        flg = false;
                }
                if (flg)
                    prime.push_back(i);
                else
                    continue;
            }
            for (itr = prime.begin(); itr != prime.end(); ++itr)
                sums.push_back(*itr + i);
            sort(sums.begin(), sums.end());
            if (sums.size() > p && sums[p] < i + prime[0]) {
                cout << sums[p - 1] << endl;
                break;
            }
        }
    }
    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int a,b;
    cin>>a>>b;
    if (a+b==15) out("+");
    if (a*b==15) out("*");
    out("x");
    
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<long long,int> P;

const ll MOD = 1e+9 + 7;

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

int main(){
    int n, k;
    ll ans = 0;
    cin >> n >> k;
    ll b[100010] = {};
    for(int g = k; g >= 1; g--){
        if(k / g == 1) b[g] = 1;
        else {
            int kk = k / g;
            ll tmp = modpow(kk, n);
            int i = 2;
            while(i * g <= k){
                tmp -= b[i * g];
                tmp %= MOD;
                i ++;
            }
            tmp += MOD;
            tmp %= MOD;
            b[g] = tmp;
        }
    }

    rep(i, k) {
        ans += b[i + 1] * (i + 1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  static const double pi = 3.141592653589793;
  
  double c;
  
  if(60*H - 11*M > 0)
    c = sqrt(A*A + B*B - 2*A*B*cos(pi*(60*H-11*M)/360));
  else
    c = sqrt(A*A + B*B - 2*A*B*cos(pi*(11*M - 60*H)/360));
  
  cout << fixed << setprecision(20);
  cout << c << endl;
}

Measured memory_bytes: 4156
#include <stdio.h>

int main(void) {
    double N;
    scanf("%lf", &N);
    for(int i=1;i<=50000;i++){
        if((int)(i*1.08) == N){
            printf("%d\n",i);
            return 0;
        }
    }
    printf(":(\n");
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> Z(N);
    for (int i=0; i<N; i++) {
        int x,y;
        cin >> x >> y;
        Z.at(i) = make_pair(x, y);
    }
    vector <int> v(N);
    for (int i=0; i<N; i++) v.at(i) = i;
    double wa=0;
    double denom=0;
    do {
        denom++;
        for (int i=0; i<N-1; i++) {
            double dx = pow((Z.at(v.at(i)).first - Z.at(v.at(i+1)).first), 2);
            double dy = pow((Z.at(v.at(i)).second - Z.at(v.at(i+1)).second), 2);
            wa+=sqrt(dx+dy);
        }
    } while(next_permutation(v.begin(), v.end()));
    printf("%.7f", wa/denom);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,k;    cin >> n >> k;
    for(int i = 0;i < k;i++){
        int a;  cin >> a;
        n -= a;
    }
    if(n < 0)   cout << "-1";
    else        cout << n;
    return 0;
}

Measured memory_bytes: 3172
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    cin>>a;
    if(a<1200)cout<<"ABC"<<"\n";
    else cout<<"ARC"<<

    "\n";
}


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

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] arr = primeArray();
    int[] fin = new int[N];
    for(int i = 0; i < N; i++) {
      fin[i] = arr[i];
    }
    String out = "";
    for(int curr : fin)
      out += curr + " ";
    System.out.println(out.substring(0, out.length()-1));
  }
  
  /*public static boolean checkIf5(int[] n) {
    int sum = 0;
    for(int curr : n) {
      sum += curr;
    }
    return sum % 5 == 0;
  }*/
  
  public static int[] primeArray() {
    int[] primes = new int[10000];
    primes[0] = 2;
    int ind = 1;
    for(int i = 3; i <= 55555; i += 2) {
      if(isPrime(i) && i % 10 == 7) {
        primes[ind] = i;
        ind++;
      }
    }
    return primes;
  }
  
  public static boolean isPrime(int n) {
    for(int i = 2; i*i < n; i++) {
      if(n % i == 0)
        return false;
    }
    return true;
  }
  
  public static int returnSum(int[] n) {
    int sum = 0;
    for(int i = 0; i < n.length; i++)
      sum += n[i];
    return sum;
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(N * A, B);
  return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
total = 0
if x == 1:
    total += 300000
elif x == 2:
    total += 200000
elif x == 3:
    total += 100000

if y == 1:
    total += 300000
elif y == 2:
    total += 200000
elif y == 3:
    total += 100000

if x == 1 and y == 1:
    total += 400000

print(total)

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

string A, B;
int ai, bi;

int nodeval(bool isA)
{
  int ret = 0;
  if(isA) while(ai < A.size() && isdigit(A[ai])) ret = ret*10 + A[ai]-'0', ai++;
  else while(bi < B.size() && isdigit(B[bi])) ret = ret*10 + B[bi]-'0', bi++;
  return ret;
}

void parse()
{
  bool advA = (ai < A.size() && A[ai] == '(');
  bool advB = (bi < B.size() && B[bi] == '(');
  if(!advA && !advB) return;
  if(advA) ai++; // (
  if(advB) bi++; // (
  if(advA && advB) cout << "(";
  parse(); // left child
  if(advA && advB) cout << ")";
  if(advA) ai+=2; // )[
  if(advB) bi+=2; // )[
  int aval = nodeval(true);
  int bval = nodeval(false);
  if(advA && advB) cout << "[" << aval+bval << "]";
  if(advA) ai+=2; // ](
  if(advB) bi+=2; // ](
  if(advA && advB) cout << "(";
  parse(); // right child
  if(advA && advB) cout << ")";
  if(advA) ai++; // )
  if(advB) bi++; // )
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> A >> B;
  parse();
  cout << endl;

  return 0;
}

Measured memory_bytes: 3144
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}   // 


int main() {
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];

	sort(ALL(a));

	if (a[0] == 5 && a[1] == 5 && a[2] == 7)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, A, B;
  cin >> N >> A >> B;

  if (N < A) {
    cout << N << endl;
    return 0;
  }

  if (A == 0) {
    cout << 0 << endl;
    return 0;
  }

  ll cnt = N / (A + B);
  ll ans = cnt * A;
  ll remain = N - cnt * (A+B);
  if (remain <= A) {
    ans += remain;
  } else {
    ans += A;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1e12
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
#define OUT(x) for(auto a:x) cout << a << " "; cout << endl;
#define OK cout << "@===================ok===================@" <<endl;
#define WTF cout <<"< "<<lo<<" | "<< hi <<" >" << endl;

using namespace std;

int n;
int next(int i){
    if(i%2==0) return i/2;
    else return n+ (i+1)/2;
}
int main()
{
    fast_cin;
    string s;
    cin >> s;
    string q="";
    string t="";
    int n=s.size();
    for(int i=0;i<n;i++){
        q+=((i%2==0)+'0');
        t+=((i%2)+'0');
    }
    int mis1=0,mis2=0;
    for(int i=0;i<n;i++){
        if(s[i]!=q[i]) mis1++;
        if(s[i]!=t[i]) mis2++;
    }
    cout << min(mis1,mis2)<<endl;
}


Measured memory_bytes: 720
class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        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


N, M = map(int, input().split())
P = map(int, input().split())

uf = UnionFind(N)
for _ in range(M):
    x, y = map(int, input().split())
    uf.union(x - 1, y - 1)

ans = 0
for i, p in enumerate(P):
    if uf.find(i) == uf.find(p - 1):
        ans += 1

print(ans)


Measured memory_bytes: 12268
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n, 0);
    map<ll, ll> edge;
    for(int i = 0; i< n; i++){
        cin >> a[i];
        edge[a[i]]++;
    }
    sort(a.begin(), a.end());
    ll edge1= 0, edge2 = 0;
    ll ans = 0;
    for(int i = n-1; i >= 0; i--){
        if(edge[a[i]] >= 4 && edge1 == 0){
            ans = a[i]*a[i];
            cout << ans << endl;
            return 0;
        }else if(edge[a[i]] >= 2){
            if(edge1 == 0) {
                edge1 = a[i];
                edge[a[i]] = 0;
            }
            else{
                edge2 = a[i];
                ans = edge1 * edge2;
                cout << ans << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
    return 0;
}

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

int main(){
  int N;
  scanf("%d",&N);
  vector<int> A(N+1), B(N);
  for(int i = 0 ; i < N+1 ; i++){
    scanf("%d",&A[i]);
  }
  for(int i = 0 ; i < N ; i++){
    scanf("%d",&B[i]);
  }
  long long sum = 0;
  for (int i = 0; i < N; i++){
    sum += min(A[i]+A[i+1], B[i]);
    A[i+1] = max(0, A[i+1] - max(0, B[i]-A[i]));
  }
  printf("%lld\n", sum);
  return 0;
}


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

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

#define v(T) vector<T>
#define vv(T) v(v(T))

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;

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

const int mod = 1000000007;

char field[55] [55];
int d[55][55];
queue<P> que;

int  R, C;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int bfs() {
    while(!que.empty()) {
        auto p = que.front(); que.pop();
        int y = p.fi;
        int x = p.se;

        rep(i, 4) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (ny>=0 && ny<R && nx>=0 && nx<C && field[ny][nx]!='#' && d[ny][nx]==INF) {
                d[ny][nx] = d[y][x] + 1;
                if (ny==R-1 && nx==C-1) break;
                que.push(P(ny, nx));
            }
        }
    }
    if (d[R-1][C-1]==INF) return -1;
    else return d[R-1][C-1];
}

int main() {
    cin >> R >> C;
    int nw = 0;
    rep(y,R)rep(x,C) {
        cin >> field[y][x];
        if (field[y][x]=='.') ++nw;
    }
    rep(y,R)rep(x,C) d[y][x] = INF;
    d[0][0] = 0;
    que.push(P(0,0));
    int res = bfs();
    if (res == -1) cout << -1 << endl;
    else cout << (nw-res-1) << endl;
    return 0;
}

















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

using namespace std;

const int ALPHA = 26;

string s;

int last[ALPHA], ans[ALPHA];

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

    cin >> s;

    for (int let = 0; let < ALPHA; let++) {
        last[let] = -1;
        ans[let] = 0;
    }

    for (int i = 0; i < s.length(); i++) {
        ans[s[i] - 'a'] = max(ans[s[i] - 'a'], i - last[s[i] - 'a'] - 1);

        last[s[i] - 'a'] = i;
    }

    for (int let = 0; let < ALPHA; let++) {
        ans[let] = max(ans[let], (int)(s.length()) - last[let] - 1);
    }

    cout << *min_element(ans, ans + ALPHA, less<int>()) << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

c = 0
for i in range(1, N):
    if S[i] == 'E':
        c += 1
dp = [{'i': 0, 'c': c}]

for i in range(1, N):
    c = dp[i-1]['c']
    if S[i-1] == 'W':
        c += 1
    if S[i] == 'E':
        c -= 1
    dp.append({'i': i, 'c': c})
dp.sort(key=lambda x:x['c'])
print(dp[0]['c'])

Measured memory_bytes: 118808
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) begin(x), end(x)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

const ll mod=1e9+7;
int main(){
  int n;
  cin>>n;

  if(n==1){
    cout<<0<<endl;
    return 0;
  }
  ll a=1,b=1,c=1;
  rep(i,n) a=a*10%mod;
  rep(i,n) b=b*9%mod;
  rep(i,n) c=c*8%mod;

  ll ans=(a-2*b+c)%mod;
  while(ans<0){
    ans+=mod;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3604
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


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


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


# 個数制限付きナップザック問題
def main():
    H, N = MI()
    A = [0] * N
    B = [0] * N
    dp = [IINF] * (H+1)
    dp[0] = 0

    for i in range(N):
        A[i], B[i] = MI()

    for i in range(N):
        dp_next = [IINF] * (H+1)
        for j in range(H+1):
            dp_next[j] = min(dp_next[j], dp[j])
            if j + A[i] <= H:
                # print(j, dp_next[j + A[i]], dp[j + A[i]], dp[j] + B[i], dp_next[j] + B[i])
                dp_next[j + A[i]] = min(dp_next[j + A[i]], dp[j + A[i]], dp[j] + B[i], dp_next[j] + B[i])
            else:
                # print(j, dp_next[H], dp[H], dp[j] + B[i], dp_next[j] + B[i])
                dp_next[H] = min(dp_next[H], dp[H], dp[j] + B[i], dp_next[j] + B[i])
        dp = dp_next
        # print(dp_next)
    print(dp[H])



if __name__ == '__main__':
    main()


Measured memory_bytes: 46040
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n;
  cin>>n;
  int ans=0;
  int i;
  for(int k=0;k<n;k++) ans+=k;
  cout<<ans-(n/2)<<endl;
  if(n%2==0){
    for(i=n;i>=0;i--){
      for(int j=1;j<=n;j++){
	if(i>j && (i+j)!=n+1){
	  cout<<i<<" "<<j<<endl;
	}
      }
    }
  }else{
    for(i=n;i>=0;i--){
      for(int j=1;j<=n;j++){
	if(i>j && (i+j)!=n){
	  cout<<i<<" "<<j<<endl;
	}
      }
    }
  }
  return 0;
}




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

int main()
{
  int n, k;
  cin >> n >> k;
  int d, tmp;
  vector<int> a(n);
  rep(i, k){
    cin >> d;
	rep(j, d){
      cin >> tmp;
      a[tmp-1]++;
    }
  }
  int count = 0;
  rep(i, n) if(a[i] == 0) count++;
  cout << count << endl;
}

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

int64_t lcm(int64_t a, int64_t b) {
    if(a < b) swap(a,b);
    return a/__gcd(a,b) * b;
}
int main(void) {
    int64_t A,B,C,D;

    int64_t divc,divd;
    int64_t g,l,divlcd;

    cin >> A >> B >> C >> D;
    // 全体で割り切れる個数　: B-A + 1
    // Cで割り切れる個数とDで割り切れる個数を引いて
    // CかつDで割り切れる(lcm)個数を足す

    divc = (B/C) - ((A-1)/C);
    divd = (B/D) - ((A-1)/D);
    
    l = lcm(C,D);
    divlcd = (B/l) - ((A-1)/l);

//printf("all:%ld c:%ld d:%ld cd:%ld div:%ld\n", B-A+1,divc,divd,l,divlcd);
    cout << B-A+1 - divc - divd + divlcd << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int i=0;
	int j=0;
	int k=0;
	int sum=0;;
	int N;
	int r;
	int x,y,z;

	cin >> N;


	for(i=1;i<=N;i++){
		for(j=1;j<=N;j++){	
			for(k=1;k<=N;k++){
				x = i;
				y = j;
				z = k;
				r = x % y;
				while(r!=0){
					x = y;
					y = r;
					r = x % y;
				}
				r = y % z;
				while(r!=0){
					y = z;
					z = r;
					r = y%z;
				}
//				cout << x <<","<< y<< ","<<z<<"\n";
				sum += z;
			}
		}
	}
	cout << sum << "\n";
}



Measured memory_bytes: 3636
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let x: usize = scan(tokens);
    let n: usize = 2 * x;
    let mut prime = vec![true; n];
    let mut i = 2;
    loop {
        if prime[i] {
            if i >= x {
                println!("{}", i);
                return;
            }
            let mut j = i * i;
            while j < n {
                prime[j] = false;
                j += i;
            }
        }
        i += 1;
    }
}


Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] A = new int[3];
		A[0] = sc.nextInt();
		A[1] = sc.nextInt();
		A[2] = sc.nextInt();
		int max = 0;
		Arrays.sort(A);
		int c = A[2]*10 + A[1];
		System.out.println(c + A[0]);
	}
}

Measured memory_bytes: 35708
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <unordered_set>
typedef long long ll;
using namespace std;
const int mod=1e9+7;

int len(ll k){
    int cnt=0;
    for(ll i=k;i;i/=10) cnt++;
    return cnt;
}

ll solve(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int &i:a) cin>>i;
    int l=1,h=*max_element(a,a+n),m,ans=h;
    while(l<=h){
        m=(l+h)/2;
        int cuts=0;
        for(int i:a){
            if(m) cuts+=(i/m-(i%m==0));
            else cuts+=(2*i+1);
        }
        if(cuts <= k) ans=m,h=m-1;
        else l=m+1;
    }

    return ans;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while(t--) cout<<solve()<<'\n';
    //while(t--) solve(),cout<<'\n';
    return 0;
}


Measured memory_bytes: 4356
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N;
int A[18], B[18];
unsigned char dp[1 << 18][36];
int keisan(int b, bool n, int k) {
	if (dp[b][k] != 255) return dp[b][k];
	if (b == (1 << N) - 1) return 0;

	int saishou = 254;
	int num2 = 0;
	rep(i, N) {
		if (!(b >> i & 1)) {
			if ((n + i) & 1) {
				if (B[i] >= k) {
					chmin(saishou, keisan(b + (1 << i), !n, B[i]) + num2);
				}
			}
			else {
				if (A[i] >= k) {
					chmin(saishou, keisan(b + (1 << i), !n, A[i]) + num2);
				}
			}
			num2++;
		}
	}
	return dp[b][k] = saishou;
}

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


	cin >> N;
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];

	pair<int, int> kari[36];
	rep(i, N) kari[i] = mp(A[i], i);
	rep(i, N) kari[i + N] = mp(B[i], i + N);
	sort(kari, kari + N * 2);
	int k = 0;
	int mae = kari[0].first;
	rep(i, N * 2) {
		if (mae != kari[i].first) k++;
		mae = kari[i].first;
		if (kari[i].second < N) A[kari[i].second] = k;
		else B[kari[i].second - N] = k;
	}

	rep(i, 1 << N) rep(j, k + 1) dp[i][j] = 255;

	int kotae = keisan(0, 0, 0);
	if (kotae == 254) co(-1);
	else co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 9472
import java.util.*;

public class Main {
    private static Scanner scn = new Scanner(System.in);
    private static int WIDTH = 5;
    private static int VANISH = 3;

    public static void main(String[] args) {
        int height;
        while((height = scn.nextInt()) > 0) {
            Puzzle puzzle = new Main().new Puzzle(height);
            puzzle.proc();
            System.out.println(puzzle.showScore());
        }
    }

    class Puzzle {
        int score;
        int[][] numbers;

        Puzzle(int height) {
            score = 0;
            numbers = new int[height][WIDTH];

            for(int i = 0; i < height; i++) {
                for(int j = 0; j < WIDTH; j++) {
                    numbers[i][j] = scn.nextInt();
                }
            }
        }

        int showScore() {
            return score;
        }

        void proc() {
            int lines;
            while((lines = vanishPhase()) > 0) {
                dropPhase(lines);
            }
        }

        private int vanishPhase() {
            int lines = 0;
            for(int i = 0; i < numbers.length; i++) {
                for(int j = 0; j <= WIDTH - VANISH; j++) {
                    int base = numbers[i][j];
                    if(base > 0) {
                        int count = 1;
                        while(j + count < WIDTH && base == numbers[i][j + count]) {
                            count++;
                        }
                        if(count >= VANISH) {
                            score += base * count;
                            while(count-- > 0) {
                                numbers[i][j + count] = 0;
                            }
                            lines++;
                            break;
                        }
                    }
                }
            }
            return lines;
        }

        private void dropPhase(int lines) {
            while(lines-- > 0) {
                for(int i = ~-numbers.length; i > 0; i--) {
                    for(int j = 0; j < WIDTH; j++) {
                        if(numbers[i][j] == 0) {
                            numbers[i][j]   ^= numbers[~-i][j];
                            numbers[~-i][j] ^= numbers[i][j];
                            numbers[i][j]   ^= numbers[~-i][j];
                        }
                    }
                }
            }
        }
    }
}

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

int main(){
    vector<string> day = {"SUN","MON","TUE","WED","THU","FRI","SAT" };
    string S;
    cin >> S;
    for(int i=0;i<day.size();i++){
        if(day.at(i) == S){
            cout << 7-i << endl;
        }
    }

    return(0);
}

Measured memory_bytes: 256
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<queue>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;

int n, m;
using P = pair<int, int>;
vector<P> works;
struct comp_delay {
    bool operator()(const P &a, const P &b) {
        return a.second >= b.second;
    }
};

struct comp_praise {
    bool operator()(const P &a, const P &b) {
        return a.first <= b.first;
    }
};

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

    cin >> n >> m;
    priority_queue<P, vector<P>, comp_delay> works;
    REP(i, n) {
        int ai, bi;
        cin >> ai >> bi;
        works.emplace(bi, ai);
        // DD(bi, ai);
    }
    // return 0;
    priority_queue<P, vector<P>, comp_praise> avails;
    int ans = 0;
    REP(i, m + 1) {
        int min_delay = i;
        // D(i);
        while(!works.empty() && min_delay >= works.top().second) {
            // D(works.top());
            avails.push(works.top());
            works.pop();
        }
        if (avails.empty()) continue;
        // DD("use", avails.top());
        ans += avails.top().first;
        avails.pop();
    }

    cout << ans << endl;
}


Measured memory_bytes: 2548
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)1e3+5;
const int Q = 102;
const int logN = 19;

const double pie = acos(-1);

void solve() {
    ll a;
    string b;
    cin>>a>>b;
    ll sum = 0;
    for(auto it:b) {
        if(it!='.')
            sum = sum*10 + (it-'0');
    }
    a *= sum;
    cout<<a/100;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = 1LL<<60;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    vector<int> a(n);
    rep(i,0,k){
        int d; cin >> d;
        rep(i,0,d){
            int b; cin >> b;
            b--;
            a[b]++;
        }
    }
    int ans = 0;
    rep(i,0,n){
        if(a[i]==0) ans++;
    }
    cout << ans << endl;
} 

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

int main() {
  char a,s;
  cin>>a>>s;
  if(a>s){
  cout <<'>'<< endl;
  }
  else if(a==s){
    cout<<'='<<endl;
  }
  else{
    cout<<'<'<<endl;
  }
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int e;
    while(cin>>e&&e!=0){
        int minSum=100000000;
        for(int z = 0; z <= 100; z++){
            if(e-(z*z*z)<0)
                break;
            for(int y = 0; y <= 1000; y++){
                if(e-y*y-z*z*z<0)
                    break;
                int x=e-y*y-z*z*z;
                minSum=min(minSum,x+y+z);
            }
        }
        cout<<minSum<<endl;
    }
    return 0;
}

Measured memory_bytes: 868
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,A,B;
  cin >> N >> A >> B;
  vi a(N),b(N),c(N);
  rep(i,N) {
    cin >> a[i] >> b[i] >> c[i];
  }
  vvi dp(410,vi(410,INF));
  dp[0][0]=0;
  rep(i,N) {
    drep(j,410) {
      drep(k,410) {
        if(j-a[i]<0) continue;
        if(k-b[i]<0) continue;
        chmin(dp[j][k],dp[j-a[i]][k-b[i]]+c[i]);
      }
    }
  }
  int ans = INF;
  srep(j,1,410) {
    srep(k,1,410) {
      if(j*B==k*A) {
        chmin(ans,dp[j][k]);
      }
    }
  }
  if(ans==INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

#ifdef Lin1043
    #define DEBUG(msg, ...) printf("(%s #%d) " msg, __FUNCTION__, __LINE__, __VA_ARGS__)
    #define massert(...) assert(...)
#else
    #define DEBUG(...)
    #define massert(...)
#endif

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

struct iopener
{
    iopener()
    {
#ifdef Lin1043
        freopen("./in" , "r" , stdin);
#endif
    }
} iop;

typedef long long LL;

template<typename T>inline bool chkmin(T &x , const T &y) { return x > y ? (x = y , 1) : 0; }
template<typename T>inline bool chkmax(T &x , const T &y) { return x < y ? (x = y , 1) : 0; }

template<typename T>inline T read(T &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c)) x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}

const int N = 100000 + 5;

int n , A[N];

#ifdef Lin1043
namespace TEST
{
    const int M = 200 + 5;

    int f[M][M] , g[M][M];

    int solve(int x , int y)
    {
        if(g[x][y])
            return 0;
        if(f[x][y] != -1)
            return f[x][y];
        int now = 0;
        if(solve(x + 1 , y) == 0)
            now = 1;
        if(solve(x , y + 1) == 0)
            now = 1;
        return f[x][y] = now;
    }
}
#endif 

int comp(int x , int y)
{
    return x > y;
}

int main()
{
    read(n);
    rep(i , 1 , n) read(A[i]);
    sort(A + 1 , A + 1 + n , comp);
#ifdef Lin1043
    rep(i , 1 , n)
        TEST::g[i][A[i]] = 1;
    memset(TEST::f , -1 , sizeof TEST::f);
    TEST::solve(1 , 0);
    cout << TEST::f[1][0] << endl;
#endif
    rep(i , 1 , n) if(i + 1 > A[i + 1])
    {
        int Ans = 0;
        rep(j , i + 1 , n)
        {
            if(A[j] != i) break;
            Ans ^= 1;
        }
        Ans |= (A[i] - i) % 2;
        if(Ans)
            puts("First");
        else
            puts("Second");
        break ;
    }
    return 0;
}



Measured memory_bytes: 768
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,m = map(int,ipt().split())
    mod = 10**9+7
    kj = [1,1]
    for i in range(2,max(m,n)+1):
        kj.append(kj[-1]*i%mod)
    if abs(n-m) >= 2:
        print(0)
    elif abs(n-m) == 1:
        print(kj[n]*kj[m]%mod)
    else:
        print((2*kj[n]**2)%mod)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 74756
#pragma GCC optimize("O3")
//#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#define re return
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define PI 3.14159265358979323846
#define E 2.71828182845904523536
#define er erase
#define in insert
#define fo(i,n) for((i)=0;(i)<(n);(i)++)
#define ro(i,n) for((i)=n-1;(i)>=0;(i)--)
#define fr(i,j,n) for((i)=(j);(i)<(n);(i)++)
#define rf(i,j,n) for((i)=((n)-1);(i)>=(j);(i)--)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
    const int N=(int)1e5+100;
    const int M=(int)2e6+100;
    const int inf=(int)1e9+100;
#define filename ""
    int ans[10][10];
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen(filename".in","r",stdin);
    //freopen(filename".out","w",stdout);
    //freopen("ans.txt","w",stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    srand(time(0));
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n,i;
    cin>>n;
    fr(i,1,n+1)
    {
        int a=i;
        while(a/10) a/=10;
        int b=i%10;
        ans[a][b]++;
    }
    int j;
    ll o=0;
    fo(i,10)
    {
        fo(j,10)
        {
            o+=(ll)ans[i][j]*ans[j][i];
        }
    }
    cout<<o;
}


Measured memory_bytes: 256