akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int N;
vector<vector<int>> child;
vector<int> X;
vector<P> val;

int nap(int limit, vector<int> weights)
{
    bitset<5000+1> b(1);
    for (auto i : weights) b = b | (b << i);
    for (int i = limit; i >= 0; i--)
    {
        if (b[i]) return i;
    }
    return -1;
}

int dfs(int root)
{
    for (auto i : child[root])
    {
        if (dfs(i)) return 1;
    }

    if (child[root].empty())
    {
        val[root] = make_pair(X[root], 0);
        return 0;
    }

    int smallerDefault = 0;
    int childsum = 0;
    vector<int> weights(child[root].size());
    for (int i = 0; i < (int)child[root].size(); i++)
    {
        P ptmp = val[child[root][i]];
        smallerDefault += min(ptmp.first, ptmp.second);
        weights[i] = abs(ptmp.first - ptmp.second);
        childsum += ptmp.first + ptmp.second;
    }
    
    if (X[root] < smallerDefault) return 1;
    int w = nap(X[root] - smallerDefault, weights) + smallerDefault;
    int tmp = childsum - w;
    val[root].first = tmp;
    val[root].second = X[root];
    return 0;
}

int main()
{
    cin >> N;
    child.resize(N);
    X.resize(N);
    val.resize(N);

    for (int i = 1; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        child[tmp - 1].push_back(i);
    }
    for (int i = 0; i < N; i++) cin >> X[i];

    if(dfs(0))
    {
        cout << "IMPOSSIBLE" << endl;
    }
    else
    {
        cout << "POSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
import math
import itertools
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
p = list(itertools.permutations([A, B, C, D, E], 5))
# print(p)
ans = 10**9
for pi in p:
    order1 = 0
    order2 = math.ceil(pi[0] / 10) * 10
    order3 = math.ceil((order2 + pi[1]) / 10) * 10
    order4 = math.ceil((order3 + pi[2]) / 10) * 10
    order5 = math.ceil((order4 + pi[3]) / 10) * 10
    total = order5 + pi[4]
    ans = min(ans, total)
print(ans)


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

int main()
{
	// 入力
	int A, B, C;
	cin >> A >> B >> C;
	
	// 容器1、2の水の量
	int container1 = B;
	int container2 = C;
	
	
	// 容器1の空き容量の計算
	int emptyContainer1 = 0;
	if (A > B)
	{
		emptyContainer1 = A - B;
	}
	
	
	int answer = 0;
	if (container2 - emptyContainer1 < 0)
	{
		answer = 0;
	}
	else {
		answer = container2 - emptyContainer1;
	}
	
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)


h, w = map(int, input().split())
maze = [[-1 for i in range(w)] for j in range(h)]

ans = 0
for i in range(h):
    maze[i] = input()

INF = 1000
ans = 0

for sy in range(h):
    for sx in range(w):
        if maze[sy][sx] == '.':
            continue

        flg = 0
        for i in range(0, 4):
            nx, ny = sx + [1, 0, -1, 0][i], sy + [0, 1, 0, -1][i]
            if 0 <= nx < w and 0 <= ny < h:
                if maze[ny][nx] == '#':
                    flg = 1
        if flg == 0:
            print('No')
            exit()

print('Yes')


Measured memory_bytes: 3192
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
#確率は1/2 ** M
#時間は(N-M) * 100 + M * 1900
answer = ((N-M) * 100 + M * 1900) / 0.5 ** M
print(int(answer))
# 16

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


//逆元
// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
  return modpow(a, mod-2, mod);
}

ll cal_comb(ll a, ll b, ll mod) {
  if (b > a-b) return cal_comb(a, a-b, mod);
  ll bunsi = 1;
  ll bunbo = 1;
  for (int i = 0; i < b; ++i) {
    bunsi *= (a - i);
    bunsi %= mod;
    bunbo *= (i + 1);
    bunbo %= mod;
  }
  return bunsi * modinv(bunbo, mod);
}

int main()
{
  int n, m;
  cin >> n >> m;
  
  vector<int> prf;
  int id = -1;
  int tmp = m;
  for (int i = 2; i*i <= tmp; ++i) {
    if (tmp % i == 0) {
      prf.push_back(0);
      ++id;
      while (tmp % i == 0) {
        tmp /= i;
        ++prf[id];
      }
    }
  }
  if (tmp > 1) {
    prf.push_back(1);
    ++id;
  }

  ll ans = 1;
  while (id >= 0) {
    ans *= cal_comb((ll)(n-1+prf[id]), (ll)prf[id], Mod) % Mod;
    ans %= Mod;
    --id;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#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++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); 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;

double a, b, x;

double calc(double mid){
    double V;
    double theta = mid * M_PI / 180.0;
    if(a*tan(theta) < b){
        V = a*a*b - a*a*a*tan(theta)/2.0;
    }
    else{
        //double s = b / tan(theta);
        //V = a * s * b / 2;
        V = a*b*b/2/tan(theta);
    }

    return V;
}

int main(){
    cin >> a >> b >> x;

    double ans = 0;

    double left = 0.0;
    double right = 90.0;
    double mid;
    while(1){
        mid = (right + left) / 2.0;
        double V = calc(mid);
        if(V > x){
            left = mid;
        }
        else{
            right = mid;
        }

        if(fabs(V - x) < 1e-8) {
            ans = mid;
            break;
        }
    }

    printf("%.20lf\n", ans);
    return 0;
}


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

int main() {
  int N, s = 0;
  cin >> N;
  int A[N + 1];
  A[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    if (i > 0) s+= abs(A[i] - A[i - 1]);
  }
  s += abs(A[0] - A[N]);
  for (int i = 1; i <= N; i++) {
    if (i < N) {
      if (A[i - 1] <= A[i]) {
        if (A[i] <= A[i + 1]) cout << s << endl;
        if (A[i] > A[i + 1] && A[i - 1] <= A[i + 1]) cout << s - 2 * abs(A[i + 1] - A[i]) << endl;
        if (A[i] > A[i + 1] && A[i - 1] > A[i + 1]) cout << s - 2 * abs(A[i] - A[i - 1]) << endl;
      } else {
        if (A[i] > A[i + 1]) cout << s << endl;
        if (A[i] <= A[i + 1] && A[i - 1] > A[i + 1]) cout << s - 2 * abs(A[i + 1] - A[i]) << endl; 
        if (A[i] <= A[i + 1] && A[i - 1] <= A[i + 1]) cout << s - 2 * abs(A[i] - A[i - 1]) << endl;
      }
    } else {
      if (A[N - 1] <= A[N]) {
        if (A[N] <= A[0]) cout << s << endl;
        if (A[N] > A[0] && A[N - 1] <= A[0]) cout << s - 2 * abs(A[0] - A[N]) << endl; 
        if (A[N] > A[0] && A[N - 1] > A[0]) cout << s - 2 * abs(A[N] - A[N - 1]) << endl;
      } else {
        if (A[N] > A[0]) cout << s << endl;
        if (A[N] <= A[0] && A[N - 1] > A[0]) cout << s - 2 * abs(A[0] - A[N]) << endl; 
        if (A[N] <= A[0] && A[N - 1] <= A[0]) cout << s - 2 * abs(A[N] - A[N - 1]) << endl;
      }
    }
  }
}

Measured memory_bytes: 1664
n,m=map(int,input().split())
A=[list(input()) for i in range(n)]
B=[list(input()) for j in range(m)]
point=[[i,j] for i in range(m) for j in range(m)]
for i in range(n-(m-1)):
    for j in range(n-(m-1)):
        cnt=0
        for x,y in point:
            if B[x][y]==A[i+x][j+y]:
                cnt +=1
        if cnt==m**2:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
n = int(input())
w = [input() for _ in range(n)]

tmp = []
ans = "Yes"
for i in range(n-1):
    if w[i] in tmp:
        ans = "No"
        break
    if not w[i] in tmp:
        tmp.append(w[i])
    if w[i][-1] != w[i + 1][0]:
        ans = 'No'
        #print('B')
#print(tmp)
if w[-1] in tmp:
    ans = "No"
print(ans)


Measured memory_bytes: 3060
/*
 * Problem: Prime Numbers
 * Author: Khan
 * Date: 11th October, 2017
 */
#include <iostream>

using namespace std;

int selectionSort(int A[], int N)
{
    int i, j, t, sw = 0, minj;
    for (i = 0; i < N - 1; ++i)
    {
        minj = i;
        for (j = i; j < N; ++j)
        {
            if(A[minj] > A[j])
                minj = j;
        }
        swap(A[i], A[minj]);
        if(i != minj)
            sw++;
    }
    return sw;
}

int main(int argc, char const *argv[])
{
    int A[100], N, sw;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        cin >> A[i];
    }

    sw = selectionSort(A, N);

    for (int i = 0; i < N; ++i)
    {
        if(i)
            cout << " ";
        cout << A[i];
    }

    cout << endl;
    cout << sw << endl;
    return 0;
}

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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,k;
  cin>>n;
  cin>>k;
  vector<int> v(n);
  for(int i=0;i<n;i++){
      cin>>v[i];
      
  }
  //cout<<v[0]<<v[1];
  vector<int> dp(k+1,0);
  for(int i=1;i<=k;i++){
      for(int j=0;j<n;j++){
            //cout<<k-v[j];      
          if(i-v[j]>=0){
              if(dp[i-v[j]]==0){
                  dp[i] = 1;
                 // cout<<i;
                  break;
              }
          }
      }
  }
   if(dp[k]==1) 
    cout<<"First";
  else 
    cout<<"Second";
}

Measured memory_bytes: 640
def main():
    N,M=map(int,input().split())
    L=2**N
    dp=[10**10 for i in range(L)]
    dp[0]=0


    for i in range(M):
        a, _ = map(int, input().split())
        key=sum([2**(int(i)-1) for i in input().split()])
        for j in range(L):
                q=j|key
                dp[q]=min(dp[j]+a,dp[q])


    ans=dp[L-1]
    print(ans if ans<10**10 else -1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

ll mpow(ll x, ll n) { ll y = 1; for (; n; n /= 2) { y = n % 2 ? y * x % MOD : y; x = x * x % MOD; } return y; }

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

    vector<ll> dp(K + 1);
    ll ans = 0;
    for (ll g = K; g > 0; --g) {
        ll p = mpow(K / g, N);
        for (int n = 2 * g; n <= K; n += g) {
            p = (p + MOD - dp[n]) % MOD;
        }
        dp[g] = p;
        ans = (ans + p * g) % MOD;
    }
    write(ans);
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
  vector<int> abc(3);
  for (int i = 0; i < 3; ++i) cin >> abc[i];
  int k;
  cin >> k;

  int ans = 0;
  for (int i = 0; i < 2; ++i) {
    while (true) {
      if (abc[i] >= abc[i + 1]) {
        ++ans;
        abc[i + 1] *= 2;
      } else {
        break;
      }
    }
  }

  if (ans <= k) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main(){
  int n;
  cin>>n;
  int a,b[n];
  for(int i=0;i<n;i++){
    cin>>a;
    b[a-1]=i+1;
  }
  for(int i=0;i<n;i++){
    cout<<b[i]<<endl;
  }
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    string s;
    while (cin >> s, s != "#") {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int W = -1;
        vector<bool> v;
        REP (pos, 0, s.size()) {
            if (s[pos] == 'b') v.push_back(true);
            else if (s[pos] != '/') {
                REP (_, 0, s[pos] - '0') v.push_back(false);
            } else if (W == -1) {
                W = v.size();
            }
        }
        v[(a - 1) * W + b - 1] = false;
        v[(c - 1) * W + d - 1] = true;
        for (int ok = 0, H = 0; H < v.size() / W; H++, ok = 1) {
            if(ok) cout << '/' ;
            int cnt = 0;
            REP (i, 0, W) {
                if (v[H * W + i]) {
                    if (cnt) cout << cnt;
                    cout << 'b';
                    cnt = 0;
                }
                else cnt++;
            }
            if (cnt) cout << cnt;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3148
import sys
import itertools

INF = 1001001001

def resolve():
  n = int(input())
  p = list(map(int, input().split()))
  q = list(map(int, input().split()))
  arr = []
  for i in range(1, n+1):
    arr.append(i)

  x = itertools.permutations(arr, n)

  a = 0
  b = 0
  for i, y in enumerate(x):
    if (p == list(y)):
      a = i + 1
    if (q == list(y)):
      b = i + 1

  print(abs(a - b))

  return

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define fi first
#define se second
#define mod 998244353
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000;
#define PI 3.14159265
int main()
{
    fastio;
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans = n/(a+b);
    ans*=a;
    ans+= min(a,n%(a+b));
    cout<<ans<<endl;
    return 0;
}


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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;

int main() {
    
    bool T[300005];
    memset(T,0,sizeof(T));

    vector<int> v;
    REP(i,2,300001) {
        if(i%7 == 1 || i%7 == 6) {
            v.push_back(i);
            T[i] = true;
        }
    }

    rep(i,v.size()) {
        int res = v[i];
        int cnt = res*2;
        while(cnt < 300000) {
            T[cnt] = false;
            cnt += res;
        }

    }

    vector<int> res;
    rep(i,300001) {
        if(T[i]) {
            res.push_back(i);
        }
    }

    int n;
    while(cin >> n) {
        if(n == 1) break;
       
        cout << n << ":";
        vector<int> ans;
        rep(i,res.size()) {
            if(n%res[i] == 0){
                ans.push_back(res[i]);
            }
        }
       
        rep(i,ans.size()) {
            cout << " " << ans[i];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 2016
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $ans="";
  if($n == 0){
    echo "0";
    exit;
  }
  while($n != 1){
    if($n % 2 == 0){
      $ans.="0";
    }else{
      $n--;
      $ans.="1";
    }
    $n /= -2;
  }
  $ans.="1";

  echo strrev($ans);

Measured memory_bytes: 16144
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (ll)(n); ++i)
#define MOD 1000000007

using namespace std;
using ll = long long;

int main() {
	int n, h[3];
	string ans;
	cin >> n;
	rep(i,3) cin >> h[i];
	vector<pair<int, int>> m;
	rep(i, n) {
		string str;
		cin >> str;
		m.emplace_back(str[0] - 'A', str[1] - 'A');
	}
	auto play = [&] (int x, int y) {
		h[x]++;
		h[y]--;
		ans += 'A' + x;
		return;
	};
	m.emplace_back(0, 1);
	rep(i, n) {
		int s = m[i].first;
		int t = m[i].second;
		if (h[s] + h[t] == 0) {
			cout << "No" << endl;
			return 0;
		}
		if (h[s] == h[t]) {
			int ns = m[i + 1].first;
			int nt = m[i + 1].second;
			if (s == ns || s == nt) play(s, t);
			else play(t, s);
		}
		else if (h[s] > h[t]) play(t, s);
		else play(s, t);
	}
	cout << "Yes" << endl;
	for (char c : ans) cout << c << endl;
	return 0;
}


Measured memory_bytes: 4272
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
    while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if (x < 0) putchar('-'), x = -x;
    if (x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 2e5 + 5, md = 998244353;

inline int add(int x, int y) {
    x += y;
    if (x >= md) x -= md;
    return x;
}

inline int sub(int x, int y) {
    x -= y;
    if (x < 0) x += md;
    return x;
}

inline int mul(int x, int y) { return 1ll * x * y % md; }

inline int fpow(int x, int y) {
    int ans = 1;
    while (y) {
        if (y & 1) ans = mul(ans, x);
        y >>= 1; x = mul(x, x);
    }
    return ans;
}

int a[N], id[N], s[N];
int n, k, p, ans;

bool cmp(int x, int y) { return a[x] < a[y]; }

struct fenwick {
    int f[N];

    inline int lowbit(int x) { return x & -x; }

    inline void add(int x, int y) {
        while (x <= n) {
            f[x] = ::add(f[x], y);
            x += lowbit(x);
        }
    }

    inline int query(int x) {
        int ans = 0;
        while (x) {
            ans = ::add(ans, f[x]);
            x ^= lowbit(x);
        }
        return ans;
    }
} tr1, tr2;

int main() {
    read(n); read(k); p = mul(k - 1, fpow(k, md - 2));
    for (int i = 1; i <= n; i++) read(a[i]), id[i] = i;
    for (int i = 1; i <= n; i++) s[i] = add(s[i - 1], fpow(p, max(i, k)));
    sort(id + 1, id + n + 1, cmp);
    for (int i = 1; i <= n; i++) {
        int p1 = sub(tr1.query(n), tr1.query(id[i])), p2 = sub(sub(s[n], s[id[i]]), p1), inv = fpow(fpow(p, max(id[i], k)), md - 2);
        p1 = mul(p1, inv); p2 = mul(p2, inv);
        ans = add(ans, sub(tr2.query(n) - tr2.query(id[i]), p1));
        ans = add(ans, mul(add(p1, p2), (md + 1) >> 1));
        tr1.add(id[i], fpow(p, max(id[i], k))); tr2.add(id[i], 1);
    }
    print(ans, '\n');
    return 0;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int tmp = 0;
	if (a == (b + c)) tmp++;
	if (b == (a + c)) tmp++;
	if (c == (a + b)) tmp++;
	if (tmp == 0) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
	
}

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

int main() {
    ll N; cin >> N;
    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }


    map<ll,ll> M;
    ll a = 2;
    while (N >= a * a) {
        if (N % a == 0) {
            M[a]++;
            N /= a;
        } else {
            a++;
        }
    }
    M[N]++;
    ll count = 0;
    for (auto x : M) {
        ll c = 1;
        while (true) {
            x.second -= c;
            if (x.second >= 0) {
                c++;
                count++;
                continue;
            }
            break;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3636
N,M,X = map(int, input().split())
A = list(map(int, input().split()))
sorted_A = sorted(A)
for i in range(M):
    if A[i]>=X:
        cnt = i
        break
ans1 = len(A[cnt:])
ans2 = len(A[:cnt])
ans = min(ans1,ans2)
print(ans)

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

#define ll long long
#define debug(x) cerr << fixed << #x << " is " << x << endl;

vector<int> v;

ll sadness(int b)
{
	ll sum = 0;
	for(int i = 1; i <= (int) v.size(); i++)
		sum += abs(v[i-1]-(b+i));
	return sum;
}

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

	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		v.push_back(x);
	}

	ll l = 0, r = 1e18;
	while(l <= r)
	{
		ll mid = (l + r) / 2;
		ll a = sadness(mid-1);
		ll b = sadness(mid);
		ll c = sadness(mid+1);
		if(a >= b && b <= c)
		{
			cout << b << endl;
			return 0;
		}
		else if(a > b && b > c)
			l = mid + 1;
		else
			r = mid - 1;
	}
	cout << "Fudeu" << endl;

	return 0;
}
/*
ll l = 0, r = 1e18;
while(l <= r)
{
	ll mid = (l + r) / 2;
	if(E(mid, i.first) < i.second * k)
		l = mid + 1;
	else
		r = mid - 1;
}
ans = max(ans, l);
*/


Measured memory_bytes: 1400
#include <iostream>

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if((a != 5 && a != 7) || (b != 5 && b != 7) || (c != 5 && c != 7)){
        cout << "NO";
    }
    else if((a + b + c) != 17){
        cout << "NO";
    }
    else{
        cout << "YES";
    }
    return 0;
}

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

int main() {
    long int x;
    long int year, money;
    cin >> x;
    money = 100;
    year = 0;
    while(money < x)
    {
        money += money * 0.01;
        year++;
    }
    cout << year << endl;
}



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

int main() {
  int n, y;
  int l = 0, m = 0, o = 0;

  scanf("%d %d", &n, &y);

  for (l = 0; l <= y / 10000; l++) {
    for (m = 0; m <= (y - (10000 * l)) / 5000; m++) {
      o = (y - (10000 * l + 5000 * m)) / 1000;
      if ((m + l + o) == n) {
        printf("%d %d %d\n", l, m, o);
        return 0;
      } 
    }
  }

  printf("-1 -1 -1\n");
  return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	void main() {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			if(x == 0 && y == 0) break;
			if(x <= y) {
				System.out.println(x +" "+ y);
			}else {
				System.out.println(y +" "+ x);
			}
		}
				
	}
	public static void main(String[] args) {
		new Main().main();
	}

}



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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    ll ans = 0;
    for(int i = 0; i < (1 << (n-1)); i++) {
        ll counter = 0;
        rep(j,n) {
            counter = counter * 10 + (s[j] - '0');
            if((1 << j) & i || j == n-1) {
                ans += counter;
                counter = 0;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int N=1e5+5;

map<int,int> h;
int n,a[N],b[N],f[N],cnt[N],x,tot,ans;

int get(int x) {return f[x]?f[x]=get(f[x]):x;}

void merge(int x,int y) {
	x=get(x);y=get(y);
	if (x==y) return;
	f[y]=x;
}

int main() {
	scanf("%d",&n);
	x=0;fo(i,1,n) scanf("%d",&a[i]),x^=a[i];a[n+1]=x;
	x=0;fo(i,1,n) scanf("%d",&b[i]),x^=b[i];b[n+1]=x;
	n++;
	fo(i,1,n) 
		if (a[i]!=b[i]||i==n) {
			if (!h[a[i]]) h[a[i]]=++tot;
			cnt[h[a[i]]]++;
		}
	fo(i,1,n) 
		if (a[i]!=b[i]||i==n) 
			cnt[h[b[i]]]--;
	fo(i,0,tot) 
		if (cnt[i]) {
			puts("-1");
			return 0;
		}
	fo(i,1,n) a[i]=h[a[i]],b[i]=h[b[i]];
	fo(i,1,n) 
		if (a[i]!=b[i]) {
			if (i<n) ans++;
			merge(a[i],b[i]);
		}
	fo(i,1,tot) if (get(i)==i) ans++;
	printf("%d\n",max(ans-1,0));
	return 0;
}

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

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> pi(n+1,-1);
  vector<vector<int>> ps(n);
  rep(i,n) {
    int l = pi[a[i]];
    if (l != -1) ps[l].push_back(i);
    pi[a[i]] = i;
  }

  vector<vector<P>> qs(n);
  rep(qi,q) {
    int l, r;
    cin >> l >> r;
    --l; --r;
    qs[l].emplace_back(r,qi);
  }

  vector<int> ans(q);
  BIT<int> d(n);
  for (int x = n-1; x >= 0; --x) {
    for (int y : ps[x]) d.add(y,1);
    for (P query : qs[x]) {
      int r = query.first, i = query.second;
      ans[i] = (r-x+1) - d.sum(r);
    }
  }

  rep(i,q) cout << ans[i] << "\n";
  return 0;
}


Measured memory_bytes: 59820
//  Copyright 2019 Nikita Golikov

#include <iostream>
#include <vector>

int main() {
  int const M = 2019;
  int l, r;
  std::cin >> l >> r;
  std::vector<bool> have(M, true);
  if (r - l + 1 < M) {
    std::fill(have.begin(), have.end(), false);
    for (int i = l; i <= r; ++i) {
      have[i % M] = true;
    }
  }
  int ans = M;
  for (int i = 0; i != M; ++i) {
    for (int j = i + 1; j != M; ++j) {
      if (!have[i] || !have[j]) {
        continue;
      }
      ans = std::min(ans, i * j % M);
    }
  }
  std::cout << ans << '\n';
  return 0;
}


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

char ch[ 210 ];
int K;

int main() {
    scanf( "%s", ch );
    scanf( "%d", &K );
    int i = 0;
    while( K ) {
        if( ch[ i ] == '1' ) {
            K--; 
            if( K == 0 ) { cout << ch[ i ] << endl; return 0; }
            ++i;
            continue;
        }
        cout << ch[ i ] << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
import sys

lis = list()

for line in sys.stdin : 
  lis.append(int(line))
  

if (lis[0] - lis[1]) < 0 : 
  print(lis[0] * lis[2])
  
else : 
  sum = lis[1] * lis[2] + (lis[0] - lis[1]) * lis[3]
  print(sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>

using namespace std;

int main(){

    LL N;cin>>N;

    for(int h=1;h<=3500;h++){
        for(int n=1;n<=3500;n++){
            if((4*n*h-N*n-N*h)>0&&(N*h*n)%(4*n*h-N*n-N*h)==0){
                cout<<h<<" "<<n<<" "<<(N*h*n)/(4*n*h-N*n-N*h)<<endl;
                return 0;
            }
        }
    }

    return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  int N,M;cin>>N;vi T(N);rep(i,N)cin>>T[i];cin>>M;
  vi P(M),X(M);rep(i,M)cin>>P[i]>>X[i];
  int tot=0;
  rep(i,N)tot+=T[i];
  
  rep(i,M){
    cout<<tot-T[P[i]-1]+X[i]<<endl;
  
  }
  
}





Measured memory_bytes: 256
from collections import deque

h, w = map(int,input().split())
S = [input() for _ in range(h)]
s = deque([(0,0)])  # サーチstack. 初期条件を設定
e = [[-1] * w for _ in range(h)]  # 探索済みノード集（総数Nを入れる）
e[0][0] = 0

def main():
    while len(s) > 0:  # len(s) > 0 でループ
        t = s.popleft()
        if is_end(t):  # 終了条件を満たすなら脱出
            break
        for i in get_children(t):  # t の子ノードを列挙
            if is_legal(i):  # i が探索対象として適切なら(この判定はget_children内でも可)
                if e[i[0]][i[1]] != -1:  # iが探索済みなら次へ(この判定はget_children内でも可)
                    continue
                s.append(i)
                e[i[0]][i[1]] = e[t[0]][t[1]] + 1 # 探索済としつつ距離を入れる
    cnt = 0
    for x in S:
        cnt += x.count(".")
    end = e[h-1][w-1]
    #printing()
    if end == -1:
        print(-1)
    else:
        print((cnt-2)-(end-1))
    
def printing():
    for i in range(len(e)):
        for j in range(len(e[i])):
            if e[i][j] == -1:
                print(S[i][j], end="")
            else:
                print(e[i][j], end="")
        print("")
    
def is_end(t):
    return t[0] == h-1 and t[1] == w-1

def get_children(t):
    return ((t[0]-1,t[1]),(t[0]+1,t[1]),(t[0],t[1]-1),(t[0],t[1]+1))

def is_legal(i):
    return -1 < i[0] < h and -1 < i[1] < w and S[i[0]][i[1]] == "."

if __name__ == "__main__":
    main()

Measured memory_bytes: 9460
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
};
typedef struct node * Node;

#define NIL NULL

Node root;


void insert(int k){
    Node y = NIL;
    Node x = root;
    Node z;
    
    z = malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while(x!=NIL){
        y=x;
        if(z->key < x->key){
            x=x->left;
        }else{
            x=x->right;
        }
    }
    z->parent=y;
    if(y==NIL){
        root=z;
    }else{
        if(z->key < y->key){
            y->left=z;
        }else{
            y->right=z;
        }
    }
}

void inorder(Node u){
    if ( u == NIL ) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}
void preorder(Node u){
    if ( u == NIL ) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}


Node find(Node u,int k){
    while (u!=NIL && k!= u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

int main(){
    int n, i, x;
    char com[20];
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
        scanf("%s", com);
        if(com[0]=='f'){
            scanf("%d", &x);
            Node t= find(root,x);
            if(t!=NIL) printf("yes\n");
            else printf("no\n");
        }  else  if ( com[0] == 'i' ){
            scanf("%d", &x);
            insert(x);
        } else if ( com[0] == 'p'){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else break;
     
    }
    
    
    
    return 0;
}


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

using namespace std;

const int N=1e5+10;

typedef long long ll;

int n,v[N][2];
vector <int> e[N];
ll sumd[N],g[N],w[N];

int tr[N],q[N];

int sub[N];
void BFS(int st){
   int top=1,bot=1;
   q[1]=st;
   memset(tr,0,sizeof(tr));
   while (top<=bot){
      int x=q[top++];
      for(auto i:e[x]) if (tr[x]!=i){
         int y=v[i][0]+v[i][1]-x;
         tr[y]=i;
         q[++bot]=y;
      } 
   }
}
void solve(){
   BFS(1);
   fill(sub+1,sub+n+1,1);
   for(int i=n;i>=2;i--){
       int x=q[i];
       int par=v[tr[x]][0]+v[tr[x]][1]-x;
       sub[par]+=sub[x];
   }
   int st=-1;
   for(int i=2;i<=n;i++){
       int x=q[i];
       if (2*sub[x]!=n){
           int n1=n-sub[x];
           int par=v[tr[x]][0]+v[tr[x]][1]-x;
//           cout<<x<<" "<<sumd[par]<<" "<<sumd[x]<<" "<<sub[x]<<'\n';
           w[tr[x]]=(sumd[par]-sumd[x])/(sub[x]-n1);
       }else st=x;
   }
   if (st!=-1){
      int rem=tr[st];
      BFS(st);
      fill(sub+1,sub+n+1,1);
      for(int i=n;i>1;i--){
          int x=q[i];
          int par=v[tr[x]][0]+v[tr[x]][1]-x;
          sub[par]+=sub[x];
          g[par]+=g[x]+sub[x]*w[tr[x]];
      }
      w[rem]=(sumd[st]-g[st])/(n/2);
   }
   for(int i=1;i<n;i++) cout<<w[i]<<'\n';
}

int main(){

   cin>>n;
   for(int i=1;i<n;i++){   
        int x,y;
        cin>>x>>y;
        v[i][0]=x;v[i][1]=y;
        e[x].push_back(i);
        e[y].push_back(i);
   }
   for(int i=1;i<=n;i++) cin>>sumd[i];
   solve();
}

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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    int sum = 0;
    for(int i =0; i<n; i++) {
        cin >> d[i];
        sum += d[i];
    }
    int ans = sum;
    int cur = 0;
    for(int i=0; i<n; i++){
        cur += d[i];
        ans = min(ans, abs(sum-cur*2));
    }
    cout << ans << endl;
    return 0;
}

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

int main(void) {
    long n, m;
    cin >> n >> m;
    vector<vector<long>> a(n, vector<long>(m));
    for(auto &l: a)
        for(auto &c: l)
            cin >> c, c--;

    long ok = 300, ng = 0;
    while(ok - ng > 1) {
        long mid = (ok+ng)/2;

        vector<long> idx(n);
        set<long> bad;

        while(1) {
            bool dame = false;

            for(long i=0; i<n; i++) {
                while(idx[i]<m && bad.count(a[i][idx[i]])) idx[i]++;
                if(idx[i] == m) {
                    dame = true;
                    break;
                }
            }
            if(dame) {
                ng = mid;
                break;
            }

            vector<long> cnt(m);
            for(long i=0; i<n; i++)
                cnt[a[i][idx[i]]]++;

            for(long i=0; i<m; i++)
                if(cnt[i] > mid)
                    bad.insert(i), dame = true;
            
            if(!dame) {
                ok = mid;
                break;
            }
        }
    }
    cout << ok << endl;
}


Measured memory_bytes: 1024
#include <iostream>

int main()
{
  int H[100];
  int N;
  std::cin >> N;
  for (int x = 0; x < N; ++x)
    std::cin >> H[x];

  int z = 1;
  int h = H[0];
  for (int x = 1; x < N; ++x)
  {
    if (h <= H[x])
    {
      z++;
    }
    h = H[x] > h ? H[x] : h;
  }
  std::cout << z << std::endl;
}

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

#define ll long long
#define ull unsigned long long 

int main(){
    int n;
    cin >>n;
    vector<int> a(n);
    vector<bool> vis(n, false);

    for(int i=0; i<n; ++i)
        cin>>a[i];

    int count=0;
    for(int i=0; i<n; ++i){
        if(a[a[i]-1] == i+1 && !vis[a[i]-1]){
            count++;
            vis[i] = true;
            vis[a[i]-1]=true;
        }
    }
    cout << count;
}


Measured memory_bytes: 3668
function Main(input) {
	input = input.split(" ");
	var N = parseInt(input[0]);
	var M = parseInt(input[1]);

	var comb_N = (N * (N - 1)) / 2;
	var comb_M = (M * (M - 1)) / 2;

	console.log(comb_N + comb_M);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
    int n;cin>>n;
    string s;cin>>s;
    int ans=n;
    for(int i=0;i+1<n;i++){
        if(s[i]==s[i+1])ans--;
    }
    cout<<ans<<endl;
}

 
    

Measured memory_bytes: 512
n,k=map(int, input("").split(" "))
w=[]
for i in range(n):
    w.append(int(input("")))
s=sum(w)
m=max(w)
while s>m:
    a=0
    b=0
    tmp=int((s+m)/2)
    for i in w:
        a+=i
        if a>tmp:
            a=i
            b+=1
    if b>=k:
        m=tmp+1
    else:
        s=tmp
print(m)


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

bool judge() {
    int n, m, x, y; cin >> n >> m >> x >> y;
    int a, b, z=x;
    for(int i=0;i<n;++i) {
        cin >> a;
        z = max(z, a);
    }
    ++z;
    if (z>y) {
        return false;
    }
    for(int j=0;j<m;++j){
        cin >> b;
        if(z>b) return false;
    }
    return true;
}

int main(int argc, char const *argv[])
{
    cout << (judge()? "No War": "War") << endl;
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll K, X;
    cin >> K >> X;
    rep2(i, X - K + 1, X + K) cout << i << endl;
    return 0;
}


Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		long size = s.nextInt();
		long returnInt = 0;
		long[] cards = new long[(int) size];
		long sum = 0;
		for (int i = 0; i < cards.length; i++) {
			cards[i] = s.nextInt();
			sum += cards[i];
		}
		long min = Long.MAX_VALUE;
		long tmpSum = 0;
		if (size == 2){
			returnInt = (int)Math.abs(cards[0]  - cards[1]);
		}else{
			for (int i = 0; i < cards.length-1; i++) {
				tmpSum += cards[i];
				if(Math.abs(2 *tmpSum  - sum) < min){
					min = Math.abs(2 *tmpSum  - sum);
				}
			}
			returnInt = (int) (min);
		}			
		System.out.println(returnInt);
	}
}


Measured memory_bytes: 84764
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;



int main(void){
    int n;
    cin >> n;
    if(n%1000==0)
        cout << 0 << endl;
    else
        cout << abs(1000-n%1000) << endl;
    return 0;
}

Measured memory_bytes: 3604
// abc059_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    string ans;
    ans += s1.substr(0, 1);
    ans += s2.substr(0, 1);
    ans += s3.substr(0, 1);
    transform(ans.begin(), ans.end(), ans.begin(), ::toupper);
    print(ans);

    return 0;
}


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

vector<long long> v;

// パスカルの三角形は解答そのまま
// Combination Table
long long C[51][51]; // C[n][k] -> nCk

void comb_table(int N)
{
    for (int i = 0; i <= N; ++i)
    {
        for (int j = 0; j <= i; ++j)
        {
            if (j == 0 or j == i)
            {
                C[i][j] = 1LL;
            }
            else
            {
                C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
            }
        }
    }
}

int main()
{

    
    int n = 0;
    int a = 0;
    int b = 0;

    // 読み取り
    cin >> n >> a >> b;

    v.resize(n);

    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    comb_table(n);
    sort(v.begin(), v.end());

    int countAll = upper_bound(v.begin(), v.end(), v[n - a]) - lower_bound(v.begin(), v.end(), v[n - a]);
    int countUntilA = a - (v.end() - upper_bound(v.begin(), v.end(), v[n - a]));

    long long count = 0;
    if (v[n - a] == v[n - 1]){
        for(int i = countUntilA; (i <= countAll && i <= b ); ++i){
            count += C[countAll][i];
        }
    }else{
        count = C[countAll][countUntilA];
    }

    std::cout << std::fixed;
    cout << (double)std::accumulate(v.end() - a, v.end(), 0.0) / a << endl;
    //cout << countAll << " " << countUntilA << endl;
    cout << count << endl;

    return 0;
}

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

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

	ll k, a, b;
	cin >> k >> a >> b;
	// Hit pocket: +1
	// Exchange: A -> B (2 ops)
	ll res = 1;

	ll cou = min(k, a-1);
	res += cou;
	k -= cou;

	if (b - a > 2) {
		res += (b - a) * (k / 2);
		res += k % 2;
	} else {
		res += k;
	}
	cout << res << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int main(){
	int n, mx = -1, mxi, a, b;
	cin >> n;
	rep(i, n){
		cin >> a >> b;
		if(mx < b || mx == b && mxi > a) mx = b, mxi = a;
	}
	cout << mxi << " " << mx << endl;
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
string s, ans = "ABC";
int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> s;
    if(s == "ABC") {
  	    ans = "ARC";
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3576
//?????????????????¶??????????????????

#include <stdio.h>

int main()
{
	int n,a[100],count=0,i,k,memo;
	scanf("%d",&n);
	for(i = 0; i < n; ++i)
	{
		scanf("%d",&a[i]);
    }

	for (i = 0; i < n; ++i)
	{
		for (k = n-1; k > i; --k)
		{
			if(a[k]<a[k-1]){memo=a[k];a[k]=a[k-1];a[k-1]=memo;count++;}
		}
	}

	for (i = 0; i < n-1; ++i)
	{
			printf("%d ", a[i]);
	}
	printf("%d\n%d\n", a[n-1], count);
	
	return 0;
}

Measured memory_bytes: 1852
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
#include <tuple>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
struct Item
{
	unsigned v;
	int t;
	int x;
	int y;
	Item(unsigned V, int T, int X, int Y):
		v(V),t(T),x(X),y(Y){
		}
};

struct comp
{
	bool operator()(Item& a, Item& b){
		return a.v > b.v;
	}
};

unsigned table[6][201][201];
bool ng[201][201];
int xs[1000];
int ys[1000];
int sx,sy,gx,gy,n,lx,ly;
int main() {
	memset(table,-1,sizeof(table));
	cin >> sx >> sy >> gx >> gy >> n;
	for(int i=0;i<n;i++){
		cin >> xs[i] >> ys[i];
	}
	cin >> lx >> ly;
	sx+=lx;sy+=ly;gx+=lx;gy+=ly;
	for(int i=0;i<n;i++){
		ng[xs[i]+lx][ys[i]+ly]=true;
	}
	int dx[2][7]={{0,1,1,0,-1,-1,0},{0,1,1,0,-1,-1,0}};
	int dy[2][7]={{1,0,-1,-1,-1,0,0},{1,1,0,-1,0,1}};
	priority_queue<Item,vector<Item>,comp> q;
	table[0][sx][sy]=0;
	q.push(Item(0,0,sx,sy));
	while(q.size()){
		Item a=q.top();
		q.pop();
		if(table[a.t][a.x][a.y]<a.v)continue;
		//cout << "pop " << a.t << ", " << a.x -lx<< ", " << a.y -ly<< ": " << a.v << endl;
		int order=abs(a.t*(a.x-lx)*(a.y-ly))%6;
		int t=(a.t+1)%6;
		int p=abs(a.x-lx)%2;
		for(int i=0;i<7;i++){
			int x=a.x+dx[p][i];
			int y=a.y+dy[p][i];
			if(x<0||2*lx<x||y<0||2*ly<y||ng[x][y])continue;
			unsigned v=a.v;
			if(order!=i){
				v++;
			}
			if(v<table[t][x][y]){
				table[t][x][y]=v;
				q.push(Item(v,t,x,y));
				//cout << t << ", " << x -lx<< ", " << y -ly<< ": " << v << endl;
			}
		}
	}
	unsigned ret=-1;
	for(int i=0;i<6;i++){
		ret=min(ret, table[i][gx][gy]);
	}
	cout << (int)ret << endl;
}

Measured memory_bytes: 2324