akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
 
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d %d", &a, &b)
#define siii(a, b, c) scanf("%d %d %d", &a, &b, &c)
 
#define sl(a) scanf("%I64d", &a)
#define sll(a, b) scanf("%I64d %I64d", &a, &b)
#define slll(a, b, c) scanf("%I64d %I64d %I64d", &a, &b, &c)
 
#define outi(a) printf("%d\n", a)
#define outii(a, b) printf("%d %d\n", a, b)
#define outiii(a, b, c) printf("%d %d %d\n", a, b, c)
 
#define outl(a) printf("%I64d\n", a)
#define outll(a, b) printf("%I64d %I64d\n", a, b)
#define outlll(a, b, c) printf("%I64d %I64d %I64d\n", a, b, c)
 
#define cel(n, k) ((n-1)/k+1)
#define sets(a) memset(a, -1, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))
 
 
#define fr(i, n) for(ll i=0; i<n;i++)
#define fr1(i, n) for(ll i=1; i<=n;i++) 
 
#define readf(f) freopen(f, "r", stdin)
#define writef(f) freopen(f, "w", stdout)
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
 
template< class T > T sq(T x) { return x * x; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
typedef long long ll;
typedef pair<int,int> pii;
 
const int N = 105;
 
int main()
{
 
	ll a,b;
 
	cin>>a>>b;
 
	cout<<lcm(a,b)<<endl;
 
 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n;
    long long ans = 0;
    scanf("%d", &n);
    for (int i = 0; i <= n; i++)
    {
        if (!(i % 3 == 0 || i % 5 == 0))
            ans += (long long)i;
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	ll n;
	cin >> n;
	for(ll i=1;i<=n;i++){
		if(i*108/100==n){
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
 int A,B,C,D;
 scanf("%d %d %d %d",&A,&B,&C,&D);
 while(0<B&&0<D){
  C-=B;
  if(C<=0){
   printf("Yes");
   break;
   }
  A-=D;
  if(A<=0){
   printf("No");
   break;
   }
 }
 return 0;
}

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

int main(){
  int n,i,j;
  int ans=0;
  cin>>n;
  for(i=0;i<=n/4;i++){
    for(j=0;j<=n/7;j++){
      if(i*4+j*7==n)ans++;
    }
  }
  if(ans)cout<<"Yes";
  else cout<<"No";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
   public static void main(String[] args){
     Scanner scanner = new Scanner(System.in);
     for(int i=1;i>0; i++){
          int H = scanner.nextInt();
          int W = scanner.nextInt();
          if(H==0&&W==0)break;
          for(int j=1;j<=H; j++){
              for(int k=1;k<=W; k++){
                if(1<j&&1<k){
                    if(j<H&&k<W){
                         System.out.print(".");
                    }else{
                        System.out.print("#");
                    }
                }else{
                   System.out.print("#");  
                }
              }
              System.out.println();
          }
          System.out.println();
   }   
}
}

Measured memory_bytes: 34232
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
typedef pair<LL, LL> Pll;
LL h, w, n = 0, m, ans =-INF, d[1000][11] = {}, a[100000][10] = {}, sum = 0;
int flag = 0;
string str;
int main() {
	cin >> n;
	for (int h = 0; h < n; h++)
		for (int i = 0; i < 10; i++)
				cin >> a[h][i];

	for (int h = 0; h < n; h++)
		for (int i = 0; i < 11; i++)
			cin >> d[h][i];

	for (int i = 1; i < (1 << 10); i++) {
		sum = 0;
		LL f[10000] = {};
		for (int j = 0; j < 10; j++) {
			int c = (i % (1 << (j + 1))) / (1 << (j));
			if (c == 1)
				for (int h = 0; h < n; h++)
					if (a[h][j] == 1)
					f[h] += 1;
		}
		for (int h = 0; h < n; h++)
			sum += d[h][f[h]];
		ans = max(sum, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int gcd(int,int);
void swap(int * ,int *);
int main(){
  int n,x,y;
  scanf("%d %d",&x,&y);
  n =gcd(x,y);
  printf("%d\n",n);
  return 0;
}

int gcd(int x,int y){
  int r;
  if (x < y) swap(&x, &y);
  while(y > 0){
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}
void swap(int *x,int *y){
  int a;
  a = *x;
  *x = *y;
  *y = a;
}

Measured memory_bytes: 592
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
int main() {
    int n = 0;
    cin >> n;
    string s;
    cin >> s;
    vector<char> stack;
    for(int i = 0; i < n; ++i) {
        if(stack.size() == 0 || (stack.size() > 0 && stack.back() != s[i])) {
            stack.push_back(s[i]);
        }
    }
    cout << stack.size() << endl;
    return 0;
}

Measured memory_bytes: 640
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

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

    ll ans = 5e15;
    for(ll i = 1; i * i <= N; i++) {
        if(N % i) continue;
        ll r = i, c = N / i;
        chmin(ans, (r - 1) + (c - 1));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> ans(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        ans[a]++;
        ans[b]++;
    }
    rep(i,n){
        cout<< ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, k, count = 0;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++)cin >> a[i];
  for(int i = 0; i < n - k; i++){
    if(a[count] < a[count + k]) cout << "Yes" << endl;
    else cout << "No" << endl;
    count++;
  }
}

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

int main(){
    int N;
    cin >> N;
    for(int c=0; c<N; ++c){
        string X,Y;
        cin >> X >> Y;
        int xlen = (int)X.size();
        int ylen = (int)Y.size();

        vector<vector<int> > L(xlen+1 ,vector<int>(ylen+1, 0));

        for(int i=1;i<=xlen;++i){
            for(int j=1;j<=ylen;++j){
                if(X[i-1] == Y[j-1]){
                    L[i][j] = L[i-1][j-1] + 1;
                } else {
                    L[i][j] = max(L[i-1][j], L[i][j-1]);
                }
            }
        }
        cout << L[xlen][ylen] << endl;
    }
}

Measured memory_bytes: 6820
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

const LL MOD = 1000000007;
LL combi(LL N_, LL C_) {
	const int NUM_ = 400001;
	static LL fact[NUM_ + 1], factr[NUM_ + 1], inv[NUM_ + 1];
	if (fact[0] == 0) {
		inv[1] = fact[0] = factr[0] = 1;
		for (int i = 2; i <= NUM_; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i%MOD, factr[i] = factr[i - 1] * inv[i] % MOD;
	}
	if (C_<0 || C_>N_) return 0;
	return factr[C_] * fact[N_] % MOD*factr[N_ - C_] % MOD;
}

LL hcomb(int P_, int Q_) { return (P_ == 0 && Q_ == 0) ? 1 : combi(P_ + Q_ - 1, Q_); }

LL modpow(LL a, LL n = MOD - 2) {
	LL r = 1;
	while (n) r = r*((n % 2) ? a : 1) % MOD, a = a*a%MOD, n >>= 1;
	return r;
}

int a[101010], cnt[101010], n;

int main() {
	cin >> n;
	REP(i, n + 1) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	int pos1 = -1, pos2;
	REP(i, n + 1) {
		if (cnt[a[i]] == 2) {
			if (pos1 == -1)pos1 = i + 1;
			else pos2 = i + 1;
		}
	}
	LL ans = 0;
	REP(i, n + 1) {
		ans = combi(n + 1, i + 1);
		ans -= combi(n + pos1 - pos2, i);
		ans += MOD;
		ans %= MOD;
		cout << ans << endl;
	}
}

Measured memory_bytes: 11392
import java.util.Comparator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	class Edge {
		int to, dist;
		Edge(int to, int dist) {
			this.to = to; this.dist = dist;
		}
	}
	class Pair {
		int f, s;
		Pair(int f, int s) {
			this.f = f; this.s = s;
		}
	}
	class Graph {
		LinkedList<Edge> edges = new LinkedList<Edge>();
	}

	final int INF = Integer.MAX_VALUE;
	final int MAX_V = 10000;

	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		
		Graph[] g = new Graph[MAX_V];
		for (int i = 0; i < MAX_V; i++)
			g[i] = new Graph();
		
		for (int i = 0; i < n; i++) {
			int u = scan.nextInt();
			int k = scan.nextInt();
			for (int j = 0; j < k; j++) {
				int v = scan.nextInt();
				int c = scan.nextInt();
				g[u].edges.add(new Edge(v, c));
			}
		}

		int[] dist = new int[MAX_V];
		for (int i = 0; i < MAX_V; i++)
			dist[i] = INF;

		Queue<Pair> que = new PriorityQueue<Pair>(new Comparator<Pair>() {
			@Override
			public int compare(Pair p1, Pair p2) {
				return p1.f - p2.f;
			}
		});
		
		dist[0] = 0;
		que.add(new Pair(0, 0));
		
		while (!que.isEmpty()) {
			Pair p = que.poll();
			int v = p.s;
			if (dist[v] < p.f) continue;
			for (int i = 0; i < g[v].edges.size(); i++) {
				Edge e = g[v].edges.get(i);
				if (dist[e.to] > dist[v] + e.dist) {
					dist[e.to] = dist[v] + e.dist;
					que.add(new Pair(dist[e.to], e.to));
				}
			}
		}
		for (int i = 0; i < n; i++)
			System.out.println(i + " " + dist[i]);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 288608
#include <iostream>

using namespace std;

int main()
{
    string s;
    int k,l,i;
    cin>>k;
    i=0;
    l=0;
    while (i<k){
        cin>>s[i];
        i++;
    }
    i=0;
    while (i<k){
        if (s[i]=='A' &&s[i+1]=='B' &&s[i+2]=='C'){
            l++;
        }
        i=i+1;
    }
    cout<<l;
    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 500000

int H;

int parent(int i){
    return i/2;
}

int left(int i){
    return 2*i;
}

int right(int i){
    return 2*i+1;
}

void maxHeapify(int *A,int i){
    int l,r,largest,temp;
    l=left(i);
    r=right(i);
    if(l<=H && A[l]>A[i])largest=l;
    else largest=i;
    if(r<=H && A[r]>A[largest])largest=r;
    
    if(largest!=i){
        temp=A[i];
        A[i]=A[largest];
        A[largest]=temp;
        maxHeapify(A,largest);
    }
}

void buildMaxHeap(int *A){
    int i;
    for(i=H/2;i>=1;i--)maxHeapify(A,i);
}

int main(){
    int i,A[MAX];
    scanf("%d",&H);
    for(i=1;i<=H;i++)scanf("%d",&A[i]);
    buildMaxHeap(A);
    
    for(i=1;i<=H;i++){
        printf(" %d",A[i]);
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 3668
// Ryo Kamoi
#define DEBUG

#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int INF = 1000000000;

vector<int> times;
int p, q, r;
int main(){
  cin >> p >> q >> r;
  times.push_back(p);
  times.push_back(q);
  times.push_back(r);
  sort(times.begin(), times.end());
  cout << times[0] + times[1] << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        String a = sc.next();
		String b = "Yes";
		String c = "No";
		String [] ksb = String.valueOf(a).split("");

       	if(ksb[0].equals(ksb[2])) {
       		System.out.println(b); 
       	}else { System.out.println(c);
       	}
    }
}

Measured memory_bytes: 21844
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	string s;
	cin>>s;
	cout<<s.substr(0,3)<<endl;

}


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

typedef vector<int> VI;


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

	VI A;
	for (int i = 0; i < M; ++i) {
		int tmp;
		cin >> tmp;
		A.push_back(tmp);
	}

	int rem = N - accumulate(A.begin(), A.end(), 0);
	if (rem < 0) rem = -1;
	cout << rem << endl;

	return 0;
}


Measured memory_bytes: 3256
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        boolean isBad = false;
        for (int i = 0; i < a.length() - 1; i++) {
            if (a.charAt(i) == a.charAt(i + 1)) isBad = true;
        }
        if (isBad) {
            System.out.println("Bad");
        } else {
            System.out.println("Good");
        }
    }
}


Measured memory_bytes: 25300
#include<stdio.h>
#define N 10000
#define Q 500

int main()
{

  int i,j,n,q,c=0,S[N],T[Q];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  
  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(S[j] == T[i]){
	c++;
	break;
      }
    }
  }
  printf("%d\n",c);
  
  return 0;
}

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

using namespace std;

const int maxn = 3100;
const int base = 1e9+7;

int n,m,f[maxn][maxn][3];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>m;
    f[0][0][1]=1;
    for (int j=1;j<=n;j++)
        f[0][j][0]=1;
    for (int i=0;i<m;i++)
        for (int j=0;j<=n;j++)
            for (int tt =0;tt<2;tt++) {
                if (j) {
                    f[i+1][j][tt | (j==1)] = (f[i+1][j][tt | (j==1)] + f[i][j][tt]) % base;
                    f[i+1][j-1][tt | (j==1)] = (f[i+1][j-1][tt | (j==1)] + f[i][j][tt]) % base;
                }
                if (j<n) {
                    f[i+1][j][tt | (j==0)] = (f[i+1][j][tt | (j==0)] + f[i][j][tt]) % base;
                    f[i+1][j+1][tt] = (f[i+1][j+1][tt] + f[i][j][tt]) % base;
                }
            }
    int res=0;
    for (int j=0;j<=n;j++) res = (res + f[m][j][1]) % base;
    cout<<res<<endl;
}


Measured memory_bytes: 110848
import sys

k=int(input())
if k%2==0:
  print(-1)
  sys.exit(0)
c=1
m=7%k
while 1:
  if m==0:
    print(c)
    sys.exit(0)
  if c>k+1:
    print(-1)
    sys.exit(0)
  m=m*10+7
  m%=k
  c+=1






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

long long c[20][10];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k; cin >> k;
    for (int i = 0; i < 10; i++) {
        c[1][i] = 1;
    }
    for (int i = 1; i < 20; i++) {
        for (int j = 0; j < 10; j++) {
            for (int r = -1; r <= 1; r++) {
                if (j + r < 0 || j + r > 9) continue;
                c[i+1][j+r] += c[i][j];
            }
        }
    }
    int curr = -1; vector<int> v;
    for (int i = 1; i < 20; i++) {
        for (int j = 1; j <= 9; j++) {
            if (c[i][j] < k) k -= c[i][j];
            else {
                curr = i, v.emplace_back(j);
                break;
            }
        }
        if (curr > 0) break;
    }
    for (int i = curr-1; i >= 0; i--) {
        int x = v.back();
        for (int j = -1; j <= 1; j++) {
            if (x + j < 0 || x + j > 9) continue;
            if (c[i][x+j] < k) k -= c[i][x+j];
            else {
                v.emplace_back(x+j);
                break; 
            }
        }
    }
    for (auto &x: v) cout << x;
    cout << "\n";
    return 0;
}

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

using namespace std;

string res;

string go()
{
    if(res.size()==0) return "";
    string t;
    for(int i=0;i<res.size()-1;i++) t+=res[i];
    return t;
}

int main()
{
    string s; cin>>s;
    for(int i=0;i<s.length();i++)
    {
        char x=s[i];
        if(x=='B')
        {
            res=go();
        }
        else if(x=='0') res+='0';
        else res+='1';
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    int n,m,c,ans,ans_n=0;
    cin>>n>>m>>c;
    int a[m],b[m];
    for(int j=0;j<m;j++)cin>>b[j];
    for(int i=0;i<n;i++){
        ans=0;
        for(int j=0;j<m;j++){
            cin>>a[j];
            ans+=a[j]*b[j];
        }
        ans+=c;
        if(ans>0)ans_n++;
    }
    cout<<ans_n<<endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
*H, = map(int, input().split())
X = [0]
for i in range(1, n):
    x = 1 << 30
    for j in range(1, k+1):
        if i-j >= 0:
            x = min(x, X[i-j]+abs(H[i]-H[i-j]))
    X.append(x)
print(X[n-1])


Measured memory_bytes: 61024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='9'){
            cout<<"Yes"<<endl;
            break;
        }
        else{
            if(i==s.length()-1){
                cout<<"No"<<endl;
            }
        }
    }
    return 0;
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;

template< typename T >
struct Dinic
{
  struct edge
  {
    int to;
    T cap;
    int rev;
  };

  const T INF;
  vector< vector< edge > > graph;
  vector< T > min_cost;
  vector< int > iter;

  Dinic(int n) : INF(numeric_limits< T >::max())
  {
    graph.resize(n);
  }

  void add_edge(int from, int to, T cap)
  {
    graph[from].push_back((edge) {to, cap, (int) graph[to].size()});
    graph[to].push_back((edge) {from, 0, (int) graph[from].size() - 1});
  }

  bool bfs(int s, int t)
  {
    min_cost.assign(graph.size(), -1);
    queue< int > que;
    min_cost[s] = 0;
    que.push(s);
    while(!que.empty()) {
      int p = que.front();
      que.pop();
      for(auto &e : graph[p]) {
        if(e.cap > 0 && min_cost[e.to] == -1) {
          min_cost[e.to] = min_cost[p] + 1;
          que.push(e.to);
        }
      }
    }
    return (min_cost[t] != -1);
  }

  T dfs(int idx, const int t, T flow)
  {
    if(idx == t) return (flow);
    for(int &i = iter[idx]; i < graph[idx].size(); i++) {
      edge &e = graph[idx][i];
      if(e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
        T d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return (d);
        }
      }
    }
    return (0);
  }

  T max_flow(int s, int t)
  {
    T flow = 0;
    while(bfs(s, t)) {
      iter.assign(graph.size(), 0);
      T f = 0;
      while((f = dfs(s, t, INF)) > 0) {
        flow += f;
      }
    }
    return (flow);
  }
};

signed main(){
    int n, m;
    string u;
    cin >> n >> m >> u;
    vector<int> a(n);
    for(auto& x : a)
        cin >> x;
    vector<vector<int>> v(n, vector<int>(n, 0));
    for(int i = 0; i < m; ++i){
        int s, t, b;
        cin >> s >> t >> b;
        --s, --t;
        if(s > t)
            swap(s, t);
        v[s][t] += b;
    }
    Dinic<i64> Segtree(n + 2);
    for(int i = 0; i < n; ++i){
        Segtree.add_edge(n, i, u[i] == 'R' ? a[i] : 0);
        Segtree.add_edge(i, n + 1, u[i] == 'L' ? a[i] : 0);
    }
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            if(v[i][j]){
                Segtree.add_edge(i, j, v[i][j]);
            }
        }
    }
    cout << Segtree.max_flow(n, n + 1) << endl;
}



