akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
	string x;
	for(;;){
	    cin >> x;
		if(x == "0")break;
		int sum=0;
        for(int i=0; i<(int)x.length(); i++){
            sum += x[i] - '0';
        }
       cout << sum << endl;
	}
	return 0;
}



Measured memory_bytes: 3160
#include<iostream>
#include<queue>
using namespace std;
const int MAX = 100;
int n, G[MAX + 1][MAX + 1];
bool book[MAX + 1] = { false };
int path[MAX + 1];
void breathFSearch(int orign)
{
	queue<int> Q;
	Q.push(orign);
	book[orign] = true;
	while (!Q.empty())
	{
		int u = Q.front();
		for (int v = 1; v <= n; v++)
		{
			if (G[u][v] && !book[v])
			{
				Q.push(v);
				book[v] = true;
				if(path[u]!=-1)
					path[v] = path[u]+1;
			}
		}
		Q.pop();
	}
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int u, d;
		cin >> u >> d;
		for (int j = 1; j <= d; j++)
		{
			int v;
			cin >> v;
			G[u][v] = 1;
		}
	}
	for (int i = 1; i <= n; i++)
		path[i] = -1;
	path[1] = 0;
	for(int i=1;i<=n;i++)
		if(!book[i])
			breathFSearch(i);
	for (int i = 1; i <= n; i++)
		cout << i << " " << path[i] << endl;
}


Measured memory_bytes: 3080
H, W = map(int, raw_input().split())
picture = [list("#"*(W+2)) for _ in xrange(H+2)]
for i in xrange(1, H+1):
    a = list(raw_input())
    for j in xrange(1, W+1):
        picture[i][j] = a.pop(0)
for p in picture:
    print "".join(p)

Measured memory_bytes: 2692
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


N, M = map(int, input().split(' '))
P = [int(c) for c in input().split(' ')]

uft = UnionFind(N)
for _ in range(M):
    x, y = map(int, input().split(' '))
    x -= 1
    y -= 1
    uft.union(x, y)

ans = 0
for i in range(N):
    if i+1 == P[i]:
        ans += 1
    else:
        if uft.find(i) == uft.find(P[i]-1):
            ans += 1

print(ans)

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

