akhauriyash/Code-Regression huggingface dataset:
S = str(input())
while "eraser" in S:     
    S=S.replace("eraser","")
while "erase" in S: 
    S=S.replace("erase","")
while "dreamer" in S: 
    S=S.replace("dreamer","")
while "dream" in S: 
    S=S.replace("dream","")
if len(S) == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
n = io.read("*n")
a, b = {}, {}
for i = 1, n do
  z = io.read("*n")
  if i % 2 == 1 then
    table.insert(a, z)
  else
    table.insert(b, z)
  end
end
if n % 2 == 0 then
  c = {}
  for i = #b, 1, -1 do
    table.insert(c, b[i])
  end
  for i = 1, #a do
    table.insert(c, a[i])
  end
  print(table.concat(c, " "))
else
  c = {}
  for i = #a, 1, -1 do
    table.insert(c, a[i])
  end
  for i = 1, #b do
    table.insert(c, b[i])
  end
  print(table.concat(c, " "))
end


Measured memory_bytes: 24276
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define fir first
#define sec second
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
int main(){
    int q;
    cin>>q;
    ll x=0,y=0;
    while(q--){
        ll a,c;char b;
        cin>>a>>b>>c;
        if(b=='(')x+=c;
        else y+=c;
        if(x==y)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3104
import java.util.Scanner

object Main {

  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val a = IndexedSeq.fill(n)(sc.nextInt())
    (n, a)
  }

  def output(result: IndexedSeq[Long]) = {
    val out = new java.io.PrintWriter(System.out)
    result.foreach(out.println)
    out.flush()
  }

  def solve(n: Int, lst: IndexedSeq[Int]): IndexedSeq[Long] = {
    def comb2(x: Int): Long = x.toLong * (x.toLong - 1) / 2

    val pool = {
      val tmp = Array.fill(n + 1)(0)
      for (e <- lst) {
        tmp(e) += 1
      }
      tmp.toIndexedSeq
    }
    val poolCmb = pool.map(comb2)
    val sumAll = poolCmb.sum

    for (k <- 0 until n) yield {
      sumAll - poolCmb(lst(k)) + comb2(pool(lst(k))-1)
    }
  }

  def main(args: Array[String]): Unit = {
    val (n, a) = read()
    output(solve(n, a))
  }
}

Measured memory_bytes: 81328
import sys
from collections import Counter

N = int(input())
a = list(map(int, input().split()))

b = list(Counter(a).items())
if sum(a) == 0:
    print("Yes")
    sys.exit()
    
if N % 3 == 0:
    if len(b) != 3:
        if len(b) == 2 and min(b[0][0], b[1][0]) == 0 and min(b[0][1], b[1][1]) == N // 3:
            print("Yes")
            sys.exit()
        print("No")
        sys.exit()
    if b[0][0] ^ b[1][0] ^ b[2][0] != 0 or b[0][1] != N // 3 or b[1][1] != N // 3:
        print("No")
        sys.exit()
    print("Yes")
else:
    print("No")

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

typedef long long ll;
const int MAX_N = 100000;

int main() {
	int N, cnt[5] = {};
	std::string march = "MARCH";
	std::cin >> N;
	for(int i = 0; i < N; ++i) {
		std::string S;
		std::cin >> S;
		for(int j = 0; j < 5; ++j) {
			if(S[0] == march[j]) ++cnt[j];
		}
	}

	ll ans = 0;
	for(int i = 0; i < 5; ++i) {
		for(int j = i + 1; j < 5; ++j) {
			for(int k = j + 1; k < 5; ++k) {
				ans += (ll) cnt[i] * cnt[j] * cnt[k];
			}
		}
	}

	std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n,k;
 	cin>>n>>k;
 	ll pw=1LL;
 	ll ans=0;
 	while(n>0)
 	{
 		n/=k;
 		ans++;
 	}	
 	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<numeric>
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
const int maxn=1000000;
#define what_is(x) cerr << #x << " is " << x << endl;
const int MOD = 1e9 + 7;
using namespace std;
string abc="abcdefghijklmnopqrstuvwxyz";
int powmod(int a, int b, int MOD = MOD){
    if(!a and !b)    return 1ll;
    if(!a)    return a;
    int res = 1ll;
    b %= (MOD - 1ll), a %= MOD;
    while(b){
        if(b%2 == 1)    res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }
    return res;
}
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
bool check(int n) {return (((double)sqrt(n)-floor((double)sqrt(n)))==0);}
vector<bool> sieve(maxn + 1, true);
void fillprime() {
    sieve[0] = sieve[1] = false;
    for (int i = 2; i <= maxn; ++i) {
        if (sieve[i] && (int) i * i <= maxn) {
            for (int j = i * i; j <= maxn; j += i) {
                sieve[j] = false;
            }
        }
    }
}
const int nn=1e5+5;
bool isPowerOfTwo(int n)
{
    if(n==0)
        return false;

    return (ceil(log2(n)) == floor(log2(n)));
}
void solve() {
   char ch;
   cin>>ch;
   if(isupper(ch)) cout<<"A";
   else cout<<'a';
}
int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //int t;cin>>t;while(t--)
        solve();
}

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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, ans = INF;
	int p[4], t[4], dp[1100] = {};
	
	cin>>N;
	
	for(int i = 0; i < 4; i++){
		cin>>p[i];
	}
	for(int i = 0; i < 4; i++){
		cin>>t[i];
	}
	
	for(int i = 1; i < 1100; i++){
		dp[i] = INF;
	}
	
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 1100; j++){
			if(dp[j] != INF){
				if(j+t[i] < 1100) dp[j+t[i]] = min(dp[j+t[i]], dp[j] + p[i]);
			}
		}
	}
	
	for(int i = N; i < 1100; i++){
		ans = min(ans, dp[i]);
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;

#define sync std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define loopi(n) for(int i=0;i<n;i++)
#define loopj(n) for(int j=0;j<n;j++)
#define loop(a,b,c) for(int i=a;i<=b;i=i+c)

#define     deb(x)      cout<<#x<<"="<<x<<endl
#define     all(x)      (x).begin(),(x).end()
#define     reset(a)    memset(a,0,sizeof(a))
#define     sz(x)       ((int)(x.size()))
#define     pb          push_back
#define     pf          push_front
#define     pob	        pop_back
#define     pof         pop_front
#define     ins         insert
#define     F           first
#define     S           second
#define     mkp         make_pair
#define     mkt         make_tuple
#define     bitcount(x) __builtin_popcountll(x)
#define     gcd(a,b)    (__gcd(a,b))
#define     lcm(a,b)    ((a*b)/gcd(a,b))
#define PI 3.1415926535897932384626

const int mod = 998244353;
const int N=1e5+5;
//=======================
bool vis[N+1];

void DFS(vector<int> v[],int i)
{
	vis[i]=true;
	for(auto c: v[i])
		if(!vis[c])
			DFS(v,c);
}


void solve()
{
	int n,m;
	cin>>n>>m;
	vector<int> v[n+1];
	loopi(m)
	{
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	memset(vis,false,sizeof(vis));
	
	int c=0;
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			DFS(v,i);
			c++;
		}
	}
	cout<<c-1;

}

