akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll INF = 1LL << 60;
int MOD = 1e9+7;
main(){
    ll H,W;
    cin >> H >> W;
    ll mindif = INF;
    for(int i = 1;i < H;i++){
        ll h = H - i,w = W;
        vector<ll> s(3);
        s[0] = i * W;
        s[1] = (h/2) * w;
        s[2] = h * w - s[1];
        sort(s.begin(),s.end());
        if(s[0])mindif = min(mindif, s[2] - s[0]);
        s[0] = i * W;
        s[1] = (w/2) * h;
        s[2] = h * w - s[1];        
        sort(s.begin(),s.end());
        if(s[0])mindif = min(mindif, s[2] - s[0]);
        
    }
        for(int i = 1;i < W;i++){
        ll h = H,w = W - i;
        vector<ll> s(3);
        s[0] = H * i;
        s[1] = (h/2) * w;
        s[2] = h * w - s[1];
        sort(s.begin(),s.end());
        if(s[0])mindif = min(mindif, s[2] - s[0]);
        s[0] = H * i;
        s[1] = (w/2) * h;
        s[2] = h * w - s[1];
        sort(s.begin(),s.end());
        if(s[0])mindif = min(mindif, s[2] - s[0]);
        
    }
    cout << mindif << endl;
}

Measured memory_bytes: 256
chrs = ["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"]
array = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
while str = gets do
    str = str.chomp.downcase
    break if str.length == 0
    chrs.each_with_index do |chr, index|
        array[index] += str.count(chr)
    end
end
chrs.each_with_index do |chr, index|
    puts chr + " : " + array[index].to_s
end

Measured memory_bytes: 8644
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};

int main(){
  string S,T,a;
  bool f=true;
  cin>>S>>T;
  a=S;
  reverse(S.begin(),S.end());
  reverse(T.begin(),T.end());
  for(int i=0;i<S.size()&&f;i++){
    int cnt=0;
    for(int j=0;j<T.size()&&i+j<S.size();j++){
      if(S[i+j]==T[j]||S[i+j]=='?') cnt++;
      if(cnt==T.size()){
        for(int k=0;k<T.size();k++) S[i+k]=T[k];
        f=false;
        break;
      }
    }
    if(f&&i==S.size()-1){
      cout<<"UNRESTORABLE"<<endl;
      return 0;
    }
  }
  reverse(S.begin(),S.end());
  for(int i=0;i<S.size();i++){
    if(S[i]=='?') cout<<'a';
    else cout<<S[i];
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));
    reverse(all(a));
    int b = 0, al = 0;
    for(int i = 0; i < n; i+= 2) {
        al += a[i];
        b += a[i+1];
    }

    cout << al - b << endl;

    return 0;
}

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

