akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi = vector<int>;
using vl= vector<ll>;
using vs=vector<string>;

ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a);}
ll max(ll a, ll b) {if (a > b) return a; else return b;}
ll min(ll a, ll b) {if (a < b) return a; else return b;}
ll power(ll a,ll b) {ll i,p=1; for(i=0;i<b;i++){p*=a;} return p;}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcase=1;
    //cin>>testcase;
    for(int p=0;p<testcase;p++){
        ll n=0;
        cin>>n;
        int array[n]={0};
        ll number=0;
        for(int i=0;i<n;i+=2){
            cin>>array[i]>>array[i+1];
            
        }
        number=array[0]^array[1];
        for(int i=2;i<n;i++){
            number=number^array[i];
        }
        for(int i=0;i<n;i++){
            array[i]=array[i]^number;
        }
	for(int i=0;i<n;i++){
cout<<array[i]<<' ';}
        
        
        }

    return 0;
}


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

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

ll lcm(ll a, ll b){
	return (a*b) / gcd(a, b);
}

ll a[1000008],b[200008];

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

	ll n,i,j;
	memset(a,0,sizeof(a));
	cin >> n;

	for(i=0;i<n;i++)
	{
		cin >> b[i];
	}

	sort(b,b+n);
	for(i=0;i<n;i++)
	{
		if(a[b[i]] == 0)
		{
			for(j=b[i];j<= 1000000;j += b[i])
			{
				a[j] += 1;
			}
		}
		else
		{
			a[b[i]] += 1;
		}	
	}

	ll cnt =0;
	for(i=0;i<n;i++)
	{
		if(a[b[i]] < 2)
			cnt++;
	}

	cout << cnt << endl;

}

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