int gcd(int x, int y) {

    if (x < y) swap(x, y);
    while (y > 0) {
        int r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main()
{
    int X, Y;
    cin >> X >> Y;
    cout << gcd(X, Y) << endl;
}


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

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


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

int main() {
    int n;
    std::cin>>n;
    std::vector<long> t(static_cast<unsigned int>(n));
    std::vector<long> a(static_cast<unsigned int>(n));
    std::vector<long> ml(static_cast<unsigned int>(n));
    std::vector<long> mh(static_cast<unsigned int>(n));
    for (int i = 0; i < n; ++i) {
        std::cin>>t[i];
        if(i==0){ml[0]=t[0];mh[0]=t[0];}
        else if(t[i]!=t[i-1]){
            ml[i]=t[i];
            mh[i]=t[i];
        }
        else {
            ml[i]=1;
            mh[i]=t[i];
        }
    }
    for (int i = 0; i < n; ++i) {
        std::cin>>a[i];
    }
    if(t[n-1]!=a[0]){std::cout<<0<<std::endl;return 0;}
    for (int i = n-1; i >= 0; --i) {
        if(i==n-1){ml[n-1]=a[n-1];mh[n-1]=a[n-1];}
        else if(a[i]!=a[i+1]){
            if(ml[i]==mh[i]&&ml[i]!=a[i]){std::cout<<0<<std::endl;return 0;}
            ml[i]=a[i];
            mh[i]=a[i];
        }
        else {
            if(ml[i]>a[i]){std::cout<<0<<std::endl;return 0;}
            ml[i]=std::max(ml[i],(long)1);
            mh[i]=std::min(mh[i],a[i]);
        }
    }
    long long ans=1;
    for (int i = 0; i < n; ++i) {
        ans=ans*(mh[i]-ml[i]+1);
        ans=ans%MOD;
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 3328
N,M = map(int,input().split())
H = list(map(int,input().split()))
C = []
counter = [0 for i in range(N+1)]
count = [0 for i in range(N+1)]
good = 0
for i in range(M):
    a = tuple(map(int,input().split()))
    a = tuple(sorted(a))
    C.append(a)
C = list(set(C))
for i in range(len(C)):
    count[C[i][0]] += 1
    count[C[i][1]] += 1
    if H[C[i][0]-1] > H[C[i][1]-1]:
        counter[C[i][0]] += 1
    elif H[C[i][0]-1] < H[C[i][1]-1]:
        counter[C[i][1]] += 1
for i in range(1,N+1):
    if counter[i] == count[i]:
        good += 1
print(good)

Measured memory_bytes: 34712
s = str(input())
k = 0

if(len(s)%2==0):
    for i in range(int(len(s)/2)):
        if(s[i]!=s[len(s)-1-i]):
            k = k + 1
else:
    for i in range(int((len(s)-1)/2)):
        if(s[i]!=s[len(s)-1-i]):
            k = k + 1
            
print(k)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define FOR(variable,start,end) for(int variable = start; variable < end; ++variable)
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	int x;
	cin >> x;
	if(x>=30){
		cout << "Yes" << endl; 
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    sort(all(a));
    ll A = a[a.size() - 1];
    ld target = A / 2.0;
    ll Bind = 0;
    ld diff = 1e18f;
    rep(i, a.size()) {
        ld d = abs(target - a[i]);
        if (diff > d) {
            diff = d;
            Bind = i;
        }
    }

    ll B = a[Bind];
    cout << A << " " << B << endl;

}
signed main(){ Main();return 0;}

Measured memory_bytes: 4028
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>

using namespace std;
using lli = long long int;

int main() {
	int N;
	cin >> N;
	int g = 0;
	for (int i = 0; i < N; i++) {
		int tmp;
		if (g == 0) {
			cin >> g;
		}
		else {
			cin >> tmp;
		}
		g = __gcd(g, tmp);
	}
	cout << g << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool dp[100005];
int main()
{
	string s;
	cin>>s;
	dp[0]=1;
	for(int i=0;i<s.length();i++)
	{
		if(i+5<=s.length()&&s.substr(i,5)=="dream")dp[i+5]=dp[i];
		if(i+6<=s.length()&&s.substr(i,6)=="eraser")dp[i+6]=dp[i];
		if(i+7<=s.length()&&s.substr(i,7)=="dreamer")dp[i+7]=dp[i];
		if(i+5<=s.length()&&s.substr(i,5)=="erase")dp[i+5]=dp[i];
	}
	if(dp[s.length()])cout<<"YES";
	else cout<<"NO";

}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
	int n, i, a[999999]={}, sum=0;
	
	scanf("%d", &n);
	
	for(i=1;i<=n;i++)
	scanf("%d", &a[i]);
	
	for(i=1;i<=n;i++){
		if(a[a[i]]==i){
			sum++;
		}
	}
	
	printf("%d\n", sum/2);
	return 0;
}


Measured memory_bytes: 4096
#python2.7

N=input()
A=map(int,raw_input().split())
num=0

for i in range(N):
	minj=i
	for j in range(N-i):
		if A[j+i] < A[minj]:
			minj=j+i
	if i != minj:
		A[i],A[minj]=A[minj],A[i]
		num+=1

for m in range(N-1):
	print str(A[m]),

print A[N-1]
print num

Measured memory_bytes: 6444
def g(a):
    n = a + 1
    if n % 2 == 0:
        return (n // 2) % 2
    else:
        p = (n // 2) % 2
        return p ^ a

def f(a, b):
    if a == 0:
        return g(b)
    else:
        return g(b) ^ g(a-1)

assert f(2, 4) == 5, f(2, 4)
assert f(123, 456) == 435, f(123, 456)
assert f(123456789012, 123456789012) == 123456789012
a, b = map(int, input().split())
print(f(a, b))

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  int64 M;
  cin >> N >> M;
  vector< int > A(N);
  cin >> A;
  sort(A.begin(), A.end());
  vector< int64 > S(N + 1);
  for(int i = 0; i < N; i++) {
    S[i + 1] = S[i] + A[i];
  }
  auto check = [&](int v) {
    int64 ret = 0, all = 0;
    for(int i = 0; i < N; i++) {
      int64 pos = lower_bound(begin(A), end(A), v - A[i]) - begin(A);
      ret += N - pos;
      all += S[N] - S[pos];
      all += (N - pos) * A[i];
    }
    return make_pair(ret, all);
  };
  int ok = 200001, ng = -1;
  while(ok - ng > 1) {
    int mid = (ok + ng) / 2;
    if(check(mid).first <= M) ok = mid;
    else ng = mid;
  }
  auto ret = check(ok);
  cout << ret.second + (M - ret.first) * (ok - 1) << endl;
}


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

int main()
{
	int N;
	cin >> N;
	
	int res = N;
	for (int i = 0; i <= N; i++)
	{
		int cc = 0;
		int t = i;
		while (t > 0) cc += t % 6, t /= 6;
		t = N - i;
		while (t > 0) cc += t % 9, t /= 9;
		if (res > cc)res = cc;
	}

	cout << res << endl;

	return 0;
}


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

#define FORS(i, j, k, step) for (int i=j; i<k; i+=step)
#define FOR(i, j, k) for (int i=j; i<k; i++) 
#define RFORS(i, j, k, step) for (int i=j; i>=k; i-=step)
#define RFOR(i, j, k) for(int i=j; i>=k; i--)
#define REP(i, k) for(int i = (0); i < (k); i++ ) 
#define RREP(i, k) for(int i = (k); i >= (0); i-- )
 
#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define RESET(a, b) memset(a, b, sizeof(a))
#define INF (int)MAX_INT
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007
#define run using
#define the namespace
#define prog std
 
run the prog;

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef long long int32;
typedef unsigned long long uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
 
template <class T>
    T sqr(T val) {
        return val * val;
    }
 
template<typename T, typename U> 
static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
} 
  
// call by reference is used in x 
template<typename T, typename U> 
static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
} 

/* To find max and min value in array.
for (auto const &val: array) 
  
        // Same as max_val = max (max_val, val) 
        // Same as min_val = min (min_val,val) 
        amax(max_val, val), amin (min_val, val);
//Then in main()
int max_val = 0, min_val = 1e5; 
 */
int32 gcd(int32 a, int32 b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);
} 
void solve() {
    /* Solution code goes here */
    vector<char> res;
    int64 n;
    cin>>n;
    while(n>0)
    {
        int64 rem = n%26;
        if(rem == 0)
        {
            res.pb('Z');
            n = (n/26) - 1;
        }
        else
        {
            res.pb((rem - 1) + 'A');
            n = n/26;
        }
    }
    reverse(res.begin(),res.end());
    for(int64 i=0;i<res.size();i++)
    {
        cout<<char(tolower(res[i]));
    }
}
 
int main() {
    std::ios_base::sync_with_stdio(false);
    int32 TC = 1;
    //cin >> TC;
    
    //cin.ignore();
    while(TC--)
    {
        solve();
    }
}

Measured memory_bytes: 3552
a,b,c,x,y=map(int,input().split())
ans=0
ans+=min(x,y)*min(2*c,a+b)
s=max(0,x-y)
t=max(0,y-x)
ans+=s*min(a,2*c) 
ans+=t*min(b,2*c)
print(ans)


Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

const int N = 2e5+1;

vector<int> segt(4*N+5);

void modify(int idx, int l, int r, int pos, int val){
	if (r < pos or l > pos) return;
	if (l == r){
		segt[idx] = max(segt[idx],val);
		return;
	}
	int mid = (l+r)>>1;
	modify(2*idx,l,mid,pos,val);
	modify(2*idx+1,mid+1,r,pos,val);
	segt[idx] = max(segt[2*idx],segt[2*idx+1]);
}

int query(int idx, int l, int r, int L, int R){
	if (r < L or l > R) return 0;
	if (l >= L and r <= R) return segt[idx];
	int mid = (l+r)>>1;
	return max(query(2*idx,l,mid,L,R),query(2*idx+1,mid+1,r,L,R));
}

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> h(n), a(n);
	for (int i=0; i<n; ++i) cin >> h[i];
	for (int i=0; i<n; ++i) cin >> a[i];
	for (int i=0; i<n; ++i){
		int ans = query(1,0,N-1,0,h[i]-1) + a[i];
		modify(1,0,N-1,h[i],ans);
	}
	cout << segt[1];
	return 0;
}

Measured memory_bytes: 12656
n = gets.to_i
numbers = gets.split.map(&:to_i)

sorted_numbers = numbers.sort

median_large = sorted_numbers[numbers.size / 2]
median_small = sorted_numbers[numbers.size / 2 - 1]

numbers.each do |number|
  puts number >= median_large ? median_small : median_large
end


Measured memory_bytes: 24896
#include<stdio.h>

int main( ){

  int A[100],flag=1,j,N,a,count=0;


  scanf("%d",&N);

  for(j=0;j<N;j++){
    scanf("%d",&A[j]);
  }
  

  while(flag){

    flag=0;

    for(j=1;j<N;j++){

      if(A[j]<A[j-1]){
	a=A[j];
	A[j]=A[j-1];
	A[j-1]=a;

	flag=1;
	count++;
       
      }

    }

  }


  for(j=0;j<N;j++){
    
    if(j==N-1)printf("%d\n",A[j]);
    else  printf("%d ",A[j]);
  }

  printf("%d\n",count);

  
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//#define int long long
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<class T>void println(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int a, b; cin >> a >> b;
    string s; cin >> s;
    rep(i, a + b + 1) {
        if(i == a && s[i] != '-') {
            cout << "No" << endl;
            return 0;
        } else if(i != a && s[i] == '-') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
M=10**9+7;D=[];i=1;r=0;N,K=map(int,input().split())
while i*i<=N:
	if N%i==0:D.append(i);i*i<N and D.append(N//i)
	i+=1
D.sort();N=[]
for i in range(len(D)):
	N.append(pow(K,-~D[i]//2,M))
	for j in range(i):
		if D[i]%D[j]==0:N[i]=(N[i]-N[j])%M
	r=(r+(N[i]*D[i]*pow(2,M-2+D[i]%2,M)))%M
print(r)

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

#define pb push_back

const int N = 100100;

int n, k, ans, par[N];
vector<int> g[N];

int dfs(int v, int p = -1) {
	int res = 0;
	for (int to: g[v]) 
		res = max(res, dfs(to, v));
	if (res == k - 1 && par[v] != 1) {
		ans++;
		return 0;
	}
	return res + 1;
}

int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> par[i];
		if (i != 1) g[par[i]].pb(i);
		else {
			ans += par[i] != 1;
			par[i] = 1;
		}
	}
	dfs(1);
	cout << ans;
}


Measured memory_bytes: 14152
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}



ll dp[21000];
main(){
    int h=in(),a=in();
    cout<<(h+a-1)/a;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a, b;
  scanf("%d %d", &a, &b);
  
  if(a-b > 0){
    printf("%d", a*2-1);
  }else if(a == b){
    printf("%d", a+b);
  }else{
    printf("%d", b*2-1);
  }
  return 0;
}
      

Measured memory_bytes: 128
N = int(input())

A = list(map(int,input().split()))
i = 0
while True:
    A.sort()
    for a in range(len(A)-1):
        if not(A[a] == 0) and A[a+1] % A[a] == 0:
                A[a+1] = A[a+1] % A[a]
        else:
            A[a+1] = A[a+1] - A[a]

    A = [i for i in A if  i > 0]
    if len(A) == 1:
        break

print(A[0])


Measured memory_bytes: 14224
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    int A, B;
    cin >> A >> B;
    if(B%A==0) cout << A+B << endl;
    else cout << B - A << endl;

    return 0;
}

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

using namespace std;
vector<vector<char> > map;
int H, W;

void dfs(int y,int x, char c) {
	int dx[4] = { 0,0,1,-1 };
	int dy[4] = { 1,-1,0,0 };
	map[y][x] = 'x';
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (nx < 0 || W - 1 < nx || ny < 0 || H - 1 < ny)continue;
		if (c == map[ny][nx]) {
			dfs(ny,nx, c);
		}
	}
}

int main() {
	while (1) {
		int count = 0;
		cin >> H >> W;
		if (H + W == 0) break;
		map.resize(H);
		for (int i = 0; i < H; i++) {
			map[i].resize(W);
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cin >> map[i][j];
			}
		}

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (map[i][j] != 'x') {
					dfs(i,j,map[i][j]);
					count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 4204
import sys

input = sys.stdin.readline
N = int(input().strip())

ans = [0] * (N+1)
path = [[] for _ in range(N+1)]

for i in range(N-1):
    u, v, w = map(int, input().strip().split())
    path[u].append((v, w % 2))
    path[v].append((u, w % 2))

is_visit = [False] * (N+1)
search_list = [(1, 0)]

while len(search_list) > 0:
    now, color = search_list.pop()
    ans[now] = color
    is_visit[now] = True

    for node, distance in path[now]:
        if not is_visit[node]:
            search_list.append((node, (distance+color) % 2))
for color in ans[1:]:
    print(color)


Measured memory_bytes: 68272
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define el '\n'
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define repd(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define large 1000000007
#define pb() push_back()
#define MAX 10e+7
int dp[100000];
void solve()
{
int n;
cin>>n;
int arr[n];
rep(i,0,n)
{
    cin>>arr[i];
}
dp[0]=0;
dp[1]=abs(arr[1]-arr[0]);

rep(i,2,n)
{
dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
}
//cout<<dp[1]<<el;
cout<<dp[n-1]<<el;
}
int main()
{
  
 long long int t;
 
  solve();
  
 
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int n,a,q,b;
    int tmp;
    std::deque<int> deq;
    cin >>n;
    for (int i=0;i<n;i++) {
        cin >> a;
        deq.emplace_back(a);
    }
    cin >> q;
    for (int j=0;j<q;j++) {
        cin >> b;
        if (binary_search(deq.begin(),deq.end(),b)) {
            cout << "1" << endl;
        } else {
            cout << "0" << endl;
        }
    }
}



Measured memory_bytes: 3380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;

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

    if(s.at(2) == s.at(3) && s.at(4) == s.at(5))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <sys/stat.h>
using namespace std;
using ll = int64_t;

bool check(char *ss, char*t , int l){
	for(int i=0;i<l;i++){
		if((ss[i]=='?')||(ss[i]==t[i])){continue;}
		return false;
	}
	return true;
}

int main(int , char **)
{
#ifdef LOCAL_DEBUG
	struct stat sb;
	ifstream in("/dev/shm/input.txt");
	if (stat("/dev/shm/input.txt",&sb)==0){ cin.rdbuf(in.rdbuf()); }
#endif

	char SS[55]={};
	char T[55]={};
	cin >> SS >> T;
	size_t ssl = strlen(SS);
	size_t tl = strlen(T);

	int tAd;
	for(tAd=ssl-tl;0<=tAd;--tAd){
		if (true == check(SS+tAd,T,tl) ){break;};
	}
	if (tAd<0){printf("UNRESTORABLE\n");return 0;}

	memcpy(SS+tAd,T,tl);
	for(uint i=0;i<ssl;i++){
		if(SS[i]=='?'){SS[i]='a';}
	}

	printf("%s\n",SS);

	return 0;
}


Measured memory_bytes: 256
N=int(input())
h=list(map(int,input().split()))

a=[0]*100100
a[0]=0
a[1]=abs(h[1]-h[0])
for i in range(N-2):
    a[i+2]=min(a[i+1]+abs(h[i+2]-h[i+1]),
        a[i]+abs(h[i+2]-h[i]))

print(a[N-1])


Measured memory_bytes: 13924
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    int n = stdin.nextInt();
    int m = stdin.nextInt();

    int[][] A = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        A[i][j] = stdin.nextInt();
      }
    }

    int[] b = new int[m];
    for (int i = 0; i < m; i++) {
      b[i] = stdin.nextInt();
    }

    for (int i = 0; i < n; i++) {
      int c = 0;
      for (int j = 0; j < m; j++) {
        c += A[i][j] * b[j];
      }
      System.out.println(c);
    }
  }

}

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

int main (){
  int i,min,max;
  long int sum=0;
  cin >> i;
  int a[i];
  for (int j = 0; j<i; j++){
    cin >> a[j];
  }
  min = a[0];
  max = a[0];
  for (int j = 1; j<i; j++){
    if (min >a[j]){
      min = a[j];

    }
  }
  for (int j = 1; j<i; j++){
    if (max <a[j]){
      max = a[j];

    }
  }
  for (int j = 0; j<i; j++){
    sum+=a[j];
  }
cout << min <<' '<< max <<' '<< sum << endl;
  return 0;
}


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

int main() {

    int a,b;

    cin >> a >> b;

    if(a == b){
        cout << "Draw" << endl;
    }
    else{

        if(a==1){
            a=14;
        }
        if(b==1){
            b=14;
        }

        if(a>b){
            cout << "Alice" << endl;
        }
        else if(a<b){
            cout << "Bob" << endl;
        }


    }

    return 0;
}

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

vector< int > dp(100010);

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

	dp[0] = 0;
	
	for(int i = 1; i <= 100000; i++)
	{
		dp[i] = 100010;
		int power = 1;

		while(power <=i){
			dp[i] = min(dp[i], dp[i-power]+1);
			power *= 6;
		}
		power = 1;
		while(power <=i){
			dp[i] = min(dp[i], dp[i-power]+1);
			power *= 9;
		}
	}
	
	cout << dp[N] << endl;
	
	return 0;

}



