akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }

int main(){
    int A, B, M;
    cin >> A >> B >> M;
    lint a[A], b[B];
    lint min_a = 1e9, min_b = 1e9;
    for(int i = 0; i < A; i++){
        cin >> a[i];
        min_a = min(min_a, a[i]);
    }
    for(int i = 0; i < B; i++){
        cin >> b[i];
        min_b = min(min_b, b[i]);
    }
    lint ans = min_a + min_b;
    for(int i = 0; i < M; i++){
        int x, y;
        lint c;
        cin >> x >> y >> c;
        x--, y--;
        ans = min(ans, a[x] + b[y] - c);
    }
    cout << ans << endl;
}



Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>

unsigned long if_even(unsigned long a, unsigned long b) {
	if((b - a) % 2 == 0) {
		return 1;
	} else {
		return 0;
	}
}

unsigned long which_small (unsigned long x, unsigned long y){
	if(x <= y) {
		return x;
	} else {
		return y;
	}
}

int main(void) {
	unsigned long N, A, B;
	unsigned long turns;

	scanf("%ld %ld %ld", &N, &A, &B);
	if(1 == if_even(A, B)) {
		turns = (B - A) / 2;
	} else {
		turns = which_small(A - 1, N - B) + 1 + ((B - A - 1) / 2);
	}
	printf("%ld\n", turns);
	return 0;
}


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

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int res = min(a, k) - max(0, min(k - a - b, c));
    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using ld=long double;
const ld EPS=1e-7;

signed main(){
  int n;cin>>n;
  vector<int> x(n),y(n);
  for(int i=0;i<n;i++)cin>>x[i]>>y[i];
  ld ans=1e9;
  for(int i=0;i<n;i++){
    for(int j=0;j<i;j++){
      ld a=x[i],b=y[i],c=x[j],d=y[j];
      ld px=a+c,py=b+d;px/=2;py/=2;
      ld r=(px-a)*(px-a)+(py-b)*(py-b);
      if(r>ans)continue;
      bool ok=1;
      for(int s=0;s<n;s++)if((px-x[s])*(px-x[s])+(py-y[s])*(py-y[s])>r+EPS)ok=0;
      if(ok)ans=r;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<i;j++){
      for(int k=0;k<j;k++){
        ld a=x[i],b=y[i],c=x[j],d=y[j],e=x[k],f=y[k];
        ld py=(e-a)*(a*a+b*b-c*c-d*d)-(c-a)*(a*a+b*b-e*e-f*f);
        if(abs(2*(e-a)*(b-d)-2*(c-a)*(b-f))>EPS)py/=2*(e-a)*(b-d)-2*(c-a)*(b-f);
        else continue;
        ld px;
        if(abs(a-c)<EPS){
          px=2*(b-f)*py-a*a-b*b+e*e+f*f;
          if(abs(e-a)>EPS)px/=2*(e-a);
          else continue;
        }
        else{
          px=2*(b-d)*py-a*a-b*b+c*c+d*d;
          px/=2*(c-a);
        }
        ld r=(px-a)*(px-a)+(py-b)*(py-b);
        if(r>ans)continue;
        bool ok=1;
        for(int s=0;s<n;s++)if((px-x[s])*(px-x[s])+(py-y[s])*(py-y[s])>r+EPS)ok=0;
        if(ok)ans=r;
      }
    }
  }
  cout<<fixed<<setprecision(12)<<sqrt(ans)<<endl;
}


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;
    return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  string a[n],b[n];
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n){
    cin>>b[i];
  }
  int ans=0;
  rep(i,n){
    rep(j,m){
      if(a[i][j]!=b[i][j]) ans++;
    }
  }
  cout<<ans<<endl;

  return 0;
}



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

typedef long long ll;
typedef vector <bool> v_bool;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll N,M,P;
vector <vector <ll> > E;
vector <ll> A;
vector <ll> F;
vector <ll> B;
int main(){
  ll INF = 1000000000000000000;
  cin >> N >> M >> P;
  A.assign(N+10,INF);
  B.assign(N+10,0);
  F.assign(N+10,1);
  E.assign(M+10,v_ll(3,0));
  for (ll i=1;i<=M;i++){
    ll x,y,z;
    cin >> x >> y >> z;
    E[i][0]=x;
    E[i][1]=y;
    E[i][2]=P-z;
  }
  A[1]=0;
  F[1]=1;
  for (ll i=1;i<=N;i++) {
    for (ll j=1;j<=M;j++){
      if (A[E[j][1]] > A[E[j][0]] + E[j][2]) {
        A[E[j][1]] = A[E[j][0]] + E[j][2];
        F[E[j][1]] = E[j][0];
        if (i==N){
          B[E[j][1]]=1;
          B[E[j][0]]=1;
        }
      }

    }
  }
  show(A);
  ll idx=N;
  while(1){
    if (B[idx]==1) {
    cout << -1 << endl;
      return 0;
    }
    if (idx==1) break;
    idx = F[idx];
  }
  if (A[N]>0) A[N]=0;
  cout << -A[N] << endl;
}


