akhauriyash/Code-Regression huggingface dataset:
// Author:: MUKUL KUMAR RAI
// Institution:: Jalpaiguri Government Engineering College
//If you are not doing well now just stick to it and learn new things one day you will be...
//Compete with yourself 
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
///*template{{{
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
#define trav(a,x) for(auto &a:x)
#define fr(i,a,b)  for(ll i=a;i<=b;i++)
#define fr1(i,a)   for(ll i=0;i<a;i++)
#define frr(i,a,b) for(ll i=b;i>=a;i--)
#define frr1(i,a)   for(ll i=a-1;i>=0;i--)
#define sorta(a,n) sort(a,a+n)
#define sortd(a,n) sort(a,a+n,greater<ll>())
#define sortva(a) sort(a.begin(),a.end())
#define sortvd(a) sort(a.begin(),a.end(),greater<ll>())
#define tc(t) while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
using vi= vector<ll>;
using vvi= vector<vi>;
using vb =vector<bool>;
using vc =vector<char>;
using vs =vector<string>;
using vld =vector<ld>;
using pii =pair<ll,ll>;
using psi =pair<string,ll>;
using pci =pair<char,ll>;
using vpii =vector<pii>;
//}}}template*/
ll mod=1e9+7;
ll const maxn=1e6+5;
ll const inf=1e18;
bool ss(const pair<ll,ll> &a, const pair<ll,ll> &b) { 
    return a.first*b.second+a.second<b.first*a.second+b.second;
}
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
ll modinverse(ll a, ll m){
    return powm(a,m-2,m);
}
bool prime(ll x){
    if(x<=1)return false;
    for(int i=2;i<=sqrt(x);i++)if(x%i==0)return false;
    return true;
}
ll divisor(ll x){
    ll cnt=0;
    for(int i=1;i<=sqrt(x);i++){
        if(x%i==0){
            if(i!=x/i)cnt+=2;
            else cnt+=1;
        }
    }
    return cnt;
}
vector<ll> sieve(ll n) {     
    bool prim[n+1]; 
    memset(prim, true, sizeof(prim)); 
  
    for (ll p=2; p*p<=n; p++) {
        if (prim[p] == true) { 
            for (int i=p*p; i<=n; i += p) 
                prim[i] = false; 
        } 
    }
    vector<ll>v;
    for(int i=2;i<=n;i++)if(prim[i])v.push_back(i);
    return v; 
}
bool check(string s){
    ll l=0,r=sz(s)-1;
    while(l<=r){
        if(s[l]!=s[r])return false;
        l++;
        r--;
    }
    return true;
}
int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif    
    fio;
    ll n;
    cin>>n;
    ll A[n];
    fr1(i,n)cin>>A[i];
    sort(A,A+n);
    ll ans=0;
    frr1(i,n){
        ll l=0,r=i-1;
        while(l<r){
            if(A[l]+A[r]>A[i]){
                ans+=(r-l);
                r--;
            }
            else l++;
        }
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i] == '-')ans--;
        else ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
//l={1,2,3,4}
//sort(l,l+N,greater<int>());	降順ソート
//sort(l,l+N);	昇順ソート
//string 変数　　変数.size()で数字化