Measured memory_bytes: 4052
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 
 using namespace std;
 
 int main()
 {
   int year,month,day;
   while(cin>>year>>month>>day)
   {
     if(year<1868||(year==1868&&month<9)||(year==1868&&month==9&&day<8))
     {
       cout<<"pre-meiji"<<endl;                                                                   
     }                         
     else if(year<1912||(year==1912&&month<7)||(year==1912&&month==7&&day<30))
     {
       cout<<"meiji "<<(year-1868+1)<<" "<<month<<" "<<day<<endl;     
     }   
     else if(year<1926||(year==1926&&month<12)||(year==1926&&month==12&&day<25))
     {
        cout<<"taisho "<<(year-1912+1)<<" "<<month<<" "<<day<<endl;        
     }
     else if(year<1989|(year==1989&&month<1)||(year==1989&&month==1&&day<8))
     {
        cout<<"showa "<<(year-1926+1)<<" "<<month<<" "<<day<<endl;       
     }
     else
     {
       cout<<"heisei "<<(year-1989+1)<<" "<<month<<" "<<day<<endl;   
     }
   } 
   //while(1);
   return 0; 
 }

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n; string s;
	cin >> n >> s;
	V sum(n + 1, 0);
	bool W = true;
	rep(i, n) {
		if (s[i] == 'R') W = false;
	}
	if (W) {
		cout << 0 << endl;
		return 0;
	}
	rep1(i, n) {
		sum[i] += sum[i - 1] + (s[i - 1] == 'R');
	}
	int ans = upper;
	rep1(i, n) {
		int LW = i - sum[i];
		int RR = sum[n] - sum[i];
		// cout << LW << " " << RR << endl;
		int e = min(LW, RR);
		LW -= e; RR -= e;
		chmin(ans, LW + RR + e);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4452
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mod=1e9+7;
vector<ll>f(1<<20);
void upd(ll pos,ll val){
  for(ll i=pos;i<f.size();i+=(i&(-i)))f[i]=max(f[i],val);
}
ll q(ll pos){
  ll ma=0;
  for(ll i=pos;i>0;i-=(i&(-i)))ma=max(ma,f[i]);
  return ma;
}
ll N;
signed main(){
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
		cin>>N;
		ll ma=0;
		vector<ll>h;
		for(int i=0;i<N;i++){
      ll a;cin>>a;
      h.push_back(a);
		}
		for(ll i=0;i<N;i++){
      ll a;
      cin>>a;
      ll k=q(h[i]-1);
      upd(h[i],k+a);
      ma=max(ma,k+a);
		}
		cout<<ma;
    return 0;
}

Measured memory_bytes: 10612
n=int(input())
a=[]

for i in range(n):
    a.append(list(map(int,input().split())))


b=sorted(a, key=lambda x: x[1])


now=0
for i in range(n):
    now+=b[i][0]
    if now>b[i][1]:
        print("No")
        quit()

print("Yes")


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int h, w, k, sx, sy, ex, ey;
	cin >>h >>w >>k >>sy >>sx >>ey >>ex;
	vector<string> s(h);
	rep(i, h) cin >>s[i];
	const int dr[]={0,1,0,-1,0};
	const int INF= 1<<28;
	vector<VI> dd(h, VI(w, INF));
	queue< pair<int, int> > que;
	que.emplace(sy-1, sx-1); dd[sy-1][sx-1]=0;
	while(!que.empty()){
		int cy,cx; tie(cy,cx) = que.front();
		que.pop();
		rep(i,4) rep2(j, 1, k+1){
			int ny=cy+dr[i]*j, nx=cx+dr[i+1]*j;
			if(ny<0 || ny>=h || nx<0 || nx>=w) break;
			if(s[ny][nx] !='.' || dd[ny][nx] <= dd[cy][cx]) break;
			if(dd[ny][nx] == INF && s[ny][nx] =='.'){
				que.emplace(ny, nx);
				dd[ny][nx] = dd[cy][cx] + 1;
			}
		}
	}
	int ans = dd[ey-1][ex-1];
	cout <<(ans <INF? ans : -1) <<"\n";
	return 0;
}


