akhauriyash/Code-Regression huggingface dataset:
n,k = map(int,input().split())

def cnt(i,k):
    cnt = 0
    while 1:
        i *= 2
        cnt += 1
        if i>=k: break
    return cnt

ans = 1-(k-1)/n #nのがでかくてサイコロだけで勝つ確率
if ans<0: ans = 0

for i in range(1,min(k,n+1)):
    ans += (1/2)**cnt(i,k) * (1/n)

print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <set>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
int A[200005];
set<int> s;

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

  cin >> N;
  int a;
  rep(i, N) {
    cin >> a;
    s.insert(a);
  }

  string ans = s.size()==N?"YES":"NO";
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 9600
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}
int tow(int n) {//2のn乗を求めるらしい
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
	//dominoに借りたやつです
}
/*
  for A以上B未満でI探索 for (int I = A; i <= B; i++)

  string s = to_string(i);　iをstringでsに変換

  char　小文字のほうが32大--------------------大文字と小文字の境=93

  大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[n])

  int i = sqrt (n) で、ｎの平方根(9に対する3)をiに入れる

  pow(a,b) → aのb乗を求める

  s1.erase(n) 文字列s1の、n文字目以降削除
  */
int a=0, b=0, c = 0;
string s = "";

int main(void) {
	//vector,set,map,stack,queue,deque,priority_queue

	int n;
	cin >> n;
	int ans = 0;
	int copy = n;
	while (n != 0) {
		ans += n % 10;
		n /= 10;
	}
	Yes(copy % ans == 0);
	
	please AC;
}

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

flag=0;
if N>81:
    print('No')
else:
    for x in range(1,10):
        for y in range(1,10):
            if(x*y==N):
                flag=1;
                break;
    
    if(flag==1):
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 2940
N,Q = map(int,input().split())
S = input()
qs = [tuple(map(int,input().split())) for i in range(Q)]

cums = [0,0]
for i in range(1,N):
    if S[i-1:i+1] == 'AC':
        cums.append(cums[-1] + 1)
    else:
        cums.append(cums[-1])

for l,r in qs:
    print(cums[r] - cums[l])

Measured memory_bytes: 19776
import collections

N = int(input())
s = [input() for i in range(N)]
count = 0
a = 0
moji = []
for i in s:
    char = list(i)
    char = sorted(char)
    char = ''.join(char)
    moji.append(char)
moji = sorted(moji)
c = collections.Counter(moji)
values, counts = zip(*c.most_common())
for count in counts:
    count -= 1
    while count > 0:
        a += count
        count -= 1
print(a)



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	ll ans=LONG_LONG_MAX;
	rep(i, s.size()-2){
		ll sum=0;
		sum += (s[i]-'0')*100;
		sum += (s[i+1]-'0')*10;
		sum += (s[i+2]-'0');
		ans = min(ans, abs(sum-753));
	}
	cout << ans << "\n";
	return 0;
}

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

