akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N; cin >> N;
	int ans = 0;
	int A=0,B=0,BA=0;
	rep(i,N){
		string s; cin >> s;
		int K = s.size();
		rep(j,K-1) if(s.substr(j,2) == "AB") ans++;
		if(s.back() == 'A') A++;
		if(s[0] == 'B') B++;
		if(s.back() == 'A' && s[0] == 'B') BA++;
	}
	if(A == BA && B == BA) ans += max(BA-1,0);
	else ans += min(A,B);
	cout << ans << endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }

  bool a;
  for(int i=0;i<N;i++){
    if(A.at(i)%2!=0){
      continue;
    }
    else{
      if(A.at(i)%3==0 || A.at(i)%5==0){
        a=true;
      }
      else{
        a=false;
        break;
      }
    }
  }
  if(a){
    cout << "APPROVED" << endl;
  }
  else{
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1e9+7;

int main(){
    vector<int> p;
    for(int i=11;i<55555;i+=10){
        bool f=true;
        for(int j=2;j<sqrt(i)+1;j++){
            if(i%j==0){
                f=false;
                break;
            }
        }
        if(f) p.push_back(i);
    }
    int N; cin>>N;
    for(int i=0;i<N-1;i++){
        cout<<p[i]<<" ";
    }
    cout<<p[N-1]<<endl;
    return 0;
}

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

class ORDER {
public:
	void INFO() {
		int c[3][3];
		int sum = 0;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				cin >> c[i][j];
				sum += c[i][j];
			}
		}
		sum /= 3;
		int b1, b2, b3;
		bool result = false;
		while (1) {
			for (int a1 = 0; a1 <= sum; a1++) {
				b1 = c[0][0] - a1;
				for (int a2 = 0; a2 <= sum; a2++) {
					b2 = c[1][1] - a2;
					for (int a3 = 0; a3 <= sum; a3++) {
						b3 = c[2][2] - a3;
						if (a1 + a2 + a3 + b1 + b2 + b3 == sum) {
							if (c[0][1] == a1 + b2&&c[0][2] == a1 + b3
								&&c[1][0] == a2 + b1&&c[1][2] == a2 + b3
								&&c[2][0] == a3 + b1&&c[2][1] == a3 + b2) {
								cout << "Yes" << endl;
								result = true;
								break;
							}
						}
					}
					if (result == true) {
						break;
					}
				}
				if (result == true) {
					break;
				}
			}
			if (!(result == true)) {
				cout << "No" << endl;
			}
			break;
		}
	}
};

