akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
const u32 P=1e9+7;
inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
u64 power(u64 a, int b) {
	u64 ans=1;
	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
	return ans;
}

const int N=101;
int n, m, h[N], real[N];
u32 f[N];
int main() {
	n=rd();
	for(int i=0; i<n; ++i) h[i]=real[i]=rd();
	std::sort(real, real+n);
	m=std::unique(real, real+n)-real;
	for(int i=0; i<n; ++i) h[i]=std::lower_bound(real, real+m, h[i])-real;
	f[0]=power(2, real[h[0]]);
	for(int i=0; i<=h[0]; ++i) f[i+1]=power(2, real[h[0]]-real[i]+1);
	for(int i=0; i<=h[0]; ++i) dec(f[i], f[i+1]);
	for(int i=1; i<n; ++i) {
		if(h[i]<=h[i-1]) {
			u32 s=0;
			for(int j=h[i]; j<=h[i-1]; ++j) inc(s, f[j+1]), f[j+1]=0;
			f[h[i]+1]=2*s%P;
		} else {
			u32 g=f[h[i-1]+1];
			for(int j=h[i-1]; j<=h[i]; ++j) f[j+1]=g*power(2, real[h[i]]-real[j]+1)%P;
			for(int j=h[i-1]; ++j<=h[i]; ) dec(f[j], f[j+1]);
			u64 p=power(2, real[h[i]]-real[h[i-1]]);
			for(int j=0; j<=h[i-1]; ++j) f[j]=f[j]*p%P;
		}
	}
	u32 ans=0;
	for(int i=0; i<=h[n-1]+1; ++i) inc(ans, f[i]);
	printf("%u\n", ans);
	return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import deque
import re
import math
import functools

def sRaw():
    return input().rstrip("\r")

def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29


def make1d_arr(n, val=INF):
    return [val for i in range(n)]


def make2d_arr(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]


def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)


def BFord(n,es):
    v_cost = [INF]*n
    v_cost[0] = 0
    for v in range(n*2):
        for e in es:
            frm = e[0]
            to = e[1]
            if v_cost[to] > v_cost[frm]+e[2]:
                v_cost[to] = v_cost[frm]+e[2]
                if v >= n:
                    v_cost[to] = -INF
        if v == n-1:
            prev = v_cost[:]
    v_cost = [-INF if prev[idx]!=v_cost[idx] else v_cost[idx] for idx in range(n)]
    return v_cost
    
def ZAlgo(s):
    l = len(s)
    A = [0]*l
    i =1
    j =0
    A[0]=l
    while i<l:
        while i+j<l and s[j] == s[i+j]:
            j+=1
        if j==0:
            i+=1
            continue
        A[i]=j
        k=1
        while (i+k<l) and (k+A[k]<j):
            A[i+k] =A[k]
            k+=1
        i+=k
        j-=k
    return A


DIV = 998244353

def main():
    X = iRaw()
    Y=X
    while True:
        Z = 2
        mayPrime = True
        while Z*Z <=Y:
            if Y%Z==0:
                mayPrime=False
                break
            Z+=1
        if mayPrime:
            return Y
        Y+=1
    

if __name__ == "__main__":

    print(main())


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