int main(){
  vector<ll> v;
  ll n,k; cin>>n>>k;
  vector<pair<ll,ll>> ab(n);
  for (ll i = 0; i < n; i++)
  {
    cin >> ab.at(i).first >> ab.at(i).second;
  }
  sort(ab.begin(),ab.end());

  ll sum = 0;
  ll ans = 0;

  

  for (ll i = 0; i < n; i++)
  {
    sum += ab.at(i).second;
    if(k <= sum)
    {
      ans = i;
      break;
    }
  }

  
  cout << ab.at(ans).first << endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const int MOD = 1e9 + 7;

int main() {

  ll N;
  int K;
  cin >> N >> K;

  int cnt = 0;
  while (N > 0) {
    N /= K;
    cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  if(N==1) {
    cout<<"First"<<endl;
    return 0;
  }
  vector<vector<int> > edge(N);
  int a, b;
  for(int i=0;i<N-1;++i) {
    cin>>a>>b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  queue<pair<int, int> > que;
  que.push(mp(0, 0));
  pair<int, int> state;
  map<int, int> amap;
  for(int i=0;i<N;++i) amap[i] = -1;
  amap[0] = 0;
  while(!que.empty()) {
    state = que.front();que.pop();
    for(int i=0;i<edge[state.fi].size();++i) {
      if(amap[edge[state.fi][i]]>-1) continue;
      que.push(mp(edge[state.fi][i], state.se+1));
      amap[edge[state.fi][i]] = state.se+1;
    }
  }
  int ans = 0;
  int node;
  for(int i=0;i<N;++i) {
    if(ans<amap[i]) {
      ans = amap[i];
      node = i;
    }
  }
  que.push(mp(node, 0));
  for(int i=0;i<N;++i) amap[i] = -1;
  amap[node] = 0;
  while(!que.empty()) {
    state = que.front();que.pop();
    for(int i=0;i<edge[state.fi].size();++i) {
      if(amap[edge[state.fi][i]]>-1) continue;
      que.push(mp(edge[state.fi][i], state.se+1));
      amap[edge[state.fi][i]] = state.se+1;
    }
  }
  for(int i=0;i<N;++i) {
    ans = max(ans, amap[i]);
  }
  ans++;
  if(ans%3==2) cout<<"Second"<<endl;
  else cout<<"First"<<endl;
}



Measured memory_bytes: 26056
N = int(input())
ans = set()
import math

rootN = math.ceil(math.sqrt(N))

for A in range(1, rootN+1):
  if N % A == 0:
    B = int(N / A)
    ans.add(max(len(str(A)), len(str(B))))
  else:
    pass
print(min(ans))

Measured memory_bytes: 9072
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> A;
map<int,bool> used;
map<int,int> cnt;
void input(){
    fast_io();
    cin >> N;
    A = fetch_vec<int>(N);
    for(auto a:A) {
        used[a] = true;
        cnt[a]++;
        }
}

vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int solve(){
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        auto div = divisor(A[i]);
        bool chk = true;
        for(int d:div){
            if(cnt[A[i]]==1 && d==A[i]) continue;
            if(used[d]){
                chk = false;
                break;
            }
        }
        if(chk) ans++;
    }
    cout << ans << endl;
    return 0;
}   

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

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



int main(){
    int N;
    cin >> N;
    
    vector<int> A(N), B(N), C(N);
    for(int i=0;i<N;i++){
        cin >> A.at(i);
    }
    for(int i=0;i<N;i++){
        cin >> B.at(i);
    }
    for(int i=0;i<N-1;i++){
        cin >> C.at(i);
    }
    vector<int> vec;
    vec.reserve(N);
    
    for(int i=0; i<N-1; i++){
        if(A.at(i)==A.at(i+1)-1){
            vec.push_back(A.at(i)-1);
        }
    }
    int ans;
    int B_sum=0, C_sum=0;
    B_sum=accumulate(B.begin(), B.end(),0);
    for(int x:vec){
        C_sum+=C.at(x);
    }
    ans=B_sum+C_sum;
    cout << ans << endl;
}

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string s;

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

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

int main(void){
  ll A, B;
  IN(A);
  IN(B);
  PRINT(lcm(A, B));
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 205
using namespace std;
typedef long long ll;
typedef double db;
int n,A[N],B[N],C[N],D[N],h[N],cnt,p[N];
bool vis[N];
struct Edge{int to,Next;}e[N*N];
void adde(int x,int y){e[++cnt].to=y,e[cnt].Next=h[x],h[x]=cnt;}
bool dfs(int u)
{
	for(int i=h[u];i;i=e[i].Next)
	{
		int v=e[i].to;
		if(vis[v]) continue;
		vis[v]=1;
		if(!p[v]||dfs(p[v])) {p[v]=u;return 1;}
	}
	return 0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d%d",&A[i],&B[i]);
	for(int i=1;i<=n;++i) scanf("%d%d",&C[i],&D[i]);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			if(A[i]<C[j]&&B[i]<D[j]) adde(i,j+n);
	int ans=0;
	for(int i=1;i<=n;++i)
	{
		memset(vis,0,sizeof(vis));
		if(dfs(i)) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
    using namespace std;
    size_t N;
    cin >> N;
    deque<pair<size_t, size_t>> bef, aft;
    vector<size_t> ans(N * N), a(N);
    for(size_t i = 0, A; i < N;){
        cin >> A;
        if(i)for(size_t j = 0; j < i; ++j)bef.emplace_back(A, i + 1);
        if(++i != N)for(size_t j = i; j < N; ++j)aft.emplace_back(N * N - A, i);
        ans[A - 1] = i;
    }
    sort(bef.begin(), bef.end());
    sort(aft.begin(), aft.end());
    size_t cnt{};
    auto f = [&bef, &cnt](auto& i){
        ++cnt;
        if(i)return;
        if(bef.empty())return;
        if(bef.front().first < cnt)return;
        i = bef.front().second;
        bef.pop_front();
    };
    for_each(ans.begin(), ans.end(), f);
    if(!bef.empty())return !puts("No");
    cnt = 0;
    swap(bef, aft);
    for_each(ans.rbegin(), ans.rend(), f);
    if(!bef.empty())return !puts("No");
    puts("Yes");
    copy(ans.cbegin(), ans.cend(), ostream_iterator<size_t>(cout, " "));
}

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

int main(void) {

    int X;
    cin >> X;

    int rad = 360;

    int res = rad % X;
    while (res != 0) {
        rad += 360;        
        res = rad % X;
    }

    int ans = rad / X;


    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3132
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = input[0];
            var D = input[1];

            var X = new double[N][];
            for (int i = 0; i < N; i++)
            {
                X[i] = Console.ReadLine().Split().Select(double.Parse).ToArray();
            }

            var cnt = 0;
            for (int i = 0; i < N - 1; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    var d = Distance(X[i], X[j]);
                    if ((int)d == d) cnt++;
                }
            }

            Console.WriteLine(cnt);
        }

        static double Distance(double[] x, double[] y)
        {
            return Math.Sqrt(x.Zip(y, (s, t) => (s - t) * (s - t)).Sum());
        }
    }
}

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

using ll = long long;

int main() {
    ll N, T, Q; cin >> N >> T >> Q;
    vector<ll> A(N), D(N);
    for(int i = 0; i < N; ++i) {
        cin >> A[i] >> D[i];
    }

    vector<ll> ans(N);
    deque<int> deq;
    int i = 0;
    while(i < N) {
        if(D[i] == 2) { // west
            if(!deq.empty() && D[deq.back()] == 1) {
                ll mid = (A[deq.back()] + A[i]) / 2;
                while(i < N && D[i] == 2) {
                    deq.push_back(i++);
                }
                for(auto j : deq) {
                    ans[j] = (abs(mid - A[j]) <= T ? mid : A[j] + (D[j] == 2 ? -T : T));
                }
                deq.clear();
            } else {
                ans[i] = A[i] - T;
                i++;
            }
        } else {
            deq.push_back(i++);
        }
    }
    for(auto j : deq) {
        ans[j] = A[j] + T;
    }

    for(int i = 0; i < Q; ++i) {
        int X; cin >> X;
        cout << ans[X - 1] << endl;
    }
}



Measured memory_bytes: 5568
#include <cstdio>
#include <cstring>
using namespace std;
#define ll long long
#define N 60
const ll MOD = 1000000007;
ll f[1<<17];
ll pow_mod(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b&1) ans = ans * a % mod;
		b >>= 1;
		a = a * a % mod;
	}
	return ans % mod;
}
int main()
{
	int n, m;
	long long ans = 1;
	scanf("%d%d", &n, &m);
	f[0] = 1;
	for(int i = 1; i < 1 << 17; i++) f[i] = f[i-1] * i % MOD;
	for(int i = 2; i * i <= m; i++)
	{
		int cnt = 0;
		if(m % i) continue;
		while(m % i == 0)
		{
			cnt++;
			m /= i;
		}
		ans = ans * f[n+cnt-1] % MOD * pow_mod(f[n-1], MOD-2, MOD) % MOD * pow_mod(f[cnt], MOD-2, MOD) % MOD;
	}
	if(m > 1)
	{
		ans = ans * n % MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1152
S = input()
T = ""
K = int(input())
for s in S:
    x = (123 - ord(s))%26
    if K >= x:
        s = "a"
        K -= x
    T += s

K = K%26
ans = ""
for t in T[::-1]:
    d = min(K, 122 - ord(s))
    K -= d
    ans += chr(ord(t)+d)

print(ans[::-1])

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF  2000000000
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<<endl;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
#define SUM(a, n) accumulate(a, a+n, 0)
#define VSUM(v) accumulate(ALL(v), 0);
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

signed main(){ INIT;
    VAR(int, n);
    OUTL(24+24-n);
RET;}

Measured memory_bytes: 892
#include <stdio.h>


int main(void)
{
  int a,b;
  char op;
  
  
  while( scanf("%d %c %d", &a, &op, &b), op != '?' )
  {
    switch( op ){
      case '+': printf("%d\n", a+b); break;
      case '-': printf("%d\n", a-b); break;
      case '*': printf("%d\n", a*b); break;
      case '/': printf("%d\n", a/b); break;
    }
  
  }
  
  
  return 0;
  
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, s, n) for (int i = s; i < (int)n; i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << " "
#define debugl(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	string S; cin >> S;
	int ans = 0, temp = 0;
	set<char> ACGT = { 'A', 'C', 'G', 'T' };
	for (char c : S) {
		if (ACGT.count(c)) {
			temp++;
		} else {
			ans = max(ans, temp);
			temp = 0;
		}
	}
	ans = max(ans, temp);
	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

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

	for (int i = 1; i < 10; ++i)
	{
		if((n % i == 0) && (n/i < 10 && n/i > 0))
		{
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";

}

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

int main() {

  int a,b,c,d,sum;
  string s,t;
  cin>>a>>b>>c;
 d=0;
  for(int i=min(a,b);i>0;i--){
  	if(a%i==0 && b%i==0){
    	d++;
      if(d==c){
      	sum =i;
        break;
      }
    }
  }
  
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;

template<class T>
T read()
{
    T value;
    std::cin >> value;
    return value;
}
 
template<class F>
void times_do(size_t n, F func)
{
    for(size_t i = 0; i < n; ++i) func();
}
 
template<class T>
vector<T> reads(size_t n)
{
    vector<T> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(read<T>());
    });
    return a;
}


int main()
{
    auto n = read<int>();
    if(n%2==0)
    {
        cout << "0.5\n";
    }
    else
    {
        cout << ((n-1)*0.5 + 1) / n << '\n';
    }
    return 0;
}


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

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;
string s;
set<char> sett;

int main() {
		
	cin >> s;
	for(int i = 0; i < s.sz; i++) sett.insert(s[i]);
	if(sett.sz == s.sz) {
		cout << "yes";
	} else {
		cout << "no";
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s; i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main(){
    string s; cin >> s;
    string ans = "Yes\n";
    int l = s.length();
    REP(i, l){
        if(i%2==0 && s[i]=='L') ans = "No\n";
        if(i%2==1 && s[i]=='R') ans = "No\n";
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
def examA():
    S = SI()
    ans = "No"
    flag = False
    for s in S:
        if flag:
            if s=="F":
                ans = "Yes"
                break
        else:
            if s=="C":
                flag = True
    print(ans)
    return

def examB():
    K, T = LI()
    A = LI(); A.sort()
    ans = max(0,A[-1]*2-sum(A)-1)
    print(ans)
    return


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int a,b,k;
	set<int> s;
	cin>>a>>b>>k;
	int c,d;
	c=a;
	d=b;
	for (int i = 0; i <k ; ++i)
		{
			if(a<=d)
			s.insert(a++);
			if(b>=c)
			s.insert(b--);
		}	

	for (auto e:s)
	{
		cout<<e<<endl;
	}
   return 0;
}


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

int main() {
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k){
        cout << s << endl;
        return 0;
    }
    rep(i, k){
        cout << s[i];
    }
    cout << "...";

    return 0;
}

Measured memory_bytes: 3628
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var one = cin.ReadLine.Split(' ');
            var two = cin.ReadLine.Split(' ');
            var N = int.Parse(one[0]);
            var W = int.Parse(one[1]);
            var n = int.Parse(two[0]);
            var w = int.Parse(two[1]);

            var result = (N - n) * (W - w);
            Console.Write(result);
        }

    }
    public class deci
    {
        public bool IsFinish { get; set; } = false;
        public int Len { get; set; }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

m=min(a,b,c,d,e)
M=max(a,b,c,d,e)

if  M-m>k:
  print(":(")
else:
  print("Yay!")
  
  
  



Measured memory_bytes: 3060
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int X = Integer.parseInt(strSplit[0]);
            int Y = Integer.parseInt(strSplit[1]);
            
            for(int i=0; i<=X; i++){
                for(int j=0; j<=X-i; j++){
                    if(i*2+j*4 == Y && i+j == X){
                        System.out.println("Yes");
                        return;
                    }
                }
            }
            
            System.out.println("No");
            
        }catch(Exception e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 32616
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str; 
  cin >> str;// 文字列を定義した
  while(str[0]!='0'){     // 文字列において0が表れるまでwhile文を繰り返す。
    int i,o=0;
     
    for(i=0;i<str.size();i++){
      o+=str[i]-'0';    //
    }
    cout << o << endl;
    cin >> str;
  }
  return 0;
}



Measured memory_bytes: 3204
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    int X;
    int T;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
        this.X = sc.nextInt();
        this.T = sc.nextInt();
    }
    
    //解答処理
    private long solve() {
        long answer = T;
        int takoyaki = 0;
        
        for (int i=1; takoyaki<N; i++) {
        		answer = T * i;
        		takoyaki += X;
        }
        
        return answer;
    }
    
    //出力
    public void show(long answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35684
fn main() {
    let s: String = read();
    let s: Vec<char> = s.chars().collect();
    let mut count = 0;
    for c in s {
        if c == '1' { count += 1; }
    }
    println!("{}", count);
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int f(int i, int K) {
    int cnt = 0;
    while (i < K) {
        ++cnt;
        i *= 2;
    }
    return cnt;
}

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

    double ans = 0.0;
    for (int i = 1; i <= N; ++i) {
        ans += 1.0 / (double)(N << f(i, K));
    }

    printf("%.10lf", ans);
    
    return 0;
}

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

using ll = long long;

const ll p = 998244353LL;

ll fac[200001];
ll inv_fac[200001];

ll mod_exp(ll a, ll b)
{
	if(b==0LL) return 1LL;

	ll ans = mod_exp(a,ll(b/2LL));
	ans*=ans;
	ans%=p;

	if(b%2LL==1LL) ans*=a;
	ans%=p;

	return ans;
}

ll C(int n, int k)
{
	ll ans = fac[n]*inv_fac[k];
	ans%=p;
	return (ans*inv_fac[n-k])%p;
}

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	fac[0]=1LL;
	inv_fac[0]=1LL;

	for(int i=1; i<=200000; i++)
	{
		fac[i] = ll(i)*fac[i-1];
		fac[i] %= p;

		inv_fac[i] = mod_exp(fac[i],p-2LL);
		// if(i<10) cout << i << " " << fac[i] << " " << inv_fac[i] << endl;
	}

	int n,m,k;
	cin>>n>>m>>k;

	ll ans=0LL;

	for(int a=0; a<=k; a++)
	{
		// a adjacencies exactly

		// (n-1 choose a) * m * (m-1)^(n-a-1)

		ll cur = C(n-1,a)*ll(m);
		cur %= p;

		cur*=mod_exp(m-1,n-a-1);
		cur %= p;

		ans += cur;
		ans %= p;
	}

	cout << ans << endl;
}

Measured memory_bytes: 6796
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.List.Split (splitOn)

main :: IO ()
main = do
  xs <- getc $ map toInt . splitOn ","
  print $ solve xs

solve :: [[Int]] -> Int
solve xs = maxpath [] xs

maxpath :: [Int] -> [[Int]] -> Int
maxpath xs [] = head xs
maxpath xs (y:ys)
  | length xs > length y = maxpath (zipWith (+) (f xs) y) ys
  | otherwise = maxpath (zipWith (+) (g xs) y) ys
  where
    f zs = zipWith max zs (tail zs)
    g [] = [0]
    g zs = (head zs : f zs) ++ [last zs]
    
toInt :: String -> Int
toInt s = read s

getc :: (String -> a) -> IO [a]
getc f = map f . lines <$> getContents

Measured memory_bytes: 4836
#include <iostream>

using namespace std;

int main() {

    int a, b;
    cin >> a >> b;

    if(a < b) {
        for(int i = 0; i < b; i++) cout << a;
    } else {
        for(int i = 0; i < a; i++) cout << b;
    }
    cout << endl;

    return 0;
}

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

vector<int> to[200001];
vector<int> ans;

void dfs(int x, int y){
  for(int u : to[x]){
    if(u == y) continue;
    ans[u] += ans[x];
    dfs(u, x);
  }
}

int main(){
  int n, q;
  cin >> n >> q;
  
  rep(i, n-1){
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  
  rep(i, q){
    int p, x;
    cin >> p >> x;
    --p;
    ans[p] += x;
  }
  
  dfs(0, -1);
  
  rep(i, n) cout << ans[i] << " ";
  cout << endl;
}

Measured memory_bytes: 23552
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll MOD=1000000007;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

using Graph=vector<vector<int>>;

vector<bool> seen;
void dfs(const Graph &G,int v){
   seen[v]=true;
   for(auto next_v:G[v]){
      if(seen[next_v]) continue;
      dfs(G,next_v);
   }
}

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

   Graph G(n);

   rep(i,m){
      int a,b;
      cin>>a>>b;
      G[a-1].push_back(b-1);
      G[b-1].push_back(a-1);
   }   

   int count=0;
   seen.assign(n,false);

   rep(v,n){
      if(seen[v]) continue;
      dfs(G,v);
      count++;
   }

   cout<<count-1<<endl;

   

   return 0;
}



Measured memory_bytes: 9596
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const ll MOD = 1000000007;
// const int INF = 2000000000;

int N;
string S;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> S;

  string prefix = "";
  string suffix = "";

  int c = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == '(') {
      c++;
    } else {
      if (c == 0) {
        prefix += "(";
      } else {
        c--;
      }
    }
  }

  c = 0;
  for (int i = N - 1; i >= 0; i--) {
    if (S[i] == ')') {
      c++;
    } else {
      if (c == 0) {
        suffix += ")";
      } else {
        c--;
      }
    }
  }

  cout << prefix << S << suffix << endl;
  return 0;
}

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

