akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
string s;
cin>>s;
if(s=="SUN"){
	cout<<'7';
}
else if(s=="MON"){
	cout<<'6';
}
else if(s=="TUE"){
	cout<<'5';
}
else if(s=="WED"){
	cout<<'4';
}
else if(s=="THU"){
	cout<<'3';
}
else if(s=="FRI"){
	cout<<'2';
}
else{
	cout<<'1';
}

	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,x,ans=1e9,sum;
bool dp[880][880];
main(){
	cin>>n;
	dp[0][0]=1;
	r(i,n){
		cin>>x;
		sum+=x;
		for(int j=879;j>=0;j--)
		  for(int k=879;k>=0;k--)
		    if(dp[j][k]){
		    	if(j+x<810)dp[j+x][k]=1;
		    	if(k+x<810)dp[j][k+x]=1;
		    }
	}
	r(i,880)r(j,880)if(dp[i][j])ans=min(ans,max({i,j,sum-i-j}));
	cout<<ans<<endl;
}

Measured memory_bytes: 3792
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    string s, t; cin >> s >> t;

    int sl = s.size(), tl = t.size();
    
    vector<vector<int>> dp(sl+1, vector<int>(tl+1));

    for (int i = 1; i < sl+1; i++) {
        for (int j = 1; j < tl+1; j++) {
            if (s[i-1] == t[j-1]) dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }

    int len = dp[s.size()][t.size()];

    string lcs;
    
    int i = sl;
    int j = tl;

    while (len > 0) {
        if (s[i-1] == t[j-1]) {
            lcs += s[i-1];
            i--; j--;
            len--;
        }
        else if (dp[i][j] == dp[i-1][j]) i--;
        else j--;
    }

    reverse(lcs.begin(), lcs.end());

    cout << lcs << endl;
}


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

Measured memory_bytes: 38576
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n;
    string s;
    cin >> n >> s;

    vector<Int> tableW(n);
    if (s[0] == 'W') {
        tableW[0] = 1;
    }
    for (int i = 1; i < n; i++) {
        if (s[i] == 'W') {
            tableW[i] = 1 + tableW[i - 1];
        } else {
            tableW[i] = tableW[i - 1];
        }
    }

    Int ans = INT64_MAX;
    for (int i = 0; i < n; i++) {
        Int westW, eastW, eastE;
        westW = (s[i] == 'W') ? tableW[i] - 1 : tableW[i];
        eastW = tableW[n - 1] - tableW[i];
        eastE = n - (i + 1) - eastW;

        ans = min(ans, westW + eastE);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2964
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let R = read::<i32>();
    let G = read::<i32>();

    println!("{}", 2*G-R);
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

///////////////////////////////////////////////////////////////////////////////////////

ll a, b, c, x, y, ans;

int main() {
	cin >> a >> b >> c >> x >> y;
	if (x < y) {
		ll t;
		t = a;
		a = b;
		b = t;
		t = x;
		x = y;
		y = t;
	}
	if (a + b > c * 2) ans += c * 2 * y;
	else ans += (a + b)*y;
	if (a > c * 2) ans += c * 2 * (x - y);
	else ans += a*(x - y);
	wrln(ans);

	return 0;
}


Measured memory_bytes: 256
# AtCoder Beginner Contest 175
# B - Making Triangle

import bisect

N=int(input())
L=list(map(int,input().split()))

L.sort()

ans=0

for i in range (N):
    for j in range (i+1,N):
        if L[i]==L[j]:
            pass
        else:
            ab=L[i]+L[j]
            c=bisect.bisect_left(L,ab)
            bequalc=bisect.bisect_right(L,L[j])
            ans+=c-(bequalc)

print(ans)

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

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

	if (C - (A - B) > 0) {
		cout << C - (A - B) << endl;
	}
	else {
		cout << 0 << endl;
	}


}


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

