akhauriyash/Code-Regression huggingface dataset:
class Node:
    def __init__(self, p=-1, l=-1, r=-1):
        self._p = p
        self._l = l
        self._r = r

T = []
Depth = []
Height = []

def get_sibling(index):
    global T
    if T[index]._p == -1:
        return -1
    if T[T[index]._p]._l != index:
        return T[T[index]._p]._l
    if T[T[index]._p]._r != index:
        return T[T[index]._p]._r
    return -1

def print_node(index):
    global Depth
    global Height
    global T
    
    deg = 0
    if T[index]._l != -1:
        deg += 1
    if T[index]._r != -1:
        deg += 1
    
    print('node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, '%(index, T[index]._p, get_sibling(index), deg, Depth[index], Height[index]), end='')

    if T[index]._p == -1:
        print('root')
    elif T[index]._l == -1 and T[index]._r == -1:
        print('leaf')
    else:
        print('internal node')

if __name__ == '__main__':
    n = int(input())

    for i in range(n):
        T.append(Node(-1, -1, -1))
        Depth.append(-1)
        Height.append(-1)

    for i in range(n):
        index, l_child, r_child = map(int, input().split())
        T[index]._l = l_child
        T[index]._r = r_child
        if l_child != -1:
            T[l_child]._p = index
        if r_child != -1:
            T[r_child]._p = index

    root = -1
    for i in range(n):
        if T[i]._p == -1:
            root = i
            break

    def rec(node, dep):
        Depth[node] = dep

        lh = rh = 0
        if T[node]._l != -1:
            lh = rec(T[node]._l, dep + 1) + 1
        if T[node]._r != -1:
            rh = rec(T[node]._r, dep + 1) + 1

        Height[node] = max(lh, rh)
        return Height[node]

    rec(root, 0)

    for i in range(n):
        print_node(i)



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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    n = n%10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
    	cout << "hon\n";
    else if(n == 3)
    	cout << "bon\n";
    else
    	cout << "pon\n";
    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long 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 {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

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


int main() {
	ll N;
	cin >> N;
	ll tmp;
	for (int i = 1; i <= pow(N, 0.5); i++) {
		if (N % i == 0) {
			tmp = i;


		}


	}
	cout << tmp + N / tmp-2;
}

//int m[500][26] = {};
//void func(string& s, int N, int i, vector<string>a, int J) {
//	int j;
//		for (j = 0; j < J; j++) {
//			if (m[J - 1 - i][(int)a[i][j] - 97] == 1) {
//		s += a[i][j];
//				break;
//			}
//			if (j == J - 1) {
//				s = "-1";
//				i = N - 1;
//				break;
//			}
//		}
//		i++;
//	if (i == N) {
//		
//	}
//	else {
//		func(s, N, i, a, J);
//	}
//}
//
//int main() {
//	ll N;
//	cin >> N;
//	vector<string>a(N);
//	
//	rep(i, N) {
//		cin >> a[i];
//	}
//	if (N == 1) {
//		cout << a[0];
//		return 0;
//	}
//	rep(i, N) {
//		rep(j, N) {
//			m[i][(int)a[i][j] - 97]=1;
//		}
//	}
//	string ans;
//
//	func(ans, N/2,0,a,N);
//
//	if (ans == "-1") {
//		cout <<ans;
//		return 0;
//	}
//		cout << ans;
//		
//		if (N % 2 == 1) {
//			cout << a[N / 2 + 1][0];
//		}
//	rep(i, N / 2) {
//
//	cout << ans[N/2-i-1];
//	
//	}
//}
//
//
//


Measured memory_bytes: 3200
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  unordered_set<string> S;
  char last = ' ';
  REP(i, 0, N) {
    string s;
    cin >> s;
    if (S.find(s) != S.end()) {
      cout << "No" << endl;
      return 0;
    }
    S.emplace(s);
    if (i > 0) {
      if (s[0] != last) {
        cout << "No" << endl;
        return 0;
      }
    }
    last = s[s.size() - 1];
  }
  cout << "Yes" << endl;

  return 0;
}


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

