akhauriyash/Code-Regression huggingface dataset:
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, n) for (ll i = n; i >= 0; i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cerr << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cerr << e << " "; } cerr << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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


template<class Monoid> struct SegTree {
    using Func = function<Monoid(Monoid, Monoid)>;
    const Func F;
    const Monoid UNITY;
    int SIZE_R;
    vector<Monoid> dat;

    SegTree(int n, const Func f, const Monoid& unity) : F(f), UNITY(unity) { init(n); }
    void init(int n) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2, UNITY);
    }

    /* set, a is 0-indexed */
    void set(int a, const Monoid& v) { dat[a + SIZE_R] = v; }
    void build() {
        for (int k = SIZE_R - 1; k > 0; --k)
            dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }

    /* update a, a is 0-indexed */
    void update(int a, const Monoid& v) {
        int k = a + SIZE_R;
        dat[k] = v;
        while (k >>= 1) dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }

    /* get [a, b), a and b are 0-indexed */
    Monoid get(int a, int b) {
        Monoid vleft = UNITY, vright = UNITY;
        for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
            if (left & 1) vleft = F(vleft, dat.at(left++));
            if (right & 1) vright = F(dat.at(--right), vright);
        }
        return F(vleft, vright);
    }
    inline Monoid operator [] (int a) { return dat[a + SIZE_R]; }

    /* debug */
    void print() {
        for (int i = 0; i < SIZE_R; ++i) {
            cout << (*this)[i];
            if (i != SIZE_R - 1) cout << ",";
        }
        cout << endl;
    }
};
// ***************************************


int main() {

    ll N;
    cin >> N;

    vector<int> h(N);
    vector<ll> a(N);

    REP(i, N) cin >> h[i];
    REP(i, N) cin >> a[i];

    SegTree<ll> st(N + 1, [](ll a, ll b) {return max<ll>(a, b); }, 0);

    ll ans = 0;
    REP(i, N) {
        ll A = st.get(0, h[i]);
        if (st.get(h[i], h[i] + 1) < A + a[i]) {
            st.update(h[i], A + a[i]);
        }
        chmax(ans, A + a[i]);
    }

    cout << ans << endl;

#ifdef _MSC_VER
    system("PAUSE");
#endif
    return 0;
}



Measured memory_bytes: 6656
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;

int C[3][3];

int main(){
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			cin >> C[i][j];
		}
	}
	
	bool ans = true;
	
	int x[3][3];
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			x[i][j] = C[i][j] - C[(i+1)%3][j];
		}
	}
	
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			//cout << x[i][j];
		}
	}
	
	for(int i=0; i<3; i++){
		if(x[i][0] != x[i][1] || x[i][1] != x[i][2] || x[i][2] != x[i][0]) ans = false;
	}
	
	int y[3][3];
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			y[j][i] = C[j][i] - C[j][(i+1)%3];
		}
	}
	
	for(int i=0; i<3; i++){
		if(y[0][i] != y[1][i] || y[1][i] != y[2][i] || y[2][i] != y[0][i]) ans = false;
	}
	
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
use std::io::*;

fn binary_search<T: Ord>(slice: &[T], x: &T) -> Option<usize> {
	use std::cmp::Ordering::*;

	let mut l = 0usize;
	let mut r = slice.len();

	while l < r {
		let mid = (l + r) / 2;

		match x.cmp(unsafe { slice.get_unchecked(mid) }) {
			Equal => return Some(mid),
			Less => r = mid,
			Greater => l = mid + 1,
		}
	}
	None
}

fn main() {
	let input = {
		let mut buf = vec![];
		stdin().read_to_end(&mut buf);
		unsafe { String::from_utf8_unchecked(buf) }
	};
	let mut lines = input.split('\n');

	let input = lines.nth(1).unwrap();
	let s_vec: Vec<u32> = input.split(' ').map(|s| s.parse().unwrap()).collect();

	let input = lines.nth(1).unwrap();
	let t_iter = input.split(' ').map(|s| s.parse::<u32>().unwrap());

	let c = t_iter
		.filter(|i| binary_search(&s_vec, i).is_some())
		.count();

	println!("{}", c);
}



Measured memory_bytes: 5032
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
	int ans	= 0;
	int max	= 0;
	for(int i = 0; i<n; i++) {
            char c = s.charAt(i);
	    if(c=='I') {
                ans++;
	    } else {
                ans--;
            }
            max	= Math.max(ans,max);
	}
        System.out.println(max);
    }
}

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

ll x(ll a) {
    if (a % 4 == 0) return a;
    if (a % 4 == 1) return 1;
    if (a % 4 == 2) return a + 1;
    return 0;
}

signed main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> as(x), bs(y), cs(z);
    rep(i, x) cin >> as[i];
    rep(i, y) cin >> bs[i];
    rep(i, z) cin >> cs[i];

    vector<ll> ab(x*y);
    int index = 0;
    for(auto a: as) {
        for(auto b: bs)
            ab[index++] = a+b;
    }
    sort(be(ab), greater<ll>());
    ab.resize(k);

    vector<ll> anss(k*z);
    index = 0;
    for(auto aa: ab) {
        for(auto c : cs) {
            anss[index++] = aa+c;
        }
    }
    sort(be(anss), greater<ll>());
    anss.resize(k);
    for(auto e: anss) {
        cout << e << nl;
    }
}


Measured memory_bytes: 31616
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