Measured memory_bytes: 1148
fun main(args:Array<String>?): Unit {
    val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)
    val number = IntArray(n){it + 1}
    for (i in 0 until m){
        number[readLine()!!.toInt() - 1] = -i
    }
    println(
            number.indices.sortedBy{number[it]}.joinToString("\n"){(it + 1).toString()}
    )
}


Measured memory_bytes: 79004
//code by lynmisakura.wish to be accepted!
/****************************/
#include<bits/stdc++.h>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;
 
const long long INF = 1LL << 55;
 
#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
long long f(long long x){
   ll a1 = (x+6)*(x+5)*(x+4)/6;
   ll a2 = (x+3)*(x+2)*(x+1)*x/24;
   ll m = 35;
   return (a1 * a2) / 35;
}

int main(void){
   long long k;cin >> k;
   vector<ll> c(605);
   // cout << f(1) << endl;
   for(ll i = 605;i >= 1;i--){
      c[i - 1] = k / f(i);
      k %= f(i);
   }
   
   ll count = 0;
   for(ll i = 0;i < 605;i++){
      cout << "FESTIVA";
      for(int j = 0;j < c[i];j++)cout << "L";
      //count += 6 + c[i];
   }
   //cout << count << endl;
   printf("\n");
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

long m;

vector<int> g[100005];
long val[100005];
long ans[100005];

void dfs1(int v, int from = -1){
  val[v] = 1;
  for(auto to : g[v]) if(to != from) {
    dfs1(to, v);
    val[v] *= val[to];
    val[v] %= m;
  }
  val[v] += 1;
}

void dfs2(int v, int from = -1, long pre = 1){
  ans[v] = pre * (val[v] - 1 + m) % m;
dbg(v,from,pre,val[v]);
  vector<int> tos;
  for(auto to : g[v]) if(to != from) tos.pb(to);

  int ts = tos.size();
  vector<long> ml(tos.size() + 1, 1), mr(tos.size() + 1, 1);
  rep(i,ts) ml[i+1] = (ml[i] * val[tos[i]]) % m;
  for(int i=ts-1; i>=0; i--) mr[i] = (mr[i+1] * val[tos[i]]) % m;

  rep(i,ts){
    dfs2(tos[i], v, (pre * ml[i]) % m * mr[i+1] % m + 1);
  }
}


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

  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
  }

  dfs1(0);
  dfs2(0);

  rep(i,n) cout << ans[i]%m << "\n";

  return 0;
}