int main() {
    ll N;
    cin >>N;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    if(A[0] !=0){
        cout << -1 << endl;
        return 0;
    }
    ll ans =0;
    for(int i=N-1;i>=0;--i){
        if(i>0){
            if(A[i] > A[i-1]+1){
                cout << -1 << endl;
                return 0;
            }
            if(A[i] == A[i-1]+1){
                ans++;
            }else{
                ans += A[i];
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4840
//
// Noszály Áron 9a Debreceni Fazekas Mihály Gimnázium
//
#include<bits/stdc++.h>
#include<cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;

#define all(s) (s).begin(),(s).end()
#define pb push_back
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define INF std::numeric_limits<int>::max()
#define MINF std::numeric_limits<int>::min()
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define mp make_pair
#define xx first
#define yy second
#define sz(x) (int)(x).size()

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

const long double PI = acos(-1);

int d1[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
int d2[8][2]={{1,0},{0,1},{0,-1},{-1,0},{1,1},{-1,1},{1,-1},{-1,-1}};

int main()
{
	IO;
	string s;cin>>s;
	if(sz(s)==2)
	{
		if(s[0]==s[1])
		{
			cout<<"1 2"<<"\n";
			return 0;
		}
	}
	for(int i=0;i<sz(s)-2;++i)
	{
		if(s[i]==s[i+1] || s[i+1]==s[i+2] || s[i]==s[i+2])
		{
			cout<<(i+1)<<" "<<(i+3)<<"\n";
			return 0;
		}
	}
	cout<<"-1 -1\n";
	return 0;
}



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

namespace _0095
{
    class Program
    {
        static void Main(string[] args)
        {
            Fish fish = new Fish();
            int n = int.Parse(Console.ReadLine());
            for(int i =0; i <n; ++i)
            {
                int[] line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                fish.Fishing(line[0],line[1]);
            }
            int value = 0;
            int keyMax=1;
            foreach (var key in fish.player.Keys)
            {
                if (value < fish.player[key])
                {
                    value = fish.player[key];
                    keyMax = key;
                }
                else if(value == fish.player[key]&&keyMax>key)
                {
                    keyMax = key;
                }
            }
            Console.WriteLine("{0} {1}", keyMax, value);
        }
    }
    class Fish
    {
        public Dictionary<int, int> player = new Dictionary<int, int>();
        public void Fishing(int number,int fish)
        {
            player.Add(number, fish);
        }
    }
}



Measured memory_bytes: 18428
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;

    class Program
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            decimal h1 = decimal.Parse(input[0]);
            decimal m1 = decimal.Parse(input[1]);
            decimal h2 = decimal.Parse(input[2]);
            decimal m2 = decimal.Parse(input[3]);
            decimal k = decimal.Parse(input[4]);
            var h1_m = h1 * 60;
            var h2_m = h2 * 60;

            var start = h1_m + m1;
            var end = h2_m + m2;

            var lastend = end - k;
            var ans = lastend - start;

            Console.WriteLine(ans.ToString());
        }
    }

Measured memory_bytes: 17988
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define debug(n) cout << "DEBUG1 " << n << "\n";
#define debug2(n, m) cout << "DEBUG2 " << n << ' ' << m << "\n";
#define debug3(n, m, x) cout << "DEBUG3 " << n << ' ' << m << ' ' << x << "\n";
#define ss_def stringstream ss // stringstream, do ss_def(str), then ss >> n (n is int)
#define upzero(n) if (n < 0) n = 0
#pragma GCC optimize("Ofast")
using namespace std;
ll int BtoPmodM(ll int b, ll int p, ll int m) { // (b ^ p) % m (Big Mod)
    b %= m;
    if (p == 0) return 1;
    else if (p % 2 == 0) return (BtoPmodM(b, p / 2, m) * BtoPmodM(b, p / 2, m)) % m; // a^(p/2) * a^(p/2) = a^p
    else if (p % 2 == 1) return (BtoPmodM(b, (p - 1) / 2, m) * BtoPmodM(b, (p - 1) / 2, m) * b) % m; // +1
    else return 0; // a function must return something
}
ll int euclid_algo(ll int a, ll int b) { // Euclidean Algorithm
    if (b == 0) return a;
    else return euclid_algo(b,a % b);
}
bool coprime(ll int a, ll int b) {
    if (euclid_algo(a, b) == 1) return true;
    else return false;
}
ll int factModP(ll int n, ll int p) {
    ll int fac[n - 1];
    fac[0] = 1;
    for (ll int i = 1;i <= n;i++) {
        fac[i] = fac[i - 1] * i % p;
    }
    return fac[n];
}
ll int power(ll int x, ll int y, ll int p) { // x ^ y % p
    ll int res = 1;
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y /= 2; 
        x = (x * x) % p; 
    } 
    return res; 
}
ll int modInverse(ll int n, ll int p) {
    return power(n, p - 2, p); 
}
ll int nCrModP(ll int n, ll int r, ll int p) {
    if (r == 0) return 1;
    else if (r > n) return 0;
    ll int fac[n + 1]; 
    fac[0] = 1; 
    for (ll int i = 1;i <= n;i++) {
        fac[i] = fac[i - 1] * i % p; 
    }
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
}
ll int nCr(ll int n, ll int r) {
    ll int ans = 1;
     if (r >= n - r) {
         for (ll int i = r + 1;i <= n;i++) ans *= i;
         for (ll int i = 1;i <= n - r;i++) ans /= i;
     } else {
         for (ll int i = n - r + 1;i <= n;i++) ans *= i;
         for (ll int i = 1;i <= r;i++) ans /= i;
     }
     return ans;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // implementation
    string str;
    cin >> str;
    int strl = str.length();
    for (int i = 0;i < strl;i++) {
    	if (str[i] == '7') {
    		cout << "Yes\n";
    		return 0;
		}
	}
	cout << "No\n";
}

Measured memory_bytes: 3656
import sys
sys.setrecursionlimit(100000)
import heapq
n=int(input())
data=[]
a=list(map(int,input().split()))
amax=0
for i in range(n):
    heapq.heappush(data,a[i])
    amax+=a[i]
ansdata=[amax]
for i in range(n,2*n):
    heapq.heappush(data,a[i])
    amax+=a[i]
    amax-=heapq.heappop(data)
    ansdata.append(amax)
data=[]
bmin=0
for i in range(2*n,3*n):
    heapq.heappush(data,-a[i])
    bmin+=a[i]
ansdata[-1]-=bmin
for i in range(n):
    t=i
    i=2*n-1-i
    heapq.heappush(data,-a[i])
    bmin+=a[i]
    bmin+=heapq.heappop(data)
    ansdata[-t-2]-=bmin

print(max(ansdata))

Measured memory_bytes: 37212
#include <iostream>


int main() {
    int A, B, X;
    std::cin >> A >> B >> X;
    if (A <= X && (A + B) - X >= 0) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int x; cin >> x;
	int a=x/100;
	a/=2;
	cout << 10-a << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << "-1\n"; return;}

void solve() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    loop(i, n) {
        int x; cin >> x;
        ans += x >= k;
    }
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<double> V(N);
  rep(i,N) cin >> V[i];
  sort(all(V));
  double ans = 0;
  double tmp=V[0];
  for(int i=1;i<N;i++){
    tmp = (tmp+V[i])/2.0;
  }
  ans = tmp;

  cout << setprecision(10) << ans << endl;
  return 0;
}


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

int main() {
    ll K, N;
    cin >> K >> N;
    vi A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll ans = A[N - 1] - A[0];
    for (int i = 1; i < N; i++) {
        ans = min(ans, K - A[i] + A[i - 1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

vector<int> v[211111];
int d[211111];

P dfs(int x,int t) {
  d[x]=t;P p=P(d[x],x);
  rep(i,v[x].size())if(d[v[x][i]]==MAX)p=max(p,dfs(v[x][i],t+1));
  return p;
}

P calc() {
  fill(d,d+211111,MAX);P p=dfs(0,0);
  fill(d,d+211111,MAX);P q=dfs(p.S,0);
  return P(p.S,q.S);
}

int dp[2][222222];
int dfs2(int nx, int t) {
  if(dp[t][nx]!=-1) return dp[t][nx];
  int r=t?0:1;
  REP(i,1,3) {
    if(nx==2&&i==2) continue;
    int x=nx-i;
    if(x>=0) {
      int z=dfs2(x,t^1);
      if(z==t) r=z;
    }
  }
  dp[t][nx]=r;
  return r;
}

void Main() {
  ll n;
  R n;
  rep(i,n-1) {
    int x,y;
    cin >> x >> y;
    x--,y--;
    v[x].pb(y);
    v[y].pb(x);
  }
  P p=calc();
  memset(dp,-1,sizeof(dp));
  if(dfs2(d[p.S]+1,1)) pr("First");
  else pr("Second");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 29696
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

int t[5002];

int main(){
  int n;

  while(cin>>n,n){
    rep(i,n){
      cin>>t[i];
    }

    int ans = INT_MIN;
    rep(i,n){
      int sum = 0;
      REP(j,i,n){
        sum += t[j];
        if(ans < sum){
          ans = sum;
        }
      }
    }

    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>

int main() {
  uint32_t N = 0;
  std::cin >> N;

  std::vector<uint32_t> A(N - 1);
  for (uint32_t i = 0; i < N - 1; i++) std::cin >> A[i];

  std::vector<uint32_t> result(N);
  for (auto &&a : A) {
    result[a - 1]++;
  }

  for (auto &&r : result) {
    std::cout << r << std::endl;
  }

  return 0;
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

ll calc(int len) {
    if (len == 0) return 1;
    
    ll tmp = 26;
    ll sum = 0;
    for (int i = 1; i <= len; i++) {
        sum += tmp;
        tmp *= 26;
    }    
    return sum;
}

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

    ll n;
    cin >> n;

    ll tmp = 26;
    ll sum = 0;
    int len = 0;
    for (int i = 1; i <= 100; i++) {
        sum += tmp;
        if (sum >= n) {
            len = i;
            break;
        }
        tmp *= 26;
    }
    //cerr << len << newl;

    tmp = 1;
    for (int i = len - 1; i >= 0; i--) {
        n -= tmp;
        tmp *= 26;
    }
    //cerr << n << newl;
    
    string ans = "";
    for (int i = 0; i < len; i++) {
        ans += 'a' + n % 26;
        n /= 26;
    }
    reverse(ans.begin(), ans.end());

    cout << ans << newl;

    return 0;
}

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

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

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

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

int main()
{
    int n; cin >> n;
    double x[n], y[n];
    for(int i=0; i<n; i++){
        double xi; cin >> xi;
        x[i] = xi;
    }
    for(int i=0; i<n; i++){
        double yi; cin >> yi;
        y[i] = yi;
    }
    double dim1 = 0, dim2 = 0, dim3 = 0;
    double dimINF = 0;
    for(int i=0; i<n; i++){
        dim1 += fabs(x[i]-y[i]);
        dim2 += fabs(x[i]-y[i])*fabs(x[i]-y[i]);
        dim3 += fabs(x[i]-y[i])*fabs(x[i]-y[i])*fabs(x[i]-y[i]);
        if(dimINF < fabs(x[i]-y[i])) dimINF = fabs(x[i]-y[i]);
    }
    dim2 = sqrt(dim2);
    dim3 = pow(dim3, 1.0/3.0);
    printf("%.5lf\n%.5lf\n%.5lf\n%.5lf\n", dim1, dim2, dim3, dimINF);
}


Measured memory_bytes: 3396
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int k, x;
    cin >> k >> x;
    if (x - k + 1 < -1000000) {
        cout << -1000000;
        for (int i = -1000000 + 1; i < k + x; i++) {
            cout << " " << i;
        }
    }
    else if (k + x >= 1000000 - 1) {
        cout << x - k + 1;
        for (int i = x - k + 2; i <= 1000000; i++) {
            cout << " " << i;
        }
    }
    else {
        cout << x - k + 1;
        for (int i = x - k + 2; i < x + k; i++) {
            cout << " " << i;
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll d[MAXn];
ll id[MAXn];
ll dsu[MAXn],sz[MAXn];
ll fnd(ll x){
    if (dsu[x] == x) return x;
    return dsu[x] = fnd(dsu[x]);
}
void mrg(ll x,ll y){
    x = fnd(x), y = fnd(y);
    if (sz[x] < sz[y]) swap(x,y);
    dsu[y] = x;
    sz[x] += sz[y];
}
int main(){
    IOS();
    ll n;
    cin >> n;
    for (int i=0;i<n;++i) {
        cin >> d[i];
        dsu[i] = -1;
        id[i] = i;
    }
    sort(id,id+n,[&](const ll a,const ll b){
        return d[a] > d[b];
    });
    ll ans = 0;
    for (int i=0;i<n;++i) {
        ll cur = id[i];
        debug(cur,d[cur]);
        dsu[cur] = cur, sz[cur] = 1;
        ll l = 0, r = 0;
        if (cur+1 < n && dsu[cur + 1] != -1) {
            r = sz[fnd(cur+1)];
            mrg(cur,cur+1);
        }
        debug(cur-1,dsu[cur-1]);
        if (cur-1 >= 0 && dsu[cur-1] != -1) {
            l = sz[fnd(cur-1)];
            mrg(cur,cur-1);
        }
        ans += (l+1) * (r+1) * d[cur];
        debug(l,r,ans);
    }
    cout << ans << endl;
}


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

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    int N,K,S;
    cin >> N >> K >> S;
    for(int i=1; i<=N; i++){
        if(i<=K) cout << S << ' ';
        else{
            if(S!=1e9) cout << S+1 << ' ';
            else cout << S-1 << ' ';
        }
    }
}


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

int dp[11][2005];//janru,satusuu
int hon[11][2005];
int satusu[11];
vector<int>V[11];
int main(){
	int n,p;
	cin>>n>>p;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		V[b].push_back(a);
		}
	
	for(int i=0;i<=10;i++){
		sort(V[i].begin(),V[i].end());
		reverse(V[i].begin(),V[i].end());
		for(int j=1;j<V[i].size();j++){
			V[i][j]+=V[i][j-1]+(2*j);
			}
		for(int j=0;j<V[i].size();j++){
			hon[i][j+1]=V[i][j];
			}		
			satusu[i]=V[i].size();
		}	
		
	for(int i=0;i<11;i++){
		for(int j=0;j<2005;j++){
			dp[i][j]=-1;
			}
		}	
	dp[0][0]=0;	
	for(int i=1;i<=10;i++){
		for(int j=0;j<=p;j++){
			for(int k=0;k<=satusu[i];k++){
				if(k<=j&&dp[i-1][j-k]>=0){
					dp[i][j]=max(dp[i][j],dp[i-1][j-k]+hon[i][k]);
					}
				}
			}
		}	
		cout<<dp[10][p]<<endl;
		
	}

Measured memory_bytes: 3288
#include <cstdio>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <utility>
using namespace std;


int main() {
	int S, W;
	scanf("%d %d", &S, &W);
	if (W >= S) {
		printf("%s\n", "unsafe");
	} else {
		printf("%s\n", "safe");
	}
	
	
	return 0;
}

Measured memory_bytes: 1656
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize)(list:[i64]));
    let mut max = 0;
    let mut min = <i64>::max_value();
    for x in list {
        max = std::cmp::max(max, x);
        min = std::cmp::min(min, x);
    }
    (max - min).to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "4\n1 4 6 3" => "5",
    test2: "2\n1000000000 1" => "999999999",
    test3: "5\n1 1 1 1 1" => "0",
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ULL unsigned long long
#define LL long long
#define Max 100005
#define mem(a,b) memset(a,b,sizeof(a));
#define pb push_back
#define mp make_pair
const LL mod=1e9;
const ULL base=131;
const LL LL_MAX=9223372036854775807;
using namespace std;
int main()
{
    LL s;
    scanf("%lld",&s);
    if(s==(LL)1000000000000000000){
        printf("%d %d %d %d %d %d\n",0,0,mod,0,0,mod);
        return 0;
    }
    for(int i=1;i<=mod;i*=10){
        if(s/i<=mod){
             printf("%lld %lld %lld %lld %lld %lld\n",(LL)0,(LL)0,(LL)(s/i+1),(LL)1,(LL)(((s/i+1)*i)-s),(LL)i);
             break;
        }
    }

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt");
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static long mod = (long)Math.Pow(10,9) + 7;

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        int n     = int.Parse(spl[0]);
        var k     = long.Parse(spl[1]);
        int[] aa = ToIntArray(input.ReadLine(), n);

        //long[] cc1 = new long[n];
        //long[] cc2 = new long[n];

        long count = 0;

        for(int i=0; i<n; i++) {
            for(int j=0; j<n; j++) {
                if (j < i) {
                    if (aa[i] > aa[j]) {
                        //cc1[i]++;
                        count += calc(k - 1) % mod;
                    }
                }
                else if (j > i) {
                    if (aa[i] > aa[j]) {
                        //cc2[i]++;
                        count += calc(k) % mod;
                    }
                }
                count = count % mod;
            }
        }
        return count;

    }

    static long calc(long n) {
        if (n % 2 == 0) {
            return ((n + 1)%mod) * (n/2 % mod);
        } else {
            long n2 = n / 2;
            return ((n + 1)%mod) * (n2 % mod) + ((n2+1) % mod);
        }
    }

    static int[] ToIntArray(string strs, int n) {
        int[] ret = new int[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++) ret[i] = int.Parse(spl[i]);
        return ret;
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(void){
	LL n;
	LL i;
	LL x,y,xx,yy;
	LL sum;
	cin>>n;
	sum=LLONG_MAX;
	x=1; 	y=1;
	for(i=1;i*i<=n;i++){
		//cout<<i<<" "<<i*i<<endl;
		if(n%i==0){
			yy=i;
			xx=n/i;
			sum=min(sum,xx-x+yy-y);
		}
	}
	cout<<sum<<endl;
	return 0;
}

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


int main()
{
 	int N, A, B, C;
	cin >> N >> A >> B;
	C = min(A,B)-(N-max(A,B));
	cout << min(A,B)  << endl;
	cout << max(C,0)  << endl;
	return 0;
}

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

#define ll long long
#define sz(x) (int)x.size();

using namespace std;

int n,x;
string s;
vector<pair<string,pair<int,int>>>v;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s>>x;
		v.push_back({s,{-x,i+1}});
	}
	sort(v.begin(), v.end());
	for(auto i:v){
		cout<<i.second.second<<'\n';
	}
}

Measured memory_bytes: 3612
up, south, east, west, north, down = map(int, input().split())
command = input()
for c in command:
    if c == 'N':
        copy = north
        north = up
        up = south
        south = down
        down = copy
    elif c == 'S':
        copy = north
        north = down
        down = south
        south = up
        up = copy
    elif c == 'W':
        copy = west
        west = up
        up = east
        east = down
        down = copy
    else:
        copy = west
        west = down
        down = east
        east = up
        up = copy
print(up)



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

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

    int n;
    cin >> n;
    vector<int> ex(n);
    rep(i, n) cin >> ex[i];

    int minv = ex[0];
    int maxv = -pow(10, 9);
    for (size_t i = 1; i < ex.size(); i++) {
        maxv = max(maxv, ex[i] - minv);
        minv = min(minv, ex[i]);
    }
    cout << maxv << endl;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, x;
    cin >> n;
    set<int> a, b, c;
    rep(i, n) {
        cin >> x;
        a.insert(x);
    }
    cin >> m;
    rep(i, m) {
        cin >> x;
        b.insert(x);
    }
    set_intersection(all(a), all(b), inserter(c, end(c)));
    for(auto e : c) {
        cout << e << "\n";
    }
}


Measured memory_bytes: 23736
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    int i,j,k,l1,l2;
    cin>>a>>b;

    l1=a.size();
    l2=b.size();
    int ar[l2+1][l1+1];
    for(i=0;i<=l2;i++){
        for(j=0;j<=l1;j++){
            if(i==0){
                ar[i][j]=j;
            }
            else if(j==0){ar[i][j]=i;}
            else if(b[i-1]==a[j-1]){ar[i][j]=ar[i-1][j-1];}
            else{ ar[i][j]=1+min(min(ar[i][j-1],ar[i-1][j]),ar[i-1][j-1]);}
        }
    }
    cout<<ar[l2][l1]<<endl;

}



Measured memory_bytes: 7136
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }


int main(){
    int X, N;
    cin >> X >> N;
    int mi = 101;
    int near;
    vector<bool> p(101, 0);
    rep(i, N){
        int pi;
        cin >> pi;
        p[pi] = 1;
    }
    rep(i, 102){
        if(p[i]==0){
            if(mi > abs(i-X)){
                mi = abs(i-X);
                near = i;
            }
        }
    }
    cout << near << endl;
    return 0;
}



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



template<class M> class SegmentTree {
public:
    using T = typename M::value_type;
private:
    int m;
    int n;
    vector<T> data;
public:
    SegmentTree(const vector<T>& a) {
        m = a.size();
        for(n = 1; n < (int)a.size(); n <<= 1);
        data.resize(n<<1, M::id);
        for(int i = 0; i < (int)a.size(); i++)data[i + n] = a[i];
        for(int i = n - 1; i >= 1; i--) data[i] = M::op(data[i<<1], data[(i<<1) + 1]);
    }

    T get(int l, int r) {
        if(l == r)return M::id;
        l += n, r += n;
        ll vl = M::id, vr = M::id;
        while(l < r) {
            if(l & 1) {
                vl = M::op(vl, data[l]);
                l++;
            }
            if(r & 1) {
                r--;
                vr = M::op(data[r], vr);
            }
            l >>= 1, r>>=1;
        }
        return M::op(vl, vr);
    }

    void assign(int index, T val) {
        index += n;
        data[index] = val;
        while(index != 1){
            index >>= 1;
            data[index] = M::op(data[index<<1], data[(index<<1) + 1]);
        }
    }

    T operator[] (int i){
        return data[i + n];
    }

};

template<class T> class Plus {
public:
    using value_type = T;
    static T op(T l, T r) {return l + r;}
    static constexpr T id = 0;
};

template<class T> class Min {
public:
    using value_type = T;
    static T op(T l, T r) {return min(l, r);}
    static constexpr T id = 1e9;
};

template<class T> class Max {
public:
    using value_type = T;
    static T op(T l, T r) {return max(l, r);}
    static constexpr T id = -1e9;
};

template<class T> class Gcd {
public:
    using value_type = T;
    static T op(T l, T r) {return __gcd(l, r);}
    static constexpr T id = 0;
};

int main()
{
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	SegmentTree<Gcd<int>> tree(a);
	int nax = 0;
	for(int i = 0; i < n; i++) {
		tree.assign(i, 0);
		nax = max(nax, tree.get(0, n));
		tree.assign(i, a[i]);
	}
	cout << nax << endl;
}

Measured memory_bytes: 4492
#include<iostream>
#include<math.h>
using namespace std;
long long int mini(long long int *h,long long int *dp,long long int i,long long int k,long long int n)
{
  if(i>=n-1)
    return 0;
  if(dp[i]!=-1)
    return dp[i];
  long long int min,j=2,val;
  min=abs(h[i]-h[i+1])+mini(h,dp,i+1,k,n);
  while(j<=k && i+j<n)
  {
    val=mini(h,dp,i+j,k,n)+abs(h[i]-h[i+j]);
    if(min>val)
      min=val;
    j++;
  }
  dp[i]=min;
  return dp[i];
}
int main(void)
{
  long long int n,k;
  cin>>n>>k;
  long long int h[n],dp[n];
  long long int i;
  for(i=0;i<n;i++)
  {
    cin>>h[i];
    dp[i]=-1;
  }
  long long int ans=mini(h,dp,0,k,n);
  cout<<ans;
  return 0;
}


Measured memory_bytes: 11136
#include <iostream>

using namespace std;

int main()
{
	long long a, b, x;
	cin>>a>>b>>x;
	a--;
	long long q = 0;
	if(a<0)a = 0, q = 1;
	cout<<((b/x) - (a/x)) + q<<endl;
	return 0;
}

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

def isSpecial(n):
    cnt = 1
    for i in range(3,n+1):
        if n % i == 0:
            cnt += 1
    return cnt == 8




def solve(N: int):
    cnt = 0
    for i in range(1,N+1,2):
        if isSpecial(i):
            cnt += 1
    print(cnt)
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int p[5] = {0,6000,4000,3000,2000};
  int a,b,ans=0;
  for(int i=0;i<4;i++){
    scanf("%d%d",&a,&b);
    cout << b * p[a] << endl;
  }

  return 0;
}

Measured memory_bytes: 1208
H,W,K=map(int,input().split())
color=[]
from itertools import combinations
for i in range(H):
	col=list(input())
	color.append(col)
ans=0
cmb_i=[]
for i in range(H+1):
	cmb_i.extend(list(combinations(range(H),i)))
cmb_j=[]
for i in range(W+1):
	cmb_j.extend(list(combinations(range(W),i)))

for i in cmb_i:
	for j in cmb_j:
		cnt=0
		for i0 in range(H):
			for j0 in range(W):
				if color[i0][j0]=="#" and (i0 not in i) and (j0 not in j):
					cnt+=1
		if cnt==K:
			ans+=1
print(ans)

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<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;}

