akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  R n;
  int ans=0;
  rep(i,n) {
    int l,r;
    cin >> l >> r;
    ans+=r-l+1;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 998244353
#define debug(x) cerr<<#x<<"="<<x<<'\n'

int k,q;
int a[5010],b[5010];
ll sum1[5010],sum[5010];

int main(){
	scanf("%d%d",&k,&q);
	for (int i=1;i<=k;i++) scanf("%d",&a[i]);
	for (int i=0;i<q;i++) {
		int n,x,m;
		scanf("%d%d%d",&n,&x,&m);
		x%=m;
		n--;
		for (int i=1;i<=k;i++) b[i]=a[i]%m;
		for (int i=1;i<=k;i++) sum1[i]=sum1[i-1]+(b[i]>0),sum[i]=sum[i-1]+(ll)b[i];
		ll tmp1=n/k*sum1[k]+sum1[n%k];
		ll tmp2=(ll)n/k*(ll)sum[k]+(ll)sum[n%k]+(ll)x;
//		cout<<tmp2<<endl;
		cout<<(ll)tmp1-tmp2/(ll)m<<endl;
	}
	return 0;
}


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

fn main() {
    let n: usize = read();

    let mut ans = 0f64;

    for _ in 0..n {
        let x: f64 = read();
        let u: String = read();
        ans += if u == "JPY" { x } else { x * 380000.0 };
    }

    println!("{}", ans);
}

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


Measured memory_bytes: 4352
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int a,b;
    cin >>a>>b;
    string ans="";
    if(a>b)ans="Alice";
    else if(a<b)ans="Bob";
    if(a==1&&b!=1)ans="Alice";
    if(a!=1&&b==1)ans="Bob";

    if(a==b)ans="Draw";


    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        APair solver = new APair();
        solver.solve(1, in, out);
        out.close();
    }

    static class APair {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int i = in.nextInt();
            int e = i / 2, o = (i + 1) / 2;
            out.println(e * o);
        }

    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>

#define mp make_pair
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i=a, _n=b; i<=_n; ++i)
#define REV(i, a, b) for(int i=a, _n=b; i>=_n; --i)
using namespace std;

const int N = 1e3+5, mod = 1e9+7;
int n, a, b, c, d;
int64_t C[N][N], P[N], f[N], r[N];

int64_t pw(int64_t a, int n)
{
    if (n == 1) return a;
    int64_t res = pw(a, n>>1);
    res = res * res % mod;
    return (n&1) ? res * a % mod : res;
}
int main()
{
    ios::sync_with_stdio(); cin.tie(0);
    ///freopen("a.inp","r",stdin);

    cin >> n >> a >> b >> c >> d;

    FOR(i, 0, n) C[i][0] = 1;
    FOR(i, 1, n) FOR(j, 1, i) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod;

    P[0] = r[0] = 1;
    FOR(i, 1, n) {
        P[i] = (P[i-1] * i) % mod;
        r[i] = pw(P[i], mod-2);
    }

    f[0] = 1;
    FOR(m, a, b) REV(i, n, 1) if (i >= m*c) {
        int64_t tmp = 1; int s = i;
        FOR(j, 1, c-1) {
            tmp = tmp * C[s][m] % mod;
            s = s - m;
        }
        FOR(j, c, d) {
            tmp = tmp * C[s][m] % mod;
            s = s - m; if (s < 0) break;
            f[i] = (f[i] + f[s] * tmp % mod * r[j] % mod) % mod;
        }
    }

    cout << f[n];
}


Measured memory_bytes: 7424
#include<stdio.h>

#define MAX 100

int A[MAX][MAX],G[MAX];
void DJP(int);

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

DJP(n);
  return 0;
}

void DJP(int n){
  int i,j,a=1,size,min,out=0;;
  int B[MAX];
  B[0]=0;
  G[0]=1;
  for(i=1;i<n;i++){
    G[i]=0;
  }
  while(1){
    size=2001;
    for(i=0;i<a;i++){
      for(j=0;j<n;j++){
        if(A[B[i]][j]<size&&A[B[i]][j]!=-1&&G[j]!=1){
          size=A[B[i]][j];
          min=j;
        }
      }
    }
    if(a!=n){
      B[a]=min;
      G[min]=1;
      out+=size;
      a++;
    }
    else break;
  }
  printf("%d\n",out);
}