int main()
{
	int n, m, d;
	cin >> n >> m >> d;

	double ans = (double)1 / n;
	if( d ) ans = (double)2 * (n - d) /n / n;
	ans *= (m - 1);

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <cstdlib> //絶対値整数abs
#include <cmath>   //絶対値少数fbs
#include <math.h>
using namespace std;
#define rep(i, N) for (ll i = 0; i < (N); i++)
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k, s;
    cin >> k >> s;
    ll x, y;
    ll count = 0;
    rep(i, k + 1)
    {
        rep(j, k + 1)
        {
            x = i;
            y = j;
            ll z = s - x - y;
            if (z >= 0 && z <= k)
            {
                count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
string n;
cin>>n;
int i,l;
long long sum=0;
l=n.size();
for(i=0;i<l;i++){
    sum=sum+n[i]-48;
}
  if(sum%9==00)
cout<<"Yes";
     else
     cout<<"No";
     
     return 0;
}

Measured memory_bytes: 3664
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();
        char[] S = s.toCharArray();
        char[] T = t.toCharArray();
        int cnt=0;
        for(int i=0; i<3; i++){
            if(S[i] == T[i]){
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21972
#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;
    ll T, A;
    cin >> T >> A;
    pll ans=mp(T,A);
    ll k;
    //cout << endl;
    ll x, y;
    rep(i, N-1){
        //cout << ans.first << " " << ans.second << endl;
        cin >> T >> A;
        k = max((ans.first + T - 1) / T, (ans.second + A - 1) / A);
        while (ans.first>k*T||ans.second>k*A){
            k++;
        }
        ans = mp(k * T, k * A);
    }
    //cout << ans.first << " " << ans.second << endl;
    cout << ans.first + ans.second << endl;
}


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

using std::cin;
using std::cout;

struct vertex {
    int vv;
    int ww;
};

//enum class VColor {White, Gray, Black};
typedef enum {White, Gray, Black} VColor;

void
dfsearch(std::vector<vertex> *gar, int gsz, int uu,
         std::vector<VColor> &color,
         std::vector<int> &dd, std::vector<int> &ff, std::vector<int> &prev,
         int &cnt)
{
    color[uu] = Gray;
    dd[uu] = ++cnt;
    //cout << uu << " " << cnt << std::endl;
    std::vector<vertex>::iterator it = gar[uu].begin();
    for (; it != gar[uu].end(); it++) {
        int     vv = (*it).vv;
        if (color[vv] == White) {
            prev[vv] = uu;
            dfsearch(gar, gsz, vv, color, dd, ff, prev, cnt);
        }
    }
    
    color[uu] = Black;
    ff[uu] = ++cnt;
    return;
}

int
main()
{
    int vn;
    std::vector<vertex> gar[100 + 1];

    cin >> vn;
    for (int idx = 0; idx < vn; idx++) {
        int uu;
        int kk;
        int vv;

        cin >> uu >> kk;
        for (int ik = 0; ik < kk; ik++) {
            cin >> vv;
            gar[uu].push_back({vv, 1});
        }
    }

#if 0
    for (int uu = 1; uu <= vn; uu++) {
        std::vector<vertex>::iterator it = gar[uu].begin();
#if 0
        for (; it != gar[uu].end(); it++) {
            printf("v = %d w = %d\n", (*it).vv, (*it).ww);
        }
#else
        for (int vv = 1; vv <= vn; vv++) {
            if (vv != 1) cout << ' ';
            if ((it != gar[uu].end()) && ((*it).vv == vv)) {
                cout << '1';
                it++;
            } else {
                cout << '0';
            }
        }
        cout << std::endl;
#endif
    }
#endif

    std::vector<VColor> color;
    std::vector<int> dd;
    std::vector<int> ff;
    std::vector<int> prev;
    int counter;

    color.assign(vn + 1, White);
    dd.assign(vn + 1, 0);
    ff.assign(vn + 1, 0);
    prev.assign(vn + 1, 0);

    counter = 0;
    dfsearch(gar, vn, 1, color, dd, ff, prev, counter);
    std::vector<VColor>::iterator cit = color.begin();
    for (cit++; cit != color.end(); cit++) {
        if (*cit == White) {
            dfsearch(gar, vn, std::distance(color.begin(), cit), color,
                     dd, ff, prev, counter);
        }
    }

    for (int uu = 1; uu <= vn; uu++) {
        cout << uu << " " << dd[uu] << " " << ff[uu] << std::endl;
    }
}

    



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

using namespace std;

using ll = long long;
using pii = pair<int, int>;

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    int n;
    ll x;
    cin >> n >> x;

    vector<ll> a(n);
    for(auto &y:a)
        cin >> y;
    
    ll ans=0;
    for(int i=0;i<n-1;i++){
        if(a[i]+a[i+1]<=x){
            continue;
        }else{
            ll sum=a[i]+a[i+1];
            ans+=sum-x;
            if(a[i+1]-(sum-x)>=0)
                a[i+1]-=sum-x;
            else{
                a[i]-=sum-x-a[i+1];
                a[i+1]=0;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4048
//
//  main.cpp
//  ThreeColor
//
//  Created by Mihozil on 4/26/19.
//  Copyright © 2019 Mihozil. All rights reserved.
//

#include <iostream>
using namespace std;
typedef long ll;
#define maxD 998244353
ll n;
ll a[301];
ll c[301][90001],cc[301][90001];

void solve() {
    ll allCase = 1;
    for (int i=1;i<=n; i++) {
        allCase = (allCase*3)%maxD;
    }
    
    ll total = a[1];
    c[1][a[1]] = 1;
    c[1][0] = 2;

    for (ll i=2; i<=n; i++) {
        total += a[i];
        for (ll j = 0; j<=total; j++) {
            c[i][j] = (c[i-1][j]*2)%maxD;
            if (j>=a[i])
                c[i][j] = (c[i][j] + c[i-1][j-a[i]])%maxD;
        }
    }
    
    ll subtract = 0;
    ll begin = total/2+1;
    for (ll j=begin; j<=total; j++)
        subtract = (subtract + c[n][j])%maxD;
    
    ll result = (allCase-(subtract*3)%maxD)%maxD;
    
    if (total%2==0) {
            total = a[1];
            cc[1][a[1]] = 1;
            cc[1][0] = 1;
            for (ll i=2; i<=n; i++) {
                total+=a[i];
                for (ll j=0; j<=total; j++) {
                    cc[i][j] = cc[i-1][j];
                    if (j>=a[i]) {
                        cc[i][j] = (cc[i][j] + cc[i-1][j-a[i]])%maxD;
                    }

                }
            }
            ll more = (c[n][total/2]*3)%maxD - (cc[n][total/2]*3)%maxD;
            more = more%maxD;
            result = (result - more)%maxD;
        }

    
    if (result<0)
        result+=maxD;
    
    cout<<result;
    
}

void read() {
    cin>>n;
    for (ll i=1; i<=n; i++)
        cin>>a[i];
    solve();
}

int main(int argc, const char * argv[]) {
    // insert code here...
//#if DEBUG
//    freopen("/Users/mihozil/Desktop/CodeJam/input.in", "r", stdin);
//#endif
    read();
    return 0;
}


Measured memory_bytes: 421504
#include <iostream>

using namespace std;
static const int SIZE = 10001;
int parent[SIZE];
int rk[SIZE];

void init()
{
	for (int i = 0; i < SIZE; ++i)
	{
		parent[i] = i;
		rk[i] = 0;
	}
}

int find(int x)
{
	if (x == parent[x])
	{
		return(x);
	}
	else
	{
		return(parent[x] = find(parent[x]));
	}
}

void unite(int x, int y)
{
	x = find(x);
	y = find(y);
	if (x == y)
	{
		return;
	}
	if (rk[x] < rk[y])
	{
		parent[x] = y;
	}
	else
	{
		parent[y] = x;
		if (rk[x] == rk[y])
		{
			rk[x]++;
		}
	}
}

bool same(int x, int y)
{
	return(find(x) == find(y));
}

void solve()
{
	init();
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < q; ++i)
	{
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0)
		{
			unite(x, y);
		}
		else
		{
			if (same(x, y))
			{
				cout << 1 << endl;
			}
			else
			{
				cout << 0 << endl;
			}
		}
	}
}

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

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

using namespace std;
using ll = long long;

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<ll> que;
    for (int i = 0; i < n; i++) 
    {
        ll a; cin >> a; que.push(a);
    }

    for (int i = 0; i < m; i++)
    {
        ll t = que.top(); que.pop();
        que.push(t / 2);
    }
    ll res = 0;
    while(!que.empty()) res += que.top(), que.pop();
    cout << res << endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 998244353;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum,ans;
ll a,b,c,d,e,f,g,h,w,v;
ll x[800005],y[800005],z[900005];




int main(){	
	cin>>n>>m;
	if((n*m)%2){
		p("Yes");
	}else{
		p("No");
	}
		
	return 0;
}

Measured memory_bytes: 6016
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,vector<ll> > P;
typedef pair<P,ll>Q;

int s[102]; 

int main(void){
    int n,k;
    cin>>n>>k;
    for(int i=0;i<k;i++){
        int d;
        cin>>d;
        for(int j=0;j<d;j++){
            int a;
            cin>>a;
            s[a]++;
        }
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(s[i]==0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		int n, ans;
		double res, min;
		
		while(!(string = reader.readLine()).equals("0")){
			n = Integer.valueOf(string);
			
			min = 1 << 29;
			ans = 0;
			for(int i = 0; i < n; i++){
				String str[] = reader.readLine().split(" ");
				
				res = Double.valueOf(str[2]) / Math.pow(Double.valueOf(str[1]) / 100 , 2);
				res = 22. > res ? 22. - res : res - 22.;
				if(min > res){
					min = res;
					ans = Integer.valueOf(str[0]);
				}
			}
			System.out.println(ans);
		}
		reader.close();
	}
}

Measured memory_bytes: 27616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		var pq=new Pq<Mo<int>>(100000,true);
		int[] b=new int[100000];
		pq.Push(new Mo<int>(1,1));
		b[1]=1;
		while(pq.Top.d!=0){
			int p=pq.Top.n,q=pq.Top.d;
			pq.Pop();
			if(b[(q*10)%n]==0||b[(q*10)%n]>p){pq.Push(new Mo<int>(p,(q*10)%n));b[(q*10)%n]=p;}
			if(b[(q+1)%n]==0||b[(q+1)%n]>p+1){pq.Push(new Mo<int>(p+1,(q+1)%n));b[(q+1)%n]=p+1;}
		}
		Console.WriteLine("{0}",pq.Top.n);
	}
}
public class Mo<T>:IComparable{
	public int n;
	public T d;
	public Mo(int n,T d){this.n=n;this.d=d;}
	public int CompareTo(object obj){
		Mo<T> mymo=(Mo<T>)obj;
		if(mymo.n>n){return -1;}
		else if(mymo.n<n){return 1;}
		else{return 0;}
	}
}
public class Pq<T> where T:IComparable{
	private T[] he;
	public int cnt=0;
	private Func<T,T,int> compare;
	public Pq(int max,bool mm){
		he=new T[max];
		if(mm){compare=Ao;}
		else{compare=Do;}
	}
	public void Push(T x){
		int j=cnt;
		while(j!=0&&compare(x,he[(j-1)/2])>0){he[j]=he[(j-1)/2];j=(j-1)/2;}
		he[j]=x;
		cnt++;
	}
	public void Pop(){
		cnt--;
		T r=he[cnt];
		int j=0;
		while(true){
			if(j*2+1<cnt){
				if(compare(he[j*2+1],he[j*2+2])>0){j=j*2+1;}
				else{j=j*2+2;}
			}
			else if(j*2<cnt){j=j*2+1;}
			else{break;}
			if(compare(he[j],r)<=0){j=(j-1)/2;break;}
			he[(j-1)/2]=he[j];
		}
		he[j]=r;
	}
	private int Ao(T x,T y){return y.CompareTo(x);}
	private int Do(T x,T y){return x.CompareTo(y);}
	public T Top{get{return he[0];}}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 16224
/*siddharth goyal*/
#include<bits/stdc++.h>
using namespace std;
#define   pb              push_back
#define   REP(i,n)        for(int i=1;i<=n;i++)
#define   FOR(i,a,b)      for(int i=a;i<=b;i++)
#define   all(v)          v.begin(),v.end()
#define   F               first
#define   S               second
#define   vl              vector<LL>
#define   itr             ::iterator it
#define   lb              lower_bound
#define   ub              upper_bound
#define   LL              long long
#define   ULL             unsigned long long
#define   ret             return 
#define   sz(x)           (LL)x.size()
LL n,i,j,ans = 0,m,dp[1000+2][1000+2];
LL M = (LL)1E9 + 7 ; 
string s[1000+2] ; 
int main()
{   // Read the constraints,highlights,Time Limit,Test Cases
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m ; 
    REP(i,n) cin>>s[i],s[i] = "x" + s[i]  ; 
    dp[1][1] = 1 ;
    for(int i=1;i<=n;i++)
    {  for(int j=1;j<=m;j++)
         if(s[i][j]=='.') dp[i][j] = (dp[i-1][j] + dp[i][j-1] + dp[i][j] +  M)%M ; 
    }
    cout<<dp[n][m]<<endl ; 

}
//Check for 0,1 and other corner cases.

Measured memory_bytes: 9088
N=int(input())
dic={}

for _ in range(N):
    s = input()
    if dic.get(s[0],0)==0:
        dic[s[0]]=1
    else:
        dic[s[0]]+=1
ans=0

m='MARCH'
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans+=dic.get(m[i],0)*dic.get(m[j],0)*dic.get(m[k],0)
print(ans)

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

int main() {
  ll n, ans;
  cin >> n;
  ans = 0;
  rep(i, n) {
    if(i % 3 != 0 && i % 5 != 0) {
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>//"geometry.cpp"
#include <iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
#include <queue>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <algorithm>//"lower_bound(it,it,v)", "next_permutation(a,a+n)"
#include <functional>//"greater<T>" Ex. sort(a,a+n,greater<int>());
#include <cmath>//"abs", "sqrt"
using namespace std;
#define pb push_back//Can be used for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert
typedef pair<int,int> pii;//Add other types in the same way.

struct edge{
	int to,cost;
};

vector<edge> g[15];
int n,dp[1<<15][15],c[1<<15];

int main(){
	int m,sc=0;
	cin>>n>>m;
	for(int j=0;j<m;++j){
		int a,b,c;
		cin>>a>>b>>c;
		sc+=c;
		g[--a].pb((edge){--b,c});
		g[b].pb((edge){a,c});
	}
	for(int s=0;s<1<<n;++s){
		c[s]=0;
		for(int v=0;v<n;++v){
			if(!(1&(s>>v))) continue;
			for(int j=0;j<g[v].size();++j){
				int w=g[v][j].to;
				if(v>w&&((s>>w)&1)) c[s]+=g[v][j].cost;
			}
		}
	}
	for(int s=1;s<1<<n;++s){
		if(!(s&1)) continue;
		fill(dp[s],dp[s]+n,-1);
		dp[s][0]=c[s];
	}
	for(int s=3;s<(1<<n);++s) for(int v=1;v<n;++v) if((s&1)&&((s>>v)&1)){
		for(int j=0;j<g[v].size();++j){
			int w=g[v][j].to,D=dp[s-(1<<v)][w];
			if(((s>>w)&1)&&D>=0) dp[s][v]=max(dp[s][v],D+g[v][j].cost);
		}
		for(int t=(s-1)&s;t>0;t=(t-1)&s){
			int D=dp[t][v];
			if((t&1)&&((t>>v)&1)&&D>=0) dp[s][v]=max(dp[s][v],D+c[s-t+(1<<v)]);
		}
	}
	cout<<sc-dp[(1<<n)-1][n-1]<<endl;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
vector<int> v;
for(int i = 1 ; i <= sqrtl(n) ; i++){
   if(n%i == 0){
      if(i != 1){
	    v.pb(i);
	  }
	  if(n/i != i){
	    v.pb(n/i);
	  }
   }
}
int cnt = 0;
set<int>st;
int temp = n;
for(auto it:v){
  int x = it;
  n = temp;
  while(n%x == 0){
   n = n/x;
  }
  if(n%x == 1){st.insert(x);cnt++;}
}
// n -1 ke divisors bhi 
n = temp-1;
v.clear();
for(int i = 1 ; i<= sqrtl(n) ; i++){
  if(n%i == 0){
    if(i != 1){
	 v.pb(i);
	}
	if(n/i != i){
	  v.pb(n/i);
	}
  }
}
for(auto it:v){
  int x = it;
  n = temp;
  int l = n;
  while(l%x == 0){
   l = l/x;
  }
  if(l%x == 1){st.insert(x);cnt++;}
}
cout<<st.size()<<endl;
}



Measured memory_bytes: 384
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        sc.close();
        int tail = n - (n / 10)*10;

        switch(tail){
            case 0:
            case 1:
            case 6:
            case 8:
                System.out.println("pon");
                break;
            case 2:
            case 4:
            case 5:
            case 7:
            case 9:
                System.out.println("hon");
                break;
            case 3:
                System.out.println("bon");
            default:
                break;
        }
    }
}

Measured memory_bytes: 35816
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  string N;
  cin>>N;
  int ans=0;
  for(auto c:N){
    if(c=='2')ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ((A + B) == (C + D)) {
  cout << "Balanced" << endl;
  }  
  else if ((A + B) >= (C + D)) {
    cout << "Left" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
N, T = (input().split())
N = int(N)
T = int(T)
road = []
for i in range(N):
    c, t = input().split()
    t = int(t)
    if t in range(1, T + 1):
        road.append((int(c), t))
if len(road) == 0:
    print("TLE")
else:
    road.sort()
    print(road[0][0])

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define MOD 1000000007
typedef pair<li, li> PI;


int main(void)
{
	li res = 0;
	li n;
	cin >> n;
	rep(i, n) {
		li l, r;
		cin >> l >> r;
		res += r - l + 1;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[110000],y[110];
main(){
  ll n,x;
  cin>>n>>x;
  rep(i,0,n){cin>>a[i];a[i]=labs(a[i]-x);}
  ll ans=a[0];
  rep(i,1,n)ans=GCD(ans,a[i]);
  cout<<ans;
}

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

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);
	
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	
	ll res = 0;
	if(n <= k) res = n * x;
	else {
		res = k * x + (n - k) * y;
	}
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN


void init(){
}

ll po(ll x, ll y) { 
    ll res = 1;
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%MOD; 
        y = y>>1;  
        x = (x*x)%MOD;
    } 
    return res; 
}



void solve(){
    ll s,w;
    cin>>s>>w;
    if( s > w ) cout<<"safe"<<endl;
    else cout<<"unsafe"<<endl;
    return;
}

int main(){
    FAST;
    init();
    ll t = 1;
    //cin>>t;
    while( t-- ) solve();
    return 0;
} 

Measured memory_bytes: 3652
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);
    try{
      String[] S = br.readLine().split(" ");
      int K = Integer.parseInt(S[0]);
      int X = Integer.parseInt(S[1]);
      int Y = Integer.parseInt(S[2]);
      int[] ans = new int[K];
      for(int i = 1; i <= K; i++){
        for(int j = i+1; j <= K; j++){
          int a = j-i;
          int b = Math.abs(X-i)+Math.abs(Y-j)+1;
          int r = Math.min(a,b);
          ans[r]++;
        }
      }
      for(int i = 1; i < K; i++){
        out.println(ans[i]);
      }
      out.flush();
    }catch(Exception e){
    }
  }
}


Measured memory_bytes: 21460
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  int n, i;
  vector<int> a, b;
  cin >> n;
  a.resize(n);
  b.resize(n);

  for(i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }

  sort(a.begin(),a.end());
  sort(b.begin(),b.end());

  if(n%2==1){
    cout << b[n/2] - a[n/2] + 1 << endl;
  }
  else{
    cout << (b[n/2]+b[n/2-1]) - (a[n/2]+a[n/2-1]) + 1 << endl;
  }

  return 0;
}


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

int main() {
  int h, n;
  cin >> h >> n;
  int tmp, s = 0;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    s += tmp;
  }
  cout << (s >= h? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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



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



int main() {

	cout << fixed << setprecision(10);

	ll K, N;
	
	cin >> N >> K;

	vector<ll> p(N + 1);

	repn(i, N) cin >> p[i];

	
	ll now = 0;
	repn(i, K) now += p[i];

	ll ans = now;

	repn(i, N - K) {
		now = now - p[i] + p[i + K];
		ans = max(ans, now);
	}

	cout << (double)(ans + K) / 2.0;

	system("PAUSE");

}


Measured memory_bytes: 2040
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 998244353, N = 1e7 + 5;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;



int n;
string s;

main () {
	cin >> n >> s;
	if (n & 1)
		cout << "No";
	else {
		forn (i, 0, n / 2 - 1)
			if (s[i] != s[i + n / 2])	 {
				cout << "No";
				return 0;
			}
		cout << "Yes\n";
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define N 500005
using namespace std;
int n,m,a[N],sum[N],sum1[N];
void add1(int l,int r,int z){sum[l]+=z;sum[r+1]-=z;}
void add2(int l,int r,int z){sum1[l]+=z;sum1[r+1]-=z;}
signed main(){
	scanf("%lld%lld",&n,&m);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for (int i=1;i<n;i++){
		int l=a[i];int r=a[i+1];
		if (l==r) continue;
		if (l<r){
			add1(1,l,r-l);
			add1(r+1,m,r-l);
			add1(l+1,r,r+1);
			add2(l+1,r,-1);
		}
		else {
			add1(r+1,l,r+m-l);
			add1(l+1,m,r+m+1);
			add2(l+1,m,-1);
			add1(1,r,r+1);
			add2(1,r,-1);
		}
	}
	int ans=1e18;
	for (int i=1;i<=m;i++){
		sum[i]+=sum[i-1];sum1[i]+=sum1[i-1];
		ans=min(ans,sum[i]+sum1[i]*i);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 9216
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
long long n, res;
int main() {
    DAU
    cin >> n;
    if (n & 1) {
        cout << 0;
        PLEC
    }
    n /= 2;
    while (n > 0)
        res += (n /= 5);
    cout << res;
    PLEC
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        String sp = "01";

        Long count_s1 = 0L;
        Long count_s2 = 0L;
        for (int i = 0; i < s.length(); i++) {
            if(i%2 ==0) {
                if (s.charAt(i) == sp.charAt(0)) {
                    count_s1++;
                } else {
                    count_s2++;
                }
            }else {
                if (s.charAt(i) == sp.charAt(1)) {
                    count_s1++;
                } else {
                    count_s2++;
                }

            }
        }

        Long min = Math.min(count_s1, count_s2);
        System.out.println(min);
    }
}


Measured memory_bytes: 28368
#include <bits/stdc++.h>
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
using namespace std;
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/*************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  vector<int> a(3);
  for (int &x : a) cin >> x;
  kek((accumulate(ALL(a), 0) >= 22) ? "bust" : "win");
  
  return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  biggner20200404_2
//
//  Created by zer0 on 2020/04/04.
//  Copyright © 2020 zer0. All rights reserved.
//

#include <iostream>  // cin, cout, endl
#include <string>    // getline
#include <sstream>   // istringstream

int main(int argc, const char * argv[]) {
    
    int n, m;
    std::cin >> n >> m;
    std::string s;
    getline(std::cin, s);
    getline(std::cin, s);
    std::istringstream iss(s);
    
    int array[100];
    
    int total = 0;
    int l = n;
    while (--l >= 0 && getline(iss, s, ' ')){
        int temp = atoi(s.c_str());
        array[l] = temp;
        total += temp;
    }
    
    int i, j, k;
    for (i = 0; i < (n - 1); i++) {
        for (j = (n - 1); j > i; j--) {
            if (array[j] > array[j - 1]) {
                k = array[j];
                array[j] = array[j - 1];
                array[j - 1] = k;
            }
        }
    }
    
    int flg = 0;
    for (i = 0; i < m; i++) {
        double jage = (double)total / (4*m);
        if (array[i] < jage) {
            flg = 1;
        }
    }
    
    if(flg == 0){
        std::cout << "Yes";
    }else{
        std::cout << "No";
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, a, b; cin >> n >> a >> b;
  int ans = 0;
  while (n--) {
    int t; cin >> t;
    if (t < a || b <= t) ++ans;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var N int
var M int
var C int

func main() {
	N = nextInt()
	M = nextInt()
	C = nextInt()
	ans := 0
	B := nextInts(M)
	for i := 0; i < N; i++ {
		A := nextInts(M)
		sum := 0
		for j := 0; j < M; j++ {
			sum += A[j] * B[j]
		}
		if sum+C > 0 {
			ans += 1
		}
	}

	fmt.Printf("%v", ans)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func MaxIn2Values(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinIn2Values(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#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(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int N;
int h[200010];
int a[200010];
int bit[200010];

int get_max(int i) {
  int r = 0;
  while (i) {
    chmax(r, bit[i]);
    i -= i & -i;
  }
  return r;
}

void update(int i, int x) {
  int tmp = x;
  while (i <= N) {
    if (tmp > bit[i]) {
      bit[i] = tmp;
    } else {
      tmp = bit[i];
    }
    i += i & -i;
  }
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  REP(i, N) cin >> h[i];
  REP(i, N) cin >> a[i];
  REP(i, N) {
    int mx = get_max(h[i]);
    update(h[i], mx+a[i]);
  }
  cout << get_max(N) << endl;

  return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> A(N), B(N);
  rep (i, N) cin >> A[i];
  rep (i, N) cin >> B[i];

  vector<long> diff(N);
  rep (i, N) diff[i] = A[i] - B[i];
  sort(diff.rbegin(), diff.rend());

  long minus_sum = 0;
  long ans = 0;

  for (auto it: diff) if (it < 0) {
    minus_sum += it;
    ans++;
  }

  if (minus_sum >= 0) {
    cout << ans << endl;
    return;
  }

  for (auto it: diff) {
    minus_sum += it;
    ans++;
    if (minus_sum >= 0) {
      cout << ans << endl;
      return;
    }
  }

  cout << -1 << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll x;
  cin>>x;
  for(ll a=-200;a<=200;a++){
    for(ll b=-200;b<=200;b++){
      if(a*a*a*a*a-b*b*b*b*b==x){
        cout<<a<<" "<<b;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3624
from collections import defaultdict

s = input()
t = input()

AL = "abcdefghijklmnopqrstuvwxyz"
S = defaultdict(int)
T = defaultdict(int)

for al in s:
  S[al] += 1

for al in t:
  T[al] += 1

ans_s = ""
for al in AL:
  ans_s += al*S[al]

ans_t = ""
for al in reversed(list(AL)):
  ans_t += al*T[al]

if ans_s < ans_t:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9320
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
    string s; cin >> s;
    int x = 0;
    int ss = 0;
    rep(i, s.size()){
        x += ctoi(s[i]);
        if (i>0){
            ss = ss*10 + ctoi(s[i]);
        }else{
            ss += ctoi(s[i]);
        }
    }
    cout << (ss%x == 0? "Yes": "No") << endl;
}

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

main(){
  int r1=0,r2=0,f;
  for(int i=0;i<3;i++){
    cin>>f;
    if(f == 5) r1+= 1;
    if(f == 7) r2+= 1;
  }
  if((r1 == 2) &&(r2 == 1)) cout<< "YES"<<endl;
  else cout<< "NO"<<endl;
  return 0;
}

Measured memory_bytes: 256
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const s = input[0][0];

  const chars: string[] = [];

  for (let i = 0; i < s.length; i += 2) {
    chars.push(s[i]);
  }

  return chars.join("");
};

console.log(main(read()));


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

int main(){
    int N; cin>>N;
    vector<pair<double,double> > z(N);
    for(int i=0;i<N;i++)cin>>z[i].first>>z[i].second;
    double res=0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            res+=sqrt(pow(z[i].first-z[j].first,2)+pow(z[i].second-z[j].second,2));
        }
    }
    cout<<fixed<<setprecision(10)<<res*2/N<<endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author CompuWare
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BTripleDots solver = new BTripleDots();
        solver.solve(1, in, out);
        out.close();
    }

    static class BTripleDots {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int K = in.nextInt();
            String S = in.next();

            if (S.length() > K) {
                out.print(S.substring(0, K) + "...");
            } else {
                out.print(S);
            }
        }

    }
}



Measured memory_bytes: 38492
#include <iostream>
#include <stdio.h>

using namespace std;

int main (void) {
  long long a, b;
  cin >> a >> b;

  long long d = a / b, r = a % b;
  double f = (double)a / b;

  printf("%d %d %.8lf\n", d, r, f);

  return 0;
}


Measured memory_bytes: 3232
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795


struct rt_t
{
	int p;
	int c;
	vi h;
	rt_t(int pp, int pc, vi ph=vi()) : p(pp), c(pc), h(ph) {}
};


void bk_fill(vector<vpii>&v, vi&e, int b, int n, int s, int t)
{
	queue<rt_t> q;
	vi f(n+1, -1);
	vi g;

	f[s]=0;
	q.push(rt_t(s, 0, vi()));
	while(!q.empty())
	{
		auto c=q.front();
		int p=c.p;
		q.pop();
		if(p==t)
		{
			g=c.h;
			break;
		}
		vi tmp=c.h;
		tmp.push_back(-1);
		for(auto&m:v[p])
		{
			int np=m.first;
			if(f[np]>=0) continue;
			f[np]=c.c+1;
			tmp.back()=m.second;
			q.push(rt_t(np, c.c+1, tmp));
		}
	}

	for(auto&m:g)
	{
		e[m]|=b;
	}
}


int bc(ll v)
{
	int ret=0;

	for(;v>0;v>>=1)
	{
		if(v&1) ret++;
	}

	return ret;
}


int main(void)
{
	int n;
	while(scanf("%d", &n)==1)
	{
		vector<vpii> v(n+1);
		vi e(n-1);

		for(int i=0;i<n-1;i++)
		{
			int a, b;
			scanf("%d%d", &a, &b);
			v[a].push_back(make_pair(b, i));
			v[b].push_back(make_pair(a, i));
		}

		int m;
		scanf("%d", &m);
		for(int i=0;i<m;i++)
		{
			int mu, mv;

			scanf("%d%d", &mu, &mv);
			bk_fill(v, e, 1<<i, n, mu, mv);
		}

		ll ans=1LL<<(n-1);
		for(int i=1;i<(1<<m);i++)
		{
			int t=0;
			for(int j=0;j<n-1;j++)
			{
				if(e[j]&i) t++;
			}
			ll x=(1LL<<(n-1-t));
			if(bc(i)%2) x=-x;
			ans+=x;

//			printf("[%x %lld]", i, x);
		}

//for(int me:e) printf("%d ", me); printf("\n");
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 636
import static java.lang.System.out;
import java.util.Scanner;
import java.util.Arrays;
public class Main{
   public static void main(String[]args){
      Scanner sc = new Scanner(System.in); 
      int N = sc.nextInt();
      int A = sc.nextInt();
      out.println((N*N)-A);
      
   }
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)

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

int main(void) {
    long long x, y, ans;
    cin >> x >> y;
    for(long long i = x; i<=y; i*=2){
        ans++;
    }

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


Measured memory_bytes: 256