int main(void)
{
	int N, M;
	cin >> N >> M;

	int ht[105], test[105];

	for (int i = 1; i <= 2*N; i++) {
		cin >> ht[i];
	}
	for (int i = 1; i <= 2*M; i++) {
		cin >> test[i];
	}

	int x, y, xi, yi, ans, xa, ya;

	for (int i = 1; i <= 2*N; i += 2) {
		int a = 500000001;
		x = ht[i];
		y = ht[i + 1];
		for (int j = 1; j <= 2*M; j += 2) {
			xi = test[j];
			yi = test[j + 1];
			xa = x - xi;
			ya = y - yi;
			if (xa < 0)
				xa *= -1;
			if (ya < 0)
				ya *= -1;
			if (a > xa + ya) {
				a = xa + ya;
				ans = (j + 1) / 2;
			}
			
		}
		cout << ans << endl;
	}
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int main()
{
    ll total; cin >> total;
    ll sum = 0;
    sum += (total / 500) * 1000;
    total %= 500;
    sum += (total / 5) *5;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n, total = 0;
  cin >> n;
  ll arr[n];
  fi(0, n) {
    cin >> arr[i];
    total += arr[i];
  }
  ll mid = round((ld)total / n);
  fi(0, n) {
    ans += (arr[i] - mid) * (arr[i] - mid);
  }
  
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
//-----------------------
// author : xyqkoala
// time : 2020-08-03
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


LL check(vector<int> &nums,int m,int k){
	LL res = 0;
	for(auto item:nums){
		int cnt = item/m;
		if(item%m) cnt++;
		res += 1ll *(cnt-1);
		if(res>k) return false;
	}
	return res<=k;
}


void solve(){
	int n,k;
	cin>>n>>k;
	vector<int> nums(n);
	for(int i=0;i<n;i++){
		cin>>nums[i];
	}
	int l=1,r = MOD;
	while(l<r){
		int m = (r-l)/2+l;
		if(check(nums,m,k)) r = m;
		else l=m+1;
	}
	cout<<l<<endl;
}


Measured memory_bytes: 3912
def main():
    n_ansl = [0]*(2*(10**5))
    for i in range(1,2*(10**5)):
    # for i in range(1,20):
        cnt = 0
        one_cnt = bin(i).count("1")
        rem = i
        while rem != 0:
            one_cnt = bin(rem).count("1")
            rem = rem%one_cnt   
            cnt += 1
        n_ansl[i] = cnt
 
    n = int(input())
    x = list(input())
    one_cnt = x.count('1')

    if one_cnt == 0:
        for i in range(n):
            print(1)
        exit()
    
    curr_2b_p = 1
    curr_2b_m = 1
    curr_sum_p1 = 0
    curr_sum_m1 = 0
    for i in range(n-1, -1, -1):
        if x[i] == '1':
            curr_sum_p1 += curr_2b_p
            curr_sum_m1 += curr_2b_m
            curr_sum_p1%=(one_cnt+1)
            if one_cnt > 1:
                curr_sum_m1%=(one_cnt-1)
        curr_2b_p*=2
        curr_2b_p%=(one_cnt+1)
        if one_cnt > 1:
            curr_2b_m*=2
            curr_2b_m%=(one_cnt-1)
 
        
 
    curr_2b_p = 1
    curr_2b_m = 1
    ansl = [0]*(n)
    for i in range(n-1, -1, -1):
        if x[i] == '1':
            diff = (-1)*curr_2b_m
            if one_cnt > 1:
                ans = (curr_sum_m1 + diff)%(one_cnt-1)
                ansl[i] = n_ansl[ans]+1
            else:
                ansl[i] = 0
        else:
            diff = curr_2b_p
            ans = (curr_sum_p1 + diff)%(one_cnt+1)
            ansl[i] = (n_ansl[ans]+1)
        curr_2b_p*=2
        curr_2b_m*=2
        curr_2b_p%=(one_cnt+1)
        if one_cnt > 1:
            curr_2b_m%=(one_cnt-1)
 
 
    # print(ansl)
    for a in ansl:
        print(a)
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 89600
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair

#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
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 long long INFLL = 1LL<<62;
const int INF = 1<<30;

int main(){
    int n,y,x;
   // int ans=0;
    cin >>n>>x>>y;
    map<int, int> ans;
    //vector<vector<int>>dis(n+1,vector<int>(n+1,INF));
    vector<int>dis(n+1,INF);
   // rep(i,n){
    //    dis[i][i]=0;
    //}
    vector<vector<int>>path(n+1);
    for(int i=0;i<n;i++){
        if(i!=n-1){
        path[i].push_back(i+1);
    }
    if(i!=0){
        path[i].push_back(i-1);
    }
    }
    x--;
    y--;

    path[x].push_back(y);
    path[y].push_back(x);
    queue<int>q;
    int at;
   
    for(int i=0;i<n;i++){
        q.push(i);
        rep(I,n){
            dis[I]=INF;
        }
        dis[i]=0;
        while(!q.empty()){
            at=q.front();
            q.pop();
            
            for(auto itr=path[at].begin();itr!=path[at].end();itr++){
                /*if(dis[at][*itr] > dis[i][at]+1){
                    chmin(dis[at][*itr],dis[i][at]+1);
                    chmin(dis[*itr][at], dis[at][i] + 1);
                   
                   
                    q.push(*itr);
                //}
                */
                if(dis[at]+1< dis[*itr]){
                    q.push(*itr);
                    chmin(dis[*itr],dis[at]+1);
                    ans[dis[*itr]]+=0;
                    ans[dis[*itr]]++;

                }
            }
            
        }
        rep(i, n)
        {

           // clog << dis[i] << " ";
        }
      //  clog << endl;
    }

    /*
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
        ans[dis[i][j]]+=0;
        ans[dis[i][j]]++;
    }
    }
    */
    for(auto i=1;i<n;i++){
        cout<<ans[i]/2<<endl;
    }
   // cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 ll N,L ; cin >> N >> L;
  vector<ll> A(N); 
  for(ll i = 0; i < N; i++){ cin >> A[i];}
  for(ll i = 0; i < N-1; i++){ if(A[i]+A[i+1] >= L){
    cout << "Possible" << endl;
    for(int j = 1; j <= i; j++){ cout << j << endl;}
    for(int k = N-1; k >= i+2; k--){cout << k << endl;}
    cout << i+1 << endl; return 0;}
                             }
  
  cout << "Impossible" << endl; return 0;}
                            


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long 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;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  const int64_t mod = 1000000007;
  int64_t n, m, k;
  std::cin >> n >> m >> k;
  if (n == 1) {
    std::swap(n, m);
  }

  int64_t sum = 0;
  for (int64_t i = 0; i < n; i++) {
    sum += (n - i - 1) * (n - i) / 2;
    sum %= mod;
  }
  int64_t cost = sum;
  int64_t count = n * n;
  count %= mod;
  for (int64_t i = 1; i < m; i++) {
    auto tmp = sum * 2 * i;
    tmp %= mod;
    tmp += count * i * (i + 1) / 2;
    tmp %= mod;

    cost += tmp;
    cost %= mod;

    cost += sum;
    cost %= mod;
    // 新しい列で完結するやつを追加.
  }
  COMinit();
  std::cout << (cost * COM(n * m - 2, k - 2)) % mod << std::endl;
  return 0;
}

Measured memory_bytes: 12160
#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++)
typedef long long int ll;
typedef unsigned long long int ull;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t;
  cin >>a>>b;
  t=500*a>=b?"Yes":"No";
  cout <<t;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define fill(a,x) memset(a,x,sizeof(a)) 
#define pb push_back
#define sz(x) (int)x.size() 
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+10; 

map<ll,int> freq;
int main()
{
  fast;
  freq.clear();
  ll largest=0;
  int n;
  cin>>n;
  FOR(i,1,n)
  {
  	ll temp;
  	cin>>temp;
  	freq[temp]++;
  }  

  map<ll,int> :: iterator it;
  ll ans=0;
  for(it=freq.begin();it!=freq.end();it++)
  {
  	ll val=it->F;
  	if(freq[val]>=4)
  		ans=max(ans,val*val);
  	if(freq[val]>=2)
  	{
  		ans=max(ans,val*largest);
  		largest=max(val,largest);
  	}
  }

  cout<<ans;
  return 0;
}

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

#define mod 998244353
#define MAX_A 1000005

ll sub(ll x, ll y) {
    x -= y;
    if (x < 0) return x + mod;
    return x;
}

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

    vector<ll>inv(MAX_A, mod);
    inv[1] = 1;
    for (int i = 2; i < MAX_A; ++i) {
        inv[i] -= inv[mod % i] * (mod / i) % mod;
    }

    vector<ll>w(inv);
    for (int i = 1; i < MAX_A; ++i) {
        for (int j = i * 2; j < MAX_A; j += i) {
            w[j] = sub(w[j], w[i]);
        }
    }

    ll ans = 0;
    // (x+y+...+z)^2 - (x^2+y^2+...+z^2) = 2*sum_i / w[i]
    vector<ll>count(MAX_A, 0);
    vector<ll>square(MAX_A, 0);
    for (int i = 0; i < N; ++i) {
        square[A[i]] += A[i] * A[i];
        square[A[i]] %= mod;
        count[A[i]] += A[i];
        count[A[i]] %= mod;
    }
    for (int i = 1; i < MAX_A; ++i) {
        ll f=0, g=0;
        for (int j = i; j < MAX_A; j += i) {
            f = (f + count[j]) % mod;
            g = (g + square[j]) % mod;
        }
        ans += sub(f * f % mod, g) * w[i];
        ans %= mod;
    }

    ans = ans * inv[2] % mod;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 33024
#include <bits/stdc++.h>
#define N 50001
#define M 100011
#define f first
#define s second
#define INF (1e9)
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int n,m,T;
vector<PP> G[M]; // to,cost
vector<string> str[M];
vector<P> D[M];
map<string,int> mp;

P dijkstra(int s,int g){
  priority_queue<PP,vector<PP>,greater<PP> >Q;
  set<P> S;
  for(int i=0;i<m;i++)
    for(int j=0;j<str[i].size();j++)if(mp[str[i][j]]==s)S.insert(P(i,j)),D[i][j]=P(0,0);
  
  for(int i=0;i<G[s].size();i++){
      PP e=G[s][i];
      int ncost=e.f.s,ncnt=0;
      int ny=e.s.f,nx=e.s.s;
      if(!S.count(P(ny,nx-1))&&!S.count(P(ny,nx+1))) ncost+=T,ncnt=1;
      if(D[ny][nx]>P(ncost,ncnt))
	D[ny][nx]=P(ncost,ncnt),Q.push(PP(D[ny][nx],P(ny,nx)));
  }

  while(!Q.empty()){
    PP t=Q.top();Q.pop();
    int cost=t.f.f,cnt=t.f.s;
    int y=t.s.f, x=t.s.s;
    int pos=mp[str[y][x]];
    if(D[y][x]<t.f) continue;
    if(pos==g) return t.f;

    for(int i=0;i<G[pos].size();i++){
      PP e=G[pos][i];
      int ncost=cost+e.f.s,ncnt=cnt;
      int ny=e.s.f,nx=e.s.s;
      if(ny!=y||abs(x-nx)!=1) ncost+=T,ncnt++;
      if(D[ny][nx]>P(ncost,ncnt))
	D[ny][nx]=P(ncost,ncnt),Q.push(PP(D[ny][nx],P(ny,nx)));
    }
  }
  return P(-1,-1);
}

void add_edge(vector<int> &cost,int i){
  int pre= mp.count(str[i][0])? mp[str[i][0]]:mp[str[i][0]]=n++;
  for(int j=0;j<cost.size();j++){
    int pos=mp.count(str[i][j+1])?mp[str[i][j+1]]:mp[str[i][j+1]]=n++;
    G[pre].push_back(PP(P(pos,cost[j]),P(i,j+1)));
    G[pos].push_back(PP(P(pre,cost[j]),P(i,j)));
    pre=pos;
  }
}

int main(){
  string s,g;
  cin>>m>>T>>s>>g;
  mp[s]=n++,mp[g]=n++;
  for(int i=0,a;i<m;i++){
    cin>>a;
    str[i].resize(a);
    D[i].resize(a,P(INF,INF));
    vector<int> cost(a-1);
    for(int j=0;j<a;j++)cin>>str[i][j];      
    for(int j=0;j<a-1;j++)cin>>cost[j];
    add_edge(cost,i);
  }

  P ans=dijkstra(0,1);
  if(ans==P(-1,-1)) cout<<-1<<endl;
  else cout<<ans.f<<" "<<ans.s<<endl;
  return 0;
}

Measured memory_bytes: 25364
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[111111],mn;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	mn=1;
	for (int i=2;i<n;i++)
	{
		if (max(a[i],a[n]-a[i])<max(a[mn],a[n]-a[mn])) mn=i;
	}
	printf("%d %d\n",a[n],a[mn]);
	return 0;
}

