akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define mod 1000000007
#define inf 9999999999999999ll
ll fac[300000]; 
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
ll nCrModp(ll n, ll r, ll p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    
    
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;
    cin>>n>>k;
    fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%mod; 
    vi a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    sort(a.begin(),a.end());
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        ll numsmall=i;
        ll numlarge=n-i-1;
        if(numsmall>=k-1)
        {   
            ans+=(a[i]*(nCrModp(numsmall,k-1,mod)))%mod;
        }
        if(numlarge>=k-1)
        {
            ans-=(a[i]*(nCrModp(numlarge,k-1,mod)))%mod;
        }
        ans+=mod;
        ans%=mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;

const ll INF = 5e15;
const ll MOD = 1e9 + 7;

ll N;
vector<ll> A;
vector<vector<ll>> memo(3000 + 10, vector<ll>(3000 + 10, INF));

ll solve(ll f, ll b){
    if(f + b == N) return memo[f][b] = 0;
    if(memo[f][b] != INF) return memo[f][b];
    if((f + b) % 2 == 0){
        ll v1 = solve(f + 1, b) + A[f];
        ll v2 = solve(f, b + 1) + A[N - 1 - b];
        return memo[f][b] = max(v1, v2);
    }else{
        ll v1 = solve(f + 1, b) - A[f];
        ll v2 = solve(f, b + 1) - A[N - 1 - b];
        return memo[f][b] = min(v1, v2);
    }
}

int main(){
    cin >> N;
    A.resize(N);
    for(ll &a : A) cin >> a;
    solve(0, 0);
    cout << memo[0][0] << endl;
    return 0;
}


Measured memory_bytes: 71296
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back 
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U;
    int x;
    cin>>n>>S;
    rep(i,0,n-2)
    {
        if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C') count++;
        // cout<<i+2<<" ";
    }
    cout<<count;
}


signed main()
{
 ///   #ifndef ONLINE_JUDGE 
 //      freopen("input.txt","r",stdin);
  //     freopen("output.txt","w",stdout);
 //   #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  
  int N = b-a, high = 0;
  for(int i = 0; i < N; i++){
  	high += i;
  }
  cout << high - a <<endl;
}


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL fact[16];
int D;
LL calsum(LL x){
  LL s = 0;
  while(x > 0){
	s += x%10;
	x /= 10;
  }
  return s;
}
LL calprod(LL x){
  LL s = 1;
  while(x > 0){
	s *= (x%10)+1;
	x /= 10;
  }
  return s;
}

LL f1(int n, int d, int sum, LL tmp){
  if(d == 0)
	return tmp / fact[n];
  
  LL res = 0;
  for(int i=0;i*d<sum&&i<=n;++i){
	res += f1(n-i, d-1, sum-i*d, tmp/fact[i]);
  }

  return res;
}

LL f2(int n, int d, int sum, LL prod, LL tmp){
  LL res = 0;
  if(d == 0)
	return (sum==0? tmp / fact[n]: 0);

  for(int i=0;0<prod&&i*d<=sum&&i<=n;++i){
	res += f2(n-i, d-1, sum-d*i, prod, tmp/fact[i]);
	prod /= d+1;
  }
  return res;
}

LL powm(LL a, LL b){
  if(b==0)return 1;
  return pow(a*a,b/2)*(b%2?a:1);
}