Measured memory_bytes: 12136
s = input()
l = 0
l_max = 0
for i in range(len(s)):
  b = s[i]
  if b == 'A' or b == 'C' or b == 'T' or b == 'G':
    l += 1
  else:
    l_max = max(l_max,l)
    l = 0
l_max = max(l_max,l)
print(l_max)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define inv(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define endl "\n"
#define Endl "\n"

using namespace std;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int x, unsigned int y) {                                                    //return x^y in order(log(y))
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template<class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<double> a(N);
  rep(i, N) cin >> a[i];
  double ans = -INF;
  sort(ALL(a));
  vector<vector<double>> check(N * (N - 1) / 2, vector<double>(3));
  int now = 0;
  rep(i, N - 1) {
    FOR(j, i + 1, N) {
      check[now++] = {a[j] - a[i], a[i], a[j]};
    }
  }
  sort(ALL(check));
  rep(i, N - 1) {
    FOR(j, i + 1, N) {
      rep(k, check.size()) {
        if (a[i] != check[k][1] and a[i] != check[k][2] and a[j] != check[k][1] and a[j] != check[k][2]) {
          ans = max(ans, (a[i] + a[j]) / check[k][0]);
          break;
        }
      }
    }
  }
  cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 30244
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
#define MOD 1000000007
using namespace std;
typedef long long ll;

vector<int> g[5005];int n;
int s[5005],fa[5005];
vector<int> c,v;

void dfs(int x, int f){
	int m=0;
	s[x]=1;
	for(int y:g[x]){
		if(y==f)continue;
		dfs(y,x);
		s[x]+=s[y];
		m=max(m,s[y]);
	}
	m=max(m,n-s[x]);
	if(m<=n/2)c.pb(x);
}

int dp[5005][5005];
int cc[5005][5005];

int f(int k, int q){
	if(dp[k][q]>=0)return dp[k][q];
	int r=0;
	if(k==SZ(v))r=q==0;
	else {
		int m=1;
		fore(i,0,min(q,v[k])+1){
			r+=1LL*((1LL*m*f(k+1,q-i))%MOD*cc[v[k]][i])%MOD;
			r%=MOD;
			m=(1LL*m*(v[k]-i))%MOD;
		}
	}
	return dp[k][q]=r;
}

int main(){
	memset(dp,-1,sizeof(dp));
	fa[0]=1;
	fore(i,1,5005)fa[i]=(1LL*fa[i-1]*i)%MOD;
	fore(i,0,5005){
		cc[i][0]=cc[i][i]=1;
		fore(j,1,i)cc[i][j]=(cc[i-1][j-1]+cc[i-1][j])%MOD;
	}
	scanf("%d",&n);
	fore(i,1,n){
		int x,y;
		scanf("%d%d",&x,&y);x--;y--;
		g[x].pb(y);g[y].pb(x);
	}
	dfs(0,-1);
	if(SZ(c)==2){printf("%lld\n",(1LL*fa[n/2]*fa[n/2])%MOD);return 0;}
	assert(SZ(c)==1);
	int x=c[0];
	if(x)v.pb(n-s[x]);
	for(int y:g[x])if(s[y]<s[x])v.pb(s[y]);
	int r=0;
	fore(i,0,n){
		int a=(1LL*fa[n-i]*f(0,i))%MOD;
		if(i%2==0)r+=a;
		else r+=MOD-a;
		r%=MOD;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 195200
from heapq import heappush, heappop

# input
X,Y,Z,K = map(int, input().split())
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
c_list = [int(i) for i in input().split()]
a_list.sort(reverse = True)
b_list.sort(reverse = True)
c_list.sort(reverse = True)

#solve
hq = []
arg_hash = {}
val = a_list[0] + b_list[0] + c_list[0]
heappush(hq, (-val,0,0,0))

for i in range(K):
    ans, a, b, c = heappop(hq)
    print(-ans)

    arg_a = (a+1, b, c)
    arg_b = (a, b+1, c)
    arg_c = (a, b, c+1)

    if a < X-1 and arg_a not in arg_hash:
        arg_hash[arg_a] = 1
        heappush(hq, (-(a_list[a+1]+b_list[b]+c_list[c]),)+arg_a)
    if b < Y-1 and arg_b not in arg_hash:
        arg_hash[arg_b] = 1
        heappush(hq, (-(a_list[a]+b_list[b+1]+c_list[c]),)+arg_b)
    if c < Z-1 and arg_c not in arg_hash:
        arg_hash[arg_c] = 1
        heappush(hq, (-(a_list[a]+b_list[b]+c_list[c+1]),)+arg_c)


Measured memory_bytes: 4768
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  std::vector<int> a(n);
  int sigma=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sigma+=a[i];
  }
  for(int result=sigma;result>=1;result--){
    if(sigma%result!=0) continue;
    std::vector<int> alpha(n);
    std::vector<int> beta(n);
    for(int i=0;i<n;i++){

      alpha[i]=a[i]%result;
    }
    std::sort(alpha.begin(), alpha.end());
    for(int i=0;i<n;i++){
      beta[i]=result-alpha[i];
    }
    std::vector<int> alpha_cum(n),beta_cum(n);
    alpha_cum[0]=alpha[0];
    beta_cum[0]=beta[0];
    for(int i=1;i<n;i++){
      alpha_cum[i]=alpha[i]+alpha_cum[i-1];
      beta_cum[i]=beta[i]+beta_cum[i-1];
    }
    for(int i=0;i<n;i++){
      int left=alpha_cum[i];
      if(left>k) continue;
      int right=beta_cum.back()-beta_cum[i];
      if(right>k) continue;
      if(left==right){
        cout<<result<<endl;
        return 0;
      }
    }
  }




  return 0;
}


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

long long n;
vector<long long> d, memo;

long long solve();
long long mpow(long long base, long long p) {
  long long ans = 1;
  while(p) {
    if(p & 1) (ans *= base) %= MOD;
    (base *= base) %= MOD;
    p >>= 1;
  }
  return ans;
}

int main() {
  cin >> n;
  d.resize(n);
  memo.assign(n, 0);
  for(int i = 0; i < n; ++i) cin >> d[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  if(d[0] != 0) return 0;
  long long ans = 1, mnum = 0;
  memo.assign(n + 1, 0);
  for(int i = 0; i < n; ++i) {
    if(d[i] >= n) return 0;
    ++memo[d[i]];
    mnum = max(mnum, d[i]);
  }
  if(memo[0] != 1) return 0;
  for(int i = 1; i <= mnum; ++i) {
    if(memo[i - 1] == 0) return 0;
    (ans *= mpow(memo[i - 1], memo[i])) %= MOD;
  }
  return ans;
}

Measured memory_bytes: 2560
//Created by Young Charlie
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c,d; cin>>a>>b>>c>>d;
	cout<<(((abs(a-b) <= d && abs(c-b) <= d) || (abs(c-a) <= d )) ? "Yes\n" : "No\n");
}


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


signed main()
{
    int n;
    cin >> n;
    if(n == 3){
        cout << 2 << " " << 5 << " " << 63;
        exit(0);
    }
    int mx = -1;
    int sm = 0;
    vector < int > ans;
    for(int i = 2; i <= 30000; ++i){
        if(n == 2){
            mx = i;
            break;
        }
        if(i % 2 == 0 || i % 3 == 0){
            ans.push_back(i);
            sm += i;
            n--;
        }
    }
    for(int i = mx; i <= 30000; ++i){
        if(!(i % 2 == 0 || i % 3 == 0))continue;
        for(int j = i + 1; j <= 30000; ++j){
            if(!(j % 2 == 0 || j % 3 == 0))continue;
            int csm = sm + i + j;
            if(csm % 2 == 0 && csm % 3 == 0){
                ans.push_back(i);
                ans.push_back(j);
                for(int k = 0; k < ans.size(); ++k){
                    cout << ans[k] << " ";
                }
                exit(0);
            }
        }
    }
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <map>
#include <unordered_map>
#include<queue>
#include <stack>


const int INF = 1 << 28;
const long long MOD = 1000000007;
using namespace std;
using Graph = vector<vector<int>>;

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

vector<int> seen(50,-1);
int counter_for_dfs = 0;
void dfs(Graph &G, int v) {
	seen[v] = counter_for_dfs;
	counter_for_dfs++;
	for (auto v_next : G[v]) {
		if (seen[v_next]>=0)continue;

		dfs(G, v_next);
	}
}

void bfs(Graph &G) {
	vector<int> dist(G.size(), -1);
	queue<int> que;
	
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
		}
	}
	for (auto i : dist) {
		cout << i << " ";
	}
}

