akhauriyash/Code-Regression huggingface dataset:
from statistics import median_low

n = int(input())
lst = list(map(int, input().split()))
mid = [None for i in range(n)]
end = [None for i in range(n)]

for i in range(n):
    mid[i] = lst[i]-i
# print(mid)

num = mid.index(median_low(mid))
for i in range(n):
    end[i] = lst[num]-num+i
# print(end)

ans = 0
for i in range(n):
    ans += abs(lst[i]-end[i])
print(ans)


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

int main(){
    ll N; cin>>N;
    int n = (int)pow(N,0.5);
    int ans=1;
    for(int i=n; i>=1; i--){
        if(N%i==0){
            ans=i;
            break;
        }
    }
    cout<<(ans-1)+(N/ans)-1<<endl;
    return 0;
}

Measured memory_bytes: 4016
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
m=[list(map(int,input().split())) for _ in range(M)]
min_a=min(a)
min_b=min(b)

min_cost=min_a+min_b
for _m in m:
  cost=a[_m[0]-1]+b[_m[1]-1]-_m[2]
  min_cost=min(min_cost,cost)
print(min_cost)






Measured memory_bytes: 38560
from fractions import gcd

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

cum_left = [A[0]]
cum_right = [A[N - 1]]
for i in range(1, N - 1):
    cum_left.append(gcd(cum_left[-1], A[i]))
    cum_right.append(gcd(cum_right[-1], A[N - 1 - i]))

ans = max(cum_left[N - 2], cum_right[N - 2])
for i in range(1, N - 1):
    ans = max(ans, gcd(cum_left[i - 1], cum_right[N - 2 - i]))
print(ans)


Measured memory_bytes: 16120
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 998244353


def resolve():
    n, k = map(int, input().split())
    LR = [list(map(int, input().split())) for _ in range(k)]

    dp = [0] * (n + 1)
    dp_sum = [0] * (n + 1)
    dp[1] = 1
    dp_sum[1] = 1
    for i in range(2, n + 1):
        for l, r in LR:
            li = max(0, i - r)
            ri = i - l
            if ri < 0:
                continue
            dp[i] += dp_sum[ri] - dp_sum[li - 1]
            dp[i] %= mod
        dp_sum[i] = dp_sum[i - 1] + dp[i]
        dp_sum[i] %= mod
    print(dp[n])


if __name__ == '__main__':
    resolve()


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

const int MAX_P = 10;

class Team {
public:
    int id;
    int solve_;
    int penalty_;
    int failures_[MAX_P];

    Team() {
        solve_ = 0;
        penalty_ = 0;
        fill_n(failures_, MAX_P, 0);
    }

    void correct(int pid, int time) {
        solve_++;
        penalty_ += failures_[pid - 1] * 1200 + time;
    }

    void wrong(int pid) {
        failures_[pid - 1]++;
    }

    friend bool operator<(const Team& t1, const Team& t2) {
        if (t1.solve_ != t2.solve_) {
            return t1.solve_ > t2.solve_;
        }
        if (t1.penalty_ != t2.penalty_) {
            return t1.penalty_ < t2.penalty_;
        }
        return t1.id < t2.id;
    }
};

int main () {
    int t, p, r;
    while (cin >> t >> p >> r, t | p | r) {
        vector<Team> teams(t);
        for (int i = 0; i < t; i++) {
            teams[i].id = i + 1;
        }

        for (int i = 0; i < r; i++) {
            int tid, pid, time;
            string message;
            cin >> tid >> pid >> time >> message;
            if (message == "CORRECT") {
                teams[tid - 1].correct(pid, time);
            } else if (message == "WRONG") {
                teams[tid - 1].wrong(pid);
            }
        }

        sort(teams.begin(), teams.end());
        for (vector<Team>::iterator it = teams.begin(); it != teams.end(); it++) {
            cout << it->id << " " << it->solve_ << " " << it-> penalty_ << endl;
        }
    }
}

Measured memory_bytes: 1220
class Integer
  def combination(k)
    return 1 if k.zero?

    (self - k + 1..self).inject(:*) / k.factorial
  end

  def permutation(k)
    return 1 if k.zero?

    (self - k + 1..self).inject(:*)
  end

  def factorial
    return 1 if self.zero?

    (1..self).inject(:*)
  end
end

n, k = gets.chomp.split.map &:to_i
1.upto(k) do |i|
  if i > n - k + 1
    puts 0
  else
    a = (n - k + 1).combination(i)
    b = (k - 1).combination(i - 1)
    puts a * b % (10 ** 9 + 7)
  end
end