Measured memory_bytes: 2056
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#include<random>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (int)(Y);++(X))
#define reps(X,S,Y) for (int (X) = (int)(S);(X) < (int)(Y);++(X))
#define rrep(X,Y) for (int (X) = (int)(Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (int)(Y)-1;(X) >= (int)(S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"
#define cauto const auto

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
template<class A,class B> pair<A,B> operator+(const pair<A,B> &p,const pair<A,B> &q){ return {p.X+q.X,p.Y+q.Y};}
template<class A,class B,class C,class D> pair<A,B>& operator+=(const pair<A,B> &p,const pair<C,D> &q){ p.X+=p.X; q.Y+=q.Y; return p;}
template<class A,class B> pair<A,B> operator-(const pair<A,B> &p,const pair<A,B> &q){ return {p.X-q.X,p.Y-q.Y};}
template<class A,class B,class C,class D> pair<A,B>& operator-=(const pair<A,B> &p,const pair<C,D> &q){ p.X-=p.X; q.Y-=q.Y; return p;}
template<class A,class B> istream& operator>>(istream &is, pair<A,B> &p){ is>>p.X>>p.Y; return is;}
template<class T> T read(){ T re; cin>>re; return move(re);}
template<class T> T read(const T &dec){ T re; cin>>re; return re-dec;}
template<class T> vector<T> readV(const int sz){ vector<T> re(sz); for(auto &x:re) x=read<T>(); return move(re);}
template<class T> vector<T> readV(const int sz, const T &dec){ vector<T> re(sz); for(auto &x:re) x=read<T>(dec); return move(re);}
vv<int> readG(const int &n,const int &m){ vv<int> g(n); rep(_,m){ cauto a=read<int>(1),b=read<int>(1); g[a].pb(b); g[b].pb(a);} return move(g);}
vv<int> readG(const int &n){ return readG(n,n-1);}

const ll MOD=1e9+7; //998244353

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	cauto n=read<int>();
	cauto g=readG(n);
	ll re=0;
	reps(i,1,n+1) re+=i*(n+1ll-i);
  rep(a,n)for(auto b:g[a])if(a<b) re-=(a+1ll)*(n-b);
	cout<<re NL;
  return 0;
}


Measured memory_bytes: 15044
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

struct UnionFind {
    vector<int> rank, parent, size;

