akhauriyash/Code-Regression huggingface dataset:
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"

using namespace std;

int main() {
    int h, w;
    int* c = new int[2];
    int* d = new int[2];
    cin >> h >> w;
    cin >> c[0] >> c[1];
    cin >> d[0] >> d[1];
    c[0]++;
    c[1]++;
    d[0]++;
    d[1]++;

    vector<vector<bool>> s(h + 4, vector<bool>(w + 4, false));
    for (auto i = 0; i < h; i++)
    {
        for (auto j = 0; j < w; j++)
        {
            char c;
            cin >> c;
            s[i + 2][j + 2] = c == '.';
        }
    }

    priority_queue<pair<long, int*>, vector<pair<long, int*>>, function<bool(pair<long, int*>, pair<long, int*>)>> queue(
        [](pair<long, int*> a, pair<long, int*>b) {return a.first > b.first; }
    );
    queue.push(make_pair(0l, c));

    vector<vector<long>> costs(h + 4, vector<long>(w + 4, LONG_MAX));
    costs[c[0]][c[1]] = 0;

    while (!queue.empty())
    {
        auto tmp = queue.top();
        queue.pop();
        auto cell = tmp.second;

        if (cell[0] == d[0] && cell[1] == d[1])
        {
            break;
        }

        for (auto i = -1; i < 2; i++)
        {
            for (auto j = -1; j < 2; j++)
            {
                if ((i != 0 && j != 0) || i == j)
                {
                    continue;
                }
                auto x = cell[0] + i;
                auto y = cell[1] + j;
                if (s[x][y] && costs[x][y] > costs[cell[0]][cell[1]] + 1)
                {
                    costs[x][y] = costs[cell[0]][cell[1]] + 1;
                    queue.push(make_pair(costs[x][y], new int[2]{ x, y }));
                }
            }
        }

        for (auto i = -2; i < 3; i++)
        {
            for (auto j = -2; j < 3; j++)
            {
                if (-1 <= i && i <= 1 && j == 0)
                {
                    continue;
                }
                if (-1 <= j && j <= 1 && i == 0)
                {
                    continue;
                }
                auto x = cell[0] + i;
                auto y = cell[1] + j;
                if (s[x][y] && costs[x][y] > costs[cell[0]][cell[1]] + 10000000)
                {
                    costs[x][y] = costs[cell[0]][cell[1]] + 10000000;
                    queue.push(make_pair(costs[x][y], new int[2]{ x, y }));
                }
            }
        }
    }

    auto cost = costs[d[0]][d[1]];
    if (cost == LONG_MAX)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << cost / 10000000 << endl;
    }
}

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

using namespace std;

int main() {

    long long N, M, A, B, C, D;
    long long ans = 0;
    string S;

    cin >> N;
    A = N / 100;
    B = N % 100;

    if(A <= 12 && B <= 12&&A>0&&B>0) {
        cout << "AMBIGUOUS" << endl;
    } else if(A <= 12&&A>0) {
        cout << "MMYY" << endl;
    } else if(B <= 12&&B>0) {
        cout << "YYMM" << endl;
    }else{
        cout<<"NA"<<endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
int a,b,c,d=0,e=0,f=0;
  cin>>a>>b>>c;
  while(true){
    f++;
    d++;
    if(d==7){
      e=e+b;
      d=0;
    }
    e=e+a;
    if(e>=c){
      cout<<f<<"\n";
      break;
    }
  }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n), b(m);
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<m; i++) cin >> b[i];
    int j = -1, sum = 0;
    while(j+1<n and sum+a[j+1]<=k){
        j++;
        sum += a[j];
    }
    int ans = j + 1;
    for(int i=-1; i<m; ){
        while(i+1<m and sum+b[i+1]<=k){
            i++;
            sum += b[i];
            ans = max(ans, i + j + 2);
        }
        if(j >= 0){
            sum -= a[j];
            j--;
        }
        else if(j < 0) break;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6360
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long N, std::string S){
  int ans=0;
  for (int i = 1; i < S.length() - 1 ; i++) {
    int a=0;
    string x = S.substr(0,i);
    string y = S.substr(i);
    set<char>sx,sy;
    for (int l = 0; l < x.length(); l++) {
      sx.insert(x[l]);
    }
    for (int l = 0; l < y.length(); l++) {
      sy.insert(y[l]);
    }
    for (auto itr: sx) {
      a += sy.erase(itr);
    }
    ans = max(ans,a);
  }
  cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
}


Measured memory_bytes: 256
vertices = []
for _ in range(20):
    try:
        vertices.append([float(x) for x in input().split(',')])
    except:
        break
