akhauriyash/Code-Regression huggingface dataset:
from collections import deque
import sys

stdin = sys.stdin
def li(): return map(int, stdin.readline().split())

N, M = tuple(li())
stack = []
for i in range(M):
    stack.append( tuple(li()) )

p_map = {}
for i in range(1, N + 1):
    # key: val
    # node_id: parent_id, union_size
    p_map[i] = [i, 1]

combs = deque()
def parent(i):
    if p_map[i][0] == i:
        return i
    else:
        return parent(p_map[i][0])
while stack:

    l, r = stack.pop()
    p_l = parent(l)
    p_r = parent(r)
    # parent should be greater
    if p_l == p_r:
        if combs:
            combs.appendleft(combs[0])
    else:
        if p_l < p_r:
            p_l, p_r = p_r, p_l
        p_map[p_r][0] = p_l
        incr = p_map[p_l][1] * p_map[p_r][1]
        p_map[p_l][1] += p_map[p_r][1]
        if combs:
            combs.appendleft(combs[0] + incr)
        else:
            combs.appendleft(incr)
cnt = 0
combs.append(0)
while combs:
    cur = combs.popleft()
    if combs:
        cnt += cur - combs[0]
        print(cnt)


Measured memory_bytes: 37732
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    char c;
    cin >> c;

    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}

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

int n, A[500000];

void maxHeapify(int A[], int i) {
    int l = 2 * i + 1;
    int r = 2 * i + 2;

    int largest = i;
    if (l < n && A[l] > A[largest]) largest = l;
    if (r < n && A[r] > A[largest]) largest = r;

    if (largest != i){
        swap(A[i], A[largest]);
        maxHeapify(A, largest);
    }
}

void maxHeap(int A[]) {
    for (int i = (n - 1)/ 2; i >= 0; i--)
        maxHeapify(A, i);
}

int main(void) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i];

    maxHeap(A);

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

    return 0;
}