Measured memory_bytes: 640
import fractions
from functools import reduce

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

t = []

N = int(input())
for i in range(N):
    t.append(int(input()))

print(lcm_list(t))


Measured memory_bytes: 5048
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
#define MAX 10000100
//#define NIL -1

LL pow(LL x, LL n){
    LL ans = 1;
    while(n>0){
        if((n&1)==1){
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

int main() {
    LL n;
    vector<LL> abc(3);
    cin >> n >> abc[0] >> abc[1] >> abc[2];
    vector<LL> l(n);
    vector<LL> l_sum(3);
    vector<LL> l_num(3);
    LL num=pow(4, n);
    LL min_ans=MAX;
    LL ans=0;

    for(LL i=0; i<n; i++){
        cin >> l[i];
    }

    for(LL i=0; i<num; i++){
        LL tmp=i;
        LL num_minus=0;
        LL num_plus=0;
        LL idx;
        for(LL j=0; j<3; j++){
            l_sum[j]=0;
            l_num[j]=0;
        }
        for(LL j=0; j<n; j++){
            idx=tmp%4;
            if(idx!=0){
                l_sum[idx-1]+=l[j];
                l_num[idx-1]++;
            }
            tmp = tmp >> 2;
        }
        //cout << l_num[0] << " " << l_num[1] << " " << l_num[2] << endl;
        if(l_num[0]==0 || l_num[1]==0 || l_num[2]==0){
            continue;
        }
        for(LL j=0; j<3; j++){
            if(abc[j]-l_sum[j]>0){
                num_plus+=(abc[j]-l_sum[j]);
            }else if(l_sum[j]-abc[j]>0){
                num_minus+=(l_sum[j]-abc[j]);
            }
        }
        ans=(l_num[0]+l_num[1]+l_num[2]-3)*10+num_plus+num_minus;
        if(min_ans>ans){
            min_ans=ans;
            //cout << i << " " << min_ans << " " << l_sum[0] << " " << l_sum[1] << " " << l_sum[2] << " " << l_num[0] << " " << l_num[1] << " " << l_num[2] << " " << num_plus << " " << num_minus << endl;
        }
    }

    cout << min_ans << endl;

    return 0;
}


Measured memory_bytes: 3604
def ans():
  S = input()
  T = input()
  s = []
  t = []
  for alp in "abcdefghijklmnopqrstuvwxyz":
    s.append(S.count(alp))
    t.append(T.count(alp))
  if(sorted(s) == sorted(t)):
    print("Yes")
  else:
    print("No")
ans()

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <queue>
#include<map>
#include<algorithm>
#include<set>
#include<iomanip>
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1; i<=n;i++)
#define ALL(a) a.begin(),a.end()
#define PI  acos(-1)
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
typedef long long int ll;
typedef long double ld;
int main() {
    int n, m, k, a, ans = 0; cin >> n >> m;
    vector<vector<int>> G(11,vector<int>(11,0));
    rep(i, m) {
        cin >> k;
        rep(j, k) {
            cin >> a; a--;
            G[i][a] = 1;
        }
    }vector<int> p(m);
    rep(i, m) cin >> p[i];
    rep(i, 1 << n) {
        int u = 0;
        rep(j, m) {
            int cnt = 0;
            rep(k, n) {
                if (G[j][k] && i & (1 << k))cnt++;
            }
            if (cnt % 2 == p[j]) u++;
        }
        if (u == m) ans++;
    }cout << ans << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <cstring>



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

using namespace std;

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

    REP(i,S.size())
    {
        if(i == 4)
        {
            cout << " ";
        }
        cout << S[i];
    }
    cout << endl;
    

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ld long double
#define PI pair<ld,ll>
#define S second
#define mp make_pair
#define F first
const int N=500005;
int n,L,top;
PI q[N];
ll sum[N];
ld ans[N];
PI operator +(PI a,PI b){
	return mp((a.F*a.S+b.F*b.S)/(a.S+b.S),a.S+b.S);
}
signed main(){
	scanf("%d%d",&n,&L);
	for(int i=1;i<=n;i++){
		int t,v; scanf("%d%d",&t,&v);
		PI dq=mp(t,v);
		while(top&&q[top]>dq){if(q[top].S+dq.S>L)q[top].S=L-dq.S; dq=dq+q[top--]; }
		q[++top]=dq; sum[top]=sum[top-1]+dq.S; ans[top]=ans[top-1]+dq.F*dq.S;
		int pos=lower_bound(&sum[1],&sum[top+1],sum[top]-L)-sum;
		printf("%.7lf\n",(double)((ans[top]-ans[pos]+q[pos].F*(L-(sum[top]-sum[pos])))/L));
	}
}

Measured memory_bytes: 36352
#include <iostream>
#include <cmath>

#define PI 3.141592654
#define EPS 1e-10

#define DEG_TO_RAD(theta) theta * PI / 180

struct point {
	double x;
	double y;
};

double getAreaOfTriangle(double sideA, double sideB, double theta)
{
	theta = DEG_TO_RAD(theta);
	return 0.5 * sideA * sideB * sin(theta);
}

int main(void)
{
	while(1) {
		int m;
		double area1 = 0;
		double area2 = 0;
		double theta;
		double lastTheta = 360;

		// 第1の多角形
		std::cin >> m;
		if(m == 0) {
			break;
		}
		for(int i = 0 ; i < m-1 ; i++) {
			std::cin >> theta;
			area1 += getAreaOfTriangle(1, 1, theta);
			lastTheta -= theta;
		}
		area1 += getAreaOfTriangle(1, 1, lastTheta);

		lastTheta = 360;
		// 第2の多角形
		std::cin >> m;
		if(m == 0) {
			break;
		}
		for(int i = 0 ; i < m-1 ; i++) {
			std::cin >> theta;
			area2 += getAreaOfTriangle(1, 1, theta);
			lastTheta -= theta;
		}
		area2 += getAreaOfTriangle(1, 1, lastTheta);

		if(fabs(area1 - area2) < EPS) {
			std::cout << '0' << std::endl;
		}
		else if(area1 > area2) {
			std::cout << '1' << std::endl;
		}
		else if(area1 < area2) {
			std::cout << '2' << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1256
X, Y = map(int, input().split())

KANE = [
    300000,
    200000,
    100000
]
ans=0
if X <= 3:
    ans += KANE[X-1]
    
if Y <= 3:
    ans += KANE[Y-1]
    
if X == 1 and Y == 1:
    ans += 400000 
    
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() 
{
	ll a,b,k;
	cin>>a>>b>>k;
	if(a+b<=k)
	{
		cout<<"0"<<" "<<"0";
	}
	else if(k>=a)
	{
		k = k-a;
		a = 0;
		b = abs(k-b);
		cout<<"0"<<" "<<b;
	}
	else
	{
		a = a-k;
		cout<<a<<" "<<b;
	}
	return 0;
}

Measured memory_bytes: 3640
import io.{StdIn => in}

object Main extends App {
  val n = in.readInt
  val li = in.readLine.split(" ").map(_.toInt)
  val max = li.max
  val otherSum = li.sum - max
  val ans = if(max < otherSum) "Yes" else "No"
  println(ans)
}


Measured memory_bytes: 27192
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>

using namespace std;

int main()
{
    string s;
    string temp = "";
    int currsiz = 0;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '1' || s[i] == '0') {
            temp += s[i];
            currsiz += 1;
        }
        if(currsiz>0 && s[i]=='B'){
            temp.pop_back();
            currsiz -= 1;

        }
        


    }
    cout << temp;

    
    
}

Measured memory_bytes: 3640
/*  ex7_1
    kento_titech*/
#include<stdio.h>
typedef struct point{//複素数を構造体を使って定義
    int x_elem;//実部
    int y_elem;//虚部
}point;

point shift_point(point vec2,point vec1){//vec2-vec1を90°回転させた複素数にvec2を足したものを返す関数
    point vec3;
    vec3.x_elem=(vec1.y_elem-vec2.y_elem)+vec2.x_elem;//(vec2-vec1)*i+vec2の計算
    vec3.y_elem=(-vec1.x_elem+vec2.y_elem)+vec2.x_elem;
    return vec3;
}

int main(void){
    point z1,z2,z3,z4;
    scanf("%d %d %d %d",&z1.x_elem,&z1.y_elem,&z2.x_elem,&z2.y_elem);
    z3=shift_point(z2,z1);//(z2-z1)*i+z2
    z4=shift_point(z3,z2);//(z3-z2)*i+z3
    printf("%d %d %d %d\n",z3.x_elem,z3.y_elem,z4.x_elem,z4.y_elem);
    return 0;
}

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

int main(void) {
  deque<char> S;
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    S.push_back(s[i]);
  }
  int Q;
  cin >> Q;
  bool top = true;
  for (int i = 0; i < Q; i++) {
    int T;
    cin >> T;
    if (T == 1) {
      top = !top;
    } else {
      int F;
      char C;
      cin >> F >> C;
      if (F == 1) {
        if (top) {
          S.push_front(C);
        } else {
          S.push_back(C);
        }
      } else {
        if (top) {
          S.push_back(C);
        } else {
          S.push_front(C);
        }
      }
    }
  }

  if (!top) {
    reverse(S.begin(), S.end());
  }
  for (auto c : S) {
    cout << c;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main()
{
  int n[26];
  for(int i=0;i<26;i++)
    n[i]=0;
  char x;
  while(cin.get(x))
  {
    if((('a'<=x)&&(x<='z'))||(('A'<=x)&&(x<='Z')))
      n[x-'a'+(('A'<=x)&&(x<='Z'))*('a'-'A')]++;
  }
  for(int i=0;i<26;i++)
    cout<<(char)('a'+i)<<" : "<<n[i]<<endl;
}

Measured memory_bytes: 3084
n,m=map(int,input().split())
a=set()
b=set()
for i in range(m):
	x,y=map(int,input().split())
	if x==1:
		b.add(y)
	if y==n:
		a.add(x)
c=a&b
if len(c)==0:
	print("IMPOSSIBLE")
else:
	print("POSSIBLE")


Measured memory_bytes: 18892
sx,sy,tx,ty = list(map(int, input().split()))

x = tx-sx
y = ty-sy
print("R"*x+"U"*y+"L"*x+"D"*y+"L"+"U"*(y+1)+"R"*(x+1)+"D"+"R"+"D"*(y+1)+"L"*(x+1)+"U")

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

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<ll> a(n + 1), b(m + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1];
    a[i + 1] += a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i + 1];
    b[i + 1] += b[i];
  }

  int r = 0;
  for (int p = 0, q = m; p <= n; p++) {
    while (q >= 0 && a[p] + b[q] > k) q--;
    if (q < 0) break;
    r = max(r, p + q);
  }
  cout << r << endl;
}


Measured memory_bytes: 6424
#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, string> P;
typedef tuple<int, string, string> T;
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);

string s;

bool solve() {
    return s[2] == s[3] && s[4] == s[5];
}

void input() {
    cin >> s;
}

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

    input();
    cout << (solve()?"Yes":"No") << endl;
}