n = len(vertices)

def dist(p,q):
    return ((p[0]-q[0])**2 + (p[1]-q[1])**2)**0.5

def area(p,q,r):
    a = dist(p,q)
    b = dist(q,r)
    c = dist(r,p)
    z = (a+b+c)/2
    return (z*(z-a)*(z-b)*(z-c))**0.5

S = 0
for i in range(1,n-1):
    S += area(vertices[0],vertices[i],vertices[i+1])

print(S)


Measured memory_bytes: 5652
#include<stdio.h>
int main()
{
      int p, j, count1=0,count2=0, i, k;
      scanf("%d", &p);
      int ara[p];
      for(j=0;j<p;j++)
      {
          scanf("%d",&ara[j]);
      }


          for(i=1;i<p-1;i++)

          {
              if(ara[i-1]<=ara[i] && ara[i]<=ara[i+1])
              {
                  count1++;
              }
              else if(ara[i-1]>=ara[i] && ara[i]>=ara[i+1])
              {
                  count2++;

              }

          }
          printf("%d",count1+count2);




      return 0;

      }



Measured memory_bytes: 1684
N, M, L = map(int, input().split())

A = [list(map(int, input().split())) for i in range(N)]  # N*M配列の取得
B = [list(map(int, input().split())) for i in range(M)]  # M*L配列の取得
ANS = [[0] * L for i in range(N)]  # N*L

for x in range(N):
    for y in range(L):
        for z in range(M):
            ANS[x][y] += B[z][y] * A[x][z]

for row in range(N):
    print("%d" % ANS[row][0], end="")
    for col in range(1, L):
        print(" %d" % (ANS[row][col]), end="")
    print()


Measured memory_bytes: 7056
#include <bits/stdc++.h>
#define REP(a,b,c) for(int a=b; a<(int)c; a++)
#define REPE(a,b,c) for(int a=b; a<=(int)c; a++)
#define REPD(a,b,c) for(int a=b; a>(int)c; a--)
#define rep(a,b) REP(a,0,b)
#define repd(a,b) REPD(a,b,0)
typedef struct{
  int m;
  int t;
  int p;
  int j;
}_datas;
typedef struct{
  int p;
  int t;
}_score;
typedef long long int ll;
using namespace std;

  