Measured memory_bytes: 3112
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
int main(void) {
  int N, M;
  cin >> N >> M;
  multiset<int> A;
  int a;
  for(int i = 0; i < N; i++) {
    cin >> a;
    A.insert(a);
  }

  for(int i = 0; i < M; i++) {
    auto itr = A.end();
    itr--;
    int aa = (*itr) / 2;
    A.erase(itr);
    A.insert(aa);
  }
  long long ans = 0;
  for(auto itr = A.begin(); itr != A.end(); itr++) {
    ans += *itr;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
import sys
readline = sys.stdin.readline

N = int(readline())

ans = 10
for a in range(1, int(N ** 0.5) + 1):
  if N % a == 0:
    b = N // a
    f = max(len(str(a)),len(str(b)))
    if ans > f:
      ans = f
print(ans)

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

int main(){
    int x; cin >> x;
    int ans = 0;
    while(x > 0){
        if((x - 500) >= 0){
            x -= 500;
            ans += 1000;
        }else if((x - 5) >= 0){
            x -= 5;
            ans += 5;
        }else{
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  long a,b,c;
  scanf("%ld %ld %ld", &a, &b, &c);
  if (a%2 == 0 || b%2 == 0 || c%2 == 0) {
    printf("0\n");
    return 0;
  }
  long min = a*b;
  if (b*c < min) {
    min = b*c;
  }
  if (c*a < min) {
    min = c*a;
  }
  printf("%ld\n", min);

  return 0;
}

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

int N, M;
int MAX = 1010;
vector<vector<int>>  D(MAX, vector<int>(MAX));
vector<vector<char>> S(MAX, vector<char>(MAX));
vector<int> dx = { 0, 1,  0, -1 };
vector<int> dy = { 1, 0, -1,  0 };

int main()
{
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> S.at(i).at(j);
		}
	}
	queue<pair<int, int>> Q;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			if (S.at(i).at(j) == '#') {
				Q.push({ i,j });
			}
		}
	}

	int ans = 0;
	while (!Q.empty()) {
		int x = Q.front().first, y = Q.front().second;
		Q.pop();
		int d = D.at(x).at(y);
		ans = d;
		for (int k = 0; k < 4; k++) {
			int px = x + dx.at(k);
			int py = y + dy.at(k);
			if (px < 0 || px >= N || py < 0 || py >= M) continue;
			if (S.at(px).at(py) == '.') {
				Q.push({ px,py });
				S.at(px).at(py) = '#';
				D.at(px).at(py) = d + 1;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 13456
# 2019-11-10 17:11:42(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n = int(sys.stdin.readline().rstrip())
    for i in range(1, 10):
        nex = int(str(i) * 3)
        if nex >= n:
            ans = nex
            break
    
    print(ans)

if __name__ == "__main__":
    main()


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


Measured memory_bytes: 256
use std::io;
use std::collections::HashMap;


fn main() {
    let (n, k, l) = {
        let i = read::<usize>();
        (i[0], i[1], i[2])
    };

    let mut uf_road = UnionFind::new(n);
    let mut uf_train = UnionFind::new(n);

    for _ in 0..k {
        let (p, q) = {
            let i = read::<usize>();
            (i[0] - 1, i[1] - 1)
        };
        uf_road.unite(p, q);
    }

    for _ in 0..l {
        let (r, s) = {
            let i = read::<usize>();
            (i[0] - 1, i[1] - 1)
        };
        uf_train.unite(r, s);
    }

    let mut hm = HashMap::new();

    for i in 0..n {
        let key = (uf_road.find(i), uf_train.find(i));
        *hm.entry(key).or_insert(0) += 1;
    }

    let mut ans = Vec::new();
    for i in 0..n {
        let key = (uf_road.find(i), uf_train.find(i));
        let cnt: usize = *hm.get(&key).unwrap_or(&0);
        ans.push(cnt.to_string());
    }

    println!("{}", ans.join(" "));
}

struct UnionFind {
    par: Vec<usize>,
    rank: Vec<usize>,
}

impl UnionFind {
    fn new(n: usize) -> Self {
        UnionFind {
            par: (0..n).collect(),
            rank: vec![0; n],
        }
    }

    fn unite(&mut self, a: usize, b: usize) {
        use std::cmp;
        let x = self.find(a);
        let y = self.find(b);

        if x == y { return; }

        match self.rank[x].cmp(&self.rank[y]) {
            cmp::Ordering::Equal => {
                self.par[y] = x;
                self.rank[x] += 1;
            },
            cmp::Ordering::Less => {
                self.par[x] = y;
            },
            cmp::Ordering::Greater => {
                self.par[y] = x;
            }
        }
    }

    fn find(&mut self, a: usize) -> usize {
        if self.par[a] == a { a }
        else {
            let p = self.par[a];
            self.par[a] = self.find(p);
            self.par[a]
        }
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 28320
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
 
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }

#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 

void func() {
  string S;
  cin >> S;

  LL N = S.length()-1;

  LL total = 0;
  for (LL bit = 0; bit < (1 << N); ++bit) {
    //cout << std::bitset<10>(bit)<<endl;
    
    vector<string> A;
    string a = S.substr(0, 1);
    A.push_back(a);
    for (LL i = 0; i < N; ++i) {
      string a = S.substr(i+1, 1);
      //cout << std::bitset<10>(bit)<<endl;
      if (bit & (1 << i)) {
        A.push_back(a);
      }
      else{
        A[A.size()-1] += a;
      }
    }
    LL t=0;
    for(auto a : A){
      //cerr << atoi(a.c_str()) << endl;
      //cerr << a << " + ";
      //cerr << (LL)atoi(a.c_str()) << " + ";
       
      
      //t += (LL)atoi(a.c_str());
      t += (LL)std::stoll(a);
       
    }
    //cerr << " = " << t << endl;
    total +=t;
  }
  cout << total;
  return;
}

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

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#define INF 100000000
#define ll long long
using namespace std;

ll par[10000], rk[10000];

ll bitFind(ll x){
  if(x == par[x])
    return x;
  return par[x] = bitFind(par[x]);
}

ll bitSame(ll x, ll y){
  return bitFind(x) == bitFind(y);
}

void bitMerge(ll x, ll y){
  x = bitFind(x);
  y = bitFind(y);
  if(rk[x] < rk[y]){
    par[x] = y;
  }else if(rk[x] > rk[y]){
    par[y] = x;
  }else{
    par[x] = y;
    rk[y]++;
  }
}

int main(){
  ll V, E;
  cin >> V >> E;
  for(ll i = 0; i < V; i++){
    par[i]  = i;
    rk[i] = 0;
  }
  priority_queue< pair<ll, pair<ll,ll> >, vector< pair<ll, pair<ll,ll> > >, greater< pair<ll, pair<ll,ll> > > > pq;
  for(ll i = 0; i < E; i++){
    ll s,t,w;
    cin >> s >> t >> w;
    pq.push(make_pair(w,make_pair(s,t)));
  }
  ll cnt = 1;
  ll cost = 0;
  if(E == 0){
    cout << 0 << endl;
    return 0;
  }
  while(!pq.empty()){
    if(!bitSame(pq.top().second.first, pq.top().second.second)){
      bitMerge(pq.top().second.first, pq.top().second.second);
      cnt++;
      cost += pq.top().first;
    }

    if(cnt == V){
      cout << cost << endl;
      return 0;
    }
    pq.pop();
  }


}

Measured memory_bytes: 6036
#include <stdio.h>
 
int main()
{
    int a,b,i,sum=0;
    scanf("%d %d",&a,&b);
    char s[a+b+1];
    scanf("%s",s);
    for(i=0;i<a+b+1;i++){
        if(i!=a){
            if(s[i]>='0' && s[i]<='9')
            {sum++;}
        } else if(s[i]=='-')
        {sum++;}
    }
    (sum==a+b+1)? printf("Yes\n"): printf("No\n");
    return 0;
}

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int a, b, c;
    cin>>a>>b>>c;
    cout<<min(c, b/a)<<endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	vi a(3);
	for (auto& x : a)
		cin >> x;
	sort(all(a));
	if (a[1] == a[0] && a[1] != a[2] || a[1] == a[2] && a[1] != a[0])
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
// AOJ 2511 Sinking islands
// 2018.2.28 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 202

/* UNION-FIND library */
int id[MAX], size[MAX]; int cnt;
void init(int n) { int i; for (i = 0; i < n; i++) id[i] = i, size[i] = 1; }
int root(int i) { while (i != id[i]) id[i] = id[id[i]], i = id[i]; return i; }
int connected(int p, int q) { return root(p) == root(q); }
void unite(int p, int q) { int i = root(p), j = root(q); if (i == j) return;
cnt++; if (size[i] < size[j]) id[i] = j, size[j] += size[i]; else id[j] = i, size[i] += size[j];
}

int N, M;
int h[MAX], t[MAX], t2[MAX], s[MAX];
typedef struct { int a, b, c, t; } C;
C c[20000], c2[20000];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int tcmp(int *a, int *b) { return *a - *b; }
int ccmp(C *a, C *b) { return a->c - b->c; }
int c2cmp(C *a, C *b) { if (b->t - a->t) return b->t - a->t; return a->c - b->c; }

int uniq(int *a, int n)
{
	int i, j, k;

	s[0] = N;
	for (i = 0, j = 1; j < n; j++) {
		k = j; while (j < n && a[j] == a[i]) j++;
		s[i+1] = s[i] - (j-k+1);
		if (j < n) if (++i != j) a[i] = a[j];
	}
	return i+1;
}

int check(int id)
{
	int i, a, b, tm;

	init(N); cnt = 1; tm = t[id];
	for (i = 0; i < M; i++) {
		if (c2[i].t < tm) break;
		a = c2[i].a, b = c2[i].b;
		if (!connected(a, b)) unite(a, b);
		if (cnt == s[id]) return 0;
	}
	return 1;
}

int main()
{
	int i, j, k, tsz, tm, ans;
	int a, b;

	while (N = in()) {
		init(N); cnt = 1;

		M = in();
		for (i = 0; i < N; i++) h[i] = t[i] = in();
		for (i = 0; i < M; i++) {
			c[i].a = a = in()-1, c[i].b = b = in()-1, c[i].c = in();
			if (t[a] <= t[b]) c[i].t = t[a]; else c[i].t = t[b]; 
			unite(a, b);
		}
		if (cnt < N) { puts("0"); continue; }

		qsort(t, N, sizeof(int), tcmp);
		tsz = uniq(t, N);
		memcpy(c2, c, sizeof(C)*M);
		qsort(c, M, sizeof(C), ccmp);
		qsort(c2, M, sizeof(C), c2cmp);

		for (i = 1; i < tsz; i++) if (check(i)) break;
		k = i-1, tm = t[k];

		ans = 0;
		init(N);
		for (i = 0; i < M; i++) {
			a = c[i].a, b = c[i].b;
			if (h[a] >= tm && h[b] >= tm && !connected(a, b)) ans += c[i].c, unite(a, b);
		}
		i = 0; while (c2[i].t >= tm) i++;
		for (j = k-1; j >= 0; j--) {
			while (c2[i].t > t[j]) i++;
			while (c2[i].t == t[j]) {
				a = c2[i].a, b = c2[i].b;
				if (!connected(a, b)) ans += c2[i].c, unite(a, b);
				i++;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2784
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include<iomanip>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int inf = 1000000;

int main(int argc, const char * argv[]) {
  ll N, M;
  cin >> N >> M;
  
  if (M == 1) {
    cout << 0 << endl;
    return 0;
  }
  
  vector<ll> a(M, 0);
  for (ll i = 0; i < M; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  
  ll sdist;
  vector<ll> dis(M - 1, 0);
  for (ll i = 0; i < M - 1; i++) {
    dis[i] = a[i + 1] - a[i];
    sdist += dis[i];
  }
  sort(dis.begin(), dis.end());
  
  for (ll i = 0; i < N - 1; i++) {
    if (sdist >= 0) {
      sdist -= dis[dis.size() - 1 - i];
    }
  }
  
  cout << max(0ll, sdist) << endl;
  return 0;
}


Measured memory_bytes: 1792
package main

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

// Diff has diff value
type Diff struct {
	value int
}

// Diffs are slice of Diff
type Diffs []Diff

// Len return length
func (d Diffs) Len() int {
	return len(d)
}

// Swap is swapping
func (d Diffs) Swap(i, j int) {
	d[j], d[i] = d[i], d[j]
}

// Less compares values
func (d Diffs) Less(i, j int) bool {
	return d[i].value > d[j].value
}
func main() {
	reader := bufio.NewReader(os.Stdin)
	tmp, _ := reader.ReadString('\n')
	tmp = strings.Trim(tmp, "\n")
	N, _ := strconv.Atoi(tmp)

	tmp, _ = reader.ReadString('\n')
	tmp = strings.Trim(tmp, "\n")
	tmpV := strings.Split(tmp, " ")
	v := make([]int, N)
	for i, sv := range tmpV {
		t, ok := strconv.Atoi(sv)
		if ok == nil {
			v[i] = t
		}
	}

	tmp, _ = reader.ReadString('\n')
	tmp = strings.Trim(tmp, "\n")
	tmpC := strings.Split(tmp, " ")
	var diffs Diffs

	for i, sc := range tmpC {
		t, ok := strconv.Atoi(sc)
		if ok == nil {
			diffs = append(diffs, Diff{value: v[i] - t})
		}
	}

	sort.Sort(diffs)

	var s int
	for i := range diffs {
		if diffs[i].value > 0 {
			s += diffs[i].value
		}
	}
	fmt.Println(s)
}


Measured memory_bytes: 640
/*
			███╗   ███╗ █████╗ ███████╗███╗   ███╗ ██████╗ ██╗   ██╗██████╗ ███████╗ █████╗ ███╗   ███╗██████╗ ██╗   ██╗
			████╗ ████║██╔══██╗╚════██║████╗ ████║██╔═══██╗██║   ██║██╔══██╗╚════██║██╔══██╗████╗ ████║██╔══██╗╚██╗ ██╔╝
			██╔████╔██║███████║    ██╔╝██╔████╔██║██║   ██║██║   ██║██║  ██║    ██╔╝███████║██╔████╔██║██║  ██║ ╚████╔╝
			██║╚██╔╝██║██╔══██║   ██╔╝ ██║╚██╔╝██║██║   ██║██║   ██║██║  ██║   ██╔╝ ██╔══██║██║╚██╔╝██║██║  ██║  ╚██╔╝
			██║ ╚═╝ ██║██║  ██║   ██║  ██║ ╚═╝ ██║╚██████╔╝╚██████╔╝██████╔╝██╗██║  ██║  ██║██║ ╚═╝ ██║██████╔╝   ██║
			╚═╝     ╚═╝╚═╝  ╚═╝   ╚═╝  ╚═╝     ╚═╝ ╚═════╝  ╚═════╝ ╚═════╝ ╚═╝╚═╝  ╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝    ╚═╝

			“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
*/
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define pb push_back
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define sz(v) ((int)((v).size()))
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define Accepted 0
#define watch(x) cout << #x << " = " << x << endl;
#define un_map unordered_map
#define RT(x) return cout << (x), 0;
#define sc(a) scanf("%d", &a)
#define scll(x) scanf("%I64d", &x)
#define scan(s) scanf("%[^\n]%*c", &s)
#define pr(s) printf("%s", s.c_str()); // print string
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double EPS = -1e-2;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const ll mod = 1000000007;
const int Mx = INT_MAX;
const int Mn = INT_MIN;
const ll MX = LLONG_MAX;
const ll MN = LLONG_MIN;
const int N = 1e5 + 1;
void Open()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
int n, k;
int dp[N];
//int mem[N];
vector<int>v;
/*int solve(int i) {
	int& ret = mem[i];
	if (~ret)return ret;
	ret = Mx;
	if (i + 1 < n)
		ret = min(ret, solve(i + 1) + abs(v[i] - v[i + 1]));
	if (i + 2 < n)
		ret = min(ret, solve(i + 2) + abs(v[i] - v[i + 2]));
	ret = ret == Mx ? 0 : ret;
	return ret;
}*/
int main()
{
	Ma7moud_7amdy;
	Open_Sesame;
	//clr(mem, -1);
	cin >> n;
	v = vector<int>(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	//cout << solve(0) << endl;;

	for (int i = 0; i < n; i++) {
		int& ret = dp[i];
		ret = Mx;
		if (i - 1 >= 0)
			ret = min(ret, dp[i - 1] + abs(v[i] - v[i - 1]));
		if (i - 2 >= 0)
			ret = min(ret, dp[i - 2] + abs(v[i] - v[i - 2]));

		ret = ret == Mx ? 0 : ret;
	}
	
	cout << dp[n - 1] << endl;
	return Accepted;
}

Measured memory_bytes: 4004
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)


def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())


directions = np.array([[1, 0], [0, 1], [-1, 0], [0, -1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact


def serch(x, count):
    #print("top", x, count)

    for d in directions:
        nx = d+x
        # print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)

    return count


field = []
for i in range(3):
    field.append(acinput())

N = int(input())


def chk(x):
    for i in range(3):
        for j in range(3):
            if field[i][j] == x:
                field[i][j] = -1


for i in range(N):
    chk(II())

#print(field)

for i in range(3):
    state = False
    for j in range(3):
        if field[i][j] != -1:
            break
        if j == 2:
            print("Yes")
            sys.exit()

for j in range(3):
    state = False
    for i in range(3):
        if field[i][j] != -1:
            break
        if i == 2:
            print("Yes")
            sys.exit()

state = False
for i in range(3):
    if field[i][i] != -1:
        break
    if i == 2:
        print("Yes")
        sys.exit()



for i in range(3):
    if field[2-i][i] != -1:
        break
    if i == 2:
        print("Yes")
        sys.exit()

print("No")

Measured memory_bytes: 12448
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[200005] = {};
    ll z = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i], a[i] += n - i;
    sort(a, a + n);
    for (int i = 0; i < n; i++) z += abs(a[n / 2] - a[i]);
    cout << z;
}

Measured memory_bytes: 1024
#include <iostream>
#include<string>
using namespace std;
using ulli = unsigned long long int;
using lli = long long int;

int main() {
    lli a, b, k;
    cin >> a >> b >> k;
    cout << ((a - k >= 0) ? a - k : 0) << " " << ((a - k >= 0) ? b : ((a + b - k >= 0) ? a + b - k : 0)) << endl;
    return 0;
}

Measured memory_bytes: 3532
#include <iostream>
#include <cmath>
using namespace std;
const int INF = 1 << 30;
int main() {
        int N, K; cin >> N >> K;
        int H[N], dp[N];

        dp[0] = 0;
        cin >> H[0];
        
        for (auto i = 1; i < N; ++i) {
                cin >> H[i];
                dp[i] = INF;
                for (auto j = 1; j <= K; ++j) {                        
                        if (i<j) break;
                        dp[i] = min(dp[i], dp[i-j]+abs(H[i]-H[i-j]));
                }
        }
        cout << dp[N-1] << "\n";
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <stack>
#include <functional>

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

using namespace std;

int main(){
	string line;
	while(std::getline(cin, line)){
		stack<double> s;

		istringstream iss(line);
		string token;
		while(iss >> token){
			if(token == "+" || token == "-" || token == "*" || token == "/"){
				std::function<double(double, double)> op;
				if(token == "+"){
					op = plus<double>();
				}
				else if(token == "-"){
					op = minus<double>();
				}
				else if(token == "*"){
					op = multiplies<double>();
				}
				else{
					op = divides<double>();
				}
				double b = s.top();
				s.pop();
				double a = s.top();
				s.pop();
				s.push(op(a, b));
			}
			else{
				s.push(strtod(token.c_str(), 0));
			}
		}
		printf("%lf\n", s.top());
	}
	return 0;
}

Measured memory_bytes: 3240
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

import numpy as np

N = int(readline())

def F(N):
    if N == 4:
        return np.array([[3,2,4],[3,4,1],[4,1,2],[2,1,3]])
    if N&1:
        x = np.arange(N)[:,None] + np.arange(N)[None,:]
        return (x[:,1:]%N)+1
    M = N//2
    x = F(M)
    arr = np.empty((N,N-1),np.int32)
    arr[0:M,0:M-1] = x
    arr[M:N,0:M-1] = x+M
    for n in range(M-1,N-1):
        arr[0:M,n] = np.arange(M) + n
        arr[M:N,n] = np.arange(M) + (1-n)        
    arr[:M,M-1:] %= M
    arr[:M,M-1:] += M+1
    arr[M:,M-1:] %= M
    arr[M:,M-1:] += 1
    return arr

if N == 2:
    print(-1)
    exit()

x = F(N)
print('\n'.join(' '.join(row) for row in x.astype(str)))

Measured memory_bytes: 13564
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  int N,Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  int l[Q],r[Q];
  rep(i,Q) {
    cin >> l[i] >> r[i];
  }
  bool ok[S.length() - 1];
  rep(i,S.length()-1) {
    if(S[i] == 'A' && S[i+1] == 'C'){
      ok[i+1] = true;
    } else {
      ok[i+1] = false;
    }
  }
  ok[0] = false;
  int acc = 0;
  int num[S.length()];
  rep(i,S.length()) {
    if(ok[i]) {
      acc++;
    }
    num[i] = acc; 
  }
  rep(i,Q) {
    cout << num[r[i]-1] - num[l[i]-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 2304
import itertools
n = int(input())
t = [i for i in range(1,n+1)]
li = list(itertools.permutations(t))
li.sort()
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
a = li.index(p)
b = li.index(q)
print(abs(a-b))

Measured memory_bytes: 8052
from itertools import product

N = int(input())
A = []
XY = [[] for _ in range(N)]
for i in range(N):
  A.append(int(input())) 
  for j in range(A[i]):
    XY[i].append(list(map(int, input().split())))

ans = 0
for pattern in product(range(2), repeat=N): # 0:不正直 1:正直
  flag = True
  for i in range(N):
    if pattern[i]: # iさんが正直と仮定
      # 発言と一致するか？
      for a in range(A[i]):
        if pattern[XY[i][a][0]-1] != XY[i][a][1]:
          flag = False
          break
  if flag:
    ans = max(ans, sum(pattern))

print(ans)

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

#define MOD 1000000007

template <class T> T comb(T n, T r)
{
    if (n < 0 || n < r || r < 0)
        return 0;

    r = min(r, n - r);
    if (r == 0)
        return 1;

    vector<T> numer(r);
    vector<T> denom(r);

    iota(begin(numer), end(numer), n - r + 1);
    iota(begin(denom), end(denom), 1);

    for (T i = 1; i < r; i++) {
        T divisor = denom[i];
        if (divisor > 1) {
            T offset = (n - r) % (i + 1);
            for (T j = i; j < r; j += i + 1) {
                numer[j - offset] /= divisor;
                denom[j] /= divisor;
            }
        }
    }
    
    T p = 1;
    for(T i = 0; i < r; i++)
        p = p * numer[i] % MOD;

    return p;
}

int main()
{
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    auto f = [&](int r, int c) {
        return comb((ll)r + c, (ll)c);
    };
    auto g = [&](int r, int c) {
        return f(r + 1, c + 1) - 1;
    };

    ll ans = g(r2, c2) + MOD - g(r2, c1 - 1) + MOD - g(r1 - 1, c2) + g(r1 - 1, c1 - 1);
    ans %= MOD;

    cout << ans << endl;
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define MAXN 100002
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second 
#define FAIL {printf("-1\n"); return 0;}

int N, M;
vector<int> edge[MAXN];
int dp[MAXN];
int visited[MAXN];

int ans;
int dfs(int u) {
    if (visited[u]) return dp[u];
    visited[u] = 1;

    for (int v: edge[u]) {
        dp[u] = max(dp[u], 1 + dfs(v));
    }

    ans = max(ans, dp[u]);
    return dp[u];
}

int main(int argc, char **argv)
{
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif

    scanf("%d %d", &N, &M);
    for (int i = 0; i < M; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        edge[u].pb(v);
    }

    for (int i = 1; i <= N; i++) dfs(i);

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

    return 0;
}


Measured memory_bytes: 7808
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

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

  string s;
  cin >> s;
  ll n = s.size();

  bool chk = true;
  repLRE(i, 1, n - 1) {
    if (s[i] != '9') {
      chk = false;
      break;
    }
  }
  ll ans = s[0] - '0' + 9 * (n - 1);
  if (!chk) ans--;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
from itertools import accumulate #list(accumulate(A))
'''
N, M , lim = mi()

A = li()
B = li()

A += [10**9+1]
B += [10**9+1]
ind_a = 0 
ind_b = 0

cnt = ans = 0

while True:
    if A[ind_a] > B[ind_b]:
        if cnt + B[ind_b] <= lim:
            ans += 1
            cnt += B[ind_b]
            if ind_b != M:
                ind_b += 1
        else:
            break

    elif A[ind_a] < B[ind_b]:
        if cnt + A[ind_a] <= lim:
            ans += 1
            cnt += A[ind_a]
            if ind_a != N:
                ind_a += 1
        else:
            break

    else:
        if ind_a == N and ind_b == M:
            break
        elif ind_a == N:
            if cnt + B[ind_b] <= lim:
                ans += 1
                cnt += B[ind_b]
                if ind_b != M:
                    ind_b += 1
            else:
                break
        elif ind_b == M:
            if cnt + A[ind_a] <= lim:
                ans += 1
                cnt += A[ind_a]
                if ind_a != N:
                    ind_a += 1
            else:
                break
        else:
            if A[ind_a+1] >= B[ind_b+1]:
                if cnt + B[ind_b] <= lim:
                    ans += 1
                    cnt += B[ind_b]
                    if ind_b != M:
                        ind_b += 1
                else:
                    break
            else:
                if cnt + A[ind_a] <= lim:
                    ans += 1
                    cnt += A[ind_a]
                    if ind_a != N:
                        ind_a += 1
                else:
                    break

print(ans)
'''
N, M , lim = mi()

A = li()
B = li()

A = [0] + list(accumulate(A))
B = list(accumulate(B))
ans = 0

for i in range(N+1):
    ind = bisect.bisect_right(B, max(lim-A[i], 0))
    if ind > 0 or lim-A[i] == 0:
        ans = max(ans, ind + i)

print(ans)

Measured memory_bytes: 43204
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); ++i)

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  int n;cin>>n;
  vector<double> v(n);
  rep(i,n)cin>>v[i];
  sort(v.begin(),v.end());
  v[0] /= pow(2.0,n-1);
  for (int i = 1; i < n; i++)
  {
    v[i] /= pow(2.0,n-i);
  }
  double ans=0.0;
  rep(i,n)ans += v[i];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String[] array = br.readLine().split(" ");
			int N = Integer.parseInt(array[0]);
			int C = Integer.parseInt(array[1]);

			TVData[] dataArray = new TVData[N];
			for (int i = 0; i < N; i++) {
				dataArray[i] = new TVData(br.readLine());
			}
			final int[] table = new int[2 * 100_001];
			final boolean[] tmp = new boolean[2 * 100_001];
			boolean updated = false;
			for (int channel = 1; channel <= C; channel++) {
				if (updated) {
					for (int i = 0; i < tmp.length; i++) {
						tmp[i] = false;
					}
					updated = false;
				}

				for (TVData data : dataArray) {
					if (data.channel == channel) {
						for (int i = data.start * 2 - 1; i <= data.end * 2; i++) {
							tmp[i] = true;
						}
						updated = true;
					}
				}

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

			System.out.println(Arrays.stream(table).max().getAsInt());
		}
	}

	public static class TVData {
		private final int channel;
		private final int start;
		private final int end;

		public TVData(String line) {
			int[] tmp = Arrays.stream(line.split(" ")).mapToInt(Integer::parseInt).toArray();
			start = tmp[0];
			end = tmp[1];
			channel = tmp[2];
		}
	}

}


Measured memory_bytes: 62960
#include <iostream>
using namespace std;
int main(){
    long long N,A,B;
    cin >> N >> A >> B;
    long long X[100000];
    for(int i=0;i<N;i++) cin >> X[i];
    long long f=0;
    for(int at=0;at<N-1;at++)
        f+=((X[at+1]-X[at])*A<B)?(X[at+1]-X[at])*A:B;
    cout << f << endl;
}

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

static const int N = 100;

int main() {
  int n, p[N + 1], m[N + 1][N + 1];
  cin >> n;
  REP1(i, n + 1) {
    cin >> p[i - 1] >> p[i];
  }

  REP1(i, n + 1) m[i][i] = 0;
  FOR(l, 2, n + 1) {
    REP1(i, n - l + 2) {
      int j = i + l - 1;
      m[i][j] = (1 << 21);
      FOR(k, i, j) {
        m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
      }
    }
  }

  cout << m[1][n] << endl;

  return 0;
}

Measured memory_bytes: 3112
#include <iostream>
using namespace std;
int main() {
    int n, w;
    cin>>n>>w; 
    long long wt[n], v[n]; 
    for(int i =0; i< n; i++){
        cin>>wt[i]>>v[i];
    }
    long long dp[n+1][w+1]; 
    for(int i = 0 ; i< n+1; i++){
        for(int j = 0; j<w+1; j++){
            if(i == 0 || j == 0){
                dp[i][j] = 0; 
            }
        }
    } 
    for(int i =1; i<= n ; i++){
        for(int j =1; j <=w ; j++){
            if(wt[i-1] <= j){
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-wt[i-1]]+v[i-1]);
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout<<dp[n][w]<<endl;
}


Measured memory_bytes: 82436
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N, M, X =map(int, input().split())
    A = list(map(int, input().split()))
    res = 0
    for i in A:
        if i>=X:
            res += 1
    print(min(res, M-res))

if __name__ == '__main__':
    main()

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

using namespace std;

#define int long long

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

template <typename T> T gcd(T m, T n) { return n == 0 ? m : gcd(n, m % n); }
template <typename T> T lcm(T m, T n) { return n * m / gcd(n, m); }
template <typename T> T fact(T n) { return (n == 0 ? 1 : n * fact(n - 1)); }
template <typename T> T modpow(T a, T e, T m) { return (e == (T)0 ? 1 : ((a % m) * modpow((a % m), e - 1, m)) % m); }

constexpr int MOD = 1e9 + 7;

signed main(void) {

  int a, b, c;
  cin >> a >> b >> c;

  if (a + b + c <= 21) {
    cout << "win";
  } else {
    cout << "bust";
  }
  cout << endl;
}

Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
dist = [[-1 for _ in range(w+2)] for _ in range(h+2)]
dist[1][1] = 1
white = 0
dl = [[1, 0], [0, 1], [-1, 0], [0, -1]]
tmp = ["#" for _ in range(w+2)]
S = [tmp]
for i in range(h):
    S.append([])
    for j in range(w):
        white += 1 if s[i][j] == "." else 0
    S[i+1].extend("#")
    S[i+1].extend(s[i])
    S[i+1].extend("#")
S.append(tmp)


def dfs():
    global S, dl
    queue = deque([[1, 1]])

    while queue:
        [x, y] = queue.popleft()
        for d in dl:
            if dist[x + d[0]][y + d[1]] == -1 and S[x + d[0]][y + d[1]] == ".":
                dist[x + d[0]][y + d[1]] = dist[x][y] + 1
                queue.append([x + d[0], y + d[1]])


dfs()
if dist[h][w] == -1:
    print(-1)
else:
    print(white-dist[h][w])


Measured memory_bytes: 9492
A, B = [int(st) for st in input().split()]
def count_tap(a, b):
    taps = 0
    if b == 1:
        return taps
    else:
        taps = 1
        if a >= b:
            return taps
        else:
            taps = 1 + (b-a) // (a-1)
        if (b - a)%(a-1) != 0:
            taps += 1
    return taps
  
  
print(count_tap(A, B))

Measured memory_bytes: 3060
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

int dp[3][101];
int n,a[3][101];

int fun(int x,int y){
    if (x>2 or y>n) return 0;
    if (x==2 and y==n) return a[2][n];
    if (dp[x][y]>0) return dp[x][y];
    return  dp[x][y] = a[x][y] + max(fun(x+1,y),fun(x,y+1)) ; 
}

inline void solve(){
    cin>>n; 
    for (int i=1;i<=2;i++)
        for (int j=1;j<=n;j++) cin >> a[i][j] ; 
    cout << fun(1,1) << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  if(n>=400&&n<600){
    cout << 8 << endl;
  }
  else if(n>=600&&n<800){
      cout << 7<< endl;
  }
  else if(n>=800&&n<1000){
      cout << 6<< endl;
  }
  else if(n>=1000&&n<1200){
      cout << 5<< endl;
  }
  else if(n>=1200&&n<1400){
      cout <<4<< endl;
  }
  else if(n>=1400&&n<1600){
      cout << 3<< endl;
  }
  else if(n>=1600&&n<1800){
      cout << 2<< endl;
  }
  else if(n>=1800&&n<2000){
      cout << 1<< endl;
  }
  
}




Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(void){
    string S;
    cin>>S;
    int count=0;
    int max=0;
    for(int i=0;i<S.length();i++){
        if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T'){
            count++;
            if(count>max){
                max=count;
            }
        }
        else{
            count=0;
        }
    }
    cout<<max<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>s;
    cout.tie(NULL);
    // 0->wolf 1->sheep
    for(int i=0;i<=1;i++){
        for(int j=0;j<=1;j++){
            int a=i,b=j,c;
            for(int k=1;k<n;k++){
                if(s[k]=='o'){
                    if(b==0){
                        c=1-a;
                    }
                    else{
                        c=a;
                    }
                }
                else{
                    if(b==0){
                        c=a;
                    }
                    else{
                        c=1-a;
                    }
                }
                a=b;
                b=c;
            }
            if(b==i){
                bool f=0;
                if(s[0]=='o'){
                    if(i==0&&j!=a){
                        f=1; 
                    }
                    if(i==1&&j==a){
                        f=1;
                    }
                }
                else{
                    if(i==0&&j==a){
                        f=1; 
                    }
                    if(i==1&&j!=a){
                        f=1;
                    }
                }
                if(!f)continue;
                int a=i,b=j,c;
                cout<<(a?'S':'W');
                for(int k=1;k<n;k++){
                    if(s[k]=='o'){
                        if(b==0){
                            c=1-a;
                        }
                        else{
                            c=a;
                        }
                    }
                    else{
                        if(b==0){
                            c=a;
                        }
                        else{
                            c=1-a;
                        }
                    }
                    a=b;
                    b=c;
                    cout<<(a?'S':'W');
                }
                return 0;
            }
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 592
using System;
class hogehoge
{
	static void Main(string[] args)
	{
		int i = int.Parse(Console.ReadLine());
		if (i / 100 == 1) i = 900 + i % 100;
		else if (i / 100 == 9) i = 100 + i % 100;
		if ((i / 10) % 10 == 1) i = (i / 100) * 100 + 90 + i % 10;
		else if ((i / 10) % 10 == 9) i = (i / 100) * 100 + 10 + i % 10;
		if (i % 10 == 1) i = (i / 10) * 10 + 9;
		else if (i % 10 == 9) i = (i / 10) * 10 + 1;
		Console.WriteLine(i);
	}
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
//#define int long long

signed main(){
    int a, b;
    cin >> a >> b;
    if((a+b) % 2 == 0){
        cout << (a + b) / 2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 256