akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
//union-findのクラス
class unionfind {
    vector<int> par, rank, size_;
    //速度ではなくメモリ効率を考えるならrankのかわりにsizeを使う
public:
    unionfind(int n) :par(n), rank(n), size_(n, 1) {
        iota(par.begin(),par.end(), 0);
    }
    int find(int x) {
        if (par[x] == x)return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y)return;
        if (rank[x] < rank[y])swap(x, y);
        par[y] = x;
        size_[x] += size_[y];
        if (rank[x] == rank[y])rank[x]++;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return size_[find(x)];
    }
};

signed main(){
    int N,M,K;
    cin >> N >> M >> K;
    vector<vector<int>>f(N),b(N);
    auto Friend = unionfind(N + 1);
    auto block  = unionfind(N + 1);
    rep(i,M){
        int a,b; cin >> a >> b;
        --a; --b;
        f[a].emplace_back(b);
        f[b].emplace_back(a);
        Friend.unite(a,b);
    }
    vector<int>ans(N,0);
    for(int i = 0; i < N; ++i){
        ans[i]  = Friend.size(i) - 1 - (int)f[i].size();
    }
    rep(i,K){
        int a,b; cin >> a >> b;
        --a; --b;
        if(Friend.find(a) == Friend.find(b)){
            ans[a]--; ans[b]--;
        }
    }
    for(auto e : ans)
        cout << e << endl;
}


Measured memory_bytes: 14964
#import numpy as np
#import functools
#import operator
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
#import collections as C #most_common

#N = int(input())
X,N= map(int,input().split())
P = list(map(int,input().split()))
#S= str(input())

for i in range(100):
    if X-i not in P:
        print(X-i)
        exit()
    elif X+i not in P:
        print(X+i)
        exit()


Measured memory_bytes: 9172
#include <iostream>
#include <map>
#include <string>
#include <algorithm>

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

using namespace std;

