akhauriyash/Code-Regression huggingface dataset:
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
ABC=n3(n)
ABC

dp=[[0,0,0] for _ in range(n)]
dp[0]=ABC[0]
for i in range(1,n):
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+ABC[i][0]
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+ABC[i][1]
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+ABC[i][2]

print(max(dp[-1]))

Measured memory_bytes: 44132
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,a;
	while(cin>>n>>m>>a,n){
		vector<pair<int,int> > data[1000];
		for(int i=0;i<m;i++){
			int h,p,q;
			cin>>h>>p>>q;h--;
			data[h].push_back(make_pair(p,q));
			data[h].push_back(make_pair(q,p));
		}
		for(int i=999;i>=0;i--){
			if(data[i].empty())continue;
			else{
				for(int j=0;j<data[i].size();j++){
					if(a==data[i][j].first){
						a=data[i][j].second;
						break;
					}
				}
			}
		}
		cout<<a<<endl;
	}
}

Measured memory_bytes: 1248
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, (int)vec.size() - 1)std::cout << vec[i] << " ";
	if(!vec.empty())std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int main(){
	std::string s;
	lint k;
	std::cin>>s>>k;
	int i=0;
	for(;i<s.size()&&s[i]=='1';i++);
	if(k<=i)puts("1");
	else std::cout<<s[i]<<std::endl;
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int h[100005];
	for(int i=0;i<n;i++)
		cin>>h[i];
	int dp[100005];
	dp[n-1] = 0;
	dp[n-2] = abs(h[n-1] - h[n-2]);
	for(int i=n-3;i>=0;i--)
	{
		dp[i] = min(dp[i+1]+abs(h[i+1]-h[i]),dp[i+2]+abs(h[i+2]-h[i]));
		
	}
	cout<<dp[0];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(1e5)+10;
const int INF=(1e9);
int n,tot,nxt[maxn*2],to[maxn*2],head[maxn],ans;
char s[maxn];
void add(int x,int y) {
	tot++; nxt[tot]=head[x];
	head[x]=tot; to[tot]=y;
}
int f[maxn],g[maxn],h[maxn],sz[maxn],son[maxn],op[maxn];
void dfs1(int u,int p) {
	sz[u]=(s[u]=='W');
	for (int i=head[u],v;i;i=nxt[i]) {
		v=to[i];
		if (v==p) continue;
		dfs1(v,u);
		sz[u]+=sz[v];
	}
}
void dfs(int u,int p) {
	int sum=0,mx=0,mx2=0,tmp,t2;
	for (int i=head[u],v;i;i=nxt[i]) {
		v=to[i];
		if (v==p||!sz[v]) continue;
		dfs(v,u);
		f[u]+=f[v]; son[u]++;
		sum+=f[v];
	}
	if (!son[u]&&s[u]=='W') {
		f[u]=g[u]=1; return;
	}
	f[u]+=son[u]+1;
	if (s[u]=='W') f[u]+=(son[u]&1);
	else f[u]+=(son[u]&1)^1;
	
	for (int i=head[u],v;i;i=nxt[i]) {
		v=to[i];
		if (v==p||!sz[v]) continue;
		mx=max(mx,f[v]-g[v]);
	}
	g[u]=sum-mx+son[u];
	if (s[u]=='W') g[u]+=(son[u]^1)&1;
	else g[u]+=son[u]&1;
	g[u]=min(g[u],f[u]);
	
	h[u]=INF;
	if (son[u]!=1) {
		mx=0,mx2=0;
		for (int i=head[u],v;i;i=nxt[i]) {
			v=to[i];
			if (v==p||!sz[v]) continue;
			if (f[v]-g[v]>mx) mx2=mx,mx=f[v]-g[v];
			else mx2=max(mx2,f[v]-g[v]);
		}
		if (s[u]=='W') t2=(son[u]&1);
		else t2=(son[u]&1)^1;
		h[u]=sum-mx-mx2+t2+son[u]-1;
		op[u]=t2;
	}
	for (int i=head[u],v;i;i=nxt[i]) {
		v=to[i];
		if (v==p||!sz[v]) continue;
		tmp=sum-f[v]+h[v]+2*(op[v]^1)+son[u];
		if (s[u]=='W') t2=(son[u]&1)^1;
		else t2=son[u]&1;
		if (tmp+t2<h[u]) h[u]=tmp+t2,op[u]=t2;
	}
	//printf("%d %d %d %d %d\n",u,f[u],g[u],h[u],op[u]);
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	int x,y;
	for (int i=1;i<n;i++) {
		read(x),read(y);
		add(x,y),add(y,x);
	}
	scanf("%s",s+1);
	dfs1(1,0);
	dfs(1,0);
	if (sz[1]==0) printf("0\n");
	else if (sz[1]==1) printf("1\n");
	else {
		ans=INF;
		for (int i=1;i<=n;i++)
			if (sz[i]==sz[1]) {
				ans=min(ans,f[i]);
				ans=min(ans,g[i]);
				ans=min(ans,h[i]);
			}
		printf("%d\n",ans);
	}
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

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

const int N=200;

int n,m,q,arr[N],a[N],b[N],c[N],d[N],ans;

void f(int i,int pv)
{
	if(i==n+1)
	{
		int cost=0;
		for(int i=0;i<q;i++)
		{
			if(arr[b[i]]-arr[a[i]]==c[i]) cost+=d[i];
		}
		ans=max(ans,cost);
		return;
	}
	for(int j=pv;j<=m;j++)
	{
		arr[i]=j;
		f(i+1,j);
	}
}

int main()
{
	cin>>n>>m>>q;
	for(int i=0;i<q;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
	f(1,1);
	cout<<ans;
}


Measured memory_bytes: 3628
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class BBalance {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n;in>>n;
	    vector<int> w(n);
	    rep(i,n) in>>w[i];
	    int res = 100000000;
	    auto right = w.begin()+1;
	    for(; right < w.end(); ++right){
	        res=min(res,abs(accumulate(w.begin(),right,0)-accumulate(right,w.end(),0)));
//	        out<<*right<<' '<<accumulate(w.begin(),right,0)<<' '<<accumulate(right,w.end(),0)<<endl;
	    }
	    out<<res<<endl;
	}
};


int main() {
	BBalance solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

//typedefs
typedef unsigned long long LL;


int main()
{
    LL n,a,b,ans,cnt;

    cin>>n>>a>>b;
    //  if(a==b)return cout<<0<<endl,0;

    if((b-a)%2==0)
    {
        cout<<(b-a)/2<<endl;
    }
    else
    {
        if((a-1)<(n-b))
        {
            ans = a-1;
            a = 1 ;
            b -= ans;
            cnt=0;
            while(1)
            {
                if((b-a)%2==0)
                    break;
                b--;
                cnt++;
            }
           // cout<<a<<" "<<b<<" "<<cnt<<endl;
            ans += cnt+(b-a)/2;
            cout<<ans<<endl;
        }
        else
        {
            ans = n-b;
            b = n;
            a += ans;
            cnt = 0;
            while(1)
            {
                if((b-a)%2==0)
                    break;
                a++;
                cnt++;
            }

            ans += cnt + (b-a)/2;
            cout<<ans<<endl;

        }
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

ll powll(ll base,ll exp) { ll res = 1; while(exp>0){ if(exp & 1)res = res * base; base = base * base; exp >>= 1; } return res;}
ll mod_pow(ll base,ll exp) { ll res = 1; while(exp>0){ if(exp & 1)res = res * base % mod; base = base * base % mod; exp >>= 1; } return res % mod;}

ll modinv(ll a) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}


class Mcomb {
public:
    vector<ll> fac;
    vector<ll> inv;
    vector<ll> finv;
    //nCnまで対応できる
    Mcomb(int n) {
        fac.resize(n + 1), inv.resize(n + 1), finv.resize(n + 1);
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for(int i = 2; i <= n; i++){
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod%i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
 
    ll ncr(int n, int r){
        if (n < r) return 0;
        if (n < 0 || r < 0) return 0;
        return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
    }
 
    ll npr(int n, int r){
        if(n < r)return 0;
        if(n < 0 || r < 0)return 0;
        return (fac[n] * inv[n - r]) % mod;
    }
 
};
Mcomb comb(2000000);

 
ll ncr(int n, int r) {
   ll res = 1;
   for (int i = n - r + 1; i <= n; i++) res = res * i % mod;
   for (int i = 1; i <= r; i++) res = res * modinv(i) % mod;
   return res;
}

int main()
{
    int x, y; cin >> x >> y;
    if((x + y) % 3) {
        cout << 0 << endl;
        return 0;
    }
    int n = (x + y) / 3;
    x -= n, y -= n;
    if(x < 0 || y < 0) {
        cout << 0 << endl;
        return 0;
    }

    cout << comb.ncr(n, x) << endl;

}

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

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    if(abs(a-b)>=2){
        int t=max(a,b);
        cout<<2*t-1<<endl;
    }
    else
    {
        int t=max(a,b);
        cout<<t+min(a,b)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*
[abc103] D - Islands War
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_M = 100000;

int N, M;
pii ba[MAX_M];

ll solve() {
    sort(ba, ba + M);

    int ans = 0;
    int last = 0;
    for (pii p : ba) {
        int a = p.second;
        int b = p.first;
        if (a >= last) {
            last = b;
            ans++;
        }
    }

    return ans;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> ba[i].second >> ba[i].first;
        ba[i].second--;
        ba[i].first--;
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;

typedef long long ll;

ll N;

ll tosa(ll n) {
	return n * (n + 1) / 2;
}

int main() {
	
	cin >> N;

	ll ans = 0;
	for (ll i = 1; i <= N; i++) {
		ans += i * tosa((N / i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    let n: i32 = 3;
    input!{
        v: [i32;n],
    }

    println!("{} {} {}", v[2],v[0],v[1]);
}

Measured memory_bytes: 4352
using System;

namespace atcoder_ABC055B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
			long N = int.Parse(Console.ReadLine());
			long power = 1;
			for (long i = 1; i <= N; i++)
			{
				power *= i;

				power %= 1000000007;
			}

			Console.WriteLine(power % 1000000007);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <stack>

using namespace std;

bool ok (string s)
{
    stack<char> stk;
    for (int i=0; i<s.size(); i++)
    {
        if (s[i]=='(') stk.push('(');
        if (s[i]=='[') stk.push('[');
        if (s[i]==')')
        {
            if (stk.empty()) return false;
            else if (stk.top()!='(') return false;
            else stk.pop();
        }
        if (s[i]==']')
        {
            if (stk.empty()) return false;
            else if (stk.top()!='[') return false;
            else stk.pop();
        }
    }
    if (stk.empty()) return true;
    else return false;
}

int main()
{
    vector<bool> f;
    string t;
    while (1)
    {
        getline(cin, t);
        if (t==".") break;
        f.push_back(ok(t));
    }
    for (int i=0; i<f.size(); i++) cout<<(f[i]? "yes\n" : "no\n");
    return 0;
}


Measured memory_bytes: 3152
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

N = I()
A = LI()
ans = 1
if 0 in A:
    print(0)
else:
    for i in A:
        ans *= i
        if ans>10**18:
            print(-1)
            break
    else:
        print(ans)


Measured memory_bytes: 23028
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+1;
int n,cnt,a[N+1],b[N];
long long sum;
int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
signed main(){
	n=read();
	for(int i=1;i<=n+1;i++) a[i]=read(),sum+=a[i];
	for(int i=1;i<=n;i++) b[i]=read();
	for(int i=1;i<=n;i++){
		if(b[i]>=a[i]){
			b[i]-=a[i];	a[i]=0;
			a[i+1]=max(a[i+1]-b[i],0);
		}else a[i]-=b[i];
	}
	for(int i=1;i<=n+1;i++) sum-=a[i];
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);

	public static void main(String args[]) {

		//初期化
		int n = scan.nextInt();
		boolean[] flag = new boolean[64];
		ArrayList<ArrayList<Integer>> bitmask = new ArrayList<>();

		for(int i=0; i<n; i++) {
			int cm = scan.nextInt();
			ArrayList<Integer> list = new ArrayList<>();

			for(int j=0; j<cm; j++) {
				list.add(scan.nextInt());
			}
			bitmask.add(list);	//WARNING
		}
		
		
		//処理
		//flagの操作をlistの範囲で切り替える
		int m = scan.nextInt();							
		
		for(int i=0; i<m; i++) {

			int query = scan.nextInt();

			switch(query) {

			case 0:	//test
				int cmd0 = scan.nextInt();
				System.out.println(flag[cmd0] ? 1 : 0);
				break;

			case 1: //set
				int cmd1 = scan.nextInt();
				for(int j=0; j<bitmask.get(cmd1).size(); j++) flag[bitmask.get(cmd1).get(j)] = true;
				break;

			case 2: //clear
				int cmd2 = scan.nextInt();
				for(int j=0; j<bitmask.get(cmd2).size(); j++) flag[bitmask.get(cmd2).get(j)] = false;
				break;
				
			case 3: //flip
				int cmd3 = scan.nextInt();
				for(int j=0; j<bitmask.get(cmd3).size(); j++) {
					if(flag[bitmask.get(cmd3).get(j)]) {flag[bitmask.get(cmd3).get(j)] = false;	//WARNING
					}else {
						flag[bitmask.get(cmd3).get(j)] = true;
					}
				}
				break;

			case 4: //all
				int cmd4 = scan.nextInt();
				int count = 0;
				for(int j=0; j<bitmask.get(cmd4).size(); j++) {
					if(flag[bitmask.get(cmd4).get(j)]) count++;
				}
				if(count == bitmask.get(cmd4).size()) System.out.println(1);
				else System.out.println(0);
				break;

			case 5: //any
				int cmd5 = scan.nextInt();
				int count2 = 0;
				for(int j=0; j<bitmask.get(cmd5).size(); j++) {
					if(flag[bitmask.get(cmd5).get(j)]) count2++;
				}
				if(count2 > 0)System.out.println(1);
				else System.out.println(0);
				break;

			case 6:	//none
				int cmd6 = scan.nextInt();
				int count3 = 0;
				for(int j=0; j<bitmask.get(cmd6).size(); j++) {
					if(flag[bitmask.get(cmd6).get(j)]) count3++;
				}
				if(count3 == 0)System.out.println(1);
				else System.out.println(0);
				break;

			case 7:	//count
				int cmd7 = scan.nextInt();
				int sum = 0;
				for(int j=0; j<bitmask.get(cmd7).size(); j++) {
					if(flag[bitmask.get(cmd7).get(j)]) sum++;
				}
				System.out.println(sum);
				break;

			case 8:	//var
				int cmd8 = scan.nextInt();
				long sum2 = 0;
				for(int j=0; j<bitmask.get(cmd8).size(); j++) {
					long pow = 1;

					if(flag[bitmask.get(cmd8).get(j)]) {
						for(int k=0; k<bitmask.get(cmd8).get(j); k++) pow *= 2;
						sum2 += pow;
					}
				}
				System.out.println(Long.toUnsignedString(sum2));
				break;
			}
		}
	}
}


Measured memory_bytes: 104932
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<List<Integer[]>> p = new ArrayList<>();
		int max = 0;
		for (int i = 0; i < N; i++) {
			int Ai = sc.nextInt();
			List<Integer[]> ops = new ArrayList<>();
			for (int j = 0; j < Ai; j++) {
				Integer[] op = new Integer[2];
				op[0] = sc.nextInt();
				op[1] = sc.nextInt();
				ops.add(op);
			}
			p.add(ops);
		}
		for (int i = (1 << N) - 1; 0 < i; i--) {
			boolean[] ans = new boolean[N];
			for (int j = 0; j < N; j++) {
				if (((i>>j)&1) == 1) {
					ans[j] = true;
				}
			}
			boolean flg = true;
			for (int k = 0; k < N; k++) {
				if (ans[k]) {
					for (Integer[] opi : p.get(k)) {
						if ((ans[opi[0]-1] && opi[1] == 1)
								|| (!ans[opi[0]-1] && opi[1] == 0)) {
							continue;
						} else {
							flg = false;
							break;
						}
					}
				}
			}
			if (flg) {
				int count = 0;
				for (boolean b : ans) {
					if (b) {
						count++;
					}
				}
				if (max < count) {
					max = count;
				}
			}
		}
		System.out.println(max);
	}
}

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

using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;

  vector<int> w, r;
  rep(i, n) {
    if (s[i] == 'R') r.push_back(i);
    if (s[i] == 'W') w.push_back(i);
  }

  sort(w.begin(), w.end());
  sort(r.rbegin(), r.rend());

  if (w.size() == 0 || r.size() == 0) {
    cout << 0 << endl;
    return 0;
  }

  r.push_back(0);
  w.push_back(1001001001);

  int ans = 0;
  int wc = 0, rc = 0;
  int wMin = w[wc];
  int rMax = r[rc];
  while (wMin <= rMax) {
    ++wc, ++rc, ++ans;
    wMin = w[wc];
    rMax = r[rc];
  }

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


Measured memory_bytes: 4764
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   string s;
   cin >> s;

   rep(i,s.size()) {
      if(s[i]==',') s[i] = ' ';
   }
   cout << s << endl;


   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define true 0
#define false 1

int solve(int, int);
int n;
int A[20];

int main(){
  int i;
  int q;
  int m[200];
  int sol;

  scanf("%d", &n);
  if(20 < n)
    exit(0);
  
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
    if(A[i] < 1 || 2000 < A[i])
      exit(1);
  }

  scanf("%d", &q);
  if(200 < q)
    exit(2);
  
  for(i = 0; i < q; i++){
    scanf("%d", &m[i]);
    if(m[i] < 1 || 2000 < m[i])
      exit(3);
  }

  for(i = 0; i < q; i++){
    sol = solve(0, m[i]);
    if(sol == true)
      printf("yes\n");
    else if(sol == false)
      printf("no\n");
  }

  return 0;
}

int solve(int i, int m){
  int res;

  if(m == 0)
    return true;
  if(n <= i)
    return false;

  res = solve(i+1, m);
  if(res == true)
    return res;
  res = solve(i+1, m-A[i]);
  if(res == true)
    return res;
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

int kakutei[100000];
vector<pair<int, int>> node[100000]; //iに対してnode[i].secondを足すとnode[i].firstに行ける

void dfs(int p, int s, vector<int>& vec){
    vec.push_back(s);
    rep(i, node[s].size()){
        int to = node[s][i].first;
        int dist = node[s][i].second;
        if(to != p && kakutei[to] == mod){
            kakutei[to] = kakutei[s]+dist;
            dfs(s, to, vec);
        }
    }
}

int main(void){
    rep(i, 100000) kakutei[i] = mod;
    int N, M; cin >> N >> M;
    rep(i, M){
        int a, b, d; cin >> a >> b >> d;
        node[a-1].push_back(make_pair(b-1, d));
        node[b-1].push_back(make_pair(a-1, -d));
    }
    for(int i = 0; i < N; i++){
        vector<int> res;
        if(kakutei[i] == mod){
            kakutei[i] = 0;
            dfs(-1, i, res);

            //この時点でiを始点とするグラフ内のノードの値は確定している
            int minval = kakutei[i], maxval = kakutei[i];
            rep(j, res.size()){
                if(kakutei[res[j]] < minval) minval = kakutei[res[j]];
                if(kakutei[res[j]] > maxval) maxval = kakutei[res[j]];
            }
            if(minval < 0){
                rep(j, res.size()){
                    kakutei[res[j]] -= minval;
                }
            }
            if(maxval > 1000000000){
                int sabun = maxval-1000000000;
                rep(j, res.size()){
                    kakutei[res[j]] -= sabun;
                }
            }
        }
    }

    rep(i, N){
        if(kakutei[i] < 0 || kakutei[i] > 1000000000){
            cout <<  "No" << endl;
            return 0;
        }
    }

    rep(i, N){
        rep(j, node[i].size()){
            if(kakutei[i] + node[i][j].second != kakutei[node[i][j].first]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  vector<vector<int>> a(n, vector<int>(3));
  for(int i=0; i<n; i++){
    cin >> a.at(i).at(0) >> a.at(i).at(1) >> a.at(i).at(2);
  }

  vector<vector<int>> h(n,vector<int>(3));
  
  //初日
  for(int k=0; k<3; k++){
    h[0][k]=a[0][k];
  }
  
  //2日目以降
  for(int i=1; i<n; i++){
    h[i][0] = max(h[i-1][1]+a[i][0], h[i-1][2]+a[i][0]);
    h[i][1] = max(h[i-1][0]+a[i][1], h[i-1][2]+a[i][1]);
    h[i][2] = max(h[i-1][0]+a[i][2], h[i-1][1]+a[i][2]);
  }
  
  
  cout << max(max(h[n-1][0], h[n-1][1]), h[n-1][2]) << endl;
  
  return 0;
}


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

void maxHeapify(vector<int>& A, int i)
{
	int H = A.size() - 1;
	int l = 2 * i;
	int r = 2 * i + 1;
	//????????????????????????????????§???????????§????????????????????¶
	int largest;
	if(l <= H && A[l] > A[i]){
		largest = l;
	}else{
		largest = i;
	}
	if(r <= H && A[r] > A[largest]){
		largest = r;
	}
	//i???????????????????????§????????´???
	if(largest != i){
		swap(A[i], A[largest]);
		//?????°??????????????????
		maxHeapify(A, largest);
	}
}

void buildMaxHeap(vector<int>& A)
{
	int H = A.size() - 1;
	for(int i = H / 2; i >= 1; i--){
		maxHeapify(A, i);
	}
}

void Output(const vector<int>& A)
{
	int H = A.size() - 1;
	for(int i = 0; i < H; i++){
		cout << " " << A[i+1];
	}
	cout << endl;
}

int main()
{
	int H;
	cin >> H;
	vector<int> Heap(H+1);
	for(int i = 0; i < H; i++){
		cin >> Heap[i+1];
	}
	buildMaxHeap(Heap);
	Output(Heap);
	return 0;
}

Measured memory_bytes: 4644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
 	  
   long int h1,m1,h2,m2,k;
   cin>>h1>>m1>>h2>>m2>>k;

   long int minutes1 = h1 * 60 + m1;
   long int minutes2 = h2 * 60 + m2;

   long int diff = minutes2 - minutes1;
   diff -= (k);

   cout<<diff;
   return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }




int main() {
	int n;
	cin >> n;
	vector<int> b(n - 1);
	rep(i, n-1) {
		cin >> b[i];
	}
	ll ans = 0;
	rep(i, n) {
		if (i == 0) {
			ans += b[0];
		}
		else if (i == n - 1) {
			ans += b[n - 2];
		}
		else {
			ans += min(b[i - 1], b[i]);
		}
	}

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


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

using namespace std;

int main(void)
{
    int r, degree;
    int sum_degree = 0;
    double wx = 0, wy = 0;
    char comma;

    while (true) {
        cin >> r >> comma >> degree;
        if (!r && !degree)
            break;

        wx += r * sin(M_PI / 180.0 * sum_degree);
        wy += r * cos(M_PI / 180.0 * sum_degree);

        sum_degree = (sum_degree + degree) % 360;
    }
    cout << (int)wx << "\n" << (int)wy << endl;

    return 0;
}

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

int main(){
    int h, w, n, x=0;
    cin >> h >> w >> n;
    vector<int> A(n);
    vector<int> C(h*w);
    for(int i=0 ; i<n ; i++){
        cin >> A[i];
    }
    for(int j=0 ; j<n ; j++){
        for(int k=x ; k<x+A[j]; k++){
            C[k]=j+1;
        }
        x+=A[j];
    }
    for(int l=0 ; l<h ; l++){
        if(l%2==1){
            reverse(C.begin()+l*w, C.begin()+(l+1)*w);
        }
    }
    for(int m=0 ; m<h*w ; m++){
        cout << C[m];
        if((m+1)%w==0){
            cout << endl;
        }else{
            cout << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
  int n,x,m[1100],sum=0,cnt=0;
  cin>>n>>x;
  int min=x;
  for(int i=0;i<n;i++){
    cin>>m[i];
    if(min>m[i]) min=m[i];
    sum+=m[i];
  }
  if(sum==x){
     cout<<n;
     return 0;
  }
  else{
    while(x-sum>=min){
      sum+=min;
      cnt++;
    }
  }
  cout<<n+cnt;
  return 0;
}


Measured memory_bytes: 256
#code
n=int(input())
a=input()
b=input()
c=input()
a=a.split()
b=b.split()
c=c.split()
a=list(map(int,a))
b=list(map(int,b))
c=list(map(int,c))
points=0
for i in range(len(a)):
    points+=b[a[i]-1]
    if( (i!=0 and a[i-1]!=n )and a[i]==a[i-1]+1):
        points+=c[a[i-1]-1]
    
print(points)
    


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

int main(){
  int N, H;
  cin >> N >> H;
  int a[N], b[N];
  rep(i, N)
    cin >> a[i] >> b[i];
  //入力終わり

  //ソートしても一般性を失わない
  sort(b, b+N, greater<>() );
  
  //a[ ]の最大を求める
  int a_max = 0;
  rep(i, N)
    if(a_max < a[i])
      a_max = a[i];

  int count = 0;

  //相手の体力が残っている間
  //ATKの大きい剣から投げていく
  while(count<N && H>0){
    //投げるより振った方がいいならwhile抜ける
    if(b[count] < a_max)
      break;
    H -= b[count++];
  }

  int tmp = 0;
  //投げるだけで倒せないとき
  if(H>0){
    //残り体力がa_maxで割り切れれば，普通に割ればよい
    if(H%a_max == 0)
      tmp = H/a_max;
    //割り切れなければ，商の切り上げ
    else
      tmp = (H+a_max)/a_max;
  }
  count += tmp;
  
  //解答
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 4396
#include <bits/stdc++.h>
#define int long long
using namespace std;
string S;
int K,counter=0;
signed main(){
  cin >> S >> K;
  for(int i=0;i<S.size();i++){
    if(S[i]=='1') counter++;
    else break;
  }
  if(counter>=K) cout << "1" << endl;
  else cout << S[counter] << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

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

            if (a < b && b < c)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}



Measured memory_bytes: 15964
#include <stdio.h>
#include <math.h>
int main(void){
int n,i;
int a[1000] = {};
double j = 0,k = 0;
scanf ("%d",&n);
for (i = 0;i < n;i++)
{
    scanf("%d",&a[i]);
}
for (i = 0;i < n;i++)
{
  j = a[i];
  j = pow(j,-1);
  k += j;
}
k = 1/k;
printf ("%2f",k);
return 0;
}

Measured memory_bytes: 128
program main;
var a,b,c : integer;
    p : boolean;
begin
  readln(a,b,c);
  if ((a=b) and (a<>c)) or ((a=c) and (a<>b)) or ((b=c) and (a<>b)) then p := true
    else p := false;
  if p then writeln('Yes')
    else writeln('No');
end.

Measured memory_bytes: 1348
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int ans = 0;
    if(B==1){ System.out.println(0); return; }
    for (int i=1;i<=B;i++){
      int T = (A*i) - (i-1);
      if (T>=B){
        System.out.println(i); break;
      }
    }
  }
}

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

void solve(int TestCase) {
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2])
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t = 1;
    //cin >> t;
    for(auto i = 1; i <= t; ++i) {
    //    cout << "Case #"<< i << ": ";
        solve(i);
    }
}

Measured memory_bytes: 256
#include <iostream>
#define MAX 50
#define WHITE 1
#define BLACK 2
using namespace std;

typedef pair<int, int> P;

char a[MAX][MAX];
int judge[MAX][MAX];
bool visitedw[MAX][MAX];
bool visitedb[MAX][MAX];
bool searchedw[MAX][MAX];
bool searchedb[MAX][MAX];
P white[MAX * MAX];
P black[MAX * MAX];
int countw;
int countb;

int p[4] = {1, 0, -1, 0}, q[4] = {0, 1, 0, -1};

void print_number(int w, int h) {
  int sumb = 0, sumw = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (judge[i][j] == BLACK) sumb++;
      else if (judge[i][j] == WHITE) sumw++;
    }
  }

  cout << sumb << ' ' << sumw << endl;
}

void dfs_b(int w, int h, int x, int y) {
  for (int i = 0; i < 4; i++) {
    int s = x + p[i], t = y + q[i];
    if (0 <= s && s <= w && 0 <= t && t <= h && a[t][s] == '.'
	&& !searchedb[t][s]) {
      judge[t][s] += BLACK;
      searchedb[t][s] = true;
      dfs_b(w, h, s, t);
    }
  }
}

void dfs_w(int w, int h, int x, int y) {
  for (int i = 0; i < 4; i++) {
    int s = x + p[i], t = y + q[i];
    if (0 <= s && s <= w && 0 <= t && t <= h && a[t][s] == '.'
	&& !searchedw[t][s]) {
      judge[t][s] += WHITE;
      searchedw[t][s] = true;
      dfs_w(w, h, s, t);
    }
  }
}

void count_black(int w, int h) {
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == 'B') {
	black[countb].first = j;
	black[countb].second = i;
	countb++;
      }
    }
  }
}

void count_white(int w, int h) {
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == 'W') {
	white[countw].first = j;
	white[countw].second = i;
	countw++;
      }
    }
  }
}

void clear_array() {
  for (int i = 0; i < MAX; i++) {
    for (int j = 0; j < MAX; j++) {
      a[i][j] = 0;
      judge[i][j] = 0;
      visitedw[i][j] = visitedb[i][j]  = false;
      searchedw[i][j] = searchedb[i][j] = false;
    }
  }
  for (int i = 0; i < MAX * MAX; i++) {
    white[i].first = white[i].second = black[i].first = black[i].second = 0;
  }
}

int main() {
  while (true) {
    int w, h;
    cin >> w >> h;
    if (w == 0 && h == 0) return 0;

    clear_array();
    
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++)
	cin >> a[i][j];

    countw = countb = 0;
    count_white(w, h);
    count_black(w, h);

    for (int i = 0; i < countw; i++) {
      dfs_w(w, h, white[i].first, white[i].second);
    }
    for (int i = 0; i < countb; i++) {
      dfs_b(w, h, black[i].first, black[i].second);
    }

    print_number(w, h);
  }
}

Measured memory_bytes: 3088
#include<cstdio>
#include<complex>
#define EPS 1e-10
using namespace std;

typedef complex<double> P;

double dot(P a,P b){return a.real()*b.real() + a.imag()*b.imag();}

int main(){
  int n;
  P p[400];
  bool use[400];

  for(;;){
    scanf("%d",&n);
    if(!n)break;

    for(int i=0;i<n;i++){
      scanf("%lf %lf",&p[i].real(),&p[i].imag());
      use[i] = false;
    }

    int cnt = n;
    double ans = 0.0;
    P prv1,prv2;
    prv1.real() = prv1.imag() = prv2.real() = 0.0;
    prv2.imag() = 1000.0;

    int num = -1;
    double val = -2.0;
    for(int i=0;i<n;i++){
      double tmp = dot(prv2-prv1,p[i]-prv1)/(abs(prv2-prv1)*abs(p[i]-prv1));
      if(val + EPS < tmp){
	val = tmp;
	num = i;
      }else if(abs(val-tmp)<EPS && abs(p[i]-prv1)+EPS < abs(p[num]-prv1)){
	val = tmp;
	num = i;
      }
    }

    ans += abs(p[num]-prv1);
    prv2 = p[num];
    use[num] = true;
    cnt--;

    while(cnt){
      int num = -1;
      double val = -2.0;
      for(int i=0;i<n;i++){
	if(!use[i]){
	  double tmp = dot(prv2-prv1,p[i]-prv2)/(abs(prv2-prv1)*abs(p[i]-prv2));
	  if(val + EPS < tmp){
	    val = tmp;
	    num = i;
	  }else if(abs(val-tmp)<EPS && abs(p[i]-prv2)+EPS < abs(p[num]-prv2)){
	    val = tmp;
	    num = i;
	  }
	} 
      }
      ans += abs(p[num]-prv2);
      prv1 = prv2;
      prv2 = p[num];
      use[num] = true;
      cnt--;
    }
    printf("%.1lf\n",ans);
  }
}

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)