int counter[200005] = {};
void bfs2(Graph &G,int p,int x) {
	vector<int> dist(G.size() , -1);
	queue<int> que;
	
	dist[p] = 0;
	que.push(p);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
			counter[g] += x;
		}
	}
}
long long int gcd(long long int a, long long int b) {
	long long int c = std::min(a, b);
	a = std::max(a, b);
	b = c;
	while (true) {
		c = a % b;
		a = b;
		b = c;
		if (c == 0)break;
	}
	return a;
}
long long int factorial(int start,int end = 1) {
	if (start == 0)return 1;
	return start == end ? end : start * factorial(start - 1,end);
}
long long int npr(int n, int r) {
	return factorial(n) / factorial(n - r);
}

long long int ncr(int n, int r) {
	return npr(n, r) / factorial(r);
}

int main()
{
	int n = 0;
	scanf("%d", &n);
	vector<vector<int>> b;
	stack<int> stck;
	int inb[100] = { 0 };
	int rslt = 0;
	
	for (int i = 1; i <= n; i++) {
		vector<int> a(2);
		scanf("%d", &a[0]);
		a[1] = i;
		if (a[0] > a[1]) {
			rslt = -1;
			break;
		}
		b.push_back(a);
	}

	if (rslt < 0) {
		cout << rslt;
	}
	else {
		while (b.size() > 0) {
			for (int i = b.size(); i >= 1; i--){
				if (b[i-1][0] == i) {
					stck.push(b[i-1][0]);
					b.erase(b.begin() + i - 1);
					break;
				}
			}
		}
		while (!stck.empty()) {
			std::cout << stck.top() << endl;
			stck.pop();
		}
	}
}

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