int main(){
  while(true){
    int M,T,P,R;
    cin >> M >> T >> P >> R;
    if(M == 0) break;
    vector<_datas> datas(R);
    rep(i,R) cin >> datas[i].m >> datas[i].t >> datas[i].p >> datas[i].j;
    //rep(i,R) cout << datas[i].m << " "<< datas[i].t << " "<< datas[i].p << " "<< datas[i].j << " " << endl;
    vector<_score> scores(T+1,{0,0});
    REPE(i,1,T){
      vector<int> miss_cnt(P+1,0);
      rep(j,R){
        _datas data = datas[j];
        if(data.t == i){
          if(data.j == 0){
            scores[i].p++;
            scores[i].t += data.m + miss_cnt[data.p]*20;
          }else{
            miss_cnt[data.p]++;
          }
        }
      }
    }
    /*cout << "score" << endl;
    REPE(i,1,T){
      cout<<i<<":" << scores[i].p << " " << scores[i].t << endl;
      }*/
    _score b_score = {0,0};
    REPE(i,1,T){
      int max_idx = 1;
      REPE(j,2,T){
        if(scores[j].p > scores[max_idx].p || (scores[j].p==scores[max_idx].p && scores[j].t <= scores[max_idx].t)){
          max_idx = j;
        }
      }
      if(i != 1){
        if(b_score.p == scores[max_idx].p && b_score.t==scores[max_idx].t) cout << "=";
        else cout << ",";
      }
      cout << max_idx;
      b_score = scores[max_idx];
      scores[max_idx] = {-1,0};
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(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 s;
    cin >> s;
    ll n = s.size();
    ll cnt = 0;
    ll ans = 0;
    rep1(i, n){
        if (s[i]=='R') cnt++;
    }
    if (cnt == 1) ans = 1;
    if (cnt == 3) ans = 3;
    if (cnt == 2){
        if (s[1]=='R') ans = 2;
        else ans = 1;
    }
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
using namespace std;
int main() {
    int H, W;
    cin >> H >> W;
    string S;
    for (int i = 1; i <= H; i++) {
        for (char j = 'A'; j < 'A' + W; j++) {
            cin >> S;
            if (S == "snuke") cout << j << i << endl;
        }
    }
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n;
  cin >> n;
  rep(i, 1, 10) {
      if(n % i != 0) continue;
      if(n / i <= 9) {
          cout << "Yes" << endl;
          return 0;
      }
  }
  cout << "No" << endl;
}


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

void getLunLun(queue<int64_t> &lunluns) {
    int64_t x=lunluns.front();
    lunluns.pop();
    if (x%10!=0) {
        lunluns.push(10*x+(x%10)-1);
    }
    lunluns.push(10*x+(x%10));
    if (x%10!=9) {
        lunluns.push(10*x+(x%10)+1);
    }
}

int main() {
    int K;
    cin >> K;
    
    queue<int64_t> lunluns;
    for (int i=1;i<10;i++) {
        lunluns.push(i);
    }
    for (int i=1;i<K;i++) {
        getLunLun(lunluns);
    }
    cout << lunluns.front() << endl;
}

Measured memory_bytes: 1792
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

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

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    string S; cin >> S; ll K; cin >> K;
    REP(i, S.size()){
        if(K <= 0){
            cout << S[i];
        }
        else{
            if(i == S.size()-1){
                cout << (char)((S[i]-'a' + K%26) % 26 + 'a'); break;
            }
            ll rem = 'z' - S[i] + 1;
            if(S[i] != 'a' && rem <= K){
                cout << 'a'; K -= rem;
            }
            else{
                cout << S[i];
            }
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 512
main=do
 [n,m]<-map read.words<$>getLine
 print$(`mod`(10^9+7))$(*if abs(n-m)==0 then 2 else if abs(n-m)==1 then 1 else 0)$(f n)*(f m)
f 0=1
f n=n*(f$n-1)`mod`(10^9+7)

Measured memory_bytes: 7804
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD1			998244353
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const int tam = 100010;
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n;
	int a;
	cin>>n;
	int res = 0;
	while(n--)
	{
		cin>>a;
		while(a % 2 == 0)
		{
			a /= 2;
			res++;
		}
	}
	cout<<res<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define MN 200005
using namespace std;
int n,m,num,que[MN<<4],head[MN<<4],rd[MN<<4];char s[MN];
struct edge{int to,next;}g[MN<<4];
void ins(int u,int v){g[++num].next=head[u];head[u]=num;g[num].to=v;}
int main(){
	scanf("%d%d%s",&n,&m,s+1);int x,y;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		if(x==y)ins(x+n,x+2*n),ins(x+3*n,x);
		else if(s[x]==s[y])ins(x+n,y),ins(x+n,y+2*n),ins(x+3*n,y),ins(x+3*n,y+2*n),ins(y+n,x),ins(y+n,x+2*n),ins(y+3*n,x),ins(y+3*n,x+2*n);
		else ins(x,y+n),ins(x,y+3*n),ins(x+2*n,y+n),ins(x+2*n,y+3*n),ins(y,x+n),ins(y,x+3*n),ins(y+2*n,x+n),ins(y+2*n,x+3*n);
	}
	for(int i=1;i<=4*n;i++)for(int j=head[i];j;j=g[j].next)rd[g[j].to]++;
	int h=1,t=0;for(int i=1;i<=4*n;i++)if(rd[i]==0)que[++t]=i;
	while(h<=t){
		
		int tmp=que[h++];
		for(int i=head[tmp];i;i=g[i].next)if(!(--rd[g[i].to]))que[++t]=g[i].to;
	}if(t==n*4)puts("No");else puts("Yes");
}


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

#define x first
#define y second

ll mod = 1e9+7;
ll fac[200000], ifac[200000];

ll bin(int x, int y) {
  if (x < 0 || y < 0) return 0;
  return fac[x+y]*ifac[x]%mod*ifac[y]%mod;
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int w, h, n;
  cin >> w >> h >> n;
  fac[0] = fac[1] = ifac[0] = ifac[1] = 1;
  for (int i = 2; i < w+h; i++) {
    fac[i] = fac[i-1]*i%mod;
    int a = mod/i, b = mod%i, ib = ifac[b]*fac[b-1]%mod;
    ifac[i] = mod-ifac[i-1]*a %mod * ib %mod;
    assert(fac[i]*ifac[i]%mod == 1);
  }
  vector<pair<int,int>> p(n);
  for (auto&v : p) cin >> v.x >> v.y;
  p.emplace_back(w,h);
  sort(p.begin(), p.end());
  for (auto&v : p) v.x--, v.y--;

  vector<ll> dp;
  for (int i = 0; i <= n; i++) {
    ll ways = bin(p[i].x,p[i].y);
    for (int j = 0; j < i; j++)
      (ways -= dp[j]*bin(p[i].x-p[j].x,p[i].y-p[j].y)) %= mod;
    dp.push_back(ways);
  }
  cout << (dp[n]+mod)%mod << endl;
}


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

conds = [400*i for i in range(1,9)]
colors = set()
frees = 0
for i in range(N):
    for c in conds:
        if A[i] < c:
            colors.add(c)
            break
    else:
        frees += 1
clen = len(colors)
print(clen if clen else 1, clen+frees)


Measured memory_bytes: 38512
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u){
  int i, c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if(T[u].p == NIL) cout << "root, ";
  else if(T[u].l == NIL) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for(i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}

int rec(int u, int p){
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r, p);
  if(T[u].l != NIL) rec(T[u].l, p+1);
}

int main(){
  int i, j, d, v, c, l, r;
  cin >> n;
  for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;

  for(i=0;i<n;i++){
    cin>>v>>d;
    for(j=0;j<d;j++){
      cin>>c;
      if(j==0) T[v].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==NIL) r=i;
  }

  rec(r,0);

  for(i=0;i<n;i++) print(i);

  return 0;
}



Measured memory_bytes: 7748
#include <iostream>
#include <cmath>
#include<iomanip>

using namespace std;

int main(int argc, char *argv[])
{
	int N, K;

	cin >> N >> K;

	double ans = 0;
	for (int i = 1; i <= N; i++) {
		int a = i, b = 0;
		double p = 1.0 / N;
		while (a < K) {
			a = a * 2;
			b++;
		}
		double q = pow(0.5, b);
		ans += p * q;
	}

	cout << setprecision(12) << ans << "\n";

	return 0;
}


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

using namespace std;

int main(){
	int a[10], b[10];
	for(int i = 0; i < 10; i++) cin>>a[i];
	for(int i = 0; i < 10; i++) cin >> b[i];
	sort(a, a+10); sort(b, b+10);
	cout << a[9]+a[8]+a[7] << " " << b[9]+b[8]+b[7] << endl;
 
	return 0;
}


Measured memory_bytes: 3108
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for(int i=0;i<n;i++) {
			list.add(scan.nextInt());
		}
		List<Integer> list2 = new ArrayList<Integer>(new HashSet<>(list));
		System.out.println(list2.size());
	}

}


Measured memory_bytes: 22996
N,M,C=[int(x) for x in input().split()]
Bs=[int(x) for x in input().split()]
r=0
for i in range(N):
    As=[int(x) for x in input().split()]
    total=0
    for j,a in enumerate(As):
        total+=a*Bs[j]
    if total+C>0:
        r+=1

print(r)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int N_MAX=300;
typedef long long ll;
int main()
{
  int n,i,j,k;
  bool f;
  ll res=0;
  ll a[N_MAX][N_MAX];
  cin >> n;
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      cin >> a[i][j];
  for(i=0;i<n-1;i++)
    for(j=i+1;j<n;j++){
      f=0;
      for(k=0;k<n;k++){
        if(k==i||k==j)
          continue;
        if(a[i][j]>a[i][k]+a[k][j]){
          cout << "-1" << endl;
          return 0;
        }
        if(a[i][j]==a[i][k]+a[k][j])
          f=1;
      }
      if(f==0)
        res+=a[i][j];
    }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4304
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> a(h);
	int sx, sy;
	REP(i, h) {
		cin >> a[i];
		REP(j, w) {
			if (a[i][j] == 'S') {
				sy = i;
				sx = j;
			}
		}
	}
	int res = 1;
	int dy[] = { 0,0,-1,1 };
	int dx[] = { 1,-1,0,0 };
	vector<vector<int>> d(h, vector<int>(w, INT_MAX));
	queue<P> q;
	q.push(P(sy, sx));
	d[sy][sx] = 0;
	while (!q.empty()) {
		P p = q.front();
		q.pop();
		REP(i, 4) {
			int ny = p.first + dy[i];
			int nx = p.second + dx[i];
			if (0 <= ny && ny < h && 0 <= nx && nx < w) {
				if (a[ny][nx] == '.'&&d[ny][nx]==INT_MAX) {
					d[ny][nx] = d[p.first][p.second] + 1;
					q.push(P(ny, nx));
				}
			}
		}	
	}
	int m = INT_MAX;
	REP(i, h) {
		REP(j, w) {
			if (d[i][j] <= k) {
				int temp = min({ i,j,h - 1 - i,w - 1 - j });
				chmin(m, temp);
			}
		}
	}
	res += (m + k - 1) / k;
	put(res);
 	return 0;
}

Measured memory_bytes: 3584
import kotlin.math.max

fun main() {
    val (n, mw) = readLine()!!.split(' ').map { it.toInt() }
    val xs = (0 until n).map {
        val (w, v) = readLine()!!.split(' ').map { it.toInt() }
        w to v
    }

    val dp = Array(n + 1) { mutableMapOf<Int, Int>() }
    dp[0][0] = 0

    for (i in 0 until n) {
        val (wi, vi) = xs[i]
        for (w in dp[i].keys) {
            dp[i + 1][w] = max(dp[i][w]!!, dp[i + 1][w] ?: 0)
            if (w + wi > mw) continue
            dp[i + 1][w + wi] = max(dp[i][w]!! + vi, dp[i + 1][w + wi] ?: 0)
        }
    }

    println(dp[n].maxBy { it.value }!!.value)
}


Measured memory_bytes: 60512
import java.util.Scanner;


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

		Scanner sc = new Scanner(System.in);
		String[] s = sc.nextLine().split("[\\s]+");
		int[] number = new int[5];

		for(int i=0;i<5;i++){
			number[i] = Integer.parseInt(s[i]);
		}

		for(int i=0;i<5;i++){
			for(int j=4;j>i;j--){
				if(number[j] > number[j-1]){
					int temp = number[j];
					number[j] = number[j-1];
					number[j-1] = temp;
				}
			}
		}
		for(int i=0;i<4;i++){
			System.out.print(number[i]+" ");
		}
		System.out.println(number[4]);
	}
}

