akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int h,n,a;
  cin>>h>>n;
  int s=0;
  for (int i=0; i<n; i++)
  {
    cin>>a;
    s+=a;
  }
  if (h-s <= 0) cout<<"Yes";
  	else cout<<"No";
  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 double PI = acos(-1);

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];

  vector<int> b(N, 0);

  //bool hantei = 1;
  int ans = 0;

  for(int i=0; i < N; i++){
    //cout << i << endl;
    int now = N - i;
    int cnt = 0;
    for(int j = now; j < N+1; j += now){
      if(b[j-1] == 1) cnt++;
      //cout << j << endl;
    }
    if(cnt % 2 != a[now - 1]) {
      b[now - 1] = 1;
      ans++;
    }
    //continue;
  }

  if(b.size() == 0) cout << 0 << endl;
  else{
    cout << ans << endl;
    rep(i, b.size()) {
      if(b[i] != 0) cout << i+1 << endl;
    }
  }
}


Measured memory_bytes: 2432
//
//  main.cpp
//  AOJ
//
//  Created by 佐々木勇星 on 2018/09/29.
//  Copyright © 2018年 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

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

    while(1){
        cin >> a;
        cin >> b;
        if(a == 0 && b == 0) break;
        for(int i = 0; i < a; i++){
            for(int j = 0; j < b; j++){
                if(i == 0 || i == a -1){
                cout << "#";
                }else{
                    if(j == 0 || j == b - 1 ){
                        cout << "#";
                    }else{
                        cout << ".";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3056
#include<stdio.h>
typedef long long ll;
const int mod=1000000007;
int mul(int a,int b){return(ll)a*b%mod;}
int pow(int a,int b){
	int s=1;
	while(b){
		if(b&1)s=mul(s,a);
		a=mul(a,a);
		b>>=1;
	}
	return s;
}
int fac[200010],rfac[200010],inv[200010],n;
void pre(){
	int i;
	fac[0]=1;
	for(i=1;i<=n;i++)fac[i]=mul(fac[i-1],i);
	rfac[n]=pow(fac[n],mod-2);
	for(i=n;i>0;i--)rfac[i-1]=mul(rfac[i],i);
	inv[1]=1;
	for(i=2;i<=n;i++)inv[i]=-mul(mod/i,inv[mod%i]);
}
int C(int n,int k){return mul(fac[n],mul(rfac[k],rfac[n-k]));}
int h[200010],nex[400010],to[400010],M;
void add(int a,int b){
	M++;
	to[M]=b;
	nex[M]=h[a];
	h[a]=M;
}
bool rg[200010],ins[200010],flag;
int v[200010],p[200010],st[200010],tp,E;
int cnt;
void dfs(int fa,int x){
	int i,j;
	ins[st[++tp]=x]=1;
	v[x]=1;
	p[++M]=x;
	for(i=h[x];i;i=nex[i]){
		E++;
		if(to[i]!=fa){
			if(v[to[i]]){
				if(ins[to[i]]){
					if(flag)continue;
					for(j=tp;j>0;j--){
						rg[st[j]]=1;
						if(st[j]==to[i])break;
					}
					flag=1;
				}
			}else
				dfs(x,to[i]);
		}
	}
	tp--;
	ins[x]=0;
}
int fa[200010];
void dfs(int x){
	v[x]=E;
	for(int i=h[x];i;i=nex[i]){
		if(to[i]!=fa[x]&&v[to[i]]!=E){
			fa[to[i]]=x;
			dfs(to[i]);
		}
	}
}
int siz[200010];
struct tree{
	int h[200010],nex[200010],to[200010],M;
	void clear(int x){
		for(int i=h[x];i;i=nex[i])clear(to[i]);
		h[x]=0;
	}
	void clear(){
		M=0;
		clear(n+1);
	}
	void add(int a,int b){
		M++;
		to[M]=b;
		nex[M]=h[a];
		h[a]=M;
	}
	void dfs(int x){
		siz[x]=1;
		for(int i=h[x];i;i=nex[i]){
			dfs(to[i]);
			siz[x]+=siz[to[i]];
		}
	}
}t;
bool in[200010];
int gao(){
	int i,j,x,s;
	t.clear();
	for(j=1;j<=M;j++){
		x=p[j];
		for(i=h[x];i;i=nex[i]){
			if(to[i]<fa[x]){
				in[to[i]]=1;
				t.add(x,to[i]);
			}
		}
	}
	for(i=1;i<=M;i++){
		x=p[i];
		if(!in[x])t.add(n+1,x);
	}
	t.dfs(n+1);
	s=fac[M];
	for(i=1;i<=M;i++)s=mul(s,inv[siz[p[i]]]);
	for(j=1;j<=M;j++){
		x=p[j];
		for(i=h[x];i;i=nex[i]){
			if(to[i]<fa[x])in[to[i]]=0;
		}
	}
	return s;
}
int main(){
	int i,j,x,y,ans,siz,res;
	scanf("%d",&n);
	for(i=1;i<=n<<1;i++){
		scanf("%d%d",&x,&y);
		add(x,y+n);
		add(y+n,x);
	}
	n<<=1;
	pre();
	ans=1;
	siz=0;
	for(i=1;i<=n;i++){
		if(!v[i]){
			E=M=0;
			flag=0;
			dfs(0,i);
			E>>=1;
			if(E!=M){
				putchar('0');
				return 0;
			}
			for(j=1;j<=M;j++){
				if(rg[p[j]]){
					x=p[j];
					break;
				}
			}
			for(j=h[x];j;j=nex[j]){
				if(rg[to[j]]){
					y=to[j];
					break;
				}
			}
			res=0;
			E=2;
			fa[y]=x;
			dfs(y);
			res+=gao();
			E=3;
			fa[x]=y;
			dfs(x);
			res+=gao();
			ans=mul(mul(ans,res),C(siz+M,M));
			siz+=M;
		}
	}
	printf("%d",(ans+mod)%mod);
}

Measured memory_bytes: 15872
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    vector<int> v {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1};
    int a, b;
    cin >> a >> b;
    if(find(v.begin(), v.end(), a) < find(v.begin(), v.end(), b)){
        cout << "Bob";
    }
    else if(find(v.begin(), v.end(), a) > find(v.begin(), v.end(), b)){
        cout << "Alice";
    }
    else
    {
        cout << "Draw";
    }
    
    cout << endl;
}


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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,m,v,p;cin>>n>>m>>v>>p;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  sort(ALLR(a));
  res=p;
  ll sum=0;
  rep(i,p,n){
    sum+=a[i-1];
    if(a[p-1]>a[i]+m)break;
    if(p*m+(a[i]+m)*(i-p+1)-sum+m*(n-i-1)<v*m)break;
    res=i+1;
  }
  cout<<res<<endl;
  return 0;
}

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

int asc(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}

int main() {
	int n, i = 0;
	cin >> n;
	int d[100050];
	rep(i, n) cin >> d[i];
	qsort(d, n, sizeof(int), asc);
	cout << abs(d[(n-1)/2+1]-d[(n-1)/2]) << endl;
}

Measured memory_bytes: 1020
#include <cstdio>
using namespace std;

int par[100001],h[100001],p[100000];
void init_tree(){
    for(int i=0;i<100001;i++){
        par[i]=i;
        h[i]=0;
    }
}
int find(int a){
    if(par[a]==a){return a;}
    else{return par[a]=find(par[a]);}
}
void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(h[a]>h[b]){par[b]=a;}
    else{
        par[a]=b;
        if(h[a]==h[b]){h[b]++;}
    }
}
bool issame(int a,int b){
    return find(a)==find(b);
}
int main(){
    init_tree();
    int N,M,x,y;
    scanf("%d %d",&N,&M);
    for(int i=0;i<N;i++){scanf("%d",p+i);}
    for(int i=0;i<M;i++){
        scanf("%d %d",&x,&y);
        unite(x,y);
    }
    int c=0;
    for(int i=0;i<N;i++){
        if(issame(i+1,p[i])){c++;}
    }
    printf("%d\n",c);
    return 0;
}            



Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
long long n,dmx,dmy,ans;
std::vector<long long> ret;

void divisor(long long n) {

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


void solve(){
 divisor(n);
 dmx=ret.at(ret.size()/2);
 dmy=n/dmx;

 cout<<(dmx+dmy-2)<<endl;


}



int main(){
  cin>>n;

  solve();
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <cstdio>
#include <unordered_map>
#define ll long long
using namespace std;

unordered_map<string, int> userToWordCountMap;


int main()
{
    int k, n;
    cin >> k >> n;
    vector <int> vec(n);
    int ans = k;
    for(int i = 0; i < n; i++){
        cin >> vec[i];
        if(i){
           int ans1 = k - vec[i];
           ans1 += vec[i-1]; 
           ans = min(ans, ans1);
        }
    }
    ans = min(ans, vec[n-1]-vec[0]);
    cout << ans;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,sum=0;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	sort(a,a+n);
	sum=ceil((double)sum/(4*m));
	reverse(a,a+n);
	for(int i=0;i<m;i++)
	{
		if(a[i]<sum)
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
string s;
int n,cnt0,cnt1;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>s;
	n=s.size();
	for (int i=0;i<n;i++)
	{
		if (s[i]=='0') cnt0++;
		if (s[i]=='1') cnt1++;
	}
	if (cnt0==n || cnt1==n || n==1)
	{
		cout<<"0";
		return 0;
	}
	cout<<min(cnt0,cnt1)*2;
	return 0;
}

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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;

    // Ls -> Ut
    // Rt -> Ds
    string path1 = "L";
    string path2 = "R";
    REP(i, yt - ys + 1) {
        path1 += "U";
        path2 += "D";
    }
    REP(i, xt - xs + 1) {
        path1 += "R";
        path2 += "L";
    }
    path1 += "D";
    path2 += "U";

    // Us -> Lt
    // Dt -> Rs
    string path3 = "";
    string path4 = "";
    REP(i, yt - ys) {
        path3 += "U";
        path4 += "D";
    }
    REP(i, xt - xs) {
        path3 += "R";
        path4 += "L";
    }

    cout << path1 << path2 << path3 << path4 << endl;


}


Measured memory_bytes: 256
/*
.......................
.......................
..... MY CODES ARE ....
... UGLIER THAN YOU ...
.......................
.......................
*/
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define maxn 1003
#define mod 1000000007
#include <bits/stdc++.h>
using namespace std;

ll w[maxn], cost[maxn], h, n;
ll dp[maxn][10004];
const ll inf = 1e12;


ll rec(ll pos, ll taken){
    if(taken >= h) return 0;
    if(dp[pos][taken] != -1) return dp[pos][taken];
    if(pos == n+1){
        return inf;
    }//cout << pos << " "<< taken << endl;
    ll res = inf;
    res = min(res, cost[pos] + rec(pos, taken + w[pos]));
    res = min(res, cost[pos] + rec(pos + 1, taken + w[pos]));
    res = min(res, rec(pos+1 ,taken));
    return dp[pos][taken] = res;
}

void solve(){
    memset(dp, -1, sizeof dp);
    cin >> h >> n;
    for(int i=1;i<=n;i++){
        cin >> w[i] >> cost[i];
    }
    cout << rec(1, 0) << endl;
}


int main() {

    int tc;
    tc = 1;
    while(tc--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 79360
s = gets().split(" ");
a = s[0].to_i;
b = s[1].to_i;
k = s[2].to_i;

if b-a+1>=2*k
	for i in a..a+k-1
		puts(i);
	end

	for j in b-k+1..b
		puts(j);
	end
elsif b-a+1<2*k
	for i in a..b
		puts(i)
	end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}	
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

void solve()
{

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

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	if(a*b>c*d) p(a*b);
	else p(c*d);
	return 0;
}	

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void){
  int i,j;
  float x1,x2,x3,y1,y2,y3,xp,yp;
  float a,b,c,s;
  while(scanf("%f %f %f %f %f %f %f %f",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
    s=0.5*abs((x1-x3)*(y2-y3)-(y1-y3)*(x2-x3));
    a=0.5*abs((x1-xp)*(y2-yp)-(y1-yp)*(x2-xp));
    b=0.5*abs((x1-xp)*(y3-yp)-(y1-yp)*(x3-xp));
    c=0.5*abs((x2-xp)*(y3-yp)-(y2-yp)*(x3-xp));
    if(s==a+b+c){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
  }
  return(0);
}

Measured memory_bytes: 604
a, b = map(int, input().split())


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def count_prime(n):
    i = 2
    primes = set()
    while i * i <= n:
        while n % i == 0:
            n /= i
            primes.add(i)
        i += 1
    if n > 1:
        primes.add(n)
    return len(primes)


print(count_prime(gcd(a, b)) + 1)


Measured memory_bytes: 3060
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;cin>>n;
    ll s=0;
    ll m=n;
    while(n>0){
        s+=n%10;
        n/=10;
    }
    //cout<<s<<endl;
    if(m%s==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
def solve():
    dp = [0]*n
    for i in range(1, n):
        if i-2>=0:
            minheight = min(abs(heights[i]-heights[i-1])+dp[i-1], abs(heights[i]-heights[i-2])+dp[i-2])
        else:
            minheight = abs(heights[i] - heights[i - 1])+dp[i-1]
        dp[i] = minheight
    return dp[n-1]


if __name__ == '__main__':
    n = int(input())
    heights = list(map(int, input().split()))
    print(solve())

Measured memory_bytes: 13908
N = int(input())
spot = [list(map(int,input().split())) for i in range(N)]

dist = 0
for i in range(N):
  for j in range(i,N):
    dist += ((spot[i][0]-spot[j][0])**2+(spot[i][1]-spot[j][1])**2)**0.5
print(dist*2/N)

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

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vector<int> left(s.size() + 1);
    vector<int> right(s.size() + 1);
    for (int i = 0; i < s.size(); i++)
        if (s[i] == '<')
            left[i + 1] = left[i] + 1;
        else
            left[i + 1] = 0;
    for (int i = s.size() - 1; i >= 0; i--)
        if (s[i] == '>')
            right[i] = right[i + 1] + 1;
        else
            right[i] = 0;
    ll ans = 0;
    for (int i = 0; i <= s.size(); i++)
        ans += max(right[i], left[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; 
const int N = 2e5 + 10;
lli nums[N];
lli nums2[N];
lli pref[N];
lli pref2[N];
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	lli k;
	cin >> k;
	for(int i = 1; i <= n; i++) cin >> nums[i];
	for(int i = 1; i <= m; i++) cin >> nums2[i];
	
	for(int i = 1; i <= n; i++) pref[i] = pref[i-1] + nums[i];
	for(int i = 1; i <= m; i++) pref2[i] = pref2[i-1] + nums2[i];
	
	lli ans = 0;
	for(int i = 0; i <= n; i++) {
		if(pref[i] > k) break;
		lli bs = upper_bound(pref2, pref2 + m + 1, k-pref[i]) - pref2-1;
		ans = max(ans, i + bs);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 9856
#include <iostream>
#define llint long long
#define mod 998244353

using namespace std;

llint n, m;
const int FACT_MAX = 4000005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

int main(void)
{
	cin >> n >> m;
	make_fact();
	
	llint ans = 0;
	for(int i = 0; i <= min(m, n); i++){
		if(m%2 != i%2) continue;
		llint rem = (3*m-i)/2;
		llint tmp = comb(rem+n-1, n-1);
		if(rem-(m+1) >= 0) tmp += mod - (n-i) * comb(rem-(m+1)+n-1, n-1) % mod, tmp %= mod;
		if(rem-m >= 0) tmp += mod - i * comb(rem-m+n-1, n-1) % mod, tmp %= mod;
		ans += tmp * comb(n, i) % mod, ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 62720
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define lsc(x)      scanf("%lld",&x)
#define sc(x)       scanf("%d",&x)
#define lpr(x)      printf("%lld ",(long long)x)
#define pr(x)       printf("%d ",x)
#define n_l         printf("\n")
#define VI          vector<int>
#define VII         vector<long long int>
#define m_p         make_pair
#define pb          push_back
#define fi           first
#define se           second
#define mset(x,y)   memset(x,y,sizeof(x))
#define sz(v)       (int)v.size()
#define all(v)      v.begin(), v.end()
#define fr(i, a, n) for(int i=a;i<=n;i++)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const int N=(int)1e6+5;
const int mod = 1000000007;
typedef long long ll;
// order_of_key (val): returns the no. of values strictly less than val
// find_by_order (k): returns the kth largest element iterator.(0-based)
// vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x);
// s.substr(pos[0-indexed], len(default=till end))
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll fmod(ll x){if (x<mod) return x;return x%mod;}
ll mul(ll a, ll b, ll c){
	ll ret=0;while(b){if (b%2) ret=(ret+a)%c;a=(a*2)%c;b>>=1;}
    return ret;
}
int modpow(ll a, ll b){
    ll ret=1;while(b){if (b%2) ret=(ret*a)%mod;a=(a*a)%mod;b>>=1;}
    return (int)ret;
}
inline int inv(int x){ return modpow(x, mod-2);}
int isprime[N];
void calc_prime(){
	isprime[1]=1;for(ll i=2;i<N;i++) if (!isprime[i]) for(ll j=i*i;j<N;j+=i) isprime[j]=1;
}
int n;
int a[N];
int solve(int i, int j, int k){
    int ptrl = 1;
    int ptrr = n;
    int sz = i + j - k;
    multiset<int, greater<int> > s;
    while(i--){
        s.insert(a[ptrl]);
        ptrl++;
    }
    while(j--){
        s.insert(a[ptrr]);
        ptrr--;
    }
    // trace(i, j, k, ptrl, ptrr);
    // assert(ptrr - ptrl >= -1);
    int ret = 0;
    for(auto it: s) {
        if (sz)
            ret += it;
        else break;
        sz--;
    }
    return ret;
}
int main(){
    sc(n);
    int k;sc(k);
    fr(i, 1 ,n) sc(a[i]);
    int ans = 0 ;
    fr(i, 0, min(n, k)){
        fr(j, 0, min(k-i, n-i)){
            fr(z, 0, min(i+j, k-i-j)){
                ans = max(ans, solve(i, j, z));
            }
        }
    }
    pr(ans);
    return 0;
}

Measured memory_bytes: 3812
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	int n;
	double d, s, c, m;
	d = s = c = m = 0;
	cin >> n;
	int* x = new int[n];
	int* y = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> y[i];
	}
	for (int i = 0; i < n; i++) {
		d += abs(x[i] - y[i]);
		s += pow(abs(x[i] - y[i]), 2);
		c += pow(abs(x[i] - y[i]), 3);
		if (m < abs(x[i] - y[i])) {
			m = abs(x[i] - y[i]);
		}
	}
	cout << fixed;
	cout << setprecision(6) << d << endl << sqrt(s) << endl << cbrt(c) << endl << m << endl;
	return 0;
}


Measured memory_bytes: 3392
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 998244353


def resolve():
    n, h = map(int, input().split())
    A, B = [], []
    for _ in range(n):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)

    MAX_A = max(A)
    B.sort(reverse=True)
    que = deque(B)

    res = 0
    while h > 0:
        if que and MAX_A < que[0]:
            damage = que.popleft()
            h -= damage
            res += 1
        else:
            res += (h + MAX_A - 1) // MAX_A
            h = 0

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 17864
s = int(input())
mod = 10**9+7

dp = [0]*(s+1)
dp[0] = 1
x = 0
for i in range(1,s+1):
  if i-3 >= 0:
    x += dp[i-3]
    x %= mod
  dp[i] = x

print(dp[s])

Measured memory_bytes: 9168
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		ContestScanner scan = new ContestScanner();
		int N = scan.nextInt();
		int[] A = new int[N];

		for(int i=0; i < N; i++) A[i] = scan.nextInt();

		(new Solve(A, N)).solve();
	}
}

class Solve {
	private final int[] A;
	private final int N;

	public Solve(final int[] A, final int N)
	{
		this.A = A;
		this.N = N;
	}

	public void solve()
	{
		int count = 0;

		int[] sorted = new int[N];

		for(int i=0; i < N; i++) sorted[i] = A[i];

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

			for(int j=i; j < N; j++)
			{
				if(sorted[j] < sorted[minj])
				{
					minj = j;
				}
			}

			if(i != minj)
			{
				int e = sorted[i];
				sorted[i] = sorted[minj];
				sorted[minj] = e;
				count++;
			}
		}

		for(int i=0; i < N; i++)
		{
			if(i > 0) System.out.print(" ");
			System.out.print(sorted[i]);
		}
		System.out.println("");
		System.out.println(count);
	}
}

class ContestScanner {
	BufferedReader reader;
	String[] line;
	int index;
	public ContestScanner() {
		reader = new BufferedReader(new InputStreamReader(System.in));
	}

	public ContestScanner(String filename) throws FileNotFoundException {
		reader = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
	}

	public String nextToken() throws IOException {
		if(line == null || index >= line.length)
		{
			line = reader.readLine().trim().split(" ");
			index = 0;
		}

		return line[index++];
	}

	public String next() throws IOException {
		return nextToken();
	}

	public String readLine() throws IOException {
		line = null;
		index = 0;

		return reader.readLine();
	}

	public int nextInt() throws IOException, NumberFormatException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException, NumberFormatException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException, NumberFormatException {
		return Double.parseDouble(nextToken());
	}

	public int[] nextIntArray(int N) throws IOException, NumberFormatException {
		int[] result = new int[N];

		for(int i=0; i < N; i++) result[i] = nextInt();

		return result;
	}

	public long[] nextLongArray(int N) throws IOException, NumberFormatException {
		long[] result = new long[N];

		for(int i=0; i < N; i++) result[i] = nextLong();

		return result;
	}

	public double[] nexDoubleArray(int N) throws IOException, NumberFormatException {
		double[] result = new double[N];

		for(int i=0; i < N; i++) result[i] = nextDouble();

		return result;
	}
}

Measured memory_bytes: 24380
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

loop = [1]
now = 1
d = set([1])
for i in range(n):
    now = a[now]
    if now in d:
        for j in range(len(loop)):
            if now == loop[j]:
                ind = j
        break
    d.add(now)
    loop.append(now)

if len(loop) >= k+1:

    print(loop[k])

else:
    k -= ind
    loop = loop[ind:]
    print(loop[k%len(loop)])


Measured memory_bytes: 126604
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[1000],i=0;

void push(int x){
  S[++top]=x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top=0;
  char s[100];
  while(scanf("%s",s)!=EOF){  
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }
    else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 2144
N = input()
N = int(N)
array = list(map(int,  input().split()))
cnt = 0
for i in range(N):
# print(' '.join(map(str, array)))
    for j in range(N-1, i, -1):
        if array[j] < array[j-1]:
            array[j], array[j-1] = array[j-1], array[j]
            cnt += 1
print(' '.join(map(str, array)))
print("%d" % (cnt))


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string S;
  IN(S);
  vll dp1(2019, 0);
  vll dp2(2019, 0);
  REP(i,S.size()){
    ll val = S[i]-'0';
    vll dp2_copy = dp2;
    REP(j,2019){
      ll n = (j*10+val)%2019;
      dp1[j] += dp2_copy[j];
      dp2[n] = dp2_copy[j];
    }
    dp2[val]++;
  }

  OUT(dp1[0]+dp2[0]);

  return 0;
}


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

ll tc, l, r, ar[200005];


int main(){
	scanf("%lld", &tc);
	for(int k = 1; k<= tc; k++){
		scanf("%lld", &ar[k]);
	}
	sort(ar + 1, ar + tc + 1);
	ll mem = tc - 2;
	ll jaw = 0;
	jaw+=ar[tc];
	for(int k = tc - 1; k>= 1; k--){
		if(mem == 0){
			break;
		}
		jaw+=ar[k];
		mem--;
		if(mem == 0){
			break;
		}
		jaw+=ar[k];
		mem--;
	}
	printf("%lld\n",jaw);
}

Measured memory_bytes: 5356
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで標準include

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s == "AKIHABARA") {

	}
	else if (s == "KIHABARA") {
		
	}
	else if (s == "AKIHBARA") {

	}
	else if (s == "AKIHABRA") {

	}
	else if (s == "AKIHABAR") {

	}
	else if (s == "KIHBARA") {

	}
	else if (s == "KIHABRA") {

	}
	else if (s == "KIHABAR") {

	}
	else if (s == "AKIHBRA") {

	}
	else if (s == "AKIHBAR") {

	}
	else if (s == "AKIHABR") {

	}
	else if (s == "AKIHBR") {

	}
	else if (s == "KIHABR") {

	}
	else if (s == "KIHBAR") {

	}
	else if (s == "KIHBRA") {

	}
	else if (s == "KIHBR") {

	}
	else {
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  string str;
  cin >> str;
  for(int i = 0; i < str.size(); i += 2){
    switch(str[i]){
    case '2': putchar('k'); break;
    case '3': putchar('s'); break;
    case '4': putchar('t'); break;
    case '5': putchar('n'); break;
    case '6': putchar('h'); break;
    case '7': putchar('m'); break;
    case '8': putchar('y'); break;
    case '9': putchar('r'); break;
    }
    if(str[i] == '0'){
      if(str[i+1]=='T') printf("wa");
      else if(str[i+1]=='U') printf("nn");
      else if(str[i+1]=='D') printf("wo");
    }else{
      switch(str[i+1]){
      case 'T': putchar('a'); break;
      case 'L': putchar('i'); break;
      case 'U': putchar('u'); break;
      case 'R': putchar('e'); break;
      case 'D': putchar('o'); break;
      }
    }
  }
  puts("");
  return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; ll k;
    cin>>n>>k;
    vll a(n);
    forn(i,n) cin>>a[i];
    if(k==0)
    {
        ll mx = 0;
        forn(i,n) mx = max(mx,a[i]);
        cout<<mx; return 0;
    }
    ll L = 0, R = *max_element(all(a)) + 2;
    while(R-L>1)
    {
        ll mid = (L+R)/2;
        ll c = 0;
        forn(i,n)
        {
            ll g = (a[i]+mid-1)/mid - 1;
            c += g;
        }
        //cout<<mid<<' '<<c<<endl;
        if(c>k) L = mid;
        else R = mid;
    }
    cout<<R;

	return 0;
}


Measured memory_bytes: 4768
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  	var K = nextInt();
	var two = nextIntArray();
	var A = two[0];
	var B = two[1];
	var output = "NG";
	for(var i = A; i <= B; i++){
		if(i % K == 0){
			output = "OK";
		}
	}
	myout(output);
}

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

const int maxn = 1e5+100;
vector<int> head[maxn];
int in[maxn],dp[maxn];
bool vis[maxn];

int main() {
	std::ios::sync_with_stdio(false);
	int n,m,u,v;
	scanf("%d%d",&n,&m);
	for(int i=0; i<m; i++) {
		scanf("%d%d",&u,&v);
		head[u].push_back(v);
		in[v]++;
	}
	int ans = 0;
	queue<int> list;
	for(int i=1; i<=n; i++) {
		if(!in[i]) list.push(i);
	}
	int now;
	while(!list.empty()) {
		now = list.front();
		list.pop();
		for(int i=0; i<head[now].size(); i++) {
			int u = head[now][i];
			if(in[u]) {
				dp[u] = max(dp[u],dp[now]+1);
				in[u]--;
				if(!in[u]) list.push(u);
			}
		}
	}
	for(int i=1; i<=n; i++) ans = max(ans,dp[i]);
	printf("%d",ans);
	return 0;
}



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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    int n; cin >> n;
    vector<pair<ll,ll>> xl(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        xl[i] = make_pair(a+b, a-b+1);
    }
    sort(xl.begin(), xl.end());


    ll ans = 0;
    ll t = -LONG_MAX;
    rep(i, n) {
        if(t < xl[i].second) {
            ans++;
            t = xl[i].first;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < (n); i++)
typedef long long ll;
// Welcome to my source code!

int main() {
    int t[5];
    REP(i,5) cin >> t[i];
    int sum = 0, mint = 100000;
    bool flag = true;
    REP(i,5) {
        sum += (t[i] + 9) / 10 * 10;
        if (t[i]%10) {
            mint = min(mint, t[i]%10);
            flag = false;
        }
    }
    if (flag) mint = 10;
    cout << sum - (10 - mint) << endl;
}

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

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

ll W,H;
ll s[1003][1003];

ll memo[1003][1003];
ll dp[1003][1003];

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

    cin >> W >> H;

    for (int i = 0;i < H;i++){
        for (int j = 0;j < W;j++){
            cin >> s[i][j];
        }
    }

    for (int i = 0;i < H;i++){
        ll sum = 0;
        for (int j = 0;j < W;j++){
            sum += s[i][j];
        }
        ll tmp = 0;
        for (int j = 0;j <= W;j++){
            memo[i][j] = tmp-(sum-tmp);
            if((i+j)%2 == 0){
                memo[i][j] *= -1;
            }
            if(j != W) tmp += s[i][j];
        }
    }

    for (int i = H;i >= 0;i--){
        for (int j = W;j >= 0;j--){
            if(i == H) dp[i][j] = 0;
            else if(j == W) dp[i][j] = memo[i][j]-dp[i+1][j];
            else dp[i][j] = max(-dp[i][j+1],memo[i][j]-dp[i+1][j]);
        }
    }

    cout << abs(dp[0][0]) << endl;

    return 0;

}


Measured memory_bytes: 26668
N = input()
A = [int(n) for n in input().split()]
count = 0

def can(array):
  C = len(list(
    filter(
      lambda i: i % 2 == 1, array
    )
  ))
  return C == 0

while can(A):
  A = [n / 2 for n in A]
  count += 1
print(count)

Measured memory_bytes: 3060
use proconio::input;

fn main() {
    input! {
        s: String,
    }

    let mut s: &str = &s;

    'outer: loop {
        for p in &["dreamer", "dream", "eraser", "erase"] {
            let ns = s.trim_end_matches(p);
            if ns != s {
                s = ns;
                continue 'outer;
            }
        }
        break;
    }

    println!("{}", if s.is_empty() { "YES" } else { "NO" })
}


Measured memory_bytes: 2352
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 998244353
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n;
	cin >> n;
	vector <vector<int>> A(2, vector<int>(n + 1, 0));
	for (int i = 0; i < 2; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> A[i][j];
		}
	}
	vector <int> pre(n + 1), suf(n + 2);
	for (int i = 1; i <= n; i++) {
		pre[i] = pre[i - 1] + A[0][i];
	}
	for (int i = n; i >= 1; i--) {
		suf[i] = suf[i + 1] + A[1][i];
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = max(ans, pre[i] + suf[i]);
	} 
	cout << ans;
}


Measured memory_bytes: 256
import bisect
n = int(input())
l = len(str(n))
ary = []
siti = ["3","5","7"]
def dfs (s,t):
	if len(s) == t:
		if s.count("3") > 0 and s.count("5") > 0 and s.count("7") > 0:
			ary.append(int(s))
		return
	for j in siti:
		dfs(s+j,t)
for i in range(3,l+1):
	dfs("",i)
# ary.sort()
print (bisect.bisect_right(ary,n))


Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define mod 1000000007
int main()
{
  int n,m;
  cin>>n>>m;
  vector<bool>v(n+1,true);
  for(int i=0;i<m;i++)
  {
      int k;
      cin>>k;
      v[k]=false;
  }

  int dp[n+1]={0};

  dp[0]=1;
  if(v[1])
    dp[1]=1;

  for(int i=2;i<=n;i++)
  {
      if(v[i-1])
        dp[i]+=dp[i-1];
      if(v[i-2])
        dp[i]+=dp[i-2];

      dp[i]%=mod;
  }

  cout<<dp[n]<<"\n";
return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<int, int> pint;
ll inf = 1000000000 + 7;




int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}




ll modpow(ll a, ll p) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		ll ret = modpow(a, p / 2);
		return (ret * ret) % inf;
	}

	else {

		return (a * modpow(a, p - 1)) % inf;

	}

}



