akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/dynamic_bitset.hpp>
using namespace std;
using u32 = uint32_t;
using s32 = int32_t;

int main() {
	u32 N, K, C;
	cin >> N >> K >> C;
	
	boost::dynamic_bitset<> days(N);
	
	for(u32 i=0; i<N; i++) {
		char c;
		cin >> c;
		days[i] = (c == 'o');
	}
	
	vector<u32> R(K, N+1);
	for(s32 i=N-1, r=K-1; i>=0 && r>=0;) {
		if(days[i]) {
			R[r] = i;
			i -= C + 1;
			r--;
		} else {
			i--;
		}
	}
	
	for(u32 i=0, l=0; i<N && l<K;) {
		if(days[i]) {
			if(R[l] == i) cout << i + 1 << endl;
			i += C + 1;
			l++;
		} else {
			i++;
		}
	}
	return 0;
}

Measured memory_bytes: 2304
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll N, A;
    cin >> N >> A;

    if(N % 500 <= A){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    long long n;
    cin >> n;
    vector<ll> nums(n);
    ll x;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        nums[i] = x - (i + 1);
    }
    priority_queue<ll> que;
    for (auto i : nums) {
        que.push(i);
    }
    for (int i = 0; i < n / 2; ++i) {
        que.pop();
    }
    ll b = que.top();
    long long sad = 0;
    for (int i = 0; i < n; ++i) {
        sad += abs(nums[i] - b);
    }
    cout << sad << endl;
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

Measured memory_bytes: 3956
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	string str;
	long long H,W;
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> str;
		cout << str << endl;
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#######################################
p = 2019

l,r = map(int, input().split())
n = r-l+1

if n<2*p:
  tmps = [(i*j)%p for i in range(l,r) for j in range(i+1,r+1)]
  mini = min(tmps)

else:
  #lis = list(range(l,r+1))[:p+1]
  #lis = list(set([li%p for li in lis]))
  #tmps = [(i*j)%p for i in lis for j in lis]
  #mini = min(tmps)
  mini = 0

print(mini)


Measured memory_bytes: 75392
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    int a,b;
    cin>>a>>b;
	if(a<=5)cout<<"0"<<endl;
	else if(a>=13)cout<<b<<endl;
	else cout<<b/2<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;


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

    int n;
    cin >> n;
    map<long long, long long> mp;
    for(int i = 0; i < n; i++){
        long long d;
        cin >> d;
        if((i == 0 && d > 0) || (i != 0 && d == 0)){
            cout << 0 << endl;
            return 0;
        }
        if(mp.count(d)) mp[d]++;
        else mp[d] = 1;
    }

    bool f = true;
    bool fst = true;
    long long befKey = 0, befValue = 0, ans = 1;
    for(auto x : mp){
        if(x.first == 0) continue;
        if(befKey + 1 != x.first){
            f = false;
            break;
        }

        if(fst){
            befKey = x.first;
            befValue = x.second;
            fst = false;
            continue;
        }

        for(int i = 0; i < x.second; i++){
            ans = (ans * befValue) % MOD;
        }

        befKey = x.first;
        befValue = x.second;
    }

    if(f){
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

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

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  string a, b, c;
  cin >> a >> b >> c;
  if(a.back() == b.front() and b.back() == c.front())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	int as,kl,o,n,m,hun,p;
	String op;
	Scanner sc = new Scanner(System.in);
	public void solve() {	
n=sc.nextInt();
 if(n>=1800) {
	System.out.println("1");
}else if(n>=1600) {
	System.out.println("2");
}else if(n>=1400) {
	System.out.println("3");
}else if(n>=1200) {
	System.out.println("4");
}else if(n>=1000) {
	System.out.println("5");
}else if(n>=800) {
	System.out.println("6");
}else if(n>=600) {
	System.out.println("7");
}else {
	System.out.println("8");
}
	}
	public static void main(String[] args) {
		new Main().solve();
	
	}
}

Measured memory_bytes: 35656
apt = Array.new( 4 ){ Array.new( 3 ){ Array.new( 10, 0 ) } }

gets
while ( info = gets )
  b, f, r, v = info.split.map(&:to_i)
  apt[ b-1 ][ f-1 ][ r-1 ] += v
