akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  int get = 0;
  for(int i=0;i<2;i++){
  if(A>=B){
    get += A;
    A -=1;
  }
  else{
    get += B;
    B-=1;
  }
  }
  cout << get << endl;
  return 0;

}

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

int main(){

    int N = 0;

    cin>>N;

    int a = 0;
    int b = 0;

    int count = 0;
    int flag = 0;
    bool y = false;

    for(int i = 0; i < N; i++){
        cin>>a>>b;

        if(a==b){
            count++;
        }
        else{
            count = 0;
        }

        if(count == 3){
            cout<<"Yes"<<endl;
            y = true;
            break;
        }
    }

    if(!y){
        cout<<"No"<<endl;
    }

    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int N;
	cin >> N;
	ce((N+1)/2)
    return 0;
}



Measured memory_bytes: 256
#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;
#define int long long int
// #define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
// int const mod = 998244353;
int const mod = 1e9+9;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            // res = res*a;
            res = (res*a)%m;
        }
        a=(a*a)%m;
        // a%=m;
        b=b/2;
    }
    return res;
}
// ll mul(ll num1,ll num2,ll m){
//     ll x = (num1*num2)%m;
//     return x;
// }

// ll add(ll num1,ll num2,ll m){
//     ll x = ((num1%m)+(num2%m))%m;
//     return x;
// }

// ll sub(ll num1,ll num2,ll m){
//     ll x = (((num1%m)-(num2%m))%m + m)%m;
//     return x;
// }


int inverse(int x , int m){
    return power(x,m-2,m);
}

int const N = 1e5+5;
int const inf = 2e18;

void solve(){  
    int i,j;
    int n;
    cin >> n;
    vector<int> a[n+1] , b[n+1];
    int aa = 0;
    int bb = 0;
    int ans = 0;

    for(i=1;i<=n;i++){
        int k,l,r;
        cin >> k >> l >> r;
        if(l > r){
            a[k].pb(l-r);
            aa = max(aa , k);
            ans += r;
        }
        else if(r > l){
            b[n-k].pb(r-l);
            bb = max(bb , n-k);
            ans += l;
        }
        else{
            ans += l;
        }
    }

    priority_queue<int> pq;
    for(i=aa;i>=1;i--){
        for(auto x:a[i]) pq.push(x);
        if(pq.empty()) continue;
        ans = ans + pq.top();
        pq.pop();
    }

    while(!pq.empty()) pq.pop();

    for(i=bb;i>=1;i--){
        for(auto x:b[i]) pq.push(x);
        if(pq.empty()) continue;
        ans = ans + pq.top();
        pq.pop();
    }
    cout<<ans<<endl;
}           

int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}


/*



*/

Measured memory_bytes: 17696
base=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())

print(base[K-1])

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

