akhauriyash/Code-Regression huggingface dataset:
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,k = readline() |> split |> parseMap
	a = Array{Int}(2,n)
	for i in 1:n
		a[:,i] = readline() |> split |> parseMap
	end
	a = sortcols(a, by = x->x[1])
	s = 0
	for i in 1:n
		s += a[2,i]
		if s >= k
			println(a[1,i])
			break
		end
	end
end

main()

Measured memory_bytes: 159016
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

  int N,W;
  cin >>N>>W;  
  int dp[W+1];
  int v[N],w[N];
  
  for(int i=0 ; i < N ; i++){
    cin >>v[i]>>w[i];
  }

  for(int i=0 ; i < W+1 ; i++)dp[i]=0;
  
  for(int i=0 ; i < N ; i++){
    for(int j=w[i] ; j < W+1 ; j++){
      dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
    }
  }
  
  cout <<dp[W]<<endl;
  
  return 0;
}

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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

template <typename T> inline
void chmin(T &a, T b){
    if (a > b) {
        a = b;
    }
}

template <typename T> inline
bool chmax(T &a, T b){
    if (a < b) {
        a = b;
        return true;
    }

    return false;
}



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

    int N, W; cin >> N >> W;

    vector<int> w(N);
    vector<LL> v(N);
    REP(i, N) cin >> w[i] >> v[i];

    vector<pair<LL, vector<int>>> V(W + 1);
    REP(i, W + 1) V[i].first = -1;


    V[0].first = 0;
    REP(i, N) V[0].second.push_back(i);

    LL res = 0;

    REP(cur_w, W+1) {
        LL cur_v = V[cur_w].first;
        if (cur_v == -1) continue;

        vector<int> remains = V[cur_w].second;

        REP(i, remains.size()) {
            int id = remains[i];

            int next_w = cur_w + w[id];
            if (next_w > W) continue;

            if(chmax(V[next_w].first, cur_v + v[id])) {
                V[next_w].second.resize(V[cur_w].second.size() - 1);
                copy(remains.begin(), remains.begin() + i, V[next_w].second.begin());
                copy(remains.begin() + i + 1, remains.end(), V[next_w].second.begin() + i);
            }
        }

        chmax(res, V[cur_w].first);
    }

    cout << res << endl;

}


Measured memory_bytes: 41984
//#include<iostream>
#include<cstring>
#include<cstdio>
//#include<math.h>
//#include<set>
//#include<queue>
//#include<bitset>
//#include<vector>
#include<algorithm>
#include<stdlib.h>
using namespace std;

#define LL long long
int qread()
{
	char c; int s=0,f=1; while ((c=getchar())<'0' || c>'9') (c=='-') && (f=-1);
	do s=s*10+c-'0'; while ((c=getchar())>='0' && c<='9'); return s*f;
}

//Pay attention to '-' , LL and double of qread!!!!

