akhauriyash/Code-Regression huggingface dataset:
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
string t="AKIHABARA";
string s;
int main()
{
	cin>>s;
	int it=0;
	for(int i=0;i<s.size();i++)
	{
		while(it<t.size()&&t[it]!=s[i])
		{
			if(t[it]!='A')
			{
				puts("NO");
				return 0;
			}
			it++;
		}
		it++;
	}
	while(it<t.size())
	{
		if(t[it++]!='A')
		{
			puts("NO");
			return 0;
		}
	}
	if(it<=t.size())puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 256
N,K,*A = `dd`.split.map &:to_i

rtree = Hash[(1..N).map{ |n| [n, []] }]
(2..N).each{ |n| m = A[n-1]; rtree[m] << n }
nn = (2..N).map{ |n| m = A[n-1]; "#{m} #{n}" }.join("\n")
nodes = IO.popen("tsort", "r+") {|io|
  io.puts nn
  io.close_write
  (0...N).map { io.gets.to_i }
}
#p tree, rtree, nodes
dp = Array.new(N+1, 0)
ans = A[0] == 1 ? 0 : 1
(1...N).reverse_each{ |i|
  n = nodes[i]
  dp[n] = (rtree[n].map{ |m| dp[m] }.max || 0) + 1
  if A[n-1] == 1
    dp[n] = 0
  elsif dp[n] == K
    dp[n] = 0; ans += 1
  end
  #p dp
}
p ans

Measured memory_bytes: 51716
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	solve()
}

func solve() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	a1 := make([]int, n, n)
	for i := 0; i < n; i++ {
		a1[i] = nextInt()
	}
	a2 := make([]int, n, n)
	for i := 0; i < n; i++ {
		a2[i] = nextInt()
	}

	res1 := make([]int, n, n)
	res1[0] = a1[0]
	for i := 1; i < n; i++ {
		res1[i] = res1[i-1] + a1[i]
	}
	res2 := make([]int, n, n)
	res2[n-1] = a2[n-1]
	for i := n - 2; i >= 0; i-- {
		res2[i] = res2[i+1] + a2[i]
	}

	ans := 0
	for i := 0; i < n; i++ {
		if ans < res1[i]+res2[i] {
			ans = res1[i] + res2[i]
		}
	}
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

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