Measured memory_bytes: 22912
""" AtCoder """

O = input()
E = input()

ans = ''
o_len = len(O)
e_len = len(E)
tmp_len = min(o_len, e_len)

for i in range(tmp_len):
    ans += O[i]
    ans += E[i]
if abs(o_len - e_len) == 1:
    ans += O[-1]

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

int main(){
	int H,W,h,w;
	cin>>H>>W>>h>>w;
	cout<<H*W-h*W-H*w+h*w;
	return 0;
	}

Measured memory_bytes: 384
# 2019-11-17 20:44:23(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n = int(sys.stdin.readline().rstrip())
    ans = (1 + (n - 1)) * (n - 1) // 2
    print(ans)
if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    long long ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans += arr[i] * arr[j];
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
    char arr[25];
    int i,n;
    gets(arr);
    n=strlen(arr);
    for(i=0;i<n;i++){
        if(arr[i]==',') arr[i]=' ';
    }
    printf("%s\n",arr);
    return 0;
}


Measured memory_bytes: 128
h, w, a, b = map(int, input().split())
mod = 10 ** 9 + 7

ans = 0
for i in range(1, h-a+1):
    if i == 1:
        t1 = 1
        t2 = 1
        for j in range(1, ((h-a-i)+(b-1)+1)):
            t1 *= j
            t1 %= mod
        for j in range(1, ((b-1)+1)):
            t2 *= j
            t2 %= mod
        for j in range(1, ((h-a-i)+1)):
            t2 *= j
            t2 %= mod
        a1 = t1 * pow(t2, mod-2, mod) % mod

        t1 = 1
        t2 = 1
        for j in range(1, ((w-b-1)+(a+i-1)+1)):
            t1 *= j
            t1 %= mod
        for j in range(1, ((w-b-1)+1)):
            t2 *= j
            t2 %= mod
        for j in range(1, ((a+i-1)+1)):
            t2 *= j
            t2 %= mod
        a2 = t1 * pow(t2, mod-2, mod) % mod
    else:
        a1 *= pow((h-a-i)+(b-1)+1, mod-2, mod) 
        a1 *= h-a-i+1
        a1 %= mod 
        a2 *=  (w-b-1)+(a+i-1) 
        a2 %= mod
        a2 *= pow(a+i-1, mod-2, mod) 
        a2 %= mod
 
    #print(a1, a2)
    ans += a1 * a2 
    ans %= mod

