akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main()
{
    int n,k,q,a[100010]={0};
    cin>>n>>k>>q;
    for(int i=1;i<=q;i++)
    {
        int x;
        cin>>x;
        a[x]++;
    }
    for(int i=1;i<=n;i++)
        if(k-(q-a[i])<=0)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
const int maxn = 300050;
using namespace std;
typedef long long ll;
int a[maxn];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n-k;i++){
		if(a[i]<a[i+k])
		cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
} 

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF 1e15

#define MAX_N 1000

ll ord[1111];
ll dl[222][222],ds[222][222],dp[1111][222];

int main(){
	cin.sync_with_stdio(false);
  while(1){
    ll n,m,r;
    cin>>n>>m;
    if(n==0)break;
    rep(i,n)rep(j,n){
      dl[i][j]=i==j?0:INF;
      ds[i][j]=i==j?0:INF;
    }
    rep(i,m){
      ll x,y,t;
      char c;
      cin>>x>>y>>t>>c;
      x--; y--;
      if(c=='L'){
        dl[x][y]=dl[y][x]=t;
      }else{
        ds[x][y]=ds[y][x]=t;
      }
    }
    rep(k,n)rep(i,n)rep(j,n){
      minch(dl[i][j],dl[i][k]+dl[k][j]);
      minch(ds[i][j],ds[i][k]+ds[k][j]);
    }
    //rep(i,n)rep(j,n)dbg(ds[i][j]);
    cin>>r;
    rep(i,r){
      cin>>ord[i];
      ord[i]--;
    }
    rep(i,r+1)rep(j,n)dp[i][j]=INF;
    dp[0][ord[0]]=0;
    rep(i,r-1){
      int crt=ord[i],nxt=ord[i+1];
      rep(j,n){
        minch(dp[i+1][j],dp[i][j]+dl[crt][nxt]);
        rep(k,n){
          minch(dp[i+1][k],dp[i][j]+dl[crt][j]+ds[j][k]+dl[k][nxt]);
        }
        if(j==crt){
          rep(k,n){
            minch(dp[i+1][k],dp[i][j]+ds[crt][k]+dl[k][nxt]);
          }
        }
      }
    }
    ll res=INF;
    rep(i,n)minch(res,dp[r-1][i]);
    cout<<res<<endl;
  }
	return 0;
}

Measured memory_bytes: 5580
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <deque>

using namespace std;
using ll = long long;
const int BIG = 100000007;


int main() {
    ll n;
    cin >> n;
    ll cash = 1000;
    ll stocks = 0;
    vector<ll> a(n,0);
    for(ll i = 0;i < n;++i)cin >> a[i];
    for(ll i = 1;i < n;++i){
        if(a[i - 1] < a[i]){
            ll st = cash / a[i - 1];
            stocks += st;
            cash -= a[i - 1] * st;
           // cout << "long:" << st << "/cash=" << cash << endl;
        }
        else{
            cash += stocks * a[i - 1];
          //  cout << "short:" << stocks << "/cash=" << cash << endl;
            stocks = 0;
        }
    }
    cash += stocks * a[n - 1];
    cout << cash << endl;
}




Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);
    int n, d;
    cin >> n >> d;
    cout << CEIL(n, 2 * d + 1) << endl;

    return 0;
}



Measured memory_bytes: 256
class Unionfind():  # Unionfind
    def __init__(self, N):
        self.N = N
        self.parents = [-1] * N

    def find(self, x):  # グループの根
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # グループの併合
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def all_group_members(self):  # グループごとの辞書
        members_dict = {i: set([i]) for i, x in enumerate(self.parents) if x < 0}
        for i, x in enumerate(self.parents):
            if x >= 0:
                members_dict[self.find(x)].add(i)
        return members_dict


n, m = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(m)]

uf = Unionfind(n)
for x, y in xy:
    uf.union(x - 1, y - 1)

ans = 0
for lst in uf.all_group_members().values():
    ans += sum((p[num] - 1 in lst) for num in lst)
print(ans)


Measured memory_bytes: 130944
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int bcnt = 0, wcnt = 0, res = INF;
    rep(i, N) {
        if(S[i] == '.')
            wcnt++;
    }
    res = min(res, wcnt + bcnt);
    rep(i, N) {
        if(S[i] == '.') {
            wcnt--;
        } else {
            bcnt++;
        }
        res = min(res, wcnt + bcnt);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=2147483647;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Segment_Tree{
	private:
	int n;
	vi date;
	public:
	Segment_Tree(int n_){
		n=1;
		while(n<n_) n*=2;
		date=vi(2*n-1,inf);
	}
	void Update(int k,int x){
		k+=n-1;
		date[k]=x;
		while(k>0){
			k=(k-1)/2;
			date[k]=min(date[k*2+1],date[k*2+2]);
		}
	}
	int Query(int a,int b){
		a+=n-1;b+=n-1;
		int m=inf;
		while(a<b){
			if(a%2==0) m=min(m,date[a++]);
			if(b%2==0) m=min(m,date[--b]);
			a/=2;b/=2;
		}
		return m;
	}
	int Open(int k){
		return date[k+n-1];
	}
};

int n,q;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>q;
	Segment_Tree st(n);
	for(int i=0;i<q;i++){
		int t,A,B;
		cin>>t>>A>>B;
		if(t) cout<<st.Query(A,B+1)<<endl;
		else st.Update(A,B);
	}
}