Measured memory_bytes: 3076
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  ll a,b,x;
  cin >> a>>b>>x;
  
  if(a==0) {
  cout << b/x+1 << endl;
  return 0;
  }
    
  else{  
  cout << b/x-(a-1)/x << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int A, B;
    cin >> A >> B;
    B -= 1;
    if (B == 0) {
        cout << 0 << endl;
        return 0;
    }
    int ans = (B-1) / (A-1) + 1;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(int argc, char const *argv[])
{
  int a,b,c,d,e,f;
  scanf("%d",&a);
  b=a/100;
  c=a%100;
  d=c/10;
  e=c%10;
  f=b+d+e;
  printf("%d",f);
  return (0);
}

Measured memory_bytes: 128
h,w,k=map(int,input().split())
G=[["."]*w for i in range(h)]
for i in range(h):
  G[i]=list(input())
ans=[[0]*w for i in range(h)]
GG=[[0] for i in range(h)]
for i in range(h):
  for j in range(w):
    if G[i][j]=="#":
      GG[i].append(j)
  GG[i].append(w)
B=[0]
a=1
for i in range(h):
  if len(GG[i])==2:
    continue
  B.append(i)
  ans[i][GG[i][0]:GG[i][2]]=[a]*(GG[i][2]-GG[i][0])
  a=a+1
  for j in range(len(GG[i])-3):
    ans[i][GG[i][j+2]:GG[i][j+3]]=[a]*(GG[i][j+3]-GG[i][j+2])
    a=a+1
B.append(h)
for i in range(B[2]-B[0]):
  ans[i]=ans[B[1]]
for i in range(B[2],h):
  if i not in B:
    ans[i]=ans[i-1]
for i in range(h):
  for j in range(w):
    print(ans[i][j],end=" ")
  print()

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

int N, A[100000];

int main(){
	vector<int> len;
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d", &A[i]);
	sort(A, A + N, greater<int>());
	for(int i = 0; i < N - 1 && len.size() < 2; i++){
		if(A[i] == A[i + 1]) len.push_back(A[i]), i++;
	}
	if(len.size() == 2) printf("%lld\n", (long long)len[0] * len[1]);
	else printf("0\n");
	return 0;
}


Measured memory_bytes: 640
// #include <iomanip>
#include <iostream>

using namespace std;

int main()
{
  // -1000000
  // +1000000

  int k, x;
  scanf("%d %d", &k, &x);

  int left = x - k + 1;
  int right = x + k - 1;

  if (left < -1000000)
  {
    left = -1000000;
    right -= (left + 1000000);
  }
  if (right > 1000000)
  {
    right = 1000000;
    left -= (right - 1000000);
  }

  for (int i = left; i <= right; i++)
  {
    printf(" %d", i);
  }
}


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

using namespace std;

int main() {
  int k, x;
  cin >> k >> x;
  // if (k == 1) {
  //   cout << x << endl;
  //   return 0;
  // }
  int start = max(-1000000, x - k + 1);
  int end = min(1000000, x + k - 1);
  for (int i = start; i <= end; ++i) {
    cout << i;
    if (i == end) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
  return 0;
}



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

ll n;
ll dp[3][100005];
int main(){
    cin >> n;
    dp[0][0]=0;
    dp[1][0]=0;
    dp[2][0]=0;
    for(ll i=1;i<=n;i++){
        ll a,b,c;
        cin >> a >> b >> c;
        dp[0][i]=max(dp[1][i-1]+a,dp[2][i-1]+a);
        dp[1][i]=max(dp[0][i-1]+b,dp[2][i-1]+b);
        dp[2][i]=max(dp[0][i-1]+c,dp[1][i-1]+c);
    }
    ll res=0;
    for(ll i=0;i<3;i++){
        res=max(res,dp[i][n]);
    }
    cout << res << endl;
}


Measured memory_bytes: 5940
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define Abs(x) ((x) > 0 ? (x) : -(x))
#define REP(i, n) for(int i = 0; i < n; i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9 + 7
typedef long long ll;

int
main(int arg, char *argv[])
{
  int n, a[20]; ll ans = 1, k = 1;
  scanf("%d", &n);
  REP(i, n){
    scanf("%d", &a[i]);
    if(!(a[i] & 1)) ans *= 2;
    k *= 3;
  }

  printf("%lld\n", k - ans);
  return 0;
}
  

  


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


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var rdx = ReadIntArray();
            int r = rdx[0], D = rdx[1], x = rdx[2];
            for (int i = 0; i < 10; i++)
            {
                x = r * x - D;
                Out(x);
            }
        }

        //最小公倍数
        static int LCM(int num1, int num2)
        {
            var gcd = GCD(num1, num2);
            return num1 * (num2 / gcd);
        }

        static long LCM(long num1, long num2)
        {
            var gcd = GCD(num1, num2);
            return num1 * (num2 / gcd);
        }

        //最大公約数
        static int GCD(int num1, int num2)
        {
            int a = Math.Max(num1, num2);
            int b = Math.Min(num1, num2);
            int mod;
            while ((mod = a % b) != 0)
            {
                a = b;
                b = mod;
            }

            return b;
        }

        static long GCD(long num1, long num2)
        {
            long a = Math.Max(num1, num2);
            long b = Math.Min(num1, num2);
            long mod;
            while ((mod = a % b) != 0)
            {
                a = b;
                b = mod;
            }

            return b;
        }

        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static string ReadString()
        {
            return Console.ReadLine();
        }

        static void Out(object o)
        {
            Console.WriteLine(o);
        }
    }

    static class EnumerableExtension
    {
        public delegate void Function<in T>(T val);

        public static void ForEach<T>(this IEnumerable<T> enumerable, Function<T> function)
        {
            foreach (var x in enumerable)
            {
                function(x);
            }
        }
    }

    class PriorityQueue<T>
    {
    }

    class UnionFind
    {
        private readonly int[] _array;

        public UnionFind(int N)
        {
            _array = new int[N];
            for (int i = 0; i < N; i++)
            {
                _array[i] = i;
            }
        }

        public int GetRootNode(int n)
        {
            if (_array[n] == n) return n;
            return _array[n] = GetRootNode(_array[n]);
        }

        public void UnionGroup(int a, int b)
        {
            var rootA = GetRootNode(a);
            var rootB = GetRootNode(b);
            if (rootA == rootB) return;
            _array[rootA] = rootB;
        }

        public bool IsSameGroup(int a, int b) => GetRootNode(a) == GetRootNode(b);

        public bool IsRoot(int n) => _array[n] == n;
    }
}