Measured memory_bytes: 17328
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
a = []
for _ in range(5):
    a.append(ni())
print(math.ceil(n/min(a))+4)



Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long n;

	std::cin >> n;

	std::map<std::string, long long> m;

	for (long long i = 0; i < n; i++)
	{
		std::string s;
		std::cin >> s;

		m[s]++;
	}

	std::vector<std::pair<long long, std::string> > v;
	long long max = 0;
	for (auto a : m) {
		v.push_back({ a.second, a.first });
		max = std::max(max, a.second);
	}

	std::sort(v.begin(), v.end());

	for (size_t i = 0; i < v.size(); i++)
	{
		if (v[i].first == max) {
			std::cout << v[i].second << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 29812
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=100010;
int a[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') ch=getchar(),o=-1;
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) a[i]=gi();
    sort(a+1,a+1+n);
    reverse(a+1,a+1+n);
    if(a[1]==0) {puts("");return 0;}
    for(int i=1;i<=n;i++)
	if(i+1>a[i+1]) {
	    bool ret=0;
	    for(int j=i+1;j<=n;j++) ret^=(a[j]==i);
	    ret|=(a[i]-i)&1;
	    puts(ret?"First":"Second");
	    break;
	}
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	int A, B;
	scanf("%d", &A);

	if (A < 1200) {
		printf("ABC");
	}
	else {
		printf("ARC");
	}





}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Team[] teams = new Team[n];
        for (int i = 0; i < n; i++) {
            teams[i] = new Team(i + 1);
        }
        for (int i = 0; i < n * (n - 1) / 2; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            int c = sc.nextInt();
            int d = sc.nextInt();
            if (c == d) {
                teams[a].point++;
                teams[b].point++;
            } else if (c > d) {
                teams[a].point += 3;
            } else {
                teams[b].point += 3;
            }
        }
        Arrays.sort(teams);
        int rank = 1;
        teams[0].rank = 1;
        for (int i = 1; i < n; i++) {
            if (teams[i].point == teams[i - 1].point) {
                teams[i].rank = rank;
            } else {
                rank = i + 1;
                teams[i].rank = rank;
            }
        }
        Arrays.sort(teams, new Comparator<Team>() {
            public int compare(Team t1, Team t2) {
                return t1.idx - t2.idx;
            }
        });
        StringBuilder sb = new StringBuilder();
        for (Team t : teams) {
            sb.append(t.rank).append("\n");
        }
        System.out.print(sb);
    }
    
    static class Team implements Comparable<Team> {
        int idx;
        int point;
        int rank;
        
        public Team(int idx) {
            this.idx = idx;
        }
        
        public int compareTo(Team another) {
            return another.point - point;
        }
    }
}



