akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  vector<ll> v(n);
  rep(i,n) cin >> v[i];

  sort(v.begin(), v.end());
  vector<pair<ld,int>> p;
  int prev = 0;
  v.emplace_back(-1);
  for (int i = 0; i <= n; i++) {
    if (v[i] != v[prev]) {
      p.emplace_back(make_pair(v[prev], i - prev));
      prev = i;
    }
  }

  sort(p.rbegin(), p.rend());

  map<ld, ll> dp;

  auto comb = [&](ll n, ll k){
    ll ret = 1;
    for (int i = 1; i <= k; i++) {
      ret *= n - i + 1;
      ret /= i;
    }
    return ret;
  };

  auto calc = [&](int m){
    ld res = 0.0;
    int cnt = 0;
    int i = 0;
    int add = 0;
    while (cnt < m && i < p.size()) {
      add = min(m - cnt, p[i].second);
      cnt += add;
      res += p[i].first * add;
      i++;
    }
    i--;
    res /= (ld)m;
    dp[res] += comb(p[i].second, add);
  };

  for (int i = a; i <= b; i++) calc(i);

  pair<ld, ll> res;
  res = {0.0, 0LL};
  for (auto e : dp) {
    if (e.first > res.first) {
      res = e;
    }
  }
  printf("%.12Lf\n", res.first);
  printf("%Ld\n", res.second);
  return 0;
}

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

#define ll long long

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

	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	a--;
	ll g=__gcd(c,d);
	ll l=c/g;
	l*=d;
	ll ans;
	ans=b/c+b/d-b/l;
	ans-=a/c+a/d-a/l;
	ans*=-1;
	ans+=b-a;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
//b
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#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 BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair

using namespace std;

static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;

int m, n;
bool vis[1024];
bool amat[1024][1024];

int main(){
	
	while(cin>>n>>m, (n||m)){
		
		CLR(amat);
		CLR(vis);
		
		for(int i=0; i<m; ++i){
			
			int p, q;
			cin>>p>>q;
			
			amat[p][q] = amat[q][p] = true;
		}
		
		int sum = 0;
		vector<int> fr;
		
		for(int i=2; i<=n; ++i){
			
			if(amat[1][i] && !vis[i]){
				fr.push_back(i);
				sum++;
				vis[i] = true;
			}
		}
		
		for(int i=0; i<fr.size(); ++i){
			for(int j=2; j<=n; ++j){
				
				if(amat[fr[i]][j] && !vis[j]){
					sum++;
					vis[j] = true;
				}
			}
		}	
		
		cout << sum << endl;
	}
	
	return 0;	
}

Measured memory_bytes: 2248
#include<iostream>
using namespace std;
int main() {

	int A,B;
	cin >> A>>B;
	if (A >= B)
	{
		if (A - 1 >= B)
			cout << A + A - 1;
		else
			cout << A + B;
	}
	if (A < B)
	{
		if (B - 1 >= A)
			cout << B + B - 1;
		else
			cout << A + B;
	}
	return 0;

}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
using namespace std;

int main() {
    string S,T; cin>>S>>T;
    cout<<T<<S<<endl;
}

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

int main(void){
   int n;string x;
   cin >> n;
   string s[n]; int t[n];
   for(int i = 0;i < n;i++)cin >> s[i] >> t[i];
   cin >> x;
   int max = 0,num = 0;
   for(int i = 0;i < n;i++){
       if(s[i] != x)max += t[i];
       else {
           max += t[i];
           break;
       }
   }
   for(int i = 0;i < n;i++)num += t[i];
    cout << num - max;
}

Measured memory_bytes: 256
N = int(input())
ab = []
for i in range(N):
    a, b = map(int, input().split())
    ab.append((i, a, b))

sum_list = []
for i in range(N):
    _, a, b = ab[i]
    sum_list.append((a + b, i))
sum_list = sorted(sum_list, key=lambda x:-x[0])

ans = 0

for k in range(N):
    if k % 2 == 0:
        su = sum_list[k]
        ans += ab[su[1]][1]
    else:
        su = sum_list[k]
        ans -= ab[su[1]][2]
print(ans)




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

int main(){
    int flag=1;
    int n;
    long long ans=0;
    int num=0,j=0;

    cin >>n;
    int data[3*n];
    
    for (int i = 0; i < 3*n; i++){
        cin >>data[i];
    }
    sort(data,data+3*n,greater<int>());

    while(num < n){
        if(j%2 == 1){
            ans += data[j];
            num++;
        }
        j++;
    }
    
    cout << ans <<endl;
    
    //cout <<fixed<<setprecision(16)<< ans <<endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n, k;
   cin >> n >> k;
   int mx = (n - 1) * (n - 2) / 2;
   if (mx < k) {
      puts("-1");
      return 0;
   }
   vector<P> ans;
   rep(i, 0, n - 1) { ans.push_back(P(i + 1, n)); }
   int add = mx - k;
   vector<P> edge;
   rep(i, 0, n - 1) rep(j, 0, i) edge.push_back(P(i + 1, j + 1));
   rep(i, 0, add) ans.push_back(edge[i]);
   cout << ans.size() << endl;
   rep(i, 0, ans.size()) {
      cout << ans[i].first << " " << ans[i].second << endl;
   }
   return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
  int i,arr[100]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> i;
  cout << arr[i-1] << endl;
  return 0;

}


