akhauriyash/Code-Regression huggingface dataset:
<?php
  list($n, $h) = explode(" ", trim(fgets(STDIN)));

  $a = [];
  $b = [];
  for ($i=0; $i<$n; $i++) {
    list($a[], $b[]) = explode(" ", trim(fgets(STDIN)));
  }

  rsort($a);
  rsort($b);
  
  for($i=0; $i<$n && $b[$i]>$a[0]; $i++){
    $h -= $b[$i];
    if($h <= 0){
      echo $i+1;
      exit;
    }
  }

  $ans = intdiv($h + $a[0] - 1, $a[0]);

  echo $ans + $i;

Measured memory_bytes: 30056
A, B = map(int, input().split())
S = input()

if any([S.count("-") != 1, S[0] == "-", S[-1] == "-"]):
  print ("No")
else:
  a, b = S.split("-")
  if len(a) == A and len(b) == B:
    print ("Yes")
  else:
    print ("No")

Measured memory_bytes: 3060
I=lambda:input()
L=lambda:list(map(int,I().split()))
n,k=L()
a=L()
m=10**9+7
kk=(k*(k+1)//2)%m
k=(k*(k-1)//2)%m
from bisect import bisect_left
x=0
for i in range(n):
  if i!=0:
    l=a[:i]
    l.sort()
    b=bisect_left(l,a[i])
    x+=(b*k)%m
  if i!=n-1:
    l=a[i+1:]
    l.sort()
    b=bisect_left(l,a[i])
    x+=(b*kk)%m
  x%=m
print(x)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;



int main(){
    cin>>N;
    if(N < 10){
        cout<<N<<endl;
        return 0;
    }
    int keta = 1, n = N;
    while(n >= 10){
        ++keta;
        n /= 10;
    }
    int base = keta >= 3, bit10 = 1;
    rep(i, keta - 3) base = base * 10 + 1;
    rep(i, keta - 1) bit10 *= 10;
    mat memo(10, vec(10, -1));
    ll ans = 0;
    reps(i,1,10){
        reps(j,1,10){
            ll plus = base + (i == j);
            if(i == n){
                plus += (N - n * bit10 - j + 10) / 10;
                //cout<<i<<' '<<j<<' '<<(N - n * bit10 - j) / 10<<endl;
            }else if(i < n){
                plus += bit10 / 10;
            }
            memo[i][j] = plus;
        }
    }
    reps(i,1,10){
        reps(j,1,10) {
            ans += memo[i][j] * memo[j][i];
            //cout<<memo[i][j]<<' ';
        }
        //cout<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
function Main(a) {
    var words = a.split(" ");
    var answer = "";
    var first = words[0].slice(0,1);
    var second = words[1].slice(0,1);
    var third = words[2].slice(0,1);
    var answer = (first + second + third).toUpperCase();
  	console.log(answer)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch SumANDSubarrays | diff SumANDSubarrays.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address SumANDSubarrays.cpp && ./a.out

/*
 
 5/3/2020
 
 21:05-
 
 */

const int MAX_N=1e3+1;
LL A[MAX_N];
int N,K;

void solve() {
  vector<LL> B;
  REP(l,N)FORE(r,l+1,N) {
    LL sum=0;
    FOR(i,l,r) sum+=A[i];
    B.push_back(sum);
  }
  sort(ALL(B));
  LL res=0;
  for(int i=40; i>=0; --i) {
    vector<LL> BB;
    FORR(a,B) if((a>>i)&1) BB.push_back(a);
    if(SZ(BB)>=K) {
      B=BB;
      res|=(1LL<<i);
    }
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>K;
  REP(i,N) cin>>A[i];
  solve();
  
  return 0;
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

main()
{
  int a,b,c,k; cin >> a >> b >> c >> k;
  if(k % 2 == 0) cout << a - b << endl;
  else cout << b - a << endl;
}


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

int main() {
  int a, b; cin >> a >> b;
  string a_s="", b_s="";
  rep(i,b) {
    a_s += to_string(a);
  }
  rep(i,a) {
    b_s += to_string(b);
  }
  if (a_s <= b_s) cout << a_s << endl;
  else cout << b_s << endl;
}

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

XOR=a[0]
for i in range(1,n):
    XOR^=a[i]

swt=format(XOR, '030b')
#print(swt)
s=[]
for i in range(30):
    if swt[i]=="1":
        s.append(i)
        #print('here')
#print(s)
ans=[]

for i in range(n):
    temp=list(format(a[i], '030b'))
    for i in s:
        if temp[i]=="1":
            temp[i]="0"
        else:
            temp[i]="1"
    #print("0b"+"".join(temp))
    ans.append(int("".join(temp),2))

print(' '.join([str(n) for n in ans]))

Measured memory_bytes: 117632
import sys, random, math
from bisect import bisect_left, bisect_right
input = sys.stdin.readline

def main():
    inf = 10 ** 20

#    t = int(input())
#    t, a, b = map(int, input().split())
    t = 1
    
    for _ in range(1, t+1):
    #    print("Case #{}: ".format(_), end = '')
        
        n = input().strip()
        if(n[-1] == '0' or n[-1] == '1' or n[-1] == '6' or n[-1] == '8'):
            print("pon")
        elif(n[-1] == '3'):
            print("bon")
        else:
            print("hon")
        
        
        
main()

Measured memory_bytes: 76992
from collections import Counter

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

c = Counter(a)
k = list(c.keys())
v = list(c.values())
if k == [0]:
    able = True
elif len(c) == 2 and 0 in c and c[0] == N // 3:
    able = True
elif len(c) == 3 and k[0] ^ k[1] == k[2] and v[0] == v[1] == v[2]:
    able = True
else:
    able = False
print('Yes' if able else 'No')


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

typedef long long ll;

using namespace std;

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

    int now = 1;

    for (int i = 0; i < n; i++) {
        if (now < k) {
            now = now * 2;
        } else {
            now += k;
        }
    }

    cout << now << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
const int maxn = 1e6+10;
int a[maxn];
int dp[maxn];
int main()
{
    int n,k;
    memset(dp,INF,sizeof dp);
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",a+i);
    }
    dp[1]=0;
    for(int i=1;i<=n-1;i++)
    {
        for(int j=1;j<=k&&i+j<=n;j++)
        {
            dp[i+j]=min(dp[i+j],dp[i]+abs(a[i+j]-a[i]));
        }
    }
    printf("%d\n",dp[n]);
    return 0;
}


Measured memory_bytes: 8012
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int n , k , ga;
    cin>>n>>k;
    if(k==0)
    {
        cout<<"0 0";
    } else {
        int ca[n+1] = { 0 };
        int wa[n+1] = { 0 };
        int x;
        string s,c="AC";
        while(k--)
        {
            cin>>x>>s;
            if(s==c)
            {
                ca[x]=1;
            } else {
                if(ca[x]==0)
                {
                    wa[x]++;
                }
            }
        }
        
        int ans1 = 0 , ans2 = 0;
        for(int i = 1;i<=n;i++)
        {
          ans1 = ans1+ca[i];
          if(ca[i]==1)
          ans2 = ans2 +wa[i];
        }
        
        cout<<ans1<<" "<<ans2;
    }
    return 0;
}

Measured memory_bytes: 4328
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

int main() {
ll a;
cin>>a;
double b;
cin>>b;
b*=(double)100.0;
b+=(double)0.000001;
ll bb=b-0;
ll ans=bb*a;
ans/=100;

cout<<ans<<endl;


}




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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int ok=0;
    for(int i=a;i<=b;i++){
        if(c%i==0){
            ok++;
        }
    }
    cout<<ok<<"\n";
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll h, w, k; cin >> h >> w >> k;
    vector<string> c(h);
    rep(i, h) cin >> c[i];
    ll ans = 0;
    for(ll tate=0; tate<(1LL<<h); tate++){
        for(ll yoko=0; yoko<(1LL<<w); yoko++){
            ll count = 0;
            vi pos_tate(h), pos_yoko(w);
            for(ll m=0; m<h; m++) if(tate&(1LL<<m)) pos_tate[m] = 1;
            for(ll m=0; m<w; m++) if(yoko&(1LL<<m)) pos_yoko[m] = 1;

            rep(i, h){
                if(pos_tate[i] == 1) continue;
                rep(j, w){
                    if(pos_yoko[j] == 1) continue;
                    if(c[i][j] == '#') count++;
                }
            }
            if(count == k) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
		long N = input[0];
		long M = input[1];
		long ans = 0;

		if (N > M / 2) { ans = M / 2; }
		else { ans = N + (M - 2 * N) / 4; }



		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int MAX = 1e6 + 10;
const int MOD = 1e9 + 7;
const int oo = 1e9;

int powmod(int a, int n){
	int s = 1;
	while(n > 0){
		if(n & 1)s = (i64)s * a % MOD;
		a = (i64)a * a % MOD;
		n >>= 1;
	}
	return s;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	#define endl '\n'
	int n; cin >> n;
	map<pair<i64, i64>, pair<int, int>> M;
	pair<int, int> zero;
	int rans = 0;
	for(int i = 0; i < n; i++){
		i64 a, b; cin >> a >> b;
		if(a == 0 and b == 0){
			rans ++;
		}
		else if(a == 0)zero.first++;
		else if(b == 0)zero.second++;
		else{
			i64 d = abs(__gcd(a, b));
			a /= d; b /= d;
			if(b < 0)a = -a, b = -b;
			
			if(a > 0){
				if(M.find({a, b}) == M.end())M[{a, b}] = {0, 0};
				M[{a, b}].first++;
			}
			else {
				if(M.find({b, -a}) == M.end())M[{b, -a}] = {0, 0};
				M[{b, -a}].second++;
			}
		}
	}
	int pans = 1;
	pans = (i64) pans * ((powmod(2, zero.first)- 1 + powmod(2, zero.second) - 1 + 1) % MOD)% MOD;
	for(auto p: M){
		//cout << p.first.first << " " << p.first.second << " "
		pans = (i64) pans * ((powmod(2, p.second.first)- 1 + powmod(2, p.second.second) - 1 + 1) % MOD)% MOD;
		

	}

	int ans = ((rans + pans - 1) % MOD + MOD) % MOD;
	cout << ans << endl;
}


Measured memory_bytes: 16068
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n;
    cin>>n;
    vector<string> s;
    rep(i,n){
        string ss;
        cin>>ss;
        s.push_back(ss+ss);
    }
//    rep(i,s.size()){
//        cout<<s[i]<<endl;
 //   }
    ll ans = 0;
    for(int i=0;i<n;i++){
            bool f = true;
            for(int si = i;si<i+n;si++){
               for(int sj = 0;sj<n;sj++) {
                   if ((si - i) == (sj)) {
                   } else {
                       if (s[sj][si] != s[si-i][sj+i]) {
                           f = false;
                           break;
                       }
                   }
                   if (!f)break;
               }
        }
        if(f)ans++;
    }
    cout<<ans*n<<endl;





    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;

int selectionSort(int A[], int N){
  int i, j, minj, cnt = 0;

  for(i = 0; i < N; i++){
    minj = i;
    for(j = i; j < N; j++){
      if(A[j] < A[minj])  minj = j;
    }
      if(i != minj){
        swap(A[i], A[minj]); 
        cnt++;
      }
  }

  return cnt;
}

int main(){
  int N, A[100], cnt, i;
  
  cin >> N;
  for(i = 0; i < N; i++) cin >> A[i];

  cnt = selectionSort(A, N);

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

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include "iomanip"
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <fstream>
#include <algorithm>
#include <queue>
#include <cassert>
#include <stack>


using namespace std;


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

    int a, b;
    cin >> a >> b;
    for (int i = b - a + 1; i < b + a; ++i) {
        cout << i << " ";
    }

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main(){
    int n, m;   cin >> n >> m;
    
    vector<int> v(n);
    REP(i, m){
        int a, b;   cin >> a >> b;
        a--; b--;
        v[a] += 1;
        v[b] += 1;
    }
    string ans="YES";
    
    REP(i, n)
        if(v[i] & 1) ans = "NO"; 
    
    cout << ans << endl;
}

Measured memory_bytes: 640
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  int N;
  ll A, B;
  cin >> N >> A >> B;

  VI h(N);
  REP(i, N) {
    cin >> h[i];
  }

  int lb = 0, ub = 1e9;
  while (ub - lb > 1) {
    int mb = (lb + ub) / 2;
    ll rem = 0;

    REP(i, N) {
      if (h[i] - B * mb > 0) {
        rem += (h[i] - B * mb - 1) / (A - B) + 1;
      }
    }

    if (rem <= mb) {
      ub = mb;
    } else {
      lb = mb;
    }
  }

  cout << ub << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int x,y,z;

int main(){
	cin>>x>>y>>z;
	int a=0;
	while(1){
		a++;
		if(y*a+z*(a+1)>x) {
			a--;
			break;
		}
	}
	cout<<a<<endl;
	return 0;
}

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

using namespace std;

int n, cnt, now;
int a[100005];

int main()
{
    scanf("%d", &n);
    scanf("%d", &a[1]);
    for(int i = 2; i <= n; i++)
    {
        scanf("%d", &a[i]);
        if(a[i - 1] == i - 1)
        {
            swap(a[i - 1], a[i]);
            cnt++;
        }
    }
    if(a[n] == n) cnt++;
    printf("%d", cnt);
    return 0;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	n := len(readString())

	for i := 0; i < n; i++ {
		fmt.Print("x")
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 998244353;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll sum(n+1);
  ll ma=0;
  reps(i,n){
    sum[i]+=sum[i-1]+i;
    if(sum[i]>=n){
      ma=i;
      break;
    }
  }
  reps(i,ma){
    if(sum[ma]-n==i) continue;
    cout<<i<<endl;
  }
  
}

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

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int x = scanner.nextInt();
		int a = scanner.nextInt();



		ArrayList<Integer> list = new ArrayList<Integer>();



		for(int i = 0; i<x; i++) {
			if(a-i != a+i) {
				if(a-i>-1000000) {
					list.add(a-i);
				}
				if(a-i<1000000) {
					list.add(a+i);
				}
			}else {
				list.add(a-i);
			}
		}


		Collections.sort(list);
		for(int num: list) {
			System.out.print(num+" ");

		}


	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int n;
    cin>>n;
    map<ll,ll,greater<ll>> m;
    rep(i,n){
        ll a;
        cin>>a;
        m[a]++;
    }
    ll e1=0,e2=0;
    for(auto x: m){
        if(x.second>=4){
            if(e1==0&&e2==0){
                e1=x.first;e2=x.first;
            }
            else{
                e2=x.first;
            }
        }
        else if(x.second>=2){
            if(e1==0){
                e1=x.first;
            }
            else{
                e2=x.first;
            }
        }
        if(e1>0&&e2>0) break;
    }
    cout<<e1*e2<<endl;
    return 0;
}


Measured memory_bytes: 6528
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func sum(x []int) int {
	s := 0
	for i := 0; i < len(x); i++ {
		s += x[i]
	}
	return s
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	wsum := sum(a) / 2
	ansList := make([]string, n)
	for i := 0; i < (n-1)/2; i++ {
		wsum = wsum - a[1+i*2]
	}
	temp := wsum
	ansList[0] = strconv.Itoa(temp * 2)
	for i := 1; i < n; i++ {
		temp = a[i-1] - temp
		ansList[i] = strconv.Itoa(temp * 2)
	}
	fmt.Println(strings.Join(ansList, " "))
}


Measured memory_bytes: 9216
input_count = int(input().rstrip())
button_list = [0,]

for _ in range(input_count):
    button_list.append(int(input().rstrip()))    

push_count = 0
next_button = 1
while True:
    next_button = button_list[next_button]
    push_count += 1
    
    if next_button == 2:
        print(push_count)
        break
    
    if push_count == len(button_list):
        print(-1)
        break

Measured memory_bytes: 7080
#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>;
const int MOD = 1000000007;

int main()
{    
    vector<vector<int>> A(3, vector<int>(3));
    rep(i, 3) {
        rep(j, 3) {
            cin >> A[i][j];
        }
    }
    int n;
    cin >> n;
    rep(k, n) {
        int b;
        cin >> b;
        rep(i, 3) {
            rep(j, 3) {
                if (A[i][j] == b) {
                    A[i][j] = 0;
                }
            }
        }
    }
    if (A[0][0] + A[0][1] + A[0][2] == 0 ||
        A[1][0] + A[1][1] + A[1][2] == 0 ||
        A[2][0] + A[2][1] + A[2][2] == 0 ||
        A[0][0] + A[1][0] + A[2][0] == 0 ||
        A[0][1] + A[1][1] + A[2][1] == 0 ||
        A[0][2] + A[1][2] + A[2][2] == 0 ||
        A[0][0] + A[1][1] + A[2][2] == 0 ||
        A[0][2] + A[1][1] + A[2][0] == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
    int h, w, a, b;
    scanf("%d%d%d%d", &h, &w, &a, &b);
    for (int i = 0; i < h; ++ i){
        for (int j = 0; j < w; ++ j){
            putchar(((i < b) ^ (j < a)) + '0');
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int d[1000010];
vector<int> to[1000010];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> in(n * n + 10);
    for (int i = 0; i < n; i++) {
        vector<int> p(n - 1);
        for (int j = 0; j < n - 1; j++) {
            cin >> p[j];
            --p[j];
        }
        for (int j = 1; j < n - 1; j++) {
            int fr, t;
            if (i < p[j - 1]) {
                fr = i * n + p[j - 1];
            } else {
                fr = p[j - 1] * n + i;
            }
            if (i < p[j]) {
                t = i * n + p[j];
            } else {
                t = p[j] * n + i;
            }
            to[fr].push_back(t);
            in[t]++;
        }
    }
    for (int i = 0; i < n * n; i++) {
        d[i] = -1;
    }
    vector<int> vv;
    stack<int> st;
    for (int i = 0; i < n * n; i++) {
        if (in[i] == 0) {
            st.push(i);
            d[i] = 0;
        }
    }
    while (!st.empty()) {
        int v = st.top();
        vv.push_back(v);
        st.pop();
        for (auto &e : to[v]) {
            in[e]--;
            if (in[e] == 0) {
                st.push(e);
            }
        }
    }
    if (vv.size() != n * n) {
        cout << -1 << endl;
        return 0;
    }
    int ans = 0;
    for (int i = 0; i < n * n; i++) {
        if (d[vv[i]] == -1) {
            continue;
        }
        chmax(ans, d[vv[i]]);
        for (auto &e : to[vv[i]]) {
            chmax(d[e], d[vv[i]] + 1);
        }
    }
    cout << ans + 1 << endl;
}


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

long long counter[200010] = {0};
vector<int> path[200010];

void count(int no){
    int terget;
    for(int i=0;i<path[no].size();i++){
        terget=path[no].at(i);
        counter[terget]+=counter[no];
        path[terget].erase(find(path[terget].begin(), path[terget].end(),no));
        count(terget);
    }
}
int main(){
    int n,q;


    cin >> n>>q;
    int a,b;
    for(int i=1;i<n;i++){
        cin >>a>>b;
        path[a-1].push_back(b-1);
        path[b - 1].push_back(a - 1);
    }
    int p,x;
    for(int i=0;i<q;i++){
        cin >>p>>x;
        counter[p-1]+=x;

    }

    count(0);
        /*
    
    for(int i=0;i<n;i++){
        for(int j=0;j<path[i].size();j++){
            counter[path[i].at(j)]+=counter[i];

        }
        
    }
*/
    for(int i=0;i<n;i++){
        cout << counter[i]<<" ";
    }
    
}


Measured memory_bytes: 30464
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <numeric>
using namespace std;

int N;
string s;
int E[300001];
int W[300001];
int main() {
  cin >> N >> s;
  for (int i = 0; i < N; ++i) {
    E[i + 1] = s[i] == 'E';
    W[i + 1] = s[i] == 'W';
  }
  partial_sum(E, E + N + 1, E);
  partial_sum(W, W + N + 1, W);
  
  int mn = 1e9;
  for (int i = 0; i < N; ++i) {
    int ans = W[i] + E[N] - E[i + 1];
    mn = min(mn, ans);
  }
  cout << mn << endl;
}


Measured memory_bytes: 3076
import collections

N = int(input())
S = list(input())

max_count = 0

for i in range(N):
    a = S[:i]
    b = S[i:]

    a_2 = collections.Counter(a)
    b_2 = collections.Counter(b)

    dst = {}

    for k,v in b_2.items():
        if k in a_2:
            dst[k] = v

    max_count = max(max_count,len(dst))

print(max_count)

Measured memory_bytes: 3316
#include<iostream>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
using namespace std;
typedef long long ll;
int main()
{
	ll a;
	ll n, d;
	cin >> n >> d;
	ll cnt = 0;
	while (n--)
	{
		double t;
		ll x, y;
		cin >> x >> y;
		t = sqrt((x * x + y * y));
		if (t - d <= 0)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

string s;

int main() {
	int n, k, ans = 0;
	int p[1005] = { 0 };
	cin >> n >> k;
	rep(i, n) {
		cin >> p[i];
	}
	sort(p, p + n);
	rep(i, k) {
		ans += p[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
int main(void)
{
    int a, b, c[1000], d;

    scanf("%d", &a);
    
    for(b=0;b<a;b++)
    {
        scanf("%d", &c[b]);

    }

    for (d = a-1;(d <=a-1)&&(0<=d);d--)
    {
        if (d != 0)
        {
            printf("%d ", c[d]);
        }
        else
        {
            printf("%d\n", c[d]);
        }
    }

    return 0;
}


Measured memory_bytes: 2044
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 200000, Q = 200000, M = N * 2 + Q;

struct V {
	int i, t;
} vv[M];

int ll[N], rr[N], xx[N], dd[Q], yy[Q];
int pq[N], ip[1 + N], cnt;

bool lt(int i, int j) {
	return xx[i] < xx[j];
}

int p2(int p) {
	return (p *= 2) > cnt ? 0 : p < cnt && lt(ip[p + 1], ip[p]) ? p + 1 : p;
}

void pq_up(int i) {
	int j, p, q;
	for (p = pq[i]; (q = p / 2) > 0 && lt(i, j = ip[q]); p = q)
		ip[pq[j] = p] = j;
	ip[pq[i] = p] = i;
}

void pq_dn(int i) {
	int j, p, q;
	for (p = pq[i]; (q = p2(p)) > 0 && lt(j = ip[q], i); p = q)
		ip[pq[j] = p] = j;
	ip[pq[i] = p] = i;
}

void pq_add(int i) {
	pq[i] = ++cnt, pq_up(i);
}

void pq_remove(int i) {
	int j = ip[cnt--];
	if (j != i)
		pq[j] = pq[i], pq_up(j), pq_dn(j);
	pq[i] = 0;
}

int main() {
	int n, q; cin >> n >> q;
	int m = 0;
	for (int i = 0; i < n; i++) {
		int s, t, x; cin >> s >> t >> x;
		ll[i] = s - x;
		rr[i] = t - x;
		xx[i] = x;
		auto &u = vv[m++];
		u.i = i;
		u.t = 0;
		auto &v = vv[m++];
		v.i = i;
		v.t = 1;
	}
	for (int h = 0; h < q; h++) {
		cin >> dd[h];
		auto &v = vv[m++];
		v.i = h;
		v.t = 2;
	}
	sort(vv, vv + m, [] (auto &u, auto &v) { 
			int ux = u.t == 2 ? dd[u.i] : u.t == 0 ? rr[u.i] : ll[u.i];
			int vx = v.t == 2 ? dd[v.i] : v.t == 0 ? rr[v.i] : ll[v.i];
			return ux < vx || ux == vx && u.t < v.t;
			});
	for (int h = 0; h < m; h++) {
		auto &v = vv[h];
		if (v.t == 0)
			pq_remove(v.i);
		else if (v.t == 1)
			pq_add(v.i);
		else
			yy[v.i] = cnt ? xx[ip[1]] : -1;
	}
	for (int h = 0; h < q; h++)
		cout << yy[h] << '\n';
	return 0;
}


Measured memory_bytes: 13640
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vi v(n);
	REP(i, n) {
		cin >> v[i];
	}

	priority_queue<pii> q;
	int sum = 0;
	REP(i, n) {

		q.push({ k + 1 - v[i],i });
		sum += max(0, k + 1 - v[i]);

	}
	if (sum > k) {
		cout << -1 << endl;
		return 0;
	}
	int prev = -1;
	vi ans;

	REP(j, k + 1) {
		auto p = q.top(); q.pop();
		pii tmp(INF, -1);
		if (p.second == prev) {
			tmp = p;
			p = q.top(); q.pop();
		}
		REP(i, n) {
			if (i == p.second || i == prev)continue;
			ans.push_back(i);
		}
		ans.push_back(p.second);
		prev = p.second;
		q.push({ p.first - 1,p.second });
		if (tmp.second != -1)q.push(tmp);
	}
	vi cnt(n,0);
	REP(i, ans.size()) {
		cnt[ans[i]]++;
	}
	bool ok = true;
	REP(i, n) {
		if (cnt[i] > v[i])ok = false;
	}
	if (ok) {
		cout << ans.size() << endl;
		REP(i, ans.size()) {
			cout << ans[i] + 1 << " ";
		}
		cout << endl;
	}
	else {
		cout << -1 << endl;
	}
}

Measured memory_bytes: 256
<?php

$rooms     = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
$floors    = array($rooms, $rooms, $rooms);
$buildings = array($floors, $floors, $floors, $floors);

$num = (int)fgets(STDIN);

while (--$num >= 0) {
  fscanf(STDIN, "%d%d%d%d", $b,$f,$r,$v);
  $buildings[$b-1][$f-1][$r-1] += $v;
}

$res = array('','','','');
for ($i = 0; $i < 4; $i++) {
  for ($j = 0; $j < 3; $j++) {
    $res[$i] .= ' ' . implode(' ', $buildings[$i][$j]) . PHP_EOL;
  }
}

echo implode('####################'.PHP_EOL, $res);

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

int main(){
   int n,ans=0;
   cin >> n;
   int a[n];
   map<int,int> mp;
   rep(i,n){
       cin >> a[i];
       mp[a[i]]++;
   }
   for(auto i:mp){
       if(i.second>1) ans += (i.second-1);
   }
   if(ans%2) cout << mp.size()-1 << endl;
   else cout << mp.size() << endl;
}

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

int main() {
	ll N;
	cin >> N;
	ll ans = 1e18;
	for (ll i = 1; i * i <= N; ++i) {
		if (N % i != 0) continue;
		ll j = N / i;
		ans = min(ans, i + j - 2);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int d,x;
    cin>>d>>x;
    int ar[n];
    int sum=0;
    sum=x+n;
    int tem=d-1;
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        sum+=tem/ar[i];
    }

    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define debug(n) cout << "DEBUG1 " << n << "\n";
#define debug2(n, m) cout << "DEBUG2 " << n << ' ' << m << "\n";
#define debug3(n, m, x) cout << "DEBUG3 " << n << ' ' << m << ' ' << x << "\n";
#define ss_def stringstream ss // stringstream, do ss_def(str), then ss >> n (n is int)
#pragma GCC optimize("Ofast")
using namespace std;
ll int BtoPmodM(ll int b, ll int p, ll int m) { // (b ^ p) % m (Big Mod)
    if (p == 0) return 1;
    else if (p % 2 == 0) return (BtoPmodM(b, p / 2, m) * BtoPmodM(b, p / 2, m)) % m; // a^(p/2) * a^(p/2) = a^p
    else if (p % 2 == 1) return (BtoPmodM(b, (p - 1) / 2, m) * BtoPmodM(b, (p - 1) / 2, m) * b) % m; // +1
    else return 0; // a function must return something
}
ll int euclidalgo(ll int a, ll int b) { // Euclidean Algorithm
    if (b == 0) {
        return a;
    } else {
        return euclidalgo(b,a % b);
    }
}
bool coprime(ll int a, ll int b) {
    if (euclidalgo(a, b) == 1) return true;
    else return false;
}
ll int factModP(ll int n, ll int p) {
    ll int fac[n - 1];
    fac[0] = 1;
    for (ll int i = 1;i <= n;i++) {
        fac[i] = fac[i - 1] * i % p;
    }
    return fac[n];
}
ll int nCrModP(ll int n, ll int r, ll int p) {
    if (r == 0) return 1;
    ll int fac[n + 1];
    fac[0] = 1;
    for (ll int i = 1;i <= n;i++) {
        fac[i] = fac[i - 1] * i % p;
    }
    return (fac[n] * BtoPmodM(fac[r], p - 2, p) % p * BtoPmodM(fac[n - r], p - 2, p) % p) % p;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll int n, m;
    cin >> n >> m;
    ll int na = n * (n - 1) / 2;
    ll int ma = m * (m - 1) / 2;
    if (n == 0 || n == 1) na = 0;
    if (m == 0 || m == 1) ma = 0;
    cout << na + ma << endl;
}

Measured memory_bytes: 256
import fractions

a,b,c,d=map(int,input().split())

cd_lcm=int(c*d/fractions.gcd(c,d))

b_count=b-(b//c+b//d-b//cd_lcm)
a_count=a-1-((a-1)//c+(a-1)//d-(a-1)//cd_lcm)

print(int(b_count-a_count))

Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>T(N);
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>T.at(i);
    sum=sum+T.at(i);
  }
  int M;cin>>M;
  for(int i=0;i<M;i++){
    int p,x;cin>>p>>x;
    cout<<sum-T.at(p-1)+x<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	int a, b;
	cin >> a >> b;
	print(max(a+(a - 1), max(a+b, b+(b - 1))));





	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
<url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0507>
?????????============================================================
????????§???????????£?????¢????´???? n ?????????.?????????????´?????????¨????°´????????????????????????????????????.
?????????,??£????????????????????´????????´??????????????????????????????????????????????????°????????????.
????????°, n = 5 ?????¨??????,?¬????????????? 7 ?????????????????????????????§??????.

(?????\)

????????????,????????????????????£?????¢????????°????????§??¨????????¨?????????.????????°, n = 5 ??? ??¨??????,????????????,
(5) (4, 1) (3, 2) (3, 1, 1) (2, 2, 1) (2, 1, 1, 1) (1, 1, 1, 1, 1)
??¨??¨????????????.
n ?????\???????????¨???, ?????????????????§??¨???????????????????????°?????????????????????.n ???30 ??¨??????.
?????????, ?????????????????¨???2??????????????? (a1, a2 , ..., as) ???????????? (b1, b2, ..., bt )
????????????, a1 > b1 ?????????, ????????´??° i > 1 ????????¨??????
a1 = b1 , ..., ai-1 = bi-1 ?????? ai > bi ?????????????????¨??? 
(a1, a2, ..., as) ??? (b1 , b2, ..., bt) ??????????????????????????????????????????????????¨??§??????.

??\???????????? ??? 1 ???????????????,1 ????????? n ?????????????????????.
=================================================================
??\???=============================================================
??\???????????°????????????????????????????????????n ??? 0 ?????¨?????\????????????????????????????????????????????°??? 5 ????¶?????????????
================================================================
??????=============================================================
???????????????????????¨???????????????????????§??¨??????????????????
================================================================
?§£??¬=============================================================

================================================================
*/

void dfs(ll pre_n, ll n, vector<ll> v,vector<vector<ll>>& res) {
	if (n == 0) { res.push_back(v); return; }
	
	if (pre_n > v[v.size() - 1]) {
		v[v.size() - 1]++;
		dfs(pre_n, n - 1, v, res);
		v[v.size() - 1]--;
	}
	pre_n = v[v.size() - 1];
	v.push_back(1);
	dfs(pre_n, n - 1, v, res);
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll n;
	while (cin >> n, n) {
		vector<vector<ll>> res;
		for (int i = n;i > 0;i--) {
			vector<ll> v; v.push_back(i);
			dfs(i, n - i, v, res);
		}
		for (auto res_v : res) {
			for (int i = 0; i < res_v.size();i++) {
				if (i != 0) cout << " ";
				cout << res_v[i];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3388
from collections import deque, defaultdict

N, M = map(int, input().split())
ab = []
for _ in range(N + M - 1):
    a, b = map(int, input().split())
    ab.append((a, b))

out = defaultdict(list)
in_cnt = defaultdict(int)
rev = defaultdict(list)
for a, b in ab:
    out[a].append(b)
    in_cnt[b] += 1
    rev[b].append(a)

queue = deque(i for i in range(1, N + 1) if in_cnt[i] == 0)
sorted_ans = []

while len(queue) != 0:
    v = queue.popleft()
    sorted_ans.append(v)
    for v2 in out[v]:
        in_cnt[v2] -= 1
        if in_cnt[v2] == 0:
            queue.append(v2)

order = [i + 1 for i, v in sorted(enumerate(sorted_ans), key=lambda x: x[1])]
order = [0] + order
ans = [0] * (N + 1)
ans[sorted_ans[sorted_ans[0]] + 1] = 0

for v in sorted_ans[:0:-1]:
    ans[v] = max((order[v2], v2) for v2 in rev[v])[1]
ans.pop(0)
for a in ans:
    print(a)


Measured memory_bytes: 74340
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using ll = long long;

using namespace std;


int main() {
	int n;
	cin>>n;
	vector<int>d(n);
	for(int i=0;i<n;i++){
		cin>>d[i];
	}
	sort(d.begin(),d.end());
	int ans=1;
	int tmp=d[0];
	for(int i=1;i<n;i++){
		if(d[i]!=tmp){
			ans++;
			tmp=d[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int N;
vector<pair<int, int>> As;

int main() {
  cin >> N;
  int A;
  rep(i, N) {
    cin >> A;
    As.push_back(make_pair(A, i+1));
  }
  sort(As.begin(), As.end());
  rep(i, N) {
    cout << As[i].second << " " << flush;
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 1780
s = input().rstrip()

a = int(s[:2])
b = int(s[2:])

if 1 <= a <= 12 and 1 <= b <= 12:
    print('AMBIGUOUS')
elif (a == 0 or 12 < a) and 1 <= b <= 12:
    print('YYMM')
elif 1 <= a <= 12 and (b == 0 or 12 < b):
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3064