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

int main()
{
    ll N, S;
    ll ans = -1;
    
    cin >> N >> S;
    
    ll val = (ll)sqrt((double)N);
    //実際に割るO(sqrt(N) log sqrt(N))
    for(ll i = 2; i <= val; i++) {
        ll sum = 0;
        ll n = N;
        while(n) sum += n % i, n /= i;
        if(!~ans && sum == S) ans = i;
    }

    for(ll i = val; i > 0; i--) {
        if((N - S) % i == 0) {
            ll sum = 0;
            ll n = N;
            ll b = ((N - S) / i + 1);
            if(b >= 2) {
                while(n) sum += n % b, n /= b;
                if(!~ans && sum == S) ans = b;
            }
        }
    }
    if(!~ans && N == S) ans = N + 1;
    cout << ans << endl;
    return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

//#include "All.h"

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

int main() {

    int N;
    string S;

    cin >> N >> S;
    rep(i, S.length()) {
        char tmp = (S[i] + N - 'A') % 26 + 'A';
        cout << tmp;
    }
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstring>
#include <cmath>
#include <climits>

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

  uint32_t N, K;

  std::cin >> N;
  std::cin >> K;

  uint32_t step[100000];
  uint32_t dp[100000];
  memset(dp, UINT_MAX, sizeof dp);

  for (uint32_t i = 0; i < N; i++) {
    std::cin >> step[i];
  }
  
  dp[0] = 0;

  for (uint32_t i = 0; i < N; i++) {
    for (uint32_t k = 1; k < K + 1 && k + i < N; k++) {
      auto cost = dp[i] + abs(step[i] - step[i + k]);
      dp[i + k] = std::min(cost, dp[i + k]);
    }
  }

  std::cout << dp[N - 1] << std::endl;

  return 0;
}


Measured memory_bytes: 1024
/**********************************************************
* @Author: 			   Maple
* @Date:   			   2020-03-01 20:21:33
* @Last Modified by:   Maple
* @Last Modified time: 2020-03-01 21:07:45
* @Remark: 
**********************************************************/
#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define CSE(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define Abs(x) (x>=0?x:(-x))
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll , ll> pll;

const int maxn=11;
int n,m,digit[maxn],book[maxn];

int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("in.in","r",stdin);
	// #endif
	CSE(digit,0);
	CSE(book,0);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int s,c;
		cin>>s>>c;
		if(book[s]==0)
			digit[s]=c;
		else{
			if(digit[s]!=c){
				cout<<"-1"<<endl;
				return 0;
			}
		}
		book[s]=1;
	}
	if(n==1)
		cout<<digit[1]<<endl;
	else{
		if(book[1]==0)
			digit[1]=1;
		if(digit[1]==0)
			cout<<"-1"<<endl;
		else{
			for(int i=1;i<=n;i++)
				cout<<digit[i];
			cout<<endl;
		}
	}
	return 0;
}

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

using namespace std;

int n;
vector<int> g[111111];
int a[111111];
vector<int> p;

bool path(int a, int pre) {
  if (a == n-1) {
    p.push_back(a);
    return true;
  }
  for (auto&& t : g[a]) {
    if (t == pre) continue;
    if (path(t, a)) {
      p.push_back(a);
      return true;
    }
  }
  return false;
}

int dfs(int v, int pre) {
  if (a[v] == 2) {
    return 0;
  }
  int c = 1;
  for (auto&& t : g[v]) {
    if (t == pre) continue;
    c += dfs(t, v);
  }
  return c;
}