Measured memory_bytes: 3040
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> V;
const int MOD = 1000000007;
const ll INF=2e18;
struct Edge{
    P to;
    ll cost;
};
ll N,M,L;
map<P,vector<Edge>> edges;
map<P,ll> minCost;
int main(){
    while(cin>>N>>M>>L,N!=0){
        for(ll i=1;i<=N;i++){
            for(ll j=0;j<=L;j++){
                minCost[P(i,j)]=INF;
            }
        }
        edges.clear();
        for(ll i=0;i<M;i++){
            ll a,b,d,e;
            cin>>a>>b>>d>>e;
            for(ll j=0;j<=L;j++){
                Edge edge;
                if(j>=d){
                    edge.to=P(b,j-d);
                    edge.cost=0;
                    edges[P(a,j)].push_back(edge);
                    edge.to=P(a,j-d);
                    edges[P(b,j)].push_back(edge);
                }
                edge.to=P(b,j);
                edge.cost=e;
                edges[P(a,j)].push_back(edge);
                edge.to=P(a,j);                
                edges[P(b,j)].push_back(edge);
            }
        }
        priority_queue<V,vector<V>,greater<V> > pq;
        pq.push(V(0,P(1,L)));
        minCost[P(1,L)]=0;
        while(!pq.empty()){
            P now=pq.top().second;
            ll cost=pq.top().first;
            pq.pop();
            if(cost>minCost[now])continue;
            /*cout<<"nowPlace:"<<now.first<<endl;
            cout<<"now money:"<<now.second<<endl;
            cout<<"now cost:"<<cost<<endl;*/
            for(auto edge:edges[now]){
                P to=edge.to;
                ll ncost=cost+edge.cost;
                if(minCost[to]>ncost){
                    minCost[to]=ncost;
                    pq.push(V(ncost,to));
                }
            }
        }
        ll ans=INF;
        for(ll i=0;i<=L;i++){
            ans=min(ans,minCost[P(N,i)]);
        }
        cout<<ans <<endl;
    }
    return 0;
}