LL nums[10];
string S;
LL ff(int idx){
  if(idx == D) return 1;
  LL res = 0;
  for(int d=0;d<10;++d){
	if(nums[d] == 0) continue;
	nums[d]--;
	if(S[idx] > '0'+d){
	  LL n = 0;
	  for(int dd=0;dd<10;++dd) n += nums[dd];
	  n = fact[n];
	  for(int dd=0;dd<10;++dd) n /= fact[nums[dd]];
	  res += n;
	}
	else if(S[idx] == '0'+d){
	  res += ff(idx+1);
	}
	nums[d]++;
  }
  
  return res;
}
LL f3(int n, int d, int sum, LL prod){
  LL res = 0;
  if(d == 0){
	nums[d] = n;
	return (sum==0 && prod==1? ff(0): 0);
  }

  for(int i=0;0<prod&&i*d<=sum&&i<=n;++i){
	nums[d] = i;
	res += f3(n-i, d-1, sum-d*i, prod);
	if(prod%(d+1) != 0) break;
	prod /= d+1;
  }
  return res;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  fact[0] =1;
  REP(i,16-1) fact[i+1] = fact[i] * (i+1);

  cin >> S;
  LL N = stoll(S);
  D = SZ(S);
  LL ans = 0, s = calsum(N), p = calprod(N);

  ans += f1(D,9,s,fact[D]);
  ans += f2(D,9,s,p-1,fact[D]);
  ans += f3(D,9,s,p);

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

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

int main() {
  int m;
  cin >> m;
  while(m--) {
    int A, y, n;
    cin >> A;
    cin >> y;
    cin >> n;

    int maxv = 0;
    for(int t = 0; t < n; ++t) {
      int mode, q;
      double p;
      cin >> mode >> p >> q;

      int a = A;
      int c = 0;
      for(int i = 0; i < y; ++i) {
	int b = (int)(a * p);
	if(mode) {
	  a = a + b - q;
	} else {
	  a = a - q;
	  c += b;
	}
      }
      maxv = max(maxv, a+c);
    }
    cout<< maxv << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import sys
input=sys.stdin.readline
a,b,m=map(int,input().split())
a_list=list(map(int,input().split()))
b_list=list(map(int,input().split()))
ans=10**9
for i in range(m):
    x,y,c=map(int,input().split())
    ans=min(ans,a_list[x-1]+b_list[y-1]-c)
ans=min(ans,min(a_list)+min(b_list))
print(ans)


Measured memory_bytes: 64800
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{

  ll a,b,c,d;
  cin>>a>>b>>c>>d;

  cout<<max(a*b,c*d)<<endl;
  return 0;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  bool ws[3] = {true, false};

  REP (j, 4) {
    vector<bool> pre(n);
    pre[0] = ws[j / 2];
    pre[1] = ws[j % 2];
    FOR (i, 1, n - 1) {
      if ((pre[i] && s[i] == 'o') || (!pre[i] && s[i] == 'x')) {
        pre[i + 1] = pre[i - 1];
      } else if ((pre[i] && s[i] == 'x') || (!pre[i] && s[i] == 'o')) {
        pre[i + 1] = !pre[i - 1];
      }
    }

    if ((pre[0] && s[0] == 'o' && pre[n - 1] == pre[1]) || (pre[0] && s[0] == 'x' && pre[n - 1] != pre[1]) || (!pre[0] && s[0] == 'o' && pre[n - 1] != pre[1]) || (!pre[0] && s[0] == 'x' && pre[n - 1] == pre[1])) {
      if ((pre[n - 1] && s[n - 1] == 'o' && pre[n - 2] == pre[0]) || (pre[n - 1] && s[n - 1] == 'x' && pre[n - 2] != pre[0]) || (!pre[n - 1] && s[n - 1] == 'o' && pre[n - 2] != pre[0]) || (!pre[n - 1] && s[n - 1] == 'x' && pre[n - 2] == pre[0])) {
        REP (i, n) {
          cout << (pre[i] ? 'S' : 'W');
        }
        cout << endl;
        exit(0);
      }
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

void solve()
{
    int n,p;
    cin>>n>>p;

    string s;
    cin>>s;

    reverse(all(s));

    if ( p != 2 && p != 5 )
    {
        vector<int> count(p,0);
        int ans = 0;
        int x = 1;
        int t = 0;
        rep(i,0,s.length())
        {
            count[t]++;
            t += (s[i]-'0')*x;
            t %= p;
            ans += count[t];
            x = x*10 % p;
        }

        cout<<ans<<endl;
    }
    else
    {
        int ans = 0;
        rep(i,0,s.length())
        {
            int x = s[i]-'0';

            if ( x % p == 0 )
            {
                ans += (s.length()-i);
            }
        }

        cout<<ans<<endl;
    }
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

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

int main(){
    int N,ans=0;
    string nstr;
    cin >> N;

    for (int i = 1; i < N + 1; i++){
        nstr = to_string(i);
        if (nstr.length() % 2 == 1) ans++;
    }
    cout << ans << endl;
}

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

int main(){
	int N;
	long long int T,A;
	long long int Ta,Aa;
	scanf("%d",&N);
	for (int i = 0; i < N; ++i)
	{
		scanf("%lld %lld",&T,&A);
		if (i==0){
			Ta=T;
			Aa=A;
		}else{
			long long int aux = max((T+Ta-1)/T,(A+Aa-1)/A);
			Ta = T*aux;
			Aa = A*aux;
		}
	}
	cout << Ta+Aa;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

#define N 55556

bool num[N];

void pri(){
    num[0]=num[1]=true;
    for(int i=2;i*i<N;i++){
        if(num[i])continue;
        for(int j=2*i;j<N;j+=i){
            num[j]=true;
        }
    }
}

int main(){
    pri();
    int n;
    cin >> n;
    vector<int> res(n,0);
    int cou=0;
    REP(i,N){
        if(num[i]==false && i%5==1){
            res[cou]=i;
            cou++;
        }
        if(cou==n)break;
    }
    REP(i,n){
//        cout << i << " ";
        cout << res[i];
        if(i!=n-1)cout << " ";
//        cout << endl;
    }
    cout << endl;
}


Measured memory_bytes: 256
/*
website for this problem:
https://atcoder.jp/contests/agc038/tasks/agc038_b
*/
#include<bits/stdc++.h>//Sorting a Segment
using namespace std;
int n,k;
const int N=(2e5+1e4);
int a[N];
set<int>ss;
int go[N];
int ans;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	go[0]=0;
	ans=0;
	for(int i=1;i<n;i++)
	{
		if(a[i]>a[i-1])
		{
			go[i]=(go[i-1]+1);
		}
		else
		{
			go[i]=0;
		}
		if(go[i]>=(k-1)) ans=1;
	}
	for(int i=0;i<k;i++)
	{
		ss.insert(a[i]);
	}
	if(go[k-1]!=(k-1))
	{
		ans++;
	}
	for(int i=k;i<n;i++)
	{
		ss.insert(a[i]);
		if(((*(ss.begin())!=a[i-k] )||(*(ss.rbegin())!= a[i])))
		{
			if(go[i]<(k-1))
			{
				ans++;
			}
		}
		ss.erase(a[i-k]);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 11136
n,x = map(int,input().split())
a = list(map(int,input().split()))
MIN = sum(a)
ans = MIN+0
tori = a + [0]
tori.pop()
for i in range(1,n):
  for j in range(n):
    ido = i+j
    if ido >= n:
      ido-=n
    if tori[j] > a[ido]:
      ans -= (tori[j] - a[ido])
      tori[j] = a[ido]
  MIN = min(ans + i*x,MIN)
print(MIN)

Measured memory_bytes: 3188
# 2019-11-11 14:35:02(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, T, A, *h = (int(x) for x in sys.stdin.read().split())

    min_diff, ans = abs(A - (T - h[0] * 0.006)), 1 # default 
    for i in range(1, n):
        t = T - h[i] * 0.006
        diff = abs(A - t)
        if diff < min_diff:
            min_diff = diff
            ans = i + 1
    print(ans)




if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long 
struct r{
	int u,v,w;
}e[400050];
int w[400050],fa[200050],cnt,n,m;
ll ans;
int get_fa(int u){return fa[u]==u ? u:fa[u]=get_fa(fa[u]);}
bool cmp(r a,r b){return a.w<b.w;}
int main(){
	scanf("%d%d",&n,&m);
	memset(w,127,sizeof w);
	for (int i=1;i<=m;i++){
		scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].w);
		w[e[i].u]=std::min(w[e[i].u],e[i].w+1);
		w[e[i].v]=std::min(w[e[i].v],e[i].w+2);
	}
	for (int i=0;i<n;i++) fa[i]=i;
	for (int i=1;i<(n<<1);i++)
		w[i]=std::min(w[i],w[i-1]+2);
	for (int i=0;i<n;i++)
		e[++m]=(r){i,(i+1)%n,std::min(w[i],w[i+n])};
	std::sort(e+1,e+m+1,cmp);
        int u,v;
	for (int i=1;i<=m;i++){
		if ((u=get_fa(e[i].u))==(v=get_fa(e[i].v))) continue;
		fa[v]=u;
		ans+=1ll*e[i].w;
		cnt++;
		if (cnt==n-1) {
			printf("%lld",ans);
			return 0;
		}
	}
} 
//code

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

using Size = int;
template<typename T> class Compression {
 public:
  Compression(const std::vector<T>& list) : value_(list) {
    std::sort(begin(value_), end(value_));
    value_.erase(std::unique(begin(value_), end(value_)), end(value_));
    for(Size i = 0; i < value_.size(); ++i) index_[value_[i]] = i;
  }
  Size size() const {return value_.size();}
  Size index(const T& v) const {return index_.at(v);}
  T operator[](const Size i) const {return value_.at(i);}
 private:
  std::unordered_map<T, Size> index_;
  std::vector<T> value_;
};

int main() {
  using LL = long long;
  struct Segment {LL x, m, y;};
  const LL INF = 9e18;

  int N, M;
  cin >> N >> M;
  vector<Segment> V(N), H(M);
  for(auto p: {&V, &H}) for(auto& s: *p) cin >> s.x >> s.m >> s.y;

  vector<LL> P = {-INF, 0, INF};
  for(auto p: {&V, &H}) for(auto& s: *p) {
    P.emplace_back(s.x);
    P.emplace_back(s.m);
    P.emplace_back(s.y);
  }
  Compression C(P);

  // (0,-1) -> (-1,0) -> (0,1) -> (1,0)
  enum {L, U, R, D};
  const int NEXT[5] = {0, -1, 0, 1, 0};
  const int W = C.size() - 1;
  vector<vector<vector<bool>>> ng(4, vector<vector<bool>>(W, vector<bool>(W)));
  for(const auto& s: V) for(auto x=C.index(s.x), y=C.index(s.y); x<C.index(s.m); ++x) ng[R][x][y-1] = ng[L][x][y] = true;
  for(const auto& s: H) for(auto x=C.index(s.x), y=C.index(s.m); y<C.index(s.y); ++y) ng[D][x-1][y] = ng[U][x][y] = true;

  vector<vector<bool>> used(W, vector<bool>(W));
  queue<pair<int, int>> q;
  q.emplace(C.index(0), C.index(0));
  LL area = 0;
  while(!q.empty()) {
    int x, y;
    tie(x, y) = q.front();
    q.pop();
    if(used[x][y]) continue;
    used[x][y] = true;
    if(x==0 || x==W-1 || y==0 || y==W-1) {
      cout << "INF" << endl;
      return 0;
    }
    auto lx = C[x], hx = C[x+1];
    auto ly = C[y], hy = C[y+1];
    area += (hx-lx) * (hy-ly);
    for(auto k=0; k<4; ++k) if(!ng[k][x][y]) {
      auto nx=x+NEXT[k], ny=y+NEXT[k+1];
      if(!used[nx][ny]) q.emplace(nx, ny);
    }
  }
  cout << area << endl;
}


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

#define sc second
#define fr first

#define ll long long
#define pi pair<int,int>
#define ppi pair<pi,pi>
#define mp make_pair
using namespace std;


int main()
{

	ios::sync_with_stdio(0);
    cin.tie(0) , cout.tie(0);

	
	int n;
	cin >> n;
	vector<pair<int, int>>v;
	for (int i = 1; i <= n; i++)
	{
		int x, y; cin >> x;
		v.push_back(mp(x, 0));
	}
	for (int i = 1; i <= n; i++)
	{
		int x, y; cin >> x;
		v[i - 1].second = x;
	}
	int ans = -1e9;
	for (int mask = 0; mask < (1 << n); mask++)
	{
		int x = 0, y = 0;
		for (int j = 0; j < n; j++)
		{
			if (mask & (1 << j))
			{
				x += v[j].first;
				y += v[j].second;
			}
		}
		ans = max(ans, x - y);
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N)
  {
    cin >> A[i];
  }
  vector<int> minimum(N), maximum(N);
  vector<int> ans(N + 5);
  rep(i, K)
  {
    rep(i, N)
    {
      minimum[i] = i - A[i];
      if (minimum[i] < 0)
        minimum[i] = 0;
      maximum[i] = i + A[i];
      if (maximum[i] > N - 1)
        maximum[i] = N - 1;
    }
    for (int i = 0; i < N; i++)
    {
      ans[minimum[i]]++;
      ans[maximum[i] + 1]--;
    }
    for (int i = 0; i < N; i++)
    {
      if (i > 0)
        ans[i] += ans[i - 1];
    }
    rep(i, N)
    {
      A[i] = ans[i];
      ans[i] = 0;
    }
    if(A[0]==N&&A[N-1]==N)
    {
      break;
    }
  }
  rep(i, N)
  {
    if (i != N - 1)
      cout << A[i] << " ";
    else
      cout << A[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 6432
# -*- coding: utf-8 -*-
import math
import datetime

# 入力
#N = int(input())
#S = str(input())
#A, B, X = map(int, input().split())
S = str(input())
H = "2019/04/30"

dateS = datetime.datetime.strptime(S, '%Y/%m/%d')
dateH = datetime.datetime.strptime(H, '%Y/%m/%d')

if dateS <= dateH :
  print ("Heisei")
else :
  print("TBD")


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


void solve(int A,int B,int T){
    int i=0;
    while(T>=A*i){
        i++;
    }
    printf("%d\n",(i-1)*B);
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int A;
    scanf("%d",&A);
    int B;
    scanf("%d",&B);
    int T;
    scanf("%d",&T);
    solve(A, B, T);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int P = Integer.parseInt(sc.next());

		sc.close();

		int answer = ((3 * A) + P) / 2;

		System.out.println(answer);

	}

}


Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
typedef long long ll;
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    char name[20];
    int vl;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}


int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}

int main(){
    int N,K;
    scanf("%d%d",&N,&K);
    ll sum=K;
    for(ll i=1;i<N;i++){
        sum*=(K-1);
    }
    printf("%lld",sum);
}


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

public class Program
{
	public static void Main()
	{
        string[] s = Console.ReadLine().Split(' ');
	    if(s[1] == "+")Console.WriteLine(int.Parse(s[0])+int.Parse(s[2]));
	    else if(s[1] == "-")Console.WriteLine(int.Parse(s[0])-int.Parse(s[2]));
	}
}

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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)

#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

int n;
int a[102];

int main(){
	cin.tie(0);
	
	cin>>n;
	rep(i, n)cin>>a[i];
	
	rrep(i, n) {
	    cout<<a[i];
	    if(i>0)cout<<' ';
	}
	
	cout<<endl;
	
	return 0;
}



Measured memory_bytes: 3084
#include<iostream>
#include <iomanip>
using namespace std;
int main()
{ 
  int N,count,i;
   cin>>N;
  count=0;
  for(i=1;i<=N;i++)
  {
    if(i%2!=0)
    {
      count++;
    }
  }

cout<<fixed<<setprecision(8)<<(double)count/N;
return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace AOJ0029
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();

                if (string.IsNullOrEmpty(input)) break;

                string[] word = input.Split(' ');

                int MaxLength = 0;
                int MaxOrder = 0;
                IDictionary<string, int> table = new Dictionary<string, int>();

                for (int i = 0; i < word.Length; i++)
                {
                    if (word[i].Length > MaxLength)
                    {
                        MaxLength = word[i].Length; MaxOrder = i;
                    }
                    if (table.ContainsKey(word[i]))
                    {
                        table[word[i]]++;
                    }
                    else {
                        table[word[i]] = 1;
                    }
                }

                List<KeyValuePair<string, int>> list = new List<KeyValuePair<string, int>>(table);
                list.Sort((a, b) => b.Value - a.Value);

                Console.WriteLine("{0} {1}", list[0].Key, word[MaxOrder]);
            }
        }
    }
}

Measured memory_bytes: 9012
// https://atcoder.jp/contests/abc175/tasks/abc175_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#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()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N), C(N);
    REP(i, N) cin >> P[i], P[i]--;
    REP(i, N) cin >> C[i];

    int ans = -1e12;
    // スタート位置
    REP(i, N) {
        vector<int> v;
        int now = i;
        while (true) {
            now = P[now];
            v.emplace_back(C[now]);
            if (now == i) {
                break;
            }
        }
        int loopSum = accumulate(ALL(v), 0LL);
        int cnt = v.size();
        double d = 1.0 / cnt;
        int t = 0;
        REP(j, min(cnt, K)) {
            t += v[j];
            // ループ内の合計x残りループ回数を加算する
            // ループ内の合計が負なら無視
            ans = max(ans, t + max(0LL, loopSum) * (int)((K - j - 1) * d));
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3852
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define MOD 1000000007

long long bigMod(long long base, long long pw)
{
    long long ret = 1, mul = base;
    while(pw)
    {
        if(pw&1)
            ret = (ret*mul)%MOD;
        mul = (mul*mul)%MOD;
        pw >>= 1;
    }
    return ret;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	int n, k;
	while(cin >> n >> k)
	{
		vector<long long> cnt(k);
		long long sum = 0;
		for(int x=k; x>0; x--)
		{
			cnt[x] = bigMod(k/x,n);
			for(int i=2*x; i<=k; i+=x)
				cnt[x] = (cnt[x] - cnt[i] + MOD) %MOD;
			sum = (sum + x*cnt[x]%MOD) %MOD;
		}
		cout << sum << '\n';
	}
}


Measured memory_bytes: 3968
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    [r,d,x] <- r'
    let f x' = r*x'-d
    mapM_ print $ take 10 $ tail $ iterate f x


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

#define ln "\n"
#define SORT(X) sort(X.begin(), X.end())
#define SORTi(X) sort(X.begin(), X.end(), greater<ll>())
#define REP(x, a, b) for (auto x = a; x <= b; x++)
#define REPi(x, b, a) for (auto x = b; x >= a; x--)
#define REPit(x, A) for (auto x = A.begin(); x != A.end(); x++)
#define REPr(x, A) for (auto x : A)
#define ll long long
#define ull unsigned long long
#define PB push_back
#define EB emplace_back
#define UMP unordered_map
#define UST unordered_set

using namespace std;

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

    int A, B, C;
    cin>>A>>B>>C;
    REP(i,1,100)
    {
        if((A*i - C) % B == 0)
        {
            cout<<"YES";
            return 0;
        }
    }
    cout<<"NO";
    return 0;
}

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

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) return 0;
    int w, h;
    cin >> w >> h;
    bool a[h + 1][w + 1];
    for (int i = 0; i < h + 1; i++)
      for (int j = 0; j < w + 1; j++)
	a[i][j] = false;

    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      a[y][x] = true;
    }

    int s, t;
    cin >> s >> t;

    int nmax = 0;
    int count;
    for (int i = 1; i <= h - t + 1; i++) {
      for (int j = 1; j <= w - s + 1; j++) {
	count = 0;
	for (int k = i; k < i + t; k++) {
	  for (int l = j; l < j + s; l++) {
	    if (a[k][l] == true) count++;
	  }
	}
	nmax = max(nmax, count);
      }
    }
    cout << nmax << endl;
  }
}