int main() {
  int N , count = 0 , box , sum1 = 0 , sum2 = 0 ;
  cin >> N ;
  vector<int> card(N);
  for ( int i = 0 ; i < N ; i++ ){
    cin >> card.at(i);
  }
  while (true){
    count = 0;
    for ( int i = 0 ; i < N-1 ; i++ ){
      if ( card.at(i) < card.at(i+1) ){
        box = card.at(i);
        card.at(i) = card.at(i+1);
        card.at(i+1) = box;
        count++;
      }
    }
    if ( count == 0 ){
      break;
    }
  }
  for ( int i = 0 ; i < N ; i += 2 ){
    sum1 += card.at(i);
  }
  for ( int i = 1 ; i < N ; i += 2 ){
    sum2 += card.at(i);
  }
  cout << sum1 - sum2 << endl;
}

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

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

  int score=1;

  for(int i=0; i<N; i++){

    int A,B;

    A=score*2; B=score+K;

    if(A<B){
      score=A;
    }else{
      score=B;
    }
  }

  cout<<score<<endl;

  return 0;

}
  

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  for(double i=0;i<=1000;i++){
    if((int)(i*0.08)==a && (int)(i*0.1)==b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
// author: Saman Mahdanian
#include <bits/stdc++.h>
using namespace std;
pair <int, int> a[200 * 1000 + 10];
int n;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i].second >> a[i].first;
	sort(a, a + n);
	long long t = 0;
	for (int i = 0; i < n; i++)
		if ((t += a[i].second) > a[i].first)
			return cout << "No" << endl, 0;
	cout << "Yes" << endl;
}

