akhauriyash/Code-Regression huggingface dataset:
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let R2 T U = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U)
let R3 T U V = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V)
let R4 T U V W = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W)
let R5 T U V W X = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W),(c.[4]|>X)
let outl s = stdout.WriteLine(s|>string)
let outsep ls = stdout.WriteLine(String.concat " " (ls|>Array.map string))
let outsepl ls = stdout.WriteLine(String.concat "\n" (ls|>Array.map string))
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let N=R int
    RS int
    |>Array.distinct
    |>Array.length
    |>fun c->if c<>N then "NO" else "YES"
    |>outl
    0
    

Measured memory_bytes: 42972
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int T;
	double A;
	cin>>n>>T>>A;
	int tmp=0;
	double ans=1e7;
	for(int i=1,h;i<=n;i++){
		scanf("%d",&h);
		double tans=T-h*0.006;
		if(abs(tans-A)<ans){
			tmp=i,ans=abs(tans-A);
		}
	}
	cout<<tmp;
	return 0;
}

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



int hassh[27];

int main() {

    ios::sync_with_stdio(0);
    long long n,a,b;
    cin>>n>>a>>b;

    long long cnt=(n/(a+b))*a;

    n%=(a+b);

    cnt+=min(a,n);
    cout<<cnt;

    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int n,m;
	cin >> n >> m;
	map<ll,ll> mp;
	for(int i = 0; i < n; i++){
		int a,b;
		cin >> a >> b;
		mp[a] += b;
	}
	ll ans = 0;
	for(auto x = mp.begin(); x != mp.end(); x++){
		if(m <= x->second){
			ans += m*x->first;
			break;
		}else{
			ans += x->first*x->second;
			m -= x->second;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
  int N, x;
  cin >> N >> x;

  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
  sort(a.begin(), a.end());

  int count = 0;
  int temp = 0;
  for (int i = 0; i < N; i++)
  {
    temp += a[i];
    if (x < temp || (temp < x && i == N - 1))
      break;
    count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import sys
import itertools


def resolve(in_):
    n = int(next(in_))
    a = tuple(map(int, next(in_).split()))
    
    m = 1000
    s = 0

    b, c = itertools.tee(a)
    next(c)
    for x, y in zip(b, c):
        # print(f'{x=} {y=}')
        if x < y:
            ss, mm = divmod(m, x)
            m = mm
            s += ss
        elif x > y:
            mm = x * s
            m += mm
            s = 0
        # print(m, s)
    else:
        mm = y * s
        m += mm
        s = 0
        # print(m, s)

    return m


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9200
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int n;
	lint count=0;
	long double sum=0;
	cin>>n;
	vector<int>x(n),y(n);
	rep(i,n)cin>>x.at(i)>>y.at(i);
	vector<int>p(n);
	rep(i,n)p.at(i)=i;
	do{
		count++;
		rep(i,n){
			if(i==n-1)continue;
			sum+=sqrt(pow(x.at(p.at(i))-x.at(p.at(i+1)),2)+pow(y.at(p.at(i))-y.at(p.at(i+1)),2));
		}
	}while(next_permutation(all(p)));
	printf("%.7lf\n",double(sum/count));
}


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

typedef long long ll;
ll kaijo[100010]={0};

int main(){
    string s;
    int n;
    cin>>n;
    map<string,ll>m;
    kaijo[0]=0;
    kaijo[1]=0;
    kaijo[2]=1;
    for(int i=3;i<=100000;i++)kaijo[i]=kaijo[i-1]+i-1;
    for(int i=0;i<n;i++){
        cin>>s;
        sort(s.begin(),s.end());
        m[s]++;
    }
    ll ans=0;
    for(auto itr=m.begin();itr!=m.end();++itr){
        ans+=kaijo[itr->second];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11904
import collections as c
class graph:
    def __init__(self, n):
        self.n = n
        self.node = [[] for _ in range(n)]
        self.unexplored = [True] * n
        self.landmark = [-1] * (n-1)

    def unit(self, a, b):
        self.node[a].append(b)
        self.node[b].append(a)
    
    def bfs(self):
        queue = c.deque([self.node[0]])
        land = c.deque([0])
        self.unexplored[0] = False
        while queue:
            v = queue.popleft()
            l = land.popleft()
            for d in v:
                if self.unexplored[d]:
                    self.landmark[d-1] = l+1
                    queue.append(self.node[d])
                    land.append(d)
                    self.unexplored[d] = False
    
    def get_land(self):
        return self.landmark

n, m = map(int, input().split())
g = graph(n)
for _ in range(m):
    a, b = map(int, input().split())
    g.unit(a-1, b-1)

g.bfs()
land = g.get_land()
if -1 in land:
    print('No')
else:
    print('Yes')
    for x in land:
        print(x)

Measured memory_bytes: 37956
D=int(input())
c=list(map(int, input().split()))
s=[list(map(int, input().split()))  for i in range(D)]
t=[int(input()) for i in range(D)]

d=[0]*(26)
v=[0]*(D+1)


for i in range(D):
    v[i]=s[i][t[i]-1]
    d[t[i]-1]=-1
    sb=0      
    for j in range(26):
        d[j]+=1 
        sb+=d[j]*c[j]
                   
    v[i]+=v[i-1]-sb
    print(v[i])

Measured memory_bytes: 9400
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int a = Integer.parseInt(br.readLine());
		System.out.println(a < 1200 ? "ABC" : "ARC");
	}
}

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

const int INF = 2e9;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    ll ans = a[n-1];
    int j = n - 2;
    for(int i = n-3;i >= 0;){
        ans += a[j];
        i--;
        if(i >= 0){
            ans += a[j];
            i--;
            j--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4032
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int daysOfWinterVacation;
		double pagesOfLangDrill, pagesOfMathDrill, pagesOfLangADay, pagesOfMathADay;
		int langDays, mathDays;
		daysOfWinterVacation = sc.nextInt();
		pagesOfLangDrill = sc.nextDouble();
		pagesOfMathDrill = sc.nextDouble();
		pagesOfLangADay = sc.nextDouble();
		pagesOfMathADay = sc.nextDouble();

		
		langDays = (int)Math.ceil(pagesOfLangDrill / pagesOfLangADay);
		mathDays = (int)Math.ceil(pagesOfMathDrill / pagesOfMathADay);
		if (langDays > mathDays) {
			System.out.println(daysOfWinterVacation - langDays);
		}else {
			System.out.println(daysOfWinterVacation - mathDays);
		}
	}

}

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

all_lst = []
for i in range(N):
  all_lst.append(list(map(int, input().split())))
  
all_lst.sort(key=itemgetter(0))

m = 0
ans = 0

for i in all_lst:
  a = i[0]
  b = i[1]
  if (b <= (M - m)):
    ans += a * b
    m += b
  else:
    ans += a * (M - m)
    m += (M - m)
    break
print(ans)
    

Measured memory_bytes: 28972
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD 1000000007
using namespace std;

struct UnionFind{
    vector<int> par;

    UnionFind(int N):par(N){
        for(int i=0; i<N; i++)par[i]=i;
    }
    int root(int x){
        if(par[x]==x)return x;
        return par[x]=root(par[x]);
    }
    void unite(int x, int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry)return;
        par[rx]=ry;
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
};

int main(void){
    long long n,m,a,b;
    cin >> n >> m;
    long long tapi,tapu;
    UnionFind tree(n);
    vector< pair<int,int> > bridge(m);
    vector<long long> unc(m+1,n*(n-1)/2);
    vector<int> vertex(n,1);
    for(int i=0; i<m; i++){
        cin >> a >> b;
        bridge[i]=make_pair(a-1,b-1);
    }

    for(int i=m-1; i>=0; i--){
        unc[i]=unc[i+1];
        a=bridge[i].first;
        b=bridge[i].second;
        if(tree.same(a,b))continue;
        tapi=vertex[tree.root(a)];
        tapu=vertex[tree.root(b)];
        unc[i]=unc[i]-((tapi)*(tapu));
        tree.unite(a,b);
        vertex[tree.root(a)]=tapi+tapu;
    }
    for(int i=1; i<=m; i++){
        cout << unc[i] << endl;
    }
    return 0;
}


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

namespace ARC093
{
    class A
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] A2 = new int[A.Length + 2];
            for (int i = 0; i < A.Length; i++)
            {
                A2[i + 1] = A[i];
            }

            int sum = 0;
            for (int i = 0; i < N + 1; i++)
            {
                sum += Math.Abs(A2[i + 1] - A2[i]);
            }

            for (int i = 1; i < N + 1; i++)
            {
                Console.WriteLine(sum + Math.Abs(A2[i - 1] - A2[i + 1]) - (Math.Abs(A2[i - 1] - A2[i]) + Math.Abs(A2[i] - A2[i + 1])));
            }
        }
    }
}



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