#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    ll n , m;

    cin >> n >> m;

    cout << ceil(n*1.0/m) << endl;





    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <cstdio>
#include <float.h>
#include <ctype.h>
#include <queue>
#include <map>
#include <stack>
#include <limits.h>
#include <cstdlib>
#include <string>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <cfloat> 
using namespace std;
int main(void) {
	int n,i,ans=0,a=1;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		ans = ans + i;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 888
txt = input()
cands = ["dream", "dreamer", "erase", "eraser"]

success = True
while len(txt) > 0:
    flag = False

    for cand in cands:
        subtxt = txt[len(txt) - len(cand):]
        if subtxt == cand:
            txt = txt[:len(txt) - len(cand)]
            flag = True
            break

    if not flag:
        success = False
        break

if success:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
import java.util.*;

class Main{
  public static int max2(int a,int b){
    return (a>b)?a:b;
  }
  
  public static long max2(long a,long b){
    return (a>b)?a:b;
  }
  
  public static int max3(int a,int b,int c){
    return (max2(a,b)<c)?c:max2(a,b);
  }
  
  public static int min2(int a,int b){
    return (a>b)?b:a;
  }
  
  public static long min2(long a,long b){
    return (a>b)?b:a;
  }
  
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int W=sc.nextInt();
    Long[] w=new Long[N];
    int[] v=new int[N];
    Long MAX=10000000000000L;
    int vsum=0;
    int answer=0;
    
    for(int i=0;i<N;i++){
      w[i]=sc.nextLong();
      v[i]=sc.nextInt();
      vsum+=v[i];
    }
      
    Long[][] ans=new Long[N][vsum+1];
    //ans[i][j]は0からi番目の荷物から、価値がj以上になるように選んだときの重さの最小値
    for(int i=0;i<N;i++){
      ans[i][0]=0L;
    }
    
    for(int j=1;j<vsum+1;j++){
      if(j<=v[0]){
        ans[0][j]=w[0];
        if(ans[0][j]<=W&&j>answer) answer=j;
      }else{
        ans[0][j]=MAX;
      }
    }
    
    for(int i=1;i<N;i++){
      for(int j=0;j<vsum+1;j++){
        if(j>=v[i]){
          ans[i][j]=min2(ans[i-1][j],ans[i-1][j-v[i]]+w[i]);
          if(ans[i][j]<=W&&j>answer) answer=j;
        }else{
          ans[i][j]=min2(ans[i-1][j],ans[i][0]+w[i]);
          if(ans[i][j]<=W&&j>answer) answer=j;
        }
      }
    }
    
    System.out.print(answer);
    
  }
}

