akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;

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

    int m;
    if ((int)n%2 == 0) m = n/2;
    else m = n/2+1;

    double ans;
    ans = (double)m/(double)n;

    printf("%.10f\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n,x,y;
	while(true){
		y=0;
		cin >>n >>x;
		if(n==0 && x==0){
			break;
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<i;j++){
				for(int k=1;k<j;k++){
					if(i+j+k==x){
						y +=1;
					}
				}
			}
		}
		cout << y << endl;
	}
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

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

static const int intMAX = (1 << 30) - 1;
static const long long llMAX = (1 << 62) - 1;

struct Point{ int x, y; };

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

	Point a[51], c[51];

	REP(i, N) {
		cin >> a[i].x >> a[i].y;
	}
	REP(i, M) {
		cin >> c[i].x >> c[i].y;
	}
	
	int dist;
	int nex, num;
	REP(i, N) {
		dist = intMAX;
		num = 0;
		REP(j, M) {
			nex = abs(a[i].x - c[j].x) + abs(a[i].y - c[j].y);
			if (nex < dist) {
				dist = nex;
				num = j;
			}
		}

		cout << num + 1 << endl;
	}


	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	M = 1000000007
)

var (
	fac  []int
	ifac []int
)

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func mpow(x int, n int) int {
	ans := 1
	for n != 0 {
		if n&1 == 1 {
			ans = ans * x % M
		}
		x = x * x % M
		n = n >> 1
	}
	return ans
}

func comb(a int, b int) int {
	if a == 0 && b == 0 {
		return 1
	}
	if a < b || a < 0 {
		return 0
	}
	tmp := ifac[a-b] * ifac[b] % M
	return tmp * fac[a] % M
}

func main() {
	X := readInt()
	Y := readInt()

	if (X+Y)%3 != 0 {
		fmt.Println(0)
		return
	}

	fac = make([]int, 666667)
	ifac = make([]int, 666667)

	a := (2*Y - X) / 3
	b := (2*X - Y) / 3

	if a < 0 || b < 0 {
		fmt.Println(0)
		return
	}

	fac[0] = 1
	ifac[0] = 1
	for i := 0; i < 666666; i++ {
		fac[i+1] = fac[i] * (i + 1) % M
		ifac[i+1] = ifac[i] * mpow(i+1, M-2) % M
	}

	fmt.Println(comb(a+b, min(a, b)) % M)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 13776
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int N, Z, W;
int a[2000];

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

  if (N == 1) {
    cout << abs(a[N - 1] - W) << endl;
  } else {
    cout << max(abs(a[N - 1] - W), abs(a[N - 1] - a[N - 2])) << endl;
  }

  return 0;
}


Measured memory_bytes: 3492
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

struct FenwickTree {
	typedef int T;
	vector<T> v;
	void init(int n) { v.assign(n, T()); }
	void add(int i, T x) {
		for(; i < (int)v.size(); i |= i + 1) v[i] += x;
	}
	T sum(int i) const {	//[0, i)
		T r = T();
		for(-- i; i >= 0; i = (i & (i + 1)) - 1) r += v[i];
		return r;
	}
	T sum(int left, int right) const {	//[left, right)
		return sum(right) - sum(left);
	}
};