Measured memory_bytes: 20644
import math
def F(a,b):
    return max(len(str(a)), len(str(b)))
    
def main():
    n =int(input())
    v = F(n,1)
    
    for a in range(1, int(math.sqrt(n))+1):
        if n % a != 0:
            continue
        
        b = n//a
        v = min(v, F(a,b))
    print(v)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define re register
#define cs const

using std::cerr;
using std::cout;

cs int N=1e6+7;

int n,c1;
int ans;
char s[N];

void Main(){
	scanf("%d%s",&n,s+1);
	for(int re i=1;i<=n;++i)s[i]-=49;
	for(int re i=1;i<=n;++i)
		if(s[i]==1){
			c1=true;
			ans^=((n-1)^(i-1)^(n-i))==0;
		}
	if(ans)cout<<1<<"\n";
	else if(c1)cout<<0<<"\n";
	else {
		ans=0;
		for(int re i=1;i<=n;++i)
			if(s[i]==2)ans^=((n-1)^(i-1)^(n-i))==0;
		cout<<(ans*2)<<"\n";
	}
}

inline void file(){
#ifdef zxyoi
	freopen("B.in","r",stdin);
#endif
}signed main(){file();Main();return 0;}

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

int main(){
  int n,x;
  cin>>n>>x;
  int sum=0;
  int min=1111;
  for(int i=0;i<n;i++){
    int z;
    cin>>z;
    sum +=z;
    
    if(min>z){
      min=z;
    }
  }
  cout<<(x-sum)/min+n<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = sorted([int(x) for x in input().split(" ")])[::-1]

N -= 2
S = A[0]

i = 1
while 1:
    if N == 0:
        break 
    if N == 1:
        S += A[i]
        break
    S += 2 * A[i]
    N -= 2
    i += 1
print(S)

Measured memory_bytes: 31436
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0;
  std::vector<int> v(4);
  rep(i,4){
    std::cin >> v[i];
  }
  sort(all(v));
  if(v[0]==1&&v[1]==4&&v[2]==7&&v[3]==9)std::cout << "YES" << '\n';
  else std::cout << "NO" << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N;
    cin >> N;
    int a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    int s;
    s = a[0];
    for (int i = 1; i < N; i++)
    {
        s ^= a[i];
    }
    int tmp = 0;
    for (int i = 0; i < N; i++)
    {
        tmp = a[i] ^ s;
        cout << tmp;
        cout << " ";
    }
    return 0;
}


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

