akhauriyash/Code-Regression huggingface dataset:
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAXN = 2e5 + 10, MOD = 1e9 + 7, INF = 1e9 + 5;

int k, n, a[MAXN];

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int ans = 0;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);
	for(int i = 0; i < k; i++){
		ans += a[i];
	}
	cout << ans << '\n';

}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;

class ABC_128_A
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int P = int.Parse(input[1]);

        Console.WriteLine((A*3+P)/2);
    }
}

Measured memory_bytes: 11092
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
int n;
int a[1000005],num[1000005],sum;
int cal(int x){
	return x*(x-1)/2;
}
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]),num[a[i]]++;
	for(int i=1;i<=n;i++) sum+=cal(num[i]);
	for(int i=1;i<=n;i++) printf("%lld\n",sum-cal(num[a[i]])+cal(num[a[i]]-1));
	return 0;
}

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

int main() 
{
    int s;
    cin >> s;
    vector<int> v;
    v.push_back(s);
    int i=1;
    while(true)
    {
        i++;
        if (s%2==0)
            s = s/2;
        else 
            s = 3*s+1;
        if (find(v.begin(), v.end(), s)!=v.end())
        {
            cout << i;
            return 0;
        }
        v.push_back(s);
    }
}

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

int main()
{
	int k;
	int a[32]={1, 1, 1, 2, 1, 2, 1
	, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1
	, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5
	, 4, 1, 4, 1, 51};
	while(cin>>k)
	{
		cout<<a[k-1]<<endl;
	}
	
	
	
return 0;
 } 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> sc(m);
    rep(i, m) {
        int tmp_s, tmp_c;
        cin >> tmp_s >> tmp_c;
        sc[i] = make_pair(tmp_s, tmp_c);
    }
    rep(i, 1000) {
        vector<int> keta(1, i % 10);
        int tmp_num = i / 10;
        int keta_num = 1;
        while ( tmp_num != 0) {
            keta.push_back(tmp_num % 10);
            tmp_num /= 10;
            ++keta_num;
        }
        if ( keta_num != n ) continue;
        reverse(keta.begin(), keta.end());
        bool ok = true;
        rep(j, m) {
            if ( keta[sc[j].first-1] != sc[j].second ) {
                ok = false;
                break;
            } 
        }
        if ( ok ) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

void s_class(int pm, int pe, int pj){
  int ave=0;
  ave+=pm+pe+pj;
  ave /= 3;
  if(pm==100 || pe==100 || pj==100) cout << 'A' << endl;
  else if((pm+pe)/2 >= 90) cout << 'A' << endl;
  else if(ave>=80) cout << 'A' << endl;
  else if(ave>=70) cout << 'B' << endl;
  else if(ave>=50 && (pm>=80 || pe>=80)) cout << 'B' << endl;
  else cout << 'C' << endl;
				    
}

int main(){
  
  int n;
  int pm,pe,pj;

  while(cin >> n){
    if(n==0) break;
    for(int i=0; i<n; i++){
      cin >> pm >> pe >> pj;
      s_class(pm,pe,pj);
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  n%=1000;
  if(n==0)n=1000;
  cout<<1000-n<<"\n";
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s, t;
	cin >> s;
	cin >> t;
	int len = s.length();
	int len1  =t.length();
	if (len1 != len + 1) cout << "No" << endl;
	else {
	for (int i = 0; i < len; i++) {
		if (t[i] != s[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}
	return 0;
} 

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long double r;
	cin >> r;
	long double ans;
	ans = 2 * 3.141 * r;
	cout << ans << "\n";
}

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

#define ll              long long
#define Ull             unsigned long long
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N = 2;
const ll MOD = 1e9 + 7;


void Solve()
{
	ll n, k;
	cin >> n >> k;
	ll a[n], dp[n];
	for (ll i = 0; i < n; i++)
		cin >> a[i];

	for (ll i = 0; i < n; i++)
		dp[i] = INF;

	dp[0] = 0;
	for (ll i = 0; i < n - 1; i++)
	{
		for (ll j = 1; j <= k; j++)
		{
			ll x = i + j;
			if (x < n)
				dp[x] = min(dp[x], (dp[i] + abs(a[x] - a[i])));
		}


	}
	cout << dp[n - 1] << "\n";
}


int main()
{

	FastRead;
	int T = 1;
	//cin>>T;
	while (T--)
	{
		Solve();
	}

	return 0;
}


Measured memory_bytes: 1792
// Problem : 
// 			A - Rainy Season
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define lli long long int 
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int ans=0;
    bool pre=false;
    for(int i=0;i<3;i++){
    	if(s[i]=='R'){
    		ans++;
    		pre=true;
    	}
    	else{
    		if(pre){
    			break;
    		}
    	}
    }
    cout<<ans;
	return 0;
}


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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n;
int a[N];
ll f[N], ans;
ll b[N], k[N];
ll inv[N];
ll pref[N];

int main () {
	SpeedForce;
	cin >> n;
	f[0] = 1;
	inv[0] = 1;
	inv[1] = 1;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		f[i] = f[i-1] * i % mod;
	}

	for (int i = 2; i <= n; ++i) {
		inv[i] = mod - (mod / i) * inv[mod%i]  % mod;
		k[i] = f[n] * inv[i] % mod;
	}

	for (int i = 1; i <= n; ++i) {
		pref[i] = pref[i-1] + k[i] % mod;
	}

	for (int i = 1; i <= n; ++i) {
		b[i] = pref[i] + pref[n-i+1] + f[n];
		b[i] %= mod;
	//	cout << i << ' ' << b[i] << '\n';
		ans = (b[i] * a[i] + ans) % mod;
	}

	cout << ans << '\n';
	
   	return Accepted;
}

// B...a

Measured memory_bytes: 13312
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin >> n;
    vector<string> arr(n);
    F0R(i,arr.size())
        cin >> arr[i];
    vector<char> st;
    map<vector<char>,ll> m;
    F0R(i,arr.size())
    {
        st.clear();
        F0R(j,arr[i].size())
            st.pb(arr[i][j]);
        sort(st.begin(),st.end());
        if(m.find(st)==m.end())
            m.insert({st,1});
        else
            m[st]++;
    }
    ll tot=0;
    for(auto &p : m)
    {
        tot+=p.s*(p.s-1)/2;
    }
    cout << tot;

    return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl
using namespace std;
int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a * n, b) << endl;
    return 0;
}

Measured memory_bytes: 3524
//#define _USE_MATH_DEFINES
//#include <math.h>
#include <iostream>
//#include <iomanip>
//#include <bits/stdc++.h>

using namespace std;

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



Measured memory_bytes: 3116
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

long[] s, t;

void main()
{
    long A, B, Q;
    scan(A, B, Q);
    s = new long[](A);
    t = new long[](B);
    foreach (i; 0 .. A)
        scan(s[i]);
    foreach (i; 0 .. B)
        scan(t[i]);

    foreach (_; 0 .. Q)
    {
        long x;
        scan(x);
        solve(x).writeln();
    }
}

long solve(long x)
{
    if (s.length <= 2 && t.length <= 2)
        return eval(s, t, x);
    if (x <= s[0] && x <= t[0])
        return eval(s[0 .. 1], t[0 .. 1], x);
    if (s[$ - 1] <= x && t[$ - 1] <= x)
        return eval(s[$ - 1 .. $], t[$ - 1 .. $], x);

    long si = bisect(x, s);
    long ti = bisect(x, t);
    return eval(s[si .. si + 2], t[ti .. ti + 2], x);

}

long bisect(long x, long[] ary)
{
    long yes, no;
    yes = 0;
    no = ary.length;
    while (1 < no - yes)
    {
        long mid = (yes + no) / 2;
        if (ary[mid] < x)
        {
            yes = mid;
        }
        else
        {
            no = mid;
        }
    }
    return yes;
}

long eval(long[] ss, long[] ts, long x)
{
    long ans = long.max;
    foreach (s; ss)
        foreach (t; ts)
        {
            ans = ans.min(min(abs(x - s), abs(x - t)) + abs(s - t));
        }
    return ans;
}


Measured memory_bytes: 6012
import math
D, G = map(int, input().split())
L = [[int(i) for i in input().split()] for j in range(D)]
p = [L[i][0] for i in range(D)]
q = [L[i][1] for i in range(D)]

#for l in L:
#   l.append(i*l[0]*100+l[1])
#   i += 1

M = [L[i][0]*(i+1)*100+L[i][1] for i in range(D)]
lis = []
for i in range(1 << D):
    s = [0, 0]
    for j in range(D):
        if ((i >> j) & 1) == 1:
            s[0] += p[j]
            s[1] += M[j]
    for j in range(D):
        if ((i >> j) & 1) == 0:
            lis.append(s+[j+1])
        else:
            lis.append(s+[0])

ans = 1010
for l in lis:
    if G <= l[1]:
        ans = min(ans, l[0])
    elif G - l[1] <= l[2] * 100 * (p[l[2]-1]-1):
        ct = ((G-l[1])+(l[2]*100)-1) // (l[2]*100)
        ans = min(ans, l[0]+ct)

print(ans)


Measured memory_bytes: 4200
package main

import (
	"fmt"
)

func solution(a, b, c int64) string {
	d := c - a - b
	if d > 0 && d*d > 4*a*b {
		return "Yes"
	}
	return "No"
}

func main() {
	var a, b, c int64
	fmt.Scan(&a, &b, &c)
	fmt.Println(solution(a, b, c))
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 10000000
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 998244353
#define PI acos(-1.0)
#define eps 1e-9

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    int n, k;
    ll s, p, r;
    cin>>n>>k>>s>>p>>r;
    string T;
    cin>>T;
    ll sum = 0;
    int tt = T.size();
    for(int i = 0; i < tt; i++)
    {
        if(i < k)
        {
            if(T[i]=='r')
                sum+=r;
            else if(T[i]=='p')
                sum+=p;
            else
                sum+=s;
        }
        else
        {
            if(T[i]==T[i-k] && i-k>=0)
            {
                if(T[i]=='r')
                {
                    if(i+k<tt)
                    {
                        if(T[i+k]=='s')
                            T[i] = 'p';
                        else
                            T[i] = 's';
                    }
                    else
                        T[i] = 's';
                }
                else if(T[i]=='s')
                {
                    if(i+k<tt)
                    {
                        if(T[i+k]=='p')
                            T[i] = 'r';
                        else
                            T[i] = 'p';
                    }
                    else
                        T[i] = 'p';
                }
                else
                {
                    if(i+k<tt)
                    {
                        if(T[i+k]=='r')
                            T[i] = 's';
                        else
                            T[i] = 'r';
                    }
                    else
                        T[i] = 'r';
                }
            }
            else
            {
                if(T[i]=='r')
                    sum+=r;
                else if(T[i]=='p')
                    sum+=p;
                else
                    sum+=s;
            }
        }
    }
    cout<<sum<<endl;

    //End();
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    ll n, k;
    cin >> n >> k;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}
    ll a_ = 0;
    ll b_ = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            if (a[i] > a[j]) a_++;
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i == j) continue;
            if (a[i] < a[j]) b_++;
        }
    }

    //cout << a_ << " " << b_ << endl;

    ll pat = k*(k-1)/2;
    pat %= MOD;
    ll ans = (a_*k) + b_*pat;
    cout << ans%MOD << endl;

}



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