Measured memory_bytes: 3024
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const X = parseInt(arg[0].split(" ")[0]);
    const A = parseInt(arg[1].split(" ")[0]);
    const B = parseInt(arg[2].split(" ")[0]);
    
    console.log((X - A) % B);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Yes(n) cout<<((n)?"YES":"NO")<<endl
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
int main(void)
{
	string a,b;
  	cin >> a >> b;
  	Yes(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]);
}

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

int64_t root(int64_t n){
    int64_t ret = pow((long double)n, 0.5L);
    while(ret*ret > n) ret--;
    while((ret+1)*(ret+1) <= n) ret++;
    return ret;
}

int main(){
    int N, D, X[10][10];
    cin >> N >> D;
    for(int i=0; i<N; i++) for(int j=0; j<D; j++) cin >> X[i][j];

    int ans = 0;
    for(int i=0; i<N; i++) for(int j=0; j<i; j++){
        int sum = 0;
        for(int k=0; k<D; k++) sum += pow(X[i][k] - X[j][k], 2);
        int r = root(sum);
        if(r*r == sum) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: Good Sequence
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

/* global variables */

mii as;

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    as[ai]++;
  }

  int sum = 0;
  for (mii::iterator mit = as.begin(); mit != as.end(); mit++) {
    const int &x = mit->first, &y = mit->second;
    sum += (y >= x) ? y - x : y;
  }

  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 4736
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
10 3
4 5 6
---+/
/+---test
20 3
4 5 6
---+/
/+---test
210 5
31 41 59 26 53
---+/
/+---test
211 5
31 41 59 26 53
---+/

void main(string[] args) {
  long H, N;
  readf(" %d %d ", &H, &N);

  const A = readln.split.map!(to!long).array;

  (H > A.sum? "No": "Yes").writeln;
}


Measured memory_bytes: 4256
#include <bits/stdc++.h>
     
using namespace std;
typedef long long ll;
const int tmax=10;
const int xmax=100010; 
long DP[tmax][xmax];

int x; 
 
int n, m;
void init_DP(void){
    for(int i = 1; i <=x ; i++){
        DP[0][i]=0;
    }
    DP[0][0]= 1;
}



int main() {
    int i,j; 
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> x;
    init_DP();
    // cout << x << endl;
    init_DP();   
    
    for(int t=1; t<=6; t++){
        int p;
        p = 100 + t -1;
        j = 0;
        DP[t][0]=1;
        for(j=0;j < p ; j++ ){
            DP[t][j] = DP[t-1][j];
        }
        for(j=p; j<= x; j++){
            DP[t][j] = DP[t-1][j] + DP[t][j-p];
        }
    }
    
    // cout << DP[6][x] << endl;
    if(DP[6][x] != 0){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
typedef long long ll;
typedef long double ld;
long long dx[] = {1,0,-1,0};
long long dy[] = {0,1,0,-1};
long long dx8[] = {1,1,0,-1,-1,-1,0,1};
long long dy8[] = {0,1,1,1,0,-1,-1,-1};
long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};

signed main(){
    int N,H,W;
    cin >> N >> H >> W;
    int A,B;
    int ans = 0;
    FOR(i,0,N){
        cin >> A >> B;
        if(A >= H && B >= W)ans++;
    }
    cout << ans << endl;
}

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

const int N = 1e5 + 10;
vector<int> g[N];

int dist[N][2];

void dfs(int s, int p, int type){
   dist[s][type] = dist[p][type] + 1;
   for(auto i: g[s]){
      if(i != p){
         dfs(i, s, type);
      }
   }
}

int main(){

   int n, u, v;
   cin >> n >> u >> v;

   for (int i = 0; i < n-1; ++i)
   {
      int x, y;
      cin >> x >> y;
      g[x].push_back(y);
      g[y].push_back(x);
   }

   dfs(u, 0, 0);
   dfs(v, 0, 1);

   int ans = 0;
   for (int i = 1; i <= n; ++i)
   {
      if(dist[i][0] < dist[i][1])
         ans = max(ans, dist[i][1] - 2);
   }

   cout<<ans;
   return 0;
}


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

pair<long long int,long long int> p[200000];

long long int a[2][200001];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>p[i].first>>p[i].second;
	for(int i=0;i<n;i++)
		if(p[i].first<p[i].second)
			swap(p[i].first,p[i].second);
	sort(p,p+n,greater<pair<long long int,long long int> >());
	a[0][n-1]=p[n-1].second;
	a[1][n-1]=p[n-1].first;
	for(int i=n-2;i>=0;i--){
		a[1][i]=a[1][i+1];
		a[0][i]=min((long long int) p[i].second,a[0][i+1]);
	}
	a[0][n]=a[1][n]=2e9;
	long long int R=p[0].first,B=p[0].second,r=p[0].first,b=p[0].second,ans=6e18;
	for(int i=1;i<n;i++){
		
		ans=min(ans,(R-min(min(a[0][i+1],r),p[i].second))*(max(B,p[i].first)-min(p[i].first,min(a[1][i+1],b))));
		ans=min(ans,(R-min(min(a[1][i+1],r),p[i].second))*(max(B,p[i].first)-min(p[i].first,min(a[0][i+1],b))));
		
		R=max(R,p[i].first);r=min(r,p[i].first);
		B=max(B,p[i].second);b=min(b,p[i].second);
	}
	ans=min(ans,(R-r)*(B-b));
	cout<<ans<<endl;
}

Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, k;
	cin >> a >> b >> k;
	if ((b - a + 1) / 2 + 1 > k) {
		for (int i = a; i < a + k; i++) {
			cout << i << "\n";
		}
		for (int i = b - k + 1; i <= b; i++) {
			cout << i << "\n";
		}
	}
	else {
		for (int i = a; i <= b; i++) {
			cout << i << "\n";
		}
	}
	return 0;
}

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

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




	return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

