akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  string str;
  cin >> str;
  for (int i = 0; i < 3; i++) {
    if (str[i] == '1') {
      str[i] = '9';
    } else {
      str[i] = '1';
    }
  }
  cout << str << endl;
 
  return 0;
}

Measured memory_bytes: 256
n,m = [int(i) for i in input().split()]
graph = [0 for _ in range(n)]

for i in range(m):
    ai,bi = [int(i) for i in input().split()]
    graph[ai-1] += 1
    graph[bi-1] += 1
    
for i in range(n):
    print(graph[i])

Measured memory_bytes: 3060
# お気に入りの数である条件
# N = am + bとおくと、a=b ∴ > N = a(m+1)
# ただし、a=b<m
# よってaはNの約数でなければならず、N>0よりa>0、a>0よりN / a = m + 1 
# 整理して m = N / a - 1.

N = int(input())
answer = 0

for i in range(1, int(N**0.5)+1):
    if N % i == 0:
        m = N // i - 1
        if m > i:
            answer += m 
        if i != N // i:
            m = N // (N // i) - 1 
            if m > i:
                answer += m

print(answer)

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

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

const int INF = 1000000007;

int main(void){
	int n,k;
	cin>>n>>k;

	ll ans=0;
	ll exp=1;
	for(int i=0;i<n-1;i++){
		exp *= (k - 1);
	}
	ans = k * exp;

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch SumOfInteriorAngles | diff SumOfInteriorAngles.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address SumOfInteriorAngles.cpp && ./a.out

/*
 
 6/1/2019
 
 5:00-
 
 */

int N;

void solve() {
  LL res=180LL*(N-2);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  solve();
  
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    int count=0;
    string str;
    cin >> str;
    for(int i=0; i<n-1; i++){
        if(str.at(i) == str.at(i+1)){
            count++;
        }
    }
    cout << n-count << endl;
}

Measured memory_bytes: 512
#include <iostream>

#include <vector>

#include <cassert>

#include <algorithm>

#include <functional>

#include <cmath>

#include <iomanip>

#include <limits>
#include <bits/stdc++.h>
#include<queue>
#include<type_traits>
#include<cstdint>
using namespace std;
using ll=long long;
ll LCM(ll a,ll b){
    if(a==0){
        return b;
    }else if(b==0){
        return a;
    }
    if(a>b){
         return LCM(a%b,b);
    }else if(b>a){
         return LCM(b%a,a);
    }else {
        return a;
    }
}
int main(){
   ll a,b,c,d;
   cin >> a >> b >> c >> d;
   ll c_pre = (a-1)/c;
   ll d_pre = (a-1)/d;
   ll c_end= b/c;
   ll d_end = b/d;
   ll lcm = c*d/LCM(c,d);
 //  cout << lcm << endl;
   ll cd_pre =(a-1)/lcm;
   ll cd_end =b/lcm;
   ll ans=(c_end-c_pre)+(d_end-d_pre)-(cd_end-cd_pre);
/*   cout <<c_end-c_pre<<endl;
   cout <<d_end-d_pre << endl;
   cout <<cd_end-cd_pre<<endl;
   cout <<ans << endl;*/
   cout << b-a+1-ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll dp[MAX_N][3];

void solve() {
	cin >> N;
	rep(i, 0, N + 1) {
		rep(j, 0, 3) {
			dp[i][j] = -linf;
		}
	}
	rep(j, 0, 3) dp[0][j] = 0;

	rep(i, 0, N) {
		ll a, b, c; cin >> a >> b >> c;
		rep(j, 0, 3) {
			if(j != 0) MAX(dp[i + 1][0], dp[i][j] + a);
			if(j != 1) MAX(dp[i + 1][1], dp[i][j] + b);
			if(j != 2) MAX(dp[i + 1][2], dp[i][j] + c);
		}
	}
	ll res = -linf;
	rep(i, 0, 3) MAX(res, dp[N][i]);
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 4352
#include<stdio.h>
#include<algorithm>
#define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
#define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

using namespace std;
int L[1010000];
int R[1010000];
long long dp[1010000];
int sz[1010000];
long long sum[1010000];
int n;
void calc(int a,int b){
	if(~L[a]){
		calc(L[a],b+1);
		sz[a]+=sz[L[a]];
		sum[a]+=sz[L[a]]+sum[L[a]];
	}
	if(~R[a]){
		calc(R[a],b+1);
		sz[a]+=sz[R[a]];
		sum[a]+=sz[R[a]]+sum[R[a]];
	}
	if(L[a]==-1&&R[a]==-1){
		sz[a]=1;
		dp[a]=0;
		return;
	}
	dp[a]=min(dp[L[a]]+dp[R[a]]+b+2,min(dp[L[a]]+sum[R[a]]+sz[R[a]]+1,dp[R[a]]+sum[L[a]]+sz[L[a]]+1));
//	printf("%d: %lld %lld %d\n",a,dp[a],sum[a],sz[a]);
}
int main(){
	BEGIN_STACK_EXTEND(60*1024*1024)
	int a;
	scanf("%d",&a);
	for(int i=0;i<1010000;i++)L[i]=R[i]=-1;
	n=a;
	for(int i=0;i<a-1;i++){
		scanf("%d%d",L+i,R+i);
		L[i]--;R[i]--;
		if(L[i]==a-1)L[i]=n++;
		if(R[i]==a-1)R[i]=n++;
	}
	calc(0,0);
	printf("%lld\n",dp[0]);
	END_STACK_EXTEND
}

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

int main() {
	int n;
	double ans = 0;
	cin >> n;
	vector<int> jun(n);
	rep(i,n) jun[i] = i;
	vector <double> x(n), y(n);
	rep(i,n) cin >> x[i] >> y[i];
	int k = 1;
	rep(i,n) k *= i + 1;
	do {
		rep(i,n-1) {
			double sq = 0;
			sq += pow((x[jun[i]] - x[jun[i+1]]), 2);
			sq += pow((y[jun[i]] - y[jun[i+1]]), 2);
			ans += sqrt(sq);
		}
	} while (next_permutation(jun.begin(), jun.end()));
	ans /= (double)k;
	printf("%.7lf\n", ans);
	return 0;
}

Measured memory_bytes: 3808
t=[0]*4
while 1:
    try:
        l=sorted(map(int,raw_input().split()))
        if l[2]>=l[1]+l[0]: break
        t[0]+=1
        r=l[2]**2-(l[1]**2+l[0]**2)
        if r>0: t[3]+=1
        elif r<0: t[2]+=1
        else: t[1]+=1
    except EOFError:
        break;
print " ".join(map(str,t))

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

int main()
{
	long long Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;

	if (2 * Q < H)H = 2 * Q;
	if (2 * H < S)S = 2 * H;
	if (2 * S < D)D = 2 * S;

	long long ans = 0;

	ans += (N / 2) * D;
	N %= 2;
	ans += N * S;

	cout << ans << endl;

    return 0;
}



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

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    double ans=1.0*(max(0,n-k+1))/n;
    for(int i=1;i<min(n+1,k);i++){
        int r = ceilf(log2(1.0*k/i));
        ans+=1.0/(1.0*n*pow(2,r));
    }
    cout << setprecision(9) << fixed << ans << endl;
    return 0;
}


Measured memory_bytes: 512
import itertools
n, m, q = [int(a) for a in input().split()]
a = []
b = []
c = []
d = []
for i in range(q):
    a_,b_,c_,d_ = [int(a) for a in input().split()]
    a.append(a_-1)
    b.append(b_-1)
    c.append(c_)
    d.append(d_)
ans = 0

for A in itertools.combinations_with_replacement(range(m), n):
    ans_ = 0
    for i in range(q):
        if A[b[i]] - A[a[i]] == c[i]:
            ans_ += d[i]
    if ans_ > ans:
        ans = ans_

print(ans)


Measured memory_bytes: 9224
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	for (ll i = 0; i < n; i++) {
		if (a[i] % 2 == 0 && (a[i] % 3 != 0 && a[i] % 5 != 0))return cout << "DENIED" << endl,0;
	}
	cout <<  "APPROVED" << endl;
}


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

const int maxn = 2e5 + 5;
ll pw[2*maxn];
const int mod = 1e9 + 7;

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

    pw[0] = 1;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        pw[i] = (2*pw[i - 1]) % mod;
    }

    int c[maxn];
    for (int i = 1; i <= n; i++) {
        cin >> c[i];
    }
    sort(c + 1, c + n + 1);
    reverse(c + 1, c + n + 1);
    ll ans = (c[1]*pw[n - 1]) % mod;
    for (int j = 2; j <= n; j++) {
        ans += c[j] * ((pw[n - j] * ((pw[j - 2] * (j + 1)) % mod)) % mod);
        ans %= mod;
    }
    cout << (pw[n]*ans) % mod << '\n';

    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000000000000LL
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int T;
ll a,b,c,d;
ll n,ans;
map<ll,ll> mp; 
ll solve(ll x)
{
    if(x==0) return 0;
    if(x==1) return d;
    if(mp.find(x)!=mp.end()) return mp[x];
    ll res=INF;
    if(INF/x>d) res=d*x;
    res=min(res,solve(x/2)+d*(x%2)+a);
    res=min(res,solve((x+1)/2)+d*(2-x%2)+a);
    res=min(res,solve(x/3)+d*(x%3)+b);
    res=min(res,solve((x+2)/3)+d*(3-x%3)+b);
    res=min(res,solve(x/5)+d*(x%5)+c);
    res=min(res,solve((x+4)/5)+d*(5-x%5)+c);
    return mp[x]=res;
}
int main()
{
    scanf("%d",&T);
    while(T--)
    {
        mp.clear();
        scanf("%lld",&n);
        scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
        printf("%lld\n",solve(n));
    }
    return 0;
}