int main(){
    ll N, K, count = 0;
    cin >> N >> K;
    ll a, b, array[100001] = {}, i;
    for(int i=0;i<N;i++){
        cin >> a >> b;
        array[a] += b;
    }
    for(i=1;i<100001;i++){
        if(K <= array[i]){
            cout << i << endl;
            break;
        }
        K -= array[i];
    }

}


Measured memory_bytes: 1024
s=list(map(int,input().split()))
if len(s)==2:c=s[0];d=s[1]
else:c=s[0];d=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
    p=i;q=0
    for j in range(c):
        if a[j]==b[p]:q+=1;p+=1
    e=max(e,q)
    i+=1
print(e)

Measured memory_bytes: 8320
#include<iostream>//AT3874
#include<cstdio>
#include<cstring>
#include<string>
#include<iomanip>
#include <algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
using namespace std;
int main()
{
    int a,b,i,j,k=1;
    cin>>a>>b;j=b;
    while(j!=0)
    {j/=10;k*=10;}
    a=a*k+b;
	for(i=3;i<=320;i++)
	 if(i*i==a){cout<<"Yes"<<endl;return 0;}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = (1..n).map {
        readLine()!!.toInt()
    }
    val po1 = emptyList<Int>().toMutableList()
    val po2 = emptyList<Int>().toMutableList()
    po1.add(0)
    po2.add(0)
    for (i in 1..n) {
        po1.add(Math.max(po1[i - 1], a[i - 1]))
        po2.add(Math.max(po2[i - 1], a[n - i]))
    }
    po1.add(0)
    po2.add(0)
    po2.reverse()
    for (i in 0 until n) {
        println(Math.max(po1[i], po2[i + 2]))
    }
}