int main() {
	int a,b,i,j;
	cin>>a>>b;
	char mat[100][100];
	cout<<100<<" "<<100;
	for(i=0;i<100;i++)
	  {
	  	  for(j=0;j<100;j++)
	  	    {
	  	    	if(i<50)
	  	    	   mat[i][j]='.';
	  	    	else
	  	    	  mat[i][j]='#';
	  	    }
	  }

	cout<<'\n';
	for(i=0;i<49;i+=2)
	  {
	  	  for(j=0;j<100;j+=2)
	  	    {
	  	    	if(--b && b>0)
	  	    	  {     
	  	    	  	 mat[i][j]='#';
	  	    	  }
	  	    }
	  }
	for(i=51;i<100;i+=2)
	  {
	  	 for(j=0;j<100;j+=2)
	  	   {
	  	   	  if(--a && a>0 ){
	  	   	    mat[i][j]='.';
	  	   	  }
	  	   }
	  }
	for(i=0;i<100;i++)
	  {
	  	  for(j=0;j<100;j++)
	  	    cout<<mat[i][j];
	  	  cout<<'\n';  
	  }
	 //cout<<a<<" "<<b<<'\n';  
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mkp make_pair
#define fi first
#define se second
const int MOD=998244353;
void read(int &x){
	int res=1;char ch=getchar();x=0;
	for (;ch==' '||ch=='\n';ch=getchar());
	if (ch=='-') res=-1,ch=getchar();
	for (;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());
	x*=res;
}
void write(ll x){
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
struct PQueue{
	priority_queue<int>q,del;
	void Upd(){while (!q.empty() && !del.empty() && del.top()==q.top())q.pop(),del.pop();}
	int top_(){Upd();return q.top();}
	void erase(int x){Upd();del.push(x);}
	void push_(int x){Upd();q.push(x);}
	bool empty(){Upd();return q.empty();}
}pq;
vector<int>g[200004],v[200004];
pii aq[200004];
int n,D[200004],a[200004];
ll dp[200004],ans=1;
bool vis[200004];
void dfs(int x){
	vis[x]=1;
	dp[x]=1;
	for (int i=0;i<g[x].size();i++){
		dfs(g[x][i]),dp[x]*=dp[g[x][i]],dp[x]%=MOD;
	}
	dp[x]++;
}
int main(){
	read(n);
	for (int i=1;i<=n;i++) read(aq[i].fi),read(aq[i].se);
	sort (aq+1,aq+1+n);
	for (int i=1;i<=n;i++) a[i]=aq[i].fi,D[i]=aq[i].se;
	for (int i=1;i<=n;i++){
		for (int j=0;j<v[i].size();j++) pq.erase(v[i][j]);
		if (!pq.empty())g[pq.top_()].push_back(i); 
		int got=upper_bound(a+1,a+1+n,a[i]+D[i]-1)-a;
		pq.push_(i); 
		v[got].push_back(i);
	}
	for (int i=1;i<=n;i++) if (!vis[i]) dfs(i),ans*=dp[i],ans%=MOD;
	write(ans);
}

Measured memory_bytes: 34928
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 28 13:44:44 2020

@author: NEC-PCuser
"""
N = int(input())
ans = 0
for i in range(1, N + 1):
    n = N // i
    ans += i * n * (n + 1) // 2 

print(ans)
    

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

using namespace std;

const int MAXN = 1E5;
int happy[MAXN][3];
int dp[MAXN][3];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> happy[i][0] >> happy[i][1] >> happy[i][2];
    dp[0][0] = happy[0][0];
    dp[0][1] = happy[0][1];
    dp[0][2] = happy[0][2];
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                if (j == k)
                    continue;
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + happy[i][j]);
            }
        }
    }
    cout << max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]) << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	ll n;
	cin>>n;
	deque<char>ans;
	while(n>0){
      	n--;
		ll k=n%26;
		char tmp='a'+k;
		ans.push_front(tmp);
		n/=26;
	}
	rep(i,size(ans)){
		cout<<ans[i];
	}
	cout<<endl;

}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+100;

ll a[N],n;
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    ll ans=1e18;
    for(int pos=1;pos<=100;pos++) {
        ll temp=0;
        for(int i=1;i<=n;i++) temp+=(a[i]-pos)*(a[i]-pos);
        ans=min(ans,temp);
    }cout<<ans;
}


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

using namespace std;

signed main(){
    int n; cin>>n;
    vector<long> a(n),ans(n,0);
    for(int i=0;i<n;i++)	cin>>a[i];
	for(long res=1,cnt=0;res<=10000000000;res*=2,cnt=0){
		for(int i=0;i<n;i++)	if( a[i]&1 )	cnt++;
		if( cnt&1 )	for(int i=0;i<n;i++) ans[i]+=res*( !(a[i]&1) ),a[i]/=2;
		else for(int i=0;i<n;i++)	ans[i]+=res*(a[i]&1),a[i]/=2;
	}
	for(int i=0;i<n;i++)	cout<<ans[i]<<" ";
}


Measured memory_bytes: 6328
#include<map>
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define MAXN 100001
#define X first
#define Y second
#define MOD 1000000007
#define fr(a,b,c) for(ll a=b;a<c;++a)
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

ll t,n,i,j;
int main()
{
    fastio;
   string s,t;
   cin>>s>>t;
   ll m=s.length();
   ll n=t.length();
   ll dp[3001][3001]={0};
   if(s[0]==t[0])
        dp[1][1]=1;
   fr(i,1,n+1){
        fr(j,1,m+1){
            if(s[j-1]==t[i-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
   }
   //cout<<dp[n][m]<<endl;
   string p;
   i=n;j=m;
   while(i>0 && j>0){
        if(s[j-1]==t[i-1]){
            p.append(1,s[j-1]);
            i--;j--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1])
                i--;
            else
                j--;
        }
   }
   i=p.length();
   for(j=i-1;j>-1;j--)
    cout<<p[j];
}


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

using namespace std;

int main() {
	long long int h;
	cin>>h;
	long long int ans = 0, cnt = 0;
	while(h) {
		cnt++;
		h = h/2;
	}
	long long int x = 1;
	for(int i = 0; i < cnt; i++) {
		ans += x;
		x *= 2;
	}
	cout<<ans<<endl;
}	


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

int main() {
    int X, Y;
    cin >> X >> Y;
    cout << X + Y / 2 << endl;
}

Measured memory_bytes: 256
N=int(input())
S=["" for j in range(N)]
for i in range(N):
    S[i]=input()

ans=0
for i in range(0,N):
    flag=True
    for j in range(0,N):
        for k in range(0,N):
            flag=flag&(S[(k+i)%N][j]==S[(j+i)%N][k])
    ans+=N*int(flag)

print(ans)


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<long long,long long>> V;
  for(int i = 0; i < N; ++i){
    int a;
    cin >> a;
    V.emplace_back(a,1);
  }
  for(int i = 0; i < M; ++i){
    int c, b;
    cin >> b >> c;
    V.emplace_back(c,b);
  }
  sort(V.rbegin(), V.rend());
  long long ans = 0, t = 0;
  for(auto p : V){
    ans += p.first*(min(N-t,p.second));
    t += p.second;
    if(t >= N) break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6512
//
//  main.cpp
//  ALDS60
// バブルソートの練習

#include <iostream>
#include <vector>

using namespace std;
int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++) {
        cin >> A.at(i);
    }
    int TMP;
    int count=0;
    for (int i=0; i<N-1; i++) {
        for (int j=N-1; j>0; j--) {
            int k=j-1;
            if (A.at(j)<A.at(k)) {
                    TMP=A.at(j);
                    A.at(j)=A.at(k);
                    A.at(k)=TMP;
                    count++;
                }
        }
    }

    for (int m=0; m<N-1; m++) {
        cout << A.at(m) << " ";
    }
    cout << A.at(N-1)<<endl;
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 3124
N, K = map(int, input().split())
A = input().split()
A = [int(a) for a in A]
S = [1]
a = 1
number = 0
numbers=[-1 for _ in range(N)]
for _ in range(N + 1):
    b = A[a - 1]
    if numbers[b-1] != -1:
      c=numbers[b-1]          #1回目にループが現れた回数-1
    #   print("ループの最初の数字",b,"最初は"+str(c+1)+"回目","周期は",number-c)
      break
    numbers[b-1]=number
    number += 1
    S.append(b)
    a = b
T = S[c+1:number+1]
if K <= number:
  print(S[K ])
else:
  z = K - c-1
  y = z % (number - c)
#   print(y)
  print(T[y])

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

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

	int p = 1, c = 0, yes = 0;

	for(int i=0; i<n; i++) {
		int a, b;

		cin >> a >> b;

		if(a == b && p == 1) {
			c++;
			if(c == 3) {
				yes = 1;
			}
		} else if(a == b) {
			p = 1;
			c++;
		} else {
			p = 0;
			c = 0;
		}
	}

	cout << (yes != 0 ? "Yes" : "No");

	return 0;
}

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

const ll MOD = 1e9+7;
long long modpow(long long a, long long n) {
      long long res = 1;
      while (n > 0) {
          if (n & 1) res = res * a % MOD;
          a = a * a % MOD;
          n >>= 1;
      }
      return res;
  }
int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    vector<string> b(n);
    vector<vector<ll>> c(n+1,vector<ll>(100,0));
    vector<ll> sum(n+1);
    sum[0 ] = 0;
    
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        std::stringstream ss;
        ss << static_cast<std::bitset<60> >(a[i]);
        string x_bin = ss.str();
        reverse(x_bin.begin(),x_bin.end());
        b[i] = x_bin;
        // std::cout << b[i] << std::endl;
        for (int j = 0; j < 60; j++) {
            c[i+1][j] = c[i][j];
            if(b[i][j]=='1'){
                c[i+1][j]++;
            }
        }
        sum[i+1] = sum[i]+a[i];
        sum[i+1] %=MOD;
    }
    ll mod = 1e9+7;
    ll res = 0;
    for (int i = 0; i < n-1; i++) {
        res += a[i]%mod*(n-i-1)%mod+(sum[n]-sum[i+1]+mod)%mod;
        res %= mod;
        for (int j = 0; j < 60; j++) {
            if(b[i][j]=='1'){
                res -= (modpow(2,j)%mod*(c[n][j]-c[i+1][j]+mod))%mod*2%mod;
                res += mod;
                res %= mod;
                // std::cout << b[i] << std::endl;
            }
        }
        // std::cout << res << std:endl;
    }
    std::cout << res << std::endl;
    
}


Measured memory_bytes: 281472
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

def f():
    req_a = 0
    req_b = 0
    for a,b in zip(A, B):
        if a > b:
            req_b += (a - b)
        else:
            if (b - a) & 1:
                req_a += (b - a) // 2 + 1
                req_b += 1
            else:
                req_a += (b - a) // 2
    return req_a >= req_b

print("Yes" if f() else "No")

Measured memory_bytes: 4600
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

#define POS(i,j) ((i)*v+(j))
#define POSDP(now,state) ((now)*(1<<v)+(state))

int calc(const int now,const int state,const int *d,int *dp,const int v){
  const int index=POSDP(now,state);
  if(dp[index]!=-1) return dp[index];//計算済み
  if(state==(1<<v)-1){//全ての頂点回った-> 0に向かう
    dp[index]=d[POS(now,0)]>=0?d[POS(now,0)]:-2;
    return dp[index];
  }
  int local=1<<30;
  int i;
  for(i=0;i<v;i++){
    if((state>>i)&0x01) continue;//すでに行った頂点
    if(d[POS(now,i)]==-1) continue;//辺無し
    int t=calc(i,state|(1<<i),d,dp,v);
    if(t>=0){
      local=MIN(local,d[POS(now,i)]+t);
    }
  }
  dp[index]=(local==(1<<30)?-2:local);
  return dp[index];
}

void run(void){
  int v,e;
  scanf("%d%d",&v,&e);
  int d[225];
  int i;
  for(i=0;i<v*v;i++) d[i]=-1;
  for(i=0;i<v;i++) d[POS(i,i)]=0;
  for(i=0;i<e;i++){
    int s,t,w;
    scanf("%d%d%d",&s,&t,&w);
    d[POS(s,t)]=w;
  }
  int *dp=(int *)malloc(sizeof(int)*(1<<v)*v);
  memset(dp,-1,sizeof(int)*v*(1<<v));
  int ans=calc(0,1,d,dp,v);
  printf("%d\n",ans>=0?ans:-1);
  return;
}

int main(void){
  run();
  return 0;
}



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

using namespace std;

template< class T >
struct ConvexHullTrickAddQueryMonotone
{
  deque< pair< T, T > > L;
  int isdec;

  ConvexHullTrickAddQueryMonotone() : isdec(-1) {}

  inline T getX(const pair< T, T > &a, const T &x)
  {
    return (a.first * x + a.second);
  }

  inline bool check(const pair< T, T > &a, const pair< T, T > &b, const pair< T, T > &c)
  {
    return ((b.first - a.first) * (c.second - b.second) >= (b.second - a.second) * (c.first - b.first));
  }

  inline bool empty() { return (L.empty()); }

  void add(T a, T b)
  {
    pair< T, T > line(a, b);

    if(!L.empty() && L.back().first == a) {
      line.second = min(line.second, L.back().second);
      L.pop_back();
    }
    while(L.size() >= 2 && check(L[L.size() - 2], L.back(), line)) L.pop_back();
    L.emplace_back(line);

  }

  T getMinimumQuery(T x)
  {
    int low = -1, high = (int) L.size() - 1;
    while(high - low > 1) {
      int mid = (low + high) >> 1;
      if((getX(L[mid], x) >= getX(L[mid + 1], x))) low = mid;
      else high = mid;
    }
    return (getX(L[high], x));
  }

  T getMinimumQueryMonotone(T x)
  {
    while(L.size() >= 2 && getX(L[0], x) >= getX(L[1], x)) {
      L.pop_front();
    }
    return (getX(L[0], x));
  }

};

using int64 = long long;
const int64 INF = 1LL << 62;

int N, T;
vector< tuple< int, int, int > > dd;
int64 dp[4001];
int64 t[4000], p[4000], f[4000];

int main()
{
  scanf("%d %d", &N, &T);
  for(int i = 0; i < N; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a <= T) dd.emplace_back(c, a, b);
  }
  sort(begin(dd), end(dd));
  N = (int) dd.size();
  for(int i = 0; i < N; i++) {
    tie(f[i], t[i], p[i]) = dd[i];
  }

  fill_n(dp, 4001, -INF);
  vector< ConvexHullTrickAddQueryMonotone< int64 > > cht(T + 1, ConvexHullTrickAddQueryMonotone< int64 >());

  for(int i = 0; i < N; i++) {
    for(int j = T; j > t[i]; j--) {
      if(cht[j - t[i]].empty()) continue;
      auto cost = -cht[j - t[i]].getMinimumQueryMonotone(f[i]) + p[i] - f[i] * f[i];
      cht[j].add(-2 * f[i], -(cost - f[i] * f[i]));
      if(cost > dp[j]) {
        dp[j] = cost;
      }
    }
    if(p[i] > dp[t[i]]) {
      dp[t[i]] = p[i];
    }
    cht[t[i]].add(-2 * f[i], -(p[i] - f[i] * f[i]));
  }

  int64 ret = 0;
  for(int j = 0; j <= T; j++) {
    ret = max(ret, dp[j]);
  }

  printf("%lld\n", ret);
}

Measured memory_bytes: 6268
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;
typedef pair<int, int> Pr;

namespace std {
	bool operator < (const Pr& a, const Pr& b){
		if (a.first != b.first) return a.first < b.first;
		return a.second > b.second;
	}
}

int N, H;
int d[100000], h[100000];

const int size = 1 << 20;
int seg_v[size * 2 - 1];
int seg_a[size * 2 - 1];
Pr rmq[size * 2 - 1];

void seg_add(int l, int r, int x, int k = 0, int a = 0, int b = size){
	if (b <= l || r <= a) return;
	if (l <= a && b <= r){
		seg_a[k] += x;
		while (k){
			k = (k - 1) / 2;
			seg_v[k] = max(
				seg_v[k * 2 + 1] + seg_a[k * 2 + 1],
				seg_v[k * 2 + 2] + seg_a[k * 2 + 2]
			);
		}
		return;
	}
	
	int m = (a + b) / 2;
	seg_add(l, r, x, k * 2 + 1, a, m);
	seg_add(l, r, x, k * 2 + 2, m, b);
}
int seg_getMax(int l, int r, int k = 0, int a = 0, int b = size){
	if (b <= l || r <= a) return -INF;
	if (l <= a && b <= r) return seg_a[k] + seg_v[k];
	int m = (a + b) / 2;
	int vl = seg_getMax(l, r, k * 2 + 1, a, m);
	int vr = seg_getMax(l, r, k * 2 + 2, m, b);
	return seg_a[k] + max(vl, vr);
}

void rmq_update(int k, int x){
	int i = k;
	k += size - 1;
	rmq[k] = Pr(x, i);
	while (k){
		k = (k - 1) / 2;
		rmq[k] = max(rmq[k * 2 + 1], rmq[k * 2 + 2]);
	}
}
Pr _rmq_getMax(int l, int r, int k = 0, int a = 0, int b = size){
	if (b <= l || r <= a) return Pr(-INF, -1);
	if (l <= a && b <= r) return rmq[k];
	int m = (a + b) / 2;
	Pr vl = _rmq_getMax(l, r, k * 2 + 1, a, m);
	Pr vr = _rmq_getMax(l, r, k * 2 + 2, m, b);
	return max(vl, vr);
}
int rmq_getMax(int l, int r){
	return _rmq_getMax(l, r).first;
}
int rmq_getMaxIdx(int l, int r){
	return _rmq_getMax(l, r).second;
}

void solve()
{
	long long int res = 0;
	
	for (int i = 0; i < N; i++){
		rmq_update(i, h[i]);
	}
	
	seg_add(0, N, H);
	
	for (int fl = 0; fl < N; fl++){
		if (seg_getMax(fl, fl + 1) > H){
			seg_add(fl, N, H - seg_getMax(fl, fl + 1));
		}
		
		seg_add(fl, N, -d[fl]);
		//printf("%dF HP=%d\n", fl, seg_getMax(fl, fl + 1));
		if (seg_getMax(fl, fl + 1) > 0) continue;
		
		while (true){
			int idx = rmq_getMaxIdx(0, fl);
			if (h[idx] > H - seg_getMax(idx, fl)){
				h[idx] = H - seg_getMax(idx, fl);
				rmq_update(idx, h[idx]);
				continue;
			}
			
			/*
			seg_add(idx, N, h[idx]);
			res++;
			if (seg_getMax(fl, fl + 1) > 0) break;
			*/
			
			int s = (H - seg_getMax(idx, fl)) / h[idx];
			int hp = seg_getMax(fl, fl + 1);
			int need = -hp + 1;
			int t = (need / h[idx]) + !!(need % h[idx]);
			int num = min(s, t);
			
			seg_add(idx, N, h[idx] * num);
			res += num;
			if (seg_getMax(fl, fl + 1) > 0) break;
		}
		
		//printf("%dF HP=%d\n", fl, seg_getMax(fl, fl + 1));
	}
	
	printf("%lld\n", res);
}

int main()
{
	scanf("%d %d", &N, &H);
	for (int i = 0; i < N - 1; i++){
		scanf("%d %d", d + i + 1, h + i);
	}
	solve();
}

Measured memory_bytes: 30636
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, M;
	cin >> N >> M;
	vector<int> data(N, -1);
	for (int i = 0; i < M; i++)
	{
		int a, b;
		cin >> a >> b;
		if (data[a - 1] == -1)
		{
			data[a - 1] = b;
		}
		else
		{
			if (data[a - 1] != b)
			{
				cout << -1 << endl;
				return;
			}
		}
	}
	if (data[0] == 0)
	{
		if (N != 1)
		{
			cout << -1 << endl;
			return;
		}
	}
	if (data[0] == -1)
	{
		if (N != 1)
		{
			data[0] = 1;
		}
	}
	for (int i = 0; i < N; i++)
	{
		if (data[i] == -1)
			data[i] = 0;
		cout << data[i];
	}
	cout << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
// ------------------------------------
// Date:2018/ 3/ 6
// Problem:ABC 081 ShiftOnly b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  int N;
  scanf("%d", &N);
  vector< int > A(N);
  REP(i, N) {
    scanf("%d", &A[i]);
  }

  bool ok = true;
  int cnt = 0;
  while (ok) {
    REP(i, N) {
      if (A[i] == 0) ok = false;
      else if (A[i] % 2 == 0) {
	A[i] /= 2;
      } else {
	ok = false;
      }
      //debug(A[i]);
    }
    ++cnt;
  }

  printf("%d\n", cnt - 1);
  
  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
	if(ch == 'A')return 1;
	else if(ch == 'C')return 2;
	else if(ch == 'G')return 3;
	else if(ch == 'T')return 4;
	else return 0;
}

long long getKey(char str[]){
	long long sum = 0, p = 1, i;
	for(i = 0; i < strlen(str); ++i){
		sum += p*(getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key){return key % M;};
int h2(int key){return 1 + (key % (M - 1));}

int find(char str[]){
	long long key, i, h;
	key = getKey(str);
	for(i = 0; ; ++i){
		h = (h1(key) + i * h2(key)) % M;
		if(strcmp(H[h], str) == 0)return 1;
		else if(strlen(H[h]) == 0)return 0;
	}
	return 0;
}

int insert(char str[]){
	long long key, i, h;
	key = getKey(str);
	for(i = 0; ; ++i){
		h = (h1(key) + i * h2(key)) % M;
		if(strcmp(H[h], str) == 0)return 1;
		else if(strlen(H[h]) == 0){
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main(){
	int i, n, h;
	char str[L], com[9];
	for(i = 0; i < M; ++i)H[i][0] = '\0';
	scanf("%d",&n);
	for(i = 0; i < n; ++i){
		scanf("%s %s",com, str);
		if(com[0] == 'i'){
			insert(str);
		}else {
			if(find(str)){
				printf("yes\n");
			}else {
				printf("no\n");
			}
		}
	}
	return 0;
		
}

Measured memory_bytes: 15344
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll t,a,b,i,j,k,n,x;
    char c;
    cin>>c;
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
    {
        cout<<"vowel"<<endl;
    }
    else
        cout<<"consonant"<<endl;
     return 0;
}


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

struct BipartiteMatching {
	int V;
	vector<vector<bool> > G;
	vector<int> match;
	vector<bool> used;

	BipartiteMatching(int v) {
		V = v;
		G = vector<vector<bool> >(v, vector<bool>(v));
		match = vector<int>(v);
		used = vector<bool>(v);
	}

	void add_edge(int v, int u) {
		G[v][u] = G[u][v] = true;
	}

	void remove_edge(int v, int u) {
		G[v][u] = G[u][v] = false;
	}

	bool dfs(int v) {
		used[v] = true;
		for(int i = 0; i < V; i++) {
			if(!G[v][i]) continue;
			int u = i, w = match[u];
			if(w < 0 || (!used[w] && dfs(w))) {
				match[v] = u;
				match[u] = v;
				return true;
			}
		}
		return false;
	}

	int calc() {
		int res = 0;
		fill(match.begin(), match.end(), -1);
		for(int v = 0; v < V; v++) {
			if(match[v] < 0) {
				fill(used.begin(), used.end(), false);
				if(dfs(v)) {
					res++;
				}
			}
		}
		return res;
	}
};


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

	int N;
	cin >> N;

	BipartiteMatching bp(2 * (N - 1));
	for(int i = 0; i < N - 1; i++) {
		for(int j = 0; j < N - 1; j++) {
			int b;
			cin >> b;
			if(b) bp.add_edge(j, (N - 1) + i);
		}
	}

	if(bp.calc() != N - 1) {
		cout << "no" << endl;
		return 0;
	}

	cout << "yes" << endl;
	for(int i = 0; i < N - 1; i++) {
		int m = bp.match[i];
		bp.match[i] = bp.match[m] = -1;
		fill(bp.used.begin(), bp.used.end(), false);
		if(bp.dfs(i)) {
			assert(m >= bp.match[i]);
		}

		for(int j = 0; j < N - 1; j++) {
			bp.remove_edge(i, N - 1 + j);
		}
		bp.add_edge(i, bp.match[i]);

		cout << bp.match[i] - (N - 1) + 1 << endl;
	}
}

Measured memory_bytes: 3240
#include <cstdio>
int main() {
  int x, y;
  bool flag=false;
  scanf("%d%d", &x, &y);
  for(int i=0;i<=x;i++) {
    if((i*4 + (x-i)*2) == y) flag = true;
  }
  flag ? puts("Yes") : puts("No");
  return 0;
}

Measured memory_bytes: 1644
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  cin >> n;
  int p[10];
  clr(d,0);
  clr(p,0);
  rep(i,0,n)cin >> d[i];
  rep(i,0,n){
    if(d[i] >= 3200){
      p[8]++;
    }else {
      p[d[i]/400]++;
    }
  }
  rep(i,0,8){
    if(p[i] != 0){
      m++;
      l++;
    }
  }
  if(m == 0 && p[8] != 0)m++;
  printf("%lld %lld\n",m,l + p[8]);
  return 0;
}

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

using namespace std;

int main(){
    string s;
    size_t k;
    cin >> s >> k;
    int lim=min(s.size(), k);
    char ans='1';
    for(int i=0; i<lim; ++i){
        if(s[i]!='1'){
            ans=s[i];
            break;
        }
    }
    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++)
using P = pair<int, int>;
const int MX = 105;
int n, v, w, dep[MX], par[MX], ans_d;
long long ans = 1e15;
vector<int> G[MX];
long long bfs_2(int s1, int s2){
	long long ret = 1 + (s1 != s2);
	int ch = 1, de = 0;
	queue<int> qu;
	fill(dep, dep+n, -1);
	dep[s1] = dep[s2] = 0;
	qu.push(s1);
	if(s1 != s2) qu.push(s2);
	while(!qu.empty()){
		int t = qu.front(); qu.pop();
		if(dep[t] != de){
			ret *= ch;
			de++;
			ch = 1;
		}
		ch = max(ch, (int)G[t].size()-(s1 != t || s2 != t));
		for(int nx: G[t]) if(dep[nx] == -1){
			dep[nx] = dep[t] + 1;
			qu.push(nx);
		}
	}
	return ret;
}
void bfs(){
	int s = 0, t = 0;
	rep(i,2){
		queue<int> qu;
		fill(dep, dep+n, -1);
		dep[s] = 0;
		qu.push(s);
		while(!qu.empty()){
			t = qu.front(); qu.pop();
			for(int nx: G[t]) if(dep[nx] == -1){
				dep[nx] = dep[t] + 1;
				par[nx] = t;
				qu.push(nx);
			}
		}
		s = t;
	}
	ans_d = dep[t]/2+1;
	rep(i,ans_d-1) s = par[s];
	if(dep[t]&1){
		ans = bfs_2(s,par[s]);
	}else{
		ans = bfs_2(s,s);
		for(int s2: G[s]) ans = min(ans,bfs_2(s,s2));
	}
	printf("%d %lld\n", ans_d, ans);
}
int main(){
	scanf("%d", &n);
	rep(i,n-1){
		scanf("%d%d", &v, &w); v--; w--;
		G[v].push_back(w);
		G[w].push_back(v);
	}
	bfs();
}

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


ll N,K;

int my_b_search(ll key,ll val,bool mode,vector<int64_t>& A){
    //mode -> true ならば昇順での二分探索 falseなら降順での二分探索
    int ok = mode ? -1 : N;
    int ng = mode ? N : -1;
    while(abs(ok-ng)>1){
        int mid=(ok+ng)/2;
        if(val*A[mid]<=key)ok=mid;
        else ng=mid;
    }
    return ok;
}

bool f(ll key,vector<int64_t>& A){
    ll cnt=0;
    for(int i=0;i<N;i++){
        if(A[i]>=0){
            cnt+=my_b_search(key,A[i],true,A)+1;
        }else{
            cnt+=N-my_b_search(key,A[i],false,A);
        }
        if(key>=A[i]*A[i])cnt--;
    }
    return cnt>=2*K;
}


int main(){
    
    cin>>N>>K;
    vector<int64_t> A(N);

    for(int64_t& a:A){
        cin>>a;
    }

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

    int64_t ok=1e18,ng=-1e18;
    rep(i,70){
        int64_t mid=(ok+ng)/2;

        if(f(mid,A)){
            ok=mid;
        }else{
            ng=mid;
        }
    }

    cout<<ok<<endl;

}

Measured memory_bytes: 1792
# coding: utf-8
# Your code here!
N,a,b=map(int,input().split())
if (b-a)%2==0:
    print((b-a)//2)
else:
    M=(a+b)//2
    if M-1<N-M:
        b-=a
        print((b-1)//2+a)
    else:
        a+=N-b+1
        print((N-a)//2+N-b+1)

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int h, w;
  cin >> h >> w;
  char mas[55][55];
  rep(i, h) rep(j, w) cin >> mas[i][j];
  int dx[] = {0, 1, 0, -1, -1, -1, 1, 1};
  int dy[] = {1, 0, -1, 0, -1, 1, -1, 1};
  int cnt[55][55];
  memset(cnt, -1, sizeof(cnt));
  rep(i, h) rep(j, w) {
    if(mas[i][j] == '#') continue;
    cnt[i][j] = 0;
    rep(k, 8) {
      if(0<=i+dy[k]&&i+dy[k]<h&&0<=j+dx[k]&&j+dx[k]<w&&mas[i+dy[k]][j+dx[k]] == '#') cnt[i][j]++;
    }
  }
  rep(i, h) {
    rep(j, w) {
      if(cnt[i][j] == -1) cout << '#';
      else cout << cnt[i][j];
    }
    cout << endl;
  }


  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  map<int, int> mp;
  for(int i=0; i<n; ++i){
    cin >> vec.at(i);
    ++mp[vec.at(i)];
  }
  long long ans=0;
  for(int i=0; i<=n; ++i){
    long long x = mp[i];
    ans += x*(x-1)/2;
  }
  for(int i=0; i<n; ++i){
    long long x=mp[vec.at(i)];
    cout << ans-x+1 << endl;
  }
}

Measured memory_bytes: 12800
package main

import (
	"fmt"
)

func main() {
	var a int
	fmt.Scanf("%d", &a)


	if a < 10 {
		fmt.Println(a)
	} else {
		var cnt, rem, sum int
		for {
			rem = a % 10
			sum += rem
			cnt++
			a = a / 10
			if a == 0 {
				break
			}
		}

		if sum > rem+(cnt-1)*9-1 {
			fmt.Println(sum)
		} else {
			fmt.Println(rem+(cnt-1)*9-1)
		}

	}
}


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

int main() {
    int X;
    cin >> X;
    int ans = 1;
    for(int i = 2;i*i<=X;++i){
        int tmpans = i;
        while(1){
            if(tmpans*i<=X){
                tmpans *= i;
            } else {
                break;
            }
        }
        ans = max(ans,tmpans);
    }
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  int a[6] = {0};
  while(n--) {
    double h;
    cin >> h;
    a[max(0, min(5, ((int)(h*10)-1600)/50))] += 1;
  }
  for(int i = 0; i < 6; ++i) {
    cout << i+1 << ":" << string(a[i], '*') << endl;
  }
  return 0;
}

Measured memory_bytes: 1240
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;


int main() {
     int ab,bc,ca;
     cin>>ab>>bc>>ca;

     cout<<(ab*bc)/2<<endl;
     return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i;

	          int N;
	          cin >> N;
	          int od=0;
	          for(i=1;i<=N;i++){
	        	  int a;
	        	  cin >> a;
	        	  if(a%2==1) od++;
	          }

	          if(od%2==0) cout << "YES" << endl;
	          else cout << "NO" << endl;

	          return 0;
}


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

#define FOR(x, a, b) for (int x = a; x <= b; ++x)
#define FOD(x, a, b) for (int x = a; x >= b; --x)
#define REP(x, a, b) for (int x = a; x < b; ++x)
#define DEBUG(X) { cout << #X << " = " << X << endl; }
#define PR(A, n) { cout << #A << " = "; FOR(_, 1, n) cout << A[_] << " "; cout << endl; }
#define PR0(A, n)  { cout << #A << " = "; REP(_, 0, n) cout << A[_] << " "; cout << endl; }

using namespace std;

typedef long long LL;

const int N = 2e5 + 10;

int n;
int a[N];

set <int> S[N];
queue <int> Q;

int Merge(int x, int y) {
    if (S[x].size() < S[y].size()) swap(x, y);
    for (set <int> :: iterator it = S[y].begin(); it != S[y].end(); ++it)
        S[x].insert(*it);
    return x;
}

int main() {
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // LOCAL
    scanf("%d", &n);
    FOR(i, 1, n) scanf("%d", &a[i]);
    FOR(i, 1, n) {
        S[i].insert(a[i]);
        Q.push(i);
    }
    sort(a + 1, a + n + 1);
    LL ans = 0;
    FOR(i, 1, n) {
        int v = a[i], sz = 0;
        assert(Q.size());
        int p = Q.front(); Q.pop();
        sz = S[p].size();
        while (*S[p].begin() != v) {
            sz += S[Q.front()].size();
            p = Merge(p, Q.front());
            Q.pop();
        }
        S[p].erase(v);
        if (S[p].size() != 0) Q.push(p);
        ans += (sz - 1);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 36776
#include<bits/stdc++.h>
using namespace std;
int main(){
int X,Y;
  cin>>X>>Y;
  if(X==1 && Y==1)
    cout<<1000000<<endl;
  else {
  int a=100000*max(4-X,0);
    int b=100000*max(4-Y,0);
    cout<<a+b<<endl;
  
  }
    return 0;
}

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

using namespace std;

int main(){
    int n,x,S[14],H[14],C[14],D[14];
    S[0]=1;
    H[0]=1;
    C[0]=1;
    D[0]=1;
    for(int i=1;i<=13;i++){
      S[i]=0;
      H[i]=0;
      C[i]=0;
      D[i]=0;
    }
    string s;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s>>x;
        if(s=="S"){
            for(int v=1;v<=13;v++){
                if(x==v)S[v]=1;
                if(S[v]!=1)S[v]=0;
            }
        }
        if(s=="H"){
            for(int v=1;v<=13;v++){
                if(x==v)H[v]=1;
                if(H[v]!=1)H[v]=0;
            }
        }
        if(s=="C"){
            for(int v=1;v<=13;v++){
                if(x==v)C[v]=1;
                if(C[v]!=1)C[v]=0;
            }
        }
        if(s=="D"){
            for(int v=1;v<=13;v++){
                if(x==v)D[v]=1;
                if(D[v]!=1)D[v]=0;
            }
        }
    }
    //S
    // cout<<endl;
    for(int i=1;i<=13;i++){
        if(S[i]==0)cout<<"S "<<i<<endl;
    }
    for(int i=1;i<=13;i++){
        if(H[i]==0)cout<<"H "<<i<<endl;
    }
    for(int i=1;i<=13;i++){
        if(C[i]==0)cout<<"C "<<i<<endl;
    }
    for(int i=1;i<=13;i++){
        if(D[i]==0)cout<<"D "<<i<<endl;
    }
    return 0;
}



Measured memory_bytes: 3164
#A1 ~ Aiまでの和 O(logN)
def BIT_query(idx):
    res_sum = 0
    while idx > 0:
        res_sum += BIT[idx]
        idx -= idx&(-idx)
    return res_sum

#Ai += x O(logN)
def BIT_update(idx,x):
    while idx <= n:
        BIT[idx] += x
        idx += (idx&(-idx))
    return

n,q=map(int,input().split())
A=list(map(int,input().split()))
#A1 ... AnのBIT(1-indexed)
BIT = [0]*(n+1)
for i,e in enumerate(A):
   BIT_update(i+1,e)
for i in range(q):
  B=list(map(int,input().split()))
  if B[0]==0:
    BIT_update(B[1]+1,B[2])
  else:
    print(BIT_query(B[2])-BIT_query(B[1]))

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

using namespace std;

#define int long long

const int mod = 1e9 + 7;

int s;
int f[2001], g[2001];

int dp(int sum)
{
	if (!sum)
		return 1;
	if (g[sum])
		return f[sum];	
	int cur = 0;
	for (int i = 3; i <= sum; i++)	
		(cur += dp(sum - i)) %= mod;
	g[sum] = 1;
	return f[sum] = cur;
}

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

	cin >> s;
	cout << dp(s);
}

Measured memory_bytes: 3696
import java.util.LinkedList;
import java.util.Scanner;

//Petoris
public class Main{

	class R{
		int h, w;
		LinkedList<LinkedList<Character>> p;
		public R(char[][] m) {
			p = new LinkedList<LinkedList<Character>>();
			for(int i=0;i<m.length;i++){
				LinkedList<Character> l = new LinkedList<Character>();
				for(int j=0;j<m[i].length;j++)l.add(m[i][j]);
				p.add(l);
			}
			for(;;){
				boolean f = true;
				for(char c:p.get(0))if(c=='#')f=false;
				if(!f)break;
				p.remove(0);
			}
			for(;;){
				boolean f = true;
				for(char c:p.get(p.size()-1))if(c=='#')f=false;
				if(!f)break;
				p.remove(p.size()-1);
			}
			h = p.size();
			for(;;){
				boolean f = true;
				for(int i=0;i<h;i++)if(p.get(i).get(0)=='#')f=false;
				if(!f)break;
				for(int i=0;i<h;i++)p.get(i).remove(0);
			}
			for(;;){
				boolean f = true;
				for(int i=0;i<h;i++)if(p.get(i).get(p.get(i).size()-1)=='#')f=false;
				if(!f)break;
				for(int i=0;i<h;i++)p.get(i).remove(p.get(i).size()-1);
			}
			w = p.get(0).size();
		}
	}
	
	char[][] rot(char[][] a){
		int h = a.length, w = a[0].length;
		char[][] r = new char[w][h];
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)r[j][i] = a[h-i-1][j];
		return r;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		while(T--!=0){
			int H = sc.nextInt(), W = sc.nextInt();
			R[] r = new R[4];
			char[][] p = new char[H][];
			for(int i=0;i<H;i++)p[i]=sc.next().toCharArray();
			for(int i=0;i<4;i++){
				r[i] = new R(p);
				p = rot(p);
			}
			H = sc.nextInt(); W = sc.nextInt();
			p = new char[H][];
			for(int i=0;i<H;i++)p[i]=sc.next().toCharArray();
			int res = -1;
			for(int k=0;k<4;k++){
				int h = r[k].h, w = r[k].w;
				for(int i=0;i+h<=H;i++)for(int j=0;j+w<=W;j++){
					boolean f = true;
					for(int y=0;y<h;y++)for(int x=0;x<w;x++){
						if(r[k].p.get(y).get(x)=='.')continue;
						if(p[i+y][j+x]=='#')f = false;
					}
					if(!f)continue;
					for(int y=0;y<h;y++)for(int x=0;x<w;x++){
						if(r[k].p.get(y).get(x)=='#')p[i+y][j+x] = '#';
					}
					int c = 0;
					for(int y=0;y<h;y++){
						boolean ok = true;
						for(int x=0;x<W;x++)if(p[i+y][x]=='.')ok = false;
						if(ok)c++;
					}
					res = Math.max(res, c);
					for(int y=0;y<h;y++)for(int x=0;x<w;x++){
						if(r[k].p.get(y).get(x)=='#')p[i+y][j+x] = '.';
					}
				}
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 14000
from decimal import Decimal
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    A, B, C = input().split()

    a, b, c = Decimal(A), Decimal(B), Decimal(C)
    n = Decimal('0.5')
    if a ** n + b ** n < c ** n:
        print('Yes')
    else:
        print('No')


main()


Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
template<typename T1, typename T2>
inline bool cmn (T1& a, T2 b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
inline bool cmx (T1& a, T2 b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int, int>> dat(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    dat[i] = {x, y};
  }
  sort(dat.begin(), dat.end());
  vector<pair<int, int>> dif;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      dif.emplace_back(
        dat[j].first  - dat[i].first,
        dat[j].second - dat[i].second
      );
    }
  }
  auto cal = [&] (int p, int q) {
    int ret = n;
    set<pair<int, int>> ckd;
    for (auto e : dat) {
      int x, y; tie(x, y) = e;
      if (ckd.count({x - p, y - q})) ret--;
      ckd.emplace(x, y);
    }
    return ret;
  };
  int ret = n;
  for (auto p : dif) {
    cmn(ret, cal(p.first, p.second));
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,b) for(int i=1;i<=b;i++)
#define drep(i,b) for(int i=b;i>=1;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define endl '\n'
#define int long long
#define ls i<<1
#define rs i<<1|1
#define mid (l+r)/2

using namespace std;

const int N=1e5+7;
const int mod=998244353;
int n,m,k,t,x,y,z;
int dis[N],vis[N],cnt[N];

#define pr pair<int,int>
#define ff first
#define ss second

void solve(int sum=0){
    cin>>n;
    set<string> se;
    string s;
    rep(i,n) {
        cin>>s;
        se.insert(s);
    }
    cout<<se.size()<<endl;
}

#undef int
int main(){
    ios::sync_with_stdio(false);
    //int T;cin>>T;
    //while(T--)
    solve();
}


Measured memory_bytes: 19292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int p[n], q[n];
    rep(i, 0, n) cin >> p[i];
    rep(i, 0, n) cin >> q[i];
    int x[n];
    rep(i, 0, n) x[i] = i + 1;
    int a = 0, b = 0;
    int cnt = 0;
    do {
        cnt++;
        bool flag1 = true;
        bool flag2 = true;
        rep(i, 0, n) {
            if (x[i] != p[i]) flag1 = false;
            if (x[i] != q[i]) flag2 = false;
        }
        if (flag1) a = cnt;
        if (flag2) b = cnt;
    } while(next_permutation(x, x + n));
    cout << abs(a - b) << endl;
    return 0;
}


Measured memory_bytes: 256