Measured memory_bytes: 47696
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var s = Console.ReadLine();
        Console.WriteLine(s.GroupBy(x => x).Count() == 2 ? "Yes" : "No");
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, c, k);
    Cins(int, n, t);
    Sort(t);
    int ans = 0, tl = 0, cl = 0;
    For(i, n){
        if(tl < t[i] || cl >= c){
            ans ++;
            tl = t[i] + k;
            cl = 0;
        }
        cl ++;
        // Cout(t[i], " : ", ans);
    }
    Cout(ans);
}


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

int main(){
	int n;
	std::cin >> n;
	std::vector<int> l(n);
	for(int i=0; i<n; i++){
		std::cin >> l[i];
	}
	std::sort(l.begin(), l.end());
	long long count = 0;
	for(int ia=n-1; ia>=2; ia--){
		for(int ib=ia-1; ib>=1; ib--){
			//if(l[ia] > l[ib]*2) break;
			for(int ic=ib-1; ic>=0; ic--){
				if(l[ia] < l[ib] + l[ic]){
					count++;
				//}else{
				//	break;
				}
			}
		}
	}
	std::cout << count << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    var(int, N);
    print(sigma(N-1));

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
int x,y;
  while(1){
    scanf("%d %d",&x,&y);
    if(x==0 && y==0){
      break;}
    if(x<y){
      printf("%d %d\n",x,y);}
    if(y<x){
      printf("%d %d\n",y,x);}
    if(x==y){
      printf("%d %d\n",x,y);}
  }
  return 0;
}


Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()
#define INF 1e9
using P = pair<int,int>;

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