// SamMHD :: Jun27-2019 :: Another Day with Shayan...

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<28;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,K;cin>>N>>K;
    vector<double> A(N+1);
    for(int i=0;i<N;i++){
        cin>>A[i+1];
        A[i+1]=(1.0+A[i+1])/2.0;
    }
    
    for(int i=1;i<=N;i++) A[i]+=A[i-1];
    
    double ans=0.0;
    
    for(int i=0;i+K<=N;i++) ans=max(ans,A[i+K]-A[i]);
    
    cout<<setprecision(25)<<ans<<endl;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    int n; cin >> n;
    bool flag = false;
    rep1(i,9){
        rep1(j,9){
            if(i * j == n){ flag = true; break;}
        }
    }
    cout << (flag? "Yes" : "No");
    return 0;
}



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

int main() {
	int a,b,c,x,y,d;
	cin >> a >> b >> c >> x >> y;
	if(a+b<=(2*c))
		d=(x*a)+(y*b);
	else{
		if(x==y)
			d=(2*c)*x;
		else if(x>y && a<=(2*c))
			d=((2*c)*y)+(x-y)*a;
		else if(x>y && a>(2*c))
			d=((2*c)*y)+(x-y)*(2*c);
		else if(y>x && b<=(2*c))
			d=((2*c)*x)+(y-x)*b;
		else if(y>x && b>(2*c))
			d=((2*c)*x)+(y-x)*(2*c);
	}
	cout << d;
	// your code goes here
	return 0;
}

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