Measured memory_bytes: 3808
#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){
  ll n, y;
  cin >> n >> y;
  REP(i, n+1) REP(j, n+1){
    if(i+j > n) continue;
    ll k = n-i-j;
    if(y == 10000*i+5000*j+1000*k){
      printf("%lld %lld %lld\n", i, j, k);
      return 0;
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}

Measured memory_bytes: 384
h,w=map(int,input().split())
a=[input() for i in range(h)]
b=[]
for i in range(h):
    ans=True
    for j in range(w):
        if a[i][j]=='#':
            ans=False
    if ans:
        b.append(i)
for i in reversed(b):
    a.pop(i)
h-=len(b)
for j in range(w-1,-1,-1):
    ans=True
    for i in range(h-1,-1,-1):
        if a[i][j]=="#":
            ans=False
    if ans:
        for i in range(h-1,-1,-1):
            a[i]=a[i][:j]+a[i][j+1:]
for i in range(h):
    print(a[i])

Measured memory_bytes: 3064
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
aa = 0
for i in range(1,N+1):
    aa += A[i-1]
    a.append(aa)
    
b = [0]
bb = 0
for i in range(1,M+1):
    bb += B[i-1]
    b.append(bb)
    
time0 = 1
ans = 0
j = M
for i in range(N+1):
    if a[i] > K:
        break
    else:
        while(j >= 0):
            if b[j] <= K - a[i]:
                ans = max(ans, i+j)
                break
            else:
                j -= 1
        
        
            
print(ans)


Measured memory_bytes: 47452
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cstring>
using namespace std;

map<int,int> dp[11][1024];
int res[11][550];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    dp[0][0][0] = 1;
    memset(res, 0, sizeof res);
    for (int i=0; i<10; ++i) {
        for (int j=0; j<1024; ++j) {
            for (auto it = dp[i][j].begin(); it != dp[i][j].end(); ++it) {
                for (int k=0; k<=9; ++k) {
                    if ((j & (1<<k)) == 0) {
                        dp[i+1][j|(1<<k)][it->first + (i+1)*k] += it->second;
                        res[i+1][it->first + (i+1)*k] += it->second;
                    }
                }
            }
        }
    }
    int n, s;
    while (cin >> n >> s) {
        cout << res[n][s] << endl;
    }
    return 0;
}

Measured memory_bytes: 3672
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#l = list(map(int, input().split()))

n, a, b = map(int, input().split())


if (a == 0):
    print (0)
    exit()

ans = n // (a+b) * a

amari = n % (a+b)
if (amari <= a):
    ans += amari
else:
    ans +=a

print (ans)



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


int main()
{int N, k, ans=0;
 cin >> N;
map<int, int> nums;
 for(int i=0; i<N; i++){
   cin >> k;
 	nums[k]++;}
 for(auto k : nums){
   if((k.second)%2==1){
     ans++;}}
 cout << ans << endl;
   
 
      
}

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

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int r, c;
    cin >> r >> c;
    vector<vector<int>> data(r, vector<int>(c));

    for(int i = 0; i < r; i++){
        for(int k = 0; k < c; k++){
            cin >> data[i][k];
        }
    }

    for(int i = 0; i < data.size(); i++) {
        int sum = 0;
        for(int k = 0; k < data[i].size(); k++) {
            sum += data[i][k];
        }
        data[i].push_back(sum);
    }

    // 列の合計を挿入
    vector<int> d;
    for(int i = 0; i < data[0].size(); i++) {
        int sum = 0;
        for(int k = 0; k < data.size(); k++) {
            sum += data[k][i];
        }
        d.push_back(sum);
    }
    data.push_back(d);

    for(int i = 0; i < data.size(); i++){
        for(int k = 0; k < data[i].size(); k++){
            if(k != 0) cout << " ";
            cout << data[i][k];
        }
        cout << endl;
    }
}



Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	  	int a,b[100007],c;
     	cin>>a;
     	c = 0;
     	for (int i = 0; i < a; ++i)
     	{
     		cin>>b[i];
     	}
     	for (int i = a - 2; i > 0; i--)
     	{
     		if(b[i] > b[i+1])
     			b[i]--;
     		if(b[i]>b[i+1])
     		{
     			c = 1;
     			break;
     		}
     	}
     	if(c == 0)
     		cout<<"Yes\n";
     	else
     		cout<<"No\n";
     	return 0;
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		int sum = 0;
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}
		sc.close();

		if (n == 1) {
			System.out.println(sum);
			return;
		}
		List<Integer> list = divList(sum);
		for (int i = list.size() - 1; i >= 0; i--) {
			int ans = list.get(i);
			long[] l = new long[n];
			for (int j = 0; j < a.length; j++) {
				l[j] = a[j] % ans;
			}
			Arrays.parallelSort(l);
			long[] r = new long[n];
			for (int j = 0; j < a.length; j++) {
				if (l[j] > 0) {
					r[j] = ans - l[j];
				}
			}
			for (int j = 1; j < a.length; j++) {
				l[j] += l[j - 1];
			}
			for (int j = a.length - 2; j >= 0; j--) {
				r[j] += r[j + 1];
			}
			for (int j = 0; j < a.length - 1; j++) {
				if (l[j] == r[j + 1] && l[j] <= k) {
					System.out.println(ans);
					return;
				}
			}
		}
	}

	static List<Integer> divList(int n) {
		List<Integer> list = new ArrayList<>();
		int end = (int) Math.sqrt(n) + 1;
		for (int i = 1; i <= end; i++) {
			if (n % i == 0) {
				list.add(i);
			}
		}
		end = list.size();
		for (int i = end - 1; i >= 0; i--) {
			list.add(n / list.get(i));
		}
		return list;
	}
}