Measured memory_bytes: 11348
import sys
N,A,B = map(int,input().split())
array = list(map(int,input().split()))

cost = 0
for J in range(len(array)-1):
        walk_cost = (array[J+1] - array[J])*A
        if walk_cost < B:
            cost += walk_cost
        else:
            cost += B
print(cost) 

Measured memory_bytes: 19980
<?php  
$stdin1 = trim(fgets(STDIN));  
$array1 = explode(' ', $stdin1);
$select = $array1[1];
$stdin2 = trim(fgets(STDIN));  
$array2 = explode(' ', $stdin2);
$sum = array_sum($array2);
$count = 0;
$warukazu = $select * 4;
 
foreach ($array2 as $num) {
  if ($sum / $warukazu > $num) {
    continue;
  }
  $count++;
}
 
if ($count >= $select) {
  echo 'Yes';
} else {
  echo 'No';
}

Measured memory_bytes: 4728
#include <iostream>
#include <string>

using namespace std;

int main() {
  string str, op;
  cin >> str;
  int q;
  cin >> q;
  for(int i=0; i<q; i++) {
    cin >> op;
    if(op == "replace") {
      int s, e;
      string c;
      cin >> s >> e;
      cin >> c;

      int pos=0;
      for(int j=s; j<=e; j++) {
        str[j] = c[pos];
        pos++;
      }
    }
    else if(op == "reverse") {
      int s, e;
      cin >> s >> e;
      char tmp;
      while(s < e) {
        tmp = str[s];
        str[s] = str[e];
        str[e] = tmp;
        s++;
        e--;
      }
    }
    else {
      int s, e;
      cin >> s >> e;
      for(int j=s; j<=e; j++) {
        cout << str[j];
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define wgt(x) (x.first)
#define s(x) (x.second.first)
#define t(x) (x.second.second)
#define mwe(w,s,t) make_pair(w,make_pair(s,t))

using namespace std;

typedef pair<int,int> edge;
typedef pair<int,edge> we;

int main()
{
	int n,G[100][100];
	bool used[100];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			scanf("%d",&G[i][j]);
	memset(used,false,sizeof(used));
	priority_queue<we,vector<we>,greater<we> > pq;
	int tot=0;
	used[0]=true;
	for(int i=0;i<n;i++)
		if(G[0][i]>=0)
			pq.push(mwe(G[0][i],0,i));
	while(!pq.empty())
	{
		we t=pq.top();pq.pop();
		if(used[t(t)]) continue;
		tot+=wgt(t);
		used[t(t)]=true;
		for(int i=0;i<n;i++)
			if(!used[i]&&G[t(t)][i]>=0)
				pq.push(mwe(G[t(t)][i],t(t),i));
	}
	printf("%d\n",tot);
	return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const ll MAX=1e18;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int> a(400);
    vector<ll> prefix(n+1);
    prefix[0]=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        prefix[i+1]=prefix[i]+a[i];
    }
    vector<vector<ll>> dp(n,vector<ll>(n));
    for(int i=0;i<n;i++){
        dp[i][i]=0;
    }
    for(int i=n-1;i>=0;i--){
        for(int j=i+1;j<n;j++){
            dp[i][j]=MAX;
            for(int k=i;k<j;k++){
                dp[i][j]=min(dp[i][j],prefix[j+1]-prefix[i]+dp[i][k]+dp[k+1][j]);
            }
        }
    }
    cout<<dp[0][n-1]<<'\n';
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, n, m) for(int i = n; i < (int)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll MOD = 1000000007;

int main()
{
    ll N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    ll LR = 0;
    ll RL = 0;
    ll ans = 0;
    REP(i,N-1) {
        if (S[i] == 'L' && S[i+1] == 'R') LR++;
        if (S[i] == 'R' && S[i+1] == 'L') RL++;
        if (S[i] == S[i+1]) ans++;
    }
    ll T = max(LR, RL);
    if (K >= T) {
        PRINT(N-1);
    } else {
        ans += 2 * (K);
        PRINT(ans);
    }

    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <iostream>

using namespace std;

#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, K;
int cnt[27];
char in[10101][20];

int main()
{
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; ++i) {
		scanf("%s", in[i]);
		cnt[in[i][0] - 'A']++;
	}
	int ret = 0;
	priority_queue<int> q;
	for (int i = 0; i < 26; ++i) if (cnt[i] > 0) {
		q.push(cnt[i]);
	}
	for (;;) {
		vector<int> a;
		bool flg = true;
		for (int i = 0; i < K; ++i) {
			if (q.empty()) {
				flg = false;
				break;
			}
			if (q.top() > 1) a.push_back(q.top() - 1);
			q.pop();
		}
		if (!flg) break;
		++ret;
		for (int v : a) if (v != 0) q.push(v);
	}
	printf("%d\n", ret);

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vint L(N);
    rep(i, N) cin >> L[i];
    sort(L.begin(), L.end());
    ll ans = 0;
    rep(i, N) {
        REP(j, i + 1, N) {
            int a = L[i];
            int b = L[j];
            int min_c = abs(a - b);
            int max_c = abs(b + a);
            auto it1 = lower_bound(L.begin(), L.end(), max_c);
            auto it2 = upper_bound(L.begin(), L.end(), min_c);
            int lower_idx = distance(L.begin(), it1);
            int upper_idx = distance(L.begin(), it2);
            int sub = 0;
            if (upper_idx <= i && i < lower_idx) sub++;
            if (upper_idx <= j && j < lower_idx) sub++;
            ans += ll(max(0, (lower_idx - upper_idx) - sub));
        }
    }
    cout << ans/3 << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N= I()
h = LI()
dp = [float('INF')]*N
dp[0] = 0
for i,j in itertools.product(range(N),[1,2]):
    if i-j>=0:
        dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[-1])


Measured memory_bytes: 53192
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,m,d,cnt,i,j,k,flg;
	char a[100][101];
	cin>>n>>m>>d;
	for(i=0;i<n;i++) cin>>a[i];
	cnt=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(a[i][j]=='.'){
				flg=1;
				for(k=1;k<d;k++){
					if(a[i][j+k]!='.'){
						flg=0;
						break;
					}
				}
				if(flg==1) cnt++;
				flg=1;
				for(k=1;k<d;k++){
					if(a[i+k][j]!='.'){
						flg=0;
						break;
					}
				}
				if(flg==1) cnt++;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3096
from sys import stdin

n = int(stdin.readline().rstrip())
p = [int(x) for x in stdin.readline().rstrip().split()]

p_con = [p[i] for i in range(
    1, n-1) if (p[i] != min(p[i-1], p[i], p[i+1])) and (p[i] != max(p[i-1], p[i], p[i+1]))]

print(len(p_con))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<(int)S.size();++i)
#define fore(i,x) for(int i = head[x] ; i ; i = e[i].next)
#define mp make_pair
#define pb push_back
#define maxn 1000005
#define ll long long 
#define fi first
#define int ll
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
int L,n;
int a[maxn];
int cmax;
vector<int> sl,sr;
int suml[maxn],sumr[maxn];
signed main()
{cin>>L>>n;
 rep(i,1,n) {scanf("%lld",&a[i]);sr.pb(a[i]);sumr[i]=sumr[i-1]+a[i];}
 cmax=max(a[n],L-a[1]);
 int t=0;
 repd(i,n,2)
   { sl.pb(L-a[i]); sr.pop_back() ;
     t++;int l=sr.size();
	 suml[t]+=suml[t-1]+L-a[i];
	 if(sl.size()>sr.size())
	    {int tmp=suml[t]*2+sumr[l]*2;
		 int cha=sl.size()-sr.size();
	     cmax=max(cmax,sumr[l]*2+suml[sr.size()-1]*2+sl[sl.size()-1]);
	     cmax=max(cmax,tmp-suml[sl.size()-sr.size()]*2-sr[sr.size()-1]);
	     cmax=max(cmax,tmp-suml[sl.size()-sr.size()-1]*2-sl[sl.size()-1]);
		}
	if(sl.size()==sr.size())
	   {int tmp=suml[t]*2+sumr[l]*2;
	    cmax=max(cmax,tmp-sl[sl.size()-1]);
	    cmax=max(cmax,tmp-sr[sr.size()-1]);
	   }
	  if(sl.size()<sr.size())
	    {int tmp=suml[t]*2+sumr[l]*2;
		 int cha=sr.size()-sl.size();
	     cmax=max(cmax,suml[t]*2+sumr[sl.size()-1]*2+sr[sr.size()-1]);
	     cmax=max(cmax,tmp-sumr[sr.size()-sl.size()]*2-sl[sl.size()-1]);
	     cmax=max(cmax,tmp-sumr[sr.size()-sl.size()-1]*2-sr[sr.size()-1]);
		}  	
   }
	cout<<cmax;
}

Measured memory_bytes: 14576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 ll a,b,c,d;
  cin>>a>>b>>c>>d;
  vector<ll> v(4);
  v[0]=a*c;
  v[1]=a*d;
  v[2]=b*c;
  v[3]=b*d;
  cout<<(*max_element(v.begin(),v.end()));
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
 
long long calc(int n, int c1, int c2, int s1, int s2, const vector<int>& options,
               int d, int nt, int ot) {
  int b1(d-1), a1(d+1), b2(d-1), a2(d+1);
  while (b1 >= 0 && options[b1] != nt) b1--;
  while (b2 >= 0 && options[b2] != ot) b2--;
  while (a1 < n && options[a1] != nt) a1++;
  while (a2 < n && options[a2] != ot) a2++;
  int x1(d-b1-1), y1(a1-d-1), z1(a1-b1-1), x2(d-b2-1), y2(a2-d-1), z2(a2-b2-1);
  int diff1 = z1*(z1+1)/2-x1*(x1+1)/2-y1*(y1+1)/2;
  int diff2 = z2*(z2+1)/2-x2*(x2+1)/2-y2*(y2+1)/2;
  return (long long) diff1 * c1 - (long long) diff2 * c2 + s1 - s2;
}
 
int main() {
  int n;
  cin >> n;
  vector<int> c(26);
  vector<array<int, 26>> s(n);
  
  vector<int> last(26, -1);
  
  for (int i = 0; i < 26; ++i)
    cin >> c[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 26; ++j)
      cin >> s[i][j];
  
  long long total(0);
  vector<int> options(n);
  
  for (int i = 0; i < n; ++i) {
    int neg(0), test(-1);
    for (int j = 0; j < 26; ++j) {
      neg -= c[j] * (i - last[j]);
    }
    
    int max_score = -1e9;
    for (int j = 0; j < 26; ++j) {
      int ss = s[i][j] + neg + c[j] * (i - last[j]);
      if (ss > max_score) {
        max_score = ss;
        test = j;
      }
    }
    total += max_score;
    options[i] = test;
    last[test] = i;
  }
  /* reversed: 109149564 */
  /* sorted: */
  /* stocahstic */
  for (int t = 1; t <= 500; ++t) {
    bool entered = false;
    for (int dd = 0; dd < n; ++dd) {
      for (int tt = 0; tt < 26; ++tt) {
        if (tt == options[dd]) continue;
        int ot = options[dd];
        long long ns = calc(n, c[tt], c[ot], s[dd][tt], s[dd][ot],
                            options, dd, tt, ot);
        //cout << ns << endl;
        if (ns > 0) {
          entered = true;
          total += ns;
          options[dd] = tt;
    	}
      }
    }
    if (!entered) break;
  }
  for (const int& i: options) cout << i + 1 << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
  int n;
  int d[102]={0};
  int max=0;
  while(cin>>n){
    d[n]++;
    if(max<d[n]){
      max=d[n];
    }
  }
  if(max!=0){
    for(int i=0;i<101;i++){
      if(d[i]==max){
	cout<<i<<endl;
      }
    }
  }
  return 0;
} 

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

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

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void solve(int D, int E) {
	double minv = 1e9;
	for (int x = 0; x <= D; x++) {
		int y = D - x;
		minv = min(minv, fabs(sqrt((double)x*x + (double)y*y) - (double)E));
	}
	cout << fixed << setprecision(10) << minv << endl;
}

int main() {
	int D, E;
	while (cin >> D >> E, D || E) {
		solve(D, E);
	}
	return (0);
}


Measured memory_bytes: 3236
N, K = list(map(int,input().split()))
A = list(map(int,input().split()))
for i in range(N):
    A[i] -= 1
    
visited = [-1] * N
visited[0] = 0
ret = [0]
next_ = A[0]
roop_start = 10 ** 9 + 7

for i in range(1, K + 1):
    if visited[next_] != -1:
        roop_start = visited[next_]
        break
    ret.append(next_)
    visited[next_] = i
    next_ = A[next_]
    
if K <= roop_start:
    print(ret[K] + 1)
else:
    roop_length = len(ret) - roop_start
    mod = (K - roop_start) % roop_length
    print(ret[roop_start + mod] + 1)

Measured memory_bytes: 94156
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int a; cin >> a;
	int b; cin >> b;
	cout << max({a + b, a - b, a * b}) << endl;
	return;
}

int main() {
	solve();
  return 0;
}

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

typedef int Capacity;
struct Edge {
    int src, dst;
    Capacity cap;
    Edge(int src_, int dst_, Capacity cap_) :
        src(src_), dst(dst_), cap(cap_) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

struct Dinic {
    int n, t;
    vector<int> level;
    vector<char> vis;
    vector<vector<Capacity>> cap, flow;
    vector<vector<int>> g;
    Capacity inf;
    Dinic(int n)
        : n(n), cap(n, vector<Capacity>(n)), flow(n, vector<Capacity>(n)),
          g(n, vector<int>()), inf(numeric_limits<Capacity>::max()/8){}
    Dinic(const Graph &graph){
        *this = Dinic(graph.size());
        rep(i,n) for(auto &e : graph[i]) addEdge(e.src, e.dst, e.cap);
    }
    void addEdge(int u, int v, Capacity c){
        cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;
        g[u].push_back(v); g[v].push_back(u);
    }
    Capacity solve(int s, int t){
        Capacity res = 0;
        this->t = t;
        while(1){
            levelize(s);
            vis.assign(n, false);
            Capacity aug = 1;
            Capacity daug = 0;
            while(aug > 0){
                daug += (aug = augment(s, inf));
            }
            res += daug;
            if(daug == 0) break;
        }
        return res;
    }
    Capacity augment(int v, const Capacity &lim){
        vis[v] = true;
        if(v == t) return lim;
        for(const int &d : g[v]){
            if(vis[d] || flow[v][d] == cap[v][d] || level[v] >= level[d]) continue;
            Capacity aug = augment(d, min(lim, cap[v][d] - flow[v][d]));
            flow[v][d] += aug;
            flow[d][v] -= aug;
            if(aug > 0) return aug;
        }
        return 0;
    }
    void levelize(int s){
        level.assign(n, inf);
        level[s] = 0;
        queue<int> q;
        q.push(s);
        while(q.size()){
            int v = q.front(); q.pop();
            for(const int &d : g[v]){
                if(level[d] <= level[v] + 1 || cap[v][d] - flow[v][d] == 0) continue;
                level[d] = level[v] + 1;
                q.push(d);
            }
        }
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    Graph g(N);
    rep(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        g[a].emplace_back(a,b,c);
    }
    Dinic ek(g);
    cout << ek.solve(0,N-1) << endl;
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Question question = new Question();
        question.solve(sc);
    }

    static class Question {
        public void solve(Scanner sc) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            int count = 0;
            int[] arr = new int[n]; 

            int sum = 0;
            int i = 0;
            while(n-- > 0) {
                int t = sc.nextInt();
                arr[i++] = t;
                sum += t;
            }
            for(int num : arr) {
                if((double)num >= ((double)sum / (4 * m))) count++;
            }
            System.out.println(count >= m ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
//解説動画写し
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  map<int,int>mp;
  long long ans=0;
  rep(i,n){
    int sa=i-a[i];
    int wa=a[i]+i;
    ans+=mp[sa];
    mp[wa]++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 21100
#include<iostream>
#include<stdio.h>//printf("%.15f\n",*********);
#include<vector>//文字列.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字)
                //to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#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++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#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 Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<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 str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
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<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

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
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}//stringのほうが効率よくないか？

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

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

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;
	
	string s;
	cin >> s;
	bool a = false, b = false;
	int x = 0;

	rep(i, s.size()) {
		if (s[i] == 'C') {
			a = true;
			x = i + 1;
			break;
		}
	}
	for (int i = x; i < s.size(); i++) {
		if (s[i] == 'F') {
			b = true;
			break;
		}
	}
	Yes(a == true && b == true);

	please AC;
}
//参考：---

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
using namespace std;
const long long M=1000000007ll;
int n,k,i,x,a,s,ans;
int main()
{
	scanf("%d %d",&n,&x);
	if(n<x)
      printf("0");
  	else
      printf("10");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if(S == U){
        cout << A-1 << " " << B << endl;
    }
    else{
        cout << A << " " << B-1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int main(void)
{
    ll X, Y;
    cin >> X >> Y;
    ll ans = 0;
    while (X <= Y)
    {
        X *= 2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  int64_t N,M;
  cin>>N>>M;
  if(N==1||M==1){cout<<abs(max(N,M)-2)<<endl;}
  else{cout<<(N-2)*(M-2)<<endl;}
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int K = Integer.parseInt(scan.next());
		scan.close();
		int ans = 0;
		int seven = 7;
		if ((K%2 == 0) || (K%5 == 0)) {
			System.out.println(-1);
		}	else {
			for (int i = 1;i <= K ;i++ ) {
				if (seven % K == 0) {
					ans = i;
					break;
				}
				seven = (seven * 10 + 7) % K;
			}
			System.out.println(ans);
		}
	}

}


Measured memory_bytes: 35616
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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



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

	double l; cin >> l;
	cout << setprecision(16) << l*l*l/27  << endl;
	
} 


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

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> A){
  set<ll> s;
  for(auto x : A) {
    if(s.find(x)==s.end())
      s.insert(x);
    else {
      std::cout << "NO" << std::endl;
      return;
    }
  }
  std::cout << "YES" << std::endl;
    
}

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



Measured memory_bytes: 11136
//This template belongs to Juan Carlo Vieri

/*   ____   __               
    /  _/  |  |    __         __        
 __|  |__  |  |   /_/        |  |                 
|__    __| |  |   __    ____ |  | __   ___   _  ___
   |  |    |  |  |  |  /  _/ |  |/ /  / _ \ | |/ _/   
   |  |    |  |  |  | |  |_  |     \ |  __/ |   / 
   |__|    |__|  |__|  \___\ |__|\__\ \___\ |__|
*/

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

typedef int_fast64_t ll;
typedef long double ld;
typedef int_fast32_t intt;
typedef int_fast32_t tmp_m;
#define deb(x) cout << #x << ' ' << x << endl
#define rep(i, cmp1, cmp2) for (tmp_m i = cmp1; i < cmp2; ++i)
#define repp(i, cmp1, cmp2) for (tmp_m i = cmp1; i >= cmp2; --i)
#define pb push_back
#define st stack
#define pa pair
#define vc vector
#define qu queue
#define pq priority_queue
#define fr first
#define sc second
#define mp map
const ld pi = acos(-1.0);
const intt mod = 1e9 + 7;

struct pr {
  intt x;
  intt y;
  intt dst;
  pr() {}
  pr(intt x, intt y, intt dst) : x(x), y(y), dst(dst) {}
  inline bool operator<(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst < cmp2.dst;
    if (x != cmp2.x) return x < cmp2.x;
    return y < cmp2.y;
  }
  inline bool operator==(const pr& cmp2) const {
    return (cmp2.dst == dst) && (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst > cmp2.dst;
    if (x != cmp2.x) return x > cmp2.x;
    return y > cmp2.y;
  }
};

struct point {
  intt x;
  intt y;
  point() {}
  point(intt x, intt y) : x(x), y(y) {}
  inline bool operator<(const point& cmp2) const {
    if (cmp2.x != x) return cmp2.x < x;
    return cmp2.y < y;
  }
  inline bool operator==(const point& cmp2) const {
    return (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const point& cmp2) const {
    if (cmp2.x != x) return cmp2.x > x;
    return cmp2.y > y;
  }
};

class prHash {
 public:
  size_t operator()(const pr& cmp1) const {
    return (hash<intt>()(cmp1.x)) ^ (hash<intt>()(cmp1.y)) ^
           (hash<intt>()(cmp1.dst));
  }
};

class pointHash {
 public:
  size_t operator()(const point& cmp1) const {
    return (hash<intt>()(cmp1.x)) ^ (hash<intt>()(cmp1.y));
  }
};

inline bool spoint(const point& cmp1, const point& cmp2) {
  // swap(cmp1, cmp2);
  if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
  return cmp1.y < cmp2.y;
}

inline bool spr(const pr& cmp1, const pr& cmp2) {
  // swap(cmp1, cmp2);
  if (cmp1.dst != cmp2.dst) return cmp1.dst < cmp2.dst;
  if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
  return cmp1.y < cmp2.y;
}

void solve() {
  intt n;
  cin >> n;
  n %= 10;
  if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
    puts("hon");
  }else if(n == 0 || n == 1 || n == 6 || n == 8){
    puts("pon");
  } else{
    puts("bon");
  }
}

void init() {
  // remove if interactive
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  // memset(dp, -1, sizeof dp);
}

int main() {
  init();
  solve();
  return 0;
}


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

int main()
{
	int cnt = 0;
	string s, rs;
	while (cin>>s)
	{
		rs = s;
		reverse(rs.begin(), rs.end());
		if (s==rs)
		{
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)

//変数
int N,T;
vector<int> c, t;

//解法
void solve() {

	int ans = 10000;

	rep(i, N) {
		if (t[i] <= T) {
			ans = min(ans, c[i]);
		}
	}

	if (ans == 10000) {
		cout << "TLE";
	}
	else {
		cout << ans;
	}

	return;
}

int main() {
	//入力
	cin >> N>>T;
	c.resize(N);
	t.resize(N);
	rep(i, N) cin >> c[i] >> t[i];
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <complex>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/3)
#define PI (2*acos(0.0))
#define EPS (1e-8)

typedef long long ll;
typedef unsigned long long ull;

int main(){
  ios_base::sync_with_stdio(0);
  double xa, ya, xb, yb, xc, yc, xd, yd;
  double c1, c2, c3, c4;
  pair<double, double> v1, v2, v3, v4;
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd) != EOF){
    v1 = pair<double, double>(xb - xa, yb - ya);
    v2 = pair<double, double>(xc - xb, yc - yb);
    v3 = pair<double, double>(xd - xc, yd - yc);
    v4 = pair<double, double>(xa - xd, ya - yd);
    c1 = v1.first * v2.second - v1.second * v2.first;
    c2 = v2.first * v3.second - v2.second * v3.first;
    c3 = v3.first * v4.second - v3.second * v4.first;
    c4 = v4.first * v1.second - v4.second * v1.first;
    if(c1 * c2 * c3 * c4 < 0) cout << "NO" << endl;
    else cout << "YES" << endl;
  }
  return 0;
}

Measured memory_bytes: 1248
#include<stdio.h>
#include<string.h>
int main()
{
  int K; char S[101];
  scanf("%d\n",&K);
  scanf("%s",S);
  if(strlen(S)<=K){
    printf("%s",S);
  }else{
    for(int i=0;i<K;i++){
      printf("%c",S[i]);
    }
    printf("...");
  }
}

Measured memory_bytes: 1728
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int N;
int cnt[200000];
int main(){
  int Lj4PdHRW;
  rd(N);
  for(Lj4PdHRW=(0);Lj4PdHRW<(N-1);Lj4PdHRW++){
    cnt[rd_int()-1]++;
  }
  {
    int e98WHCEY;
    for(e98WHCEY=(0);e98WHCEY<(N);e98WHCEY++){
      wt_L(cnt[e98WHCEY]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20200430-1

// --- original code ---
// int N, cnt[2d5];
// {
//   rd(N);
//   rep(N-1) cnt[rd_int()-1]++;
//   wtLn(cnt(N));
// }


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

typedef long long int ll;

int dp[100004][4];

int vaction(int vec[][4], int n, int day, int flag){
    
    if (day == n)
        return 0;

    if (dp[day][flag]!=-1)
        return dp[day][flag];

    int maxi = 0;
    if (flag == 0){
        maxi = max(maxi , vec[0][0] + vaction(vec, n, day+1, 1));
        maxi = max(maxi , vec[0][1] + vaction(vec, n, day+1, 2));
        maxi = max(maxi , vec[0][2] + vaction(vec, n, day+1, 3));
    }
    else if (flag==1){
        maxi = max(maxi , vec[day][1] + vaction(vec, n, day+1, 2));
        maxi = max(maxi , vec[day][2] + vaction(vec, n, day+1, 3));
    }
    else if (flag==2){
        maxi = max(maxi , vec[day][0] + vaction(vec, n, day+1, 1));
        maxi = max(maxi , vec[day][2] + vaction(vec, n, day+1, 3));
    }
    else {
        maxi = max(maxi , vec[day][0] + vaction(vec, n, day+1, 1));
        maxi = max(maxi , vec[day][1] + vaction(vec, n, day+1, 2));
    }

    dp[day][flag] = maxi;
    return dp[day][flag];

}

int main(){

    // #ifndef ONLINE_JUDGE
        // freopen("input.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
    // #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;

    memset(dp, -1, sizeof(dp));

    int vec[n+1][4];

    for (int i=0; i<n; i++){
        for (int j=0; j<3; j++){
            cin >> vec[i][j];
        }
    }

    cout << vaction(vec, n, 0, 0) << endl;

   return 0;
}


Measured memory_bytes: 14516