long long int lcm(long long int x, long long int y);

int main()
{
    int n;
    int i;
    long long int ans = 1;
    
    cin >> n;
    
    long long int t[n];
    
    for(i = 0; i < n; i++) {
        cin >> t[i];
    }
    
    sort(t, t+n);
    
    for(i = 0; i < n; i++) {
        
        if(ans != t[i]) {
            if((t[i] % ans == 0) || (ans % t[i] == 0)) {
                ans = max(ans, t[i]);
            } else {
                ans = lcm(max(ans, t[i]), min(ans, t[i]));
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

long long int lcm(long long int x, long long int y)
{
    long long int i = x, j = y;
    long long int r = i % j;
    
    while(r != 0) {
        i = j;
        j = r;
        r = i % j;
    }
    
    return x / j * y;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int,input().split()))

    count = 0
    flag = False

    set_A = set(A)

    if(len(set_A) == len(A)):
        print('YES')
    else:
        print('NO')
        
    '''
    for i in A:
        if(A.count(i) > 1):
            flag = True
            break

    if(flag):
        print('NO')
    else:
        print('YES')
    '''

'''
    for i in A:
        for j in A:
            if(i == j):
                count += 1
            if(count > 1):
                flag = True
                break
        count = 0

        if(flag):
            break

    if(flag):
        print('NO')
    else:
        print('YES')
        '''

if __name__ == "__main__":
    main()

Measured memory_bytes: 25168
import java.util.*;

public class Main{
  public static void main(String[] arg){
    Scanner sc = new Scanner(System.in);
    double N = sc.nextDouble();
    double ans = 1;
    for(long i = 0; i < N; i++){
      ans = (ans*(i+1))%(Math.pow(10,9)+7);
    }
    System.out.println((int)ans);
  }
}


Measured memory_bytes: 24660
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int N;
	cin >> N;
	vector<bool> C(8, false);
	int over3200 = 0;
	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		if (a >= 3200)
			over3200++;
		else if (a >= 2800)
			C[0] = true;
		else if (a >= 2400)
			C[1] = true;
		else if (a >= 2000)
			C[2] = true;
		else if (a >= 1600)
			C[3] = true;
		else if (a >= 1200)
			C[4] = true;
		else if (a >= 800)
			C[5] = true;
		else if (a >= 400)
			C[6] = true;
		else
			C[7] = true;
	}
	int cnt = 0;
	for (int i = 0; i < 8; i++)
	{
		if (C[i])
			cnt++;
	}
	cout << max(1, cnt) << " " << cnt + over3200 << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

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

int a[200];

int main(void){
    int n;
    ll c = 0;

    scanf("%d",&n);
    REP(i,n)
        scanf("%d",&a[i]);

    REP(i,n){
        RFOR(j,i + 1,n)
            if(a[j] < a[j - 1]){
                swap(a[j],a[j - 1]);
                c++;
            }
    }

    REP(i,n){
        if(i < n - 1)
            printf("%d ",a[i]);
        else
            printf("%d\n",a[i]);
    }
    printf("%lld\n",c);
    return 0;
}

Measured memory_bytes: 3204
import math

n, a, b = map(int, input().split())
hs = list(map(int, (input() for _ in range(n))))

m = sum(hs) // (a + (n-1)*b) - 1
#M = sum(math.ceil(h/a) for h in hs)
M = max(hs) // b + 1

def killable(p, hs, a, b):
    x = sum(max(0, math.ceil((h-p*b) / (a-b))) for h in hs)
    return x <= p

while(m+1 < M):
    c = (m+M) // 2
    if killable(c, hs, a, b):
        M = c
    else:
        m = c
print(M)

Measured memory_bytes: 54616
#include <atcoder/dsu>
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
	int n, q; cin >> n >> q;
	atcoder::dsu uf(n);
	for (int i = 0; i < q; ++i) {
		int t, u, v; cin >> t >> u >> v;
		if (t == 0) uf.merge(u, v);
		else if (uf.same(u, v)) printf("1\n");
		else printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a(0), b(0);
  cin >> a >> b;
 
  if ( (0 == a % 2) ||  (0 == b % 2)) 
  {
    cout << "Even" << endl;
  }
  else
  {
    cout << "Odd" << endl;
  }
}

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

using namespace std;

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int price = x * a + b * y;
  if (x > y) {
    int price1 = 0;
    if (2 * c < a + b) {
      price1 += c * 2 * y;
    }
    else {
      price1 += a * y + b * y;
    }
    if (2 * c < a) {
      price1 += 2 * c * (x - y);
    }
    else {
      price1 += a * (x - y);
    }
    price = min(price, price1);
  }
  if (x < y) {
    int price1 = 0;
    if (2 * c < a + b) {
      price1 += c * 2 * x;
    }
    else {
      price1 += a * x + b * x;
    }
    if (2 * c < b) {
      price1 += 2 * c * (y - x);
    }
    else {
      price1 += b * (y - x);
    }
    price = min(price, price1);
  }
  if (x == y && 2 * c < a + b) {
    price = 2 * c * x;
  }
  cout << price;
}


Measured memory_bytes: 256
using System;

class Program
{
	static void Main(string[] args)
    {
    	var a = Console.ReadLine();
        var b = Console.ReadLine();
        var c = Console.ReadLine();

        var a_count = 0;
        var b_count = 0;
        var c_count = 0;
        var answer = 'A';
        var tmp = 'a';
      	while(true)
        {
        	if (tmp == 'a')
            {           	
                if (a_count == a.Length)
                {
                	answer = 'A';
                  	break;
                }
                else
                {
                	tmp = a[a_count];
                    a_count += 1;
                }
            }
            if (tmp == 'b')
            {           	
                if (b_count == b.Length)
                {
                	answer = 'B';
                  	break;
                }
                else
                {
                	tmp = b[b_count];
                    b_count += 1;
                }
            }
        	if (tmp == 'c')
            {           	
                if (c_count == c.Length)
                {
                	answer = 'C';
                  	break;
                }
                else
                {
                	tmp = c[c_count];
                    c_count += 1;
                }
            }      
        }
        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int m1,d1,m2,d2;
	cin>>m1>>d1>>m2>>d2;
	if(m1==1 ||m1==3|| m1==5 || m1==7 || m1==8 ||m1==10 ||m1==12 )
	{
		if(d1==31)
			cout<<1<<endl;
		else
		cout<<0<<endl;
		return 0;
	}
	if(m1==4 ||m1==6|| m1==9 || m1==11 )
	{
		if(d1==30)
			cout<<1<<endl;
		else
		cout<<0<<endl;
		return 0;
	}	
	if(m1==2)
	{
		if(d1==28)
			cout<<1<<endl;
		else
		cout<<0<<endl;
		return 0;
	

	}
	return 0;
}

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

aa=sorted(a)
th=10**18
ans=1

for i in range(len(aa)):
    if aa[i]==0:
        print(0)
        break
    ans*=aa[i]
    if ans>th:
        print(-1)
        break
    if i==len(aa)-1:
        print(ans)

Measured memory_bytes: 21644
#include <iostream>
#include <algorithm>
using namespace std;
bool cmp(char a,char b)
{
	return a>b;
}
int main()
{
	string s,t;
	int i,n,m;
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),cmp);
	if(s<t)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
int N;
int main() {
	ll ans = 0, t;
	scanf("%lld", &N);
	vector<ll> aa(N);
	map<ll, ll> a;
	rep(i, 0, N)scanf("%lld", &t), a[t]++, aa[i] = t;
	for (auto it = a.begin(); it != a.end(); it++) {
		ll n = it->second;
		ans += n * (n - 1) / 2;
	}
	rep(i, 0, N) {
		printf("%lld\n", ans - a[aa[i]] + 1);
	}
	return 0;
}

Measured memory_bytes: 11008
#include <stdio.h>
#include<string.h>
#include <ctype.h>

int main(void){
    char ch;
    while(1){
        scanf("%c", &ch);
        //"."??????"while"????????????
        if( ch == '\n' ){
            printf("\n");
            break;
        }
        //?°???????????????§?????????
        else if( islower(ch)){
            printf("%c",toupper(ch));
        }
        //??§?????????????°??????????
        else if(isupper(ch)){
            printf("%c", tolower(ch));
        }
        //????????\?????????????????????
        else{
            printf("%c",ch);
        }
    }
    return 0; /*0?????????*/
}

Measured memory_bytes: 524
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			int[] array = new int[n];
			
			for(int i = 0; i < n; i++){
				array[i] = sc.nextInt();
			}
			
			final int purpose = sc.nextInt();
			
			int start = 0;
			int end = n - 1;
			
			int count = 0;
			while(start <= end){
				int med = (end + start) / 2;
				
				count++;
				if(array[med] > purpose){
					end = med - 1;
				}else if(array[med] < purpose){
					start = med + 1;
				}else{
					break;
				}
			}
			
			System.out.println(count);
		}

	}

}

Measured memory_bytes: 12000