end
apt.each.with_index(0) do | bldg, i |
  puts "#"*20 if i > 0
  bldg.each do | floor |
    puts " "+floor.join( " " )
  end
end

Measured memory_bytes: 8820
#include <iostream>
using namespace std;
int isprime(int n)
{
  int factor=0;
  for(int i=2;i*i<=n;i++)
  {
    if(n%i==0)
      factor++;
  }
  if(factor>0)
    return 0;
  else
    return 1;
}
int main()
{
  long long n;
  cin>>n;
  while(isprime(n)!=1)
  {
    n++;
  }
  cout<<n;
}

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

void solve_A(){
	int a,b;
	cin >> a >> b;
	if(a>=10||b>=10) cout << "-1" << endl;
	else cout << a*b << endl;
}

void solve_B(){
	bool s[105]={0};
	int n,i,j;
	cin >> n;
	for(i=1;i<=9;i++){
		for(j=1;j<=9;j++){
			s[i*j]=true;
		}
	}
	if(s[n]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void solve_C(){
	long long n,i,m=0;
	cin >> n;
	for(i=1;i*i<=n;i++){
		if(n%i==0) m=i;
	}
	cout << m+n/m-2 << endl;
}

void solve_D(){
	double a,b,x,ans;
	cin >> a >> b >> x;
	x /= a;
	if(x>=a*b/2){
		x -= a*b/2.0;
		x = 2.0*x/a;
		x = b-x;
		ans =atan(x/a);
	} else {
		x = 2.0*x/b;
		ans = atan(b/x);
	}
	ans = ans*180.0/3.1415926535897;
	printf("%.13lf\n",ans);
}


int main() {
	// your code goes here
	//solve_A();
	//solve_B();
	solve_C();
	//solve_D();
	return 0;
}

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define repe(a, b) for (auto&(a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define mp(a, b) make_pair((a), (b))
#define Push_back(a, b) push_back( mp( (a), (b) ) )

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;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

const int inf = 0x3fffffff;
const int64_t INF = 0x3fffffffffffffff;
const int64_t MOD = 1e9+7;

void bfs ( Graph G ) {
    std::vector<int64_t> seen(G.size(), 0);
    int64_t ans = 0;
    rep(i, G.size()) {
        if ( G[i].size() == 0 ) {
            ans++;
            continue;
        }
        if ( seen[i] == 1 ) continue;
        ans++;
        queue<int64_t> q;
        // int64_t start_num = 0;
        q.push(i);
        while ( !q.empty() ) {
            int64_t num = q.front();
            seen[num] = 1;
            q.pop();
            rep(i, G[num].size()) {
                int64_t see = G[num].at(i);
                if ( seen[see] == 0 ) {
                    q.push(see);
                    seen[see] = 1;
                }
            }
        }
    }

    cout << ans-1 << endl;
    return;
}

int main() {
    int64_t n, m;
    cin >> n >> m;
    std::vector<int64_t> a(m), b(m);
    Graph G(n);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    bfs(G);
    return 0;
}


Measured memory_bytes: 16732
#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 pll pair<ll,ll>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1e9+7;
 
using namespace std;

int main(){
	int q=1;
	//cin>>q;
	while(q--){
		ll x;
		cin>>x;
		ll ans=100,c=0;
		while(x>ans){
			ans=ans*1.01;
			c++;
		}
		cout<<c<<endl;
	}   	
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 1000000007;

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

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}


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

  int n;
  cin >> n;
  
  vll sum(n+1);
  for(int i = 1;i <= n;i++)sum[i] = sum[i-1] + i;

  ll ret = 0;
  for(int i = 1;i <= n;i++){
    ret += sum[n/i] * i;
  }

  cout << ret << endl;
}

Measured memory_bytes: 81340
from collections import defaultdict
from sys import setrecursionlimit, getrecursionlimit

setrecursionlimit(100*getrecursionlimit())

N = int(input())
g = defaultdict(list)
K = []
for i in range(N-1):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)
    K.append((a,b))

C = sorted([int(i) for i in input().split()], reverse=True)

a = {i:0 for i in range(1, N+1)}

visited = defaultdict(bool)
ct = 0
def dfs(v):
    global ct
    visited[v] = True
    a[v] = C[ct]
    ct += 1
    for c in g[v]:
        if not visited[c]:
            dfs(c)

dfs(1)

ans1 = 0
ans2 = ' '.join([str(b) for b in a.values()])
for b, c in K:
    ans1 += min(a[b], a[c])

print(ans1)
print(ans2)

Measured memory_bytes: 16084
#include<stdio.h>

int main()
{
  int n;
  scanf("%d", &n);
  int arr[n][n];
    for(int i = 0; i < n; i++)
    {
      for(int j = 0; j < n; j++)
	{
	  arr[i][j] = 0;
	}
    }
  int t1, t2;
  int m;

  for(int i = 0; i < n; i++)
    {
      scanf("%d", &t1);
      scanf("%d", &t2);
      for(int j = 0; j < t2; j++)
	{
	  scanf("%d", &m);
	  arr[t1-1][m-1] = 1;
	}
    }

  for(int i = 0; i < n; i++)
    {
      for(int j = 0; j < n; j++)
	{
	  if(j == n-1)
	    {
	      printf("%d", arr[i][j]);
	      break;
	    }
	  printf("%d ", arr[i][j]);
	}
      printf("\n");
    }
}



Measured memory_bytes: 2120
n,m = gets.split.map(&:to_i)
a = readlines.map(&:to_i)
dp = Array.new(n+1)
dp[0] = 1
MOD = 10**9 + 7
if a[0] == 1
  dp[1] = 0
  a.shift
else
  dp[1] = 1
end
for i in 2..n
  if a[0] == i
    dp[i] = 0
      a.shift
  else
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] = dp[i].modulo(MOD)
  end
end
puts dp[n]

Measured memory_bytes: 9084
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
 
int main(){
    int a,b;cin>>a>>b;
    if((a+b)%2==1){
        cout<<"IMPOSSIBLE"<<endl;
    }
    else{
        cout<<(a+b)/2<<endl;
    }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;
constexpr int mod = 1e9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> s, t;
  rep(i,n) {
    cin >> a[i];
    if (a[i] < 0) t.push_back(a[i]);
    else s.push_back(a[i]);
  }

  int S = s.size();
  int T = t.size();

  bool ok = false;

  if (S > 0) {
    if (n == k) ok = (T % 2 == 0);
    else ok = true;
  } else {
    ok = (k % 2 == 0);
  }

  mint res = 1;

  if (!ok) {
    sort(a.begin(), a.end(), [](int x, int y) {
      return abs(x) < abs(y);
    });
    rep(i,k) res *= a[i];
  } else {
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if (k % 2 == 1) {
      res *= s.back();
      s.pop_back();
    }
    vector<ll> p;
    while (s.size() >= 2) {
      ll x = s.back(); s.pop_back();
      x *= s.back(); s.pop_back();
      p.emplace_back(x);
    }
    while (t.size() >= 2) {
      ll x = t.back(); t.pop_back();
      x *= t.back(); t.pop_back();
      p.emplace_back(x);
    }
    sort(p.rbegin(), p.rend());
    rep(i,k/2) res *= p[i];
  }

  cout << res.x << endl;
  return 0;
} 

Measured memory_bytes: 6332
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

if (A+B)%2 == 0:
	print((A+B)//2)
else:
	print("IMPOSSIBLE")


Measured memory_bytes: 5716
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	 const int N =1e5+5;
    
     int mod= 1e9+7,INF=1e17;
     
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
 
     
     void solve(){
       int n;
       cin>>n;
       
       vi v(n);
       
       rep(i,0,n)
         cin>>v[i];    
       
       multiset<int> mt;
       
       rep(i,0,sz(v)){
		   auto it=mt.lb(v[i]);
		   
		   if(it==mt.begin())
		     mt.insert(v[i]);
		   
		   else{
			   it--;
			   mt.erase(it);
			   mt.insert(v[i]); 
		   }	   
	   }
	   
	   cout<<sz(mt)<<endl;  
               
	 }
	
      int32_t main() {
	    cool;
	    int t=1;
        //cin>>t;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


Measured memory_bytes: 5760
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    int a, b ,x;
    cin >> a >> b >> x;
    if(x <= a + b && x >= a){
        cout << "YES";
    }else{
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t / 2;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}



int main() {
	int x,y;
 	cin >> x >> y;
    vector<int> v; 
 	v = {0,1,3,1,2,1,2,1,1,2,1,2,1};
 	if(v[x]==v[y]){
     cout << "Yes" << endl;
    }
 	else{
     cout << "No" <<  endl;
    }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int W,a,b; cin >> W >> a >> b;

    if ((a+W >= b && a+W <= b+W) || (b+W >= a && b+W <= a+W)) {
        cout << "0\n"; exit(0);
    }

    cout << min(abs((a+W)-b), abs((b+W)-a)) << "\n";

}


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

int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  long t = 0;
  int m = 0;
  int x = 1000000000;
  int w;
  for (int i = 0; i < n; i++) {
    w = v[i];
    if (w < 0) {
      w = -w;
      m++;
    }
    t += w;
    x = min(x, w);
  }
  if (m & 0x01) {
    t -= x * 2;
  }
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 640
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func setWatchman(n, d int) int {
	watchLength := d*2 + 1
	return int(math.Ceil(float64(n) / float64(watchLength)))
}

func main() {
	n, d := nextInt(), nextInt()
	fmt.Println(setWatchman(n, d))
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**6)


def main(input, print):
    n = int(input())
    x = list(map(int, input().split()))
    ans = 1
    if 0 in x:
        print('0')
        return
    for i in range(len(x)):
        ans *= x[i]
        if ans > 10**18:
            print('-1')
            return
    print(ans)


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 83304
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

ans = 0
counter = Counter(A)
keys = sorted(counter.keys(), reverse=True)
flag = False
for k in keys:
    if ans == 0 and counter[k] >= 4:
        ans = k*k
        flag = True
        break
    elif ans == 0 and counter[k] >= 2:
        ans = k
    elif ans != k and counter[k] >= 2:
        ans = ans * k
        flag = True
        break
if flag:
    print(ans)
else:
    print(0)

Measured memory_bytes: 105508
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] w = new int[4];
        for(int i=0;i<4;i++){
            w[i] = sc.nextInt();
        }
        String ans;
        if(w[0]+w[1]>w[2]+w[3]) ans = "Left";
        else if(w[0]+w[1]==w[2]+w[3]) ans = "Balanced";
        else ans = "Right";
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<String, Integer> word = new HashMap<>();
		for(int i = 0; i < n; i++) {
			String s = sc.next();
			if(word.containsKey(s)) {
				int val = word.get(s);
				val++;
				word.put(s, val);
			} else {
				word.put(s, 1);
			}
		}
		int m = sc.nextInt();
		for(int i = 0; i < m; i++) {
			String s = sc.next();
			if(word.containsKey(s)) {
				int val = word.get(s);
				val--;
				if(val == 0) {
					word.remove(s);
				} else {
					word.put(s, val);
				}
			}
		}
		int max = 0;
		for(Map.Entry<String, Integer> e : word.entrySet()) {
			max = Math.max(max, e.getValue());
		}
		System.out.println(max);

	}

}


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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int X = N/2;
    int cnt = 0;
    for(int i = 0; i < X; i++) {
        if(S[i] == S[X+i]) {
            cnt++;
        }
    }
    if(N%2 == 1) {
        cout << "No" << endl;
    }
    else if(cnt == X) {
    	cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
 
 
int main () {
    int N, A, B;

    cin >>  N >> A >> B;

    if(A*N< B)cout << A*N <<endl;
    else cout << B << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main()
    {
    	int n;
     	cin>>n;
        char s1[n] ,s2[n];
      	for(int i = 0; i < n; i++)
        {
    		cin>>s1[i];
        }
      	for(int i = 0; i < n; i++)
        {
            cin>>s2[i];
        }
        for(int i = 0; i < n; i++)
        {
            cout<<s1[i]<<s2[i];
        }
      	cout<<endl;
        return 0;
    }


Measured memory_bytes: 256
x = 1000000007

n = int(input())

ans10 = 1
ans9 = 1
ans8 = 1
for i in range(n):
    ans10 *= 10
    ans10 %= x

    ans9 *= 9
    ans9 %= x

    ans8 *= 8
    ans8 %= x

ans=(ans10 - 2*ans9 + ans8) % x

print(ans)

Measured memory_bytes: 63516
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;


signed main(){
	int N;
	cin >> N;
	string s;
	cin >> s;
	vector<int>a(N);
	REP(i,N){
		a[i] = s[i] - '0';
	}
	vector<int>b(N - 1);
	int flg = 0;
	REP(i,N - 1){
		b[i] = abs(a[i] - a[i + 1]);
		if(b[i] == 1)flg = 1;
	}
	REP(i,N)if(flg && b[i] == 2)b[i] = 0;
	int sum = 0;
	REP(i,N - 1){
		if(b[i] == 0)continue;
		sum += (N - 2) == ((N - 2) | (N - 2 - i));
		sum %= 2;
	}
	if(flg == 0 && sum)out(2);
	else if(flg && sum)out(1);
	else out(0);
}

Measured memory_bytes: 17028
// AtCoder Beginner Contest 150
// Problem B - Count ABC

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

int main(){
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   ll N;
   string s = " ";
   cin >> N >> s;
   ll ans = 0;
   for(int i = 0; i <= N-3; ++i){
      if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
         ++ans;
      }
   }
   cout << ans << '\n';
   return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

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


int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  if (A - B < C) cout << (C - (A - B)) << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
from fractions import gcd
def lcm(a,b):
    return a*b//gcd(a,b)
n,m=map(int,input().split())
a=list(map(int,input().split()))
h=list(map(lambda x:x//2,a))
l=1
for i in range(n):
    l=lcm(l,h[i])
for i in range(n):
    if (l//h[i])%2==0:
        print(0)
        exit()
print((m//l+1)//2)

Measured memory_bytes: 89696
#include <iostream>                                                             
                                                                                
using namespace std;                                                            
                                                                                
int main (void) {                                                               
  int a, b;                                                                     
  char op;                                                                      
  while (true) {                                                                
    cin >> a >> op >> b;                                                        
    if (op=='?') {                                                              
      break;                                                                    
    }                                                                           
    int ans;                                                                    
    switch (op) {                                                               
    case '+':                                                                   
      ans = a+b;                                                                
      break;                                                                    
    case '-':                                                                   
      ans = a-b;                                                                
      break;                                                                    
    case '*':                                                                   
      ans = a*b;                                                                
      break;                                                                    
    case '/':                                                                   
      ans = a/b;                                                                
      break;                                                                    
    default:                                                                    
      break;                                                                    
    }                                                                           
    cout << ans << endl;                                                        
  }                                                                             
}                                    

Measured memory_bytes: 3096
package main

import (
	"fmt"
	"sort"
)

func main() {
	a := make([]int, 3)
	fmt.Scan(&a[0], &a[1], &a[2])

	sort.Ints(a)
	fmt.Println(a[2] - a[1] + a[1] - a[0])
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
struct T{ //v, w, t, d, s(priority)
    ll v, w, d; 
    char t;
    string s;
};
bool asc(const T& l, const T& r){
    if(l.v == r.v){
        if(l.w == r.w){
            if(l.t == r.t){
                if(l.d == r.d)return l.s < r.s;
                else return l.d < r.d;
            }
            else return l.t < r.t;
        }
        else return l.w < r.w;
    }
    else return l.v < r.v;
}
int main(){
    int n; cin >> n;
    vector<T> p(n);
    rep(i,n){
        ll v, w, d;
        char t;
        string s;
        cin >> v >> w >> t >> d >> s;
        p[i].v = v;
        p[i].w = w;
        p[i].t = t;
        p[i].d = d;
        p[i].s = s;
    }
    sort(all(p), asc);
    rep(i,n){
        printf("%lld %lld %c %lld ", p[i].v, p[i].w, p[i].t, p[i].d);
        cout << p[i].s << endl;
    }
    return 0;
}


Measured memory_bytes: 12928
import sys
input = sys.stdin.buffer.readline
import numpy as np
N = int(input())
A = np.array([int(input()) for _ in range(N)] + [0], dtype=np.int64)
# print(A)
ans = (A[:-1][A[:-1] >= A[1:]]).sum()
if any(A[:-1] + 1 < A[1:]):
    ans = -1
elif A[0] != 0:
    ans = -1

print(ans)


Measured memory_bytes: 23804
from collections import defaultdict
dic = defaultdict(int)

N = int(input())
for _ in range(N):
    S = input()
    A = []
    for s in S:
        A.append(s)
    A.sort()
    word = ""
    for a in A:
        word += a
    dic[word] += 1

ans = 0
for v in dic.values():
    if v >= 2:
        ans += v * (v - 1) // 2
print(ans)

Measured memory_bytes: 18148
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	switch s {
	case "SUN":
		fmt.Println(7)
	case "MON":
		fmt.Println(6)
	case "TUE":
		fmt.Println(5)
	case "WED":
		fmt.Println(4)
	case "THU":
		fmt.Println(3)
	case "FRI":
		fmt.Println(2)
	case "SAT":
		fmt.Println(1)
	}
}


Measured memory_bytes: 512
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		long[] A = new long[N];
		for(int i=0; i<N; i++)
			A[i] = sc.nextInt()-i;
		
		Arrays.sort(A);
		long ans = 0;
		for(int i=0; i<N; i++)
			ans += Math.abs(A[i]-A[N/2]);
		
		System.out.println(ans);
		sc.close();
	}
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}


int main(void){
	int32 N;
	cin >> N;
	set<string> st;
	string bef = "";
	REP(i, N){
		string s;
		cin >> s;
		if(bef.size() == 0 || bef.back() == s[0]){
			if(st.find(s) == st.end()){
				bef = s;
				st.insert(s);
			}else{
				cout << "No" << endl;
				return 0;
			}
		}else{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <map>
#include <string>
#include <math.h>
using namespace std;


int main() {

    //10^18 around((2^63)-1) 64bit整数値
    long long int H,ans=0;
    cin >> H;
    long long int i=1;
    while(H>0){
        H/=2;
        ans += i;
        i*=2;
    }

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


Measured memory_bytes: 256
from collections import Counter
N = int(input())
S = input()
D = Counter(S)
ans = 1
for d in D.values():
    ans *= d

if len(D.values()) < 3:
    ans = 0

for i in range(N):
    for x in range(1, (N-i+1)//2):
        if S[i] != S[i+x] and S[i+x] != S[i+2*x] and S[i+2*x] != S[i]:
            ans -= 1
print(ans)

Measured memory_bytes: 9444
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


S = input()

if S[0] == '>':
    S = '<' + S
    # print(S)

if S[-1] == '<':
    # print('this?')
    S = S + '>'


# 連長圧縮する
s_pre = '<'
sum_s_tmp = 0
rencho = []  # 偶数番に<の個数、奇数番に>の個数が入る
for s in S:
    if s_pre == s:
        sum_s_tmp += 1
    else:
        rencho.append(sum_s_tmp)
        sum_s_tmp = 1
        s_pre = s
rencho.append(sum_s_tmp)

# print(rencho)
ans = 0
for a_big, a_small in zip(rencho[0::2], rencho[1::2]):
    if a_big < a_small:
        a_big, a_small = a_small, a_big
    ans += sum(range(a_big + 1))
    ans += sum(range(a_small))


print(ans)

# A_sum = 0
# A_min = 0
# a_now = 0
# for s in S:
#     if s == '<':
#         a_now += 1
#         A_sum += a_now
#     if s == '>':
#         a_now -= 1
#         A_sum += a_now
#         A_min = min(a_now, A_min)

# print(A_sum - A_min * len(S))


Measured memory_bytes: 8240
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001

int main(void) {
	int a,b,t; cin >> a >> b >> t;
	cout << (t/a)*b << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define endl '\n'
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    string a,b;
    cin>>a>>b;
    ll n=a.size(),m=b.size();
    ll dp[n+1][m+1];
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=m;j++){
            if(i==0 || j==0)dp[i][j]=0;
            else{
                if(a[i-1]==b[j-1])dp[i][j]=dp[i-1][j-1]+1;
                else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
   // cout<<dp[n][m]<<endl;
    string ans="";
    ll i=n,j=m;
    while(i>0 && j>0){
        if(a[i-1]==b[j-1]){
            ans+=a[i-1];
            i--,j--;
        }
        else{
                if(dp[i][j-1]>dp[i-1][j]){
                        j--;
                }
                else {
                    i--;
                }
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl




signed main(){
    int s;
    cin >> s;
    bool D[1114514]={};
    D[s]=1;
    int i=1;
    while(1){
        i++;
        if(s%2==0){
            s=s/2;
        }else{
            s=3*s+1;
        }
        if(D[s]==1){
            cout << i << endl;
            return 0;
        }else{
            D[s]=1;
        }
        
    }
    return 0;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;

int n,p,mx=0,sum=0;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>p;
		if(p>mx)
			mx=p;
		sum+=p;
	}
	sum-=mx;
	sum+=(mx/2);
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
sp = input()
t = input()

ls = len(sp)
lt = len(t)
ok = 1
s = list(sp)
for i in range(ls-1, -1, -1):
    ok = 1
    for j in range(lt):
        if i + j >= ls:
            ok = 0
            break
        if (sp[i+j] == t[j]) or (sp[i+j] == '?'):
            continue
        ok = 0
        break
    if ok == 1:
        for si in range(i, i+lt):
            s[si] = t[si - i]
        break

if ok == 1:
    print(''.join(s).replace("?", "a"))
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf LLONG_MAX
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define f first
#define s second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);


	ll n,k;
	cin>>n>>k;
	ll h[n+1];
	for(ll i=1;i<=n;i++)
		cin>>h[i];
	ll dp[n+1];
	memset(dp,0,sizeof dp);
	for(ll i=2;i<=n;i++)
	{
		dp[i]=inf;
		dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
		for(ll j=2;j<=k;j++)
		{
			if(i-j<=0)
				break;
			dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
		}
	}
	cout<<dp[n]<<'\n';
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(){
    int n;
    long long s = 0;
    scanf("%d", &n);
    for(int i = 1;i<=n;i++){
        if(i%3!=0 and i%5!=0){
            s+=i;
        }
    }
    printf("%lld\n", s);
}

Measured memory_bytes: 1712
#include <iostream>
using namespace std;
int main(void){
    int N;
    int a[100000];
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> a[i] ;
    }
    int current_botan = 1;
    int ans = 0;
    for (int i=0 ;i<N ;i++){
        if(current_botan == 2){
            cout << ans << endl;
            return 0;
        }
        current_botan = a[current_botan];
        ans++;
    }

    cout << -1 << endl;
}

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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s;
    cin >> s;
    
    if(s == "SUN"){
        cout << 7 << endl;
    } else if(s == "MON"){
        cout << 6 << endl;
    } else if(s == "TUE"){
        cout << 5 << endl;
    } else if(s == "WED"){
        cout << 4 << endl;
    } else if(s == "THU"){
        cout << 3 << endl;
    } else if(s == "FRI"){
        cout << 2 << endl;
    } else if(s == "SAT"){
        cout << 1 << endl;
    }
    
    
    
}


Measured memory_bytes: 764
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			Integer p[] = new Integer[n];
			for (int i = 0; i < n; i++) {
				p[i] = sc.nextInt();
			}

			Arrays.sort(p);
			System.out.println(p[n / 2] - p[n / 2 - 1]);

		}

	}

}

Measured memory_bytes: 63044
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		String s=scanner.next();
		int mm=Integer.parseInt(s.substring(5, 7));
		System.out.println(mm<=4?"Heisei":"TBD");
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 22612
#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 <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#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 <codecvt>
#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>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
  ll n;cin>>n;
  vector<ll>G[n];
  rep(i,n-1){
    ll a,b;cin>>a>>b;a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<ll>c(n);
  rep(i,n)cin>>c[i]; 
  sort(all(c),greater<ll>());

  //use
  vector<ll>d(n,-1);
  set<ll>set1,set2;
  ll index=0;
  set1.insert(0);
  set2.insert(0);
  while(!set1.empty()){
    ll u=*set1.begin();
    set1.erase(u);
    d[u]=c[index];
    index++;
    // cout<<u<<" "<<index<<endl;
    for(auto&&j:G[u]){
      if(set2.find(j)!=set2.end())continue;
      set2.insert(j);
      set1.insert(j);
    }
  }
  ll ans=0;
  rep(i,n-1)ans+=c[i+1];
  cout<<ans<<endl;
  for(auto&&i:d)cout<<i<<" ";
  cout<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}


Measured memory_bytes: 3596