Measured memory_bytes: 35760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  int n;
  cin >> n;
  int x = n*800;
  int y = int(n/15)*200;
  cout << x - y << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef unsigned long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()


int main(){

    ll N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;

}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for (int i=(a); i>=(b); --i)
#define REP(i,b) for (int i=0; i<(b); ++i)
#define endl '\n'
#define sz(x) (int) x.size()
#define mod %
#define fillchar(x,y,z) memset(x,z,y)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define sqr(x) ((x)*(x))
typedef long long int64;
typedef unsigned long long qword;
using namespace std;
const int maxn=2e5+5;
int64 f[maxn],t[maxn];
int h[maxn];
int b[maxn];
int n,m;
void Input()
{
    cin >> n;
    FOR(i,1,n) {
        cin >> h[i];
        b[i]=h[i];
    }
}
int64 Get(int x)
{
    int64 res=0;
    for (;x>0; x-=x&-x) res=max(res,t[x]);
    return res;
}
void update(int x, int64 val)
{
    for (;x<=m; x+=x&-x) t[x]=max(t[x],val);
}
void Solve()
{
    sort(b+1,b+1+n);
    m=unique(b+1,b+1+n)-b-1;
    int64 res=0;
    FOR(i,1,n) {
        int a;
        cin >> a;
        int pos=lower_bound(b+1,b+1+m,h[i])-b;
        int64 tmp=Get(pos-1)+a;
        res=max(res,tmp);
        update(pos,tmp);
    }
    cout << res;
}
int main()
{
    #ifdef meomeomeooooo
        freopen("input.txt","r",stdin);
        //freopen(".out","w",stdout);
    #endif // meomeomeooooo
    iostream::sync_with_stdio(false);
    cin.tie(0);
    Input();
    Solve();
    return 0;
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;

int main(){

	int left_length,right_length,max,tmp,left_start,left_end,right_start,right_end,k;
	char left[4001],right[4001];

	while(scanf("%s",left) != EOF){
		scanf("%s",right);

		for(left_length = 0;left[left_length] != '\0';left_length++);
		for(right_length = 0; right[right_length] != '\0';right_length++);

		max = 0;
		if(right_length > left_length){

			//left???????????¨right???????????????????????§
			for(right_end = 1;right_end <= left_length;right_end++){
				tmp = 0;
				for(left_start = left_length-right_end,k=0; k < right_end; k++){
					if(left[left_start+k] == right[k]){
						tmp++;
						max = (max >= tmp)?max:tmp;
					}else{
						tmp = 0;
					}
				}
			}

			//left???????????¨right???????????????????????§
			for(right_end = left_length;right_end < right_length;right_end++){
				tmp = 0;
				for(right_start = right_end-left_length,k=0;right_start + k < right_end; k++){
					if(left[k] == right[right_start+k]){
						tmp++;
						max = (max >= tmp)?max:tmp;
					}else{
						tmp = 0;
					}
				}
			}

			//left_end???0??????????????§
			for(left_end = left_length-1;left_end >= 1; left_end--){
				tmp = 0;
				for(right_start = right_length-left_end,k=0;k < left_end; k++){
					if(left[k] == right[right_start+k]){
						tmp++;
						max = (max >= tmp)?max:tmp;
					}else{
						tmp = 0;
					}
				}
			}

			printf("%d\n",max);

		}else{

			//right???????????¨left???????????????????????§
			for(left_end = 1;left_end <= right_length;left_end++){
				tmp = 0;
				for(right_start = right_length-left_end,k=0; k < left_end; k++){
					if(right[right_start+k] == left[k]){
						tmp++;
						max = (max >= tmp)?max:tmp;
					}else{
						tmp = 0;
					}
				}
			}

			//right???????????¨left???????????????????????§
			for(left_end = right_length;left_end < left_length;left_end++){
				tmp = 0;
				for(left_start = left_end-right_length,k=0;left_start + k < left_end; k++){
					if(right[k] == left[left_start+k]){
						tmp++;
						max = (max >= tmp)?max:tmp;
					}else{
						tmp = 0;
					}
				}
			}

			//right_end???0??????????????§
			for(right_end = right_length-1;right_end >= 1; right_end--){
				tmp = 0;
				for(left_start = left_length-right_end,k=0;left_start + k < left_length; k++){
					if(right[k] == left[left_start+k]){
						tmp++;
						max = (max >= tmp)?max:tmp;
					}else{
						tmp = 0;
					}
				}
			}

			printf("%d\n",max);
		}
	}

	return 0;
}

Measured memory_bytes: 2576
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=100010;
int n,m,a[maxn];
int calc(int l,int r,int x){
	return max(l,min(r,x));
}

int main(){

	
    int X;
    scanf("%d%d",&X,&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    int L,R=X;//
    int t=0,k=0,s=-1,x=0;
    int time,A;
    scanf("%d",&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d",&time,&A);
        while(k<n && a[k+1]<=time){
            int dif=s*(a[k+1]-t);
            L = calc(0,X,L+dif);
            R = calc(0,X,R+dif);
            s*=-1;
            x+=dif;
            t=a[k+1];
            k++;
        }
        int T=time-t;
        A=calc(L,R,A+x);
        A=calc(0,X,A+s*T);
        printf("%d\n",A);
    }
    return 0;
}

Measured memory_bytes: 1536
def resolve():
    '''
    code here
    '''
    N = int(input())
    hs = [int(item) for item in input().split()]

    cnt = 0
    flag = False
    while any(hs):
        # print(hs)
        for i in range(N):
            if hs[i] > 0:
                flag = True
                hs[i] -= 1
            else:
                if flag:
                    cnt += 1
                    flag = False
        else:
            if flag:
                cnt += 1
            flag = False

    print(cnt)



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <bitset>

using namespace std;
using ll = long long;

int main() {
    int h, n;
    cin >> h >> n;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        sum += a;
    }
    cout << ((sum >= h) ? "Yes" : "No") << "\n";
    return 0;
}


Measured memory_bytes: 256
s = input()
if(s[-1]=='2' or s[-1]=='4' or s[-1]=='5' or s[-1]=='7' or s[-1]=='9'):
    print("hon")
elif(s[-1]=='0' or s[-1]=='1' or s[-1]=='6' or s[-1]=='8'):
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9088
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  ll input(n, c);
  vector<ll> x(n), v(n);
  REP(i, n) cin >> x[i] >> v[i];
  vector<ll> maxvs(n);

  vector<ll> xc(x);
  vector<ll> vc(n, 0);
  partial_sum(v.begin(), v.end(), vc.begin());
  maxvs[0] = max(0ll, vc[0] - xc[0]);
  REP(i, n - 1) {
    maxvs[i + 1] = max(maxvs[i], vc[i + 1] - xc[i + 1]);
  }

  vector<ll> rmaxvs(n);
  vector<ll> rxc(n, 0);
  REP(i, n) rxc[n - 1 - i] = c - x[i];
  vector<ll> rvc(n, 0);
  partial_sum(v.rbegin(), v.rend(), rvc.begin());
  rmaxvs[0] = max(0ll, rvc[0] - rxc[0]);
  REP(i, n - 1) {
    rmaxvs[i + 1] = max(rmaxvs[i], rvc[i + 1] - rxc[i + 1]);
  }

  ll maxv = rmaxvs[n - 1];
  REP(i, n - 1) {
    maxv = max(maxv, (vc[i] - xc[i]*2) + rmaxvs[n - 2 - i]);
  }

  maxv = max(maxv, maxvs[n - 1]);
  REP(i, n - 1) {
    maxv = max(maxv, (rvc[i] - rxc[i]*2) + maxvs[n - 2 - i]);
  }
  print(maxv);
}

