akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
 
int main() {
  int n,a,b;
  cin >> n >> a >> b;

  string s;
  cin >> s;
  int size = s.size();
  int foreign_rank = 1;
  int count = 0;
  for(int i=0;i<size;i++){
    if(s[i]=='a'){
      if(count < a+b){
        count++;
        printf("Yes\n");
      }else{
        printf("No\n");
      }
    }else if(s[i]=='b'){
      if(count < a+b && foreign_rank <= b){
        count++;
        printf("Yes\n");
      }else{
        printf("No\n");
      }
      foreign_rank++;
    }else{
      printf("No\n");
    }


  }
}

Measured memory_bytes: 3728
class Node:
  def __init__(self, v):
    self.v = v
    self.p = None
    self.n = None
  
  def delete(self):
    if self.p:
      self.p.n = self.n
    if self.n:
      self.n.p = self.p

N = int(input())
pp = list(map(int, input().split()))
nn = dict()
prev = None
for i, p in enumerate(pp):
  n = Node(i)
  if prev:
    prev.n = n
    n.p = prev
  nn[p] = n
  prev = n
s = 0
for x in range(1, N):
  c = nn[x]
  ci = c.v
  pi = c.p.v if c.p else -1
  ni = c.n.v if c.n else N
  if c.p:
    ppi = c.p.p.v if c.p.p else -1
    s += x * (pi - ppi) * (ni - ci)
  if c.n:
    nni = c.n.n.v if c.n.n else N
    s += x * (ci - pi) * (nni - ni)
  c.delete()
