akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict

N = int(input())
V = list(map(int, input().split()))

if N == 2:
    if V[0] == V[1]:
        print(0)
    else:
        print(1)
    exit()

d_even = defaultdict(int)
d_odd = defaultdict(int)

for i in range(N):
    v = V[i]
    if i % 2 == 0:
        d_even[v] += 1
    else:
        d_odd[v] += 1

if len(set(V)) == 1:
    print(N//2)
    exit()


l_even = sorted(d_even.items(), key=lambda x: -x[1])
l_odd = sorted(d_odd.items(), key=lambda x: -x[1])

if l_even[0][0] != l_odd[0][0]:
    print(N - l_even[0][1] - l_odd[0][1])
else:
    print(min(N - l_even[0][1] - l_odd[1][1], N - l_even[1][1] - l_odd[0][1]))


Measured memory_bytes: 67052
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve() {
    string s;
    cin >> s;
    string ans = s[2]==s[3] && s[4]==s[5] ? "Yes" : "No";
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

int h, w;
int ko_saga(vector<string>& g, int a, int b, int c, int d) {
  vector<vi> dist(h, vi(w, INF));
  vector<vb> visit(h, vb(w, false));
  priority_queue<tuple<int, int, int>> q;
  q.emplace(0, a, b);
  dist[a][b] = 0;
  while (!q.empty()) {
    auto [dis, x, y] = q.top();
    q.pop();
    if (visit[x][y]) continue;
    if (x == c and y == d) return abs(dis);
    visit[x][y] = true;
    for (int i = -2;i <= 2;i++) {
      for (int j = -2;j <= 2;j++) {
        int nx = x + i;
        int ny = y + j;
        if (nx < 0 or nx >= h or ny < 0 or ny >= w or visit[nx][ny] or g[nx][ny] == '#') continue;
        dist[nx][ny] = abs(dis) + (abs(i) + abs(j) != 1);
        q.emplace(-dist[nx][ny], nx, ny);
      }
    }
  }
  return -1;
}

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

  cin >> h >> w;
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  a--, b--, c--, d--;
  vector<string> m(h);
  loop(h) {
    cin >> m[i];
  }
  cout << ko_saga(m, a, b, c, d) << endl;
	return 0;
}



Measured memory_bytes: 9336
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll n,k;
	cin >> n >> k;
	cout << min(n%k, abs(n%k - k)) << '\n';
	return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in(), m = in();
    vector<ll>k(m);
    vector<vector<ll>>s(m);
    REP(i, m) {
        k[i] = in();
        REP(j, k[i])s[i].push_back(in());
    }
    vector<ll>p(m);
    REP(i, m)p[i] = in();

    ll ans = 0;

    ll powtwo = 1; REP(i, n)powtwo *= 2;
    REP(i, powtwo) {
        ll pc = i;
        vector<ll>bv;
        REP(j, n) {
            bv.push_back(pc % 2);
            pc >>= 1;
        }
        ll cnt = 0;
        REP(j, m) {
            ll foo = 0;
            REP(l, k[j])foo += bv[s[j][l] - 1];
            if (foo % 2 == p[j])++cnt;
        }
        if (cnt == m)++ans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int a,b;
    string s;
    cin>>a>>b;
    cin>>s;
    rep(i,s.size()){
        if(i!=a){
            if(!isdigit(s[i])){
                cout<<"No"<<endl;return 0;
            }
        }
        else{
            if(s[i]!='-'){
                cout<<"No"<<endl;return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
//作者:中国江苏南京丁天行
//from CrAzYUnIoN
//I prefer being hacked to being FST
using namespace std;
//数组不要开小了
int n,a[50],b[50],c[50],ma,mb;
int f[205][205];
int main()
{
    scanf("%d%d%d",&n,&ma,&mb);
    for(int i=1;i<=n;i++)scanf("%d%d%d",a+i,b+i,c+i);
    for(int i=0;i<=ma*20;i++){
            for(int j=0;j<=mb*20;j++)f[i][j]=orz;
    }
    f[0][0]=0;
    int maa=20*ma,mbb=20*mb;
    for(int i=1;i<=n;i++){
            for(int j=maa;j>=a[i];j--){
                    for(int k=mbb;k>=b[i];k--)f[j][k]=min(f[j][k],f[j-a[i]][k-b[i]]+c[i]);
            }
    }
    int ans=orz;
    for(int i=1;i<=20;i++)ans=min(ans,f[i*ma][i*mb]);
    if(ans==orz)puts("-1");
    else printf("%d\n",ans);
//	system("pause");
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
using namespace std;
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b;
   cin>>a>>b;
   if(a<=8 && b<=8)
      cout<<"Yay!"<<endl;
   else
      cout<<":("<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ld long double
#define ll long long
#define st first
#define nd second
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
using namespace std;
const ll INF = 1e18+1;
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll k;
	cin>>k;
	vector<bool> vis(k+1);
	ll rem = 7%k;
	for(int i=1; i<=k; ++i) {
		if(vis[rem]) break;
		if(rem==0) {
			cout<<i;
			return 0;
		}
		rem = (rem*10 + 7)%k;
	}
	cout<<-1;
}


Measured memory_bytes: 3704
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

int n;
int a[100005];

int main()
{
    while(~scanf("%d",&n))
    {
        int sum=0;
        for(int i=0;i<n;++i)
        {
            cin>>a[i];
            if(a[i]%2) sum++;
        }
        if(sum%2) printf("NO\n");
        else printf("YES\n");
    }
}


Measured memory_bytes: 640
;;(declaim (optimize (speed 0) (safety 3) (debug 3)))
#+sbcl (declaim (sb-ext:unmuffle-conditions sb-ext:compiler-note))
(declaim (optimize (speed 3) (safety 0) (debug 0)))

(declaim (type (integer 1 4000) *str-len*))
(defvar *str-len* (read))

(declaim (type simple-string *str*))
(defvar *str* (coerce (read-line) 'simple-string))

(defstruct entry r g b rg gb br rgb)

(defvar *table* (make-array (1+ *str-len*)
			    :element-type 'entry))
(setf (aref *table* 0) (make-entry :r 0 :g 0 :b 0
				   :rg 0 :gb 0 :br 0
				   :rgb 0))
(case (aref *str* 0)
      (#\R (incf (entry-r (aref *table* 0))))
      (#\G (incf (entry-g (aref *table* 0))))
      (#\B (incf (entry-b (aref *table* 0)))))
(loop for i from 1 to (1- *str-len*) do
      (let ((e (copy-entry (aref *table* (1- i)))))
	(case (aref *str* i)
	      ;; ちょっとひどい
	      (#\R
	       (incf (entry-rgb e) (entry-gb e))
	       (incf (entry-rg e) (entry-g e))
	       (incf (entry-br e) (entry-b e))
	       (incf (entry-r e)))
	      (#\G
	       (incf (entry-rgb e) (entry-br e))
	       (incf (entry-rg e) (entry-r e))
	       (incf (entry-gb e) (entry-b e))
	       (incf (entry-g e)))
	      (#\B
	       (incf (entry-rgb e) (entry-rg e))
	       (incf (entry-gb e) (entry-g e))
	       (incf (entry-br e) (entry-r e))
	       (incf (entry-b e))))
	(setf (aref *table* i) e)))

(defvar *s* (entry-rgb (aref *table* (1- *str-len*))))
(loop for dif from 1 to *str-len* do
      (loop for i from 0 to *str-len* do
	    (let ((j (+ i dif))
		  (k (+ i dif dif)))
	      (when (>= k *str-len*) (return))
	      (when (char/= (aref *str* i)
			(aref *str* j)
			(aref *str* k))
		(decf *s*)))))

(princ *s*)


Measured memory_bytes: 25432
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args)throws Exception {
		BufferedReader br = new BufferedReader ( new InputStreamReader(System.in));
		String []input = br.readLine().split(" ");
		int board = Integer.parseInt(input[0]);
		int alice = Integer.parseInt(input[1]);
		int borys = Integer.parseInt(input[2]);

		if(Math.abs(alice - borys) == 1 ) {
			System.out.println("Borys");
		}else if(Math.abs(alice - borys) == 2) {
			System.out.println("Alice");
		}else if(Math.abs(alice - borys)%2 == 0) {
			System.out.println("Alice");
		}else {
			System.out.println("Borys");
		}

	}

}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int dp[1005][10005];
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    REP(i, N) { cin >> A.at(i) >> B.at(i); }

    REP(i, N + 1) {
        REP(j, H + 1) { dp[i][j] = INF; }
    }
    dp[0][0] = 0;
    REP(i, N) {
        REP(j, H + 1) {
            chmin(dp[i + 1][j], dp[i][j]);
            if (j >= A[i]) {
                chmin(dp[i + 1][j], dp[i + 1][j - A[i]] + B[i]);
            } else {
                chmin(dp[i + 1][j], dp[i + 1][0] + B[i]);
            }
        }
    }
    /*
        REP(i, N + 1) {
            REP(j, H + 1) { cout << dp[i][j] << " "; }
            cout << endl;
        }
    */
    cout << dp[N][H] << endl;
    return 0;
}


Measured memory_bytes: 39424
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef LOCAL
    #define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define debug(...) 42
    #define eprintf(...) 42
#endif

#define PI 3.1415926535897932384626433832795
#define INF 2e9
#define SINV(t) greater<t>()
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()

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

typedef long long ll;
#define vv(t) vector< t > 

#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))

template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}

#pragma endregion

template<typename T>
void SV(vector<T> v){
    #ifdef LOCAL
        REP(i,v.size()){
                cout << i << " : " << v[i] << endl;
        }
    #endif
}

template<typename T>
void SV(map<int, T> v){
    #ifdef LOCAL
        FOREACH(i, v){
            cout << i.first << " : " << i.second << endl;
        }
    #endif
}
int bitCount(int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >> 16);
}

int main(void){
    string s, t;
    cin >> s >> t;
    bool fff=false;
    REPR(i, s.length()-t.length()){
        bool flg=true;
        REP(j, t.length()){
            if(s[i+j]=='?'||s[i+j]==t[j]){
            }else{
                flg=false;
                break;
            }
        }
        if(flg){
            REP(j, t.length()){
                s[i+j]=t[j];
                debug(s);
            }
            fff=true;
            break;
        }
    }
    if(!fff){
        cout << "UNRESTORABLE\n";
        return 0;
    }
    REP(i, s.length()){
        if(s[i]=='?'){
            s[i]='a';
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, T = lr()
AB = [lr() for _ in range(N)]
AB.sort()
# 時間のかかる物は後ろへ
dp = np.zeros(T, np.int64)
answer = 0
for a, b in AB:
    answer = max(answer, dp.max() + b)
    prev = dp
    dp[a:] = np.maximum(prev[a:], prev[:-a] + b)

print(answer)


Measured memory_bytes: 12808
#include <iostream>
#include<string>
#include<vector>
#include<list>
#include <algorithm>

using namespace std;
int main()
{


	uint64_t Q;
	list<string> ls;

	string str;
	cin >> str;

	for (int i = 0; i < str.length(); i++) {
		string a{ str[i] };
		ls.push_back(a);
	}
	cin >> Q;

	int reverse_count = 0;



	for (uint64_t i = 0; i < Q; i++) {
		int T, F;
		string C;
		cin >> T;


		if (T == 1) {
			reverse_count +=1 ;
			reverse_count = reverse_count % 2;
		}
		else {
			cin >> F >> C;
			if (!reverse_count) {

				if (F == 1) {
					ls.push_front(C);
				}
				else {
					ls.push_back(C);
				}
			}
			else {
				if (F == 1) {
					ls.push_back(C);
				}
				else {
					ls.push_front(C);
				}
			}
		}


	}
	if (reverse_count==1) {
		ls.reverse();
	}
	
	for (const string& x : ls) {
		cout << x;
	};
	
	return 0;

}



Measured memory_bytes: 24064
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    string s; cin >> s;
    ll k; cin >> k;
    for (int i = 0; i < s.size(); i++)
    {
        if (k == 0) break;
        if (s[i] == 'a') continue;
        int a = 'z'-s[i]+1;
        if (a > k) continue;
        s[i] += a;
        if (s[i] > 'z') s[i] = s[i]-'z'+'a'-1;
        k -= a;
    }

    int len = s.size();
    s[len-1] += k%26;
    if (s[len-1] > 'z') s[len-1] = s[len-1]-'z'+'a'-1;

    cout << s << endl;
    
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
//#include<math.h>

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007ll
#define pb push_back
#define fi first
#define se second
#define mk(a, b) make_pair(a, b)
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int h, w, d[] = {0, 1, 0, -1, 0}, D[60][60];
char fld[60][60];

signed main()
{
    cin >> h >> w;
    int cnt = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> fld[i][j];
            if(fld[i][j] == '#')cnt++;
        }
    }
    memset(D, -1, sizeof(D));
    queue<PA> que;
    que.push(mk(0, 0));
    D[0][0] = 0;
    while(!que.empty()){
        int x = que.front().first;
        int y = que.front().second;
        que.pop();
        for(int i = 0; i < 4; i++){
            int nx = x + d[i], ny = y + d[i + 1];
            if(D[nx][ny] == -1 && 0 <= nx && nx < h && 0 <= ny && ny < w && fld[nx][ny] != '#'){
                D[nx][ny] = D[x][y] + 1;
                que.push(mk(nx, ny));
            }
        }
    }
    if(D[h - 1][w - 1] == -1){
        cout << "-1" << endl;
        return 0;
    }
    cout << h * w - (D[h - 1][w - 1] + 1) - cnt << endl;



    return 0;
}
/*


*/


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < n; i++)
#define REP(n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using INT64 = long long;
using UINT64 = unsigned long long;

struct pq {
    INT64 val;
    int i;
    int j;
    int k;

    bool operator<(const pq& lhs) const{
        return val < lhs.val;
    }
    
    bool operator==(const pq& lhs) const {
        if (i != lhs.i) return false;
        if (j != lhs.j) return false;
        if (k != lhs.k) return false;
        return true;
    }
    
};

int main(void)
{
    IOS
    //const int KMAX = 3000;
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<INT64> a(x), b(y), c(z);
    REP(x) cin >> a[i];
    REP(y) cin >> b[i];
    REP(z) cin >> c[i];

    sort(RALL(a));
    sort(RALL(b));
    sort(RALL(c));
    
    //int ai , bi , ci = 0;
    priority_queue<pq> p;
    vector<pq> v;
    int ki = 0;
    pq f = {a[0]+b[0]+c[0],0,0,0};
    p.push(f);
    while(ki < k) {
        pq top = p.top();
        p.pop();ki++;
        cout << top.val << endl;

        if (top.i < x-1) {
            pq aq = {a[top.i+1]+b[top.j]+c[top.k],top.i+1,top.j,top.k};
            auto itr = find(ALL(v),aq);
            if (itr == v.end()) {
                //cerr << "i:" << aq.i << " j:" << aq.j << " k:" << aq.k << endl;
                v.emplace_back(aq);
                p.emplace(aq);
            }
        }
        if (top.j < y-1) {
            pq bq = {a[top.i]+b[top.j+1]+c[top.k],top.i,top.j+1,top.k};
            auto itr = find(ALL(v),bq);
            if (itr == v.end()) {
                //cerr << "i:" << bq.i << " j:" << bq.j << " k:" << bq.k << endl;
                v.emplace_back(bq);
                p.emplace(bq);
            }
        }
        if (top.k < z-1) {
            pq cq = {a[top.i]+b[top.j]+c[top.k+1],top.i,top.j,top.k+1};
            auto itr = find(ALL(v),cq);
            if (itr == v.end()) {
                //cerr << "i:" << cq.i << " j:" << cq.j << " k:" << cq.k << endl;
                v.emplace_back(cq);
                p.emplace(cq);
            }
        }
        //cerr << p.size() << endl;
    }


    return 0;
}


Measured memory_bytes: 768
s=input()
n=len(s)
kodomo=[0 for i in range(n)]
cr1=0
cr2=0
rflag=False
rlflag=False
for i in range(n):
  if s[i]=='R':
    rlflag=False
    if rflag:
      cr2+=1
      rflag=False
    else:
      cr1+=1
      rflag=True
  else:
    if rlflag:
      continue
    else:
      rlflag=True
      if rflag:
        kodomo[i-1]+=cr1
        kodomo[i]+=cr2
        cr1=0
        cr2=0
      else:
        kodomo[i-1]+=cr2
        kodomo[i]+=cr1
        cr1=0
        cr2=0
    rflag=False

cl1=0
cl2=0
lflag=False
lrflag=False
for i in range(n):
  if s[n-1-i]=='L':
    lrflag=False
    if lflag:
      cl2+=1
      lflag=False
    else:
      cl1+=1
      lflag=True
  else:
    if lrflag:
      continue
    else:
      lrflag=True
      if lflag:
        kodomo[n-i]+=cl1
        kodomo[n-i-1]+=cl2
        cl1=0
        cl2=0
      else:
        kodomo[n-i]+=cl2
        kodomo[n-i-1]+=cl1
        cl1=0
        cl2=0
    lflag=False
print(' '.join(map(str, kodomo)))

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

int n,mid,temp;
float cnt;
int main()
{
    cin>>n;
    mid=n/2;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        if(temp%4==0)
            cnt++;
        else if(temp%2==0)
            cnt+=0.5;
    }
    if(cnt>=mid)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    cin.tie(0);
   	ios::sync_with_stdio(false);

    int K, S; cin >> K >> S;
    int count = 0;
    for(int i=0; i<=K; i++)
    {
        for(int j=0; j<=K; j++)
        {
            if(S - i - j >= 0 && S - i - j <= K)
            {
                count++;
            }
        }
    }
    cout << count;
}

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 4){
        if (s[i] == '2') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;

vvi graph;
vi vis;

int dfs(int s){
    int ans = 1;
    vis[s] = 1;
    trav(v, graph[s]){
        if(vis[v]==0){
            ans += dfs(v);
        }
    }
    return ans;
}

int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    int n,m;
    cin >> n >> m;
    graph = vvi(n);
    int a,b;
    rep(i,0,m){
        cin >> a >> b;
        a--;
        b--;
        graph[a].pb(b);
        graph[b].pb(a);
    }
    int n4=0;
    int n6=0;
    int d4;
    rep(i,0,n){
        int s = sz(graph[i]);
        if(s%2){
            cout << "No" << endl;
            return 0;
        }
        if(s==4){
            n4++;
            d4 = i;
        }else if(s>4){
            n6++;
        }
    }
    if(n6){
        cout << "Yes" << endl;
        return 0;
    }
    if(n4>2){
        cout << "Yes" << endl;
        return 0;
    }
    if(n4<=1){
        cout << "No" << endl;
        return 0;
    }

    vis = vi(n);
    vis[d4] = 1;
    int len;
    if(d4==0){
        len = dfs(1);
    }else{
        len = dfs(0);
    }
    if(len==n-1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 7424
n=int(input())
A=[int(x) for x in input().split()]
ans=[]

cnt=n-1
while cnt>=0:
  ans.append(A[cnt])
  cnt-=2
if cnt==-2:
  cnt=1
else:
  cnt=0
while cnt<=n-1:
  ans.append(A[cnt])
  cnt+=2

for i in range(n):
  if i==n-1:
    print(ans[i])
  else:
    print(ans[i],"",end="")

Measured memory_bytes: 26180
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b;
    for(int i = 0; i < m; ++i){
    	int x; cin >> x;
    	b.pb(x);
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
    	int sum = 0;
    	for(int j = 0; j < m; ++j){
    		int x; cin >> x;
    		sum = sum + (b[j] * x);
    	}
    	if(sum + c > 0) ans++;
    }
    cout << ans << endl;
	return 0;
} 	

Measured memory_bytes: 256
import collections
n=int(input())
a=list(map(int, input().split()))
s=[0]*3*n
for i in range(n):
    s[3*i]+=a[i]+1
    s[3*i+1]+=a[i]-1
    s[3*i+2]+=a[i]
c=collections.Counter(s)
print(c.most_common()[0][1])

Measured memory_bytes: 34012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e5;
char s[2 * N + 5];
ll a[2 * N + 5], d[2 * N + 5];
const ll mod = 1e9 + 7;
int main()
{
    ll n;
    cin >> n;
    getchar();
    ll offset = 0;
    d[0] = 1;
    for (ll i = 1; i <= n * 2; i++)
    {
        scanf("%c", &s[i]);
        a[i] = (s[i] == 'W' ? 0 : 1);
        d[i] = a[i] ^ a[i - 1] ^ (d[i - 1] == 0);
    }
    /*
    for (ll i = 1; i <= n * 2; i++)
    {
        cout << a[i];
    }
    cout << endl;
    for (ll i = 1; i <= n * 2; i++)
    {
        cout << d[i];
    }
    */

    ll cnt = 0ll;
    ll ans = 1ll;
    for (ll i = 1; i <= n * 2; i++)
    {
        if (d[i] == 1)
        {
            cnt++;
        }
        else
        {
            if (cnt <= 0)
            {
                cout << 0;
                return 0;
            }
            ans = ans * cnt % mod;
            cnt--;
        }
    }
    if (cnt > 0)
    {
        cout << 0;
        return 0;
    }
    for (ll i = n; i >= 1; i--)
    {
        ans = ans * i % mod;
    }
    cout << ans;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N;
vector<int> A, B, C;

// 1-indexed BIT (i : [1, len])
template<typename T, int len>
struct BIT
{
    array<T, len + 1> val;
    BIT() { val.fill(0); }
    void add(int pos, T v)
    {
        while (pos > 0 && pos <= len)
        {
            val[pos] += v;
            pos += pos & -pos;
        }
    }
    T sum(int pos)
    {
        T res = 0;
        while (pos > 0)
        {
            res += val[pos];
            pos -= pos & -pos;
        }
        return res;
    }
};


int cnt(const vector<double> &vec)
{
    vector<double> vec_sorted = vec;
    sort(vec_sorted.begin(), vec_sorted.end());
    
    map<double, int> ma;
    REP(i, vec_sorted.size()) ma[vec_sorted[i]] = i + 1;
    
    BIT<int, 40001> bit;
    int ans = 0;
    for (auto v : vec)
    {
        ans += bit.sum(ma[v]);
        bit.add(ma[v], 1);
    }
    return ans;
}

double solve(const vector<int> &A, const vector<int> &B, const vector<int> &C)
{
    using p = pair<double, double>;
    vector<p> info(N);
    REP(i, N) info[i] = p((double)A[i] / B[i], (double)C[i] / B[i]);
    sort(info.begin(), info.end());

    double l = -1E10, r = 1E10;
    while (r - l > 1E-10 and (r - l) > (abs(l) + abs(r)) * 1E-10)
    {
        double c = (l + r) / 2;
        vector<double> vec(N);
        REP(i, N) vec[i] = info[i].second - info[i].first * c;
        if (cnt(vec) > N * (N - 1) / 2 / 2) l = c;
        else r = c;
    }
    return l;
}

int main()
{
    cin >> N;
    A.resize(N);
    B.resize(N);
    C.resize(N);
    REP(i, N) cin >> A[i] >> B[i] >> C[i];

    cout << solve(A, B, C) << " " << solve(B, A, C) << endl;
}


Measured memory_bytes: 5708
# -*- coding: utf-8 -*-
"""
Created on Thu May 14 15:58:56 2020

@author: shinba
"""

n,k = map(int,input().split())

data = {}

for i in range(n):
    a,b = map(int,input().split())
    if not a in data:
        data[a] = b
    else:
        data[a] += b

Data = sorted(data.items())

l = 0

for i,j in Data:
    l += j
    if l >= k:
        print(i)
        break

    
    



Measured memory_bytes: 14564
from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))
B = list(accumulate(A))
mod = 10**9+7
ans = 0
sumA = sum(A)

for i in range(N-1):
    ans += A[i] * (sumA-B[i]) % mod
    ans = ans%mod
    
print(ans)




Measured memory_bytes: 102140
S = gets.strip
N = S.size
n = S.to_i

def dfs(s, n, a)
  if s.size == n
    a << s.to_i if s.split('').uniq.sort.eql?(['3', '5', '7'])
    return
  end

  dfs(s + '3', n, a)
  dfs(s + '5', n, a)
  dfs(s + '7', n, a)
end

a = []
3.upto(N) { |i| dfs('', i, a) }

puts a.count { |d| d <= n }


Measured memory_bytes: 2172
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

int dx[] = { -1, 0, 1, 0, -1, -1, 1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};


int main() {

	vector<string> v = {"Sunny", "Cloudy", "Rainy"};
	string s; cin >> s;

	if (s == v[0]) cout << v[1];
	else if (s == v[1]) cout << v[2];
	else cout << v[0];

	return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>

int main(void)
{
	int n, m;
	
	while (scanf("%d %d", &n, &m), n != 0){
		int i;
		int place[1000];
		int now;
		int flag = 0;
		int goal;
		
		for (i = 0; i < n; i++){
			scanf("%d", place + i);
		}
		
		now = 1;
		for (i = 0; i < m; i++){
			int t;
			
			scanf("%d", &t);
			if (n <= now + t){
				now = n;
			}
			else {
				now += t;
				now += place[now - 1];
				if (n < now){
					now = n;
				}
			}
			if (n == now && flag == 0){
				goal = i + 1;
				flag = 1;
			}
		}
		printf("%d\n", goal);
	}
	
	return 0;
}

Measured memory_bytes: 604
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] line = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();
		int[] sunuke =new int[line[0]];
		for (int i = 0; i < line[1]; i++) {
			sc.nextLine();
			int[] ret = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();
			for (int j = 0; j < ret.length; j++) {
				sunuke[ret[j] - 1]++;
			}
		}

		int ans =0;

		for (int i = 0; i < sunuke.length; i++) {
			if (sunuke[i] == 0) {
				ans++;
			}

		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 37280
#include<bits/stdc++.h>
#define lint long long
#define INF 0x3f3f3f3f3f3f3f3f
using namespace std;

lint pd[100010];
int h[100010];
int n,k;

long long sapo2(int i){
	if(pd[i] != -1) return pd[i];
	if(i == n) return pd[i] = 0;
	pd[i] = INF;
	for(int j=i+1; j<=i+k && j<=n ;j++){
		pd[i] = min(pd[i], abs(h[i] - h[j]) + sapo2(j));
	}
	return pd[i];
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>h[i];
	memset(pd,-1,sizeof(pd));
	cout<<sapo2(1)<<"\n";
	return 0;	
}


Measured memory_bytes: 6144
#include <iostream>
#include <cstring>
#define rep(i,n) for (int i = 0; i < (n); ++i) 
#define MAX 100000
#define SENTINEL 2000000000
#define NIL -1
typedef long long ll;
using namespace std;

struct Node {
    int parent; // parent
    int left; // most left child 
    int right; // right brother
};

Node T[MAX];
int D[MAX];

// args(u, p) u: node's element , p: node's depth
// recurrent function
void setDepth(int u, int p)
{
    D[u] = p;
    if(T[u].right != NIL) setDepth(T[u].right, p);
    if(T[u].left != NIL) setDepth(T[u].left, p+1);
}

void getType(int u)
{
    if(T[u].parent == NIL) cout << "root, ";
    else if (T[u].left == NIL) cout << "leaf, "; 
    else cout << "internal node, "; 
}

void printChildren(int u){
    cout << "[";
    int c = T[u].left;
    int i = 0;
    while (c != NIL){
       if(i) cout << ", ";
       cout << c;
       ++i;
       c = T[c].right; 
    }
    cout << "]";
}

int main()
{
    int n, id, k, c, l, root;
    cin >> n;
    rep(i, n) T[i].parent = T[i].left = T[i].right = NIL;

    rep(i, n){
        cin >> id >> k;
        rep(j, k){
            cin >> c;
            if(j == 0) T[id].left = c;
            else T[l].right = c;
            l = c;
            T[c].parent = id;
        }
    }

    rep(i, n){
        if(T[i].parent == NIL) root = i;
    }

    setDepth(root, 0);

    rep(i,n){
        cout << "node " << i << ": parent = " << T[i].parent << ", depth = " << D[i] << ", ";
        getType(i);
        printChildren(i);
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 7708
#include<iostream>
#define INT_MIN -100000000

using namespace std;

int main(){
	int n, t;
	int *a;

	cin>> n>> t;
	a= new int[n];

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

	int minA[n];
	int profit[n];

	minA[0]= a[0];
	profit[0]= -a[0];

	for(int i=1; i<n; i++) minA[i]= min(minA[i-1], a[i]);
	for(int i=1; i<n; i++) profit[i]= a[i]-minA[i-1]; 

	int maxProfit= INT_MIN;
	int numMax=0;
	for(int i=0; i<n; i++) maxProfit= max(maxProfit, profit[i]);
	for(int i=0; i<n; i++){
		if(profit[i] == maxProfit) numMax++;			
	}

	cout<< numMax<< endl;

	return 0;	
}


Measured memory_bytes: 1408
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int A, B;
	std::cin >> A >> B;
	std::cout << std::max(std::max(A+B, A-B), A*B) << "\n";
}


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

using namespace std;

int main(void){
    int s;
    cin>>s;
    int L=s/100;
    int R=s%100;
    if(1<=L&&L<=12){
        if(1<=R&&R<=12){
            cout<<"AMBIGUOUS"<<endl;
        }else{
            cout<<"MMYY"<<endl;
        }
    }else{
        if(1<=R&&R<=12){
            cout<<"YYMM"<<endl;
        }else{
            cout<<"NA"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void getSumList(long long lst[], int len){
  int p;
  for (int i = 0; i < len; i++){
    scanf("%d", &p);
    if(i == 0){
      lst[i] = p;
    }else{
	  lst[i] = lst[i-1] + p;
    }
  }
}

int main() {
  int n, m;
  long k;
  scanf("%d %d %ld", &n, &m, &k);
  long long asum[n+1] = {}, bsum[m] = {};
  asum[0] = 0;
  getSumList(&asum[1] ,n);
  getSumList(bsum, m);
  int max_cnt = 0;
  int b_pvcnt = m-1;
  for (int i = 0; i <= n; i++){
    if(asum[i] > k){
      break;
    }
    int curr_cnt = i;
    int zan_tm = k - asum[i];
    for(int j = b_pvcnt; j >= 0; j--){
      if (zan_tm < bsum[j]){
      }else{
        curr_cnt += j + 1;
        break;
      }
      b_pvcnt = j;
    }
    max_cnt = max_cnt < curr_cnt ? curr_cnt: max_cnt;
  }
  std::cout << max_cnt << endl;
  return 0;
}

Measured memory_bytes: 6848
N=int(input())

if(N%2==1):
    print(0)
    exit()

#s=0
#for i in range(2,N+1,2):
#    while(i%5==0 and i!=0):
#        s+=1
#        i=i//5
#print(s)

s=0
t=10
while(N>=t):
    s+=(N//t)
    t*=5
print(s)

#L=len(str(N))-1
#s+=L*(L-1)
#T=N//10
#s+=T
#print(s)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
bool isPalindrome(string str , int l , int h)
{

    //int l = 0;
    //int h = str.length() - 1;

    while (h > l)
    {
        if (str[l++] != str[h--])
        {

            return 0;
        }
    }

    return 1;
}
int main()
{
    string str;
    cin >> str;
    int k =str.length();
    int y = ((k-1)/2)-1 ;
    int z = ((k+3)/2)-1;
    if(isPalindrome(str,0,k-1) && isPalindrome(str,0,y ) && isPalindrome(str,z,k-1) )
       cout << "Yes" ;
    else cout <<"No";
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
	int n, m, l;

	cin >> n >> m >> l;

	int	A[100][100] = { 0 };
	int B[100][100] = { 0 };

	long int C[100][100] = { 0 };

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> A[i][j];

	for (int i = 0; i < m; i++)
		for (int j = 0; j < l; j++)
			cin >> B[i][j];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < m; k++)
				C[i][j] += A[i][k] * B[k][j];
			if (j == 0)
				cout << C[i][j];
			else
				cout << " " << C[i][j];
		}
		cout << endl;
	}

}


Measured memory_bytes: 3280
//Problem: DP_C from Educational DP Contest
//Progress: In Progress
#include <iostream>
#include <algorithm>
typedef long long int ll;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t, a, b, c;
    cin >> t;
    ll adp[t], bdp[t], cdp[t];
    for(ll i=0; i<t; i++){
        cin >> a >> b >> c;
        if(i == 0){
            adp[i] = max(b, c);
            bdp[i] = max(a, c);
            cdp[i] = max(a, b);
        }
        else{
            adp[i] = max(bdp[i-1], cdp[i-1]) + a;
            bdp[i] = max(adp[i-1], cdp[i-1]) + b;
            cdp[i] = max(adp[i-1], bdp[i-1]) + c;
        }
    }
    cout << max(adp[t-1], max(bdp[t-1], cdp[t-1]));
    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>

using std::cin;
using std::cout;
using std::endl;

int main(void) {
  int num = 0;
  int N;

  int A[10000];

  cin >> N;

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

  for (int i = 0; i < N; ++i) {
    while(A[i] % 2 == 0) {
      A[i] /= 2;
      num += 1;
    }
  }

  cout << num << endl;
  return 0;
  
}


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

int main() {
    int n;double count=0;double c;
cin>>n;
if(n>=1&&n<=100)
{
for(int i=1;i<=n;i++)
{
if(i%2!=0)
{
count++;
}
}
}
c=count/n;
cout<<c;
	// your code goes here
	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List

toThree :: String -> IO [Int]
toThree l =  return (map read . words $ l)

toArray :: [String] -> [[Int]]
toArray = map (map read . words)

getNLine :: [Int] -> IO ([[Int]], [[Int]])
getNLine (n:m:l:_) = do
        a <- replicateM n getLine
        b <- replicateM m getLine
        return (toArray a, toArray b)

multi :: [Int] -> [Int] -> Int
multi [] _ = 0
multi _ [] = 0
multi (a:as) (b:bs) = a * b + multi as bs

solv :: ([[Int]], [[Int]]) -> IO [[Int]]
solv (a, _b) = return $ map (\al -> map (\bl -> multi al bl ) b ) a
    where
      b = transpose _b

showRes :: [[Int]] -> String
showRes [] = ""
showRes (x:xs) = (concat . intersperse " " . map show $ x) ++ "\n" ++ (showRes xs)

main = getLine >>= toThree >>= getNLine >>= solv >>= putStr . showRes

Measured memory_bytes: 12224
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
#include <iomanip>
using namespace std;
// type alias
typedef long long LL;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))

// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');

// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpf(args...) if(TRACE) { fprintf(stderr, ##args); putchar('\n'); }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
template<class Iter> void dumpc(Iter begin, Iter end) { if (TRACE) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; } }

// $ cp-batch Pyramid | diff Pyramid.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Pyramid.cpp && ./a.out

/*
 
 1/17/2019
 
 14:49-
 
 */

const int MAX_N=1e2+1;
LL X[MAX_N],Y[MAX_N],H[MAX_N];
int N;

void solve() {
  REPE(cx,100)REPE(cy,100) {
    LL h=0;
    REP(i,N) if(H[i]!=0) {
      LL dx=abs(cx-X[i]),dy=abs(cy-Y[i]);
      h=H[i]+dx+dy;
      break;
    }
    if(h==0) continue;
    bool ok=true;
    REP(i,N) {
      LL dx=abs(cx-X[i]),dy=abs(cy-Y[i]);
      LL hh=max(h-dx-dy,0LL);
      ok&=hh==H[i];
    }
    if(ok) {
      println("%d %d %lld",cx,cy,h);
      return;
    }
  }
  assert(false);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>X[i]>>Y[i]>>H[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  int N,M;
  cin >> N >> M;
  int min,max;
  if(N == 1){
    min = 0;
    max = 9;
  }
  if(N == 2){
    min = 10;
    max = 99;
  }
  if(N == 3){
    min = 100;
    max = 999;
  }
  vector<int> s(M);
  vector<int> c(M);
  rep(i,M){
    cin >> s.at(i) >> c.at(i);
  }
  for(int n=min;n < max +1;n++){
    bool tf = true;
    rep(i,M){
      if(s.at(i) == N && n % 10 != c.at(i)){
        tf = false;
        break;
      }
      else if(s.at(i) == 1 && n /int(pow(10,N-1)) != c.at(i)){
        tf = false;
        break;
      }
      else if(s.at(i) == 2 && (n % int(pow(10,N-1))) / int(pow(10,N-2)) != c.at(i)){
        tf = false;
        break;
      }
    }
    if(tf){
      cout << n << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}

Measured memory_bytes: 256