//pow(llpow,modpow)
template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    ll n,m;
    cin>>n>>m;
    vll s(m),c(m);
    rep(i,m)cin>>s[i]>>c[i];
    vi ans(n,-1);
    rep(i,m){
        if(ans[s[i]-1]==-1){
            ans[s[i]-1]=c[i];
        }
        else if(ans[s[i]-1]==c[i])continue;
        else{
            cout<<-1<<endl;
            return 0;
        }
    }
        if(n!=1&&ans[0]==0){
            cout<<-1<<endl;
            return 0;
        }
        if(n!=1&&ans[0]==-1)ans[0]=1;
    rep(i,n){
            if(ans[i]!=-1)cout<<ans[i];
            else{
                cout<<0;
            }
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


  

long long power(long long a, long long b,long long mod) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %mod;
        a = a * a %mod;
        b >>= 1;
    }
    return res;
}

int seg[1200005];
void upd(int ver,int tl,int tr,int pos,int val)
{
    if(tl>tr)
            return ;
    else if(tl==tr)
    {
        seg[ver]=max(seg[ver],val);
    }
    else
    {
        int tm=(tl+tr)/2;
        if(tm>=pos)
            upd(2*ver,tl,tm,pos,val);
        else
            upd(2*ver+1,tm+1,tr,pos,val);
        seg[ver]=max(seg[2*ver],seg[2*ver+1]);
    }
}