using namespace std;

#define fastio cin.tie(NULL);cout.tie(NULL);ios_base::sync_with_stdio(0);
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define MAXN 100005
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define pb push_back
#define int long long
#define endl '\n'

typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <pii> vii;
typedef vector <vi> matriz;
typedef vector <pair <string, int>> vis;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// auto timer_start = chrono::steady_clock::now().time_since_epoch().count();

int a, b, c, l, m, n, k;
string s, t;

int32_t main(){
    fastio
    cin >> s >> t;
    int c = 0;
    for(int i = 0; i < sz(s); i++) c += (s[i] != t[i]);
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 3740
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String c = scan.nextLine();
		if(c.substring(0,1).equals("a") || c.substring(0,1).equals("i") || c.substring(0,1).equals("u") || c.substring(0,1).equals("e")  || c.substring(0,1).equals("o")) {
			System.out.println("vowel");
		} else {
			System.out.println("consonant");
		}
		scan.close();

	}

}


Measured memory_bytes: 23508
using System;
class p
{
  static void Main()
  {
    string[] arr = Console.ReadLine().Split(' ');
    int N = int.Parse(arr[0]);
    arr = new string[N];
    for (int i = 0; i < N; i++) {
      arr[i] = Console.ReadLine();
    }
    Array.Sort(arr);
    Console.WriteLine(string.Join("", arr));
  }
}