int main() {
	ORDER x;
	x.INFO();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <complex>
#include <cmath>
#include <cstdio>
using namespace std;
#define RESIDUE(s,t) (capacity[s][t]-flow[s][t])

#define INF (1ll<<60)

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;



Weight minimumCut(const Graph &g) {
  int n = g.size();
  vector< vector<Weight> > h(n, vector<Weight>(n)); // make adj. matrix
  REP(u,n) FOR(e,g[u]) h[e->src][e->dst] += e->weight;
  vector<int> V(n); REP(u, n) V[u] = u;

  Weight cut = INF;
  for(int m = n; m > 1; m--) {
    vector<Weight> ws(m, 0);
    int u, v;
    Weight w;
    REP(k, m) {
      u = v; v = max_element(ws.begin(), ws.end())-ws.begin();
      w = ws[v]; ws[v] = -1;
      REP(i, m) if (ws[i] >= 0) ws[i] += h[V[v]][V[i]];
    }
    REP(i, m) {
      h[V[i]][V[u]] += h[V[i]][V[v]];
      h[V[u]][V[i]] += h[V[v]][V[i]];
    }
    V.erase(V.begin()+v);
    cut = min(cut, w);
  }
  return cut;
}


int main(){
	int n,m;
	while(cin >> n >> m && n){
		Graph g(n);
		long long ans = 0;
		for(int i = 0 ; i < m ; i++){
			int a,b,c;
			cin >> a >> b >> c;
			if( c <= 0 ) ans += c;
			else g[a].push_back(Edge(a,b,c)),g[b].push_back(Edge(b,a,c));
		}

		cout << ans+minimumCut(g) << endl;
	}
	
}

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

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

using namespace std;
using lint=long long;

lint modinv(lint a,lint m){
	lint b=m,u=1,v=0;
	while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
	return (u+m)%m;
}

lint modpow(lint a,lint k,int m){
	lint r=1;
	for(lint x=a%m;k>0;k>>=1,x=x*x%m) if(k&1) r=r*x%m;
	return r;
}

constexpr int MOD=1000003;

int main(){
	vector<lint> fact(MOD);
	fact[0]=1;
	rep(i,MOD-1) fact[i+1]=fact[i]*(i+1)%MOD;

	int q; scanf("%d",&q);
	rep(_,q){
		lint x,d,n; scanf("%lld%lld%lld",&x,&d,&n);

		lint ans;
		if(x==0){
			ans=0;
		}
		else if(d==0){
			ans=modpow(x,n,MOD);
		}
		else{
			lint p=modinv(d,MOD)*x%MOD;
			if(p+n-1>=MOD){
				ans=0;
			}
			else{
				ans=fact[p+n-1]*modinv(fact[p-1],MOD)%MOD;
				ans=ans*modpow(d,n,MOD)%MOD;
			}
		}
		printf("%lld\n",ans);
	}

	return 0;
}


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

typedef long long ll;
#define pb push_back

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    ll sum=0;
    for(int i=0;i<s.size();i++) sum+=(s[i]-'0');
    if(sum%9==0) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#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 REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000003  
//1000000007
#define P pair<ll, ll>


ll n, m, cnt, s[110000], ans;
bool used[110000];
vector<ll> list, g[110000], now;

void dfs(ll a) {
	used[a] = true;
	now.push_back(s[a]);
	REP(i, g[a].size()) {
		if (!used[g[a][i]])dfs(g[a][i]);
	}
}
int main() {
	cin >> n >> m;
	REP(i, n) cin >> s[i];
	REP(i, m) {
		ll a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	REP(i, n) {
		now.resize(0);
		if (!used[i]) {
			cnt++;
			dfs(i);
			sort(ALL(now));
			ans += now[0];
			FOR(j, 1, now.size()) {
				list.push_back(now[j]);
			}
		}
	}
	if (cnt == 1) {
		cout << 0 << endl;
		return 0;
	}
	if (list.size() < cnt - 2) {
		cout << "Impossible" << endl;
		return 0;
	}
	sort(ALL(list));
	REP(i, cnt - 2) {
		ans += list[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 9716
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,D;
  cin >> N >> D;
 
  vector<vector<long long>> k(N,vector<long long>(2));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 2; j++){
     cin >> k.at(i).at(j);
}
}
  
  int a = 0;
  
  for(int i = 0; i < N; i++){
    if(k.at(i).at(0)*k.at(i).at(0) + k.at(i).at(1)*k.at(i).at(1) <= D*D)
    {a++;}
  }
  
  cout << a << endl;
}
       

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

int main() {
  string s;
  cin >> s;
  string ret = "";

  rep(i, s.size()) {
    char c = s[i];
    if (c == '0' || c == '1')
      ret.push_back(c);
    else {
      if (ret == "") continue;
      ret.pop_back();
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, K: int):
    return N - (K - 1)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    result = solve(N, K)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5884
# = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = list(input())
# = [tuple(map(int, input().split())) for _ in range(n)]

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

m = float('inf')
ans = 0
for x in p:
    if x < m:
        ans += 1
        m = x

print(ans)

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

int calc(int a,int b){
	int A=(a>b)?a:b;
	int B=(a>b)?b:a;
	int r=1;

	while(r!=0){
		r=(A%B);
		A=B;
		B=r;
	}

	return A;
}

int main(){
    int a,b;

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

	int ans=calc(a,b);

	printf("%d\n",ans);


	return 0;
}


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

constexpr int MaxN = 100;

int main()
{
	int sx, sy, tx, ty;

	cin >> sx >> sy >> tx >> ty;

	int dx = tx - sx;
	int dy = ty - sy;

	for (int i = 0; i < dx; ++i)
	{
		cout << 'R';
	}

	for (int i = 0; i < dy; ++i)
	{
		cout << 'U';
	}

	for (int i = 0; i < dx; ++i)
	{
		cout << 'L';
	}

	for (int i = 0; i < dy; ++i)
	{
		cout << 'D';
	}

	cout << 'D';

	for (int i = 0; i < dx + 1; ++i)
	{
		cout << 'R';
	}

	for (int i = 0; i < dy + 1; ++i)
	{
		cout << 'U';
	}

	cout << 'L';
	cout << 'U';

	for (int i = 0; i < dx + 1; ++i)
	{
		cout << 'L';
	}

	for (int i = 0; i < dy + 1; ++i)
	{
		cout << 'D';
	}

	cout << 'R' << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       	int n = sc.nextInt();
        System.out.println(n>999 ?"ABD":"ABC");
    }
}

Measured memory_bytes: 21844
import numpy as np
from time import time
start = time()
def scoring(c,s,t):
    score = 0
    from_last = np.zeros(26)
    for i in range(s.shape[0]):
        from_last = from_last+1
        score += s[i,t[i]-1]
        from_last[t[i]-1] = 0
        score = score - (c*from_last).sum()
    return score


D = int(input())
c = list(map(int,input().split()))
s = np.empty((D,26))
for i in range(D):
    s[i,:] = np.array(list(map(int,input().split())))


t = []
for i in range(D):
    chosen = s[i,:].flatten().argmax()+ 1
    t.append(chosen)


score = scoring(c,s,t)
while time()-start < 1.85:
    i = np.random.randint(D)
    old = t[i]
    t[i] = np.random.randint(1,27)
    new_score = scoring(c,s,t)
    if new_score > score:
        score = new_score
    else:
        t[i] = old

for i in t:
	print(i)


Measured memory_bytes: 27292
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
/*const int maxn=105;
int sg[maxn];
int getsg(int x)
{
    if(sg[x]!=-1) return sg[x];
    if(x==0) return 0;
    if(x==1) return 1;
    set<int> all;
    all.insert(0);
    for(int i=1;i<=x-1;i++)
    {
        int cur=0;
        for(int j=x-i;j<=x-1;j++) cur^=getsg(j);
        all.insert(cur);
    }
    for(int i=0;;i++)
    {
        if(!all.count(i))
            return sg[x]=i;
    }
}*/
const int maxn=4e5+7;
int sz[maxn<<2];
int nxt[maxn<<2][2];
int tot=1;
int cnt[105];
void Insert(string s)
{
    int rt=1;
    for(int i=0;i<s.length();i++)
    {
        sz[rt]++;
        if(!nxt[rt][s[i]=='1'])
            nxt[rt][s[i]=='1']=++tot;
        rt=nxt[rt][s[i]=='1'];
    }
    sz[rt]++;
}
ll L;
void dfs(int u,int dep=0)
{
    //dbg(u,dep);
    if(u==0)
    {
        if(dep>L) return ;
        ll val=L-dep+1;
        //dbg(dep);
        int cc=0;
        while(val%2==0&&val)
        {
            val/=2;
            cc++;
        }
        cnt[cc]++;
        return;
    }
    dfs(nxt[u][0],dep+1);
    dfs(nxt[u][1],dep+1);
}
int main()
{
    int n;
    cin>>n>>L;
    /*memset(sg,-1,sizeof(sg));
    for(int i=0;i<maxn;i++)
    {
        dbg(i,getsg(i));
    }*/
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        Insert(s);
    }
    dfs(1);
    bool ok=0;
    for(int i=0;i<100;i++)
    {
        //dbg(i,cnt[i]);
        if(cnt[i]&1) ok=1;
    }
    if(ok) cout<<"Alice\n";
    else cout<<"Bob\n";
}

Measured memory_bytes: 4764
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= c && c <= b) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

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

bool f(int n)
{
  return 1 <= n && n <= 12;
}

int main()
{
  int n;
  cin >> n;
  string ans[] {"NA", "YYMM", "MMYY", "AMBIGUOUS"};
  cout << ans[(f(n / 100) ? 2 : 0) + (f(n % 100) ? 1 : 0)] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;

int N, T, t;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N >> T;
  int prev;
  ll ans = 0;
  cin >> t;
  FOR(i, 1, N){
    prev = t;
    cin >> t;
    ans += min(t - prev, T);
  }
  ans += T;
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int Z = sc.nextInt();
        int W = sc.nextInt();
        int[] A = new int[N];

        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
        }

        if(N==1){
            System.out.println(Math.abs(A[0] - W));
        }
        else{
            System.out.println(Math.max(Math.abs(W - A[N - 1]), Math.abs(A[N - 2] - A[N - 1])));
        }
    }
}