struct Point {
	int x, y;
	Point() {}
	Point(int x, int y) {
		this->x = x;
		this->y = y;
	}
};

class Graph {
private:
	class Edge {
	public:
		int to;
		int cap;
		int rev;
		Edge(int to, int cap, int rev) {
			this->to = to;
			this->cap = cap;
			this->rev = rev;
		}
	};

	int calcFlow(int s, int t, int left) {
		if (s == t) return left;

		visited[s] = true;

		rep(i, nextEdges[s].size()) {
			Edge &edge = nextEdges[s][i];
			if (edge.cap == 0) continue;
			if (visited[edge.to]) continue;
			int flow = calcFlow(edge.to, t, min(left, edge.cap));
			if (flow > 0) {
				edge.cap -= flow;
				nextEdges[edge.to][edge.rev].cap += flow;
				return flow;
			}
		}

		return 0;
	}

	vector<bool> visited;
	vector<vector<Edge>> nextEdges, backUpNextEdges;
public:
	Graph() {}
	Graph(int n) {
		nextEdges.resize(n);
		visited.resize(n);
	}

	void addEdge(int node, int to, int cap) {
		nextEdges[node].push_back(Edge(to, cap, nextEdges[to].size()));
		nextEdges[to].push_back(Edge(node, 0, nextEdges[node].size() - 1));
	}

	int calcMaxFlow(int s, int t) {
		backUpNextEdges = nextEdges;

		int ret = 0;
		while (true) {
			rep(i, nextEdges.size()) visited[i] = false;
			int flow = calcFlow(s, t, INT_MAX);
			if (flow == 0) break;
			ret += flow;
		}

		nextEdges = backUpNextEdges;

		return ret;
	}
};