int get(int ver,int tl,int tr,int l,int r)
{
    if(tl>tr||l>r||tr<l||r<tl)
            return 0;
    else if(tl==l&&tr==r)
            return seg[ver];
    else
    {
        int tm=(tl+tr)/2;
        return max(get(2*ver,tl,tm,l,min(tm,r)),get(2*ver+1,tm+1,tr,max(tm+1,l),r));
    }
}


signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int lim=3e5;
    for(int i=1;i<=n;i++)
    {
        int z=get(1,1,lim,max(1LL,a[i]-k),min(lim,a[i]+k));
        upd(1,1,lim,a[i],z+1);
    }
    cout<<seg[1];
}

Measured memory_bytes: 14192
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int time = scan.nextInt();
		scan.close();
		int h,m,s;
		s = time % 60;
		m = time / 60;
		h = m / 60;
		m = m - h * 60;
		String answer =h + ":" + m +":" + s;
		System.out.println(answer);
	}
}

Measured memory_bytes: 17352
#include<bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define what(x) cout<<#x<<" is "<<x<<endl;
using namespace std;


template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

ll powmod(ll a,ll b,ll mod) {
    ll res=1;a%=mod;
    //assert(b>=0);
    for(;b;b>>=1){
        if(b&1)res=res*a%mod;a=a*a%mod;
    }
    return res;
}