Measured memory_bytes: 27500
import collections

n = int(input())

al = [int(l) for l in input().split()]

a = []
b = []
for i, x in enumerate(al):
    if i%2 == 0:
        a.append(x)
    else:
        b.append(x)

ac = collections.Counter(a).most_common()
bc = collections.Counter(b).most_common()

if ac[0][0] != bc[0][0]:
    print(n-ac[0][1]-bc[0][1])
else:
    if len(ac) == 1 and len(bc) == 1:
        print(n-max(ac[0][1], bc[0][1]))
    elif len(ac) == 1:
        print(n-max(ac[0][1], ac[1][1]+bc[0][1]))
    elif len(ac) == 1:
        print(n-max(bc[0][1], ac[0][1]+bc[1][1]))
    else:
        print(n-max(ac[1][1]+bc[0][1], ac[0][1]+bc[1][1]))
    


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

int main() {
	int A, B;
	cin >> A >> B;
	bool ans = true;

	for (int i = 0; i < A + B + 1; i++) {
		char x;
		cin >> x;
		if (i == A) {
			if (x != '-') {
				ans = false;
				break;
			}
		}
		else {
			if (x == '-') {
				ans = false;
				break;
			}
		}
	}
	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 998244353;

int main() {
    ll K; cin >> K;
    string S = "";
    rep(i, K){
        S += "ACL";
    }

    cout << S << endl;
}

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

using namespace std;

#define MAXN 100010
#define INF 0x3f3f3f3f
typedef long long LL;

int n, sz[MAXN], az = INF, au, av;
LL ans;
vector<pair<int, int> > adj[MAXN];

void Init()
{
    int i, u, v, w;
    scanf("%d", &n);
    for(i = 1; i < n; ++i){
        scanf("%d %d %d", &u, &v, &w);
        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }
}

void DFS(int u, int fa)
{
    sz[u] = 1; int m = 0;
    for(auto &v: adj[u]){
        if(v.first == fa) continue;
        DFS(v.first, u);
        ans += min(sz[v.first], n - sz[v.first]) * 2LL * v.second;
        sz[u] += sz[v.first];
        m = max(m, sz[v.first]);
    }
    m = max(m, n - sz[u]);
    if(m < az) az = m, au = u, av = 0;
    else if(m == az) av = u;
}

int main()
{
    Init();
    DFS(1, 0);
    if(au && av){
        for(auto &v: adj[au]){
            if(v.first == av)
                ans -= v.second;
        }
    }
    else{
        int ww = INF;
        for(auto &v: adj[au]){
            ww = min(ww, v.second);
        }
        ans -= ww;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11520
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    ll r = 0;
    
    ll one = min (min(q*4, h*2), s);
    r = min(one*n, d*(n/2) + one*(n%2));
    mes(r);
    
    


}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    int k;
    cin>>k;
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<a[k-1]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

ll modpow(ll a, ll n, ll mod){
    ll ret=1;
    while(n>0){
        if(n&1) ret=ret*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ret;
}

int main(){
    ll k;
    cin>>k;
    ll mod=0;
    ll ans=-1;
    if(k%2==0 || k%5==0){
        cout<<-1<<endl;
        return 0;
    }
    for(ll i=1;i<=k;i++){
        mod+=modpow(10,i,k)*7;
        mod%=k;
        if(mod==0){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

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

	if (a + b > c + d)
	{
		cout << "Left";
		return 0;
	}
	else if (a + b == c + d)
	{
		cout << "Balanced";
		return 0;
	}
	else
	{
		cout << "Right";
		return 0;
	}
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static int[][] mtx ;
        static List<int>[] tm;
        static int n;
        static int[] results;
        static List<string> cons = new List<string>();
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s1 = Console.ReadLine().Split(' ');

            int[] n1 = new int[n-1];

            for (int i = 0; i < n - 1; i++)
            {
                n1[i] = int.Parse(s1[i]);
            }

            if (n == 2)
            {
                Console.WriteLine(n1[0]*2);
                return;
            }

            if (n==3)
            {
                var sum = n1[0] + n1[1] + Math.Min(n1[0], n1[1]);
                Console.WriteLine(sum);
                return;
            }


            var score = 0;
            score += n1[0];
            score += n1[n - 2];

            for (int i = 0; i < n-2; i++)
            {
                var min = Math.Min(n1[i], n1[i + 1]);
                score += min;
            }

            Console.WriteLine(score);
        }

 

    }

}

Measured memory_bytes: 13140
#include <stdio.h>

int A[100000], n;

int binarySearch(int key) {
    int left = 0, right = n;
    int mid;
    while (left < right) {
        mid = (left + right ) / 2;
        if ( A[mid] == key ) {
            return mid;
        } else if ( key < A[mid] ) {
            right = mid;
        } else {
            left = mid + 1;
        }
        
    }
    return 0;
}

int main (void) {
    int i , j , q , k , sum = 0;

    scanf("%d", &n );
    for (i = 0 ; i <  n ; i++ ) {
        scanf("%d", &A[i] );
    }

    scanf("%d", &q );
    for (j = 0; j < q ; j ++ ) {
        scanf("%d", &k );
        if ( binarySearch( k )) sum++;
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 980
from collections import deque
n , k = map(int,input().split())
d = set(list(map(int,input().split())))
kouho =list({0,1,2,3,4,5,6,7,8,9} - d)
kouho.sort()

p = deque()
p.append(0)

while p:
    now = p.popleft()
    if now >= n:
        print(now)
        exit()
    for i in kouho:
        p.append(now*10+i)

Measured memory_bytes: 5620
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	a := make([]int, n*m)
	b := make([]int, m)
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			fmt.Scan(&a[i*m+j])
		}
	}
	for i := 0; i < m; i++ {
		fmt.Scan(&b[i])
	}
	for i := 0; i < n; i++ {
		c := 0
		for j := 0; j < m; j++ {
			c += a[i*m+j] * b[j]
		}
		fmt.Println(c)
	}
}



Measured memory_bytes: 1808
n = gets.strip.to_i
array = gets.split(' ').map(&:to_i)
swap_count = 0

0.upto(array.size-1) do |i1|
  i_min = i1
  (i1+1).upto(array.size-1) do |i2|
    if (array[i2] < array[i_min]) then
      i_min = i2
    end
  end

  if (i_min != i1) then
    array[i_min], array[i1] = array[i1], array[i_min]
    swap_count += 1
  end
end

puts array.join(' ')
p swap_count

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

ll H, W, N;
set<pair<int, int>> B, cand;

void add(int y, int x) {
   if (y >= 0 && y < H-2 && x >= 0 && x < W-2) {
      cand.insert({y, x});
   }
}

int main() {
   cin >> H >> W >> N;
   rep (i, N) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      B.insert({a, b});
      rep (y, 3) {
         rep (x, 3) {
            add(a-y, b-x);
         }
      }
   }

   vec<ll> ans(10);
   ans[0] = 1LL*(H-2)*(W-2);
   for (auto c : cand) {
      int y = c.first, x = c.second;
      int cnt = 0;
      rep (i, 3) {
         rep (j, 3) {
            if (B.find({y+i, x+j}) != B.end()) {
               cnt++;
            }
         }
      }
      ans[cnt]++;
      ans[0]--;
   }

   for (ll x : ans) {
      cout << x << endl;
   }

   return 0;
}

Measured memory_bytes: 47104
#include <iostream>
using namespace std;
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int x;
    int i = 1;

    while (true) {
        cin >> x;

        if (x == 0) break;

        cout << "Case " << i << ": " << x << "\n";
        ++i;
    }
}