print(ans)



Measured memory_bytes: 3064
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let mut x: u64 = read();
    let y: u64 = read();
    let mut ans = 0;

    while y >= x {
        x *= 2;
        ans += 1;
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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


int main(void) {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int ans = 1;
  int i = k;
  while (i < n) {
    i += (k - 1);
    ans++;
  }

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

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

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

    vector<ll> A;
    rep(i, 9)
        A.push_back(i + 1);

    int now = 0, sz = 0;
    while (sz < K) {
        if (A[sz] % 10 == 0) {
            A.push_back(A[sz] * 10);
            A.push_back(A[sz] * 10 + 1);
        }
        else if (A[sz] % 10 == 9) {
            A.push_back(A[sz] * 10 + 8);
            A.push_back(A[sz] * 10 + 9);
        } else {
            A.push_back(A[sz] * 10 + A[sz] % 10 - 1);
            A.push_back(A[sz] * 10 + A[sz] % 10);
            A.push_back(A[sz] * 10 + A[sz] % 10 + 1);
        }
        ++sz;
    }
    cout << A[K - 1] << endl;

    return 0;
}

Measured memory_bytes: 6512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>


using namespace std;

int main(){

	int N, H, W;

	cin >> N >> H >> W;

	int Hd = N-H+1;
	int Wd = N-W+1;

	cout << Hd*Wd << endl;

	return 0;
}


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

using namespace std;

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

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    int X,t;
    cin>>X>>t;
    if(X-t>0)cout<<X-t<<endl;
    else cout<<0<<endl;

    return 0;
}