int main() {
	string S;
	while(cin >> S) {
		int n = S.size();
		int cnt[26] = {};
		rep(i, n) ++ cnt[S[i] - 'a'];
		bool ok = true;
		rep(a, 26) ok &= cnt[a] % 2 == 0;
		if(!ok) {
			puts("-1");
			continue;
		}

		const int A = 26;
		vector<vi> indices(A);
		rep(i, n)
			indices[S[i] - 'a'].push_back(i);
		vector<pii> intervals(A);
		rep(a, A)
			intervals[a] = { 0, (int)indices[a].size() };
		ll ans = 0;
		FenwickTree ft;
		ft.init(n + 1);
		rep(k, n / 2) {
			int minCost = INF;
			int minA = -1, minL = -1, minR = -1;
			rep(a, A) {
				pii p = intervals[a];
				if(p.first == p.second) continue;
				int L = indices[a][p.first];
				int R = indices[a][p.second - 1];
				int l = L + ft.sum(L + 1);
				int r = R + ft.sum(R + 1);
				int cost = (l - k) + ((n - 1 - k) - r);
				if(minCost > cost) {
					minCost = cost;
					minA = a;
					minL = L;
					minR = R;
				}
			}
			ans += minCost;
			++ intervals[minA].first;
			-- intervals[minA].second;
			ft.add(0, +1);
			ft.add(minL, -1);
			ft.add(minR + 1, -1);
			ft.add(n, +1);
		}
		
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 7080
#include<cstdio>
#include<climits>
#include<algorithm>
using namespace std;
int n,k,ans;
int f[36][2];
int main()
{
	scanf("%d%d",&n,&k);
	k/=100;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&f[i][0],&f[i][1]);
		f[i][1]/=100;
	}
	ans=INT_MAX;
	for(int i=0;i<1<<n;i++)
	{
		int sum=0,ml=0,l=0;
		for(int j=1;j<=n;j++)
			if(i>>(j-1)&1)
				sum+=f[j][0]*j+f[j][1],ml+=f[j][0];
			else
				l=j;
		if(sum<k)
		{
			if(f[l][0]*l+sum<=k)
				continue;
			ml+=(k-sum)%l==0?(k-sum)/l:(k-sum)/l+1;
		}
		ans=min(ml,ans);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
s = input()
s_rev = s[::-1]
while s_rev[0:1]:
    if s_rev.startswith("maerd"):
        s_rev = s_rev[5::1]
    elif s_rev.startswith("remaerd"):
        s_rev = s_rev[7::1]
    elif s_rev.startswith("esare"):
        s_rev = s_rev[5::1]
    elif s_rev.startswith("resare"):
        s_rev = s_rev[6::1]
    else:
        print("NO")
        break
if bool(s_rev[0:1]) == False:
    print("YES")


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

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


using namespace std;


int32_t main()
{
    IOS;

    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        string s; cin>>s;
        if(s =="BBB" or s =="AAA") cout<<"No";
        else cout<<"Yes";
        


		
		cout<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
//ProblemA.cpp

#include <iostream>

static std::istream & ip = std::cin;
static std::ostream & op = std::cout;

#if OJ_MYPC
#include <ojio.h>
#endif

#ifndef OPENOJIO
#define OPENOJIO
#endif

#if 1 || DEFINE
/***************************************************************/
typedef unsigned long long u64;
typedef long long s64;

typedef unsigned uint;

#define ABS(x) ((x) > 0 ? (x) : -(x))

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define MIN3(x, y, z) MIN(x, MIN(y, z))
#define MAX3(x, y, z) MAX(x, MAX(y, z))

#define FillZero(arr) memset(arr, 0, sizeof(arr));

/***************************************************************/
#endif //1 || DEFINE

#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>

//001
//op << setfill('0') << setw(3) << setiosflags(ios::right) << 1;

//op << fixed << setprecision(20);

using namespace std;

//ProblemA.cpp

int main(int argc, char* argv[])
{
	OPENOJIO;

	string s;
	ip >> s;

	int cc[4];
	memset(cc, 0, sizeof(cc));
	for (auto c : s) {
		switch (c)
		{
		case 'N':
			++cc[0];
			break;
		case 'S':
			++cc[1];
			break;
		case 'W':
			++cc[2];
			break;
		case 'E':
			++cc[3];
			break;
		default:
			break;
		}
	}

	bool rst = true;
	if (cc[0] == 0 && cc[1] != 0) rst = false;
	if (cc[1] == 0 && cc[0] != 0) rst = false;
	if (cc[2] == 0 && cc[3] != 0) rst = false;
	if (cc[3] == 0 && cc[2] != 0) rst = false;

	op << (rst ? "Yes" : "No") << endl;

	return 0;
}
/***************************************************************/


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

int main()
{
  int N, K;
  cin >> N >> K;
  int D[10];
  for (int i = 0; i < K; i++) {
    cin >> D[i];
  }
  int n = N;
  while (1) {
    int a[5];
    int nc = n;
    bool flag = true;
    for(int i = 0; i < 5; i++) {
      a[i] = nc % 10;
      nc -= a[i];
      nc /= 10;
    }
    
    int J;
    if (a[4] == 0) {
      J = 4;
      if (a[3] == 0) {
        J = 3;
        if(a[2] == 0) {
          J = 2;
          if (a[1] == 0)
            J = 1;
        }
      }
    }
    else J = 5;
    
    for (int i = 0; i < K; i++) {
      for (int j = 0; j < J; j++) {
        if (D[i] == a[j])
          flag = false;
      }
    }
    if (flag) {
      cout << n << endl;
      break;
    } else {
      n++;
    }
  } 
  return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Double radius = Double.parseDouble(br.readLine());
		Double diameter = radius * 2;
		Double area = radius*radius*Math.PI;
		Double circumference = diameter * Math.PI;
		System.out.println(String.format("%.6f", area) + " " + String.format("%.6f", circumference));
	}
}

Measured memory_bytes: 16920
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[310];

double dp[301][301][301];

double calc(int one, int two, int three) {
    if (one == 0 && two == 0 && three == 0) return 0;
    if (dp[one][two][three] < 0) {
        int zero = n - one - two - three;
        double pzero = (double)zero/n;
        double pone = (double)one/n;
        double ptwo = (double)two/n;
        double pthree = (double)three/n;
        dp[one][two][three] = 1;
        if (one > 0) dp[one][two][three] += pone * calc(one-1, two, three);
        if (two > 0) dp[one][two][three] += ptwo * calc(one+1, two-1, three);
        if (three > 0) dp[one][two][three] += pthree * calc(one, two+1, three-1);
        dp[one][two][three] *= 1.0 / (1 - pzero);
    }
    return dp[one][two][three];
}

double solve() {
    for (int i = 0; i < 301; i++)
        for (int j = 0; j < 301; j++)
            fill_n(dp[i][j], 301, -1);

    int num[3] = {0, 0, 0};
    for (int i = 0; i < n; i++) {
        num[a[i]-1]++;
    }
    return calc(num[0], num[1], num[2]);
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


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

main() {
  string s;
  cin >> s;
  bool nine = true;
  for (int i = 1; i < s.size(); i++)
    if (s[i] != '9') nine = false;
  cout << s[0] - '0' + 9 * (s.size() - 1) + (nine ? 0 : -1) << endl;
}


Measured memory_bytes: 256
#include <set>
#define M 1000001
using namespace std;

int a[M];
int main(){
  set<int> s;
  int t,u;
  s.insert(1);
  s.insert(2);
  s.insert(3);
  s.insert(5);
  set<int>::iterator ite=s.begin();
  while((t=*ite)<M){
    if(t*2>t)s.insert(t*2);
    if(t*3>t)s.insert(t*3);
    if(t*5>t)s.insert(t*5);
    ite++;
  }
  for(ite=s.begin();*ite<M;ite++)a[*ite]=1;
  for(t=0;t<M;t++)a[t]+=a[t-1];
  for(;scanf("%d",&t),t;printf("%d\n",a[u]-a[t-1]))
    scanf("%d",&u);
  return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
int main() {
	string x;
	cin >> x;
	int n = x.size(), i;
	int cnts = 0, cntt = 0;
	for (i = 0; i < n; i++) {
		if (cnts == 0) {
			if (x[i] == 'S') {
				cnts++;
			}
			else {
				cntt++;
			}
		}
		else {
			if (x[i] == 'T') {
				cnts--;
			}
			else {
				cnts++;
			}
		}
	}
	cout << cnts + cntt << endl;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static int[] cin = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
    static int[] l = new int[cin[0]];
    static int ans = Int16.MaxValue;

    static void Main(string[] args)
    {
        for (int i = 0; i < cin[0]; i++)
            l[i] = int.Parse(Console.ReadLine());

        Dfs(0, 0, 0, 0, 0);
        Console.WriteLine(ans);
    }

    static void Dfs(int n, int a, int b, int c, int t)
    {
        if (cin[0] < n) return;
        else ans = Math.Min(ans, Point(a, b, c, t));
        Dfs(n + 1, a, b, c, t);
        if (n < cin[0])
        {
            Dfs(n + 1, a + l[n], b, c, t + 1);
            Dfs(n + 1, a, b + l[n], c, t + 1);
            Dfs(n + 1, a, b, c + l[n], t + 1);
        }
        return;
    }

    static int Point(int a, int b, int c, int t)
    {
        int p = Int16.MaxValue;
        if (a > 0 && b > 0 && c > 0)
            p = Math.Abs(a - cin[1]) + Math.Abs(b - cin[2]) + Math.Abs(c - cin[3]) + (t - 3) * 10;
        return p;
    }
}

Measured memory_bytes: 13396
io = STDIN
n=io.gets.to_i
aa=io.gets.split.map(&:to_i)
sum=aa.inject(:+)
x,y=aa[0],sum-aa[0]
min=Float::INFINITY
if aa.size==2
  min=  x>y ? x-y : y-x
else
  (1...(aa.size-1)).each do |i|
    x+=aa[i]
    y-=aa[i]
    min=[min,  x>y ? x-y : y-x  ].min
  end
end
puts min


Measured memory_bytes: 19204
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    string S, T;
    int A, B;
    cin >> S >> T >> A >> B;
    string X;
    cin >> X;
    if (X == S) A--;
    else B--;
    cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
a,b,c,x,y=map(int,input().split())
ans1=x*a+y*b #aとbだけ
d=0
if x>y : d=a
else : d=b 
ans2=min(x,y)*c*2+(max(x,y)-min(x,y))*d #xとyの最小
ans3=max(x,y)*2*c
print(min(ans1,ans2,ans3))


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    ll maxi = 0;
    rep(i, N) {
        cin >> A[i];
        maxi = max(maxi, A[i]);
    }
    ll l = 1, r = maxi;
    do {
        ll key = (l + r) / 2;
        ll temp = 0;
        iter(i, A) temp += i / key + !!(i % key) - 1;
        if(temp <= K) r = key - 1;
        else l = key + 1;
    } while(l <= r);
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 4776
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = int64_t;
using ull = uint64_t;
 
template <typename T> vector<T> make_vec_nd(T init, size_t size) {
  return vector<T>(size, init);
}
template <typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
  auto inner = make_vec_nd(init, rest...);
  return vector<decltype(inner)>(size, inner);
}
 
struct Mod {
	static ll BASE;
	ll value = 0;
	static ll residue(ll value) { return (value % BASE + BASE) % BASE; }
	Mod(ll value)
	: value(residue(value)) {}
	Mod operator+(const Mod& rhs) const { return Mod(value + rhs.value); }
	void operator+=(const Mod& rhs) { *this = *this + rhs; }
	Mod operator-(const Mod& rhs) const { return Mod(value - rhs.value); }
	void operator-=(const Mod& rhs) { *this = *this - rhs; }
	Mod operator*(const Mod& rhs) const { return Mod(value * rhs.value); }
	void operator*=(const Mod& rhs) { *this = *this * rhs; }
};
ll Mod::BASE = 1000000007;
 
int main() {
	string K;
	cin >> K;
	vector<ll> Ki;
	for (ll i = 0; i < K.size(); i++) {
		Ki.push_back(K[i] - '0');
	}
	ll D;
	cin >> D;
	auto dig_sum = make_vec_nd((ll)0, K.size() + 1);
	for (ll i = 1; i <= K.size(); i++) {
		dig_sum[i] = (dig_sum[i-1] + Ki[i-1]) % D;
	}
	auto dp = make_vec_nd((Mod)0, K.size() + 1, D);
	for (ll i = 1; i <= K.size(); i++) {
		for (ll d = 0; d < D; d++) {
			for (ll n = 0; n < 10; n++) {
				if ((dig_sum[i-1] + n) % D == d && n < Ki[i-1]) {
					dp[i][d] += 1;
				}
				dp[i][d] += dp[i-1][((d - n) % D + D) % D];
			}
		}
	}
	Mod ans = dp[K.size()][0];
	if (dig_sum[K.size()] == 0) {
		ans += 1;
	}
	ans -= 1;
	cout << ans.value << endl;
}


Measured memory_bytes: 8576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class _C
{
	void _()
	{

		var N = _Ns()[0];

		long ans = 0;
		long A = _Ns()[0];
		for (int i = 1; i<N; i++)
		{
			long AA = _Ns()[0];

			ans += A / 2;

			if (A % 2 == 1)
			{
				if (AA >= 1)
				{
					ans += 1;
					A = AA - 1;
				}
				else
					A = AA;
			}
			else
				A = AA;

		}
		ans += A / 2;
		Console.WriteLine(ans);

	}

	static void Main(string[] args)
  {
    new _C()._();
  }

  #region

  string _S()
  {
    return Console.ReadLine();
  }

  string[] _Ss()
  {
    return Console.ReadLine().Split();
  }

  int[] _N(int n)
  {
    var x = new int[n];
    for (var i = 0; i < n; i++)
    {
      x[i] = int.Parse(Console.ReadLine());
    }
    return x;
  }

  int[] _Ns()
  {
    var ss = Console.ReadLine().Split();

    var x = new int[ss.Length];
    for (var i = 0; i < ss.Length; i++)
      x[i] = int.Parse(ss[i]);

    return x;
  }
  #endregion
}


Measured memory_bytes: 6744
public class Main {
	public static void main(String[] args) {
		var sc = new java.util.Scanner(System.in);
		var s = sc.next();
		var max = 0;
		var cnt = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'R') {
				cnt++;
			} else {
				cnt = 0;
			}
			max = Math.max(cnt, max);
		}
		System.out.println(max);

	}
}


Measured memory_bytes: 35624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<complex>//real().imag().
#include<cctype>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<string>
#include<utility>
#include<iterator>
#define pii pair<int,int>
#define make_pair mp
using namespace std;
typedef long long ll;
int main()
{
    // freopen("D:\\in.txt","r",stdin);
    // freopen("D:\\out.txt","w",stdout);
    //ios::sync_with_stdio(false);
    //system("pause");
    string s;
    char c;
    int f=0;
    getline(cin,s);
    for(char b:s)
    {
        if(f==1)
        {
            c=b;
            break;
        }
        if(b==' ')
        {
            f=1;
        }
    }
    cout<<"A"<<c<<"C"<<endl;
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
const int mod=1e9+7;
using namespace std;
#define ll long long
const int maxn=1e5+10;
int s[maxn];
int vis[maxn];
ll sum[maxn];
int main()
{
    int n;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>s[i];
        vis[s[i]]++;
    }
    ll ans=0;
    int minn=0;
    int cnt;
    for(int i=1; i<maxn; i++)
    {
        if(vis[i]) ans++;
        if(vis[i]>1)
        {
            cnt=vis[i]-1;
            if(minn==0)
            {
                minn+=cnt;
            }
            else if(cnt>=minn)
            {
                cnt-=minn;
                minn=cnt;
            }
            else
            {
                minn-=cnt;
            }
        }
    }
    if(minn!=0)
    {
        if(minn%2!=0){
            ans-=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n,m;
int a[125252];

int calc(int i, int j){
  return (abs(a[j]-i) + abs(a[i]-j)) - (abs(a[i]-i) + abs(a[j]-j));
}

int main(){
  scanf("%d%d",&n,&m);
  REP(i,n)scanf("%d",a+i);
  ll ans = 0;
  REP(i,n)ans += abs(a[i]-i);
  set<pii> S[5];
  REP(i,n){
    if(a[i]<=i){
      S[1].insert(pii(a[i],i));
      S[2].insert(pii(i,a[i]));
    }else{
      S[3].insert(pii(i,a[i]));
      S[4].insert(pii(a[i],i));
    }
  }
  while(m--){
    pii sp = pii(-1,-1);
    int mxgain = -1;
    FOR(i,1,4+1)if(S[i].size()){
      pii P;
      int id;
      if(i==1){
        P = *S[i].rbegin();
        id = P.second;
      }else if(i==2){
        P = *S[i].begin();
        id = P.first;
      }else if(i==3){
        P = *S[i].rbegin();
        id = P.first;
      }else{
        P = *S[i].begin();
        id = P.second;
      }
      S[i].erase(P);
      FOR(j,1,4+1)if(S[j].size()){
        int id2;
        if(j==1)id2 = S[j].rbegin()->second;
        else if(j==2)id2 = S[j].begin()->first;
        else if(j==3)id2 = S[j].rbegin()->first;
        else if(j==4)id2 = S[j].begin()->second;
        int g = calc(id,id2);
        if(g > mxgain){
          mxgain = g;
          sp = pii(id,id2);
        }
      }
      S[i].insert(P);
    }
    if(mxgain == -1)break;
    ans += mxgain;
    {
      int i = sp.first;
      if(a[i]<=i){
        S[1].erase(pii(a[i],i));
        S[2].erase(pii(i,a[i]));
      }else{
        S[3].erase(pii(i,a[i]));
        S[4].erase(pii(a[i],i));
      }
      i = sp.second;
      if(a[i]<=i){
        S[1].erase(pii(a[i],i));
        S[2].erase(pii(i,a[i]));
      }else{
        S[3].erase(pii(i,a[i]));
        S[4].erase(pii(a[i],i));
      }
    }
    swap(a[sp.first],a[sp.second]);
    {
      int i = sp.first;
      if(a[i]<=i){
        S[1].insert(pii(a[i],i));
        S[2].insert(pii(i,a[i]));
      }else{
        S[3].insert(pii(i,a[i]));
        S[4].insert(pii(a[i],i));
      }
      i = sp.second;
      if(a[i]<=i){
        S[1].insert(pii(a[i],i));
        S[2].insert(pii(i,a[i]));
      }else{
        S[3].insert(pii(i,a[i]));
        S[4].insert(pii(a[i],i));
      }
    }
  }
  printf("%lld\n",ans);
  return 0;
}



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

int main(){
    int k,a,b;
    int i,flag=0;
    cin >> k >> a >> b;

    for(i=a;i<=b;i++){
        if(i%k==0){
            flag = 1;
            break;
        }
    }


    if(flag==1){
        cout << "OK";
    }else{
        cout << "NG";
    }

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[]) {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ans=min(b,d)-max(a,c);
  if(ans<0) ans=0;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
/*
*
* author: ian macleod
*
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef vector<long long int> vll;

#define IO                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
 
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b) for(ll i=a;i>=b;i--)

ll power(ll x, ll y) {
    ll res = 1;     // Initialize result
    x = x ;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0) {
        if (y & 1)
            res = (res*x);
        y = y>>1; // y = y/2
        x = (x*x);  // Change x to x^2
    }
    return res;
}


void solve() {
    
    ll a, b;
    double h, m, c = 0.000000;
    double t;
    cin >> a >> b >> h >> m;
    double x1 = h*30+m*.5; 
    double x2 = m*6;
    
    t = fabs(x1-x2);
    
    if (t > 180) {
        t = 360 - t;
    }
    c = sqrt( a*a + b*b - 2*a*b*cos(t*acos(-1)/180));
   
    printf("%.20lf\n",c);
    return ;
}



int main() {
    solve();
}



Measured memory_bytes: 4188
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    set<int >s;
    int L,R,d;
    cin>>L>>R>>d;
    if(R%d==0 and L%d==0){
        cout<<(R/d)-(L/d)+1;
    }
    else
    cout<<(R/d)-(L/d);
}

Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	a, b := nextInt(), nextInt()

	res := a - 1
	if a <= b {
		res++
	}
	fmt.Println(res)
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

typedef long long ll;


int main(){
  int N,x;
  cin >> N >> x;
  if(x==1||x==N*2-1){cout << "No\n"; return 0;}
  else cout << "Yes\n";
  //NとN+1番目にx!=2*N-2  x+1 x x-1 x+2 x==2*n-2 x-1 x x+1 x-2

  if(x!=2*N-2){
    int j=1;
    rep(i,2*N-1){
      if(i==N-2){cout << x+1 << "\n";}
      else if(i==N-1){cout << x << "\n";}
      else if(i==N){cout << x-1 << "\n";}
      else if(i==N+1){cout << x+2 << "\n";}
      else if(j==x-1){j=x+3;cout << j << "\n"; j++;}
      else {cout << j << "\n"; j++;}
    }
  }
  if(x==2*N-2){
    int j=1;
    rep(i,2*N-1){
      if(i==N-2){cout << x-1 << "\n";}
      else if(i==N-1){cout << x << "\n";}
      else if(i==N){cout << x+1 << "\n";}
      else if(i==N+1){cout << x-2 << "\n";}
      else if(j==x-2){j=x+2;cout << j << "\n"; j++;}
      else {cout << j << "\n"; j++;}
    }
  }
  

  return 0;
}


Measured memory_bytes: 1536
import itertools

N, M = map(int, input().split())
ab=[]
for _ in range(M):
    ab.append(tuple(map(int, input().split())))

lst=[[] for _ in range(N+1)]
for el in ab:
    lst[el[0]].append(el[1])
    lst[el[1]].append(el[0])
#print(lst)

count=0
for permu in itertools.permutations(range(1,N+1)):
    if permu[0] == 1:
        for i in range(0,N-1):
            if permu[i+1] in lst[permu[i]]:
                pass
            else:
                break
        else:
            count+=1
            #print(permu)
print(count)



Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++)

int main() {
	int n;
	cin >> n;
	if (n <= 999)cout << "ABC";
	else cout << "ABD";
	return(0);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int ans = 0;
        for (int i = 1; i <= n / 2; i++) {
            if (n - i != i) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
//
// UVA 1627
// 思路：
// 每一个人都可以讲所有人分为两组，认识的和不认识的。
// 认识的可能不在一个组中，但不认识的必然不在一组中。
//
// 所以第一步，如果可以生成二分图，则统计每部分的数量，求差。
// 利用差，转换为 0 1 背包问题，进行计算。
//
// 类似的问题可以看一下 Uva 323（更难）
//
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxx = 200005;


int main() {
    //freopen("../input.txt", "r", stdin);
    //freopen("../output.txt", "w", stdout);
    int n, q, f, l;
    int ns[maxx];
    int as[maxx];
    while (cin >> n >> q) {

        vector<int> e[maxx];
        memset(ns, 0, sizeof(ns));
        memset(as, 0, sizeof(as));
        for (int i = 0; i < n - 1; ++i) {
            cin >> f >> l;
            e[f - 1].push_back(l - 1);
            e[l - 1].push_back(f - 1);
        }
        for (int i = 0; i < q; ++i) {
            cin >> f >> l;
            ns[f - 1] += l;
        }
        queue<int> qq;
        qq.push(0);
        while (!qq.empty()) {
            int x = qq.front();
            qq.pop();
            as[x] = 1;
            for (int i = 0; i < e[x].size(); ++i) {
                if (!as[e[x][i]]) {
                    ns[e[x][i]] += ns[x];
                    qq.push(e[x][i]);
                }
            }
        }
        cout << ns[0];
        for (int i = 1; i < n; ++i) {
            cout << " " << ns[i];
        }
        cout << endl;

    }


    return 0;
}


Measured memory_bytes: 16372
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main()
    {
        int[] NK = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int N = NK[0];
        int K = NK[1];
        Console.ReadLine();
        Console.WriteLine((N - 1) % (K - 1) == 0 ? (N - 1) / (K - 1) : (N - 1) / (K - 1) + 1);
    }
}

Measured memory_bytes: 15328
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
const int Max = 3e5 + 5;
const int Mod = 1e9 + 7;

double a[Max];

double f(ll x)
{
	return (double)(x + 1) / 2;
}

int main()
{
	GO;
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		ll x;
		cin >> x;
		a[i] = a[i - 1] + f(x);
	}
	double ans = 0;
	for (int i = k; i <= n; i++)
		ans = max(ans, a[i] - a[i - k]);
	cout << setprecision(10) << fixed << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << endl;

}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL //デバッグ出力系
#define dout(s) cout<<s<<"\n";
#define debug() if(true)
#else
#define dout(s)
#define debug() if(false)
#endif//
#define next asdnext
#define prev asdprev
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define vout(v) for(auto &i:v){cout<<i<<" ";}cout<<"\n"; //配列出力
#define vin(v) for(auto &i:v)cin>>i; //配列入力
#define vec(v,n) vector<int> v(n);
typedef long long ll;
typedef unsigned long long ull;

struct KOZO {
public:
	int B;
	int C;
};

bool hikaku(const KOZO& kozo1, const KOZO& kozo2) {
	return (kozo1.C>kozo2.C);
}

void Main() {
	int N, M;
	cin >> N >> M;

	vec(A, N);

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

	vector<KOZO> kozo(M);

	rep(i,M) {
		cin >> kozo[i].B >> kozo[i].C;
	}
	sort(all(A));
	sort(kozo.begin(), kozo.end(), hikaku);

	int index=0;
	bool end=false;

	for (int i = 0; i < M; i++) {
		for (int j = 0; j < kozo[i].B; j++) {
			if ((index == N) ||(kozo[i].C < A[index])) {
				dout("here" + to_string(index));
				end = true;
				break;
			}
			A[index] = kozo[i].C;
			index++;
		}
	}
	debug() {
		rep(i, M)
			cout << "\n" << kozo[i].B << "\t" << kozo[i].C;
		cout << "\n";
	}
	debug() {
		rep(i,N)
			cout << "\n" << A[i];
		cout << "\n";
	}

	ll sum = 0;
	for (auto&i:A) {
		sum += i;
	}

	cout << sum << "\n";
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 1408
n = int(input())
x = list(int(i) for i in input().split())
a = []
b = []
for i in range(0, n):
    if i % 2 == 0:
        a.append(x[i])
    else:
        b.append(x[i])
cnta = [0] * (100002 + 1)
cntb = [0] * (100002 + 1)
vala = 0
vala1 = 0
maxCnta = 0
maxCnta1 = 0
for i in a:
    cnta[i] += 1

for i in a:
    if maxCnta < cnta[i]:
        vala = i
        maxCnta = cnta[i]
for i in a:
    if maxCnta1 < cnta[i] and vala != i:
        maxCnta1 = cnta[i]
        vala1 = i
#---------------------------
valb = 0
valb1 = 0
maxCntb = 0
maxCntb1 = 0
for i in b:
    cntb[i] += 1

for i in b:
    if maxCntb < cntb[i]:
        valb = i
        maxCntb = cntb[i]

for i in b:
    if maxCntb1 < cntb[i] and valb != i:
        maxCntb1 = cntb[i]
        valb1 = i

if valb != vala:
    res = 0
    for i in a:
        if i != vala:
            res += 1
    for i in b:
        if i != valb:
            res += 1
    print(res)
else:
    resa = 0
    resb = 0
    resa1 = 0
    resb1 = 0
    for i in a:
        if i != vala:
            resa += 1
        if i != vala1:
            resa1 += 1
    for i in b:
        if i != valb:
            resb += 1
        if i != valb1:
            resb1 += 1
    print(min(resa + resb1, resa1 + resb))

#print(a, b, vala, valb)

Measured memory_bytes: 13984
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

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

  int c = -1, f = -1;
  for (int i = 0; i < s.size(); i++) {
    if (c < 0) {
      if (s[i] == 'C') c = i;
    } else {
      if (s[i] == 'F') {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iterator>
using namespace std ;
long long int power(long long int x,long long int y) ;
long long int power(long long int x,long long int y)
{ if(y==0)
   return 1 ;
   long long int z=power(x,y/2) ;
   if(y%2==0)
   return z*z ;
   else return x*z*z ; }


int main()
 { long long int t,n,m,count,i,j,x,a,b,sum,bal,e,o,y,k,z,temp,q,c,d,x1,x2,y1,y2 ;
    cin>>n>>x ;
    long long int arr[n] ;
    sum=0 ;
    for(i=0;i<n;i++)
      { cin>>arr[i] ;
        sum+=arr[i] ;

      } sort(arr,arr+n) ;
       z=sum/(4*x) ;
       if(sum%(4*x)!=0)
        z++ ;
       for(i=n-1;i>=0;i--)
       { if(arr[i]>=z)
          x-- ;
          else break ;


       } if(x>0)
          cout<<"No" ;
          else cout<<"Yes" ;
          return 0 ; }


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextLong();
  int M = nextLong();
  ll K = nextLong();
  vector<ll> A(N+1), B(M+1);
  REP(i, N) A[i+1] = nextLong();
  REP(i, M) B[i+1] = nextLong();

  // pv(ALL(A));
  for (int i = 1; i <= N; i++) A[i] += A[i-1];
  for (int i = 1; i <= M; i++) B[i] += B[i-1];
  // pv(ALL(A));

  int ans = 0;
  for (int a = 0; a <= N; a++) {
    ll R = K - A[a];
    if (R < 0) continue;
    int b = distance(B.begin(), upper_bound(ALL(B), R)) - 1;
    // cout << a << " " << b << endl;
    chmax(ans, a + b);
  }

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

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

#define ll unsigned long long

const ll mod = 1'000'000'007;

ll my_pow(ll base, ll exp) {
    if(exp == 0) return 1;
    if(exp % 2 == 1) return (base * my_pow(base, exp - 1)) % mod;
    ll tmp = my_pow(base, exp / 2);
    return (tmp * tmp) % mod;
}

int main() {
    std::ios::sync_with_stdio(false);
    using namespace std;
    ll n, k;
    cin >> n >> k;
    vector<ll> A(n + 1);
    A[0] = my_pow(10, 100);
    for(int i = 0; i < n; i++)
        A[i + 1] = (A[i] + 1) % mod;
    sort(A.begin(), A.end());
    /*
    for(int i = 0; i < n + 1; i++)
        cout << A[i] << " ";
    cout << "\n";
    */
    vector<ll> pre(n + 3, 0),
               suf(n + 3, 0);
    for(int i = 0; i < n + 1; i++)
        pre[i + 1] = (pre[i] + A[i]) % mod;
    reverse(A.begin(), A.end());
    for(int i = 0; i < n + 1; i++)
        suf[i + 1] = (suf[i] + A[i]) % mod;
    /*
    for(int i = 0; i < n + 3; i++)
        cout << pre[i] << " " << suf[i] << "\n";
    cout << "\n\n";
    */
    ll result = 0;
    for(int m = k; m < n + 2; m++) {
        ll mmin = pre[m];
        ll mmax = suf[m];
        //cout << mmin << " " << mmax << "\n";
        result = (result + mmax + mod - mmin + 1) % mod;
    }
    cout << result << "\n";
    return 0;
}


Measured memory_bytes: 7948
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
typedef long long ll ;

int main(){
    int N,a=0,i=0;
    cin>>N;
    while(a<N){
        i++;
        a+=i;
    }
    while(N>0){
        if(N>=i){
            N-=i;
            cout<<i<<endl;
        }
        i--;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
point = [0] * n
for i in range(n * (n - 1) // 2):
    A, B, X, Y = map(int, input().split())
    if X > Y:
        point[A - 1] += 3
    elif Y > X:
        point[B - 1] += 3
    else:
        point[A - 1] += 1
        point[B - 1] += 1

point_sorted = sorted(point, reverse=True)

for i in range(n):
    print(point_sorted.index(point[i]) + 1)



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

int linearsearch(int *S, int n, int *T, int q){
  int count = 0;
  for(int j = 0; j < q; ++j){
    for(int i = 0; i < n; ++i){
      if(T[j] == S[i]){
        ++count;
        break;
      }
    }
  }
  return count;
}

int main(){
  int n, q;
  scanf("%d", &n);
  int S[n];
  for(int i = 0; i < n; ++i){
    scanf("%d", &S[i]);

  }
  scanf("%d", &q);
  int T[q];
  for(int i = 0; i < q; ++i){
    scanf("%d", &T[i]);
  }
  printf("%d\n", linearsearch(S, n, T, q));
  return 0;
}



Measured memory_bytes: 2044
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s;
    cin>>s; // 文字列を1行入力
    int ans=0;
    for(int i=0;i<4;i++){
        if(s[i]=='+')ans++; // s の i 文字目が '+' なら ans を 1 増やす
        else ans--;  // そうでなければ 1 減らす
    }
    cout<<ans;
}

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

cnt = 0
flag = False
while True:
    for a in arr:
        if a == 0 or a == 1 or a % 2 == 1:
            flag = True
            break

    if flag:
        break

    arr = [a // 2 for a in arr]
    cnt += 1

print(cnt)


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
  //c_p_c();
  char x;
  cin >> x;
  if(x >= 'A' and x <= 'Z')
  {
    cout<<'A'<<endl;
  }
  else
  {
    cout<<'a'<<endl;
  }
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<ll>> matrix;
const int MOD = 1000000007;

ll modpow(ll b, ll e, ll m) {
  ll r = 1;
  while(e) {
    if(e%2) {
      r*=b;
      r%=m;
    }
    b*=b;
    b%=m;
    e/=2;
  }
  return r;
}

pii l[3005];
ll fact[200005];
ll invfact[200005];

ll choose(int n, int k) {
  ll r = fact[n];
  r *= invfact[k];
  r %= MOD;
  r *= invfact[n-k];
  r %= MOD;
  return r;
}

int n, r, c;
ll dp[3005][2];

void solve() {
  cin >> r >> c >> n;
  fact[0] = 1;
  for(int i = 1; i <= r+c; i++) {
    fact[i] = (fact[i-1] * i) % MOD;
  }
  invfact[r+c] = modpow(fact[r+c], MOD-2, MOD);
  for(int i = r+c-1; i >= 0; i--) {
    invfact[i] = (invfact[i+1]) * (i+1);
    invfact[i] %= MOD;
  }
  for(int i = 0; i < n; i++) {
    cin >> l[i].first >> l[i].second;
  }
  l[n++] = {1, 1};
  l[n++] = {r, c};
  sort(l, l+n);
  dp[0][0] = 1;
  for(int i = 1; i < n; i++) {
    for(int j = 0; j < i; j++) {
      if(l[j].second > l[i].second) continue;
      dp[i][1] += dp[j][0] * choose(l[i].first - l[j].first + l[i].second - l[j].second, l[i].first - l[j].first);
      dp[i][1] %= MOD;
      dp[i][0] += dp[j][1] * choose(l[i].first - l[j].first + l[i].second - l[j].second, l[i].first - l[j].first);
      dp[i][0] %= MOD;
    }
  }
  ll ret = dp[n-1][1] - dp[n-1][0];
  ret %= MOD;
  ret += MOD;
  ret %= MOD;
  cout << ret << endl;
}

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


Measured memory_bytes: 3456