Measured memory_bytes: 2976
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		long val[][] = new long[R][C];
		for(int k = 0 ; k < K; ++k){
			int r = sc.nextInt() - 1;
			int c = sc.nextInt() - 1;
			long v = sc.nextLong();
			val[r][c] = v;			
		}
		long prev[] = new long[C];
		for(int i = 0 ; i < R ; ++i){
			long dp[][] = new long[C][4];
			for(int j = 0 ; j < C ; ++j){				
				dp[j][0] = prev[j];
				dp[j][1] = prev[j] + val[i][j];
				if(j > 0){
					dp[j][0] = Math.max(dp[j][0], dp[j - 1][0]);
					dp[j][1] = Math.max(dp[j - 1][0] + val[i][j] , dp[j][1]);
					dp[j][1] = Math.max(dp[j - 1][1], dp[j][1]);
					dp[j][2] = Math.max(dp[j - 1][2], dp[j - 1][1] + val[i][j]);
					dp[j][3] = Math.max(dp[j - 1][3], dp[j - 1][2] + val[i][j]);
				}
				prev[j] = Math.max(Math.max(dp[j][0], dp[j][1]) , Math.max(dp[j][2], dp[j][3]));
			}
		}
		System.out.println(prev[C - 1]);
	}
}


Measured memory_bytes: 146176
//
//  main.cpp
//  CoderW
//
//  Created by Minoru Hayashi on 2020/02/22.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//