//a=97,z=122

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

int N, M;
vector<bool> AC;
vector<int> WA;

void input_init(void) {
	cin >> N >> M;
	AC.resize(N + 1, false);
	WA.resize(N + 1, 0);
}

void solve(void) {
	for (int i = 0; i < M; ++i) {
		int p;
		string s;
		cin >> p >> s;
		if (s == "AC")
			AC[p] = true;
		else {
			if (!AC[p])
				++WA[p];
		}
	}
}

int main(void) {
	input_init();
	solve();
	int ac_cnt = 0;
	int wa_cnt = 0;
	for (int i = 1; i <= N; ++i) {
		if (AC[i]) {
			++ac_cnt;
			wa_cnt += WA[i];
		}
	}
	cout << ac_cnt << ' ' << wa_cnt << '\n';
	return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline

def f(x):
    res = []
    flag = False
    tank = []
    for i in range(len(x)):
        if x[i] == 0 and x[i+1] > 0:
            flag = True
        elif x[i] == 0:
            res.append(0)
        elif x[i] > 0:
            tank.append(x[i])
        elif x[i] == -1 and flag:
            tank.sort()
            res.append(sum(tank[:len(tank)//2+1]))
            flag = False
            tank = []
        else:
            res.append(-1)
    return res


testnum = int(input())
for testcase in range(testnum):
    ss = list(input())
    s = []
    tmp,p = 0,0
    for i in range(len(ss)-2,-1,-1):
        if ss[i] == "]":
            s.append(-1)
        elif ss[i] == "[":
            s.append(0)
        else:
            tmp += int(ss[i])*pow(10,p)
            p += 1
            if ss[i-1] == "[":
                s.append(tmp//2+1)
                tmp,p = 0,0
    s = s[::-1]
    while len(s) > 1:
        s = f(s)
    print(s[0])


Measured memory_bytes: 5872
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
const long double PI = 3.14159255358979323846264338327950288l;
struct Point { long double px, py; };
long double theta(long double a, long double b, long double c) {
	long double s = (a + b + c) / 2.0l;
	long double S = sqrtl(s*(s - a)*(s - b)*(s - c));
	long double A = -1000, B = -1000, C = -1000, H;

	if (a > b && a > c) { H = 2.0l * S / a; B = asin(H / c)*180.0l / PI; C = asin(H / b)*180.0l / PI; A = 180.0l - B - C; }
	else if (b > a && b > c) { H = 2.0l * S / b; A = asin(H / c)*180.0l / PI; C = asin(H / a)*180.0l / PI; B = 180.0l - A - C; }
	else { H = 2.0l * S / c; A = asin(H / b)*180.0l / PI; B = asin(H / a)*180.0l / PI; C = 180.0l - A - B; }

	return A;
}
long double theta_(Point a, Point b, Point c) {
	//a->b->c
	long double A1 = sqrtl((a.px - c.px)*(a.px - c.px) + (a.py - c.py)*(a.py - c.py));
	long double B1 = sqrtl((a.px - b.px)*(a.px - b.px) + (a.py - b.py)*(a.py - b.py));
	long double C1 = sqrtl((b.px - c.px)*(b.px - c.px) + (b.py - c.py)*(b.py - c.py));
	return theta(A1, B1, C1);
}
long double dp[22][22], prev_[22][22], r, t, theta__[22][22][22], dist_[22][22]; Point x[30]; int n;
int main() {
	cin >> n >> r >> t;
	for (int i = 0; i < n; i++)cin >> x[i].px >> x[i].py;
	for (int i = 0; i < 22; i++) { for (int j = 0; j < 22; j++) { dp[i][j] = 999999999.9l; prev_[i][j] = 999999999.9l; } }
	for (int i = 0; i < n; i++) { if (i != 0) { prev_[0][i] = sqrtl((x[0].px - x[i].px)*(x[0].px - x[i].px) + (x[0].py - x[i].py)*(x[0].py - x[i].py)); } }
	for (int i = 0; i < 22; i++) { for (int j = 0; j < 22; j++) { for (int k = 0; k < 22; k++) { theta__[i][j][k] = 180.0l - theta_(x[i], x[j], x[k]); } } }
	for (int i = 0; i < 22; i++) { for (int j = 0; j < 22; j++) { dist_[i][j] = sqrtl((x[i].px - x[j].px)*(x[i].px - x[j].px) + (x[i].py - x[j].py)*(x[i].py - x[j].py)); } }
	int maxn = 0;
	for (int i = 1; i < 100000; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				for (int l = 0; l < n; l++) {
					if (j == k || k == l || theta__[j][k][l] > t)continue;
					dp[k][l] = min(dp[k][l], prev_[j][k] + dist_[k][l]);
				}
			}
		}
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				if (prev_[j][k] < r)maxn = i;
				prev_[j][k] = dp[j][k]; dp[j][k] = 999999999.9l;
			}
		}
		if (maxn != i)break;
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 3668
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int A,B,cnt,d[11][11];
bool b[11][11];
struct edge{
	int s,t,w;
	edge():s(0),t(0),w(0){}
	edge(int s,int t,int w):s(s),t(t),w(w){}
}es[40005];
inline int read(){
	int x=0,f=1;char c=getchar();
	for(;c<'0'||c>'9';f=c=='-'?-1:1,c=getchar());
	for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c=getchar());
	return x*f;
}
int main(){
	A=read();B=read();
	for(int i=1;i<=A;i++)
		for(int j=1;j<=B;j++)
			d[i][j]=read();
	for(int i=0;i<=100;i++)
		for(int j=0;j<=100;j++){
			int maxw=0;
			for(int k=1;k<=A;k++)
				for(int l=1;l<=B;l++)
					maxw=max(maxw,d[k][l]-k*i-l*j);
			es[++cnt]=edge(i+1,202-j,maxw);
			for(int k=1;k<=A;k++)
				for(int l=1;l<=B;l++)
					if(d[k][l]==k*i+l*j+maxw)b[k][l]=1;
		}
	for(int i=1;i<=A;i++)
		for(int j=1;j<=B;j++)
			if(!b[i][j])return 0*puts("Impossible");
	printf("Possible\n202 %d\n",cnt+200);
	for(int i=1;i<=100;i++)printf("%d %d X\n%d %d Y\n",i,i+1,i+101,i+102);
	for(int i=1;i<=cnt;i++)printf("%d %d %d\n",es[i].s,es[i].t,es[i].w);
	puts("1 202");
	return 0;
}

Measured memory_bytes: 768
import math

N = int(input())

dp = [[-1] * 10 for _ in range(10)]
temp = 0
total = 0

mae_usiro = [[-1] * 2 for _ in range(N+1)]
for i in range(1, N+1):
    mae = int(i / 10 ** int(math.log10(i)))
    usiro = i % 10
    mae_usiro[i] = [mae, usiro]

for i in range(1, N+1):
    mae, usiro = mae_usiro[i]
    if i > 100:
        total += dp[mae][usiro]
    elif dp[mae][usiro] != -1:
        total += dp[mae][usiro]
    else:
        count = 0
        for j in range(1, N+1):
            mae2, usiro2 = mae_usiro[j]
            if mae == usiro2 and usiro == mae2:
                count += 1
        dp[mae][usiro] = count
        total += count
    
print(total)

Measured memory_bytes: 76140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  string a, b, c;
  cin >> a >> b >> c;

  cout << "A";
  cout << b[0];
  cout << "C";
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
n=gets.to_i
q=[1,2,3,4,5,6,7,8,9]
tmp=nil

n.times do |i|
    tmp=q.shift
    q.push(tmp*10+tmp%10-1) if tmp%10!=0
    q.push(tmp*10+tmp%10) 
    q.push(tmp*10+tmp%10+1) if tmp%10!=9
end

p tmp

Measured memory_bytes: 3964
#!/usr/bin/env python3
def main():
    from collections import deque
        
    N, X, Y = map(int, input().split())

    G = [[1]] + [[x - 1, x + 1] for x in range(1, N - 1)] + [[N - 2]]
    G[X - 1].append(Y - 1)
    G[Y - 1].append(X - 1)

    dist = [[-1] * N for _ in [0] * N]
    for start in range(N):
        q = deque([start])
        dist[start][start] = 0
        while q:
            now = q.popleft()
            for next in G[now]:
                if dist[start][next] == -1:
                    dist[start][next] = dist[start][now] + 1
                    q.append(next)
    res = [0] * N
    for i in range(N):
        for j in range(i + 1, N):
            res[dist[i][j]] += 1
    for d in range(1, N):
        print(res[d])


if __name__ == '__main__':
    main()


Measured memory_bytes: 106992
n = gets.to_i
permutation = gets.split(' ').map(&:to_i)
count = 0

(1..(n-2)).each do |idx|
  if (permutation[idx - 1] < permutation[idx] && permutation[idx] < permutation[idx + 1]) || (permutation[idx - 1] > permutation[idx] && permutation[idx] > permutation[idx + 1])
    count += 1
  end
end

puts count

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

int main(){
  int s[100010]={},a,N;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>a;
    s[a+1]+=1;
    s[a+2]+=1;
    s[a]+=1;
  }
  int mx=0;
  for(int i=0;i<=100002;i++){
    if(s[i]>mx){
      mx=s[i];
    }
  }
  cout<<mx<<endl;
  return 0;
}


Measured memory_bytes: 640
/*
 * d.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int INF = 1 << 30;

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

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

  int mina = INF, maxa = -INF;
  ll sum = 0;

  for (int i = 0; i < n; i++) {
    int ai;
    cin >> ai;

    if (mina > ai) mina = ai;
    if (maxa < ai) maxa = ai;
    sum += ai;
  }

  printf("%d %d %lld\n", mina, maxa, sum);
  return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#define popcount __builtin_popcount

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N,K;
  while(cin >> N >> K){
    double ans = 0;

    FORE(i,1,N){
      if(i >= K){
	ans += 1.0/N;
      }else{
	int x = 0;

	int j=i;
	while(j<K){
	  j *= 2;
	  ++x;
	}

	dump(x);

	ans += pow(0.5, x) / N;
      }
    }

    cout << setprecision(12) << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){

    set<int> b;
    int a;
    cin >> a;
    b.insert(a);
    cin >> a;
    b.insert(a);
    cin >> a;
    b.insert(a);
    /*
    if(c7 == 1 && c5 == 2 ){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    */
    
    cout << b.size() << endl;

    return 0; 
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;

void show(lld n) {
  if (n > 26) {
    show((n - 1) / 26);
    n = (n - 1) % 26 + 1;
  }
  cout << (char)('a' + n - 1);
}

int main(void) {
  lld n;
  cin >> n;
  show(n);
  cout << "\n";
}

Measured memory_bytes: 3632