Measured memory_bytes: 9588
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(M)]

import sys
sys.setrecursionlimit(10**8)
class Scc:
    def __init__(self,n):
        self.n = n
        self.edges = []

    def add_edge(self,fr,to):
        assert 0 <= fr < self.n
        assert 0 <= to < self.n
        self.edges.append((fr, to))

    def scc(self):
        csr_start = [0] * (self.n + 1)
        csr_elist = [0] * len(self.edges)
        for fr,to in self.edges:
            csr_start[fr + 1] += 1
        for i in range(1,N+1):
            csr_start[i] += csr_start[i-1]
        counter = csr_start[:]
        for fr,to in self.edges:
            csr_elist[counter[fr]] = to
            counter[fr] += 1

        self.now_ord = self.group_num = 0
        self.visited = []
        self.low = [0] * self.n
        self.ord = [-1] * self.n
        self.ids = [0] * self.n
        def _dfs(v):
            self.low[v] = self.ord[v] = self.now_ord
            self.now_ord += 1
            self.visited.append(v)
            for i in range(csr_start[v], csr_start[v+1]):
                to = csr_elist[i]
                if self.ord[to] == -1:
                    _dfs(to)
                    self.low[v] = min(self.low[v], self.low[to])
                else:
                    self.low[v] = min(self.low[v], self.ord[to])
            if self.low[v] == self.ord[v]:
                while 1:
                    u = self.visited.pop()
                    self.ord[u] = self.n
                    self.ids[u] = self.group_num
                    if u==v: break
                self.group_num += 1
        for i in range(self.n):
            if self.ord[i] == -1: _dfs(i)
        for i in range(self.n):
            self.ids[i] = self.group_num - 1 - self.ids[i]

        groups = [[] for _ in range(self.group_num)]
        for i in range(self.n):
            groups[self.ids[i]].append(i)
        return groups

scc = Scc(N)
for a,b in AB:
    scc.add_edge(a,b)
ans = scc.scc()
print(len(ans))
for row in ans:
    print(*[len(row)] + row)

Measured memory_bytes: 260768
#include<bits/stdc++.h>
#include<climits>
typedef long long int ll;
#define MOD 1000000007
using namespace std;
ll fast_expo(ll num, ll b)
{
    if(b==0)
    {
        return 1;
    }
    else
    {
        if(b%2==1)
        {
            ll x=((fast_expo(num,b-1)%MOD)*num)%MOD;
            return x%MOD;
        }
        else if(b%2==0)
        {
            ll x=(fast_expo(num,b/2)%MOD);
            return (x*x)%MOD;
        }
    }
}
int main() 
{
    ll n;
    cin>>n; 
    ll x=fast_expo(10,n)%MOD;
    ll y=((fast_expo(9,n)%MOD)*2)%MOD;
    ll z=fast_expo(8,n)%MOD;
    ll res=(((x-y)%MOD)+MOD)%MOD;
    res=(((res+z)%MOD)+MOD)%MOD;
    cout<<res<<endl;    

} 

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define MOD (1e9+7)