    // +1 for 1-indexed nodes
    UnionFind(int n) : rank(n + 1, 0), parent(n + 1), size(n + 1, 1) {
        iota(parent.begin(), parent.end(), 0); // parent is itself
    }
    int root(int x) {
        if (x != parent[x]) {
            parent[x] = root(parent[x]);
        }
        return parent[x];
    }
    bool isSame(int x, int y) { return root(x) == root(y); }
    bool unite(int x, int y) { return link(root(x), root(y)); }
    bool link(int x, int y) {
        if (x == y)
            return false;
        if (rank[x] > rank[y]) {
            parent[y] = x;
            size[x] += size[y];
        } else {
            parent[x] = y;
            size[y] += size[x];
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
        return true;
    }
    int getSize(int x) { return size[root(x)]; }
};

int main() {
    int n, m;
    cin >> n >> m;
    vi p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        p[i]--;
    }
    UnionFind uf(n);
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        uf.unite(x, y);
    }
    int ret = 0;
    for (int i = 0; i < n; ++i) {
        if (uf.isSame(i, p[i]))
            ret++;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int a, b;
    cin >> a >> b;
    int n = b - a;
    cout << n * (n+1) / 2 - b << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int cnt=0;
	for(int i=1;i<=9;++i)
		for(int j=1;j<=9;++j){
			int cnt1=0;
			for(int k=1;k<=n;++k){
				int h=k,t=k%10;
				while(h>=10)
					h/=10;
				if(h==i&&t==j)
					++cnt1;
			}
			int cnt2=0;
			for(int k=1;k<=n;++k){
				int h=k,t=k%10;
				while(h>=10)
					h/=10;
				if(h==j&&t==i)
					++cnt2;
			}
			cnt+=cnt1*cnt2;
		}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> field(h);
    rep(i, h) cin >> field[i];
    int sy = 0, sx = 0, gy = h - 1, gx = w - 1;

    vector<vector<int>> dist(h, vector<int>(w, INF));
    queue<P> q;
    auto update = [&](int y, int x, int v) {
        if(dist[y][x] != INF) return;
        dist[y][x] = v;
        q.push(P(y, x));
    };
    update(sy, sx, 0);
    while(!q.empty()) {
        int ny = q.front().first, nx = q.front().second;
        q.pop();
        rep(dir, 4) {
            int nj = ny + dy[dir], ni = nx + dx[dir];
            if(nj >= h || nj < 0 || ni >= w || ni < 0) continue;
            if(field[nj][ni] == '#') continue;
            update(nj, ni, dist[ny][nx] + 1);
        }
    }
    int maxv = dist[gy][gx];
    if(maxv == INF) {
        cout << -1 << endl;
        return 0;
    }
    
    int tot = 0;
    rep(i, h) {
        rep(j, w) {
            if(field[i][j] == '.') tot++;
        }
    }
    int ans = tot - (maxv + 1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

	return i
}

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

func main() {
	sc.Split(bufio.ScanWords)
	N, M := nextInt(), nextInt()

	AC := make(map[int]int, N)
	WA := make(map[int]int, N)

	ACNum, WANum := 0, 0
	for i := 0; i < M; i++ {
		p, s := nextInt(), nextString()

		if AC[p] > 0 {
			continue
		}
		if s == "AC" {
			AC[p] = 1
			ACNum += 1
			WANum += WA[p]
		} else if s == "WA" {
			WA[p] += 1
		}
	}

	fmt.Println(ACNum, WANum)
}


Measured memory_bytes: 6144
cdict = "abcdefghijk"

N = int(input())

def str_func( s , num ):
  if( len(s) == N ):
    print(s)
    return
  else:
    for i in range( num ):
      if( i==num-1):
        str_func( s+cdict[i], num+1)
      else:
        str_func( s+cdict[i], num)
        
str_func( "", 1 )

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

using namespace std;

int main(){

  string x;
   
  while(getline(cin,x)){
   
    for(int i=0;i<(int)x.size(); i++){
      //大文字→小文字
      if( (65<=x[i])&& (x[i]<=90)){
	x[i]+=32;
      }
      //小文字→大文字
      else if((97<=x[i])&& (x[i]<=122)){
	x[i]-=32;
      }
    }
    cout <<x<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define se second

signed main(){
    int n;
    cin>>n;
    int a[n];
    r(i,n)cin>>a[i];
    map<int,int>m1,m2;
    map<int,int>::iterator it;
    r(i,n){
        if(i%2)m1[a[i]]++;
        else m2[a[i]]++;
    }
    vector<P>v1,v2;
    for(it=m1.begin();it!=m1.end();it++){
        v1.push_back(P((*it).se,(*it).fi));
    }
    for(it=m2.begin();it!=m2.end();it++){
        v2.push_back(P((*it).se,(*it).fi));
    }
    sort(v1.begin(),v1.end(),greater<P>());
    sort(v2.begin(),v2.end(),greater<P>());
    int s=1e9;
    r(i,min((int)v1.size(),(int)10)){
       r(j,min((int)v2.size(),(int)10)){
        if(v1[i].se==v2[j].se)s=min(s,min(n-v1[i].fi,n-v2[j].fi));
        else{
            s=min(s,n-v1[i].fi-v2[j].fi);
        }
       } 
    }
    cout<<s<<endl;
}

Measured memory_bytes: 9592
#include<algorithm>
#include<iostream>
#include<cstdio>

using namespace std;

int a[300005],n;

bool check(int o,int p)
{
	int mx=0,mm=n+1,s=0,ss=0;
	for(int i=o;i<=p;i++) mx=max(mx,a[i]),mm=min(mm,a[i]);
	if((mx!=p)||(mm!=o)) return false;
	for(int i=o;i<=p;i+=2)
	    if(a[i]>s) s=a[i];else if(a[i]>ss) ss=a[i];else return false;
	return true;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		if(a[i]==i) continue;
		int p;
		for(p=i;p<=n-2;p+=2)
		    if((a[p+1]!=(p+1))||(a[p+2]==(p+2))) break;
		if(!check(i,p)) {cout<<"No"<<endl;return 0;}
		i=p;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
        a[i]--;
    }
    int j = 0;
    int count = 0;
    int ans = -1;
    while(true){
        count++;
        if(a[j] == 1){
            ans = count;
            break;
        }
        j = a[j];
        if(count == n)break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <string.h>
int main (){

int a,b;
char c[15],d[15],e[15];
	scanf("%s %s %d %d %s",&c,&d,&a,&b,&e);
if((strcmp(c,e)==0))
{
	printf("%d %d",a-1,b);
}
else{
	printf("%d %d",a,b-1);
}

	return 0;
}

Measured memory_bytes: 1712
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n, m) for (int i = (n), i < (m); i++)

typedef struct {int a, id;} student;

int s_sort(const void *a, const void *b) {
  student x = *(student *)a, y = *(student *)b;
  return x.a - y.a;
}

int
main(int argc, char *argv[])
{
  int n;
  student x[100010];
  scanf("%d", &n);
  rep(i, n) {
    scanf("%d", &x[i].a);
    x[i].id = i;
  }

  qsort(x, n, sizeof(student), s_sort);
  rep(i, n) {
    printf("%d ", x[i].id + 1);
  }
  endl;
  return 0;
}


Measured memory_bytes: 1788
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#define FOR(i, k, n) for (int(i) = (k); (i) < (n); ++(i))
#define rep(i, n) FOR(i, 0, n)
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef deque<bool> db;
template <class T>
using vv = vector<vector<T>>;

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

  if (X == 1)
  {
    cout << 1 << endl;
    return 0;
  }

  int limit = int(floor(sqrt(X)));
  int res = 1;

  for (int i = limit; 1 < i; --i)
  {
    int tmp = i * i;
    while (tmp <= X)
    {
      res = max({tmp, res});
      tmp *= i;
    }
  }

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

Measured memory_bytes: 764
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    s = list(input())
    k= int(input())
    tar = s[k-1]
    for i in range(n):
        if tar != s[i]:
            s[i] = "*"
    print("".join(s))
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 10372
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}

void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

int main(){
	int x1,x2,y1,y2;
	scanf("%d %d %d %d", &x1,&y1,&x2,&y2);
	printf("%d %d %d %d\n", y1 - y2 + x2, x2 - x1 + y2,y1 - y2 + x1, x2 - x1+y1);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <stack>
#include <queue>

using namespace std;

int main(){
    int i_max = 200000;
    queue<int> prime_temp;
    queue<int> prime;
    for(int i=2; i<i_max; i++){
        prime_temp.push(i);
    }
    while(prime_temp.empty()!=true){
        prime.push(prime_temp.front());
        //cout<<prime_temp.front()<<" "<<endl;
        int temp_top = prime_temp.front();
        int temp_size = prime_temp.size();
        for(int i=0; i<temp_size; i++){
            if(prime_temp.front()%temp_top==0){
                prime_temp.pop();
            }else{
                prime_temp.push(prime_temp.front());
                prime_temp.pop();
            }
        }
    }
    
//    while(prime.empty()!=true){
//        cout<<prime.front()<<" ";
//        prime.pop();
//    }
    
    
    int x;
    while(cin>>x){
        if(x==0)break;
        queue<int> prime_out;
        prime_out=prime;
        int out_sum=0;
        for(int i=0; i<x; i++){
            out_sum+=prime_out.front();
            prime_out.pop();
        }
        cout<<out_sum<<endl;
    }
}

Measured memory_bytes: 2064
import copy
N,M=map(int,input().split())
 
A = [[int(i)-1 for i in input().split()] for i in range(M)]
#print(A)
def dfs(x):
  if visited[x]:
    return
  visited[x]=True
  for i in range(N):
    if edgemat[x][i]:
      dfs(i)
answer=0
 
for i in range(M):
  visited=[False]*N
  Acopy=copy.deepcopy(A)
  del Acopy[i]
  edgemat=[[0] *N for j in range(N)]
  for m,n in Acopy:
    edgemat[m][n]=1
    edgemat[n][m]=1
  dfs(0)
  if any(visited[y] == False for y in range(N)):
    answer+=1
print(answer)

Measured memory_bytes: 3572
S = str(input())

# dpテーブルを定義する[桁数][余りの数]

dp = [[0]*13 for _ in range(100001)]

# dpテーブルの初期条件, 0桁の数字を13で割って0余るパターンが1通りあるとして計算をしていく
dp[0][0] = 1

for i in range(len(S)):
    # 「(i-1)文字目まで計算した結果、余りがjになるようなものはk通りある」ということをメモして、
    # そのk通りがi文字目の計算をしたときにどのjに遷移するかを求めて行く
    for remain in range(13):  # それぞれの余りのパターンの総数について
        # S[i]の取り方について全通り試して行く
        if S[i] == '?':  # 今見ている数字が'?'である場合
            for target in range(10):  # 0~9まで試す
                next_remain = (remain*10 + target) % 13
                dp[i+1][next_remain] += dp[i][remain]
                dp[i+1][next_remain] %= 1000000007
        else:
            next_remain = (remain*10 + int(S[i])) % 13
            dp[i+1][next_remain] += dp[i][remain]
            dp[i+1][next_remain] %= 1000000007

# print(dp[0])
# print(dp[1])
print(dp[len(S)][5])


Measured memory_bytes: 63932
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}

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

    int N;
    cin >> N;
    vector<int> v(3 * N);
    for (auto &&i : v) {
        cin >> i;
    }
    RSORT(v);

    ll ans  = 0;
    int cnt = 0;
    int i   = 1;
    while (cnt != N) {
        ans += v[i];
        i += 2;
        cnt++;
    }
    std::cout << ans << '\n';

    return 0;
}

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

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int vmax=100010;

vi graph[vmax],ord,low,scc;
stack<int>s;

void add_edge(int f,int t){ graph[f].pb(t);}
void add_both_edges(int f,int t){add_edge(f,t);add_edge(t,f);}

void dfs(int v,int p,int &k){
	ord[v]=k++;
	low[v]=ord[v];
	s.push(v);
	for(auto &i:graph[v]){
		if(ord[i]==-1){
			dfs(i,v,k);
			low[v]=min(low[v],low[i]);
		}else if(scc[i]==-1)
			low[v]=min(low[v],ord[i]);
	}
	if(ord[v]==low[v]){
		while(1){
			int u=s.top();s.pop();
			scc[u]=v;
			if(u==v) break;
		}
	}
}

void lowlink(int n){
	int k=0;
	ord.assign(n,-1),low.resize(n),scc.assign(n,-1);
	rep(i,n) if(ord[i]==-1) dfs(i,-1,k);
}

int main(void){
	int v,e;
	cin >> v >> e;
	rep(loop,e){
		int a,b;
		cin >> a >> b;
		add_edge(a,b);
	}
	lowlink(v);
/*	rep(i,v){
		cout << "ord[" << i << "]=" << ord[i]  << endl;
		cout << "low[" << i << "]=" << low[i]  << endl;
	}
*/	int q;
	cin >> q;
	rep(loop,q){
		int a,b;
		cin >> a >> b;
		cout << (scc[a]==scc[b]) << endl;
	}
	return 0;
}

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

int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  for (int i=1; i<=n; ++i){
    if(i%3 == 0) continue;
    if(i%5 == 0) continue;
    ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
from collections import deque

h,w=map(int,input().split())
a=[input() for i in range(h)]
lis=[[-1 for i in range(w)] for j in range(h)]
q=deque()


for i in range(h):
  for j in range(w):
    if a[i][j]=="#":
      q.append((i,j))
      lis[i][j]=0


while q:
  cur=q.popleft()
  i,j=cur[0],cur[1]

  if 0<=i+1<=h-1 and 0<=j<=w-1:
    if lis[i+1][j]==-1:
      lis[i+1][j]=lis[i][j]+1
      q.append((i+1,j))
  
  if 0<=i-1<=h-1 and 0<=j<=w-1:
    if lis[i-1][j]==-1:
      lis[i-1][j]=lis[i][j]+1
      q.append((i-1,j))

  
  if 0<=i<=h-1 and 0<=j+1<=w-1:
    if lis[i][j+1]==-1:
      lis[i][j+1]=lis[i][j]+1
      q.append((i,j+1))
      
  if 0<=i<=h-1 and 0<=cur[1]-1<=w-1:
    if lis[i][j-1]==-1:
      lis[i][j-1]=lis[i][j]+1
      q.append((i,j-1))      
  
print(max(max(l) for l in lis))



Measured memory_bytes: 104284
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if len(set([L[i], L[j], L[k]])) != 3:
                continue
            if not ((L[i] + L[j] > L[k]) and (L[j] + L[k] > L[i]) and (L[k] + L[i] > L[j])):
                continue
            ans += 1
print(ans)


Measured memory_bytes: 9156
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, q;
    string s;
    cin >> n >> q >> s;

    vector<int> c(n + 1);
    for(int i = 1; i < n; i++){
        c[i+1] = c[i];
        if(s[i-1] == 'A' && s[i] == 'C'){
            c[i+1]++;
        }
    }

    rep(i, q){
        int l, r;
        cin >> l >> r;
        cout << c[r] - c[l] << endl;
    }

    return 0;
}


Measured memory_bytes: 1856
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main()
{
    f_io;
    ll n,k;
    cin >> n >> k;
    vector<ll> arr(n),dp(n,INF);
    foi(0,n)
        cin >> arr[i];
    dp[0]=0;
    foi(1,n)
    {
        foj(1,k+1)
        {
            if(i-j>=0)
                dp[i] = min(dp[i-j]+abs(arr[i]-arr[i-j]),dp[i]);
        }
    }

    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 4784
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INF = 2147483647;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	int i, K, N, l, r;
	ll least = 1e14;
	cin >> N >> K;
	vector<ll> x(N);
	for (i = 0; i < N; i++) cin >> x[i];
	for (l = 0, r = K - 1; r < N; l++, r++){
		least = min(least, min(abs(x[l]), abs(x[r])) + x[r] - x[l]);
	}
	cout << least << endl;
	return 0;
}


Measured memory_bytes: 1024
using System;

public class p0216
{
	p0216 ()
	{
		string str;
		
		while ((str=Console.ReadLine()) != null && str != "-1") {
			Console.WriteLine ("{0}", (4280-func(int.Parse(str)-10)));
		}
	}
	
	public int func (int v)
	{
		int res = 1150;
		
		if (v < 0)
			return res;
		
		if (v < 10)
			return res + v * 125;
		res += 1250;
		v -= 10;
		
		if (v < 10)
			return res + v * 140;
		res += 1400;
		v -= 10;
		
		return res+v*160;
	}
	
	public static int Main(string[] args){
		new p0216();
		return 0;
	}
}

Measured memory_bytes: 5604
#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>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
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 };

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
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() {
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  sort(all(a),greater<int>());
  vector<bool> exist(a[0]+1,false);
  vector<vector<int>> d(a[0]+1,vector<int>(0));

  bool pc = true;
  for(int i = 2;i <= a[0];i++){
    if(!d[i].empty())continue;
    for(int j = i;j <= a[0];j += i){
      d[j].pb(i);
    }
  }
  rep(i,n){
    for(int prime : d[a[i]]){
      if(exist[prime]){
        pc = false;
        break;
      }
      exist[prime] = true;
    }
    if(!pc)break;
  }
  if(pc){
    print("pairwise coprime");
    return 0;
  }

  int g = a[0];
  rep(i,n){
    g = gcd(g,a[i]);
  }
  if(g == 1)print("setwise coprime");
  else print("not coprime");
  return 0;
}

