akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    cout << 100 << " " << 100 << endl;
    char c[101][101];
    for(int i=0;i<50;i++)for(int j=0;j<100;j++)c[i][j]='.';
    for(int i=50;i<100;i++)for(int j=0;j<100;j++)c[i][j]='#';
    int i=0; int j=0;
    int k=0; int l=0;
    while(i<b-1){
        c[k][l]='#';
        i++;
        l+=2;
        if(l>=100){
            l=0;
            k+=2;
        }
    }
    k=51; l=0;
    while(j<a-1){
        c[k][l]='.';
        j++;
        l+=2;
        if(l>=100){
            l=0;
            k+=2;
        }
    }
    for(i=0;i<100;i++){
        for(j=0;j<100;j++)cout << c[i][j];
        cout << endl;
    }
}

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

int n;
bool *lst;
vector<pair<int,bool>> *proof;
//例のごとくindex0はつかわない.


void init(){
    cin>>n;
    lst = new bool[n+1];
    proof = new vector<pair<int,bool>>[n+1];
    for(int i=1;i<n+1;i++){
        int num;cin>>num;
        for(int j=0;j<num;j++){
            int x;bool t;cin>>x>>t;
            proof[i].push_back(make_pair(x,t));
        }
    }
}
bool judge(){
    for(int i=1;i<n+1;i++){
        if(lst[i] == 0)continue;//嘘つきの証言なら無視
        for(int j=0;j<proof[i].size();j++){
            int x = proof[i][j].first;
            bool t = proof[i][j].second;
            if(lst[x] != t)return 0;
        }
    }
    return 1;
}
void set(int t){
    for(int i=0;i<n;i++){
        lst[i+1] = (t >> i) & 0x1;
    }
}
int counter(){
    int cnt = 0;
    for(int i=1;i<n+1;i++){
        if(lst[i] == 1)cnt++;
    }
    return cnt;
}