Measured memory_bytes: 389824
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

typedef pair<double,int> pdi;
signed main(){
	int n,l;
	double sum=0;
	cin>>n>>l;
	deque<pdi>que;
	rep(i,n){
		double t;
		int v;
		cin>>t>>v;
		if(!i){
			que.pb({t,v});
			sum+=t*v;
		}else{
			int nv=v;
			while(nv){
				int w=min(nv,que[0].second);
				sum-=w*que[0].first;
				que[0].second-=w;
				nv-=w;
				if(!que[0].second)que.pop_front();
			}
			sum+=t*v;
			while(!que.empty()){
				pdi a=que.back();
				que.pop_back();
				if(a.first<t){
					que.pb(a);
					break;
				}
				t=(v*t+a.first*a.second)/(v+a.second);
				v+=a.second;
			}
			que.pb({t,v});
		}
		cout<<shosu(9)<<sum/l<<endl;
	}
}















Measured memory_bytes: 18192
n = int(raw_input())

def dfs(u, n,c):
	if u > n:
		return
	if u != 0: 
		if set(str(u)) == set(['3','5','7']):
			c[0] += 1
	
	for digit in [3,5,7]: dfs(u*10 + digit,n,c)

c = [0]
dfs(0, n, c)
print c[0]

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

h = list(map(int,input().split()))

dp = [0] * n

dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2,n):
    dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]))

print(dp[n-1])


Measured memory_bytes: 52208
#include<bits/stdc++.h> 
#define ll long long
#define pb push_back
using namespace std;

const int mod = 1e9+7;

int main(){
  int n,W;
  cin>>n>>W;
  vector<int> w(n),val(n);
  for(int i=0;i<n;i++)
    cin>>w[i]>>val[i];
  
  ll dp[n+1][W+1]={0};
  for(int i=0;i<n+1;i++)
    dp[i][0]=0;
  for(int i=0;i<W+1;i++)
    dp[0][i]=0;
  
  for(int i=1;i<=n;i++)
  {
      for(int j = 1;j<=W;j++){
        dp[i][j] = dp[i-1][j];
        if(w[i-1]<=j)
          dp[i][j] = max(dp[i][j],val[i-1] + dp[i-1][j-w[i-1]]);
      }
  
  }

  cout<<dp[n][W]<<"\n";
  return 0;
}

Measured memory_bytes: 82388