int main() {
  long double N,memo=0;
  cin >> N;
  long double result;
  for(int i=1;i<N+1;i++){
    if(i % 2 ==1){
      memo++;
      // cout << i <<endl;
    }
  }
  result = memo / N;
  cout << result; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 998244353
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
ll fac[600000 + 2];

ll nCr(ll n, ll r, ll p)
{
    if (r == 0)
        return 1;
    return (fac[n] * modInverse(fac[r], p) % p *
            modInverse(fac[n - r], p) % p) %
           p;
}
int main()
{
    ::fac[0] = 1;
    for (ll i = 1; i <= 600001; i++)
        ::fac[i] = (::fac[i - 1]) * i % rem;
    FAST
        // freopen("input1.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
        /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
        ll n,
        m, k;
    cin >> n >> m >> k;
    if (n==1)
    {
        cout<<m<<"\n";
        return 0;
    }
    ll ans = 0;
    rep(i, 0, k + 1)
    {
        ll val = nCr(n - 1, i, rem);
        ll add = power(m - 1, n - 1 - i, rem) * m;
        add %= rem;
        add *= val;
        add %= rem;
        ans += add;
        ans %= rem;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 8344
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        int n = scan.nextInt();
        int cnt = 1;
        int h[] = new int[n];
        
        int my_height;
        
        for( int i = 0 ; i < n; i++){
          h[i] = scan.nextInt();
        }
        
        for( int i = n-1 ; i > 0 ; i-- ){
          my_height = h[i];
          cnt++;
          for( int j = i ; j >= 0 ; j-- ){
            if( my_height < h[j] ){
              cnt--;
              break;
            }
          }
        }
            
        System.out.println(cnt);
	  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;++i)
#define MOD (int) 1e9+7
#define INF (int) 2e9

int main(){
    int n, m;
    cin >> n >> m;
    int p[m], y[m];
    map<int, vector<int>> mp;

    rep(i, m){
        cin >> p[i] >> y[i];
        mp[p[i]].emplace_back(y[i]);
    }

    for (auto& p : mp){
        sort(p.second.begin(), p.second.end());
    }

    rep(i, m){
        int num = lower_bound(mp[p[i]].begin(), mp[p[i]].end(), y[i]) - mp[p[i]].begin();
        printf("%06d", p[i]);
        printf("%06d\n", num+1);
    }
    return 0;
}

Measured memory_bytes: 13184
def sum_lr(l, r, cnt):
    cnt += 1
    lr = l + r
    if lr < 10:
        l = lr
        return l, cnt
    else:
        l = lr // 10
        r = lr % 10
        return sum_lr(l, r, cnt)

from collections import defaultdict
aaa = defaultdict(lambda:{})
for l in range(10):
    for r in range(10):
        aaa[l][r] = sum_lr(l,r,0)
        

def dc_compression(d, c, ret, cnt):
    if c == 1:
        ret.append((d, 1))
        return ret, cnt
    
    if c % 2 == 1:
        ret.append((d, 1))
        c -= 1
    d, tmp_cnt = aaa[d][d]
    c = c // 2
    cnt += tmp_cnt * c
    #print(d, c, ret, cnt)
    return dc_compression(d, c, ret, cnt)
    
    
    
        

M = int(input())

nums = []
l = 0
cnt = 0
import sys
input = sys.stdin.readline
for _ in range(M):
    d, c = map(int, input().split())
    tmp_nums, tmp_cnt= dc_compression(d,c,[], 0)
    for t,_ in tmp_nums:
        nums.append(t)
    
    cnt += tmp_cnt
    
#print(nums)    
    
for d in nums:
    l, tmp_cnt = aaa[l][d]
    cnt += tmp_cnt

print(cnt-1)

Measured memory_bytes: 146644
h=[[[0]*10for i in[0]*3]for j in[0]*4];i=0
for _ in[0]*int(input()):b,f,r,v=map(int,input().split());h[~-b][~-f][~-r]+=v
for b in h:
 for f in b:print("",*f)
 print(("","#"*20+"\n")[i<3],end="");i+=1


Measured memory_bytes: 5624
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
#include <numeric>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l

int gcd(int a, int b) {
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}


int main() {
	int n, h[100];
	cin >> n;
	int ans = 1;
	rep(i, n)cin >> h[i];
	for (int i = 1; i < n;i++) {
		bool a = true;
		rep(j, i) {
			if (h[i] < h[j])a = false;
		}
		if (a)ans++;
	}
	cout << ans << endl;
	cin >> n;
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

ans = "No"

for i in range(N-M+1):
    for j in range(N-M+1):
        C = []
        for k in range(i,i+M):
            C.append(A[k][j:j+M])
        if B == C:
            ans = "Yes"

print(ans)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Scanner;




class Main{


	static	ArrayList<Integer> one ;
	static	ArrayList<Integer> two ;
	static	ArrayList<Integer> three ;
	static	ArrayList<Integer> four ;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);			//文字の入力
		char[] a = sc.next().toCharArray();
		char[] b = sc.next().toCharArray();



		char[] longmozi ;
		char[] shortmozi ;

		if(a.length != b.length){


			for(int i = 0;i < b.length;i++){
				System.out.print(a[i]);
				System.out.print(b[i]);

			}
			System.out.print(a[a.length-1]);
		}else{
			for(int i = 0;i < b.length;i++){
				System.out.print(a[i]);
				System.out.print(b[i]);

			}
			
		}


	}
}

class Pair implements Comparable{
	Character from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}




Measured memory_bytes: 21716
#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>
struct kek{
    int a,b,c,d;
};




vector<kek> arr;
int ans=0;
void gogo(int n, int m, int kolvo, vector<int> &now, int last){
    if(kolvo==n){
        int sm=0;
        for(int j=0;j<arr.size();j++){
            if(now[arr[j].b-1]-now[arr[j].a-1]==arr[j].c){
                sm+=arr[j].d;
            }
        }
        ans=max(ans, sm);
        return;
    }
    for(int i=last;i<=m;i++){
        now[kolvo]=i;
        gogo(n,m,kolvo+1, now, i);
    }

}
void solve() {
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC";
    else cout<<"ABC";
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(0);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}

Measured memory_bytes: 3656
def main():
    N, P = map(int, input().split())
    S = [int(c) for c in input()]

    ret = 0
    if P in {2, 5}:
        for i, x in enumerate(S, 1):
            if x % P == 0:
                ret += i
        print(ret)
        return

    else:
        curr_num = 0
        counter = [0] * P
        counter[0] = 1
        mul = 1
        for i, x in enumerate(reversed(S)):
            curr_num = (curr_num + x * mul) % P
            ret += counter[curr_num]
            counter[curr_num] += 1
            mul = (mul * 10) % P
        print(ret)
        return


if __name__ == '__main__':
    main()


Measured memory_bytes: 5096
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	int dp[20][2][2][2][2][2] = {};
	dp[0][0][0][0][0][0] = 1;
	rep(i,s.size()) rep(j,2) rep(k,2) rep(l,2) rep(m,2) rep(n,2) {
		int lim = j ? 9 : s[i] - '0';
		for(auto d : {0, 3, 5, 7}){
			if(d > lim) continue;
			dp[i + 1][j or d < lim][k or d == 3][l or d == 5][m or d == 7][n or (d == 0 and (k or l or m))]
				+= dp[i][j][k][l][m][n];
		}
	}

	int sum = 0;
	rep(i,2){
		sum += dp[s.size()][i][1][1][1][0];
	}
	cout << sum << endl;
}


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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator*(long long y,const mint& m){ return m*y; }