int main() {
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    rep(i, N) cin >> a.at(i);

    sort(a.begin(), a.end());

    int ans = 0;

    rep(i, N) {
        if (x >= a[i]) {
            ans++;
            x -= a[i];
        }
    }

    if (ans == N && x > 0) ans--;

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


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

constexpr long double EPS = 10e-6;
constexpr long double radius = 1.0 + EPS;
constexpr long double diameter = 2.0 + EPS;

class Point{
    public: 
    long double x,y;
    Point(long double x = 0.0, long double y = 0.0): x(x), y(y) {}
    Point operator + (Point p) const {
        return Point(x+p.x, y+p.y);
    }
    Point operator - (Point p) const {
        return Point(x-p.x, y-p.y);
    }
    Point operator * (long double a) const {
        return Point(x*a, y*a);
    }
    Point operator / (long double a) const {
        return Point(x/a, y/a);
    }
    long double norm() const {
        return x*x + y*y;
    }
    long double dot(Point p) const {
        return x*p.x + y*p.y;
    }
};

int main() {
    int n;
    while(scanf("%d", &n) && n){
        vector<Point> points(n);
        rep(n) scanf("%Lf %Lf", &points[i].x, &points[i].y);

        int ans = 1, tmp;
        Point mid, midv, center;
        long double c;
        rep(n){
            repp(j, n){
                if(j == i) continue;
                mid = points[j] - points[i];
                if(mid.norm() > diameter*diameter) continue;
                mid = mid * 0.5;
                midv = Point(mid.y, -mid.x);
                c = sqrt((1.0 - mid.norm())/midv.norm());
                center = points[i] + mid + midv * c;
                tmp = 0;
                for(Point p: points){
                    Point v = p-center;
                    if(v.norm() <= radius) tmp++;
                }
                ans = max(tmp, ans);
            }
        }
        printf("%d\n", ans);
    }
}


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

ll ans = 10000000005;

void setans(ll a, ll b, ll c) {
// cout << "a: " << a << ", b: " << b << ", c: " << c << endl;
    if (a == 0 || b == 0 || c == 0) {
        return;
    }
    ll x = max(a, max(b, c));
    ll y = min(a, min(b, c));
    ans = min(ans, x - y);
}

void f(ll x, ll y) {
    for (int i = 1; i < x; i++) {
        // 面積
        ll a = i * y;
        ll b = (x - i) / 2 * y;
        ll c = (x - i - (x - i) / 2) * y;
        setans(a, b, c);

        b = (x - i) * (y / 2);
        c = (x - i) * (y - y / 2);
        setans(a, b, c);
    }
}

int main() {
    int H, W;
    cin >> H >> W;
    
    f(H, W);
    f(W, H);
    cout << ans << endl;
}

Measured memory_bytes: 3612
/**
 *   @FileName	f.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.21 21:36:30
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

constexpr int MOD = 1e9 + 7;
struct mint {
private:
    long long x;
public:
    mint(long long x = 0) :x((MOD+x)%MOD) {}
    mint(std::string &s) {
        long long z = 0;
        for (int i = 0; i < s.size(); i++) {
            z *= 10;
            z += s[i] - '0';
            z %= MOD;
        }
        this->x = z;
    }
    mint& operator+=(const mint &a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint &a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint &a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint& operator/=(const mint &a) {
        long long n = MOD - 2;
        mint u = 1, b = a;
        while (n > 0) {
            if (n & 1) {
                u *= b;
            }
            b *= b;
            n >>= 1;
        }
        return *this *= u;
    }
    mint operator+(const mint &a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint &a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint &a) const {
        mint res(*this);
        return res /= a;
    }
    friend std::ostream& operator<<(std::ostream &os, const mint &n) {
        return os << n.x;
    }
    bool operator==(const mint &a) const {
        return this->x == a.x;
    }
};

struct Combination {
private:
    int N;
    vector< mint > FACT, IFACT;
    
    mint pow(mint k, ll n) {
        mint res = 1;
        while (n > 0) {
            if (n & 1) {
                res *= k;
            }
            k *= k;
            n >>= 1;
        }
        return res;
    }
public:
    
    Combination(int n) : N(n) {
        FACT.resize(n + 1);
        IFACT.resize(n + 1);
        FACT[0] = 1;
        IFACT[0] = 1;
        for (int i = 1; i <= n; i++) {
            FACT[i] = FACT[i - 1] * i;
            IFACT[i] = pow(FACT[i], MOD - 2);
        }
    }
    mint comb(int n, int r) {
        if (n < 0 || r < 0 || r > n) return 0;
        if (r > n / 2) r = n - r;
        return FACT[n] * IFACT[n - r] * IFACT[r];
    }
};

template<typename T, typename U>
T pow(T k, U n, T unity = 1) {
    while (n > 0) {
        if (n & 1) {
            unity *= k;
        }
        k *= k;
        n >>= 1;
    }
    return unity;
}
int main() {
    int k;cin >> k;
    string s;cin >> s;
    Combination cb(k+s.size());
    mint ans = 0;
    for (int i = s.size() - 1; i < s.size() + k; i++) {
        ans += cb.comb(i,s.size()-1) * pow(mint(25),i-s.size()+1) * pow(mint(26),s.size()+k-1-i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35512
N,K = [int(i) for i in input().split()]
s = [[int(i) for i in input().split()] for N in range(N)]
s = sorted(s)
ans_bool = True

for i in s:
  K = K - i[1]
  if (K <= 0) and (ans_bool):
    ans_bool = False
    print(i[0])

Measured memory_bytes: 22432
#include <iostream>

using namespace std;

int main() {

  string str;

  int hit,blow;


  while(1) {

    getline(cin,str);

    if(str=="0 0") break;

    hit=blow=0;

    for(int i=0;i<4;i++) {

      for(int j=0;j<4;j++) {

	if(str[i]==str[j+5]) {

	  if(i==j) hit++;

	  else blow++;

	}

      }

    }

    cout << hit << " " << blow << endl;

  }

  return 0;

}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    char arr[26];
    arr[0]='z';
    arr[1]='a';
    for(int i=2;i<26;i++)
    {
        arr[i]=arr[i-1]+1;
    }
    vector<char>ans;
    ll temp=0;
    while(n>0)
    {
        temp=n%26;
        ans.push_back(arr[temp]);
        if(temp!=0)
        n=n-temp;
        else if(temp==0)
        {
            n=n-26;
        }
        
        n=n/26;
    }
    for(int i=ans.size()-1;i>=0;i--)
    cout<<ans[i];



    
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

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

    int a,b,c;

    a = N/100;
    b = (N-100*a)/10;
    c = N%10;

    if(a==7 || b==7 || c==7) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fr ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include<string>
#include<algorithm>
#include<vector>
const long long int maxn = 1e3+2;
const long long int mod = 1e3+2;

int main()
{
	fr
	ll n;
	cin>>n;
	ll a[n+2], dp[n+2];
	memset(dp, 0, n+2);
	
	for(ll i=1;i<=n;i++)
		cin>>a[i];
	dp[n] = 0;
	dp[n-1] = abs(a[n-1]-a[n]);
	for(ll i=(n-2);i>=1;i--)
	{
		dp[i] = min((dp[i+1]+abs(a[i]-a[i+1])), (dp[i+2]+abs(a[i]-a[i+2])));	
	}	
//	for(ll i=1;i<=n;i++)	cout<<dp[i]<<" ";	cout<<endl;
	cout<<dp[1]<<endl;
	return 0;
	
}


Measured memory_bytes: 1792
n, t = list(map(int, input().split()))
a = list(map(int, input().split()))

max_benefit = 0
a_min = a[0]
ans = 0
for i in range(1, n):
    if a[i] < a_min:
        a_min = a[i]
    benefit = (a[i] - a_min)
    if  benefit == max_benefit:
        ans += 1
    elif benefit > max_benefit:
        ans = 1
        max_benefit = benefit

print(ans)

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

ans = float('inf')
a, b = 1, N-1
while a <= b:
  sum_d_a = sum(map(int, str(a)))
  sum_d_b = sum(map(int, str(b)))
  ans = min(ans, sum_d_a + sum_d_b)
  a += 1
  b -= 1

print(ans)

Measured memory_bytes: 3064
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_f)

@sum = 0.to_f
a.each do |i|
  if i !=0
	  @sum += 1/i
  end
end

if @sum !=0
	print 1/@sum
else
	print 0 
end

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cassert>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    string ss;
    cin >> ss;
    bool a[26];
    rep(i,ss.size()){
        a[ss[i]-'a'] = true;
    }
    int ans = 10000;
    rep(i,26){
        if(!a[i])continue;
        string s = ss;
        string aa;
        rep(kk,ss.size()){
            aa += 'a'+i;
        }
        if(s == aa){
            cout << 0 << endl;
            return 0;
        }
        //show(aa);
        rep(j,100){
            rep(k,s.size()-1){
                if(s[k] != 'a'+i){
                    if(s[k+1] == 'a' +i){
                        s[k] = 'a' + i;
                    }
                }
            }
            s.resize(s.size()-1);
            aa.resize(s.size());
            //cout << s << endl;
            if(s == aa){
                ans = min(ans,j+1);
                break;
            }
            
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<set>
using namespace std;
int a[1<<18],c[20],cnt=0;
bool b[1<<18];
inline bool count(int x){
	bool s=0;
	while(x){
		x^=x&-x;
		s=!s;
	}
	return s;
}
inline void walk(int x,int h){
	int i,j,res=x;
	set<int> s;
	for(i=0;i<(1<<h);++i){
		s.insert(res);a[++cnt]=res;
		for(j=0;j<h;++j)if(s.find(res^(1<<j))==s.end()){
			res^=1<<j;
			break;
		}
	}
}
void go(int x,int y,int h){
	if(h==1){a[++cnt]=x;a[++cnt]=y;return;}
	if((x&(1<<h-1))!=((y&(1<<h-1)))){
		walk(x,h-1);
		x=a[cnt]^(1<<h-1);
		go(x,y,h-1);
	}else{
		go(x,y,h-1);--cnt;
		go(a[cnt]^(1<<h-1),y^(1<<h-1),h-1);
		a[++cnt]=y;
	}
}
int main(){
	int n,s,t,i;
	scanf("%d%d%d",&n,&s,&t);
	if(!(count(s)^count(t))){
		puts("NO");
		return 0;
	}
	puts("YES");
	go(s,t,n);
	for(i=1;i<=cnt;++i)printf("%d ",a[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f first 
#define s second
int32_t main(){
     int n;
     cin>>n;
     int arr[n];
     int xorrval = 0;
     for(int i = 0 ; i < n ;i++){
         cin>>arr[i];
         xorrval = xorrval^arr[i];
     }
     for(int i = 0 ; i < n; i++){
          cout<<(xorrval^arr[i])<<" ";
     }
}

Measured memory_bytes: 5120
N, K = map(int, input().split())
if (N-1)*(N-2)//2 < K:
    print(-1)
else:
    cnt = (N-1)*(N-2)//2 - K
    print((N-1 + cnt))
    for i in range(2, N+1):
        print(1, i)
    for i in range(2, N):
        j = i + 1
        while cnt > 0 and j <= N:
            print(i, j)
            j += 1
            cnt -= 1


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define minit(a,b) memset(a,b,sizeof(a))
const int DX[4] = {0,1,0,-1}, DY[4] = {1,0,-1,0};

typedef pair< int, int > pii;
typedef pii Point;
typedef pair< pii, pii > Load;
  
int n, stx, sty, t;
set< Load > loads;
int d[110];
char c[110];
  
bool dp[1010][55][55][4][4];
  
void solve() {
    minit(dp, 0);
      
    for_(r,0,4) fill(dp[0][sty][stx][r], dp[0][sty][stx][r] + 4, 1);
      
    int i = 0;
    for_(ii,0,t) {
        for_(rep,0,d[ii]) {
            for_(y,0,55) for_(x,0,55) for_(r,0,4) {
                bool flag = false;
                for_(pr,0,4) flag |= dp[i][y][x][r][pr];
                if (!flag) continue;
                  
                int nx = x + DX[r], ny = y + DY[r];
                Load ld(Point(x, y), Point(nx, ny));
                if (loads.find(ld) == loads.end()) continue;
                  
                for_(nr,0,4) {
                    if (nr == 2) continue;
                      
                    int dir = (r + nr) % 4;
                      
                    dp[i + 1][ny][nx][dir][r] = 1;
                }
            }
              
            ++i;
        }
        
        int ok = 0;
        if (c[ii] == 'S') ok = 2;
        if (c[ii] == 'E') ok = 1;
        if (c[ii] == 'W') ok = 3;
          
        for_(y,0,55) for_(x,0,55) for_(r,0,4) for_(pr,0,4){
            if (r != ok && pr != ok) dp[i][y][x][r][pr] = 0;
        }
    }
      
    for_(x,0,55) for_(y,0,55) {
        bool flag = false;
        for_(r,0,4) {
            int xx = x + DX[r], yy = y + DY[r];
            Load ld(Point(x, y), Point(xx, yy));
            if (loads.find(ld) == loads.end()) continue;        
            for_(pr,0,4) flag |= dp[i][y][x][r][pr];
        }
        if (flag) cout << x << " " << y << endl;
    }
}
  
int main() {
    cin >> n >> stx >> sty >> t;
      
    for_(i,0,n) {
        int sx, sy, ex, ey; cin >> sx >> sy >> ex >> ey;
          
        int x = min(sx, ex), xx = max(sx, ex);
        for (int j = 0; x + j < xx; ++j) {
            loads.insert( Load(Point(x + j, sy), Point(x + j + 1, sy)) );
            loads.insert( Load(Point(x + j + 1, sy), Point(x + j, sy)) );
        }
          
        int y = min(sy, ey), yy = max(sy, ey);
        for (int j = 0; y + j < yy; ++j) {
            loads.insert( Load(Point(sx, y + j), Point(sx, y + j + 1)) );
            loads.insert( Load(Point(sx, y + j + 1), Point(sx, y + j)) );
        }
    }
      
    for_(i,0,t) cin >> d[i] >> c[i];
      
    solve();
    return 0;
}

Measured memory_bytes: 49092
#include <iostream>
using namespace std;
int main(void){
    int H,W,i,j;
    while(1){
        cin >> H >> W ;
        if(H==0 && W==0) break;
        else{
            for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                    if(i%2==0){
                        if(j%2==0) cout <<"#";
                        else cout <<".";
                    }
                    else{
                        if(j%2==0) cout <<".";
                        else cout <<"#";
                    }
                }
                cout <<endl;
            }
        }
        cout <<endl;
    }
}


Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
#define MAX 301

typedef pair<int, int> P;

int h, w, d;
int a[MAX][MAX];
P place[MAX * MAX];

signed main() {
  cin >> h >> w >> d;
  for (int i = 0; i < h; i++) {
    for (int j = 0 ; j < w; j++) {
      cin >> a[i][j];
      place[a[i][j]] = P(i, j);
    }
  }
  int res[h * w + 1];
  for (int i = 1; i <= d; i++) {
    res[i] = 0;
  }
  for (int i = 1; i <= d; i++) {
    for (int j = i; j <= h * w - d; j += d) {
      P current = place[j];
      P next = place[j + d];
      int tmp = abs(current.first - next.first) + abs(current.second - next.second);
      res[j + d] = res[j] + tmp;
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << res[r] - res[l] << endl;
  }
  return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
#include <numeric>
#include <vector>
#include <algorithm>

int main()
{
    int input_num;
    std::cin >> input_num;
    std::vector<int> inputs;
    inputs.reserve(input_num);

    int input;
    while (std::cin >> input) {
        inputs.push_back(input);
    }

    std::cout << *std::min_element(inputs.begin(), inputs.end()) << " " << *std::max_element(inputs.begin(), inputs.end()) << " " << std::accumulate(inputs.begin(), inputs.end(), 0LL) << std::endl;
    

    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define pb push_back
#define all(v) v.begin(),v.end()
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
using ll = long long;
using lf = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int gr[100005];
int a[105];
int n, k;

int main(){
    fio;
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i <= k; i++){
        for(int j = 0; j < n; j++){
            if(i < a[j]) break;
            if(!gr[i - a[j]]){
                gr[i] = 1;
                break;
            }
        }
    }
    cout << (gr[k] ? "First\n" : "Second\n") << '\n';
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
    int n;
    vector<T> d;

    BIT(int n = 0) : n(n), d(n + 1) {}

    void add(int i, T x = 1) {
        for (i++; i <= n; i += i & -i) {
            d[i] += x;
        }
    }

    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i & -i) {
            x += d[i];
        }
        return x;
    }
};

BIT<mint> dp[110];

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    rep(i, N + 1) dp[i] = BIT<mint>(K + 1);
    dp[0].add(0, 1);
    rep(i, N) {
        rep(j, K + 1) {
            mint now = dp[i].sum(j);
            int low = j - a[i] - 1;
            if (low >= 0) now -= dp[i].sum(low);
            dp[i + 1].add(j, now);
        }
    }
    cout << (dp[N].sum(K) - dp[N].sum(K - 1)).x << endl;
}

Measured memory_bytes: 79488
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

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

	if(S.size() == 3)
		reverse(S.begin(), S.end());
		
	cout << S << endl;

	return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    int n,r;cin>>n>>r;
    if(n<10){
        cout<<r+(10-n)*100<<endl;
    }
    else{
        cout<<r<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

vector<vector<int>> g;
vector<ll> h;

int main(){
  int n, m;
  cin >> n >> m;
  h.resize(n);
  for(int i = 0; i < n; ++i){
  	cin >> h[i];
  }
  g.resize(n);
  for(int i = 0; i < m; ++i){
  	int a, b;
  	cin >> a >> b;
  	--a;
  	--b;
  	g[a].push_back(b);
  	g[b].push_back(a);
  }

  int cnt = 0;
  for(int i = 0; i < n; ++i){
  	++cnt;
  	for(auto nv : g[i]){
  		if(h[nv] >= h[i]){
  			--cnt;
  			break;
  		}
  	}
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 9004
# import itertools
# import math


def solve(H, N, A):
    if (sum(A) >= H):
        return 'Yes'
    return 'No'


# N = int(input())
# S = input()
H, N = map(int, input().split())
A = list(map(int, input().split()))

# P = []
# S = []
# for i in range(N):
#     pp, ss  = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(H, N, A))


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

int main(){
    int n,d,x;
    cin>>n>>d>>x;
    int sum=0;
    
    rep(i,n){
        int a;
        int b;
        cin>>a;
        b=1;
        while(b<=d){
            b+=a;
            sum++;
        }
    }
    
    cout<<sum+x<<"\n";
    return 0;
}

Measured memory_bytes: 3576
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination

int main(){
    int n, m;
    cin >> n>> m;
    vector<vector<int>> vec(m);

    rep(i,m){
        int k;
        cin >>k;
        vec[i].resize(k);
        rep(j,k){
            cin >> vec[i][j];
            --vec[i][j];
        }
    }

    vector<int> p(m);
    rep(i,m) cin >> p[i];
    //スイッチの状態をNbitの整数にエンコードして解こうとしている
    int ans = 0;
    for(int i=0;i<(1<<n);i++){//1を左nbitシフト つまり　１の2^n倍のこと　全ての場合をbitに落とし込んだ！
        bool ok = true;
        for(int j=0;j<m;j++){//ある電球jについて
            int c=0;
            for(int id:vec[j]){//vec[j]中の全ての値について
                if((i>>id)&1){//&はアドレス  iをidビットシフト  最下位ビットのみを取り出す つまりidビット目が1かどうかの判定　つまりスイッチidがonかどうかの判定
                    ++c;
                }
            }
            c%=2;
            if(c != p[j]){//点灯しないなら
                ok = false;
            }
        }
        if(ok){
            ++ans;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

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

  int count = 0;
  rep(i,10) {
    rep(j,10) {
      rep(k,10) {
        int p = 0;
        rep(l,N) {
          if (p == 0 && S[l] == char(i + '0')) {
            p++;
            continue;
          }
          if (p == 1 && S[l] == char(j + '0')) {
            p++;
            continue;
          }
          if (p == 2 && S[l] == char(k + '0')) {
            count++;
            break;
          } 
        }
      }
    }
  } 

  cout << count << endl;
}

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

using namespace std;
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
#define pint(x) printf("%d",x)
#define all(x) x.begin(),x.end()
#define ps printf(" "); 
#define plint(x) printf("%lld",x)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define bg begin()
#define ed end()
#define Set(a, s) memset(a, s, sizeof (a))
#define mod 1000000007
#define tmod(k) if ((k) >= mod) k %= mod;
#define endl '\n'
#define nl printf("\n");
#define fore(i,n) for(int i=n; i>=0; i--)
#define fors(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
typedef pair<int,int> pii;
typedef vector<lli> vli;
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}
const int INF = 0x3f3f3f3f;
#define pi 3.14159265

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

int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
	/*
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	*/
    // cout<<"Execution time : "<<tick()<<"\n";
	
	lli n,m;
	lint2(n,m);
	if(n>m) swap(n,m);
	if(n==1 and m==1){
		cout<<1;
	}
	else if(n==1){
		cout<<(m-2);
	}
	else if(n==2){
		cout<<0;
	}
	else{
		cout<<(lli)(n-2)*(m-2);
	}
	
    return 0;
}