Measured memory_bytes: 72692
import sys
input = sys.stdin.readline

def main():
    n,k = map(int, input().split())
    A = sorted(map(int, input().split()))
    mod = 10**9 + 7
    ans, sign = 1, 1

    l, r = 0, n-1

    if k%2:
        ans = A[r]
        r-=1
        k-=1
        if ans < 0:
            sign = -1
    while k:
        x = A[l]*A[l+1]
        y = A[r]*A[r-1]

        if x*sign > y*sign:
            ans = x%mod * ans%mod
            l+=2
        else:
            ans = y%mod * ans%mod
            r-=2
        k-=2
    print((ans+mod)%mod)
main()

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

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

    map<string, long> mp;
    rep(i, n) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    
    long long cnt = 0;
    for (auto& kv : mp) {
        cnt += (long long)kv.second * (kv.second - 1) / 2;
    }
    cout << cnt << endl;
}


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

int main(void){
    ll x,k,d;
    cin >> x >> k >> d;
    x = abs(x);

    if(k<x/d){
        cout << x-k*d << endl;
        return 0;
    }

    ll sp = x - (x/d)*d;
    k -= x/d;
    if(k%2==1) cout << d-sp << endl;
    else cout << sp << endl;
    return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define ld long double
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define sc(x) scanf("%s",x)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int> 
#define pli pair<ll,int>
#define pil pair<int,ll>  
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb(x) push_back(x)
#define ub upper_bound
#define lb lower_bound
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define clr(x) memset(x,0,sizeof(x))
#define sws ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pi acos(-1)
#define rep(I, N) for (ll I = 0; I < (N); ++I)
#define repp(I, a, B) for (ll I = (a); I <= (B); ++I)
#define t1(x)                cout<<#x<<": "<<x<<endl
#define t2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define t3(x, y, z)          cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define t4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define t5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define t6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;

const int N = 2e5 + 5;
const int M = 2e5 + 5;
const int LN = 30;
const int BLOCK = 1000;
const int MAX = 1e6 + 5;

ll fact[N], invfact[N];

ll pwr(ll base, ll p, ll mod = MOD)
{
    ll ans = 1;
    while(p)
    {
        if(p & 1) ans = (ans * base) % MOD;
        base = (base * base) % MOD;
        p /= 2;
    }
    return ans;
}

ll C(ll n, ll k) 
{
    return ((fact[n] * invfact[n - k]) % MOD * invfact[k]) % MOD;
}

void Combpre()
{
    fact[0] = 1;
    invfact[0] = 1;
    for(ll i = 1; i < N; ++i) 
    {
        fact[i] = (i * fact[i - 1]) % MOD;
        invfact[i] = (invfact[i - 1] * pwr(i, MOD - 2, MOD)) % MOD;
    }
}

int main()
{
    sws;
    srand(time(NULL));
    cout << fixed << setprecision(10);
    clock_t clk;
    clk = clock();
    

    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);


    Combpre();
    ll n, m;
    cin >> n >> m;
    ll ans = 1;
    for(int i = 2; i * i <= m; i++)
    {
        int cnt = 0;
        while(m % i == 0)
        {
            m /= i;
            cnt++;
        }
        ans = (ans * C(n - 1 + cnt, n - 1)) % MOD;
    }
    if(m > 1)
        ans = (ans * n) % MOD;
    cout << ans;


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    
    return 0;
}