Measured memory_bytes: 640
N, X = gets.chomp.split(' ').map(&:to_i)

BARGER_COUNT_TABLE =
  (1..N).reduce({ 0 => 1 }) do |acc, n|
    m = acc[n - 1]
    acc[n] = m * 2 + 3
    acc
  end

PATTIE_MAX_COUNT_TABLE =
  (1..N).reduce({ 0 => 1 }) do |acc, n|
    m = acc[n - 1]
    acc[n] = m * 2 + 1
    acc
  end

def patti_eat_count(n, x)
  count = BARGER_COUNT_TABLE[n]
  center = (count / 2) + 1
  if n == 0
    PATTIE_MAX_COUNT_TABLE[0]
  elsif x <= n
    0
  elsif x < center
    patti_eat_count(n - 1, x - 1)
  elsif x == center
    PATTIE_MAX_COUNT_TABLE[n - 1] + 1
  elsif x < count - n
    patti_eat_count(n, center) + patti_eat_count(n - 1, x - center)
  else
    PATTIE_MAX_COUNT_TABLE[n]
  end
end
puts patti_eat_count(N, X)


Measured memory_bytes: 1788
require "bigdecimal/math"
include BigMath
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

a,b,c=get_i
puts yn_judge((c-a-b)>0&&BigDecimal((4*a*b).to_s)<BigDecimal(((c-a-b)**2).to_s))


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define int long long
int INF = 1e9 +7;
signed main(){
    int n,m,a,b;
    cin>>n>>m;
    vector<int> hen[n];
    for(int i=0;i<m;i++){
        cin >>a>>b;
        hen[a-1].push_back(b-1);
        hen[b-1].push_back(a-1);
    }
    vector<int> hen4;
    int t=0;
    int y=0;

    for(int i=0;i<n;i++ ){
        if(hen[i].size()%2!=0){
            y=-1;
           // cout<<"No ";
            break;
        }
        if(hen[i].size()>=6){
            t=1;
           
          
        }
        if(hen[i].size()==4){
           hen4.push_back(i);
        }
    }
    if((hen4.size()>2||t==1)&&y!=-1)cout<<"Yes";
    else{
        if(y==-1||hen4.size()<2)cout<<"No";
        else{
            for(int i=0;i<4;i++){
                int k0=hen4[0];
                int k=hen[hen4[0]][i];
                while(k!=hen4[0]&&k!=hen4[1]){
                    if(k0==hen[k][0]){
                        k0=k;
                        k=hen[k][1];

                    }
                    else {
                        k0=k;
                        k=hen[k][0];
                    }
                }
                if(k==hen4[0])t=1;

            }
            if(t==1)cout<<"Yes";
            else cout<<"No";
        }

        

    }
    

    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "random"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
main(){
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    fasty;
    int n; cin>>n;
    string s; cin>>s; s=" "+s;
    if(n&1) return cout<<"No",0;
    int l=1,r=s.size()/2+1;
    while(r<=n){
        if(s[l]!=s[r]) return cout<<"No",0;
        l++; r++;
    }
    cout<<"Yes\n";
}



Measured memory_bytes: 256
#include<iostream>


using namespace std;

int main(){

    int A,B; cin >> A >>B ;

    if(A == B){
      cout <<"Draw"<<endl;
    }
    else if((A > B && B != 1) || A == 1){
      cout << "Alice"  << endl;
    }
    else {
      cout << "Bob" << endl;
    }
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/tenka1-2017-beginner/tasks/tenka1_2017_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    cout << count(ALL(s), '1') << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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 MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll a;
  int b,d;
  char c;
  cin >> a >> b >> c >> d;
  b=b*100+d;
  a*=b;
  a/=100;
  cout <<a << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

static int primeTbl[] = {2,3,5,7,11,13,17,19,23,29};
#define PTBL_SIZE (sizeof(primeTbl)/sizeof(primeTbl[0]))

int main(void)
{
  int x;
  int i;
  int end = 0;

  scanf("%d", &x);

  while(end == 0)
  {
    for(i=0; i<PTBL_SIZE; i++)
    {
      if(x==primeTbl[i])
      {
        end = 1;
        break;
      }
      if(!(x%primeTbl[i]))
      {
        x++;
        break;
      }
    }

    if(i == PTBL_SIZE){
      // 29の次の素数からカウントアップして割り切れるかチェックする
      for(i=31; i < x; i++)
      {
        if(!(x%i))
        {
          x++;
          break;
        }
      }
    
      if(i == x)
      {
          end = 1;
      }
    }
  }

  printf("%d\n",x);

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define bye return 0
#define Yes cout << "Yes" << "\n"
#define No  cout << "No" << "\n"
#define YES cout << "YES" << "\n"
#define NO cout << "NO" << "\n"
#define endl cout << "\n";
using namespace std;
int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int> v;
    vector<int> v1;
    set<int> sets;
    vector<string> str;
    string s;
    int a, b, c, t, cnt=0;
    cin >> s;

    for(int i=0; i<s.size(); ++i){
    	sets.insert(s[i]);
    }

    if(s.size() != sets.size()){
    	cout << "no" << "\n";
    }else{
    	cout << "yes" << "\n";
    }

    
   bye;

}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, X: int, Y: int):
    c = 0
    if (A + B < 2 * C):
        c += min(X, Y) * (A + B)
    else:
        c += min(X, Y) * 2 * C
    if X > Y:
        c += (X - Y) * min(A, 2 * C)
    else:
        c += (Y - X) * min(B, 2 * C)
    print(c)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(A, B, C, X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値取得
		int N = scan.nextInt();

		//WK変数

		//演算
		int result = (N + 999) / 1000 * 1000 - N;

		//結果出力
		System.out.println(result);
	}
}