int main(){
    init();
    int cnt = 0;
    for(int i=0;i<pow(2,n);i++){
        set(i);
        if(judge()){
            cnt = max(cnt,counter());
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
int main(){
    string s;cin >> s;
    int q;cin >> q;
    deque<char> d;
    for(int i=0;i<s.size();i++){
        d.push_back(s[i]);
    }
    int cnt=0;
    for(int i=0;i<q;i++){
        int type;cin >> type;
        if(type==1){
            cnt++;
        }
        else{
            int f;cin >> f;
            char c;cin >> c;
            if(f==1&&cnt%2==0||f==2&&cnt%2==1){
                d.push_front(c);
            }
            else d.push_back(c);
        }
    }
    if(cnt%2==1) reverse(d.begin(),d.end());
    string ans="";
    for(int i=0;i<d.size();i++){
        ans+=d[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 60;
constexpr auto mod = 1000000007;
constexpr auto MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    int f = 0, b = 0;
    int fcnt = 0, bcnt = 0;
    int itr = 0;
    while (itr < n) {
        while (itr < n && s[itr] == '(') {
            fcnt++;
            itr++;
        }
        while (itr < n && s[itr] == ')') {
            bcnt++;
            itr++;
        }

        if (fcnt < bcnt) {
            f += bcnt - fcnt;
            fcnt = 0;
        }
        else if (fcnt >= bcnt)fcnt -= bcnt;
        bcnt = 0;
    }
    b = fcnt;

    string F = "", B = "";
    FOR(i, 0, f)F += '(';
    FOR(i, 0, b)B += ')';
    cout << F + s + B << "\n";
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner
var out *bufio.Writer

const INF = 1 << 60

func main() {
	sc = bufio.NewScanner(os.Stdin)
	//bytes, _ := ioutil.ReadFile("./stdin.txt")
	//sc = bufio.NewScanner(strings.NewReader(string(bytes)))
	out = bufio.NewWriter(os.Stdout)
	buf := make([]byte, 1<<20)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	N, M := nextInt2()
	G := make([]map[int]int, N+1)
	for i := 0; i < len(G); i++ {
		G[i] = make(map[int]int)
	}
	for i := 0; i < M; i++ {
		a, b, c := nextInt3()
		G[a][b] = -c
	}
	d, neg := solve(G, 1)
	if !neg[N] {
		fmt.Fprintln(out, -d[N])
	} else {
		fmt.Fprintln(out, "inf")
	}
}

func solve(G []map[int]int, s int) ([]int, []bool) {

	d := make([]int, len(G))
	for i := 0; i < len(G); i++ {
		d[i] = INF
	}
	d[s] = 0
	neg := make([]bool, len(G))

	for i := 0; i < len(G)-1; i++ {
		end := true
		for u := 0; u < len(G); u++ {
			if d[u] == INF {
				continue
			}
			for v, cost := range G[u] {
				if d[v] > d[u]+cost {
					d[v] = d[u] + cost
					end = false
				}

			}
		}
		if end {
			return d, neg
		}
	}
	for i := 0; i < len(G); i++ {
		for u := 0; u < len(G); u++ {
			if d[u] == INF {
				continue
			}
			for v, cost := range G[u] {
				if d[v] > d[u]+cost {
					d[v] = d[u] + cost
					neg[v] = true
				}

			}
		}
	}
	return d, neg
}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInt2() (int, int)      { return nextInt(), nextInt() }
func nextInt3() (int, int, int) { return nextInt(), nextInt(), nextInt() }
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func cond(condition bool, t, f int) int {
	if condition {
		return t
	}
	return f
}
func abs(a int) int { return cond(a < 0, -a, a) }
func min(a ...int) int {
	ret := a[0]
	for i := 1; i < len(a); i++ {
		chmin(&ret, a[i])
	}
	return ret
}
func max(a ...int) int {
	ret := a[0]
	for i := 1; i < len(a); i++ {
		chmax(&ret, a[i])
	}
	return ret
}
func chmin(a *int, b int) { *a = cond(*a < b, *a, b) }
func chmax(a *int, b int) { *a = cond(*a > b, *a, b) }


Measured memory_bytes: 2136
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
  int N;
  int ans = 0;
  cin >> N;
  for(int A = 1; A < N;A++){
    ans += (N-1)/A;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int mod;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int popcount(int x){
	int res = 0;
	while(x){
		res += (x&1);
		x >>= 1;
	}
	return res;
}

int f(int x, int c){
	if(x == 0) return c;
	return f(x % popcount(x), c+1);
}

int main() {
	int n; cin >> n;
	string x; cin >> x;
	int k = count(x.cbegin(), x.cend(), '1');
	vector<int> s(n), l(n);
	int sums = 0;
	int suml = 0;
	if(k > 1){
		int t = 1 % (k-1);
		for(int i=0; i<n;  i++){
			s[i] = t;
			t = (t * 2) % (k - 1);
			if(x[n-1-i] == '1'){
				sums = (sums + s[i]) % (k-1);
			}
		}
	}
	int t = 1 % (k+1);
	for(int i=0; i<n; i++){
		l[i] = t;
		t = (t * 2) % (k + 1);
		if(x[n-1-i] == '1'){
			suml = (suml + l[i]) % (k+1);
		}
	}
	if(k>1){
	rep(i,n){
		if(x[i] == '1'){
			int d = (sums + (k-1) - s[n-1-i]) % (k-1);
			cout << f(d,1) << endl;
		}else{
			int d = (suml + l[n-1-i]) % (k+1);
			cout << f(d,1) << endl;
		}
	}
	}else{
		rep(i,n){
		if(x[i] == '1'){
			cout << "0\n";
		}else{
			int d = (suml + l[n-1-i]) % (k+1);
			cout << f(d,1) << endl;
		}
		}
	}
}

Measured memory_bytes: 5240
#pragma region template
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n, q;
  cin >> n >> q;
  fenwick_tree<ll> ft(n);
  rep(i, n){
    ll x;
    cin >> x;
    ft.add(i, x);
  }
  while(q--){
    ll a, b, c;
    cin >> a >> b >> c;
    if(a == 0){
      ft.add(b, c);
    }else{
      print(ft.sum(b, c));
    }
  }
}


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

const int INF = 1001001001;

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> key;
  rep(i, m){
    int a, b;
    cin >> a >> b;
    int s = 0;
    rep(j, b){
      int c;
      cin >> c;
      --c;
      s |= 1 << c;
    }
    key.emplace_back(s, a);
  }
  vector<int> dp(1 << n, INF);
  dp[0] = 0;
  rep(s, 1<<n){
    rep(i, m){
      int t=s | key[i].first;
      int cost = dp[s] + key[i].second;
      dp[t] = min(dp[t], cost);
    }
  }
  int ans = dp.back();
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}


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

int main()
{
	string s, t;
	cin >> s >> t;
	int n = s.length(), ans = 0;

	for (int i = 0; i < n; i++)
	{
		if (s[i] != t[i])
		{
			ans++;
		}

	}

	cout << ans << endl;
}

Measured memory_bytes: 3844
### constant

MOD = 2011

### subroutines

def get_base(strs, topl, btml)
  base = nil
  while base.nil?
    for y in (topl..btml)
      if strs[y][$pos] != '.'
        base = y
        break
      end
    end
    $pos += 1 if base.nil?
  end
  base
end

def expr(strs, topl, btml, base = nil)
  #p ["expr", topl, btml, base, $pos]

  base = get_base(strs, topl, btml) if base.nil?
  
  v = term(strs, topl, btml, base)
  op = strs[base][$pos + 1]
  while op == '+' || op == '-'
    $pos += 3
    v0 = term(strs, topl, btml, base)
    v = (op == '+') ? (v + v0) % MOD : (v - v0) % MOD
    op = strs[base][$pos + 1]
  end

  #p ["  expr", v, base]
  v
end

def term(strs, topl, btml, base)
  #p ["term", topl, btml, base, $pos]

  v = factor(strs, topl, btml, base)
  while strs[base][$pos + 1] == '*'
    $pos += 3
    v0 = factor(strs, topl, btml, base)
    v = (v * v0) % MOD
  end

  #p ["  term", v, $pos]
  v
end

def factor(strs, topl, btml, base)
  #p ["factor", topl, btml, base, $pos]

  v = nil
  if strs[base][$pos, 2] == '--'
    v = fraction(strs, topl, btml, base)
  elsif strs[base][$pos, 2] == '-.'
    $pos += 2
    v = MOD - factor(strs, topl, btml, base)
  else
    v = powexpr(strs, topl, btml, base)
  end

  #p ["  factor", v, $pos]
  v
end

def powexpr(strs, topl, btml, base)
  #p ["powexpr", topl, btml, base, $pos]

  v = primary(strs, topl, btml, base)

  if base > 0 && strs[base - 1][$pos] =~ /[0-9]/
    n = digit(strs, topl, btml, base - 1)

    pm = 1
    while n > 0
      pm = (pm * v) % MOD if (n & 1) == 1
      v = (v * v) % MOD
      n >>= 1
    end

    v = pm
  end

  #p ["  powexpr", v, $pos]
  v
end

def primary(strs, topl, btml, base)
  #p ["primary", topl, btml, base, $pos]

  v = nil
  if strs[base][$pos] == '('
    $pos += 2
    v = expr(strs, topl, btml, base)
    $pos += 2
  else
    v = digit(strs, topl, btml, base)
  end

  #p ["  primary", v, $pos]
  v
end

def fraction(strs, topl, btml, base)
  #p ["fraction", topl, btml, base, $pos]

  pos0 = $pos
  v0 = expr(strs, topl, base - 1)
  $pos = pos0
  v1 = expr(strs, base + 1, btml)
  $pos = pos0
  v = (v0 * $invs[v1]) % MOD

  while strs[base][$pos] == '-'
    $pos += 1
  end

  #p ["  fraction", v, $pos]
  v
end

def digit(strs, topl, btml, base)
  #p ["digit", topl, btml, base, $pos]

  v = strs[base][$pos].to_i
  $pos += 1

  #p ["  digit", v, $pos]
  v
end

### main

$invs = Array.new(MOD){0}
for y in (1...MOD)
  for z in (1...MOD)
    if (y * z) % MOD == 1
      $invs[y] = z
      break
    end
  end
end
#p $invs; exit

loop do
  n = gets.to_i
  break if n == 0

  strs = Array.new(n){gets.strip}
  #p strs

  $pos = 0
  p expr(strs, 0, n - 1)
end

Measured memory_bytes: 6080
#include<bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	typedef double d;
    #define    thunder   ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL)
    int main()

    {
    thunder;
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    int64_t c=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]<a[i-1]) {c+=(a[i-1]-a[i]);a[i]=a[i-1];}
    }
    cout<<c;
    }

Measured memory_bytes: 4376
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#define N 1000005
using namespace std;
struct P{
	int l,r;
	P(){}
	P(int a,int b){l=a;r=b;}
	friend bool operator <(P a,P b){
		return a.l<b.l;
	}
}a[N];
char st[N],t[N];
int n,tot,ans=0,mx[N],pos[26];
vector<int> v[26];
set<P> s;
void add(int k,int val){
	for(k;k<=n;k+=k&-k) mx[k]=max(mx[k],val);
}
int find(int k){
	int ans=0;
	for(k;k;k-=k&-k) ans=max(ans,mx[k]);
	return ans;
}
bool solve(){
	bool G=1;
	for(int i=1;i<=n;i++){
		v[st[i]-'a'].push_back(i);
		if(st[i]!=t[i]) G=0;
	}
	for(int i=0;i<26;i++) pos[i]=v[i].size()-1;
	if(G) return 1;
	for(int i=n,p;i;i=p){
		for(p=i;t[p]==t[i]&&p;p--);
		int x=t[i]-'a';
		while(pos[x]>=0&&((v[x][pos[x]]>=a[tot].l&&tot)||(v[x][pos[x]]>p+1)))
			pos[x]--;
		if(pos[x]<0) return 0;
		a[++tot]=P(v[x][pos[x]],i);
	}
	sort(a+1,a+tot+1);
	ans=1;
	for(int i=tot;i;i--){
		int l=i+1,r=tot,mid;
		mx[i]=1;
		while(l<=r){
			mid=l+r>>1;
			if(a[mid].l-(mid-i-1)<=a[i].r) mx[i]=(mid-i+1),l=mid+1;
			else r=mid-1;
		}
		ans=max(ans,mx[i]);
	}
	return 1;
}
int main(){
	scanf("%d",&n);
	scanf("%s",st+1);
	scanf("%s",t+1);
	if(!solve()) puts("-1");
	else printf("%d",ans);
	return 0;
}

Measured memory_bytes: 19020
import std.stdio;
import std.string;
import std.array; // split
import std.conv; // to

void main()
{
   string[] input = split(readln()); // splitで文字列を文字列の配列に切り分け
   int a = to!int(input[0]); // 第0要素を整数に変換
   int b = to!int(input[1]); // 第1要素を整数に変換
   if((a*b)%2 == 0){
       writeln("Even"); // 表示
   } else {
       writeln("Odd"); // 表示
   }
   
}

Measured memory_bytes: 256
def det_par_sib_deg(nodes):
    n = len(nodes)
    parent = [-1] * n
    sibling = [-1] * n
    degree = [0] * n
    
    for i in range(n):
        p = nodes[i][0]
        l = nodes[i][1]
        r = nodes[i][2]
        if l==-1 and r==-1:
            degree[i] = 0
        elif l!=-1 and r==-1:
            parent[l] = p
            degree[i] = 1
        elif l==-1 and r!=-1:
            parent[r] = p
            degree[i] = 1
        else:
            parent[l] = parent[r] = p
            sibling[l] = r
            sibling[r] = l
            degree[i] = 2
    
    return parent, sibling, degree

def get_root(parent):
    n = len(parent)
    for i in range(n):
        if parent[i]==-1:
            return i

def det_types(root,nodes,degree):
    n = len(nodes)
    types = [""] * n
    for i in range(n):
        if degree[i]==0:
            types[i] = "leaf"
        else:
            types[i] = "internal node"
    types[root] = "root"
    return types

def get_child(num,nodes,degree):
    deg = degree[num]
    if deg==2:
        return deg, [nodes[num][1], nodes[num][2]]
    if deg==1:
        if nodes[num][1]==-1:
            return deg, [nodes[num][2]]
        else:
            return deg, [nodes[num][1]]
    if deg==0:
        return deg, []

def get_leaves(nodes,types):
    n = len(nodes)
    leaves = []
    for i in range(n):
        if types[i]=="leaf":
            leaves.append(i)
    return leaves

def det_height_depth(root,nodes,parent,types):
    n = len(nodes)
    height = [0] * n
    depth = [0] * n
    
    leaves = get_leaves(nodes,types)    
    for leaf in leaves:
        branch = [leaf]
        h = 1
        p = parent[leaf]
        while p!=-1:
            branch.append(p)
            if h>height[p]:
                height[p] = h
            p = parent[p]
            h += 1
        for i,node in enumerate(branch):
            depth[node] = (h-1) - i
        
    return height, depth

# def det_depth(root,nodes,parent,types,height):
#     n = len(nodes)
#     depth = [0] * n
    
#     leaves = get_leaves(nodes,types)
    
#     for leaf in leaves:
#         h = 1
#         p = parent[leaf]
#         branch = [leaf, p]
#         while p!=-1:
#             p = parent[p]
#             branch.append(p)
#             h += 1
#         for node in branch:
#             depth[node] = (h - 1) - height[node]
        
#     return depth

def print_res(n, nodes):
    parent, sibling, degree = det_par_sib_deg(nodes)
    root = get_root(parent)
    types = det_types(root,nodes,degree)
    height, depth = det_height_depth(root,nodes,parent,types)
    for i in range(n):
        num = nodes[i][0]        
        print("node " + str(num) + \
              ": parent = " + str(parent[i]) + \
              ", sibling = " + str(sibling[i]) + \
              ", degree = " + str(degree[i]) + \
              ", depth = " + str(depth[i]) + \
              ", height = " + str(height[i]) + \
              ", " + types[i] )

if __name__ == "__main__":
    n = int(input())
    nodes = [[]] * n
    for i in range(n):
        node = list(map(int, input().split()))
        nodes[node[0]] = node
    print_res(n,nodes)


Measured memory_bytes: 5628
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {

    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n; cin >> n;
    int x = ceil(n/1.08);
    if (floor(x*1.08) <= n)
        cout << x << endl;
    else
        cout << ":(" endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 200010 
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
int n,a[N],pl[N],f[N];
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read(),pl[a[i]]=i,f[i]=1;	
	int ans=1;
	for(int i=2;i<=n;i++)
		if(pl[i-1]<pl[i]) f[i]=f[i-1]+1,ans=max(ans,f[i]);
	printf("%d",n-ans);		
	
	return 0;
}

Measured memory_bytes: 2560
n = int(input())

table = [ [0]*10 for _ in range(10) ]

# print(table)

for i in range(1,n+1):
    a = str(i)
    s = int(a[0])
    e = int(a[-1])
    table[s][e] += 1

# print(table)

ans = 0
for i in range(10):
    for j in range(10):
        ans += table[i][j] * table[j][i]

print(ans)

Measured memory_bytes: 3064
[N, M] = map(int, input().split())
a = [list(map(int, input().split())) for i in range(N)]
def v(x, s):
	return sum([x[i]*(1 - 2*((s & (1 << i)) >> i)) for i in range(3)])
print(0 if M == 0 else max([sum([v(a[j], s) for j in sorted([i for i in range(N)], key = lambda i : v(a[i], s))[-M:]]) for s in range(8)]))

Measured memory_bytes: 3392
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i< (n) ; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
  int data[100];
  int n,m,res=0;
  cin >> n;
  rep(i,n){
    cin >> data[i];
  }
  for(int i=0;i<n;i++){
  	for(int j=i+1;j<n;j++){
  		for(int k=j+1;k<n;k++){
          if(data[i]==data[j] || data[j]==data[k] || data[k]==data[i] ) continue;
           if((data[i] < (data[j] + data[k])) && 
             (data[j] < (data[i] + data[k])) &&
             (data[k] < (data[j] + data[i])) ) res++;
  		}
  	}
  }
	cout << res << endl;

    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
 
 
int main () {
    int N,A;

    cin >> N;

    int max = 0;
    int min = 1000000000;
    rep(i,N){
        cin >>A;
        if(max < A) max =A;
        if(min > A) min =A;
    }

    cout << (max-min) << endl;
}

    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int na = (c + b - 1) / b;
  int nb = (a + d - 1) / d;
  cout << (na <= nb ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

template <class T>
struct SegmentTree{
  using F = function<T(T,T)>;
  F f;
  T inf;
  int n;
  vector<T> node;

  SegmentTree(vector<T> v,T inf,F f):inf(inf),f(f){
    n = 1; while(n < v.size()) n *= 2;
    node.resize(2*n-1,inf);
    for(int i = 0; i < v.size(); i++) node[i+n-1] = v[i];
    for(int i = n-2; i >= 0; i--) node[i] = f(node[2*i+1],node[2*i+2]);
  }

  void update(int k,T val){
    k += n-1;
    node[k] = val;
    while(k > 0){
      k = (k-1) / 2;
      node[k] = f(node[2*k+1],node[2*k+2]);
    }
  }

  void add(int k,T val){
    k += n-1;
    node[k] += val;
    while(k > 0){
      k = (k-1) / 2;
      node[k] = f(node[2*k+1],node[2*k+2]);
    }
  }

  T getval(int a,int b){ return getval(a,b,0,0,n); }
  T getval(int a,int b,int k,int l,int r){
    //区間[a, b)の値を返す
    if(r <= a || b <= l) return inf;
    if(a <= l && r <= b) return node[k];
    T vl = getval(a, b, 2*k+1, l, (l+r)/2);
    T vr = getval(a, b, 2*k+2, (l+r)/2, r);
    return f(vl, vr);
  }
};

const int N = 200001;

signed main(){

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

  SegmentTree<int> seg(vector<int>(N,0),0,[&](int x,int y){
    return max(x,y);
  });
  for(int i = 0; i < n; i++){
    int res = seg.getval(0,h[i]) + a[i];
    if(seg.getval(h[i],h[i]+1) < res){
      seg.update(h[i],res);
    }
  }
  cout << seg.getval(0,N) << endl;

  return 0;
}


Measured memory_bytes: 9088
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int r;
	cin >> r;
	cout << 3 * r * r << endl;
}

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  double k;
  cin >> k;
  cout << ((int)k)/2 *ceil(k/2) << endl; 
  return 0;
    

}


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

#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(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;

//////////////////ここの値は必ず確認！！！！！////////////////////
//---------------------------------------------------------//
const int MOD = 1e9+7;
const int MAXR = 510000;
//---------------------------------------------------------//

template<ll mod> class modint{
public:
    ll val=0;
    //コンストラクタ
    modint(ll x=0){while(x<0)x+=mod;val=x%mod;}
    //コピーコンストラクタ
    modint(const modint &r){val=r.val;}
    //算術演算子
    modint operator -(){return modint(-val);} //単項
    modint operator +(const modint &r){return modint(*this)+=r;}
    modint operator -(const modint &r){return modint(*this)-=r;}
    modint operator *(const modint &r){return modint(*this)*=r;}
    modint operator /(const modint &r){return modint(*this)/=r;}
    //代入演算子
    modint &operator +=(const modint &r){
        val+=r.val;
        if(val>=mod)val-=mod;
        return *this;
    }
    modint &operator -=(const modint &r){
        if(val<r.val)val+=mod;
        val-=r.val;
        return *this;
    }
    modint &operator *=(const modint &r){
        val=val*r.val%mod;
        return *this;
    }
    modint &operator /=(const modint &r){
        ll a=r.val,b=mod,u=1,v=0;
        while(b){
            ll t=a/b;
            a-=t*b;swap(a,b);
            u-=t*v;swap(u,v);
        }
        val=val*u%mod;
        if(val<0)val+=mod;
        return *this;
    }
    //等価比較演算子
    bool operator ==(const modint& r){return this->val==r.val;}
    bool operator <(const modint& r){return this->val<r.val;}
    bool operator !=(const modint& r){return this->val!=r.val;}
};

using mint = modint<MOD>;

//入出力ストリーム
istream &operator >>(istream &is,mint& x){//xにconst付けない
    ll t;is >> t;
    x=t;
    return (is);
}
ostream &operator <<(ostream &os,const mint& x){
    return os<<x.val;
}

//累乗
mint modpow(const mint &a,ll n){
    if(n==0)return 1;
    mint t=modpow(a,n/2);
    t=t*t;
    if(n&1)t=t*a;
    return t;
}

//二項係数の計算
mint fac[MAXR+1],finv[MAXR+1],inv[MAXR+1];
//テーブルの作成
void com_init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    FOR(i,2,MAXR){
        fac[i]=fac[i-1]*mint(i);
        inv[i]=-inv[MOD%i]*mint(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}
//演算部分
mint com(ll n,ll k){
    if(k==0) return 1;
    if(n<k)return 0;
    if(n<0)return 0;
    if(k<0)return 0;
    return fac[n]*finv[k]*finv[n-k];
}

int main() {
    com_init();
    int N; cin >> N;
    cout << modpow(10,N) + modpow(8,N) - modpow(9,N) - modpow(9,N) << endl;

    return 0;
}

Measured memory_bytes: 15588
from collections import deque

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

result = deque([])
while b:
    t = len(result)
    for i in range(len(b) - 1, -1, -1):
        if b[i] == i + 1:
            result.appendleft(b.pop(i))
            break
    if len(result) == t:
        break

if not b:
    print('\n'.join(str(i) for i in result))
else:
    print(-1)


Measured memory_bytes: 3444
l, r = map(int, input().split())

# # 
# l = 2020
# r = 2040
r = min(r, l + 2019)

min = -1
for tl in range(l, r + 1):
  for tr in range(tl + 1, r + 1):
    tmp = (tl * tr) % 2019
    if min == -1 or min > tmp:
      min = tmp

print(min)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<set>

using namespace std;

int main(){
  set<string> s;
  int n;
  cin >> n ;
  string array[n];
  for(int i=0;i<n;i++){
    cin >> array[i];
  }
  for(int i=0;i<n;i++){
    s.insert(array[i]);
  }
  //set<string> a{array};
  cout << s.size() << endl;
}

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

int main () {
   int a,b,c;
   cin >>a>>b>>c;

  if (a==b &&a!=c){
    cout <<"Yes"<<endl;
  }else if (b==c&&a!=b){
    cout <<"Yes"<<endl;
  }else if(a==c&&a!=b){
    cout <<"Yes"<<endl;
  }else {
    cout <<"No"<<endl;
  }
}


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

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

    int cou = B - A + 1;
    int jud = 0;
    int ans;
    int q[5];

    for(int i = 0; i < cou; i++){
        ans = A + i;
        for(int j = 0;j < 5; j++){
            q[j] = ans % 10;
            ans /= 10;
        }

        if(q[0] == q[4] && q[1] == q[3]){
            jud++;
        }
    }

    cout << jud << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a[100001],n;
	cin>>n;int sum=0;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		if(a[i]==i){
			int t=a[i];
			a[i]=a[i+1];
			a[i+1]=t;
			sum++;
		}
	cout<<sum<<endl;


}

Measured memory_bytes: 640
N,C,K = [int(i) for i in input().split()]
T = [int(input()) for _ in range(N)]

T.sort()
ans = 1
p = T[0]
count = 1
for i in range(1,N):
    if T[i]-p > K:
        ans += 1
        count = 1
        p = T[i]
    else:
        if count < C:
            count += 1
        else:
            ans += 1
            count = 1
            p = T[i]

print(ans)


Measured memory_bytes: 52184
# S の長さが K 以下であれば、S をそのまま出力してください。
# S の長さが K を上回っているならば、
# 先頭 K 文字だけを切り出し、末尾に ... を付加して出力してください。

# K は 1 以上 100 以下の整数
# S は英小文字からなる文字列
# S の長さは 1 以上 100 以下

K = int(input())
S = str(input())

if K >= len(S):
    print(S)
else:
    print((S[0:K] + '...'))


Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>Pi;
#define S second
#define F first
#define psb push_back
#define pob pop_back
#define mpa make_pair
int main(){
  stack<int>place;
  vector<Pi>sub;
  string s;
  int flag = 0,flug = 0;
  int cnt = 0;
  cin >> s;
  for(int i = 0;i < s.size();i++){
    if(s[i] == '\\'){place.push(i);cnt++;flag = true;}
    else if(s[i] == '/'){
      cnt--;if(flag)flug = true;
      if(place.empty())sub.psb(mpa(0,cnt));
      else {
	int p = place.top();place.pop();
	int size = sub.size();size--;
	int sum = i - p;
	while(~size && sub[size].S > cnt){
	  sum += sub[size].F;sub.pob();size--;
	}
	sub.psb(mpa(sum,cnt));
      }
    }
  }
  int water = 0;cnt = 0;
  for(int i = 0;i < sub.size();i++){
    if(sub[i].F){cnt++;water += sub[i].F;}
  }
  cout << water << endl;
  cout << cnt;
  if(!flug || sub.empty())cout << endl;
  else cout << " ";
  int i;
  int sz = -1;
  for(i = sub.size() - 1;i >= 0;i--){
    if(sub[i].F){sz = i;break;}
  }
  for(i = 0;i <= sz - 1;i++){
    if(sub[i].F)cout << sub[i].F << " ";
  }
  if(~sz && sub[i].F)cout << sub[i].F << endl;
  return 0;
}

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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define PI         2*acos(0.0)
#define lb         lower_bound
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define btpc       __builtin_popcountll
#define spc(x)     cout<<fixed<<setprecision(x)

const   long long  cs=2e5+5;
const   long long  inf=1e18;
const   long long  mod=1e9+7;
void solve()
{
    int64_t t,n,m,a,b,c,d,e,i,j,k,x,y,cnt=0,cnt1=0;
    bool flag = false;   
    
    cin>>n;
    cout<<3*n*n<<endl;
    
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3588
#!/usr/bin/env/ python3
import sys

"""
嫌いな数字がk個あり，それがd1~dk
N円のものを買うときの最低値
入力:
n k
d1-dk
"""


def contain(s, l):
    for i in range(len(s)):
        for j in l:
            if s[i] == j:
                return False
    else:
        return True


def main():
    n, k = map(str, input().split())
    kirai_num_list = input().split()

    if contain(n, kirai_num_list):
        print(n)
    else:
        while True:
            n = int(n) + 1
            if contain(str(n), kirai_num_list):
                print(str(n))
                sys.exit()


if __name__ == "__main__":
    main()


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;
	int cnt = 0;
	int mini = 2e9;
	ll res = 0;
	REP(i, n) {
		int a; cin >> a;
		if (a < 0) cnt++;
		mini = min(mini, abs(a));
		res += abs(a);
	}
	// cout << mini << " " << cnt << " " << res << '\n';
	if (cnt % 2) res -= mini * 2;
	cout << res << '\n';
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

#define N 36

typedef struct {
    char sign;
    int number;
}Card;

typedef struct {
    Card card[N];
}Card_Array;

void comp_memer(Card_Array, Card_Array, int);
void print_array(Card_Array, int);
Card_Array Bubble(Card_Array, int);
Card_Array Selection(Card_Array, int);

int main() {
    int i, num;
    Card_Array data[3];
    

    scanf("%d", &num);
    for(i=0; i<num; ++i) 
        scanf(" %c%d", &data[0].card[i].sign, &data[0].card[i].number);
    
    data[1] = Bubble(data[0], num);
    printf("Stable\n");

    data[2] = Selection(data[0], num);
    comp_memer(data[1], data[2], num);

    return 0;
}

Card_Array Bubble(Card_Array p, int num) {
    int i,j;
    Card tmp;
    Card_Array ret_data;

    for(i=0; i<num; ++i){
        for(j=num-1; j>=i+1; --j){
            if(p.card[j].number < p.card[j-1].number) {
                tmp = p.card[j];
                p.card[j] = p.card[j-1];
                p.card[j-1] = tmp; 
            }
        }
        ret_data.card[i] = p.card[i];
    }
    print_array(p, num);

    return ret_data;
}

Card_Array Selection(Card_Array p, int num) {
    int i, j, minj = 0;
    Card tmp;
    Card_Array ret_data;
    
    for(i=0; i < num; ++i){
        minj = i;
        for(j=i; j < num; ++j){
            if(p.card[j].number < p.card[minj].number)
                minj = j;
        }
        tmp = p.card[i];
        p.card[i] = p.card[minj];
        p.card[minj] = tmp;
        ret_data.card[i] = p.card[i];
    }
    print_array(p, num);

    return ret_data;
}

void print_array(Card_Array data, int num) {
    int i;
    for(i=0; i<num; ++i) {
        if(i) 
            printf(" ");

        printf("%c%d", data.card[i].sign, data.card[i].number);
    }
    printf("\n");
}

void comp_memer(Card_Array data1, Card_Array data2, int num){
    int i;

    for(i=0; i<num; ++i){
        if(data1.card[i].sign != data2.card[i].sign){
            printf("Not stable\n"); 
            return ;
        }
    }
    printf("Stable\n");
}


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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Yes or No
void yesno(bool ok, string yes = "Yes", string no = "No") {
  cout << (ok ? yes : no) << endl;
}

// Paste snippets here!!

//

void solve(long long N, long long M, long long K, std::vector<long long> A,
           std::vector<long long> B)
{
  vec<ll> cumB(M+1,0);
  rep(i,M){ cumB[i+1]=cumB[i]+B[i]; }
  ll ret = 0; ll cumA = 0;
  //dump(cumB);
  rep(i,N+1){
    // A から i 冊読む場合
    if(cumA>K) continue;
    auto it = lower_bound(all(cumB), K-cumA);
    int j = it - cumB.begin();
    if(*it != K-cumA) j--;
    if(j<0) continue;
    if(ret<i+j) ret = i+j;
    cumA += A[i];
  }
  cout << ret << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long N;
  std::cin >> N;
  long long M;
  std::cin >> M;
  long long K;
  std::cin >> K;
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    std::cin >> A[i];
  }
  std::vector<long long> B(M);
  for (int i = 0; i < M; i++) {
    std::cin >> B[i];
  }
  solve(N, M, K, std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 7944
k = int(input())
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list[k-1])


Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>
#include <iostream>
using namespace std;

int main(){
	int N;
	int K, con_K;
	cin >> N >> K;
	if (N>=1&&K<=100) {
		if (N%2==0) {
			con_K = N / 2;
		}
		else {
			con_K = (N + 1) / 2;
		}
		if (con_K >= K) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}

}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
	s := nextString()
	q := nextInt()
	now := 0
	add_top := make([]string, 0, q)
	add_tail := make([]string, 0, q)
	for i := 0; i < q; i++ {
		t := nextInt()
		if t == 1 {
			now++
		}
		if t == 2 {
			f := nextInt()
			c := nextString()
			if (now%2 == 0 && f == 1) || (now%2 == 1 && f == 2) {
				add_top = append(add_top, c)
			} else {
				add_tail = append(add_tail, c)
			}
		}
	}
	if now%2 == 0 {
		for i := len(add_top) - 1; i >= 0; i-- {
			fmt.Print(add_top[i])
		}
		fmt.Print(s)
		for i := 0; i < len(add_tail); i++ {
			fmt.Print(add_tail[i])
		}
		fmt.Println()
	} else {
		for i := len(add_tail) - 1; i >= 0; i-- {
			fmt.Print(add_tail[i])
		}
		for i := len(s) - 1; i >= 0; i-- {
			fmt.Print(string(s[i]))
		}
		for i := 0; i < len(add_top); i++ {
			fmt.Print(add_top[i])
		}
		fmt.Println()
	}
}

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

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

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 10752
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<uint> vuint;
typedef vector<ull> vull;
typedef vector<ll> vll;

#define init(type,var) type var;cin>>var;
#define vinit(type,var,n) vector<type> var((uint)n);loop(i,0,n)cin>>var[i];
#define linit(type,var,n) list<type> var;loop(i,0,n){type _v;cin>>_v;var.push_back(_v);}
#define range(container) container.begin(),container.end()
#define loop(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(out) cout<<(out)<<endl;

const ull INF = (ull)(-1LL);

typedef ull aint;

typedef vector<aint> vaint;
typedef list<aint> laint;

int main(void){
	init(aint, n);
	vinit(aint, a, n);

	aint l = 0;
	for (aint ai : a)l += ai;

	aint ans = 0;

	uint index = 0;
	while (a[index] * 2 < l)l -= a[index++] * 2;
	if (l < a[index] * 2 - l)ans = l;
	else ans = a[index] * 2 - l;

	outl(ans);

	return 0;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var list = readLine()!!.split(" ").map(String::toInt)
    var alice = 0
    var bob = 0
    list = list.sortedDescending()
    for (i in 0 until n) {
        if (i % 2 == 0) {
            alice += list[i]
        } else {
            bob += list[i]
        }
    }
    println(alice - bob)
}

Measured memory_bytes: 37928
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;i--)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);i--)
#define rep0(i,n) for(i=0;i<(n);++i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