int main() {
    int n = 0;
    cin >> n;
    map<int, int>A;
    int B[100000] = {0};
    REP(i, n) {
        int a = 0;
        cin >> a;
        A[a]++;
    }
    for (auto itr = A.begin(); itr != A.end(); itr++){
        const int key = itr->first;
        if (A.count(key - 1)){
            B[key] += A[key - 1];
        }
        if (A.count(key + 1)){
            B[key] += A[key + 1];
        }
        B[key] += A[key];
    }
    int ret = 0;
    for (int i = 0; i < 100000; i++){
        if (ret < B[i]){
            ret = B[i];
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 3584
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[input() for i in range(n)]
    cnt=0
    from collections import Counter
    c=Counter(l)# ()にカウンターの対象のリストの変数名
    for i in c.values():
        if i%2==1:
            cnt+=1
    print(cnt)
resolve()

Measured memory_bytes: 60636
#include<iostream>

using namespace std;

int main (){
	int i,h,m,s;
	while ( cin >> i){
		h = i/3600;
		m = i%3600/60;
		s = i%3600%60;
		cout << h << ':' << m << ':' << s << endl;
	}
	return 0 ;
} 


Measured memory_bytes: 3132
/*
  AtCoder Beginner Contest 081
  D - Non-decreasing

  方針
    (1)すべての数字が非負の場合 or 負の場合
      N-1回の操作で条件を満たすことができる。
    (2)上記以外の場合  
      N+1回以内に上記の場合に持ち込む
  
  実装
    入力と共に最小値、最大値を保持しておく
    方針の通り
      (1)の場合は、N-1回の操作で条件を満たすことができる。
      (2)の場合は、最小値の絶対値と最大値の絶対値のうち大きい方の数をすべての数に足せば、(1)の場合に帰着できる。
*/

#include<iostream>
using namespace std;

int N, a;

int main() {
  scanf("%d", &N);
  int minval = 1000001, maxval = -1000001;
  int mini, maxi;
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &a);

    if (a < minval) {
      minval = a;
      mini = i;
    }

    if (a > maxval) {
      maxval = a;
      maxi = i;
    }
  }

  if (minval > 0) {
    printf("%d\n", N - 1);
    for (int i = 1; i < N; ++i) printf("%d %d\n", i, i + 1);
  }
  else if (maxval < 0) {
    printf("%d\n", N - 1);
    for (int i = N; i > 1; --i) printf("%d %d\n", i, i - 1);
  }
  else {
    printf("%d\n", 2 * N - 1);
    if (abs(minval) > maxval) {
      for (int i = 1; i <= N; ++i) printf("%d %d\n", mini, i);
      for (int i = N; i > 1; --i) printf("%d %d\n", i, i - 1);
    }
    else {
      for (int i = 1; i <= N; ++i) printf("%d %d\n", maxi, i);
      for (int i = 1; i < N; ++i) printf("%d %d\n", i, i + 1);
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vector<double> v(n);
    rep(i, n) {
        cin >> v[i];
    }
    sort(all(v));

    double ans = v[0];
    exrep(i, 1, n-1) {
        ans = (ans + v[i])/2.0;
    }

    exout(ans);
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool mycomp(pair <int, int> a, pair <int, int> b) {
  return a.second < b.second;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector <pair <int, int> > ab(m);
  for (int i = 0; i < m; i++) {
	  int a, b;
	  cin >> a >> b;
	  ab[i] = make_pair(a, b);
	}
  sort(ab.begin(), ab.end(), mycomp);
  int ans = 0;
  int l   = 1;
  for (int i = 0; i < m; i++) {
	  if (l <= ab[i].first) {
		  ans++;
		  l = ab[i].second;
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
////
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#include <bits/stdc++.h>

#include <random>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//#ifdef __int128
using hll = __int128;

using ll = long long;
//#endif
using pii = pair<ll, ll>;
using ld = double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

//#define solvsh
//#define multi

#ifdef solvsh
#else

ll mod = 1000000007;

ll add(ll a, ll b){
    return (a + b) % mod;
}
ll ml(ll a, ll b) {
    return (a * b) % mod;
}

ll sub(ll a, ll b) {
    return add(a, mod - b);
}

const int MAXN =1e5 + 32;

vector<int> g[MAXN];

bool usd[MAXN];

void dfs(int ver) {
    if (usd[ver]) return;
    usd[ver] = true;
    for (auto e : g[ver]) { dfs(e) ;};
}

void solve() {

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    int cnt = 0;

    for (int i = 1; i <= n; ++i) {
        if (!usd[i]) {
            ++cnt;
            dfs(i);
        }
    }
    cout << cnt - 1 << "\n";
}


#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case " << i << ": ";
        solve();
//        cout << "\n";
        i++;
    }
}

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifndef ONLINE_JUDGE
#else
#endif
#ifdef multi
    //        gen();
    multisolve();
#else
    solve();
//    gen();
#endif
//    time_calc();
}


Measured memory_bytes: 9708
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF = ll(1e18)+5;
ll A,B,C,D;

map<ll,ll> mem;

ll dfs(ll N){
    if(mem.find(N) != mem.end()){
        return mem[N];
    }
    if(N==0){
        return INF;
    }
    if(N==1){
        mem[1] = D;
        return D;
    }
    //ベースライン
    ll retVal;
    if(N <=INF/D){
        retVal = N*D;
    }else{
        retVal = INF;
    }
   
    ll least2 = ((N-1)/2);
    retVal = min(retVal,(N-least2*2)*D + A + dfs(least2));
    least2++;
    retVal = min(retVal,(least2*2-N)*D +A +dfs(least2));

    ll least3 = ((N-1)/3);
    retVal = min(retVal,(N-least3*3)*D + B +dfs(least3));
    least3++;
    retVal = min(retVal,(least3*3-N)*D + B +dfs(least3));
    
    ll least5 = ((N-1)/5);
    retVal = min(retVal,(N-least5*5)*D + C + dfs(least5));
    least5++;
    retVal = min(retVal,(least5*5-N)*D + C + dfs(least5));

    mem[N] =retVal;
    // cerr <<"N="<< N<<"retVal =" << retVal << endl;
    return retVal;
}

int main() {
    ll T,N;
    cin >> T;
    for(int i=0;i<T;i++){
        
        cin >>N>> A >> B>>C>>D;
        mem.clear();
        cout << dfs(N) << endl;
    }

    return 0;
}

Measured memory_bytes: 4808
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long L = sc.nextLong();
        long R = sc.nextLong();

        if(R-L>3000) {
            System.out.println(0);
        } else {
            long res = 2018;
            for(long i = L; i < R; i++) {
                for(long j = L+1; j <= R; j++) {
                    res = Math.min(res, (i*j)%2019);
                }
            }
            System.out.println(res);
        }
    }
}


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

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

vector<int> check(1000010);
bool div(int k){
  bool res = false;
  if(check.at(k)) res = true;
  
  for(int i = 1; i * i <= k; i++){
    if(k % i) continue;
    int a = i, b = k / i;
    if(a != 1){
      for(int j = a; j < 1000001; j += a) check.at(j) = 1;
    }
    if(b != 1){
      for(int j = b; j < 1000001; j += b) check.at(j) = 1;
    }
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  bool ok = true;
  for(int i = 0; i < n; i++){
    if(div(a.at(i))) ok = false;
    if(!ok) break;
  }
  if(ok){
    cout << "pairwise coprime" << endl;
    return 0;
  }
  
  int k = a.at(0);
  for(int i = 0; i < n; i++){
    k = gcd(k , a.at(i));
  }
  if(k == 1) cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;
}

Measured memory_bytes: 11100
#include<stdio.h>

int main() {
    int H, N;
    scanf("%d %d", &H, &N);

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

    for(i = 0; i < N; i++) {
        H = H - A[i];
    }

    if(H <= 0) {
        printf("Yes");
    } else {
        printf("No");
    }


    return 0;
}

Measured memory_bytes: 512
#39 階乗の0個数 - Time Limit Exceeded

while True:
    n=int(input())
    x=1
    y=[]
    z=0
    if n==0:
        break
    for i in range(1,n+1):      #階乗
        x*=i
        #print(x)
    #print(str(x))
    for j in str(x):    #文字列
        y+=[j]
    #print(y)
    y.reverse()         #逆順
    #print(y)
    for k in y:         #0以外の値がきたら終わり
        if k=='0':
            z+=1
        elif k!=0:
            break
    print(z)


Measured memory_bytes: 6492
#include <iostream>
#include <queue>
#include <set>
#include <utility>
#include <string>
using namespace std;

int main() {
    queue<pair<int,pair<int,int>>> q;
    set<pair<int,int>> p;
    unsigned char r[1000][1000];
    for(int i = 0;i < 1000;i++)for(int j=0;j<1000;j++)r[i][j]=0;
    int h,w;
    cin >> h >> w;
    string buf;
    for(int y = 0;y < h;y++) {
        cin >> buf;
        for(int x = 0;x < w;x++) {
            if(buf[x] == '#') {
                q.push(make_pair(0,make_pair(x,y)));
            } else {
                r[x][y] = 1;
                //p.insert(make_pair(x,y));
            }
        }
    }
    int res = 0;
    int f[4][2] = {{0,1},{0,-1},{1,0},{-1,0}};
    while(!q.empty()) {
        auto& c = q.front().second;
        int n = q.front().first;
        res = max(res,n);
        for(int i = 0;i < 4;i++) {
            if(c.first+f[i][0] >= 0 && c.first+f[i][0] < 1000 && c.second+f[i][1] >= 0 && c.second+f[i][1] < 1000 && r[c.first+f[i][0]][c.second+f[i][1]] == 1) {
                q.push(make_pair(n+1,make_pair(c.first+f[i][0],c.second+f[i][1])));
                r[c.first+f[i][0]][c.second+f[i][1]] = 0;
            }
            /*auto d = p.find(make_pair(c.first+f[i][0],c.second+f[i][1]));
            if(d != p.end()) {
                q.push(make_pair(n+1,make_pair(c.first+f[i][0],c.second+f[i][1])));
                p.erase(d);
            }*/
        }
        q.pop();
    }
    cout << res << endl;
}

Measured memory_bytes: 13328
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

const P: i64 = 1_000_000_007;

pub fn pow(x: i64, n: i64) -> i64 {
    let (mut x, mut y, mut n) = (x % P, 1_i64, n);
    while n > 0 {
        if n % 2 != 0 {
            y = (y * x) % P;
            n -= 1;
        }

        x = (x * x) % P;
        n /= 2;
    }
    y
}

fn main() {
    let (X, Y) = read!(i64, i64);

    if (X + Y) % 3 != 0 {
        println!("0");
        return;
    }

    let K = (X + Y) / 3;
    if 2 * K < X || X < K {
        println!("0");
        return;
    }

    let mut fact = vec![0; K as usize * 2 + 1];
    fact[0] = 1;
    fact[1] = 1;
    for n in 2..fact.len() {
        fact[n] = n as i64 * fact[n - 1] % P;
    }

    let mut fact_inv = vec![0; fact.len()];
    for n in 0..fact_inv.len() {
        fact_inv[n] = pow(fact[n], P - 2);
    }

    let mut n = fact[K as usize];
    n *= fact_inv[(2 * K - X) as usize];
    n %= P;

    n *= fact_inv[(X - K) as usize];
    n %= P;

    println!("{}", n)
}


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

int main(){
    int K,N;
    cin >> K >> N;
    int A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    //maxIdxから始めた時が最小になる(=最大を避ける)ようにする
    int max= -1,maxIdx = -1;
    for(int i=0;i<N-1;i++){
        int def = A[i+1] - A[i];
        if(def > max){
            max = def;
            maxIdx = i+1;
        } 
    }
    if(K-A[N-1]+A[0] > max){
        maxIdx = 0;
    }

    int sum=0;
    for(int i= maxIdx;i<N-1;i++){
        sum += A[i+1] - A[i];
    }

    if(maxIdx != 0){
        sum += K - A[N-1] + A[0];
        for(int r = 0;r<maxIdx-1;r++){
            sum += A[r+1] - A[r];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pi pair<int,int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e9+10;

/*----------------------------------------------*/

signed main(){
  int n,k;
  cin>>n>>k;
  vi h(n+k,0);
  rep(i,n) cin>>h[i];
  vi dp(n+k+3,INF);
  dp[0]=0;
  rep(i,n){
    FOR(j,1,k){
      chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]))
    }
    // chmin(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
    // chmin(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
  }

  cout<<dp[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

signed main()
{
  ll L;
  cin >> L;

  double ans = (double)(L * L * L) / (3.0 * 3.0 * 3.0);

  cout << fixed << setprecision(9) << ans << endl;
}


Measured memory_bytes: 256
// /*
// power code taken from geeks for geeks
// */
// cout << setprecision (2) << fixed << 1.2;

#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 100000000
#define MAX_N 100001LL

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

const ll INF = 1e18 + 5;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
    return 1LL;

    ll P = power(k, p/2LL);
    P = (P * P) % MODD;

    if (p % 2 == 1)
    P = (P * k) % MODD;

return P;
}

ll power(ll k, ll p, bool f){
    if (p == 0)
    return 1LL;

    ll P = power(k, p/2LL);
    P = (P * P);

    if (p % 2 == 1)
    P = (P * k);

return P;
}


struct p_str{
    ll a, b;
};



void solve(){
    ll N, W;
    cin >> N >> W;
    ll w[N+1], v[N+1];
    for(ll i = 1; i <= N; i++) {
        cin >> w[i] >> v[i];
    }

    ll sum_val = 0;
    for(ll i = 1; i <= N; i++) {
        sum_val += v[i];
    }

    ll dp[MAX_N]; // dp[i] => min wt for value i for all n items
    dp[0] = 0;
    for(ll i = 1; i < MAX_N; i++) {
        dp[i] = INF;
    }

    for(ll i = 1;i <= N; i++) {
        for(ll j = sum_val; j >= 0; j--) {
            if(dp[j] != INF){
                ll val = v[i];
                ll wt = w[i];
                ll idx = j + val;

                // cout << "idx " << idx << endl;

                dp[idx] = min(dp[idx], dp[j] + wt);
            }
        }
    }

    // cout << "dp ";
    // for(ll i = 0; i <= sum_val; i++){
    //     cout << dp[i] << " "; 
    // }cout << endl;

    ll ans = 0;
    for(ll i = sum_val; i >= 0; i-- ) {
        if(dp[i] != INF && dp[i] <= W) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
}



int main(){




    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;

    // init();

    // cin>>t;

    while(t--){

        solve();
    }
    return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> hoge(n);
    for(int i=0;i<n;i++) cin>>hoge[i];
    
    long long ans=0;
    int mi=999999;
    
    for(int i=0;i<n;i++){
        if(i==0){
            ans++;
            mi=hoge[i];
        }else{
            mi=min(mi,hoge[i]);
            if(hoge[i]==mi) ans++;
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
int n,m,i,j,k,count1=0,count2=0;
using namespace std;
void ABC120(void);
void ABC121(void);
void ABC122(void);
void ABC123(void);
void ABC124(void);
void ABC125(void);
void ABC126(void);
void ABC127(void);
void ABC128(void);
void ABC129(void);

int main(void){
    ABC125();
}

void ABC125(){
    int sum=0;
    cin>>n;
    vector<int> v(n),c(n);
    for(i=0;i<n;i++){
        cin>>v[i];
    }
    for(i=0;i<n;i++){
        cin>>c[i];
        if(v[i]-c[i]>0)sum+=v[i]-c[i];
    }
    cout<<sum<<endl;
}


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

int main() {
	int a[3];
	for (int i = 0; i < 3; i++) {
		std::cin >> a[i];
	}

	std::sort(std::begin(a), std::end(a));

	if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}

	//system("pause");
}

Measured memory_bytes: 256
use std::io;
use std::cmp::Ordering;

fn main() {
    let mut ab: Vec<u8> = read_input_vec();
    for e in ab.iter_mut() {
        if e == &1 {
            *e = 14
        }
    }

    match ab[0].cmp(&ab[1]) {
        Ordering::Equal => println!("Draw"),
        Ordering::Greater => println!("Alice"),
        Ordering::Less => println!("Bob")
    }
}

fn read_input<T: std::str::FromStr>() -> T {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    return input.parse::<T>().ok().unwrap();
}

fn read_input_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    return input
        .split_whitespace()
        .map(|x| x.parse::<T>().ok().unwrap())
        .collect();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
Int mod = 1e9+7;

Int par[100001];

Int root(Int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
}

void unite(Int x, Int y) {
    Int rx = root(x);
    Int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
}

int main() {
    Int n, m;
    cin >> n >> m;
    for (Int i = 1; i <= n; i++) par[i] = i;
    for (Int i = 0; i < m; i++) {
        Int x, y, z;
        cin >> x >> y >> z;
        unite(x, y);
    }
    map<Int, Int> mp;
    for (Int i = 1; i <= n; i++) {
        mp[root(i)]++;
    }
    dump(mp.size());
    return 0;
}

Measured memory_bytes: 7296
#include<stdio.h>
#define REP(i,n) for(i=0;i<n;i++)
int main(void){
  int hito,X,Y,Z;

  scanf("%d %d %d",&X,&Y,&Z);

  X-=Z;
  hito=X/(Y+Z);

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

  return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        List<String> inputs = new ArrayList<>();

        int num = sc.nextInt();
        for (int i = 0; i < num; i++) {
            inputs.add(sc.next());
        }

        int maxInput = 0;
        for (int i = 1; i < inputs.size(); i++) {
            if (inputs.get(maxInput).length() < inputs.get(i).length()) {
                maxInput = i;
            }
        }

        String[] maxStrArr = inputs.get(maxInput).split("");
        List<String[]> otherStrArr = new ArrayList<>();
        for (int i = 0; i < inputs.size(); i++) {
            if (i == maxInput) continue;
            otherStrArr.add(inputs.get(i).split(""));
        }

        List<String> ansChars = new ArrayList<>();
        for (String aMaxStrArr : maxStrArr) {
            int matchCount = 0;
            for (String[] anOtherStrArr : otherStrArr) {
                for (int k = 0; k < anOtherStrArr.length; k++) {
                    if (aMaxStrArr.equals(anOtherStrArr[k])) {
                        matchCount++;
                        anOtherStrArr[k] = "";
                        break;
                    }
                }
            }

            if (matchCount == otherStrArr.size()) {
                ansChars.add(aMaxStrArr);
            }
        }

        Collections.sort(ansChars);

        for (String ansChar : ansChars) {
            System.out.print(ansChar);
        }
        System.out.println();
    }
}


Measured memory_bytes: 23764
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int max = Math.max(a, Math.max(c, b));
		int sum = (max - a) + (max - b) + (max - c);
		if (sum % 2 == 0)
			out.println(sum / 2);
		else
			out.println(sum / 2 + 2);
		
		out.close();
	} 

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}


Measured memory_bytes: 22868
//ABC152 A

#include <bits/stdc++.h>
using namespace std;

int N;
long long P;
int ans = 0;

int main() {
  cin >> N;

  long long min_p = 100000000000;
  for(int i=0;i<N;i++){
    scanf("%lld",&P);
    if(min_p > P){
      ans++;
      min_p = P;
    }

  }

  cout << ans << endl;
}


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

using namespace std;

#define rep1(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep2(i, n, m) for (long long i = (long long)(n); i <= (long long)(m); i++)
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
const long long mod = 1e9 + 7;

int main() {
    double tax1 = 0.08;
    double tax2 = 0.10;
    long long a, b;
    cin >> a; cin >> b;
    long long result = -1;
    rep2(i, b / tax2, b / tax2 + 9) {
        if ((long long) ((double) i * tax1) == a) {
            result = i;
            break;
        }
    }
    cout << result << endl;
}


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

int main () {
    int n; cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        while (a % 2 == 0) {
            ans++;
            a /= 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
'use strict';
const main = input => {
  const n = parseInt(input[0]);
  let x = new Array(n), y = new Array(n), h = new Array(n);
  for(let i=0; i<n; i++) {
    let s = input[i+1].split(' ');
    x[i] = parseInt(s[0]);
    y[i] = parseInt(s[1]);
    h[i] = parseInt(s[2]);
  }
  // console.log(n, x, y, h);
  for(let px=0; px<101; px++) {
    for(let py=0; py<101; py++) {
      let height = 1;
      for(let i=0; i<n; i++) {
        if (h[i]) height = h[i]+Math.abs(px-x[i])+Math.abs(py-y[i])
      }
      let tf = 1;
      for(let k=0; k<n; k++) {
        if (Math.max(height-Math.abs(px-x[k])-Math.abs(py-y[k]), 0) != h[k]) {
          tf = 0;
        }
      }
      if (tf==1) {
        console.log(px, py, height);
        return;
      }
    }
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 9664
#include<iostream>
using namespace std;
#include<vector>
#include<cmath>
#include<algorithm>
#define int long long int
#define mod 1000000007
#define inf 20001
int answer=0;
void function(int h,int val)
{
	if(h==1)
	{
		answer+=val;
	}
	else
	{
		answer+=val;
		function(h/2,2*val);
	}
}
int32_t main()
{
   int h;
   cin>>h;
   function(h,1);
   cout<<answer<<endl; 
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)


int main() {
  int n;
  cin >> n;
  
  vector<string> p(n);
  rep(i,n) {
  cin >> p[i];
  }
  
  bool ans = true;
  repo(i,n) {
    if(p[i-1].at(p[i-1].size()-1)!=p[i].at(0)) {
    ans=false;
    break;
    }
  }
  
  sort(all(p));
  
  repo(i,n) {
    if(p[i-1]==p[i]) {
    ans = false;
    break;
    }
  }
  
  cout << (ans?"Yes":"No") << endl;

}

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

using namespace std;

void printSeries(int a, int b, int k){
    if(a + k <= b){
        set<int> s;
        for(int i = a ; i <= a + k - 1 ; i++){
            s.insert(i);
        }
        for(int i = b - k + 1; i <= b ; i++){
            s.insert(i);
        }
        set<int>:: iterator it = s.begin();
        for(; it!=s.end(); it++){
            cout<< *it<<endl;
        }

    }else{
        for(int i = a ; i <= b ; i++){
            cout << i << endl;
        }
    }

}

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    printSeries(a,b,k);
    return 0;
}


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

const int N = 200005;

int n, k;
long long a[N];
vector<long long> z;
long long ans;

// BIT
int T[N];
void upd(int x) { for (; x < N; x += x & -x) T[x]++; }
int get(int x) { int res = 0; for (; x > 0; x -= x & -x) res += T[x]; return res; }

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i], a[i] -= k;
		a[i] += a[i-1]; // a[] indicates prefix sums now
		z.push_back(a[i]);
	}
	z.push_back(0);
	sort(z.begin(), z.end());
	z.resize(distance(z.begin(), unique(z.begin(), z.end())));

	// solve
	upd(lower_bound(z.begin(), z.end(), 0) - z.begin() + 1);
	for (int i = 1; i <= n; ++i) {
		int pos = lower_bound(z.begin(), z.end(), a[i]) - z.begin() + 1;
		int cur = get(pos);
		ans += cur;
		upd(pos);
	}

	cout << ans << endl;
}

Measured memory_bytes: 4720
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            var values = Console.ReadLine().Split(' ');
            int n = int.Parse(values[0]);
            int a = int.Parse(values[1]);
            int b = int.Parse(values[2]);

            int plan1 = n * a;

            Console.WriteLine(Math.Min(plan1, b));
        }
    }
}


Measured memory_bytes: 11092
#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>;
typedef vector<int> vi;

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; a++) {
    int rem = X - a * 500; // 残金
    // 区間の上端 - 区間の下端
    res += max(0, min(rem / 100 + 1, B + 1)) - max(0, min((rem - (C - 1) * 50) / 100, B + 1));
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3484
import java.util.*;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int result = 0;
		if(a > b) {
			result = 2*a - 1;
		} else if(a == b) {
			result = a*2;
		}else {
			result = 2*b - 1;
		}
		System.out.println(result);
	}
}

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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;