void solve(){
	int n,k;
	cin>>n>>k;
	
	vector<int> vp(n);
	for(int i=0;i<n;i++)cin>>vp[i];

	int l=1,h=*max_element(all(vp));
	while(l<h){
		int mid=l+(h-l)/2,sum=0;
		for(int i=0;i<n;i++){
			sum+=((vp[i]-1)/mid);
		}
		if(sum>k){
			l=mid+1;
		}else{
			h=mid;
		}
	}
	cout<<h<<endl;

}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tc=1;
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	#endif
	// cin>>tc;
    while(tc--)solve();
}


Measured memory_bytes: 3988
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,m=nii()
l=[lnii() for i in range(m)]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

uf=UnionFind(n)
for a,b, in l:
  a-=1
  b-=1
  if uf.same(a,b)==False:
    uf.union(a,b)

ans=0
roots=uf.roots()
for i in uf.roots():
  ans=max(ans,uf.size(i))
print(ans)

Measured memory_bytes: 49924
#include <stdio.h>

int main (){
  int num,i,tmp,flag,cnt=0;
  
  scanf("%d",&num);
  int array[num];

  for (i=0;i<num;i++){
    scanf("%d",&array[i]);
  }

  flag = 1;

  while(flag==1){
    flag = 0;

    for(i=num-1;i>0;i--){
      if(array[i]<array[i-1]){
	tmp=array[i-1];
	array[i-1]=array[i];
	array[i]=tmp;
	cnt++;
	flag=1;
      }
      
    }
  }

  for(i=0;i<num-1;i++) printf("%d ",array[i]);
  printf("%d\n",array[num-1]);
  printf("%d\n",cnt);

  return 0;
  
}