int main(void) {
  scanf("%d", &n);
  if (n == 2) {
    puts("Snuke");
    return 0;
  }
  for (int i = 0; i < n-1; i++) {
    int a, b; scanf("%d%d", &a, &b);
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  path(0, -1);
  for (int i = p.size()-1, k = 0; i >= 0; i--, k++) {
    if (k < (p.size()+1)/2) {
      a[p[i]] = 1;
    } else {
      a[p[i]] = 2;
    }
  }
  int cnt = dfs(0, -1);
  // printf("%d\n", cnt);
  puts(cnt-(n-cnt) > 0 ? "Fennec" : "Snuke");
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef long double ld;

void solve()
{
	ll n, n1;
	cin >> n;
	n1 = n;
	set <ll> v;
	while(n % 2 == 0)
	{
		n = n / 2;
		v.insert(2);
	}
	for(ll i = 3; i * i <= n; i += 2)
	{
		if(n % i == 0)
		{
			while(n % i == 0)
			{
				n = n / i;
			}
			v.insert(i);
		}
	}
	if(n > 2) v.insert(n);
//	cout << v.size() << "\n";
	ll cnt = 0;
	n = n1;
	for(ll i : v)
	{
		ll sum = i;
		while(n % sum == 0)
		{
//			cout << "hi";
			n = n / sum;
			sum = sum * i;
			cnt++;
		}
		if(n <= 1) goto aa;
	}
	aa:;
	cout << cnt << "\n";
}

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



Measured memory_bytes: 3628
N,Q=map(int,raw_input().split())
c=map(int,raw_input().split())
 
mxc=max(c)
p=[0]*(mxc+1)
for i in c:
    p[i]=1
     
l=[0]*(mxc+1)
num=0
for i in range(mxc+1):
    l[i]=num
    if p[i]:
        num=i
         
for i in range(Q):
    q=int(raw_input())
    sp=mxc
    ans=0
    while 1:
        r=sp%q
        ans=max(ans,r)
        if sp-r<=0:break
        sp=l[sp-r]
    print ans

Measured memory_bytes: 32332
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;

int main(){
	int N;
	cin >> N;
	vvint g(N);
	for(int i = 0;i < N-1;i++){
		int ai, bi;
		cin >> ai >> bi;
		g[ai-1].push_back(bi-1);
		g[bi-1].push_back(ai-1);
	}
	vint c(N), used(N, 0), ans(N);
	for(int i = 0;i < N;i++)	cin >> c[i];
	sort(c.rbegin(), c.rend());
	LL num = 0;
	for(int i = 1;i < N;i++)	num += c[i];
	int id = 0;
	queue<int>	que;
	que.push(0);
	used[0] = 1;
	while(!que.empty()){
		int p = que.front();
		que.pop();
		ans[p] = c[id++];
		used[p] = 1;
		for(auto s : g[p]){
			if(!used[s])	que.push(s);
		}
	}
	cout << num << endl;
	for(auto s : ans)	cout << s << endl;
}

Measured memory_bytes: 1024
from collections import deque

def bfs(maze, visited, sy, sx):
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    while queue:
        y, x = queue.popleft()
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])
    return visited[y][x]

if __name__ == "__main__":
    H, W = map(int, input().split())
    maze = []
    maze.append(['#']*(W+2))
    for i in range(H):
      maze.append(['#']+ list(input()) + ['#'])
    maze.append((['#']*(W+2)))
    
    ans = -1
    for x in range(1,H+1):
      for y in range(1,W+1):
        if maze[x][y] =='.':
          visited = [[-1]*(W+2) for j in range(H+2)]
          ans = max(ans,bfs(maze,visited,x,y))
          
    print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>


#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}


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

const ll INF = 1e9;
ll dp[1010][10100];
int main(){
    int h, n;
    cin >> h >> n;
    vector<int>attack(n), cost(n);
    rep(i, n){
        cin >> attack[i] >> cost[i];
    }
    rep(i, n+10)rep(j, h+10)dp[i][j] = INF;
    rep(i, n)dp[i][0] = 0;

    rep(i, n){
        rep(j, h+1){
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            dp[i+1][min(j + attack[i], h)] = min(dp[i+1][min(j + attack[i], h)], dp[i+1][j] + cost[i]);
        }
    }
    cout << dp[n][h] << endl;
}

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

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    int N, M;
    cin >> N >> M;

    vector<ll> X(M);
    REP(i, M) cin >> X[i];

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

    vector<ll> Y(M);
    Y[0] = 0;
    ll s = 0;
    FOR(i, 1, M) {
        ll d = X[i] - X[i-1];
        Y[i] = d;
        s += d;
    }

    sort(Y.begin(), Y.end(), greater<>());

    ll ans = s;
    REP(i, N - 1) {
        if (i > M - 1) break;
        ans -= Y[i];
    }

    cout << ans << endl;

}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