Measured memory_bytes: 35784
import heapq

class MinCostFlow:
    class Edge:
        def __init__(self,to,cap,rev,cost):
            self.to = to
            self.cap = cap
            self.rev = rev
            self.cost = cost

    def __init__(self,n,inf=1000000007):
        self.n = n
        self.inf = inf
        self.e = [[] for _ in range(n)]

    def add_edge(self, fr, to, cap, cost):
        self.e[fr].append(self.Edge(to,cap,len(self.e[to]),cost))
        self.e[to].append(self.Edge(fr,0,len(self.e[fr])-1,-cost))

    def compute(self,source,sink,f):
        res = 0
        h = [0]*self.n
        prevv = [0]*self.n
        preve = [0]*self.n
        while (f > 0):
            pq = []
            dist = [self.inf]*self.n
            dist[source] = 0
            heapq.heappush(pq,(0,source))
            while pq:
                cost, v = heapq.heappop(pq)
                cost = -cost
                if dist[v] < cost:continue
                for i, edge in enumerate(self.e[v]):
                    if edge.cap > 0 and dist[v] - h[edge.to] < dist[edge.to] - edge.cost - h[v]:
                        dist[edge.to] = dist[v] + edge.cost + h[v] - h[edge.to]
                        prevv[edge.to] = v
                        preve[edge.to] = i
                        heapq.heappush(pq,(-dist[edge.to],edge.to))
            if dist[sink] == self.inf:return -1
            for v in range(self.n):
                h[v] += dist[v]

            d, v = f, sink
            while v != source:
                d = min(d,self.e[prevv[v]][preve[v]].cap)
                v = prevv[v]
            f -= d
            res += d*h[sink]
            v = sink
            while v != source:
                self.e[prevv[v]][preve[v]].cap -= d
                self.e[v][self.e[prevv[v]][preve[v]].rev].cap += d
                v = prevv[v]
        return res

