akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <stack>
#define mp make_pair
#define MIN(a,b) (a>b?b:a)
//#define MAX(a,b) (a>b?a:b)
typedef long long ll;
typedef unsigned long long ull;
const int MAX=1e5+5;
const int INF=1e8+5;
using namespace std;
//const int MOD=1e9+7;
typedef pair<ll,int> pii;
const double eps=0.00000001;
struct node
{
    ll a,b;
}re[MAX];
bool cmp(node x,node y)
{
    if(x.a-x.b!=y.a-y.b)
        return x.a-x.b<y.a-y.b;
    else
        return x.b>y.b;
}
ll x,y,z;
ll gold[MAX],silver[MAX];
ll sum,gsum,ssum;
priority_queue<ll> g,s;
int main()
{
    scanf("%lld%lld%lld",&x,&y,&z);
    ll num=x+y+z;
    ll p,q,r;
    for(ll i=1;i<=num;i++)
    {
        scanf("%lld%lld%lld",&p,&q,&r);
        re[i].a=p-r;re[i].b=q-r;
        sum+=r;
    }
    sort(re+1,re+1+num,cmp);
    ssum=gsum=0LL;
    for(ll i=x+y+z;i>=y+z+1;i--)
    {
        g.push(-re[i].a);
        gsum+=re[i].a;
    }
    gold[x]=gsum;
    for(ll i=y+z;i>y;i--)
    {
        g.push(-re[i].a);
        gsum+=re[i].a;
        gsum+=g.top();
        gold[x+y+z-i+1]=gsum;
        g.pop();
    }
    for(ll i=1;i<=y;i++)
    {
        s.push(-re[i].b);
        ssum+=re[i].b;
    }
    silver[y]=ssum;
    for(ll i=y+1;i<=y+z;i++)
    {
        s.push(-re[i].b);
        ssum+=re[i].b;
        ssum+=s.top();
        silver[i]=ssum;
        s.pop();
    }
    ll an;
    for(ll i=y;i<=y+z;i++)
    {
        if(i!=y)
            an=max(an,silver[i]+gold[x+y+z-i]);
        else
            an=silver[i]+gold[x+y+z-i];
    }
    printf("%lld\n",an+sum);
    return 0;
}


Measured memory_bytes: 3228
n=int(input())
s=input()
ans=s.count("R")*s.count("G")*s.count("B")
for j in range(n):
  J=s[j]
  for i in range(j):
    k=2*j-i
    if k<n:
      I=s[i]
      K=s[k]
      if I!=J!=K!=I:
        ans-=1   
print(ans)


Measured memory_bytes: 9192
// This code Write By chtholly_micromaker(MicroMaker)
#include <cstdio>
#include <cctype>
#include <iostream>
#define reg register
using namespace std;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
signed main(void)
{
	reg int a,b;
	cin>>a>>b;
	for(int i=b-a+1;i<=b+a-1;++i)
		printf("%d ",i);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int answer = n%k;
		if (n%k == 0) {
			System.out.println(0);
		} else {
			System.out.println(1);
		}
	}
}


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

int main() {
    long long n;
    scanf("%lld", &n);
    for(long long i=1; i<=n; i++) {
        long long nSum = 0;
        for(long long x=1; x*x<=i; x++) {
            for(long long y=1; y*y<=i; y++) {
                long long nn = x*x+y*y+x*y;
                if(nn > i) {
                    break;
                }
                for(long long z=1; z*z<=i; z++) {
                    long long mm = nn + y*z+z*x+z*z;
                    if(i == mm) {
                        // printf("%lld %lld %lld\n", x, y, z);
                        nSum++;
                    }
                    else if(i < mm) {
                        break;
                    }
                }
            }
        }
        printf("%lld\n", nSum);
    }
    return 0;
}

Measured memory_bytes: 3808
N,K,L=map(int,input().split())
G=[[] for i in range(N)]
H=[[] for i in range(N)]
#T=[-1 for i in range(N)]
#B=[-1 for i in range(N)]
for i in range(K):
    p,q=map(int,input().split())
    G[p-1].append(q-1)
    G[q-1].append(p-1)
for i in range(L):
    r,s=map(int,input().split())
    H[r-1].append(s-1)
    H[s-1].append(r-1)
