akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;
constexpr LL kInf = 1e18;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N; cin >> N;
  vector<LL> A(N), sum(N+1); cin >> A;
  sum[0] = 0;
  for (int i = 0; i < N; ++i) {
    sum[i+1] = sum[i] + A[i];
  }

  LL ans = 1e18, vmin = 0, low = 0, high = 0;
  for (int i = 0; i <= N; ++i) {
    vmin = kInf, low = 0, high = i;
    while (high - low > 1) {
      int mid = (high + low) / 2;
      LL p = sum[mid] - sum[0], q = sum[i] - sum[mid];
      if (p > q) high = mid;
      else       low = mid;
    }
    LL P1 = sum[low] - sum[0], P2 = sum[high] - sum[0];
    LL Q1 = sum[i] - sum[low], Q2 = sum[i] - sum[high];
    LL P, Q;
    if (abs(P1-Q1) < abs(P2-Q2)) P = P1, Q = Q1;
    else                         P = P2, Q = Q2;

    vmin = kInf, low = i, high = N;
    while (high - low > 1) {
      int mid = (high + low) / 2;
      LL r = sum[mid] - sum[i], s = sum[N] - sum[mid];
      if (r > s) high = mid;
      else       low = mid;
    }
    LL R1 = sum[low] - sum[i], R2 = sum[high] - sum[i];
    LL S1 = sum[N] - sum[low],     S2 = sum[N] - sum[high];
    LL R, S;
    if (abs(R1-S1) < abs(R2-S2)) R = R1, S = S1;
    else                         R = R2, S = S2;

    ans = min(ans, max({P, Q, R, S}) - min({P, Q, R, S}));
  }
  cout << ans << endl;
}



Measured memory_bytes: 3328
s = input()
n = int(len(s))
ans_1,ans_2 = 0,0

for i in range(n):
    if i % 2 == 0:
        t = "0"
    if i % 2 == 1:
        t = "1"
    if s[i] != t:
        ans_1 += 1

for i in range(n):
    if i % 2 == 0:
        t = "1"
    if i % 2 == 1:
        t = "0"
    if s[i] != t:
        ans_2 += 1

print(min(ans_1,ans_2))


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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

using namespace std;

int s, w;

int main()
{
    cin >> s >> w;
    if (s <= w)
        cout << "unsafe";
    else
        cout << "safe";
	return 0;
}


Measured memory_bytes: 3620
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

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

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

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

        if x == y:
            return

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

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

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

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

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

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,m = lr()
x = [0 for i in range(n-1)]
for i in range(m):
    a,b = lr()
    a,b = min(a,b), max(a,b)
    a-=1
    b-=1
    x[a]+=1
    if b != n-1:
        x[b]-=1
x1 = [0]
for i in range(n-1):
    x1.append(x1[-1]+x[i])
flag = True
for num in x1:
    if num%2 == 1:
        flag = False
        break
if flag:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 86892
#include<stdio.h>

int main(void)
{
  int a, b, c, i, x, cnt = 0;

  scanf("%d %d %d", &a, &b, &c);

  for(i = 1; i <= c; i++) {
    if(c % i == 0) {
      x = c / i;
      if(a <= x && x <= b) {
	cnt++;
      }
    }
  }

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

  return 0;
}

Measured memory_bytes: 596
from fractions import gcd
A, B, C, D = map(int,input().split())
total = B - A + 1
divC = B//C - (A-1)//C
divD = B//D - (A-1)//D
lcm = int(C * D / gcd(C, D))
divCD = B//lcm - (A-1)//lcm
print(total - divC - divD + divCD)


