akhauriyash/Code-Regression huggingface dataset:
N,C,K=map(int,input().split())
arrive=[]
c=0
for i in range(N):
    temp=int(input())
    arrive.append(temp)

arrive.sort()
sw=False
ans=0

for j in range(N):
    if sw==False:
        lim=arrive[j]+K
        c+=1
        sw=True
    else:
        c+=1
    if j<N-1:
        if c==C or lim<arrive[j+1]:
            ans+=1
            c=0
            sw=False
    else:
        ans+=1
print(ans)


Measured memory_bytes: 13236
#include<bits/stdc++.h>
#define FOR(x, z, y) for(int x = (z); y; x++)
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; FOR(cnt, 0, getline(stream,res,sp_word))
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
const int MOD = 1000000007; 
typedef long long ll;
using namespace std;

 
int main() {
  int A,B;
  scanf("%d%d",&A,&B);

  if(A == 1) A = 14;
  if(B == 1) B = 14;

  if(A > B) puts("Alice");
  else if(A < B) puts("Bob");
  else puts("Draw");

  return 0;
}

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

int main(void){

    string S;
    cin >> S;
    
    map<char,int> mp;
    
    for(int i = 0; i < S.size();i++)mp[S[i]]++;
    
    string ans = "No";
    if(mp['A']>0 && mp['B']>0)ans = "Yes";

    cout << ans <<endl;
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n,k;
vll x;
lli ans = LONG_MAX;

int main(){
  cin >> n >> k;
  x = vll(n);
  for(lli i = 0;i < n;i++) cin >> x[i];
  for(lli i = 0;i < n-(k-1);i++){
    lli l = x[i];
    lli r = x[i+k-1];
    if(l < 0 && r < 0){
      ans = min(ans, -l);
    }else if(l < 0 && r >= 0){
      ans = min(ans, -l+r+min(-l,r));
    }else if(l >= 0 && r >= 0){
      ans = min(ans, r);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int A, B;
  cin >> A >> B;
  cout << max(max(A + B, A - B), A * B) << endl;
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n;
int a[N];
ll add[N];
ll sum;

ll solve(ll x) {
    ll ans = 0;
    ll sum = x;
    for (int i = 1; i < n; ++i) {
        ll nsum = sum + a[i];
        if (sum < 0) {
            if (nsum <= 0) { // to 1
                ans += 1 - nsum;
                nsum = 1;
            }
        } else {
            if (nsum >= 0) { // to -1
                ans += nsum + 1;
                nsum = -1;
            }
        }
        sum = nsum;
    }
    return ans;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    if (a[0] == 0) {
        cout << min(solve(1), solve(-1)) + 1 << endl;
    } else {
        ll ans1 = solve(a[0]);
        ll ans2;
        if (a[0] > 0) {
            ans2 = solve(-1) + a[0] + 1;
        } else {
            ans2 = solve(1) + 1 - a[0];
        }
        cout << min(ans1, ans2) << endl;
    }
    return 0;
}


Measured memory_bytes: 4036
// ini template jangan diedit
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int M,N,Hasil;
	cin >> M >> N;
	Hasil = M * N;
	if (M > 9 || N > 9)
	{
		cout << "-1";
	}
	else
	cout << Hasil;
	

// Type Your Body of Code Here
return 0;
}


Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=5005;
ll f[2][N][2];int l[N],r[N],id[N],n,t,m;
inline bool cmp(const int &x,const int &y){return l[x]+r[x]>l[y]+r[y];}
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d%d",&l[i],&r[i]);
	n+=(n&1^1),m=(n-1)>>1;fp(i,1,n)id[i]=i;
	sort(id+1,id+1+n,cmp);
	memset(f,0x3f,sizeof(f));
	f[0][0][0]=0,t=0;
	for(R int i=0;i<=m;++i,t^=1){
		memset(f[t^1],0x3f,sizeof(f[t^1]));
		fp(j,0,m)fp(k,0,1){
			R int ip=id[i+j+k+1],len=l[ip]+r[ip];
			if(i<m)cmin(f[t^1][j][k],f[t][j][k]+r[ip]+1ll*len*i);
			if(j<m)cmin(f[t][j+1][k],f[t][j][k]+l[ip]+1ll*len*j);
			if(k<1)cmin(f[t][j][k+1],f[t][j][k]+1ll*m*len);
		}
	}
	printf("%lld\n",f[t^1][m][1]);
	return 0;
}

Measured memory_bytes: 640
#
import sys
import math
import numpy as np
import itertools


n = int(input())

# n行の複数列ある数値を二次元配列へ。x[n][?]
d = [[int(i) for i in input().split()] for i in range(n)] 

r=0

for i in range(n):
    if d[i][0]==d[i][1]:
        r += 1
    else:
        r=0
    if r==3:
        print("Yes")
        exit()
print("No")




Measured memory_bytes: 27152
n = int(input())
h = list(map(int, input().split()))
cur = 0
ans = 0
for i in range(1, n):
    if h[i - 1] < h[i]:
        ans = max(ans, cur)
        cur = 0
    else:
        cur += 1
ans = max(ans, cur)
print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <cstring>
#include <climits>
#include <set>
#include <map>
#include <algorithm>  
#include <cmath>
#include <iomanip>
#define ll long long
using namespace std;
ll n;
ll mod=pow(10,9)+7;
bool visit[100005];
vector<ll>* tree=new vector<ll>[100005];
pair<ll,ll> calc(ll node,ll par)
{
    visit[node]=true;
    ll b=1;ll w=1;
    for(ll i=0;i<tree[node].size();++i)
    {
        if(visit[tree[node][i]]==false)
        {
            pair<ll,ll> ans=calc(tree[node][i],node);
            w=((w%mod)*((ans.first+ans.second)%mod))%mod;
            b=((b%mod)*((ans.first)%mod))%mod;
        }
    }
    return make_pair(w,b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    memset(visit,false,sizeof(visit));
    //memset(dp,-1,sizeof(dp));
    for(ll i=1;i<=n-1;++i)
    {
        ll a,b;
        cin>>a>>b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    pair<ll,ll> okok=calc(1,-1);
    cout<<(okok.first+okok.second)%mod<<endl;
}






































Measured memory_bytes: 14712
#include<bits/stdc++.h>
using namespace std;
int n,m=INT_MAX,x=INT_MIN;
int A[100];
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
        m = min(m, A[i]);
        x = max(x, A[i]);
    }
    long long ans = INT_MAX;
    for (int i = m; i < x+1; i++)
    {
        long long k = 0;
        for (int j = 0; j < n; j++)
        {
            k += (A[j] - i) * (A[j] - i);
        }
        ans = min(ans, k);
        //cout << ans << " ";
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
static const int WHITE = 0;
static const int GRAY = 1;
vector<int>V[2001];
queue<int>Q;
int color[2001];
int d[2001];
int D[2001]; //距離を記録
int n;
int x, y;

//でバグ用
void print(){
  for (int i=0;i<=n;i++){
    cout << i << " ";
    for (int j=0;j<V[i].size();j++){
      cout << V[i][j] << " ";
    }
    cout << endl;
  }
}

void deep_seek(int u){
  color[u] = GRAY;
  for (int i=0;i<V[u].size();i++){
    int this_node = V[u][i];
    if (color[this_node]==WHITE){
        Q.push(this_node);
        d[this_node] = d[u] + 1;
        int dis = d[this_node];
        color[this_node] = GRAY;
        //cout << u << " " << this_node << " " << dis << endl;
        D[dis] += 1;
    }
  }
}

void init(){ //u移行を初期化
  for (int i=0;i<=n;i++){
    d[i] = 0;
    color[i] = 0;
  }
}

void Seek(int start){
  Q.push(start);
  while (!Q.empty()){
    int pick_one = Q.front();
    // cout << pick_one << endl;
    Q.pop();
    deep_seek(pick_one);
  }
}

int main(){
  cin >> n;
  cin >> x >> y;
  for (int i=1;i<n;i++){
    V[i].push_back(i+1);
    V[i+1].push_back(i);
  }
  V[x].push_back(y);
  V[y].push_back(x);
  //print();
  for (int i=1;i<=n;i++){
    init();
    Seek(i);
  }

  //D[1]--;

  for (int i=1;i<n;i++){
    int s = D[i] / 2;
    cout << s << endl;
  }
  return 0;


}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	vector<int> v(12); rep(i, 0, 12) { cin >> v[i]; }
	sort(v.begin(), v.end());
	if (v[0] == v[1] && v[1] == v[2] && v[2] == v[3] &&
		v[4] == v[5] && v[5] == v[6] && v[6] == v[7] &&
		v[8] == v[9] && v[9] == v[10] && v[10] == v[11])cout << "yes" << endl;
	else cout << "no" << endl;
	return 0;
}

Measured memory_bytes: 3144
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int N,K;
	cin >> N >> K;
	string S;
	cin >> S;

	int ans=0;
	for(int i=1; i<N; i++){
		if(S[i-1]==S[i]){
			ans++;
		}
	}

	ans=ans+K*2;

	if(ans<N){
		cout << ans << endl;
	}else{
		cout << N-1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

set<ll> s;
ll min_range(ll num){
    vec memo(num - K + 1, 0);
    auto ite = s.begin();
    auto rite = s.rbegin();
    rep(i,num - K + 1){
        memo[i] -= *ite;
        memo[num - K - i] += *rite;
        ++ite; ++rite;
    }
    ll res = 4e+18;
    rep(i,num - K + 1) res = min(res, memo[i]);
    return res;
}

int main() {
    cin>>N>>K;
    vp xy(N);
    rep(i,N) cin>>xy[i].fi>>xy[i].se;
    sort(xy.begin(), xy.end());
    ll ans = 4e+18;
    reps(num,K,N+1){ //x軸方向の点の数
        rep(i,num) s.insert(xy[i].se);
        ans = min(ans, min_range(num) * (xy[num - 1].fi - xy[0].fi));
        reps(i,1,N - num + 1){ //左端のindex
            s.erase(xy[i-1].se);
            s.insert(xy[num + i - 1].se);
            ans = min(ans, min_range(num) * (xy[num + i - 1].fi - xy[i].fi));
        }
        s.clear();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int A = in.nextInt(), B = in.nextInt(), X = in.nextInt();

			if (A + B >= X && A <= X) {
				out.println("YES");
			} else {
				out.println("NO");
			}

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

double const pi = acos(-1);

int main() {
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double x1 = a*cos(2*pi*(h*60+m)/720),x2 = b*cos(2*pi*m/60),y1 = a*sin(2*pi*(h*60+m)/720),y2 = b*sin(2*pi*m/60);
    cout << fixed << setprecision(12) << sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) << endl;
}

Measured memory_bytes: 4160
#include <stdio.h>

int main() {

    int w, i, k = 0;
    char res[20];
    scanf("%d", &w);

    while ( w > 0 ) {
	switch ( w%3 ) {
	case 0:
	    res[k++] = '0';
	    w /= 3;
	    break;
	case 1:
	    res[k++] = '+';
	    w /= 3;
	    break;
	case 2:
	    res[k++] = '-';
	    w = w/3 + 1;
	    break;
	}
    }
    for ( i=k-1; i>=0; --i ) printf("%c", res[i]);
    printf("\n");
    return 0;
}



Measured memory_bytes: 2108
N, K = map(int, input().split())
V = list(map(int, input().split()))

ma = 0
for i in range(K):
    P = K - i
    for p in range(P + 1):
        q1 = []
        q2 = []
        s = 0
        for j in range(min(N, p)):
            if V[j] >= 0:
                s += V[j]
            else:
                q1.append(V[j])
        if len(q1) == p:
            q1 = []
        for j in range(N - 1, max(p - 1, N - (P - p) - 1), -1):
            if V[j] >= 0:
                s += V[j]
            else:
                q2.append(V[j])
        if len(q2) == P - p:
            q2 = []

        q = sorted(q1 + q2)
        if len(q) < i:
            t = 0
        else:
            t = sum(q[i:])
        ma = max(s + t, ma)

print(ma)

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll ans=0;
	string s;
	cin >> s;
	ll n=SIZE(s)-1;
	for(int bit=0;bit<(1<<n);bit++){
        vll v;
		ll tmp=s[0]-'0';
        rep(i,n){
            if(bit&(1<<i)) v.push_back(1);
			else v.push_back(0);
        }
		rep(i,n){
			if(v[i]==0){
				tmp=tmp*10+(s[i+1]-'0');
			}
			else{
				ans+=tmp;
				tmp=s[i+1]-'0';
			}
		}
		ans+=tmp;
    }
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(void) {
  int h, w;
  cin >> h >> w;
  string s[h];
  for(int i = 0; i < h; i++) {
    cin >> s[i];
  }

  for(int i = 0; i < w + 2; i++) {
    cout << '#';
  }
  cout << endl;

  for(int i = 0; i < h; i++) {
    cout << '#' << s[i] << '#' << endl;
  }

  for(int i = 0; i < w + 2; i++) {
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
c = 0
d = 0
for i in range(N-1,-1,-1):
    if A[i+1]<=B[i]:
        c = B[i]-A[i+1]
        d += A[i+1]
        if A[i]>c:
            A[i] -= c
            d += c
        else:
            d += A[i]
            A[i] = 0
            
    else:
        d += B[i]

print(d)

Measured memory_bytes: 18476
import math


def is_prime(n):
    if n == 2:
        return 1
    if n == 1 or n % 2 == 0:
        return 0

    for i in range(3, int(math.sqrt(n)) + 1, 2):
        if n % i == 0:
            return 0
    return 1


def main():
    num_el = int(input())
    nums = [int(input()) for i in range(num_el)]
    are_primes = [is_prime(num) for num in nums]
    print(sum(are_primes))


if __name__ == "__main__":
    main()



Measured memory_bytes: 6012
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N + 1);
  L[0] = 0;
  REP1(i, N) cin >> L[i];
  vector<int> D(N + 1);
  D[0] = 0;
  REP1(i, N + 1) D[i] = D[i - 1] + L[i - 1];
  int ans = 0;
  REP1(i, N + 1) if (D[i] <= X) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f;








void sol()
{   
    cin>>n>>k;
    in(a,n);
    sort(all(a));
    c=0;
    fo(i,n-k)c+=a[i];
    
    
    
    cout<< c <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

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

int main(){
    string a,b;
    cin>>a>>b;
    
    int len1=a.length();
    int len2=b.length();
    bool yes=true;
    if(len1!=len2 and len2-1==len1){
        
        for(int i=0;i<len1;i++){
            if(a[i]!=b[i]){
                //cout<<"Yes"<<endl;
                yes=false;
                break;
            }
        }
    }
    if(yes==false){
        cout<<"No"<<"\n";
    }
    if(yes==true){
        cout<<"Yes"<<"\n";
    }
}

Measured memory_bytes: 3632
#include <stdio.h>

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

int main(void)
{
	int q1, b, c1, c2, q2;
	int aChick, bChick;
	
	while (1){
		scanf("%d", &q1);
		
		if (!q1) break;
		
		scanf("%d %d %d %d", &b, &c1, &c2, &q2);
		
		aChick = min(b / c1, q2);
		b -= aChick * c1;
		bChick = max(0, b / c2);
		b -= bChick * c2;
		
		while (aChick + bChick < q1 && aChick){
			b += c1;
			b += bChick * c2;
			bChick = b / c2;
			b -= bChick * c2;
			aChick--;
		}
		
		if (aChick){
			printf("%d %d\n", aChick, bChick);
		}
		else {
			printf("NA\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 612
N, H = map(int, input().split())
B = []
a_max = 0
for i in range(N):
    a, b = map(int, input().split())
    a_max = max(a_max, a)
    B.append(b)

B = sorted([b for b in B if b > a_max], reverse = True)

cnt = 0
for b in B:
    H -= b
    cnt += 1
    if H <= 0:
        break
if H > 0:
    cnt += ((H-1) // a_max) + 1


print(cnt)



Measured memory_bytes: 8976
import java.util.Scanner;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt();
                        double[] A = new double[N], B = new double[N];
                        for (int i = 0; i < N; i++) {
                                A[i] = sc.nextDouble();
                        }
                        for (int i = 0; i < N; i++) {
                                B[i] = sc.nextDouble();
                        }
                        double[] ans = new double[4];
                        for (int i = 0; i < N; i++) {
                                double num = Math.abs(A[i] - B[i]);
                                ans[0] += num;
                                ans[1] += num * num;
                                ans[2] += num * num * num;
                                ans[3] = Math.max(ans[3], num);
                        }
                        ans[1] = Math.sqrt(ans[1]);
                        ans[2] = Math.cbrt(ans[2]);
                        System.out.println(ans[0]);
                        System.out.println(ans[1]);
                        System.out.println(ans[2]);
                        System.out.println(ans[3]);
                }
        }
}


Measured memory_bytes: 29036
#include <bits/stdc++.h>
#define LIM 1<<17
/// TONI BO$$ was here
/// #MLC

using namespace std;
char BUF[LIM];
int poz;

inline char getChar(){
    poz++;
    if(poz>=LIM){
    	fread(BUF,LIM,1,stdin);
    	poz=0;
    }
    return BUF[poz];
}

inline int getNr(){
    int r=0, semn=1;
    char ch=getChar();
    while(isdigit(ch)==0 && ch!='-') ch=getChar();
    if(ch=='-'){
        semn=-1;
        ch=getChar();
    }
    while(isdigit(ch)!=0){
        r=r*10+semn*(ch-'0');
        ch=getChar();
    }
    return r;
}
vector < pair <int,int> > prefecture[100001];
pair <int,int> rez[100001];
int main()
{
    int n,m,i,p,y,j;
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    scanf("%d%d",&n,&m);
    for(i=1; i<=m; i++)
    {
        scanf("%d%d",&p,&y);
        prefecture[p].push_back({y,i});
    }
    for(i=1; i<=n; i++)
        sort(prefecture[i].begin(),prefecture[i].end());
    for(i=1; i<=n; i++)
        for(j=0; j<prefecture[i].size(); j++)
            rez[prefecture[i][j].second]={i,j+1};
    for(i=1; i<=m; i++)
        printf("%06d%06d\n",rez[i].first,rez[i].second);

    return 0;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)
 
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
 
#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))
 
// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
 
// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;
 
int n;
 
ll dp[125][5*5*5*5];
bool ng[625];
int f(int a,int b,int c,int d){
  return a*125 + b*25 + c*5 + d;
}
// a:1, g:2, c:3, t:4
 
int main(){
  scanf("%d",&n);
  dp[0][0] = 1;
  REP(i,5)ng[f(i,1,2,3)] = true;
  REP(i,5)ng[f(1,i,2,3)] = true;
  REP(i,5)ng[f(1,2,i,3)] = true;
  REP(i,5)ng[f(i,2,1,3)] = true;
  REP(i,5)ng[f(i,1,3,2)] = true;
  REP(i,n)REP(st,625)if(dp[i][st]){
    FOR(x,1,5){
      int nxt = (st * 5 % 625) + x;
      if(ng[nxt])continue;
      (dp[i+1][nxt] += dp[i][st]) %= MOD;
    }
  }
  ll ans = 0;
  REP(i,625)ans += dp[n][i];
  ans %= MOD;
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 768
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int S1[30000], S2[30000];

int main(){
	int N;
	cin >> N;
	vector<long long int> A(N + 1, 0);
	for(int i = 1; i < N; i++){
		cin >> A[i];
	}
	for(int i = 1; i < 30000; i++){
		S1[i] = INF;
		S2[i] = INF;
	}
	for(int i = 1; i <= N; i++){
		for(int j = 0; j <= i; j++){
			long long int num = min(S1[j], S2[i - j]);
			S1[j] = min(S1[j], num + A[i]);
			S2[i - j] = min(S2[i - j], num + A[i]);
			if(i == N && j == N / 2){
				cout << num << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a%3==0||b%3==0||(a+b)%3==0)
    {
        printf("Possible");
    }
    else
    {
        printf("Impossible");
    }


    return 0;

}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n;
	cin >> n;
	vll a(n);
	rep(i,n) cin >> a[i];
	sort(all(a));
	ll ans=1;
	rep(i,n-1){
		if(a[i]*2>=a[i+1]) ans++;
		else ans=1;
		a[i+1]+=a[i];
	}
	cout << ans << endl;
	return 0;
}

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

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

  if (s == "SUN")
  {
    cout << 7 << endl;
  }
  else if (s == "MON")
  {
    cout << 6 << endl;
  }
  else if (s == "TUE")
  {
    cout << 5 << endl;
  }
  else if (s == "WED")
  {
    cout << 4 << endl;
  }
  else if (s == "THU")
  {
    cout << 3 << endl;
  }
  else if (s == "FRI")
  {
    cout << 2 << endl;
  }
  else
  {
    cout << 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <tuple>

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REPEAT(i) FOR(counter1234,0,i)
#define iter(el, arr) for(auto& el : arr)
#define ALL(a) a.begin(), a.end()

#define ld long double
#define ll long long
#define pii pair<int, int>
#define pll pair<ll,ll>
#define MP make_pair
#define MT make_tuple
#define SZ(a) ll((a).size())
#define X first
#define Y second

#define endl '\n'
#define PB push_back
#define has(i, m) (m.find(i) != m.end())

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define vch vector<char>
#define vvi vector<vi>
#define vvll vector<vll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vb vector<bool>
#define vvb vector<vb>
#define vs vector<string>
#define pdd pair<ld, ld>
#define vpll vector<pll>
#define vpdd vector<pdd>
#define pq priority_queue
#define mod 1000000007
using namespace std;

const ll INF = 1e18;
const ll MAXN = 100001;

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("Out.txt", "w", stdout);

	string s;
	cin >> s;
	ll n = s.size();
	ll ans = (n *  (n + 1LL)) / 2LL;

	map<char, ll> m;
	FOR(i, 0, n)
		m[s[i]]++;

	ans++;
	ans -= n;
	for (auto i : m)
		if (i.Y > 1)
			ans -= (i.Y * 1LL * (i.Y - 1)) / 2;

	cout << ans;
	return 0;
}

Measured memory_bytes: 720
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] k = new int[n];
		int[] p = new int[n];
		for(int i = 0 ; i<n ; i++){
			k[i] = scan.nextInt();
			p[i] = scan.nextInt();
		}
		for(int i = 0 ; i<n ; i++){
			if(k[i]%p[i] == 0){
				System.out.println(p[i]);
			}else{
				System.out.println(k[i]%p[i]);
			}
		}
	}
}

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

Measured memory_bytes: 2760
from sys import stdin

n = int(stdin.readline().rstrip())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
A,B = li[0][0],li[0][1]
for i in range(1,n):
    a,b = li[i][0],li[i][1]
    bai = max(-(-A//a),-(-B//b))
    A = bai*a
    B = bai*b
print(A+B)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N],b[N];
int main(){
	int A,B,m,ans,Amin=1e5,Bmin=1e5;
	cin>>A>>B>>m;
	for(int i=1;i<=A;++i)
		cin>>a[i],Amin=min(Amin,a[i]);
	for(int i=1;i<=B;++i)
		cin>>b[i],Bmin=min(Bmin,b[i]);
	int x,y,c;
	ans=Amin+Bmin;
	for(int i=1;i<=m;++i){
		cin>>x>>y>>c;
		ans=min(ans,a[x]+b[y]-c);
	}
	cout<<ans;
	return 0;
}

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

#define all(v) begin(v), end(v)
#define endl '\n';
#define int long long
#define pii pair<int, int>

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

    int n; cin >> n;
    vector<int> a(n);
    map<int, int> cnt;
    int summ = 0;
    for (int& x : a) {
        cin >> x;
        cnt[x]++;
        summ += x;
    }
    int q; cin >> q;
    while (q--) {
        int b, c; cin >> b >> c;
        summ -= cnt[b] * b;
        summ += cnt[b] * c;
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << summ << endl;
    }

}

Measured memory_bytes: 10028
N = int(input())
A = list(map(int, input().split()))
if max(A) < N:
  print(0)
  quit()

ans = 0
while max(A) >= N:
  times = [0] * N
  for i, a in enumerate(A):
    t = -(-(a - (N-1))//N)
    A[i] -= t*N
    times[i] = t
  total = sum(times)
  ans += total
  for i in range(N):
    A[i] += total - times[i]

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&a!=c&&b!=c)
		cout<<"Yes"<<endl;
	else if(b==c&&a!=b&&a!=c)
		cout<<"Yes"<<endl;
	else if(a==c&&a!=b&&b!=c)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
list=list(map(int,input().split()))
flg=0
for i in(list):
  if(i%2==0):
    if(i%3!=0 and i%5!=0):
      flg=1
      break
if(flg==0):
  print('APPROVED')
else:
  print('DENIED')


Measured memory_bytes: 38384
import sys

stdin = sys.stdin

ns = lambda: stdin.readline()
ni = lambda: int(ns())
na = lambda: list(map(int,stdin.readline().split()))

n = ni()
a = na()

l = []
m = []
for i, x in enumerate(a):
    if (i%2==1):
        l.append(x)
    else:
        m.append(x)

if (n%2==0):
    l.reverse()
    l.extend(m)
    ret = l
else:
    m.reverse()
    m.extend(l)
    ret = m

ans = ""
for i, x in enumerate(ret):
    ans += str(x)
    if (i!=n-1): ans += " "
    
print (ans)

Measured memory_bytes: 25644
var a,b,t:byte;
begin
	readln(a); readln(b);
    if(a>b) then begin t:=a; a:=b; b:=t; end;
    if (a=1) and (b=2) then write(3) else if (a=1) and (b=3) then write(2) else write(1)
end.

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
//long int l[100000], r[100000];

int main() {
	long int a, b, c, d, e, f, g, h, i;
	string s;
	

	cin >> a >>b ;

	c = 1;
	d = a;



	for (i = 1; i <= b; i++) {
		cin >> e >> f;
		if (e > c)
			c = e;
		if (f < d)
			d = f;
	}
	h = d - c+1;
	if (h < 0)
		h = 0;

	cout << h;



	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <numeric> 
#include <bits/stdc++.h>
typedef long long ll;
typedef std::pair<std::pair<int,int>,int>pi;
using namespace std;

int main() {
    int r;
    cin >> r;
    double pi = 3.14159265359;
    cout << 2*r*pi << endl;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vl v(n),c(n);
  rep(i,n){
    cin >> v[i];
  }
  rep(i,n){
    cin >> c[i];
  }
  vl plus(n);
  rep(i,n){
    plus[i]=v[i]-c[i];
  }
  ll sum=0;
  rep(i,n){
    if(plus[i]>0){
      sum +=plus[i];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>
using namespace std;
struct po{
  int x,y;
};
int mp[10][10];
string str[10];
queue <po> Q;

void bfs(int x,int y) {
  int dx[] = {0,0,1,-1};
  int dy[] = {-1,1,0,0};

  po t;
  t.x =x;
  t.y = y;
  Q.push(t);

  while(!Q.empty()){
    t = Q.front();
    Q.pop();

    str[t.y][t.x] = '0';
    
    for(int i=0;i<4;i++){
      int nx = t.x;
      int ny = t.y;
      for(int j=0;j<3;j++){
	nx += dx[i];
	ny += dy[i];
	if(nx < 0 || nx >= 8 || ny < 0 || ny >= 8) continue;
	po a;
	a.x = nx;
	a.y = ny;
	if(str[ny][nx] == '1') Q.push(a);
      }
    }
  }
}

int main() {

  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    
    for(int j=0;j<8;j++){
      cin >> str[j];
      if(str[j].size() == 0)j--;
    }

    int sx,sy;
    cin >> sx >>sy;
    bfs(sx-1,sy-1);
    
    cout << "Data "<<i+1<<":"<<endl;
    for(int j=0;j<8;j++)cout << str[j] << endl;

  }

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	string s,t;
	cin>>s>>t;
	ll a,b;
	cin>>a>>b;
	string k;
	cin>>k;
	map<string,ll> mp;
	mp[s] = a;
	mp[t] = b;
	mp[k] --;
	cout<<mp[s]<<" "<<mp[t]<<endl;
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
  int a;
  string s;
  cin >> a >> s;
  if(a>=3200){
    cout << s << endl;
  }
  else{
    cout << "red" << endl;
  }
}

Measured memory_bytes: 764
# print(max([len(v) for v in input().split('S')]))

d = {
    'RRR': 3,
    'RRS': 2,
    'RSR': 1,
    'RSS': 1,
    'SRR': 2,
    'SRS': 1,
    'SSR': 1,
    'SSS': 0,
}
print(d[input()])


Measured memory_bytes: 8932
#define _USE_MATH_DEFINES
#include <iostream> 
#include <iomanip> 
#include <cmath> 
using namespace std; 
int main(){
	int n;
	cin >> n;
	for(int i=1;i<=n;i++){
		int x = i/10;
		int y = i/100;
		int z = i/1000;
		int w = i/10000;
		int v = i/100000;
		if(i%3==0){
			cout << " " << i;
		}
		else if(i%10==3){
			cout << " " << i;
		}
		else if(x%10==3){
			cout << " " << i;
		}
		else if(y%10==3){
			cout << " " << i;
		}
		else if(z%10==3){
			cout << " " << i;
		}
		else if(w%10==3){
			cout << " " << i;
		}
		else if(v%10==3){
			cout << " " << i;
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3092
import java.util.*;
import java.util.stream.*;

public class Main {

  public static void main(String[] args) {
    
     Scanner sc = new Scanner(System.in);
     int N = sc.nextInt();
     Integer[] count = new Integer[N];
     for(int i = 0; i < N; i++) {
       int h = sc.nextInt();
       count[h - 1] = i;
     }
     System.out.println(
	 Arrays.stream(count)
       .map(v -> Integer.toString(v + 1))
       .collect(Collectors.joining(" "))
       );
  }
  
}
  

Measured memory_bytes: 62316
import sys
sys.setrecursionlimit(10**7)
mod = 10**9+7
fact = [1]*(2*10**5+1)
for n in range(1,2*10**5+1):
    fact[n] = n*fact[n-1]%mod
factinv = [1]*(2*10**5+1)
inv = [1]*(2*10**5+1)
for n in range(1,2*10**5+1):
    factinv[n] = pow(fact[n],mod-2,mod)
    inv[n] = pow(n,mod-2,mod)
def comb(n,k):
    return fact[n]*factinv[k]*factinv[n-k]%mod

N = int(input())
g = [[] for _ in range(N)]

for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

p = [-1]*N
p[0] = 0
q = [0]
while q:
    i = q.pop()
    for j in g[i]:
        if p[j]==-1:
            p[j] = i
            q.append(j)

c = [[] for _ in range(N)]
for i in range(1,N):
    c[p[i]].append(i)

cn = [-1]*N
def rec(n):
    if cn[n] != -1:
        return cn[n]
    res = 0
    for i in c[n]:
        res += rec(i)+1
    cn[n] = res
    return res

cn[0] = rec(0)    

ans = [0]*N

def dfs(n):
    res = fact[cn[n]]
    for c in g[n]:
        if c==p[n]:
            continue
        res *= factinv[cn[c]+1]*dfs(c)
        res %= mod
    return res

ans[0] = dfs(0)

q = [0]
while q:
    i = q.pop()
    for j in g[i]:
        if ans[j]==0:
            ans[j] = ans[i]*(cn[j]+1)*inv[N-1-cn[j]]%mod
            q.append(j)

for i in range(N):
    print(ans[i])


Measured memory_bytes: 177912
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int n; cin >> n;
  string s; cin >> s;
  int x = 0;
  int mx = 0;
  REP(i, n) {
    if (s[i] == 'I') x++;
    else x--;
    mx = max(x, mx);
  }
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,a[100];

int main(){
	while(cin>>n){
		if(!n)return 0;
		int ans=0;
		for(int i=0;i<n;i++)cin>>a[i];
		for(int i=0;i<n-1;i++){
			for(int j=0;j<n-1-i;j++){
				if(a[j]>a[j+1]){
					ans++;
					swap(a[j],a[j+1]);
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

//a^b % MOD
long long mod_pow(ll a,ll b){
	long long ret = 1;
	long long c = a;
	for(int i = 0;i <= 60;i++){
		if(b & (1LL << i))ret = (ret * c) % MOD;
		c = (c * c) % MOD;
	}
	return ret;
}

//ａをbで割る
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

#define MAX_K 555555
vector<long long> fact(MAX_K);
long long combination(long long n, long long r){
    if(n < r || n < 0 || r < 0)
        return 0;
	if(fact[0] != 1){
		fact[0] = 1;
		for(long long i = 1;i < MAX_K;i++)fact[i] = (fact[i-1] * i) % MOD;
	}
    long long ret = fact[n];
	long long tmp = (fact[r] * fact[n-r]) % MOD;
    return mod_div(ret,tmp);
}

ll permutation(ll n, ll r){
	if(n < r || n < 0 || r < 0)
			return 0;
	if(fact[0] != 1){
		fact[0] = 1;
		for(long long i = 1;i < MAX_K;i++)fact[i] = (fact[i-1] * i) % MOD;
	}
	long long ret = fact[n];
	long long tmp = fact[n-r];
	return mod_div(ret,tmp);
}

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

	ll n, m;cin >> n >> m;
	ll ans = permutation(m, n);

	for(ll i = 1;i <= n;i++){
		ll tmp = combination(n, i) * permutation(m - i, n - i) % MOD;
		if(i % 2){
			ans = (ans - tmp + MOD) % MOD;
		}
		else {
			ans = (ans + tmp) % MOD;
		}
	}

	cout << (ans * permutation(m, n) % MOD) << endl;

	return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using p = pair<int, int>;
using Graph = vector<vector<char>>;
#define rep(i,n)  for(int i = 0; i < n ; i++)
#define chmax(x,y) x = max(x,y);
int dx[4]{ -1,0,1,0 };
int dy[4]{ 0,1,0,-1 };
const ll INF = 1e18;
ll dp[200005][4]; // i番目までの個数でj個余分な×を選んだ際の和の最大値

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

Measured memory_bytes: 256
INF = 10 ** 20
d, n = map(int,input().split())
temp = [int(input()) for i in range(d)]
temp.insert(0,0)
alst = []
blst = []
clst = []
for i in range(n):
  a,b,c = map(int,input().split())
  alst.append(a)
  blst.append(b)
  clst.append(c)

dp = [[0] * n for i in range(d + 1)]

for i in range(n):
  if not (alst[i] <= temp[1] <= blst[i]):
    dp[1][i] = -INF

for i in range(2, d + 1):
  t = temp[i]
  for j in range(n):
    if alst[j] <= t <= blst[j]:
      dp[i][j] = max(dp[i - 1][x] + abs(clst[j] - clst[x]) for x in range(n))

print(max(dp[d]))


Measured memory_bytes: 6172