using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds; 

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX

const int MAXN=1e6+3;
const int M=998244353;



void solve(){
		int n;
		sfi(n)
		int val=n%10;

		if(val==0 || val==1 || val==6|| val==8){
			printf("pon\n");
		}
		else if(val==3){
			printf("bon\n");
		}
		else{
			printf("hon\n");
		}
}	

int main(){	

			solve();

	return 0;	
}

Measured memory_bytes: 3760
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
const ll inf=(1e18);
const ll mod=1000000007;
ll dp[100];
ll fib(int n){
    if(n<2){
        return dp[n];
    }
    if(dp[n]!=-1)return dp[n];
    ll res=fib(n-1)+fib(n-2);
    return dp[n]=res;

}
int main(){
int n;
cin>>n;
fill(dp,dp+100,-1);
dp[0]=0;dp[1]=1;
cout<<fib(n+1)<<endl;

}





Measured memory_bytes: 3108
N,M=map(int,input().split())
AC=[False for i in range(0,N)]
WA=[0 for i in range(0,N)]
for i in range(0,M):
    p,S=map(str,input().split())
    p=int(p)
    if AC[p-1]:
        continue
    if S=="AC":
        AC[p-1]=True
    else:
        WA[p-1]+=1

ac=0
wa=0
for i in range(0,N):
    if AC[i]:
        ac+=1
        wa+=WA[i]
