akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

const long long MOD = 1000000007;

// Ref. https://qiita.com/ofutonfuton/items/c17dfd33fc542c222396 //
struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

  vector<int> pn(N);
  REP(n,N){
    int tmp;
    cin >> tmp;
    pn.at(n) = tmp - 1;
  }


  UnionFind tree(N);


  for(int i = 0; i < M; i++) {
      int x, y;
      cin >> x >> y;
      tree.unite(x-1, y-1);
  }


  int ans = 0;
  REP(n,N){
    int num = pn.at(n);
    if(tree.same(n,num)) ans += 1;
  }
  cout << ans << endl;
}


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

int main(){
	int sx,sy,gx,gy ;
	cin >> sx >> sy >> gx >> gy ;
		for(int i=0;i<gy-sy;i++) cout << 'U' ;
		for(int i=0;i<gx-sx;i++) cout << 'R' ;
		for(int i=0;i<gy-sy;i++) cout << 'D' ;
		for(int i=0;i<gx-sx;i++) cout << 'L' ;
		cout << 'L' ;
		for(int i=0;i<gy-sy+1;i++) cout << 'U' ;
		for(int i=0;i<gx-sx+1;i++) cout << 'R' ;
		cout << 'D' ;
		cout << 'R' ;
		for(int i=0;i<gy-sy+1;i++) cout << 'D' ;
		for(int i=0;i<gx-sx+1;i++) cout << 'L' ;
		cout << 'U' ;
		cout << endl ;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

bool sieve[1001000];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(3);

    for (int i = 0; i < 1001000; ++i)
        sieve[i] = true;
    sieve[0] = sieve[1] = false;
    for (int i = 2; i * i < 1001000; ++i)
    {
        if (sieve[i])
        {
            for (int j = 2; j * i < 1001000; ++j)
                sieve[i * j] = false;
        }
    }
    vector<int> primes;
    for (int i = 0; i < 1001000; ++i)
    {
        if (sieve[i])
            primes.push_back(i);
    }
    int n;
    while (cin >> n)
    {
        if (n == 0)
            break;
        cout << accumulate(primes.begin(), primes.begin() + n, 0) << endl;
    }
    return 0;
}


Measured memory_bytes: 4328
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
#define endl        	"\n"
#define int         	long long int  
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define pll         	pair<ll,ll>
#define vec     		vector<ll>
#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod     		1000000007

ll mod_pow(ll a,ll b)
{
    ll res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    
    return res;
}

void solve()
{
	string s;
	
	cin>>s;
	
	if(s[2] == s[3] && s[5] == s[4])
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No";
	}
}
 
signed main()
{
 
    fast;
 
    ll t;
    
    t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
//#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

#define int ll


const int N = 5e5+33, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
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; }


typedef pair <int, int> pii;        // #include <ext/pb_ds/assoc_container.hpp>
typedef pair <ll, ll> pll;         // #include <ext/pb_ds/tree_policy.hpp>
typedef vector <int> vi;          // #include <ext/rope>
bool prime(int n) {
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){return 0;}
    }return 1;}
#define endl '\n'
ll bp(ll a , ll b) {if(b == 0) return 1; if(b&1) return bp(a , b-1) * a % mod; ll t = bp(a , b/2); return t*t%mod;}
//////////////////////////////////////////////////////////////////////////////////////////

void solve() {
    int x;
    cin >> x;
    int p = x , cnt = 1;
    while(p % 360 != 0) {
        p += x;
        cnt ++;
    }
    cout << cnt;
}

/*

*/

main() {
    ios;
    int tt = 1;
//    cin >> tt;
    while(tt --) {
        solve();
//        brute();
    }
    return 0;
}


Measured memory_bytes: 3692
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int p[110][110];
int q[110][110];
bitset<28000> dp[82][82];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			scanf("%d",&p[i][j]);
		}
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			scanf("%d",&q[i][j]);
			if(p[i][j]>q[i][j])swap(p[i][j],q[i][j]);
		}
	}
	dp[0][0][14000+p[0][0]-q[0][0]]=dp[0][0][14000-p[0][0]+q[0][0]]=1;
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		if(i+1<a){
			dp[i+1][j]|=(dp[i][j]<<(q[i+1][j]-p[i+1][j]));
			dp[i+1][j]|=(dp[i][j]>>(q[i+1][j]-p[i+1][j]));
		}
		if(j+1<b){
			dp[i][j+1]|=(dp[i][j]<<(q[i][j+1]-p[i][j+1]));
			dp[i][j+1]|=(dp[i][j]>>(q[i][j+1]-p[i][j+1]));
		}
	}
	int ret=mod;
	for(int i=0;i<28000;i++){
		if(dp[a-1][b-1][i])ret=min(ret,ABS(14000-i));
	}
	printf("%d\n",ret);
}

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