Measured memory_bytes: 11360
#include<stdio.h>
int liserch(int*,int,int);
int main(){
  int s[10000],t[500],i,j,a,b,k=0;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&t[i]);
    k+=liserch(s,t[i],a);
  }
  
  printf("%d\n",k);
  return 0;
}
int liserch(int *s,int t,int n){
  int i;
  for(i = 0;i < n;i++){
    if(s[i] == t){
      return 1;
    }
  }
  return 0;
}



Measured memory_bytes: 2768
P = 10**9+7
fa = [1]
for i in range(1, 1010): fa.append(fa[-1] * i % P)
fainv = [pow(fa[-1], P-2, P)]
for i in range(1, 1010)[::-1]: fainv.append(fainv[-1] * i % P)
fainv = fainv[::-1]

k = 70
kk = 1<<k
nu = lambda L: int("".join([bin(kk+a)[-k:] for a in L[::-1]]), 2)
st = lambda n: bin(n)[2:] + "0"
li = lambda s: [int(a, 2) % P if len(a) else 0 for a in [s[-(i+1)*k-1:-i*k-1] for i in range(N+1)]]

N, K = map(int, input().split())
A = [int(a) for a in input().split()]
X = [fa[N]] + [0] * N
for a in A:
    X = li(st(nu(X) * nu([fainv[i] * fa[N-i] * fainv[a-i] * fainv[N-a] % P if i <= a else 0 for i in range(N+1)])))