string fld1[60];
string fld2[60];
int h,w;

bool inside(int x,int y){
	return 0<=x&&x<w&&0<=y&&y<h;
}

void f2(int x,int y){
	fld2[y][x]=' ';
	rep(i,4){
		if(inside(x+dx[i],y+dy[i])&&fld2[y+dy[i]][x+dx[i]]=='.')f2(x+dx[i],y+dy[i]);
	}
}

void f1(int x,int y){
	fld1[y][x]=' ';
	rep(i,4){
		if(inside(x+dx[i],y+dy[i])&&fld1[y+dy[i]][x+dx[i]]=='.')f1(x+dx[i],y+dy[i]);
	}
}

int main() {
	IL{
		cin>>w>>h;
		if(h==0&&w==0)break;
		rep(i,h)cin>>fld1[i];
		rep(i,h)fld2[i]=fld1[i];
		rep(i,h)rep(j,w)if(fld1[i][j]=='W')f1(j,i);
		rep(i,h)rep(j,w)if(fld2[i][j]=='B')f2(j,i);
		int res1=0,res2=0;
		rep(i,h)rep(j,w)if(fld1[i][j]=='.')++res1;
		rep(i,h)rep(j,w)if(fld2[i][j]=='.')++res2;
		bool ok1=false,ok2=false;
		rep(i,h)rep(j,w)if(fld1[i][j]=='B')ok1=true;
		rep(i,h)rep(j,w)if(fld2[i][j]=='W')ok2=true;
		cout<<(ok1?res1:0)<<" "<<(ok2?res2:0)<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s;
    s.push_back(string(w + 2, '#'));
    for (int i = 0; i < h; ++i) {
        string t;
        cin >> t;
        s.push_back("#" + t + "#");
    }
    s.push_back(string(w + 2, '#'));
    for (string t : s) cout << t << '\n';
    return 0;
}

Measured memory_bytes: 384