int main() 
{
	sync;

	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
	}
}

Measured memory_bytes: 10088
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(m);   (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
  ll L;cin>>L;
  ld l1=L*1.0/3;
  cout<<fixed<<setprecision(10)<<l1*l1*l1;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;

class Cube{
    public:
    int f[6];
    
    void roll_x(){
        roll(0, 1, 5, 4);
    }
    void roll_y(){
        roll(0, 2, 5, 3);
    }
    void roll_z(){
        roll(1, 2, 4, 3);
    }
    void roll(int i, int j, int k, int l){
        int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
    }
};

bool eq(Cube c1, Cube c2){
    for(int i = 0; i < 6; i++){
        if(c1.f[i] != c2.f[i]) return false;
    }
    return true;
}

bool equal(Cube c1, Cube c2){
    for(int i = 0; i < 6; i++){
        for(int j = 0; j < 4; j++){
            if(eq(c1, c2)) return true;
            c1.roll_z();
        }
        if(i % 2 == 0) c1.roll_y();
        else c1.roll_x();
    }
    return false;
}

int main(){
    Cube c1, c2;
    
    for(int i = 0; i < 6; i++) cin >> c1.f[i];
    for(int i = 0; i < 6; i++) cin >> c2.f[i];
    
    if(equal(c1,c2)) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>



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

  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }
  vector<int> b(n);
  rep(i,n){
    b[i]=i+1;
  }

  int c=0;
  rep(i,n){
    if(a[i]!=b[i]) c++;
  }

  if(c<=2){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
 
using namespace std;

int main (){
    int A,B,K,c;
	
	cin >> A >> B >> K;

	c = 0;
	rel(i,max(A,B),1){
		if(A%i==0 && B%i==0){
			c++;
		}
		if(c==K){
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
N = gets.to_i
S = gets.chomp

a = %W(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)
 
ans = ""
len = S.length - 1
s = S.split("")
for i in 0..len do
  ans = ans + a[(a.index(s[i]) + N) % 26]
end
puts ans

Measured memory_bytes: 19836
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s.size()%2==0)
		cout<<"No"<<endl;
	else
	{
		string s1;
		s1 = s;
		reverse(s1.begin(),s1.end());
		if(s1!=s)
			cout<<"No"<<endl;	
		else
		{
			s1="";
			for(int i=0;i<s.size()/2;i++)
				s1 = s1 + s[i];
			string s2;
			s2=s1;
			reverse(s1.begin(),s1.end());
			if(s1!=s2)	
				cout<<"No"<<endl;	
			else
			{
				s1="";
				for(int i=s.size()/2+1;i<s.size();i++)
					s1 = s1 + s[i];
				s2=s1;
				reverse(s1.begin(),s1.end());
				if(s1!=s2)	
					cout<<"No"<<endl;	
				else
					cout<<"Yes"<<endl;	
			}	
		}
	}	
}

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

int main()
{
    int n;
    cin >> n;
    int mod = 1000000007;
    long answer = 1;
    for (int i = 1; i <= n; i++)
    {
        answer = ((answer % mod) * (i % mod)) % mod;
    }
    cout << answer << endl;
}

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

void solve(){
    int64_t A, B, C, D;
    cin >> A >> B >> C >> D;
    int64_t K = max((A+B)/(B+1), (A+B)/(A+1));

    int64_t ok = -1, ng = B+1;
    while(ng-ok>1){
        int64_t v = (ok+ng)/2;
        int64_t a = A - K*v, b = B - v;
        int64_t y = b/K;
        a -= y;
        (a >= 0 ? ok : ng) = v;
    }
    int64_t x = ok, y = (B-ok)/K;
    int64_t a = A - K*x - y, b = B - x - K*y;
    int64_t X = x*(K+1);

    for(int c=C; c<=D; c++){
        if(c <= X){
            cout << (c%(K+1) == 0 ? 'B' : 'A');
        }else if(c <= X+a){
            cout << 'A';
        }else if(c <= X+a+b){
            cout << 'B';
        }else{
            int c2 = c - (X+a+b);
            cout << (c2%(K+1) == 1 ? 'A' : 'B');
        }
    }
    cout << endl;
}

int main(){
    int Q;
    cin >> Q;
    while(Q--) solve();
    return 0;
}

Measured memory_bytes: 384
import math

X, N = map(int, input().split())
if N == 0:
  print(X)
else:
  p = list(map(int, input().split()))
  q = [int(i)-10 for i in range(121)]
  #print(q)

  for i in p:
    q.remove(i)

  ans = 0
  r0 = 100000
  for j in q:
    r = abs(j-X)
    if r0 > r:
      r0 = r
      ans = j
  print(ans)

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define ull unsigned long long
#define ll long long

void add(int &a,int b){
    a+=b;
    if(a>=mod)
        a-=mod;
}
int nCr(long long m, long long n){

    //6 * 5 * 4 *../ 1*2*3*...
    int ans = 1;
    for (long long i = 1; i <= n; i++){
        ans = ans * (m - i + 1) / i;
 
    }
    return ans;
}

int32_t main()
{
    int n;cin>>n;
    map<int,int> mp;
    int sum=0;
    for(int i=0;i<n;i++){
        int t;cin>>t;
        mp[t]++;
        sum+=t;
    }
    int t;cin>>t;
    while(t--){
        int x,y;cin>>x>>y;
        int p=mp[x];
        sum-=(p*x);
        mp[x]=0;
        mp[y]+=p;
        sum+=p*y;
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 9384
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	string S; cin >> S;
	for (int i = 0; i < S.length() - 1; ++i)
	{
		if (S[i] == 'A' && S[i + 1] == 'C')
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 3628
import math


def nCr(n,r):
    if n<r:
        return 0
    
    result = math.factorial(n)//math.factorial(r)//math.factorial(n-r)
    return result

N,M = map(int,input().split())

total = nCr(N,2) + nCr(M,2)

print(total)




Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B,K;
    cin>>A>>B>>K;
    for(int i=min(A,B);i>=1;i--){
        if(A%i==0 && B%i==0)K--;
        if(K==0){
            cout<<i<<endl;
            return 0;
        }    
    }
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

//chmin,chmax
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin>>s;
    ll res=0;
    res+=count(all(s),'+');
    res-=count(all(s),'-');
    cout<<res<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;

int main() {
  int n;cin>>n;
  int ans = 0;
  int l,r;rep(i,n) {
    cin>>l>>r;
    ans += r - l + 1;
  } 
  cout << ans << endl;
}


Measured memory_bytes: 256
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N, long long M, std::vector<long long> L, std::vector<long long> R){
  vl pos(N+1);
  rep(i,M){
    pos[L[i]-1] += 1;
    pos[R[i]] -= 1;
  }
  rep(i,N) pos[i+1] += pos[i];
  ll ans = 0;
  rep(i,N){
    if(pos[i]==M) ans++;
  }
  cout << ans << endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> L(M);
  std::vector<long long> R(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&L[i]);
    scanf("%lld",&R[i]);
  }
  solve(N, M, std::move(L), std::move(R));
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define int long long
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int a[200010];
int num1=0,num2=0,num3=0;
int sum1=0,sum2=0,sum3=0;
inline bool check(int m){
	if(m==0){
		if(sum1+sum2>=k)return true;
		return false;
	}
	if(m>0){
		int sum=0;
		for(register int i=1;i<=num1;i++){
			int l=i+1,r=num1,ans=num1+1;
			while(l<=r){
				int mid=(l+r)>>1;
				if(a[mid]*a[i]<=m){r=mid-1;ans=mid;}
				else l=mid+1;
			}
			sum+=num1-ans+1;
		}
		for(register int i=num1+num2+1;i<=n;i++){
			int l=i+1,r=n,ans=i;
			while(l<=r){
				int mid=(l+r)>>1;
				if(a[mid]*a[i]<=m){l=mid+1;ans=mid;}
				else r=mid-1;
			}
			sum+=ans-i;
		}
		return sum+sum1+sum2>=k;
	}
	if(m<0){
		int sum=0;
		for(register int i=1;i<=num1;i++){
			int l=num1+num2+1,r=n,ans=n+1;
			while(l<=r){
				int mid=(l+r)>>1;
				if(a[mid]*a[i]<=m){r=mid-1;ans=mid;}
				else l=mid+1;
			}
			//cout<<m<<" "<<i<<" "<<ans<<endl;
			sum+=n-ans+1;
		}
		//cout<<m<<" "<<sum<<endl;
		return sum>=k;
	}
}

signed main(){	
	n=read();k=read();
	for(register int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
	for(register int i=1;i<=n;i++){
		if(a[i]<0)num1++;
		if(a[i]==0)num2++;
		if(a[i]>0)num3++;
	}
	sum1=num1*num3;sum2=num2*(num1+num3)+num2*(num2-1)/2;sum3=num1*(num1-1)/2+num3*(num3-1)/2;
	//cout<<num1<<" "<<num2<<" "<<num3<<" "<<sum1<<" "<<sum2<<" "<<sum3<<endl;
	int l=-1e18,r=1e18,ans;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid)){r=mid-1;ans=mid;}
		else l=mid+1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
l,r=map(int,input().split())
amari = 2018
if r-l > 2019:
  print(0)
else:
  for i in range(l, r+1):
    for j in range(i+1, r+1):
      temp = (i*j)%2019
      if temp < amari:
        amari = temp
     
  print(amari)

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int N; cin >> N;
    string S; cin >> S;
    int res = 0, score = 0;
    rep(i, 0, N) {
      if (S[i] == 'I') ++score;
      else --score;
      res = max(res, score);
    }
  
    cout << res << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int bit_search(int H, int W, int K, vector<vector<char>> c) {
    int sum = 0;
    vector<vector<char>> d;
    for (int bit_h = 0; bit_h < (1 << H); ++bit_h) {
        for (int bit_w = 0; bit_w < (1 << W); ++bit_w) {
            int black = 0;
            d = c;
            for (int i = 0; i < H; i++) {
                if (bit_h & (1 << i)) {
                    for (int j = 0; j < W; j++){
                        d.at(i).at(j) = '-';
                    }
                }
            }
            for (int j = 0; j < W; j++) {        
                if (bit_w & (1 << j)) {
                    for (int i = 0; i < H; i++) {
                        d.at(i).at(j) = '-';
                    }
                }
            }
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (d.at(i).at(j) == '#') black++;
                }
            }
            if (black == K) sum++;
        }
    }
    return sum;
}

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++) cin >> S.at(i);
    int ac = 0, wa = 0, tle = 0, re = 0;
    for (int i = 0; i < N; i++) {
        if (S.at(i) == "AC") ac++;
        else if (S.at(i) == "WA") wa++;
        else if (S.at(i) == "TLE") tle++;
        else re++;
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using ll = long long;

ll comb(int x, int y) {
  ll sum = 1;
  for (int i = 1; i <= y; i++) {
    sum *= x - i + 1;
    sum /= i;
  }
  return sum;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end(), greater<ll>());
  double avg = 0;
  for (int i = 0; i < a; i++) {
    avg += v[i];
  }
  avg /= a;
  for (int i = 0; i < a;) {
    int cnt = upper_bound(ALL(v), v[i], greater<ll>()) - lower_bound(ALL(v), v[i], greater<ll>());
    if (i == 0 && i + cnt > a) {
      int mn = a - i;
      int mx = min(cnt, b - i);
      ll sum = 0;
      for (int j = mn; j <= mx; j++) {
        sum += comb(cnt, j);
      }
      printf("%.8f\n", avg);
      printf("%lld\n", sum);
      return 0;
    } else if (i > 0 && i + cnt > a) {
      printf("%.8f\n", avg);
      printf("%lld\n", comb(cnt, a - i));
      return 0;
    }
    i += cnt;
  }
  printf("%.8f\n", avg);
  printf("1\n");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
int a[100010];
int cnt[100010];

int main () {
  cin >> N;
  for (auto i = 0; i < N; ++i) {
    cin >> a[i];
  }
  fill(cnt, cnt+100010, 0);
  for (auto i = 0; i < N; ++i) {
    cnt[a[i]]++;
  }
  int ans = 0;
  for (auto i = 1; i < 100004; ++i) {
    ans = max(ans, cnt[i-1] + cnt[i] + cnt[i+1]);
  }
  cout << ans << endl;
}


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

var pw = PrintWriter(System.out)
fun solve(N: Long){
    println(if(N >=1000) "ABD" else "ABC")
    pw.flush()
    return
}


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



Measured memory_bytes: 31400
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int main(void){
	int n;
	scanf("%d",&n);
	int a,k;
	int res=0;
	for (int i=1;i<=n;++i){
		scanf("%d%d",&a,&k);
		while(true){
			if (a<k) break;
			if (!(a%k)) break;
			int st=a/k,beg=st*k;
			a-=(a-beg+st)/(st+1)*(st+1);
		}
		if (a<k) continue;
		res^=(a/k);
	}
	puts(res?"Takahashi":"Aoki");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
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(){
    ll n;cin>>n;
    ll ans = 0;
    for(int i = 1;i<n;++i){
        for(int j=1;j*j<=i;j++){
            if(i%j==0){
                ans++;
                if(i/j != j)ans++;
            }
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <unordered_set>

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	unordered_set<char> us;
	for (auto&& ch : s)
		us.insert(ch);
	for (auto&& ch : t)
		if (us.find(ch) == us.end()) {
			cout << -1;
			return 0;
		}
	size_t pos = 0, res = 0;
	for (auto&& ch : t) {
		auto tmp = s.find(ch, pos);
		if (tmp != string::npos)
			pos = tmp + 1;
		else {
			res += s.size();
			pos = s.find(ch) + 1;
		}
	}
	cout << res + pos;
}

Measured memory_bytes: 592
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;

  for( int i=0;i<(int)s.length();i++ ){
    s[i] -= 3;
    if( s[i] < 'A' )
      s[i] += 26;
  }
  cout << s << endl;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
int a[maxn];
int b[maxn];
int aa[maxn];
int bb[maxn];
int n;
int get_pos(int a[],int x){
    int l = -1, r = n;
    while (r - l > 1){
        int mid = (l + r) >> 1;
        if (a[mid] >=x) r = mid;
        else l = mid;
    }
    return r;
}

int get_pos2(int a[],int x){
    int l = -1, r = n;
    while (r - l > 1){
        int mid = (l + r) >> 1;
        if (a[mid] >= x) r = mid;
        else l = mid;
    }
    return r - 1;
}
int Get(int x){
    for (int i = 0; i < n; i++){
        aa[i] = a[i] % (1 << (x + 1));
        bb[i] = b[i] % (1 << (x + 1));
    }
    sort(bb,bb + n);
    int tot = 0;
    for (int i = 0; i < n; i++){
        int lower = get_pos(bb,(1 << x)  - aa[i]);
        int upper = get_pos2(bb,(1 << (x + 1)) - aa[i]);
        if (upper - lower + 1 >= 0){
            tot += upper - lower + 1;
        }
        int pos = get_pos(bb,(1 << x) + (1 <<  (x + 1)) - aa[i]);
        tot += n - pos;
    }
    return tot;
}

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

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

    int ans = 0;
    for (int i = 0; i <= 28; i++){
        int dig = Get(i);
        ans |= (1 << i) * (dig & 1);
    }

    printf("%d\n",ans);
}


Measured memory_bytes: 3328
R,C,K= map(int,input().split(" "))
original=[[0]*(C+1) for i in range(R+1)]
for _ in range(K):
    r,c,v= map(int,input().split(" "))
    original[r][c]=v
d1=[[0]*(C+1) for i in range(R+1)]
d2=[[0]*(C+1) for i in range(R+1)]
d3=[[0]*(C+1) for i in range(R+1)]
for i in range(1,R+1):
    for j in range(1,C+1):
        curr= original[i][j]
        d1[i][j]=max(d1[i-1][j]+curr,d2[i-1][j]+curr,d3[i-1][j]+curr,d1[i][j-1],curr)
        d2[i][j]=max(d2[i][j-1],d1[i][j-1]+curr)
        d3[i][j]=max(d3[i][j-1],d2[i][j-1]+curr)
print(max(d1[-1][-1],d2[-1][-1],d3[-1][-1]))

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

using namespace std;

using ll = long long;

const int N = (int)1e6 + 5, M = (int)5e5 + 5, mod = 998244353;
int n, m, fact[4 * M], inv_fact[4 * M], ans;

int add (int _a, int _b) {
    _a += _b;
    if (_a >= mod) _a -= mod;
    return _a;
}

int multi (int _a, int _b) { return (int)( (ll)_a * _b % mod); }

int bin_pow (int _a, int _n) {
    int ret = 1;
    for (; _n; _n >>= 1, _a = multi(_a, _a) ) if (_n & 1) ret = multi(ret, _a);
    return ret;
}

int C (int _k, int _n) {
    if (_k < 0 || _k > _n || _n < 0) return 0;
    return multi(fact[_n], multi(inv_fact[_k], inv_fact[_n - _k]) );
}

int candy_distribution (int _n, int _sum) { return C(_n - 1, _sum + _n - 1); }

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

    fact[0] = 1; for (int i = 1; i < 4 * M; ++i) fact[i] = multi(fact[i - 1], i);
    inv_fact[4 * M - 1] = bin_pow(fact[4 * M - 1], mod - 2);
    for (int i = 4 * M - 2; i >= 0; --i) inv_fact[i] = multi(inv_fact[i + 1], i + 1);

    cin >> n >> m;

    for (int n_odd = 0; n_odd <= m; ++n_odd) {
        int rem = 3 * m - n_odd;
        if (rem & 1) continue ;
        rem >>= 1;
        ans = add(ans, multi(C(n_odd, n), candy_distribution(n, rem) ) );
    }

    for (int exceed = 2 * m + 1; exceed <= 3 * m; ++exceed) {
        int rem = 3 * m - exceed;
        ans = add(ans, mod - multi(n, candy_distribution(n - 1, rem) ) );
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 16512
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int l=sc.nextInt();
		int sum1=0,sum2=0;
		int[] a=new int[n+1];
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				sum1+=l+j-1;
				if(j!=i)
				sum2+=l+j-1;
			}
			a[i]=sum1-sum2;
			if(a[i]<0)
			a[i]=-a[i];
			sum1=0;
			sum2=0;
		}
		int min=a[1];
		for(int i=1;i<=n;i++){
			if(min>a[i])
				min=a[i];
		}
		
		for(int i=1;i<=n;i++){
			if(min==a[i])
				for(int j=1;j<=n;j++){
					if(j!=i)
					sum2+=l+j-1;
				}
		}
		System.out.println(sum2);
		
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string a, b, c;
    cin >> a >> b >> c;
    if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;   
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

#[allow(unused_macros)]
macro_rules! debug {
    ($var:expr) => {
        match &$var { v => eprintln!(concat!(stringify!($var), "={:?}"), v) }
    };
    ($var:expr, $($vars:expr),*) => {
        match &$var { v => eprint!(concat!(stringify!($var), "={:?} "), v) }
        debug!($($vars),*);
    };
}

fn main() {
    let n: usize = input();
    let q: usize = input();
    let ab: Vec<(usize, usize)> = (0..n - 1).map(|_| (input(), input())).collect();
    let px: Vec<(usize, i64)> = (0..q).map(|_| (input(), input())).collect();

    let mut e = vec![vec![]; n];
    for &(a, b) in &ab {
        e[a - 1].push(b - 1);
        e[b - 1].push(a - 1);
    }

    let mut pp = vec![0; n];
    for &(p, x) in &px {
        pp[p - 1] += x;
    }

    let mut cnt = vec![0; n];
    dfs(0, 0, n, &mut cnt, &e, &pp);

    with_stdout_lock(|mut w| {
        for i in 0..n {
            write!(w, "{}{}", cnt[i], if i == n - 1 { '\n' } else { ' ' }).unwrap();
        }
    });
}

fn dfs(cur: usize, score: i64, prev: usize, cnt: &mut Vec<i64>, e: &Vec<Vec<usize>>, p: &Vec<i64>) {
    cnt[cur] = score + p[cur];
    for &next in &e[cur] {
        if next != prev {
            dfs(next, score + p[cur], cur, cnt, e, p);
        }
    }
}


Measured memory_bytes: 46588
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int p = n%10;
  if(p==3) cout << "bon\n";
  else if(p==0 || p==1 || p==6 || p==8) cout << "pon\n";
  else cout << "hon\n";

  return 0;
}


Measured memory_bytes: 3688
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

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

  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  ll ans = 0;
  if (k >= a) {
    ans += a;
    k -= a;
  } else {
    ans = k;
    cout << ans << endl;
    return 0;
  }
  if(k >= b){
    k -= b;
  } else {
    cout << ans << endl;
    return 0;
  }

  if(k >= c)  {
    ans -= c;
    k -= c;
  } else {
    ans -= k;
    cout << ans << endl;
    return 0;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int e ,f;
    e=a*c;
    if(e<b)
        cout<<c<<endl;
    else
        cout<<b/a<<endl;
    return 0;
}


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

using namespace std;

#define mid ((b + e) / 2)

const int N = 1e5 + 5;
const int maxn = 1e5;

vector< int> B[N + 5];
int seg[4 * N];
int value[N];

void build(int at, int b, int e) {
	if (b == e) {
		seg[at] = b;
		return;
	}

	build(at * 2, b, mid);
	build(at * 2 + 1, mid + 1, e);

	if (value[seg[at * 2]] > value[seg[at * 2 + 1]]) seg[at] = seg[at * 2];
	else seg[at] = seg[at * 2 + 1];
}

int query(int at, int b, int e, int l, int r) {
	if (e < l or r < b) return -1;
	if (l <= b and e <= r) return seg[at];
	int q1 = query(at * 2, b, mid, l, r);
	int q2 = query(at * 2 + 1, mid + 1, e, l, r);
	if (q1 == -1) return q2;
	if (q2 == -1) return q1;

	if (value[q1] > value[q2]) return q1;
	return q2;
}

void update(int at, int b, int e, int pos) {
	if (b == e) {
		seg[at] = b;
		B[b].pop_back();
		if (B[b].empty()) value[b] = 0;
		else value[b] = B[b].back();
		return;
	}
	if (pos <= mid) update(at * 2, b, mid, pos);
	else update(at * 2 + 1, mid + 1, e, pos);

	if (value[seg[at * 2]] > value[seg[at * 2 + 1]]) seg[at] = seg[at * 2];
	else seg[at] = seg[at * 2 + 1];
}


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

	int n, m;
	cin >> n >> m;

	for (int i = 1; i <= n; i ++) {
		int a, b;
		cin >> a >> b;
		B[a].emplace_back(b);
	}

	for (int i = 1; i <= 100000; i ++) {
		sort(begin(B[i]), end(B[i]));
		if (!B[i].empty()) value[i] = B[i].back();
	}

	build(1, 1, maxn);
	long long result = 0;


	for (int i = maxn - 1; i >= 0; i --) {
		int j = query(1, 1, maxn, 1, m - i);
		if (j != -1 && value[j] != 0) {
			result += value[j];
			update(1, 1, maxn, j);
		}
	}
	cout << result << endl;
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mod 1000000007
#define pi (3.141592653589)
#define deb(n) cerr << #n << " = " << (n) << " ";
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout << fixed;
	cout.precision(10);
	
	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a + n);
	int sol = 0;
	for(int i = 0; i < k; i++)
	{
		sol += a[i];
	}
	cout << sol;

	return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include<stdlib.h>
#define S_len 500001
#define INFI 1000000001

int comp = 0;
int L[S_len/2+2],R[S_len/2+2];

void merge(int *S, int left, int right, int mid){
    int i,j,k;
    int n1 = mid - left;
    int n2 = right - mid;
    
    for(i=0; i<n1;i++){
        L[i] = S[left + i];
    }
    for(i=0; i<n2; i++){
        R[i] = S[mid + i];
    }

    L[n1] = INFI;
    R[n2] = INFI;
    i=0; j=0;
    for(k=left; k<right; k++){
        comp++;
        if(L[i]<=R[j]){
            S[k] = L[i++];
        }else{
            S[k] = R[j++];
        }
    } 
}

void mergeSort(int *S,int left,int right){
    if(left+1 < right){
        int mid = (left + right)/2;
        mergeSort(S,left,mid);
        mergeSort(S,mid,right);
        merge(S,left,right,mid);
    }
}

int main(){
    int n,i,left,right;
    int S[S_len];

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

    for(i=0;i<n;i++){
        printf("%d",S[i]);
        if(i!=(n-1))printf(" ");
    }
    printf("\n%d\n",comp);
    return 0;
}


Measured memory_bytes: 5632
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    x = LI()
    fact = [1]
    for i in range(1,n):
        fact.append(fact[-1]*i%mod)
    S = [fact[n-1]*pow(i,mod-2,mod)%mod for i in range(1,n)]
    for i in range(n-2):
        S[i+1] += S[i]
        S[i+1] %= mod
    ans = 0
    for i in range(n-1):
        d = x[i+1]-x[i]
        ans += d*S[i]%mod
        ans %= mod
    print(ans)
    return

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


Measured memory_bytes: 63128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  string s;
  cin >> s;
  int cnt = 0;
  int p = s.size();
  rep(i,p){
    if(s[i] !=s[p-1-i]) cnt++;
  }
  cout << cnt/2 << endl;
         
         
  
}


Measured memory_bytes: 256
import fractions

def main():
  n = int(input())
  a = list(map(int, input().split()))

  right = []
  left  = []

  right.append(a[0])
  left.append(a[-1])

  for i in range(1, len(a)-1):
    right.append(fractions.gcd(right[i-1], a[i]))
    left.append(fractions.gcd(left[i-1], a[-i-1]))
  
  ans = max(right[-1], left[-1])
  
  for i in range(len(right)-1):
    ans = max(ans, fractions.gcd(right[i], left[-i-2]))
    
  print(ans)
  
main()

Measured memory_bytes: 16124
import math

while True:
    n = int(input())
    if(n == 0):
        exit()
    else:
        s = [int(x) for x in input().split()]
        m = sum(s)/len(s)

        for i in range(n):
            s [i] = (s[i] - m)**2

        print("%.5f" % (math.sqrt(sum(s)/len(s))))

Measured memory_bytes: 7780