Measured memory_bytes: 4520
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

const int N=1000005;
int f[N],pa[N],n,m,a,b;
vector<pii> ans;
map<pii,int> E;
vi e[N];

inline int getpa(int x){
	return pa[x]==x?x:pa[x]=getpa(pa[x]);
}

void dfs(int u,int fa){
	for(auto v:e[u])
		if(v!=fa){
			dfs(v,u);
			if(f[v]){
				f[u]^=1;
				f[v]^=1;
				if(E[mp(u,v)])ans.pb(mp(v,u));
				else ans.pb(mp(u,v));
			}
			else{
				if(E[mp(u,v)])ans.pb(mp(u,v));
				else ans.pb(mp(v,u));
			}
		}
}

int main(){
	cin>>n>>m;
	rep(i,1,n)pa[i]=i;
	rep(i,1,m){
		cin>>a>>b;
		E[mp(a,b)]=1;
		if(getpa(a)==getpa(b)){
			f[a]^=1;
			ans.pb(mp(a,b));
		}
		else{
			f[a]^=1;
			e[a].pb(b);
			e[b].pb(a);
			pa[getpa(a)]=getpa(b);
		}
	}
	dfs(1,0);
	if(f[1])return puts("-1"),0;
	for(auto x:ans)
		printf("%d %d\n",x.fi,x.se);
	return 0;
}