vector<vector<int>> cost_map(
    int Y,int X,int sy,int sx,
    vector<string> &s){

    vector<vector<int>> cost(Y, vector<int>(X,INF));
    cost[sy][sx] = 0;
    queue<P> qu;
    qu.push(P(sy,sx));
    while(qu.size()){
        P p = qu.front(); qu.pop();
        int y = p.first;
        int x = p.second;
        rep(i,4){
            int ny = y+dy[i];
            int nx = x+dx[i];
            if(nx<0 || ny<0 || nx>=X || ny>=Y) continue;
            if(s[ny][nx] == 'x') continue;
            if( cost[ny][nx] > cost[y][x] + 1){
                cost[ny][nx] = cost[y][x] + 1;
                qu.push(P(ny, nx));
            }
        }
    }
    return cost;
}

int main(void){
    int Y,X;
    while(cin>>X>>Y, Y|X){
        vector<string> s(Y);
        rep(y,Y) cin>>s[y];
        vector<P> pos;
        rep(y,Y)rep(x,X){
            if(s[y][x]=='o' || s[y][x]=='*'){
                pos.push_back(P(y,x));
            }
        }
        int n = pos.size();
        int d[11][11];
        bool ng = false;
        rep(i,n){
            int y = pos[i].first;
            int x = pos[i].second;
            auto cost = cost_map(Y,X,y,x,s);
            rep(j,n){
                int ny = pos[j].first;
                int nx = pos[j].second;
                d[i][j] = cost[ny][nx];
                if(d[i][j] == INF) ng = true;
            }
        }
        if(ng){
            cout<<-1<<endl;
            continue;
        }
        vector<int> perm(n);
        rep(i,n) perm[i] = i;
        int res = INF;
        do{
            int sy = pos[perm[0]].first;
            int sx = pos[perm[0]].second;
            if(s[sy][sx] != 'o') continue;
            int cost = 0;
            rep(i,n-1){
                cost += d[perm[i]][perm[i+1]];
            }
            res = min(res, cost);
        }while(next_permutation(all(perm)));
        cout<<res<<endl;
    }
    return 0;
}



Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
	int count = 0;
	string s;
	while(getline(cin, s)){
		if(equal(s.begin(), s.end(), s.rbegin())) count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		int h[] = new int[N];
		for(int i = 0; i < N; i++) {
			h[i] = scan.nextInt();
		}
		
		for(int i = 0; i < N - 1; i++ ) {
			if(h[i + 1] < h[i]) {
				System.out.println("No");
				return;
			}
			
			if(h[i + 1] > h[i]) {
				h[i  + 1]--;
			}
		}
		
		System.out.println("Yes");
	}
}


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

int main() {
  double a, b;
  cin >> a >> b;
  if (a > b) {
    cout << "GREATER";
  }
  else if (a == b) {
    cout << "EQUAL";
  }
  else {
    cout << "LESS";
  }
  cout << endl;
}



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

int n,x,l;

