akhauriyash/Code-Regression huggingface dataset:
//Two Colors Card Game

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int n;cin>>n;
    map<string,int>s{};
    rep(i,0,n){
        string c;cin>>c;
        s[c]++;
    }
    cin>>n;
    rep(i,0,n){
        string c;cin>>c;
        s[c]--;
    }
    int me=-inf;
    irep(i,s){
        me=max(me,i->second);
    }
    cout <<(me<0 ? 0 : me)<<nnn;
    return 0;
}

Measured memory_bytes: 3560
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
//10:23-10:24
string S;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>S;
    ll ans=S.size();
    REP(f,2){
        ll c=0;
        REP(i,S.size()){
            if(S[i]!='0'+(f+i)%2){
                c++;
            }
        }
        ans=min(ans,c);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main(){

	int a;
	int b;
	int c;

	cin >> a  >> b >> c;

    int min = a + b;

    if(b + c < min){
    	min = b + c;
    }

    if(c + a < min){
    	min = c + a;
    }


	cout << min << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rev(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rev2(i, s, n) for (int i = (int)(n) - 1; i >= (int)(s); i--)
#define bitrep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define all(v) v.begin(), v.end()
#define println(x) cout << x << endl
#define fi first
#define se second
#define Yes println("Yes")
#define No println("No")
#define YES println("YES")
#define NO println("NO")
using pii = pair<int, int>;

int main()
{
    int n; cin >> n;
    string s; cin >> s;
    int cnt = 0;
    rep(i, 10)
    rep(j, 10)
    rep(k, 10)
    {
        vector<char> vc(3);
        vc[0] = '0' + i;
        vc[1] = '0' + j;
        vc[2] = '0' + k;
        int idx = 0;
        rep(l, s.size())
        {
            if (s[l] == vc[idx])
            {
                idx++;
                if (idx == 3)
                {
                    cnt++;
                    break;
                }
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3596
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kishan Sairam Adapa
 */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ll long long int
#define MOD ((int)(1e9) + 7)

using namespace std;

class BIncrementDecrement {
public:
    void solve(istream& cin, ostream& cout) {
        int n; string s;
        cin >> n >> s;
        ll a = 0, r = 0;
        for(auto k: s) {
            (k == 'I') ? r++ : r--;
            a = max(a, r);
        }
        cout << a << '\n';
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    BIncrementDecrement solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

using std::sort;

static int N;
static int X[100000], L[100000];
static int table[100000];

static int
solve()
{
  for (int n = 0; n < N; n++)
  {
    table[n] = n;
  }
  sort(&table[0], &table[N],
       [](int const &lhs, int const &rhs) {
         return X[lhs] + L[lhs] < X[rhs] + L[rhs];
       });
  int count = 0;
  int right = -1000000001;
  for (int n = 0; n < N; n++)
  {
    int t = table[n];
    if (right <= X[t] - L[t])
    {
      count++;
      right = X[t] + L[t];
    }
  }
  return count;
}

int
main()
{
  cin >> N;
  for (int n = 0; n < N; n++)
  {
    cin >> X[n] >> L[n];
  }
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 4764
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	int ans = 0;
	while(n){
		n /= k;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
   int n,k;
   cin>>n>>k;
   long long ans=0;
   for(int b=k+1;b<=n;b++){
      if(n%b>=k){
         if(k>0)ans+=n/b*(b-k)+n%b-k+1;
         else ans+=n/b*(b-k)+n%b;
      }
      else ans+=n/b*(b-k);
   }
   cout<<ans<<endl;
   
}

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]

res = 0
end = False
buf = a[:]
while True:
  for i,v in enumerate(buf):
    if v % 2 == 0:
      buf[i] = v // 2
    else:
      end = True
      break
  if not end:
    res += 1
  else:
    break

print(res)


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

using namespace std;
int main()
{
	vector<int>x(10000);
	vector<int>y(10000);

	int N,M,X,Y;

	bool X_STATE = true;
	bool Y_STATE = true;

	cin >>N>>M>>X>>Y;





	for(int i=0;i<N;i++){
		cin>>x[i];



				}


	for(int j=0;j<M;j++){
		cin>>y[j];

			}



	for(int k=X+1;k<=Y;k++){



		 X_STATE = true;
	     Y_STATE = true;


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

		if(x[i]>=k){
		X_STATE = false;
		continue;
			}
	}


	for(int j=0;j<M;j++){

		if(y[j]<k){
	    Y_STATE = false;
	    continue;
			}

	    }

	    if((X_STATE==true)&(Y_STATE==true)){
	    	cout<<"No War"<<endl;
	    	break;
	    }


	    if(k==Y){
	    	cout<<"War"<<endl;
	    	break;

	    }





			}










	return 0;
}




Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a+b==c||b+c==a||c+a==b){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>

int main() {
  int N;
  std::string S;
  std::cin >> N >> S;
  
  if (S.size() % 2 != 0) {
    std::cout << "No" << std::endl;
  } else {
    int mid = S.size() / 2;
    for (int i=0; i<mid; ++i) {
      if (S[i] != S[mid+i]) {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
    std::cout << "Yes" << std::endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ull     		unsigned long long int
#define ll      		long long int
#define loop(i,s,e)     for(ll i=(s);i<(e);i++)
#define rloop(i,s,e)    for(ll i=(s);i>=(e);i--)
#define scan(any)       for(auto &i:any) cin>>i;
#define print(any)      for(auto i:any) cout<<i<<" "; nl;
#define nl              cout<<'\n'
#define pi 3.141592654
#define hell 1000000007
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define IP(n) int n;cin>>n
#define IP2(a, b) int a,b;cin>>a>>b
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define all(v) (v).begin(), (v).end()
#define sz(x) (int)x.size()
#define set(a,n) memset(a,n,sizeof(a))
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
const int INF = 1<<29;
inline int two(int n) { return 1 << n; }
inline int last_bit(int n) { return n & (-n); }
inline int test(int n, int b) { return (n>>b)&1; }
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline void set_bit(int & n, int b) { n |= two(b); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////////////////
int main()
{
IP2(n,r);
int p=0;
while(n)
{
p++;
n/=r;
}
cout<<p<<endl;
return 0;
}	


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

int main()
{
	ll N, mod = 0, res = 0;
	cin >> N;
	for (ll i = 0, a; i < N; i++) {
		cin >> a;
		res += (a + mod) / 2;
		if (a)
			mod = (a + mod) % 2;
		else
			mod = 0;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
H, W, K = [int(x) for x in input().split()]
p = 10 ** 9 + 7

# H = 1, 縦棒W本のあみだくじの数　→フィボナッチ数列
h1amida = [1, 1, 2] + [None] * 6
for i in range(3, 9):
    h1amida[i] = h1amida[i - 2] + h1amida[i - 1]

# dp[h][k] = 縦棒の長さh+1、縦棒の本数W、ゴールの棒kとなるあみだの数
# dp[0][*]とdp[*][0]はダミー
dp = [[0 for _ in range(W + 1)] for _ in range(H + 1)]

for k in range(1, W + 1):
    if k == 1:
        dp[1][k] = h1amida[W - 1]
    elif k == 2:
        dp[1][k] = h1amida[W - 2]
    else:
        dp[1][k] = 0

for h in range(2, H + 1):
    for k in range(1, W + 1):
        if k > 1:
            dp[h][k] += (dp[h - 1][k - 1] * h1amida[k - 2] % p) * h1amida[W - k] % p
        dp[h][k] += (dp[h - 1][k] * h1amida[k - 1] % p) * h1amida[W - k] % p
        if k < W:
            dp[h][k] += (dp[h - 1][k + 1] * h1amida[k - 1] % p) * h1amida[W - k - 1] % p
        dp[h][k] %= p

print(dp[H][K])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

vector<int> G[200010];
int dist[200010];
const int INF=1e9;

int N;

int bfs(int s)
{
    for(int i=0;i<N;i++) dist[i]=INF;
    dist[s]=0;
    queue<int> Q;
    Q.push(s);

    while(!Q.empty()){
	int v=Q.front();
	Q.pop();
	for(int u:G[v]){
	    if(dist[u]==INF){
		dist[u]=dist[v]+1;
		Q.push(u);
	    }
	}
    }
    int maxDist=-INF;
    int res=-1;
    for(int i=0;i<N;i++){
	if(dist[i]>maxDist){
	    maxDist=dist[i];
	    res=i;
	}
    }
    return res;
}

signed main()
{
    cin>>N;
    for(int i=0;i<N-1;i++){
	int a,b; cin>>a>>b;
	a--; b--;
	G[a].push_back(b);
	G[b].push_back(a);
    }

    int x=bfs(0);
    int y=bfs(x);

    if((dist[y]+1)%3==2){
	cout<<"Second"<<endl;
    }else{
	cout<<"First"<<endl;
    }
}


Measured memory_bytes: 15984
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,0,n){
        cin>>a[i];
        a[i]-=i;//あらかじめiを引いておきましょう
    }
    sort(a,a+n);
    int median;
    median=a[(n-1)/2];
    ll cnt=0; //10^5*10^9なのでintは足りません
    rep(i,0,n)cnt+=abs(a[i]-median);//絶対値abs
    cout<<cnt;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	int f = 0, t = 0, o = 0;
	rep(i, n){
		int a; cin >> a;
		if(a % 4 == 0) f++;
		else if(a % 2 == 0) t++;
		else o++;
	}
	bool ok = f >= o;
	if(f && f == o - 1 && t % 2 == 0) ok = 1;
	if(f == 0 && o == 0 && t % 2 == 0) ok = 1;
	
	cout << (ok ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}

signed main() {
	int n,d=0;
	string s;
	cin >> n >> s;
	rep(i, n) {
		if (s[i] == '.') {
			d++;
		}
	}
	int c;
	c = d;
	rep(i, n) {
		if (s[i] == '#') {
			d++;
		}
		else {
			d--;
		}
		if (c > d) {
			c = d;
		}
	}
	cout << c << endl;
}


Measured memory_bytes: 640
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ----------- debug ---------- */

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p);

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    return b == 0 ? a : gcd(b, a % b);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

template <typename T>
T iceil(T n, T d) {
    return (n + d - 1) / d;
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    ll K, A, B;
    cin >> K >> A >> B;

    if (K + 1 <= A || B - A <= 2) {
        cout << K + 1 << endl;
        return 0;
    }

    K -= A - 1;
    cout << A + (B - A) * (K / 2) + K % 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>

typedef struct {
	double x, y;
} Coord;

Coord coord[ 21 ];

double area_poly( Coord *coord, int n ) {
	int i;
	double sum = 0.0;

	for ( i = 1; i <= n; i++ )
		sum += coord[ i - 1 ].x * coord[ i % n ].y - coord[ i - 1 ].y * coord[ i % n ].x;

	return fabs( sum ) / 2.0;
}

int main( void ) {
	int n;

	for ( n = 0; scanf( "%lf,%lf", &coord[ n ].x, &coord[ n ].y ) != EOF; n++ ) ;

	printf( "%f\n", area_poly( coord, n ) );

	return 0;
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;


int32_t main()
{
    IOS;

    int tt=1;
    //cin>>tt;
    while(tt--)
    {
      int n; cin>>n;
      string s; cin>>s;
      string a = s.substr(0,n/2);
      string b = s.substr(n/2);
      //cout<<a<<endl;
      //cout<<b<<endl;
      
      if(a == b ) cout<<"Yes";
      else cout<<"No";
    }
    return 0;

}


Measured memory_bytes: 256
# A
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

N, M = list(map(int, input().split()))
S = input()
T = input()

re = -1
if S == T:
    re = N
elif S[0] == T[0]:
    min_num = (N * M)  // gcd(N, M) # 最小公倍数を求める（基本はこれが答え）
    re = min_num
    # 重なる部分が同じ文字かを調べる
    s_d = min_num // N
    t_d = min_num // M
    # 最小公倍数みる
    st_min = (s_d * t_d) // gcd(s_d, t_d)
    st = st_min
    i = 1
    while st // s_d < N and st // t_d < M:
        if S[st // s_d] != T[st // t_d]:
            re = -1
            break
        else:
            i += 1
            st = st_min * i

print(re)

Measured memory_bytes: 40048
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define LONG_INF 10000000000000000
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
#define int long long
	int woa[4] = {};
	int n,w;
	cin >> n >> w;
	int a, b;
	cin >> a >> b;
	vector<int> wow[4];
	wow[0].push_back(b);
	REP(i, n-1) {
		int c, d;
		cin >> c >> d;
		wow[c-a].push_back(d);
		woa[c - a] += d;
	}
	REP(i, 4) {
		sort(wow[i].begin(), wow[i].end(),greater<int>());
	}
	long long ans = 0;
	long long pre_ans = 0;
	for (int i = 0;i <= wow[0].size();++i) {
		long long tmp = w - a*i;
		if (i != 0) {
			pre_ans += wow[0][i - 1];
		}
		if (tmp >= 0) {
			for (int q = 0;q <= wow[1].size();++q) {
				tmp -= q*(a + 1);
				if (q != 0) pre_ans += wow[1][q - 1];
				if (tmp >= 0) {
					for (int j = 0;j <= wow[2].size();++j) {
						tmp -= j * (a + 2);
						if (j != 0) pre_ans += wow[2][j - 1];
						if (tmp >= 0) {
							for (int ww = 0;ww <= wow[3].size();++ww) {
								tmp -= ww * (a + 3);
								if (ww != 0) pre_ans += wow[3][ww - 1];
								if (tmp >= 0) {
									ans = max(ans, pre_ans);
								}
								tmp += ww*(a + 3);
							}
							pre_ans -= woa[3];
						}
						tmp += j * (a + 2);
					}
					pre_ans -= woa[2];
				}
				tmp += q * (a + 1);
			}
			pre_ans -= woa[1];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

ans = 0
while True:
    if max(h) == 0:
        break
    i = 0
    while i < N:
        if h[i] == 0:
            i += 1
        else:
            ans += 1
            while i < N and h[i] > 0:
                h[i] -= 1
                i += 1

print(ans)

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef long long lint;

int N;
lint A[300005];

bool able(lint x, int piv) {
	int add = 0;
	for_(i,0,3) {
		int lb = 0, ub = N+10;
		while (ub - lb > 1) {
			int med = (ub + lb) / 2;
			if (A[piv + add + med] - A[piv + add] >= x) ub = med;
			else lb = med;
		}
		add += ub;
		if (add > N) return false;
	}
	return true;
}

void solve() {
	for_(i,1,N+1) A[i + N] = A[i + 2 * N] = A[i];
	for_(i,1,3*N+5) A[i] += A[i - 1];
	
	lint ans = 0;
	for_(piv,0,N) {
		lint lb = 0, ub = 1e16;
		while (ub - lb > 1) {
			lint med = (ub + lb) / 2;
			if (able(med, piv)) lb = med;
			else ub = med;
		}
		ans = max(ans, lb);
	}
	cout << ans << endl;
}

int main() {
	cin >> N;
	for_(i,0,N) cin >> A[i + 1];	
	solve();
}

Measured memory_bytes: 5444
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0

[n,l]=inpl()
applist = np.arange(1,n+1) + l - 1
applist.sort()

if 0 in applist:
    ans = applist.sum()
elif applist[0] > 0:
    ans = applist[1:].sum()
elif applist[-1] < 0:
    ans = applist[:-1].sum()
print(ans)

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

using namespace std;

template <int MD>
struct ModInt {
    typedef ModInt M;
    int v;
    ModInt(int _v = 0) : v(_v) {}
    M& operator += (const M &r) {
        if ((v += r.v) >= MD) v -= MD;
        return *this;
    }
    M operator + (const M &r) const { return M(*this) += r; }
};

typedef pair<int, int> P;
typedef ModInt<1000000007> Mint;

const int MN = 310;
int n, m;
Mint dp[MN][MN][MN];
vector<P> v[MN];

int check(int a, int b, int c, int l) {
    return (l <= a) + (l <= b) + (l <= c);
}

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        int x, y, z;
        scanf("%d %d %d", &x, &y, &z);
        v[y].push_back(P(x, z));
    }

    Mint sm = 0;
    dp[0][0][0] = 1;
    for (int r = 0; r <= n; r++) {
        for (int g = 0; g <= n; g++) {
            for (int b = 0; b <= n; b++) {
                if (!dp[r][g][b].v) continue;
                int i = max(r, max(g, b));
                bool ok = true;
                for (int j = 0; j < int(v[i].size()); j++) {
                    int l = v[i][j].first;
                    int c = v[i][j].second;
                    ok &= check(r, g, b, l) == c;
                }
                if (!ok) continue;

                if (i == n) sm += dp[r][g][b];
                else {
                    dp[i+1][g][b] += dp[r][g][b];
                    dp[r][i+1][b] += dp[r][g][b];
                    dp[r][g][i+1] += dp[r][g][b];
                }
            }
        }
    }
    printf("%d\n", sm.v);
    return 0;
}

Measured memory_bytes: 116608
import heapq


N, M = [int(x) for x in input().split()]
A = [-int(x) for x in input().split()]

heapq.heapify(A)
for i in range(M):
    a = -heapq.heappop(A)
    a //= 2
    heapq.heappush(A, -a)

print(-sum(A))


Measured memory_bytes: 20448
# coding: utf-8
# Your code here!

N = int(input())
S = input()
A = list(S)

alpha2num = lambda c: ord(c) - ord('A') + 1
num2alpha = lambda c: chr(c+64)

lis1 = list(map(lambda x: alpha2num(x), A))
lis2 = list(map(lambda x: (x + N) % 26, lis1))
lis3 = list(map(lambda x: x + 26 if x == 0 else x, lis2))
lis4 = list(map(lambda x: num2alpha(x), lis3))

print(''.join(lis4))

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, ans=0;
    string S;
    cin >> A >> B;
    // cout << ans<<endl;
    
    if(A<B)
    	cout << 0<<endl;
    else
    	cout <<10<<endl;
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;

    // if(A == 1)
    // 	puts("ABC");
    // else
    // 	puts("chokudai");
    	
}


Measured memory_bytes: 256
n = int(input())
abc = []
for _ in range(n):
    abc_ = list(map(int, input().split()))
    abc.append(abc_)
dp = [[0]*3 for _ in range(n)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]
for i in range(1, n):
    dp[i][0] = max(abc[i][0]+dp[i-1][1], abc[i][0]+dp[i-1][2])
    dp[i][1] = max(abc[i][1]+dp[i-1][0], abc[i][1]+dp[i-1][2])
    dp[i][2] = max(abc[i][2]+dp[i-1][0], abc[i][2]+dp[i-1][1])
print(max(dp[n-1][0], dp[n-1][1], dp[n-1][2]))

Measured memory_bytes: 47336
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

ll N;
ll sum;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cin >> N;
	for(int i = 1; i <= N; i++){
		if(i % 3 != 0 && i % 5 != 0) sum += i;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3612
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans,dp[3100][3100],a[220000], b[220000];
string str, ss;
bool f[220000];
char c[4000][4000];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>vec,rvec;
vector<edge>ed;
vector<LL>v;
map<string, LL>ma;
set<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> str >> ss;
	string res;
	rep(i, str.size()) {
		rep(j, ss.size()) {
			if (str[i] == ss[j]) {
				dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
			}
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);
		}
		dp[i + 1][ss.size()] = max(dp[i + 1][ss.size()], dp[i][ss.size()]);
	}
	rep(i, ss.size())dp[str.size()][i + 1] = max(dp[str.size()][i+1],dp[str.size()][i]);
	s = str.size(), t = ss.size();
	while (s > 0 && t > 0) {
		if (dp[s][t] == dp[s - 1][t])
			s--;
		else if (dp[s][t] == dp[s][t - 1])
			t--;
		else if (dp[s][t] == dp[s - 1][t - 1] + 1) {
			res = str[s - 1] + res; s--, t--;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 76032
#include<bits/stdc++.h>
using namespace std;
int dp[100025];
int main()
{
  int n,h[100015];
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>h[i];
  }
  dp[1]=0;
  dp[2]=abs(h[2]-h[1]);
  for(int i=3;i<=n;i++){
    dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
  }
  cout<<dp[n]<<"\n";
  return 0;
}


Measured memory_bytes: 1024
#113_D
H,W,K=map(int,input().split())
K-=1
Mod=10**9+7

#row全探索
Row=[]
for i in range(2**(W-1)):
    row=[]
    flg=True
    for j in range(W-1):
        if j>0:
            if (i>>j)&1 and (i>>(j-1))&1:
                flg=False
        row.append((i>>j)&1)
    if flg:
        Row.append(row)
        
Count=[0 for _ in range(W-1)]
for row in Row:
    for i in range(W-1):
        Count[i]+=row[i]

dp=[[0 for _ in range(W)] for _ in range(H+1)]
dp[0][K]=1
if W==1:
    print(1)
    
else:
    for h in range(1,H+1):
        for x in range(W):
            if x==0:
                dp[h][x]=dp[h-1][x]*(len(Row)-Count[x])+dp[h-1][x+1]*Count[x]
            elif x==W-1:
                dp[h][x]=dp[h-1][x]*(len(Row)-Count[x-1])+dp[h-1][x-1]*Count[x-1]
            else:
                dp[h][x]=dp[h-1][x]*(len(Row)-Count[x]-Count[x-1])+dp[h-1][x+1]*Count[x]+dp[h-1][x-1]*Count[x-1]

    print(dp[H][0]%Mod)

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

using namespace std;
#define ll long long
const int MAXN = 2e5 + 1;
int mass[301][301];
int ans[301][301];
int summcolomn[301];
void solve() {
    int n,m, k;
    cin>>n>>m>>k;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        for(int j=0;j<m;j++){
            mass[i][j]=(s[j]=='#')?1:0;
            summcolomn[j]+=mass[i][j];
        }
    }
    /*for(int i=0;i<m;i++) cout<<summcolomn[i]<<" ";
    cout<<endl;*/
    int left=0;
    int lastcolor=0;
    bool end;
    for(int i=0;i<m;i++){
        if(summcolomn[i]==0) continue;
       /* cout<<endl;
        cout<<" i "<<i<<endl;
        for(int c=0;c<n;c++){
            for(int j=0;j<m;j++){
                cout<<ans[c][j]<<" ";
            }
            cout<<endl;
        }*/
        end=(lastcolor+summcolomn[i]==k);
        for(int j=0;j<n;j++){
            //cout<<((end)?(m-1):i)<<" i "<<i<<" "<<m-1<<endl;
            for(int kk=left;kk<=((end)?(m-1):i);kk++){
                ans[j][kk]=lastcolor+summcolomn[i];
                //cout<<kk<<" ";
            }
        }
        int up=0;
        for(int j=0;j<n;j++){
            if(mass[j][i]){
                for(int s=up;s<=j;s++){
                    for(int kk=left;kk<=((end)?(m-1):i);kk++){
                        ans[s][kk]=lastcolor+1;
                        //cout<<kk<<endl;
                    }
                }
                lastcolor++;
                up=j+1;
            }
        }
        left=i+1;
    }


    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }



}

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


Measured memory_bytes: 1536
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v = procon_read();
	let a: i32 = v[0];
	let p: i32 = v[1];
	println!("{}", (3*a + p)/2);
}

Measured memory_bytes: 2168
#include <iostream>
#include <bits/stdc++.h>
#include <string.h>
#include <cstdlib>
using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	if( a+b==15){
	    cout<<"+";
	}
	else if( a*b==15){
	    cout<<"*";
	}
	else{
	    cout<<"x";
	}
}

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

int main(void){
    int m,n,i,j;
    int A[101][101];
    int B[101];
    int C[101];
    int dummy;
    
    scanf("%d %d",&n,&m);
    
    if(m<1||n<1||100<m||100<n){
        printf("error\n");
        return 0;
    }
    
   
    
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&dummy);
            if(dummy<0||1000<dummy){
                printf("error\n");
                return 0;
            }
            else{
                A[j][i]=dummy;
            }
        }
    }
    
    for(i=0;i<m;i++){
        scanf("%d",&B[i]);
        if(B[i]<0||1000<B[i]){
            printf("error\n");
            return 0;
        }
    }
    
    
    for(i=0;i<n;i++){
        C[i]=0;
        for(j=0;j<m;j++){
            C[i]+=A[j][i]*B[j];
        }
    }
    
    for(i=0;i<n;i++){
        printf("%d\n",C[i]);
    }
    
    return 0;
}


Measured memory_bytes: 2104
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) { // nCr の計算
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

int main() {
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	if (a[0] == a[1] && a[1] == a[2]) {
		cout << "No" << endl;
	} else if (a[0] == a[1] || a[1] == a[2]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3524
import java.io.*;

class Main {
    BufferedReader bf;
    PrintWriter writer;
    StringBuilder sb;
    static boolean local_system = false;

    void run() throws IOException {
        char[] d = bf.readLine().trim().toCharArray();
        int v = 0;
        for(char e : d) v=(v+(e-'0'))%9;
        writer.print(v == 0 ? "Yes" : "No");
    }   

    public static void main(String[] args) throws IOException {
        long start_time = System.currentTimeMillis();
        Main obj = new Main();
        obj.run();
        long end_time = System.currentTimeMillis();
        if (local_system) obj.writer.println("Time : " + (end_time - start_time));
        obj.close();
    }

    public Main(){
        writer = new PrintWriter(System.out);
        bf = new BufferedReader(new InputStreamReader(System.in));
        sb = new StringBuilder();
    }

    public int i() throws IOException {
        return Integer.parseInt(bf.readLine());
    }

    public long l() throws IOException {
        return Long.parseLong(bf.readLine());
    }

    public int[] ni() throws IOException {
        String[] data = bf.readLine().split(" ");
        int[] send = new int[data.length];
        for (int i = 0, h = data.length; i < h; i++) send[i] = Integer.parseInt(data[i]);
        return send;
    }

    public long[] nl() throws IOException {
        String[] data = bf.readLine().split(" ");
        long[] send = new long[data.length];
        for (int i = 0, h = data.length; i < h; i++) send[i] = Long.parseLong(data[i]);
        return send;
    }

    public void close() throws IOException{
        writer.flush();
        writer.close();
        bf.close();
    }
}




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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int N, C, s, t, c; cin >> N >> C;
	vector <vector <pair<int,int>>> v(C);
	for (int i = 0; i < N; ++i){
		cin >> s >> t >> c;
		s *= 2; t *= 2; --c;
		v[c].emplace_back(s,t);
	}
	vector <pair<int,int>> sor;
	for (int i = 0; i < C; ++i){
		sort(v[i].begin(),v[i].end());
		vector <pair<int,int>> tmp;
		if (!v[i].empty()){
//			pair<int,int> p;
			int x = v[i][0].first;
			for (int j = 1; j < v[i].size(); ++j){
				if (v[i][j-1].second != v[i][j].first){
					tmp.emplace_back(x, v[i][j-1].second);
					x = v[i][j].first;
				}
			}
			tmp.emplace_back(x, v[i][v[i].size()-1].second);	
		}
//		cout << "Test " << i  << " " << tmp.size()<< "\n";
		for (auto i : tmp){
			sor.push_back(i);
		}	
	}
	sort(sor.begin(),sor.end());
//	for (auto i : sor){
//		cout << i.first <<  " " << i.second << "\n";
//	}
	int req = 1;
	multiset <int> free;
	for (int i = 0; i < sor.size(); ++i){
		if (free.empty()){
			free.insert(sor[i].second);
		}else{
			if (*free.begin() < sor[i].first){
				free.erase(free.begin());
				free.insert(sor[i].second);
			}else{
				++req;
				free.insert(sor[i].second);
			}
		}
	}
	cout << req << "\n";
	
	return 0;
}


Measured memory_bytes: 5576
// Template begins
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue> 
#include <string.h>
#include <string>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<b;i++)
#define all(v) (v).begin(),(v).end()
#define sort0(v) sort(all(v))
#define lbb(a,b,arr,x) lower_bound(arr+a,arr+b+1,x)-arr
#define ubb(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-arr
#define freq(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-lower_bound(arr+a,arr+b+1,x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define printp(x) cout << x.ff << " " << x.ss << endl

const ll mod=998244353;
#define inf 9999999999999
#define MAXN   100001 
  
// stores smallest prime factor for every number 

 
ll inv(ll i){if(i==1) return 1;return (mod-((mod/i)*inv(mod%i))%mod)%mod;}
 
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b,b%a);}
inline void fastio(){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
// Template ends
const int MN = 2e5+7;
bool visited[100001];
int color[100001];
vector<long> v; 

//
//ll input[100002][100002];
//ll arr[300000];
int n,k;
ll arr[200002];
ll check(ll x){
    ll val=0;
    for(int i=0;i<n;i++){
        val+=(arr[i]/x);
        if(arr[i]%x==0){
            val--;
        }
        
    }
    return val;
}

int main(){
    fastio();
    //write code
    cin>>n>>k; int i;
    ll low=1;
    ll high=0;
    ll mid;
    fo(i,0,n){
        cin>>arr[i];
        high=max(high,arr[i]);
    }
    ll ans=-1;
    while(low<=high){
        mid=(low+high)/2;
        //cout<<"mid :"<<mid<<endl;
        //cout<<"check :"<<check(mid)<<endl;
        if(check(mid)<=k){
            ans=mid;
            high=mid-1;
        }else{
            low=mid+1;
        }
    }
    cout<<ans<<endl;

    
    return 0;
}

 

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

#define INF 10000000000000000
#define N 100
long long A[N][N];

void warshallfloyd(int n) {
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            if (A[i][k] == INF) continue;
            for (int j = 0; j < n; j++) {
                if (A[k][j] == INF) continue;
                A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
            }
        }
    }
}

int main() {
    int n, e;
    cin >> n >> e;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) A[i][j] = 0;
            else A[i][j] = INF;
        }
    }

    int node1, node2;
    long long w;
    for (int i = 0; i < e; i++) {
        cin >> node1 >> node2 >> w;
        A[node1][node2] = w;
    }

    warshallfloyd(n);

    bool negative = false;
    for (int i = 0; i < n; i++) {
        if (A[i][i] < 0) {
            negative = true;
            break;
        }
    }

    if (negative) {
        cout << "NEGATIVE CYCLE" << endl;
    } else {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (j != 0) cout << " ";
                if(A[i][j] == INF) cout << "INF";
                else cout << A[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}



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

#define lli long long int
#define ld long double
//初期化
#define DEFO(n) lli n = 0;
//整数最大
#define MAX(n) lli n = 9000000000000000000;
//整数最小
#define MIN(n) lli n = -9000000000000000000;
//少数最大
#define MAX_D(n) ld n = 4500;
//少数最小
#define MIN_D(n) ld n = -4500;
//整数入力
#define LLI(n) \
  lli n;       \
  cin >> n;
//少数入力
#define LD(n) \
  ld n;       \
  cin > n;
//整数配列入力
#define LLIV(a, n)            \
  vector<lli> a(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
//２列整数配列入力
#define LLIV2(a, b, n)         \
  vector<lli> a(n), b(n);      \
  for (lli i = 0; i < n; i++)  \
  {                            \
    cin >> a.at(i) >> b.at(i); \
  };
//３列整数配列入力
#define LLIV3(a, b, c, n)                 \
  vector<lli> a(n), b(n), c(n);           \
  for (lli i = 0; i < n; i++)             \
  {                                       \
    cin >> a.at(i) >> b.at(i) >> c.at(i); \
  };
//少数配列入力
#define LDV(a, n)             \
  vector<ld> a(n);            \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
//文字列入力
#define STR(n) \
  string n;    \
  cin >> n;
//文字列配列入力
#define STRV(a, n)            \
  vector<string> a(n);        \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
//配列の合計
#define SUM(n) accumulate(n.begin(), n.end(), 0);
//配列を昇順
#define SORT(n) sort(n.begin(), n.end());
//配列を降順
#define REVE(n) reverse(n.begin(), n.end());
//Yesと表示
#define yes              \
  cout << "Yes" << endl; \
  return 0;
//Noと表示
#define no              \
  cout << "No" << endl; \
  return 0;
//Noneと表示
#define none              \
  cout << "None" << endl; \
  return 0;
//四捨五入
#define C45(n) (n + 1) / 2
//nを出力
#define OUT(n) cout << n << endl;
//文字列からcを探す
#define SRC(n, c)                    \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    if (s.at(i) == c)                \
    {                                \
      n++;                           \
    }                                \
  };

//素数
bool IsPrime(lli num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}
//各桁の和
lli KSum(lli n)
{
  lli sum = 0;
  if (n < 0)
    return 0;
  while (n > 0)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

//数値反転
bool KReve(lli n)
{
  int reverse = 0;
  int remaind;
  int tmp = n;
  while (tmp != 0)
  {
    remaind = tmp % 10;
    reverse = reverse * 10 + remaind;
    tmp /= 10;
  }
  if (reverse == n)
    return true;
  else
    return false;
}

int main(void)
{
  ios::sync_with_stdio(false);
  LLI(a)LLI(b)LLI(c)LLI(x)LLI(y)DEFO(ans)
  lli z = min(x, y);
  lli w = a * x +  b * y;
  lli q = c * z * 2 + a * (x - z) + b * (y - z);
  lli s = c * max(x, y) * 2;
  ans = min(w, q);
  ans = min(ans, s);
  OUT(ans)
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL E[4] = {};
		rep(i, 6) {
			UL e; cin >> e; e--;
			E[e]++;
		}
		sort(E, E + 4);
		if (E[0] == 1 && E[1] == 1 && E[2] == 2) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

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

int main() {
	string num;
	int count=0;
	cin >> num;
	for (int i = 0; i < 3; i++) {
		if (num[i] == '1'){
			count++;
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int M1, M2, D1, D2;
  cin >> M1 >> D1 >> M2 >> D2;
    if (D2 == 1){
      cout << 1 << endl;
    }
  else {
    cout << 0 << endl;
  }
}

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

int main(){
  int n;
  cin>>n;
  vector<int> A(n);
  vector<int> B(n-1);
  rep(i,n-1) cin>>B[i];
  int ans=0;
  A[0]=B[0];
  A[n-1]=B[n-2];
  for(int i=1;i<n-1;i++){
    A[i]=min(B[i-1],B[i]);
  }
  rep(i,n) ans+=A[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 256