Measured memory_bytes: 256
import copy

n = int(input())
x = list(map(int, input().split()))

if n == 2:
    print(x[1])
    print(x[0])
    exit()

y = copy.deepcopy(x)
y.sort()
mid_s = y[n // 2 - 1]
mid_l = y[n // 2]
for a in x:
    if a < mid_l:
        print(mid_l)
    else:
        print(mid_s)


Measured memory_bytes: 26724
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int a, b;

int main()
{
    cin >> a >> b;
    int sub = b - a;
    ll ans = 0;
    rrep(i, sub) ans += i;
    cout << ans - b << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from math import ceil
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split())) + [0]
    kabu = 0
    money = 1000
    max_money = 1000
    state = 0
    for i in range(N):
        a = A[i]
        if state == 0 and a < A[i + 1]:
            kabu = money // a
            money = money % a
            state = 1
        elif state == 1 and a > A[i + 1]:
            money += kabu * a
            max_money = max(max_money, money)
            kabu = 0
            state = 0
    money += kabu * A[-1]
    max_money = max(max_money, money)
    print(max_money)

if __name__ == "__main__":
    main()


Measured memory_bytes: 62100
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        char[] answer = new char[line.length()];
        for (int i = 0; i < line.length(); i++) {
            char c = line.charAt(i);
            if (Character.isLowerCase(c)) {
                answer[i] = (Character.toUpperCase(c));
            } else if (Character.isUpperCase(c)) {
                answer[i] = (Character.toLowerCase(c));
            } else
                answer[i] = c;
        }
        System.out.println(answer);
    }
}