int main() {
  cin >> n >> x;
  int s = 0,i;
  for (i = 0; i < n; ++i) {
    cin >> l;
    s += l;
    if (s > x) break;
  }
  cout << i + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;
 long long q(long long a,long long b)
{
    long long ans = 1;
    while(b)//用一个循环从右到左便利b的所有二进制位
    {
        if(b&1)//判断此时b[i]的二进制位是否为1
        {
            ans = (ans*a);//乘到结果上，这里a是a^(2^i)%m
            b--;//把该为变0
        }
        b/=2;
        a = a*a;
    }
    return ans;
}
int main()
{
  int n;
  cin>>n;
  long long s=q(3,n);
 
  int k,sum=1,pp;
  for(int i=0;i<n;i++){
    k=0;
    cin>>pp;
    if(pp%2==1) k++;
    if((pp-1)%2==1)k++;
    if((pp+1)%2==1) k++;
    sum=sum*k;
  }
   cout<<s-sum<<endl;
}


Measured memory_bytes: 256
s = input()
start = 0
end = 0
flag = 0
for i in range(len(s)):
    if s[i] == 'A' and flag == 0:
        start  = i
        flag += 1
    if s[i] == 'Z':
        end = i

ans = s[start:(end+1)]
print(len(ans))


Measured memory_bytes: 3516
N=int(input())
A=list(map(int,input().split()))
dp=[0]*N
dp[0]=1000
for i in range(1,N):
    dp[i]=max(dp[i-1],dp[i-1]//A[i-1]*A[i]+dp[i-1]%A[i-1])
print(dp[-1])

Measured memory_bytes: 9196
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

template<class Val>
vector<Val> compress(vector<Val> &v) {
    vector<Val> a = v;
    sort(all(a));
    a.erase(unique(all(a)), a.end());
    each(b, v)b = (int)(lower_bound(all(a), b) - a.begin());
    return a;
}

template<class Val, class Cmp>
class DynamicRMQ {
    int n;
    Val init;
    vector<Val> dat;
    Cmp cmp;
    inline Val query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return init;
        if (a <= l && r <= b) return dat[k];
        else {
            Val vl, vr;
            vl = query(a, b, k << 1, l, (l + r) >> 1);
            vr = query(a, b, (k << 1) | 1, (l + r) >> 1, r);
            return cmp(vl, vr) ? vl : vr;
        }
    }
public:
    DynamicRMQ() {}
    DynamicRMQ(int n_, Val init_) :n(1), init(init_) {
        for (; n<n_; n <<= 1);
        dat = vector<Val>(n << 1, init);
    }
    void update(int k, Val a) {
        k += n;
        dat[k] = a;
        while (k > 1) {
            k >>= 1;
            dat[k] = cmp(dat[k << 1], dat[(k << 1) | 1]) ? dat[k << 1] : dat[(k << 1) | 1];
        }
    }
    Val query(int a, int b) {
        return query(a, b, 1, 0, n);
    }
};

typedef DynamicRMQ<long long, less<long long> > RMinQ64;
typedef DynamicRMQ<long long, greater<long long> > RMaxQ64;
typedef DynamicRMQ<int, less<int> > RMinQ32;
typedef DynamicRMQ<int, greater<int> > RMaxQ32;

void solve() {
    int N;
    cin >> N;
    vi H(N), A(N);
    rep(i, N)cin >> H[i];
    rep(i, N)cin >> A[i];

    compress(H);

    RMaxQ64 ma(N + 1, 0);
    rep(i, N) {
        ma.update(H[i] + 1, ma.query(0, H[i] + 1) + A[i]);
    }
    cout << ma.query(0, N + 1) << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 5876
def resolve():
    n = int(input())
    lists = list(map(int, input().split()))
    count = 0
    for i in range(1,n-1):
        if lists[i-1] < lists[i] < lists[i+1] or lists[i-1] > lists[i] > lists[i+1]:
            count += 1
    print(count)
resolve()

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a + b == 15) cout << '+' << endl;
    else if (a * b == 15) cout << '*' << endl;
    else cout << 'x' << endl;
    return 0;
}

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

int main(){
    int k;
    string s,ans;
    cin >>k >> s;
    if(s.length()<=k){
        cout << s <<endl;
    }else{
        ans=s.substr(0,k)+"...";
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;


int main(){

  char ani;
  cin>>ani;


  if(ani == 'A')
  cout<<"T"<<endl;
  else if(ani == 'T')
    cout<<"A"<<endl;
  else if(ani == 'C')
    cout<<"G"<<endl;
  else
    cout<<"C"<<endl;


return 0;
}



Measured memory_bytes: 256
a,b,c=map(int,input().split())
import math
C=math.radians(c)
k =(a**2+b**2-2*a*b*math.cos(C))**0.5
S = 0.5*a*b*math.sin(C)
L = a+b+k
h = (S*2)/a
print(S)
print(L)
print(h)


Measured memory_bytes: 5720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();

		String[] n = line.split(" ");
		int W = Integer.parseInt(n[0]);
		int H = Integer.parseInt(n[1]);
		int x = Integer.parseInt(n[2]);
		int y = Integer.parseInt(n[3]);
		int r = Integer.parseInt(n[4]);

		if (x - r < 0 || x + r > W || y - r < 0 || y + r > H) {
			System.out.println("No");

		} else {
			System.out.println("Yes");

		}

	}

}