int main() {
  int a;
  cin >> a;
  int cnt = 0;
  if(a / 100 == 1){
    cnt++;
    a = a%100;
  }
  if(a /10 == 1){
    cnt++;
    a = a%10;
  }
  if(a/1 == 1){
    cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    // #define te
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 200100;
    typedef pair<pii, ll> piii;

    void solve() {
    	ll n;
    	cin >> n;
    	pii a[n], b[n];
    	rep(i, n) cin >> a[i].fst, a[i].snd = i+1;
    	rep(i, n) cin >> b[i].fst, b[i].snd = i+1;
    	sort(a, a+n); sort(b, b+n);
    	rep(i, n) if(a[i].fst > b[i].fst) {
    		cout << "No" << endl;
    		return;
    	}
    	rep(i, n-1) if(a[i+1].fst <= b[i].fst) {
    		cout << "Yes" << endl;
    		return;
    	} ll p[n+1] = {0};
    	rep(i, n) p[a[i].snd] = b[i].snd;
    	ll x = 1, cnt = 0;
    	do cnt++, x = p[x]; while(x!=1);
    	cout << (cnt == n ? "No" : "Yes") << endl;
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      // ll ti;   cin >> ti;  while(ti--)
      solve();
      return 0;
    }


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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int k;
	cin >> k;
	REP(i,s.length()){
		if(s[i] != s[k - 1])s[i] = '*';
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define MAX 1000

int  main()
{
  int i, j, n, key, a[N];
  
  if((scanf("%d",&n)) > N)return 0;
  for(i = 0; i < n; i++)
    {
      if((scanf("%d", &a[i])) > MAX)return 0;
    }

  for( j = 1; j <= n; j++)
    {
      for( i = 0; i < n; i++)
	{
	  printf("%d", a[i]);
	  
	  if(i < n-1)printf(" ");
	  else printf("\n");
	}
      if(j == n)continue;
      
      key = a[j];
      
      for(i = j-1; i >= 0 && a[i] > key; i--)
	{
	  a[i+1] = a[i];
	}
      a[i+1] = key;
    }
  
  return 0;
}



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

int main(){
    int N;
    cin >> N;
    double A[N];
    double sum = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        sum += 1/A[i];
    }

    cout << fixed << 1/sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(){
	char a[20000];
	scanf("%s",a);
	printf("%c",a[0]);
	scanf("%s",a);
	printf("%c",a[0]);
	scanf("%s",a);
	printf("%c\n",a[0]);
	return 0;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> vec[m];
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    if (a > m) continue;
    --a;
    vec[a].push_back(b);
  }
  
  priority_queue<int> que;
  int ans = 0;
  rep(i, m) {
    if (!vec[i].empty()) {
      for (int money : vec[i]) {
        que.push(money);
      }
    }
    if (!que.empty()) {
      ans += que.top();
      que.pop();
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
string f[8];
int n,m;
int main(){
	cin>>n>>m;
	rep(i,n) cin>>f[i];
	if(f[0][0]=='.'){
	    puts("Impossible");
		return 0;
	}
	while(1){
		vector<P>vec;
		rep(i,n)rep(j,m) if(f[i][j]=='#'){
			if(i>0 && f[i-1][j]=='#') continue;
			if(j>0 && f[i][j-1]=='#') continue;
			vec.pb(mp(i,j));
		}
		if(vec.size() != 1) break;
		f[vec[0].fi][vec[0].sc] = '.';
	}
	rep(i,n)rep(j,m){
		if(f[i][j]=='#'){
			puts("Impossible");
			return 0;
		}
	}
	puts("Possible");
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main()
{
    int a,b,sum,cnt;
    while(scanf("%d %d", &a, &b)==2)
    {
        sum=a+b;
        cnt=0;
        while(sum>0)
        {
            sum/=10;
            cnt++;
        }
        printf("%d\n",cnt);
    }
    return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n,m;
  cin>>n>>m;
  vector<tuple<int,int>> vt;
  for(int i:irange(0,m)) {
    int a,b;
    cin>>a>>b;
    int mask = 0;
    for(int j:irange(0,b)) {
      int c;
      cin>>c;
      --c;
      mask |= 1 << c;
    }
    vt.emplace_back(a,mask);
  }
  constexpr int INF = 1'000'000'000;
  vecint dp(1<<n, INF);
  dp[0] = 0;
  for (int i:irange(0,1<<n)) {
    for (const auto& t:vt) {
      int a, msk;
      tie(a,msk) = t;
      dp[i|msk] = min(dp[i|msk], dp[i] + a);
    }
  }
  if (dp.back() < INF) {
    cout<<dp.back()<<endl;
  } else {
    cout<<-1<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
N, M = list(map(int, input().split()))
array= [0] * (N+1)

for  i in range(1, M+1):
    a, b = list(map(int, input().split()))
    array[a] = array[a] +1
    array[b] = array[b] +1

for j in range(0, N):
    print(array[j+1])


Measured memory_bytes: 3060
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
// cout << fixed << setprecision(10);

int main() {
    int N;
    cin >> N;
    map<string, int> countMap;
    int Max = -1;
    for(size_t i = 0; i < N; i++) {
        string s;
        cin >> s;
        countMap[s]++;
        Max = max(Max, countMap[s]);
    }
    for(auto x : countMap) {
        if(x.second == Max) {
            cout << x.first << endl;
        }
    }
}

Measured memory_bytes: 17664
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a, b, k;
  cin >> a>> b >> k;
  int ans = 0;
  int c = 0;
  vector<int > v;
  for(int i = 1;i <=  min(a,b); i++){
    if(a%i == 0 && b%i == 0){
      v.push_back(i);
      // cout << i << endl;
      // if(c == k){
      // 	ans = i;
      // 	cout << i << endl;
      // 	return 0;
      // }
    }
  }
  // cout << v.size() << endl;
  cout << v[v.size() - k] << endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[] a = new int[m];
        for(int i = 0; i < m; i ++) {
            a[i] = scan.nextInt();
        }
        int sum = 0;
        for(int i = 0; i < a.length; i++) {
            sum += a[i];
        }
        if(n - sum < 0){
            System.out.println(-1);
        }else{
            System.out.println(n - sum);
        }


    }

}


Measured memory_bytes: 46348
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10;

int main() {
	fast_cin();
	ll n, a, b;
	cin >> n >> a >> b;
	if ((a + b) % 2 == 0) {
		cout << (b - a) / 2 << endl;
	} else {
		ll ans = a + (b - a - 1) / 2;
		a = n - a + 1;
		b = n - b + 1;
		swap(a, b);
		ans = min(ans, a + (b - a - 1) / 2);
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#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;
#define COUT(v) cout<<(v)<<endl
#define COUTDOUBLE(v) cout << std::setprecision(10)<<(v)<<endl;
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
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(){
   CIN(X);CIN(Y);
   COUT(X+Y/2);
    rt 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int dp[200] = {0};
int h[200];
int r[200];
int n,m;

int dfs(int id){
	if(dp[id])return dp[id];
	int ans = 1;
	rep(i,n){
		if(h[i] < h[id] && r[i] < r[id]){
			ans = max(dfs(i)+1,ans);
		}
	}
	return dp[id] = ans;
}
int main(){
	while(cin >> n , n){
		rep(i,200)dp[i] = 0;
		rep(i,n)cin >> h[i] >> r[i];
		cin >> m;
		rep(i,m)cin >> h[i+n] >> r[i+n];
		n += m;
		int ans = 0;
		rep(i,n){
			ans = max(ans,dfs(i));
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
n,a,b,c,d = map(int,input().split())
s = [i == "#" for i in list(input())]
s.append(False)
def check_route(x,y):
    for i in range(x,y):
        if s[i] and s[i+1]:
            return False
    return True

def check_three(x,y):
    for i in range(x-1,y):
        if (not s[i]) and (not s[i+1]) and (not s[i+2]):
            return True
    return False

if c < d:
    if check_route(a-1,c-1) and check_route(b-1,d-1):
        print("Yes")
    else:
        print("No")
else:
    if check_route(a-1,c-1) and check_route(b-1,d-1):
        if check_three(b-1,d-1):
            print("Yes")
        else:
            print("No")
    else:
        print("No")

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

const int INF = 1<<29;
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 (b<a) { a=b; return 1; } return 0; }
int dp[100010];
int main(){
    int n;
    cin >> n;
    rep(i,100010){
        dp[i]=INF;
    }
    dp[0]=0;
    int k;
    int l;
    for(int i=1;i<=n;i++){
        chmin(dp[i],dp[i-1]+1);
        k=1;
        l=1;
        while(i-pow(6,k)>=0){
            chmin(dp[i],dp[i-(int)pow(6,k)]+1);
            k++;
        }
        while(i-pow(9,l)>=0){
            chmin(dp[i],dp[i-(int)pow(9,l)]+1);
            l++;
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void dfs(vector<bool> &visited, VVI &es, VI &c, VI &ns, int &n, int s, int &cnt) {
    ns[s] = c[cnt];
    ++cnt;
    visited[s] = true;
    for (auto &e: es[s]) {
        if (visited[e]) continue;
        dfs(visited,es,c,ns,n,e,cnt);
    }
}

void solve() {
    int n;
    cin >> n;
    VVI es(n);
    int a,b;
    REP(i,0,n-1) {
        cin >> a >> b;
        es[a-1].push_back(b-1);
        es[b-1].push_back(a-1);
    }
    VI c(n);
    REP(i,0,n) cin >> c[i];
    sort(all(c));
    reverse(all(c));
    VI ns(n);
    int cnt = 0;
    vector<bool> visited(n);
    dfs(visited,es,c,ns,n,0,cnt);
    LL ans = 0;
    REP(i,0,n) {
        for (auto &e: es[i]) ans += min(ns[i], ns[e]);
    }
    cout << ans / 2 << endl;
    REP(i,0,n) {
        if (i) cout << " ";
        cout << ns[i];
    }
    cout << endl;
}

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

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

const int mod = (int)1e9 + 7;
const int N = 2005;

int f[N][N], d[2*N][N];

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	if (!a || !b) {
		cout << 1 << endl;
		return 0;
	}
	for (int i = 0; i <= a; ++i) {
		for (int j = 0; j <= b; ++j) {
			if (!i && !j) {
				f[i][j] = 1;
				d[i][j] = 1;
				continue;
			}
			int start = i - min(i, k - 1);
			int finish = i - max((k - 1) - j, 0);
			if (finish >= start && (i + j - (k - 1)) >= 0) {
				f[i][j] = (f[i][j] + d[i + j - (k - 1)][finish]) % mod;
				if (start > 0) {
					f[i][j] = (f[i][j] + (mod - d[i + j - (k - 1)][start-1])) % mod;
				}
			}
			d[i + j][i] = f[i][j];
			if (i > 0) {
				d[i + j][i] = (d[i + j][i] + d[i + j][i - 1]) % mod;
			}
		}
	}
	int result = 0;
	for (int x = 0; x <= a; x += k - 1) {
		for (int y = 0; y <= b; y += k - 1) {
			int i = a - x;
			int j = b - y;
			int start = i - min(i, k - 1);
			int finish = i - max(k - j, 1);
			if (finish >= start && (i + j - k) >= 0) {
				result = (result + d[i + j - k][finish]) % mod;
				if (start > 0) {
					result = (result + (mod - d[i + j - k][start-1])) % mod;
				}
			}
		}
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 46464
#include<bits/stdc++.h>
#define eps 0.000000001
using namespace std;
typedef double ld;
typedef pair<int,int> p;
typedef pair<ld,p> P;

int n;
ld px[200],py[200],pz[200],vx[200],vy[200],vz[200],r[200],vr[200];

ld getlen(int a,int b,ld M){
  ld ax=px[a]+vx[a]*M,ay=py[a]+vy[a]*M,az=pz[a]+vz[a]*M,ar=r[a]-vr[a]*M;
  ld bx=px[b]+vx[b]*M,by=py[b]+vy[b]*M,bz=pz[b]+vz[b]*M,br=r[b]-vr[b]*M;
  ld dx=ax-bx,dy=ay-by,dz=az-bz;
  return sqrt(dx*dx+dy*dy+dz*dz)-(ar+br);
}

ld check(int a,int b){
  ld L=0,R=100,M;
  int s=50;
  while(s--){
    M=(L+R)/2;
    ld len=getlen(a,b,M),len1=getlen(a,b,M+eps);
    if(len<len1||len<0)R=M;
    else L=M;
  }
  if(getlen(a,b,R)>0)return 100;
  return R;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++)
      cin>>px[i]>>py[i]>>pz[i]>>vx[i]>>vy[i]>>vz[i]>>r[i]>>vr[i];
    priority_queue<P,vector<P>,greater<P> > q;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++)
	q.push(P(check(i,j),p(i,j)));
      q.push(P(r[i]/vr[i],p(i,i)));
    }
    ld used[200]={};
    while(!q.empty()){
      ld t=q.top().first;
      int a=q.top().second.first,b=q.top().second.second;
      q.pop();
      if(used[a]||used[b])continue;
      used[a]=used[b]=t;
    }
    for(int i=0;i<n;i++)printf("%.10lf\n",used[i]);
  }
  return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  string s,t;cin>>s>>t;
  sort(all(s));
  sort(all(t),greater<char>());
  bool ans=(s<t);
  cout << btos(ans) << endl;
  return 0;
}

Measured memory_bytes: 256
import math
N, D = list(map(int, input().split()))
X = [None] * N
pair = 0

def count(l,r):
    s = 0
    for i in range(D):
        s += abs(l[i]-r[i])**2
    return math.sqrt(s)


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

for i in range(N-1):
    for j in range(i+1,N):
        #print(count(X[i], X[j]))
        if count(X[i], X[j]).is_integer():
            pair += 1

print(pair)

Measured memory_bytes: 38256
/*
    author: Salam_35
    Created at :

*/

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));


const ll MOD = 1e9+7;

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;
vec primes;


int main()
{
    string a;
  cin >> a;
  for(int i=0;i<a.size();i++)cout<<'x';cout<<endl;


}



Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int q;cin>>q;
    map<string,int> mp;
    rep(i,0,q){
        int cmd;cin>>cmd;
        if(cmd==0){
            string key;int x;cin>>key>>x;
            mp[key]=x;
        }else if(cmd==1){
            string key;cin>>key;
            cout<<mp[key]<<endl;
        }else {
            string key;cin>>key;
            mp[key]=0;
        }
    }
    
    
}



/*

*/



Measured memory_bytes: 27720
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

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

using namespace std;

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

	int ans = 0;
	if (N % 10 == 0) {
		N /= 2;
		while (N > 0) {
			ans += (N % 10);
			N /= 10;
		}
		ans *= 2;
	}
	else {
		while (N > 0) {
			ans += (N % 10);
			N /= 10;
		}
	}

	cout << ans << 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++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

vector<LL> wa;


vector<LL> calc(){

    vector<LL> v(100000);
    v[0] = 0;
    rep(i,100000){
        if(i == 0)continue;
        LL tmp = i*(i+1)/2;
        v[i] = tmp;
    }
    return v;
}

bool che(LL n,LL ind){
    return n >= wa[ind];
}

map<LL,int> prime_factor(LL n){
  map<LL,int> ret;
  for(LL i = 2; i * i <= n; i++){
    while(n % i == 0){
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


int main() {
    LL N;cin >> N;
    wa = calc();

    auto m = prime_factor(N);

    LL ans = 0;
    for(auto t : m){
        LL now = t.S;
        LL ct = 0;
        while(true){
            if(che(now,ct+1)){
                ct++;
            }
            else{
                ans += ct;
                break;
            }
        }
    }

    cout << ans << endl;
}

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

int N;

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

template<typename T>
struct Compress{
    vector<T> xs;
    Compress() = default;
    Compress(const vector<T> &vs){
        add(vs);
    }
    Compress(const initializer_list<vector<T>> &vs){
        for(auto &p : vs)   add(p);
    }

    // vs 内の座標をすべて追加
    void add(const vector<T> &vs){
        copy(begin(vs), end(vs), back_inserter(xs));
    }

    void add(const T &x){
        xs.emplace_back(x);
    }
    
    void build(){
        sort(begin(xs), end(xs));
        xs.erase(unique(begin(xs), end(xs)), end(xs));
    }

    // vs 内の座標を座標圧縮したものを返す
    vector<int> get(const vector<T> &vs) const{
        vector<int> ret;
        transform(begin(vs), end(vs), back_inserter(ret), [&](const T &x){
            return lower_bound(begin(xs), end(xs), x) - begin(xs);
        });
        return ret;
    }

    // 座標 x を座標圧縮したものを返す (x が xs 内で何番目にあるかを返す)
    int get(const T &x) const{
        return lower_bound(begin(xs), end(xs), x) - begin(xs);
    }

    // 座標圧縮後の k が示す実際の座標を返す
    const T &operator[](int k) const{
        return xs[k];
    }
};

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

    int V, E;
    cin >> V >> E;
    vector<vector<int>> graph(V);
    vector<int> in(V, 0);
    for(int i = 0; i < E; ++i){
        int s, t;
        cin >> s >> t;
        graph[s].push_back(t);
        ++in[t];
    }
    vector<int> vs;
    queue<int> que;
    for(int i = 0; i < V; ++i){
        if(!in[i])  que.push(i);
    }
    while(!que.empty()){
        int u = que.front();
        que.pop();
        vs.push_back(u);
        for(int v : graph[u]){
            if(--in[v] == 0)    que.push(v);
        }
    }
    cout << (vs.size() != V) << endl;
}


Measured memory_bytes: 3220
using System;

namespace tst
{
    class Program
    {
        public static void Main()
        {
            int x = int.Parse(Console.ReadLine());
            int cnt500 = 0;
            int cnt5 = 0;
            while (x >= 500)
            {
                x -= 500;
                cnt500++;
            }
            while (x >= 5)
            {
                x -= 5;
                cnt5++;
            }
            Console.WriteLine(1000 * cnt500 + 5 * cnt5);
        }
    }
}

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

int main() {
  string S;
  string S1="SSS";
  string S2="RSS", S3="SRS", S4="SSR";
  string S5="RRS", S6="RSR", S7="SRR";
  string S8="RRR";
  int cnt = 0;
  cin >> S;
  
  if(S == S1){
    cnt = 0;
  }else if(S == S2 || S == S3 || S == S4 || S == S6){
    cnt = 1;
  }else if(S == S5 || S == S7){
    cnt = 2;
  }else {
    cnt = 3;
  }
  
  cout << cnt << endl;
  
  return 0;
}

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

int main(){
    
    ios_base::sync_with_stdio(NULL);
    
    long long  n;
    string s="";
    cin>>n;
    for(long long i=1;i<=40;i++){
        
        if(n<=pow(26,i)){
         n--;
         for(long long j=0;j<i;j++){
             s+=(char(97+n%26));
             n/=26;
         }
         break;
        }
        else{
            n-=pow(26,i);
        }
    }
    
    reverse(s.begin(),s.end());
    cout<<s;
}

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

int main(){
  string s;
  cin >> s;
  int cnt = 1;
  for ( int i = 1; i < s.length(); i++){
    if ( s[i-1] != s[i]){
      cnt ++;
    }
  }

  cout << cnt -1 << endl;

  return 0;
}

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

int main() {
	int A[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin >> A[i][j];
		}
	}
	int N;
    cin >> N;
	for(int i=0;i<N;i++){
		int b;
		cin >> b;
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(A[i][j] == b){
					A[i][j] = -1;
				}
			}
		}
	}
	bool ok = false;
	// diagonal
	if(A[0][0] == -1 && A[1][1]==-1 && A[2][2]==-1){
		ok = true;
	}
	if(A[2][0]==-1 && A[1][1]==-1 && A[2][0]==-1){
		ok = true;
	}
	for(int i=0;i<3;i++){
		if (ok){
			break;
		}
		// column
		bool l = true;
		for(int j=0;j<3;j++){
			if(A[i][j] != -1){
				l = false;
			}
		}
		if (l){
			ok = true;
		}
		l = true;
		// row
		for(int j=0;j<3;j++){
			if(A[j][i] != -1){
				l = false;
			}
		}
		if (l){
			ok = true;
		}
	}
	if(ok){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    lint n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    // a=0としたい
    b = b - a;
    // i:プラスの数
    for (lint p = 0; p < n - 1; p++) {
        lint q = n - 1 - p;
        lint M = d * p - c * q, m = c * p - d * q;
        if (b >= m && b <= M) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

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

#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<long long,long long>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define eb emplace_back

const int MOD1=1000000007;
const int MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const int dx[]={0,1,0,-1,1,-1,1,-1};
const int dy[]={1,0,-1,0,1,1,-1,-1};

#define unless(a) if(!(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(n);i++)
#define bitrep(i,s,n) for(int i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}
long long cutup(long long a,long long b){return (a+b-1)/b;}
long long popcnt(long long a){return __builtin_popcountll(a);}
template<class T,class U> inline bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template<class T,class U> inline bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}

struct edge{long long to,cost;};
struct edge2{long long from,to,cost;};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vl A(n),B(n);
    rep(i,n)cin>>A[i];
    rep(i,n)cin>>B[i];
    vl D(n);
    rep(i,n)D[i]=A[i]-B[i];
    ll d=accumulate(all(D),0LL);
    if(d<0){
        cout<<-1<<endl;
        return 0;
    }
    sort(all(D));
    int ind=n-1;
    ll res=0;
    rep(i,n){
        if(D[i]>=0)break;
        if(!i)res++;
        while(D[i]<0){
            res++;
            if(D[i]+D[ind]<0){
                D[i]+=D[ind];
                D[ind]=0;
                ind--;
            }else{
                D[ind]+=D[i];
                D[i]=0;
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 5584
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            while(true) {
                int num = scn.nextInt();
                char[][] abacus = new char[8][5];
                for(int i = 0; i < abacus.length; i++) {
                    Arrays.fill(abacus[i], i != 2 ? '*' : '=');
                }
                for(int i = 0; i < 5; i++) {
                    int now = num / (int)Math.pow(10, 4 - i) % 10;
                    abacus[now > 4 ? 0 : 1][i] = ' ';
                    abacus[now % 5 + 3][i] = ' ';
                }
                for(char[] ary : abacus) {
                    System.out.println(ary);
                }
                if(scn.hasNextInt()) {
                    System.out.println();
                } else {
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 33432
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
bool comp(pair<int,int>a,pair<int,int>b)
{
    if(a.first<b.first)
        return true;
    else
        return false;
}
int main()
{
int n,k,s;
cin>>n>>k>>s;
vector<int>v;
 if(k!=0)
 {
   while(k--)
        v.push_back(s);
   while(v.size()!=n)
   {
       int x ;
       if(s!=1)
        x=s-1;
       else
        x=s+1;
       v.push_back(x);
   }
for(int i=0;i<v.size();i++)
    cout<<v[i]<<" ";

 }
 else
 {
     int x;
        if(s==1)
           x=2;
        else
            x = s-1;
     for(int i=0;i<n;i++)
        cout<<x<<" ";
 }


}



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

int main() {
    int N;
    string S, T;
    cin >> N >> S >> T;

    rep(i, N)
        cout << S[i] << T[i];
    cout << endl;
}


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

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

int main() {
  int n;
  cin >> n;
  set<int> a;
  rep(i,n){
    int tmp;
    cin >> tmp;
    auto itr = a.find(tmp);
    if(itr != a.end()){
      a.erase(tmp);
    }
    else{
      a.insert(tmp);
    }
  }
  cout << a.size() << endl;

  return 0;
}


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  long N, M;
  cin >> N >> M;
  cout << abs((N - 2) * (M - 2)) << endl;
}

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

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
#define rep(i,n) for(ll i = 0;i<(ll)n;i++)
using namespace std;
typedef long long ll;
static const int MAX = 50;
static const long long INFTYL = 9223372036854775807;
static const int INFTY = 2147483647;
ll mod = 1000000007;

int main()
{
	int N;
	cin >> N;
	int C[500];
	int S[500];
	int F[500];
	rep(i, N - 1) cin >> C[i] >> S[i] >> F[i];

	for (int i = 0; i < N - 1; i++) {
		ll c = 0;
		for (int j = i; j < N - 1; j++) {
			if (c <= S[j]) {
				c += S[j] - c;
			}
			else {
				ll p = c / F[j];
				ll q = c % F[j];
				if (q == 0) {
					p = 0;
				}
				else if (q != 0) {
					c += (p + 1)* F[j] - c;
				}
			}

			c += C[j];
		}
		cout << c << endl;
	}
	cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define mii map<int,int>


using namespace std;

int main(){
    int h,a;
    cin>>h>>a;

    cout<<ceil(h/(float)a)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(){
  long a,b,c;
  long double x;
  scanf("%ld %ld %ld",&a,&b,&c);
  x=a+b+2*sqrtl(a*b);
  if(x<c)printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long

int n;
vector<int> v;

void dfs(int a) {
    if(a > n) return;
    v.push_back(a);
    int b[] = {3, 5, 7};
    for(int i = 0; i < 3; i++) {
        dfs(a * 10 + b[i]);
    }
}

signed main() {
    cin >> n;

    dfs(3); dfs(5); dfs(7);

    int ans = 0;
    for(int i = 0; i < v.size(); i++) {
        string s = to_string(v[i]);
        if(s.find('3') != -1 && s.find('5') != -1 && s.find('7') != -1) {
            ans++;
        }
    }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

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

    ll weight[101] = {0};
    ll value[101] = {0};
    ll vmax[101][100001] = {0};

    rep(i, N) {
        int wi, vi;
        cin >> wi >> vi;
        weight[i] = wi;
        value[i] = vi;
    }

    rep(j, W + 1) {
        if(j < weight[N-1]) {
            vmax[N-1][j] = 0;
        } else {
            vmax[N-1][j] = value[N-1];
        }
    }

    for (int i = N-2; i >= 0; i--) {
        for (int j = 0; j <= W; j ++) {
            if (j < weight[i]) {
                vmax[i][j] = vmax[i + 1][j];
            } else {
                vmax[i][j] = max(
                    vmax[i+1][j], 
                    value[i] + vmax[i+1][j - weight[i]]
                );
            }
        }
    }

    // rep(i, N) {
    //     rep(j, W + 1) {
    //         DEBUG(i);
    //         DEBUG(j);
    //         DEBUG(vmax[i][j]);
    //     }
    // }

    cout << vmax[0][W] << endl;
}


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

int main() {
  cout<<setprecision(10)<<endl;
  static const double pi = 3.141592653589793;
  double a,b,h,m,ax,ay,bx,by;
  cin>>a>>b>>h>>m;
  ax=a*cos(h*pi/6+(pi/6)*(m/60));
  ay=a*sin(h*pi/6+(pi/6)*(m/60));

  bx=b*cos(m*pi/30);
  by=b*sin(m*pi/30);

  double ans;
  
  ans=(ax-bx)*(ax-bx)+(ay-by)*(ay-by);
  ans = sqrt(ans);
  cout<<ans<<endl;
}

Measured memory_bytes: 4164
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int n, d;
	cin >> n >> d;
	vector<vector<int>> x(n, vector<int>(d));
	for(int i=0;i<n;i++)
		for (int j = 0; j < d; j++)
		{
			cin >> x[i][j];
		}

	int cnt = 0;

	int dist=0;
	double ddist=0;

	for (int i = 0; i < n-1; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			dist = 0;
			ddist = 0;
			for (int k = 0; k < d; k++)
			{
				dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
				ddist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			dist = sqrt(dist);
			ddist = sqrt(ddist);

			if (ddist == dist)
			{
				cnt++;
			}
		}
	}

	cout << cnt << endl;

}

Measured memory_bytes: 256