print(ac,wa)


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

int main() {
     int A,B,C;

     cin >> A >> B >> C;

     if((A<C)&&(C<B)){
          cout << "Yes";
     }else if((B<C)&&(C<A)){
          cout << "Yes";
     }else{
          cout << "No";
     }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a, b;
int main(){
    scanf("%d %d", &a, &b);
    if(a>0) return !printf("Positive");
    if(a<=0 && b>=0) return !printf("Zero");
    a = abs(a);
    b = abs(b);
    if(!((a-b)&1)) return !printf("Negative");
    printf("Positive");
}

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

int main(){
  int r,c=0;
  string S;
  cin >> S;
  r=15-S.size();
  for(int i=0; i<S.size(); i++){
    if(S[i]=='o') c++;
  }
  if(c+r>=8){
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)


{


 int W,H,x,y,r;


 scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);


 if(W<x+r||x-r<0||H<y+r||y-r<0){


    printf("No\n");


 }else{


    printf("Yes\n");


 }


 return 0;


}

Measured memory_bytes: 2636
n = int(input())
li = list(map(int,input().split()))

for i in reversed(range(1,n)):
  if li[i-1] <= li[i]:
    continue
  elif li[i-1] -1 == li[i]:
    li[i-1] -= 1
  else:
    print("No")
    exit()
print("Yes")

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    vector<int> p(10);

    REP(i, 10)
    {
        cin >> p[i];
    }

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

    REP(i, 3)
    {
        cout << p[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
const int maxx = 10010;
const int INF = 1 << 30;
int n;
int flag[maxx];
// ???????????????????????\??¨??¨?????????pair.first?????¶???v???pair.second?????????
vector<pair<int, int> > adj[maxx];

void dijkstra() {
	priority_queue<pair<int, int> > PQ;
	int d[maxx];
	for (int i = 0; i < n; i++) {
		d[i] = INF;
		flag[i] = 0;
	}

	d[0] = 0;
	PQ.push(make_pair(0, 0));
	while (!PQ.empty()) {

		pair<int, int> f = PQ.top(); PQ.pop();
		int u = f.second;

		// ?????°???????????\S
		flag[u] = 1;

		//????????????????°?????????????????????\
		if (d[u] < f.first *(-1))
			continue;
		int len = adj[u].size();
		for (int j = 0; j < len; j++) {
			int v = adj[u][j].first;
			if (flag[v] == 0 && d[v] > d[u] + adj[u][j].second) {
				d[v] = d[u] + adj[u][j].second;
				// priority_queue??????????????§???????????\?????\-1
				PQ.push(make_pair(d[v] * (-1), v));
			}
		}
	}

	for (int i = 0; i < n; i++)
		printf("%d %d\n", i, d[i] == INF ? -1 : d[i]);
}
int main()
{
	int u, v, k, c;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d %d", &u, &k);
		for (int j = 0; j < k; j++) {
			scanf("%d %d", &v, &c);
			adj[u].push_back(make_pair(v, c));
		}
	}
	dijkstra();
	return 0;
}

Measured memory_bytes: 8064
N,W,D = map(int,input().split())

while W:
  cp = [[0,0,0,0] for _ in range(2*N+1)]	#始点x,始点y,長さx,長さy
  cp[0] = [0,0,W,D]
  
  for time in range(N):
    P,S = map(int,input().split())
    P -= 1
    ta = cp[P]
    S %= (ta[2]+ta[3])*2
    
    #カット処理
    #面積が小さいほうが番号が小さい
    
    #上辺
    if 0 <= S < ta[2]:
      if S < ta[2]/2:
        cp[time+1] = [ta[0],ta[1],S,ta[3]]
        cp[time+2] = [ta[0]+S,ta[1],ta[2]-S,ta[3]]
      else:
        cp[time+1] = [ta[0]+S,ta[1],ta[2]-S,ta[3]]
        cp[time+2] = [ta[0],ta[1],S,ta[3]]
        
    #右辺
    elif S < ta[2]+ta[3]:
      S -= ta[2]
      if S < ta[3]/2:
        cp[time+1] = [ta[0],ta[1],ta[2],S]
        cp[time+2] = [ta[0],ta[1]+S,ta[2],ta[3]-S]
      else:
        cp[time+1] = [ta[0],ta[1]+S,ta[2],ta[3]-S]
        cp[time+2] = [ta[0],ta[1],ta[2],S]
        
    #下辺
    elif S < ta[2]*2+ta[3]:
      S = ta[2]-(S-ta[2]-ta[3])
      if S < ta[2]/2:
        cp[time+1] = [ta[0],ta[1],S,ta[3]]
        cp[time+2] = [ta[0]+S,ta[1],ta[2]-S,ta[3]]
      else:
        cp[time+1] = [ta[0]+S,ta[1],ta[2]-S,ta[3]]
        cp[time+2] = [ta[0],ta[1],S,ta[3]]
        
    #左辺
    else:
      S = ta[3]-(S-ta[2]*2-ta[3])
      if S < ta[3]/2:
        cp[time+1] = [ta[0],ta[1],ta[2],S]
        cp[time+2] = [ta[0],ta[1]+S,ta[2],ta[3]-S]
      else:
        cp[time+1] = [ta[0],ta[1]+S,ta[2],ta[3]-S]
        cp[time+2] = [ta[0],ta[1],ta[2],S]
        
    #カットされたやつのデータを消す
    del cp[P]
    
    
  #データ出力
  ansli = []
  for el in cp:
    ansli.append(el[2]*el[3])
  ansli.sort()
  print(*ansli)
  
  N,W,D = map(int,input().split())


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

int main()
{
  long long n;

  cin >> n ;

  vector<long long> a(n+1);

  long long ans =0;

  rep(i,n) cin >> a.at(i);
  a.at(n) = 10000000000;

  for(int i = 1;i<=n; i ++){
    if(a.at(i-1) > a.at(i)){
      long long sa = (a.at(i-1)-a.at(i));
      a.at(i) += (a.at(i-1)-a.at(i));
      ans += sa;
    }


  }
  // rep(i,n) cout <<  a.at(i) << endl;

  cout << ans;


}


Measured memory_bytes: 4752