akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int main(){
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  vector<int>si(s.length()), sim(s.length()); // sim: si mod 2019
  vector<int>simr(s.length()+1, 0);
  for(int i=0; i<s.length(); i++){
    si[i] = s[i]-'0';
  }
  int pow10 = 1;
  for(int i=0; i<s.length(); i++){
    sim[i] = (si[i]*pow10)%2019;
    pow10 *= 10;
    pow10 %= 2019;
  }
  for(int i=1; i<=s.length(); i++){
    simr[i] = (simr[i-1]+sim[i-1])%2019;
  }
  vector<long>cntmod(2019, 0);
  for(int i: simr){
    cntmod[i]++;
  }
  long ret = 0;
  for(int i=0; i<2019; i++){
    ret += cntmod[i]*(cntmod[i]-1)/2;
  }
  cout << ret;
  return 0;
}
  

Measured memory_bytes: 5312
#include <stdio.h>

long long n;
long long h[100010];
long long dp[100010];

long long chmin(long long a, long long b)
{
	if (b > a)
		return a;
	else 
		return b;
}

long long ab(long long x)
{
	if (x < 0)
		return -x;
	return x;
}

int main(int argc, char const *argv[])
{
	scanf("%lld", &n);
	for (int i = 0; i < n; i++)
	{
		dp[i] = 99999999999999;
		scanf("%lld", &h[i]);
	}
	dp[0] = 0;

	for (int i = 0; i < n; i++)
	{
		if(i+1 < n) dp[i + 1]=chmin(dp[i] + ab(h[i + 1] - h[i]), dp[i + 1]);
		if(i+2 < n) dp[i + 2]=chmin(dp[i] + ab(h[i + 2] - h[i]), dp[i + 2]);
	}

	printf("%lld\n", dp[n - 1]);
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdlib>

using namespace std;

long long a[2001];
long long din[2001][2];

int main()
{
    int n, w;
    cin >> n >> w >> a[0];
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        a[i] = abs(a[i] - a[n]);
    din[0][n - 1] = a[n - 1];
    din[1][n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; i--) {
        din[0][i] = a[i];
        for (int j = i + 1; j < n; j++)
            din[0][i] = max(din[0][i], din[1][j]);
        din[1][i] = a[i];
        for (int j = i + 1; j < n; j++)
            din[1][i] = min(din[1][i], din[0][j]);
    }
    cout << din[0][0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <limits>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <string>
#include <iostream>

int main()
{
	using namespace std;
    int a,b;
	cin >> a >> b;
    cout << ceil((a+b)/2.0) << endl;
	return 0;
}


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

int main(void) {
	int A, B, C;
	cin >> A >> B >> C;

	string ans = "Yes\n";
	if ((A == B && B == C && C == A) || (A != B && B != C && C != A))
		ans = "No\n";

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
struct edge{int to,  cost;};
vector<edge> G[100001];
int N;
int V[100001];

void dfs(int v){
	for(int i=0;i<G[v].size();i++){
	
		int u=G[v][i].to;
		int w=G[v][i].cost;
		if(V[u]==-1){
			if(V[v]==0){
				if(w%2==1)V[u]=1;
				else V[u]=0;
			}
			else if(V[v]==1){
				if(w%2==1)V[u]=0;
				else V[u]=1;
			}
			dfs(u);
		}
	}
}
int main(){
	for(int i=0;i<100001;i++)V[i]=-1;
	cin >> N;
	for(int i=0;i<N-1;i++){
		int u,v,w;
		cin >> u >> v >> w;
		edge e;
		e.to = v; e.cost =w;
		G[u].push_back(e);
		e.to = u;
		G[v].push_back(e); 
	}
	V[1]=0;
	dfs(1);
	for(int i=1;i<=N;i++)cout << V[i] << endl;
	return 0;
}

Measured memory_bytes: 8448
A, B, C, D = [int(i) for i in list(input())]

ans = 0
ans = "{0}+{1}+{2}+{3}=7".format(A, B, C, D) if A+B+C+D==7 else ans
ans = "{0}+{1}+{2}-{3}=7".format(A, B, C, D) if A+B+C-D==7 else ans
ans = "{0}+{1}-{2}+{3}=7".format(A, B, C, D) if A+B-C+D==7 else ans
ans = "{0}+{1}-{2}-{3}=7".format(A, B, C, D) if A+B-C-D==7 else ans
ans = "{0}-{1}+{2}+{3}=7".format(A, B, C, D) if A-B+C+D==7 else ans
ans = "{0}-{1}+{2}-{3}=7".format(A, B, C, D) if A-B+C-D==7 else ans
ans = "{0}-{1}-{2}+{3}=7".format(A, B, C, D) if A-B-C+D==7 else ans
ans = "{0}-{1}-{2}-{3}=7".format(A, B, C, D) if A-B-C-D==7 else ans

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll m=1e9+7;
int main(){
int n;
cin>>n;
ll a[n];
ll pref[n];
memset(pref,0,sizeof(pref));
for(ll &z:a){ cin>>z; }
pref[0]=a[0];
for(int i=1;i<n;i++){
	pref[i]=pref[i-1]+a[i];
}
ll s=0;
for(int i=0;i<n-1;i++){
	//(s+=((pref[n-1]-pref[i])*a[i]))%=m;
  	ll f=(pref[n-1]-pref[i])%m;
  	s+=(f*a[i]);
  	s%=m;
}
cout<<s;
return 0;
}


Measured memory_bytes: 6740
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int d[11][11];//d[u][v]??????e=(u,v)????????????(?????¨???????????´??????INF,??????d[i][i]=0??¨??????)
int V=10;//????????°
const int INF=10000000;

void warshall_floyd(){
	for(int k=0;k<V;k++){
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
}

int main(){
	while(1){
		rep(i,0,10){
			rep(j,0,10){
				if(i==j) d[i][j]=0;
				else d[i][j]=INF;
			}
		}
		int n;
		cin>>n;
		if(n==0) break;
		int from,to,dist;
		rep(i,0,n){
			cin>>from>>to>>dist;
			d[from][to]=dist;
			d[to][from]=dist;
		}
		warshall_floyd();
		int MIN=INF,ans=0;
		rep(i,0,10){
			int sum=0;
			rep(j,0,10){
				if(d[i][j]!=INF) sum+=d[i][j];
			}
			if(sum==0) continue;
			if(sum<MIN){
				MIN=sum;
				ans=i;
			}
		}
		o(ans<<" "<<MIN);
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
ll factorial(ll a){return a < 2 ? 1 : factorial(a - 1) * a;}
ll summation(ll a){return a < 1 ? 0 : (a * a + a) / 2;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ll N = 200005;
const ll M = 100005;
const string ALPHABETS = "abcdefghijklmnopqrstuvwxyz";
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//ll dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
ll n, m, x, y, z, w, h;
string s, t;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> x >> y >> z){
        ll ans = 0, tmp = 0, cnt = 0, mx = -INF, mn = INF;
        ll a[N] = {}, b[N] = {}, c[N] = {};
        vll v;
        if(x == y && y == z){
            if(x % 2){
                print(0);
                return 0;
            }else{
                print(-1);
                return 0;
            }
        }
        ll tmp2;
        while(x % 2 == 0 && y % 2 == 0 && z % 2 == 0){
            tmp = x, tmp2 = y, x = (y + z) / 2, y = (tmp + z) / 2, z = (tmp + tmp2) / 2, ans++;
        }
        print(ans);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;



int main() {
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << " " << y << " " << z << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

bool f[100001];

int main () {
  ll n, k;
  cin >> n >> k;
  ll r, s, p;
  cin >> r >> s >> p;
  string t;
  cin >> t;

  ll ans = 0;
  rep(i,n) {
    if (t[i] == 's') ans += r;
    else if (t[i] == 'p') ans += s;
    else ans += p;
  }

  rep(i,n) {
    if (i+k < n && t[i] == 's' && t[i+k] == 's') {
      if (!f[i]) {
        ans -= r;
        f[i+k] = true;
      }
    }
    else if (i+k < n && t[i] == 'p' && t[i+k] == 'p') {
      if(!f[i]) {
        ans -= s;
        f[i+k] = true;
      }
    }
    else if (i+k < n && t[i] == 'r' && t[i+k] == 'r') {
      if(!f[i]) {
        ans -= p;
        f[i+k] = true;
      }
    }
  }

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

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


long long Gcd(long long int m, long long int n)
{
	long long int temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}
long long int Lcm(long long int m, long long int n)
{
	return m * n / Gcd(m,n); 
}


int main(){
 long long int a,b,c,d,count;
  count=0;
  cin>>a>>b>>c>>d;
  long long int tmp1=0;
  long long int tmp2=0;
  long long int tmp3=0;
  long long int tmp4=0;
  long long int tmp5=0;
  long long int tmp6=0;
  long long int i=b;
  long long int abc=Lcm(c, d);
  tmp1=b/c; 
  tmp2=b/d;
  tmp3=a/c;
  tmp4=a/d;
  tmp5=b/abc;
  tmp6=a/abc;

 long long int ans=0;

 ans=(tmp1-tmp3)+(tmp2-tmp4)-(tmp5-tmp6);
 if(b%c==0){
 //	ans++;
 }
 if(b%d==0){
 //	ans++;
 }
 if(a%c==0){
    ans++;
 }
 if(a%d==0){
 	ans++;
 }
 if(b%abc==0){
 //	ans--;
 }
 if(a%abc==0){
 	ans--;
 }

/* cout<<(tmp1-tmp3)<<endl;
 cout<<(tmp2-tmp4)<<endl;
 cout<<(tmp5-tmp6)<<endl;
 cout<<tmp5<<endl;
 cout<<tmp6<<endl;
 cout<<ans<<endl;*/
 cout<<1+b-a-ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,q,k;
string s;
int main()
{
	cin>>n>>s;
	cin>>q;
	while(q--)
	{
		ll a=0,b=0,c=0,b2=0,ans=0;
		cin>>k;
		for(int i=0;i<n;i++)
		{
			if(s[i]=='D')a++;
			if(s[i]=='M')b++,b2+=a;
			if(s[i]=='C')ans+=b2;
			if(i>=k-1)
			{
				int fir=i-k+1;
				if(s[fir]=='D')a--,b2-=b;
				if(s[fir]=='M')b--;
			}
		}
		cout<<ans<<endl;
	} 
}

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

int main(){
	int n,m,i,j;
	while(cin >> n >> m, n && m){	
		int ret = 0;
		vector<int> data(n+1);
		vector<int> all;
		for(i=0;i<n;i++)cin >> data[i];
		for(i=0;i<n+1;i++)
			for(j=i;j<n+1;j++)
				all.push_back(data[i]+data[j]);
		sort(all.begin(),all.end());
		for(i=0;i<all.size();i++){
			int t = m-all[i];
			vector<int>::iterator it = upper_bound(all.begin(),all.end(),t);
			if( it == all.end() ){
				ret = max(ret,all[i] + all.back());
			}else if(it != all.begin()){
				ret = max(ret,all[i] + *(it-1) );
			}
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a,b;
  cin>>a>>b;
  ll c=a%2019;
  ll d=b%2019;
  if(d<=c){
    cout<<0<<endl;
    return 0;
  }
  if(b-a>d-c){
    cout<<0<<endl;
    return 0;
  }
  ll f=c*(c+1);
  for(ll i=c+1;i<d+1;i++){
    for(ll j=c;j<i;j++){
      f=min(f,i*j%2019);
    }
  }
  cout<<f<<endl;
    
      
}


Measured memory_bytes: 3612
# include<iostream>
# include<vector>
#include<algorithm>
#include<cstdlib>
#include <math.h>
using namespace std;

int main(){
    int mod = 2019;
    int l, r;cin >> l >> r;
    if(r-l >= 2019){cout << 0 << endl;return 0;}
    l = l%mod;
    r = r%mod;
    if(l>=r){
        cout << 0 << endl;
        return 0;
    }
    int min = 3000;
    for(int i = l; i<r; i++){
        for(int k = i+1; k<=r; k++){
            int res = (i*k)% mod;
            if(res < min){min = res;}
        }
    }
    cout << min << endl;
}

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

using namespace std;

#define IO ios_base::sync_with_stdio(0);cin.tie(0);

int main()
{
  IO;
  int n; cin >> n;
  int a = n / 1000, b = n / 100 % 10, c = n / 10 % 10, d = n % 10;

  for (int i = 0; i <= 1; ++i)
  for (int j = 0; j <= 1; ++j)
  for (int k = 0; k <= 1; ++k) {
    int sum = 0;
    if (i) sum += a + b; else sum += a - b;
    if (j) sum += c; else sum -= c;
    if (k) sum += d; else sum -= d;
    if (sum == 7) {
      cout << a;
      if (i) cout << "+"; else cout << "-";
      cout << b;
      if (j) cout << "+"; else cout << "-";
      cout << c;
      if (k) cout << "+"; else cout << "-";
      cout << d << "=7" << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

int n;
pii vec[200000];
int ans[200000];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &vec[i].first);
		vec[i].second = i;
	}
	sort(vec, vec + n);

	for (int i = 0; i < n / 2; i++)
		ans[vec[i].second] = vec[n / 2].first;

	for (int i = n / 2; i < n; i++)
		ans[vec[i].second] = vec[n / 2 - 1].first;

	for (int i = 0; i < n; i++)
		printf("%d\n", ans[i]);
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n;cin >> n;
  vector<ll> a(n+1);
  for(int i=1; i<n+1; i++) cin>>a.at(i);
  a.at(0)=0;
  
  sort(a.begin(), a.end());
  bool ans=true;
  for(int i=1; i<n+1; i++) {
    if(a.at(i-1)==a.at(i)) {
      ans=false;
      break;
    }
  }
  if(ans==false) cout << "NO" << endl;
  else cout << "YES" << endl;
  
}

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

int main() {
  int N;
  int sum = 0;
  cin >> N;
  
  vector<int> taste(N);
  
  for (int i = 0; i < N; i++) {
    cin >> taste.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N ;j++) {
      sum += taste.at(i) * taste.at(j);
    }
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a[100000];

	int b = 0;

	for(int i=1;i < 100000;i++)
	{
		cin >> a[i];

		b++;

		if(a[i] == 0)
		{
			break;
		}
	}

	for(int i = 1; i < b; i++)
	{
		cout << "Case " << i << ": " << a[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3104
input_train_price1=input()
input_train_price2=input()
input_bus_price1=input()
input_bus_price2=input()

train_price=[int(input_train_price1),int(input_train_price2)]
bus_price=[int(input_bus_price1),int(input_bus_price2)]

best_train_price=min(train_price)
best_bus_price=min(bus_price)

#print(best_train_price+"+"+best_bus_price)

total_price=best_train_price+best_bus_price

print(str(total_price))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  int n, m;
  cin >> n >> m;
  int ans=0;
  ans = (n * (n -1))/2 + (m * (m -1))/2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
int main(){
  int h,w,i,j;
  
  for(;;){
    
    scanf("%d %d",&h,&w);

    if(h == 0 && w ==0){
      break;
    }
    
    for(i = 0;i < h;i++ ){
      if(i % 2 == 1){
        for(j = 0;j < w;j++){
          if(j % 2 == 0){
            printf(".");
	  }
	  else{
	    printf("#");
	  }
	}
      }
      else{
        for(j = 0;j < w;j++){
          if(j % 2 == 0){
            printf("#");
	  }
	  else{
	    printf(".");
	  }
        }
      }
      printf("\n");
    }
    printf("\n");  
  }
  return 0; 
}

Measured memory_bytes: 572
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

long long n, k;
vector<int> bitcnt;
long long dp[41][2];

long long calc(int d, bool f){
    if(dp[d][f] >= 0) return dp[d][f];
    if(d < 0) return 0;
    long long res = 0;
    int m = (f? (k & (1LL << d)) >> d : 1);
    for(int i = 0; i <= m; i++){
        int c;
        if(i == 0) c = bitcnt[d];
        else c = n - bitcnt[d];  
        res = max(res, calc(d - 1, f & (i == m)) + (1LL << d) * c);
    }
    return dp[d][f] = res;
}

int main(){
    cin >> n >> k;
    vector<long long> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    bitcnt = vector<int>(41);
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= 40; j++){
            if(a[i] & (1LL << j)){
                bitcnt[j]++;
            }
        }
    }
    for(auto&& i : dp){
        for(auto&& j : i){
            j = -1;
        }
    }
    long long ans = calc(40, true);
    cout << ans << endl;
    return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

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

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

ll dp[110][310];

int main() {
    int N, W;
    cin >> N >> W;
    V<pii> vec(N);

    int w1;
    memset(dp, -1, sizeof(dp));

    dp[0][0] = 0;

    rep(i, N) {
        int w, v;
        cin >> w >> v;
        if (i == 0) {
            w1 = w;
            dp[1][0] = v;
        } else {
            for (int j = N; j >= 0; --j) {
                rep(k, 310) {
                    if (dp[j][k] != -1) {
                        chmax(dp[j + 1][k + w - w1], dp[j][k] + v);
                    }
                }
            }
        }
    }

    ll ans = 0;
    rep(j, 110) {
        rep(k, 310) {
            if (dp[j][k] != -1 && (ll)j * w1 + k <= W) {
                chmax(ans, dp[j][k]);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
from itertools import accumulate
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float('inf')
from functools import reduce

n,m = map(int,input().split())
edge=[]
for i in range(m):
    a, b, c = map(int, input().split())
    edge.append([a,b,-c])

dist = [inf]*n
dist[0] = 0
for i in range(1,n):
    for j in range(m):
        if dist[edge[j][1]-1] > dist[edge[j][0]-1]+edge[j][2]:
            dist[edge[j][1]-1] = dist[edge[j][0]-1]+edge[j][2]

ans = dist[n-1]

for j in range(m):
    if dist[edge[j][1]-1] > dist[edge[j][0]-1]+edge[j][2]:
        dist[edge[j][1]-1] = dist[edge[j][0]-1]+edge[j][2]
if dist[n-1]<ans:
    print("inf")
else:
    print(-ans)

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

bool custom(pair<long long int, long long int> p, pair<long long int, long long int> q) {
    return (p.first < q.first);
}

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

  vector<pair<long long int, long long int>> drink(n);

  for(int i=0;i<n;i++) {
    cin >> drink[i].first >> drink[i].second;
  }

  sort(drink.begin(), drink.end(), custom);

  int bottle = 0;
  long long int answer = 0;
  for(int i=0;i<n;i++) {
    if(bottle+drink[i].second>m) {
      answer += drink[i].first * (m - bottle);
      break;
    } else {
      bottle += drink[i].second;
      answer += drink[i].first * drink[i].second;
    }
  }

  cout << answer << endl;
}

Measured memory_bytes: 1792
/*---------------------*/
/*    books            */
/*    aoj0561          */
/*    dynamic program  */
/*---------------------*/

#include<bits/stdc++.h>
using namespace std;

int n,k;
vector<int> book[10];
int dp[10][2001];

int solve(int genre,int cnt);
int sum(int genre,int getnum);

int main(){
  memset(dp,-1,sizeof(dp));
  cin >> n >> k;
  for (int i = 0; i < n; i++){
    int a,b;
    cin >> a >> b;
    book[b-1].push_back(a);
  }
  for(int i = 0; i < 10; i++){
    sort(book[i].begin() , book[i].end() , greater<int>());
  }
  cout << solve(0,0) <<endl;
}

int solve(int genre,int cnt){
  if(genre == 10)return 0;
  if(dp[genre][cnt] != -1)return dp[genre][cnt];
  int rec = 0;
  for(int i = 0; i <= book[genre].size(); i++){
    if(cnt + i > k)break;
    rec = max(rec,solve(genre + 1,cnt + i) + sum(genre,i));
  }
  return dp[genre][cnt] = rec;
}

int sum(int genre,int getnum){
  int sum = 0;
  if(getnum == 0)return 0;
  for(int i = 0;i < getnum;i++){
    sum += book[genre][i];
  }
  return sum + (getnum - 1) * getnum;
}

Measured memory_bytes: 1316
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll X; cin >> X;
    res = 1;
    for(ll b = 2;b*b<=X;b++){
        ll t = b*b;
        while(t*b <= X) t*=b;
        res = max(res,t);
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string s;
  cin >> s;
  if(s.back() != 's'){
    cout << s+'s' << endl;
  }else{
    cout << s+"es" << endl;
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  int l, r, sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 3532
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]


    N = II()
    A = LMIIS()
    B = LMIIS()
    C = LMIIS()
    sums = 0
    pre = -9999
    for a in A:
        a = a-1
        sums += B[a]
        if a - pre == 1:
            sums += C[pre]
        pre = a
    print(sums)

        



if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define Mx 2000001
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);

typedef long long  L;
typedef pair<L, L> pii;
L in,a,a1,a2,a3,b,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,q,q1,q2,q3,q4,r,s,t,
u,v,x,y,z,sum,mx,mn,flg,flg1,flg2,id1,id2,id3,id4,lim,tm1,st,en;

void solve(){
    if(n%2)printf("%lld\n",n/2+1);
    else printf("%lld\n",n/2);
}
int main()
{
    scanf("%lld",&n);
    solve();
    return 0;
}
/// lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 256
#include<stdio.h>

#define mod 1000000007

int main(){
	int n,m,i;
	long long ans=0,tmp=1;
	scanf("%d%d",&n,&m);
	if(n==m||n==m+1||n+1==m){
		if(n==m){
			for(i=1;i<=n;i++)tmp=(tmp*i)%mod;
			ans=(tmp*tmp*2)%mod;
		}else
		if(n==m+1){
			for(i=1;i<=m;i++)tmp=(tmp*i)%mod;
			ans=(tmp*((tmp*n)%mod))%mod;
		}else
		if(m==n+1){
			for(i=1;i<=n;i++)tmp=(tmp*i)%mod;
			ans=(tmp*((tmp*m)%mod))%mod;
		}
		printf("%lld\n",ans%mod);
	}else puts("0");
	return 0;
}
	

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int i, j, limit=1000000, count;
	int prime[1000001];
	
	for (i = 0; i < limit; i++) {
		prime[i] = i;
	}
		
	for (i = 2; i*i < limit; i++) {
	    if(prime[i]) {
	    	for (j = i * 2; j < limit; j+=i) {
	    			prime[j] = 0;
	    	}
	    }
	}
	
	int n;
	while(scanf("%d", &n) != EOF) {
	    count=0;
    	for (i = 2; i <= n; i++) {
    	    if (prime[i] != 0) {
		    	count++;
		    }
	    }
	    printf("%d\n", count);
	}
	return 0;
}


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#pragma region
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#pragma endregion

typedef tuple<int,int,int> dt;
int n, m;
vector<int> a, sm;
int cnt_le(int x)
{
    int ret = 0;
    forn(lh, n)
    {
        int lv = a[lh];
        int c = a.end() - lower_bound(a.begin(), a.end(), x - lv);
        ret += c;
    }
    return ret;
}
int tot_le(int x)
{
    int ret = 0;
    forn(lh, n)
    {
        int lv = a[lh];
        int c = a.end() - lower_bound(a.begin(), a.end(), x-lv);
        ret += sm[n-1];
        if (n-1-c>=0) ret -= sm[n-1-c];
        ret += lv * c;
    }
    return ret;
}

void solve()
{
    cin>>n>>m;
    a.resize(n);
    forn(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    debug(a);
    sm = a;
    forn(i, n-1) sm[i+1] += sm[i];
    //
    int lf = 0, rg = 2*1e5 + 7;
    int fd = 0;
    while (lf <= rg)
    {
        int mid = (lf + rg) / 2;
        if (cnt_le(mid) >= m) fd = mid, lf = mid + 1;
        else rg = mid - 1;
    }
    int cnt = cnt_le(fd);
    int tot = tot_le(fd);
    //
    int fld = cnt - m;

    //
    int ans = tot - fld * fd;
    cout << ans << '\n';
}


signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << fixed << setprecision(22);
    // cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;typedef vector<int> ivec;typedef vector<string> svec;

int N,ans;
double T,A,tmp=1e9;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> T >>A;
	vector<double> H(N,0),t(N,0);
	for(int i=0;i<N;i++){
		cin >> H[i];
		t[i]=T-H[i]*0.006;
		if(abs(t[i]-A)<tmp){
			ans = i;
			tmp = abs(t[i]-A);
		}
	}
	cout << ans+1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define ll long long
#define coYes cout << "Yes" << endl;
#define coYES cout << "YES" << endl;
#define coyes cout << "yes" << endl;
#define coNo cout << "No" << endl;
#define coNO cout << "NO" << endl;
#define cono cout << "no" << endl;
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
int gcd(int a, int b){
    if(a%b == 0){
        return b;
    }else{
    return gcd(b, a%b);
    }
}

int main(){
    ll n;
    cin >> n;
    for(int i=n;i>0;i--){
        int temp=i*1.08;
        //cout << temp << endl;
        if(n==temp){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 3636
A,B= map(int,input().split(" "))
count = 0
x = int(A/10**4)
y = int(A/10**3) - x*10
z = int(A/10**2) - x*10**2 - y*10
N = A
while N <= B:
    while y < 10:
        while z < 10:
                    N = x*(10**4)+y*(10**3)+z*(10**2)+y*(10**1)+x
                    if N > B:
                        break
                    if N == B:
                        count = count + 1
                        break
                    if N < A:
                        count = count -1
                    count = count + 1
                    z = z + 1
        z = 0
        y = y + 1
        if N >= B:
            break
    x = x + 1
    y = 0
print(count)

Measured memory_bytes: 3316
#include <stdio.h>

int main(void)
{
    int n;
    int m[1000] = {0};
    int x;
    int tmp = 0;
    int num;

    scanf("%d %d", &n, &x);
    int i;
    for (i = 0;i < n;i++) {
        scanf("%d", &m[i]);
        tmp += m[i];
    }
    int min = m[0];
    for (i = 1;i < n;i++) {
        if (min > m[i]) {
            min = m[i];
        }
    }

    num = (x - tmp) / min + n;
    printf("%d\n", num);

    return 0;
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  string s;

  cin >> s;

  s[3] = '8';

  cout << s << '\n';

  return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int k;
string s;

int memo[100][2][4];

int dfs(int i,bool smaller,int c){
	if(i==s.length()) return c==k?1:0;
	if(c>k) return 0;

	if(memo[i][smaller][c]!=-1) return memo[i][smaller][c];

	int res=0,d_max=(smaller?9:s[i]-'0');
	rep(d,d_max+1){
		res+=dfs(i+1,smaller||d<d_max,c+(d==0?0:1));
	}
	return memo[i][smaller][c]=res;
}

int main(){
	memset(memo,-1,sizeof memo);

	cin>>s>>k;
	cout<<dfs(0,false,0)<<'\n';

	return 0;
}


Measured memory_bytes: 256
using System;

namespace AOJ0063
{
    class Program
    {
        public void Proc()
        {
            int count = 0;
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;

                char[] arr = input.ToCharArray();
                char[] rev = new char[arr.Length];
                for (int i = 0; i < arr.Length; i++)
                {
                    rev[i] = arr[arr.Length - 1 - i];
                }
                string reverse = new string(rev);

                if (input.Equals(reverse)) count++;
            }
            Console.WriteLine(count);
        }
        static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }
    }
}

Measured memory_bytes: 8816
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans;
    cin>>n;
    if(n%1000==0)
        cout<<0<<endl;
    else
    {
      ans=n%1000;
      ans=1000-ans;
      cout<<ans<<endl;
    }
}


Measured memory_bytes: 3632
n=int(input())
#x,n=map(int,input().split())
#pl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

res=''

# 文字数を求める
total=0
i=1
while True:
    if total+26**i>=n:
        break
    else:
        total+=26**i
        i+=1

# 文字数iがわかったので，そのなかでn-i番目
k=n-total-1
for j in range(i):
    res+=chr(ord('a')+k%26)
    k=k//26

print(res[::-1])


Measured memory_bytes: 9096
#include <stdio.h>

int main()
{
    int a,b,c;
    int buf;
    int count;
    
    count = 0;
    scanf("%d%d%d",&a,&b,&c);
    // printf("%d %d %d\n",a,b,c);
    while (a <= b)
    {
        buf = c % a;
        if (buf == 0)
            count++;
        a++;
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2148
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N,M;
string S;

//解法
void solve() {

	if (S[5] == '0' && S[6] <= '4') {
		cout << "Heisei";
	}
	else {
		cout << "TBD";
	}

	return;
}

int main() {

	//入力
	cin >>S;

	solve();
	cout << endl;
	return 0;
}

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

using namespace std; 
 
#define int long long
#define M 1000000007
 
signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int val=1;
	int cnt=0;
	int ans[n+1]={0};
	for(int i=n-1;i>=0;i--){
		if(a[i]==val){
			cnt++;
			ans[val]=1;
			while(ans[val]==1){
				val++;
			}
		}
		ans[a[i]]=1;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 6740
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main()
{
  float n;
  cin >> n;
  float ans = 2 * n * 3.1415926535;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 3260
#include <iostream>
#include <cmath>
#include <string>
#include <utility>
#include <queue>
using namespace std;
typedef long long int ll;

int main() {
  int N, K;
  ll ans = 0;
  priority_queue<int> H;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    H.push(x);
  }
  for (int i = 0; i < K; i++) H.pop();
  for (int i = 0; i < N - K; i++) {
    ans += H.top();
    H.pop();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

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

  int n = s.size();

  // xabxbax

  string t;
  for (char c : s) if (c != 'x') t += c;

  vector<int> cont;
  int i = 0;
  s = "$" + s + "$";
  n += 2;
  while (i < n - 1) {
    int j = i;
    i++;
    while (i < n && s[i] == 'x') i++;
    cont.push_back(i - j - 1);
  }

  for (int i = 0; i < t.size(); i++) {
    if (t[i] != t[t.size() - 1 - i]) {
      cout << -1 << endl;
      return 0;
    }
  }

  int ans = 0;
  for (int i = 0; i * 2 + 1 < cont.size(); i++) {
    ans += abs(cont[i] - cont[cont.size() - 1 - i]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1148
//Author:- Yatin Patel
//Mail:- yatinpatel.gt@gmail.com

#include <bits/stdc++.h>
#define FILEIN ifstream fin;fin.open("input.txt");
#define FILEOUT ofstream fout;fout.open("output.txt");

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

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

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second

#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> >
#define maxQueue priority_queue<ll,vector<ll>,less<ll> > 

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>b;i--)
#define FILL(a,b) memset((a),(b),sizeof((a)))

#define MOD 1000000007
#define INF LONG_MAX
#define MINF LONG_MIN

ll power(ll x, unsigned ll y){
    if (y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);
}

//#define fin cin
//#define fout cout

int main(){

    FAST;
    ll n,a,b;
    cin>>n>>a>>b;
    ll cnt1=0,cnt2=0,cnt3=0;
    for(ll i=0;i<n;i++){
        ll tmp;
        cin>>tmp;
        if(tmp<=a){
            cnt1++;
        }
        else if(tmp>a && tmp<=b){
            cnt2++;
        }else{
            cnt3++;
        }
    }
    cout<<min(min(cnt1,cnt2),cnt3);
    return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    string a;
    cin >> a;
    int ans = 0;
    for (int i = 0; i < a.size(); i++) {
        ans += (a.at(i) - '0');
    }
    if (ans == 1)cout << 10 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();


		if(n%2==1)
		{
			System.out.println((n/2+1)/(double)n);
		}
		else
			System.out.println(.5);
	}
}

Measured memory_bytes: 23764
#include <algorithm>
#include <bitset>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pp;       // int aa = pp.first;
typedef tuple<int, int, int> tp; // int aa = get<0>(tp);

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

int all[100100];

class BIT {
public:
  vector<int> bit;
  int M;

  BIT(int M) : bit(vector<int>(M + 1, 0)), M(M) {}

  int get(int i) const {
    if (!i)
      return 0;
    return bit[i] + get(i - (i & -i));
  }

  void add(int i, int x) {
    if (i > M)
      return;
    bit[i] += x;
    add(i + (i & -i), x);
  }
};

void solve(long long N, long long M, vector<long long> &l,
           vector<long long> &r) {
  BIT bit(100010);

  vector<tp> vtp;
  REP(i, N) { vtp.push_back(tp(r[i] - l[i] + 1, l[i], r[i])); }
  sort(ALL(vtp));

  int pc = 0;
  FOR(m, 1, M + 1) {
    ll ans = 0;

    while (pc < N && get<0>(vtp[pc]) < m) {
      bit.add(get<1>(vtp[pc]), 1);
      bit.add(get<2>(vtp[pc]) + 1, -1);
      pc++;
    }

    ans += N - pc;

    for (int v = m; v <= M; v += m) {
      ans += bit.get(v);
    }

    cout << ans << endl;
  }
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  long long M;
  cin >> N;
  vector<long long> r(N - 1 + 1);
  vector<long long> l(N - 1 + 1);
  cin >> M;
  for (int i = 0; i <= N - 1; i++) {
    cin >> l[i];
    cin >> r[i];
  }
  solve(N, M, l, r);
  return 0;
}


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

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

    int max_length = 0, sum = 0;
    for (int i = 0; i < N; i++) {
        int l;
        cin >> l;
        sum += l;
        max_length = max(max_length, l);
    }

    if (max_length < sum - max_length)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256