akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#include<iostream>
#include<cstdlib>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define fir first
#define sec second

const int M = 21;
const int inf = 1500000*2;
const int N = 101;
int dp[N][M];
int cost[N][N];
void pre(int n,int *in){
  rep(i,n){
    cost[i][i]=in[i];
    REP(j,i+1,n)cost[i][j]=cost[i][j-1]+in[j];
  }
}

int solve(int n,int m){
  rep(i,n+1)rep(j,m+1)dp[i][j]=inf;
  //dp[0][0]=0;
  REP(i,1,n+1){
    REP(j,1,m+1){
      rep(k,i){
	if (k==0)dp[i][j]=min(dp[i][j],cost[k][i-1]              );
	else     dp[i][j]=min(dp[i][j],max(dp[k][j-1],cost[k][i-1]));
      }
    }
  }
  return dp[n][m];
}

int main(){
  int n,m;
  int in[N];
  while(cin>>m>>n && n){
    rep(i,n)cin>>in[i];
    pre(n,in);
    cout << solve(n,m) << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl p(n);
  rep(i, n) cin >> p[i];
  ll ans = 0;
  rep2(i, 1, n - 1) {
    if(p[i - 1] < p[i] && p[i] < p[i + 1]) ans++;
    if(p[i - 1] > p[i] && p[i] > p[i + 1]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

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

    boost::multiprecision::cpp_int maximum = 1;
    for (size_t i = 0; i < 18; i++)
    {
        maximum *= 10;
    }

    boost::multiprecision::cpp_int current = 1ll;
    vector<boost::multiprecision::cpp_int> A(N);
    for (boost::multiprecision::cpp_int &a : A)
    {
        cin >> a;
        if (a == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    for (boost::multiprecision::cpp_int &a : A)
    {
        current *= a;
        if (current > maximum)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << current << endl;
}


Measured memory_bytes: 6496
#define REP(i, t, n)  for (int i = t; i < n; i++)
#define ALL(n)        (n).begin(),(n).end()
#include <limits.h>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include <numeric>

#define INF (1000000000)
#define FENNEC	("Fennec")
#define SNUKE		("Snuke")
#define N_MAX		(100000)

using namespace std;

typedef bool               BOOL;
typedef short              WORD;
typedef unsigned short     U_WORD;
typedef long               DWORD;
typedef unsigned long      U_DWORD;
typedef long long          QWORD;
typedef unsigned long long U_QWORD;

int N;
vector<DWORD> vecList[N_MAX + 1];
DWORD	adwFennec[N_MAX + 1];
DWORD adwSnuke[N_MAX + 1];

void searchDistance(DWORD start, DWORD *adwField)
{
	queue<DWORD> que;
	BOOL	abIsVisit[N_MAX + 1] = {};

	que.push(start);
	adwField[start] = 0;
	abIsVisit[start] = true;
	while(!que.empty()) {
		DWORD dwDst = que.front();	que.pop();
		for (auto iter = vecList[dwDst].begin(); iter != vecList[dwDst].end(); ++iter) {
			if (!abIsVisit[*iter]) {
				adwField[*iter] = adwField[dwDst] + 1;
				que.push(*iter);
				abIsVisit[*iter] = true;
			}
		}
	}
}

void compDistance()
{
	DWORD dwFennec, dwSnuke;
	dwFennec = 0;
	dwSnuke = 0;

	REP (i, 2, N) {
		if (adwSnuke[i] < adwFennec[i]) {
			dwSnuke++;
		} else {
			dwFennec++;
		}
	}

	if (dwSnuke >= dwFennec) {
		cout << SNUKE << endl;
	} else {
		cout << FENNEC << endl;
	}
}

void solve_main()
{

	cin >> N;

	REP (i, 0, N - 1) {
		DWORD dwTempA, dwTempB;
		cin >> dwTempA >> dwTempB;

		vecList[dwTempA].push_back(dwTempB);
		vecList[dwTempB].push_back(dwTempA);
	}

	//まずは１から探索。
	searchDistance(1, adwFennec);
	//次にNから探索。
	searchDistance(N, adwSnuke);

	compDistance();
}

int main()
{
#ifdef FOR_IDE
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
#endif

	solve_main();
	return 0;
}


Measured memory_bytes: 8132
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 30;


int main(){
    string S;
    cin >> S;
    ll N = S.length();
    reverse(ALL(S));
    vector<vll> dp(N, vll(2, 0)); //* dp[i][0] no 
    dp[0][0] = S[0] - '0'; dp[0][1] = 10 - (S[0] - '0');
    ll cnt = 0;
    for(ll i=0; i< N-1; i++){
        ll x = S[i+1]-'0';
        if(x == 9){
            dp[i+1][0] = x + dp[i][0];
            dp[i+1][1] = min(10-x + dp[i][0], 9-x+dp[i][1]);
        }
        else{
            dp[i+1][0] = min(x + dp[i][0], (x+1)%10 + dp[i][1]);
            dp[i+1][1] = min(10-x + dp[i][0], 9-x+dp[i][1]);
        }
        
    }
    cout<< min(dp[N-1][0], dp[N-1][1]+1)<<endl;
    //cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 55940
#include<iostream>
int main(){
  int u,k,C,V,A[1000][1000],D[1000][1000],n;
  std::cin >> n;
  for(int i=0;i<n;i++)for(int j=0;j<n;j++)D[i][j] = 200001;
  for(int i=0;i<n;i++){  
    std::cin >> u >> k;
    for(int j=0;j<k;j++){
      std::cin >> V >> C;
      D[u][V] = C;
    }  
  }
  for(int i=0;i<n;i++)D[i][i] = 0;
  for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)D[i][j]= std::min(D[i][j],D[i][k] + D[k][j]);
  for(int i=0;i<n;i++)std::cout << i << " " << D[0][i] << std::endl;
  return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ll> vull;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int N, M, Q;

string base36 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

void print_light(vull &p) {
    REP(i, M) {
        int light = 0;
        int idx = 0;
        REP(j, N) {
            if (p[i] & (1L<<j)) {
                light++;
                idx = j;
            }
        }
        cout << (light == 1 ? base36[idx] : '?');
    }
    cout << endl;
}

int main() {
    while (cin >> N >> M >> Q, N|M|Q) {
        vull p(M, (1L<<N)-1);
        string prev_state(M, '0');
        REP(i, Q) {
            string sw, state;
            cin >> sw >> state;

            REP(i, M) {
                REP(j, N) {
                    if ((sw[j] == '1' && state[i] == prev_state[i]) ||
                        (sw[j] == '0' && state[i] != prev_state[i])) {
                        p[i] &= ~(1L<<j);
                    }
                }
            }
            prev_state = state;
        }
        print_light(p);
    }
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
char a[3];
int main(){
	for(int i=0;i<2;i++){
		cin>>a[i];
		if(a[i]=='9'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

void rec(vector<mint> &ans, vector<int> &a, int lv, int n, mint &aa){
  if(lv == n) return ;
  rec(ans, a, lv+1, n, aa);
  int now = a.at(lv);
  ans.at(0) += 1;
  rrep(i, ans.size()-now){
    ans.at(i+now) += ans.at(i);
  }
  aa += ans.at(ans.size()-1);
  return ;
}

int main(){
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  rep(snip_i, n) cin >> a.at(snip_i); 
  mint ans = 0;
  vector<mint> arr(s+1, 0);
  rec(arr, a, 0, n, ans);
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 384
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var KN = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var K = KN[0]; var N = KN[1];
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var max = 0;
            for (int i = 1; i < N; i++)
            {
                max = Math.Max(max, A[i] - A[i - 1]);
            }
            max = Math.Max(A[0] + K - A[N - 1], max);

            Console.WriteLine(K - max);
        }
    }
}


Measured memory_bytes: 34652
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
  ll n, a, b, c, q, ans = 0LL;
  cin >> n;
  vector<ll> v(100001);
  for (int i = 0; i < n; i++) {
    cin >> a;
    v[a]++;
    ans += a;
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> b >> c;
    ans += (c - b) * v[b];
    v[c] += v[b];
    v[b] = 0LL;
    cout << ans << endl;
  }
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  for(auto& a : A){
    cin >> a;
    a--;
  }
  for(auto& b : B){
    cin >> b;
  }
  for(auto& c : C){
    cin >> c;
  }
  
  int ans = B[A[0]];
  for(int ii=1; ii<N; ii++){
    ans += B[A[ii]];
    if(A[ii]==A[ii-1]+1) ans += C[A[ii-1]];
  }
  cout << ans << endl;
  return 0;
}


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

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

	int rtn = 0;
	while(tgt > 0) {
		rtn += tgt % 10;
		tgt /= 10;
	}

	if(N % rtn == 0) {
		puts("Yes");
	} else {
		puts("No");
	}
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  string s;
  int count=0;
  std::cin >> s;
  std::vector<int> num(26, 0);
  for(int i=0;i<4;i++) num[s[i]-'A']++;
  for(int i=0;i<26;i++) if(num[i]==2) count++;
  if(count==2) std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,pi,z[200009],zi,pas,mx[32],mx2[32],lef,rig,mid,zx,xc,t;
long double xx,yy,zz;
pair <long double, pair <int, int> > p[200009];
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>t;
	for(i=1; i<=a; i++){
		cin>>c>>d;
		c++;
		if(c==1){
			zi++;z[zi]=d+1;
			continue;
		}
		pi++;
		xx=c-1;yy=d+1;
		p[pi].first=-xx/yy;p[pi].second.first=c;p[pi].second.second=d;
	}
	sort(p+1,p+pi+1);
	sort(z+1,z+zi+1);
	for(i=1; i<=zi; i++) z[i]+=z[i-1];
	mx[0]=0;
	for(i=1; i<=30; i++) mx[i]=t+1;
	j=0;
	lef=0;rig=zi+1;
			xc=t;
			zx=0;
			while(1){
				if(lef+1>=rig) break;
				mid=(lef+rig)/2;
				if(z[mid]>xc){
					rig=mid;
				}else{
					lef=mid;
					zx=mid;
				}
			}
			if(pas<j+zx) pas=j+zx;
	for(i=1; i<=pi; i++){
		mx2[0]=1;c=p[i].second.first;d=p[i].second.second;
		for(j=1; j<=30; j++){
			if(mx[j-1]==t+1){
				mx2[j]=t+1;continue;
			}
			if((t-d)/c<mx[j-1]+1){
				mx2[j]=t+1;continue;
			}
			mx2[j]=(mx[j-1]+1)*c+d;
			lef=0;rig=zi+1;
			xc=t-mx2[j];
			zx=0;
			while(1){
				if(lef+1>=rig) break;
				mid=(lef+rig)/2;
				if(z[mid]>xc){
					rig=mid;
				}else{
					lef=mid;
					zx=mid;
				}
			}
			if(pas<j+zx) pas=j+zx;
		}
		for(j=0; j<=30; j++) mx[j]=min(mx2[j],mx[j]);
	}
	cout<<pas;
	return 0;
}

Measured memory_bytes: 6528
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){ 
    string a,b,c;
    cin>>a>>b>>c;
    while (1){
        cout << (char)(a[0]-32) << (char)(b[0]-32) << (char)(c[0]-32) ;
        return;
    }
}

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


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

ll gcd(ll a, ll b)
{
    if(a%b == 0) return b;
    return gcd(b, a%b);
}

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

int main(){
    std::ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> num_two_factor(n);
    for(int i=0;i<n;++i) {
        cin >> a[i];
        a[i] /= 2;
        int tmp = a[i];
        int cnt = 0;
        while((tmp % 2) == 0) {
            cnt++;
            tmp /= 2;
        }
        num_two_factor[i] = cnt;
        a[i] = tmp;
    }

    for(int i=0;i<n-1;++i)
    {
        if(num_two_factor[i] != num_two_factor[i+1])
        {
            cout << 0 << endl;
            return 0;
        }
    }
    
    for(int i=0;i<num_two_factor[0];++i) m /= 2;
    // calc lcm
    ll lcm_ = 1;
    for(int i=0;i<n;++i)
    {
        lcm_ = lcm(lcm_, a[i]);
    }

    if (m < lcm_) {
        cout << 0 << endl;
    }
    else
    {
        cout << (m / lcm_ + 1) / 2 << endl;        
    }
}

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

int main() {
    int H, W;
    for(;;) {
        cin >> H >> W;
        if(H==0 && W==0)break;
        for(int h=0;h<H;h++) {
            for(int w=0;w<W;w++) {
                if((h+w)%2 == 0) {
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#define _USE_MATH_DEFINES //M_PI, M_E
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	long double a,b;
	cin>>a>>b;
	a *= b;
    b = ceil(a)-a;
  	if(b<0.001 && b!=0) a += 1;
	cout<<(ll)a<<endl;
	return 0;
}


Measured memory_bytes: 3696
N,K = map(int, input().split())
hs = []
for _ in range(N):
    h = int(input())
    hs.append(h)
hs.sort()
# print(hs)
ans = 1e9
for i in range(N-K+1):
    ans = min(ans, abs(hs[i]-hs[i+K-1]))
print(ans)

Measured memory_bytes: 7488
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
int a,b,c;
int main(){ _;
  cin>>a>>b>>c;
  int cnt=1;
  if(a!=b)cnt++;
  if(a!=c&&b!=c)cnt++;
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

N,C = map(int,readline().split())
sushi = [list(map(int,readline().split())) for i in range(N)]
import copy
revsushi = copy.deepcopy(sushi)[::-1]
for i in range(len(sushi)-1, 0, -1):
  sushi[i][0] = sushi[i][0] - sushi[i - 1][0]

for i in range(len(revsushi)):
  revsushi[i][0] = C - revsushi[i][0]
for i in range(len(revsushi)-1, 0, -1):
  revsushi[i][0] = revsushi[i][0] - revsushi[i - 1][0]

# 左回り/右回りにi個食べたときの結果
# 0個のときは0を入れておく
left = [[0] * 2 for i in range(N + 1)]
right = [[0] * 2 for i in range(N + 1)]

left[0] = [0,0]
right[0] = [0,0]

# 累積ポイント, そこまでのベストポイント
for i in range(len(sushi)):
  x,v = sushi[i]
  left[i + 1][0] = left[i][0] + v - x # 摂取カロリー - 消費カロリー
  if left[i + 1][0] > left[i][1]: # 前回までのベストより優れている
    left[i + 1][1] = left[i + 1][0]
  else:
    left[i + 1][1] = left[i][1]
    
# この状態で右回りにチェックしていく
best = left[-1][1] # 左回りにすべて取った場合を最大値としてスタート
cal = 0
for i in range(len(revsushi)):
  count = i + 1 # 取る寿司の数
  lp = left[N - count][1]
  # 逆回りに取れる寿司の最大値
  x,v = revsushi[i]
  cal += (v - x * 2)
  if lp + cal > best:
    best = lp + cal

# 右回りを作る
for i in range(len(revsushi)):
  x,v = revsushi[i]
  right[i + 1][0] = right[i][0] + v - x
  if right[i + 1][0] > right[i][1]:
    right[i + 1][1] = right[i + 1][0]
  else:
    right[i + 1][1] = right[i][1]

best = max(best, right[-1][1])
cal = 0
for i in range(len(sushi)):
  count = i + 1 # 取る寿司の数
  rp = right[N - count][1]
  # 逆回りに取れる寿司の最大値
  x,v = sushi[i]
  cal += (v - x * 2)
  if rp + cal > best:
    best = rp + cal

print(best)

Measured memory_bytes: 66228
//      https://youtu.be/X_hMZYDMps4

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

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;    // 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nl                  "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define pf                  push_front
#define all(x)              x.begin(),x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"

int main()
{
    fast;
    ll t,i,j,k,l,m,n,o,p,q,temp,flag=0,mod=1000000007;
    cin>>n;
    ll a[n],ans[n];
    for(i=0;i<n;i++){
        cin>>a[i];
        ans[i]=inf;
    }
    ans[0]=0;
    for(i=1;i<n;i++){
        ans[i]=min(ans[i],ans[i-1]+abs(a[i]-a[i-1]));
        if(i-2>=0) ans[i]=min(ans[i],ans[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<ans[n-1];
}


Measured memory_bytes: 5220
X, K, D = map(int, input().split())
Xa = abs(X)
if Xa/D >= K:
    ans = Xa -K*D
else:
    if int(Xa/D) %2 == K%2:
        ans = abs(Xa - D*int(Xa/D))
    else:
        ans = abs(Xa-D*(int(Xa/D)+1))
print(ans)

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

vector<string> Split(char c,string s){
  vector<string> res(0);
  string str = "";
  rep(i,s.size()){
    if(s[i] == c){
      res.push_back(str);
      str.clear();
    }
    else{
      str += s[i];
    }
  }
  res.push_back(str);
  return res;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  string s;
    cin.ignore();
  rep(l,n){
    getline(cin,s);
    auto vs = Split(' ',s);
    ll tmp = 1,num = 0;
    rep(i,2){
      rep(j,vs[i].size()){
        if(vs[i][j] - '0' > 1 && vs[i][j] - '0' < 10){
          tmp = vs[i][j] -'0';
        }
        else{
          if(vs[i][j] == 'm'){
            num += 1000 * tmp;
          }
          else if(vs[i][j] == 'c'){
            num += 100 * tmp;
          }
          else if(vs[i][j] == 'x'){
            num += 10 * tmp;
          }
          else{
            num += tmp;
          }
          tmp = 1;
        }
      }
    }
//     cout << num <<endl;
    string ans = "";
    if(num/1000){
      if(num/1000 != 1){
        ans += to_string(num/1000);
      }
      ans += "m";
    }
    num %= 1000;
    if(num/100){
      if(num/100 != 1){
        ans += to_string(num/100);
      }
      ans += "c";
    }
    num %= 100;
    if(num/10){
      if(num/10 != 1){
        ans += to_string(num/10);
      }
      ans += "x";
    }
    if(num % 10){
      if(num % 10 != 1){
        ans += to_string(num % 10);
      }
      ans += "i";
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3280
import sys
readline = sys.stdin.readline
from collections import defaultdict

S = list(map(lambda x: ord(x)-97, readline().strip()))
N = len(S)

table = [0] + [1<<S[i] for i in range(N)]
for i in range(1, N+1):
    table[i] ^= table[i-1]

inf = 10**9+7
dp = defaultdict(lambda: inf)
dp[0] = 0

for i in range(1, N+1):
    t = table[i]
    res = 1+dp[t]
    for j in range(26):
        res = min(res, 1+dp[t^(1<<j)])
    dp[t] = min(dp[t], res)
print(res)

Measured memory_bytes: 356000
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    unordered_map<int, int> um;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        um[a]++;
    }
    int res = 0;
    for (auto p : um) {
        res += p.second % 2;
    }
    cout << res << endl;
}




Measured memory_bytes: 7280
#include<stdio.h>
int main(){
 
   int a,b,c,tmp;
 
   scanf("%d %d %d",&a,&b,&c);
 
   if(a > b){tmp = a;
             a = b;
             b = tmp;}
 
   if(a > c){tmp = a;
             a = c;
             c = tmp;}
 
   if(b > c){tmp = b;
             b = c;
             c = tmp;}
 
   printf("%d %d %d\n",a,b,c);
 
   return 0;
}

Measured memory_bytes: 596
mod=1e9+7,dp[3333][3333]={1};
c,j;
main(i)
{
	gets(&c);
	for(;c=getchar()%3-1;i++)
	{
		for(j=0;j<=i;j++)dp[i][j]=~c?*dp[i-1]-dp[i-1][j]:dp[i-1][j];
		for(;j--;)dp[i][j]=(1L*dp[i][j]+dp[i][j+1]+mod)%mod;
	}
	printf("%d",*dp[i-1]);
}

Measured memory_bytes: 28800
#include <iostream>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <utility>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <sstream>
#include <cstring>
#include <bitset>
#include <stack>
using namespace std;
#define MP make_pair
#define PB push_back

int n,ans;
struct node{
	int x,y,id;
	
	inline void scan(int i)
	{
		scanf("%d%d",&x,&y);
		id=i;
	}
	
}a[100005],b[100005];

int par[100005];

vector <pair<int,pair<int,int> > >edge;

inline int dist(int x,int y)
{
	int r1=abs(b[x].x-b[y].x);
	int r2=abs(b[x].y-b[y].y);
	return min(r1,r2);
}

inline bool cmp1(node p,node q)
{
	return p.x<q.x;
}

inline bool cmp2(node p,node q)
{
	return p.y<q.y;
}

inline int Find(int x)
{
	return (x==par[x]?x:par[x]=Find(par[x]));
}

inline void Union(int x,int y)
{
	par[Find(x)]=Find(y);
}

inline void kruskal()
{
	for (int i=1;i<=n;i++) par[i]=i;
	sort(edge.begin(),edge.end());
	for (int i=0;i<edge.size();i++)
	{
		int x=edge[i].second.first;
		int y=edge[i].second.second;
		if (Find(x)==Find(y)) continue;
		ans+=dist(x,y);
		Union(x,y);
	}
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		a[i].scan(i);
		b[i]=a[i];
	}
	sort(a+1,a+1+n,cmp1);
	for (int i=1;i<n;i++)
		edge.PB(MP(dist(a[i].id,a[i+1].id),MP(a[i].id,a[i+1].id)));
	sort(a+1,a+1+n,cmp2);
	for (int i=1;i<n;i++)
		edge.PB(MP(dist(a[i].id,a[i+1].id),MP(a[i].id,a[i+1].id)));
	edge.resize(unique(edge.begin(),edge.end())-edge.begin());
	kruskal();	
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 7284
#include<bits/stdc++.h>
using namespace std;
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long i,j,k,l,m,n,o,p,q;
    while(cin>>m>>n>>p)

    {
        if(m>p||m+n<p)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
import bisect
n = int(input())
arr = list(map(int,input().split()))
arr.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        x = arr[i]+arr[j]
        ind = bisect.bisect_left(arr,x)
        ans+=(ind-j-1)
print(ans)

Measured memory_bytes: 9356
n,m = map(int,input().split())
vote = [0 for i in range(m)]
for i in range(n):
    l = [int(j) for j in input().split()]
    for j in range(l[0]):
        k = l[j+1]-1
        vote[k] = vote[k] + 1 
flag = 0
for i in range(m):
    if vote[i] == n:
        flag = flag + 1
print(flag)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; 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 (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

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

    string T = "zyxwvutsrqponmlkjihgfedcba";
    if(S == T){
        cout << -1 << endl;
        return 0;
    }

    int N = S.length();

    string ans;
    if(N != 26){
        set<char> se;
        REP(i,N){
            char c = S[i];
            se.insert(c);
        }
        REP(i,26){
            char c = 'a' + i;
            if(se.find(c) == se.end()){
                ans = S + c;
                break;
            }
        }
    }
    else{
        set<char> se;
        for(int i = 25; i >= 0; i--){
            char c = S[i]; 
            int t = c - 'a';
            S.erase(i);
            for(int k = t+1; k < 26; k++){
                char x = 'a' + k;
                if(se.find(x) != se.end()){
                    S += x;
                    goto fin;
                }
            }
            se.insert(c);
        }
fin:
        ans = S;
    }

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


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
avg = 0
for a in A:
    avg += a
avg = avg / N
target = 1000
for a in A:
    dif1 = abs(target-avg)
    dif2 = abs(a-avg)
    if dif2 < dif1:
        target = a
ans = 0
for i,a in enumerate(A):
    if a == target:
        ans = i
        break
print(ans)

Measured memory_bytes: 3064
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
ab=[list(map(int,input().split())) for i in range(n)]

# print(ab)
alst=[0]*n
blst=[0]*n
for i in range(n):
    a,b=ab[i]
    alst[i]=a
    blst[i]=b
alst.sort()
blst.sort()
# print(alst)
# print(blst)
if n%2==0:
    # print((alst[n//2]+alst[n//2-1])/2)
    # print((blst[n//2]+blst[n//2-1])/2)
    print(int(((blst[n//2]+blst[n//2-1])/2-(alst[n//2]+alst[n//2-1])/2)*2+1))
else:
    # print(alst[n//2])
    # print(blst[n//2])
    print(blst[n//2]-alst[n//2]+1)

Measured memory_bytes: 107544
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
 
struct Card { char suit; int value; };
 
void Bubblesort(struct Card A[], int N) {
    bool flag = 1;
    for (int i = 0; flag; i++) {
        flag = 0;
        for (int j = N - 1; j > i; j--) {
            if (A[j].value < A[j - 1].value) {
                swap(A[j], A[j - 1]);
                flag = 1;
            }
        }
    }
}
 
void Selectionsort(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        int minj = i;
        for (int j = i+1; N>j; j++) {
            if (A[minj].value > A[j].value) {
                minj = j;
            }
        }
        if (i != minj) {
            swap(A[i], A[minj]);
        }
    }
}
void print(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        if (i) {
            cout << " ";
        }
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[],struct Card C2[],int N){
    for (int i=0;i<N;i++){
        if(C1[i].suit!=C2[i].suit){
            return false;
            break;
        }
    }
    return true;
}




int main() {
    int N;
    Card C1[100], C2[100];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> C1[i].suit >> C1[i].value;
    }
    for (int i = 0; i < N; i++) {
        C2[i] = C1[i];
    }
 
    Bubblesort(C1, N);
    Selectionsort(C2, N);
 
    print(C1, N);
    cout << "Stable" << endl;
 
    print(C2, N);
    if (isStable(C1,C2,N)) {
        cout << "Stable" << endl;
    }
    else {
        cout << "Not stable" << endl;
    }
    return 0;
}

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

int main()
{
    char s[10];
    scanf("%s",s);
    for(int i=0; s[i]!='\0'; i++)
    {
        if(s[i]=='A'&&s[i+1]=='C')
        {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N;
double dp[305][305][305];

double solve(int i, int j, int k){
  if(i == 0 && j == 0 && k == 0) return 0.0;
  if(dp[i][j][k] >= 0) return dp[i][j][k];

  int M = i + j + k;
  double ret = N / (double)M;
  if(i>0){
    ret += solve(i-1,j+1,k) * (i / (double)M);
  }
  if(j>0){
    ret += solve(i,j-1,k+1) * (j / (double)M);
  }
  if(k>0){
    ret += solve(i,j,k-1) * (k / (double)M);
  }
  return dp[i][j][k] = ret;
}

int main(){

  cin >> N;
  int A = 0, B = 0, C = 0;
  rep(i,N){
    int a;
    cin >> a;
    if(a == 3) A++;
    if(a == 2) B++;
    if(a == 1) C++;
  }

  rep(i,305) rep(j,305) rep(k,305) dp[i][j][k] = -1;

  printf("%.12lf\n", solve(A, B, C));
  
  return 0;
}


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

using namespace std;
using ll = long long;

#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
#define PI 3.14159265358979323

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

	long double a, b, c, d;
	cin >> a >> b >> c >> d;
	long double x = (d / 60) * 360;
	long double y = (c * 30) + (d / 2);
	long double z = abs(x - y);
	long double ans = pow(a, 2) + pow(b, 2);
	long double part = 2 * a * b * (cos((z * PI / 180)));
	ans -= part;
	cout << fixed << setprecision(9) << sqrt(ans);
}


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

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

#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rep2(i,a,n) for(ll i=a;i<(n);++i)
#define repr(i,n) for(ll i=n;i>=0; --i)
#define repr2(i,a,n) for(ll i=n;i>=a; --i)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define VEC(v) vector<v >

#define INT(...) int __VA_ARGS__;IN(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;IN(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;IN(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;IN(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;IN(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;IN(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;IN(__VA_ARGS__)

int scan(){ return getchar(); }
void scan(int& a){ cin>>a; }
void scan(long long& a){ cin>>a; }
void scan(char &a){cin>>a;}
void scan(double &a){ cin>>a; }
void scan(long double& a){ cin>>a; }
void scan(char a[]){ scanf("%s", a); }
void scan(string& a){ cin >> a; }
template<class T> void scan(vector<T>&);
template<class T, size_t size> void scan(array<T, size>&);
template<class T, class L> void scan(pair<T, L>&);
template<class T, size_t size> void scan(T(&)[size]);
template<class T> void scan(vector<T>& a){ for(auto& i : a) scan(i); }
template<class T> void scan(deque<T>& a){ for(auto& i : a) scan(i); }
template<class T, size_t size> void scan(array<T, size>& a){ for(auto& i : a) scan(i); }
template<class T, class L> void scan(pair<T, L>& p){ scan(p.first); scan(p.second); }
template<class T, size_t size> void scan(T (&a)[size]){ for(auto& i : a) scan(i); }
template<class T> void scan(T& a){ cin >> a; }

void IN(){}
template <class Head, class... Tail> void IN(Head& head, Tail&... tail){ scan(head); IN(tail...); }

int in() {int x;cin>>x;return x;}
ll llin() {unsigned long long x;cin>>x;return x;}

#define ios cin.tie(NULL), ios_base::sync_with_stdio(false)
#define cfs(n) cout<<fixed<<setprecision((n))
#define endl '\n'
#define ret return 0

constexpr ll mod=998244353;
constexpr ll mod2=10e9+7;
const double PI = 3.1415926535897932384626433832795028841971; //acos(-1)

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;}
// endmacro

int main(){
  ios; cfs(15);
  INT(n,x,t);
  unsigned time = 0;
  time = ((n/x)+((n%x)>0 ? 1 : 0)) * t;
  cout<<time<<endl;
  ret;
}

Measured memory_bytes: 3668
/*
 Sarthak Jain
*/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;
int min(int a,int b){
	return (a<b)?a:b;
}
int max(int a,int b){
	return (a>b)?a:b;
}
int fp(int a,int b){
	if(b==0) return 1;
	int x=fp(a,b/2);
	x=(x*x)%mod;
	if(b&1) x=(x*a)%mod;
	return x;
}


signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
string a,b;
cin>>a>>b;
int ans=0;
for(int i=0;i<a.size();i++)
ans+=(a[i]!=b[i]);
cout<<ans;
}


Measured memory_bytes: 3804
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long lint; using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define rep(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  int n;
  cin>>n;
  vector<int> d(n);
  rep(i,n)cin>>d[i];
  sort(d.begin(),d.end());
  cout<<d[n/2]-d[n/2-1]<<endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;

vvi v(101010);
vvi dist(101010,vi(2,-1));
void dfs(int pos, int mode, int depth){
    for(auto i:v[pos]){
        if(dist[i][mode]!=-1)continue;
        dist[i][mode]=depth+1;
        dfs(i,mode,depth+1);
    }
}


int main() {
    
    int n,U,V;
    cin>>n>>U>>V;
    U--;V--;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        v[a].pb(b);
        v[b].pb(a);
    }
    dist[U][0]=0;
    dist[V][1]=0;
    dfs(U,0,0);
    dfs(V,1,0);
    int ans=0;
    rep(i,n){
        if(dist[i][0]<=dist[i][1]){
            int t=dist[i][0];
            t+=(dist[i][1]-dist[i][0])-1;
            chmax(ans,t);
        }
    }
    fin(ans);
}








Measured memory_bytes: 15104
//あとでみる
package main

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

func main() {
	rd := bufio.NewReader(os.Stdin)
	s, _ := rd.ReadString('\n')
	n := len(s)
	m := make(map[int]int)
	r := 0
	k := 1
	ans := 0
	for i := n - 1; i >= 0; i-- {
		r += int(s[i]-'0') * k
		r %= 2019
		if m[r] > 0 {
			ans += m[r]
		}
		m[r]++
		k *= 10
		k %= 2019

	}
	fmt.Println(ans)
}


Measured memory_bytes: 2664
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

int main()
{
  int n, k;
  cin >> n >> k;
  int s = k - 1;
  int a = n;
  int b = n;
  double ans = 0;
  int m = 1;
  while (a > 0)
  {
    a = min(s, n);
    double x = b - a;
    ans += (x / m) / n;
    b = a;
    s /= 2;
    m *= 2;
  }
  printf("%.12f\n", ans);
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int a;
	scanf("%d", &a);
	int b = a * a;
	int c = a * a * a;
	int d = a + b + c;
	printf("%d", d);
	return 0;
}

Measured memory_bytes: 1732
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     loopR(n,i,a)    for(int i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
#define     test(i)        cout<<i<<endl
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e5+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = 3.14159265358979323846;
int n,k;
ll arr[mxN];
bool check(ll mid){
    ll cnt=0;
    bool flag=false;
    loop(n,i,0){
        if(arr[i]>=mid)
            flag=true;
        cnt+=((arr[i]+mid-1)/mid-1);
    }
    return flag&&cnt<=k;

}
void solve(){
    cin>>n>>k;
    loop(n,i,0)
        cin>>arr[i];
    sort(all(arr,n));
    ll l=1,r=arr[n-1],res=0;
    while(l<=r){
        ll mid=(l+r)>>1;
        if(check(mid)){
            res=mid;
            r=mid-1;
        } else
            l=mid+1;
    }
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}


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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solution(String[] args) throws Exception{

		int N = nextInt();
		N=N%10;
		String ans ;
		switch (N){
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			ans="hon";
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			ans="pon";
			break;
			default:
				ans="bon";
				break;
		}

		pw.println(ans);

	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 25388
import collections
import itertools as it
import math
import numpy as np

# A = input()
# A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()

N = int(input())
if int(math.ceil(N / 1.08) * 1.08) == N:
    print(int(math.ceil(N / 1.08)))
else:
    print(":(")

Measured memory_bytes: 21488
#include<stdio.h>
int main(void)
{
	int a[3];
	int b;
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	if(a[0]>a[1])
	{b=a[0];a[0]=a[1];a[1]=b;}
	if(a[0]>a[2])
	{b=a[0];a[0]=a[2];a[2]=b;}
	if(a[1]>a[2])
	{b=a[1];a[1]=a[2];a[2]=b;}
	printf("%d %d %d\n",a[0],a[1],a[2]);
	return 0;
}



Measured memory_bytes: 2024