akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7
#define pb           push_back
using namespace std;
ll t;
ll arr[200005];
map<string,string>np;
vector<ll>v,v1;
int main()
{
    ll a,b,c,d,e,f=0,g,i,j,cnt;
    string s1,s2,s3;
    cin>>s1;
    for(i=0;i<s1.size();i++)cout<<'x';
    cout<<endl;

}


Measured memory_bytes: 384
N = int(input())
a = [0]+list(map(int,input().split()))

b = [0 for i in range(N+1)]
M = 0

for i in range(N):
    ind = N-i
    val = 0
    j=2
    while ind*j<=N:
        val += b[ind*j]
        j+=1
    if val%2 != a[ind]:
        M+=1
        b[ind]=1
print(M)
if M!=0:
    for i in range(1,N+1):
        if b[i]==1:
            if M!=1:
                print(i,end=' ')
            else:
                print(i)


Measured memory_bytes: 72412
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        
        String result = "Christmas";
        for (int i=0; i<25%d; i++) {
            if (25%d != 0) {
                result = result.concat(" Eve");
            }
        }

        System.out.println(result);
    }
}


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

using namespace std;

#define ll long long
#define endl '\n'
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
ll dp[2005];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        if (fopen("A.inp", "r")){
                freopen("test.inp", "r", stdin);
                freopen("test.out", "w", stdout);
        }
        ll n;
        cin >> n;
        ll mnmin = 1e18, mnpl = 1e18, mxmin = -1e18, mxpl = -1e18;
        for (int i = 1; i <= n; i++){
                ll x, y;
                cin >> x >> y;
                mnpl = min(mnpl, x + y);
                mxpl = max(mxpl, x + y);
                mnmin = min(mnmin, x - y);
                mxmin = max(mxmin, x - y);
        }
        cout << max(abs(mnmin - mxmin), abs(mnpl - mxpl));
}
/*
*/


Measured memory_bytes: 3648
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_D&lang=jp
 */

import java.util.*;

public class Main {
	int m = 0;
	int count = 0;
	int[] g = new int[100];

