akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var N, D, X int
	fmt.Scan(&N, &D, &X)

	var a int
	ans := 0
	for i := 0; i < N; i++ {
		fmt.Scan(&a)
		for d := 0; d <= D; d++ {
			if d*a+1 <= D {
				ans++
			}
		}
	}
	fmt.Println(ans + X)
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

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

using pll = pair<ll, ll>;

int main(){
  int N, K;
  cin >> N >> K;
  vector<pair<ll, ll>> dt(N);
  for(int i = 0; i < N; i++){
    cin >> dt[i].second >> dt[i].first;
  }
  
  sort(all(dt), greater<pair<ll, ll>>());

  vector<bool> used(N + 10, false);
  priority_queue<pll, vector<pll>, greater<pll>> que;
  ll ans = 0, cnt = 0;
  
  for(int i = 0; i < K; i++){
    ans += dt[i].first;
    if(!used[dt[i].second]){
      cnt++;
      used[dt[i].second] = true;
    }else{
      que.push(dt[i]);
    }
  }
  ans += (cnt * cnt);
  ll new_ans = ans;
   //cerr << "update " << ans << endl;
  for(int i = K; i < N; i++){
    if(used[dt[i].second]) continue;
    if(que.empty()) break;
    pll x = que.top(); que.pop();
    used[dt[i].second] = true;
    cnt++;
    new_ans = (new_ans - x.first + dt[i].first) + (cnt * cnt) - ((cnt - 1) * (cnt - 1));
    ans = max(ans, new_ans);
    //cerr << "update " << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2940
n,c,k = (int(i) for i in input().split())
t = sorted(int(input()) for i in range(n))
ans = pas = time = 0
for j in t:
  if j > time or pas >= c:
    ans += 1
    time = j + k
    pas = 1
  elif j <= time and pas < c:
    pas += 1
print(ans)

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

int main(void) {

	int a, b;

	std::cin >> a >> b;

	std::cout << (a % b == 0 ? 0 : 1) << std::endl;
	return 0;
}

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

int n, k;
long long sum = 0, bf = 0;
vector<long long> a;

int main() {
  cin >> n >> k;
  a.resize(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < k; ++i) sum += a[i];
  for (int i = k; i < n; ++i) {
    bf = sum;
    sum += a[i] - a[i - k];
    if (sum > bf)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 4816
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int h = scanner.nextInt();
        final int w = scanner.nextInt();

        final boolean[][] table = new boolean[h][w];
        for (int i = 0; i < h; i++) {
            final String s = scanner.next();
            for (int j = 0; j < s.length(); j++) {
                if (s.charAt(j) == '.') {
                    table[i][j] = true;
                }
            }
        }

        final int answer = dijkstra(table, h, w);
        System.out.println(answer);
    }

    private static int dijkstra(final boolean[][] table, final int h, final int w) {
        final PriorityQueue<Pair> queue = new PriorityQueue<>(Comparator.comparingInt(pair -> pair.cost));
        final int[][] d = new int[h][w];
        for (final int[] array : d) {
            Arrays.fill(array, Integer.MAX_VALUE);
        }
        d[0][0] = table[0][0] ? 0 : 1;
        queue.add(new Pair(1, 0, d[0][0] + calc(0, 0, 1, 0, table)));
        queue.add(new Pair(0, 1, d[0][0] + calc(0, 0, 0, 1, table)));

        while (!queue.isEmpty()) {
            final Pair pair = queue.poll();
            if (d[pair.i][pair.j] <= pair.cost) {
                continue;
            }

            d[pair.i][pair.j] = pair.cost;
            if (pair.i < h - 1) {
                queue.add(new Pair(pair.i + 1, pair.j, pair.cost + calc(pair.i, pair.j, pair.i + 1, pair.j, table)));
            }
            if (pair.j < w - 1) {
                queue.add(new Pair(pair.i, pair.j + 1, pair.cost + calc(pair.i, pair.j, pair.i, pair.j + 1, table)));
            }
        }

        return d[h - 1][w - 1];
    }

    private static int calc(final int i, int j, final int nextI, final int nextJ, final boolean[][] table) {
        if (table[nextI][nextJ] || !table[i][j] && !table[nextI][nextJ]) {
            return 0;
        } else {
            return 1;
        }
    }

    static class Pair {
        final int i;
        final int j;
        final int cost;

        Pair(final int i, final int j, final int cost) {
            this.i = i;
            this.j = j;
            this.cost = cost;
        }
    }
}


Measured memory_bytes: 27348
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    int a, b;
    cin >> a >> b;
    cout << max(a - 2 * b , 0) << endl;
    return 0;
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i, n) for (ll i = 0; i < (n); i++)
#define forn for (ll i = 0; i < (n); i++)
#define fori(i, k, n) for (ll i = k; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}
template <typename T>
void print(vector<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(deque<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(vector<vector<T>> &a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

int main()
{
	fast;
	ll n, k;
	cin >> n >> k;
	// cout << n * 2 << " " << n * 4 << " " << en;
	if (k % 2 == 0 && (k >= n * 2 && k <= n * 4))
	{
		cout << "Yes" << en;
	}
	else
	{
		cout << "No" << en;
	}
}

Measured memory_bytes: 3648
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n, m; cin>>n>>m;
    vector<vector<int>> G(n);
    for(int i=0; i<m; i++){
        int s, t; cin>>s>>t;
        s--, t--;
        G[s].emplace_back(t);
    }

    vector<double> dp(n, 0);
    for(int cv=n-2; cv>=0; cv--){
        for(auto nv : G[cv]) dp[cv] += dp[nv];
        dp[cv] /= G[cv].size();
        dp[cv] += 1;
    }

    double ans = dp[0];

    for(int cv=0; cv+1<n; cv++){
        auto dp2 = dp;
        for(int i=0; i<=cv; i++) dp2[i] = 0;

        if(2 <= G[cv].size()){
            vector<double> v;
            for(auto nv : G[cv]) v.emplace_back(dp2[nv]);
            sort(v.begin(), v.end());

            for(int i=0; i+1<v.size(); i++) dp2[cv] += v[i];
            dp2[cv] /= (G[cv].size() - 1);
            dp2[cv] += 1;
        }
        else continue;

        for(int i=cv-1; i>=0; i--){
            for(auto nv : G[i]) dp2[i] += dp2[nv];
            dp2[i] /= G[i].size();
            dp2[i] += 1;
        }

        chmin(ans, dp2[0]);
    }

    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int>a(n);
  int ans=0;
  vector<int>l(n);
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n-1;i++)
  {
    l[i+1]=__gcd(a[i],l[i]);
  }
  vector<int>r(n);
  for(int i=n-1;i>=1;i--)
  {
    r[i-1]=__gcd(r[i],a[i]);
  }
  for(int i=0;i<n;i++)ans=max(ans,__gcd(l[i],r[i]));
  cout<<ans<<endl;

  return 0;
  
}

Measured memory_bytes: 1408
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class EWhoSaysAPun {
public:

    void Zalgorithm(vector<int>& A, string& S) {
      A[0] = S.size();
      int i = 1, j = 0;
      while (i < S.size()) {
        while (i+j < S.size() && S[j] == S[i+j]) ++j;
        A[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;
        i += k; j -= k;
      }
    }

    void solve(istream& cin, ostream& cout) {
      //SPEED;
      int n; cin >> n;
      string s; cin >> s;
      int ans = 0;
      rep(i, n) {
        string t;
        for(int j=i; j<n; j++) {
          t.push_back(s[j]);
        }
        // i to n-1;
        vector<int> a(n-i);
        Zalgorithm(a, t);
        for(int j=0; j<n-i; j++) {
          int k = j;
          int l = (n-i-j);
          int now = a[j];
          debug(a[j], k, l);
          chmin(now, k);
          chmin(now, l);
          debug(i,j,now);
          chmax(ans, now);
        }
      }
      cout << ans << endl;


    }
};

signed main() {
  EWhoSaysAPun solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char **argv)
{
    int k, s;
    scanf("%d %d", &k, &s);

    int c = 0;
    for (int x = 0; x <= k; ++x) {
        for (int y = 0; (y <= k && y <= s-x); ++y) {
            int z = s - x - y;
            if (0 <= z && z <= k) {
                c++;
            }
        }
    }
    printf("%d\n", c);
    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
n = int(input())
s = input()

c = 0

for i in range(10):
    i = str(i)
    for j in range(10):
        j = str(j)
        for k in range(10):
            k = str(k)
            if i in s:
                t = s[s.index(i)+1:]
                if j in t:
                    u = t[t.index(j)+1:]
                    if k in u:
                        c+=1
print(c)


Measured memory_bytes: 72304
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T &a, T b) {if (a < b) {a = b;return 1;}return 0;}
template<class T> inline bool chmin(T &a, T b) {if (a > b) {a = b;return 1;}return 0;}

int main(){
  int k,a,b;
  cin >> k >> a >> b;
  for (int i = 1; i < b+1; i++) {
    if (a <= i * k && i * k <= b) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
using namespace std;
typedef long long ll;

int main(){
  string S;
  cin >> S;
  int S_length = S.size();
  for(int i = 0; i < S_length; i++){
    cout << "x";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for (int i = 0; i + 2 < n; i++) ans += s.substr(i, 3) == "ABC";
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MAXN=110000;
int N,M,S,T;
vector<int> adj[MAXN];
int d[MAXN][3];

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	cin>>N>>M;
	rep(i,0,M) {
		int x,y;
		cin>>x>>y;
		x--,y--;
		adj[x].push_back(y);
	}
	cin>>S>>T;
	S--,T--;
	
	rep(i,0,N) rep(j,0,3) d[i][j]=-3;
	
	d[S][0]=0;
	queue<pair<int,int>> q;
	q.emplace(S,0);
	while (!q.empty()) {
		int v,k;
		tie(v,k)=q.front();
		q.pop();
		
		int nk=(k+1)%3;
		for (int u:adj[v]) if (d[u][nk]==-3) {
			d[u][nk]=d[v][k]+1;
			q.emplace(u,nk);
		}
	}
	
	cout<<d[T][0]/3<<"\n";
}


Measured memory_bytes: 7168
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tests int t;cin>>t;while(t--)
#define take(a,i,n) for(i=0;i<n;i++) cin>>a[i]
#define hell 1000000007
#define ret(a) { cout<<a; return 0;}
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);  cout.tie(0);
#define vi vector <int>
#define pii pair <int,int>
#define vii vector < pii >
#define pi 3.14159265
using namespace std;
//Auhtor:-Avinash
 
ll power(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 
 
ll modInverse(ll a, ll m) 
{  
    return power(a, m-2, m);  
} 

int main(){
    fastio
    int n;
    cin>>n;
    long long max=0;
    long long array[n];
    for(int i=0;i<n;i++){
      cin>>array[i];
    }
    sort(array,array+n);
    for(int i=0;i<n-2;i++){
      for(int j=i+1;j<n-1;j++){
        for(int k=j+1;k<n;k++){
          if(array[i]+array[j] > array[k] && array[i] != array[j] && array[j] != array[k] && array[i] != array[k]){
            max++;
          }
        }
      }
    }
    cout<<max;


}

Measured memory_bytes: 3656
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define endl '\n'
#define PB pop_back
#define pb push_back
#define mp make_pair
#define int long long
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef map<int , int> mii;
typedef pair<int , int> pii;
typedef map<string , int> msi;
int a , b;
bool bo[4];
int32_t main()
{
	cin >> a >> b , bo[a] = true , bo[b] = true;
	for(int i = 1 ; i <= 3 ; i ++)
		if(!bo[i])
			return cout << i << endl , 0;
	return 0;
}
	


Measured memory_bytes: 256
require 'prime'
N = gets.to_i

divs = N.prime_division.flat_map{|d, n|
  a = n/2; b = n-a
  [d**a, d**b]
}
divs = [1] if divs.empty?
len = divs.length
ans = Float::INFINITY
for b in 0..(2**len-1)
  pat = format("%0#{len}b", b).chars
  u = v = 1
  pat.zip(divs) do |group, d|
    group == "0" ? u *= d : v *= d
  end
  uu = u.to_s.length
  vv = v.to_s.length
  ans = [ans, [uu, vv].max].min
end
p ans


Measured memory_bytes: 2300
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        struct Node
        {
            internal int left;
            internal int right;
        }

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Node[] nodes = new Node[n];
            bool[] isChild = new bool[n];

            for (int i = 0; i < n; i++)
            {
                int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                nodes[input[0]].left = input[1];
                nodes[input[0]].right = input[2];

                if (input[1] != -1) isChild[input[1]] = true;
                if (input[2] != -1) isChild[input[2]] = true;
            }

            int rootIdx = Array.IndexOf(isChild, false);

            StringBuilder sb = new StringBuilder();
            sb.AppendLine("Preorder");
            Preorder(nodes, rootIdx, sb);
            Console.WriteLine(sb);

            sb = new StringBuilder();
            sb.AppendLine("Inorder");
            Inorder(nodes, rootIdx, sb);
            Console.WriteLine(sb);

            sb = new StringBuilder();
            sb.AppendLine("Postorder");
            Postorder(nodes, rootIdx, sb);
            Console.WriteLine(sb);
        }

        static void Preorder(Node[] nodes, int x, StringBuilder sb)
        {
            if (x == -1) return;

            sb.Append(" " + x);
            Preorder(nodes, nodes[x].left, sb);
            Preorder(nodes, nodes[x].right, sb);
        }

        static void Inorder(Node[] nodes, int x, StringBuilder sb)
        {
            if (x == -1) return;

            Inorder(nodes, nodes[x].left, sb);
            sb.Append(" " + x);
            Inorder(nodes, nodes[x].right, sb);
        }

        static void Postorder(Node[] nodes, int x, StringBuilder sb)
        {
            if (x == -1) return;

            Postorder(nodes, nodes[x].left, sb);
            Postorder(nodes, nodes[x].right, sb);
            sb.Append(" " + x);
        }
    }
}

Measured memory_bytes: 9664
N,M = map(int,input().split(" "))
ab = [0]*N
cd = [0]*M
for i in range(N):
    ab[i] = list(map(int,input().split(" ")))

for i in range(M):
    cd[i] = list(map(int,input().split(" ")))+[i+1]

for a,b in ab:
    m = min(cd,key=lambda x:10000*(abs(a-x[0])+abs(b-x[1]))+x[2])
    print(m[2])

Measured memory_bytes: 3316
N = int(input())
 
numss = [[0]*(10) for _ in range(10)]

for i in range(1, N+1):
  ss = str(i)
  hd = int(ss[0])
  tl = int(ss[-1])
  numss[hd][tl] += 1
  #print(f'hd = {hd}, tl = {tl}')
  
ans = 0
for x in range(1, 10):
  for y in range(1, 10):
    ans += numss[x][y] * numss[y][x]

print(ans)

Measured memory_bytes: 9208
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = input()
    c = I()
    a = eval(s)
    b = int(s[0])
    n = len(s)
    if n == 1:
        if int(s[0]) == c:
            print("U")
        else:
            print("I")
        quit()
    key = 0 if s[1] == "+" else 1
    for i in range(2,n):
        if not i%2:
            if key:
                b *= int(s[i])
            else:
                b += int(s[i])
        else:
            key = 0 if s[i] == "+" else 1
    if a == b:
        if a == c:
            print("U")
        else:
            print("I")
    elif a == c:
        print("M")
    elif b == c:
        print("L")
    else:
        print("I")
    return

#B
def B():
    n,m = LI()
    t = [0 for i in range(2*n+3)]
    for i in range(m):
        a,b = LI()
        t[2*a] += 1
        t[2*b+1] -= 1
    for i in range(2*n+1):
        t[i+1] += t[i]
    ans = n+1
    s = 0
    key = 1
    for i in t:
        if i > 0:
            if key:
                key = 0
                s += 1
            ans += 1
        else:
            key = 1
    ans -= s
    print(ans)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    B()



Measured memory_bytes: 8268
n, m = map(int, input().split())
if (m & 1):
    if n & 1:
        left_1 = 1
        right_1 = n // 2
        left_2 = (n // 2) + 1
        right_2 = n
    else:
        left_1 = 1
        right_1 = n // 2 - 1
        left_2 = (n // 2) + 1
        right_2 = n
else:
    if n & 1:
        left_1 = 1
        right_1 = n // 2
        left_2 = (n // 2) + 1
        right_2 = n
    else:
        left_1 = 1
        right_1 = n // 2 - 1
        left_2 = (n // 2) + 1
        right_2 = n
for _ in range(m // 2):
    print(left_1, right_1)
    left_1 += 1
    right_1 -= 1
for _ in range(m // 2, m):
    print(left_2, right_2)
    left_2 += 1
    right_2 -= 1


Measured memory_bytes: 70140
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        set<int> vis;
        for(int i=1;i<=n;i++) vis.insert(i);
        long long ans = 0;
        vector<pair<int, int> > dp1, dp2;
        for(int i=1;i<=n;i++){
            int k, l, r;
            cin >> k >> l >> r;
            dp1.emplace_back(make_pair(l-r, k));
            ans += r;
        }
        sort(dp1.begin(), dp1.end());
        reverse(dp1.begin(), dp1.end());
        for(int i=0;i<dp1.size();i++){
            int val = dp1[i].first, k = dp1[i].second;
            if(val <= 0){
                dp2.emplace_back(make_pair(val, k));
            }
            else{
                if(vis.upper_bound(k) == vis.begin()) dp2.emplace_back(make_pair(val, k));
                else{
                    auto it = (--(vis.upper_bound(k)));
                    vis.erase(it);
                    ans += val;
                }
            }
        }
        int cnt = 0;
        for(int i=1;i<=n;i++){
            if(vis.find(i) != vis.end()) cnt++;
        }
        vis.clear();
        for(int i=n;i>=n-cnt+1;i--) vis.insert(i);
        sort(dp2.begin(), dp2.end());
        for(int i=0;i<dp2.size();i++){
            int val = dp2[i].first, k = dp2[i].second;
            if(vis.upper_bound(k) == vis.end()){
                ans += val;
                auto it = vis.lower_bound(1);
                vis.erase(it);
            }
            else{
                auto it = vis.upper_bound(k);
                vis.erase(it);
            }
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 15696
n = int(input())
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)
if digitSum(n)%9 == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 11104
#include "bits/stdc++.h"

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

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

constexpr int nax = 1000 * 1000 + 105;
constexpr int infty = 1000 * 1000 * 1000 + 5;
constexpr int mod = 1000 * 1000 * 1000 + 7;

int n2;
int drz[nax * 2];

int odczyt(int a, int b) {
  assert(a <= b);
  a += n2;
  b += n2;
  int wynik = max(drz[a], drz[b]);
  while ((a / 2) != (b / 2)) {
    if (a % 2 == 0) wynik = max(wynik, drz[a + 1]);
    if (b % 2 == 1) wynik = max(wynik, drz[b - 1]);
    a /= 2;
    b /= 2;
  }
  return wynik;
}

void ustaw(int w, int x) {
  w += n2;
  while (w) {
    drz[w] = max(drz[w], x);
    w /= 2;
  }
}

int main() {
  int x1, y1, x2, y2;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  int il_x = 1, il_y = 1;
  if (x1 > x2) {
    il_x = -1;
  }
  if (y1 > y2) {
    il_y = -1;
  }
  x1 *= il_x;
  y1 *= il_y;
  x2 *= il_x;
  y2 *= il_y;
  int n;
  scanf("%d", &n);
  vector<pair<int, int>> punkty;
  punkty.emplace_back(x1, y1);
  punkty.emplace_back(x2, y2);
  while (n--) {
    int x, y;
    scanf("%d%d", &x, &y);
    x *= il_x;
    y *= il_y;
    if (x1 <= x and x <= x2 and y1 <= y and y <= y2) {
      punkty.emplace_back(x, y);
    }
  }
  vector<int> num;
  for (const auto& p : punkty) {
    num.push_back(p.first);
    num.push_back(p.second);
  }
  sort(num.begin(), num.end());
  num.resize(unique(num.begin(), num.end()) - num.begin());
  n2 = 1;
  while (n2 <= (int) num.size()) n2 *= 2;
  for (auto& p : punkty) {
    for (int* x : {&p.first, &p.second}) {
      *x = lower_bound(num.begin(), num.end(), *x) - num.begin();
    }
  }
  sort(punkty.begin(), punkty.end());
  int wynik = 0;
  for (const auto& p : punkty) {
    int val = odczyt(0, p.second);
    ustaw(p.second, val + 1);
    wynik = max(wynik, val + 1);
  }
  wynik -= 2;
  assert(wynik >= 0);
  debug() << imie(wynik);
  ll razem = 100ll * (abs(x1 - x2) + abs(y1 - y2)) - 20ll * wynik;
  constexpr long double pi = 3.1415926535897932384626433832795028841971l;
  long double result = razem + 5.0l * pi * wynik;
  if (wynik == abs(x1 - x2) + 1 or wynik == abs(y1 - y2) + 1) {
    result += 5.0l * pi;
  }
  printf("%.20Lf\n", result);
  return 0;
}


Measured memory_bytes: 7152
#include <stdio.h>

long long ABS(long long x){
    return (x>0) ? x : -x ;
}

int main(){
    long long N, K;
    scanf("%lld%lld", &N, &K);
    N %= K;
    while(1){
        if(N > ABS(N-K)){
            N = ABS(N-K);
        }else{
            break;
        }
    }
    printf("%lld\n", N);
    return 0;
}

Measured memory_bytes: 128
import java.io.*;

public class Main {
  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] value = br.readLine().split(" ");
    int a = Integer.parseInt(value[0]);
    int b = Integer.parseInt(value[1]);

    System.out.println(Math.max(a * b, Math.max(a + b, a - b))); 
  }
}


Measured memory_bytes: 21204
#bfs(両端キュー)
from collections import deque
import copy

h,w=map(int, input().split())
d=[list(input()) for i in range(h)]
inf=10**7

def bfs(sx,sy):
    a=copy.deepcopy(d)
    for i in range(h):
        for j in range(w):
            if a[i][j]=='.':
                a[i][j]=inf
    que=deque([[sy,sx]])
    a[sy][sx]=0

    while que:
        y,x=que.popleft()
        for i,j in [(1,0),(0,1),(-1,0),(0,-1)]:
            ny,nx=y+i,x+j
            if nx>=0 and nx<w and ny>=0 and ny<h:
                dist=a[ny][nx]
                if dist!='#':
                    if dist>a[y][x]+1:
                        a[ny][nx]=a[y][x]+1
                        que.append([ny,nx])

    m=0
    for i in range(h):
        for j in range(w):
            if a[i][j]!='#' and a[i][j]!=inf:
                if a[i][j]>m:
                    m=a[i][j]
    return m
    
# BFSのstartを決める
ans=0
for i in range(h):
    for j in range(w):
        if d[i][j]=='.':
            if ans<bfs(j,i):
                ans=bfs(j,i)
print(ans)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	fast;
	ll a[4];
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+3+1);
	if((a[1]==a[2]||a[2]==a[3])&&a[1]!=a[3])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}/*『你强归你强，Siyuan比你强』*/



//dfsdf

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647

int main() {
  kyun;
  int a,b;
  cin >> a >> b;
  int ans = 0;
  if(a >= b*2) ans = a - b*2;
  cout << ans;
  hinata;
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
from decimal import Decimal
#======================================================#
def main():
    a, b = IS().split()
    a = Decimal(a)
    b = Decimal(b)
    print(int(Decimal(a*b)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 10068
#include <iostream>
#include <algorithm>
#include <vector>

#define MAXN 100000
#define WHITE 0
#define GRAY 1
#define BLACK 2

using namespace std;

struct EDGE {
  int u, v;
} typedef edge;

bool operator< ( const edge& x, const edge& y )
{
  if ( x.u != y.u ) return x.u < y.u;
  else return x.v < y.v;
}

vector<int> V[MAXN];
vector<edge> E;
int ord[MAXN], par[MAXN], low[MAXN];
bool visited[MAXN];
int timer = 0;
int v, e;


void dfs ( int current, int pre )
{
  par[current] = pre;
  ord[current] = low[current] = timer;
  ++timer;

  visited[current] = true;
  for ( auto it = V[current].begin(); it != V[current].end(); ++it )
  {
    int next = *it;
    if ( !visited[next] )  {
      dfs(next, current);
      low[current] = min ( low[current], low[next] );
    } else if ( next != pre ) {
      low[current] = min ( low[current], ord[next] );
    }
  }

}

void jointpoint ( int root, int v )
{
  for ( int i = 0; i < v; ++i ) visited[i] = false;
  dfs( root, -1);
  for ( int i = 0; i < v; ++i ) visited[i] = false;
  int p = 0;

  for ( int i = 0; i < v; ++i ) {
    if ( i == root ) continue;
    if ( par[i] == root ) {
      ++p;
      continue;
    }
    if ( ord[par[i]] <= low[i] ) visited[par[i]] = true;
  }
  if ( p >= 2 ) visited[root] = true;

}

void bridge ( int root, int v )
{
  jointpoint(root,v);
  for ( int i = 0; i < v; ++i ) {
    for ( auto it = V[i].begin(); it != V[i].end(); ++it ) {
      int next = *it;
      if (  ord[i] < low[next] ) {
        E.push_back({min(i,next), max(i,next)});
      }
    }
  }

  sort ( E.begin(), E.end());
  cout << E.size() << "\n";


}

int main()
{
  cin >> v >> e;

  while(e--) {
    int s,t;
    scanf("%d%d", &s, &t);
    --s; --t;
    V[s].push_back(t);
    V[t].push_back(s);
  }

  bridge(0,v);
}


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

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

int D;
vector<int> c;
vector<vector<int>> s;
vector<int> solution;
vector<int> last(26);
vector<ll> type_score(26);

unsigned int xor128() {
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t;
    t = x ^ (x << 11);
    x = y; y = z; z = w;
    return w = w ^ (w >> 19) ^ (t ^ (t >> 8));
}

ll evaluate(vector<int>& sol) {
    fill(ALL(last), 0);

    REP(i, 26) type_score[i] = 0;

    REP(d, D) {
        int j = sol[d] - 1;
        last[j] = d + 1;
        REP(i, 26) {
            type_score[i] -= (d + 1 - last[i]) * c[i];
        }
        type_score[j] += s[d][j];
    }


    ll score = 1e6;
    REP(i, 26) score += type_score[i];

    return max(score, 0ll);
}

void simulated_annealing() {

    auto begin_time = chrono::steady_clock::now();
    auto cur_time = begin_time;
    ll time_elapsed = 0;
    const ll DURATION = 1900;

    double temperature = 1;

    vector<int> cur_state = solution;

    ll cur_score = evaluate(cur_state);
    ll best_score = cur_score;

    int iter = 0;

    while (true) {
        // check the time and update the temperature
        if (iter % 100 == 0) {
            cur_time = chrono::steady_clock::now();
            time_elapsed = chrono::duration_cast<chrono::milliseconds>(cur_time - begin_time).count();
            if (time_elapsed > DURATION) break;
            temperature = (double) (DURATION - time_elapsed) / DURATION;
        }

        // get the next state
        // pick a day and change it to other type
        int d = xor128() % D;
        int i = cur_state[d];
        int j = xor128() % 26 + 1;
        cur_state[d] = j;

        // calculate the score of the next state
        ll next_score = evaluate(cur_state);

        const ll R = 10000;
        bool force_next = temperature > (double) (xor128() % R) / R;
        if (time_elapsed < 1000) force_next = false;

        if (next_score > cur_score || force_next) {
            cur_score = next_score;
        } else {
            // roll back the change
            cur_state[d] = i;
        }

        // save the best state
        if (cur_score > best_score) {
            solution = cur_state;
            best_score = cur_score;
        }

        iter++;
    }
}

void greedy() {
    fill(ALL(last), 0);

    for (int d = 0; d < D; d++) {
        int j = 0, score = 0;
        for (int i = 0; i < 26; i++) {
            int nscore = s[d][i] + (d - last[i]) * c[i] * 5;
            if (nscore > score) {
                j = i;
                score = nscore;
            }
        }
        last[j] = d + 1;
        solution[d] = j + 1;
    }
}

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

    cin >> D;
    c.resize(26);
    REP(i, 26) cin >> c[i];
    s.resize(D, vector<int>(26));
    REP(i, D) REP(j, 26) cin >> s[i][j];
    solution.resize(D);

    greedy();
    simulated_annealing();

    REP(d, D) cout << solution[d] << endl;
}

Measured memory_bytes: 3708
/*dp[n] = 0;
    for(ll i = n-1; i >= 1; --i){
        dp[i] = INF;
        for(ll j = i+1; j <= n; ++j){
            dp[i] = min(dp[i], dp[j] + (a[i]-a[j])*(a[i]-a[j]) + c);   
        }
    }
    cout<<dp[1];*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll INF = 1e18, N = 200005;
ll n, c, a[N], dp[N];

struct L{
    ll a, b;
    ll value(ll x){
        return a * x + b;
    }
    pair<ll, ll> intersect(const L& temp) const{
        ll one = temp.b - b;
        ll two = a - temp.a;
        if(two < 0){ two *= -1; one *= -1; }
        return {one, two};
    }
};

int main() {
    cin>>n>>c;
    for(ll i = 0; i < n; i++){
        cin>>a[i];
    }
    vector<L> lines;
    ll start = 0;
    for(ll i = 0; i < n; i++){
        while(start <= (ll)lines.size()-2){
            L A = lines[start];
            L B = lines[start+1];
            if(A.value(a[i]) >= B.value(a[i])){start++;}else{break;}
        }
        ll best = 0;
        if(i != 0){
            best = lines[start].value(a[i]) + a[i]*a[i] + c;
        }
        L line = {-2 * a[i], best + a[i]*a[i]};
        while(start <= (ll)lines.size()-2){
            L A = lines[(ll)lines.size()-2];
            L B = lines[(ll)lines.size()-1];
            pair<ll, ll> one = A.intersect(B);
            pair<ll, ll> two = B.intersect(line);
            if((__int128)one.first * two.second >= (__int128)one.second * two.first){
                lines.pop_back();
            }else{
                break;
            }
        }
        lines.push_back(line);    
        if(i == n-1){
            cout<<best;
        }
    }
	return 0;
}

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

#define REP(i,n) for(decltype(n) i=0; i<(n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define st first
#define nd second
#define pb push_back

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

void solve(){
    map<char, int> cnt;
    string s;
    int h,w;
    cin>>h>>w;
    REP(_,h){
        cin>>s;
        for(char c : s)
            cnt[c]++;
    }
    vector<int> v;
    for(auto& p : cnt)
        v.pb(p.second);
    if(h%2 == 0 && w%2 == 0)
        cout<<(all_of(ALL(v), [](int n){return n%4 == 0;})?"Yes\n":"No\n");
    else if(h%2 == 1 && w%2 == 1) {
        int a=0,b=0;
        for(int i : v){
            if(i%2 == 1)
                ++a;
            else if(i%4 == 2)
                ++b;
        }
        cout<<(a==1 && b<=(w+h-2)/2 ? "Yes\n":"No\n");
    } else {
        int k = w%2==1 ? h : w;
        k /= 2;
        int a=0, b=0;
        for(int i : v){
            if(i%2 == 1)
                ++a;
            else if(i%4 == 2)
                ++b;
        }
        cout<<(a==0 && b<=k ? "Yes\n":"No\n");
    }
}

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


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
//#include <algorithm>
#include <vector>
 
int main(int argc, char* argv[])
{
    long d, g;
    scanf("%ld %ld", &d, &g);

    std::vector<long> p(d);
    std::vector<long> c(d);
    long i, j;
    for(i=0; i<d; i++) {
        scanf("%ld %ld", &(p[i]), &(c[i]));
    }

    long ans = 1000000000;

    long max = (1<<d);
    for(i=0; i<max; i++) {
        long   num = 0;
        long   value = 0;
        for(j=0; j<d; j++) {
            if(i & (1<<j)) {
                value += (100*(j+1)*p[j] + c[j]);
                num += p[j];
            }
        }
        
        for(j=d-1; j>=0; j--) {
            if(value >= g) {
                break;
            }
            if(i & (1<<j)) {
                continue;
            }
            long aa = ((g - value) - 1) / (100*(j+1)) + 1;
            if(aa > p[j]) {
                aa = p[j];
            }
            value += (100*(j+1))*aa;
            num += aa;
        }
        if(value >= g) {
            if(ans > num) {
                ans = num;
            }
        }
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef   long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
	int n;
	cin>>n;
	int x=n%10;
	if(x==3)cout<<"bon";
	else if(x==0 || x==1 || x==6 || x==8)cout<<"pon";
	else cout<<"hon";	

}

int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;

int main() {
  int n, x;
  cin >> n >> x;
  vi a(n);
  ll s = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    int t = max(0, a[i] - x);
    s += t;
    a[i] -= t;
  }
  for (int i = 1; i < n; ++i) {
    int t = max(0, a[i] + a[i-1] - x);
    a[i] -= t;
    s += t;
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 640
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

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

func main() {
	a, b := nextInt(), nextInt()

	for x := 1; x < 1500; x++ {
		if int(float64(x)*0.08) == a && int(float64(x)*0.1) == b {
			fmt.Println(x)
			return
		}
	}
	fmt.Println(-1)
}


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

using ll=int64_t;

int main() {
  ll N; cin >>N;
  vector<ll> A(N);
  rep(i,0,N) {
    cin >>A[i];
    if (A[i]==0) {
      cout <<0 <<endl;
      return 0;
    }
  }

  ll check=1e18;
  ll ans=A[0];
  rep(i,1,N) {
    if (ans>check/A[i]) {
      cout <<-1 <<endl;
      return 0;
    } else {
      ans*=A[i];
    }
  }
  cout <<ans <<endl;
  return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}
bool same(const vector<int>&a, const vector<int>&b){
  int n = (int)a.size();
  for(int i = 0; i < n; ++i){
    if(a[i] != b[i])return false;
  }
  return true;
}
int main(){
  int n; cin >> n;
  vector<int> v(n), w(n); cin >> v >> w;
  vector<int> u;
  for(int i = 1; i <= n; ++i)u.push_back(i);
  ll a=0, b=0;
  {
    ll idx = 0;
    do{
      if(same(v,u))a = idx;
      if(same(w,u))b = idx;
      idx++;
    }while(next_permutation(u.begin(),u.end()));
  }
  cout << abs(b-a)  << endl;
  return 0;
}


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

int main(){
  int N;
  cin>>N;
  bool flag=false;
  for(int i=1;i<10;i++){
    if(N%i==0&&N/i<10){
      flag=true;
    }
  }
  
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
ll arr[200005];
ll brr[200005];
vi v;
ll n, m, k;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m >> k;
	REP(i, 0, n){
		cin >> arr[i];
	}
	REP(i, 0, m){
		cin >> brr[i];
	}
	ll cur = 0;
	REP(i, 0, m){
		v.PB(cur);
		cur += brr[i];
	}
	v.PB(cur);
	
	ll ans = 0;
	ll x = (upper_bound(v.begin(), v.end(), k) - v.begin());
	x -= 1;
	ans = max(ans, x);
	
	REP(i, 0, n){
		k -= arr[i];
		if (k < 0) break;
		ll x = (upper_bound(v.begin(), v.end(), k) - v.begin());
		ans = max(ans, (ll)i + (ll)1 + x - (ll)1);
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 8424
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
#define mk make_pair
using namespace std;
typedef pair<int,int>P;
int s[100011],ans,n;
main(){
	cin>>n;
	int a[n];
	r(i,n)cin>>a[i];
	r(i,n){
		s[a[i]]++;
		if(a[i]!=0)s[a[i]-1]++;
		s[a[i]+1]++;
	}
	r(i,100011)ans=max(ans,s[i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	} else if (a % b) {
		return gcd(b, a % b);
	} else {
		return b;
	}
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;  // Be careful not to overflow
}

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

	int a, b;

	cin >> a >> b;

	cout << lcm(a, b) << endl;

	return 0;
}

Measured memory_bytes: 256