#define vi vector<int>
#define vll vector<long long>
#define ll long long
#define ull unsigned long long
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define nl cout<<'\n'
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pll pair<long long,long long>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define sll set<long long>
#define all(v) (v).begin(),(v).end()
#define Unique(x)           (x).erase(unique(all(x)), x.end())
#define v_present(vec,x)  (find(all(vec),x)!=(vec).end())
#define present(myset,x)    ((myset).find(x)!=(myset).end())
#define Cprint(c)  for(auto i:(c)) { cout<<i<<" "; } nl
#define trace2(x,y) cout<<x<<" "<<y<<endl;
#define trace3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define trace4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<endl;
ll mod = 1e9+7;
const int MAX = 1e5+5;
using namespace std;
ll dp[100005][3];

int main()
{
    FAST_IO;
    int n;
    cin>>n;
    ll a[n+1]; ll b[n+1]; ll c[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }

    dp[1][0]=a[1];
    dp[1][1]=b[1];
    dp[1][2]=c[1];
    for(int i=2;i<=n;i++){
        dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
        dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
        dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
    }
    cout<<max(max(dp[n][0],dp[n][1]),dp[n][2]);
    return 0;

}


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

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector <int> a(A), b(B);
  for (int i = 0; i < A; i++) {
  	cin >> a.at(i);
  }
  for (int i = 0; i < B; i++) {
  	cin >> b.at(i);
  }
  int normin;
  normin = *min_element( a.begin(), a.end() ) + *min_element( b.begin(), b.end() );

  vector<int> discount(M);
  int ida, idb, disc, dismin;
  for (int i = 0; i < M; i++) {
  	cin >> ida >> idb >> disc;
    discount.at(i) = a.at(ida-1) + b.at(idb-1) - disc;
  }
  cout << min(normin, *min_element( discount.begin(), discount.end() )) << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