print(s)

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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


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

  if(b+1 == d) cout << 0 << endl;
  else cout << 1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n, a, b, c, d, e = 0, f = 0,g=0; cin >> n >> a >> b >> c >> d;
	string s; cin >> s;
	if (c < d) {
		for (int i = a; i < d - 1; i++) {
			if (s[i] == '#' && s[i + 1] == '#') {
				e++;
			}
		}
		if (e == 0) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	else {
		for (int i = b - 2; i < d-1; i++) {
			if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
				f++;
			}
		}
		for (int i = a; i < c; i++) {
			if (s[i] == '#' && s[i + 1] == '#') {
				g++;
			}
		}
		if (f > 0 && g==0) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 640
N, A, B = map(int, input().split())
S = input()

confirmed = 0
confirmedB = 0

for c in S:
    if c == "a" and confirmed < A+B:
        print("Yes")
        confirmed += 1
    elif c == "b" and confirmed < A+B:
        if confirmedB < B:
            print("Yes")
            confirmed += 1
            confirmedB += 1
        else:
            print("No")
    else:
        print("No")
    

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    string ans;
    while(1){
        c-=b;
        if(c<=0){
            ans = "Yes";
            break;
        }
        a-=d;
        if(a<=0){
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
}


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

int main(){
  int n;
  cin >> n;
  
  vector<long> a(n);
  for (int i=0; i<n; i++) cin >> a[i];
  
  long odd = 0, even = 0, sum = 0;
  
  for (int i=0; i<n; i++){
    sum += a[i];
    if(i%2==0&&sum<=0){
      odd += abs(sum)+1;
      sum = +1;
    }
    else if(i%2==1&&sum>=0){
      odd += abs(sum)+1;
      sum = -1;
    }
  }
  
  sum = 0;
  for (int i=0; i<n; i++){
    sum += a[i];
    if (i%2==1&&sum<=0){
      even += abs(sum)+1;
      sum = +1;
    }
    else if(i%2==0&&sum>=0){
      even+=abs(sum)+1;
      sum=-1;
    }
  }
  
  cout << min(odd,even) << endl;
  
}

Measured memory_bytes: 1024
def main():
    M = int(input())
    DC = [list(map(int, input().split())) for _ in range(M)]
    S = 0
    cS = 0

    for d, c in DC:
        cS += c
        S += d*c

    ans = cS - 1 + (S-1)//9
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 45360
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

const i64 mod = 1e9 + 7;
i64 ipow(i64 a, i64 b) {
    i64 x = a, y = 1;
    for (; b > 0; b >>= 1) {
        if (b & 1) (y *= x) %= mod;
        (x *= x) %= mod;
    }
    return y;
}
int main() {
    i64 n, k;
    cin >> n >> k;
    i64 ans = 0;
    vector<i64> tab(k + 1);
    for (i64 i = 1; i <= k; ++i) {
        ans += i * ipow(k / i, n) % mod;
        ans -= tab[i] * ipow(k / i, n) % mod;
        // cerr << tab[i] << endl;
        ans += 2 * mod;
        ans %= mod;
        for (i64 j = 2 * i; j <= k; j += i) {
            tab[j] += i - tab[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4048
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  //1000000000000000000
  //1000000000000000001
  
  i64 inf = 1000000000000000001;

  i64 m = 1;

  bool over = false;

  F0R(i, N) {
    i64 d;
    if (m > 0) {
      d = (inf + m-1) / m;
    }

    i64 a;
    cin >> a;

    if (m > 0) {
      if (a >= d) {
        over = true;
      }

      if (!over || a == 0) {
        m *= a;
      }
    }
  }

  cout << (m == 0 ? 0 : over ? -1 : m);
}
#endif


Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n==1)
	cout<<1;
	if(n>=2&&n<=3)
	cout<<2;
	if(n>=4&&n<=7)
	cout<<4;
	if(n>=8&&n<=15)
	cout<<8;
	if(n>=16&&n<=31)
	cout<<16;
	if(n>=32&&n<=63)
	cout<<32;
	if(n>=64)
	cout<<64;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
  int n,m;
  int a[2][200]; // sono ka-do ha nannbanndesyou...
  scanf("%d %d",&n,&m);
  for(int i=0;i<2*n;i++) a[0][i] = i+1;
  for(int i=0;i<m;i++){
    int k;
    scanf("%d",&k);
    int from = i%2;
    int to = (i+1)%2;
    if(k==0){
      for(int i=0;i<n;i++){
        a[to][i*2] = a[from][i];
        a[to][2*i+1] = a[from][n+i];
      }
    }else{
      for(int i=0;i<2*n;i++){
        if(i<k) a[to][2*n-k+i] = a[from][i];
        else a[to][i-k] = a[from][i];
      }
    }
  }
  for(int i=0;i<2*n;i++) printf("%d\n",a[m%2][i]);
  return 0;
}

Measured memory_bytes: 2616
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
	int x,n,i,j,mini=100,flag=0,ii;
	cin >> x >> n;
	vector<int> p(n);
	int a[102]={0};

	for(i=0;i<n;i++)cin >> p.at(i);
	//存在する値を色塗り
	for(i=0;i<102;i++){
		for(j=0;j<n;j++){
			a[p.at(j)]=1;
		}
	}
	for(i=101;i>=0;i--){
		if(a[i]!=1 && mini>=abs(x-i)){
			mini=abs(x-i);
			ii=i;
		}
	}
	cout << ii <<endl;
return 0;
}

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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	double sum = 0.;
	rep(i, n) {
		int a; cin >> a;
		sum += 1. / a;
	}
	cout << 1. / sum << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
L = []

for _ in range(N):
  A, B = map(int, input().split())
  L.append([A, B])

L.sort( key = lambda x: x[1])

T = 0

for AB in L:
  T += AB[0]
  if T > AB[1]:
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 38036
animal,leg = [int(x) for x in input().split()]
# crane + turtle = animal
# 2*crane + 4*turtle = leg
import numpy as np
A = np.array([
    [1,1],
    [2,4]
])
B = np.array([
    [animal],
    [leg]
])
A_inv = np.linalg.inv(A)
ans = A_inv.dot(B)
result = 0
for a in ans:
    for b in a:
        if b<0 or not b.is_integer():
            result = 1
            break
if result:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 27616
-- AtCoder My Practice
    -- author: Leonardone @ NEETSDKASU
     
    -- 解説読後
    -- http://arc060.contest.atcoder.jp/data/arc/060/editorial.pdf
     
    import qualified Data.Array as A
    import qualified Data.Map as M
     
    main = print . solve . map read . words =<< getContents
     
    solve (n:a:xs) = ans where
        x  = maximum (a:xs)
        nx = n * x
        ys = A.listArray (1, n) $ map (+ (-a)) xs
        dp j t m =
            case M.lookup (j, t) m of
            Just c  -> (c, m)
            Nothing ->
                case True of
                    _ | j == 0 && t == nx -> (1, m)
                    _ | j >= 1 && (ty <  0 || ty >  2 * nx) -> ans where
                        (a1, m1) = dp j1 t m
                        ans = (a1, M.insert (j, t) a1 m1) -- 間違いあったのに通った？
                    _ | j >= 1 && (ty >= 0 && ty <= 2 * nx) -> ans where
                        (a1, m1) = dp j1 t m
                        (a2, m2) = dp j1 ty m1
                        ans = (a1 + a2, M.insert (j, t) (a1 + a2) m2)
                    _ -> (0, m)
            where
                j1 = j - 1
                ty = t - (ys A.! j)
        ans = fst (dp n nx M.empty) - 1

Measured memory_bytes: 7292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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

    if (k > (n - 1) * (n - 2) / 2) {
        cout << -1 << endl;
        return 0;
    }

    vector<pair<int, int>> pr;
    bool v[n][n] = {};
    rep(i, 1, n) {
        pr.push_back(make_pair(0, i));
        v[0][i] = true;
        v[i][0] = true;
    }

    int cnt = (n - 1) * (n - 2) / 2;
    rep(i, 1, n - 1) {
        if (cnt == k) break;
        pr.push_back(make_pair(i, i + 1));
        v[i][i + 1] = true;
        v[i + 1][i] = true;
        cnt--;
    }

    rep(i, 0, n) {
        rep(j, i + 1, n) {
            if (cnt == k) break;
            if(!v[i][j]) {
                pr.push_back(make_pair(i, j));
                v[i][j] = true;
                v[j][i] = true;
                cnt--;
            }
            if (cnt == k) break;
        }
        if (cnt == k) break;
    }

    cout << pr.size() << endl;
    for (auto i : pr) {
        cout << i.first + 1 << " " << i.second + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }



template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    map<int,int> m;
    REP(i,0,n) m[a[i]]++;
    int ans = 0;
    REP(i,0,n) {
        if (a[i] == 1) {
            if (m[1] == 1) ++ans;
            continue;
        }

        m[a[i]]--;

        if (m[a[i]] > 0 || m.count(1) > 0) {
            m[a[i]]++;
            continue;
        }
        bool b = true;
        for (int j = 2; j * j <= a[i]; ++j) {
            if (a[i] % j != 0) continue;
            if (m.count(a[i]/j) > 0 || m.count(j) > 0) {
                b = false;
                break;
            }
        }
        if (b) {
            //dump(i);
            ++ans;
        }

        m[a[i]]++;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 14012
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(12);
  int n,k;
  cin>>n>>k;
  double p[n];
  rep(i,n){
    cin>>p[i];
    p[i]=(p[i]+1)/2;
  }
  double ans=0;
  double now=0;
  rep(i,n){
    if(i<k){
      ans+=p[i];
      now+=p[i];
    }else{
      now+=p[i];
      now-=p[i-k];
      ans=max(now,ans);
    }
  }
  cout<<ans<<endl;
	  

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9


int main() {
	int N, K; cin >> N >> K;
	int h[N], dp[N];
	for (int i = 0; i < N; i++) cin >> h[i];
	dp[0] = 0;

	for (int i = 1; i < N; i++) {
		dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		for (int j = 2; j <= K && i-j >= 0; j++) {
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}

	cout << dp[N - 1] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
ld eps = 1e-9;

int main() {
	int N, M; cin >> N >> M;
	vector<int>nums;
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		nums.emplace_back(a);
	}
	const int whitenum = accumulate(nums.begin(), nums.end(), 0);
	vector<int>sizes;
	vector<int>finnums;
	for (int i = 0; i < M; ++i) {
		int a; cin >> a;
		sizes.emplace_back(a);
		for (int j = 0; j < a; ++j) {
			finnums.push_back(i % 2 == 0);
		}
	}
	int firstnum = 0;
	int secondnum = 0;
	{
		for (int i = 0; i < M; i += 2) {
			firstnum += sizes[i];
		}
		secondnum = N - firstnum;
	}
	int ans = 1e8;
	if (firstnum == whitenum) {
		auto it = find(nums.begin(), nums.end(), 1);
		auto jt = find(finnums.begin(), finnums.end(), 1);
		int nans = 0;
		for (int i = 0; i < whitenum; ++i) {
			nans += abs((it - nums.begin()) - (jt - finnums.begin()));
			it = find(next(it), nums.end(), 1);
			jt = find(next(jt), finnums.end(), 1);
		}
		ans = nans;
	}
	if (secondnum == whitenum) {
		auto it = find(nums.begin(), nums.end(), 1);
		auto jt = find(finnums.begin(), finnums.end(), 0);
		int nans = 0;
		for (int i = 0; i < whitenum; ++i) {
			nans += abs((it - nums.begin()) - (jt - finnums.begin()));
			it = find(next(it), nums.end(), 1);
			jt = find(next(jt), finnums.end(), 0);
		}
		ans =min(ans, nans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3164
N = int(input())
Fizz = int(N / 3)
Buzz = int(N / 5)
FizzBuzz = int(N / 15)
Answer =  int((N * ( N + 1) / 2)
              - (3 * Fizz * (Fizz + 1) / 2)
              - (5 * Buzz * (Buzz + 1) / 2)
              + (15 * FizzBuzz * (FizzBuzz + 1) / 2))
print(Answer)


Measured memory_bytes: 9184
using System;
    using System.Collections.Generic;
    using System.Text;
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int a1 = int.Parse(input.Split(' ')[0]);
            int a2 = int.Parse(input.Split(' ')[1]);
            int a3 = int.Parse(input.Split(' ')[2]);

            if (a1 + a2 + a3 >= 22)
            {
                Console.WriteLine("bust");
            }
            else
            {
                Console.WriteLine("win");

            }

        }
    }

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int INF = 0x3f3f3f3f;

int main() {
    int n, W, vsum = 0;
    cin >> n >> W;

    vector <int> w(n), v(n);

    for (int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
        vsum += v[i];
    }

    vector <vector <long long>> dp(n + 1, vector <long long> (vsum + 1, INF));
    dp[1][0] = 0;
    dp[1][v[0]] = w[0];
    
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j <= vsum; j++) {
            if (j - v[i - 1] >= 0 && (w[i - 1] + dp[i - 1][j - v[i - 1]] <= W)) {
                dp[i][j] = min(dp[i - 1][j], w[i - 1] + dp[i - 1][j - v[i - 1]]);
            }
            else
                dp[i][j] = dp[i - 1][j];
        }
    }

    int maxv;
    for (int i = vsum; i >= 0; i--) {
        if (dp[n][i] != INF && dp[n][i] > 0) {
            maxv = i;
            break;
        }
    }

    cout << maxv << '\n';
    return 0;
}

Measured memory_bytes: 80256
N, K = map(int, input().split())
M = N - K
mod = 10**9 + 7

class Combination:
    def __init__(self, n):
        self.facts = [1 for i in range(n+1)]
        self.invs = [1 for i in range(n+1)]
        
        for i in range(1, n+1):
            self.facts[i] = self.facts[i-1] * i % mod
            self.invs[i] = pow(self.facts[i], mod-2, mod)

    def ncr(self, n, r):
        if n < r:
            return 0
        if n < 0 or r < 0:
            return 0
        else:
            return self.facts[n] * self.invs[r] * self.invs[n-r] % mod

    def nhr(self, n, r): 
        return self.ncr(n+r-1, n-1)

comb = Combination(max(M+1, K-1))

for i in range(K):
    ans = comb.ncr(M+1, i+1) * comb.ncr(K-1, i)
    print(ans%mod)

Measured memory_bytes: 3444
#include<stdio.h>
typedef long long ll;
int main(){
    int n;
    scanf("%d",&n);
    int c[n],v[n];
    for(int i=0;i<n;i++){
        scanf("%d",&v[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%d",&c[i]);
    }
    int a[50];
    int ans=0;
    for(int i=0;i<n;i++){
        a[i]=v[i]-c[i];
        if(a[i]>0){
            ans+=a[i];
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
# E - Colorful Blocks

MOD = 998244353
N, M, K = map(int, input().split())

# 予め階乗を計算しておく
f = [1]
for i in range(N):
    f.append(f[i]*(i+1)%MOD)

# 組み合わせ関数
def comb_mod(n, r, p):
    return f[n] * pow(f[r], p-2, p) * pow(f[n-r], p-2, p)

ans = 0
for i in range(K+1):
    ans = (ans + (M*pow(M-1, N-1-i,MOD)) * comb_mod(N-1, i, MOD))%MOD

print(ans)


Measured memory_bytes: 81324
from operator import itemgetter
N, M = map(int, input().split())

A = []
for i in range(M):
  A.append([i] + list(map(int, input().split())) + ["x"])

A.sort(key=itemgetter(1,2))

keynum, count = 0, 1
for i in range(M):
  if keynum != A[i][1]:
    keynum = A[i][1]
    count = 1
  else:
    count += 1
    
  A[i][3] = str(keynum).zfill(6) + str(count).zfill(6)
  
A.sort(key=itemgetter(0))
for i in range(M):
  print(A[i][3])

Measured memory_bytes: 38688
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long

using namespace std;

inline void cmin(ll &x,ll y){y<x?x=y:0;}

const int N=1e5+10;
const ll inf=1e18;
int n,e,t,a[N]; ll f[N],mi;

int main(){
	scanf("%d%d%d",&n,&e,&t);
	rep (i,1,n) scanf("%d",&a[i]);
	memset(f,0x3f,sizeof(f)),f[0]=0;
	int p=0; mi=inf;
	rep (i,1,n){
		while (p<=i&&2ll*(a[i]-a[p+1])>t)
			mi=min(mi,f[p]-2*a[p+1]),p++;
		cmin(f[i],mi+2ll*a[i]);
		if (p<i) cmin(f[i],f[p]+t);
	}
	printf("%lld\n",f[n]+e);
	return 0;
}

Measured memory_bytes: 1408
#include                        <bits/stdc++.h>
#include                        <ext/pb_ds/assoc_container.hpp>
#define lb                      lower_bound
#define ub                      upper_bound
#define fe(x)                   *(x.begin())
#define le(x)                   *(x.rbegin())
#define pb                      push_back
#define load(node,n)            bool operator < (const node &n) const
#define fbo(x)                  find_by_order(x)
#define ook(x)                  order_of_key(x)
#define all(x)                  (x).begin(),(x).end()
#define FOR(i,n)                for(int i = 1; i<=n; i++)
#define REP(i,n)                for(int i = 0; i<n;  i++)
#define TT                      int TC;  scanf("%d",&TC);  while(TC--)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define dbg(...)                debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#define set(x)                  tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>
using                           namespace __gnu_pbds;
using                           namespace std;
typedef                         long long ll;
typedef                         pair<ll,ll> pll;
typedef                         pair<int,int> pii;

vector<string> vec_splitter(string s){
    s += ','; vector<string> res;
    while(!s.empty()) res.push_back(s.substr(0,s.find(','))), s = s.substr(s.find(',') + 1);
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused))int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T){
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") "; stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str(); debug_out(args, idx + 1, LINE_NUM, T...);
}



#define mx 100005
ll ar[mx],ara[mx];

main(){
//read;

int n;
cin>>n;

FOR(i,n+1)    cin>>ar[i];
FOR(i,n)    cin>>ara[i];

ll ans = 0;

for(ll i = 1; i<=n; i++){
    ll p = ara[i];
    ll q = min(ar[i+1]+ar[i],p);
    ans+=q;
    ar[i+1]-=min(ar[i+1],q-min(ar[i],q));
    ar[i]-=min(ar[i],q);
}

cout<<ans;


return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  int n, m, a[100010];
  double sum = 0;
  
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  
  sort(a, a+n);
  reverse(a, a+n);
  
  if (a[m-1] < sum / (4 * m)) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  Int q;
  cin>>q;
  for(Int i=0;i<q;i++){
    Int b,e,k;
    cin>>b>>e>>k;
    cout<<count(a.begin()+b,a.begin()+e,k)<<endl;
  }
  return 0;
}



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

int main(){
    ll a, p;
    cin >> a >> p;
  a = 3*a+p;
    cout << a/2 << endl;
    return 0;
}


Measured memory_bytes: 3612
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = int(1e9) + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    int N, K;
    cin >> N >> K;
    vector<pair<int, int>> xy;
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        xy.emplace_back(x, y);
    }
    sort(all(xy));

    vector<pair<int, int>> xy_range(N);
    ll ans = INT64_MAX;
    rep(x1, 0, N) rep(x2, x1 + 1, N + 1) {
        int nx = x2 - x1;
        if (nx < K) continue;
        ll dx = xy[x2 - 1].first - xy[x1].first;

        copy(xy.begin() + x1, xy.begin() + x2, xy_range.begin());
        sort(xy_range.begin(), xy_range.begin() + nx, [](auto & l, auto & r) { return l.second < r.second; });

        rep(y1, 0, nx - K + 1) {
            int y2 = y1 + K;
            ll dy = xy_range[y2 - 1].second - xy_range[y1].second;

            ans = min(ans, dx * dy);
        }
    }

    write(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi a1(n), a2(n);
    rep(i,n) cin >> a1.at(i);
    rep(i,n) cin >> a2.at(i);
    int64_t sum;
    // i: 折り返しの場所、 j: 足しあわせのindex
    int64_t res = 0;
    rep(i,n){
        sum = 0;
        rep(j,n){
            if(j<i){
                sum += a1.at(j);
            }else if(i==j){
                sum += a1.at(j);
                sum += a2.at(j);
            }else{
                sum += a2.at(j);
            }
            // cout << "i:" << i << " j:" << j << " sum:" << sum << endl;
        }
        res = max(res, sum);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
/*
* Copyright 2019 yaito3014
*/
#include "bits/stdc++.h"
using namespace std;

int main() {
  constexpr int MAX_N = 100;
  constexpr int MAX_V = 1000;
  constexpr int64_t INF = INT64_MAX - 1000000000;
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  for (int i = 0; i < N; ++i)
    cin >> w[i] >> v[i];
  array<int64_t, (MAX_N * MAX_V + 1)> dp;
  dp.fill(INF);
  dp[0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = MAX_N * MAX_V; j >= v[i]; --j) {
      dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
    }
  }
  int ans = distance(
    find_if(rbegin(dp), rend(dp), [&](auto c) { return c <= W; }),
    rend(dp)) - 1;
  cout << ans << endl;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>x(n),y(n); for(auto&i:x)cin>>i; y=x;
	sort(y.begin(),y.end());
	int med=y.at(n/2),med2=y.at(n/2-1);
	for(int i=0;i<n;++i){
		if(x.at(i)<med)cout<<med;
		else cout<<med2;
		cout<<"\n"s;
	}
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

bool judge(ll x) {
    bool f3 = false, f5 = false, f7 = false;
    while (x > 0) {
        ll d = x % 10;
        if (d == 3) f3 = true;
        else if (d == 5) f5 = true;
        else if (d == 7) f7 = true;
        else return false;
        x /= 10;
    }
    return f3 && f5 && f7;
}

ll dfs(ll cur, ll n) {
    if (cur > n) return 0;
    ll res = judge(cur);
    res += dfs(cur * 10 + 7, n);
    res += dfs(cur * 10 + 5, n);
    res += dfs(cur * 10 + 3, n);
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    cout << dfs(0, n) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N, K;
    vector<ll> H(200010,0LL);
    cin >> N >> K;
    for (int i=0;i<N;i++) cin >> H[i];

    sort(H.begin(), H.end());
    reverse(H.begin(), H.end());
    for (int i=0;i<K;i++) H[i] = 0;
    ll res = accumulate(H.begin(), H.end(), 0LL);
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
from collections import deque
b=deque()
for i in range(n):
    if i%2==0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
if n%2==0:
    print(*b)
else:
    print(*(reversed(b)))



Measured memory_bytes: 26180
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i < N; i++)
	{
		ans += N / i;
		if (N % i == 0)ans --;
	}
	cout << ans << '\n';
}

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

int main() {
  int A, B;
  string s;
  cin >> A >> B >> s;
  bool answer = true;
  
  if (s.at(A) != '-') answer = false; 
  
  for (int i = 0; i <= A+B; i++){
    if(i == A) continue;
    if (!((s.at(i) >= '0')&&(s.at(i) <= '9'))) answer = false;
  }
  if (answer) cout << "Yes" << endl;
  else cout << "No" << endl;
} 

Measured memory_bytes: 256
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>


/* ----- Type Alias ----- */
using Bool = bool;
using Int = long long int;
using Real = long double;
using Char = char;
using String = std::string;
template <class T, class U>
using Pair = std::pair<T, U>;
template <class... Ts>
using Tuple = std::tuple<Ts...>;

template <class T>
using Vector = std::vector<T>;
template <size_t N>
using Bits = std::bitset<N>;
template <class T>
using Queue = std::queue<T>;
template <class T>
using Stack = std::stack<T>;
template <class T>
using Deque = std::deque<T>;

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
using Set = std::set<T>;
template <class T, class U>
using Map = std::map<T, U>;

template <class T, class... Us>
using Func = std::function<T(Us...)>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return Vector<decltype(genv<T>(ts...))>(l, genv<T>(ts...));
}

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = Vector<Vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
// constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// constexpr Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

int main() {
    Int l, r;
    std::cin >> l >> r;

    if (r - l >= 2019) {
        std::cout << 0 << std::endl;
        return 0;
    }

    Int ans = 2019;
    for (Int x = l; x <= r; ++x) {
        for (Int y = l; y < x; ++y) {
            ans = std::min(ans, x * y % 2019);
        }
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
long n;int m,q,a[1<<17];
bool f[7][1<<18];
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
void bfs(int x,int y,long _n)
{
	queue<pair<int,int> >P;
	f[x][y]=true;
	P.push(make_pair(x,y));
	while(!P.empty())
	{
		pair<int,int>p=P.front();P.pop();
		for(int r=0;r<4;r++)
		{
			int tx=p.first+dx[r],ty=p.second+dy[r];
			if(tx<0||ty<0||tx>=7||ty>=_n||f[tx][ty])continue;
			f[tx][ty]=true;
			P.push(make_pair(tx,ty));
		}
	}
}
main()
{
	cin>>n>>m>>q;
	for(int i=0;i<q;i++)
	{
		cin>>a[i];
	}
	if(n<=100000)
	{
		for(int i=0;i<7;i++)
		{
			for(int j=0;j<n;j++)
			{
				int b=(j*7+i)%m;
				if(upper_bound(a,a+q,b)!=lower_bound(a,a+q,b))f[i][j]=true;
			}
		}
		long ans=0;
		for(int i=0;i<7;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(!f[i][j])
				{
					ans++;
					bfs(i,j,n);
				}
			}
		}
		cout<<ans<<endl;
	}
	else if(m%7==0)
	{
		for(int i=0;i<7;i++)
		{
			for(int j=0;j<m/7*2;j++)
			{
				int b=(j*7+i)%m;
				if(upper_bound(a,a+q,b)!=lower_bound(a,a+q,b))f[i][j]=true;
			}
		}
		long count1=0;
		for(int i=0;i<7;i++)
		{
			for(int j=0;j<m/7*2;j++)
			{
				if(!f[i][j])
				{
					count1++;
					bfs(i,j,m/7*2);
				}
			}
		}
		for(int i=0;i<7;i++)
		{
			for(int j=0;j<m/7*3;j++)
			{
				f[i][j]=false;
				int b=(j*7+i)%m;
				if(upper_bound(a,a+q,b)!=lower_bound(a,a+q,b))f[i][j]=true;
			}
		}
		long count2=0;
		for(int i=0;i<7;i++)
		{
			for(int j=0;j<m/7*3;j++)
			{
				if(!f[i][j])
				{
					count2++;
					bfs(i,j,m/7*3);
				}
			}
		}
		long kousa=count2-count1;
		long syokou=count1-kousa*2;
		cout<<syokou+kousa*(n/(m/7))<<endl;
	}
	else
	{
		for(int i=0;i<7;i++)
		{
			for(int j=0;j<m;j++)
			{
				int b=(j*7+i)%m;
				if(upper_bound(a,a+q,b)!=lower_bound(a,a+q,b))f[i][j]=true;
			}
		}
		long count1=0;
		for(int i=0;i<7;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(!f[i][j])
				{
					count1++;
					bfs(i,j,m);
				}
			}
		}
		for(int i=0;i<7;i++)
		{
			for(int j=0;j<2*m;j++)
			{
				f[i][j]=false;
				int b=(j*7+i)%m;
				if(upper_bound(a,a+q,b)!=lower_bound(a,a+q,b))f[i][j]=true;
			}
		}
		long count2=0;
		for(int i=0;i<7;i++)
		{
			for(int j=0;j<2*m;j++)
			{
				if(!f[i][j])
				{
					count2++;
					bfs(i,j,2*m);
				}
			}
		}
		for(int i=0;i<7;i++)
		{
			for(int j=0;j<n-n/m*m+m;j++)
			{
				f[i][j]=false;
				int b=(j*7+i)%m;
				if(upper_bound(a,a+q,b)!=lower_bound(a,a+q,b))f[i][j]=true;
			}
		}
		long count3=0;
		for(int i=0;i<7;i++)
		{
			for(int j=0;j<n-n/m*m+m;j++)
			{
				if(!f[i][j])
				{
					count3++;
					bfs(i,j,n-n/m*m+m);
				}
			}
		}
		long kousa=count2-count1;
		long syokou=count1-kousa;
		long amari=count3-syokou-kousa;
		cout<<syokou+kousa*(n/m)+amari<<endl;
	}
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
     
    using namespace std; 
    #define REP(i, n) for (int i = 0; i < (n); i++)
    #define NUM_M 1000
    #define MAX_H 10000
    typedef long long ll;
    ll dp[NUM_M + 1][MAX_H + 1]; // dp[i+1][j] -> i番目までの魔法でダメージがj(以上?)になるように選んだ時の魔力消費の最小値
    int main(int argc, char const *argv[])
    {
        cin.tie(0);
       	ios::sync_with_stdio(false);
        ll H, N; cin >> H >> N;
        vector<ll> damage;
        vector<ll> mp;
        REP(i, N) {
            ll tmp_d, tmp_m; cin >> tmp_d >> tmp_m;
            damage.push_back(tmp_d);
            mp.push_back(tmp_m);
        }
        ll INF = 1000000000; // A_i >= 1 H<= 10^4 より　B_i(max) 10^4 * H は越えない
        REP(i, NUM_M + 1) {
            REP(j, MAX_H + 1) {
                dp[i][j] = INF;
            }
        }
        REP(i, NUM_M + 1) {
            dp[i][0] = 0;
        }
        REP(i, N) {
            REP(j, MAX_H + 1) {
                if(j == 0) continue;
                int j_i = max(j-(int)damage[i], 0);
                if (i == 0) {
                    dp[i][j] = dp[i][j_i] + mp[i];
                }
                else dp[i][j] = min(dp[i-1][j], min(dp[i][j_i] + mp[i], dp[i-1][j_i] + mp[i]));
            }
        }
        cout << dp[N-1][H] << endl;
        return 0;
    }

Measured memory_bytes: 78464
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    long long int a[n];
    long long int r[100001]={0};
    long long int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        r[a[i]]++;
        sum+=a[i];
       }
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
            int b,c;
            cin>>b>>c;
            sum-=(long long int)(b*r[b]);
            sum+=(long long int)(r[b]*c);
            r[c]+=r[b];
            r[b]=0;
            cout<<sum<<"\n";
    }
}

Measured memory_bytes: 5112
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
        
def lcm(a,b):
    return b * a//gcd(a,b)
    
n = int(input())
ans=1
for i in range(n):
    t = int(input())
    ans = lcm(ans,t)
    
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <string>

using namespace std;

int solve();

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

int solve() {

	string str;
	int a, b, c, d;
	int w, h;


	cin >> str;
	if (str == "#") { return 0; }

	cin >> a >> b >> c >> d;

	//	まず盤面のサイズを取得する

	// height
	{
		h = 1;
		for (int i = 0; i < str.length(); i++)
			if (str[i] == '/') h++;
	}

	//	width
	{
		string s = str.substr(0, str.find("/", 0));

		w = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s[i] == 'b') { w++; }
			else { w += s[i] - '0'; }
		}
	}

	//	盤面を行単位に分割する
	vector< vector< int > > v(h, vector<int>(w, 0));
	vector< string > col(h);

	{
		int pos = 0;
		for (int i = 0; i < h; i++) {
			int nextpos = str.find("/", pos+1);
			if (nextpos == string::npos) { nextpos = static_cast<int>(str.length()); }

			col[i] = str.substr(pos, nextpos - pos);

			pos = nextpos + 1;
		}
	}

	//　盤面状態を取得する
	{
		for (int i = 0; i < h; i++) 
		{
			int p = 0;
			for (int j = 0; j < col[i].length(); j++)
			{
				if (col[i][j] == 'b') 
				{
					v[i][p] = 1;
					p++;
				}
				else
				{
					p += col[i][j] - '0';
				}
			}
		}
	}

	v[a-1][b-1] = 0; v[c-1][d-1] = 1;


	//	盤面をjfen形式で出力する
	{
		for (int i = 0; i < h; i++) {
			if (i > 0) { cout << "/"; }
			int cnt = 0;
			for (int j = 0; j < w; j++) {
				if (v[i][j] == 0) {
					cnt++;
					if (j == w - 1) {
						cout << cnt;
					}
				}
				else {
					if (cnt == 0) {
						cout << "b";
					}
					else {
						cout << cnt << "b";
					}
					cnt = 0;
				}
			}
		}

		cout << endl;
	}

	return 1;
}


Measured memory_bytes: 3220
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

#define ll long long
#define inf 1e9
#define eps 1e-10
#define md
using namespace std;

int main()
{
	int A,B,C,D,E,F; 
	scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);
	int water,suger,sum=0,su=0;
	double ans=-1;
	A*=100; B*=100;
	for (int a=0;a<=30;a++)
	{
		water=a*A;
		if (water>F) break;
		for (int b=0;b<=30;b++)
		{
			for (int c=0;c<=F;c++)
			{
				suger=c*C;
				if (water+suger>F||suger>water*E/100) break;
				suger+=(min(E*water/100,F-water)-suger)/D*D;
				if (water&&ans<suger*1.0/water)
				{
					sum=water+suger;
					su=suger;
					ans=suger*1.0/water;
				}
			}
			water+=B;
			if (water>F) break;
		}
	}
	printf("%d %d\n",sum,su);
	return 0;
}
		