Measured memory_bytes: 256
s = input()[::-1]
t = input()[::-1]
 
def check(c,t):
    if len(c) < len(t):
        return False
    for i in range(len(t)):
        if c[i] != "?" and c[i] != t[i]:
            return False
 
    return True
        
 
i = 0 
Has = False
ans = ""
while i < len(s):
    if (s[i] == "?" or s[i] == t[0]) and not Has:
        if check(s[i:],t):
            Has = True
            ans += t
            i += len(t)
        else:
            if s[i] == "?":
                ans += "a"
            else:
                ans += s[i]
            i += 1
 
    elif s[i] == "?":
        i += 1
        ans += "a"
    else:
        ans += s[i]
        i += 1
 
if Has:
    print(ans[::-1])
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int n[101];
  int i;
  int num;
  cin >> num;
  for(i=0;i<num;i++) cin >> n[i];
  cout << n[num-1];
  for(i=1;i<num;i++) cout <<" "<< n[num-i-1];
  cout << endl;
  return 0;
}



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

int main() {
  ll l, r;
  cin >> l >> r;
  r = min(r, l+4038);
  int ans = 2018;
  for (ll i = l; i <= r; i++) {
    for (ll j = i+1; j <= r; j++) {
      int x = i*j%2019;
      ans = min(ans, x);
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n;
  cin >>n;
  vector<int> bot(n,-1);
  for(int i=0;i<n;i++){
    cin>>bot.at(i);
  }
  int c=0,a=0;
  
  vector<int> fl(n,0);
  while(c>-1){
    a=bot.at(a)-1;
    c++;
    if(a==1){
      break;
    }
    if(fl.at(a)==1){
        c=-1;
    }
    fl.at(a)=1;
  }
  cout<<c<<endl;
}


Measured memory_bytes: 1024
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {

    int h,w;

    
    while(1){
        cin >> h >> w;
        
        if(h==0 && w==0)
            break;
        
        for(int i=0; i<h; i++){
            if(i%2==0){
                for(int j=0; j<w; j++){
                    if(j%2==0)
                        cout << "#";
                    else
                        cout << ".";
                }
            }
            else{
                for(int j=0; j<w; j++){
                    if(j%2!=0)
                        cout << "#";
                    else
                        cout << ".";
                }
            }
            cout << endl;
            
        }
        cout << endl;
    }
    
    return 0;
    
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a, LL b) {LL s = 1; while (b > 0) {if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1;} return s;}
LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
int dr[2][4] = {1, -1, 0, 0, 0, 0, -1, 1};
typedef pair<int, int> P;

const int maxn = 200 + 10;
int X[maxn][maxn];

bool judge(int n) {
	int t = sqrt(n);
	return t * t == n;
}
int main(void)
{
	LL L, R;
	cin >> L >> R;
	if ((R - L + 1) >= 2019)
		cout << "0" << endl;
	else {
		LL t = INFF;
		for (LL i = L; i <= R; ++i) {
			for (LL j = i + 1; j <= R; ++j) {
				t = min(t, i * j % 2019);
			}
		}
		cout << t << endl;
	}



	return 0;
}

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

const int N = 100000, A = 1e9;

int n, a[N];

int main() {
  cin >> n;
  rep(i, n) cin >> a[i];

  vector<int> factor;
  for (int i = 1; i * i <= A; i++) {
    rep(ai, 2) {
      if (a[ai] % i == 0) {
        factor.push_back(i);
        factor.push_back(a[ai] / i);
      }
    }
  }

  int ans = 0;
  rep(i, factor.size()) {
    int c = 0;
    rep(j, n) if (a[j] % factor[i] == 0) c++;
    if (c >= n - 1) ans = max(ans, factor[i]);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
const double pi=acos(-1.0);
const double eps=1e-9;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair <int,int>
#define piii pair < pii, int>
#define pll pair <long long , long long>
#define plll pair <pll , long long>
#define hjsagjfasjg y1
typedef long long ll;

const ll M=(ll)1e9+7;
const int N=(int)2e5;

ll ans,fact[N],h,w,b,a,was;

ll Pow(ll x,ll a)
{
	if(a==0)return 1;
	if(a==1) return x;
	ll t=Pow(x,a/2);
	if(a%2==0) return t*t%M;
	return t*t%M*x%M;
}

ll o(ll x)
{
	return Pow(x,M-2);
}

ll c(ll n,ll k)
{
	return fact[n]*o(fact[n-k])%M*o(fact[k])%M;
}

int main()
{
	ios:: sync_with_stdio(false);
	cin >> h >> w >> a >> b;
	fact[0]=1;
	for(int i=1;i<N;i++)
		fact[i]=fact[i-1]*i%M;
	for(int i=0;i<h-a;i++)
	{
		ans+=c(b+i,b)*c(w-b+h-i-2,w-b-1)%M;
		ans%=M;
		ans-=was*c(w-b+h-i-2,w-b-1)%M;
		ans+=M;
		ans%=M;
		was=c(b+i,b);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
bool used[105];
int main()
{
  int n,ans=0;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    int x;
    cin>>x;
    if(!used[x])
    {
      used[x]=true;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

static const int MAX = 100;

int A[MAX];
int N;

void insertionSort();
void Print();

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


void insertionSort() {
    int v, j;
    Print(); // output
    for (int i = 1; i < N; i++) {
        v = A[i];
        j = i - 1;
        while (j >= 0 and A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j+1] = v;
        
        Print(); // output

    }
}

void Print() {
    for (int i = 0; i < N; i++) {
        if (i) cout << ' ';
        cout << A[i];
    }
    cout << '\n';
}



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

int main() {
    ll N, K, ans = 0;
    cin >> N >> K;
    ans += pow((int)(N / K), 3);
    if(K % 2 == 0)
        ans += pow((int)((N + K / 2) / K), 3);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <math.h>
#include <bitset>
#include <vector>
using namespace std;
 
 int n, W;
 int weight[110], value[110];
 int dp[1000][5500];

int main() {
  int n;
  bool flag=0;
  cin >> n;
  for(int i=0;i<=25;i++){
      for(int j=0;j<=14;j++){
          if(4*i+7*j==n)flag=1;
      }
  }
  if(flag){
      cout <<"Yes"<<endl;
  }else{
      cout <<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#define EPS 1e-9
using namespace std;
int S,A,C,N,M=256;
int l[257];
int u[257];

int main(){
    int i,s,a,c;
    double b;
    while(1){
        scanf("%d",&N);
        if(!N){break;}
        for(i=1;i<=N;i++){
            scanf("%d",&l[i]);
        }
        double r=1e5;
        for(S=15;S>=0;S--){
            for(A=15;A>=0;A--){
                for(C=15;C>=0;C--){
                    int q,m[256]={0};
                    double p=0.0;
                    u[0]=S;
                    for(i=1;i<=N;i++){
                        u[i]=(A*u[i-1]+C)%M;
                        m[(l[i]+u[i])%M]++;
                    }
                    for(i=0;i<256;i++){
                        if(m[i]){p+=((double)(m[i])/N*log((double)(m[i])/N));}
                    }
                    if(r+EPS>=-p){
                        r=-p;
                        s=S,a=A,c=C;
                    }
                }
            }
        }
        printf("%d %d %d\n",s,a,c);
    }
    return 0;
}




Measured memory_bytes: 2756
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void)
{		
	int n;
	cin >> n;
	
	int a[10000];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	int min = a[0], max = a[0];
	long int sum = 0;
	for (int j = 0; j < n; j++) {
		if (a[j] < min) min = a[j];
		if (a[j] > max) max = a[j];
		sum += a[j];
	}
	
	cout << min << " " << max << " " << sum << endl;
	
	return 0;
}

Measured memory_bytes: 3144
package main

import (
	"fmt"
	"os"
	"bufio"
	"strconv"
	// "strings"
)

var s = bufio.NewScanner(os.Stdin)

func nextLine() string {
	s.Scan()
	return s.Text()
}

func main() {
	ni := []int64{}
	points := []int64{}
	var n, k, q int64
	fmt.Scan(&n)
	fmt.Scan(&k)
	fmt.Scan(&q)
	for i := int64(0); i < q; i++ {
		s2 := nextLine()
		sConv, _ := strconv.ParseInt(s2, 10, 64)
		ni = append(ni, sConv)
	}
	for i := int64(0); i < n; i++ {
		points = append(points, k)
	}
	for _, co := range ni {
		coNum := co - 1
		points[coNum] += 1
	}
	for _, point := range points {
		if (point - q) <= 0 {
			fmt.Println("No")
		} else {
			fmt.Println("Yes")
		}
	}
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

using R = double;
R x[41][41][41], dp[41][41][41], area[41][41][41];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    constexpr R PI = acos(-1);

    while(1) {
        ll n, m;
        cin >> n >> m;
        if(!n) break;
        vector<R> p(n);
        REP(i, n) cin >> p[i], p[i] *= 2*PI;

        REP(i, n) FOR(j, i, n) FOR(k, j, n) {
            area[i][j][k] = (sin(p[j]-p[i]) + sin(p[k]-p[j]) + sin(p[i]-p[k]))/2;
        }

        REP(i, 41) REP(j, 41) REP(k, 41) dp[i][j][k] = -LLINF;
        REP(i, 41) REP(j, 41) dp[i][j][2] = 0;

        R ans = -LLINF;
        REP(l, n) FOR(cnt, 2, m) FOR(r, l+1, n) FOR(i, r+1, n) {
            if(dp[l][r][cnt] == -LLINF) continue;
            chmax(dp[l][i][cnt+1], dp[l][r][cnt] + area[l][r][i]);
            if(cnt+1 <= m) chmax(ans, dp[l][i][cnt+1]);
        }

        cout << fixed << setprecision(6) << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 4548
#include <iostream>
#include <vector>
#include <string>
#include <functional>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

int main(){
  string S;
  cin >> S;
  int al[26]={0};
  for(int i=0;i<4; i++){
    al[S[i]-'A']++;
  }
  int cnt=0;
  for(int i=0;i<26;i++){
    if(al[i]==2){
      cnt++;
    }
  }
  if(cnt==2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main(){
  int A,B;
  string S;
  cin >> A >> B >> S;

  for(int i=0; i<A; i++){
    if(S[i]<'0' || '9'<S[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  if(S[A]!='-'){
    cout << "No" << endl;
    return 0;
  }
  for(int i=A+1; i<A+B+1; i++){
    if(S[i]<'0' || '9'<S[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    int W, H, x, y, r;
    
    cin >> W >> H >> x >> y >> r;
    
    if(0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3112
X, Y = map(int, input().split())
MOD = 10**9+7
MAX = 10**6+1

 # a!のテーブルfact
fact = [0] * MAX

def comb_init():
    # 累積積のイメージ
    fact[0] = fact[1] = 1
    for i in range(2, MAX):
        fact[i] = i * fact[i-1] % MOD

def comb(n, r):
    return fact[n]*pow(fact[r], -1, MOD)*pow(fact[n-r], -1, MOD)%MOD  

if (X+Y) % 3 != 0:
    print(0)
else:
    num = (X+Y)//3
    p = (Y - X + num) // 2
    q = (X + num - Y) // 2
    if not num >= min(p, q) >= 0:
        print(0)
        exit()
    comb_init()
    print(comb(num, min(p, q)))

Measured memory_bytes: 48524
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N = I()
A = III()
B = III()
C = III()

ans = 0
for i in range(N):
    ans += B[i]
    if i!=N-1:
        if A[i+1] == A[i]+1:
            ans += C[A[i]-1]
        
print(ans)

Measured memory_bytes: 38256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

N = int(input())
S = np.array([ord(x) for x in input().rstrip()],dtype=np.int64)

MOD = 10**9 + 7
base = 1234

def cumprod(arr):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

x = np.full(N,base,np.int64); x[0] = 1
power = cumprod(x)
x = np.full(N,pow(base,MOD-2,MOD),np.int64); x[0] = 1
power_inv = cumprod(x)

# rolling hash
H = S * power % MOD
Hcum = H.cumsum() % MOD

def test(n):
    # 長さnの文字列で2回現れるものが存在する
    x = (Hcum[n-1:N] - Hcum[:N-n+1] + H[:N-n+1]) % MOD
    x *= power_inv[:N-n+1]
    x %= MOD
    for i,a in np.ndenumerate(x):
        if (x[i[0]+n:] == a).any():
            return True
    return False

left = 0 # 存在
right = N+1 # 非存在
while left + 1 < right:
    mid = (left + right)//2
    if test(mid):
        left = mid
    else:
        right = mid

answer = left
print(answer)

Measured memory_bytes: 14796
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    string s; cin >> s;
    s[3] = '8';
    OUT(s)

    return 0;
}

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

int main(){
  int64_t a,b,k;
  cin >> a >> b >> k;
  
  
    if(a >= k){
      cout << a-k << " " <<  b << endl;
    }else if( a<= k && k<=a+b ){
      cout << 0 << " "<<b-(k-a) << endl;
    }else if(a+b <= k){
      cout << 0 <<" "<< 0<< endl;
    } 
  
  
}

Measured memory_bytes: 256
n,p=map(int,input().split())
s=[int(j) for j in input()][::-1]

if p==2:
    ans=0
    for i,j in enumerate(s):
        if j%2==0:
            ans+=(n-i)
    print(ans)
    exit()
if p==5:
    ans=0
    for i,j in enumerate(s):
        if j%5==0:
            ans+=(n-i)
    print(ans)
    exit()

c=[0]*p
tmp=0
c[0]+=1
t=1
import numpy as np
for i in s:
    tmp+=t*i
    c[tmp%p]+=1
    t=(t*10)%p
c=np.array(c)
ans=c*(c-1)//2
print(ans.sum())

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

int main() {
  int n;
  	cin>>n;
  vector<int>vec(n);
  vector<int>bec(n);
  vector<int>all(n);
  for(int i=0;i<n;i++){
    	cin>>vec[i];
  }
  for(int i=0;i<n;i++){
        cin>>bec[i];
  }
	int sum=0;
  for(int i=0;i<n;i++){
		all[i]+=(vec[i]-bec[i]);
  }
  	sort(all.begin(), all.end());
  for(int i=0;i<n;i++){
	if(all[i]>0){
      sum+=all[i];
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100007)

def main():
    n, m = map(int, input().split())
    
    grid = [[] for _ in range(n)]
    
    for _ in range(m):
        x, y = map(int, input().split())
        grid[x-1].append(y-1)
    
    memo = [-1]*n
    
    def dp(n):
        if memo[n] != -1:
            return memo[n]
        res = 0
        for v in grid[n]:
            res = max(res, dp(v)+1)
        memo[n] = res
        return res
    
    ans = 0
    for i in range(n):
        sub = dp(i)
        if ans < sub:
            ans = sub
        
    print(ans)
    
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 74364
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int a,b,c;
	cin>>a>>b>>c;
	int k=a-b;
	int p=c-k;
	if(p<=0)cout<<0;
	else cout<<p;
	return 0;
}

Measured memory_bytes: 384
from itertools import permutations
def check(queen):
    for r1, c1 in queen:
        if any((r1 != r2 or c1 != c2) and (r1 == r2 or c1 == c2 or r1 + c1 == r2 + c2 or r1 - c1 == r2 - c2) for r2, c2 in queen):
            return False
    return True
N = int(input())
Q, row, col = [], list(range(8)), list(range(8))
for _ in range(N):
    r, c = map(int, input().split())
    Q.append((r, c))
    row.remove(r)
    col.remove(c)
for l in permutations(col):
    queen = Q[:] + list(zip(row, l))
    if check(queen):
        board = [''.join('Q' if (r, c) in queen else '.' for c in range(8)) for r in range(8)]
        print(*board, sep='\n')
        break

Measured memory_bytes: 7760
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();

    for i in 1..b + 1 {
        if (a * i) % b == c {
            println!("YES");
            return;
        }
    }
    println!("NO");
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

#define ll long long
#define llong long long
#define REP(i,n) for(auto i=0;i<n;++i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define ALL(v) v.begin(),v.end()
#define pb push_back

using namespace std;

//約数が現在の範囲で何個あるか
int divisor[100001];

//その値が範囲内に2個以上あるか
bool is_used[100001] = {};

//現在の範囲で2個以上あるものの総数
int num;


//値xの約数について、範囲に追加
void plus_divisor(int x){
  
  divisor[x]++;
  
  for(int i = 1; i * i <= x; ++i){
    if(x % i == 0){
      divisor[i]++; 
      if(i * i != x) divisor[x / i]++;
      if(divisor[i] >= 2 && !is_used[i]){
        num++;
        is_used[i] = true;
      }
      if(divisor[x / i] >= 2 && !is_used[x / i]){
        num++;
        is_used[x / i] = true;
      }
    }
  }
}

//値xの約数について、範囲から削除
void minus_divisor(int x){

  
  divisor[x]--;
  
  for(int i = 1; i * i <= x; ++i){
    if(x % i == 0){
      divisor[i]--; 
      if(i * i != x) divisor[x / i]--;
      if(divisor[i] < 2 && is_used[i]){
        num--;
        is_used[i] = false;
      }
      if(divisor[x / i] < 2 && is_used[x / i]){
        num--;
        is_used[x / i] = false;
      }
    }
  }
}

int main(){

  int n, w;
  cin >> n >> w;
  
  for(int i = 1; i <= w; ++i){
    plus_divisor(i);
  }

  for(int i = 1; i <= n - w + 1; ++i){
    cout << num;
    if(i != n - w + 1){
      minus_divisor(i); plus_divisor(i+w);
      cout << " ";
    }else{
      cout << "\n";
    }
  }

  return 0;
}




Measured memory_bytes: 3508
n, Y = map(int, input().split())
for x in range(n+1):
    for y in range(n-x+1):
        z = n-x-y
        if (x*10000 + y*5000 + z*1000) == Y:
            print(x, y, z)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 40684
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include <numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD=1000000007;
//scanf("%d", &a); '\n';


int main() {
	ll n;
	cin >> n;
	if (n % 2 != 0) {
		cout << 0; return 0;
	}
	ll j = 1;
	ll ans = 0;
	while (n >=(10 * j)) {
		ll p = 10 * j;
		ans += ll(n /p);
		j *= 5;
	}
	cout << ans;
	}

	

Measured memory_bytes: 256
ps = [1]
999.times do
  p = ps.last
  ps << p + -p / p.abs * (-1i)
end
loop do
  n = gets.to_i
  break if n < 0
  n -= 1
  puts "%.2f\n%.2f" % [ps[n].real, ps[n].imag]
end

Measured memory_bytes: 8828
#include<iostream>
#include<cmath>

using namespace std;

int small=10000;

int main(){
 int n, x;
   cin >> n >> x;
 int m[n];
  for(int i=0;i<n;i++){
   cin >> m[i];
    x-=m[i];
  small=min(small,m[i]);
  }
  
  cout << n+x/small << endl;
  }

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

#define _USE_MATH_DEFINES
#define reb(i,b,n)         for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n)           reb(i,0,n)
#define each(it,v)         for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v)        for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vsort(v)           sort((x).begin(), (x).end()
#define rvsort(v)          sort((x).rbegin(), (x).rend()
#define mp(a, b)           make_pair(a, b)
#define fi                 first
#define se                 second
#define pb                 push_back
#define dbg(x)             cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;
#define dbgArr(table, n)   rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define dbg2Arr(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}

using namespace std; using std::stringstream;

typedef long long       ll; typedef unsigned long long ull; typedef long double     ld;
typedef pair <int, int> P;  typedef pair <int, P>      PP;
typedef vector<int>     vi; typedef vector<vi>         vvi; typedef vector<ll>      vl;
typedef vector<P >      vP; typedef vector<char>       vc;  typedef vector<string>  vs;

static const int    INF  = 0x3f3f3f3f;
static const ll     INFL = 0x3f3f3f3f3f3f3f3fLL;
static const double EPS  = 1e-9;
static const ll     MOD  = 1000000007LL;

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

#define NG_VAL  1000000000000000000

int main(int argc, char *argv[])
{
    int N;
    cin >> N;
    vector<ull> A(N);
    ull ans = 1;
    rep(i, N) {
        cin >> A[i];
        if (A[i] == 0) {
            ans = 0;
        }
    }

    if (ans == 0) {
        cout << 0 << endl;
    } else {
        ans = A[0];
        bool ret = true;
        reb(i, 1, N) {
            ull tmp = NG_VAL / A[i];
            if (tmp < ans) {
                ret = false;
                break;
            }
            ans *= A[i];
            // if (ans > NG_VAL) {
            //     ret = false;
            //     break;
            // }
        }

        if (ret) {
            cout << ans << endl;
        } else {
            cout << -1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4052
void main() {
    int n = readln.chomp.to!int;
    double[string] rate;
    rate["JPY"] = 1.0, rate["BTC"] = 380000.0;
    double gift = 0.0;
    foreach (i; 0 .. n) {
        string[] tmp = readln.split;
        gift += tmp[0].to!double * rate[tmp[1]];
    }
    gift.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 256
void main() {
	auto N = ri;
	auto H = readAs!(int[]);

	ulong res, tmp;
	int current = H[0];
	foreach(v; H[1..$]) {
		if(current >= v) {
			tmp++;
		} else {
			res = max(res, tmp);
			tmp = 0;
		}
		current = v;
	}
	res = max(res, tmp);
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 4092
def num(s):
    return ord(s) - ord("a")

S = input()

used = [False] * 26

for s in S:
    used[num(s)] = True

if len(S) != 26:
    for i in range(26):
        if not used[i]:
            ans = S + chr(ord("a") + i)
            break
    print(ans)
else:
    if S == "zyxwvutsrqponmlkjihgfedcba":
        print(-1)
    else:
        for i in range(len(S) - 1, -1, -1):
            s = S[i]
            used[num(s)] = False
            isOk = False
            for j in range(num(s) + 1, 26, 1):
                if not used[j]:
                    isOk = True
                    last = j
                    break
            if isOk:
                ans = S[:i] + chr(ord("a") + j)
                print(ans)
                break



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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(ll i=ll(m); i<ll(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<ll,ll>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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 int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 10000000007;



int main() {

	ll n, d;
	cin >> n >> d;

	ll ans = 0;

	d *= d;

	REP(i, n) {
		ll x, y;
		cin >> x >> y;
		x *= x;
		y *= y;
		if (x + y <= d)ans++;
	}

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

Measured memory_bytes: 3628
def judge(N,Y):
    a,b,c = 10000,5000,1000
    if Y % c != 0 or Y < c or N*a < Y:
        return (-1,-1,-1)
    else:
        a,b,c,Y = a//1000,b//1000,c//1000,Y//1000
        for s in range(N+1):
            for t in range(N-s+1):
                u = N-s-t
                if a*s + b*t + c*u == Y:
                    return (s,t,u)
        return (-1,-1,-1)

def main():
    N,Y = map(int,input().split())

    ans = judge(N,Y)
    print(" ".join(map(str,ans)))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		double ans = 0.0;
		for(int i = 1; i < N + 1; i++) {
			int tmp = i;
			double per = 1.0 / N;
			while(tmp < K) {
				tmp *= 2;
				per /= 2.0;
			}
			ans += per;
		}
		System.out.println(ans);
	}

}


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

ll chk(ll x, ll b) {
  ll sum = 0;
  while (x) {
    sum += x % b;
    x /= b;
  }
  return sum;
}

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

  ll ncr[12][12] = {};
  for (int i = 0; i <= 10; ++i) {
    ncr[i][i + 1] = i ? 2 : 1;
    ncr[i][0] = ncr[i][i] = 1;
    for (int j = 1; j < i; ++j)
      ncr[i][j] = ncr[i - 1][j] + ncr[i - 1][j - 1], ncr[i][i + 1] += ncr[i][j];
  }
  string s;
  cin >> s;
  int n = s.size();
  ll ans = 0;
  for (int l = 0; l < n; ++l) {
    ll x = 0;
    int lf = max(0, l - 1);
    for (int r = l; r < n; ++r) {
      x = x * 10 + (s[r] - '0');
      int rg = max(0, n - r - 2);
      ans += x * ncr[lf][lf + 1] * ncr[rg][rg + 1];
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; 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)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
#define INF 1001001001

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

    ll rmin,rmax,bmin,bmax;
    rmin = INF;
    rmax = 0;
    bmin = INF;
    bmax = 0;
    vector<pair<ll,ll>> v;
    rep(i,n){
        ll a,b; cin >> a >> b;
        if(a>b)swap(a,b);
        v.push_back(P(a,b));
        if(a<rmin)rmin = a;
        if(rmax<a)rmax = a;
        if(b<bmin)bmin = b;
        if(bmax<b)bmax = b;
    }
    ll ans = (rmax-rmin)*(bmax-bmin); // パターン1

    /*
    rep(i,n){
        if(v[i].first==rmin && v[i].second==bmax){
            cout << ans << endl;
            return 0;
        }
    }
    */
    sort(v.begin(),v.end());

    int use[n] = {};
    
    rmax = bmax;
    bmax = 0;
    bmin = INF;
    rep(i,v.size()){
        if(v[i].first==rmin){
            ll b = v[i].second;
            if(b<bmin)bmin = b;
            if(bmax<b)bmax = b;
            use[i] = 1;
        }else if(v[i].second==rmax){
            ll b = v[i].first;
            if(b<bmin)bmin = b;
            if(bmax<b)bmax = b;
            use[i] = 1;
        }else if(v[i].second <= bmax){
            ll b = v[i].second;
            if(b<bmin)bmin = b;
            use[i] = 1;
        }else if(bmin <= v[i].first){
            ll b = v[i].first;
            if(bmax<b)bmax = b;
            use[i] = 1;
        }
    }

    


    rep(i,v.size()){
        if(use[i]==1)continue;
        if(v[i].second<=bmax){ // 決定的
            ll b = v[i].second;
            if(b<bmin)bmin = b;
            continue;
        }
        if(bmin<=v[i].first){ // 終了条件
            bmax = max(bmax,(ll)v[v.size()-1].first);
            ans = min(ans,(rmax-rmin)*(bmax-bmin));
            cout << ans << endl;
            return 0;
        }
        ll tmp_bmin = v[i].first;
        ll tmp_bmax = max(bmax,(ll)v[v.size()-1].first);
        ans = min(ans,(rmax-rmin)*(tmp_bmax-tmp_bmin));
        bmax = max(bmax,(ll)v[i].second);
    }
    ans = min(ans,(rmax-rmin)*(bmax-bmin));

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


Measured memory_bytes: 6384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
using namespace std;

template<class T> inline void chmax(T &a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T &a, T b) {
	a = std::min(a, b);
}

int mod_pow(int x, int y, int m = mod) {
	int res = 1;
	while (y) {
		if (y % 2) {
			res *= x;
			res %= m;
		}
		x = x * x % mod;
		y /= 2;
	}
	return res;
}
int kai[1005];
void init() {
	kai[0] = 1;
	REP(i,1001)
		kai[i] = kai[i - 1] * i % mod;
}
int comb(int x, int y) {
	if (y > x)
		return 0;
	return kai[x] * mod_pow(kai[x - y], mod - 2, mod) % mod
			* mod_pow(kai[y], mod - 2, mod) % mod ;
}

int n, a, b, c, d;
int dp[1005][1005];
signed main() {
	init();
	cin >> n >> a >> b >> c >> d;
	dp[0][0] = 1;
	rep(i,n)
	{
		rep(j,n+1)
		{
			dp[i][j] %= mod;
			dp[i][j + 1] += dp[i][j];
		}
		for (int k = 1; k <= n; k++) {
			if (k < a || k > b)
				continue;
			int ans = 1ll;
			for (int l = 1;; l++) {
				int m = i + k * l, pre = i + k * (l - 1);
				if (m > n || l > d)
					break;
				ans *= comb(n - pre, k);
				ans %= mod;
				int memo = ans * mod_pow(kai[l], mod - 2, mod);
				memo %= mod;
				if (l >= c) {
					dp[m][k] += memo * dp[i][k - 1];
					dp[m][k] %= mod;
				}
			}
		}
	}
	int sum = 0;
	rep(i,n+1)
		sum += dp[n][i];
	cout << sum % mod << endl;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
  long long l,r;
  cin>>l>>r;
  long long mina=2018;
  r=min(r,l+2019);
  for(auto i=l;i<=r;++i)
    for(auto j=i+1;j<=r;++j)
    {
      mina=min(mina,(i*j)%2019);
    }
    cout<<mina;
  }

Measured memory_bytes: 256
#from:#7967379
N = int(input())
W = list(map(int, input().split()))
judge = True

for i in range(N-1):
  if W[i]<W[i+1]:
    W[i+1]-=1
  if W[i]>W[i+1]:
    judge = False
    break
print('Yes' if judge else 'No')

'''
in [1]:
  4
  4 3 5 6
out [1]:
  No
'''

Measured memory_bytes: 14396
import java.util.Scanner;
class Main{
public static void main(String[] args){
 Scanner scan = new Scanner(System.in);
 
 int N = scan.nextInt();
 int FB[] = new int[N];
 long sum = 0;
  //配列にNまで代入
  for (int i = 0; i < N; i++){
    FB[i] = i + 1;
  }
  //文字へ置換
  for (int i = 0; i < N  ; i++){
   if (FB[i] % 3 == 0 || FB[i] % 5 == 0){
     FB[i] = 0;
   }
    sum = sum + FB[i];
   }
  System.out.println(sum);
 }
}

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

# a 回目、b 回目を考えたとき、a mod K と b mod K の値が異なれば、a, b それぞれの回で独立に手を選べる。
# mod K の値に応じて、N 回のジャンケンを K 個のグループに分けたとき、各グループに対して、最大何点取れるかを考えればよい。
# あるグループで最大何点取れるかは、前回の手を覚えておきながら DP or 貪欲法で求めればよい。

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = str(input())
# print(n, k, r, s, p, t)

t_list = list(t)
groups = [[] for i in range(k)]
for i in range(len(t_list)):
    mod = i % k
    groups[mod].append(t_list[i])
# print(groups)

def calc_score(my_hand, hand):
    if my_hand == 'r' and hand == 's':
        return r
    elif my_hand == 's' and hand == 'p':
        return s
    elif my_hand == 'p' and hand == 'r':
        return p
    else:
        return 0

def get_win_hand(hand):
    if hand == 'r':
        return 'p'
    elif hand == 's':
        return 'r'
    else:
        return 's'

def get_best_hand(j, hands, my_hand_prev):
    hand = hands[j]
    win_hand = get_win_hand(hand)
    # decide which hand to take
    candidates = ['r', 's', 'p']
    # when we can win
    if j == 0 or j != 0 and win_hand != my_hand_prev:
        candidates = [win_hand]
    else:
        # can't take a hand twice in a row
        candidates.remove(my_hand_prev)
        # just pop when it's last hand in a group
        if j == len(hands) - 1:
            candidates.pop()
        else:
            hand_next = hands[j+1]
            win_hand_next = get_win_hand(hand_next)
            # just pop when win_hand_next has already removed
            if win_hand_next == my_hand_prev:
                candidates.pop()
            else:
                candidates.remove(win_hand_next)
    return candidates[0]

result = 0
# for each group
for i in range(k):
    hands = groups[i]
    my_hand_prev = ''
    # for each hand in a group
    for j in range(len(hands)):
        my_hand = get_best_hand(j, hands, my_hand_prev)
        my_hand_prev = my_hand
        # calculate score according to the hand decided
        result += calc_score(my_hand, hands[j])

print(result)


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

typedef long long ll;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> pllpl;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;

const double INF = 1e18;

inline ll sq(ll x){
	return x*x;
}

vector<pllpl> titik;
vector<pid> adj[1010];

void make_edge(int x, int y){
	double jar = sqrt(sq(titik[x].first.first - titik[y].first.first) + sq(titik[x].first.second - titik[y].first.second));
	jar -= titik[x].second + titik[y].second;
	jar = max(0.00,jar);
	adj[x].push_back(make_pair(y,jar));
	adj[y].push_back(make_pair(x,jar));
	return ;
}

double jar[1010];

double dijk(int x, int y){
	for(int i=1;i<=y;i++) jar[i] = INF;
	priority_queue<pdi> pq;
	jar[x] = 0.00;
	pq.push(make_pair(0.00,x));
	while(!pq.empty()){
		pdi cur = pq.top(); pq.pop();
		if(cur.second == y) return fabs(cur.first);
		if(jar[cur.second] < -cur.first) continue;
		int now = cur.second;
		double tmp = cur.first;
		for(int i=0;i<adj[now].size();i++){
			int skrg = adj[now][i].first;
			double tmpj = tmp-adj[now][i].second;
			if(jar[skrg] <= -tmpj) continue;
			jar[skrg] = -tmpj;
			pq.push(make_pair(tmpj,skrg));
		}
	}
	return -1;
}

int n;

int main(){
	pll a,b;
	scanf("%lld%lld%lld%lld",&a.first,&a.second,&b.first,&b.second);
	titik.push_back(make_pair(a,0));
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		ll x,y,z;
		scanf("%lld%lld%lld",&x,&y,&z);
		titik.push_back(make_pair(make_pair(x,y),z));
	}
	titik.push_back(make_pair(b,0));
	for(int i=0;i<titik.size();i++){
		for(int j=i+1;j<titik.size();j++){
			make_edge(i,j);
		}
	}
	double ans = dijk(0,titik.size()-1);
	printf("%.10lf\n",ans);
	return 0;
}///

Measured memory_bytes: 23736
#include <iostream>
#include <vector>
#include <string>
#include <cstddef>
#include <limits>

template<class T>
using matrix = std::vector<std::vector<T>>;
using usize = std::size_t;
using isize = std::ptrdiff_t;

constexpr usize word = 26;
constexpr usize infty = std::numeric_limits<usize>::max();

matrix<usize> make_index (const std::string &s) {
	const usize n = s.length();
	matrix<usize> index(n + 1, std::vector<usize>(word, n + 1));
	for (usize i = n; i > 0; i--) {
		index[i - 1] = index[i];
		index[i - 1][s[i - 1] - 'a'] = i - 1;
	}
	return index;
}

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

int main() {
	std::string s;
	std::cin >> s;
	const usize n = s.length();
	auto index = make_index(s);
	
	std::vector<usize> dp(n + 1, infty);
	std::vector<char> ch(n + 1, 'a');
	dp[n] = 1;
	
	for (usize i = n; i > 0; i--) {
		for (usize j = 0; j < word; j++) {
			const char c = ('a' + j);
			if (index[i - 1][j] == n + 1) {
				if (chmin<usize>(dp[i - 1], 1)) ch[i - 1] = c;
			} else if (chmin(dp[i - 1], dp[index[i - 1][j] + 1] + 1)) {
				ch[i - 1] = c;
			}
		}
	}

	usize i = 0;
	std::string ans = "";
	while (i <= n) {
		ans += ch[i];
		i = index[i][ch[i] - 'a'] + 1;
	}
	
	std::cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 53716
import java.util.*;


public class Main{

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] l=new int[n];
		
		for(int i=0;i<n;i++) {
			l[i]=sc.nextInt();
		}
		
		Arrays.sort(l);
		
		int ans=0;
		
		for(int i=0;i<n-2;i++) {
			int e1=l[i];
			Loop: for(int j=i+1;j<n-1;j++) {
				int e2=l[j];
				if(e1==e2)continue;
				for(int k=n-1;k>j;k--) {
					int e3=l[k];
					if(e1!=e3 && e2!=e3 && e2-e1<e3 && e1+e2>e3) ans++;
						//else break Loop;
				}
			}
		}
		
		
		
		System.out.println(ans);

	}

	
}


Measured memory_bytes: 36808