Measured memory_bytes: 26312
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll k;
  cin >> k;
  ll ans = 0;
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) {
      for (int x = 1; x <= k; x++) {
        ans += __gcd(__gcd(i, j), x);
      }
    }
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 3652
// atcoder/abc146/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

const int N = 1e5 + 5;
vector<int> g[N];
int color[N];

map<pair<int, int>, int> idx;

int rec(int curr, int prev)
{
  int c = 0;
  each (next, g[curr]) {
    if (next == prev) continue;
    int a = idx[make_pair(curr, next)];
    int b = idx[make_pair(next, curr)];
    if (color[idx[make_pair(curr, prev)]] == c) ++c;
    color[a] = color[b] = c++;
    rec(next, curr);
  }
  return 0;
}

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

  int n;
  while (cin >> n) {
    fill(g, g + N, vector<int>());
    fill(color, color + N, -(1 << 29));
    vector<pair<int, int>> v;
    for (int i = 0; i < n - 1; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      pair<int, int> e = {a, b};
      pair<int, int> r = {b, a};
      v.push_back(e);
      idx[e] = idx[r] = i;
      g[a].push_back(b);
      g[b].push_back(a);
    }

    // int root = 0;
    // for (int i = 0; i < N; ++i) {
    //   if (g[root].size() < g[i].size()) {
    //     root = i;
    //   }
    // }
    color[idx[make_pair(0, -1)] = N - 1] = 1 << 29;
    rec(0, -1);
    cout << *max_element(color, color + n) + 1 << endl;
    each (i, v) cout << color[idx[i]] + 1 << endl;
    // cout << endl;
  }

  return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;

  map<ll, ll> cnts;
  cnts[0] = 1;
  ll sum = 0;
  rep (i, n) {
    int a;
    cin >> a;
    sum += a;
    cnts[sum % m]++;
  }

  ll ans = 0;
  for (auto cnt : cnts) {
    ans += cnt.S * (cnt.S - 1) / 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#define FOR(i,n,x) for(int i=0;i<n;i+=x)
#define ll long long int 
#define llu unsigned long long int
#define pb(x) push_back(x)
#define mp make_pair
#define vi vector<int>
#define vvi vector<vi>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define max(x,y) (x>y)?x:y
#define min(x,y) (x<y)?x:y 
#define mid(s,e) (s+(e-s)/2)
#define MOD 1000000007
#define MAXI 100000000000009
const int MX = 10010896;
const int lmt = 3164;
const int MAXL = 1000;
const int MAX_MID = 1e5;
using namespace std;

void solve(){
    int a;
    cin>>a;
    int ans = a + a*a + a*a*a;
    cout<<ans;
}

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

Measured memory_bytes: 3576
//Author : Abhishek Yadav
#include <bits/stdc++.h>
#define endl "\n"
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        n%=10;
        if(n==2 or n==4 or n==5 or n==7 or n==9)cout<<"hon";
        else if(n==0 or n==1 or n==6 or n==8 )cout<<"pon";
        else if(n==3)cout<<"bon";
    
        cout<<endl;
    }
    return 0;
}

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