def less(a,b):
    for i in range(3):
        if b[i]<=a[i]:return False
    return True

def main():
    while True:
        n = int(input())
        if n==0:break
        a = []
        MCF = MinCostFlow(n+n+2)
        s = n+n
        t = s+1
        summ = 0
        for i in range(n):
            x = list(map(int,input().split()))
            x.sort()
            a.append(x)
            summ+=(x[0]*x[1]*x[2])
        for i in range(n):
            for j in range(n):
                if i == j:continue
                if less(a[i],a[j]):
                    MCF.add_edge(i,j+n,1,-(a[i][0]*a[i][1]*a[i][2]))
        for i in range(n):
            MCF.add_edge(s,i,1,0)
            MCF.add_edge(i+n,t,1,0)
        MCF.add_edge(s,t,MCF.inf,0)
        print (summ+MCF.compute(s,t,MCF.inf))

if __name__ == '__main__':
    main()




Measured memory_bytes: 6900
#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 INF = numeric_limits<int>::max();

struct edge {
    int from, to, cost;
};

struct Graph {
    vector<edge> es;
    vector<int> d;
    Graph(int n) {
        d.assign(n, INF);
    }
};

int main()
{
    int nv, ne, r;
    cin >> nv >> ne >> r;
    Graph g(nv);
    rep(i, ne) {
        int s, t, d;
        cin >> s >> t >> d;
        g.es.push_back({s, t, d});
    }
    g.d[r] = 0;
    rep(i, nv) {
        for (auto& e : g.es) {
            if (g.d[e.from] != INF && g.d[e.to] > g.d[e.from] + e.cost) {
                if (i == nv - 1) {
                    cout << "NEGATIVE CYCLE" << endl;
                    return 0;
                }
                g.d[e.to] = g.d[e.from] + e.cost;
            }
        }
    }
    for (auto d : g.d) {
        if (d == INF) {
            cout << "INF" << endl;
        } else {
            cout << d << endl;
        }
    }
}


Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int s = 0;
    for (int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        s += r - l + 1;
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,d,x,y,m,n;
    cin>>a>>b>>c>>d;
    x=a*c;
    y=b*d;
    m=a*d;
    n=b*c;
    cout<<max({x,y,m,n});



return 0;
}


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