Measured memory_bytes: 2104
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}


 main()

{
    fast
    int k;
    string s;
    cin>>s;
    cin>>k;
    vector<int>yo;
    int cnt=0;
    int sz=s.size();
    int len=sz;
    s=s+"#";
    int ses=0;
    f(i,0,sz-1)
    {
        if(s[i]==s[i+1])
        {
            cnt++;
        }
        else
        {
            cnt++;
            ses+=(cnt/2);
            yo.pb(cnt);
            cnt=0;
        }
    }
    if(k==1)
    {
        cout<<ses<<endl;
        return 0;
    }
    sz=yo.size();
    if(sz==1)
    {
        ses=(k*len)/2;
        cout<<ses<<endl;
        return 0;
    }
    int st=yo[0];
    int en=yo[sz-1];
    if(s[0]!=s[len-1])
    {
        cout<<ses*k<<endl;
        return 0;
    }
    if(st%2==0 || en%2==0)
    {
        cout<<ses*k<<endl;
    }
    else
    {
        cout<<ses*k+(k-1)<<endl;
    }
    return 0;

}





































Measured memory_bytes: 256
#include<stdio.h>
int main()
{int a,b,c,s;
 scanf("%d %d %d",&a,&b,&c);
s=a+b+c;
if(a,b,c>=0 && a,b,c<=13)
 {if(s>=22) 
      printf("bust\n");
   else
        printf("win\n");
   }
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

typedef long long ll;
const int Max = 1e6;
using namespace std;

int main(){
	char s[111];
	char a[3];
	int i, j, n, m, k;
	while(~scanf("%s", &s)){
		getchar();
		int b[111];
		int len = strlen(s);
		k = 0;
		for(i = 0; i < len - 2; i++){
			a[0] = s[i], a[1] = s[i + 1], a[2] = s[i + 2];
			b[k++] = abs(atoi(a) - 753);
		}
		sort(b, b + k);
		cout << b[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

#define INF 99999

int matrixChainOrder(int *);
int min(int,int);

int n;

int main(){
  int *p;
  int i;
  int x;

  scanf("%d",&n);
  p=(int *)malloc(n*sizeof(int));
  
  for(i=0;i<n;i++){
    scanf("%d%d",&p[i],&p[i+1]);
  }
  x=matrixChainOrder(p);
  printf("%d\n",x);
  return 0;
}
int matrixChainOrder(int *p){
  int i,j,k,l;
  int m[n+1][n+1];
  int q;
 
  for(i=1;i<=n;i++) m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=INF;
      for(k=i;k<j;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	m[i][j]=min(m[i][j],q);
      }
    }
  }
  return m[1][n];
}
int min(int x,int y){
  if(x>=y) return y;
  else return x;
}



Measured memory_bytes: 2108
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Map<Long, Long> map = new HashMap<Long, Long>();

		int s = in.nextInt();
		for (int i = 1; i <= s; i++) {
			long tmpKey = in.nextLong();
			if (map.containsKey(tmpKey)) {
				long curVal = map.get(tmpKey);
				map.replace(tmpKey, curVal + 1);
				continue;
			}
			map.put(tmpKey, 1l);
		}
		long counter = 0l;
		for (long k : map.keySet()) {
			long tmpRes = map.get(k) - k;
			if (tmpRes < 0) {
				counter += map.get(k);
			} else {
				counter += tmpRes;
			}
		}
		System.out.println(counter);
	}

}

Measured memory_bytes: 63796