Measured memory_bytes: 62584
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int dx = abs(x1-x2);
    int dy = abs(y1-y2);

    if (x1 <= x2 && y1 <= y2) {
        cout << x2 - dy << ' ' << y2 + dx << ' '
             << x1 - dy << ' ' << y1 + dx << ' ' << endl;
    } else if (x1 >= x2 && y1 <= y2) {
        cout << x2 - dy << ' ' << y2 - dx << ' '
             << x1 - dy << ' ' << y1 - dx << ' ' << endl;
    } else if (x1 >= x2 && y1 >= y2) {
        cout << x2 + dy << ' ' << y2 - dx << ' '
             << x1 + dy << ' ' << y1 - dx << ' ' << endl;
    } else if (x1 <= x2 && y1 >= y2) {
        cout << x2 + dy << ' ' << y2 + dx << ' '
             << x1 + dy << ' ' << y1 + dx << ' ' << endl;
    }

    return 0;
}


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

xy = []
for i in range(N):
    x, y = input().split()
    xy.append([i + 1, x, int(y)])

sort_xy = sorted(sorted(xy), key=lambda x: (x[1],-x[2]))

for i in range(N):
    print(sort_xy[i][0])


Measured memory_bytes: 3060
import java.io.*
import java.util.*

fun <T, R> Iterable<T>.scanLeft(initial: R, operation: (acc: R, T) -> R): Sequence<R> {
    var last = initial
    return this.asSequence().map { last = operation(last, it); last }
}