int main(){
    ll n; cin >> n;
    vector<ll> b(n);
    REP(i,n) cin >> b[i];
    vector<ll> c;
    c.pb(b[0]);
    FOR(i,1,n-2){
        if (b[i]!=b[i-1]) c.pb(b[i]);
    }
    c.pb(b[n-1]);
    /*REP(i,c.size()) cout << c[i] << " ";
    cout << endl;*/
    vector<ll> a;
    a.pb(c[0]);
    FOR(i,1,c.size()-2){
        if (c[i-1]<c[i]&&c[i]<c[i+1])continue;
        if (c[i-1]>c[i]&&c[i]>c[i+1])continue;
        a.pb(c[i]);
    }
    a.pb(c[c.size()-1]);
    /*REP(i,a.size()) cout << a[i] << " ";
    cout << endl;*/
    ll x = 1000/a[0];
    ll ans = 1000;
    n = a.size();
    FOR(i,0,x){
        ll k = i;
        ll l = 1000-i*a[0];
        FOR(i,1,n-1){
            if (a[i]>a[i-1]){
                l += a[i]*k;
                k = 0;
                ans = max(ans,l);
            }
            else{
                ll buy = l/a[i];
                k += buy;
                l -= a[i]*buy;
                ans = max(ans,l);
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  for (int i = 0; i < N; i++)
    cin >> V.at(i);
  for (int i = 0; i < N; i++)
    cin >> C.at(i);
  int ans;
  for (int i = 0; i < N; i++) {
    if (V.at(i) > C.at(i))
      ans += V.at(i) - C.at(i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#S = input()
N = int(input())
#A, B, C = input().split()
#N, M = map(int, input().split())

#N = int(input())
#A = [int(x) for x in input().split()]

#H, W = map(int, input().split())
S = [input() for _ in range(N)]
print(len(set(S)))

Measured memory_bytes: 107556
n = int(input())
p = list(map(int, input().split()))
ans=0
for i in range(1,n-1):
    if p[i-1] < p[i] and p[i] < p[i+1]:
        ans+=1
    elif p[i-1] > p[i] and p[i] > p[i+1]:
        ans+=1
print(ans)

Measured memory_bytes: 38512
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<ctime>
#include<cmath>
#include<cstdlib>
#include<utility>
#include<bitset>
using namespace std;
const int maxn=110;
int n,f[maxn][10],p[maxn][11],ans=-1000000000;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<10;j++)
		{
			cin>>f[i][j];
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<11;j++)
		{
			cin>>p[i][j];
		}
	}
	for(int i=1;i<1024;i++)
	{
		int tmp=0;
		for(int j=0;j<n;j++)
		{
			int cnt=0;
			for(int k=0;k<10;k++)
			{
				if((i&(1<<k))&&(f[j][k]))
				{
					++cnt;
				}
			}
			tmp+=p[j][cnt];
		}
		ans=max(ans,tmp);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
//bismillahir rahmanir rahim            //Author:Fayed Anik

#include <bits/stdc++.h>

using namespace std;


#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         SET(m)                      memset(m, 1,sizeof m)
#define         RESET(m)                    memset(m,0,sizeof m)
#define         mp(a,b)                     make_pair(a,WWb)
#define         mod                         1000000007
#define         INF                         1e17
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)

//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;

#define N 200005

ll a[N],b[N];
int main(){
    ll n;
    sfl(n);
    b[0]=INF;
    for(ll i=1;i<=n;i++){
        sfl(a[i]);
        b[i]=min(b[i-1],a[i]);
    }
    ll cnt=0;
    for(ll i=1;i<=n;i++){
        if(b[i]>=a[i]) cnt++;
    }
    pfl(cnt);
    return 0;
}



Measured memory_bytes: 3328
#include <stdio.h>

int main()
{
	long long X;

	scanf("%ld",&X);

	long long a;
	a=200;
	if(X<=200)
	{
		printf("%ld\n",X-100);
		return 0;
	}
	int i=0;
	while(a<X)
	{
		a=a*1.01;
		i++;
	}
	printf("%d\n",i+100);
	return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define div 1e9+7
using ll = long long;
using P = pair<int,int>;
int main(){
	int n;
	string s;
	cin>>n>>s;
	if(n%2==1){
		puts("No");
		return 0;
	}else{
		if(s.substr(0,n/2)==s.substr(n/2,n/2)){
			puts("Yes");
		return 0;
		}else{
			puts("No");
		return 0;
		}
		
	}
	
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("rawtypes")
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		ArrayList<Integer> a = new ArrayList<Integer>();

		for(int i = 0; i < n; i++) {
			a.add(Integer.parseInt(sc.next()));
		}
		Collections.sort(a);

		int ai = a.get(n - 1);

		// (ai/2)に最も近い数を探索する
		for(int i = 0;; i++) {
			if((double)a.get(i) >= (double)ai / 2.0) {
				if((double)a.get(i) - ((double)ai / 2.0) < ((double)ai / 2.0) - (double)a.get(i - 1)){
					System.out.println(ai + " " + a.get(i));
				}else {
					System.out.println(ai + " " + a.get(i - 1));
				}
				break;
			}
		}

	}

}


Measured memory_bytes: 50400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
int main(){
    int n;cin >> n;
    vector<ll> a(n);
    int mcnt=0;
    bool zero=false;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]==0) zero=true;
        if(a[i]<0) mcnt++;
    }
    ll sum=0;
    vector<ll> pa(n);
    for(int i=0;i<n;i++){
        if(a[i]<0){
            sum+=-a[i];
            pa[i]=-a[i];
        }
        else{
            sum+=a[i];
            pa[i]=a[i];
        }
    }
    sort(pa.begin(),pa.end());
    ll mn=pa[0];
    if(mcnt%2==0) cout << sum << endl;
    else{
        cout << sum-2*mn << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double K;
typedef pair<int, int> pii;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

const int inf = 2000000000;

main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    set<int> s;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(s.find(x) != s.end()){
            s.erase(x);
        } else {
            s.insert(x);
        }
    }
    cout << s.size();
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
int main(){
	string s; cin>>s;
	rep(i,19){
		if(s[i]==',') cout<<" ";
		else cout<<s[i];
	}
	cout<<endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
int main(void){
    int  a;
    int  b;
    int  n;
    
    n = 0;
    scanf ("%d %d", &a, &b);
    if (a > b)
        n = a + a - 1;
    if (a < b)
        n = b + b - 1;
    if (a == b)
        n = a + b;
    printf ("%d", n);
    return (0);
}


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

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out,false);
        int n = scanner.nextInt(), k = scanner.nextInt(), q = scanner.nextInt();
        int[] score = new int[n];
        Arrays.fill(score, k-q);
        while(q-->0){
            score[scanner.nextInt()-1]++;
        }
        for(int i = 0; i < n; i++) {
            if (score[i] <= 0) out.println("No");
            else out.println("Yes");
        }
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

int main() {

    int a,b,c;
	cin >> a >> b >> c;
  	int x = a + b + c;
  	if(x < 22){
    	cout << "win" << endl;
    }else{
    	cout << "bust" << endl;
    }
	

}


Measured memory_bytes: 256
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

n=ii()
print(n+n*n+n*n*n)

Measured memory_bytes: 65044
from collections import OrderedDict
N = int(input())
S = OrderedDict([('AC', 0), ('WA', 0), ('TLE', 0), ('RE', 0)])
for i in range(N):
    text = input()
    if text in S.keys():
        S[text] =S[text] + 1
        # print(S)

for key, value in S.items():
    print('{} x {}'.format(key, value))

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

int main()
{
	int n,a;
	cin>>n;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		if(a-ans<=-2)
		{
			cout<<"No";
			return 0;
		}
		ans=max(a,ans);
	}
	cout<<"Yes";

	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

class A {
    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final String S = sc.next().intern();
        final String T = sc.next().intern();
        final int A = sc.nextInt();
        final int B = sc.nextInt();
        final String U = sc.next().intern();
        if (S == U)
            System.out.printf("%d %d\n", A - 1, B);
        else
            System.out.printf("%d %d\n", A, B - 1);
    }
}

public class Main {
    public static void main(String... args) {
        A.main();
    }
}


Measured memory_bytes: 21844
a, b = gets.strip.split
c = (a + b).to_i

def is_square n
    up = Math.sqrt(n)
    for i in (1..up)
        if i * i == n
            return true
        end
    end
    false
end

if is_square c
    puts 'Yes'
else
    puts 'No'
end

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

using namespace std;

template <typename A> ostream & operator << (ostream & out, vector <A> x) {
    out << "{";
    for (int i = 0; i < (int) x.size(); i++) {
        out << x[i] << ", ";
    }
    return out << "}\n";
}

template <typename A, typename B> ostream & operator << (ostream & out, pair <A, B> x) {
    return out << "{" << x.first << ", " << x.second << "}\n";
}

int main() {
    string a[3];
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < 3; i++) {
        cout << a[i][i];
    }
    cout << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

int main(){

    ll A, B;

    cin >> A >> B;

    cout << (A % 3 && B % 3 && (A + B) % 3 ? "Impossible" : "Possible") << endl;

    return 0;
}

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

int main()
{
	int N, SA = 0, SB = 0;
	string A, B;
	cin >> N;
	for(int i = 0; i < N; ++i)
	{
		cin >> A >> B;
		if(A == B)
		{
			SA += 1;
			SB += 1;
		}
		else if(A > B)
		{
			SA += 3;
		}
		else
		{
			SB += 3;
		}
	}
	cout << SA << " " << SB << endl;

    return 0;
}



Measured memory_bytes: 3128
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    String[] a = new String[h];

    for (int i = 0; i < h; i++) {
      a[i] = sc.next();
    }

    for (int j = 0; j < w+2; j++) {
      System.out.print("#");
    }

    System.out.println();


    for (int j = 0; j < h; j++) {
      System.out.print("#"+a[j]);
      System.out.println("#");
    }

    for (int j = 0; j < w+2; j++) {
      System.out.print("#");
    }

    System.out.println();

  }

}