func anser(b bool, y string, n string) string {
	if b {
		return y
	}
	return n
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 4000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
using namespace std;

ll gcd(ll n1,ll n2){
	if(!n1)return n2;
	if(!n2)return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
	base%=mod;
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	ans%=mod;
	return ans;
}
ll x[upperlimit+1];
ll y[upperlimit+1];
vll p1,p2;
bool cmpx(pll a,pll b){
	return (a.F<b.F);
}
bool cmpy(pll a,pll b){
	return (a.S<b.S);
}
bool val(ll a,ll b,ll c){
	return (a>=b && a<=c);
}
int main()
{
	int n,i,j,k;
	sd(n);sd(k);
	for(i=1;i<=n;i++){
		slld(x[i]);
		slld(y[i]);
		p1.pb(mp(x[i],y[i]));
		p2.pb(mp(x[i],y[i]));
	}
	sort(p1.begin(),p1.end(),cmpx);
	sort(p2.begin(),p2.end(),cmpy);
	ll answer=INFL;
	for(i=0;i<n;i++)for(j=i+1;j<n;j++)for(int ii=0;ii<n;ii++)for(int jj=ii+1;jj<n;jj++){
		ll x1,x2,y1,y2;
		x1=min(p1[i].F,min(p2[ii].F,p2[jj].F));
		x2=max(p1[j].F,max(p2[ii].F,p2[jj].F));
		y1=min(p2[ii].S,min(p1[i].S,p1[j].S));
		y2=max(p2[jj].S,max(p1[i].S,p1[j].S));
		int cnt=0;
		for(int ind=1;ind<=n;ind++)if(val(x[ind],x1,x2) && val(y[ind],y1,y2))cnt++;
		if(cnt>=k)answer=min(answer,(y2-y1)*(x2-x1));
	}
	plldn(answer);
	return 0;
}

Measured memory_bytes: 2304
#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;
typedef long long ll;




int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    
    sort(all(A));
    
    //rep(i,N) cout << A[i] << " "; cout << endl;
    
    
    priority_queue<int, vector<int>, greater<int>> pq;
    
    A.push_back(-1);
    int a = 1;
    for (int i = 1; i <= N; i++) {
        if(A[i] == A[i-1]) a++;
        else pq.push(a),a=1;
    }
    int ans = 0;
    while (!pq.empty()) {
        int p = pq.top();
        pq.pop();
        if(p == 1) ans++;
        else if(p > 2) p-=2,pq.push(p);
        else if(!pq.empty()){
            int q = pq.top();
            pq.pop();
            p--,q--;
            if(p == 1) ans++;
            else pq.push(p);
            if(q == 1) ans++;
            else pq.push(q);
        }
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 1528
#include"stdio.h"
#include"math.h"



int main() {
	char a[101], b[101],ans[201];
	int n;
	scanf("%d", &n);
	scanf("%s %s", &a, &b);
	for(int i=0;i<201;i++)	ans[i] = 0;

	for (int i = 0;i < n;i++) {
		ans[2*i] = a[i];
		ans[2*i+1] = b[i];
	}
	printf("%s", ans);
	return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
from collections import Counter 


def read():
    N, P = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, P, A


def binom_64bit(n):
    c = [1 for i in range(n+1)]
    for k in range(1, n):
        c[k] = c[k-1] * (n-k+1) // k
    return c


def solve(N, P, A):
    B = Counter([a % 2 for a in A])
    C0 = binom_64bit(B[0])
    C1 = binom_64bit(B[1])
    ans = 0
    if P == 1:
        for i in range(0, B[0]+1):
            for j in range(1, B[1]+1, 2):
                ans += C0[i] * C1[j]
    else:
        for i in range(0, B[0]+1):
            for j in range(0, B[1]+1, 2):
                ans += C0[i] * C1[j]
    return ans


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 9436
import heapq

n, m = map(int, input().split())
s = list(map(lambda x: x* (-1), map(int, input().split())))

heapq.heapify(s)

while m != 0:
  num = heapq.heappop(s)
  heapq.heappush(s, -1*num//2*-1)
  m -= 1

print(-1 * sum(s))



Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    vector<int> a(n+2, 0);
    for(int i = 1; i <= n; ++i) cin >> a.at(i);

    int sum = 0;
    for(int i = 1; i < n+2; ++i) {
        sum += abs(a.at(i)-a.at(i-1));
    }

    for(int i = 1; i <= n; ++i) {
        int ans = 0;
        ans = sum + abs(a.at(i+1)-a.at(i-1)) - (abs(a.at(i)-a.at(i-1)) + abs(a.at(i+1)-a.at(i)));
        cout << ans << endl;
    }
}

Measured memory_bytes: 1664
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    public void run() {
 
        while (true) {
            int[] val = new int[] { sc.nextInt(), sc.nextInt() };
            if(val[0]==0 &&val[1]==0)break;
            if(val[0]>val[1])swap(val);
            ln(val[0] + " " + val[1]);
        }
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
 
    public static int[] swap(int[] vals) {
        int tmp = vals[0];
        vals[0] = vals[1];
        vals[1] = tmp;
        return vals;
    }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end(), greater<int>());

    int counter = 0;
    for (int i = 0; i < N - 1; ++i) {
        if (vec.at(i) == vec.at(i + 1)) {
            ++counter;
        }
    }

    cout << N - counter << endl;
}

Measured memory_bytes: 256
n,m,r = map(int,input().split())
l = list(map(int,input().split()))
g = [[10**10]*(n+1) for _ in range(n+1)]
for i in range(n+1):
  g[i][i] = 0
for _ in range(m):
  a,b,c = map(int,input().split())
  g[a][b] = c
  g[b][a] = c
for k in range(1,n+1):
  for i in range(1,n):
    for j in range(i+1,n+1):
      if g[i][j] >= g[i][k] + g[k][j]:
        g[i][j] = g[i][k] + g[k][j]
        g[j][i] = g[i][j]
g[0] = [0]*(n+1)
def dfs(cur,res,dis,use):
  if res == 0:
    return dis
  ans = 10**10
  for i in range(r):
    if not use[i]:
      use[i] = 1
      ans = min(ans, dfs(l[i],res-1,dis+g[cur][l[i]],use))
      use[i] = 0
  return ans
print(dfs(0,r,0,[0]*r))
    

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

using namespace std;

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

  int res1 = a/c + ((a%c == 0)? 0 : 1);
  int res2 = b/d + ((b%d == 0)? 0 : 1);

  cout << l - max(res1, res2) << endl;

  return 0;
}

Measured memory_bytes: 1160
import sys


def run():
    q = []

    for line in sys.stdin:
        if line.startswith("i"):
            v = int(line[7:])
            q.append(v)
            i = len(q) - 1
            while i > 0:
                p = (i-1) // 2
                vp = q[p]
                if vp < v:
                    q[p], q[i] = v, vp
                    i = p
                else:
                    break
        elif line.startswith("ex"):

            size = len(q) - 1
            if size < 0:
                raise ValueError('get from empty queue')

            v = q[0]
            last = q.pop()
            if size > 0:
                q[0] = last
                i = 0
                while i < size // 2:
                    top, vt = i, last
                    left = (i+1) * 2 - 1
                    right = (i+1) * 2
                    if left < size:
                        vl = q[left]
                        if vl > vt:
                            top, vt = left, vl
                    if right < size:
                        vr = q[right]
                        if vr > vt:
                            top, vt = right, vr

                    if top > i:
                        q[top], q[i] = last, vt
                        i = top
                    else:
                        break
            print(v)
        elif line.startswith("end"):
            break
        else:
            ValueError("invalid command")


if __name__ == '__main__':
    run()


Measured memory_bytes: 44692
//
// Created by sark2 on 19-12-2019.
//

#include "bits/stdc++.h"

using namespace std;
#define pb push_back
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define CASES int t;cin>>t;while(t--)

using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;

int main() {

    ll n; cin>>n;
    ll a[n+5];

    for(ll i = 0; i < n; i++)cin>>a[i];

    ll sum = 0;
    for(int i = 0; i < 60; i++){

        ll zc = 0, oc = 0;
        ll unit_sum =  0;
        for(ll j = 0; j < n; j++){
            if(a[j] % 2 == 0)
                zc++;
            else
                oc++;
            a[j] /= 2;
        }
        unit_sum = (((((1LL << i)%mod)*oc)%mod * zc) % mod)%mod;

        sum += unit_sum, sum %= mod;
    }

    cout<<sum%mod<<"\n";



}


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


void solve(long long X){
	long c500 = X / 500; 
	long c5 = X - c500 * 500; 
	c5 = c5 / 5; 

	cout << c500 *1000 + (c5)*5 << endl; 
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
K = int(input())
dic = {i+1:[] for i in range(11)}

dic[1] = [str(i+1) for i in range(9)]

if K < 10:
    print(dic[1][K-1])
else:
    cnt = 9
    ans = -1
    for i, nums in dic.items():
        for n in nums:
            ds = n[-1]
            dd = int(ds)
            if dd > 0:
                dic[i+1].append(n + str(int(ds)-1))
                cnt += 1
            dic[i+1].append(n + str(int(ds)))
            cnt += 1
            if dd < 9:
                dic[i+1].append(n + str(int(ds)+1))
                cnt += 1
        if cnt >= K:
            ans = dic[i+1][K-cnt-1]
            break
    print(ans)

Measured memory_bytes: 17244
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	long long n; cin >> n;
	long long cnt = 0;
	for(int i = 1; i < n; i++){
		// if(n%i > i-1 && n%i > maxp){
		// 	maxp = max(n%i, maxp);
		// 	maxid = i;
		// }
		cnt += i;
	}
	//cnt = cnt - maxid + maxp;
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    string a, b; cin >> a >> b;
    if (a == "H") {
        if (b == "D") puts("D");
        else puts("H");
    } else if (a == "D") {
        if (b == "D") puts("H");
        else puts("D");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

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

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c - '0';}


// TODO: write
int main() {
  #define int ll 
  int n,W;cin>>W>>n;
  vector<int> w(n),v(n);rep(i,n)cin>>w[i]>>v[i];
  vector<vector<int>> dp(n+10,vector<int>(W+10,INF));
  rep(i,n+10)dp[i][0] = 0;
  rep(i,n){
    rep(j,W+1){
      chmin(dp[i+1][j],dp[i][j]);
      chmin(dp[i+1][j],dp[i+1][max(j-w[i],0ll)] + v[i]);
    }
  }
  print(dp[n][W]);
  return 0;
}

Measured memory_bytes: 79360
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    real A, B;
    scan(A, B);
    foreach (x; 1 .. 10_000)
    {
        // writeln(x, " ", (x * 108) / 100);
        if (A == floor(x * 0.08) && B == floor(x * 0.1))
        {
            writeln(x);
            return;
        }
    }
    writeln(-1);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        int i,cnt = 0;
        for(i=0;i<3;i++)
            a[i]=sc.nextInt();
        if(a[0]!=a[1]) cnt++;
        if(a[0]!=a[2]) cnt++;
        if(a[1]!=a[2]) cnt++;
        if(a[0]==a[1] && a[1]==a[2]) cnt=1;
        System.out.println(cnt);
    }
}


