akhauriyash/Code-Regression huggingface dataset:
$N = <STDIN>+0;
$line = <STDIN>;
@T = split " ", $line;
$line = <STDIN>;
@V = split " ", $line;

push @T,1;
push @V,0;
$N+=1;

$sumT=0;
for($i=0;$i<$N;$i++){
 $TT[$i]=$sumT;
 $sumT += $T[$i];
}

$v=0;$x=0;$t=0;$it=0;
while($t<$sumT-1) {
	$f=0;
	if ($TT[$it]<=$t) { $it+=1; }
	for($i=$it;$i<$N;$i++){
		if ( $v-($TT[$i]-$t)*1>=$V[$i] ) {
			$f=1; last;
		}
	}
	if ($f) {
		$x=$x+$v/2-0.25; $v=$v-0.5;
	} elsif ($v>=$V[$it-1]) {
		$x=$x+$v/2;
	} else {
		$x=$x+$v/2+0.25; $v=$v+0.5;
	}
	$t=$t+0.5;
}
print "$x\n";


Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

ll inq(ll x, ll y, ll mod)
{
    if (y == 0) return 1;
    ll l = inq(x, y / 2, mod);
    if (y % 2) return l * l % mod * x % mod;
    return l * l % mod;
}

ll rev(ll x, ll mod)
{
    return inq(x, mod - 2, mod);
}

inline int nextInt()
{
    int x = 0;
    char c = getchar();
    int mi = (c == '-');
    if (c == '-') c = getchar();
    while ('0' <= c && c <= '9')
    {
        x = 10 * x + c - '0';
        c = getchar();
    }
    if (mi) return x * -1;
    return x;
}

S s;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    int ans = s.size();
    for (int i = 0; i + 1 < s.size(); i++)
    {
        if (s[i] != s[i + 1])
        {
            int l = i + 1;
            int r = s.size() - l;
            ans = min(ans, max(l, r));
        }
    }
    cout << ans;
}

Measured memory_bytes: 512
n, W = map(int, input().split())
wv = []
for i in range(n):
    wv.append(list(map(int, input().split())))
num = wv[0][0]
dp = [[-float("inf") for i in range(3 * (n - 1) + 1)] for j in range(n + 1)]
dp[0][0] = 0
for i in range(n):
    w, v = wv[i][0], wv[i][1]
    w -= num
    for j in range(n - 1, -1, -1):
        for k in range(3 * (n - 1) + 1 - w):
            dp[j + 1][k + w] = max(dp[j + 1][k + w], dp[j][k] + v)
ans = 0
for i in range(3 * (n - 1) + 1):
    for j in range(n + 1):
        if j * num + i <= W:
            ans = max(ans, dp[j][i])
print(ans)

Measured memory_bytes: 74412
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int a[310], dp[2][310][310];
 