print(X[-1])

Measured memory_bytes: 3744
#include <iostream>

using namespace std;

int main(void){
  int R,L,d;
  cin>>L>>R>>d;
  int ans=0;
  for(int i=L;i<R+1;i++){
    if(i%d==0)ans++;
  }
  cout<<ans<<endl;
  return 0; 
}


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

int main() {
  string a[2]; cin >> a[0]>> a[1];
  sort(a, a+2);
  int roop = stoi(a[1]);
  string ans = a[0];
  for (int i=0; i<roop-1; i++) {
    ans += a[0];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a =sc.nextInt();
    int b =sc.nextInt();
    System.out.println(a+b/2);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
 
int main(){
  int n;
  cin >> n;
  map<int,int> mp;
  int free = 0;
  rep(i,n) {
    int a;
    cin >> a;
    if (a < 400) mp[0] = 1;
    else if (a < 800) mp[1] = 1;
    else if (a < 1200) mp[2] = 1;
    else if (a < 1600) mp[3] = 1;
    else if (a < 2000) mp[4] = 1;
    else if (a < 2400) mp[5] = 1;
    else if (a < 2800) mp[6] = 1;
    else if (a < 3200) mp[7] = 1;
    else free++; 
  }
  cout << (!mp.empty() ? mp.size() : 1) << " " << mp.size() + free << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define int long long 
using namespace std;
struct Edge{
	int u,v,w;
	Edge(){}
	Edge(int u,int v,int w):u(u),v(v),w(w){}
	friend bool operator<(Edge a,Edge b)
	{
		return a.w<b.w;
	}
};
const int size=1e5+5;
Edge edges[size];
int val[size];
int sum[size];
int cnt[size];
int fa[size];
int find(int x)
{
	if(x==fa[x]) return x;
	int f=find(fa[x]);
	sum[f]+=sum[x];
	sum[x]=0;
	cnt[f]+=cnt[x];
	cnt[x]=0;
	return fa[x]=f;
}
void merge(int fx,int fy)
{
	if(fx==fy)
		cnt[fy]++;
	else 
	{
		sum[fy]+=sum[fx];
		sum[fx]=0;
		cnt[fy]=cnt[fy]+cnt[fx]+1;
		cnt[fx]=0;
		fa[fx]=fy;
	}
}
int32_t main()
{
	int n,m;
	int ans=0;
	memset(cnt,0,sizeof(cnt));
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++) scanf("%lld",&val[i]),fa[i]=i,sum[i]=val[i];
	for(int i=1;i<=m;i++) scanf("%lld%lld%lld",&edges[i].u,&edges[i].v,&edges[i].w);
	sort(edges+1,edges+1+m);
	for(int i=1;i<=m;i++)
	{
		int x=find(edges[i].u),y=find(edges[i].v);
		merge(x,y);
		if(edges[i].w<=sum[y])
		{
			ans+=cnt[y];
			cnt[y]=0;
		}
	}
	printf("%lld\n",m-ans);
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  ll a,b;
  cin >> a >> b;
  string ans = "";
  if(a>0 && b>0) ans = "Positive";
  else if(a*b <= 0) ans = "Zero";
  else{
    if((b-a)%2 == 1) ans = "Positive";
    if((b-a)%2 == 0) ans = "Negative";
  }
  cout << ans << endl;
}

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

int main(){
    ll N;
    cin >> N;
    int array[N];
    rep(i, 0, N) array[i] = i;

    double x[N], y[N];
    rep(i, 0, N) cin >> x[i] >> y[i];

    double ans = 0, cnt = 0;
    do{
        cnt += 1;
        for(int i = 0; i < N; i++){
            if(i == 0) continue;
            double dx = x[array[i-1]] - x[array[i]];
            double dy = y[array[i-1]] - y[array[i]];
            ans += sqrt(dx*dx + dy*dy);
        }
    }while(next_permutation(array, array+N));

    printf("%.12lf\n", ans/cnt);
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int a, b;
	while (cin >> a >> b, a || b) {
		int n; cin >> n;
		vector<vector<int>>v(b, vector<int>(a, INF));
		rep(i, 0, n) {
			int x, y; cin >> x >> y;
			x--; y--;
			v[y][x] = 0;
		}
		v[0][0] = 1;
		rep(i, 1, b) {
			v[i][0] = min(v[i - 1][0], v[i][0]);
		}
		rep(i, 1, a) {
			v[0][i] = min(v[0][i - 1], v[0][i]);
		}
		rep(i, 1, b) {
			rep(j, 1, a) {
				if (v[i][j] == INF) {
					v[i][j] = v[i - 1][j] + v[i][j - 1];
				}
			}
		}
		cout << v[b - 1][a - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
X,Y = map(int,input().split())

if Y%2 != 0:
    print('No')
    exit()

else:
    for a in range(X + 1):
        for b in range(X + 1 - a):
            if 2*a + 4*b == Y and a + b == X:
                print('Yes')
                exit()
            else:
                pass

    print('No')

Measured memory_bytes: 9004
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int ans,n,m,cnt,f[6000010],ch[6000010][2],rt[500010];
vector<int>zh[500010];
void ins(int &x,int la,int l,int r,int t){
	x=++cnt;f[x]=f[la]+1;
	ch[x][0]=ch[la][0];ch[x][1]=ch[la][1];
	if(l==r)return;
	int mid=(l+r)/2;
	if(mid>=t)ins(ch[x][0],ch[la][0],l,mid,t);
	 else ins(ch[x][1],ch[la][1],mid+1,r,t);
}
int query(int x,int l,int r,int t,int k){
	if(!x)return 0;
	if(l==t&&r==k)return f[x];
	int mid=(l+r)/2;
	if(mid>=k)return query(ch[x][0],l,mid,t,k);
	 else if(t>mid)return query(ch[x][1],mid+1,r,t,k);
	  else return query(ch[x][0],l,mid,t,mid)+query(ch[x][1],mid+1,r,mid+1,k);
}
int main(){
	int i,x,y,j,nt;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%d%d",&x,&y);
		zh[y].push_back(x);
	}
	for(i=1;i<=m;i++){
		rt[i]=++cnt;ch[rt[i]][0]=ch[rt[i-1]][0];ch[rt[i]][1]=ch[rt[i-1]][1];
		f[rt[i]]=f[rt[i-1]];
		for(j=0;j<zh[i].size();j++){
			x=zh[i][j];
			ins(rt[i],rt[i],1,m,x);
		}
	}
	for(i=1;i<=m;i++){
		ans=0;
		for(j=i;j<=m;j+=i){
			nt=min(m,j+i-1);
			ans=ans+query(rt[nt],1,m,1,j)-query(rt[j-1],1,m,1,j);
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 83968
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int A,B;
  cin>>A>>B;
  int N=__gcd(A,B),j=1;
  for(int i=2;i*i<N;i++){
    if(N%i==0){
      for(;N%i==0;N/=i){}
      j++;
    }
  }
  if(N!=1)
    j++;
  cout<<j<<endl;
}


Measured memory_bytes: 3672
#include <iostream>
#include <cmath>
using namespace std;
int main() {
        int d, n;
        cin >> d >> n;
        int base = pow(100, d);
        int ans = base * n;

        if ((ans / (int)pow(100, d)) % 100 == 0) {
                ans = base * (n+1);
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 200005
#define ll long long
using namespace std;
inline int in(){
    int x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
ll res;
int a[MN],n;
int main()
{
	n=in();
	for (int i=1;i<=n;++i) a[i]=in();
	for (int i=1;i<=n;++i){
		if (a[i]-a[i-1]>=2||a[i]>=i) {printf("-1");return 0;}
		else if (a[i]-a[i-1]==1) ++res;
		else res+=1ll*a[i];
	}printf("%lld",res);return 0;
}

Measured memory_bytes: 896
url = "https://atcoder.jp//contests/abc049/tasks/arc065_a"

def main():
    words = ['dream','dreamer', 'erase', 'eraser']
    s = input()
    rs = s[::-1]
    while rs != '':
        tmp = len(rs)
        for word in words:
            if len(word) > len(rs):
                continue
            rs = rs[0:len(word)].replace(word[::-1], '') + rs[len(word):]
        if tmp == len(rs):
            print('NO')
            exit()
    print('YES')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9316
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}






int main() {
  int N,M,sum = 0;
  cin >> N >> M;
  rep(i,M) {
    int a;
    cin >> a;
    sum += a;
  }
  cout << ((N-sum>=0) ? N-sum : -1) << endl;

  return 0;
}


Measured memory_bytes: 3164