Measured memory_bytes: 23356
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	string s; cin >> s;
	sort(ALL(s));
	cout << (s == "abc" ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int H, N;
	cin >> H >> N;
	int sum=0;
	for(int i=0; i<N; ++i){
		int A;
		cin >> A;
		sum += A;
	}
	if(H<=sum) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> a(m);
  vector<bool> f(n, false);
  for(int i = 0; i < m; i++) {
    cin >> a.at(i);
    f.at(a.at(i)) = true;
  }
  int l = 0;
  int r = 0;
  for(int i = 1; i < x; i++) {
    if(f.at(i)) {
      l++;
    }
  }
  for(int i = x + 1; i < n; i++) {
    if(f.at(i)) {
      r++;
    }
  }
  if(l < r) {
    cout << l << endl;
  } else {
    cout << r << endl;
  }
}


Measured memory_bytes: 256
n = gets.chomp!.to_i
pl = gets.split(" ").map(&:to_i)
d = Array.new(n, 0)
#p d
i = 1
while i <= n-2
  e = Array.new
  e = [pl[i-1].to_i, pl[i].to_i, pl[i+1].to_i]
  #p e
  ne = e.sort
  if ne[1] == pl[i]
    d[ne[1]-1] += 1
  end
  i+=1
end
#p d
p d.count{|item| item > 0 }