int main(){
	ll n, m;
	cin >> n >> m;

	map<int, ll> mp;
	mp[0] = 0;

	rep(i, m){
		ll a, b;
		cin >> a >> b;
		int cs = 0;
		rep(j, b){
			int c;
			cin >> c;
			cs += (1 << (c-1));
		}
		map<int, ll> tmp(mp);
		for(auto it : mp){
			int n_cs = it.first | cs;
			ll tmp_a = tmp[n_cs];
						if(tmp_a == 0) tmp[n_cs] = (it.second + a);
			else tmp[n_cs] = min(tmp_a, it.second + a);
		}
		mp = tmp;
	}

	int all = 0;
	rep(i, n){
		all = all * 2 + 1;
	}
	if(mp[all] == 0) cout << -1 << endl;
	else cout << mp[all] << endl;

	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>A(N);
  vector<bool>B(1000001,true);
  vector<int>D(1000001,0);
  for(int i=0;i<N;i++){
    cin>>A[i];
    D[A[i]]++;
    if(B[A[i]]==false||D[A[i]]>1)continue;
    for(int j=2;A[i]*j<=1000000;j++)B[j*A[i]]=false;
  }
  int ans=0;
  for(int i=0;i<N;i++)if(B[A[i]]&&D[A[i]]<2)ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 7992
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {0,1,1,1,0,-1,-1,-1};
const static int ty[] = {-1,-1,0,1,1,1,0,-1};

class State{
public:
  int x;
  int y;
  int stage;
  int move_count;
  State(int _x,int _y,int _s, int _m) : x(_x),y(_y),stage(_s),move_count(_m){}
  State() : x(0),y(0),stage(0),move_count(0){}

  bool operator<(const State& s) const{
    return move_count < s.move_count;
  }
  bool operator>(const State& s) const{
    return move_count > s.move_count;
  }
};

int update(int stage,int vx,int vy,int N){
  int next = stage;
  for(int y=0;y<N;y++){
    for(int x=0;x<N;x++){
      if(x == vx && y == vy) continue;
      int count = 0;
      for(int i=0;i<8;i++){
	int dx = x + tx[i];
	int dy = y + ty[i];
	if(dx < 0 || dy < 0
	   || dx >= N || dy >=N) continue;
	if(stage & (1 << (dy*N+dx))) count++;
	if(dx == vx && dy == vy) count++;
      }
      if((stage & (1<<(y*N+x)))
	 && (count == 3 || count == 2)){
	next |= (1<<(y*N+x));
      }
      else if(!(stage & (1<<(y*N+x)))
	      && count == 3){
	next |= (1<<(y*N+x));
      }
      else{
	next &= ~(1<<(y*N+x));
      }
    }
  }
  return next;
}

void print_stage(int stage,int N){
  for(int y=0;y<N;y++){
    for(int x=0;x<N;x++){
      printf("%c",(stage & (1<<(y*N+x)) ? '#' : '.'));
    }
    printf("\n");
  }
  printf("\n");
}

int main(){
  int N;
  while(~scanf("%d",&N)){
    if(N==0) break;

    int stage = 0;
    int sx,sy;
    for(int y=0;y<N;y++){
      char buf[128];
      scanf("%s",buf);
      for(int x=0;x<N;x++){
	if(buf[x] == '@'){
	  sx = x;
	  sy = y;
	}
	if(buf[x] == '#'){
	  stage |= (1 << (y*N+x));
	}
      }
    }
    priority_queue<State,vector<State>,greater<State> > que;
    //x,y,visited,stage,move_count
    que.push(State(sx,sy,stage,0));
    
    map<int,int> move_count[25];
    move_count[sy*N+sx][stage] = 0;
    int res = -1;
    if(stage == 0){
      res = 0;
      goto found;
    }

    while(!que.empty()){
      State s = que.top();
      que.pop();
      for(int i=0;i<8;i++){
	int dx = s.x + tx[i];
	int dy = s.y + ty[i];
	if(dx < 0 || dy < 0
	   || dx >= N || dy >=N) continue;
	if(s.stage & (1<<(dy*N+dx))) continue;

	// print_stage(s.stage,N);
	int next_stage = update(s.stage,dx,dy,N);

	map<int,int>::iterator it = move_count[dy*N+dx].find(next_stage);
	if(it != move_count[dy*N+dx].end()) continue;
	
	move_count[dy*N+dx][next_stage] = s.move_count + 1;
	if(next_stage == 0){
	  res = s.move_count + 1;
	  goto found;
	}

	que.push(State(dx,dy,next_stage,s.move_count+1));
      }
    }
  found:;
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1556
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var n = N;

            var sum = 0;
            while (n != 0)
            {
                sum += n % 10;

                n /= 10;
            }

            if (N % sum == 0)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13140
/* ex4_3
	kanon */

#include <stdio.h>
#include <math.h>

int main(void)
{

    //与えられる値を入れる数を宣言
    int height_a,height_b;

    //変数に値を入力する
    scanf("%d %d",&height_a,&height_b);
  
  	//高さを計算する
    int diff=height_b-height_a,ans=0;
    for(int i=1;i<diff;i++){
        ans+=i;
    }
    ans-=height_a;
    printf("%d",ans);

    return 0;
}

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

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

Measured memory_bytes: 3624
eval"N,K,*A="+`dd`.split*?,
t=[];N.times{|i|s=0;A[i,N].map{|x|t<<s+=x}}
40.times{|i|u=t.select{|x|x[39-i]>0};u.size<K||t=u}
p eval t*?&

Measured memory_bytes: 44416
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int h, w, n;
    cin >> h >> w >> n;
    int y, x;
    cin >> y >> x;
    string s, t;
    cin >> s >> t;
    int r = y, c = x;
    rep(i, n)
    {
        if (s[i] == 'U')
            r--;
        if (r == 0)
        {
            cerr << "U" << endl;

            cout << "NO" << endl;
            return 0;
        }
        if (t[i] == 'D')
            r = min(h, r + 1);
    }
    r = y, c = x;
    rep(i, n)
    {
        if (s[i] == 'D')
            r++;
        if (r == h + 1)
        {
            cerr << "D" << endl;

            cout << "NO" << endl;
            return 0;
        }
        if (t[i] == 'U')
            r = max(1, r - 1);
    }
    r = y, c = x;
    rep(i, n)
    {
        if (s[i] == 'L')
            c--;
        if (c == 0)
        {
            cerr << "L" << endl;

            cout << "NO" << endl;
            return 0;
        }
        if (t[i] == 'R')
            c = min(w, c + 1);
    }

    r = y, c = x;
    rep(i, n)
    {
        if (s[i] == 'R')
            c++;
        if (c == w + 1)
        {
            cerr << "R" << endl;
            cout << "NO" << endl;
            return 0;
        }
        if (t[i] == 'L')
            c = max(1, c - 1);
    }
    cout << "YES" << endl;
    return 0;
}


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

static const int UP = 0;
static const int LEFT = 1;
static const int DOWN = 2;
static const int RIGHT = 3;

int dh[4] = {-1,0,1,0};
int dw[4] = {0,-1,0,1};

int adjacent_graph[30][30][4];


int BFS(int h, int w){
  vector<vector<int>> color_graph(h,vector<int>(w));
  rep(i,h)rep(j,w) color_graph[i][j] = 0;
  queue<pair<int,int>> que;
  que.emplace(make_pair(0,0));
  color_graph[0][0] = 1;
  while(!que.empty()){
    pair<int,int> now  = que.front(); que.pop();
    rep(d,4){
      int n_h = now.first + dh[d];
      int n_w = now.second + dw[d];
      if(0 <= n_h && n_h < h && 0 <= n_w && n_w < w && adjacent_graph[now.first][now.second][d] == 0 && color_graph[n_h][n_w] == 0){
        color_graph[n_h][n_w] = color_graph[now.first][now.second] + 1;
        que.emplace(make_pair(n_h,n_w));
      }
    }
  }

  return color_graph[h-1][w-1];
}

int main(){
  // init
 int H, W, input;


  while(true){
    //input
    cin >> W >> H;
    if (H == 0)break;
    rep(i,H){
      adjacent_graph[i][0][LEFT] = 1;
      adjacent_graph[i][W-1][RIGHT] = 1;
    }
    rep(i,H){
      adjacent_graph[0][i][UP] = 1;
      adjacent_graph[H-1][i][DOWN] = 1;
    }
    rep(i,2*H-1){
      int tmp_H = i/2;
      int tmp_W;
      if(i%2 ==0) {
        tmp_W = W -1;
        rep(j,tmp_W){
          cin >> input;
          adjacent_graph[tmp_H][j][RIGHT] = input;
          adjacent_graph[tmp_H][j+1][LEFT] = input;
        }
      }
      else{
        tmp_W = W;
        rep(j,tmp_W){
          cin >> input;
          adjacent_graph[tmp_H][j][DOWN] = input;
          adjacent_graph[tmp_H+1][j][UP] = input;
        }
      }
    }
    //BFS
    int ans = BFS(H,W);
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3196
# coding: utf-8
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    K = II()
    return (K,)


def solve(K):
    N = 50
    a = [49] * N
    div, mod = divmod(K, N)
    for i in range(N):
        a[i] += div
    if mod != 0:
        for i in range(mod):
            a[i] += N - (mod - 1)
        for i in range(mod, N):
            a[i] += -mod

    ans = "50\n" + " ".join(map(str, a))

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  int H, W, N;
  cin >> H >> W >> N;
  vector<vector<int>> answer(H, vector<int>(W));
  int dstH, dstW;
  dstH = dstW = 0;
  bool forward = true;
  rep(i, N) {
    int a;
    cin >> a;
    while (a--) {
      answer[dstH][dstW] = i + 1;
      if (forward) {
        if (dstW == W - 1) {
          dstH++;
          forward = false;
        } else {
          dstW++;
        }
      } else {
        if (dstW == 0) {
          dstH++;
          forward = true;
        } else {
          dstW--;
        }
      }
    }
  }

  rep(i, H) {
    rep(j, W) { cout << answer[i][j] << " "; }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] first = br.readLine().split(" ", 2);
        int n = Integer.parseInt(first[0]);
        int k = Integer.parseInt(first[1]);
        double[] arr = new double[n];
        String[] line = br.readLine().split(" ", n);
        for (int i = 0; i < n; i++) {
            double x = Integer.parseInt(line[i]);
            arr[i] = x * (x + 1) / 2 / x;
        }
        double max = 0;
        for (int i = 0; i < k; i++) {
            max += arr[i];
        }
        double sum = max;
        for (int i = 0; i + k < n; i++) {
            sum += arr[i + k] - arr[i];
            max = Math.max(max, sum);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 50044
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   string s,t,u,v;
   int a=0;
   cin>>s;
   t=s;
   reverse(t.begin(),t.end());
   if(s==t)a++;
   u=s.substr(0,s.size()/2);
   v=u;
   reverse(v.begin(),v.end());
   if(v==u)a++;
   
   if(a==2)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	int n,d;
	cin >> n;
	d = n%10;
	if((d==2)||(d==4)||(d==5)||(d==7)||(d==9)){
		cout << "hon" << endl;
	}
	else if((d==0)||(d==1)||(d==6)||(d==8)){
		cout << "pon" << endl;
	}
	else cout << "bon" << endl;
	return 0;
}

Measured memory_bytes: 3632