ll comb(ll a, ll b) {
	ll	k = 1;
	ll t = 1;
	ll ans = 1;
	rep(i, b) {
		k = (k * (i + 1)) % inf;
		t =(t * (a - i)) % inf;
		
	}

	
	ans = (t * modpow(k, inf - 2)) % inf;
	
	return ans;

}


ll pcount[100001];

int main() {
	ll N, M, Q;
	ll ans = 1;
	cin >> N >> M;
	Q = M;
	
	rep(i, sqrt(Q)) {
		while (M % (i + 2) == 0) {
			M /= i + 2;
			pcount[i + 2] += 1;
		}

		
		
		ans = (ans * comb(N - 1 + pcount[i + 2], pcount[i + 2])) % inf;


	}
	
	if (M > 1) {
		ans = (ans * (N % inf)) % inf;
	}

	
	cout << ans << endl;

	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> d;

    for (int i = 0; i < 2*n; i++) {
        int _d;
        cin >> _d;
        d.push_back(_d);
    }

    string ans = "a";
    for (int i = 0; i < n-2; i++) {
        if (d[2 * i] == d[2 * i + 1] && d[2 * (i + 1)] == d[2 * (i + 1) + 1] && d[2 * (i + 2)] == d[2 * (i + 2) + 1]) {
            ans = "Yes";
        }
    }
    if (ans != "Yes") {
        ans = "No";
    }

    cout << ans;
}

Measured memory_bytes: 3132