	void insertionSort(int[] array, int g) {
		for (int i = g; i < array.length; i++) {
			int v = array[i];
			int j = i - g;
			while (j >= 0 && array[j] > v) {
				array[j+g] = array[j];
				j = j - g;
				count++;
			}
			array[j+g] = v;
		}
	}
	void shellSort(int[] array) {
		count = 0;
		int h = array.length;
		while (true) {
			h /= 2;
			g[m++] = h;
			if (h <= 1) break;
		}
		for (int i = 0; i < m; i++) {
			insertionSort(array, g[i]);
		}
	}
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] array = new int[n];
		for (int i = 0; i < array.length; i++) {
			array[i] = scan.nextInt();
		}
		shellSort(array);
		System.out.println(m);
		for (int i = 0; i < m; i++) {
			System.out.print(g[i] + " ");
		}
		System.out.println();
		System.out.println(count);
		for (int i = 0; i < array.length; i++) {
			System.out.println(array[i]);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 298272
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    inf = 10**17
    #mod = 10**9 + 7

    n,m,s = map(int, input().split())
    s = min(s, 2500)
    # edge[i]:頂点iからの[行先, 必要な銀貨, 時間]
    edge = [[] for _ in range(n)] #頂点数, 場合によって変える
    for _ in range(m):
        a,b,c,d = map(int, input().split())
        edge[a-1].append((b-1, c, d))
        edge[b-1].append((a-1, c, d))

    # 銀貨との交換を自己ループとする
    for i in range(n):
        c, d = map(int, input().split())
        edge[i].append((i, -c, d))

    dp = [[inf]*2501 for _ in range(n)]
    dp[0][s] = 0
    # [時間, 所持金, 頂点]
    hq = [(0, s, 0)]
    heapify(hq)

    while hq:
        t, ginka, v = heappop(hq)
        if dp[v][ginka] < t:
            continue
        for nv, a, b in edge[v]:
            if ginka < a:
                continue
            ng = ginka - a
            if ng > 2500:
                ng = 2500
            if dp[nv][ng] > t+b:
                dp[nv][ng] = t+b
                heappush(hq, (t+b, ng, nv))
    
    for i in range(1, n):
        print(min(dp[i]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 91064
#include <iostream>
#include <cstdio>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    stack<int> S1;
    stack<pair<int,int> > S2;
    char ch;
    int A=0;
    for (int i=0; cin >> ch; i++) {
        if (ch=='\\') {
            S1.push(i);
        } else if (ch=='/' && S1.size()>0) {
            int j=S1.top();
            S1.pop();
            A+=i-j;
            int a=i-j;
            while (S2.size()>0 && S2.top().first>j) {
                a+=S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j,a));
        }
    }
    vector<int> L;
    while (S2.size()>0) {
        L.push_back(S2.top().second);
        S2.pop();
    }
    reverse(L.begin(),L.end());
    printf("%d\n",A);
    printf("%d",L.size());
    for (int k=0; k<L.size(); k++) {
        printf(" %d",L[k]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 3276
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

vector<int> A;
int sum, sum2;
int N;

int main() {
	cin >> N;
	A.resize(N);
	sum = 0;
	sum2 = 0;
	for (int n = 0; n < N; n++) {
		cin >> A[n];
		sum += A[n];
		sum2 += A[n] * A[n];
	}
	int X = floor((long double)sum/N);
	int Y = ceil((long double)sum / N);
	cout << min(
		sum2 - 2 * X * sum + N * X * X,
		sum2 - 2 * Y * sum + N * Y * Y
	) << endl;
	return 0;
}

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

int main(){
  int N,M;
  int ans=0;
  
  cin >> N;
  cin >> M;
  for(int i=1;i<=M;i++){
    int a;
    cin >> a;
    ans+=a;
  }
  N-=ans;
  if(N<0){
    N=-1;
  }
  cout << N << endl;
  return 0;
}

Measured memory_bytes: 3624
n = int(input())
a = list(map(int,input().split()))

list=[0]
list += a
list += [0]

sum=0
for i in range(n+1):
    sum += abs(list[i] - list[i+1])

for i in range(1,n+1):
    ans = 0
    ans = sum - abs(list[i] - list[i - 1]) -abs(list[i + 1] - list[i]) + abs(list[i + 1] - list[i - 1])
    print(ans)

Measured memory_bytes: 13916
n = int(input())
for l in range(n):
    a = [int(i) for i in input().split()]
    b = 0
    c = 0
    ans = "YES"
    for i in range(10):
        if a[i] > b:
             b= a[i]
        elif a[i] > c:
            c = a[i]
        else:
            ans = "NO"
    print(ans)


Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int A,B,C;
	cin>>A>>B>>C;
	if(A<=C&&C<=B)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

template<typename T>
struct BinaryIndexedTree{
    private:
    vector<T> dat;
    public:
    BinaryIndexedTree(int sz){
        dat.assign(++sz,0);
    }
    void add(int k,T x){
        for (;k<=dat.size();k+=k&-k) dat[k]+=x;
    }
    T sum(int k){
        T ret=0;
        for (;k>0;k-=k&-k) ret+=dat[k];
        return ret;
    }
    int lower_bound(T x){
        if (x<=0) return 0;
        int lb=0,r=1;
        while(r<dat.size()) r<<=1;
        for (;r>0;r>>=1){
            if (lb+r<dat.size()&&dat[lb+r]<x){
                x-=dat[lb+r];
                lb+=r;
            }
        }
        return lb+1;
    }
    T query(int l,int r){ //[l,r)
        return sum(r-1)-sum(l-1);
    }
};

const ll MAX_N=1e5+10;

ll N;
vector<ll> A(MAX_N);
vector<ll> sum(MAX_N,-1);
vector<vector<ll>> sumid(2*MAX_N);
ll minimum;

bool can(int n){
    rep2(i,1,N+1) sum[i]=-1;
    sum[0]=0;
    rep(i,N) if (A[i]<=n) sum[i+1]=1;
    rep(i,N) sum[i+1]+=sum[i];
    rep(i,2*MAX_N) sumid[i].clear();
    rep(i,N+1) sumid[sum[i]+MAX_N].push_back(i);
    BinaryIndexedTree<ll> BIT(N+1);
    ll cnt=0;
    rep(i,2*MAX_N){
        for (auto x:sumid[i]) cnt+=BIT.sum(x+1);
        for (auto x:sumid[i]) BIT.add(x+1,1);
    }
    if (cnt>=minimum) return true;
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i,N) cin >> A[i];
    minimum=N*(N+1)/2/2+1;
    ll lb=0,ub=1e9+1;
    while(ub-lb>1){
        ll mid=(ub+lb)/2;
        if (can(mid)) ub=mid;
        else lb=mid;
    }
    cout << ub << endl;
}

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

using namespace std;
using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}


ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}

const int MAX = 50;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){

    int h, w;
    cin>>h>>w;
    int n;
    cin>>n;

    vector<int> a(n);

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

    vector<int> line;
    for(int i=0;i<n;i++){
      for(int j=0;j<a[i];j++){
        line.push_back(i+1);
      }
    }


    for(int i=0;i<h;i++){
      if(i%2==0){
        for(int j=0;j<w;j++){
          cout<<line[i*w+j]<<" ";
          //piv++;
        }
      }else{
        for(int j=w-1;j>=0;j--){
          cout<<line[i*w+j]<<" ";
          //piv++;
        }
      }
      cout<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int gcdf(unsigned long a, unsigned long b)
{
	return (b == 0 ? a : gcdf(b, a % b));
}

int gcd(unsigned long va, unsigned long vb)
{
	return (va > vb ? gcdf(va, vb) : gcdf(vb, va));
}

int main(void)
{	
	while (1) {
		unsigned long a, b, divisor;
		if ((scanf("%lu %lu", &a, &b) == EOF))
			break;

		divisor = gcd(a, b);
		printf("%lu %lu\n", divisor, a / divisor * b );
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

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

const int mod=1e9+7;

int main(){
    string s;
    cin >> s;
    int ans1=0,ans2=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=(i%2==0?'0':'1')){
            ans1++;
        }
    }
    for(int i=0;i<s.size();i++){
        if(s[i]!=(i%2==1?'0':'1')){
            ans2++;
        }
    }
    cout << min(ans1,ans2) << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<queue>
#include<utility>
#include<vector>


using namespace std;

class ChessBord {
public:
	char** field;
	int num_queen;
	int num_brank;
	ChessBord();
	ChessBord(ChessBord*);
	void put_queen(int row, int column);
};

ChessBord::ChessBord(ChessBord *origin) {
	field = new char* [8];
	for (int i = 0;i < 8;i++) {
		field[i] = new char[8];
		for (int j = 0;j < 8;j++) {
			field[i][j] = origin->field[i][j];
		}
	}
	num_brank = origin->num_brank;
	num_queen = origin->num_queen;
}
 
inline bool operator<=(ChessBord a, ChessBord b) {
	return a.num_brank <= b.num_brank;
}

inline bool operator<(ChessBord a, ChessBord b) {
	return a.num_brank < b.num_brank;
}

inline bool operator>=(ChessBord a, ChessBord b) {
	return a.num_brank >= b.num_brank;
}

inline bool operator>(ChessBord a, ChessBord b) {
	return a.num_brank > b.num_brank;
}




ChessBord::ChessBord() {
	field = new char* [8];
	for (int i = 0;i < 8;i++) {
		field[i] = new char[8];
		for (int j = 0;j < 8;j++) {
			field[i][j] = '0';
		}
	} 
	num_brank = 64;
	num_queen = 0;
}

void ChessBord::put_queen(int row, int column) {
	field[row][column] = 'Q';
	num_queen++;
	num_brank--;
	for (int i = row - 1;i >= 0;i--) {
		if (field[i][column] == '0') {
			num_brank--;
			field[i][column] = '.';
		}
	}

	for (int i = row +1;i <8;i++) {
		if (field[i][column] == '0') {
			num_brank--;
			field[i][column] = '.';
		}
	}
	for (int i = column - 1;i >= 0;i--) {
		if (field[row][i] == '0') {
			num_brank--;
			field[row][i] = '.';
		}
	}
	for (int i = column +1;i<8;i++) {
		if (field[row][i] == '0') {
			num_brank--;
			field[row][i] = '.';
		}
	}

	for (int i = 1;i <= min(row, column);i++) {
		if (field[row - i][column - i] == '0') {
			num_brank--;
			field[row - i][column - i] = '.';
		}
	}

	for (int i = 1;i <= min(7 - row, column);i++) {
		if (field[row+i][column - i] == '0') {
			num_brank--;
			field[row + i][column - i] = '.';
		}
	}
	for (int i = 1;i <= min(row, 7-column);i++) {
		if (field[row - i][column + i] == '0') {
			num_brank--;
			field[row - i][column + i] = '.';
		}
	}

	for (int i = 1;i <= min(7-row, 7-column);i++) {
		if (field[row + i][column + i] == '0') {
			num_brank--;
			field[row + i][column + i] = '.';
		}
	}
}



int main() {
	int n,row,column;
	ChessBord tmp;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> row >> column;
		tmp.put_queen(row, column);
	}
	priority_queue<ChessBord> pq;
	ChessBord newbord;
	while (tmp.num_queen != 8) {
		for (int i = 0;i < 8;i++) {
			for (int j = 0;j < 8;j++) {
				if (tmp.field[i][j] == '0') {
					newbord = new ChessBord(&tmp);
					newbord.put_queen(i, j);
					pq.push(newbord);
					
				}
			}
		}
		tmp = pq.top();
		pq.pop();
	}
	for (int i = 0;i < 8;i++) {
		for (int j = 0;j < 8;j++) {
			cout << tmp.field[i][j];
		}
		cout << endl;
	}
	
}




Measured memory_bytes: 15872
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

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

vector<vector<vector<int>>> dp(127, vector<vector<int>>(2, vector<int>(8, 0)));
/// dp[digit][isSmall][num of K]

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

    dp[0][0][0] = 1;

    const int L = N.size();
    rep(i, L) {
        const int D = N.at(i) - '0';
        rep(j, 2) {
            rep(k, K + 1) {
                for(int d = 0; d <= (j ? 9 : D); ++d) {
                    dp[i + 1][j || (d < D)][k + (d != 0)] += dp[i][j][k];
                }
            }
        }
    }
    cout << dp[L][0][K] + dp[L][1][K] << endl;
}


Measured memory_bytes: 3632
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    int c=0;
    fff(i,n-2) {
        if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C')
        c++;
    }
    cout << c;
    
    
    
	return 0;
    
}

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