Measured memory_bytes: 20948
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    a();
  }

  public static void a() {
    try (Scanner sc = new Scanner(System.in)) {

      char al = sc.next().charAt(0);
      if (Character.isUpperCase(al)) {
        System.out.println("A");
      } else {
        System.out.println("a");
      }

    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }
}

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

using namespace std;

/*
bool desc (pair <char, long long>& a, pair <char, long long>& b)
{
    //return ((a.second > b.second)
    //      ||
    //    ((a.second == b.second) && (a.first < b.first))
    //  );

    if (a.first == b.first)
        return a.second > b.second;
    return a.first < b.first;
}

bool desc2 (set <long long> &a, set <long long> &b) {
    return a.size() < b.size();
}

int binary (vector <long long> v, long long n, long long x)
{
    long long st = 0, en = n;
    while (st <= en)
    {
        long long mid = st + (en - st) / 2;
        if (v[mid] == x)
        {
            return mid;
        }
        if (v[mid] < x)
        {
            st = mid + 1;
        }
        else if (v[mid] > x)
        {
            en = mid - 1;
        }
    }
    //return mid;
}

int arr[100001];
void sieve ()
{
    arr[0] = 1;
    arr[1] = 1;
    for (long long i = 2; i < 100001; i ++)
    {
        if (arr[i] == 0)
        {
            for (long long j = i * 2; j < 100001; j += i)
            {
                arr[j] = 1;
            }
        }
    }
}

bool isPrime(long long n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (long long i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
long long hcf(long long a, long long b)
{
    if (b == 0)
        return a;
    return hcf(b, a % b);

}

long long w = 12, n = 5;
long long DP[10001][10001];
long long W[5] = {10, 4, 20, 5, 7};
long long C[5] = {10, 15, 3, 1, 4};
long long knapsack (long long i , long long rem)
{
    if (i == n) {
        return 0;
    }
    //if (DP[W[i]][C[i]] != -1) {
      //  return DP[W[i]][C[i]];
    //}
    long long c1 = knapsack(i + 1, rem), c2;
    if (W[i] <= w) {
        c2 = knapsack(i + 1, rem - W[i]) + C[i];
    }
    return max(c1, c2);
}
*/

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.tie(0);
    // 8 2 5 7 8 12 20 1 3 15
    //freopen("aplusb.in", "r", stdin);
    //freopen("aplusb.out", "w", stdout);

    long long n, x;
    cin >> n;
    vector <long long> ans(n + 1);
    for (long long i = 1; i <= n; i ++) {
        cin >> x;
        ans[x] = i;
    }
    for (long long i = 1; i < n + 1; i ++) {
        cout << ans[i] << " ";
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 1664
"use strict"
function Main(input) {
  input = input.trim().split('\n');
  const S = input[0].trim().split(' ')[0];
  const T = input[0].trim().split(' ')[1];
  const A = input[1].trim().split(' ').map(Number)[0];
  const B = input[1].trim().split(' ').map(Number)[1];
  const U = input[2].trim();

  if(U === S){
    console.log(A-1, B);
  }else if(U === T){
    console.log(A, B-1);
  } else {
    console.log(A, B)
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=1e6+10;
const int Mod=1e9+7;

int N;
long long Inv[maxm];

int main(){
	register int i;
	register long long Ans=0,Add;
	scanf("%d",&N);
	Inv[0]=Inv[1]=1;
	for(i=2;i<=max(N,3);i++) Inv[i]=(Mod-Mod/i)*Inv[Mod%i]%Mod;
	Add=Inv[3]*Inv[N]%Mod;
	for(i=1;i<=N;i++){
		Ans=(Ans+Add*Inv[N-i+1])%Mod;
		Add=Add*Inv[3]%Mod;
	}
	printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 8064
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 505

using namespace std;
typedef pair <int,int> P;
typedef pair <P,P> PP;

int A[SIZE][SIZE];

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	vector <PP> ans;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			scanf("%d",&A[i][j]);
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(A[i][j]%2==1)
			{
				if(i+1<n)
				{
					ans.push_back(PP(P(i,j),P(i+1,j)));
					A[i+1][j]++;
				}
				else if(j+1<m)
				{
					ans.push_back(PP(P(i,j),P(i,j+1)));
					A[i][j+1]++;
				}
			}
		}
	}
	printf("%d\n",ans.size());
	for(int i=0;i<ans.size();i++)
	{
		P p=ans[i].first,q=ans[i].second;
		printf("%d %d %d %d\n",p.first+1,p.second+1,q.first+1,q.second+1);
	}
	return 0;
}


Measured memory_bytes: 5104
#include<bits/stdc++.h> 
using namespace std; 
int gcdEx(int a, int b, int *x, int *y){if(!a){*x=0;*y=1;return b;} 
int x1,y1,gcd=gcdEx(b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
int modI(int b, int m)      {int x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define loop(b,n)           for(int i=b;i<n;i++)
#define loopv(b,n,a)         for(int i=b;i<n;i+=a)
#define loopr(b,n)           for(int i=n;i>=0;i--)

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define pb                  push_back 
#define MOD                 1000000007 
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(int)(MOD+((a%MOD)-(b%MOD))%MOD):(int)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (int)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;}
y=y>>1; x=(x*x)%MOD;} return r;}


int main()
{ 
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    ll n,b,d;
    double sum=0;
    cin>>n>>d;
    double a[n][d];
    ll ans=0;
    loop(0,n)
    {  for(int j=0;j<d;j++)
        cin>>a[i][j];
        
    }
    loop(0,n)
    {   for(int k=i+1;k<n;k++)  
        {
            sum=0;
            for(int j=0;j<d;j++)
            sum+=abs((a[i][j]-a[k][j])*(a[i][j]-a[k][j]));
        sum=sqrt(sum);
        if(sum==floor(sum)) ans++;
        }
    }
    cout<<ans<<"\n";
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,ans = - 2000000000;
  cin >> n;
  int R[n],mi[n + 1];
  mi[0] = 1000000000;
  for(int i = 0;i < n;i++){
    cin >> R[i];
    mi[i + 1] = min(mi[i],R[i]);
  }
  for(int i = 1;i < n;i++){
    ans = max(ans,R[i] - mi[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4640
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <array>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

ULL Gcd(ULL m, ULL n)
{
	ULL temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

ULL Lcm(ULL m, ULL n)
{
	ULL gcd = Gcd(m, n);
	if ((m / gcd) < (n / gcd)) {
		return (m / gcd) * n;
	}
	else {
		return (n / gcd) * m;
	}
}

int main(void) {
	ULL T[100] = { 0 };
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> T[i];
	}
	
	ULL r = T[0];
	for (int i = 1; i < N; i++) {
		r = Lcm(r, T[i]);
	}
	cout << r << endl;

	return 0;
}

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

using namespace std;

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

    string hantei = {'A', 'C', 'G', 'T'};
    int Max = 0;
    int count = 0;
    bool flag = false;
    for(int i = 0; i < S.length(); i++){
        for(int j = 0; j < hantei.length(); j++){
            if(S[i] == hantei[j]){
                flag = true;
                count++;
                Max = max(Max, count);
            }
        }
        if(!flag) count = 0;
        flag = false;
    }
    cout << Max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define endl '\n'
    #define modulo 1000000007
    //#define int long long
    #pragma GCC optimize("-Ofast")
    #define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096
    #define sinDegrees(x) sin((x) * PI / 180.0)
    using namespace std;
    int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return (power(x, y / 2) * power(x, y / 2))%modulo;
    else
        return (x * power(x, y / 2) * power(x, y / 2))%modulo;
}
    /*#include "testlib.h"
    int main(int argc, char* argv[])
    {
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    registerGen(argc, argv, 1);
    int n =rnd.next(2,10000),k;
    cout<<n<<'\n';
    int nn=n;
    k=1;
    while(n--){
    k=rnd.next(k,min(k*2,1000000000));
    cout <<k<<' ';
    }
    cout<<'\n';
    k=1;
    while(nn--){
    k=rnd.next(k,min(k*2,1000000000));
    cout <<k<<' ';
    }
    }*/
    bool comp(pair<pair<int,int>,int>a,pair<pair<int,int>,int>b){
    return a.second>b.second;
    }
    int32_t main()
    {
    //freopen("output.txt","w", stdout);
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(b>d)
    cout<<1;
    else
    cout<<0;
    return 0;
    }


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  int need_right = 0, need_left = 0;

  rep(i, s.size()) {
    if (s[i] == '(')
      need_right++;
    else {
      if (!need_right)
        need_left++;
      else
        need_right--;
    }
  }
  rep(i, need_left) cout << "(";
  cout << s;
  rep(i, need_right) cout << ")";
  cout << endl;
}


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

int main() {
    int a,b;
    char c;
    while(cin>>a>>c>>b) {
        int ans = 0;
        if(c=='?') break;
        if(c=='+') ans = a+b;
        if(c=='-') ans = a-b;
        if(c=='*') ans = a*b;
        if(c=='/') ans = a/b;

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  int n, q;
  cin >> n >> q;
  vector<int> E[200010];
  rep(i, n - 1)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    E[a].push_back(b);
    E[b].push_back(a);
  }
  ll sum[200010] = {};
  rep(qi, q)
  {
    int p, x;
    cin >> p >> x;
    p--;
    sum[p] += x;
  }
  bool used[200010] = {};
  queue<int> que;
  que.push(0);
  used[0] = true;
  while (!que.empty())
  {
    int q = que.front();
    que.pop();
    for (auto to : E[q])
    {
      if (used[to])
        continue;
      sum[to] += sum[q];
      used[to] = true;
      que.push(to);
    }
  }
  rep(i, n) cout << sum[i] << (i == n - 1 ? "\n" : " ");
  return 0;
}


Measured memory_bytes: 16500
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll target;

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

    ll maxi=0,f=0,mini=INF,sum=0;
    string str,str1,str2;
    ll h,w;
    ll n,x,m;
    ll a,b,d,c;
    set<string> s;
    cin>>n;
    char endc;
    rep(i,n){
        cin>>str;
        if(s.find(str)!=s.end()){
            No;
            return 0;
        }
        s.insert(str);
        if(i!=0){
            if(str[0]!=endc){
                No;
                return 0;
            }
        }
        endc=str[str.length()-1];
    }
    Yes;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  map<char,int> mp_count;
  for(int i='a';i<'z'+1;i++){mp_count[char(i)]=0;}
  
  string output = "yes";
  for(int i=0;i<s.size();i++){
    if(mp_count[s[i]]>0){
      output = "no";
      break;
    }else{
      mp_count[s[i]]+=1;
    }
  }
  cout << output << endl;
}

Measured memory_bytes: 256
#coding:utf-8
H,W=map(int,input().split())

while not(H==0 and W==0):
    for i in range(0,H):
        for j in range(0,W):
            if i==0 or j==0 or i==H-1 or j==W-1:
                print("#",end="")
            else:
                print(".",end="")
        print("")
    print("")

    H,W=map(int,input().split())

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

#define ft first
#define sd second

using namespace std;

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







int n, a, ans, tmp;


int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		tmp = 0;
		while (a % (1 << tmp) == 0)
			tmp++;
		ans += tmp;
	}
	cout << ans - n;
	return 0;
}

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

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