int main(){
	int n,m; scanf("%d%d",&n,&m);

	mint dp[2][301][300]; // dp[頂点 0 を含む強連結成分のサイズ][新たに訪れた部分のサイズ] = 場合の数
	dp[0][1][0]=1;
	int curr=0,next=1;
	rep(t,m){
		rep(i,n+1) rep(j,n) dp[next][i][j]=0;

		for(int i=1;i<=t+1;i++) rep(j,n-i+1) {
			dp[next][i+j][0]+=i*dp[curr][i][j]; // 0 を含む強連結成分に移動
			dp[next][i][j]+=j*dp[curr][i][j]; // 新たに訪れた j 個の頂点のうちのどれかに移動
			dp[next][i][j+1]+=(n-i-j)*dp[curr][i][j]; // 未到達の頂点に移動
		}
		swap(curr,next);
	}
	printf("%d\n",dp[curr][n][0].to_int());

	return 0;
}


Measured memory_bytes: 896
#include<stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	printf("Christmas");
		if (n == 24) {
			printf(" Eve");
		}
	if (n == 23) {
		printf(" Eve Eve");
	}
	if (n == 22) {
		printf(" Eve Eve Eve");
	}
}


Measured memory_bytes: 128
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    auto p = vector<int>(n);
    for (auto &p_i : p)
        cin >> p_i;

    auto doubled_exp = vector<int>(n);
    for (int i = 0; i < n; i++) {
        doubled_exp[i] = (1 + p[i]);
    }

    auto exp = vector<int>(k);
    auto sum = 0;
    for (int i = 0; i < k; i++) {
        exp[i] = doubled_exp[i];
        sum += doubled_exp[i];
    }

    auto max_sum = sum;
    auto droppos = 0;

    for (int i = k; i < n; i++) {
        sum -= exp[droppos];
        exp[droppos] = doubled_exp[i];
        sum += doubled_exp[i];
        droppos = (droppos + 1) % k;
        if (sum > max_sum)
            max_sum = sum;
    }

    printf("%.12f", 0.5*max_sum);
    return 0;
}


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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

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

    ll r,g,b,n;
    cin >> r >> g >> b >> n;

    ll ans = 0;
    fr(i,0,n)
    {
    	ll x = r*i;
    	if(x>n)
    		break;

    	fr(j,0,n)
    	{
    		ll y = g*j;
    		ll z = x+y;
    		if(z>n)
    			break;

    		ll m = n-z;

    		if(m%b==0)
    		{
    			// cout << i << " " << j << endl;
    			ans++;
    		}
    	}
    }

    cout << ans << endl;
}


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