int main() {
  int a,b;
  string op;
  cin >> a >> op >> b;
  int ans = 0;
  if (op == "+") {
    ans = a + b;
  } else {
    ans = a - b;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
[val1, val2] = input().split(" ")
val1 = int(val1)
val2 = int(val2)
if val1 >= 1 and val2 <=100:
    a = int(val1 * val2)
    b = int((val1 + val2) *2)
    a = str(a)
    b = str(b)
    print(a + " " + b)


Measured memory_bytes: 5596
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int K, X;

  std::cin >> K >> X;

  std::cout << (K * 500 >= X ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 256
b = list(input())
ans = []
for i in range(len(b)):
    if b[i] == "A":
        ans.append("T")
    elif b[i] == "T":
        ans.append("A")
    elif b[i] == "C":
        ans.append("G")
    else:
        ans.append("C")
for i in range(len(ans)):
    if i != len(ans)-1:
        print(ans[i],end="")
    else:
        print(ans[i])

Measured memory_bytes: 3060
import collections
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
s = [""]*N
S = []
for i in range(N):
    s[i] = input()
    test = list(s[i])
    test.sort()
    S.append("".join(test))
ana = sorted(collections.Counter(S).values())
count = 0
for i in ana:
    if i >= 2:
        count += combinations_count(i,2)
print(count)

Measured memory_bytes: 26996
#include<stdio.h>
int main()
{
    int n,x=0,i,max;
    int ch[100];
	char str0[1],str[100];
    scanf("%d",&n);
    gets(str0);
    gets(str);
    if(n>=1&&n<=100)
    {
        for(i=0; i<n; i++)
        {
            if(str[i]=='I')
            {
                x++;
                ch[i]=x;
            }
            else if(str[i]=='D')
            {
                x--;
                ch[i]=x;
            }
        }
        max=0;
        for(i=0; i<n; i++)
		{
        if(ch[i]>max)
		 max=ch[i];
		}
		printf("%d\n",max);
    }
    return 0;
}

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

int main(void) {

	int A, B;
	cin >> A >> B;

	// 消費税が10%のときにB円の消費税が課されるものを探し、それをA円に適用する
	int min = B * (1.0 / 0.10);

	int max = (B + 1) * (1.0 / 0.10);
	if (max * 0.10 == B) {
		max++;
	}
	
	// 確認用
	//std::cout << min << " " << max << std::endl;

	int answer = -1;

	for (int i = min; i < max; i++) {
		if (int(i * 0.08) == A) {
			answer = i;
			break;
		}
	}

	cout << answer;

	return 0;
}

Measured memory_bytes: 256
/*"You can do anything you set your mind to,man" - Eminem*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define llpow(a,b) (ll)(pow(a,b)+0.5)
#define l_b(a,val) min((int)a.size()-1, (int)(lower_bound(a.begin(),a.end(),val)-a.begin()))
#define f first
#define up(a,b) max(a,b)
#define s second
#define INF 9223372036854775807
const  int mod = 1000000007;
template <typename T> T add(T& a, T b){a+=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
template <typename T> T mul(T& a, T b){a*=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
template <typename T> T up_self(T& a, T b){a = up(a,b);}
template <typename T> T min_self(T& a, T b){a = min(a,b);}
ll binexpomodulo(ll x, ll y){ll res =1;x%=mod;if(!x)return 0;while(y){if(y&1){mul(res, x);}mul(x,x);y>>=1;}return res;}
ll nCrInOr(ll n, ll r){ll res = 1;if(r>n-r)r = n-r;ll rin = 1;for(ll i = 1; i <=r ; i++)rin = (rin*i)%mod;rin = binexpomodulo(rin,mod-2);for(ll i = 1; i <= r; i++)res = (res*(n-i+1))%mod;res = (res*rin)%mod;return res;}
int msb(ll n){int ans;for(int i = 0 ; i < 64;  i++)if(n&(1LL<<i))ans = i+1;return ans;}
/*All the macros below are copied from nik_y(OG)*/
#define test() int t; cin>>t; while(t--)
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define all(c) c.begin(),c.end()
#define endl "\n"
#define get(a,n) fl(i,0,n)  cin>>a[i];
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
int main()
{
	Shazam;
	int n; cin>>n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++){
		cin>>a[i];
		if(i){
			a[i]+=a[i-1];
		}
	}
	auto sum = [&](int i, int j){
		if(i)
			return a[j]-a[i-1];
		else
			return a[j];
	};
	vector<vector<ll>> dp(n, vector<ll>(n,INF)); //dp[i][j] minimum cost of combining all the slimes in the range [i,j]
	for(int i = n-1 ; i >=0;  i--){
		for(int j = i ; j < n ;j++){
			if(i==j)
				dp[i][j] = 0;
			else{
				for(int k = i; k<j; k++){
					min_self(dp[i][j] , dp[i][k]+dp[k+1][j] + sum(i,j));
				}
			}
		}
	}	
	cout<<dp[0][n-1]<<endl;
  	return 0;
		
}

Measured memory_bytes: 1536
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
 
  static void Main(string[] args)
  {
    int n = int.Parse(Console.ReadLine());
    var standardStrings = new List<string>();
    standardStrings.Add("a");
    
    for (int i = 2; i <= n; i++)
    {
      var next = new List<string>();
      foreach (var s in standardStrings)
      {
        char max = s.Max();
        if (max < 'z')
          max++;
        for (char c = 'a'; c <= max; c++)
          next.Add((s + c));
      }
      standardStrings = next;
    }
    foreach (var s in standardStrings)
      Console.WriteLine(s);
  }
}

Measured memory_bytes: 27600
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

#define INF (1e+9)
#define LLINF (1e+18)
#define LL long long

using namespace std;

int n,k;
bool flag;
int field[200000];

int dp[200000][2];

int ans;

int reset(){
	for(int i = 0;i < 200000;i++){
		for(int j = 0;j < 2;j++){
			dp[i][j] = 1;
		}
	}
}

int main (void){

	while(true){
		scanf("%d%d",&n,&k);
		if(n == 0 && k == 0)break;

		reset();
		flag = false;
		ans = 0;
		for(int i = 0;i < k;i++){
			scanf("%d",field + i);
		}
		sort(field,field + k);

		for(int i = 0;i < k;i++){
			if(field[i] == 0){
				//puts("###DBG0");
				flag = true;
				dp[i + 1][1] = dp[i][0] + 1;
				i++;
			}
			if(field[i + 1] - field[i] == 1){
				dp[i + 1][0] = dp[i][0] + 1;
				dp[i + 1][1] = dp[i][1] + 1;
			}
			else if(field[i + 1] - field[i] == 2){
				if(flag){
					//puts("###DBG1");
					dp[i + 1][1] = dp[i][0] + 2;
				}
			}
		}

		for(int i = 0;i < k;i++){
			//printf("##%d",field[i]);
			for(int j = 0;j < 2;j++){
				//printf("##%d",dp[i][j]);
				ans = max(ans,dp[i][j]);
			}
			//puts("");
		}

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


	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> ac(N, K - Q);
    for (int i = 0; i < Q; i++) {
        int a;
        cin >> a;
        ac[--a]++;
    }

    for (int x : ac) {
        cout << (x > 0 ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i,N){
        cin >> A[i];
    }
    int ans = 5e7;
    repf(i,-100,101){
        int now = 0;
        rep(j,N){
            now += (i - A[j]) * (i - A[j]);
        }
        ans = min(ans, now);
    }
    cout << ans << endl;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[45][2]; // i桁目までで、k以下であるかがjという状態の

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  
  ll flg=false;
  rep(i,n) if(a[i]%2) flg=true;
  if(flg) cout<<"first"<<endl;
  else cout<<"second"<<endl;
  
}

Measured memory_bytes: 1024
M, D = map(int, input().split())
ans = 0
for i in range(1, M+1):
    for j in range(1, D+1):
        if j % 10 < 2 or j // 10 < 2:
            continue
        else:
            j_str = str(j)
            mul = int(j_str[0]) * int(j_str[1])
            if mul == i:
                ans += 1
print(ans)

Measured memory_bytes: 9196
// 基本テンプレート
 
#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;
 
signed main() {
    int N, S; cin >> N >> S;
    if(N < S) cout << -1 << endl;
    else if(N == S) cout << N+1 << endl;
    else {
        int ans = INF;

        // b > \sqrt(N) -> 2 けた
        for(int d2=1; d2*d2<N; d2++) {
            int d1 = S - d2;
            if(d1 < 0 || (N - d1) % d2) continue;
            int b = (N - d1) / d2;
            if(d1 >= b || d2 >= b) continue;
            chmin(ans, b);
        }

        // b <= \sqrt(N) -> 試す
        for(int b=2; b*b<=N; b++) {
            int P = N, sum = 0;
            while(P) {
                sum += P % b;
                P /= b;
            }
            if(sum == S) chmin(ans, b);
        }
        printf("%lld\n", (ans == INF) ? -1 : ans);
    }
    return 0;
}

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

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

    int sum = 0;
    int a[N];
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        sum ^= a[i];
        a[i] &= -a[i];
    }

    int ans = 0;
    for (int b = 30; b >= 0; --b) {
        if (((sum >> b) & 1) == 0) continue;
        for (int i = 0; i < N; ++i) {
            if (((a[i] >> b) & 1) == 1) {
                ++ans;
                sum ^= (a[i] << 1) - 1;
                break;
            }
        }
    }

    cout << (sum > 0 ? -1 : ans) << endl;
    return 0;
}


Measured memory_bytes: 640
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;
using ll = long long;

ll a, b, c, d;

ll gcd(ll a, ll b) {
    if (a % b == 0) return b;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c >> d;
    ll k = lcm(c, d);
    ll cntc = b / c - (a - 1) / c;
    ll cntd = b / d - (a - 1) / d;
    ll cntcandd = b / k - (a - 1) / k;
    ll cntcord = cntc + cntd - cntcandd;
    // D(k);
    cout << b - a + 1 - cntcord << endl;
}


Measured memory_bytes: 888
#include<iostream>
#include <string>
#include<vector>
#include<cmath>

typedef long long ll;

using namespace std;
ll mypow(int x,int y) {
	ll kotae=1;
	if (y = 0) {
		return kotae;
	}
	for (int i = 0; i < y; i++) {
		kotae *= x;
	}
	return kotae;
}

int main()
{
	int n;
	cin >> n ;
	vector<int> ra;
	while (1) {	
		int temp;
		if (n % 2) {
			temp = 1;
		}
		else {
			temp = 0;
		}
		ra.push_back(temp);
		if (n -temp== 0) break;
		n -=temp;
		n /= (-2);
	}
	for (int i = 0; i < ra.size(); i++) {
		cout <<ra[ra.size()-1-i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	ll a,b; cin>>a>>b;
	ll p = 10*b;
	for(ll i=p;i<=p+9;i++)
	{
	    if( (i*8)/100 == a ){ cout<<i; return 0; }
	}
	cout<<-1;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
   int n,m=0;
   cin>>n;
   int sum=0;
   rep(i,0,n) {
      int l;
      cin>>l;
      sum=sum+l;
      if(m<l)m=l;
   }
   if (sum-2*m>0) cout<<"Yes";
   else cout<<"No";
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = []
B = []
ans = [1 for i in range(N)]
for i in range(M): 
    a, b = map(int, input().split())
    if H[a-1] < H[b-1]:
        # print()
        # print("bad")
        # print(str(a))
        ans[a-1] = 0
    elif H[a-1] == H[b-1]:
        ans[a-1] = 0
        ans[b-1] = 0

    else:
        ans[b-1] = 0

# print(ans)
print(sum(ans))

Measured memory_bytes: 91192
#include <iostream>
#include <string>
#include <vector>
using namespace std;

const string MINUS_INF = "-";

void update_char_max(string &a, string b){
    if (a == MINUS_INF){
        a = b;
    } else if (a.size() < b.size()) {
        a = b;  // stringの比較のため、まず桁違いのものは更新
    } else if (a.size() == b.size()) {
        if (a < b) {
          a = b;  // 同じ桁のstringは純粋に値の比較
        }
    }
}

long long match_map[10] = {2,5,5,4,5,6,3,7,6};
string dp[100000];

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<int> a(m);
    for (int i=0; i<m; ++i) {
        cin >> a[i];
    }

    // 初期化
    for (int i=0; i<100000; ++i) {
        dp[i] = MINUS_INF;
    }

    // 初期条件
    dp[0] = "";

    // DP ループ
    for (int i = 0; i <= n; ++i) {
        if (dp[i] == MINUS_INF) continue;
        for (auto ae : a) {
            update_char_max(dp[i+match_map[ae-1]], dp[i]+(char)('0'+ae));
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 44416
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = 1
i = 0

while flag:
    flag = 0
    for j in range(N - 1, i , -1):
        if A[j - 1] > A[j]:
            v = A[j - 1]
            A[j - 1] = A[j]
            A[j] = v
            count += 1
            flag = 1
    i += 1

s = [str(a) for a in A]
s = ' '.join(s)
print(s)
print(count)



Measured memory_bytes: 5604
#include <iostream>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;
using std::pow;

int main()
{
  int n, k;

  cin >> n >> k;
  long long ans = pow((k - 1), n - 1) * k;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
N=1
for i in range(n):
    N*=(i+1)
a=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
l=[0 for i in range(len(a))]
k=0
for i in a:
    tmp=N
    while True:
        if tmp%i==0:
            l[k]+=1
            tmp=tmp//i
        else:
            k+=1
            break
up74=len([i for i in l if i>=74])
up24=len([i for i in l if i>=24])
up14=len([i for i in l if i>=14])
up4=len([i for i in l if i>=4])
up2=len([i for i in l if i>=2])
print(up74+up24*(up2-1)+up14*(up4-1)+up4*(up4-1)//2*(up2-2))

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
int a[N], b[N], n;
void solve(){
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i] >> b[i];
    }
    for(int i = 1; i + 2 <= n; ++i) {
        if(a[i] == b[i] && a[i + 1] == b[i + 1] && a[i + 2] == b[i + 2]) {
            cout << "Yes";
            return;
        }
    }
    cout << "No";
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 3648
class Point
  attr_accessor :x, :y
  def initialize(x, y)
    @x = x
    @y = y
  end

  def +(p)
    Point.new(@x + p.x, @y + p.y)
  end

  def -(p)
    Point.new(@x - p.x, @y - p.y)
  end

  def *(k)
    Point.new(@x * k, @y * k)
  end

  def to_s
    "#{@x} #{@y}"
  end
end

def dot(a, b)
  a.x * b.x + a.y * b.y
end

def cross(a, b)
  a.x * b.y - a.y * b.x
end

def norm(a)
  a.x * a.x + a.y * a.y
end

Segment = Struct.new('Segment', :p1, :p2)

def project(s, p)
  base = s.p2 - s.p1
  r = dot(p - s.p1, base).to_f / norm(base)
  s.p1 + base * r
end

x0, y0, x1, y1 = gets.split.map(&:to_i)
p0 = Point.new(x0, y0)
p1 = Point.new(x1, y1)
base = Segment.new(p0, p1)

n = gets.to_i
n.times do
  x, y = gets.split.map(&:to_i)
  p = Point.new(x, y)
  puts project(base, p).to_s
end


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

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

      double h_d, m_d, pi, deg_r, ans_rad, ans;
      h_d = (h*30 + m/2);
      m_d = m*6;
      pi = 3.14159265358979;
      deg_r = abs(h_d - m_d) * pi/180;


      ans_rad = a*a + b*b - 2*a*b*cos(deg_r);
      ans = sqrt(ans_rad);

      cout << fixed << setprecision(10) << ans <<endl;
}


Measured memory_bytes: 4188
a, b, c = map(int, input().split())
za = 0
zb = 0
zc = 0

d = 0

if a == b == c and a % 2 == 0:
    print(-1)
    exit()
elif not(a % 2 == 0 and b % 2 == 0 and c % 2 ==0):
    print(0)
    exit()


while a % 2 == 0 and b % 2 == 0 and b % 2 == 0:

    za = a
    zb = b
    zc = c

    a = zb // 2 + zc // 2
    b = za // 2 + zc // 2
    c = za // 2 + zb // 2

    d += 1

print(d)

Measured memory_bytes: 3064
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	map<char,ll> m ;
	string march = "MARCH" ;
	for(int i=0;i<5;i++) m[march.at(i)] = 0 ;
	for(int i=0;i<n;i++){
		string s ; cin >> s ;
		for(int i=0;i<5;i++){
			if(s.at(0)==march.at(i)){
				m[march.at(i)]++ ;
			}
		}
	}
	ll ans = 0 ;
	for(int i=0;i<3;i++){
		for(int j=i+1;j<4;j++){
			for(int k=j+1;k<5;k++){
				ans += m[march.at(i)]*m[march.at(j)]*m[march.at(k)] ;
			}
		}
	}
	cout << ans << endl ;
}


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

const int mod=2019;

int main()
{
    string S;
    cin >> S;
    int n=S.size();
    int T[n+1];
    int ten=1;
    int dp[mod];
    for(int i=0;i<mod;i++)dp[i]=0;
    for(int i=0;i<=n;i++)T[i]=0;
    for(int i=n-1;i>=0;i--){
        T[i]=T[i+1]+(S[i]-'0')*ten;
        T[i]%=mod;
        ten*=10;
        ten%=mod;
    }
    for(int i=0;i<=n;i++){
        dp[T[i]]++;
    }
    int ans=0;
    for(int i=0;i<mod;i++){
        dp[i]=dp[i]*(dp[i]-1)/2;
        ans+=dp[i];
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 4456
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        int[] md1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] md2 = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var ans = "0";
        if(md1[0] !=md2[0]) ans = "1";
        
        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"("<<(x).FI<<", "<<(x).SE<<")"<<endl;
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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


int main()
{
  int A, B; cin >> A >> B;
  if (B % A == 0) cout << (A + B) << endl;
  else cout << (B - A) << endl;
  return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
ans=0
r=w%2
rh=h%2
if h==1 or w==1:
  ans=1
if ans==0:
  if r==0:
    ans=(w//2)*h
  else:
    if rh==0:
      ans=w*(h//2)
    else:
      ans=w*(h//2)+(w//2)+1
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,a) for(int i=lst[a];i;i=nxt[i])
using namespace std;

typedef long long ll;

const int N=2e3+5,Mo=1e9+7;

int t[N],v[N],nxt[N],lst[N],l;
void add(int x,int y,int z) {t[++l]=y;v[l]=z;nxt[l]=lst[x];lst[x]=l;}

int n,m,pw[N],fa[N],dep[N],val[N];
bool used[N];
ll w;

int get(int x) {return fa[x]?fa[x]=get(fa[x]):x;}

struct Edge{int x,y,z;}e[N],p[N];
bool cmp(Edge a,Edge b) {return a.z<b.z;}

void dfs(int x,int y) {
	fa[x]=y;dep[x]=dep[y]+1;
	rep(i,x)
		if (t[i]!=y) {
			val[t[i]]=v[i];
			dfs(t[i],x);
		}
}

int find(int x,int y) {
	if (dep[x]<dep[y]) swap(x,y);
	int mx=0;
	for(;dep[x]>dep[y];x=fa[x]) mx=max(mx,val[x]);
	for(;x!=y;x=fa[x],y=fa[y]) mx=max(mx,max(val[x],val[y]));
	return mx;
}

int main() {
	scanf("%d%d%lld",&n,&m,&w);
	fo(i,1,m) scanf("%d%d%d",&e[i].x,&e[i].y,&e[i].z);
	sort(e+1,e+m+1,cmp);
	ll c=0;int mm=0;
	fo(i,1,m) {
		int x=get(e[i].x),y=get(e[i].y);
		if (x==y) {p[++mm]=e[i];continue;}
		fa[y]=x;c+=e[i].z;
		add(e[i].x,e[i].y,e[i].z);
		add(e[i].y,e[i].x,e[i].z);
	}
	if (c>w) {puts("0");return 0;}
	fo(i,1,n) fa[i]=0;dfs(1,0);
	pw[0]=1;fo(i,1,m) pw[i]=(pw[i-1]<<1)%Mo;
	int ans=(c==w)?(ll)(pw[n-1]-2)*pw[m-n+1]%Mo:0;
	fo(i,1,mm) p[i].z-=find(p[i].x,p[i].y);
	sort(p+1,p+mm+1,cmp);
	fo(i,1,mm) if (c+p[i].z==w) (ans+=pw[mm-i+1])%=Mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

struct UnionFind {
    V<ll> rank;
    V<ll> parent;
    V<ll> size;

    UnionFind(ll N) : rank(N, 0), parent(N), size(N, 1) {
        iota(parent.begin(), parent.end(), 0ll);
    }

    ll find(ll child) {
        return (child == parent[child] ? child : parent[child] = find(parent[child]));
    }

    void unit(ll x, ll y) {
        ll px = find(x);
        ll py = find(y);
        if(px == py) {
            return;
        }
        if(rank[px] < rank[py]) {
            swap(px, py);
        }
        parent[py] = px;
        rank[px] += (rank[px] == rank[py]);
        size[px] += size[py];
    }

    bool same(ll x, ll y) {
        return (find(x) == find(y));
    }
};
    
const size_t max_size = 3e5 + 1;
using BS = bitset<max_size>;

int main() {
    ll N, R;
    cin >> N >> R;
    V<ll> P(N);
    for(auto &&e : P) { 
        cin >> e;
        e--; 
    }
    UnionFind uf(N);
    for(ll i = 0; i < N; i++) uf.unit(P[i], i);
    BS bs(1);
    ll cnt_one = 0;
    for(ll i = 0; i < N; i++) if(uf.find(i) == i) {
        auto s = uf.size[i];
        if(2 <= s) bs |= (bs << uf.size[i]);
        else cnt_one++;
    }

    for(auto n : { R, N - R }) {
        for(ll i = max<ll>(n - cnt_one, 0); i <= n; i++) if(bs.test(i)) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 12296
import java.util.List;
import java.util.Scanner;
import java.util.Vector;

public class Main {

	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ST st = new ST();
		st.init(N);
		int h[] = new int[N];
		int a[] = new int[N];
		for (int i=0;i<N;i++) 
			h[i] = sc.nextInt()-1;
		for (int i=0;i<N;i++) 
			a[i] = sc.nextInt();
		
		for (int i=0;i<N;i++) {
			long m = st.Q(0, h[i]);
			
			st.update(h[i], m+a[i]);
		}
		System.out.println(st.Q(0, N));
	}

}

class ST{
	int MaxN = 1 << 18;
	int n;
	long dat[] = new long[2 * MaxN - 1];

	void init(int n_) {
		n = 1;
		while (n < n_)
			n *= 2;
		for (int i = 0; i < 2 * n - 1; i++)
			dat[i] = 0; // Set min value
	}

	void update(int k, long a) {
		k += n - 1;
		dat[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = Math.max(dat[k * 2 + 1], dat[k * 2 + 2]); // Max
		}
	}

	long query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)
			return 0;
		if (a <= l && r <= b)
			return dat[k];
		long vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		long vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return Math.max(vl, vr); // Max
	}
	
	long Q(int a, int b) {
		return query(a,b,0,0,n);
	}
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int W, H, x, y, r;
  scanf(" %d %d %d %d %d", &W, &H, &x, &y, &r);
  if ((x - r) < 0) {
    printf("No\n");
    return 0;
  }
  if ((y - r) < 0) {
    printf("No\n");
    return 0;
  }
  if ((x + r) > W) {
    printf("No\n");
    return 0;
  }
  if ((y + r) > H) {
    printf("No\n");
    return 0;
  }
  printf("Yes\n");
}



Measured memory_bytes: 2676
const main = stdin => {
  const input = stdin.trim().split('\n')
  const N = parseInt(input[0])
  const S = input[1]

  let max = 0
  for (let i = 0; i < N; i++) {
    const leftMemo = []
    for (let j = 0; j <= i; j++) {
      leftMemo.push(S[j])
    }
    const rightMemo = []
    for (let j = i + 1; j < N; j++) {
      rightMemo.push(S[j])
    }

    const productSet = leftMemo.filter(val => rightMemo.includes(val))

    const uniqueSet = new Set(productSet)
    max = Math.max(max, uniqueSet.size)
  }

  console.log(max)
}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 30296
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
type Element struct {
	id, cost int
}

type PQ []Element

func (pq PQ) Len() int           { return len(pq) }
func (pq PQ) Less(i, j int) bool { return pq[i].cost > pq[j].cost }
func (pq PQ) Swap(i, j int)      { pq[i], pq[j] = pq[j], pq[i] }

func (pq *PQ) Push(x interface{}) {
	*pq = append(*pq, x.(Element))
}

func (pq *PQ) Pop() interface{} {
	old := *pq
	n := len(old)
	x := old[n-1]
	*pq = old[0 : n-1]
	return x
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, M := sc.nextInt(), sc.nextInt()
	pq := &PQ{}
	heap.Init(pq)
	for i := 0; i < N; i++ {
		heap.Push(pq, Element{i, sc.nextInt()})
	}
	ans := 0
	for pq.Len() > 0 {
		e := heap.Pop(pq).(Element)
		if M > 0 {
			e.cost /= 2
			M--
			heap.Push(pq, e)
		} else {
			ans += e.cost
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


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

using namespace std;

typedef long long int ll;
 
template<class T> inline bool chmax(T& a,T b){ if(a<b){ a=b; return true;} return false; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){ a=b; return true;} return false; }
 
typedef pair<int,int> pair;

int main(){
  int n,m; cin >> n >> m;
  vector<int> a(n); for(int i=0;i<n;i++) cin >> a[i];

  int sum=0;
  for(auto v : a) sum+=v;

  double border=0.25*sum/m;

  int count=0;
  for(auto v : a){
    if((double)v >= border)
      count++;
  }

  if(count>=m) puts("Yes");
  else puts("No");
}

Measured memory_bytes: 256
// Karm Karta ja, Phal Ki Chinta na Kar:)
#include <bits/stdc++.h>
using namespace std;
#include<stdio.h>
typedef long long int ll;
#define INF 1e18+3
#define M 1000000007
#define PI 3.14159265358979323846
int main()
{
    string S;
    cin>>S;
    int n=S.length();
    int i,ans=0;
    for(i=0;i<n/2;i++)
    {
       if(S[i]!=S[n-i-1])
       {

           ans++;
       }
    }
    cout<<ans;
}






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

int N, A, B;
int main(){
  cin >> N >> A >>B;
  
  int counter =0;
  for (int i=1; i < N+1; ++i){
    int num4 = i /10000;
    int num3 = (i - num4 *10000) /1000;
    int num2 = (i - num4 *10000- num3 *1000) /100;
    int num1 = (i - num4 *10000- num3 *1000- num2*100) /10;
    int num = (i - num4 *10000 - num3 *1000 -num2*100 -num1*10);

    if ( num4 +num3 +num2 +num1 +num > A-1 && num4 +num3 +num2 +num1 +num  < B+1){
      counter += i;
    }
  }
  cout << counter << endl;
  return 0;
}

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

    using namespace std;
    int main(){
    string s;
      cin>>s;
      bool f=false;
      for(int i=0; i<s.size(); i++)
      {
      if(s[i]=='7')
      {
        f=true;
        break;
      }
      }
      if(f)
        cout<<"Yes"<<endl;
      else
        cout<<"No"<<endl;
    }


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) printf("%d ", v[X]); printf("\n");
#define endl "\n"
const int INF= 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
const int MOD=1e9+7;
const ll LINF=0x3f3f3f3f3f3f3f3f;

int n;

int main() {
  int cont4 = 0, cont2 = 0, conti = 0;
  sc(n);
  for(int i = 0; i < n; i++) {
    int a;
    sc(a);
    if(a % 4 == 0) cont4++;
    else if(a % 2 == 0) cont2++;
    else conti++;
  }
  if(cont4 > conti) {
    cout<<"Yes"<<endl;
    return 0;
  }
  if(cont4 == conti - 1 and cont2 == 0 and n % 2 == 1) {
    cout<<"Yes"<<endl;
    return 0;
  }
  if(cont4 == conti) {
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
Answer_list = []
for i in list(S):
    num = ord(i)+N
    if num >= 65 and num <= 90:
        Answer_list.append(chr(num))
    elif num > 90:
        Answer_list.append(chr(num - 26))
print(''.join(Answer_list))

Measured memory_bytes: 3188