ll kaizyou(ll N){
  ll num=1;
  for(ll i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int>X(M);
  vector<int>XX(M-1);
  rep(i,M){
    cin >> X.at(i);
  }
  sort(X.begin(),X.end());
  rep(i,M-1){
    XX.at(i)=abs(X.at(i+1)-X.at(i));
  }
  sort(XX.begin(),XX.end());
  int ans=0;
  rep(i,M-N){
    ans+=XX.at(i);
  }
  cout << ans << endl;
    
}
      
  
  
  

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int64 h,w;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    cout << (h*w+1) / 2 << endl;
}

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, d; cin >> n;
	unordered_map <int,int> mp;
	for (int i = 0; i < n; ++i){
		cin >> d;
		mp[d]++;
	}
	priority_queue <long long int> pq;
	for (auto it = mp.begin(); it != mp.end(); ++it){
		if (it->second >= 2) pq.push(it->first);
		if (it->second >= 4) pq.push(it->first);
	}
	pq.push(0);
	pq.push(0);
	long long int first = pq.top();
	pq.pop();
	long long int second = pq.top();
	cout << first * second << "\n";	
	return 0;
}


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

const int MAXN = 2e5;
const int INF = 0x3f3f3f3f;

int n, a[MAXN + 9];
long long ans = 0;
int s[MAXN + 9], top = 0, l[MAXN + 9], r[MAXN + 9];