def dfs(A):
    k=1
    q=[]
    reached=[0 for i in range(N)]
    res=[0 for i in range(N)]
    for i in range(N):
        if reached[i]==1:
            continue
        q.append(i)
        while(len(q)>0):
            r=q[-1]
            q.pop()
            res[r]=k
            for p in A[r]:
                if reached[p]==1:
                    continue
                q.append(p)
                reached[p]=1
        k+=1
    return res
T=dfs(G)
B=dfs(H)
TB=[(T[i],B[i]) for i in range(N)]
D=dict()
for i in range(N):
    if TB[i] in D:
        D[TB[i]]+=1
    else:
        D[TB[i]]=1
ans=[str(D[TB[i]]) for i in range(N)]
print(" ".join(ans))


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

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

	int n = sc.nextInt();
	int i = 1;
	while (n != 0) {
	    System.out.println("Case " + i++ + ": " + n);
	    n = sc.nextInt();
	}
    }
}


Measured memory_bytes: 42476
import sys

input = sys.stdin.readline

N, M = map(int,input().split())
xyz = [list(map(int,input().split())) for i in range(M)]

class UnionFind:
    def __init__(self,n):
        self.par = [i for i in range(n)] #親
        self.rank = [1]*n #深さ
        self.size = [1]*n #size[i]:=iを根とするグループのサイズ
    
    def find(self,x):
        if self.par[x] == x:
            return x
        else:
            return self.find(self.par[x])
            
    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.par[x] = y
                self.size[y] += self.size[x]
            else:
                self.par[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
                    
    def same(self,x,y):
        return self.find(x) == self.find(y)
        
    def group_size(self,x):
        return self.size[self.find(x)]
        
uf = UnionFind(N)
for x, y, z in xyz:
    x, y = x-1, y-1
    uf.unite(x,y)
ans = 0
for i in range(N):
    if i == uf.find(i):
        ans += 1
print(ans)





Measured memory_bytes: 33088
#include<iostream>
#include<string>
#define STEP 7
#define N 1046527
using namespace std;

bool isFilled[N];
string data[N];

int getVal(string s){
    int val=0;
    int p=1;
    for(int i=0;i<s.length();i++){
        val+=p*(s[i]-64);
        p*=5;
    }
    return val;
}

int getKey(string s){
    int val=getVal(s);
    int k=val%N;
    while(isFilled[k]){
        //k=(k+STEP)%N;
        k=(k+(1+k%(N-1)))%N;
    }
    isFilled[k]=true;
    data[k]=s;
    return k;
}
int findVal(string s){
    int val=getVal(s);
    int k=val%N;
    //cout<<"???"<<val<<' '<<k<<endl;
    while(data[k]!=s&&isFilled[k]){
        //cout<<k<<' '<<data[k]<<endl;
        //k=(k+STEP)%N;
        k=(k+(1+k%(N-1)))%N;
    }
    if(!isFilled[k]) return -1;
    return k;
}
int main(){
    int n,k=0;
    string s;
    string data;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s>>data;
        if(s=="insert"){
            getKey(data);
        }else
        if(s=="find"){
            k=findVal(data);
            if(k!=-1) cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 43948
function main(input) {
  input=input.trim()
  const N = parseInt(input.split(" ")[0], 10);
  const T = parseInt(input.split(" ")[1], 10);
  var arr=[]
for(var i=0; i<N; i++){
  var c=parseInt(input.split("\n")[i+1].split(" ")[0], 10);
  var t=parseInt(input.split("\n")[i+1].split(" ")[1], 10);
  if(t<=T){
    arr.push(c)
  }
}
if(arr.length==0){
  console.log("TLE");
}else{
  console.log(Math.min.apply(null,arr ));

}
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7612
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  int n;cin>>n;
  int a[5][n+10];

  vector<int>upsm(n+10,0),dnsm(n+10,0);
  rep(i,0,2){
    rep(j,0,n){
      cin>>a[i][j];
      if(i==0)upsm[j+1]=upsm[j]+a[i][j];
      else dnsm[j+1]=dnsm[j]+a[i][j];
    }

  }

  int ma=0;
  rep(i,0,n){
    ma=max(ma,upsm[i+1]+dnsm[n]-dnsm[i]);
  }

  out(ma);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

const LL MOD = 1000000007;

template<typename T>
void dump(T a, int n) { for (int i = 0; i < n; i++) cout << a[i] << (i == n - 1 ? '\n' : ' '); }

template<typename T>
void dump(T a) { dump<T>(a, a.size()); }

int main(void) {
	vector<LL> pow3;
	for (LL i = 3; i <= 2000000000L; i*=3) {
		pow3.push_back(i);
	}

	int N;
	cin >> N;

	auto it = lower_bound(pow3.begin(), pow3.end(), N);
	
	cout << it - pow3.begin() + 1 << endl;

	return 0;
}

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

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
	
	int l;
	cin >> l;
	
	
	int n = 0;
	int tmp = 1;
	while(tmp <= l) ++n, tmp *= 2;
	int m = 2 * n - 2;
	int ii = l;
	while(ii > 0) m++, ii -= ii & (-ii);
	m--;
	cout << n << " " << m << "\n";
	REP1(i, n - 1){
		cout << i << " " << i + 1 << " " << (int)pow(2, n - i - 1) << "\n";
		cout << i << " " << i + 1 << " " << 0 << "\n";
	}
	int jj = l;
	int o = 0;
	while(jj > 0 && (int)pow(2, n - 1) != jj){
		int k = jj & (-jj);
		o += k;
		jj -= jj & (-jj);
		int q = n + 1;
		while(k > 0) k >>= 1, q--;
		cout << 1 << " " << q << " " << l - o << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<cstdlib>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

int main(){
    int n, k;
    cin >> n >> k;
    int v[n];
    rep(i, n) cin >> v[i];
    int ans = 0;
    for (int i = 1; i <= min(n, k); i++){
        for (int j = 0; j <= i; j++){
            priority_queue<int , vector<int>, greater<int> > que;
            int sm = 0;
            for (int l = 0; l < j; l++){
                // cout << v[l] << " ";
                que.push(v[l]);
                sm += v[l];
            }
            for (int l = n - 1; l > n - 1 - (i - j); l--){
                // cout << v[l] << " ";
                que.push(v[l]);
                sm += v[l];
            }
            int num = k - i;
            while(num > 0 && que.size() > 0 && que.top() < 0){
                sm -= que.top();
                que.pop();
                num--;
            }
            ans = max(ans, sm);
        }

    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
	    int W = sc.nextInt();
	    char[][] s = new char[H][W];
        for (int h = 0; h < H; h++) {
          String line = sc.next();
            for (int w = 0; w < W; w++) {
                s[h][w] = line.charAt(w);
            }
        }
        
        for (int h = 0; h < H; h++) {
            for (int w = 0; w < W; w++) {
                if (s[h][w] == '#'){
                    if (h > 0 && s[h-1][w] == '#') {
                        continue;
                    }
                    if (h < H - 1 && s[h+1][w] == '#') {
                        continue;
                    }
                    if (w > 0 && s[h][w-1] == '#') {
                        continue;
                    }
                    if (w < W - 1 && s[h][w+1] == '#') {
                        continue;
                    }
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
      
    }
}


Measured memory_bytes: 21844
s = int(input())

a = [s]
i = 2
while True:
    if a[i-2]%2==0:
        a_ = int(a[i-2]/2)
    else:
        a_ = int(3*a[i-2]+1)
    if a_ in a:
        print(i)
        break
    else:
        a.append(a_)
        i += 1


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

constexpr ll MOD = 1000000007;

ll modPow(ll x, int n) {
    ll ans = 1ll;
    ll mul = x;
    while (n) {
        if (n & 1) (ans *= mul) %= MOD;
        (mul *= mul) %= MOD;
        n >>= 1;
    }
    return (ans);
}
ll modInv(ll x) {
    return (modPow(x, MOD - 2));
}

ll N;
vector<vll> G(200005);
ll size[200005];
ll dfs(ll v, ll prev) {
    ll ret = 0;
    size[v] = 1;
    for (auto &u : G[v]) {
        if (u != prev) {
            (ret += dfs(u, v)) %= MOD;
            (ret += (MOD + modPow(2, size[u]) - 1) * (MOD + modPow(2, N - size[u]) - 1)) %= MOD;
            size[v] += size[u];
        }
    }
    return (ret);
}
int main() {
    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b; --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cout << ((dfs(0, -1) + modPow(2, N) - 1) % MOD * modInv(modPow(2, N)) % MOD + MOD - N * modInv(2) % MOD) % MOD << endl;
    return (0);
}

Measured memory_bytes: 22016
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
    #include<numeric>
    #include<array>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define Vl vector<ll>
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<ll>>;
    using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;
const ll ZER = 0;

int main(){
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if(a > b)swap(a, b);
    ll r1 = a + v * t;
    ll r2 = b + w * t;
    if(r1 >= r2){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

double distance(double x1, double x2, double y1, double y2) {
    double dx = x2 - x1;
    double dy = y2 - y1;
    return sqrt(dx * dx + dy * dy);
}

int main() {
    int N;
    double D;
    cin >> N >> D;
    
    int ans = 0;
    rep(i, N) {
        double X,Y;
        cin >> X >> Y;
        if(distance(0,X,0,Y) <=D) ++ ans;
    }
    cout << ans << endl;

}


Measured memory_bytes: 3836
parseInt(x) = parse(BigInt,x)
parseMap(x::Array{SubString{String}, 1}) = map(parseInt, x)
parseF(x) = parse(Float64,x)

function main()
    N = parseInt(readline())
    A= parseMap(split(readline()))
    prod(A) <= 10^18 ? println(prod(A)) : println(-1)
end

main()

Measured memory_bytes: 249936
def insertion_sort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and v < A[j]:
            A[j+g] = A[j]
            j -= g
            cnt += 1
            A[j+g] = v
    return cnt

def shell_sort(A, n):
    cnt = 0
    h = 1
    g = []
    while h <= n:
        g.append(h)
        h = 3*h + 1
    g.reverse()
    m = len(g)
    for i in range(m):
        cnt = insertion_sort(A, n, g[i], cnt)
    show(n, m, g, A, cnt)

def show(n, m, G, A, cnt):
    print(m)
    for i in range(m):
        if i != m-1:
            print(G[i], end = " ")
        else:
            print(G[i])
    print(cnt)
    for i in range(n):
        print(A[i])

if "__main__" == __name__:
    n = int(input())
    data = []
    for i in range(n):
        data.append(int(input()))
    shell_sort(data, n)


Measured memory_bytes: 45520
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
	cin >> n >> m >> k;
	if(k>=n&&n+m>=k){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

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

const auto PI=acosl(-1);
int main()
{
    long double a; cin>>a;
    a=a/180*PI;

    double x=1, y=0, t=a;
    for(int k=1; ; ++k, t+=a) {
        auto p=cos(t), q=sin(t);
        x+=p, y+=q;
        if (fabs(x)<1e-9) x=0;
        if (fabs(y)<1e-9) y=0;
        if (x==0 and y==0) {
            cout<<k+1<<endl;
            break;
        }
    }
}


Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pvllvll pair <vector <ll>, vector <ll> >
#define ld long double
#define veci vector <int>
#define vecll vector <ll>


const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

int p[(int)2e5+10];

int get(int v) {
    return (v == p[v] ? v : p[v] = get(p[v]));
}

void unite(int v, int u) {
    v = get(v), u = get(u);
    if(v == u) return;
    if(rand() & 1) p[v] = u;
    else p[u] = v;
}

void solve() {
    int n, q;
    cin >> n >> q;
    iota(p + 1, p + n + 1, 1);
    while(q--) {
        int t, u, v;
        cin >> t >> u >> v;
        if(!t) unite(u + 1, v + 1);
        else cout << (get(u + 1) == get(v + 1)) << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    ///cin >> T;
    while(T--) solve(), cout << '\n';
    return 0;
}


Measured memory_bytes: 4252
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    vl A={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll N;
    cin >> N;
    prt(A[N-1]);

    return 0;
}

 



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;
mt19937 mrand(time(0));
ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; }
ll get(ll l, ll r) { return get(r - l + 1) + l; }

int n, m, cnt[200100], v[200100], cur; vi G[200100];
void dfs(int x) {
    cnt[v[x] = cur]++;
    for(int y : G[x]) if(!v[y]) dfs(y);
}
signed main() {
    scanf("%d %d", &n, &m);
    for(int i = 1; i <= m; i++) {
        int x, y; scanf("%d %d", &x, &y);
        G[x].pb(y), G[y].pb(x);
    }
    for(int i = 1; i <= n; i++) if(!v[i]) cur++, dfs(i);
    printf("%d\n", *max_element(cnt + 1, cnt + 1 + cur));
    fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
    return 0;
    /* 取模直接除，爆零两行泪
     * 不开ll见祖宗
     */
}

Measured memory_bytes: 21760
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,cnt,ans1=0,ans2=0,ans3=0,ans4=0;
	string a;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
            if(a[0]=='A')
                ans1++;
            else if(a[0]=='W')
                ans2++;
            else if(a[0]=='T')
                ans3++;
            else
                ans4++;
    }
    cout<<"AC"<<" "<<"x"<<" "<<ans1<<endl;
    cout<<"WA"<<" "<<"x"<<" "<<ans2<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<<ans3<<endl;
    cout<<"RE"<<" "<<"x"<<" "<<ans4<<endl;
    return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int32_t main(){
    boost;

   
    
    //code

    int n;
    cin >> n;
    int ans = 1;

    for(int i = 2 ; i <= n ; ++i){
    	ans *= i;
    	ans %= mod;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, A: "List[int]", B: "List[int]"):
    ret = 0
    for i in range(N):
        if A[i] <= B[i]:
            B[i] -= A[i]
            ret += A[i]
            tmp = min(A[i + 1], B[i])
            #print(B[i], tmp)
            A[i + 1] -= tmp
            ret += tmp
        else:
            A[i] -= B[i]
            ret += B[i]
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N+1) ]  # type: "List[int]"
    B = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A, B)

if __name__ == '__main__':
    main()


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

int main(){
    int n,k;
    cin>>n>>k;
    int a[100005];
    int pos;
    for(int i=1;i<=n;i++){
        scanf("%d",a+i);
        if(a[i]==1){
            pos=i;
        }
    }
    int r = n-pos;

    int ans = r/(k-1) + (r%(k-1)!=0);
    //cout<<ans<<endl;
    if(ans*(k-1)>r){
        pos = max(1,pos - (ans*(k-1) - r));
    }
    pos--;
    //cout<<pos<<endl;
    ans += pos/(k-1) + (pos%(k-1)!=0);
    cout<<ans;

    return 0;
}


Measured memory_bytes: 640
x, n = map(int, input().split())
p = list(map(int, input().split()))
left = 10**9
right = 10**9
i = x
while True:
    if not i in p:
        left = abs(i - x)
        break
    i -= 1
i = x
while True:
    if not i in p:
        right = abs(i - x)
        break
    i += 1
if left == right:
    print(x - left)
elif left < right:
    print(x - left)
else:
    print(x + right)

Measured memory_bytes: 9204
# coding: utf-8
def main():
    N = int(input())
    s = input()
    rcount = 0
    # bcount = 0
    for si in s:
        if si == 'R':
            rcount += 1
        # elif si == 'B':
        #     bcount += 1
    bcount = N - rcount
    if rcount > bcount:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define M 1000000007

using namespace std;

// Solve function here


// End Solve function

int main(){
	//ios::sync_with_stdio(0);
	//cin.tie(0);
    //ifstream cin1("input.in");
	//clock_t start, finish;
	int n, k;
	cin >> n >> k;
	vector<int> ar;
	for(int i = 0; i < n; ++i){
		int t; cin >> t;
		ar.push_back(t);
	}
	sort(ar.begin(), ar.end());
	int res = 0;
	for(int i = 0; i < k; ++i){
		res += ar[i];
	}
	cout << res << endl;
	return 0;
}


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

using namespace std;

int main() {
	string S;
	cin >> S;

	int count = 0;

	for(int i = 0; i < 3; i++) {
		if(i == 0 && S[i] == 'R' && S[i+1] == 'R' && S[i+2] == 'R') {
			count = 3;
			break;
		}
		if(i != 2 && S[i] == 'R' && S[i+1] == 'R') {
			count = 2;
			break;
		}
		if(S[i] == 'R') {
			count = 1;
			break;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= b; --i)
#define range(i, a, b, c) for (int i = a;             \
                               c > 0 ? i < b : i > b; \
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define dump(x) cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else
const bool test = false;
#endif

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while (getline(ss, buffer, sep))
    {
        v.push_back(buffer);
    }
    return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
    return accumulate(begin, end, 0ll);
}

void solve();

signed main()
{
    cout << fixed << setprecision(20);
    solve();
    while (true)
    {
        char s[MAX];
        if (scanf("%s", s) == EOF)
            break;
        int n = strlen(s);
        for (int i = n - 1; i > -1; i--)
        {
            ungetc(s[i], stdin);
        }
        solve();
    }
    return 0;
}

struct Edge {
	int src, dst, weight;
};

int N, M;
vector<Edge> graph[MAX];
int d[MAX];

void solve()
{
    cin >> N >> M;
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        graph[a].push_back({a, b, c});
    }
    rep(i, N) d[i] = -INF;
    d[0] = 0;

    bool update = true;
    rep(loop, 4)
    {
        update = false;
        rep(i, N + 100)
        {
            rep(j, N)
            {
                rep(k, (int)graph[j].size())
                {
                    // dump(graph[j][k].id);
                    // dump(graph[j][k].dist);
                    if (d[graph[j][k].dst] < d[j] + graph[j][k].weight)
                    {
                        d[graph[j][k].dst] = d[j] + graph[j][k].weight;
                        if (graph[j][k].dst == N - 1) {
                            update = true;
                        }
                    }
                }
            }
        }
        if (update == false)
        {
            // rep(i, N) {
            //     cout << d[i] << endl;
            // }
            cout << d[N - 1] << endl;
            return;
        }
    }
    cout << "inf" << endl;
}


Measured memory_bytes: 4992
N = int(input())
a = list(map(int,input().split()))

def dev2(a):
    count = 0
    while(True):
        if a % 2 == 0:
            a = int(a/2)
            count += 1
        else:
            break
    return count
           
b = [dev2(i) for i in a]
print(sum(b))

Measured memory_bytes: 4148
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

bool isOK(vector<ll> &a, ll index, ll key){
	if(a[index] >= key) return true;
	else return false;
}

int binary_search(vector<ll> &sfor, ll key){
	ll ng = -1;
	ll ok = sfor.size();
	while(abs(ok-ng) > 1){
		int mid = (ok + ng)/2;
		if(isOK(sfor,mid,key))ok = mid;
		else ng = mid;
	}
	return ok;
}

LP dist(vector<ll> &f, ll st){
	int f_pos = binary_search(f, st);
	ll f_dis_f = INF, f_dis_b = INF;
	if(f_pos != f.size())f_dis_f = f[f_pos];
	if(f_pos != 0)f_dis_b = f[f_pos-1];
	return make_pair(f_dis_f, f_dis_b);
}

ll dist(vector<ll> &fst, vector<ll> &scd, ll st){
	ll res1 = 0, res2 = 0, res3 = 0, res4 = 0;
	LP first_place = dist(fst, st);
	res1 = res2 = abs(st - first_place.first);
	res3 = res4 = abs(st - first_place.second);
	LP second_place1 = dist(scd, first_place.first);
	LP second_place2 = dist(scd, first_place.second);
	res1 += abs(second_place1.first - first_place.first);
	res2 += abs(second_place1.second - first_place.first);
	res3 += abs(second_place2.first - first_place.second);
	res4 += abs(second_place2.second - first_place.second);
	return min({res1, res2, res3, res4});
}

int main(){
	ll A, B, Q;
	cin >> A >> B >> Q;
	vector<ll> shrine(A);
	vector<ll> temple(B);
	vector<ll> querys(Q);
	rep(i,A)cin >> shrine[i];
	rep(i,B)cin >> temple[i];
	rep(i,Q)cin >> querys[i];
	rep(i,Q){
		ll now = querys[i];
		cout << min(dist(shrine, temple, now), dist(temple, shrine, now)) << endl;
	}
	return 0;
}


Measured memory_bytes: 5572
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 234567;
int a[MAXN];
LL dp[MAXN][2];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) scanf("%d", &a[i]);
    dp[1][1] = -a[1];
    dp[1][0] = a[1];
    for (int i = 2; i <= N; i++) {
         dp[i][0] = max(dp[i - 1][1] - a[i], dp[i - 1][0] + a[i]);
         dp[i][1] = max(dp[i - 1][1] + a[i], dp[i - 1][0] - a[i]);
    }
    printf("%lld\n", dp[N][0]);
    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

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

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class Program{
  public static void Main(){

    var input = Console.ReadLine().Split();
    int x = int.Parse(input[0]);
    int y = int.Parse(input[1]);
    
    int[] a = {0,1,3,1,2,1,2,1,1,2,1,2,1};
    if(a[x] == a[y]) Console.WriteLine("Yes");
    else Console.WriteLine("No");
  }
}


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

int main() {
    string s;
    cin >> s;
    int first = 0, last = s.size() - 1;
    cout << s[0] << s.size() - 2 << s[last] << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>

typedef long long ll;

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll A, B, C, D;
  std::cin >> A >> B >> C >> D;

  for (ll i = 0; i <= 1000; ++i) {
    if (i % 2 == 0) {
      C -= B;
    } else {
      A -= D;
    }
    if (A <= 0) {
      judge = "No";
      break;
    }
    if (C <= 0) {
      judge = "Yes";
      break;
    }
  }

  print(judge);

  return 0;
}


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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
//int a[N+2];
vector<int>g[N+2];
int vis[N+2]={0};
void dfs(int u){
  //cout<<u<<" u\n";
  vis[u]=1;
  for(int v:g[u]){
    if(vis[v])continue;
    dfs(v);
  }
  return;
}
int32_t  main(){
	IOS;
  int n,m;cin>>n>>m;
  for(int i=1;i<=m;++i){
    int u,v,z;cin>>u>>v>>z;
    g[u].pb(v);
    g[v].pb(u);
  }
  int ans=0;
  memset(vis,0,sizeof(vis));
  for(int i=1;i<=n;++i){
    if(vis[i]==0){dfs(i);ans++;}
  }
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
int n;
int a;
map<int,int> mp;
int main()
{
    cin>>n;
    for(int i=2;i<=n;i++){
        cin>>a;
        mp[a]++;
    }
    for(int i=1;i<=n;i++){
        cout<<mp[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 12972
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int N, K;
int x, y, comp;
vector <vector <int> > G;
int viz[100005], V[100005];

void DF(int node) {
    viz[node] = comp;

    for(int i = 0; i < G[node].size(); ++i) {
        if(viz[G[node][i]] == 0) {
            DF(G[node][i]);
        }
    }
}

int main() {
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    cin >> N >> K;

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

    G.resize(N + 2);
    for(int i = 1; i <= K; ++i) {
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    for(int i = 1; i <= N; ++i) {
        if(viz[i] == 0) {
            ++comp;
            DF(i);
        }
    }

    int ans = 0;

    for(int i = 1; i <= N; ++i) {
        if(viz[V[i]] == viz[i]) {
            ++ans;
        }
    }

    cout << ans << '\n';

    return 0;
}


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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

using namespace std;

int main ()
{
  string S,T,Tsub;

  cin >> S >> T;
  Tsub = T.substr (0, S.size ());
  if (Tsub == S)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3620
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;
#define int long long

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

const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;
const ll inf=1e18+10;

///---program start---///

const int M=1e6;

int sum(int n,int b)
{
    int res=0;
    while (n){
        res+=n%b;
        n/=b;
    }
    return res;
}

int get_big(int n,int s)
{
    int res=inf;
    for (int val=1;val<=min({n,s,M});val++){
        int rest=s-val;
        if ((n-rest)%val==0){
            int b=(n-rest)/val;
            if (b>=2&&n/b==val){
                if (b>=2){
                    res=min(res,b);
                }
            }
        }
    }
    /// if val==0
    if (n==s){
        res=min(res,n+1);
    }
    return (res==inf?-1:res);
}

main()
{
    #ifdef Barik
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    int n,s;
    cin>>n>>s;
    for (int b=2;b<M;b++){
        if (sum(n,b)==s){
            cout<<b<<"\n";
            return 0;
        }
    }
    cout<<get_big(n,s)<<"\n";
}


Measured memory_bytes: 384
#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;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	int n,m;
	cin >> n >> m;
	cout << (n==m ? "Yes" : "No") << endl;
	return 0;
}


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

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<int> A(N), B(N), C(N - 1);
	for (auto& e: A)
	{
		scanf("%d", &e);
		e--;
	}
	for (auto& e: B) scanf("%d", &e);
	for (auto& e: C) scanf("%d", &e);

	int ans{};
	for (auto& e: A) ans += B[e];
	for (int i{}; i < N - 1; i++)
		if (A[i] + 1 == A[i + 1])
			ans += C[A[i]];
	
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;
int main(){
  int n; cin >> n;
  vector<int> h;
  for(int i=0; i<n; i++){
    int hi; cin >> hi;
    h.push_back(hi);
  }
  vector<int> dp(n, INF);
  dp[0]=0;
  for(int i=0; i<n-1; i++){
    if(dp[i+1]>dp[i]+abs(h[i]-h[i+1])) dp[i+1]=dp[i]+abs(h[i]-h[i+1]);
    if(i+2<n && dp[i+2]>dp[i]+abs(h[i]-h[i+2])) dp[i+2]=dp[i]+abs(h[i]-h[i+2]);
  }
  cout << dp[n-1];
  return 0;
}

Measured memory_bytes: 1144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		var adj = Range(0, N).Select(_ => new List<(long, long)>()).ToArray();
		for(long i = 0; i < N - 1; i++)
		{
			long u = GetLong() - 1;
			long v = GetLong() - 1;
			long w = GetLong();
			adj[u].Add((v, w));
			adj[v].Add((u, w));
		}

		var ans = new long[N];
		void dfs(long v, long p, long pc)
		{
			foreach(var (u, w) in adj[v])
			{
				if(u == p)
					continue;

				if(w % 2 == 0)
				{
					ans[u] = pc;
					dfs(u, v, pc);
				}
				else
				{
					ans[u] = pc ^ 1;
					dfs(u, v, pc ^ 1);
				}
			}
		}
		dfs(0, -1, 0);

		WriteLine(string.Join("\n", ans));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

const int MAXN = 400;
const int MAXW = 400;
int N;
int S[MAXN], L[MAXN], P[MAXN];
int dp[MAXW];

int main() {
  while(cin >> N) {
    for(int i = 0; i < N; ++i) {
      cin >> S[i] >> L[i] >> P[i];
    }
    fill(dp, dp+MAXW, -1);
    dp[0] = 0;

    for(int w = 0; w < MAXW; ++w) {
      if(dp[w] == -1) continue;
      for(int i = 0; i < N; ++i) {
        for(int j = S[i]; j <= L[i] && w+j < MAXW; ++j) {
          dp[w+j] = max(dp[w+j], dp[w] + P[i]);
        }
      }
    }

    int m;
    cin >> m;
    bool flag = true;
    int ans[m];
    for(int i = 0; i < m; ++i) {
      int w;
      cin >> w;
      if(dp[w] == -1) flag = false;
      ans[i] = dp[w];
    }
    if(flag) {
      for(int i = 0; i < m; ++i) {
        cout << ans[i] << endl;
      }
    } else {
      cout << -1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main() {
    ULL ans=1;
    int n; cin>>n;
    repp(i,1,n+1){
        ans = ((ans%mod) * (i%mod)) % mod;
    }
    cout<<ans<<endl;
}

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
        ans += s[i] - '0';
    }
    if (ans % 9 == 0) {
        cout << "Yes\n";
        return 0;
    }

    cout << "No\n";
    return 0;
}


Measured memory_bytes: 3640
n=int(input())
a=input().split()
lans=[int(i) for i in range(n)]
sp=' '
ans=''

for i in range(n):
	lans[int(a[i])-1]=i+1
ans+=str(lans[0])
for i in range(1,n):
	ans+=sp
	ans+=str(lans[i])
print(ans)

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

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::for_each;
using std::binary_search;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for_each(v.begin(),v.end(),[](int &_e){cin >> _e;});
	int q;
	cin >> q;
	while (q--) {
		int k;
		cin >> k;
		cout << binary_search(v.begin(),v.end(),k) << endl;
	}
}


Measured memory_bytes: 3100
#include<iostream>
using namespace std;
int main(){
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(s==u){
    a--;
  }
  else if(t==u){
    b--;
  }
  cout << a << ' ' << b << endl;
  return 0;
}

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

int main() {
  vector<int> x(3);
  rep(i,0,3) cin >>x[i];
  sort(x.begin(),x.end());
  cout <<x[0]+x[1] <<endl;
}


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

int main() {
  double x,xx,y,yy,a,aa,b,bb;
  while(cin>>x>>y>>xx>>yy>>a>>b>>aa>>bb){
    string str[2]={"YES","NO"};
    bool ans=0;
    if((aa<x || xx<a))ans=1;
    if((bb<y || yy<b)) ans=1;
    cout << str[ans]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1228