#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;


void solve(void){
  
  int N, M;
  
  cin >> N >> M;
  
  long long x[N], y[N], z[N];
  
  long long P[N];
  
  int fx, fy, fz;
  
  for (int i=0; i<N; i++){
    cin >> x[i] >> y[i] >> z[i];
  }
  
  long long maxP = 0;
  
  for (int b=0; b<8; b++){
    // b2 b1 b0 : fz fy fx :: 0 means -  1 means +
    fx = (b & 0b001) ? 1:-1;
    fy = (b & 0b010) ? 1:-1;
    fz = (b & 0b100) ? 1:-1;
    
    for (int j=0; j<N; j++){
      P[j]= fx * x[j] + fy * y[j] + fz * z[j];
    }
/*
    for (int i=0; i<N; i++){
      cout << i << '/' << P[i] << endl;
    }
*/
    sort(P, P+N, greater<>());
/*
    for (int i=0; i<N; i++){
      cout << i << ':' << P[i] << endl;
    }
 */
    long long tmp = 0;
    
    for (int i=0; i<M; i++){
      tmp += P[i];
    }
    maxP = max(maxP, tmp);
    
//    cout << "maxP[" << b << "]=" << maxP << endl;
  }
  
  cout << maxP << endl;
  
  return;
}



int main(int argc, const char * argv[]) {


    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
  
  
  solve();
  
  return 0;
}


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