Measured memory_bytes: 3836
import math
a, b, h, m = map(int, input().split())
H = 30 * h + 0.5 * m
M = 6 * m
angle = abs(H - M)

ans = a**2 + b**2 - (2 * a * b * math.cos(math.radians(angle)))
print(math.sqrt(ans))

Measured memory_bytes: 9364
use proconio::input;

fn main() {
  input! {
    n: usize,
    q: usize,
    s: String,
    lrs: [(usize,usize);q],
  }
  let s = String::from(" ") + &s;
  let s = s.chars().collect::<Vec<char>>();
  let mut dp = vec![0;n+1];
  for i in 1..=n {
    if s[i-1] == 'A' && s[i] == 'C' {
      dp[i] = dp[i-1] + 1;
    } else {
      dp[i] = dp[i-1];
    }
  }

  for (l, r) in lrs {
    println!("{}", dp[r] - dp[l]);  
  }
}

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

int main() {
  long long m,d; cin >> m >> d;
  long long ans;
  for(int j = 1; j<=m; j++){
    for(int i = 1; i<=d; i++){
      long long a = i/10;
      long long b = i%10;
      if(a>=2&&b>=2&&a*b==j) ans++;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))
for i in range(len(H)-1):
  if H[-i-1] >= H[-i-2]:
    pass
  elif H[-i-1] == H[-i-2] - 1:
    H[-i-2] -= 1
  else:
    print("No")
    exit()
    
print("Yes")

Measured memory_bytes: 14396
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;

ll a, b, c, n, k, x;
string s;

int main()
{
  cin >> n;
  ll a[3 * n];
  for (ll i = 0; i < 3 * n; i++)
  {
    cin >> a[i];
  }
  sort(a, a + 3 * n, greater<int>());
  ll ans = 0;
  ll j = 1;
  for (ll i = 0; i < n; i++)
  {
    ans += a[j];
    j += 2;
  }
  cout << ans << endl;
}


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

if n == 1:
    print('YES')
    exit()

if sum(a) % ( (1 + n) * n // 2 ) != 0:
    print('NO')
    exit()

k = sum(a) // ( (1 + n) * n // 2 )

temp = k - a[0] + a[n - 1]
if temp % n != 0 or temp < 0:
    print('NO')
    exit()

d = temp // n
for i in range(1, n):
    temp = k - a[i] + a[i - 1]
    if temp % n != 0 or temp < 0:
        print('NO')
        exit()
    d += temp // n

print('YES')



Measured memory_bytes: 14996
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n;
    cin>>n;
    ll a[n][3];
    ll i,j;
    for (i=0;i<n;i++)
    {

        for (j=0;j<3;j++)
        {

            cin>>a[i][j];
        }
    }
    ll dp[n][3];
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for (i=1;i<n;i++)
    {


            dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
            dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
            dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];


    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 4992
#include<iostream>

using namespace std;

int main(void) {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	while (A>=0||C>=0) {
		C -=B ;
		if (C <= 0) {
			cout << "Yes" << endl;
			break;
		}
		A -= D;
		if (A <= 0) {
			cout << "No" << endl;
			break;
		}
	}
	return 0;

}

Measured memory_bytes: 3040
n = int(input())
s = sorted([int(input()) for _ in range(n)])

ans = sum(s)
if ans % 10 != 0:
    print(ans)
else:
    cnt = 0
    for i in s:
        if i % 10 == 0:
            cnt += 1
        else:
            ans -= i
            print(ans)
            break

    if cnt == n:
        print(0)


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }

    return true;
}
int main(void){
    int N, C_money;
    cin >> N >> C_money;
    vector<int> v(N);

    for (int i = 0; i < N; i++) {
        cin >> v[i];
        C_money -= v[i];
    }

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

    N += C_money / v[0];
    cout << N << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  ll n;cin>>n;
  cout<<(n-1)/2<<endl;
  return 0;
}