int main() {
    int cnt[4] = {0};
    rep(i, 6) {
        int a;
        cin >> a;
        --a;
        ++cnt[a];
    }

    int two = 0, one = 0;
    rep(i, 4) {
        if (cnt[i] > 2) {
            cout << "NO" << endl;
            return 0;
        } else if (cnt[i] == 2)
            ++two;
        else if (cnt[i] == 1)
            ++one;
    }

    if(two==one&&one==2)
        cout << "YES";
    else
        cout << "NO";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	cout << n/3 << endl;

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
string dir[] = {"R", "D", "L", "U"};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, ans = 1;
    string s;
    cin >> n >> s;
    for(int i=1;i<n;i++){
        if(s[i-1]=='x' && s[i]=='x')break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3328
#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

const double PI = acos(-1);
constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

int f(int x, int y, int c){
    if(not x and not y) return c;
    int a = x % 10, b = y % 10;
    return a * b + c + f(x/10, y/10, (a+b+c)/10);
}

int calc(int x, int y){
    string sx = to_string(x), sy = to_string(y);
    int res = 0, nx = sx.size(), ny = sy.size(), c = 0;
    for(int i = 0; i < max(nx, ny); i++){
        int tx = (nx <= i ? 0 : (int)(sx[i] - '0'));
        int ty = (ny <= i ? 0 : (int)(sy[i] - '0'));
        int t = tx * ty + c;
        c = 0;
        if(t >= 10){
            c = 1;
            t -= 10;
        }
        res += t;
    }
    return res;
}

class Task{
public:
    void solve(istream& in, ostream& out){
        int N;
        in>>N;
        vc<int> A(N), pref(N+1, 0);
        REP(i, N){
            in>>A[i];
            pref[i+1] += pref[i] + A[i];
        }
        const int INF = ten(9);
        vvc<int> dp(N, vc<int>(N, INF));
        REP(i, N) dp[i][i] = 0;
        FOR(l, 2, N+1){
            REP(i, N-l+1){
                int j = i + l - 1;
                FOR(k, i, j){
                    int x = pref[k+1] - pref[i];
                    int y = pref[j+1] - pref[k+1];
                    chmin(dp[i][j], dp[i][k]+dp[k+1][j]+f(x, y, 0));
                }
            }
        }
        out<<dp[0][N-1]<<'\n';
#ifdef DEBUG
        out<<f(456, 545, 0)<<'\n';
#endif
    }
};

int main(){
    istream& in(cin);
    ostream& out(cout);
    ios_base::sync_with_stdio(false);
    in.tie(nullptr), out.tie(nullptr);
    Task solver;
    solver.solve(in, out);
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

double n, m, d;
signed main()
{
    cin >> n >> m >> d;

    if(d == 0) {
        printf("%.11f\n", (1.0 / n) * (m - 1.0));
    } else {
        printf("%.11f\n", (2 * (n - d) / (n * n)) * (m - 1.0));
    }
    return 0;
}


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

namespace test
{
  static class test
  {
	static void Main()
    {
    	string day = Console.ReadLine();
        var days = new Dictionary<string, int>();
        days.Add("SUN", 7);
        days.Add("MON", 6);
        days.Add("TUE", 5);
        days.Add("WED", 4);
        days.Add("THU", 3);
        days.Add("FRI", 2);
        days.Add("SAT", 1);
        
        Console.WriteLine(days[day]);
    }
  }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <unordered_set>
#include <math.h>

using namespace std;

using ll = long long;
const ll mod = 1e9 + 7;
vector<vector<int>> v;
vector<int> vec;
int n, m, lst = 1;

void gen(int pos)
{
	if (pos == n)
		v.push_back(vec);
	else
	{
		for (int i = lst; i <= m; i++)
		{
			vec[pos] = i;
			int prev = lst;
			lst = i;
			gen(pos + 1);
			lst = prev;
		}
	}
}

int main()
{
	int q;
	cin >> n >> m >> q;
	vec.resize(n);
	vector<int> a(q), b(q), c(q), d(q);
	gen(0);
	for (int i = 0; i < q; i++)
	{
		cin >> a[i] >> b[i]>> c[i] >> d[i];
		a[i]--;
		b[i]--;
	}
	ll ans = 0;
	for (auto vv : v)
	{
		ll sum = 0;
		for (int i = 0; i < q; i++)
		{
			if (vv[b[i]] - vv[a[i]] == c[i])
				sum += d[i];
		}
		ans = max(ans, sum);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 9776
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n, m;
    cin >> n >> m;
    vvbool e(n+1, vbool(n+1, false));
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        e[a][b] = true;
        e[b][a] = true;
    }
    vint p(n);
    iota(all(p), 1);
    int ans = 0;
    do {
        if (p[0] != 1) break;
        rep(i, n-1) {
            if (!e[p[i]][p[i+1]]) break;
            if (i == n-2) ans++;
        }
    } while( next_permutation(all(p)) );

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

Measured memory_bytes: 256
#include<iostream>
#define ll long long

using namespace std;

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll d = n/(a+b);
  if(n % (a+b) >= 0 && n % (a+b) <= a) cout << d*a + n % (a + b) << endl;
  else if(n % (a+b) > a) cout << (d+1)*a << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 2e17;
const int mod = 1e9 + 7;

signed main() {
    int N;
    cin >> N;
    vector<int> A(N, 0);
    cin >> A;
    int ans = 0;
    bool check = false;
    for (int i = 0; i < N; i++) {
        ans += A[i] / 2;
        A[i] = A[i] % 2;

        if (A[i] == 1 && i + 1 != N && A[i + 1] > 0) {
            ++ans;
            A[i]--;
            A[i + 1]--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
  char S[4];
  int C[4];
  scanf("%s",S);
  
  for(int i = 0 ;i<4;i++){
    C[i]=0;
    for(int j = 0;j<4;j++){
   		if(S[i] == S[j])C[i]++; 
    }
    if(C[i] != 2){
      printf("No");
      return 0;
    }
  }
  printf("Yes");
  
  return 0; 
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FOD(i,a,b) for(ll i=(a);i>=(b);--i)
#define name "a"
#define pb push_back
typedef pair < ll , ll > ii;
const ll maxn=4e5+7,oo=1e18,mod=1e9+7;
ll n,k,a[maxn],kq=oo,s[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(name".inp","r",stdin);
    //freopen(name".out","w",stdout);
    cin>>k>>n;
    FOR(i,1,n)
    {
        cin>>a[i];
        s[i]=s[i-1]+a[i]-a[i-1];
    }
    FOR(i,n+1,2*n)
    {
        a[i]=a[i-n];
        if(i==n+1)
            s[i]=s[i-1]+a[1]+k-a[n];
        else s[i]=s[i-1]+abs(a[i]-a[i-1]);
    }
    FOR(i,1,n)
    {
        ll tmp=s[i+n-1]-s[i];
        kq=min(kq,tmp);
    }
    cout<<kq;
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

const int N = 123;

int a[2][N];

void solve() {
	int n; scanf("%d", &n);
	for (int j = 0; j < 2; ++j) {
		for (int i = 0; i < n; ++i) {
			scanf("%d", a[j]+i);
			if (i) a[j][i] += a[j][i-1];
		}
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		ans = max(ans, a[0][i]+a[1][n-1]-(i?a[1][i-1]:0));
	}
	printf("%d", ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc001.contest.atcoder.jp/tasks/agc001_b>
問題文============================================================
 高橋君は 1 辺の長さが N の 3 枚の鏡を正三角形状に組み合わせました。 三角形の頂点をそれぞれ a,b,c とします。
 
 高橋君は、辺 ab 上の頂点 a から X の点から、辺 bc と平行に不思議な光を発射しました。
 不思議な光は、普通の光と同じように真っすぐ進み、鏡に当たると反射するのですが、
 不思議な光がすでに通った点に当たったときにも反射をします。
 
 不思議な光を発射した時、不思議な光は必ず発射した点に戻ってくることが証明できます。
 このとき、光の軌跡の長さが全体でいくらになるかを求めて下さい。

=================================================================

解説=============================================================

================================================================
*/
ll solve(){
    ll ret = 0;
    ll N,X; cin >> N >> X;
    
    ret += N;
    ll a = X;
    ll b = N - X;
    while(true){
        if(a <= b){
            ret += b/a * 2 * a;
            if(b%a == 0){
                ret -= a;
                break;
            }
            b = b - b/a*a;
        }else{
            ret += a/b * 2 * b;
            if(a%b == 0){
                ret -= b;
                break;
            }
            a = a - a/b*b;
        }
    }
    return ret;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


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

int main(){
	int n,k; cin>>n>>k;
	int ans=(n-k+k-1-1)/(k-1);
	cout<<ans+1<<endl;
}

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

using namespace std;

const long long mod = 1000000007;

long long gcd(long long a, long long b)
{
	return b ? gcd(b, a % b) : a;
}

int main(int, char**) {
	int n;
	cin >> n;
	long long cnt0 = mod-1;
	map<pair<long long, long long>, pair<long long, long long>> cnt;
	long long pw[202020] = {1};
	for (int i=1; i<202020; i++) pw[i] = (pw[i - 1] * 2) % mod;
	for (int i=0; i<n; i++) {
		long long a, b; 
		cin >> a >> b;
		if (a==0 && b==0) {
			cnt0++;
			continue;
		}
		if (make_pair(a, b) < make_pair(0ll, 0ll)) a = -a, b = -b;
		long long g = gcd(abs(a), abs(b));
		a /= g;
		b /= g;
		if (b>0) cnt[{a, b}].first++;
		else cnt[{-b, a}].second++;
	}
	long long ret = 1;
	for (auto& c : cnt) {
		ret = ret * (pw[c.second.first] + pw[c.second.second] - 1) % mod;
	}
	cout << (ret + cnt0) % mod << endl;
	return 0;
}


Measured memory_bytes: 20820
#include <bits/stdc++.h>
const int INF = 1e9;
const int MODk = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    int n,r;
    while(cin >> n >> r){
        if(n == 0 && r == 0)return 0;
        vector<int> cards(n);
        iota(cards.begin(),cards.end(),1);
        for(int i = 0;i < r;i++){
            int p,c;cin >> p >> c;
            vector<int> vec(n);
            for(int a = 0;a <= n-p-c;a++){
             //   cout<<a<<endl;
                vec.at(a) = cards.at(a);
            }
           // cout<<endl;
            for(int a = n-p-c+1 ;a <= n-(p);a++){
            //    cout<<a<<endl;
                vec.at(a+(p-1)) = cards.at(a);

            }
        //    cout<<endl;
            for(int a = n-p+1;a < n;a++){
          //      cout<<a<<endl;
                vec.at(a-c) = cards.at(a);
            }
            cards = vec;
        }
        cout<<cards.back()<<endl;
    }
}



Measured memory_bytes: 3076
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

struct edge {
	ll to;
	ll cost;
};
typedef pair<ll, ll> P;
vector<ll> d;

void dijkstra(int s, vector<vector<edge>>& g) {
	priority_queue<P, vector<P>, greater<P>> q;
	d = vector<ll>(g.size(), INF_LL);
	d[s] = 0;
	q.push(P{ 0,s });

	while (!q.empty()) {
		P p = q.top(); q.pop();
		ll v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < g[v].size(); i++) {
			edge e = g[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				q.push(P{ d[e.to] , e.to });
			}
		}
	}
}

bool bellman_f(int s, vector<vector<edge>> &g) {
	d = vector<ll>(g.size(),INF_LL);
	d[s] = 0;
	for (int i = 0; i < g.size(); i++) {
		for (int j = 0; j < g.size(); j++) {
			for (int k = 0; k < g[j].size(); k++) {
				auto e = g[j][k];
				if (d[j] != INF_LL && d[e.to] > d[j] + e.cost) {
					d[e.to] = d[j] + e.cost;
					if (i == g.size() - 1)return true;
				}
			}
		}
	}
	return false;
}

int main() {
	int V, E;
	cin >> V >> E;
	vector<vector<edge>> g(V);
	for (int i = 0; i < E; i++) {
		int a, b;
		cin >> a >> b;
		g[a].push_back({ b,-1 });
	}

	bool flag = false;

	for (int i = 0; i < V; i++) {
		flag = flag | bellman_f(i, g);
	}
	cout << flag << endl;
}


Measured memory_bytes: 3172
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
const ll MOD=998244353;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};


int main()
{
  int n; cin >> n;
  string s; cin >> s;
  mint res(1);
  vector<mint> buf(7);
  // 0: , 1:R, 2:G, 3:B, 4:RG, 5:GB, 6:BR
  buf[0].x = n;
  rep(i, 3*n) {
    if(s[i] == 'R') {
      if(buf[5].x > 0) {
	res *= buf[5];
	buf[5].x--;
      }
      else if(buf[2].x > 0) {
	res *= buf[2];
	buf[2].x--;
	buf[4].x++;
      }
      else if(buf[3].x > 0) {
	res *= buf[3];
	buf[3].x--;
	buf[6].x++;	
      }
      else {
	res *= buf[0];
	buf[0].x--;
	buf[1].x++;	
      }
    }
    else if(s[i] == 'G') {
      if(buf[6].x > 0) {
	res *= buf[6];
	buf[6].x--;
      }
      else if(buf[1].x > 0) {
	res *= buf[1];
	buf[1].x--;
	buf[4].x++;
      }
      else if(buf[3].x > 0) {
	res *= buf[3];
	buf[3].x--;
	buf[5].x++;	
      }
      else {
	res *= buf[0];
	buf[0].x--;
	buf[2].x++;	
      }
    }
    else {
      if(buf[4].x > 0) {
	res *= buf[4];
	buf[4].x--;
      }
      else if(buf[1].x > 0) {
	res *= buf[1];
	buf[1].x--;
	buf[6].x++;
      }
      else if(buf[2].x > 0) {
	res *= buf[2];
	buf[2].x--;
	buf[5].x++;	
      }
      else {
	res *= buf[0];
	buf[0].x--;
	buf[3].x++;	
      }
    }        
  }
  cout << res.x << "\n";
    
  return 0;
}


Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int x=0; char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return x;
}
main()
{
	long long n = read();
    long long ans = n;
	for (int i = 1; i < n; ++i)
	{
        long long u = read(), v = read();
		if (u > v) swap(u, v);
        ans += i * (n - i + 1) - u * (n - v + 1);
	}
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#define REP(i, n) for(int i = 0; i < n; i++) //普通のループ
#define REPR(i, n) for(int i = n; i >= 0; i--) //逆ループ
#define FOR(i, m, n) for(int i = m; i < n; i++) //最初の数値を指定したループ

//型名省略
typedef long long ll;

using namespace std;

int main(){
    //string s;
    //bool ans;
    ll x, y, z, tmp;

    cin >> x >> y >> z;

    if(1>x || x>100) return 0;
    if(1>y || y>100) return 0;
    if(1>z || z>100) return 0;  

    tmp = x;
    x = y;
    y = tmp;

    tmp = x;
    x = z;
    z = tmp;

    cout << x << " " << y << " " << z << endl;
    //ans = checkCharacterMatching(s, 2, 3);
    //cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>
#define rep(i,n) for (int i=0; i <(n); ++i)
using namespace std;


int main() {
  int X, Y;
  cin >> X >> Y;
  
int a;
string result;
result = "No";
for (int i=0; i < X+1; ++i){
  a = X - i;
  if(2*i+4*a==Y){
    result = "Yes";
  } 
  
}
cout << result << endl;
return 0;
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int i=0;
 int n;
 int l;
 cin>>n>>l;
 vector<string> s(n);
 while(i<n)
 {
 	cin>>s[i];
 	i++;
 }
 string ans="";
 sort(s.begin(),s.end());
 for(i=0;i<n;i++)
 ans+=s[i];
 cout<<ans<<endl;
 return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }
    else{
        int a,b;cin>>a>>b;
        cout<<a+b<<endl;
    }
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define for_each(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

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

struct TopologicalSort {
    vector<vector<int>> edge;
    vector<int> sorted;
    TopologicalSort(int n) : edge(n), sorted(n) {}

    void add_edge(int a, int b) {
        edge[a].push_back(b);
    }

    bool visit(int v, vector<int> &order, vector<int> &color) {
        color[v] = 1;
        for (int u : edge[v]) {
            if (color[u] == 2) continue;
            if (color[u] == 1) return false;
            if (!visit(u, order, color)) return false;
        }
        order.push_back(v);
        color[v] = 2;
        return true;
    }

    bool sort() {
        int n = edge.size();
        vector<int> color(n);
        for (int u = 0; u < n; u++)
            if (!color[u] && !visit(u, sorted, color)) return false;
        reverse(sorted.begin(), sorted.end());
        return true;
    }
};

int dp[100005];
bool used[100005];

int dfs(int i, vii &edge) {
    if (used[i]) return dp[i];
    used[i] = true;
    for (auto e : edge[i]) {
        chmax(dp[i], dfs(e, edge) + 1);
        used[e] = true;
    }
    return dp[i];
}

int main() {
    int n, m;
    cin >> n >> m;
    TopologicalSort ts(n);
    vii E(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        ts.add_edge(a, b);
        E[a].push_back(b);
    }
    ts.sort();

    for_each(cu, ts.sorted) for_each(to, E[cu]) chmax(dp[to], dp[cu] + 1);
    int ans = 0;
    rep(i, n) chmax(ans, dp[i]);
    cout << ans << endl;
}


Measured memory_bytes: 13432
#include<bits/stdc++.h>
using namespace std;
int main(){
int x, h, m, s, e = 60;
cin >> x;
h=x/(e*e);
x-=h*e*e;
m=x/e;
x-=m*e;
s=x;
	cout<<h<<":"<<m<<":"<<s<<endl;
	return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextLong();

  vector<vector<int>> g(N);
  REP(i, N-1) {
    int a = nextLong() - 1;
    int b = nextLong() - 1;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<ll> ans(N);
  vector<ll> c(N);
  REP(i, N) c[i] = nextLong();
  sort(ALL(c));

  vector<int> deg(N);
  REP(i, N) deg[i] = g[i].size();

  queue<int> q;
  REP(i, N) {
    if (deg[i] == 1) {
      q.push(i);
    }
  }

  int ci = 0;
  while (!q.empty()) {
    int v = q.front(); q.pop();
    // cout << "v=" << v << endl;
    ans[v] = c[ci++];
    for (int u : g[v]) {
      deg[u]--;
      if (deg[u] == 1) {
        q.push(u);
      }
    }
  }

  ll score = 0;
  REP(u, N) {
    for(int v : g[u]) if (u < v) {
      score += min(ans[u], ans[v]);
    }
  }
  cout << score << endl;
  REP(i, ans.size()) {
    if (i) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 4312
n = input()
a = map(int,raw_input().split())

for i in xrange(len(a)):
  v = a[i]
  j = i - 1
  while j >= 0 and a[j] > v :
    a[j+1] = a[j]
    j = j - 1
  a[j+1] = v

  print " ".join(map(str,a))

Measured memory_bytes: 6460
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    ll ans = 0;
    vector<pair<ll, int> > pairs(n);
    for (int i = 0; i < n; i++) {
        ll a;
        int b;
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
    }

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

    for (int i = 0; i < n; i++) {
        if (pairs[i].second < m) {
            ans += pairs[i].first * pairs[i].second;
            m -= pairs[i].second;
        } else {
            ans += pairs[i].first * m;
            m -= pairs[i].second - m;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include <algorithm>
#include<functional>//greaterの使用
using namespace std;
#define MAX_LIST 60000


bool find_list(int *list,int a,int b,int x){
	if(b-a<2){
		if(list[b]==x){
			return true;
		}
		if(find(list+a,list+b,x)!=list+b){
			return true;
		}
		return false;
	}
	if(list[(b+a)/2]>x){
		return find_list(list,a,(b+a)/2,x);
	}else if(list[(a+b)/2]<x){
		return find_list(list,(a+b)/2,b,x);
	}
	return true;
}

int main(){
	bool prime[MAX_LIST];
	for(int i=0;i<MAX_LIST;i++){
		prime[i]=1;
	}
	prime[0]=prime[1]=0;
	for(int i=0;i*i<MAX_LIST;i++){
		if(prime[i]==1){
			for(int j=i*2;j<MAX_LIST;j=j+i){
				prime[j]=0;
			}
		}
	}
	int primelist[60000];
	int j=0;
	for(int i=0;i<MAX_LIST;i++){
		if(prime[i]==1){
			primelist[j]=i;
			j++;
			if(j>60000){
				break;
			}
		}
	}
	int in;
	while(cin>>in,in){
		int ans=0;
		for(int i=0;primelist[i]*2<=in;i++){
			if(prime[in-primelist[i]]==1){
				ans++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1244
class NormalInput{
    input: string[];
    pointer: number;
    constructor(raw:string){
      this.input=raw.split(/ |\n/);
      this.pointer=0;
    }
    int():number{
      const ret= parseInt(this.input[this.pointer], 10);
      this.pointer++;
      return ret;
    }
    str():string{
      const ret= this.input[this.pointer];
      this.pointer++;
      return ret;
    }
    strs(length:number):string[]{
      let ret:string[]=[];
      for(let i=0;i<length;i++){
        ret.push(this.str());
      }
      return ret;
    }
    ints(length:number):number[]{
      let ret:number[]=[];
      for(let i=0;i<length;i++){
        ret.push(this.int());
      }
      return ret;
    }
  }
  function Main(_: NormalInput) {
    const [a,b,c]=[_.int(),_.int(),_.int()];
    console.log(((a==b||b==c||c==a)&&!(a==b&&b==c&&c==a))?"Yes":"No")
  }
  
  //DO NOT EDIT
  Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 7372