int main(){
  ll x,cnt=0; cin >>x;
  cnt+=x/11*2;
  x%=11;
  if(x>6) cnt+=2;
  else if(x!=0)cnt++;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int H ,W;
    cin >> H >> W;
    vector<vector<char>> data(H+2, vector<char>(W+2));
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin >> data[i][j];
        }
    }
    //
    for(int i=0;i<=H+1;i++){
        for(int j=0;j<=W+1;j++){
            if((i==0)||(i==H+1)){
                data[i][j]='#';
            }
            else if((j==0)||(j==W+1)){
                data[i][j]='#';
            }
        }
    }
    //
    for(int i=0;i<=H+1;i++){
        for(int j=0;j<=W+1;j++){
            if(j!=W+1){
                cout << data[i][j] ;
            }
            else{
                cout << data[i][j] << endl;
            }
        }
    }
}

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

using namespace std;

int main(){
  long N;
  vector<long long> cp(5);
  cin >> N;
  for( int i = 0; i < 5; ++i ){
    cin >> cp[i];
  }
  sort(cp.begin(), cp.end());
  cout << (N+cp[0]-1)/cp[0]+(5-1) << endl;
  return 0;
}



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

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	int N, t, cnt = 0;
	scanf("%d %d", &N, &t);
	for(int i = 1; i <= N; i++) {
		int x;
		scanf("%d", &x);
		if(x >= t) cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){

  int n;
  cin>>n;

  int d,x;

  cin>>d>>x;

  int a[101];

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

  int ans=0;
  
  for(int i=0;i<n;i++){
    for(int j=1;j<=d;j+=a[i]){
      ans+=1;
    }
  }

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


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

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((abs(a-b)<=d && abs(b-c)<=d)||(abs(a-c)<=d)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
ll mod=1e9+7;
ll inv(ll a){
    ll n=mod-2,ans=1;
    while(n>0){
        if(n&1) ans=ans*a%mod;
        n=n/2;
        a=a*a%mod;
    }
    return ans;
}
ll A[200001];
void init(){
    A[0]=1;
    rep(i,200000) A[i+1]=A[i]*(i+1)%mod;
}
ll nCk(ll n,ll k){
    return A[n]*inv(A[k])%mod*inv(A[n-k])%mod;
}
int main(){
    init();
    ll n,k,B[200001];
    cin>>n>>k;
    rep(i,n) cin>>B[i];
    if(k==1){cout<<0;return 0;}
    sort(B,B+n);
    ll C[200001];
    C[0]=0;
    rep(i,n) C[i+1]=(C[i]+B[i]+mod)%mod;
    ll ans=0;
    for(int i=n;i>=k;i--){
        ans+=nCk(i-2,k-2)*((C[n]-C[i-1]+mod)%mod-(C[n-i+1]-C[0]+mod)%mod+mod)%mod;
    }
    cout<<ans%mod<<"\n";
}


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

const int nax = 3005;
int main()
{
    int n;
    cin>>n;
    long long dp[nax][nax];
    vector<int> a(n);
    for(int& x: a){
        scanf("%d",&x);
    }
    for(int l=n-1;l>=0;l--){
        for(int r=l;r<n;r++){
            if(l==r)
                dp[l][r] = a[l];
            else{
                dp[l][r] = max(a[l] - dp[l+1][r], a[r] - dp[l][r-1]);
            }
        }
    }
    printf("%lld\n", dp[0][n-1]);
    //cout<<dp[0][n-1];
}


Measured memory_bytes: 70656
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<double,int> pint;
typedef long long ll;
const int inf   = 1<<29;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int n,k;
  cin>>n>>k;
  int ans=1;
  rep(i,n)ans+=min(ans,k);
  cout<<ans<<endl;
  return 0;  
  } 


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;

class Main {
	
	static ArrayList<Integer> primeList = new ArrayList<Integer>();
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		makePrimeList();

		while(sc.hasNext()) {
			int n = sc.nextInt();
			int count = 0;
			for(int i = 0; i < n+1; i++) {
				if(Collections.binarySearch(primeList, i+1) >= 0 && Collections.binarySearch(primeList, n - i) >= 0) count++;
			}
			System.out.println(count);
			
			
			
			
			
		}
	}
	static void makePrimeList() {
		boolean[] isntPrime = new boolean[10001];
		primeList.add(2);
		for(int i = 3; i < 10001; i += 2) {
			if(!isntPrime[i]) {
				primeList.add(i);
				for(int j = i + i; j < 10001; j += i) {
					isntPrime[j] = true;
				}
			}
		}
	}
}