int main(){
	string w;
	cin >> w;
	map<char,int> cnt;
	rep(i,w.size()){
		cnt[w[i]]++;
	}
	int counts = 0;
	for(auto x: cnt){
		auto k = x.first;
		auto v = x.second;
		if(v%2 == 0) counts++;
	}
	cout << (counts == cnt.size() ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<stdio.h>
#include<vector>

using namespace std;

int main(int n, int m) {
    cin >> n >> m;
    int A[n][m] = {};
    int B[m] = {};
    int C[n] = {};
    int a, b;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a;
            A[i][j] += a;
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> b;
        B[i] += b;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            C[i] += A[i][j] * B[j];
        }
        cout << C[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>

using namespace std;

typedef long long ll;
#define rg register int

inline void read(int &x)
{
    int s = 0, w = 1;
    char c = getchar();
    while(!isdigit(c)){if(c == '-')w = -1; c = getchar();}
    while(isdigit(c)){s = (s << 3) + (s << 1) + c - '0', c = getchar();}
    x = s * w;
}

const int N = 2000010, mod = 1e6 + 3;

inline int ksm(int a, int b)
{
    int res = 1;
    while(b)
    {
        if(b & 1)
            res = (ll) res * a % mod;
        a = (ll) a * a % mod, b >>= 1;
    }
    return res;
}

int fac[N], ifac[N], x, n, d, Q;

int main()
{
    fac[0] = 1;
    for (rg i = 1; i < mod; i++)
        fac[i] = (ll) fac[i - 1] * i % mod;
    ifac[mod - 1] = ksm(fac[mod - 1], mod - 2);
    for (rg i = mod - 1; i; i--)
        ifac[i - 1] = (ll) ifac[i] * i % mod;
    read(Q);
    while(Q--)
    {
        read(x), read(d), read(n);
        if(d == 0)
        {
            printf("%d\n", ksm(x, n));
            continue ;
        }
        int t = (ll) x * ksm(d, mod - 2) % mod;
        if(n - 1 >= mod - t)
            printf("0\n");
        else
        {
            int ans = (ll) fac[t + n - 1] * ifac[t - 1] % mod;
            ans = (ll) ans * ksm(d, n) % mod;
            printf("%d\n", ans);
        }
    }
}

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

#define INF 1000000000

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    string s;
    int ans = INF;
    cin >> s;
    for (int i = 0; i < 2; ++i) {
        int cnt = 0;
        for (int j = 0; j < s.size(); ++j) if (s.at(j) - '0' == (i + j) % 2) ++cnt;
        ans = min(ans, cnt);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll K, S;
    cin >> K >> S;
    ll count{0};
    for (auto &&i: irange(0LL, K+1)){
        for (auto &&j: irange(0LL,K+1)){
            ll Z = S - i - j;
            if (Z >= 0 && Z <= K)count ++;
        }
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>

using namespace std;


int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<int64_t> a(x);
  vector<int64_t> b(y);
  vector<int64_t> c(z);
  for (int i = 0; i < x; i++)
    cin >> a[i];
  for (int i = 0; i < y; i++)
    cin >> b[i];
  for (int i = 0; i < z; i++)
    cin >> c[i];
  sort(c.begin(), c.end(), greater<int64_t>());
  vector<int64_t> ab(x*y);
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      ab[i*x + j] = a[i]+b[j];
    }
  }
  sort(ab.begin(), ab.end(), greater<int64_t>());
  int l = min(k, x*y);
  vector<int64_t> abc;
  for (int i = 0; i < l; i++) {
    for (int j = 0; j < z; j++) {
      abc.push_back(ab[i] + c[j]);
    }
  }
  sort(abc.begin(), abc.end(), greater<int64_t>());
  for (int i = 0; i < k; i++)
    cout << abc[i] << endl;
  return 0;
}


Measured memory_bytes: 42984
#include <bits/stdc++.h>
#define ff first
#define dd second
#define pp pair<int,int>
#define pb push_back
#define N 100005
#define mp make_pair
using namespace std;

int n, m;

string s;

int tab[26];

main() {
    ios_base::sync_with_stdio(false);
    //freopen("test2", "r", stdin);
    cin >> s;
    for(int i = 0; i < 26; ++i) {
        tab[i] = 0;
    }
    n = s.size();
    for(int i = 0; i < n; ++i) {
        int znak = s[i] - 'a';
        tab[znak]++;
        if(tab[znak] > 1) {
            cout << -1 << endl; exit(0);
        }
    }

    if(n > 26) {
        cout << -1 << endl; exit(0);
    }



    if(n < 26) {
        int wsk = 0;
        while(tab[wsk] > 0) wsk++;
        cout << s << ((char)('a'+wsk)) << endl; exit(0);
    }

    for(int i = 1; i < n; ++i) {
        if(s[i-1] < s[i]) break;
        if(i == 25) {
            cout << -1 << endl; exit(0);
        }
    }

    vector<int> temp;
    for(int i = 0; i < n; ++i) temp.pb(s[i]-'a');
    next_permutation(temp.begin(), temp.end());
    int ctr = 0;
    for(auto &i: temp) {
        cout << ((char)(i+'a'));
        if((s[ctr]-'a') != i) break;
        ctr++;
    } cout << endl;

}

Measured memory_bytes: 256