Measured memory_bytes: 5088
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	long long a, b, c;
	cin >> a >> b >> c;
	REP(i, b * 2) {
		long long geko = i * a;
		if (geko % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 100005
#define pb push_back
#define vit vector<int>::iterator
typedef pair<lint,lint> pii;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string S;
    cin>>S;
    if(S[S.size()-1]=='s') cout<<S<<"es";
    else cout<<S<<'s';
    return 0;
}


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

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

    int n;cin>>n;

    bool ans=true;

    int x=0;
    int y=0;
    int t=0;

    for(int i=0;i<n;i++)
    {
        int it,ix,iy;
        cin>>it>>ix>>iy;

        int tt=it-t;
        int dd=abs(x-ix)+abs(y-iy);

        if(tt==dd||(tt>dd&&abs(dd-tt)%2==0))
        {
            x=ix;
            y=iy;
            t=it;
        }
        else
        {
            ans=false;
        }
    }

    puts(ans?"Yes":"No");

    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define N 20
#define M (1 << 15 | 5)
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
	while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return f?x:-x;
}
int mp[N][N], inc[M], cot[M][N], dp[M][N];
int main(int argc, char const *argv[]) {
	int n = read(), m = read();
	for (int i = 1; i <= m; i++) {
		int x = read() - 1, y = read() - 1;
		mp[x][y] = mp[y][x] = read();
	}
	int tot = 1 << n;
	for (int i = 0; i < tot; i++)
		for (int a = 0; a < n; a++) if (i >> a & 1)
			for (int b = 0; b < a; b++) if (i >> b & 1)
				if (mp[a][b]) inc[i] += mp[a][b];
	for (int i = 0; i < tot; i++)
		for (int a = 0; a < n; a++) if (~ i >> a & 1)
			for (int b = 0; b < n; b++) if (i >> b & 1)
				if (mp[a][b]) cot[i][a] += mp[a][b];
	memset(dp, -1, sizeof dp);
	dp[1][0] = 0;
	for (int i = 0; i < tot; i++) {
		for (int a = 0; a < n; a++) {
			if ((i >> a & 1) && ~ dp[i][a]) {
				for (int b = 0; b < n; b++) if (~ i >> b & 1)
					if (mp[a][b]) dp[i | (1 << b)][b] = max(dp[i | (1 << b)][b], dp[i][a] + mp[a][b]);
				int lst = tot - 1 - i;
				for (int j = lst; j; j = (j - 1) & lst) {
					int now = inc[j] + cot[j][a];
					dp[i | j][a] = max(dp[i | j][a], dp[i][a] + now);
				}
			}
		}
	}
	printf("%d\n", inc[tot - 1] - dp[tot - 1][n - 1]);
	return 0;
}


Measured memory_bytes: 5504
#!/usr/bin/env python
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

max_x = max(x)
min_y = min(y)

for z in range(X+1, Y):
    if max_x < z and z <= min_y:
        print('No War')
        break
else:
    print('War')

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

typedef long long ll;

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

    string s;
    cin >> s;

    int n = s.size();

    int pos = 0;

    vector<int> L(n), R(n), a(n);

    for(int i = 0; i < n; i++) {
        R[i] = pos;
        if(s[i] == 'R') pos = i;
    }

    pos = n - 1;

    for(int i = n - 1; i >= 0; i--) {
        L[i] = pos;
        if(s[i] == 'L') pos = i;
    }

    for(int i = 0; i < n; i++) {
        if(s[i] == 'L') {
            int len = i - R[i];
            if(len & 1) a[R[i] + 1]++;
            else a[R[i]]++;
        }
        else {
            int len = L[i] - i;
            if(len & 1) a[L[i] - 1]++;
            else a[L[i]]++;
        }
    }

    for(int i = 0; i < n; i++) cout << a[i] << " ";
    cout << endl;
}

/**
*/


Measured memory_bytes: 1872
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin>>n;
  vector<pair<ll,ll>> p;
  rep(i,n){
    ll a,b;
    cin>>a>>b;
    p.push_back(pair<ll,ll>(b,a));
  }
  sort(ALL(p));
  ll ans=0;
  bool flag=true;
  rep(i,n){
    ans+=p[i].second;
    if(!(ans<=p[i].first)) flag=false;
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

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

    int N, M; cin >> N >> M;
    int ans = 0;
    for (int i = 1; i * i <= M; i++) {
        if (M % i > 0) continue;
        int j = M / i;
        if (j >= N) ans = max(ans, i);
        if (i >= N) ans = max(ans, j);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> D(n); rep(i, n) cin >> D[i];
  sort(all(D));
  cout << D[n/2] - D[n/2-1] << "\n";
  return 0;
}


Measured memory_bytes: 3700
A, B, C = gets.split.map(&:to_i)
K = gets.to_i
a = A
b = B
c = C

i = 0
until a < b do
  b *= 2
  i += 1
end

until b < c do
  c *= 2
  i += 1
end

if i <= K
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 14392
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)