Measured memory_bytes: 50548
import math
n=int(input())
for i in range(n):
    x1,y1,x2,y2,x3,y3=[float(i) for i in input().split()]
    A=math.hypot(x2-x3,y2-y3)**2
    B=math.hypot(x1-x3,y1-y3)**2
    C=math.hypot(x1-x2,y1-y2)**2
    t1=A*(B+C-A)
    t2=B*(A+C-B)
    t3=C*(A+B-C)
    px=(t1*x1+t2*x2+t3*x3)/(t1+t2+t3)
    py=(t1*y1+t2*y2+t3*y3)/(t1+t2+t3)
    r=math.hypot(px-x1,py-y1)
    print("%.3f %.3f %.3f"%(round(px,3),round(py,3),round(r,3)))


Measured memory_bytes: 5688
k, n = list(map(int, input().split()))
arry = list(map(int, input().split()))
t_arry = []
for i in range(0,len(arry)-1):
    t_arry.append(arry[i+1]-arry[i])
# 始点と終点の距離
dist = arry[0] + k - arry[len(arry)-1]
t_arry.append(dist)

print(sum(t_arry) - max(t_arry))

Measured memory_bytes: 26444
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll n;
	cin >> n;
	string s;
	cin >> s;
	Vec r, g;
	set<ll> b;
	rep(i, s.size()){
		if(s[i] == 'R') r.pb(i);
		else if(s[i] == 'G') g.pb(i);
		else b.insert(i);
	}

	ll ans = 0;
	for(ll i : r){
		for(ll j : g){
			ll cnt = 0;
			if(b.find(2 * i - j) != b.end()) cnt++;
			if(b.find(2 * j - i) != b.end()) cnt++;
			if(i % 2 == j % 2 && b.find((i + j) / 2) != b.end()) cnt++;
			ans += b.size() - cnt;
		}
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 3652
/**
 * Heaps - Maximum Heap
 */

#include <iostream>

using namespace std;

int H, A[500001];

void heapfy(int *a, int i) {

    int l, r;
    l = i * 2;
    r = i * 2 + 1;

    int i_ = i;

    if (l <= H && a[l] > a[i_]) i_ = l;
    if (r <= H && a[r] > a[i_]) i_ = r;

    if (i_ != i) {
        int tmp = a[i];
        a[i] = a[i_];
        a[i_] = tmp;
        heapfy(a, i_);
    }
}

int main() {

    cin >> H;

    for (int i = 1; i <= H; i++) {
        cin >> A[i];
    }

    for (int i = H / 2; i >= 1; i--) {
        heapfy(A, i);
    }

    for (int i = 1; i <= H; i++) {
        cout << " " << A[i];
    }
    cout << endl;
}


Measured memory_bytes: 5036
#include <iostream>
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <numeric>
#include <vector>
#include <cmath>
using namespace std;


int main(){
   int x, y, z;
   cin >> x >> y >> z;

   int temp = x;
   x = y;
   y = temp;
   int temp1 = x;
   x = z;
   z = temp1;
   cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
bool CAN=true;
using namespace std;

int main(){
  ll N,X;
  cin>>N>>X;
  
  if(X==1 || X==2*N-1) CONo;
  else{
    COYe;
    for(ll i=1; i<=2*N-1; ++i){
      ll ans=i+X-N;
      while(ans<=0) ans+=2*N-1;
      while(ans>=2*N) ans-=2*N-1;
      cout<<ans<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1536
fun main(args : Array<String>) {
    val input = listOf(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
    val k = readLine()!!.toInt()

    println(input[k-1])
}

Measured memory_bytes: 31940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] S = new long[n];

		for(int i = 0; i < n; i++) {
			S[i] = sc.nextLong();
		}

		int q = sc.nextInt();
		int count = 0;

		for(int j = 0; j < q; j++) {
			long T = sc.nextLong();
			for(int i = 0; i < n; i++) {
				if(T == S[i]) {
					count++;
					break;
				}
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 40340
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <valarray>
#include <utility>
#include <set>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<=(int)(n);i++)
#define INF 500000000  //
#define INFLL 1000000000000000000  //
#define MOD (1e9)+7

typedef long long int ll;

// a 0x61  z 0x7a  0 0x30


//------------------------------------------------------

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

    int a[n] = {};
    rep(i, n) cin >> a[i];

    sort(a, a + n);

    int A = 0;
    int B = 0;

    if (n % 2 == 1) {
        for (int i = 0; i < n - 2; i += 2) {
            A += a[i];
            B += a[i + 1];
        }
        A += a[n - 1];
    } else {
        for (int i = 0; i < n; i += 2) {
            B += a[i];
            A += a[i + 1];
        }
    }

    cout << A - B << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;




int main(){
	string str = "abcdefghijklmnopqrstuvwxyz";
	int n;
	cin >> n;

	int data[50][26];

	rep(i, 0, 50)rep(j, 0, 26)data[i][j] = 0;


	char ch[51];
	rep(i, 0, n) {
		scanf("%s", ch);
		rep(j, 0, strlen(ch)) {
			data[i][ch[j]-'a']++;
		}
	}

	rep(j, 0, 26) {
		vector<int> v;
		rep(i, 0, n) {
			v.push_back(data[i][j]);
		}
		sort(v.begin(), v.end());
		rep(k,0,v[0]) {
			cout << str[j];
		}
	}
	cout << endl;




	return 0;
}



Measured memory_bytes: 256
n = int(input())

a = [int(x) for x in input().split()]

mx = max(a)

mark = [0 for _ in range(mx+1)]

for i in range(n):
	for x in range(a[i], mx+1, a[i]):
		mark[x] += 1

ans = 0

for i in range(n):
	if mark[a[i]] == 1:
		ans += 1

print(ans)

Measured memory_bytes: 32196
#include <stdio.h>

int main(int argc, const char * argv[])
{

    int input;
    int cnt = 0;
    int idx = 0;
    int prime[1000000] = {0};
    int i, j;
    
    while (scanf("%d", &input) != EOF) {
        prime[1] = 1;
        for (i = 2; i <= input; i++) {
            for (j = 2; j * i <= input; j++) {
                    //printf("%d\n", i * j);
                idx = i * j;
                prime[idx]++;
            }
        }
        for (i = 1; i <= input; i++) {
            if (prime[i] == 0) {
                //printf("%d\n", i);
                cnt++;
            }
        }
        printf("%d\n", cnt);
        cnt = 0;
    }
    return 0;
}

Measured memory_bytes: 4512
#include <bits/stdc++.h>
#define tam 100010

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <vii> graph;

bool comp(int a, int b) {
	return a > b;
}

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

	string s;
	cin >> s;
	int n = s.size();
	int cont = 0;
	int mayor = -1;
	for (int i = 0; i < n; ++i)
	{
		if (s[i] == 'A' || s[i] == 'G' || s[i] == 'T' || s[i] == 'C') cont++;
		else {
			mayor = max(cont, mayor);
			cont = 0;
		}
	}
	mayor = max(mayor, cont);
	cout << mayor << "\n";
	return 0;
}


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

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;

int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

const ll INF = 1e9;
/////////////////////////////////////////////////////////////////////////////////////////

int main(){
    string s,t;
    cin >> s >> t;
    vector<vector<int>> dp(3010,vector<int>(3010));

    for (int i = 0;i < s.size();i++){
        for (int j = 0;j < t.size();j++){
            if (s[i] == t[j]){
                dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j] + 1);
            }
            dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j+1]);
            dp[i+1][j+1] = max(dp[i+1][j],dp[i+1][j+1]);
        }
    }

    string ans;
    int i = s.size(),j = t.size();

    while(i > 0 && j > 0){
        if (dp[i][j] == dp[i-1][j]) i--;
        else if (dp[i][j] == dp[i][j-1])j--;
        else {
            ans = s[i-1] + ans;
            i--;
            j--;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 35712
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
x = gets.chomp.to_i

result = 0
sum = 0

(a + 1).times do |i|
  (b + 1).times do |j|
    (c + 1).times do |k|
      sum = 500 * i + 100 * j + 50 * k
      result += 1 if sum == x
    end
  end
end

puts result

Measured memory_bytes: 1788
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int i, j, n, v;
  int A[100];

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

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

  for(i = 1; i < n; i++) {
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;

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

  return 0;
}


Measured memory_bytes: 1900
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950

int main() {
	int N; std::cin >> N;
	int ans = 0;
	int sum = -1;
	for (int x = 1; x <= N; ++x) {
		int count = 0;
		int i = x;
		while (i % 2 == 0) {
			i = i / 2;
			++count;
		}
		if (count > sum) {
			sum = count;
			ans = x;
		}
	}
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 3540
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int p = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(n==0 && m==0 && p==0 && a==0 && b==0) break;
			
			int[] t = new int[n];
			for(int i=0;i<n;i++) t[i] = sc.nextInt();
			
			int[][] d = new int[m+1][m+1];
			for(int i=0;i<=m;i++) Arrays.fill(d[i], Integer.MAX_VALUE);
			
			for(int i=0;i<p;i++){
				int x = sc.nextInt();
				int y = sc.nextInt();
				int z = sc.nextInt();
				d[x][y] = d[y][x] = z;
			}
			
			double[][] dp = new double[1<<n][m+1];
			for(int i=0;i<1<<n;i++) Arrays.fill(dp[i], Integer.MAX_VALUE);
			dp[(1<<n)-1][a] = 0;
			
			
			for(int s=(1<<n)-1;s>=0;s--){
				for(int v=1;v<=m;v++){
					for(int i=0;i<n;i++){
						if((s>>i&1)==1){
							for(int u=1;u<=m;u++){
								if(d[v][u]>=0){
									dp[s&~(1<<i)][u] = Math.min(dp[s&~(1<<i)][u], dp[s][v] + (double)d[v][u]/t[i]);
								}
							}
						}
					}
				}
			}
			
			double res = Integer.MAX_VALUE;
			for(int i=0;i<(1<<n)-1;i++) res = Math.min(res, dp[i][b]);
			
			if(res>10000) System.out.println("Impossible");
			else System.out.printf("%.3f\n", res);
		}	
	}	
}

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

int main(){
	int N;
	scanf("%d", &N);

	char map[100][100+1];
	memset(map, 0, sizeof(map));

	int tmp;
	for (int i = 1; i < N + 1; i++) {
		scanf("%d", &tmp);
		for (int j = 0; j < 100; j++) {
			map[j][i] = (j < tmp) ? 1 : 0;
		}
	}

	int count = 0;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < N; j++) {
			if (map[i][j] == 0 && map[i][j + 1] == 1) count++;
		}
	}

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

	return 0;
}


Measured memory_bytes: 128
import numpy as np
N, M = input().split(' ')
lis = np.array([int(n) for n in input().split(' ')])
#print("{} {}".format(sum(lis) / 4 / int(M), lis[int(M)-1]))

count = sum(sum(lis) / 4.0 / int(M) <= lis)

if count >= int(M):
	print("Yes")
else:
 	print("No")

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

int main() {
  int N; cin >> N;
  int A[N]; for (int i = 0; i < N; i++) cin >> A[i];
  int C[N]; for (int i = 0; i < N; i++) C[i] = 0;
  for (int i = 0; i < N; i++) C[A[i]-1]++;
  long com = 0;
  for (int i = 0; i < N; i++) com += (long)C[i] * (C[i]-1) / 2;
  for (int i = 0; i < N; i++)
    cout << com - C[A[i]-1] + 1 << endl;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  char a,b;cin >> a >> b;
  cout << (a==b? 'H' : 'D') << endl;
  return 0;
}


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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++) cin >> a[i];
  int ans = 0;
  for(int i = 0; i < N; i++){
    ans += a[i] -1;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 3612
s = input()

if(len(s) % 2 == 0):
    s = s[:-2]
else:
    s = s[:-1]

while(s != ""):
    l = len(s)//2
    if(s[:l] == s[l:]):
        print(l*2)
        break
    s = s[:-2]


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;

    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;


void solve()
{
    ll n;
    cin>>n;

     n=n%10;
    if(n==2||n==4||n==5||n==7||n==9)
    {
       cout<<"hon\n";
    } 
    else if(n==0||n==1||n==6||n==8)
    {
       cout<<"pon\n";
    }
    else{
        cout<<"bon\n";
    }

}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,K;
  cin >> A >> B >> C>> K;
  
  int counter=0;
  while(B<=A){
    counter++;
    B*=2;
  }
  while(C<=B){
    counter++;
    C*=2;
  }
  if(counter<=K){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<map>
using namespace std;
typedef long long ll;


// 半分の仕方は2通りあるので、差が小さいほうを採用
pair<ll, ll> cut_half(ll H, ll W) {
	ll half_h, half_w;
	half_h = H / 2;
	half_w = W / 2;
	ll dif1 = W * (H - half_h) - W * half_h;
	ll dif2 = H * (W - half_w) - H * half_w;
	if (dif1 <= dif2) {
		pair<ll, ll> p(W * (H - half_h), W * half_h); // 常にp.first >= p.second;
		return p;
	}
	else {
		pair<ll, ll> p(H * (W - half_w), H * half_w);
		return p;
	}
}

int main() {
	int H, W;
	cin >> H >> W;
	ll ans = 1000000000;

	// int a[3];

	for (ll i = 1; i < H; i++) {
		pair<ll, ll> p = cut_half(H - i, W);
		ll temp = max(abs(p.first - W * i), abs(p.second - W * i));
		temp = max(p.first - p.second, temp);
		if (ans > temp) {
			ans = temp;
			// a[0] = p.first; a[1] = p.second; a[2] = W * i;
		}
	}

	for (ll i = 1; i < W; i++) {
		pair<ll, ll> p = cut_half(H, W-i);
		ll temp = max(abs(p.first - H * i), abs(p.second - H * i));
		temp = max(p.first - p.second, temp);
		if (ans > temp) {
			ans = temp;
			// a[0] = p.first; a[1] = p.second; a[2] = H * i;
		}
	}

	cout << ans << endl;
	// cout << a[0] << " " << a[1] << " " << a[2] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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>;
const int inf{int(1e9)};
int main(void){
  int A, B, K;
  cin >> A >> B >> K;

  if (B - A + 1 >= 2 * K){
    for (int i = 0; i < K; i++) cout << A + i << endl;
    for (int i = 0; i < K; i++) cout << B - K + 1 + i << endl;
  }else{
    for (int i = A; i <= B; i++) cout << i << endl;
  }
}


Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        long
            a = long.Parse(Console.ReadLine());
        long sum = 0;
        for(long
            i = 0; i < a; i++)
        {
            long[] n = Read.longs();
            sum += n[1] - n[0];
        }Console.WriteLine(sum+a);
    }

    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a / gcd(a, b) * b;
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (long i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13396
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {
            
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);


            string N = Console.ReadLine();
            long sum = 0;
            long n = long.Parse(N);

            for(var i = 0; i < N.Length; i++)
            {
                sum += N[i] - '0';
            }

            Console.WriteLine(n % sum == 0 ? "Yes" : "No");

            //Console.Out.Flush();
            
        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}



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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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

int a, b;

int main(){
	cin >> a >> b;
	
	if(a <= b) cout << a << endl;
	else cout << a-1 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int n = c/b;
	if(c%b)
		n++;
	int m = a/d;
	if(a%d)
		m++;
	if(n <= m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3640
//long time no ac
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     SPEED       ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());




int main()
{
	SPEED;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		// cs++;
		cin>>n;
		// n=s.length();
		ll a[n];
		rep(i,n)
		{
			cin>>a[i];
			if(a[i]>=c) c=a[i],cs++;
		}
		
		
		cout<<cs;
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
int main() {
    // input
    int n, k; cin >> n >> k;
    vector<vector<int> > g(n);
    repeat (i,n-1) {
        int a, b; cin >> a >> b;
        -- a; -- b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    // compute
    function<int (int, int, int)> dfs = [&](int i, int p, int depth) {
        int cnt = 1;
        if (depth) for (int j : g[i]) if (j != p) {
            cnt += dfs(j, i, depth-1);
        }
        return cnt;
    };
    int cnt = 0;
    if (k % 2 == 0) {
        repeat (i,n) {
            setmax(cnt, dfs(i, -1, k/2));
        }
    } else {
        repeat (i,n) {
            for (int j : g[i]) {
                setmax(cnt, dfs(i, j, k/2) + dfs(j, i, k/2));
            }
        }
    }
    // output
    cout << n - cnt << endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

/*void insertionSort(int *A, int N){ // N個の要素を含む0-オリジンの配列A
  int i,j,keep,k;
  for(i=1;i <= N-1;i++){
    keep = A[i];
    j = i - 1;
    while(j>= 0 && A[j] > keep){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = keep;
    for(k=0;k<N;k++){
      if(k>0) printf(" ");
      printf("%d",A[k]);
    }
    printf("\n");
  }
  }*/

int main(){
  int array[1000],i=0,n,keep,k,j;
  scanf("%d",&n);
  if(n<0 || n>100) exit(2); 
  for(i=0;i<n;i++) scanf("%d",&array[i]);
  for(k=0;k<n;k++){
    if(k>0) printf(" ");
    printf("%d",array[k]);
  }
  printf("\n");
  //insertionSort(array,n);
  for(i=1;i <= n-1;i++){
    keep = array[i];
    j = i - 1;
    while(j>= 0 && array[j] > keep){
      array[j+1] = array[j];
      j--;
    }
    array[j+1] = keep;
    for(k=0;k<n;k++){
      if(k>0) printf(" ");
      printf("%d",array[k]);
    }
    printf("\n");
  }
  
  return 0;
}



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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

int digit(int num){
    int dig;
    int sum = 0;
    while(num){
        dig = num % 10;
        sum = sum + dig;
        num = num / 10;
    }
    return sum;
}

int atcoder(){
    int n,ans=INT_MAX;
    cin>>n;
    REP(i,1,n){
        int j=n-i;
        chmin(ans,digit(i)+digit(j));
    }
    cout<<ans<<ENT;
    return 0;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long int ll;
const ll inf = 1e9+7;
ll maxProductSubarrayOfSizeK(ll A[], int n, int k)
{
    sort(A, A + n);
    ll product = 1;
    if (A[n - 1] == 0 && (k & 1))
        return 0;
    if (A[n - 1] <= 0 && (k & 1)) {
        for (int i = n - 1; i >= n - k; i--)
            product = ((product * A[i])%inf + inf)%inf;
        return product;
    }
    int i = 0;
    int j = n - 1;
    if (k & 1) {
        product = ((product * A[j])%inf + inf)%inf;
        j--;
        k--;
    }
    k >>= 1;
    for (int itr = 0; itr < k; itr++)
    {
        ll left_product = A[i] * A[i + 1];
        ll right_product = A[j] * A[j - 1];
        if (left_product > right_product) {
            product = ((product * (left_product%inf))%inf + inf)%inf;
            i += 2;
        }
        else {
            product = ((product * (right_product%inf))%inf + inf)%inf;
            j -= 2;
        }
    }
    return product;
}
int main()
{
    int n,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    cout << maxProductSubarrayOfSizeK(a, n, k)<<endl;
}


Measured memory_bytes: 5152
N = int(input())
l = [0] + [0] * N
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            temp = x**2 + y**2 + z**2 + x * y + y * z + z * x
            if temp <= N:
                l[temp] += 1

# print(l)
for i in range(1, N + 1):
    print(l[i])


Measured memory_bytes: 9244
#include<iostream>
using namespace std;
int main() {
    int s; cin >> s;
    int a[1000000] = {0};
    a[s] = 1;
    int cnt = 1;
    while (1) {
        cnt++;
        if (s % 2 == 0) {
            s /= 2;
        } else {
            s = 3 * s + 1;
        }
        //cout << s << endl;
        if (a[s] == 0) {
            a[s] = 1;
        } else {
            cout << cnt << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
typedef pair<double, double> P;

signed main(){
   ll a,b,n;cin>>a>>b>>n;
   ll maxa=(a*n)/b,maxb=n/b;
   ll tmax=maxa-a*maxb;
       if(n%b==0){
           ll tmpa=(a*(n-1))/b,tmpb=(n-1)/b;
           cout<<tmpa-a*tmpb<<endl;
       }else{
           ll tmp=(n/b)*b-1;
           ll tmpa=(a*tmp)/b,tmpb=tmp/b;
           cout<<max(tmpa-a*tmpb,tmax)<<endl;
       }
    return 0;
}

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

play_list = []

for _ in range(N):
    s, t = map(str, input().split())
    play_list.append((s, int(t)))

sleep = input()

sleeped = False

ans = 0

for tup in play_list:
    s = tup[0]
    t = tup[1]
    if sleeped:
        ans += t
    if sleep == s:
        sleeped = True

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top,Data[1000];
void push(int x){
  Data[++top]=x;
}
int pop(){
  top--;
  return Data[top+1];
}
int main(){
  int x,a,b;
  char data[100];
  top = 0;

  while(scanf("%s", data)!=EOF){  
    if ( data[0] == '+' ){
      a=pop();
      b=pop();
      push(a + b);
    } else if ( data[0] == '-' ){
      b=pop();
      a=pop();
      push(a - b);
    } else if ( data[0] == '*' ){
      a=pop();
      b=pop();
      push(a * b);
    } else {
      push(atoi(data));
    }
  }
  printf("%d\n",pop());

  return 0;
}


Measured memory_bytes: 2108
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let v = get!(String);
    let e_count = v.chars().filter(|&x| x == 'E').count();
    let w_count = n - e_count;
    let mut te = e_count;
    let mut tw = w_count;
    let v: Vec<char> = v.chars().collect();
    let mut ans = n;
    for (_, c) in v.iter().enumerate() {
        if *c == 'W' {
            ans = std::cmp::min(ans, te + (w_count - tw));
            tw -= 1;
        } else {
            te -= 1;
            ans = std::cmp::min(ans, te + (w_count - tw));
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396