Measured memory_bytes: 3328
//include
//------------------------------------------
#include <vector>
#include <stdio.h>
using namespace std;
template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}

//main code
const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
vector<vector<int>> G(100000);
vector<int>  dp(100000,-1);
int main(int argc, char *argv[])
{
	int n,m;
	n = getint();
	m = getint();
	for (int i = 0; i < m; i++) {
		int x,y;
		x = getint();
		y = getint();
		x--;y--;
		G[x].emplace_back(y);
	}
	auto rec = [&](auto&& rec, int v)->int{
		if (dp[v]!=-1) return dp[v];
		int res = 0;
		for (auto nv : G[v]) {
			chmax(res, rec(rec, nv)+1);
		}
		return dp[v] = res; // メモしながらreturn
	};
	int res = 0;
	for (int i = 0; i < n; i++) {
		chmax(res, rec(rec, i));
	}
	printf("%d\n",res);
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int64_t> X(N),copy(N);
  for(int i=0;i<N;i++){
    cin >> X.at(i);
  }
  copy=X;
  sort(copy.begin(),copy.end());
  int64_t min=copy.at(N/2-1);
  int64_t max=copy.at(N/2);
  double average=(min+max)/2.0;
  for(int i=0;i<N;i++){
    if(X.at(i)<average){
      cout << max << endl;
    }else{
      cout << min << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 5376
import java.io.*;
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        long n = sc.nextLong();
        System.out.println((n) * (n-1) / 2);
    }


    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 21460
N=int(input())
A=list(map(int,input().split()))
OD=0
EV4=0
for i in A:
  if i%2==1:
    OD+=1
  elif i%4==0:
    EV4+=1
EV=N-OD-EV4
ret = 'No'
if EV4>=OD:
  ret='Yes'
elif EV4==OD-1 and EV==0:
  ret='Yes'
print(ret)

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

int main() {
	string s,p;
	cin >> s >> p;
	s += s;
	string::size_type n = s.find(p);
	if (n != string::npos)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3164
a, b, c, x, y = map(int, input().split())
ans = 0
if a + b <= 2 * c:
    print(a * x + b * y)
else:
    ans += c * min(x, y) * 2
    z = abs(x-y)
    if x == y:
        pass
    elif x > y:
        if a >= 2 * c:
            ans += 2 * c * z
        else:
            ans += a * z
    else:
        if b >= 2 * c:
            ans += 2 * c * z
        else:
            ans += b * z
    print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main{

    public static void main(String args[]){

        //配列の宣言
        int[] num = new int[1000000];
        // スキャナーの宣言
        Scanner sc = new Scanner(System.in);
        // 整数の入力
		int s = sc.nextInt();

        int i = 0;
        while(true){
            i++;
            if(num[s-1] == 1){
                break;
            }else{
                num[s-1] = 1;
            }
            if(s % 2 == 0){
                s = s / 2;
            }else{
                s = 3 * s + 1;
            }
        }

        // 出力
        System.out.println(i);

    }

}

Measured memory_bytes: 25940
import java.util.*;
public class Main {
	//内部类
    class Drinks{
		int pro_num;
		int pro_time;
		//构造方法
		public Drinks(int num,int time) {
			this.pro_num=num;
			this.pro_time=time;
		}
		//获取喝饮料后的对应题数
		public int get_num(){
			return pro_num;
		}
		//获取喝饮料后做题的时间
		public int get_time() {
			return pro_time;
		}
		
	}
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		Main out_Times=new Main();
		int N=sc.nextInt();
	    int N_time[]=new int[N];
	    for(int i=0;i<N;i++) {
	    	N_time[i]=sc.nextInt();
	    }
	    
	    int M=sc.nextInt();
	    int temp=0;
	    Drinks drinks[]=new Drinks[M];
	    for(int i=0;i<M;i++) {
	    	int num=sc.nextInt();
	    	int time=sc.nextInt();
	    	drinks[i]=out_Times.new Drinks((num-1),time);
	    }
	    for(int i=0;i<M;i++){
	    	int total_time=0;         //用于计算总时间
	    	//替换喝饮料时间
	    	int k=drinks[i].get_num();
	    	temp=N_time[k];
	    	N_time[k]=drinks[i].get_time();
	    	for(int j=0;j<N;j++) {
	    		total_time=total_time+N_time[j];

	    	}
	    	System.out.println(total_time);
	    	//保持原来的时间数据不变
	    	N_time[k]=temp;
	    }
	    
	}

}


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

#ifdef LOCAL
#define dbg(x) (cerr << "ln " << __LINE__ << ": " << #x << " = " << (x) << '\n')
#else
#define dbg(x) {}
#endif

typedef long long ll;

int n, m, k;
int a[100005];
bool vis[100005];
vector<int> e[100005];
vector<vector<int>> b;

void dfs(int x, vector<int>& k) {
	k.push_back(a[x]);
	vis[x] = true;
	for (int y : e[x]) {
		if (!vis[y]) {
			dfs(y, k);
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	cin >> n >> m;
	for (int i=1; i<=n; i++) {
		cin >> a[i];
	}
	for (int i=1; i<=m; i++) {
		int u, v;
		cin >> u >> v;
		u++;
		v++;
		e[u].push_back(v);
		e[v].push_back(u);
	}

	// komponente
	for (int i=1; i<=n; i++) {
		if (!vis[i]) {
			vector<int> komp;
			dfs(i, komp);
			b.push_back(komp);
		}
	}

	k = b.size();

	if (n < 2*k-2) {
		cout << "Impossible\n";
		return 0;
	}

	if (k == 1) {
		cout << "0\n";
		return 0;
	}

	ll sol = 0;

	vector<int> svi;

	dbg(sol);

	for (auto& v : b) {
		sort(v.rbegin(), v.rend());
		sol += v.back();
		v.pop_back();

		copy(v.begin(), v.end(), back_inserter(svi));
	}

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

	sol = accumulate(svi.begin(), svi.begin() + k - 2, sol);

	cout << sol << '\n';
}

Measured memory_bytes: 10036
#include <bits/stdc++.h>
#define rep(a, b, c) for(int a = (b); a <= (c); ++ a)
#define per(a, b, c) for(int a = (b); a >= (c); -- a)
using namespace std;
template <class T> void rd(T &x){
  x = 0; int f = 1; char ch = getchar();
  while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); }
  while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  x *= f;
}

const int mod = 998244353;
const int maxn = 205;
int n;
int x[maxn], y[maxn], pw[maxn];
int ans;

int main(){
  rd(n);
  pw[0] = 1;
  rep(i, 1, n) rd(x[i]), rd(y[i]), pw[i] = pw[i - 1] * 2 % mod;
  int ans = pw[n] - n - 1;
  rep(i, 1, n){
	rep(j, i + 1, n){
	  int cnt = 0;
	  rep(k, j + 1, n){
		if((y[i] - y[k]) * (x[j] - x[k]) == (y[j] - y[k]) * (x[i] - x[k]))
		  cnt ++;
	  }
	  ans = (ans + mod - pw[cnt]) % mod;
	}
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

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

const ll LINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9+7;

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){
	fastio;
	int n;
	cin >> n;
	cout << setprecision(10) << fixed << ceil(n/2.0)/(n*1.0) << endl;	
	return 0;
}

Measured memory_bytes: 256
x, n = [int(x) for x in input().split()]
if n == 0:
    print(x)
else:
    arr = {int(x):True for x in input().split()}
    if x not in arr:
        print(x)
    else:
        left, right = x-1, x+1
        while True:
            if left not in arr:
                print(left)
                break
            elif right not in arr:
                print(right)
                break
            left -= 1
            right += 1


Measured memory_bytes: 9160
def main():
    import sys
    input = sys.stdin.buffer.readline
    MOD = 10**9 + 7
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    A.sort()
    m = N+5
    fac = [0] * m
    finv = [0] * m
    inv = [0] * m

    def COMBinitialize(m):
        fac[0] = 1
        finv[0] = 1
        if m > 1:
            fac[1] = 1
            finv[1] = 1
            inv[1] = 1
            for i in range(2, m):
                fac[i] = fac[i-1] * i % MOD
                inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
                finv[i] = finv[i - 1] * inv[i] % MOD

    def COMB(n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

    COMBinitialize(m)
    ans = 0
    minS = 0
    maxS = 0
    for i in range(K-1, N):
        maxS += A[i]*COMB(i, K-1)
        maxS %= MOD
    for i in range(N-K+1):
        minS += A[i]*COMB(N-i-1, K-1)
        minS %= MOD
    ans = maxS - minS
    ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 58096
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<x<<endl;
#define ll long long int
#define pb push_back
#define in insert
#define mp make_pair
#define F first
#define S second
#define N 1000000
#define mod 1000000007
#define PI acos(-1)
int main()
{
	IOS
	int n;
	cin>>n;
	ll a[n],i;
	for(i=0;i<n;i++)
	cin>>a[i];
	multiset<pair<ll,ll> > st;
	sort(a,a+n,greater<ll>());
	st.insert({a[1],a[0]});  //{small,large}
	st.insert({a[1],a[0]});
	ll ans=a[0];
	for(i=2;i<n;i++)
	{
		auto it=st.end();
		it--;
		ans+=it->first;
		pair<ll,ll> p=*it;
		st.erase(it);
		st.insert({a[i],p.first});
		st.insert({a[i],p.second});
	}
	cout<<ans;
}

Measured memory_bytes: 17716
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    int N, Y;
    cin >> N >> Y;

    for (int ichiman = 0; ichiman <= Y / 10000; ichiman++)
    {
        for (int gosen = 0; gosen <= Y / 5000; gosen++)
        {
            int sen = N - (ichiman + gosen);
            bool isPlus = (sen >= 0);
            bool price = (ichiman * 10000 + gosen * 5000 + sen * 1000 == Y);
            bool num = (ichiman + gosen + sen == N);
            if (isPlus == true && price == true && num == true)
            {
                printf("%d %d %d\n", ichiman, gosen, sen);
                return (0);
            }
        }
    }
    printf("-1 -1 -1\n");
    return (0);
}

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

int main() {
  ll n, t, mx1 = 0, mx2 = 0, x1, x2, ans;
  cin >> n;
  vector<ll> v1(100001), v2(100001);
  rep(i, n) {
    cin >> t;
    if (i % 2 == 0) {
      v1[t]++;
      if (v1[t] > mx1) mx1 = v1[t], x1 = t;
    } else {
      v2[t]++;
      if (v2[t] > mx2) mx2 = v2[t], x2 = t;
    }
  }

  sort(v1.rbegin(), v1.rend());
  sort(v2.rbegin(), v2.rend());

  if (x1 != x2)
    ans = n - mx1 - mx2;
  else
    ans = n - max(mx1 + v1[1], mx2 + v2[1]);

  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
struct Edge {
  int to, id;
};
vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c=-1, int p = -1) {
  int k=1;
  rep(i, g[v].size()) {
    int u = g[v][i].to, ei = g[v][i].id;
    if(u == p) continue;
    if(k == c) k++;
    ans[ei] = k; k++;
    dfs(u, ans[ei], v);
  }
}

int main() {
  int n; cin >> n;
  g.resize(n);
  ans = vector<int>(n-1);
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(Edge{b, i});
    g[b].push_back(Edge{a, i});
  }
  dfs(0);
  int mx = 0;
  rep(i, n) mx = max(mx, int(g[i].size()));
  cout << mx << endl;
  rep(i, n-1) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
bool exist[1000010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K; cin >> K;
    int r = 7 % K;
    int cnt = 0;
    while(true) {
        cnt++;
        if(exist[r]) {
            cout << "-1" << endl;
            return 0;
        }
        exist[r] = true;
        if(r == 0) {
            cout << cnt << endl;
            return 0;
        }
        r = (r * 10 + 7) % K;
    }

    return 0;
}


Measured memory_bytes: 4488
#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
int a[26];
int main()
{
    string s;
    cin>>s;
    int l=s.size(),c=1;
    for(int i=0;i<l;i++)
    {
       a[s[i]-'a']++;
    }
    for(int i=0;i<26;i++)
    {
       if(a[i]%2!=0)
       {
          c=0;
       }
    }
    if(c)
      cout<<"Yes"<<nl;
    else
      cout<<"No"<<nl;
    return 0;
}


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

int main() {
  
  while (true) {
    
    int H, W; cin >> H >> W;
    
    if (H != 0 && W != 0) {
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) cout << "#";
        cout << endl; 
      }
    }
    
    else {
      break;
    }
    
    cout << endl;
    
  }
  
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define ll long long

#define nl printf("\n")
#define pb(x) push_back(x)

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define P(a) printf("%d",a)

#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a<b)?a:b)

#define PL(a) printf("%lld",a)
#define PLN(a) printf("%lld\n",a)
#define PLC(a) printf("%lld ",a)
#define SL(a) scanf("%lld",&a)
#define SL2(a,b) scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SL4(a,b,c,d) scanf("%lld%lld%lld%lld",&a,&b,&c,&d)

#define CLR(a) memset(a,0,sizeof(a))
#define SET(a) memset(a,-1,sizeof(a))
#define FOOL(a) memset(a,false,sizeof(a))
#define fr(i,a,n) for(i=a;i<=n;i++)
#define frv(i,v) for(i=0;i<(int)v.size();i++)
#define pi acos(-1.0)
#define po 1000000
#define co 1000000
#define mod 786433

using namespace std;
int main()
{
    ll n,k,x,y,ans,b;
    SL2(n,k);
    ans=0;
    if(k==0)ans=n*n;
    else
    {
        for(b=1;b<=n;b++)
        {
            ans+=n,y=min(k,b),x=y*(n/b),ans-=x,y=n%b,x=min(k-1,y),ans-=x;
        }
    }
    PLN(ans);
}

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

int main(int argc, char const *argv[])
{
    string a;
    cin >> a;

    char b = a[a.size() - 1];
    if (b == '3')
    {
        cout << "bon" << endl;
        return 0;
    }
    else if (b == '0' || b == '1' || b == '6' || b == '8')
    {
        cout << "pon" << endl;
        return 0;
    }

    cout << "hon" << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(void){
    
    //変数：机の数「　desk　」、椅子の数「　chair　」と置く
    int desk, chair;
    
    //変数：机の数「　desk　」、椅子の数「　chair　」を入力
    cin >> desk >> chair;
    
    //出力:イベントに準備する椅子の数　＝　机の数　✖　椅子の数
    cout << desk * chair << endl;
    
    return 0;
}



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

int main(){
    int N,cnt;
    cnt = 0;
    cin>>N;
    
    for(int i=0;i<N;i++){
        int n;
        cin>>n;
        for(int j = 2;j<=sqrt(n);j++){
            if(n%j==0){
                cnt++;
                break;
            }
        }
    }
    
    int np=N-cnt;
    cout<<np<<endl;
    return 0;
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,l;
cin>>n>>l;
vector<string>s(n);
rep(i,n)cin>>s[i];
sort(s.begin(),s.end());
string ans="";
rep(i,n)ans+=s[i];
cout<<ans<<endl;
return 0;
}

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

using namespace std;
int powint(int powintnum,int powintjou){
if(powintjou==1){
return powintnum;
}else if(powintjou==0){
return 1;
}else if(powintjou%2==0){
int powinttmp=powint(powintnum,powintjou/2);
return powinttmp*powinttmp;
}else{
int powinttmp=powint(powintnum,powintjou-1);
return powinttmp*powintnum;
}
}

int main(void) {
	double n,k;
	double ans=0.0,tmp;

	cin>>n>>k;
	double ki=0.0;

	for (int i = n; i >= 1; i--) {
		double ii=i;
		while(1){
			if(ii*powl(2.0,ki)<k)ki++;
			else break;
		}
		tmp=powl(2.0,double(ki));
		ans=ans+1/tmp;
		//printf("%d,%d,%lf\n",i,ki,ans);
	}

	ans=ans/n;

	//cout<<ans<<"\n";
	printf("%.10lf\n",ans);


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    ll int n;
    lld d;
    cin>>n>>d;
    ll int i,cnt=0;
    lld x,y,w;
    for(i=1;i<=n;i++)
    {
    	cin>>x>>y;
    	w=sqrt(x*x+y*y);
    	if(w<=d)
    		cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3864
#!/usr/bin/python3

import array
from fractions import Fraction
import math
import os
import sys


class Vec(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y
        super().__init__()

    def __add__(self, other):
        return Vec(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vec(self.x - other.x, self.y - other.y)

    def __mul__(self, scalar):
        return Vec(self.x * scalar, self.y * scalar)

    def __truediv__(self, scalar):
        return Vec(self.x / scalar, self.y / scalar)

    def __iadd__(self, other):
        self.x += other.x
        self.y += other.y
        return self

    def __isub__(self, other):
        self.x -= other.x
        self.y -= other.y
        return self

    def __imul__(self, scalar):
        self.x *= scalar
        self.y *= scalar
        return self

    def __idiv__(self, scalar):
        self.x /= scalar
        self.y /= scalar
        return self

    def __neg__(self):
        return Vec(-self.x, -self.y)

    def dot(self, other):
        return self.x * other.x + self.y * other.y

    def cross(self, other):
        return self.x * other.y - self.y * other.x

    def abs2(self):
        return self.x * self.x + self.y * self.y

    def __abs__(self):
        return math.sqrt(float(self.abs2()))

    def __str__(self):
        return '({}, {})'.format(self.x, self.y)


def main():
    x1, y1, x2, y2 = read_ints()
    Q = read_int()
    for _ in range(Q):
        x, y = read_ints()
        print(*solve(Vec(x1, y1), Vec(x2, y2), Vec(x, y)))


def solve(u, v, a):
    v -= u
    a -= u
    f = Fraction(v.dot(a), v.abs2())
    v *= f
    v += u
    return float(v.x), float(v.y)


###############################################################################
# AUXILIARY FUNCTIONS

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()



Measured memory_bytes: 7336
# import numpy as np
# import scipy as sp
# import sys
# input = sys.stdin.readline
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# a=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# a=[int(input()) for _ in range (n)]  #リスト入力  改行でa1 ... anのとき
# s=[list(map(str,list(input()))) for i in range(h)]  # 文字列の二次元配列入力
# s = [list(map(int, input().split())) for i in range(n)] # 数値の二次元配列入力
# a = b[:], a = [x[:] for x in b] # deepcopy
# chr(ord('a') + 1) # chrのインクリメント
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#　

s = input()
if s == 'AAA' or s == 'BBB':
    print('No')
else:
    print('Yes')


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


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;cin>>n;
	ll i,j;
	string s;cin>>s;
	ll c=('R')^('G')^('B');
	//cout<<char(c^'R'^'B');
	map<char,vector<ll>> ma;
	ll sum=0;
	for(i=0;i<n;i++)
		ma[s[i]].push_back(i);
	for(i=0;i<n;i++)
		for(j=i+1;j<n;j++){
			if(s[i]!=s[j])
			{
				char ch=char(c^(s[i])^(s[j]));
				sum+=ma[ch].end()-lower_bound(ma[ch].begin(),ma[ch].end(),j);
				if(lower_bound(ma[ch].begin(),ma[ch].end(),j-i+j)!=ma[ch].end() and (*lower_bound(ma[ch].begin(),ma[ch].end(),j-i+j))==j-i+j)
					sum--;
			}
		}
		cout<<sum;
	return 0;
} 

Measured memory_bytes: 3660