bool B[ 50 ];
bool C[ 50 ];


int main()
{
int i;
int j;
int M;
int N;
int K;
int A;
int iCnt;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> M;

	for( i = 1; i <= M; i++ ) B[ i ] = true;

	for( i = 0; i < N; i++ )
	{
		cin >> K;

		for( j = 1; j <= M; j++ ) C[ j ] = false;

		for( j = 0; j < K; j++ )
		{
			cin >> A;

			C[ A ] = true;
		}

		for( j = 1; j <= M; j++ )
			if( ! C[ j ] ) B[ j ] = false;
	}

	iCnt = 0;
	for( j = 1; j <= M; j++ )
	{
		if( B[ j ] ) iCnt++;
	}

	cout << iCnt << endl;



	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<vector>
std::vector<int>a[1010];
int n;
int main()
{
	scanf("%d",&n);
	int k=((int)(sqrt(1+8*n))+1)/2;
	if(k*(k-1)/2!=n){
		printf("No\n"); return 0;
	}
	int tot=0;
	for(int i=1;i<=k;i++)
		for(int j=1;j<i;j++){
			++tot;
			a[i].push_back(tot); a[j].push_back(tot);
		}
	printf("Yes\n");
	printf("%d\n",k);
	for(int i=1;i<=k;i++){
		int size=a[i].size();
		printf("%d ",size);
		for(int j=0;j<size;j++)
			printf("%d ",a[i][j]);
		printf("\n");
	}
}

Measured memory_bytes: 2304
#include <cstdio>
#include <algorithm>
#include <limits.h>
#include <cstring>
#include <vector>

using namespace std;

const int N = 1 << 19;
vector <int> A, B;
int n;

int main () {
	scanf ("%d", &n);
	for (int i = 1; i <= (1 << n); ++i) {
		int tmp;
		scanf ("%d", &tmp);
		A.push_back (tmp);
	}
	sort (A.rbegin (), A.rend ());
	B.push_back (A[0]);
	A.erase (A.begin());
	for (int i = 0; i < n; ++i) {
		sort (B.rbegin (), B.rend ());
		int id = 0;
		vector<int> C;
		for (int j = 0; j < (1 << i); ++j) {
			while (id < A.size() && B[j] <= A[id])
				C.push_back (A[id++]);
			if (id >= A.size ()) {
				printf ("No\n");
				return 0;
			}
			B.push_back (A[id++]);
		}
		while (id < A.size ()) C.push_back (A[id++]);
		A = C;
	}
	printf ("Yes\n");
	return 0;
}

Measured memory_bytes: 3360
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string a,b,c;
  cin >> a >> b >> c;
  cout << "A";
  cout << b[0];
  cout << "C";
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;
ll gcd(ll a, ll b)
{
	if(b==0)
		return a;
	else
		return gcd(b, a%b);
}

int main()
{
	ll a, b;
	scanf("%lld %lld", &a, &b);
	printf("%lld\n", (a*b)/gcd(a, b));
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<vector>
#include<queue>
using namespace std;
vector<int>mp[250000];
int vis[250000];
int dist[250000];
int n,m;
void SPFA()
{
    queue<int>s;
    for(int i=1;i<=n;i++)dist[i]=0x3f3f3f3f,vis[i]=0;
    s.push(1);
    dist[1]=0;
    while(!s.empty())
    {
        int u=s.front();
        vis[u]=0;
        s.pop();
        for(int i=0;i<mp[u].size();i++)
        {
            int v=mp[u][i];
            if(dist[v]>dist[u]+1)
            {
                dist[v]=dist[u]+1;
                if(vis[v]==0)
                {
                    vis[v]=1;
                    s.push(v);
                }
            }
        }
    }
    if(dist[n]<=2)printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
}
int main()
{
    while(~scanf("%d%d",&n,&m))
    {
        for(int i=1;i<=n;i++)mp[i].clear();
        for(int i=0;i<m;i++)
        {
            int x,y;
            scanf("%d%d",&x,&y);
            mp[x].push_back(y);
        }
        SPFA();
    }
}


Measured memory_bytes: 11640
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
typedef vector<vp> vvp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;

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



Measured memory_bytes: 3636
#!/usr/bin/env python3


def solve(N: str):
    return {
        "0": "pon",
        "1": "pon",
        "2": "hon",
        "3": "bon",
        "4": "hon",
        "5": "hon",
        "6": "pon",
        "7": "hon",
        "8": "pon",
        "9": "hon",
    }[N[-1]]


def main():
    S = input()
    answer = solve(S)
    print(answer)


if __name__ == "__main__":
    main()


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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

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

int64 N, M;
string S, T;

// 最大公約数の取得
int64 gcd(int64 a, int64 b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

// 最小公倍数の取得
int64 lcm(int64 a, int64 b) {
	return a * b / gcd(a, b);
}

signed main(){
	cin >> N >> M;
	cin >> S;
	cin >> T;
	
	// 最小公倍数
	int64 L = lcm(N, M);

	int64 n = L/N;
	int64 m = L/M;
//	cout << "N = " << N << " M = " << M << "  L = " << L << "  L/N = " << n << "  L/M = " << m << endl;
	int64 n1, m1;
	for(int64 i=0; i < N; i++) {						// Ｓのインデックス
		n1 = n * i;						// Ｓの送り先
		if(n1 % m == 0) {				// Ｔが同じ場所に送るか？
			m1 = n1 / m;				// Ｔのインデックス
//			cout << "S[" << i << "] = " << S[i] << "  T[" << m1 << "] = " << T[m1] << endl;
			if(S[i] != T[m1]) {			// 同じ場所に送るが中身が違う
				cout << -1 << endl;
				return 0;
			}
		}
	}
	cout << L << endl;
	
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vii;
typedef vector<ll> vll;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int a, b, c, d;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    int l;
    cin >> l;
    cin >> a >> b >> c >> d;
    int day_a = a % c == 0 ? a / c : a / c + 1;
    int day_b = b % d == 0 ? b / d : b / d + 1;
    cout << l - max(day_a, day_b) << endl;
    return 0;
}




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

int main()
{
  int n;
  cin >> n;
  vector<long> a;
  vector<long> b;
  for(int i = 0; i < n + 1; i++){
    long x;
    cin >> x;
    a.push_back(x);
  }
  for(int i = 0; i < n; i++){
    long x;
    cin >> x;
    b.push_back(x);
  }
  long ans = 0;
  long rest = 0;
  for(int i = 0; i < n; i++){
    long enemy = max(a[i] - rest, static_cast<long>(0));
    ans += min(enemy, b[i]) + a[i] - enemy;
    rest = b[i] - min(enemy, b[i]);
    if (rest < 0) rest = 0;
  }
  ans += min(a[n], rest);
  
  cout << ans;
  return 0;
}


Measured memory_bytes: 2548
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let ans = a.iter().fold(0, |acc, &a|gcd(acc, a));

    println!("{}", ans);
}


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
const ll INF = LLONG_MAX / 2;

signed main() {
    int N;
    cin >> N;
    printf("%.7lf\n", N & 1 ? (double)(N + 1) / (2 * N) : 0.5);
    return 0;
}


Measured memory_bytes: 256
S = input()
T = input()


def rotate(S):
        tmp = S[-1]
        S = S[:-1]
        S = tmp + S
        return S

tmp = T
for i in range(len(S)):
        if S == tmp:
                print("Yes")
                exit()
        else:
                tmp = rotate(tmp)
print("No")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll n, x, t;
 	cin >> n >> x >> t;
 	ll ans = n / x;
 	if (n % x != 0) ans++;
 	cout << ans * t << endl;   
	return 0;
}

Measured memory_bytes: 3644
O = list(input())
E = list(input())

ans = list()
for i in range(max(len(O),len(E))):
    try:
        ans.extend([O[i],E[i]])
    except IndexError:
        if len(O) > len(E):
            ans.extend(O[i])
        else:
            ans.extend(E[i])
print(''.join(ans))


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

const long long MOD = 1000000007;

long long JC[100005];
long long num[100005];

void Init () {
	JC[1] = 1;
	for (long long i = 2; i <= 100000; ++i) {
		JC[i] = JC[i-1] * i;
		JC[i] %= MOD;
	}
}

long long Quick_Pow (long long xx, long long yy) {
	long long ret = 1, rem = xx;
	while (yy) {
		if (yy & 1) {
			ret *= rem;
			ret %= MOD;
		}
		rem *= rem;
		rem %= MOD;
		yy >>= 1;
	}
	return ret;
}

long long Ni (long long xx) {
	return Quick_Pow (xx, MOD-2);
}

long long Comb (long long xx, long long yy) {
	if (xx == yy || yy == 0)
		return 1;
	long long yy_ = Ni ((JC[yy]*JC[xx-yy]) % MOD);
	return (JC[xx]*yy_) % MOD;
}

int main () {
	Init ();
	long long n, kk;
	scanf ("%lld%lld", &n, &kk);
	for (long long i = 1; i <= n; ++i)
		scanf ("%lld", &num[i]);
	sort (num+1, num+n+1);
	long long ans = 0;
	for (long long i = 1; i <= n; ++i) {
		long long a = 0, b = 0;
		if (i >= kk)
			a = Comb (i-1, kk-1);
		if (n-i >= kk-1)
			b = Comb (n-i, kk-1);
		ans += (((a-b)*num[i])%MOD);
		ans %= MOD;
	}
	printf ("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1792
N = int(input())
A = [int(input()) for _ in range(N)]
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
def solve(N,A):
    lis = []
    for i in range(N):
        ind = bisect_left(lis,A[i])
        if ind == len(lis):
            lis.append(A[i])
        else:
            lis[ind] = A[i]
    ans = len(lis)
    return ans
print(solve(N,A))



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


int main() {

    string s;
    cin >> s;
    int cnt = 0;
    int t = 0;
    if (s[0] == 'A') ++cnt;
    for (int i = 2; i <= s.size()-2; ++i) {
        if (s[i] == 'C') ++t;
    }
    if (t == 1) ++cnt;
    sort(s.begin(), s.end());
    int res = 0;
    for (int i = 2; i <= s.size(); ++i) {
        if ('a' <= s[i] && s[i] <= 'z') ++res;
    }
    if (res == s.size()-2) ++cnt;
    if (cnt == 3) cout << "AC" << endl;
    else cout << "WA" << endl;
    return 0;
}

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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

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

    ll x;
    cin >> x;
    for (ll i=-500; i<=500; ++i) {
        for (ll j=-500; j<=500; ++j) {
            if (i*i*i*i*i-j*j*j*j*j==x) {
                cout << i << " " << j;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
int main(){
  int i,n,j,k;
  int b,f,r,v;
  int p[4][3][10]={0};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d %d",&b,&f,&r,&v);
    p[b-1][f-1][r-1]+=v;
    }

  for(k=0;k<4;k++){
    for(j=0;j<3;j++){
     for(i=0;i<10;i++){
       printf(" %d",p[k][j][i]);
    }
    printf("\n");
    }
    if(k==3){
      break;
    }
    printf("####################\n");
  }
  return 0;
} 


Measured memory_bytes: 2036