Measured memory_bytes: 384
import math

# inputList=[]
# for i in range(6):
#     inputNum = input()
#     inputList.append(inputNum)
inputa = input().split()
# inputb = input().split()

inputa = [int(n) for n in inputa]
inputa.sort()

a = int(inputa[0])
b = int(inputa[1])
c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

ans = abs(b - a) + abs(c - b)
print(ans)


Measured memory_bytes: 38492
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

const int MAX_N = 100100;
int n;



// n要素で初期化
void init(int par[], int rank[], int n){
    for(int i=0;i<n;i++){
        par[i] = i;
        rank[i] = 0;
    }
}

// 木の根を求める
int find(int par[], int x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par,par[x]);
    }
}

// xとyの属する集合を併合
void unite(int par[], int rank[], int x, int y){
    x = find(par,x);
    y = find(par,y);
    if(x == y) return;

    if(rank[x] < rank[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(rank[x] == rank[y]) rank[x]++;
    }
}

// xとyが同じ集合に属するか否か
bool same(int par[], int x, int y){
    return find(par,x) == find(par,y);
}

int main() {
    cin >> n;
    vector<P> v; 
    vector<int> x[MAX_N];
    vector<int> y[MAX_N];

    int parx[MAX_N]; // 親
    int pary[MAX_N];
    int rankx[MAX_N]; // 木の深さ
    int ranky[MAX_N];

    init(parx,rankx,MAX_N);
    init(pary,ranky,MAX_N);

    rep(i,n){
        int x_,y_;
        cin >> x_ >> y_;
        x[x_].push_back(y_);
        y[y_].push_back(x_);
        v.push_back(P(x_,y_));
    }

    sort(v.begin(),v.end());
    ll ans = 0;

    rep(i,n){
        if(x[v[i].first].size()>=2&&y[v[i].second].size()>=2){
            //ans += (x[v[i].first].size()-1)*(y[v[i].second].size()-1);
            rep(j,x[v[i].first].size()-1){
                unite(pary,ranky,x[v[i].first][j],x[v[i].first][j+1]);
            }
            rep(j,y[v[i].second].size()-1){
                unite(parx,rankx,y[v[i].second][j],y[v[i].second][j+1]);
            }
        }
    }

    ll countx[MAX_N] = {};
    ll county[MAX_N] = {};

    rep(i,MAX_N){
        countx[find(parx,i)]++;
        county[find(pary,i)]++;
    }
    /*
    rep(i,15){
        cout << find(parx,i) << ' ';
    }
    cout << endl;
    rep(i,15){
        cout << find(pary,i) << ' ';
    }
    cout << endl;
    */


    int flag[MAX_N] = {};

    rep(i,n){
        if(countx[find(parx,v[i].first)]>=2&&county[find(pary,v[i].second)]>=2){
            ans--;
            if(flag[find(parx,v[i].first)]==0){
                flag[find(parx,v[i].first)] =1;
                ans += countx[find(parx,v[i].first)]*county[find(pary,v[i].second)];
                //cout << countx[find(parx,v[i].first)]*county[find(pary,v[i].second)] << endl;
            }
        }
    }

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


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

int main() {
  int H,W; cin >> H >> W;
  string s[H]; for (int i =0; i<H; i++) cin >> s[i];
  
  for (int i =0; i<H; i++) {
    cout << s[i] << endl;
    cout << s[i] << endl;
  }
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int Magic(int a){
    return a>1 ? (a-1)*10 : 0;
}
int main(){
    int N,A,B,C;
    cin >> N >> A >> B >> C;
    int l[N];
    for(int i=0; i<N; i++) cin >> l[i];
    
    int MP=1e9;
    for(int mask=0; mask<pow(4,N); ++mask){
        int a[3]={},cnt[3]={};
        int tmp=mask;
        for(int i=0; i<N; i++){
            if(tmp%4==1){
                a[0]+=l[i];
                cnt[0]++;
            }else if(tmp%4==2){
                a[1]+=l[i],cnt[1]++;
            }else if(tmp%4==3){
                a[2]+=l[i],cnt[2]++;
            }
            tmp/=4;
        }
        if(a[0] && a[1] && a[2]){
            int mp=abs(A-a[0]) + abs(B-a[1]) + abs(C-a[2]);
            for(int i=0; i<3; i++) mp += Magic(cnt[i]);
            MP = min(MP, mp);
        }

    }
    cout << MP << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <stack>
#include <queue>

#define MAX_NM 1500
#define MAX_S 1500*1000

using namespace std;

int N, M;
int h[MAX_NM], w[MAX_NM];
int hsum[MAX_S], wsum[MAX_S];

int main(){
	while(1){
		cin >> N >> M;
		if(N == 0)break;
		for(int i = 0; i < N; i++){
			cin >> h[i];
		}
		for (int i = 0; i < M; i++)
		{
			cin >> w[i];
		}
		for (int i = 0; i < MAX_S; i++)
		{
			hsum[i] = 0;
			wsum[i] = 0;
		}
		for (int i = 0; i < N; i++)
		{
			int s = h[i];
			for (int j = i+1; j <= N; j++)
			{
				hsum[s]++;
				if(j < N) s += h[j];
			}
		}
		for (int i = 0; i < M; i++)
		{
			int s = w[i];
			for (int j = i+1; j <= M; j++)
			{
				wsum[s]++;
				if(j < M) s += w[j];
			}
		}
		int ans = 0;
		for (int i = 0; i < MAX_S; i++)
		{
			ans += hsum[i]*wsum[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 12888
def sub():
    N, M = [int(e) for e in input().split()]
    memo = [0 for _ in range(M)]
    for i in range(N):
        lines = [int(e) for e in input().split()]
        K = lines[0]
        As = lines[1:]
        for a in As:
            memo[a-1] = memo[a-1] + 1
    count = 0
    for m in memo:
        if m == N:
            count += 1
    print(count)

sub()



Measured memory_bytes: 38384
let hd_opt t =
  match t with
  | [] -> None
  | x :: _ -> Some x

open Batteries
let () =
  let s = Scanf.scanf "%s " (fun a -> a) in
  let rev_s = String.rev s in

  let dict = ["dream";"dreamer";"erase";"eraser"] in
  let rev_dict = List.map (fun x -> String.rev x) dict in

  let rec aux s = match s with
      "" -> "YES"
    | s -> 
      let res = List.map (fun dict_s -> 
          let len = String.length dict_s in
          let target = String.slice ~last:len s in
          if dict_s = target then len else 0
        ) rev_dict |> List.filter (fun x -> x <> 0) in

      match (hd_opt res) with
      Some x -> aux (String.slice ~first:x s)
      | None -> "NO"
  in

  Printf.printf "%s\n" @@
  aux rev_s


Measured memory_bytes: 8576
#include <iostream>

using namespace std;

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

    int x;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(i%2==0 && x%2==1)
        {
            cnt++;
        }
    }
    cout<<cnt;


}


Measured memory_bytes: 3544
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
cd=[list(map(int,input().split())) for _ in range(m)]

for i in range(n):
    le=float("inf")
    a,b=ab[i][0],ab[i][1]
    for j in range(m):
        c,d=cd[j][0],cd[j][1]
        if le>abs(a-c)+abs(b-d):
            ans=j+1
            le=abs(a-c)+abs(b-d)
    print(ans)


Measured memory_bytes: 39408