void trase(int* A, int n) {
	for (int i = 0; i < n; ++i) {
		if (i > 0) { cout << ' '; }
		cout << A[i];
	}
	cout << endl;
}

void insertion(int* A, int n) {
	int v, j;
	for (int i = 1; i < n; ++i) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trase(A, n);
		}

}

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

	int* A = new int[n];
	for (int i = 0; i < n ; ++i) {
		cin >> A[i];

	}

	trase(A, n);
	insertion(A, n);

}


Measured memory_bytes: 3108
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N;
	std::cin >> N;
	ll s = 0;
	ll e = N - 1;
	string s1,s2;
	std::cout << 0 << endl;
	std::cin >> s1;
	if (s1 == "Vacant") {
		return 0;
	}
	ll idx = 0;
	while (true) {
		ll idx = (e - s+1) / 2+s;
		std::cout << idx << endl;
		std::cin >> s2;
		if (s2 == "Vacant") {
			return 0;
		}
		else if (((idx-s)&1&&s1!=s2)||(!((idx-s)&1)&& s1 == s2)) {
			s = idx;
			s1 = s2;
		}
		else {
			e = idx;
		}
	}

	return 0;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if(a*b > c*d) printf("%d\n", a*b);
	else printf("%d\n", c*d);
	
	return 0;
}


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

#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int n, m, si;
	char ci;
	string ans;
	cin >> n >> m;
	ans.assign(n+1, 'a');
	ans[n] = '\0';
	int flag = 0;
	//casos que devo cobrir:
	//[X] colocar o mesmo dígito na mesma posição duas vezes
	//[X] colocar dois dígitos diferentes na mesma posição
	//[X] não preencher o primeiro dígito com n > 1
	//[X] não preencher o primeiro dígito com n == 1
	//[X] preencher o primeiro dígito com 0 com n > 1
	while(m--) {
		cin >> si >> ci;
		si--;
		if ((si == 0) && (ci == '0') && (n != 1) || (ans[si] != ci) && (ans[si] != 'a'))
			flag = 1;
		ans[si] = ci;
	}
	if (!flag)
		if ((n == 1) && (ans[0] == 'a')) ans = "0";
		else {
			if (ans[0] == 'a') ans[0] = '1';
			for (int i = 1; i < n; i++) {
				if (ans[i] == 'a') ans[i] = '0';
			}
		}
	else
		ans = "-1";
	cout << stoi(ans) << ende;
  return 0;
}


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