signed main() {
	int N;
	cin >> N;

	vector<Point> red, blue;
	rep(i, N) {
		int x, y;
		cin >> x >> y;
		red.push_back(Point(x, y));
	}
	rep(i, N) {
		int x, y;
		cin >> x >> y;
		blue.push_back(Point(x, y));
	}

	Graph g(2 * N + 2);
	rep(i, N) {
		g.addEdge(0, i + 1, 1);
		g.addEdge(N + i + 1, 2 * N + 1, 1);
	}
	rep(i, N) rep(j, N) {
		if (red[i].x < blue[j].x && red[i].y < blue[j].y) {
			g.addEdge(i + 1, N + j + 1, 1);
		}
	}

	cout << g.calcMaxFlow(0, 2 * N + 1) << endl;

    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, M) = Read2Longs();
            var x = new long[N];
            var y = new long[N];
            var z = new long[N];
            for (int i = 0; i < N; i++)
            {
                (x[i], y[i], z[i]) = Read3Longs();
            }

            var max = 0L;
            var pm = new long[] { 1, -1 };
            foreach (var xSign in pm)
            {
                foreach (var ySign in pm)
                {
                    foreach (var zSign in pm)
                    {
                        var sum = Enumerable.Range(0, (int)N)
                            .Select(i => xSign * x[i] + ySign * y[i] + zSign * z[i])
                            .OrderByDescending(x => x)
                            .Take((int)M)
                            .Sum();

                        max = Math.Max(max, sum);
                    }
                }

            }

            return max;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28932
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int N, ans;
  string A, B, C;
  cin >> N >> A >> B >> C;
  ans=0;
  for (int i=0; i<N; i++) {
    if (A[i]==B[i] && B[i]==C[i]) {
      ans=ans;
    }
    else {
      if (A[i]==B[i] || B[i]==C[i] || C[i]==A[i]) {
        ans=ans+1;
      }
      else {
        ans=ans+2;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define rep(i,a,b) for (int i=(a); i<(b); i++)
#define per(i,a,b) for (int i=(b-1); i>=(a); i--)
#define de(x) cout << #x << " => " << x << endl
using namespace std;

#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;

#define pb push_back
typedef vector<int> vi;

typedef long long ll;
typedef long double ld;

///----------------------------------------------
struct Hug {
    static const int Hug_N = 7 + 3000;
    int nx, ny;
    vi G[Hug_N];
    int par[Hug_N];
    bool vis[Hug_N];
    ///init
    void link(int a, int b) { G[a].pb(b); }
    void init(int _nx, int _ny) {
        nx = _nx; ny = _ny;
        rep(i, 1, nx + 1) G[i].clear();
    }
    ///find
    bool find(int u) {
        rep(i, 0, sz(G[u])) {
            int v = G[u][i]; if (vis[v]) continue;
            for (vis[v] = true; !~par[v] || find(par[v]); ) return par[v] = u, true;
        }
        return false;
    }
    ///work
    int work( ) {
        int ret = 0;
        rep(i, 1, ny + 1) par[i] = -1;
        rep(i, 1, nx + 1) {
            rep(k, 1, ny + 1) vis[k] = false;
            if (find(i)) ret++;
        }
        return ret;
    }
}   hug;
///-----
bool isP(int dig) {
    if (dig < 2) return false;
    for (int i = 2; i * i <= dig; i++)
        if (dig % i == 0) return false;
    return true;
}
///-----
vi v[2]; void add(int dig) { v[dig&1].pb(dig); }
///-----
int main() {

    ///freopen ( "xx.in" , "r" , stdin );

    ///read
    int n; cin >> n;
    int pre = -1;
    rep(i, 0, n) {
        int dig; scanf("%d",&dig);
        if (dig != pre + 1) {
            add(dig);
            if (~pre) add(pre + 1);
        }
        pre = dig;
    }
    add(pre + 1);

    ///work
    hug.init(sz(v[0]), sz(v[1]));
    rep(i, 0, sz(v[0])) {
        rep(j, 0, sz(v[1])) {
            if (isP(abs(v[0][i] - v[1][j]))) hug.link(i + 1, j + 1);
        }
    }

    ///print
    int can = hug.work();
    int ans = can;
    ans += (sz(v[0]) - can) / 2 * 2;
    ans += (sz(v[1]) - can) / 2 * 2;
    if ((sz(v[0]) - can)&1) ans += 3;
    printf("%d", ans);

}



Measured memory_bytes: 384
#include <math.h>

#include <algorithm>
#include <climits>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
const ll INF = 1000000000000000000;

int main() {
  int n;
  cin >> n;
  ll res = 1;
  bool un = true;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << 0;
      goto end;
    }
  }
  sort(a.begin(), a.end());
  rep(i, n) {
    if (res > res * a[i]) {
      un = false;
    }
    res *= a[i];
  }
  if (res > INF || !un)
    cout << -1;
  else
    cout << res;
end:
  return 0;
}


Measured memory_bytes: 4052
n,k = map(int,input().split())
v = list(map(int,input().split()))
kk = k
k = min(n,k)

ans = 0
for i in range(k+1):
	for j in range(k-i+1):
		# print(i,j)
		L = v[:i]
		R = v[-j:]
		if len(R) == n:
			R = []
		LR = L+R+[0]
		LR.sort()
		zero_idx = min(LR.index(0),kk-i-j)
		# print(LR,zero_idx,sum(LR[zero_idx:]))
		ans = max(ans,sum(LR[zero_idx:]))
print(ans)

Measured memory_bytes: 3064
// 2013/11/01 Tazoe

#include <iostream>
#include <queue>
using namespace std;

// 位置
struct point{
	int y;
	int x;
};

// 位置＋時間
struct state{
	int y;
	int x;
	int t;
};

int main()
{
	int H, W, N;
	cin >> H >> W >> N;

	char F[1002][1002];
	for(int y=0; y<=H+1; y++){
		for(int x=0; x<=W+1; x++){
			F[y][x] = 'X';
		}
	}

	struct point P[10];			// 巣(0)と工場(1-N)の位置

	for(int y=1; y<=H; y++){
		for(int x=1; x<=W; x++){
			cin >> F[y][x];

			if(F[y][x]=='S'){
				P[0].y = y;
				P[0].x = x;
				F[y][x] = '.';
			}
			else if('0'<=F[y][x] && F[y][x]<='9'){
				P[F[y][x]-'0'].y = y;
				P[F[y][x]-'0'].x = x;
				F[y][x] = '.';
			}
		}
	}

	int sum = 0;				// 合計時間

	for(int i=0; i<N; i++){			// P[i]からP[i+1]までの時間を求める
		struct state s;
		s.y = P[i].y;
		s.x = P[i].x;
		s.t = 0;

		queue<struct state> q;
		q.push(s);				// スタートをキューに挿入

		bool memo[1002][1002];
		for(int y=1; y<=H; y++){
			for(int x=1; x<=W; x++){
				memo[y][x] = false;
			}
		}
		memo[s.y][s.x] = true;			// スタートを訪問済

		while(true){
			if(q.empty())				// キュートップに頂点がなければ
				break;

			s = q.front();

			if(s.y==P[i+1].y && s.x==P[i+1].x){	// ゴールならば
				sum += s.t;
				break;
			}

			if(F[s.y][s.x+1]=='.' && !memo[s.y][s.x+1]){	// 東
				struct state t;
				t.y = s.y;
				t.x = s.x+1;
				t.t = s.t+1;

				q.push(t);
				memo[t.y][t.x] = true;
			}

			if(F[s.y][s.x-1]=='.' && !memo[s.y][s.x-1]){	// 西
				struct state t;
				t.y = s.y;
				t.x = s.x-1;
				t.t = s.t+1;

				q.push(t);
				memo[t.y][t.x] = true;
			}

			if(F[s.y+1][s.x]=='.' && !memo[s.y+1][s.x]){	// 南
				struct state t;
				t.y = s.y+1;
				t.x = s.x;
				t.t = s.t+1;

				q.push(t);
				memo[t.y][t.x] = true;
			}

			if(F[s.y-1][s.x]=='.' && !memo[s.y-1][s.x]){	// 北
				struct state t;
				t.y = s.y-1;
				t.x = s.x;
				t.t = s.t+1;

				q.push(t);
				memo[t.y][t.x] = true;
			}

			q.pop();
		}
	}

	cout << sum << endl;

	return 0;
}

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

bool is_prime[10001];
 
void sieve(){
	fill(is_prime,is_prime+10001,true);
	is_prime[0]=is_prime[1]=false;
	for(int i=2; i<=10000; ++i){
		if(is_prime[i]){
			for(int j=2; i*j<=10000; ++j){
				is_prime[i*j]=false;
			}
		}
	}
}

int main(){
	sieve();
	int N;
	while(cin >> N&&N){
		for(int i=N; i>=2; --i){
			//cout << i << endl;
			if(is_prime[i]&&is_prime[i-2]){
				cout << i-2 << ' ' << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1168
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<algorithm>
#include<list>
#include<cstring>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define pop pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define MOD         1000000007
#define I 10000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout); 
using namespace std;
int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
int main()
{
    jaldi
    #ifndef ONLINE_JUDGE 
    //TakeInput
    #endif
    string a[3]={"Sunny","Cloudy","Rainy"};
    string b;
    cin>>b;
    ll i;
    if(b=="Sunny"){
        i=0;
    }
    else if(b=="Cloudy"){
        i=1;
    }
    else{
        i=2;
    }
    cout<<a[++i%3];
    
}
 
 








 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b ,x ;
  cin >> a  >> b ;
  x = ( a * b ) % 2 ;
    if ( x == 1 ) {
      cout << "Odd" << endl ;
    }
  else {
    cout << "Even" << endl;
  }
  
}

Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
input_list = list(map(int, input().split()))

input_list = [-x for x in input_list]

heapq.heapify(input_list)
discount_element = heapq.heappop(input_list)


i = 0
while i < m:
    discount_element = -(-(discount_element) // 2)
    heapq.heappush(input_list, discount_element)
    discount_element = heapq.heappop(input_list)
    i += 1

heapq.heappush(input_list, discount_element)

print(-(sum(input_list)))



Measured memory_bytes: 14180
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int[] hills=new int[10];
		for(int i=0;i<10;i++){
			hills[i]=sc.nextInt();
		}
		for(int i=0;i<9;i++){
			for(int j=9;j>i;j--){
				if(hills[j]<hills[j-1]){
					int box=hills[j];
					hills[j]=hills[j-1];
					hills[j-1]=box;
				}
			}
		}
		for(int i=9;i>6;i--){
			System.out.println(hills[i]);
		}
	}
}

Measured memory_bytes: 17176
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
mod = 10 ** 9 + 7; INF = float("inf")

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

class SegmentTree(object):
	def __init__(self, N):
		self.N = N
		self.N0 = 2 ** (N - 1).bit_length()
		self.initVal = 0
		self.data = [self.initVal] * (2 * self.N0)

	# 区間クエリの種類
	def calc(self, a, b):
		return max(a, b)

	#k番目の値をxに更新
	def update(self, k, x):
		k += self.N0 - 1
		self.data[k] = x
		while k > 0:
			k = (k - 1) // 2
			self.data[k] = self.calc(self.data[2 * k + 1], self.data[2 * k + 2])

	#区間[l, r]の演算値
	def query(self, l, r):
		L = l + self.N0; R = r + self.N0 + 1
		m = self.initVal
		while L < R:
			if R & 1:
				R -= 1
				m = self.calc(m, self.data[R - 1])
			if L & 1:
				m = self.calc(m, self.data[L - 1])
				L += 1
			L >>= 1; R >>= 1

		return m

def main():
	N, K = getlist()
	n = 3 * (10 ** 5) + 2
	Seg = SegmentTree(n)
	for i in range(N):
		a = int(input())
		l = max(0, a - K)
		r = min(n - 1, a + K)
		res = Seg.query(l, r)
		Seg.update(a, res + 1)

	ans = Seg.query(0, n - 1)
	print(ans)




if __name__ == '__main__':
	main()

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  ll N;
  scanf("%lld", &N);

  // vll z_list;
  // vll w_list;

  ll z_max = -INF;
  ll w_max = -INF;

  ll z_min = INF;
  ll w_min = INF;

  for (ll i = 0; i < N; i++) {
    ll x, y;
    scanf("%lld %lld", &x, &y);

    ll z = x + y;
    ll w = x - y;

    z_max = max(z_max, z);
    z_min = min(z_min, z);

    w_max = max(w_max, w);
    w_min = min(w_min, w);
  }

  ll a1 = z_max - z_min;
  ll a2 = w_max - w_min;

  ll a = max(a1, a2);
  cout << (a) << endl;
}


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

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

using namespace std;

int main(){
	int n;
	string s; cin>>n>>s;
	cout<<(count(s.begin(),s.end(),'R')>count(s.begin(),s.end(),'B')?"Yes":"No")<<'\n';
	return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
int n,max=0;
int candi[3][101];
int book[3][101];
void Dfs(int x,int y,int num){
	//printf("开始*%d*\n",num);
	int map[2][2]={{0,1},{1,0}};
	int k,i,j;
	if(x==2&&y==n){
		if(num>max)max=num;
		return ;
	}
	for(k=0;k<2;k++){
		i=x+map[k][0];
	    j=y+map[k][1];
		if(i<=2&&j<=n&&book[i][j]==0){	
	     	     book[i][j]=1;
				 num+=candi[i][j];
				 //printf("%d %d 增加 %d\n",i,j,num);
				 Dfs(i,j,num);
				 book[i][j]=0;
				 num-=candi[i][j];
				 //printf("返回 %d\n",num);	
		}
	}
}
int main(){
	int i,j,num=0;
	scanf("%d",&n);
	for(i=1;i<=2;i++){
		for(j=1;j<=n;j++){
			scanf("%d",&candi[i][j]);
		}
	}
	num=candi[1][1];
	book[1][1]=1;
	Dfs(1,1,num);
	printf("%d",max);
	return 0;
}

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

#define int long long int
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define lb lower_bound
#define ub upper_bound
#define srt(a) sort(a.begin(),a.end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
#define mxe(a) *max_element(a.begin(),a.end())
#define mne(a) *min_element(a.begin(),a.end())
#define endl '\n'
#define mod 1000000007
#define INF64 1e18

const int maxn=10000,maxd=100;
int dp[maxn+5][2][maxd+5];
int n,d;
vi digit;
string s;

int solve(int pos,int flag,int remainder){
  if(pos==n)return remainder==0;
  if(dp[pos][flag][remainder]!=-1)return dp[pos][flag][remainder];

  int limit=flag?digit[pos]:9;
  int res=0;
  for(int i=0;i<=limit;i++){
    bool new_flag=flag&&(i==limit);
    res+=solve(pos+1,new_flag,(remainder+i)%d);
  }

  return dp[pos][flag][remainder]=res%mod;
}

int32_t main(){
  #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
  #endif
  
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  memset(dp,-1,sizeof(dp));
  cin>>s>>d;
  n=s.size();
  for(int i=0;i<n;i++)
    digit.pb(s[i]-'0');
  int ans=(mod+solve(0,1,0)-1)%mod;
  cout<<ans;
}

Measured memory_bytes: 20924
#include<bits/stdc++.h> 
using namespace std; 
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forp(i,a,b) for (int i = a; i <b; i++)
#define forn(i,a,b) for (int i = a; i >b; i--)
#define mod 1000000007
#define MAX 50
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;


long long int fact(long long int n)
{
  if(n==0 || n==1)
  return 1;
  else
  return (n*fact(n-1)%mod)%mod;
}

int prime(long long int n)
{
  for(int i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      return 0;
    }
  }
  return 1;
}

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

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

int check_palin(string s)
{
  string str=s;
  reverse(str.begin(),str.end());
  if(str==s)
  return 1;
  else 
  return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
            int k,n,z=0,ans=0,start=-1,end=-1,f=0,c=0;
            cin>>n>>k;
            cout<<max(2*n-1,max(2*k-1,k+n));
            
            
return 0;
}
            
            
            
            


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;


int main(){
  int n; 
  cin >> n;
  int cnt=0;
  for(int i=1,k; i<=n; i++){
    cin >> k;
    if(k==(cnt+1)){
      cnt++;
    }
  }
  if(cnt==0){ cout << -1 <<endl; return 0;}
  cout << n-cnt <<endl;
  return 0;
}


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


using namespace std;

int main(){
	//哈哈哈 暴力遍历解决
	
	string s,t;
	cin >> s >> t;
	
	int slen = s.length();
	int tlen = t.length();
	
	int ans = 1000;
	for(int i = 0;i + tlen <= slen;i++){
		int change = 0;
		for(int j = 0;j < tlen;j++){
			if(s[i+j] != t[j]){
				change++;
			}
		}
		ans = min(ans,change);
	}
	 
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
 int N, x, y;
cin >> N >> x >> y;
--x; --y;
    Graph G(N);
    G[0].push_back(1);
    G[N-1].push_back(N-2);
    for (int i = 1; i < N-1 ; ++i) {
        G[i].push_back(i+1);
        G[i].push_back(i-1);
    }
    G[x].push_back(y);
    G[y].push_back(x);
  
int ans[N] = {0};
for(int p = 0; p < N; p++){
     vector<int> dist(N, -1); 
    queue<int> que;
    dist[p] = 0;
    que.push(p); 

    while (!que.empty()) {
        int v = que.front(); 
        que.pop();

        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; 
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
     for(int u= 0; u<N;u++) ans[dist[u]]++;
}
for (int i = 1; i<=N-1; i++)cout << ans[i] / 2 << endl;
return 0;
}

Measured memory_bytes: 3724
n = int(input())
lst1 = list(map(int,input().split()))

def func(a,b):
    for i in range(21):
        if (a>>i)&(b>>i): #AND回路
            return False
    return True

def add_point(length):
    res = 0
    for i in range(1,length):
        res += i
    return res

a,b,count,ans = 0,1,0,0
host = lst1[0]
#尺取法
while True:
    if b >= n and a >= n:
        break
    while  b<n and func(host,lst1[b]):
        host = host^lst1[b]
        b += 1
    host = host^lst1[a] #使わなくなる部分を引く
    if b -a > 1:
        ans += b-a-1
    a += 1

ans += n
print(ans)

Measured memory_bytes: 77900
N = int(input())
hs =[10**6]+ list(map(int, input().split()))
dp = [0] * (N+1)
for i in range(2, N+1):
    dp[i] = min(dp[i-1]+abs(hs[i]-hs[i-1]), dp[i-2]+abs(hs[i]-hs[i-2]))
print(dp[N])

Measured memory_bytes: 13924
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long A, B, M;
	cin >> A >> B >> M;
	vector<long long> X(A), Y(B);
	for (int i = 0; i < A; i++) cin >> X[i];
	for (int i = 0; i < B; i++) cin >> Y[i];
	long long ANS = 1000000000000;
	for (int i = 0; i < M; i++) {
		long long P, Q, R;
		cin >> P >> Q >> R;
		P--, Q--;
		ANS = min(ANS, X[P] + Y[Q] - R);
	}
	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());
	ANS = min(ANS, X[0] + Y[0]);
	cout << ANS << endl;
}

Measured memory_bytes: 1792
using System;
namespace ABC145B
{
    public class EmptyClass
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            if (n%2==1)
            {
                Console.WriteLine("No");
            }
            else
            {
                string a = s.Substring(n / 2);
                string res = s == a + a ? "Yes" : "No";
                Console.WriteLine(res);
            }
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <math.h>

int main(){

    int i, j;
    int n, tmp, count = 0;

    scanf("%d", &n);

    for(i = 0; i < n; i++){
        scanf("%d", &tmp);

        for(j = 2; j <= sqrt(tmp); j++){
            if (tmp%j == 0) break;
        }
        if (j>sqrt(tmp) || sqrt(tmp)<2){
            count++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;
#define debug(x) cout<<"debugg:: "<<(x)<<'\n';


int main(){
	fast_io
	string s;
	cin>>s;
	int m=2019;
	
	vi suf(m,0);
	suf[0]=1;
	
	int pot=1,val=0;
	lli ans=0;
	for(int i=s.size()-1; i>=0; --i){
		val=(val+(s[i]-'0')*pot)%m;
		pot=(pot*10)%m;
		ans+=suf[val];
		suf[val]++;
	}
	cout<<ans<<'\n';
	return 0;
}

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

int main() {
    int n,alice = 0,bob = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    for(int i = 0; i < n; i++){
        if(i % 2 == 0){
            alice += a.at(i);
        }else{
            bob += a.at(i);
        }
    }
    cout << abs(alice - bob) << endl;
}


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

int main()
{
    string s; cin >> s;
    reverse(s.begin(), s.end());

    vector<string> t(4);
    t.at(0) = "dream"; 
    t.at(1) = "erase"; 
    t.at(2) = "eraser"; 
    t.at(3) = "dreamer"; 
    rep(i,4) {
        reverse(t.at(i).begin(), t.at(i).end());
    }

    bool can;

    for(int i = 0; i < s.size();) {
        can = false;
        for(int j = 0; j < 4; j++) {
            if(s.substr(i,t.at(j).size()) == t.at(j)) {
                can = true;
                i += t.at(j).size();
            }
        }
        if(!can) break;
    }

    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

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

const int N = 200005;
int p[N];

int find(int u) {
    return u == p[u] ? u : (p[u] = find(p[u]));
}

struct C {
    int c0, c1, i;

    bool operator<(const C &c) const {
        return (ll)c0 * c.c1 < (ll)c1 * c.c0;
    }
};

int pp[N];
priority_queue<C> q;
C g[N];
bool us[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(cout.fixed);
    cout.precision(20);
    int n;
    cin >> n;
    for (int i = 2; i <= n; i++) {
        cin >> pp[i];
    }
    for (int i = 1; i <= n; i++) {
        int v;
        cin >> v;
        p[i] = i;
        g[i] = {v == 0, v == 1, i};
        if (i != 1) {
            q.push(g[i]);
        }
    }
    ll res = 0;
    while (!q.empty()) {
        C c = q.top();
        q.pop();
        int i = c.i;
        if (us[i]) {
            continue;
        }
        us[i] = true;
        int j = find(pp[i]);
        res += (ll)g[j].c1 * g[i].c0;
        g[j].c0 += g[i].c0;
        g[j].c1 += g[i].c1;
        if (j != 1) {
            q.push(g[j]);
        }
        p[i] = j;
    }
    cout << res << "\n";
}


Measured memory_bytes: 8564
#define rep(i,n) REP(i,0,n)
#define REP(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

int main(void) {
   ll A,P;
   cin>>A>>P;
   cout<<(A*3+P)/2<<endl;

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
const int T = 1000000001;
int main() {
	int n, k;
	cin >> n >> k;
	int i;
	int ans = 0;
	for (i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a >= k) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>

using namespace std;

int main(){
    string S;
    cin >> S ;
    if((S[0] == 'A' && S[1]  == 'A'  && S[2]  == 'A') || (S[0] == 'B' && S[1]  == 'B'  && S[2]  == 'B') ) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=4e5+23;

vector<int> v[4][maxn<<2],l[maxn<<2],d[maxn<<2];

int n;
int x[maxn],y[maxn],type[maxn];
char op[4];
// U D 0 1
// L R 2 3

int main(){
	cin>>n;
	int ans=1e9;
	for(int i=1;i<=n;i++){
		scanf("%d%d%s",&x[i],&y[i],op);
		if(op[0]=='U') type[i]=0;
		if(op[0]=='D') type[i]=1;
		if(op[0]=='L') type[i]=2;
		if(op[0]=='R') type[i]=3;
	}
	int base=maxn;
	for(int i=1;i<=n;i++){
		if(type[i]==1){
			v[0][y[i]-x[i]+base].push_back(x[i]);
			v[1][y[i]+x[i]+base].push_back(x[i]);
			d[x[i]+base].push_back(y[i]);
		}
		else if(type[i]==0){
			v[2][y[i]+x[i]+base].push_back(x[i]);
			v[3][y[i]-x[i]+base].push_back(x[i]);
			
		}
		if(type[i]==2){
			l[y[i]+base].push_back(x[i]);
		}
	}
	for(int i=0;i<maxn<<2;i++){
		sort(l[i].begin(),l[i].end());
		sort(d[i].begin(),d[i].end());
	}
	for(int i=1;i<=n;i++){
		if(type[i]==0){
			int to=x[i]+base;
			auto it=lower_bound(d[to].begin(),d[to].end(),y[i]);
			if(it!=d[to].end()){
				ans=min(ans,(*it-y[i])*5);
			}
		}
		if(type[i]==3){
			int to=y[i]+base;
			auto it=lower_bound(l[to].begin(),l[to].end(),x[i]);
			if(it!=l[to].end()){
				ans=min(ans,(*it-x[i])*5);
			}
		}
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<maxn<<2;j++){
			sort(v[i][j].begin(),v[i][j].end());
		}
	}
	for(int i=1;i<=n;i++){
		if(type[i]==3){
			int to=y[i]-x[i]+base;
			auto it=lower_bound(v[0][to].begin(),v[0][to].end(),x[i]);
			if(it!=v[0][to].end())
				ans=min(ans,10*(*it-x[i]));
			to=y[i]+x[i]+base;
			it=lower_bound(v[2][to].begin(),v[2][to].end(),x[i]);
			if(it!=v[2][to].end())
				ans=min(ans,(*it-x[i])*10);
		}
		else if(type[i]==2){
			int to=y[i]+x[i]+base;
			auto it=upper_bound(v[1][to].begin(),v[1][to].end(),x[i]);
			if(it!=v[1][to].begin())
				ans=min(ans,-10*(*(--it)-x[i]));
			to=y[i]-x[i]+base;
			it=upper_bound(v[3][to].begin(),v[3][to].end(),x[i]);
			if(it!=v[3][to].begin())
				ans=min(ans,-10*(*(--it)-x[i]));
		}
	}
	if(ans>1e8) puts("SAFE");
	else printf("%d ",ans);
}

Measured memory_bytes: 249620
#include <stdio.h>
#include <stdlib.h>
#define MAX 200

void initialize(void);
int isEmpty(void);
int isFull(void);
void push(int,int*);
int pop(int*);

int top=0;

int main(){
  char s;
  int i,a,b,c,sum=0,n[MAX],count=0,keta=1,suuji[10],x=0;
  
  initialize();
  while(1){
    scanf("%c",&s);
    if(s == '\n') break;
    if(s == '+'){
      
      b = pop(n);
      a = pop(n);
      c = a + b;

      push(c,n);
      x = 1;
    }
    else if(s == '-'){
      b = pop(n);
      a = pop(n);
      c = a - b;

      push(c,n);
      x= 1;
    }
    else if(s == '*'){
      a = pop(n);
      b = pop(n);
      c = a * b;
      push(c,n);
      x = 1;
    }
    else{
      if(s == ' ' && x == 0){
	for(i = 0; i < count; i++){
	  keta = keta * 10;
	}
	for(i = 0; i < count; i++){
	  keta = keta / 10;
	  sum += suuji[i] * keta;
	}
	push(sum,n);
	count = 0;
	keta = 1;
	sum = 0;
      }
      else if(s == ' ' && x == 1){
	x = 0;
      }
      else{
	  
	suuji[count] = atoi(&s);
	count++;

      }
    }
  }
  printf("%d\n",n[top]);
  
  return 0;  
}

void initialize(){
  top = 0;
}

int isEmpty(){
  return top == 0;
}

int isFull(){
  return top >= MAX - 1;
}

void push(int x,int *n){
  if( isFull() ){
    printf("error (overflow)\n");
  }
  top++;
  n[top] = x;
}
      
int pop(int *n){
  if( isEmpty() ){
    printf("error(underflow)\n");
  }
  top--;
  return n[top+1];
}

Measured memory_bytes: 548
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

typedef long long ll;

const int N = 304;
const int MOD = 998244353;

int add(int a, int b) {
    ll res = (ll)a + b;
    return res % MOD;
}

int dp[N][2 * N][N];

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

	string s;
	int k;
	cin >> s >> k;
	int cnt_1 = 0;
	for (int i = (int)s.size() - 1; i >= 0; i--) {
		if (s[i] == '0') {
			break;
		} else {
			cnt_1++;
		}
	}
	s.push_back('0');
	int n = (int)s.size();
	k = min(k, n);
	for (int i = 0; i <= cnt_1; i++) {
		dp[n - 1][i][i] = 1;
	}
	//dp[i][cnt][fly]
	int last = -1;
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == '1') continue;
		int p = -1;
		for (int j = i - 1; j >= 0; j--) {
			if (s[j] == '0') {
				p = j;
				break;
			}
		}
		if (p == -1) {
			last = i;
			break;
		}
		int block = 0;
		for (int j = p - 1; j >= 0; j--) {
			if (s[j] == '0') {
				break;
			} else {
				block++;
			}
		}
		for (int cnt = 0; cnt <= 2 * n; cnt++) {
			for (int fly = 0; fly <= n; fly++) {
				if (!dp[i][cnt][fly]) continue;
				if (cnt == 0) assert(fly == 0); 
				for (int nblock = 0; nblock <= n; nblock++) {
					if (fly + block - nblock < 0) continue;
					dp[p][cnt + abs(block - nblock)][fly + (block - nblock)] = add(dp[p][cnt + abs(block - nblock)][fly + (block - nblock)], dp[i][cnt][fly]);

				}
			}
		}
	}
	int ans= 0;
	for (int mv = 0; mv <= 2 * k; mv++) {
		ans = add(ans, dp[last][mv][0]);
	}	
	cout << ans << endl;
}

Measured memory_bytes: 56268
H, W = gets.chomp.split.map(&:to_i)
N = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

c = Array.new(H).map{Array.new(W, 0)}



arr = []
N.times do |i|
  a[i].times do |j|
    arr << i + 1
  end
end

# p arr

cnt = 0
H.times do |i|
  if i.even?
    0.upto(W-1) do |j|
      c[i][j] = arr[cnt]
      cnt += 1
    end
  else
    (W-1).downto(0) do |j|
      c[i][j] = arr[cnt]
      cnt += 1
    end
  end
end

H.times do |i|
  puts c[i].join(' ')
end


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define sp fixed<<setprecision
#define sz sizeof
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod2=998244353;
ll fpow(ll x,ll y,ll p=MOD){x=x%p;ll sum=1;while(y){if(y&1)sum=sum*x;sum%=p;y=y>>1;x=x*x;x%=p;}return sum;}
ll inv(ll a,ll m=MOD){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
ll spf[10005];
void sieve()
{
  for(int i=1;i<10005;i++)
  spf[i]=i;
  for(int i=2;i*i<=10005;i++)
  if(spf[i]==i)
  for(int j=2*i;j<10005;j+=i)
  spf[j]=min(spf[j],(ll)(i));
}

int main(){
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   ll x;
   cin>>x;
   if(x>=30)
   cout<<"Yes\n";
   else
   cout<<"No\n";

}


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

int main(){
  int n, m=0, ans=0;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    m=max(m, a[i]);
  }
  
  for(int i=2;i<=m;i*=2){
    for(int j=0;j<n;j++){
      if(a[j]%i==0)ans++;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
k=int(input())
flag=0
ab=list(map(int, input().split()))
i=0
while ab[1]-ab[0]+1-i>0:
  if (ab[0]+i)%k==0:
    flag=1
    print("OK")
    break
  i=i+1
if flag==0:
  print("NG")

Measured memory_bytes: 9184
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		new Main().start();
	}
	boolean[][] done;
	int[][] memo;
	int[]vs,ws;
	int N;
	void start(){
		Scanner in = new Scanner(System.in);
		N = in.nextInt();
		final int W = in.nextInt();
		done = new boolean[N+1][W+1];
		memo = new int[N+1][W+1];
		vs = new int[N];
		ws = new int[N];
		for(int i = 0; i < N;i++){
			vs[i] = in.nextInt();
			ws[i] = in.nextInt();
		}
		System.out.println(getValue(0,W));
		in.close();
	}
	int getValue(int i, int u){
		if(done[i][u])return memo[i][u];
		int res = 0;
		if(i == N){

		}else if(u < ws[i]){
			res = getValue(i+1,u);
		}else{
			int res1 = getValue(i+1,u);
			int res2 = getValue(i+1,u-ws[i])+vs[i];
			res = max(res1,res2);
		}
		done[i][u] = true;
		memo[i][u] = res;
		return res;
	}
	int max(int a, int b){
		return a > b ? a : b;
	}


}

Measured memory_bytes: 33608
#include "bits/stdc++.h"
using namespace std;


int main()
{
	int n, m, c;
	cin >> n >> m >> c;
	vector<int> b(m);
	for (int i = 0; i < m; i++) {
		cin >> b.at(i);
	}
	vector<vector<int>> a(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int a_in;
			cin >> a_in;
			a.at(i).push_back(a_in);
		}
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		int sum = c;
		for (int j = 0; j < m; j++) {
			sum += a.at(i).at(j) * b.at(j);
		}
		if (sum > 0) {
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    int a,b;cin>>a>>b;
    if(a%b==0) cout<<a/b<<endl;
    else cout<<a/b+1<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Numerics;

public class Program
{

    static void Main()
    {
        var inputs = Console.ReadLine()
                            .Split(" ")
                            .Select(t => decimal.Parse(t))
                            .ToArray();

        var product = Math.Floor(inputs[0] * inputs[1]);
        Console.WriteLine(product); 
    }
}


Measured memory_bytes: 28296
N,Y = map(int, input().split())
for i in range(N + 1):
    for l in range(N - i + 1):
            if 10000*i + 5000*l + 1000*(N - i - l) == Y:
                print(i ,l ,(N - i - l))
                exit()

print(-1 ,-1 ,-1)


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

using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
//using u64 = long long;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;


int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    u64 N = 0;
    char c;
    while (cin >> c) {
        u64 bit = c - '0';
        N += bit;
        N %= 9;
    }
    if (!N) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
    
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


void solve(){
  ll Q,H,S,D; cin >>Q >>H >>S >>D;
  ll N; cin >>N; N *= 4;
  /* 1L: Q yen, 2L: H yen, 4L: S yen, 8L: D yen
     Buy icetea N L.
  */
  // aaa
  ll res = 0;
  // 8L で帰る分
  res += min( D*(N/8), min( S*(N/8*2), min( H*(N/8*4), Q*(N/8*8) ) ) );
  N %= 8;
  // 4L で帰る分
  res += min( S*(N/4), min( H*(N/4*2), Q*(N/4*4) ) );
  N %= 4;
  // 2L
  res += min( H*(N/2), Q*(N/2*2) );
  N %= 2;
  res += Q*N;
  cout <<res <<endl;
}

int main() {
  solve();
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const string D_blue    = "\x1b[36m";
const string D_green   = "\x1b[32m";
const string D_red     = "\x1b[31m";
const string D_yellow  = "\x1b[33m";
const string Db_red    = "\x1b[41m";
const string Db_yellow = "\x1b[43m";
const string D_end     = "\x1b[39m";
const string Db_end    = "\x1b[49m";

int main (){
  string s;
  int K;
  while (cin >> s >> K){
    vector<string> sub;
    REP(i,s.size()){
      for(int j = 1; j <= s.size()-i && j <= K;j++){
	string st = s.substr(i,j);
	sub.push_back(st);
      }
    }
    sort(ALL(sub));
 
    unique(ALL(sub));
    
    cout << sub[K - 1] << endl;
 
    sub.clear();
  }
  return 0;
}


Measured memory_bytes: 1660