void ToLeft() {
  s[top = 1] = n;
  for (int i = n - 1; i; --i) {
    while (top && a[s[top]] > a[i]) l[s[top--]] = i + 1;
    s[++top] = i;
  }
  while (top) l[s[top--]] = 1;
}

void ToRight() {
  s[top = 1] = 1;
  for (int i = 2; i <= n; ++i) {
    while (top && a[s[top]] > a[i]) r[s[top--]] = i - 1;
    s[++top] = i;
  }
  while (top) r[s[top--]] = n;
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);

  ToLeft(), ToRight();
  for (int i = 1; i <= n; ++i) ans += 1LL * (i - l[i] + 1) * (r[i] - i + 1) * a[i];

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

  return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>

using namespace std;

struct student {
  int id;
  int a;
  student(int id_, int a_) {
    id = id_;
    a = a_;
  }
};

bool comp(const student &x, const student &y) {
  return x.a < y.a;
}

int main() {
  int n;
  cin >> n;
  
  vector<student> s;
  for (int i = 1; i <= n; i++) {
    int ai;
    cin >> ai;
    s.push_back(student(i, ai));
  }
  sort(s.begin(), s.end(), comp);
  
  for (int i = 1; i <= n; i++) {
    cout << s.at(i-1).id << " ";
  }
  cout << endl;

  return 0;
}

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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
    string s;
    cin >> s;
    string answer;
    switch (s[s.size()-1] - '0') {
        case 0: 
            answer = "pon";
            break;
        case 1:
            answer = "pon";
            break;
        case 2:
            answer = "hon";
            break;
        case 3:
            answer = "bon";
            break;
        case 4:
            answer = "hon";
            break;
        case 5:
            answer = "hon";
            break;
        case 6:
            answer = "pon";
            break;
        case 7:
            answer = "hon";
            break;
        case 8:
            answer = "pon";
            break;
        case 9:
            answer = "hon";
            break;
    }
    cout << answer << "\n";
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int n;
    cin >> n;
    vector<ll> leaves(n + 1);
    vector<ll> nodes(n + 1);
    vector<ll> genkai(n + 1);
    nodes[0] = 1;
    genkai[0] = 1;
    for(int i = 0; i <= n; i++) cin >> leaves[i];
    if(leaves[n] == 0) {cout << -1; return 0;}
    ll border = -1;
    for(int i = 0; i < n; i++){
        if(genkai[i] - leaves[i] < 0) {cout << -1; return 0;}
        genkai[i + 1] = (genkai[i] - leaves[i]) * 2;
        if(genkai[i + 1] > 1e18) {border = i + 1; break;}
    }
    
    if(border != -1)for(int i = border; i <= n; i++) genkai[i] = 1e18;
    if(genkai[n] < leaves[n]) {cout << -1; return 0;}
    
    nodes[n] = leaves[n];
    for(int i = n; i > 0; i--){//node数を考えている
        ll cur = min(genkai[i - 1], leaves[i - 1] + nodes[i]);
        nodes[i - 1] = cur;
    }
    ll ans = 0;
    for(int i = 0; i <= n; i++){
        ans += nodes[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5644
#include<iostream>
#include<vector>
#include<limits>

using namespace std;

int MAX_INT = numeric_limits<int>::max();

int getMinTimes(int N, vector<int>& vec6, vector<int>& vec9, int idx6, int idx9) {
  if (N < 6) return N;

  while (1) {
    if (idx6 == -1) break;
    if (vec6[idx6] <= N) break;
    idx6 -= 1;
  }
  
  while (1) {
    if (idx9 == -1) break;
    if (vec9[idx9] <= N) break;
    idx9 -= 1;
  }

  int buf6 = MAX_INT, buf9 = MAX_INT;
  if (idx6 != -1) buf6 = getMinTimes(N - vec6[idx6], vec6, vec9, idx6, idx9);
  if (idx9 != -1) buf9 = getMinTimes(N - vec9[idx9], vec6, vec9, idx6, idx9);
  
  if (buf6 < buf9) {
    // cout << buf6 << ": " << N << " " << vec6[idx6] << " " << vec9[idx9] << endl;
    return buf6 + 1;
  }
  else {
    // cout << buf9 << ": " << N << " " << vec6[idx6] << " " << vec9[idx9] << endl;
    return buf9 + 1;
  }
}

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

  int N;
  cin >> N;

  int count = 0;
  
  vector<int> vec6, vec9;
  int base;

  base = 1;
  while (base * 6 <= N) {
    base *= 6;
    vec6.push_back(base);
  }

  base = 1;
  while (base * 9 <= N) {
    base *= 9;
    vec9.push_back(base);
  }

  int idx9 = vec9.size() - 1, idx6 = vec6.size() - 1;
  cout << getMinTimes(N, vec6, vec9, idx6, idx9) << endl;

  return 0;
}

Measured memory_bytes: 256
from collections import deque


def dijkstra(start: int, edges: list):
    """print the shortet path  O(|E|log|V|)
    maybe verified
    """
    dist = [float('inf') for _ in range(N)]  # list dist[|V|]
    dist[start] = 0
    prev_v = [-1]*(len(dist))  # 最短経路でのひとつ前の頂点
    q = deque([(0, start)])  # （暫定的な距離，頂点）
    while q:
        d_cur, cur = q.pop()
        if dist[cur] < d_cur:  # すでに探索済み
            continue
        for nex, cost in edges[cur]:
            if dist[nex] > dist[cur]+cost:
                dist[nex] = dist[cur]+cost
                q.append((dist[nex], nex))
                prev_v[nex] = cur
    return dist

    # # 以下 path の復元
    # path = []
    # v = goal
    # while v != -1:
    #     path.append(v)
    #     v = prev_v[v]
    # path = path[::-1]  # reverse
    # print("Shortest path: ", path)


if __name__ == "__main__":
    N, X, Y = map(int, input().split())
    X, Y = X-1, Y-1
    edges = [[] for _ in range(N)]
    for i in range(1, N):
        edges[i].append((i-1, 1))
    for i in range(N-1):
        edges[i].append((i+1, 1))
    edges[X].append((Y, 1))
    edges[Y].append((X, 1))
    # print(edges)

    cnt = [0]*N
    for i in range(N):
        d = dijkstra(i, edges)
        for di in d:
            cnt[di] += 1
    cnt = [ci//2 for ci in cnt]
    print(*cnt[1:], sep="\n")


Measured memory_bytes: 66652
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

float a, b, c, L, ans;


void solve(){
    a = L/3;
    b = L/3;
    c = L/3;
    ans = a * b * c;
    cout << setprecision(17)  << ans << endl;
}

int main(){
    cin >> L;

    solve();
}


Measured memory_bytes: 256
def solve():
    crd_antenna=[0]*5
    for i in range(5):
        crd_antenna[i]=int(input())
    dist_limit = int(input())
    bool = "True"
    for i in range(0,5):
        if bool == "False":
            break
        for j in range(i+1,5):
            if crd_antenna[j]-crd_antenna[i] > dist_limit:
                bool = "False"
                print(":(")
                break
            else:
                bool = "True"
    if bool == "True":
        print("Yay!")

solve()

Measured memory_bytes: 3060
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import math
import sys


def solve(values, nb, max_jump_size):
    max_jump_size = min(nb, max_jump_size)
    cost_to = [0]
    for i in range(1, nb):
        j = max(0, i - max_jump_size)
        value_i = values[i]
        new_cost = min(
            prev_cost + abs(value_i - prev_value)
            for prev_cost, prev_value in zip(cost_to[j:i], values[j:i])
        )
        cost_to.append(new_cost)
    return new_cost


def do_job():
    "Do the work"
    # first line is number of test cases
    R = int(input().strip())
    result = 2 * math.pi * R
    print(result)


def print_output(testcase, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {:f}".format(testcase + 1, result))


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


Measured memory_bytes: 17348
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int n,z,w;
    cin>>n>>z>>w;
    int a[n+2];
    f(i,1,n)
    {
        cin>>a[i];
    }
    int last=a[n];
    int v1=abs(last-w);
    if(n==1)
    {
        cout<<v1<<endl;
        return 0;
    }
    int v2=abs(last-a[n-1]);
    if(v1>v2)
    {
        cout<<v1<<endl;
        return 0;
    }
    cout<<v2<<endl;
    return 0;

}





































Measured memory_bytes: 3660