using namespace std;

using int64 = long long;

int main() {
  int N, Q;
  cin >> N >> Q;
  int latte[100000] = {}, malta[100000] = {};
  latte[0] = true;
  malta[0] = malta[1] = true;

  for(int i = 0; i < Q; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    swap(latte[x], latte[y]);
    swap(malta[x], malta[y]);

    if(x && latte[x - 1]) {
      malta[x] = true;
    }
    if(x + 1 < N && latte[x + 1]) {
      malta[x] = true;
    }

    if(latte[x]) {
      if(x) malta[x - 1] = true;
      if(x + 1 < N) malta[x + 1] = true;
    }

    if(latte[y]) {
      if(y) malta[y - 1] = true;
      if(y + 1 < N) malta[y + 1] = true;
    }


    if(y && latte[y - 1]) {
      malta[y] = true;
    }
    if(y + 1 < N && latte[y + 1]) {
      malta[y] = true;
    }

  }

  cout << count(malta, malta + N, true) << endl;
}

Measured memory_bytes: 1024
using System;
using System.Text.RegularExpressions;
using System.Linq;

namespace D_FPU
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] tmpLine = Console.ReadLine()
                                    .Split(' ')
                                    .Select(s => int.Parse(s))
                                    .ToArray();
            
            int N = tmpLine[0];
            int K = tmpLine[1];
            string S = Console.ReadLine();
            int groupsL = Regex.Matches(S, @"L+").Count;
            int groupsR = Regex.Matches(S, @"R+").Count;
            int groups = groupsL + groupsR - K * 2;
            if (groups <= 0)
            {
                groups = 1;
            }
            Console.WriteLine(N - groups);
        }
    }
}