Measured memory_bytes: 26324
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
long long MOD  = 1e9+7;


signed main(){
    fast;
    int n; cin >> n;
    int a[n+1],b[n+1],c[n+1];
    for(int i=1 ; i<=n ; i++)
        cin >> a[i];

    int ans = 0;
    for(int i=1 ; i<=n ; i++){
            cin >> b[i];
    }
    for(int i=1;  i<n ; i++){
            cin >> c[i];
    }

    for(int i=1 ; i<=n-1 ; i++){
        if(a[i]+1 == a[i+1]){
            ans += c[a[i]];
        }
    }
    for(int i=1 ; i<=n ; i++){
        ans+=b[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long
#define mp make_pair
using pi=pair<int,int>;
main(){
  int n,q;
  cin>>n>>q;
  vector<int> cnt(n,0),res(n);
  vector<vector<int>> e(n);
  for(int i=0;i<n-1;++i){
    int a,b;
    cin>>a>>b;
    a--; b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  for(int i=0;i<q;++i){
    int p,x;
    cin>>p>>x;
    p--;
    cnt[p]+=x;
  }
  queue<pi> que;
  vector<bool> vis(n,false);
  que.push(mp(0,0));
  while(!que.empty()){
    pi p=que.front(); que.pop();
    res[p.first]=(p.second+=cnt[p.first]);
    vis[p.first]=true;
    for(auto i:e[p.first])if(!vis[i])que.push(mp(i,p.second));
  }
  for(int i=0;i<n;++i)cout<<(i?" ":"")<<res[i];
}

Measured memory_bytes: 21104
def prime(x):
  for i in range(2,int(x**0.5)+1):
    if x%i==0:
      return False
  return True
c = [0]*100002
for k in range(2,100001):
    if prime(k):
        c[k]=1


pri = [0]*100002
for i in range(2,100001):
    if c[i]==1 and c[(i+1)//2]==1:
        pri[i] = pri[i-1] +1 
    else:
        pri[i] = pri[i-1]

q = int(input())
a = [list(map(int, input().split())) for _ in range(q)]
for l,r in a:
    print(pri[r]-pri[l-1])


Measured memory_bytes: 29992
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

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

struct state {
	int x, y, dir;
	vs field;
	string command;
	state(int x, int y, int dir, vs field, string command) : x(x), y(y), dir(dir), field(field), command(command) {};
};

int getDir(char c) {
	switch(c) {
	case 'U':
		return 3;
	case 'D':
		return 1;
	case 'L':
		return 2;
	case 'R':
		return 0;
	}
}

char getDirChar(int dir) {
	switch(dir) {
	case 0:
		return 'R';
	case 1:
		return 'D';
	case 2:
		return 'L';
	case 3:
		return 'U';
	}
}

bool isProperXY(int x, int y, int H, int W) {
	return 0 <= x && x < W && 0 <= y && y < H;
}

bool isEmptyField(vs field) {
	REP(i, field.size()) {
		REP(j, field[i].size()) {
			if(field[i][j] != '.') {
				return false;
			}
		}
	}
	return true;
}

int main() {
	int H, W;
	cin >> H >> W;
	vs field(H);

	int x, y, dir;
	REP(i, H) {
		cin >> field[i];
		REP(j, field[i].size()) {
			if(field[i][j] != '.' && field[i][j] != 'o') {
				x = j;
				y = i;
				dir = getDir(field[i][j]);
				field[i][j] = '.';
			}
		}
	}

	string ans;
	stack<state> S;
	S.push(state(x, y, dir, field, ""));
	while(!S.empty()) {
		state st = S.top();
		S.pop();

		if(isEmptyField(st.field)) {
			ans = st.command;
			break;
		}

		FOR(d, -1, 1) {
			int nx = st.x, ny = st.y, ndir = (st.dir+d+4)%4;
			bool update = true;
			while(st.field[ny][nx] != 'o') {
				nx += dx[ndir], ny += dy[ndir];
				if(!isProperXY(nx, ny, H, W)) {
					update = false;
					break;
				}
			}

			if(update) {
				vs nfield = st.field;
				nfield[ny][nx] = '.';
				string ncommand = st.command;
				ncommand.push_back(getDirChar(ndir));
				S.push(state(nx, ny, ndir, nfield, ncommand));
			}
		}
	}

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

Measured memory_bytes: 1232