Measured memory_bytes: 54248
#include <iostream>
#include <algorithm> 
typedef long long ll;

using namespace std;

int main() {

	ll L, R;
	cin >> L >> R;

	int mod_min = 2018;

	R = min(R, L + 2019);

	for (ll i = L; i < R; i++)
	{
		for (ll j = i + 1; j <= R; j++)
		{

			int mod = (i * j) % 2019;

			mod_min = min(mod_min, mod);
		}
	}

	cout << mod_min << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 1000001

int linearSearch(int A[],int n,int key)
{
  int i=0;

  A[n]=key;
  if(A[0]==key){
    return 1;
  }
  while(A[i]!=key){
    i++;
  }
  if(i==n){
    return 0;
  }
  return i;
}

int main(){

  int i,n,q,key,sum=0,A[N];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&key);
    if(linearSearch(A,n,key)){
      sum++;
    }
  }


  printf("%d\n",sum);
  return 0;

}

/*
#include<stdio.h>
#define N 10001
 
int linearSearch(int A[],int n,int key)
{
  int i=0;
 
  A[n]=key;
  if(A[0]==key){
    return 1;
  }
  while(A[i]!=key){
    i++;
  }
  if(i==n){
    return 0;
  }
  return i;
}
 
int main(){
 
  int i,n,q,key,sum=0,A[N];
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
 
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&key);
    if(linearSearch(A,n,key)){
      sum++;
    }
  }
 
 
  printf("%d\n",sum);
  return 0;
 
}
*/



Measured memory_bytes: 2144
# coding: utf-8
# coding: Shift_JIS
# coding: EUC-JP
# coding: cp932
import math

n = int(input())
room = [[[0 for i in range(10)] for j in range(3)] for z in range(4)]
while(n>0):
    n = n-1
    b,f,r,v = map(int,input().split())
    room[b-1][f-1][r-1] += v

for i in range(4):
    if i != 0:
        print("#"*20)
    for j in range(3):
        st = ""
        for z in range(10):
            st = st + " " + str(room[i][j][z])
        print(st)



Measured memory_bytes: 5668
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	sum := 0
	xm := make(map[int]int)
	xm[0]++
	for i := 0; i < n; i++ {
		a := scanInt()
		sum += a
		xm[sum]++
	}

	ans := 0
	for _, v := range xm {
		ans += (v * (v - 1)) / 2
	}
	fmt.Println(ans)
}


Measured memory_bytes: 12672