using namespace std;

typedef pair<ll, int> P;

vector<int> g[123456];
bool done[123456],cnt[123456];
int where[123456];
queue<int> q;
priority_queue<P, vector<P>, greater<P> > pq;

int main(void){
    int n,m,i,x,y,v,j,num=0,sur;
    ll a[123456],ans=0ll;
    P s,t;
    bool flag = true;
    fill(done,done+123456,false);
    fill(cnt,cnt+123456,false);
    cin >> n >> m;
    for(i=0; i<n; i++){
        cin >> a[i];
    }
    for(i=0; i<m; i++){
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(i=0; i<n; i++){
        if(done[i]){
            continue;
        }
        num++;
        q.push(i);
        while(!q.empty()){
            v = q.front();
            q.pop();
            if(done[v]){
                continue;
            }
            done[v] = true;
            where[v] = i;
            for(j = (g[v].size()-1); j>=0; j--){
                q.push(g[v][j]);
            }
        }
    }
    if(num == 1){
        cout << 0 << endl;
        return 0;
    }
    for(i=0; i<n; i++){
        pq.push(P(a[i],where[i]));
    }
    fill(done,done+123456,false);
    sur = (num-1)*2-num;
    while(!pq.empty()){
        s = pq.top();
        pq.pop();
        if(done[s.second]){
            if(sur>0){
                ans += s.first;
                sur--;
            }
        }else{
            ans += s.first;
            done[s.second] = true;
        }
    }
    for(i=0; i<n; i++){
        if(!done[where[i]]){
            flag = false;
            break;
        }
    }
    if(flag && sur==0){
        cout << ans << endl;
    }else{
        cout << "Impossible" << endl;
    }
}

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

int main() {
    int n;
    cin >> n;
    int l[2 * n];
    for (int i = 0; i < 2 * n; i++) {
        cin >> l[i];
    }
    sort(l, l + 2 * n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += l[i << 1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
'use strict'


const btc = 380000.0
function main(input) {
  input = input.split('\n')
  const n = ~~input[0]
  const gain = input.slice(1).map(v => v.split(' '))
  let sum = 0;
  for (let i = 0; i < n; i++) {
    sum += gain[i][1] == 'JPY' ? ~~gain[i][0]:Number(gain[i][0]) * btc
  }
  console.log(sum)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include <bits/stdc++.h>
struct LazySegmentTreeAddSum {
    int n;
    std::vector<int> node, lazy;
    LazySegmentTreeAddSum(std::vector<int> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);
        for(int i=0;i<sz;++i) {
            node[i+n-1] = v[i];
        }
        for(int i=n-2;i>=0;--i) {
            node[i] = node[i*2+1] + node[i*2+2];
        }
    }
    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }
    void add(int a, int b, long long x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
            return;
        }
        add(a, b, x, 2*k+1, l, (l+r)/2);
        add(a, b, x, 2*k+2, (l+r)/2, r);
        node[k] = node[2*k+1] + node[2*k+2];
    }
    long long getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(b <= l || r <= a) return 0;
        eval(k, l, r);
        if(a <= l && r <= b) return node[k];
        long long vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        long long vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int r, c, n; cin >> r >> c >> n;
  vector<pair<ll, ll>> v;
  bool ok = true;
  for(int i=0;i<n;++i) {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    if((x1 == 0 || x1 == r || y1 == 0 || y1 == c) && (x2 == 0 || x2 == r || y2 == 0 || y2 == c)) {
      int tmp1 = 0, tmp2 = 0;
      int res1 = 0, res2 = 0;
      if(y1 == 0) {
        tmp1 = x1;
      } else if(x1 == r) {
        tmp1 = r + y1;
      } else if(y1 == c) {
        tmp1 = r + c + r - x1;
      } else {
        tmp1 = r + c + r + c - y1;
      }
      if(y2 == 0) {
        tmp2 = x2;
      } else if(x2 == r) {
        tmp2 = r + y2;
      } else if(y2 == c) {
        tmp2 = r + c + r - x2;
      } else {
        tmp2 = r + c + r + c - y2;
      }
      v.push_back({tmp1, i});
      v.push_back({tmp2, i});
    }
  }
  sort(v.begin(), v.end());
  stack<int> st;
  for(int i=0;i<(int)(v.size());i++) {
    if(st.empty()) {
      st.push(v[i].second);
    } else if(st.top() == v[i].second) {
      st.pop();
    } else {
      st.push(v[i].second);
    }
  }
  cout << (st.empty() ? "YES" : "NO") << endl;
}


Measured memory_bytes: 6128
use std::cmp::*;
use std::collections::HashMap;
use std::io::*;

fn dfs(dp: &mut HashMap<i64, i64>, x: i64, a: i64, b: i64, c: i64, d: i64) -> i64 {
    if dp.contains_key(&x) {
        dp[&x]
    } else {
        let mut res = x.saturating_mul(d);
        res = min(res, dfs(dp, x / 2, a, b, c, d) + a + x % 2 * d);
        if x % 2 != 0 {
            res = min(res, dfs(dp, x / 2 + 1, a, b, c, d) + a + d);
        }
        res = min(res, dfs(dp, x / 3, a, b, c, d) + b + x % 3 * d);
        if x % 3 != 0 {
            res = min(res, dfs(dp, x / 3 + 1, a, b, c, d) + b + (3 - x % 3) * d);
        }
        res = min(res, dfs(dp, x / 5, a, b, c, d) + c + x % 5 * d);
        if x % 5 != 0 {
            res = min(res, dfs(dp, x / 5 + 1, a, b, c, d) + c + (5 - x % 5) * d);
        }
        dp.insert(x, res);
        res
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let t: usize = itr.next().unwrap().parse().unwrap();
    for _ in 0..t {
        let n: i64 = itr.next().unwrap().parse().unwrap();
        let a: i64 = itr.next().unwrap().parse().unwrap();
        let b: i64 = itr.next().unwrap().parse().unwrap();
        let c: i64 = itr.next().unwrap().parse().unwrap();
        let d: i64 = itr.next().unwrap().parse().unwrap();
        let mut dp = HashMap::<i64, i64>::new();
        dp.insert(0, 0);
        dp.insert(1, d);
        println!("{}", dfs(&mut dp, n, a, b, c, d));
    }
}


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

int gcd(int a,int b);

int main(void){
  int n,i,a[100010],l[100010],r[100010];
  cin >> n;
  for (i=0;i<n;i++) cin >> a[i];
  l[0]=a[0];
  for (i=1;i<n;i++) l[i]=gcd(l[i-1],a[i]);
  r[n-1]=a[n-1];
  for (i=n-2;i>=0;i--) r[i]=gcd(r[i+1],a[i]);
  
  int ans=r[1],k;
  for (i=1;i<n-1;i++){
    k=gcd(l[i-1],r[i+1]);
    if (ans<k) ans=k;
  }
  if (ans<l[n-2]) ans=l[n-2];
  cout << ans << endl;
  return 0;
}

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

Measured memory_bytes: 1408
from bisect import bisect_left
from bisect import bisect_right


N = int(input())
L = list(map(int, input().split()))
L.sort()

"""
短いほうから２本固定して条件に合うものをさがす（長いほうから２本固定でもOK）
最長と最短を固定するとややこしくなるから、こういう場合は最長/最短どちらかから固定するほうがいいか
"""


ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        # そもそもcがaやbより大きいので、下の解法のようにilを求める必要などなく、il=で考えれば良かったんや！
        k = bisect_left(L, a+b)
        ans += k - j - 1



"""
ans = 0
for i in range(N):
    for j in range(i+1, N):
        l = L[j] - L[i]
        r = L[j] + L[i]
        #  a < b < c（場合によっては等号を含む）で考えたときの、b - a < cを満たすもの 
        il = bisect_right(L, l, lo=j)
        #  a < b < c（場合によっては等号を含む）で考えたときの、c < a + bを満たすもの
        ir = bisect_left(L, r, lo=j)
        # b - a < cを満たすものがない場合、飛ばす
        if il == N-1:
            break
        
        ans += ir - il - 1
"""

print(ans)


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

class Sieve {
    long long n_;
    vector<long long> sieve_, primes_;

public:
    explicit Sieve(long long n=1): n_(n), sieve_(n + 1) {
        sieve_[0] = sieve_[1] = -1;
        for (long long i = 2; i <= n; ++i) {
            if (sieve_[i]) continue;
            primes_.push_back(i);
            sieve_[i] = i;
            for (long long j = i*i; j <= n; j += i) {
                if (!sieve_[j]) sieve_[j] = i;
            }
        }
    }
    bool isPrime(long long x) {
        assert (n_ * n_ >= x);
        if (n_ >= x) {
            return sieve_[x] == x;
        } else {
            for (const auto prime : primes_) {
                if (x % prime == 0) return false;
            }
            return true;
        }
    }
    vector<long long> getPrimes() {
        return primes_;
    }
    vector<pair<long long, int>> getPrimeFactorList(long long x) {
        assert (n_ * n_ >= x);
        vector<long long> factorList;
        for (int i=(int)primes_.size()-1; i>=0; i--) {
            if (n_ >= x) break;
            while (x % primes_[i] == 0) {
                x /= primes_[i];
                factorList.emplace_back(primes_[i]);
            }
        }
        if (isPrime(x)) {
            factorList.emplace_back(x);
            x /= x;
        }
        assert (n_ >= x);
        while (x != 1) {
            factorList.push_back(sieve_[x]);
            x /= sieve_[x];
        }
        if (factorList.empty()) return {};
        vector<pair<long long, int>> res(1, pair<long long, int>(factorList[0], 0));
        for (long long p : factorList) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};

void solve(long long N){
    Sieve sieve(1e6+1);
    auto factorList = sieve.getPrimeFactorList(N);
    int answer = 0;
    for (auto p : factorList) {
        int i = 1;
        while (p.second >= i) {
            p.second -= i;
            i++;
            answer++;
        }
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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


bool check(const std::string& b) {
	return std::all_of(b.begin(), b.end(), [&b](char v) {return v == b[0];});
}

int solve(std::string b)
{
	int cnt = 0;
	char beg = b.front();

	for (int i = 0; i < b.size(); i++) {
		if (beg != b.at(i)) {
			cnt++;
			beg = b.at(i);
		}
	}



	return cnt;
}


int main()
{
	std::string board;
	std::cin >> board;

	std::cout << solve(board) << std::endl;


}

Measured memory_bytes: 512
#include <stdio.h>

int main(){
	int a, b;
	scanf("%d %d", &a, &b);
	if (a < b){
		printf("a < b\n");
	}
	if (a > b){
		printf("a > b\n");
	}
	if (a == b){
		printf("a == b\n");
	}




	return 0;
}

Measured memory_bytes: 1008
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String W = sc.next().toLowerCase();
    String T;
    int count=0;

    while(!(T = sc.next()).equals("END_OF_TEXT")){
      if(T.toLowerCase().equals(W)){
        count++;
      }
    }
    sc.close();
    System.out.println(count);
  }
}


Measured memory_bytes: 26296
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>

using namespace std;

struct Edge {
    int source, target, distance; 
};

int main()
{
    int n_vertices, n_edges, source_node;
    cin >> n_vertices >> n_edges >> source_node;
    vector< vector<Edge> > rev_adjlist(n_vertices); // indexed by target
    bool negative_cycle = false;
    
    for (int i = 0; i < n_edges; ++i) {
        int source, target, distance;
        cin >> source >> target >> distance;
        rev_adjlist[target].emplace_back(Edge{source, target, distance});
    }

    vector< vector<int> > shortest_paths(n_vertices + 1,
                                         vector<int>(n_vertices,
                                                     numeric_limits<int>::max()));
    shortest_paths[0][source_node] = 0;

    for (int i = 1; i <= n_vertices; ++i) {
        for (int v = 0; v < n_vertices; ++v) {
            int min_include_edge = numeric_limits<int>::max();
            for (auto edge : rev_adjlist[v]) {
                if (shortest_paths[i-1][edge.source] == numeric_limits<int>::max()) continue;
                int include_edge = shortest_paths[i-1][edge.source] + edge.distance;
                if (include_edge < min_include_edge) {
                    min_include_edge = include_edge;
                }
            }
            shortest_paths[i][v] =
                min(shortest_paths[i-1][v], min_include_edge);
        }
        if (i == n_vertices && shortest_paths[i] != shortest_paths[i-1])
            negative_cycle = true;
    }

    if (negative_cycle) {
        cout << "NEGATIVE CYCLE" << endl;
    } else {
        for (auto distance : shortest_paths[n_vertices-1]) {  
            if (distance == numeric_limits<int>::max()) {
                cout << "INF";
            } else {
                cout << distance;
            }
            cout << endl;
        }
    }
}



Measured memory_bytes: 6836
#include <bits/stdc++.h>
#define rep0(i, n) for(int i=0; i<(int)(n);i++)
using namespace std;
typedef int64_t lint;

// Union - Find
const int MAX_N = 100000;
int par[MAX_N];
int rnk[MAX_N];

// 関数
void initunion(int n){
    rep0(i, n){
        par[i] = i;
        rnk[i] = 0;
    }
}

//木を駆け上がりrootを探索する
int findroot(int x){
    if(par[x] == x)return x;
    else return par[x] = findroot(par[x]);
}

//結合
void uniteroot(int x, int y){
    x = findroot(x);
    y = findroot(y);
    if( x == y )return; //結合済
    if(rnk[x] < rnk[y])par[x] = y;
    else if(rnk[x] > rnk[y])par[y] = x;
    else {
        par[y] = x;
        rnk[x]++;
    }
}

int main(){
    lint n, m, x, y, z;
    cin >> n >> m;
    initunion(n);
    //union-findでつながりをまとめていく．
    //zはいらない（奇数か偶数かはどっちでもよいので）
    rep0(i, m){
        cin >> x >> y >> z;
        uniteroot(x,y);
    }

    //rootの数を数える=一つのまとまりは1として幾つのまとまりがあるか数える．
    vector<lint> isroot(n,0);
    rep0(i,n){
        isroot[findroot(i)] ++;
    }
    lint rootnum = 0;
    rep0(i,n){
        if(isroot[i]>0)rootnum++;
    }

    //かたまりの中で1つでもカードがわかれば全てわかる．
    //故にかたまりの数=答え
    cout << rootnum << endl;
    return 0;
}

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

#define Pb push_back
#define Mp make_pair
#define ff first
#define ss second
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define db1(x) cout<<#x<<" : "<<x<<endl;
#define db2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define db3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;

typedef long long int ll;
typedef long double ld;

const int  N = 1e5+7;
const int inf = INT_MAX;
const int MOD = 1e9+7;

#define int ll

void solve()
{
   int n , m, k;
	cin >> n >> m >> k;
	int a[n],b[m];
	for(int i=0;i<n;i++) cin >> a[i];
   for(int j=0;j<m;j++)
   {
      cin >> b[j];
      if(j != 0)
      {
         b[j] += b[j-1];
      }
   }
	int mx = 0,sum = 0;
   for(int i = 0; i <= n; i++)
   {

		if(i != 0)  {
			sum += a[i-1];
		}

		if(sum > k) {
			break;
		}

		auto idx = upper_bound(b,b+m,k-sum) - b;

		mx = max(mx , i + idx);
	}
	cout << mx;
}

int32_t main()
{
   IOS;
   //freopen("input.txt", "rt", stdin);
   //freopen("output.txt", "wt", stdout);
   int t=1;
   //cin >> t;
   for(int i=1;i<=t;i++)
   {
      //cout<<"Case #"<<i<<": ";
      solve();
   }
   return 0;
}
/*==============================================================================================================================================================*/


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

#define PB push_back
#define SZ(c) ll((c).size())
#define ALL(c) (c).begin(), (c).end()
#define CONTAINS(c, x) ((c).find(x) != (c).end())
#define REP(i, n) for(ll i=1; i<=n; i++)
#define WAIT cout<<flush, system("PAUSE");
using namespace std;
typedef long long ll;
typedef pair<ll, bool> pii;
const ll MAX = 100100;

ll N, M, C[MAX], u, v, c, sol, si, no, one;
vector<ll> E[MAX];
bool used[MAX], ok;
vector<pii> all;

void DFS(ll n){
	//cout << n << endl;
	used[n] = true;
	c++;
	
	for(auto x: E[n]) 
		if (!used[x]){
			C[x] = 1-C[n];
			DFS(x);
		}else{
			ok &= C[x] != C[n];
		}
}

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

	cin >> N >> M;
	REP(I, M){
		cin >> u >> v;
		E[u].PB(v);
		E[v].PB(u);
	}
	REP(I, N) if (!used[I]){
		ok = true;
		c = 0;
		DFS(I);
		
		//cout << I << ": " << c << " " << ok << endl;
		all.PB( pii(c, ok) );
		
		if (c > 1){
			no += (ok?2:1);
			si += 1;
		}else{
			one ++;
		}
	}
	
	for(auto x: all){
		if (x.first == 1) sol += N;
		else if (!x.second) sol += si + one * x.first;
		else                sol += no + one * x.first;
		//cout << sol << endl;
	}
	cout << sol << endl;
	
	// REP <=
}


















Measured memory_bytes: 12544
#include "bits/stdc++.h"
#include <sys/timeb.h>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;

bool BellmanFord(vvP graph, int start, vi &cost, int V) {
	vi prev(V);
	vb visitable(V, false);
	int k = 1;
	int visitable_num = 0;

	stack<int> st;
	st.push(start);
	while (!st.empty()) {
		int pos = st.top();
		st.pop();
		visitable[pos] = true;
		rep(i, graph[pos].size()) {
			if (!visitable[graph[pos][i].first]) {
				st.push(graph[pos][i].first);
			}
		}
	}

	rep(i, V) {
		if (visitable[i])visitable_num++;
	}

	fill(cost.begin(), cost.end(), INF);
	cost[start] = 0;

	while (true) {
		bool flag = true;
		rep(i, V)rep(j, graph[i].size()) {
			// ??¨???(i->graph[i][j].first)????????????
			if (visitable[i] && cost[graph[i][j].first] > cost[i] + graph[i][j].second) {
				cost[graph[i][j].first] = cost[i] + graph[i][j].second;
				prev[graph[i][j].first] = i;
				flag = false;
				break;
			}
		}
		if (flag)break;
		if (k == visitable_num) return false;
		k++;
	}
	return true;
}

int main() {
	int V, E, r;
	cin >> V >> E >> r;
	vvP G(V);
	vi c(V);
	rep(i, E) {
		int s, t, d;
		cin >> s >> t >> d;
		G[s].push_back(mp(t, d));
	}

	if (BellmanFord(G, r, c, V)) {
		rep(i, V) {
			if (c[i] > INF / 2) {
				cout << "INF" << endl;
			}
			else {
				cout << c[i] << endl;
			}
		}
	}
	else {
		cout << "NEGATIVE CYCLE" << endl;
	}

	return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
int deg[5];
int main()
{

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

	for(int i=1; i<=3; i++) {
		int u,v;
		cin>>u>>v;
		deg[u]++;
		deg[v]++;
	}
	int cnt1=0; int cnt2=0;
	for(int i=1; i<=4; i++) {
		if(deg[i]==1) {
			cnt1++;
		}
		if(deg[i]==2) {
			cnt2++;
		}
	}
	if(cnt1==2&&cnt2==2) {
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//
typedef pair<int, int> node;

int MAX_N = 200000;
int SIZE[200000];
vector<node> unionfind(MAX_N);

void init(int N){
	for(int i=0;i<N;i++){
		unionfind[i].first = i;
		unionfind[i].second = 0;
		SIZE[i] = 1;
	}
}

int find(int n){
	if(unionfind[n].first == n){
		return n;
	}
	else{
		unionfind[n].first = find(unionfind[n].first);
		return unionfind[n].first;
	}
}
void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(unionfind[x].second > unionfind[y].second){
		unionfind[x].first = y;
	} 
	else{
		unionfind[y].first = x;
	}
	if(unionfind[x].second == unionfind[y].second){
		unionfind[x].second++;
	}
	int tmp = SIZE[x];
	SIZE[x] += SIZE[y];
	SIZE[y] += tmp;
}

int main(){
	int N, M;
	cin >> N >> M;
	int A[M], B[M];
	init(N);
	for(int i=0;i<M;i++){
		cin >> A[i] >> B[i];
		unite(A[i], B[i]);
	}
	int ans = 0;
	for(int i=0;i<N;i++){
		ans = max(SIZE[i], ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 7156