int n;
#define maxn 200011
int a[maxn];
int Abs(int x) {return x>0?x:-x;}
int main()
{
	n=qread();
	for (int i=1;i<=n;i++) a[i]=qread()-i;
	sort(a+1,a+1+n); int mid=a[(n+1)>>1];
	LL ans=0; for (int i=1;i<=n;i++) ans+=Abs(mid-a[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n;
    cin >> n;
    vector<pair<int, int>> m(n);
    int a, b;
    rep(i, n) {
        cin >> a >> b;
        m[i] = make_pair(a, b);
    }
    vector<vector<int>> dp(n, vector<int>(n, INF));
    rep(i, n) dp[i][i] = 0;
    for (int len = 1; len <= n; len++) {
        for (int i = 0; i < n; i++) {
            int j = i + len - 1;
            if (j >= n)
                continue;
            for (int k = i; k < j; k++) {
                chmin(dp[i][j], dp[i][k] + dp[k + 1][j] +
                                    m[i].first * m[k].second * m[j].second);
            }
        }
    }
    cout << dp[0][n - 1] << endl;
}


Measured memory_bytes: 3212
#!/usr/bin/env pypy
from __future__ import division, print_function
 
import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase
 
import __pypy__
 
def partial(S):
    P = [0] * len(S)
    g = 0
    for i in range(1, len(S)):
        while g and (S[g] != S[i]):
            g = P[g - 1]
        P[i] = g = g + (S[g] == S[i])
 
    return P
 
def match(S, pattern):
    if not pattern: return list(range(len(S)))
    P = partial(pattern)
    g = 0
    ret = []
    
    for i in range(len(S)):
        while g and pattern[g] != S[i]:
            g = P[g - 1]
        g += pattern[g] == S[i]
        if g == len(P): 
            ret.append(i + 1 - g)
            g = P[g - 1]
    
    return ret
 
 
def main():
    s = input()
    t = input()
 
    if len(s) < len(t):
        s *= (len(t) + len(s) - 1) // len(s)
    n = len(s)
    s *= 3
 
    lo, hi = 0, (len(s) + len(t) - 1) // len(t)
    while lo < hi:
        mi = (lo + hi) // 2
        u = mi * t
        if not match(s, u):
            hi = mi
        else:
            lo = mi + 1
 
    if len(t * (lo - 1)) >= 2 * n:
        print(-1)
        return
 
    print(lo - 1)
 
 
# region fastio
 
BUFSIZE = 8192
 
 
class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()
 
 
class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)
 
    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()
 
 
def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
 
 
sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# endregion
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 133604
s = input()
n_cnt = 0
s_cnt = 0
e_cnt = 0
w_cnt = 0
for i in range(len(s)):
  if s[i] == 'N':
    n_cnt += 1
  if s[i] == 'S':
    s_cnt += 1
  if s[i] == 'W':
    w_cnt += 1
  if s[i] == 'E':
    e_cnt += 1
if (n_cnt > 0 and s_cnt > 0) or (n_cnt == 0 and s_cnt == 0):
  length = True
else:
  length = False
if (e_cnt > 0 and w_cnt > 0) or (e_cnt == 0 and w_cnt == 0):
  width = True
else:
  width = False
  
if length and width:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

bool possible(ll n, ll m, ll x){
    return (m - 2 * x) >= 0 && (n + (m - 2 * x) / 2) >= x;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    ll min_c = 0;
    ll max_c = m;
    while(max_c - min_c > 1){
        ll mid = (max_c + min_c) / 2;
        if(possible(n, m, mid)){
            min_c = mid;
        }else{
            max_c = mid;
        }
    }
    cout << min_c << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>

using namespace std;

typedef pair<int, int> P;
typedef pair<P, int> P2; //3d array

const int dx[] = {-1, 0, 1, 2, 2, 2, 1, 0, -1, -2, -2, -2}; //direction column
const int dy[] = {2, 2, 2, 1, 0, -1, -2, -2, -2, 1, 0, -1}; // direction row

int sx, sy, n;

bool Solution(vector<P> sprinkler)
{
    queue<P2> que;
    que.push(P2(P(sx, sy), 0));
    
    while(!que.empty())
    {
        int x = que.front().first.first;
        int y = que.front().first.second;
        int c = que.front().second;
        
        que.pop();
        
        if(c == n)
        {
            return true;
        }
        
        for(int i = 0 ; i < 12 ; i++)
        {
            int nx = x + dx[i];
            int ny = y + dy[i];
            
            if(0 <= nx && nx <= 9 && 0 <= ny && ny <= 9 &&
               abs(nx - sprinkler[c].first) <= 1 && abs(ny - sprinkler[c].second) <= 1)
            {
                que.push(P2(P(nx, ny), c + 1));
            }
        }
    }
    return false;
}

int main()
{
    while(cin>>sx>>sy, sx&&sy)
    {
        cin>>n;
        
        vector<P> sprinkler(n);  //notice P is pair<int, int>
        
        for(int i = 0 ; i < n ; i++)
        {
            cin>>sprinkler[i].first>>sprinkler[i].second;
        }
        
        if(Solution(sprinkler))
        {
            cout << "OK" << endl;
        }
        else
        {
            cout << "NA" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int64 gcd(int64 a, int64 b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int h,n; cin >> h >> n;
		vector<int64> a(n);
		vector<int64> b(n);
		vector<int64> dp(h + 1, INF);
		dp[0] = 0;
		rep (i,n) cin >> a[i] >> b[i];
		rep (i, h) {
			rep (j, n) {
				int ni = i + a[j];
				if (ni >= h) ni = h;
				dp[ni] = min(dp[ni], dp[i] + b[j]);
			}
		}
		cout << dp[h] << endl;
    return;
}

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



Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	int n;
	std::cin >> n;
	std::vector<lnt> a(n);
	rep(i,n) std::cin >> a[i];
	lnt ac=0;
	rep(i,n) ac^=a[i];
	rep(i,n) std::cout << (a[i]^ac) << ' ';
	std::cout << EL;
}


Measured memory_bytes: 4740
x=[]
for i in range(4):
    a=int(input())
    x.append(a)
    
x.remove(min(x))
 
y=[]    
for j in range(2):
    a=int(input())
    y.append(a)
    
y.remove(min(y))

z=x+y

print(sum(z))



Measured memory_bytes: 5596
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;
use std::mem;

fn main() {
    let (mut n, mut m): (usize, usize);
    input!(n, m);

    if n > m {
        mem::swap(&mut n, &mut m);
    }
    if n == 1 && m == 1 {
        p(1);
    } else if n == 2 {
        p(0);
    } else if n == 1 {
        p(m - 2);
    } else if n >= 3 && m >= 3 {
        p((n - 2) * (m - 2));
    } else {
        panic!["Err"];
    }
}

Measured memory_bytes: 4352
#include <stdio.h>

main(void) {
  int iarray[] = {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};
  int K = 0;
  scanf("%d",&K);
  printf("%d",iarray[K-1]);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  vpll A(n);
  FOR(i,0,n){
    ci(A[i].fi);
    A[i].se=i+1;
  }
  SORT(A);
  FOR(i,0,n){
    cout<<A[i].se<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 3200
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
   
    int a,b;
    cin>>a>>b;
    
    if(a*b%2==1){
        cout<<"Odd"<<endl;
    }else{
        cout<<"Even"<<endl;
    }
   
    
    return 0;
   
}






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

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B && A != C) cout << "Yes";
    else if(B == C && C != A) cout << "Yes";
    else if(C == A && A != B) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;
struct node{
    int w,v;
};
vector<node> weight[4];
int check[101];


bool comp(struct node &A ,struct node &B){
    
    return A.v > B.v;
}

int value_sum[4][102];
int main(int argc, const char * argv[]) {
  
    int n,w;
    int count[4];
    
    scanf("%d %d",&n,&w);
    struct node a[101];
    long long first = 0;
    for(int i=0;i<n;i++){
        scanf("%d %d",&a[i].w,&a[i].v);
        if(i==0) first = a[i].w;
        weight[a[i].w-first].push_back(a[i]);
        count[a[i].w-first]++;
    }
    
    for(int i=0;i<4;i++){
        sort(weight[i].begin(),weight[i].end(),comp);
    }
 
    
    for(int i=0;i<4;i++){
        for(int j=0;j<weight[i].size();j++){
            value_sum[i][j+1] = value_sum[i][j] + weight[i][j].v;
    
        }
    }
    
    long long max = -1;
    
    for(int i=0;i<weight[3].size()+1;i++){
        long long present = (3+first) * (i);
        long long vv = value_sum[3][i];
        if( present <= w){
            for(int j=0;j<weight[2].size()+1;j++){
                long long present2 = present + (2+first) * (j);
                long long vv2 = vv+ value_sum[2][j];
                
                if(present2 <= w){
                    
                    for(int k=0;k<weight[1].size()+1;k++){
                        
                        long long present3 = present2+ (1+first) * (k);
                        long long vv3 =  vv2 + value_sum[1][k];
                        if(present3 <= w){
                            
                            for(int l=0;l<weight[0].size()+1;l++){
                               long long  present4 = present3+ (first) * l;
                                long long vv4 = vv3+ value_sum[0][l];
                                if(present4<=w){
                                    
                                    if(max < vv4){
                                        max =vv4;
                                    }
                                }
                            }
                        }else{
                            break;
                        }
                }
                }else{
                    break;
                }
            }
        }else{
            break;
        }
        
    }
    
    printf("%lld\n",max);
    
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
class Main{
	public static void main(String[]args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		
		while(true){
			String[] test=br.readLine().split(" ");
			int m=Integer.parseInt(test[0]);
			int f=Integer.parseInt(test[1]);
			int r=Integer.parseInt(test[2]);
			if(m==-1&&f==-1&&r==-1){
				break;
			}
			if(m==-1||f==-1){
				sb.append("F\n");
			}
			else if((m+f)>=80){
				sb.append("A\n");
			}
			else if((m+f)>=65&&(m+f)<80){
				sb.append("B\n");
			}
			else if((m+f)>=50&&(m+f)<65){
				sb.append("C\n");
			}
			else if((m+f)>=30&&(m+f)<50){
				if(r>=50){
					sb.append("C\n");
				}
				else{
					sb.append("D\n");
				}
			}
			else if((m+f)<30){
				sb.append("F\n");
			}
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 24220
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int vis[N],in[N];
int main(){
	int n,x,mx=0,ans=0;scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&x),mx=max(mx,x),in[x]++;
	for(int i=1;i<=mx;i++){
		if(!in[i])continue;
		if(!vis[i]&&in[i]==1)ans++;
		for(int j=i;j<=mx;j+=i)vis[j]=1;
	}
	printf("%d",ans);
	return 0;
}

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

string s;

int main() {
    cin >> s;
    int ans = 0;
    int n = (int)s.size();
    for (int i = 0; i < n/2; ++i) {
        ans += s[i] != s[n-i-1];
    }
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 256
// Todo
// * [x] inputをパースしてrを返す関数
// * [x] rから値を返す関数

function parse(input) {
  return parseInt(input, 10)
}

function f(r) {
  if (r < 1200) return "ABC"
  if (r < 2800) return "ARC"
  return "AGC"
}

module.exports = {
  f,
  parse,
}

function Main(input) {
  const r = parse(input)

  console.log(f(r))
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"))


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

int A,B;
int ans = 0;

int main()
{
    scanf("%d%d",&A,&B);
    for(int i = A; i <= B; i++)
    {
        if(i / 10000 % 10 == i % 10 && i / 1000 % 10 == i / 10 % 10)ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 500005

ll mod_pow(ll x, ll n, ll mod){ // x ^ n % mod
    ll res = 1;
    while(n > 0){
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

const ll MOD = 1000000007;
vector<int> v[1<<20];
int main() {
    int n;
    cin >> n;
    int a[n] = {};
    int sum[n+1] = {};
    int x = 0;
    rep(i,n){
        cin >> a[i];
        x ^= a[i];
        sum[i+1] = x;
    }

    ll ans = 0;
    // cout << x << endl;
    // rep(i,n+1)cout << sum[i] << ' ';
    // cout << endl;
    if(x == 0){
        srep(i,1,n){
            if(sum[i] == 0)continue;
            v[sum[i]].push_back(i);
        }
        ll zero[n+1] = {};
        srep(i,1,n+1){
            zero[i] = zero[i-1];
            if(sum[i] == 0)zero[i]++;
        }
        ans = mod_pow(2,zero[n-1],MOD);
        srep(i,1,1<<20){
            if(v[i].size() == 0)continue;
            int m = v[i].size();
            ll dp[m][2];
            dp[0][0] = 1;
            dp[0][1] = 1;
            srep(j,1,m){
                rep(k,2)dp[j][k] = dp[j-1][k];
                ll z = zero[v[i][j]] - zero[v[i][j-1]];
                dp[j][1] += dp[j-1][0];
                dp[j][1] += dp[j-1][1] * z;
                dp[j][0] += dp[j-1][1] * z;
                rep(k,2)dp[j][k] %= MOD;
            }
            // cout << i << ' ' << dp[m-1][1] << endl;
            ans += dp[m-1][1];
            ans %= MOD;
        }
    }else{
        ll dp[n][2];
        rep(i,n)rep(j,2)dp[i][j] = 0;
        dp[0][0] = 1;
        srep(i,1,n){
            rep(j,2)dp[i][j] = dp[i-1][j];
            if(sum[i] == 0){
                dp[i][0] += dp[i-1][1];
            }else if(sum[i] == x){
                dp[i][1] += dp[i-1][0];
            }
            rep(j,2)dp[i][j] %= MOD;
        }
        ans = dp[n-1][0];
    }

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




Measured memory_bytes: 44900
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int MOD = 1000 * 1000 * 1000 + 7;

int mod(int n) {
    n %= MOD;
    if (n < 0) return n + MOD;
    else return n;
}   
int fp(int a, int p) {
    int ans = 1, c = a;
    for (int i = 0; (1ll << i) <= p; ++i) {
        if ((p >> i) & 1) ans = mod(ans * c);
        c = mod(c * c);
    }   
    return ans;
}   
int dv(int a, int b) { return mod(a * fp(b, MOD - 2)); }

const int N = 5007;
vector <int> tree[N];

int dp[N][N];
int f[N];

int dfs(int u) {
    int ans = 1;
    for (int v : tree[u])
        ans += dfs(v);
    return ans;
}   

bool onc[N];

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    f[0] = 1;
    for (int i = 1; i < N; ++i)
        f[i] = f[i - 1] * i % MOD;

    int n;
    cin >> n;
    vector <int> p(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> p[i];
        if (p[i] != -1) 
            tree[p[i]].app(i);
    }

    int k = 0;
    vector <int> cnt;
    for (int i = 1; i <= n; ++i)
        if (p[i] == -1) {
            ++k;
            cnt.app(dfs(i));
        }

    #ifdef HOME
    for (auto e : cnt)
        cout << e << ' ';
    cout << endl;
    #endif

    int way = fp(n - 1, k);

    dp[0][0] = 1;
    for (int i = 0; i < k; ++i) {
        for (int j = 0; j <= i; ++j) {
            if (!dp[i][j])
                continue;
            dp[i + 1][j] = mod(dp[i + 1][j] + dp[i][j]);
            dp[i + 1][j + 1] = mod(dp[i + 1][j + 1] + dp[i][j] * cnt[i]);
        }   
    }   

    int comp = 0;    
    for (int i = 2; i <= k; ++i) {
        comp = mod(comp + mod(dp[k][i] * f[i - 1]) * fp(n - 1, k - i));
    }
    for (auto e : cnt)
        comp = mod(comp + (e - 1) * fp(n - 1, k - 1));        

    vector <int> in(n + 1);
    for (int i = 1; i <= n; ++i) {
        if (p[i] != -1) {
            ++in[p[i]];
        }   
    }   

    vector <bool> onc(n + 1, 1);

    queue <int> q;
    for (int i = 1; i <= n; ++i) 
        if (!in[i]) 
            q.push(i);
    while (q.size()) {
        int u = q.front(); q.pop();
        onc[u] = 0;
        if (p[u] != -1) {
            --in[p[u]];
            if (in[p[u]] == 0)
                q.push(p[u]);
        }   
    }   

    vector <bool> used(n + 1);
    int cyc = 0;
    for (int i = 1; i <= n; ++i) {
        if (onc[i] && !used[i]) {
            ++cyc;
            int u = i;
            while (!used[u]) {
                used[u] = 1;
                u = p[u];
            }   
        }   
    }   

    comp = mod(comp + cyc * way);

    #ifdef HOME
    cout << "cyc " << cyc << endl;
    cout << "way " << way << endl;
    cout << "comp " << comp << endl;            
    #endif

    cout << mod(way * n - comp) << endl;
}

Measured memory_bytes: 120896
using System;
class p
{
  static void Main()
  {
    string S = Console.ReadLine();
    string T = Console.ReadLine();
    int cnt = 0;
    for (int i = 0; i < S.Length; i++) {
      if (S[i] != T[i]) {
        cnt++;
      }
    }
    Console.WriteLine(cnt);
  }
}

Measured memory_bytes: 27440
sa = input()
sb = input()
sc = input()

a,b,c = 0,0,0
turn = 'a'
ans = '?'

while True:
    if turn == 'a':
        if a == len(sa):
            ans = 'A'
            break
        turn = sa[a]
        a += 1
    elif turn == 'b':
        if b == len(sb):
            ans = 'B'
            break
        turn = sb[b]
        b += 1
    else:
        if c == len(sc):
            ans = 'C'
            break
        turn = sc[c]
        c += 1

print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    bool frag=false;
    int ans = 0;
    string q = "ATGC";
    rep(i,s.size()){
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
            int cnt=0;
            while(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
                cnt++;i++;
            }
            ans = max(ans,cnt);
            i--;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  cout << "ABC" << n << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
      
#define MIN 1
#define MAX 100
     
int main(void)
{

    int x = 0;

    scanf("%d", &x);

    if(x < MIN || x > MAX){
        return -1;
    }
   
    printf("%d\n", x*x*x);
     
    return 0;
}


Measured memory_bytes: 2136
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Convert;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }


        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            var ans = Ceiling((double)(a + b) / 2);
            WriteLine(ans);
        }


        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
using namespace std;
int main(void){
	int date[100];
	int n,q;
	int i,j;
	
	while(cin>>n>>q,(n||q)){
		for(i=0;i<100;i++)date[i]=0;

		for(i=0;i<n;i++){
			int m;
			cin>>m;
			for(j=0;j<m;j++){
				int d;
				cin>>d;
				date[d]++;
			}
		}
		int max=0;
		for(i=0;i<100;i++){
			if(date[i]>date[max]){
				max=i;
			}
		}
		if(date[max]>=q){
			cout<<max<<endl;
		}else{
			cout<<0<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 864
#include <iostream>
#include <numeric>
#include <vector>
int main(int argc, char *argv[]) {
	size_t n, m; std::cin >> n >> m;
	std::vector<uint32_t> a(n, 0);
	for (size_t i = 0; i < n; i++) {
		size_t k; std::cin >> k;
		for (size_t j = 0; j < k; j++) {
			size_t aij; std::cin >> aij;
			a[i] |= UINT32_C(1) << (aij - 1);
		}
	}
	const uint32_t aa = std::accumulate(
		a.begin(), a.end(), ~UINT32_C(0),
		[] (const auto &acc, const auto &arg) {
			return (acc & arg);
		}
	);
	// FIXME: Use __builtin_popcount, std::bitset or boost::dynamic_bitset?
	size_t pc = 0;
	for (size_t i = 0; i < m; i++) {
		const uint32_t mask = UINT32_C(1) << i;
		const uint32_t aam  = aa & mask;
		const bool     pop  = (aam == mask);
		if (pop) { pc++; }
	}
	std::cout << pc << std::endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

struct RandomNumberGenerator {
    mt19937 mt;

    RandomNumberGenerator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

    int operator()(int a, int b) { // [a, b)
        uniform_int_distribution< int > dist(a, b - 1);
        return dist(mt);
    }

    int operator()(int b) { // [0, b)
        return (*this)(0, b);
    }
};

RandomNumberGenerator RNG;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<vector<int>> G(N);
    rep(i,N-1) {
        int u,v; cin >> u >> v;
        --u; --v;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    vector<int> V(N,1e9);
    int K; cin >> K;
    int r = -1;
    rep(i,K) {
        int v,p; cin >> v >> p;
        --v;
        V[v] = p;
        r = v;
    }

    auto No=[]() {
        cout << "No" << ln;
        exit(0);
    };
    vector<int> L(N,-1e9), R(N,1e9);
    {
        auto dfs=[&](auto&& self, int v, int pv)->void {
            if (L[v] > R[v]) No();
            if (V[v] != 1e9) {
                if (pv != -1 and L[v]%2!=V[v]%2) No();
                L[v] = R[v] = V[v]; 
            }
            for (auto nv : G[v]) {
                if (nv==pv) continue;
                chmax(L[nv],L[v]-1);
                chmin(R[nv],R[v]+1);
                self(self, nv, v);
                chmax(L[v],L[nv]-1);
                chmin(R[v],R[nv]+1);
            }
        };
        dfs(dfs,r,-1);
        dfs(dfs,r,-1);
    }

    cout << "Yes" << ln;
    vector<int> d = {-1,1};
    vector<int> ans(N);
    ans[r] = V[r];
    {
        auto dfs=[&](auto&& self, int v, int pv)->void {
            for (auto nv : G[v]) {
                if (nv==pv) continue;
                int n = RNG(2);
                int val = ans[v]+d[n];
                if (val < L[nv] or R[nv] < val) n = 1-n;
                ans[nv] = ans[v]+d[n];
                self(self,nv,v);
            }
        };
        dfs(dfs,r,-1);
    }

    rep(i,N) cout << ans[i] << ln;
}

Measured memory_bytes: 12032
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
	while (true) {
		vector<pair<int, int> > s;
		set<pair<int, int> > d;
		int m, n;
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; ++i) {
			int a, b; cin >> a >> b;
			s.push_back(make_pair(a, b));
		}
		cin >> m;
		for (int i = 0; i < m; ++i) {
			int a, b; cin >> a >> b;
			d.insert(make_pair(a, b));
		}
		sort(s.begin(), s.end());

		for (set<pair<int, int> >::iterator it = d.begin(); it != d.end(); ++it) {
			int dx = it->first - s[0].first;
			int dy = it->second - s[0].second;
			bool ok = true;
			for (int j = 1; j < n; ++j) {
				if (d.find(make_pair(s[j].first+dx, s[j].second+dy)) == d.end()) {
					ok = false;
					break;
				}
			}
			if (ok) { cout << dx << " " << dy << endl; break; }
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.math.BigInteger;
// warm-up
// Tribute to number 9 huh? As long as i can practice here at Atcoder. Thank you
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		BigInteger b = BigInteger.ZERO;
		BigInteger NINE = new BigInteger("9");
		for (char ch : sc.next().toCharArray()) b=b.add(new BigInteger(""+ch));
		System.out.println(b.mod(NINE).equals(BigInteger.ZERO) ? "Yes" : "No");
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}


Measured memory_bytes: 60452
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 5e5 + 10;
ll t[maxN], v[maxN];
ll L;
bool is_bad(pair < ld, ll >& f1, pair < ld, ll >& f2, pair < ld, ll >& f3) {
    return (f2.first - f1.first) * (f3.second - f2.second) <= (f3.first - f2.first) * (f2.second - f1.second);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> L;
    for (int i = 1; i <= n; i++) {
        cin >> t[i] >> v[i];
    }
    deque < pair < ld, ll > > all;
    all.emplace_back(t[1] * L, L);
    cout.precision(8);
    cout << fixed << t[1] << '\n';
    ll addY = 0;
    ll addX = 0;
    all.emplace_front(0, 0);
    for (int i = 2; i <= n; i++) {
        addX += v[i];
        addY += v[i] * t[i];
        while (all.size() >= 2 && all[all.size() - 2].second + addX >= L) all.pop_back();
        while (all.size() >= 2 && all[all.size() - 2].second + addX >= L) all.pop_back();
        ld val = addY + (all[all.size() - 2].first * (all[all.size() - 1].second + addX - L) + all[all.size() - 1].first * (L - all[all.size() - 2].second - addX)) /
                        (all[all.size() - 1].second - all[all.size() - 2].second);
        assert(all.back().second + addX >= L);
        all[all.size() - 1].first = val - addY;
        all[all.size() - 1].second = L - addX;
        all.emplace_front(-addY, -addX);
//        cout << "STEP-1 " << endl;
//        for (auto it : all) {
//            cout << (it.first + addY) / (it.second + addX) << " " << it.second + addX << endl;
//        }
//        cout << "----------------" << endl;
        while (all.size() >= 3 && is_bad(all[0], all[1], all[2])) {
            all[1] = all[0];
            all.pop_front();
        }

//        cout << "STEP0 " << endl;
//        for (auto it : all) {
//            cout << (it.first + addY) / (it.second + addX) << " " << it.second + addX << endl;
//        }
//        cout << "----------------" << endl;
        cout << fixed << (all.back().first + addY) / L << '\n';
    }
    return 0;
}

Measured memory_bytes: 33724
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e10;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

// Cap int ,Cost long long
template<typename Cap,typename Cost>
struct mcf_graph{
    struct edge{
        int to;
        Cap cap;
        Cost cost;
        int rev;
    };
    int n;
    vector<vector<edge>> G;
    vector<Cost> dist;
    vector<int> prev_edge;
    vector<int> prev_vertex;

    mcf_graph(int n):n(n),G(n),dist(n,-1),prev_edge(n),prev_vertex(n){}

    void add_edge(int from,int to,Cap cap,Cost cost){
        G[from].push_back(edge{to,cap,cost,(int)G[to].size()});
        G[to].push_back(edge{from,0,-cost,(int)G[from].size()-1});
    }

    // min cost  s -> t (f flow)
    pair<Cap,Cost> min_cost_max_flow(int s,int t,Cap f){
        Cost res = 0;
        Cap f_ = f;
        while(f > 0){
            fill(dist.begin(),dist.end(),LINF);
            dist[s] = 0;
            bool update = true;
            while(update){
                update = false;
                for(int i=0;i<n;i++){
                    if(dist[i]>=LINF) continue;
                    for(int j=0;j<(int)G[i].size();j++){
                        edge &e = G[i][j];
                        if(e.cap > 0 && dist[e.to] > dist[i] + e.cost){
                            dist[e.to] = dist[i] + e.cost;
                            prev_vertex[e.to] = i;
                            prev_edge[e.to] = j;
                            update = true;
                        }
                    }
                }
            }

            if(dist[t] == LINF){
                return pair<Cap,Cost>{f_-f,res};
            }

            Cap d = f;
            for(int v=t;v!=s;v=prev_vertex[v]){
                d = min(d,G[prev_vertex[v]][prev_edge[v]].cap);
            }
            f -= d;
            res += d*dist[t];
            for(int v=t;v!=s;v=prev_vertex[v]){
                edge &e = G[prev_vertex[v]][prev_edge[v]];
                e.cap -= d;
                G[v][e.rev].cap += d;
            }
        }
        return pair<Cap,Cost>{f_,res};
    }

};

ll a[60][60];

int main(){
    int n,k;
    cin >> n >> k;
    rep(i,n)rep(j,n) cin >> a[i][j];
    int s = 2*n,t = 2*n+1;

    mcf_graph<int,ll> G(2*n+2);

    G.add_edge(s,t,n*k,LINF);

    rep(i,n){
        G.add_edge(s,i,k,0);
        G.add_edge(i+n,t,k,0);
    }

    rep(i,n)rep(j,n){
        G.add_edge(i,j+n,1,LINF-a[i][j]);
    }

    pair<int,ll> ans = G.min_cost_max_flow(s,t,n*k);

    cout << (ll)ans.first * LINF - ans.second << endl;

    vector<vector<char>> maze(n,vector<char>(n,'.'));

    rep(i,n){
        for(int j=0;j<(int)G.G[i].size();j++){
            if(G.G[i][j].to==s || G.G[i][j].to == t || G.G[i][j].to < n) continue;
            if(G.G[i][j].cap == 0) maze[i][G.G[i][j].to-n] = 'X';
        }
    }

    rep(i,n){
        rep(j,n){
            cout << maze[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3840
// Vicfred
// https://atcoder.jp/contests/abc155/tasks/abc155_c
import std.algorithm;
import std.conv;
import std.stdio;
import std.string;

void main() {
    int n = readln.chomp.to!int;

    int[string] votes;

    foreach(_; 0..n) {
        string s = readln.chomp;
        votes[s] = votes.get(s,0)+1;
    }

    int maxima = 0;
    foreach(item; votes.values()) {
        maxima = max(maxima, item);
    }

    string[] ans;
    foreach(item; votes.keys()) {
        if(votes[item] == maxima)
            ans ~= item;
    }

    sort(ans);

    foreach(item; ans)
        item.writeln;
}



Measured memory_bytes: 29180
<?php
  $m=0;
  $n=0+fgets(STDIN);
  for($i=0;$i<$n;$i++)
  {
    $x=0+fgets(STDIN);
    $s+=$x;
    if($m<$x)$m=$x;
  }
  echo $s-$m/2;

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

int main() {
  int N,A,S=0,count=0;
  cin >> N;
  while(N--){
    cin >> A;
    S |= A;
  }
  while(S%2==0){
    ++count;
    S/=2;
  }
  cout << count << endl;  
}


Measured memory_bytes: 3540
def is_month(dst):
    a = int(dst)
    if a < 1:
        return False
    elif a > 12:
        return False
    else:
        return True

def main():
    N = input()
    f = N[:2]
    b = N[2:]
    if is_month(f) :
        if is_month(b):
            print('AMBIGUOUS')
        else:
            print('MMYY')
    else:
        if is_month(b):
            print('YYMM')
        else:
            print('NA')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

n = int(input())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ans = 0
for i in range(n+1):
    if (len(make_divisors(i))==8) and (i%2==1):
        ans += 1

print(ans)

Measured memory_bytes: 3060