Measured memory_bytes: 128
//c++11
#include <stdio.h>
#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;

bool judge(char);
int compareLength(string, string);
void solve(int);

bool judge(char x){
	//a,i,u,e,o
	return (x == 'a' || x == 'i' || x == 'u'
			|| x == 'e' || x == 'o');
}

int compareLength(string a, string b){
	int i = 0;
	while(a[i] == b[i]){
		i++;
	}
	return i;
}

void solve(int n){
	vector<string> table;
	multiset<string> newtable;
	//INPUT
	for(int iz = 0;iz < n;iz++){
		string tmp = "";
		string input;

		cin >> input;
		tmp.push_back(input[0]);

		for(string::iterator i = input.begin(); i != input.end()-1; i++ ){
			if(judge(*i))
				tmp.push_back(*(i+1));
		}
		table.push_back(tmp);
	}
	
	//resize 
	/*
	for(vector<string>::iterator i = table.begin(); i != table.end(); i++){
		string tmp = *i;
		string res = *i;
		int ix = 0;
		while(res.length() < 50){
			res.push_back(tmp[ix%tmp.length()]);
			ix++;
			ix %= tmp.length();
		}
		newtable.insert(res);
	}
	*/
	for(auto i = table.begin(); i != table.end(); i++){
		newtable.insert(*i);
	}

	/*cout << "===" << endl;
	for(auto i = newtable.begin(); i != newtable.end(); i++){
		cout << *i << endl;
	}
	cout << "===" << endl;*/

	//compare
	int k = 0;
	for(int i  = 1; i <= 50; i++){
		set<string> dup;
		bool flag = true;
		for(auto it = newtable.begin(); it != newtable.end(); it++){
			int index = i;
			if (it->length() <= i)
				index = it->length();
			if(dup.count(string(it->begin(), it->begin()+index)) >= 1){
				flag = false;
				break;
			}
			dup.insert(string(it->begin(), it->begin()+index));
		}
		if(flag){
			k = i;
			break;
		}
	}
	//output
	if( k == 0 )
		cout << "-1" << endl;
	else 
		cout << k << endl;

	return;
}