fun solve(N: Int, a: LongArray) {
    val cumSum = a.toList().scanLeft(0L) { a, b -> a + b }.toList()
    val dp = Array(N + 1) { LongArray(N + 1) { -1 } }
    for (i in 0 until N) {
        dp[i][i + 1] = 0L
    }
    fun rec(i: Int, j: Int): Long {
        // [i, j)の最小値
        if (dp[i][j] >= 0L) return dp[i][j]
        val s = cumSum[j - 1] - cumSum.getOrElse(i - 1) { 0L }
        val ret = (i + 1 until j)
            .map { rec(i, it) + rec(it, j) }
            .min() ?: 0L
        dp[i][j] = ret + s
        return ret + s
    }
    println(rec(0, N))
    // println(dp.contentDeepToString())
    return
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val a = LongArray(N)
    for (i in 0 until N) {
        a[i] = sc.next().toLong()
    }
    solve(N, a)
}


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

using namespace std;

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

    int n, step = 5e4;
    cin >> n;
    int a[n], b[n];

    a[0] = b[n - 1] = 1;
    for (int i = 1; i < n; i++)
        a[i] = a[i - 1] + step, b[n - i - 1] = a[i];

    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        a[p - 1] += i;
    }

    for (int x : a)
        cout << x << ' ';
    cout << '\n';
    for (int x : b)
        cout << x << ' ';
    cout << '\n';

    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll nax=1e6+5, inf=1e18;
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (1LL*x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll powMod(ll base,ll expo){
	if(base==0)return 0;
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base); 
		expo>>=1;
	}
	return ans;
}
void solve(){
	ll n;
	cin>>n;
	ll x=n%10;
	if(x==3){
		cout<<"bon";
	}else if(x==2||x==4||x==5||x==7||x==9){
		cout<<"hon";
	}else
		cout<<"pon";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
struct BinaryIndexedTree {
  BinaryIndexedTree(size_t n) : n(n + 1), v(n + 2, 0), r(1 << (31 - __builtin_clz(n + 1))) {}

  size_t n;
  int r;
  vector<int> v;

  int sum(int k) {
    int ret = 0;
    for (++k; k; k -= k & -k) ret += v[k];
    return ret;
  }

  void add(int k, int x) {
    for (++k; k <= n; k += k & -k) v[k] += x;
  }

  int lower_bound(int w) {
    int idx = 0;
    for (int k = r; k > 0; k /= 2) {
      if (idx + k <= n && v[idx + k] < w) {
        w -= v[idx + k];
        idx += k;
      }
    }
    return idx;
  }
};

 
struct segtree {
  segtree() {}
  segtree(int n, vector<char> v) : n(n) {
    init(v);
  }
 
  pair<char, int> id = make_pair('{', -1);
  int n;
  vector<pair<char, int>> node;
 
  void init(vector<char> v) {
    int n_ = n;
    n = 1;
    while (n < n_) n *= 2;
 
    node.assign(2 * n - 1, id);
    for (int i = 0; i < v.size(); ++i) {
      int idx = i + n - 1;
      node[idx] = make_pair(v[i], i);
    }
    for (int i = n - 2; i >= 0; --i) {
      node[i] = min(node[2 * i + 1], node[2 * i + 2]);
    }
  }
 
  pair<char, int> find(int a, int b, int k, int l, int r) {
    if (b <= l || r <= a) return id;
    if (a <= l && r <= b) return node[k];
 
    return min(find(a, b, 2 * k + 1, l, (l + r) / 2), find(a, b, 2 * k + 2, (l + r) / 2, r));
  }
 
  pair<char, int> find(int a, int b) {
    return find(a, b, 0, 0, n);
  }
 
  void update(int k) {
    k += n - 1;
    node[k] = id;
    while (k) {
      k = (k - 1) / 2;
      node[k] = min(node[2 * k + 1], node[2 * k + 2]);
    }
  }
};
 
int main() {
  string s;
  int k;
 
  cin >> s >> k;
  vector<char> v(s.size());
  for (int i = 0; i < s.size(); ++i) v[i] = s[i];
 
  BinaryIndexedTree bit(s.size());
  segtree seg(s.size(), v);
 
  for (int i = 0; i < s.size(); ++i) bit.add(i, 1);
 
  string ans;
  for (int i = 0; i < s.size(); ++i) {
    int r = bit.lower_bound(k + 1);
    pair<char, int> c = seg.find(0, r + 1);
    seg.update(c.second);
    bit.add(c.second, -1);
    k -= bit.sum(c.second);
 
    ans.push_back(c.first);
  }
 
  cout << ans << endl;
}

Measured memory_bytes: 8732
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
int main() {
	int n, m, x; std::cin >> n >> m >> x;
	std::vector<std::pair<int, std::vector<int>>> books(n);
	for (auto& book : books) {
		std::cin >> book.first;
		book.second.resize(m);
		for (auto& a : book.second) std::cin >> a;
	}
	int min_price{ INT_MAX };
	for (auto i = 1; i < (1 << n); ++i) {
		std::vector<int> score(m, 0);
		int sum_price{ 0 };
		for (auto j = 0; j < n; ++j) if ((i & (1 << j)) != 0) {
			sum_price += books[j].first;
			for (auto k = 0; k < m; ++k) {
				score[k] += books[j].second[k];
			}
		}
		if (std::all_of(score.begin(), score.end(), [x](const int s) {return s >= x; })) {
			min_price = std::min(min_price, sum_price);
		}
	}
	if (min_price == INT_MAX) {
		std::cout << "-1\n";
	}
	else {
		std::cout << min_price << '\n';
	}
}


Measured memory_bytes: 3636
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

signed main() {
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (i % 2 == 0 && !(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) {
			cout << "No" << endl;ggr
		}
		elif(i % 2 == 1 && !(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) {
			cout << "No" << endl;ggr
		}
	}
	cout << "Yes" << endl;
}

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

public class Main {
	public static void main(String[] args) {
		// You - N = T => T + N = You
		Scanner sc = new Scanner(System.in);
		String NS = sc.next();
		int len = NS.length();
		int N[] = new int[len];
		for(int i = 0 ; i < len ; ++i){
			N[i] = NS.charAt(len - 1 - i) - '0';
		}
		// 9 6
		//   
		//   6
		int dp[][] = new int[len][2];
		dp[0][0] = N[0];
		dp[0][1] = 10 - N[0];
		for(int i = 1 ; i < len ; ++i){
			int n = N[i];
			dp[i][0] = dp[i - 1][0] + n;
			if(n != 9){
				dp[i][0] = Math.min(dp[i][0], dp[i - 1][1] + (n + 1));				
			}
			dp[i][1] = dp[i - 1][0] + (10 - n);
			if(n == 9){
				dp[i][1] = Math.min(dp[i][1], dp[i - 1][1]);								
			}else{
				dp[i][1] = Math.min(dp[i][1], dp[i - 1][1] + (10 - (n + 1)));				
			}
		}	
		int ret = Math.min(dp[len - 1][0], dp[len - 1][1] + 1);
//		System.out.println(Arrays.deepToString(dp));
		System.out.println(ret);
	}
}


Measured memory_bytes: 69316
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>

#define MOD 1000000007

using namespace std;

typedef long long ll;

typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ll, ll> pll;
typedef pair<int, int> pi;

typedef vector<pll> vpl;
typedef vector<pi> vpi;

typedef queue<ll> ql;
typedef queue<int> qi;

template <class T>
void printv(vector<T> vc) {
    for (auto e: vc) cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc) { 
    for (auto vc: vvc) {
        for (auto e: vc) cout << e << " ";
        cout << endl;
    }
}

template <class T>
void printvp(vector<pair<T, T> > vp) {
    for (auto pT: vp) cout << pT.first << " " << pT.second << endl;
}

int main() {
    int x; cin >> x;
    if (x == 7 || x == 5 || x == 3) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256