#define int long long 

int n, a[100005]; 
int dp[100005]; 
 
int func(int ind) {
	if(ind==(n-1)) 
	return 0; 
	if(ind>=n) 
	return INT_MAX; 
 
	if(dp[ind]!=-1) 
	return dp[ind]; 
    
	int left = abs(a[ind]-a[ind+1]) + func(ind+1); 
	int right = INT_MAX; 
	if(ind+2<n) {
		right = abs(a[ind] - a[ind+2]) + func(ind+2); 
	}
 
	return dp[ind] = min(left, right); 
}
signed main() {
	
	cin >> n;
 
	memset(dp, -1, sizeof dp); 
	
	for(int i = 0;i<n;i++) {
		cin >> a[i]; 
	}
 
	cout << func(0); 
}

Measured memory_bytes: 9864
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    private struct Pair { public int x, y; }
    public static void Main()
    {
        int N = NextInt();
        int W = NextInt();
        long[,] dp = new long[N + 1, W + 1];
        for (int i = 0; i < N; i++)
        {
            int w = NextInt();
            int v = NextInt();
            for (int j = 0; j <= W; j++)
            {
                if (j < w) dp[i + 1, j] = dp[i, j];
                else dp[i + 1, j] = Math.Max(dp[i, j], dp[i, j - w] + v);
            }
        }
        Console.WriteLine(dp[N, W]);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 90848
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 15:57:29 2020

@author: NEC-PCuser
"""

S = input()

count = 0
S_num = [0] * len(S)
moji_now = 'R'
for i in range(0, len(S)):
    if (S[i] == moji_now):
        count += 1
    else:
        if (S[i] == 'L'):
            S_num[i - 1] = count
            moji_now = 'L' 
        if (S[i] == 'R'):
            S_num[i - count] = count
            moji_now = 'R'
        count = 1
else:
    S_num[i - count + 1] = count

i = 0
while (i < len(S_num)):
    if (S_num[i] == 0):
        i += 1
        continue
    left = 0
    right = 0
    if (S_num[i] % 2 == 0):
        left += S_num[i] // 2
        right += S_num[i] // 2
    elif (S_num[i] % 2 == 1):
        left += S_num[i] // 2 + 1
        right += S_num[i] // 2
    if (S_num[i + 1] % 2 == 0):
        left += S_num[i + 1] // 2
        right += S_num[i + 1] // 2
    elif (S_num[i + 1] % 2 == 1):
        right += S_num[i + 1] // 2 + 1
        left += S_num[i + 1] // 2
    S_num[i] = left
    S_num[i + 1] = right
    i += 2
print(' '.join(map(str, S_num)))
        
    

Measured memory_bytes: 10612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll d = 0;
  cin >> d;
  vector<ll> c(26);
  //ll min = 0;
  //min = pow(10,18);
  //ll mini = 0;
  for(int i = 0;i < 26;i++){
    cin >> c[i];
    //if(min > c[i])min = c[i],mini = i;
  }
  vector<vector<ll>> s(d,vector<ll>(26));
  for(int i = 0;i < d;i++){
    ll now = 0;
    ll nowi = 0;
    for(int j = 0;j < 26;j++){
      cin >> s[i][j];
      s[i][j] += c[j] * (d - i);
      if(now < s[i][j]){
        now = s[i][j];
        nowi = j;
      }
    }
    cout << nowi + 1 << endl;
  }
  //for(int i = 0;i < 365;i++)cout << mini + 1 << endl;
}

Measured memory_bytes: 3720
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>

using namespace std;
using ll = long long int;


int main(void){
  
  int n;
  cin>>n;

  set<int> s;

  for(int i=0;i<n;i++){
    int d;
    cin>>d;
    s.insert(d);
  }

  cout<<s.size()<<endl;  
  return 0;
}

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

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

 typedef long long ll;
 const long long INF = 1LL << 60;



 int main()
 {
    int n;
    string s;
    cin >> n >> s;

    if((n%2) != 0)
    {
        cout << "No" << endl;
        return 0;
    }


    if(s.substr(0, n /2) == s.substr(n/2, n/2))
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }
    


    return 0;
 }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

void chmin(int &a, int b) {
	a = min(a, b);
}
void chmax(int &a, int b) {
	a = max(a, b);
}
ll mod_pow(ll a, ll n, ll m = mod) {
	a %= m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

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


void solve() {
	ll a; cin >> a;
	string s; cin >> s;
	rep(i, s.size())if (s[i] == '.') {
		s.erase(s.begin() + i); break;
	}
	ll b = stoll(s);
	ll ans = a * b / 100;
	cout << ans << "\n";
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 7732
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            var day = 0;
            switch (s)
            {
                case "SUN": day = 7; break;
                case "MON": day = 6; break;
                case "TUE": day = 5; break;
                case "WED": day = 4; break;
                case "THU": day = 3; break;
                case "FRI": day = 2; break;
                case "SAT": day = 1; break;
                default: break;
            }
            Console.WriteLine(day);
        }
    }
}


Measured memory_bytes: 13152
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> h(n);
    rep(i,n)cin>>h[i];
    sort(h.begin(),h.end(),greater<ll>());
    ll sum=0;
    rep(i,n){
        if(i>=k){
            sum+=h[i];
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1792
program main
    implicit none
    integer, dimension(3) :: input
    integer :: num5 = 0, num7 = 0, i
    read *, input
    do i=1, 3
        select case (input(i))
        case (5)
            num5 = num5 + 1
        case (7)
            num7 = num7 + 1
        end select
    end do
    if ( num5 == 2 .and. num7 == 1) then
        write (*, fmt='(a)', advance='no') 'YES'
    else
        write (*, fmt='(a)', advance='no') 'NO'
    endif
end program main


Measured memory_bytes: 640
import java.util.Scanner;

class Solver{
	Scanner sc =new Scanner(System.in);
	
	void run(){
		
		String buf = sc.next();
		
		int[] used = new int['z'+1];
		
		for(char ch:buf.toCharArray()){
			used[ch]++;
		}
		
		String res = null;
		int max = 0;
		for(int i = 'a'; i <= 'z'; i++){
			if(used[i] == 0 && res == null){
				res = buf + (char)i;
			}
			max = Math.max(used[i],max); 
		}
		
		
		if(buf.length() == 26){
			System.out.println(getNext(buf));
			return;
		}
		
		System.out.println(max == 1 ? res : "-1");
		
	}
	
	String getNext(String buf){
		char[] arr = buf.toCharArray();
		int n = 26;
		
		int used[] = new int['z'+1];
		String res = "-1";
		
		for(int i =0 ;i < n;i++){
			used[arr[i]]++;
			for(int j = arr[i]+1 ; j <= 'z';j++){
				if(used[j] == 0){
					res = buf.substring(0, i) + (char)j;
					break;
				}
			}
		}
		return res;
		
	}
}

public class Main {
	public static void main(String[] args){
		Solver s  = new Solver();
		s.run();
	}
}


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

int dp[2048][2048];
int n;

bool type[4048];
int a[4048];

//1=black,2=white
int pos1[2048],pos2[2048];
set<int> ws1,ws2,bs1,bs2;
int bmark[4048][2048],smark[4048][2048];
int bsmall[4048][2048],ssmall[4048][2048];

inline int calc(int pos,int p1,int p2)
{
	return pos-bmark[pos][p1]-smark[pos][p2]-1;
}

int main ()
{
	int i,j;
	scanf("%d",&n);string ss;
	for (i=1;i<=n*2;i++)
	{
		cin>>ss;
		scanf("%d",&a[i]);
		if (ss=="B") type[i]=false; else type[i]=true;
		if (!type[i]) pos1[a[i]]=i; else pos2[a[i]]=i;
	}
	for (i=1;i<=n*2;i++)
		for (j=1;j<=i-1;j++)
			if (!type[j]) bmark[i][a[j]]++; else smark[i][a[j]]++;
	for (i=1;i<=n*2;i++)
		for (j=2;j<=n;j++)
		{
			bmark[i][j]+=bmark[i][j-1];
		}
	for (i=1;i<=n*2;i++)
		for (j=2;j<=n;j++)
			smark[i][j]+=smark[i][j-1];
	for (i=0;i<=n;i++)
		for (j=0;j<=n;j++)
			dp[i][j]=INF;
	dp[0][0]=0;
	for (i=0;i<=n;i++)
	{
		for (j=0;j<=n;j++)
		{
			if (!i && !j) continue;
			if (i) dp[i][j]=min(dp[i][j],dp[i-1][j]+calc(pos1[i],i-1,j));
			if (j) dp[i][j]=min(dp[i][j],dp[i][j-1]+calc(pos2[j],i,j-1));
		}
	}
	printf("%d\n",dp[n][n]);
	return 0;
}


Measured memory_bytes: 82432
N = int(input())
X = input()

a = X.count("1")
ap, am = a+1, a-1
Flag = True

if am == 0:
  Flag = False
  am += 1

Ap = [1]
Am = [1]

for i in range(N-1):
  Ap.append(Ap[-1]*2%ap)
  Am.append(Am[-1]*2%am)

Aps = 0
Ams = 0

for i in range(N):
  if X[-1-i] == "1":
    Aps += Ap[i]
    Aps %= ap
    Ams += Am[i]
    Ams %= am
    
def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x = x + (x >> 8) 
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f

for i in range(N):
  cnt = 0
  if X[i] == "1":
    if Flag:
      p = Ams - Am[-1-i]
      p %= am
      cnt += 1
    else:
      p = 0
  else:
    p = Aps + Ap[-1-i]
    p %= ap
    cnt += 1
  while p > 0:
    p %= popcount(p)
    cnt += 1
  print(cnt)

Measured memory_bytes: 25300
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator

import datetime


inf = float('inf')


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_list_of_int():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


# inputs
S = ""


def set_inputs():
    global S
    S = get_str()


def main():
    set_inputs()
    d = datetime.datetime.strptime(S, "%Y/%m/%d").date()
    if d <= datetime.date(2019, 4, 30):
        print("Heisei")
    else:
        print("TBD")


if __name__ == '__main__':
    main()


Measured memory_bytes: 52076
#include <cstdio>
using namespace std;

int main(){
  int K, S;
  int variables = scanf("%d %d", &K, &S);
  
  int count = 0;
  for(int x=0; x<=K; x++){
    for(int y=0; y<=K; y++){
      int z=S-x-y;
      if(0<=z && z<=K) count++;
    }
  }
  printf("%d", count);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

int main(void) {
    int N,A,B;
    int num;
    int sum = 0;

    std::cin >> N >> A >> B;

    for(int i = 1; i <= N; i++) {
        num = i/10000%10 + i/1000%10 + i/100%10 + i/10%10 + i%10;
        if(num >= A && num <= B)
            sum += i;
    }

    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void){
  int n;
  int x[1000];
  int i;
  int z;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&x[i]);
   }
  for(z=1; z<=n; z++){
    if(z==n){printf("%d\n",x[i-z]);}
    else{printf("%d ",x[i-z]);}
  }
return 0;
    }

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

using namespace std;
using Edge = pair<int, long long>;
using Graph = vector<vector<Edge>>;

vector<ll> d = vector<ll>(100010);
Graph g = Graph(100010);
void dfs(int n, ll dist, int p) {
  d.at(n) = dist;
  for(auto e : g.at(n)) {
    if(e.first == p) continue;
    dfs(e.first, dist + e.second, n);
  }
}

int main() {
  int N, Q, K;
  cin >> N;

  int a, b, c;
  REP(i, N - 1) {
    cin >> a >> b >> c;
    a--;
    b--;
    g.at(a).push_back({b, c});
    g.at(b).push_back({a, c});
  }

  cin >> Q >> K;
  K--;
  dfs(K, 0, -1);

  int x, y;
  REP(i, Q) {
    cin >> x >> y;
    x--;
    y--;
    ll ans = d.at(x) + d.at(y);
    cout << ans << endl;
  }
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;
    if (v <= w) cout << "NO" << '\n';
    else if (abs(a - b) <= (t * (v - w))) cout << "YES" << '\n';
    else cout << "NO" << '\n';
}


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

using namespace std;

const double EPS = 1e-7;
const int N = 1e2+6, M = 1e4+5, OO = 0x3f3f3f3f;

int n,m,flag;
char a[N][N];

int main(){
    cin >> n >> m;
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < m; ++j)
        {
            scanf(" %c", &a[i][j]);
        }
    }



    //ROOWWWWSSSS
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < m; ++j)
        {
            if(a[i][j] == '#')flag = 1;
        }
        if(flag == 0)
        {
            for(int j = 0; j < m; ++j)
            {
                a[i][j] = '0';
            }
        }else
        {
            flag = 0;
        }
    }

    //ColumnSSSSSS
    for(int j = 0; j < m; ++j)
    {
        for(int i = 0; i < n; ++i)
        {
            if(a[i][j] == '#')flag = 1;
        }
        if(flag == 0)
        {
            for(int i = 0; i < n; ++i)
            {
                a[i][j] = '0';
            }
        }else
        {
            flag = 0;
        }
    }








    int x = 1;
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < m; ++j)
        {
            if(a[i][j] == '0')
            {
                continue;
            }
            else
            {
                printf("%c", a[i][j]);
            }
        }
        printf("\n");
    }
    return 0;
}


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


public class Main{
    static long [][] memo;
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        // Start writing your solution here. -------------------------------------
        long MOD = 1000000007;
        //int t = sc.nextInt();
        int t = 1;
        Main sol = new Main();
        while(t -- > 0)
        {
            int n = sc.nextInt();
            memo = new long[n][n];
            Integer a[][] = new Integer[n][2];
            long res = 0l;
            for(int i = 0; i < n; i++) {
                a[i][0] = sc.nextInt();
                a[i][1] = i;
            }
            Arrays.sort(a, (a1, a2) -> a1[0] - a2[0]);
            res = solve(a, 0, n- 1);
            //for(int ii = 0; ii < n; ii++) System.out.println(Arrays.toString(memo[ii]));
            out.println(res);
        }
        out.close();
    }
    public static long solve(Integer[][] a, int lo, int hi){
        if(lo > hi) return 0l;
        if(memo[lo][hi] > 0) return memo[lo][hi];
        int n = a.length,  ind = hi - lo;
        long res = Math.max(solve(a, lo + 1, hi) + 1L * Math.abs(lo - a[ind][1]) * a[ind][0],
                solve(a, lo, hi - 1) + 1L * Math.abs(hi - a[ind][1]) * a[ind][0]);
        return memo[lo][hi] = res;
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}


Measured memory_bytes: 85400
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#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 FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int n, m;
    while (cin >> n  >> m) {
        int a[n], b[n], c[m], d[m];
        FOR(i,0,n)
            cin >> a[i] >> b[i];
        FOR(i,0,m)
            cin >> c[i] >> d[i];
        int cnt = 1e5, ans;
        FOR(i,0,n) {
            cnt = 1e9;
            FOR(j,0,m) {
                int length = abs(a[i] - c[j]) + abs(b[i] - d[j]);
                if (cnt > length) {
                    cnt = length;
                    ans = j+1;
                }
            }
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			int ans = 0;
			while (true) {
				var m = Regex.Match(s, "([ATCG]+)(.*)");
				if (m.Success) {
					ans = Math.Max(ans, m.Groups[1].Value.Length);
					s = m.Groups[2].Value;
				} else {
					break;
				}
			}
			Console.WriteLine(ans);
		}
	}
}

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

int main()
{
	string S ;
	cin  >> S ;
	
	if(S=="ABC")
		cout << "ARC" <<endl ;
	else
		cout << "ABC" <<endl ;
}	


Measured memory_bytes: 3596
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
 
#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
 
// mp::cpp_int
 
 int hell=0;
const int MOD=1000000007;
const int MOD1=1000000007;
 
int power(int a,int b)
{
  if(b==0)return 1;
  if(b==1)return a%hell;
  int t=power(a,b/2);
  t*=t;
  t%=hell;
   if(b&1)
   {
       t*=a;
       t%=hell;
   }
   return t;
 
}
 
void EE(int a, int b, int& x, int& y)
{
    if(a%b == 0)
    {
        x=0;
        y=1;
        return;
    }
    EE(b,a%b,x,y);
    int temp = x;
    x = y;
    y = temp - y*(a/b);
}
 
 
int inverse(int a)
{
    int x=0,y=0;
    int m=hell;
    EE(a,m,x,y);
    if(x<0) x +=MOD*m;
    x%=m;
    return x;
}
 
 
int pw(int a,int b)
{
  int x=a;
  rep(i,1,b){
    a=a*x;
    }
  return a;
}
 
 
int gcd(int a,int b)
{   
  
  if(b==0)return a;
  return gcd(b-a%b,a%b);
}
int dig(int a)
{
  int sum=0;
  while(a!=0)
  {
    sum+=a%10;
    a/=10;
  }
  
} 


 
int solve()
{  

int n;
cin>>n;
vi a(n);
rep(i,0,n)cin>>a[i];
int ans=0;
rep(i,1,n-1)
{  

  int mx=max({a[i-1],a[i],a[i+1]});
  int mn=min({a[i-1],a[i],a[i+1]});
    if(a[i]>mn&&a[i]<mx)ans++;
}
cout<<ans;

  return 0;
}
 
 
signed main()
{  int t=1;
 
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);                                                                    
 
 

 
//pri();
 
  clock_t time_req;
 
    // Without ung pow function
                                                                                                                   
 
  //cin>>t;
 
    int k=1;
   while(t--)
     {
      // cout<<"Case #"<<k<<":"<<" ";k++;
      solve();
      //cout<<endl;
     }
 
         time_req = clock() - time_req;
    //cout <<endl<< "Processor time taken is "
     // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;
 
 
    return 0;
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}

ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


string Toupper(string s){
  string ans="";
  rep(i,s.size()){
    if('a'<=s[i] && s[i]<='z') ans+=(char)s[i]-32;
    else ans+=s[i];
  }
  return ans;
}
string Tolower(string s){
  string ans="";
  rep(i,s.size()){
    if('A'<=s[i] && s[i]<='Z') ans+=(char)s[i]+32;
    else ans+=s[i];
  }
  return ans;
}


const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*bool cmp(pint a, pint b) { return a.second < b.second; }*/

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k;
  cin>>n>>k;
  vector<string> v(n);
  rep(i,n) cin>>v[i];
  sort(ALL(v));
  rep(i,n){
    cout<<v[i];
  }
  cout<<endl;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

vector<P> c;


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  vector<llvec> v(N);
  rep(i, N-1){
    ll a, b;
    cin >> a >> b;
    a--;b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  ll ans = 0;
  rep(i, N){
    ll c1;cin>>c1;
    c.push_back({c1,i});
    ans += c1;
  }
  sort(ALL(c), [](P a, P b){return a.first>b.first;});
  ans -=c[0].first;
  vector<ll> marked(N, 0);
  cout << ans << endl;
  ll ind=1, queind=1;
  queue<ll> que;
  que.push(0);
  marked[0]=1;
  c[0].second=1;
  while(!que.empty()){
    ll current = que.front();
    rep(i, v[current].size()){
      ll next = v[current][i];
      if(marked[next]!=0){
        continue;
      }
      marked[next] = 1;
      c[ind].second=next+1;
      ind++;
      que.push(next);
    }
    que.pop();
  }
  
  sort(ALL(c), [](P a, P b){return a.second<b.second;});
  rep(i, N){
    cout << c[i].first << " " ;
  }
  
  return 0;
}


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

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int x;
  cin >> x;

  if(x < 1200){
    cout << "ABC\n";
  }else{
    cout << "ARC\n";
  }
  return 0;
}



Measured memory_bytes: 256
// ref. https://atcoder.jp/contests/code-festival-2016-qualb/tasks/codefestival_2016_qualB_c

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll w, h;
  cin >> w >> h;
  vector<P> edges; // pair of <cost, type>. 0 .. p, 1 .. q
  rep(i, w) {
    ll cost;
    cin >> cost;
    edges.emplace_back(cost, 0);
  }
  rep(i, h) {
    ll cost;
    cin >> cost;
    edges.emplace_back(cost, 1);
  }

  sort(all(edges));
  ll x = w+1; // remaining x
  ll y = h+1; // remaining y

  ll ans = 0;
  for (auto& p : edges) {
    ll cost = p.first;
    ll type = p.second;
    if (type == 0) { // type x
      ans += cost * y;
      --x;
    } else { // type y
      ans += cost * x;
      --y;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define fo(i, n) for(int i = 1; i <= n; ++i)
#define mp make_pair
#define F first
#define S second
#define pb push_back

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

const int N = 200200;
const int mod = 1e9 + 7;

int a[N];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);

	ll n;
	cin >> n;
	int len = 0;
	int cnt = 0;
	while(n > 0)
	{
		a[++cnt] = n % 10;
		n /= 10;
	}
	reverse(a + 1, a +cnt+1);
	ll ans = 0,sum=0;
	for(int i =1 ;i<=cnt; ++i)
	{
		ans = max(ans,sum+a[i]-1 +9*(cnt-i));
		sum+=a[i];
	}
	ans =max(ans,sum);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  typedef long long ll;
  int k;
  int b=0;
  ll ans = 0;
  cin >> k;
  int a[k][k][k]= {};
  for(int i=1;i<=k;++i) {
    for(int j=1;j<=k;++j) {
      for(int l=1;l<=k; ++l) {
        if(a[i-1][j-1][l-1] != 0) {
          ans +=a[i-1][j-1][l-1];
          continue;
        }
        b = gcd(i,j);
        ans += gcd(b,l);
        a[i-1][j-1][l-1] = gcd(b,l);
        a[i-1][l-1][j-1] = gcd(b,l);
        a[j-1][i-1][l-1] = gcd(b,l);
        a[j-1][l-1][i-1] = gcd(b,l);
        a[l-1][j-1][i-1] = gcd(b,l);
        a[l-1][i-1][j-1] = gcd(b,l);
      }
    }
  }
  cout << ans;
}

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

typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

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

  int N = 13;
  string t = s;
  reverse(t.begin(), t.end());

  vector<ll> dp(N, 0);
  dp[0] = 1;

  ll base = 1;
  for (int i = 0; i < t.size(); i++) {
    vector<ll> next(N, 0);
    if (t[i] == '?') {
      for (int k = 0; k <= 9; k++) {
        ll d = k * base;
        for (int j = 0; j < N; j++) {
          next[(d + j) % N] += dp[j];
          next[(d + j) % N] %= MOD;
        }
      }
    } else {
      for (int j = 0; j < N; j++) {
        ll d = ((t[i] - '0') * base);
        next[(d + j) % N] += dp[j];
        next[(d + j) % N] %= MOD;        
      }
    }
    dp = next;
    base *= 10;
    base %= 13;
  }
  cout << dp[5] << endl;
  return 0;
}


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

int main()
{
	while (true) {
		int m, nmin, nmax;
		cin >> m >> nmin >> nmax;

		if (m == 0 && nmin == 0 && nmax == 0) {
			break;
		}

		vector<int> P;

		for (int i = 0; i < m; i++) {
			int temp;
			cin >> temp;
			P.push_back(temp);
		}

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

		int gap = 0;
		int num;

		for (int i = nmin; i <= nmax; i++) {
			if (P[m - i] - P[m - 1 - i] >= gap) {
				gap = P[m - i] - P[m - 1 - i];
				num = i;
			}
		}

		cout << num << endl;
	}

	return 0;
}

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

long long Modpow(long long a, long long n, long long mod)
{
	long long res = 1;
	while (n > 0)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
 
long long Modinv(long long a, long long mod)
{
	return Modpow(a, mod - 2, mod);
}

int main()
{
    constexpr int MOD = 1'000'000'007;
    
    long long k;
    std::string s;
    std::cin >> k >> s;
    long long n = s.size();
    
    long long num = 1;
    long long den = 1;
    for(int i = 0; i < n; ++i)
    {
        num = (num * (n - i)) % MOD;
        den = (den * (i + 1)) % MOD;
    }
    long long last = 1;

    // i = 0
    long long rtn = Modpow(26, k, MOD);

    for(long long i = 1; i <= k; ++i)
    {
        long long suf = Modpow(26, k - i, MOD);
        long long pre = Modpow(25, i, MOD);
        num = (num * (n - 1 + i)) % MOD;
        num = (num * Modinv(last, MOD)) % MOD;
        ++last;
        long long comb = (num * Modinv(den, MOD)) % MOD;
        rtn = (rtn + (suf * ((pre * comb) % MOD) % MOD)) % MOD;
    }
    
    std::cout << rtn << std::endl;
}

Measured memory_bytes: 4460