int main() {
  string s;
  int cnt = 0;
  while (cin >> s) {
    string r = s;
    reverse(r.begin(), r.end());
    if (r == s) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3068
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	bool flag[1000005];
	rep(i,1000005)flag[i]=false;
	int s;
	cin>>s;
	flag[s]=true;
	int cnt=2;
	while(true){
		if(s%2==0)s/=2;
		else s=3*s+1;
		if(flag[s])break;
		flag[s]=true;
		cnt++;
	}

	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main(){
  int N, A[101];
  cin >> N;
  for (int i=0;i<N;i++) cin >> A[i];
  int absnum = 0;
  int temp = 0;
  for (int i=0;i<N;i++){
    for (int j=0;j<N;j++){
      temp = abs(A[i]-A[j]);
      if (temp>absnum) absnum = temp;
    }
  }
  cout << absnum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
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; }


int main(){
    string str;
    int k;
    cin >> str;
    rep(i, str.length()){
        int x = (char)str.at(i) - '0';
        k += x;
        k %= 9;
    }
    if(k == 0){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//long longのシフト演算には気をつけよう

int main(){
    int x,a,b; cin >> x >> a >> b;
    if(-a+b <= 0) cout << "delicious" << endl;
    else if(-a+b <= x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

int main()
{
    double a, b, x;
    cin >> a >> b >> x;

    double pi, unit;
    pi = 2.0 * asin(1.0);
    unit = 180.0 / pi;
    if (2 * x >= a * a * b)
    {
        cout << setprecision(10) << atan2(b - x / a / a, a / 2) * unit << endl;
    }
    else
    {
        cout << setprecision(10) << atan2(b, 2 * x / a / b) * unit << endl;
    }
}

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

int main(){
    int n;
    cin>>n;
    int a, amin = 1001001001, amax = 0;
    rep(i,n){
        cin>>a;
        amin = min(amin, a);
        amax = max(amax, a);
    }
    
    cout << amax -amin << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
from collections import deque
from heapq import heappush, heappop

def main():
    n_d_a = sys.stdin.readline().strip().split(' ')
    n, d, a = [int(s) for s in n_d_a]
    # n = 5
    # d = 1
    # a = 3
    # xh = [[0, 7],[1, 9], [2, 10], [4, 15], [20, 8]]

    xh = [[]] * n

    for i in range(n):
        x, h = [int(s) for s in sys.stdin.readline().strip().split(' ')]
        xh[i] = [x, h]
    xh.sort()

    cur = 0
    attack_rightmost_idx = [-1] * n
    for i in range(n):
        x, h = xh[i]
        attack_rightmost = x + 2 * d
        while cur < n-1 and xh[cur+1][0] <= attack_rightmost:
            cur += 1
        attack_rightmost_idx[i] = cur

    events = deque()
    total_damage = 0
    ans = 0
    for i in range(n):
        while events and events[0][0] <= i:
            total_damage += events[0][1]
            events.popleft()

        x, h = xh[i]

        remaining_life = h - total_damage
        if remaining_life <= 0:
            continue

        needed = remaining_life // a
        if remaining_life % a:
            needed += 1
        ans += needed
        total_damage += needed * a
        events.append((attack_rightmost_idx[i]+1, - needed * a))

    print(ans)


if __name__ == '__main__':
    main()


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

map<int, int> s;

int main(void)
{
	//freopen("abc.in", "r", stdin);
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	++s[a];
	++s[b];
	++s[c];
	if (s[b] == 2 || s[a] == 2 || s[c] == 2)
		printf("Yes");
	else
		printf("No");
	
}

Measured memory_bytes: 256
from collections import defaultdict
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = [list(map(int,input().split())) for i in range(Q)]

dic = defaultdict(int)
for a in A:
    dic[a] += 1

ans = sum(A)

for b,c in BC:
    t = dic[b]
    ans -= b*t
    dic[b] = 0
    dic[c] += t
    ans += c*t
    print(ans)





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

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
int wait() {
    int tempInput;
    cin >> tempInput;
    return 0;
}
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int N;
    cin >> N;
    vector<int> v(N);
    REP(i, N) cin >> v[i];
    vector<int> v2(v);
    RSORT(v2);
    REP(i, N) {
        if(v[i] == v2[0]) {
            cout << v2[1] << endl;
        } else {
            cout << v2[0] << endl;
        }
    }
    return wait();
}

Measured memory_bytes: 3200
from collections import deque

N = int(input())
branch = [list(map(int, input().split())) for _ in range(N-1)]

adj = [[] for _ in range(N+1)]
for b in branch:
  adj[b[0]].append([b[1],b[2]])
  adj[b[1]].append([b[0],b[2]])

ans = [-1] * (N+1)
deq = deque()
deq.appendleft(1)
while len(deq) > 0:
  v = deq.pop()
  for u, w in adj[v]:
    if ans[u] == -1:
      deq.appendleft(u)
    if ans[v] == -1 and ans[u] == -1:
      if w % 2 == 0:
        ans[v] = 0
        ans[u] = 0
      else:
        ans[v] = 0
        ans[u] = 1
    elif ans[v] == 0:
      if w % 2 == 0:
        ans[u] = 0
      else:
        ans[u] = 1
    else:
      if w % 2 == 0:
        ans[u] = 1
      else:
        ans[u] = 0
if N == 1:
  print(0)
else:
  for i in range(1,N+1):
    print(ans[i])

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

string sub(string x, string y) {
    int num_y = atoi(y.c_str());
    string ans = "";
    for(int i = 0; i < num_y; i++) {
        ans = ans + x;
    }
    return ans;
}

int main() {

    string a, b;
    cin >> a >> b;
    string a_b, b_a;
    a_b = sub(a, b);
    b_a = sub(b, a);
    //int a_b_int = atoi(a_b.c_str());
    //int b_a_int = atoi(b_a.c_str());
    //if(a_b_int > b_a_int) {
    //    cout << a_b_int << endl;
    //}
    //else {
    //    cout << b_a_int << endl;
    //}
    int size_a_b = (int)(a_b.length());
    int size_b_a = (int)(b_a.length());
    int cnt = 0;
    if(size_a_b > size_b_a) {
        cnt = size_a_b;
    } else {
        cnt = size_b_a;
    }
    for(int i = 0; i < cnt; i++) {
        if(a_b.substr(i,1) < b_a.substr(i,1)) {
                cout << a_b << endl;
                return 0;
        } else if(a_b.substr(i,1) > b_a.substr(i,1)) {
                cout << b_a << endl;
                return 0;
        }
    }
    cout << a_b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int data[1010][1010];
int num[1010][1010];

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

	int h, w;
	cin >> h >> w;

	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			char c;
			cin >> c;
			if(c == '.'){
				data[i][j] = -1;
			}
			else {
				data[i][j] = (int)(c - '0');
			}
			//cout << data[i][j] << " ";
		}
		//cout << endl;
	}

	vector<int> cx;
	vector<int> cy;
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			if(data[i][j] == -1) continue;
			for(int k = -1; k <= 1; ++k){
				for(int l = -1; l <= 1; ++l){
					if(k == 0 && l == 0) continue;
					if(data[i + k][j + l] == -1){
						++num[i][j];
					}
				}
			}
			if(num[i][j] >= data[i][j]){
				cx.push_back(i);
				cy.push_back(j);
			}
		}
	}
	
	for(size_t i = 0; i < cx.size(); ++i){
		data[cx[i]][cy[i]] = -1;
	}

	if(cx.empty()){
		cout << 0 << endl;
		return 0;
	}
	int turn = 1;
	while(1){
		vector<int> cx2;
		vector<int> cy2;
		for(size_t a = 0; a < cx.size(); ++a){
			for(int i = -1; i <= 1; ++i){
				for(int j = -1; j <= 1; ++j){
					if(i == 0 && j == 0) continue;
					int x = cx[a] + i;
					int y = cy[a] + j;
					if(data[x][y] == -1) continue;
					++num[x][y];
					if(num[x][y] >= data[x][y]){
						cx2.push_back(x);
						cy2.push_back(y);
						data[x][y] = -1;
					}
				}
			}
		}
		if(cx2.empty()) break;
		++turn;
		cx = cx2;
		cy = cy2;
		/*
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				cout << data[i][j] << " ";
			}
			cout << endl;
		}
		cout << endl;
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				cout << num[i][j] << " ";
			}
			cout << endl;
		}
		cout << endl;
		for(size_t i = 0; i < cx.size(); ++i){
			cout << cx[i] << " " << cy[i] << endl;
		}
		*/
	}

	cout << turn << endl;

	return 0;
}

Measured memory_bytes: 11028
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second

constexpr int mod = 1000000007;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
int N;
int A[200020];

void solve() {

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	vi maxL(N), maxR(N);
	maxL[0] = A[0];
	maxR[N - 1] = A[N - 1];
	for (int i = 1; i < N; i++) {
		maxL[i] = max(maxL[i - 1], A[i]);
		maxR[N - 1 - i] = max(maxR[N - 1 - i + 1], A[N - 1 - i]);
	}

	cout << maxR[1] << endl;
	for (int i = 1; i < N - 1; i++) {
		cout << max(maxL[i - 1], maxR[i + 1]) << endl;
	}
	cout << maxL[N - 2] << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}


Measured memory_bytes: 3968
let readString () = Scanf.scanf " %s" (fun s -> s)

let borders s =
  let n = String.length s in
  let b = Array.make (n+1) (-1) in
  for i=0 to n-1 do
    let j = ref b.(i) in
    while !j >= 0 && s.[!j] <> s.[i] do
      j := b.(!j)
    done;
    b.(i+1) <- !j+1
  done;
  b

type result = [`Unknown | `Cycle | `Length of int]
type knownResult = [`Cycle | `Length of int]

let rec compare (a: result) (b: result) =
  match (a, b) with
  | (`Unknown, `Unknown) -> 0
  | (`Cycle, `Cycle) -> 0
  | (`Length x, `Length y) -> Pervasives.compare x y
  | (`Unknown, _) -> -1
  | (`Cycle, _) -> 1
  | _ -> -(compare b a)

let solve s t : knownResult =
  let n = String.length s in
  let m = String.length t in
  let b = borders t in
  let yes = Array.make n false in
  let j = ref 0 in
  for i=0 to n+m-2 do
    while !j >= 0 && (!j >= m || t.[!j] <> s.[i mod n]) do
      j := b.(!j)
    done;
    incr j;
    if !j = m then yes.(i+1-m) <- true
  done;
  let plen: result array = Array.make n `Unknown in
  let rec calc ?(start = None) i : knownResult =
    let i0 = match start with None -> i | Some i0 -> i0 in
    match plen.(i) with
    | `Unknown ->
        begin
          let ans =
            if start <> None && i = i0 then `Cycle
            else if not yes.(i) then `Length 0
            else
              match calc ~start:(Some i0) ((i + m) mod n) with
              | `Cycle -> `Cycle
              | `Length x -> `Length (1 + x)
          in
          plen.(i) <- ans;
          ans
        end
    | `Cycle -> `Cycle
    | `Length x -> `Length x
  in
  let res: knownResult ref = ref (`Length 0) in
  for i=0 to n-1 do
    let x = calc i in
    if compare (!res :> result) (x :> result) < 0 then res := x
  done;
  match !res with
  | `Cycle -> `Cycle
  | `Length x -> `Length x

let main () =
  let s = readString () in
  let t = readString () in
  Printf.printf "%d\n" (match solve s t with `Cycle -> -1 | `Length x -> x)

let () = main ()


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

#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()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

int dp[100000];
int p[10000];
int d[10000];
int t[10000];
int id[10000];

int main() {
  int L,n;
  while(cin>>L>>n) {
    vector<int> v;
    v.push_back(0);
    v.push_back(L);
    REP(i,n) {
      cin >> p[i] >> d[i] >> t[i];
      v.push_back(p[i]);
      v.push_back(p[i]+d[i]);
    }
    sort(ALL(v));
    v.erase(unique(ALL(v)), v.end());
    map<int,int> xmp;
    REP(i,v.size()) {
      xmp[v[i]] = i;
    }
    memset(id,-1,sizeof(id));
    REP(i,n) {
      id[xmp[p[i]]] = i;
    }
    memset(dp,0x3f,sizeof(dp));
    dp[0] = 0;
    REP(i,v.size()-1) {
      if (id[i] >= 0) {
        chmin(dp[xmp[v[i]+d[id[i]]]], dp[i]+t[id[i]]);
      }
      chmin(dp[i+1], dp[i] + v[i+1]-v[i]);
    }
    cout << dp[v.size()-1] << endl;
  }
}


Measured memory_bytes: 1776
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	map<ll, ll> ncnt;
	ll i, n, cnt = 0;
	cin >> n;
	for (i = 0; i < n; i++){
		ll a;
		cin >> a;
		ncnt[a]++;
	}
	for (auto k : ncnt){
		if (k.first > k.second) cnt += k.second;
		else cnt += (k.second - k.first);
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio (false) ;cin.tie(NULL);
#define tc  int t;cin>>t;for(int i=0;i<t;i++)
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define um(a,b) unordered_map<a,b>
#define vv(a) vector<a>
#define pp(a,b) pair<a,b>
ll power(ll a,ll b,ll mod){  ll ans=1;  while(b>0){
  if(b&1){ ans=(ans*a)%mod;} a=(a*a)%mod;  b=b/2; } return ans;}
ll count(set<ll> temp,ll n,ll m,ll k,char arr[8][8]){
vv(ll) helper;
for(int i=0;i<m;i++ ){
    ll count=0;
    for(int j=0;j<n;j++){
        if(temp.find(j)==temp.end()&&arr[j][i]=='#'){
            count++;
        }
    }
    helper.push_back(count);
}
sort(helper.begin(),helper.end());
ll dp[helper.size()+1][k+1];
memset(dp,0,sizeof(dp));
dp[0][0]=1;
for(int i=1;i<=helper.size();i++){
    for(int j=0;j<=k;j++){
        if(helper[i-1]>j){
            dp[i][j]=dp[i-1][j];
        }else{
           dp[i][j]=dp[i-1][j]+dp[i-1][j-helper[i-1]];
        }
    }
}
return dp[helper.size()][k];

}
ll find(set<ll> temp,ll s,ll n,ll m,ll k,char arr[8][8]){
    if(s==n){
        return count(temp,n,m,k,arr);
    }
    temp.insert(s);
    ll a=find(temp,s+1,n,m,k,arr);
    temp.erase(s);
    ll b=find(temp,s+1,n,m,k,arr);
    return a+b;
}
int main(){
FIO
  ll n,m,k;
  cin>>n>>m>>k;
  char arr[8][8];
  forn(i,n){
    forn(j,m){
      cin>>arr[i][j];
    }
  }
  set<ll> temp;
  ll ans=find(temp,0,n,m,k,arr);
  cout<<ans<<endl;
}


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

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define Itr(i, c) for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;

int main(){
	int d, g; cin >> d >> g;
	int p[d], c[d];
	Rep(i, d){
		cin >> p[i] >> c[i];
	}
	int ans = inf;
	for(int i = 0; i < (1 << d); i++){
		int sum = 0, count = 0;
		for(int j = d-1; j >= 0; j--){
			if(((i >> j) & 1) == 1){
				sum += (j+1) * 100 * p[j] + c[j];
				count += p[j];
			}
		}
		if(sum >= g){
			ans = min(ans, count);
		}else{
			for(int j = d-1; j >= 0; j--){
				int s = (j+1) * 100;
				if(((i >> j) & 1) == 0){
					if((g - sum) <= s * (p[j]-1)){
						int k = (g-sum-1) / s + 1;
						sum += k * s;
						count += k;
					}else{
						sum += (p[j]-1) * s;
						count += p[j]-1;
					}
				}
				if(sum >= g) break;
			}
			if(sum >= g) ans = min(ans, count);
			else continue;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

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

int main() {
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;

    return 0;
}


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

typedef long long LL;
const LL MOD = 1e9+7;

string s;
LL memo[100005][6][6];
char ada[4]={' ','A','B','C'};
LL p3[100005];

void pre()
{
   p3[0]=1LL;
   for(int i=1;i<=100000;i++)
   {
      p3[i] = (p3[i-1]*3LL)%MOD;
   }
   return ;
}

//LL dp(int id, int num)
//{
//   cout << id << " " << num << endl;
//   if(num == 4) return 1LL;
//   if(id>=(int)s.size()) return 0LL;
//   if(memo[id][num]!=-1) return memo[id][num];
//   LL ret = 0LL;
//   ret = dp(id+1,num) % MOD;
//   cout << ">>> " << ret << endl;
////   for(int i=1;i<=num;i++)
////   {
////      
////   }
//   if(s[id]==ada[num] || s[id]=='?') ret = (ret + dp(id+1,num+1))%MOD;
//   return memo[id][num] = ret;
//}
int pst[100005];

int main()
{
   pre();
//   memset(memo,-1,sizeof(memo));
   cin >> s;
   for(int i=0;i<s.size();i++)
   {
      if(i==0)
      {
         if(s[i]=='?') pst[i]=1;
         else pst[i]=0;
      }
      else
      {
         pst[i]=pst[i-1];
         if(s[i]=='?') pst[i] ++;
      }
   }
   for(int i=(int)s.size()-1;i>=0;i--)
   {
      for(int j=1;j<=3;j++) for(int k=0;k<=3;k++) memo[i][j][k] = memo[i+1][j][k];
      if(s[i]=='C')
      {
         memo[i][3][0]++;
      }
      else if(s[i]=='B')
      {
         memo[i][2][1]+=memo[i+1][3][1];
         memo[i][2][0]+=memo[i+1][3][0];
      }
      else if(s[i]=='A')
      {
//         memo[i][1][2]+=memo[i+1][2][2];
//         memo[i][1][1]+=memo[i+1][2][1];
//         memo[i][1][0]+=memo[i+1][2][0];
         LL tmp;
         int n = (int)s.size() -1;
         tmp =p3[max(0,pst[n]-0)];
         memo[i][1][0]+=(tmp*memo[i+1][2][0]);
         tmp = p3[max(0,pst[n]-1)];
         memo[i][1][1]+=(tmp*memo[i+1][2][1]);
         tmp = p3[max(0,pst[n]-2)];
         memo[i][1][2]+=(tmp*memo[i+1][2][2]);
      }
      else
      {
         memo[i][3][1]++;
         memo[i][2][1]+=memo[i+1][3][0];
         memo[i][2][2]+=memo[i+1][3][1];
         LL tmp;
         int n = (int)s.size() -1;
         tmp =p3[max(0,pst[n]-1)];
         memo[i][1][1]+=(tmp*memo[i+1][2][0]);
         tmp = p3[max(0,pst[n]-2)];
         memo[i][1][2]+=(tmp*memo[i+1][2][1]);
         tmp = p3[max(0,pst[n]-3)];
         memo[i][1][3]+=(tmp*memo[i+1][2][2]);
      }
      for(int j=1;j<=3;j++)for(int k=0;k<=3;k++) memo[i][j][k]%=MOD;
   }
   LL ans = 0LL;;
//   for(int j=1;j<=3;j++)
//   {
//      for(int i=0;i<s.size();i++)
//      {
//         printf("%d ",memo[i][j]);
//      }
//      printf("\n");
//   }
   for(int i=0;i<=3;i++) ans = (ans + memo[0][1][i])%MOD;
   printf("%lld\n",ans);
 	return 0;
}


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

int main(){
  int N,K,X,Y;
  cin>>N>>K>>X>>Y;
  if(K>=N){
    cout<<N*X<<endl;
  }
  else if(K<N){
    cout<<K*X+Y*(N-K)<<endl;
  }
}
    

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

namespace _166B
{
    class Program
    {
        static void Main(string[] args)
        {
            //input
            long[] NK = Console.ReadLine().Split(' ').Select(tmp => long.Parse(tmp)).ToArray();
           
            var I = new List<long>();
            var I_dum = new List<long>();
            long temp = 0;
            long[] vals = new long[NK[0]];
                       
            for (var i = 0; i < NK[0]; i++) {
                I.Add(i+1);
            }
                          
            for (var k = 0; k < NK[1]; k++)
            {   
                //input
                temp = long.Parse(Console.ReadLine());
                vals = Console.ReadLine().Split(' ').Select(tmp => long.Parse(tmp)).ToArray();

                /*
                //check
                foreach (var i in I)
                {
                    if (vals.Contains(i)) 
                    {
                        I_dum.Add(i);
                    }
                    
                }
                

                //remove
                foreach (var dum in I_dum)
                {
                    I.Remove(dum);
                }
                
                */
                foreach (var val in vals)
                {
                    I.Remove(val);
                }
               
                //I_dum.Clear();//initialize

            }

            Console.WriteLine(I.Count());
        }
    }
}


Measured memory_bytes: 28304
#include <cstdio>
using namespace std;

int main() {
    int sum = 0;

    for (int i=0; i<5; i++) {
        int score;
        scanf("%d", &score);
        if (score < 40) score = 40;
        sum += score;
    }

    printf("%d\n", sum/5);
}

Measured memory_bytes: 1028
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
using namespace std;

const int maxn=1000+10;

int a[maxn];

int main()
{
	int n,m;
	while(1)
	{
		cin>>n>>m;
		if(!n && !m) break;
		rep(i,1,n) scanf("%d",a+i);
		sort(a+1,a+n+1);
		
		int ans=0;
		for(int i=n;i>=2;--i)
		{
			int p=m-a[i];
			int pos=upper_bound(a+1,a+i,p)-a;
			if(pos==i) --pos;
			if(a[pos]+a[i] <= m) ans=max(ans,a[pos]+a[i]);
			--pos;if(pos==0) continue;
			if(a[pos]+a[i] <= m) ans=max(ans,a[pos]+a[i]);
		}
		if(ans==0) puts("NONE");
		else cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 3264
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
class Main{
	public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	ArrayList<Integer> list = new ArrayList<Integer>();
		while(scan.hasNextLine()){
			int a = scan.nextInt();
			String op = scan.next();
			int b = scan.nextInt();
			//int a = Integer.parseInt(aa);
			//int b = Integer.parseInt(bb);
			int cal =0;
			
			if(op.charAt(0) == '?'){
				break;
			}
			else{
				if(op.charAt(0) == '+'){
					cal = a + b;
				}
				if(op.charAt(0) == '-'){
					cal = a - b;
				}
				if(op.charAt(0) == '*'){
					cal = a * b;
				}
				if(op.charAt(0) == '/'){
					cal = a / b;
				}
				list.add(cal);			
			}
		}
		for(int i=0;i<list.size();i++){
			System.out.println(list.get(i));
		}
	}
}

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

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

#define INF 1e9
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (n); i++)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  int N;
  cin >> N;
  map<string, int> mp;
  rep(i, N) {
    string s;
    cin >> s;
    mp[s]++;
  }

  int mx = 0;
  each(x, mp) mx = max(mx, x.second);
  each(x, mp) {
    if (x.second != mx) continue;
    print(x.first);
  }
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N,K; cin>>N>>K;
	rep(i,N){
		ll x; cin>>x;
	}
	cout<<ceil((double)(N-1)/(K-1));
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int ch,cw,dh,dw;

//dijkstra
//参考：http://nocotan.github.io/%E3%82%A2%E3%83%AB%E3%82%B4%E3%83%AA%E3%82%BA%E3%83%A0/2017/01/26/dijkstra-copy.html

const ll MXV=1000000;//変更可
vector<edge> G[MXV];
vl d(MXV,INF);

void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P>> pq;
    d[s]=0;
    pq.push(P(0,s));
    while(pq.size()){
        P p=pq.top();
        pq.pop();
        int V=p.second;
        if(d[V]<p.first){
            continue;
        }
        rep(i,G[V].size()){
            edge e=G[V][i];
            if(d[e.to]>d[V]+e.cost){
                d[e.to]=d[V]+e.cost;
                pq.push(P(d[e.to],e.to));
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H,W;
    cin >> H >> W;
    cin >> ch >> cw >> dh >> dw;
    ch--;cw--;dh--;dw--;
    vvc s(H,vc(W));
    rep(i,H){
        rep(j,W){
            cin >> s[i][j];
        }
    }
    rep(i,H){
        rep(j,W){
            if(s[i][j]=='#')continue;
            FOR(dx,-2,3){
                FOR(dy,-2,3){
                    if(abs(dx)+abs(dy)==0)continue;
                    int nx=i+dx,ny=j+dy;
                    if(!(0<=nx&&nx<H&&0<=ny&&ny<W&&s[nx][ny]=='.'))continue;
                    int c=(abs(dx)+abs(dy)==1?0:1);
                    G[1000*i+j].pb({1000*nx+ny,c});G[1000*nx+ny].pb({1000*i+j,c});
                    //cout << i << ' ' << j << ' ' << nx << ' ' << ny << ' ' << c << endl;
                }  
            }
        }
    }
    dijkstra(1000*ch+cw);
    cout << (d[1000*dh+dw]==INF?-1:d[1000*dh+dw]) << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/


Measured memory_bytes: 291452
#include<stdio.h>
#include<string.h>

#define M 1046527 // ハッシュテーブルの配列の長さ
#define L 14  // 与えられた文字列を格納する配列の長さ

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
  return key % M;
}

int h2(int key){
  return 1 + (key % (M-1));
}

int find(char str[]){
  long long key;   // 文字列に対応した数値
  long long i;     // 衝突回数
  long long h;     // ハッシュ値

  key = getKey(str);   // 文字列を数値に変換

  for (i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if ( strcmp(H[h], str) == 0)  // ハッシュ表に str が格納されているか
      return 1;
    else if (strlen(H[h]) == 0)   // ハッシュ表が 空でないか
      return 0;
  }

  return 0;
}

int insert(char str[]){
  long long key;   // 文字列に対応した数値
  long long i;     // 衝突回数
  long long h;     // ハッシュ値

  key = getKey(str);   // 文字列を数値に変換

  for (i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if ( strcmp(H[h], str) == 0)  // ハッシュ表に str が格納されているか
      return 1;
    else if (strlen(H[h]) == 0) {  // ハッシュ表が 空でないか
      strcpy(H[h], str);
      return 0;
    }
  }

  return 0;



}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



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

signed main(void)
{
	long long sum_a, sum_b, diff;
	int n;
	cin >> n;
	int a[n], b[n];

	sum_a = sum_b = 0;
	rep(i, n) 
	{
		cin >> a[i];
		sum_a += a[i];
	}
	rep(i, n) 
	{
		cin >> b[i];
		sum_b += b[i];
	}
	diff = 0;
	rep(i, n)
	{
		if (a[i] < b[i])
		{
			diff += (b[i] - a[i]) / 2;
			if ((b[i] - a[i]) % 2 != 0)
				diff++;
		}
	}
	if (diff <= sum_b - sum_a)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

constexpr int max_n = 100005;

int N,u,v;
vector<vector<int>> G;
int p[max_n], d[max_n];

void dfs(int cur, int par,int dep){
    p[cur] = par;
    d[cur] = dep;
    for(auto nxt : G[cur]){
        if(nxt == par) continue;
        dfs(nxt, cur, dep+1);
    }
}

int dfs2(int cur){
    int ret = d[cur];
    for(auto nxt : G[cur]){
        if(nxt == p[cur]) continue;
        ret = max(ret, dfs2(nxt));
    }
    return ret;
}

int main(){
    cin >> N >> u >> v;
    u--; v--;
    G.resize(N);
    rep(i,N-1){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    dfs(v,-1,0);

    vector<int> lst;
    int now = u;
    while(now != v){
        lst.emplace_back(now);
        now = p[now];
    }
    lst.emplace_back(v);

    int root = lst[(d[u]-1)/2];
    int ud = d[root];
    int dst = dfs2(root);

    cout << (dst - ud) + (ud - 1) << endl;
}


Measured memory_bytes: 13564
import java.util.Scanner;

class Main {
    public static void main(String[] args) {

        Scanner scn = new Scanner(System.in);
        int x[];
        x = new int[26];

        while (scn.hasNext()){
            String str = scn.next();
            str = str.toLowerCase();
            for(int i = 0; i < str.length(); i++){
                char chr = str.charAt(i);
                if((chr - 'a') >= 0 && (chr - 'a') < 26){
                    x[chr - 'a']++;
                }
            }
        }
        for(char moji = 'a'; moji <= 'z'; moji++){
            System.out.println(moji + " : " + x[moji - 'a']);
        }
    }
}


Measured memory_bytes: 26208
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if (a < b && b < c) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  VI A(N+1),B(N);
  rep(i,N+1) cin>>A[i];
  rep(i,N) cin>>B[i];
  ll ans=0;
  rep(i,N){
    ans+=min(A[i],B[i])+min(A[i+1],B[i]-min(A[i],B[i]));
    A[i+1]-=min(A[i+1],B[i]-min(A[i],B[i]));
  }
  cout<<ans<<endl;
}


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

int main(){
    ll n;
    cin >> n;
    vector<ll> ans;

    cout << n << ":";

    for(ll i = 2; i*i <= n; i++){
        while(n % i == 0){
            ans.emplace_back(i);
            n /= i;
        }
    }
    if(n != 1) ans.emplace_back(n);
    
    sort(ans.begin(), ans.end());
    
    for(auto a : ans){
        cout << ' ' << a ;
    }
    cout << endl;
}


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

using namespace std;

int n;
string s;

void rec(int i, char mx) {
	if (i == n - 1) {
		cout << s << endl;
		return;
	}
	for (char c = 'a'; c <= mx + 1; ++c) {
		s[i + 1] = c;
		rec(i + 1, max(mx, c));
	}
}

int main() {
	cin >> n;
	s.assign(n, ' ');
	s[0] = 'a';
	rec(0, 'a');
	return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>

int main() {

int al[30] = {0};
char b[2000]= {0};
int i,j,n;

i=0;

while( scanf("%c",&b[i]) != EOF) {

if (b[i] >= 'A' && 'Z' >= b[i] ) {
n = b[i] - 'A';
al[n] += 1;

} else if(b[i] >=  'a' && b[i] <= 'z' ) {
n = b[i] - 'a';
al[n] += 1;
}
i=i+1;
}

for(j=97; j<=122; j++) {
n = j - 'a';
printf("%c : %d\n",j,al[n]);
}

return 0;

}


Measured memory_bytes: 2076
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
bool check(string s, int l, int r){
	while(l < r){
		if(s[l] != s[r]) return false;
		l++;
		r--;
	}
	return true;
}
int main() {
    string s;
    cin >> s;
    int len = s.size();
    bool x = check(s, 0, len - 1);
    bool y = check(s, 0, (len - 1) / 2 - 1);
    bool z = check(s, (len + 3) / 2 - 1, len - 1);
    if(x && y && z) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
} 

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

over = 0
loss = 0
c = []
for i in range(N):
    d = B[i] - A[i]
    if d > 0:
        loss += d
    else:
        over -= d
        c += [-d] 
   
c.sort()
amari = over - loss
cnt = 0
for i in range(len(c)):
    if c[i] > amari:
        break
    else:
        amari -= c[i]
        cnt += 1
        
        
if over >= loss:
    print(N-cnt)
else:
    print(-1)
        

Measured memory_bytes: 19068
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------



int main() {
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    cout<<(h2-h1)*60+(m2-m1)-k<<endl;
}


Measured memory_bytes: 3632
/*...Part - 01...*/

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <iterator>
#include <bitset>
#include <assert.h>
#include <new>
#include <sstream>
//#include <bits/stdc++.h>
using namespace std ;

/*...Part - 02...*/

typedef long long               ll ;
typedef long double             ld ;
typedef unsigned long long      ull ;
typedef pair<int,int>           pii ;
typedef pair<ll,ll>             pll ;
typedef vector<int>             vi ;
typedef vector<ll>              vll ;
typedef vector<vector<int>>     vvi ;

int Int(){int x ; scanf("%d",&x) ; return x ;}
ll Long(){ll x ; scanf("%lld",&x) ; return x ;}

/*...Part - 03...*/
/*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/*...Part - 04...*/
/*...Needed to change according to problem requirements...*/

const int N          = (int)1e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;

/*..........................................................*/
/*...Part - 05...*/

#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     Int         Int()
#define     Long        Long()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)

/*...Part - 06...*/
/*...... ! Code start from here ! ......*/

ll dp[102][N] ;

int main(){
    int test = 1 , tc = 0 ;
    while(test--){
        int n = Int, w = Int ;
        vi a(n + 1), b(n + 1) ;
        for(int i = 1 ; i <= n ; ++i){
        	a[i] = Int, b[i] = Int ;
        }
        for(int i = 1 ; i <= n ; ++i){
        	for(int j = 0 ; j <= w; ++j){
        		if(a[i] <= j)dp[i][j] = max(dp[i - 1][j - a[i]] + b[i], dp[i - 1][j]) ;
        		else dp[i][j] = dp[i - 1][j] ;
        	}
        }
        cout << dp[n][w] << '\n' ;
    }
    return 0 ;
}

/*...Always look at the part - 04...*/
/*...............END................*/




Measured memory_bytes: 78336
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n){
    cin >> a[i];
  }
  int l=0, r=1e9;
  while(l+1<r){
    int x=(r+l)/2;
    ll now=0;
    rep(i, n){
      now+=(a[i]-1)/x;
    }
    if(now<=k){
      r=x;
    } else {
      l=x;
    }
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 4048
#include<iostream>
using namespace std;
int main(){
int x,y;
for(int i=0;i<3000;i++){
cin>> x >> y;
if(x == 0 && y == 0)break;
if(x > y){
cout << y << " " << x << endl;
}
if(x < y){
cout << x << " " << y << endl;
}
if(x==y){
cout << y << " " << x << endl;
}
}
return 0;
}


Measured memory_bytes: 3000
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>

using namespace std;  //このネームスペースを使う

int main(){
  int H,W;
  int h,w;
  cin >> H >> W;
  cin >> h >> w;

  cout << H*W - H*w - h*W + h*w << endl;

  return 0;
}



Measured memory_bytes: 256