int main() {
	lint N, A, B;
	cin >> N >> A >> B;
	vector<lint>T(N);
	rep(i, N) {
		cin >> T[i];
	}
	int cnt = 0;
	rep(i, N) {
		if (A <= T[i] && T[i] < B) {
			cnt++;
		}
	}
	cout << N - cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    int n, l;
    cin >> n >> l;
    ll a[n];
    for(int i = 0; i < n; i++)  cin >> a[i];
    int ans;
    for(ans = 1; ans < n; ans++){
        if(a[ans]+a[ans-1] >= l)    break;
    }
    if(ans == n){
        cout << "Impossible" << endl;
    }else{
        cout << "Possible" << endl;
        for(int i = 1; i < ans; i++)    cout << i << endl;
        for(int i = n-1; i > ans; i--)  cout << i << endl;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            for (; ; )
            {
                var inputLine = Console.In.ReadLine();
                var inputs = inputLine.Split(new char[] { ' ', '\t', '　' });
                if (inputs.Length != 2)
                {
                    return;
                }

                var H = int.Parse(inputs[0]);
                var W = int.Parse(inputs[1]);
                if (H == 0 && W == 0)
                {
                    break;
                }

                for (int ih = 0; ih < H; ++ih)
                {
                    for (int iw = 0; iw < W; ++iw)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}


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

using namespace std;

int main(){
	double res;
	for(int n; cin >> n, n; cout << (int)res << endl){
		res = 0.0;
		vector<int> l;
		for(int i = 0; i < n; i++){
			int buf; cin >> buf;
			l.push_back(buf);	
		}
		sort(l.begin(), l.end());
		for(int i = 1; i < l.size() - 1; i++){res += (double)l[i];}
		res /= (double)(l.size() - 2);
	}
	return 0;
}

Measured memory_bytes: 1216
from itertools import combinations
# from math import factorial as f
def cmb(n, k, mod, fac, ifac):
    """
    nCkを計算する
    """
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def make_tables(mod, n):
    """
    階乗テーブル、逆元の階乗テーブルを作成する
    """
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac

MOD = 10**9 + 7
def main():
    X, Y = map(int, input().split())
    a = 2 * X - Y
    if a % 3 != 0 or a < 0:
        print(0)
        return
    a = a // 3

    b = 2 * Y - X
    if b % 3 != 0 or b < 0:
        print(0)
        return
    b = b // 3

    total = a + b
    fac, ifac = make_tables(MOD, total)
    ans = cmb(a+b, min(a, b), MOD, fac, ifac)
    print(ans)


main()

Measured memory_bytes: 82508
#include <iostream>
#include <cstdio>  
#include <cmath>
#include <algorithm>

using namespace std;
const int INF = 10000000;

int M,N;
int X1[100+10], X2[100+10], Y[100+10], Z[100+10], P[200+10];
double ans;

double width(int* X, int* YZ, int n, double x){  
	double lb=INF, ub=-INF;  
	for (int i=0; i<n; i++){  
		double x1=X[i], y1=YZ[i], x2=X[(i+1) % n], y2=YZ[(i+1) % n];  
		if ((x1-x) * (x2-x) <= 0 && x1 != x2){   
			double y=y1 + (y2-y1) * (x-x1) / (x2-x1);  
			lb = min(lb, y);  
			ub = max(ub, y);  
		}  
	} 
	return max(0.0, ub-lb);  
}  


void solve(){
	ans = 0.0;
	int min1 = *min_element(X1,X1+M);
	int min2 = *min_element(X2,X2+N);
	int max1 = *max_element(X1,X1+M);
	int max2 = *max_element(X2,X2+N);
	
	sort(P,P+M+N);
		
	for (int i=0; i<M+N-1; i++){
		double a = P[i];
		double b = P[i+1];
		double c = (a+b)/2;
		if (min1<=c && min2<=c && c<=max1 && c<=max2){
			double fa = width(X1, Y, M, a) * width(X2, Z, N, a);  
			double fb = width(X1, Y, M, b) * width(X2, Z, N, b);  
			double fc = width(X1, Y, M, c) * width(X2, Z, N, c);
			ans += (b-a)/6*(fa+4*fc+fb);
		}
	}
	printf("%.10f\n", ans);
}

int main() {
	while ((cin >> M >> N) && M && N){
		for (int i=0; i<M; i++){
			cin >> X1[i] >> Y[i];
			P[i] = X1[i];
		}
		for (int i=0; i<N; i++){
			cin >> X2[i] >> Z[i];
			P[M+i] = X2[i];
		}
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 3064
function main(input) {
  input=input.trim();
  const n = parseInt(input.split(" ")[0], 10);
  const m = parseInt(input.split(" ")[1], 10);
  const x = parseInt(input.split(" ")[2], 10);
  const arrA = input.split('\n')[1].split(' ').map((n) => parseInt(n, 10));

  var temp1=0
  var temp2=0
  for(var i=0; i<m; i++){
    if(arrA[i]<x){
      temp1++
    }else{
      temp2++
    }
  }
  console.log(Math.min.apply(null, [temp1,temp2]));
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define mod 1000000007
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
struct data{int u,v,w;}s[2010];
int fa[1010],FA[1010],fw[1010],dep[1010];
std::vector<pr>G[1010];
int hd(int x){return fa[x]==x?x:fa[x]=hd(fa[x]);}
void DFS(int x,int f=-1){
	for(pr s:G[x])if(s.fi!=f)FA[s.fi]=x,dep[s.fi]=dep[x]+1,fw[s.fi]=s.se,DFS(s.fi,x);
}
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi(),m=gi();
	ll X=gi();
	for(int i=1;i<=m;++i)s[i].u=gi(),s[i].v=gi(),s[i].w=gi();
	std::sort(s+1,s+m+1,[](data a,data b){return a.w<b.w;});
	for(int i=1;i<=n;++i)fa[i]=i;
	ll sum=0;
	for(int i=1;i<=m;++i){
		int X=hd(s[i].u),Y=hd(s[i].v);
		if(X!=Y)fa[X]=Y,G[s[i].u].push_back({s[i].v,s[i].w}),G[s[i].v].push_back({s[i].u,s[i].w}),sum+=s[i].w,s[i].w=-1;
	}
	DFS(1);
	int c=0,ans=0,MUL=1;
	for(int i=1;i<=m;++i){
		if(s[i].w==-1)continue;
		int x=s[i].u,y=s[i].v,mx=0;
		if(dep[x]<dep[y])std::swap(x,y);
		while(dep[x]>dep[y])cxk(mx,fw[x]),x=FA[x];
		while(x!=y)cxk(mx,fw[x]),x=FA[x],cxk(mx,fw[y]),y=FA[y];
		if(sum-mx+s[i].w==X)++c;
		else if(sum-mx+s[i].w>X)MUL=MUL*2%mod;
	}
	if(sum==X)ans=1ll*(pow(2,n-1)-2)*pow(2,m-n+1)%mod;
	inc(ans,2ll*(pow(2,c)-1)*MUL%mod);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
import heapq


def resolve():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    query = []
    for i in range(n):
        heapq.heappush(query, -a[i])
    for i in range(m):
        nexta = -1 * heapq.heappop(query) // 2
        heapq.heappush(query, -nexta)
    print(-sum(query))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 64792
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define MP make_pair
#define pss pair<string,string>
#define vi vector<int>
#define pb push_back
using namespace std;
const int N=1e5+5;
ll n,m,x,y;

int main()
{
	cin>>n>>m>>x>>y;
	cout<<n*m/2; 
	if(n*m%2==0)
		cout<<".0";
	else
		cout<<".5";
	cout<<"00000 ";
	if(x*2==n&&y*2==m)
		cout<<"1\n";
	else
		cout<<"0\n";
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
//#include<numeric>
#include<functional>
//#include<string>
//#include<iostream>

using namespace std;
const int one = 1;
const int big = (one<<20);
typedef long long int llint;

int main(void){
	llint i,ans=0,N,x=0,s=0;
	scanf("%lld",&N);
	for(i=0;i<N;i++){
		scanf("%lld",&x);
		if(x==0){s=0;}
		s+=x;
		ans+=s/2;
		s%=2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();

    let mut num_zero: i64 = 0;
    let mut num_one: i64 = 0;

    for e in &s {
      if *e == '1' {
        num_one += 1;
      }
      else {
        num_zero += 1;
      }
    }

    println!("{}", std::cmp::min(num_one, num_zero) * 2);
}


Measured memory_bytes: 4352
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll a[100010];
ll m=INF,M;
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n){
		int t;
		scanf("%d",&t);
		a[t]++;
		m=min(m,t);
		M=max(M,t);
	}
	if(M-m>1){
		puts("No");
	}else if(M==m){
		//全員バラバラか
		if(M==n-1)puts("Yes");
		//どの色も2人以上
		//n人がM色
		else if(M*2<=n)puts("Yes");
		//ダメ
		else puts("No");

	}else{
		//ぼっちとそうじゃないやつがいる
		//ぼっちがa[m]人、そうじゃないやつは
		//残りのn-a[m]人がM-a[m]色
		if(M-a[m]>0&&(M-a[m])*2<=n-a[m])puts("Yes");
		else puts("No");
	}
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define _GLIBCXX_DEBUG
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int sum=0;
    rep(i,n-2){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')sum++;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define int long long
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%lld",&a)
#define getII(a,b) scanf("%lld%lld",&a,&b)
#define getIII(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define VgetI(n) int (n); scanf("%lld",&(n))
#define VgetII(n,m) int (n),(m); scanf("%lld%lld",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define INF 2000000000
main(){
	string s;
	cin>>s;
	if(s=="ABC") puts("ARC");
	else puts("ABC");
}


Measured memory_bytes: 3592
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int n, m;
    cin >> n >> m;
    Graph G(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        G[a].push_back(b);
        G[b].push_back(a);
    }

    for (int i = 0; i < n; i++) {
        cout << G[i].size() << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// created on : Tue Jun 23 2020
 
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        int n = in.nextInt() % 10;
        if(n == 3){
            println("bon");
        }
        else if(n == 0 || n == 1 || n == 6 || n == 8){
            println("pon");
        }
        else{
            println("hon");
        }
        
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static int[] readInt(int N) throws IOException { 
    	int arr[] = new int[N];
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    	return arr;
    }
    
    static long[] readLong(int N) throws IOException { 
    	long arr[] = new long[N];
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    	return arr;
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i] + " "); 
    	} 
    	println(""); 
    }
    
    static void displayRuntime(long startTime){
        long stopTime = System.currentTimeMillis();
        long elapsedTime = stopTime - startTime;
        System.out.println("Runtime: " + elapsedTime / 1000D);
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;

const ld PI = acosl(-1.0);
const int M = 3030;

int n;
int a[M];
int l;

void read() {
  cin >> n >> l;
  for (int i = 0; i < n; ++i)
    cin >> a[i];
}

void naive() {
  ld by = PI / l;
  ld x = .0;
  ld y = .0;
  for (int i = 0; i < n; ++i) {
    ld sum = 0;
    for (int j = 0; j < n; ++j)
      for (int k = 0; k < n; ++k)
        if (i != j && j != k && k != i) {
          ld A = fabs(sin(by * (a[k] - a[j])));
          ld B = fabs(sin(by * (a[i] - a[k])));
          ld C = fabs(sin(by * (a[i] - a[j])));
          sum += A / (A + B + C);
          x += cos(2 * by * a[i]) * A / (A + B + C);
          y += sin(2 * by * a[i]) * A / (A + B + C);
        }
    cerr << a[i] << " -> " << sum / 2 << "\n";
  }

  ld cnt = n * (n - 1) * (n - 2) / 3; // OVERFLOWWWWW
  x /= cnt;
  y /= cnt;
  cout << x << " " << y << "\n";
}

void solve() {
  ld by = PI / l / 2;
  ld x = .0;
  ld y = .0;
  
  int cur = 0;
  for (int ITER = 0; ITER < n; ++ITER) {
    a[n] = a[0];
    for (int i = 0; i < n; ++i)
      a[i] = a[i + 1];
    int shift = a[0];
    cur = (cur + shift) % l;
    for (int i = 0; i < n; ++i)
      a[i] = (a[i] - shift + l) % l;
    assert(is_sorted(a, a + n));

    ld sum = .0;
    //sum += (n - 1) * (n - 2) / 2;
    ld mem = .0;
    for (int i = 1; i < n; ++i) {
      ld t = tanl(by * a[i]);
      sum -= mem / t;
      mem += t;
    }

    sum /= (n - 1) * (n - 2);
    sum += 0.5;

    //cerr << "cur = " << cur << "\n";
    //cerr << "sum = " << sum << "\n";
    //cerr << cur << " -> " << sum << "\n";
    y += sinl(4. * by * cur) * sum;
    x += cosl(4. * by * cur) * sum;
  }
  
  ld cnt = ld(n) / 3; // OVERFLOWWWWW
  x /= cnt;
  y /= cnt;
  cout << x << " " << y << "\n";
}

int main() {
#ifdef LOCAL
  assert(freopen("d.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;

  read();
  //naive();
  solve();

}



Measured memory_bytes: 384
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

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

	cout << (X - A) % B << endl;
}

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

int main(){
	int n;cin>>n;
	
int r=n%10;
if(r==0||r==1||r==6||r==8) 
  cout<<"pon"<<endl;
else if(r==3) 
  cout<<"bon"<<endl;
else 
   cout<<"hon"<<endl;
   return 0;
}

Measured memory_bytes: 3608
require 'set'

n, m, tax = gets.strip.split.map(&:to_i)
abc = readlines.map {|line| line.strip.split.map(&:to_i) }
abc = abc.map {|a, b, c| [a, b, -1*(c-tax)] }

# 特殊な隣接リストを構築
graph = Array.new(n+1) { [] }
r_graph = Array.new(n+1) { [] }
abc.each do |a, b, c|
  graph[a] << [b, c]
  r_graph[b] << [a, c]
end

# スタートとゴールから到達可能なノードを列挙
from_1 = []
from_1 << 1
q = [1]
until q.empty?
  c = q.shift
  graph[c].each do |to, _|
    next if from_1.include?(to)
    from_1 << to
    q.push(to)
  end
end

from_n = []
from_n << n
q = [n]
until q.empty?
  c = q.shift
  r_graph[c].each do |to, _|
    next if from_n.include?(to)
    from_n << to
    q.push(to)
  end
end

available_nodes = from_1 & from_n
available_roads = abc.select {|a, b, _| available_nodes.include?(a) || available_nodes.include?(b) }

# ベルマンフォードで経路探索、最短経路を算出
INF = 10**13
dist=Array.new(n+1, INF)
dist[1]=0
updated=false

available_nodes.each do
  updated=false
  available_roads.each do |from, to, cost|
    if dist[from] != INF && dist[to] > dist[from] + cost
      dist[to] = dist[from] + cost
      updated = true
    end
  end
  break unless updated
end

if updated
  p -1
  exit
end

#p abc
#p [from_1, from_n]
#p available_roads
#p dist
p [-1*dist[n], 0].max



Measured memory_bytes: 3452
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int n;
    string s;
    bool same_string=true;
    cin >> n;
    cin >> s;
    if(n%2==1){
        same_string=false;
    }else{
        for(int i=0; i<n/2; i++){
            if(s[i]!=s[i+n/2]){
                same_string=false;
            }
        }
    }
    if(same_string){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N,K = map(int, input().split())
S = input()
memo =[]
now = '1'
cnt = 0
for s in S:
    if s==now:
        cnt+=1
    else:
        memo.append(cnt)
        cnt=1
        now = '1' if now=='0' else '0'
else:
    memo.append(cnt)
if S[-1] == '0':
    memo.append(0)
ans = 0
add = K*2+1

ruiwa = [0]*(len(memo)+1)
for i in range(len(memo)):
    ruiwa[i+1]=ruiwa[i]+memo[i]

for i in range(N)[::2]:
    if i < N:
        tmp = ruiwa[min(i+add, len(ruiwa)-1)] - ruiwa[min(i, len(ruiwa)-1)]
        ans = max(ans, tmp)
print(ans)


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

int main()
{
  int n, x, min = 1000001, max = -1000001;
  long sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x > max) max = x;
    if (x < min) min = x;
    sum += x;
  }
  cout << min << ' ' << max << ' ' << sum << endl;
}



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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

template<class T>bool ch1000000(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


const int MAX = 42;




int main() {
  int N;
  cin >> N;
  vector<char> stone(N);

  rep(i, 0, N){
    cin >> stone[i];
  }

  int l = 0, r = N-1;
  int ans = 0;

  while(l < r){
    if(stone[l] == 'W' && stone[r] == 'R'){
      ans++;
      l++;
      r--;
    }
    if(stone[l] == 'R'){
      l++;
    }
    if(stone[r] == 'W'){
      r--;
    }
  }

  cout << ans << endl;





  // ll K;
  // cin >> K;

  // if(K % 2 == 0){
  //   cout << -1 << endl;
  //   return 0;
  // }

  // ll digit = floor(log10(K)+1);
  // ll times = ll(pow(10, digit));
  // ll add = 7;
  // rep(i, 0, digit-1){
  //   add *= 10;
  //   add += 7;
  // }
  // ll cnt = 1;
  // ll a = 7;
  // while(true){
  //   if(a % K == 0){
  //     cout << cnt << endl;
  //     break;
  //   }else{
      
  //     ll res = digit - floor(log10(a)+1);
  //     times = ll(pow(10, res));
  //     add = 7;
  //     for(int i = 0; i < res-1; i++){
  //       add *= 10;
  //       add += 7;
  //     }
  //     // cout << "1" << a << endl;
  //     a *= times;
  //     a += add;
  //     // cout << "2" << a << endl;
  //     a %= K;
  //     cnt += res+3;
  //     // cout << cnt << endl;
  //   }
  // }







  




  // cout << setprecision(8) << ans << endl;  // For double
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

int N,W;
int val[101],weight[101];
int dp[101][100001];

int f(int i,int v){//min weight with val v up till index (i,N-1)
    if(i==N && v==0)return 0;
    if(i==N && v!=0)return INT_MAX;
    if(dp[i][v]!=-1)return dp[i][v];
    
    int a=weight[i]+f(i+1,v-val[i]);
    int b=f(i+1,v);
    
    return dp[i][v]=min(a,b);
}

signed main(){
    FASTER;
    memset(dp,-1,sizeof dp);
    cin>>N>>W;
    for(int i=0;i<N;i++)cin>>weight[i]>>val[i];
    
    int ans=0;
    for(int vall=100000;vall>=0;vall--){
        if(f(0,vall)<=W){
            ans=vall;
            break;
        }
    }
    cout<<ans;
}



Measured memory_bytes: 79232
import java.util.*;
import java.io.*;

public class Main {

    public Main(FastScanner in, PrintWriter out, int test) {
        int N = in.nextInt();
        int M = in.nextInt();
        int K = in.nextInt();

        int res = 0;

        long[] A = new long[N + 1];
        for (int i = 0; i < N; i++) {
            A[i + 1] = A[i] + in.nextInt();
            if (A[i + 1] <= K) res = i + 1;
        }

        long[] B = new long[M + 1];
        for (int i = 0; i < M; i++)
            B[i + 1] = B[i] + in.nextInt();

        int a = res, b = 0;
        while (a >= 0 && b <= M) {
            while (b <= M && A[a] + B[b] <= K)
                b++;
            res = Math.max(res, a + b - 1);
            a--;
        }

        out.println(res);
    }

    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        // Scanner in = new Scanner(
                // new BufferedReader(new InputStreamReader(System.in)));
        FastScanner in = new FastScanner(System.in);

        // int T = in.nextInt();
        for (int t = 1; t <= 1; t++) {
            Main sol = new Main(in, out, t);
        }

        out.close();
    }
}


class FastScanner{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner(InputStream stream)
    {
        this.stream = stream;
    }

    int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    boolean isSpaceChar(int c)
    {
        return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
    }

    boolean isEndline(int c)
    {
        return c=='\n'||c=='\r'||c==-1;
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String next(){
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isSpaceChar(c));
        return res.toString();
    }

    String nextLine(){
        int c = read();
        while (isEndline(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isEndline(c));
        return res.toString();
    }
}

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

int dividable_cnt (int n);

int main () {

    int N;
    cin >> N;

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

    int ans = 0;

    for (int i = 0; i < N; i++) {
        ans += dividable_cnt(a[i]);
    }

    cout << ans << endl;

    return 0;
}

int dividable_cnt (int n) {

    int cnt = 0;

    while (n > 0 && n % 2 == 0) {
        n /= 2;
        cnt++;
    }

    return cnt;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vs>		vvs;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

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

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


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

	int ans = X.length();
	int scount = 0;
	for (int i = 0; i < X.length(); i++) {
		if (X[i] == 'S') scount++;
		else {
			if (scount > 0) {
				scount--;
				ans -= 2;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 	3.14159265358979323846

int main(){
	ll n;
	cin >> n;
	static ll cd[4][3][10] = {0};
	REP(i,n){
		ll a,b,c,d;
		cin >> a >> b >> c >>d;
		cd[a-1][b-1][c-1] += d;
	}
	REP(i,4){
		REP(j,3){
			REP(k,10){
				cout << " " << cd[i][j][k];
			}
			cout << endl;
		}
		if(!(i+1==4)){
			cout << "####################" << endl;
		}
	}
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    int ans = 0;
    map<pair<int, int>, int> count;
    for(int i = 1; i <= n; i++){
        int d = log10(i);
        int l = i / (int)pow(10, d), r = i % 10;
        if(r == 0) continue;
        count[{l, r}]++;
    }
    for(int i = 1; i <= n; i++){
        int d = log10(i);
        int l = i / (int)pow(10, d), r = i % 10;
        if(r == 0) continue;
        ans += count[{r, l}];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define mp(a, b) make_pair(a, b)
typedef pair<int, int> pii;
const int maxn = 25;
vector<pii> E[maxn];
void dfs(int L, int s, int & t)
{
	if(L == 2)
	{
		E[t - 1].push_back(mp(t, 0));
		E[t - 1].push_back(mp(t, 1));
		return;
	}
	if(L & 1)
	{
		dfs(L - 1, s, t);
		E[s].push_back(mp(t, L - 1));
	}
	else
	{
		dfs(L / 2, s + 1, ++t);
		for(int i = s + 1; i < t; ++i)
			for(auto & e : E[i])
				e.second *= 2;
		E[s].push_back(mp(s + 1, 0));
		E[s].push_back(mp(s + 1, 1));
	}
}
int main()
{
	int L, t;
	scanf("%d", &L);
	dfs(L, 1, t = 2);
	int m = 0;
	for(int i = 1; i <= t; ++i)
		m += E[i].size();
	printf("%d %d\n", t, m);
	for(int i = 1; i <= t; ++i)
		for(auto e : E[i])
			printf("%d %d %d\n", i, e.first, e.second);
	return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <utility>
#include <string>
#include <queue>
#include <cmath>
#include <array>

typedef long long ll;

int main(int argc, char *argv[])
{
    const ll MOD = 1e9 + 7;
    ll n;
    ll k;
    ll ans = 0;

    std::cin >> n >> k;

    for (ll i = k; i <= n + 1; i++) {
        ll min = i * (i - 1) / 2;
        ll max = min + (n - i + 1) * i;
        ans += (max - min + 1);
        ans %= MOD;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3648
from itertools import accumulate

n = int(input())
a = list(accumulate(map(int, input().split())))

ans = abs(a[n - 1] - 2 * a[0])
for i in range(1, n - 1):
    ans = min(ans, abs(a[n - 1] - 2 * a[i]))
print(ans)


Measured memory_bytes: 101972