signed main() {
    int N, K; cin >> N >> K;
    rep(i,0,N) cin >> a[i];

    dp[0][0][0] = 1;
    rep(i,0,N) {
        int cur = i%2, nxt = cur ^ 1;
        rep(j,0,300) rep(k,0,300) {
            if(!dp[cur][j][k]) continue;

            // 取る
            (dp[nxt][j+1][k^a[i]] += dp[cur][j][k] * (j + 1)) %= MOD;

            // 取らない
            (dp[nxt][j][k] += dp[cur][j][k]) %= MOD;

            dp[cur][j][k] = 0;
        }
    }

    int ans = 0;
    rep(i,0,300) {
        (ans += dp[N%2][i][K]) %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
n,m,v,p = map(int,input().split())
A = list(map(int,input().split()))

A.sort()
C = [0] * (n+1)
for i in range(n):
  C[i+1] = C[i] + A[i]
  
ans = 0
for i in range(n):
  x = A[i] + m
  if x < A[-p]:
    continue
  if (v-p-i) > 0:
    u = (v-p-i) * m
    if u <= x * (n-p-i) - C[n-p+1] + C[i+1]:
      ans += 1
  else:
    ans += 1
    
print(ans)

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

int main() {
  int N, C, c, S = 30, s;
  cin >> N;
  vector<int> A(N);

  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    s = A.at(i);
    c = 0;
    while (s % 2 == 0) {
      s = s / 2;
      c = c + 1;
    }
    S = min(S, c);
  }
  
  cout << S << endl;

}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

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

void solve(){
	long n = rlong;
	if(n % 2) "0".writeln;
	else{
		long a;
		for(long m = 5; m <= n; m *= 5) a += n / (2 * m);
		a.writeln;
	}
}

/*
 nが奇数のときは0
 nが偶数のときはn以下の偶数の5の倍数の個数（重複度込み）（2はふんだんにあるので）
 それは
*/

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const long long INF = 1e12;
string getstring(int a){
    string s = "";
    for(int i = 0;i<10;i++){
        if(a%2==0) s+='0';
        else s+='1';
        a/=2;
    }
    return s; 
}
int match(string s,int f[]){
    int t = 0;
    rep(i,10){
        if((s[i]-'0')==f[i] && f[i]==1) t++;
    }
    return t;
}
int main(){
    int n;
    cin >> n;
    int f[n][11];
    rep(i,n){
        rep(j,10){
            cin >> f[i][j];
        }
    }
    long long p[n][11];
    rep(i,n){
        rep(j,11){
            cin >> p[i][j];
        }
    }
    long long ans = -INF;
    long long tmp;
    string s;
    int c[n];
    for(int i = 1;i<1024;i++){
        tmp = 0;
        s = getstring(i);
        rep(j,n){
            c[j] = match(s,f[j]);
        }
        rep(j,n){
            tmp+=p[j][c[j]];
        }
        ans = max(tmp,ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
   int M;
   cin >> M;
   long long d[M];
   long long c[M];
   long long sum = 0;
   long long ans = 0;
   for(int i = 0 ; i < M; i++){
      cin >> d[i] >> c[i];
      sum+= d[i]*c[i];
      ans+=c[i];
   }
   cout << ans-1+(sum-1)/9<<endl;
   return 0;
}


Measured memory_bytes: 6692
#include <iostream>
#include <vector>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
using ll = long long;
using namespace std;

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n, tmp;
    cin >> n;
    ll ans=0;
    
    vector< ll > ret = divisor(n);

    ret.erase(ret.begin());

    for(ll i : ret){
        tmp = n;
        while (tmp % i == 0){
            tmp = tmp/i;
        }
        if (tmp % i == 1){
            ans ++;
        }
    }

    ans += divisor(n - 1).size() - 1;

    cout << ans;

    
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
typedef pair<int, int>P;

int main() {
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	int account[100010];
	for (int i = 0; i < n; i++) {
		account[i] = 0;
	}
	account[0] = 0;
	for (int i = 1; i < n; i++) {
		if (s[i-1] == 'A'&&s[i] == 'C') {
			account[i] += account[i - 1] + 1;
		}
		else {
			account[i] = account[i - 1];
		}
	}
	int l, r;
	vector<int>ans;
	for (int i = 0; i < q; i++) {
		cin >> l >> r;
		ans.push_back(account[r - 1] - account[l - 1]);
	}
	for (int i = 0; i < q; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1912
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <map>
#include <cmath>
#include <bitset>
#include <string>

using namespace std;

#define int long long

signed main() {
    int x;
    cin >> x;

    int ans = (x / 500) * 1000 + ((x % 500) / 5) * 5;
    
    cout << ans << endl;
    return 0;
}

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

void solve(int D, int T, int S)
{
    if(float(S)>=(float(D)/T))
        cout<<"Yes";
    else
        cout<<"No";
}

int main()
{
    int d,t,s;
    cin>>d>>t>>s;
    solve(d,t,s);
    return 0;
}


Measured memory_bytes: 3592
/**
*    author:  boutarou
*    created: 25.07.2020 20:58:38
**/

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

int main() {
    int x;
    cin >> x;
    if (x % 200 == 0){
        cout << (2000 - x) / 200 << endl;
    }
    else cout << (2000 - x) / 200 + 1 << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	long N;
	cin >> N;
	
	vector<long> a(N + 1);
	for (int i = 0; i < N; i++)
	{
		cin >> a[i + 1];
	}
	
	vector<long> b(N + 1);
	
	// 大きい倍数から処理する
	for (long i = N; i >= 1; i--)
	{
		int sum = 0;
		
		// i以外の倍数をの総和
		for (int j = i + i; j <= N; j += i)
		{
			sum += b[j];
		}
		
		sum %= 2;
		// ボールの総数を2で割った余りの数がa[i]でない場合に
		if (sum != a[i])
		{
			// 現在のiの箱にボールをいれます。
			b[i] = 1;
		}
	}
	
	vector<long> answer;
	
	// 1の倍数からNの倍数の箱
	for (long i = 1; i <= N; i++)
	{
		// ボールがある場合
		if (b[i])
		{
			// ボールを入れる箱に書かれた整数を格納する
			answer.push_back(i);
		}
	}
	
	// 出力
	cout << answer.size() << endl;
	for (int i = 0; i < answer.size(); i++)
	{
		cout << answer[i] << endl;
	}
	
	return 0;
}

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

int main(void) {
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0; i<n; i++) {
    cin >> p.at(i);
  }
  int ans=0;
  for(int i=1; i<n-1; i++) {
    if(p.at(i-1) < p.at(i) && p.at(i) < p.at(i+1)) {
      ans++;
    }
    else if(p.at(i+1) < p.at(i) && p.at(i) < p.at(i-1)){
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main(){
    int l, i, al[120] = {};
    char s[2048] ={};
    while(scanf("%s", s) != EOF){
        l = strlen(s);
        for(i = 0;i < l;i++) if('A' <= s[i] && 'Z' >= s[i]) s[i] += 'a' - 'A';
        for(i = 0;i < l;i++) if('a' <= s[i] && s[i] <= 'z') al[s[i] - 'a']++;
    }
    for(i = 0;i < 26;i++)
        printf("%c : %d\n", i + 'a', al[i]);
    return 0;
}



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

const ll INF = 1LL << 60;

ll N, X;
// a: 総数
// p: レベル iにあるパティの枚数
vector<ll>a, p;

ll f(ll L, ll X) {
    // cout << L << " " << X << endl;
    if (L == 0) {
        if (X <= 0) return 0;
        return 1;
    }

    ll mid = (a[L] + 1) / 2;

    if (mid < X) {
        // 真ん中より大きい
        return p[L - 1] + 1 + f(L - 1, X - mid);
    } else if (mid == X) {
        // ちょうど真ん中
        return p[L - 1] + 1;
    } else {
        // 真ん中未満
        return f(L - 1, X - 1);
    }
}

int main() {
    cin >> N >> X;
    a.resize(N + 1);
    p.resize(N + 1);

    a[0] = 1;
    p[0] = 1;

    for (int i = 0; i < N;  i++) {
        a[i + 1] = 2 * a[i] + 3;
        p[i + 1] = 2 * p[i] + 1;
    }

    ll ans = f(N, X);
    cout << ans << endl;
    // rep(i, N + 1) {
    //     cout << a[i] << " ";
    // }
    // cout << endl;

    // rep(i, N + 1) {
    //     cout << p[i] << " ";
    // }
    // cout << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++)
        cin >> L[i];

    sort(L.begin(), L.end());

    long long res = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int max = L[i] + L[j];
            int min = abs(L[i] - L[j]);
            int lower = int(upper_bound(L.begin(), L.end(), min) - L.begin());
            int upper = int(lower_bound(L.begin(), L.end(), max) - L.begin() - 1);
            int included = 0;
            if (L[i] >= L[lower] && L[i] <= L[upper]) included++;
            if (L[j] >= L[lower] && L[j] <= L[upper]) included++;

            if (upper - lower > 0) {
                res += upper - lower - included + 1;
            }
        }
    }
    cout << res / 3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  if(x<=y)
    cout<<min(a+b,c*2)*x+min(b,c*2)*(y-x)<<endl;
  else
    cout<<min(a+b,c*2)*y+min(a,c*2)*(x-y)<<endl;
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#else
        #define debug(...) 4
        #define input 4
#endif

using ll = long long;
constexpr int N = 2e5+ 5;
constexpr int mod = 1e9 + 7;

int main() {
    input;
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n;
    cin >> n;
    map<string, int> f;
    f["AC"];
    f["TLE"];
    f["RE"];
    f["WA"];
    while(n--) {
        string s;
        cin >> s;
        f[s]++;
    }
    string ans[4];
    for(auto it : f) {
        if(it.first == "AC")
            ans[0] = it.first + " x " + to_string(it.second);
        if(it.first == "WA")
            ans[1] = it.first + " x " + to_string(it.second);
        if(it.first == "TLE")
            ans[2] = it.first + " x " + to_string(it.second);
        if(it.first == "RE")
            ans[3] = it.first + " x " + to_string(it.second);
                

        // cout << it.first << " ";
        // cout << "x ";
        // cout << it.second << "\n";
    }
    cout << ans[0] << "\n" << ans[1] << "\n" << ans[2] << "\n" << ans[3] << "\n";
}




Measured memory_bytes: 3704
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int ans = 1e9;

int32_t main(){_
    //freopen("input","r",stdin);
    string s;
    cin >> s;
    auto check = [](string s)
    {
        for(int i = 1;i < sz(s);i++)
        {
            if(s[i] != s[i - 1]) return false;
        }
        return true;
    };
    string tmp = s;
    for(char c = 'a';c <= 'z';c++)
    {
        int x = 0;
        s = tmp;
        while(!check(s))
        {
            x ++;
            for(int i = 0;i < s.size() - 1;i++)
            {
                if(s[i + 1] == c) s[i] = c;
            }
            s.erase(sz(s) - 1,1);
        }
        ans = min(ans,x);
    }  
    rc(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
#define MOD ((int)1e9+7)
#define N ((int)2e3+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

int ans, n,x,y, v[N];

void solve(){
    scanf("%d%d%d", &n, &x, &y);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j)continue;
            ans = min(min(abs(i-j),abs(i-x)+abs(j-y)+1),abs(i-y)+abs(j-x)+1);
            v[ans]++;
            //printf("%d %d %d\n",i,j,ans);
        }
    }
    for(int i=1;i<n;i++)printf("%d\n",v[i]>>1);
}

int main(){
    ios_base::sync_with_stdio(0);
    int t = 1; //scanf("%d",&t);
    for(int caso=1;caso<=t;caso++){
        solve();
    }
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct edge{int to, cost;};

const int MAX_V = 100000;
vector<edge> es[MAX_V];
vector<int> col(MAX_V, -1);

void dfs(int now, int pre){
    for(auto &e: es[now]){
        if(e.to == pre) continue;
        col[e.to] = col[now]^e.cost;
        dfs(e.to, now);
    }
}

int main(){
    int N;
    cin >> N;
    rep(i, N-1){
        int u, v, w; cin >> u >> v >> w; u--, v--, w &= 1;
        es[u].eb((edge){v, w}), es[v].eb((edge){u, w});
    }
    col[0] = 0;
    dfs(0, -1);
    rep(i, N) cout << col[i] << endl;
}

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 2e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

int main()
{
	ll a, b, k;
	cin>>a>>b>>k;
	ll z = k - a;
	if(z <= 0)
	{
		a = a - k;
		cout<<a<<" "<<b<<endl;
	}
	else
	{
		b = b- z;
		cout<<0<<" "<<max(0LL, b)<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef pair<ll,pi> pii;
typedef vector<pi> vpi;
typedef set<ll> si;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define f first
#define s second
ll INF = 1e9;
ll MOD = 1e9;
#define lb lower_bound
#define ub upper_bound
#define SZ(x) (ll)x.size()
#define ALL(x) x.begin(),x.end()

int N,a,L,b,Q;
vi V;
int dst[100100][18];

int query(int x, int y){
  int ans = 0;
  for (int i=17;i>=0;--i){
    if (dst[x][i] == -1 || dst[x][i] > y)continue;
    x = dst[x][i];
    ans += (1<<i);
    if (x == y)return ans;
  } 
  return ans + 1;
}

int main(){
  // freopen("in.txt","r",stdin);
  cin >> N;
  for (int i=0;i<N;++i){
    cin >>a ;
    V.pb(a);
  }
  V.pb(INF);
  cin >> L;
  memset(dst, -1, sizeof(dst));
  for (int i=0;i<N;++i){
    int t = V[i]+L;
    int x = ub(ALL(V), t)  - V.begin() - 1;
    if (i != x)dst[i][0] = x;
  }
  // for (int i=0;i<N;++i)cout<<dst[i][0]<<' ';cout<<'\n';
  for (int i=1;i<18;++i){
    for (int j=0;j<N;++j){
      if (dst[j][i-1] != -1)dst[j][i] = dst[ dst[j][i-1] ][i-1];
    }
  }
  // for (int i=0;i<4;++i){
    // for (int j=0;j<=N;++j)cout<<dst[j][i]<<' ';cout<<'\n';
  // }
  cin >> Q;
  while (Q--){
    cin >>a >> b;
    --a;--b;
    if (a > b)swap(a,b);
    cout<<query(a,b)<<'\n';
  }
}


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

#define co(x) cout << x << endl ;

int main ()
{
    int num ;
    string col ;

    cin >> num ;
    cin >> col ;

    if (num < 3200)
    {
        col = "red" ;
    }

    co (col)

    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*
	__________   _____     _________   __            __    __________    ________     _________
	----------  | ----\    ---------   \ \   		/ /    |  _______|	| _____  \    ---------
		||      ||    ||  	  ||		\ \		   / /	   | |			| |		\ \	     ||
		||      ||____//      ||		 \ \      / /	   | |_____ 	| |		 | |	 ||
		||      |__ __/       ||		  \ \    / /	   | _____|		| |		 | |	 ||
		||      || \\         ||		   \ \  / /	   	   | |			| |		 | |	 ||
		||      ||  \\     ___||____        \ \/ /         | |_______ 	| |_____/ /   ___||____
		||		|| 	 \\    _________         \__/		   |_________|	|________/	  _________
*/
/********************************************************************/
/*
Codeforces : @a.trivedi
Codechef   : @adityat25
HackerRank : @adityatrivedi

/********************************************************************/
#define M1 1000000007
#define M3 1000000009
#define M2 998244353
#define ll long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
/********************************************************************/
const double pi = 3.1415926535;
/********************************************************************/
//FAST IO//
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
/********************************************************************/

int main() {
	FAST();
	ll  n, x;
	cin >> n >> x;
	vector<ll > price(n), pages(n);
	for (int i = 0; i < n; i++) {
		cin >> price[i] >> pages[i];
	}
	// for (ll &v : price) cin >> v;
	// for (ll &v : pages) cin >> v;
	vector<vector<ll >> dp(n + 1, vector<ll >(x + 1, 0));
	for (ll  i = 1; i <= n; i++) {
		for (ll  j = 0; j <= x; j++) {
			dp[i][j] = dp[i - 1][j];
			ll  left = j - price[i - 1];
			if (left >= 0) {
				dp[i][j] = max(dp[i][j], dp[i - 1][left] + pages[i - 1]);
			}
		}
	}
	cout << dp[n][x] << endl;
	return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    cout << a+b+c << endl;

    return 0;
}


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

string s, g;

int proc(string t, char x) {
	bool y = 0;
	for (int i = 0; i < t.length(); ++i)
		if (t[i] == x)
			y = 1;
	if (y == 0)
		return 100;
	y = 0;
	for (int i = 0; i < t.length(); ++i)
		if (t[i] != x)
			y = 1;
	if (y == 0)
		return 0;

	g = "";
	for (int i = 0; i < t.length()-1; ++i) {
		if (t[i] == x || t[i+1] == x)
			g += x;
		else
			g += t[i];
	}

	return 1+proc(g, x);
}

int main() {
	cin >> s;
	int mini = 500;
	for (char x = 'a'; x <= 'z'; ++x)
		mini = min(mini, proc(s, x));
	cout << mini << endl;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    int ans=a[0];
    for(int i=1;i<n;i++){
        if(a[i]>a[i-1])ans+=a[i]-a[i-1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

#define MOD 1000000007

int main()
{
	ios::sync_with_stdio(false);

	ll n;
	cin >> n;
	vector<ll> f(n+1,0);
	
	f[n] = 1;
	f[n-1] = n;
	
	ll sf = f[n-1] + f[n];
	for(int i=(int)n-2; 0<=i; --i)
	{
		//f[i] = sf-f[i+1] + (n-1)*(n-1) + f[i+1];
		//f[i] = (sf + (n-1)*(n-1)) % MOD;
		f[i] = sf-f[i+1]-f[i+2] + (i+1)   + (n-1)*(n-1) + f[i+1] + MOD*2;
		f[i] %= MOD;
		sf = (sf + f[i]) % MOD;
	}
	
	ll ans = f[0];
	cout << ans%MOD << "\n";
	
	return 0;
}


Measured memory_bytes: 8064
#include <stdio.h>

typedef struct Vector{
  double x;
  double y;
}Vec;

Vec sub_vector(Vec *a, Vec *b)
{
  Vec ret;
  ret.x = a->x - b->x;
  ret.y = a->y - b->y;
  return ret;
}

int main(void)
{
  double x1[100], x2[100], x3[100], y1[100], y2[100], y3[100], xp[100], yp[100];
  int i = 0;
  int count;

  while((scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1[i], &y1[i], &x2[i], &y2[i], &x3[i], &y3[i], &xp[i], &yp[i])) != EOF){
      if(-100.0 <= x1[i] && 100.0 >= x1[i] && -100.0 <= y1[i] && 100.0 >= y1[i] && -100.0 <= x2[i] && 100.0 >= x2[i] && -100.0 <= y2[i] && 100.0 >= y2[i] &&-100.0 <= x3[i] && 100.0 >= x3[i] && -100.0 <= y3[i] && 100.0 >= y3[i] && -100.0 <= xp[i] && 100.0 >= xp[i] && -100.0 <= yp[i] && 100.0 >= yp[i])
      i++;
    if(100 <= i) break;
    count = i;
  }

  for(i = 0; i < count; i++){
   Vec A = {x1[i], y1[i]};
   Vec B = {x2[i], y2[i]};
   Vec C = {x3[i], y3[i]};
   Vec P = {xp[i], yp[i]};

   Vec AB = sub_vector(&B, &A);
   Vec BP = sub_vector(&P, &B);

   Vec CA = sub_vector(&A, &C);
   Vec AP = sub_vector(&P, &A);

   Vec BC = sub_vector(&C, &B);
   Vec CP = sub_vector(&P, &C);

    double c1 = AB.x * BP.y - AB.y * BP.x;
    double c2 = CA.x * AP.y - CA.y * AP.x;
    double c3 = BC.x * CP.y - BC.y * CP.x;

    if(c1 > 0 && c2 > 0 && c3 > 0 || c1 < 0 && c2 < 0 && c3 < 0)
      printf("YES\n");
    else 
      printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 620
import numpy as np
n,D=map(int,input().split())
a = [input().split() for l in range(n)]
c=0
d=0
for i in range(n):
  for j in range(i+1,n):
    d=0
    for t in range(D):
      d=d+(int(a[i-1][t-1])-int(a[j-1][t-1]))**2
    if np.sqrt(d)%1==0:
      c=c+1
print(c)

Measured memory_bytes: 12468
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            var s = ReadLine().Split(' ').Select(int.Parse).ToArray();

            int ans = 0;
            int tmp = 0;
            for (int i = 0; i < n-1; i++)
            {
                if (s[i] >= s[i + 1])
                {
                    tmp++;
                    ans = Max(tmp, ans);
                }
                else tmp = 0;
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28252
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<utility>
#include<climits>
#define ll long long int 
using namespace std;
int main()
{ 
   ll n,W;
   cin>>n>>W;
   
   vector< pair<ll,ll> >v;
   
   for(int i=0;i<n;i++)
   {
   	ll x,y;
   	cin>>x>>y;
   	
   	v.push_back(make_pair(x,y));
   }
   
   sort(v.begin(),v.end());
//   cout<<endl;
//   for(int i=0;i<n;i++)
//   {
//   	cout<< v[i].first<<" "<<v[i].second<<endl;
//   }


ll d[n][W+1];
for(int i=0;i<=W;i++)
{
	/////cout<<v[0].first<<"**"<<i<<"**"<<v[0].second<<"@@@@@@@@@@";
	if(v[0].first<=i)
	{
		d[0][i]=v[0].second;
	}
	else
	{
		d[0][i]=0;
	}
//	cout<<d[0][i]<<"   ";
	
	
}

//cout<<endl<<endl;


for(int i=1;i<n;i++)
{
	
	for(int j=0;j<=W;j++)
	{
		if(v[i].first<=j)
		{
			d[i][j]=max(d[i-1][j],v[i].second+d[i-1][j-v[i].first]);
		}
		else
		d[i][j]=d[i-1][j];
	}
}
//for(int i=0;i<n;i++)
//{
//	for(int j=0;j<=W;j++)
//	cout<<d[i][j]<<"  ";
//	cout<<endl;
//}
cout<<d[n-1][W];   
	
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N, D;
    cin >> N;
    vector<int> X(N), Y(N);
    cin >> D;
    REP (i, N) {
        cin >> X[i] >> Y[i];
        if (X[i]*X[i]+Y[i]*Y[i]<=D*D) ans++;
   }
   cout << ans << endl;
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc174/abc174_b && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc174/abc174_b && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc174/abc174_b && sh shellscripts/submit_cpp.sh
*/


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

int main() {
    string ans = "NO";
    int A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    if(V >= W) {
        long long L = abs(A - B);
        long long v = abs(V - W);
        if(L <= v * T)
            ans = "YES";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
N, M = map(int, input().split())
if 2 * N > M:
  print(M // 2)
else:
  C = M // 2
  n = (C - N) // 2
  print(max(min(N+n-1, C-n+1), min(N+n, C-n), min(N+n+1, C-n-1)))


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    int ans = 0;
    while (n > 0)
    {
        if (ans == 0)
        {
            ans++;
            n -= k;
        }
        else
        {
            ans++;
            n -= (k - 1);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(void){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];
  int even = 0;
  for(int i = 0; i < n; i++) if(a[i] % 2 == 0) even++;
  int ans = pow(3, n) - pow(2, even);
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> P;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N;
P A[500000];

bool compare_y(P a, P b){ return a.second < b.second;}

int closest_pair(P *a, int n){
  if(n<=1) return INF;
  int m = n/2;
  int x = a[m].first;
  int d = min(closest_pair(a, m), closest_pair(a + m, n-m));
  inplace_merge(a, a + m, a + n, compare_y);

  vector<P>b;
  for(int i=0;i<n;i++){
    if(fabs(a[i].first - x) >= d) continue;

    for(int j=0;j<b.size();j++){
      int dx = a[i].first - b[b.size()-j-1].first;
      int dy = a[i].second - b[b.size()-j-1].second;
      if(dy >= d) break;
      d = min(d, SQ(dx) + SQ(dy));
    }
    b.push_back(a[i]);
  }
  return d;
}

int main(){
  scanf("%d", &N);
  int x,y;
  rep(i, N){
    scanf("%d%d", &x, &y);
    A[i].first = x; A[i].second = y;
  }
  
  sort(A, A + N);
  printf("%d\n", closest_pair(A, N));
  return 0;
}

Measured memory_bytes: 10692
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;

int main() {
    ll X;
    cin>>X;
    ll A, B;
    ll tmp;
    ll l, r, m;
    bool minus;
    for(ll i=0;i<10000;++i){
        tmp = i*i*i*i*i - X;
        if(tmp==0){
            A = i;
            B = 0;
            break;
        }
        if(tmp>0) minus = false;
        else {
            minus = true;
            tmp = -tmp;
        }
        l = 0;
        r = 1000;
        while(l<r){
            m = (l+r)/2;
            if(tmp==m*m*m*m*m){
                l = m;
                break;
            }
            else if(tmp > m*m*m*m*m){
                l = m+1;
            }
            else{
                r = m;
            }
        }
        if(tmp==l*l*l*l*l){
            A = i;
            if(minus) B = -l;
            else B = l;
            break;
        }
    }
    cout<<A<<" "<<B<<endl;
}



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

long long GCD(long long m, long long n){
    long long tmp;
    while (m % n != 0){
        tmp = n;
        n = m % n;
        m = tmp;
    }
    return n;
}

long long LCM(long long A, long long B){
    long long ans;
    if (A < B){
        ans = A * B / GCD(B, A);
    } else{
        ans = A * B / GCD(A, B);
    }
    return ans;
}

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

    long long ans = 0;
    ans = LCM(A, B);

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


Measured memory_bytes: 256
import sys
temp=list(map(int, input().split()))
N=temp[0]
A=temp[1]
B=temp[2]
cnt=0
if (B-A)%2==1:
  if A-1<=N-B:
    cnt=A
    B-=A
    A=1
  else:
    cnt=N-B+1
    A+=(N-B)+1
    B=N
if A!=B:
  cnt+=(B-A)//2
print(cnt)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)

/*
上から順に決めれそう
*/

bool ok=true;
ll n,a[200010],b[200010];
vector<ll> fact[200010],ans;

void factoring(ll n,vector<ll> v[]){
	ll visit[300010]={};
	reg(i,2,n){
		if(visit[i]==0){
			reg(j,1,n){
				if(j*i>n)break;
				visit[i*j]=1;
				v[i*j].push_back(i);//素因数リスト（重複は含まず）
			}
		}
	}
}

void init(){
	cin>>n;
	reg(i,1,n)cin>>a[i];
	// factoring(n,fact);
}

int main(void){
	init();
	ireg(i,1,n){
		if(a[i]==1){
			ans.push_back(i);
			reg(j,1,i){
				if(j*j>i)break;
				if(i%j!=0)continue;
				if(j==i/j){
					a[j]=1-a[j];
				}else{
					a[j]=1-a[j];
					a[i/j]=1-a[i/j];
				}
			}
		}
	}
	ireg(i,1,n)if(a[i]==1)ok=false;
	if(ok){
		cout<<ans.size()<<endl;
		rep(i,ans.size())cout<<ans[i]<<" ";
		cout<<endl;
	}else{
		cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 9716
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a , b , c , d;
  cin >> a >> b >> c >> d;
 
  if ( a + b > c + d ) {
    cout << "Left" << endl;
  }  
  else if ( a + b < c + d ) {
    cout << "Right" << endl;
  }
  
  else
    cout << "Balanced" << endl;
}

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

#define N 55555

int prime[N];

void Eratosthenes(int n) {
    for (int i = 0; i < N; i++) {
        prime[i] = 1;
    }
    for (int i = 2; i < sqrt(N); i++) {
        if (prime[i]) {
            for (int j = 0; i * (j + 2) < N; j++) {
                prime[i * (j + 2)] = 0;
            }
        }
    }

    for (int i = 2; i < N; i++) {
        if (prime[i]) {
            if (i%5 == 1) {
                cout << i << " ";
                n--;
            }
        }
        if (n == 0) {
            cout << endl;
            break;
        }
    }
}
int main() {
    int n;
    cin >> n;
    Eratosthenes(n);
}

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


int main()
{
    int n;
    cin >> n;
    vector<int> a;
    vector<int> b;
    vector<int> c;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}
    rep(i, n){ int tmp; cin >> tmp; b.push_back(tmp);}
    rep(i, n - 1){ int tmp; cin >> tmp; c.push_back(tmp);}

    int ans = 0;
    rep(i, n){
        ans += b[i];
        if (i != 0 && a[i] - a[i - 1] == 1){
            ans += c[a[i - 1] - 1];
        }
    }
    cout << ans << endl;

}



Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    int n, m, b;
    cin>>n>>m>>b;
    // vector<pair<int, int>> b;
    vector<int> xaxis(n+1, 0), yaxis(m+1, 0);
    map<pair<int, int>, int> mp;
    for(int i = 0; i <b; i++){
        int x, y;
        cin>>x>>y;
        mp[{x, y}]++;
        xaxis[x]++;
        yaxis[y]++;
    }
    ll ans = 1;
    pair<int, int> mx = {0, 0}, my = {0, 0};
    for(int i = 0; i <= n; i++){
        if(mx.first < xaxis[i]){
            mx = {xaxis[i], i};
        }
    }
    for(int i = 0; i <= m; i++){
        if(my.first < yaxis[i]){
            my = {yaxis[i], i};
        }
    }
    for(int i = 1; i <= m; i++)
        ans = max(ans, ll(mx.first+yaxis[i]-mp[{mx.second, i}]));
    
    for(int i = 1; i <= n; i++)
        ans = max(ans, ll(xaxis[i]+my.first-mp[{i, my.second}]));
    cout<<ans;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 61792
#include <bits/stdc++.h>
#include <stdlib.h>
#include <math.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

const double PI=3.14159265359;

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

    double NG=PI/2, OK=0;
    while(NG-OK>0.000000001){
        double MID=(NG+OK)/2;
        double taiseki;
        
        if(tan(MID)>b/a) taiseki=(b*b*a)/(2*tan(MID));
        else taiseki=(a*a*b)-(a*a*a*tan(MID)/2);
        if(taiseki>x) OK=MID;
        else NG=MID;
    }
    cout<<setprecision(10)<<OK*180/PI<<endl;

}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <tuple>
#include <algorithm>
//#include <cmath>
using namespace std;

const long MAXDOG = 1000000000000001; // 16桁

long exp26(int N){
    long res = 1;
    for(int i=0;i<N;i++){
        res = res*26;
    }
    return res;
}

int main(){

    // 1...12乗
    vector<long> arr(12,0);
    vector<long> arr2(12,0);
    arr[0] = 1;
    arr2[0] = 1;
    for(int i=1;i<12;i++){
        arr2[i] = exp26(i);
        arr[i] = arr[i-1] + arr2[i];
        //cout << arr[i] << endl;
    }
    //arr[0] = 1;

    long N;
    cin >> N;

    long stage_idx;
    long stage_num;
    for(int i=1;i<12;i++){
        if(N<arr[i]){
            stage_idx = i-1;
            stage_num = N - arr[i-1];
            break;
        }
    }

    //cout << stage_idx+1 << endl; // 出力は stage_idx+1 文字
    //cout << stage_num << endl; // 番号

    string result(stage_idx+1,'a');
    for(int i=0;i<=stage_idx;i++){
        // 各文字を決める
        int res=0;
        while(stage_num - arr2[stage_idx-i]>=0){
            stage_num -= arr2[stage_idx-i];
            result[i]++;
        }
    }

    cout << result << endl;

// jjddja

    
    return 0;
}

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

int main() {
  
  int N;
  cin >> N;
  
  int64_t a0=2, a1=1;
  
  for (int i=0;i<N/2;i++){
    a0 = a0+a1;
    a1 = a0+a1;
  }
  
  if (N%2==0) cout << a0 << endl;
  else cout << a1 << endl;
}


Measured memory_bytes: 256
(defun get-input-array (n)
  (let ((rst (make-array n)))
    (dotimes (i n)
      (setf (aref rst i) (read)))
    rst))

(defun main (h n)
  (let* ((input (get-input-array n))
        (remaining h)
        (rst "No"))
    (loop for i from (- n 1) downto 0
          do (setf remaining (- remaining (aref input i)))
             '(format t  "~A ~A ~A~%" i remaining n)
          if (<= remaining 0) do (progn (setf rst "Yes")
                                   (return))
          )
    rst))

(format t "~A~%" (main (read) (read)))


Measured memory_bytes: 57700
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a>b){
    swap(a,b);
  }
  if(b>c){
    swap(b,c);
  }
  if(a>b){
    swap(a,b);
  }
  cout<<c*10+a+b;
}

Measured memory_bytes: 256
chomp($s = <>);
chomp($n = <>);

$t = "";
@str = ();
for (split(//, $s)){
	if($t ne ""){
		if($_ eq substr($t,0,1)){
			$t .= $_;
		}else{
			push(@str, $t);
			$t = $_;
		}
	}else{
		$t = $_;
	}
}
push(@str, $t);

$cnt = 0;
if(scalar(@str) == 1){
	$cnt = int(length($s) * $n / 2);
}else{
	for $i (1 .. $#str - 1){
		$cnt += int(length($str[$i]) / 2);
	}
	$cnt = $cnt * $n;

	if(substr($str[0],0,1) eq substr($str[$#str],0,1)){
		$cnt += int((length($str[0]) + length($str[$#str])) / 2) * ($n - 1);
		$cnt += int(length($str[0]) / 2);
		$cnt += int(length($str[$#str]) / 2);
	}else{
		$cnt += int(length($str[0]) / 2) * $n;
		$cnt += int(length($str[$#str]) / 2) * $n;
	}

}

print "$cnt\n";



Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
 
int puzzle[4][4];
int tmp[4][4];
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
void empty(int *,int *);
int dfs(int,int,int,int,const int);
int cal();
void swap(int *,int *);
 
int main() {
    int i,j,n,x,y,l;
    for(i=0; i<4; i++) {
        for(j=0; j<4; j++) scanf("%d",&puzzle[i][j]);
    }
 
    empty(&x,&y);
    for(l=0; l<100; l++) {
        for(i=0; i<4; i++) {
            for(j=0; j<4; j++) tmp[i][j] = puzzle[i][j];
        }
 
        n = dfs(x,y,-1,0,l);
        if(n!=-1) {
            printf("%d\n",n);
            break;
        }
 
        for(i=0 ; i<4; i++) {
            for(j=0 ; j<4; j++) puzzle[i][j] = tmp[i][j];
        }
        n = -1;
        if(l==99) printf("%d\n",n);
    } 
    return 0;
}
 
void empty(int *x,int *y) {
    int i,j;
    for(i=0; i<4; i++) {
        for(j=0; j<4; j++) {
            if(!puzzle[i][j]) {
                *x = j;
                *y = i;
                return;
                
            }
        }
    }
}
 
 
void swap(int *n,int *m) {
    int tmp;
    tmp = *n;
    *n = *m;
    *m = tmp;
}
 
 
int cal() {
    int i,n,sum=0;
    for(i=0; i<16; i++) {
        n = puzzle[i/4][i%4];
        if(n) {
            n--;
            sum += abs(i/4 - n/4) + abs(i%4 - n%4);
        }
    }
    
    return sum;
    
}
 
 
int dfs(int x,int y,int p,int dep,const int lim) {
    int i,h,nx,ny,res;
 
    h = cal();
    if(h==0) return dep;
    if(dep+h>lim) return -1;
 
    for(i=0; i<4; i++) {
        nx = x+dx[i];
        ny = y+dy[i];
 
        if(~p && i==(p+2)%4) continue;
        if(!(0<=nx && nx<4 && 0<=ny && ny<4)) continue;
 
        swap(&puzzle[y][x],&puzzle[ny][nx]);
        res = dfs(nx,ny,i,dep+1,lim);
        if(~res) return res;
 
        swap(&puzzle[y][x],&puzzle[ny][nx]);
    }
 
    return -1;
}



Measured memory_bytes: 2108
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        if(a<=b)
        {
            for (int i = 0; i < b; i++) {
                System.out.print(a);
            }
        }
        else
        {
            for (int i = 0; i < a; i++) {
                System.out.print(b);
            } 
        }  
    }
}

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

#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define FORD(i,a,b) for(int i=a ; i>=b ; i--)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )
#define all(x) x.begin(),x.end()
#define flog2(n) 64 - __builtin_clzll(n) - 1
#define popcnt(n) __builtin_popcountll(n)

using namespace std;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const ll K = 1e9 + 7;

string s;
int n;

ll d[3005][3005];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	
	cin >> n;
	cin >> s;

	s = '0' + s;

	d[1][1] = 1;

	FOR (i, 2, n) {
		if (s[i - 1] == '<') {
			FOR (j, 1, i) {
				d[i][j] = (d[i - 1][j - 1] + d[i][j - 1]) % K;
			}		
		}
		else {
			FORD (j, i, 1) {
				d[i][j] = (d[i - 1][j] + d[i][j + 1]) % K; 
			}
		}
	}

	ll res = 0;

	FOR (i, 1, n) {
		res = (res + d[n][i]) % K;
	}

	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 69120
#include <stdio.h>

int main(){

  int a, b, c;
  int tmp;

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

  if(a > b){
    tmp = a;
    a = b;
    b = tmp;
  }
  if(b > c){
    tmp = b;
    b = c;
    c = tmp;
  }
  if(a > b){
    tmp = a;
    a = b;
    b = tmp;
  }

  printf("%d %d %d\n", a, b, c);

  return 0;
}

Measured memory_bytes: 596