Measured memory_bytes: 45396
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
typedef long long LL;
LL a[100005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    LL ans=0;
    if(n%2==1)
    {
        int num=(n-1)/2;
        for(int i=n;i>=n-(n-1)/2+1;i--)
        {
            ans+=a[i]*2;
        }
        for(int i=1;i<=(n-1)/2-1;i++)
        {
            ans-=a[i]*2;
        }
        for(int i=(n-1)/2;i<=n-(n-1)/2;i++)
        {
            ans-=a[i];
        }
        LL sum=0;
        for(int i=1;i<=n/2;i++)
        {
            sum-=a[i]*2;
        }
        sum+=a[n/2+1]+a[n/2+2];
        for(int i=n/2+3;i<=n;i++)
        {
            sum+=a[i]*2;
        }
        if(sum>ans)
        {
            ans=sum;
        }
    }
    else
    {     
         for(int i=n;i>=n-(n-2)/2+1;i--)
         {
             ans+=a[i]*2;
         }
         ans+=a[n-(n-2)/2];
         ans-=a[n-(n-2)/2-1];
         for(int i=1;i<=(n-2)/2;i++)
         {
             ans-=a[i]*2;
         }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
	static int dp[];
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		int n=fs.nextInt();
		int arr[]=fs.readArray(n);
		dp=new int[n];
		dp[0]=0;
		int s=0;
		dp[1]=Math.abs(arr[1]-arr[0]);
		for(int i=2;i<n;i++)
		{
		  dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
//		   s=s+dp[i];
		}
		System.out.println(dp[n-1]);
	}
}
class FastScanner 
{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public double nextDouble()
		{
			return Double.parseDouble(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}

Measured memory_bytes: 43004
N,Y = map(int,input().split())
na,nb,nc = -1,-1,-1
a,b,c = 10000,5000,1000

for i in range(N+1):
  for j in range(N-i+1):
    if a*i+b*j+c*(N-i-j) == Y:
      na,nb,nc = i,j,N-i-j
      break
print(na,nb,nc)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
ll N,W,w[100],v[100],A[100000];
int main(){
    cin>>N>>W;
    for(int i=0 ; i<N ; i++){
        cin>>w[i]>>v[i];
        for(int j=W-w[i] ; j>=0 ; j--){
            if(A[j]){
                A[j+w[i]] = max(A[j+w[i]],A[j]+v[i]);
            }
        }
        A[w[i]] = max(A[w[i]],v[i]);
    }
    ll ans = 0;
    for(int i=0 ; i<=W ; i++){
        ans = max(A[i],ans);
    }
    cout<<ans;
}

Measured memory_bytes: 1024
/*
   Username : moondancer
   Name : Moon Dancer
*/


#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,x,t;
    cin>> n>>x>>t;
    cout<<(n+x-1)/x*t;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
int a,b,p[100000],q[100000],i,j,k,n;
int main(){
	cin>>a>>b;
	if(a<3){
		cout<<"0"<<endl;
		return 0;
	}
	a-=2;
	n=a/11*5;
	a%=11;
	for(i=1;i<=a;i++){
		for(j=2;j<=6;j++){
			if(((i*7+j)*9)%11==b)
				n++;
		}
	}
	cout<<n<<endl;
}


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

int main(){
    long N;
    long p[100002]={};
    long count=0;

    cin >> N;
    for(long i=1;i<=N;i++){
        cin >> p[i];
    }

    for(long i=1;i<=N;i++){
        if(i==p[i]){
            if(i+1==p[i+1]){
                count++;
                i++;
            }
            else{
                count++;
            }
        }
    }

    cout << count << "\n";
    return 0;

}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#define PI 3.14159265358979323846

int main(void) {
	
	int N, K;
	char S[50];
	scanf("%d%d%s", &N, &K, S);
	S[K - 1] += 32;

	printf("%s", S);


	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;


int main() {
	
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])cout << "Yes";
	else cout << "No";
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

vector<ll> a(51, 1);
vector<ll> p(51, 1);

ll f(ll n, ll x) {
    if (n == 0) {
        return x > 0 ? 1 : 0;
    }
    if (x <= a[n - 1] + 1) {
        return f(n - 1, x - 1);
    } else {
        // + 1 is center patty / -2 are first buns & center patty
        return p[n - 1] + 1 + f(n - 1, x - a[n - 1] - 2);
    }
}

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

    for (int i = 1; i <= n; i++) {
        a[i] = a[i - 1] * 2 + 3;
        p[i] = p[i - 1] * 2 + 1;
        //cout << i << ": " << a[i] << "/" << p[i] << endl;
    }

    cout << f(n, x) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head

int main(void){
    string s;
    cin>>s;
    cout<<((s[2]==s[3]&&s[4]==s[5])?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
W,H=map(int,input().split())
p=sorted(int(input())for _ in'_'*W)
p+=10**18,
q=sorted(int(input())for _ in'_'*H)
q+=10**18,
z=i=j=0
h,w=H+1,W+1
while i<W or j<H:
	if p[i]<q[j]:
		z+=h*p[i]
		i+=1
		w-=1
	else:
		z+=w*q[j]
		j+=1
		h-=1
print(z)


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

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    int m ,d, count = 0;
    cin >> m >>d;
    for(int i = 1; i < m+1; i++){
        for(int j = 22; j < d+1; j++){
            if(((j/10)*(j%10)) == i && j%10 >= 2) {
                count++;
            }
        }
    }
    cout << count;
    return 0;
}


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

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if (arr[0] == 0 && arr[1] == 0) break;

                var s_be = string.Join("", Enumerable.Repeat("#", arr[1]));

                var s_bt = "#" + string.Join("", Enumerable.Repeat(".", arr[1] - 2)) + "#";

                Console.WriteLine(s_be);
                Console.WriteLine(string.Join("\n", Enumerable.Repeat(s_bt, arr[0] - 2)));
                Console.WriteLine(s_be);

                Console.WriteLine();
            }
        }
    }
}



Measured memory_bytes: 18320
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
n=0
for i in range(N):
  if A[i]>=B[i]:
    n+=B[i]
  else:
    l=min(B[i],A[i]+A[i+1])
    n+=l
    A[i+1]+=A[i]-l
print(n)

Measured memory_bytes: 18476