int main(){
	int n;
	while(cin >> n, n != 0)
		solve(n);
	return 0;
}


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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << a + b + c + d << endl;
}


Measured memory_bytes: 3084
n =int(input())
R = [0]*(n+1)
C = [0]*(n+1)
for u in range(n):
    R[u+1], C[u+1] = map(int, input().split())

INF = 10**18    
dp = [[INF]*(n+1) for _ in range(n+1)]
for i in range(1,n+1):
    dp[i][i] = 0
for l in range(1,n):
    for i in range(1,n+1-l):
        dp[i][i+l] = min(dp[i][k]+ dp[k+1][i+l] + R[i]*C[k]*C[i+l] for k in range(i,i+l))

print(dp[1][n])


Measured memory_bytes: 5656
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int mod = 1e9 + 7;
int main()
{
	SPEED
	char ch, m;
	cin >> ch;
	m = ch+1;
	cout << m;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int N, Q;
vector<int> edges[202020];

void dfs(int v, int p, vector<long long> &num){
    
    // 頂点から子の方へ向かって流す（下流へ）
    for (int j : edges[v]){
        
        // 逆流防止弁をつける
        if (j != p){
            num[j] += num[v];
            dfs(j, v, num);
        }
    }

}

int main(){
    cin >> N >> Q;
    
    // input of a graph
    for (int i = 0; i < N-1; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    
    vector<long long> num(202020);
    
    // preparation for the imos
    for (int i = 0; i < Q; i++){
        long long p, x;
        cin >> p >> x;
        p--;
        
        // p-1番目にのみxを加算する
        // あとで累積和を取る
        num[p] += x;
    }
    
    // imos method on a tree
    dfs(0, -1, num);
    
    for (int i = 0; i < N; i++){
        if (i == N-1){
            cout << num[i] << endl;
        }
        else{
            cout << num[i] << " ";
        }
    }
    
    
}    

Measured memory_bytes: 27392
#include <iostream>
 
int main(int argc, const char * argv[]) {
    int n, m, l;
    std::cin >> n >> m >> l;
    int a[n][m] = {}, b[m][l] = {};
    long long c[n][l] = {};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            std::cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < l; j++) {
            std::cin >> b[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            for (int k = 0; k < m; k++) {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    for (int i = 0; i < n; i++) {
        std::cout << c[i][0];
        for (int j = 1; j < l; j++) {
            std::cout << " " << c[i][j];
        }
        std::cout << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3124