akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  c*=2;
  
  if(x==y) cout<<x*min(c,a+b);
  else if(x>y){
    cout<<min( min(x*c,a*x+b*y), y*min(a+b,c)+(x-y)*min(a,c) );
  }
  else{
    cout<<min( min(y*c,a*x+b*y), x*min(a+b,c)+(y-x)*min(b,c) );
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "



//#define int long long
vector<pair<int,int>>nieg(int r, int c);
const int inf = 1e8 + 5;
int n, m;
vector<vector<char>>a;
vector<vector<int>>dp;
vector<vector<bool>>vis;
queue<pair<int,int>>q;
vector<pair<int,int>>area(int r, int c){
	vector<pair<int,int>>ans;
	for(int R=r-2;R<=r+2;R++){
		for(int C=c-2;C<=c+2;C++){
			if(R==r && C==c){
				continue;
			}
			else{
				if(0<=R&&R<n && 0<=C&&C<m){
					ans.push_back({R, C});
				}
			}
		}
	}
	return ans;
}
vector<pair<int,int>>nieg(int r, int c){
	vector<pair<int,int>>ans;
	if(0<=r+1&&r+1<n && 0<=c&&c<m){
		ans.push_back({r+1, c});
	}
	if(0<=r-1&&r-1<n && 0<=c&&c<m){
		ans.push_back({r-1, c});
	}
	if(0<=r&&r<n && 0<=c+1 && c+1<m){
		ans.push_back({r, c+1});
	}
	if(0<=r && r<n  && 0<=c-1 && c-1<m){
		ans.push_back({r, c-1});
	}
	return ans;
}
void dfs(int r, int c){
	q.push({r, c});
	vis[r][c] = 1;
	vector<pair<int,int>>nie = nieg(r, c);
	for(pair<int,int>p : nie){
		if(a[p.first][p.second] == '.' && dp[p.first][p.second] > dp[r][c]){
			dp[p.first][p.second] = dp[r][c];
			dfs(p.first, p.second);
		}
	}
}
void test_case() {
	cin>>n>>m;
	int r1, c1; cin>>r1>>c1; r1--; c1--;
	int r2, c2; cin>>r2>>c2; r2--; c2--;
	a.resize(n, vector<char>(m));
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++) cin>>a[i][j];
	}
	dp.resize(n, vector<int>(m, inf));
	vis.resize(n, vector<bool>(m, false));
	dp[r1][c1] = 0;
	dfs(r1, c1);
	while(!q.empty()){
		int i = q.front().first;
		int j = q.front().second;
		q.pop();
		vector<pair<int,int>>nei = area(i, j);
		for(pair<int,int>p : nei){
			 if(a[p.first][p.second]=='.'&& dp[p.first][p.second]>dp[i][j]+1){
				 dp[p.first][p.second] = dp[i][j] + 1;
				 dfs(p.first, p.second);
			 }
		 }
	 }
	//for(int i=0;i<n;i++){
		//for(int j=0;j<m;j++){
			//if(vis[i][j]) cout<<1;
			//else cout<<0;
		//}
		//cout<<endl;
	//}
	
	 if(!vis[r2][c2]){
		 cout<<-1<<endl;
	 }
	 else cout<<dp[r2][c2]<<endl;
}

signed main() {
	IOS
	int i=1, T=1;
	//cin>>T;
	while(T--){
		//cout<<"Case #"<<i<<": ";
		test_case();
		i++;
	}
}


Measured memory_bytes: 8844
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int ans;
int a, b, c;
int tmp;

int main() {
	cin >> a >> b;
	tmp = a + b;
	ans = a - b;
	if (tmp < ans) {
		tmp = ans;
	}
	ans = a * b;
	if (tmp < ans) {
		cout << ans << endl;
		return 0;
	}


	cout << tmp << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 100
#define vmax 10000
#define sentinel 2000000000
#define INF (1<<30)
constexpr long long int inf = 1000000000000;
constexpr long long int rinf = -(INT64_MAX);
static const int NIL=-1;

//cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);

struct edge
{
    int to,cost;
};


int V;                //Vは頂点数
bool used[MAX+1];         //頂点iがxに含まれているか
vector<edge> g[MAX+1];


int prim(int s){
    for(int i=1;i<=V;i++){
        used[i]=false;
    }
    int res=0;
    priority_queue<P,vector<P>,greater<P>> que;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top();que.pop();
        int v=p.second;
        if(used[v]) continue;
        res+=p.first;
        used[v]=true;
        for(auto e:g[v]){
            que.push(P(e.cost,e.to));
        }
    }
    return res;
}

int main() {
    int x;
    cin>>V;
    for(int i=1;i<=V;i++){
        for(int j=1;j<=V;j++){
            cin>>x;
            if(x!=-1){
                g[i].push_back({j,x});
            }
        }
    }
    cout<<prim(1)<<endl;
    return 0;
}






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

int b_search(vector<long long> &a,int key){
    int left = 0,right = a.size();
    while(left < right){
        int mid = (left + right) / 2;
        if(a[mid] == key)return mid;
        if(key < a[mid])right = mid;
        else left = mid + 1;
    }
    return 0;
}

int main(){
    int n,q,ans = 0;
    cin >> n;
    vector<long long>s(n);
    for(int i = 0;i < n;i++){
        cin >> s[i];
    }
    cin >> q;
    long t;
    for(int i = 0;i < q;i++){
        cin >> t;
        if(b_search(s,t))ans++;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 3616
#include<iostream>

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

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

    int tmp =n;
    int res = 0;

    for(int i=1;i<=8;i++){
        res += tmp%10;
        tmp /= 10;
    }
    if(n%res == 0) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
};



Measured memory_bytes: 256
a, b = map(int, input().split())
s = {1, 3, 5, 8, 7, 10, 12}
t = {4, 6, 9, 11}
u = {2}
if a in s and b in s:
    print("Yes")
elif a in t and b in t:
    print("Yes")
elif a in u and b in u:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost {ios_base::sync_with_stdio(false);}
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PII, PII> PP;
typedef pair <PII, int> PPI;
typedef pair <int, PII> PIP;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
typedef vector <int> vi;
const int mod = 1e9+7;
const int inf = 1e9+10;
const ll MOD = 1e9+696969;
const ll INF = 1e18;
#define maxn 100100
ll a[maxn], b[maxn], ans[maxn];
int n, zap, DL;

int main()
{
	boost;
	cin >> n >> zap;
	a[++DL] = n;
	FOR(i, 1, zap)
	{
		ll x;
		cin >> x;
		while (a[DL] >= x) --DL;
		a[++DL] = x;
	}
	b[DL] = 1;
	for (int i=DL; i>1; --i)
	{
		ll x = a[i];
		while (x > 0)
		{
			int l = 0, r = i;
			while (r - l > 1)
			{
				int sr = (l + r)/2;
				if (x >= a[sr]) l = sr;
				else r = sr;
			}
			if (l == 0)
			{
				ans[x] += b[i];
				break;
			}
			b[l] += b[i] * (x / a[l]);
			x %= a[l];
		}
	}
	
	ans[a[1]] += b[1];
	for (int i=n; i>0; --i) ans[i] += ans[i+1];
	FOR(i, 1, n) cout << ans[i] << "\n";
}


Measured memory_bytes: 4096
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>

namespace TokorotenLab
{
    class Logger
    {
    private:
        bool isEnable;

    public:
        Logger(bool isEnable = true) : isEnable(isEnable) {}

        template<class T>
        Logger& operator<<(const T& val)
        {
            if(isEnable)
            {
                std::cout << val;
            }
            return *this;
        }

        void set_enable()
        {
            isEnable = true;
        }

        void set_disable()
        {
            isEnable = false;
        }

        void endl()
        {
            if(isEnable)
            {
                std::cout << std::endl;
            }
        }
    };

    Logger logger;

    /*
    Arguments:
        Search range: [begin, end)
        Target function: f(x)
    Requirement:
        f(x) => { false, ..., false, true, ..., true }
    Judge:
        true_bound == begin => All f(x) are true
        true_bound == end => All f(x) are false
    */
    std::pair<long long, long long> binary_search(long long begin, long long end, std::function<bool(long long)> f)
    {
        long long false_bound = begin - 1LL; // ( ..., false_bound] => false
        long long true_bound = end; // [true_bound, ... ) => true
        long long x;

        while(true_bound - false_bound > 1LL)
        {
            x = false_bound + (true_bound - false_bound) / 2LL;
            if(f(x))
            {
                true_bound = x;
            }
            else
            {
                false_bound = x;
            }
        }

        return std::make_pair(false_bound, true_bound);
    }
}

using namespace std;

#define int long long

signed main()
{
    int n;
    vector<int> a;

    cin >> n;

    a.resize(n);

    for(int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }

    sort(a.begin(), a.end(), greater<int>());

    vector<int> ans;
    for(int i = 1; i < n; ++i)
    {
        if(a[i] == a[i - 1])
        {
            ans.push_back(a[i]);
            ++i;
        }
    }

    if(ans.size() < 2)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << ans[0] * ans[1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1660
#include "bits/stdc++.h"

using namespace std;

void Main() {
    long long a, b, x;
    cin >> a >> b >> x;

    long long ans = (b / x) - (a / x);
    if (a % x == 0) {
        ++ans;
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int A[20001],r[20001];

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

	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	
	for (int i = 1; i <= N; i++)
		r[A[i]] = i;
		
	for (int i = 1; i <= N; i++) {
		ll ans = 30000 * i;
		printf("%lld",ans);
		if (i == N)continue;
		printf(" ");
	}
	cout << endl;

	for (int i = 1; i <= N; i++) {
		ll ans = 30000 * (N - i) + r[i];
		printf("%lld",ans);
		if (i == N)continue;
		printf(" ");
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
// #define x first
// #define y second
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define pld pair <ld, ld>
#define all(a) a.begin(), a.end()
#define vvl vector <vector <ll> >
#define cld complex <double>

typedef long long ll;

typedef long double ld;

using namespace std;

const ll maxn = 1e6 + 100;

ll n, m, k, t;

int main() {
    ll q, w, e, a, b, c;
    cin >> k;
    if (k == 1) {
        cout << 1 << endl;
        cout << 1 << endl;
        return 0;
    }
    ll half = (k + 3) / 4;
    n = half * 2;
    cout << n << endl;
    for (q = 0; q < n; q++) {
        for (w = 0; w < n; w++) {
            if (q % 2 == 0) {
                cout << (q + w) % n + 1 << " ";
            }
            else {
                if ((q + w) % n + n < k) {
                    cout << (q + w) % n + n + 1 << " ";
                } 
                else {
                    cout << (q + w) % n + 1 << " ";
                }
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3608
//?????????????????????(8??????????????????????????´??°??¨1?????????????????????????????§????????????)???????????????????????§, ???????±??????????
//?£(N[i]^K) = N9^K (1???i???8)??¨??????K????±?????????°?????????
//1??????????¢???????????????°OK
//reading hard
#include <stdio.h>
#define int long long

int T;
int N[9];

signed main() {
	int i, j, k;
	
	scanf("%lld", &T);
	for (i = 0; i < T; i++) {
		for (j = 0; j < 9; j++) {
			scanf("%llx", N + j);
		}
		
		int key = 0;
		int sum = 0;
		for (j = 0; j < 32; j++) {
			int e = (sum >> j) % 2;
			for (k = 0; k < 9; k++) e ^= ((N[k] >> j) & 1);
			if (e) { key += (1LL << j); }
			for (k = 0; k < 8; k++) sum += ((((N[k] >> j) & 1) ^ e) << j);
		}
		printf("%llx\n", key);
	}
	return 0;
}

Measured memory_bytes: 2608
def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8) 
    x = x + (x >> 16) 
    x = x + (x >> 32) 
    return x & 0x0000007f
f=popcount
a=[]
n=int(input())
for _ in range(n):
    a.append(tuple(map(int,input().split())))

S=1<<n
dp=[0]*(S)


dp[0]=1

for s in range(1,S):
    i=f(s)
    for j in range(n):
        if s>>j&1:
            if a[i-1][j]:
                dp[s]+=dp[s-(1<<j)]
        else:
            dp[s]%=10**9+7
            continue
# print(dp)
print(dp[S-1]%(10**9+7))

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;

typedef long long ll;

stack<int> s;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string str;   
    while (cin >> str) {
        if (str == "+" || str == "-" || str == "*") {
            int a = s.top();
            s.pop();
            int b = s.top();
            s.pop();

            if (str == "+") {
                s.push(b + a);
            } else if (str == "-") {
                s.push(b - a);
            } else if (str == "*") {
                s.push(b * a);
            }
        } else {
            s.push(atoi(str.c_str()));
        }
    }

    cout << s.top() << "\n";
}



Measured memory_bytes: 3232
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

use std::collections::HashMap;

fn main() {
    let _n = input!(i64);
    let a_lst = input!(i64; n);
    let mut map = HashMap::new();

    for &a in a_lst.iter() {
        if map.contains_key(&a) {
            if let Some(x) = map.get_mut(&a) {
                *x += 1;
            }
        } else {
            map.insert(a, 1);
        }
    }

    let mut cnt: i64 = 0;
    for (key, value) in map.iter() {
        if key > value {
            cnt += *value;
        } else if key < value {
            cnt += value - key;
        }
    }
    println!("{}", cnt);
}

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

int main(void){
    string s;
    cin>> s;
    if(s[0] == s[2] && s[0]==s[1]){
        cout<<"No"<<endl;
        return 0;
    }
    if(s[0] == s[2] && s[1] ==s[3]){
        cout<<"Yes"<<endl;
        return 0;

    }else if(s[0]==s[1] && s[2] == s[3]) {
        cout<<"Yes"<<endl;
        return 0;
    }else if(s[0]==s[3] && s[1] == s[2]){
        cout<<"Yes"<<endl;
        return 0;
    }else{
        cout<<"No"<<endl;
        return 0;
    }

}

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

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define rrange(v) v.rbegin(), v.rend()
#define mod (int)(1e9 + 7)
#define inf (int)(5e18)
#define N (int)(2e5 + 10)

using namespace std;

void solve() {
	int n, m;
	cin >> n >> m;
	vector<string> grid(n);
	for (string &s : grid) cin >> s;
	int dp[1005][1005] = {};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (!i and !j) dp[i][j] = 1;
			else {
				if (grid[i][j] == '#') continue;
				int &ans = dp[i][j];
				if (i) ans += dp[i - 1][j];
				if (j) ans += dp[i][j - 1];
				ans %= mod;
			}
		}
	}

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


}
// Remember to clear the global containers



// Got stuck and want to leave ? look at the bottom once..
int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
	// cin >> t_c;
	while (t_c--)
		solve();
}
/* Come on Dude .. Dont get up until u get the solution
 * Giving up not gonna help ryt ? So get ur lazy ass to code already
 * You can do it ... Stay Calm and Dont Panic :)
 */


Measured memory_bytes: 12572
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

	vector<string> a(H);
	for (int i = 0; i < H; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < H + 2; i++) {
		for (int j = 0; j < W + 2; j++) {
			if (i == 0 || i == H + 1 || j == 0 || j == W + 1) {
				cout << '#';
				if (j == W + 1) {
					cout << endl;
				}
			}
			else {
				cout << a[i - 1][j - 1];
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
// C - Base -2 Number
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	string ans = "";
	int p = -2;
	while(N != 0){
		int r = N % p; N /= p;
		if(r < 0){ r -= p; N += 1; }
		ans = to_string(r) + ans;
	}
	if(ans == "") ans = "0";
	cout<< ans <<endl;
}


Measured memory_bytes: 256
package main
import (
  "fmt"
)
func main() {
  var l, r uint64
  fmt.Scan(&l, &r)
  var result uint64
  if 672 <= r-l {
    result = 0
  } else {
    result = 2019
    var i uint64
    for i = l; i < r; i++ {
      var j uint64
      for j = i+1; j <= r; j++ {
        num := i*j%2019
        if num < result {
          result = num
        }
        if result == 0 {
          break
        }
      }
    } 
  }
  fmt.Println(result)
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int win[100000+10];
int solve(int x, VI& a){
  if(win[x]) return win[x];
  if(!x) return win[x] = -1;

  for(int y: a){
    if(y <= x){
      int res = solve(x-y, a);
      if(res == -1){
        return win[x] = 1;
      }
    }
  }
  return win[x] = -1;
}


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

  int N, K;
  cin >> N >> K;
  VI xs(N);
  cin >> xs;

  cout << (solve(K, xs) == 1 ? "First" : "Second") << endl;

  return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, ns, ne) for (int i = ns; i < ne; ++i)

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

  int N, K, k;
  cin >> N >> K;
  set<int> set;
  rep(i, 0, 10) { set.insert(i); }

  rep(i, 0, K) {
    cin >> k;
    set.erase(k);
  }

  bool ok;
  int ans = N;

  while (N < 10001) {
    string str = to_string(ans);
    ok = true;
    rep(i, 0, str.size()) {
      if (!set.count(str[i] - '0')) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << ans << endl;
      break;
    }
    ans++;
  }
  getchar();
}

Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <bitset>
#include <set>
#include <chrono>
#include <string>
#include <assert.h>

using namespace std;

#define endl '\n'

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

    int n; cin >> n;

    long long k; cin >> k;

    vector<long long> a(n);
    vector<long long> b(n);

    for (int i= 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i= 0; i < n; ++i) {
        cin >> b[i];
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    long long lo = -1, hi = a.back() * b.back();

    while (lo + 1 < hi) {
        long long m = (lo + hi) / 2;
        // auto m = 1;
        auto r = k;

        bool ok = true;

        for (int i = 0; i < n; ++i) {
            auto A = a[n - i - 1];
            auto B = b[i];

            if (A * B - m <= 0)
                continue;

            long long t = (A * B - m + B - 1) / B;
            if (t > r) {
                ok = false;
                break;
            }

            r -= t;
        }

        if (ok)
            hi = m;
        else
            lo = m;
    }

    cout << hi << endl;

    return 0;
}

Measured memory_bytes: 3456
/*
 AUTHOR : ANSHU BABU RAJPUT
 
    JAI MAA SARASWATI
    OM NAMAH SHIVAY
    JAI SHRI KRISHNA
    JAI SHRI RAM
    BHARAT MATA KI JAI

    #PKMKB	
    #CKMKB
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int  long long 
#define endl    ("\n")
#define ff       first
#define ss      second
#define pb   push_back
#define pf  push_front
#define ppb   pop_back
#define ppf  pop_front
#define mp   make_pair
#define mod 1000000007

#define L(x)    x.length()
#define B(x)     x.begin()
#define E(x)       x.end()
#define F(x)     x.front()
#define SZ(x)     x.size()
#define CLR(x)   x.clear()

#define all(x)                      x.begin(),x.end()
#define sortD(x) sort(x.begin(),x.end(),greater<int>)
#define rev(x)             reverse(x.begin(),x.end())

#define intV vector<int>

#define PI          (3.141592653589)
#define PMAX     priority_queue<int>
#define PMIN             priority_queue<int,vi,greater<int>>
#define setbits(x)                   __builtin_popcountll(x)
#define zrobits(x)                        __builtin_ctzll(x)

#define KING(i, n) for (int(i) = 0; (i) < n; (i)++)
#define MAHAKAL(i, n) for (int(i) = n-1; (i) >= 0; (i)--)

#define Anshu        int t; cin>>t; while(t--)
#define SITARAM(n,type) type* input=new type[n]

mt19937                          rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void ViLiFY_KiNG()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt","w",stderr);
#endif
}
 
int32_t main()
{
    ViLiFY_KiNG();
    int n;
    cin>>n;
    SITARAM(n,int);
    int temp = 0;
    KING(i,n) {
        cin>>input[i];
        temp = temp^input[i];
    }

    KING(i,n) {
        cout<<(temp^input[i])<<" ";
    }
    return 0;
}

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

int main() {
  string s;
  cin>>s;
  cout<<(s[0]==s[1]&&s[1]==s[2] ? "No":"Yes")<<endl;
  return 0;
}

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

public class Main {
	static final int MOD = 998244353;

	static long add(long x, long y) {
		x += y;
		if (x >= MOD) return x - MOD;
		return x;
	}

	static long sub(long x, long y) {
		x -= y;
		if (x < 0) return x + MOD;
		return x;
	}

	static long mult(long x, long y) {
		return (x * y) % MOD;
	}

	static long mult(long x, long y, long z) {
		return mult(x,  mult(y, z));
	}

	static long pow(long base, long exp) {
		if (exp == 0) return 1;
		if ((exp & 1) == 1) return mult(base, pow(base, exp - 1));
		return pow(mult(base, base), exp / 2);
	}

	static long inverse(long x) {
		return pow(x, MOD - 2);
	}

	static long[] getPots(long base, int max) {
		long[] ret = new long[max + 1];
		ret[0] = 1;
		for (int i = 1; i <= max; i++) {
			ret[i] = mult(ret[i-1], base);
		}
		return ret;
	}

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int S = sc.nextInt();
		int[] vals = new int[N];
		for (int i = 0; i < N; i++) {
			vals[i] = sc.nextInt();
		}
		int ans = 0;
		long[] pots = getPots(2, N);
		long[][] sums = new long[N + 1][S+1];
		sums[0][0] = pots[N];
		long inv2 = inverse(2);

		for (int i = 0; i < N; i++) {
			for (int j = 0; j <= S; j++) {
				sums[i+1][j] = sums[i][j];
			}
			for (int j = 0; j + vals[i] <= S; j++) {
				sums[i + 1][j + vals[i]] = add(sums[i + 1][j + vals[i]], mult(sums[i][j], inv2));
			}
		}

		out.println(sums[N][S]);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 105216
#include<iostream>
#include<vector>
#include<algorithm>

int main() {

	std::vector<int> v(3);
	for (int& x : v) {
		std::cin >> x;
	}

	std::sort(v.begin(), v.end());



	std::cout << v[0]*v[1]/2 << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 10000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

vector<char> V[110000];

int main(){
    string s[110000];
    char temp;
    int N;
    cin>>N;
    for(int i=0;i<=N;i++){
        for(int j=0;j<10;j++){
            cin>>temp;
            V[i].push_back(temp);
        }
        sort(V[i].begin(),V[i].end());
        for(int j=0;j<10;j++) s[i].push_back(V[i][j]);
    }
    sort(s,s+N);
    s[N]="AAAAAAAAAA";
    ll count=1,ans=0;
    for(int i=0;i<N;i++){
        if(s[i]==s[i+1]) count++;
        else{
            ans+=count*(count-1)/2;
            count=1;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 13056
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int n,m;
int cnt=0,head[200005],to[200005],nxt[200005];
ll f[200005],ans[200005];
ll p[200005],a[200005],b[200005],dp[200005];
void add(int x,int y){
	to[++cnt]=y;
	nxt[cnt]=head[x];
	head[x]=cnt; 
}
void dfs(int x,int par=-1){
	int cnter=0;
	f[x]++;
	for(int i=head[x];i;i=nxt[i]){
		if(to[i]!=par){
			dfs(to[i],x);
			f[x]=f[x]*f[to[i]]%m;
		}
	}
	for(int i=head[x];i;i=nxt[i]){
		if(to[i]!=par){
			p[++cnter]=to[i];
		}
	}
	f[x]++;
	f[x]%=m;
	a[0]=b[cnter+1]=1;
	for(int i=1;i<=cnter;++i){
		a[i]=a[i-1]*f[p[i]]%m;
	}
	for(int i=cnter;i>0;--i){
		b[i]=b[i+1]*f[p[i]]%m;
	}
	for(int i=1;i<=cnter;++i){
		dp[p[i]]=a[i-1]*b[i+1]%m;
	}
}
void DFS(int x,int par=-1){
	if(x==1){
		ans[x]=1;
	}
	else{
		ans[x]=(dp[x]*ans[par]+1)%m;
	}
	for(int i=head[x];i;i=nxt[i]){
		if(to[i]!=par){
			DFS(to[i],x);
		}
	}
}
int main(){
	cin>>n>>m;
	for(int i=1;i<n;++i){
		int a,b;
		cin>>a>>b;
		add(a,b),add(b,a);
	}
	dfs(1);
	DFS(1);
	for(int i=1;i<=n;++i){
		cout<<ans[i]*(m+f[i]-1)%m<<'\n';
	}
	return 0;
} 

Measured memory_bytes: 14592
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n; cin>>n;
    vector<ll> a(5,0);
    rep(i,5) cin>>a[i];
    sort(al(a));
    cout<<4+(n+a[0]-1)/a[0]<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

def f(x, y):
    if x == 0:
        return y
    elif y == 0:
        return x
    elif x < y:
        return f(x, y%x)
    else:
        return f(x%y, y)

p = None
for i in range(N):
    m = A[i]

    if p == None:
        p = m
        continue

    p = f(p, m)
    




print(p)

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

int main() {
  int n;
  ll W;
  cin >> n >> W;
  vector<ll> w(n);
  vector<ll> v(n);
  rep(i, n) cin >> w[i] >> v[i];
  ll min_weight = w[0];
  vector<ll> min_weight_value1;
  vector<ll> min_weight_value2;
  vector<ll> min_weight_value3;
  vector<ll> min_weight_value4;
  rep(i,n){
    if(w[i] == w[0]) min_weight_value1.push_back(v[i]);
    if(w[i] == w[0] + 1) min_weight_value2.push_back(v[i]);
    if(w[i] == w[0] + 2) min_weight_value3.push_back(v[i]);
    if (w[i] == w[0] + 3) min_weight_value4.push_back(v[i]);
  }
  sort(min_weight_value1.begin(), min_weight_value1.end(), greater<ll>());
  sort(min_weight_value2.begin(), min_weight_value2.end(), greater<ll>());
  sort(min_weight_value3.begin(), min_weight_value3.end(), greater<ll>());
  sort(min_weight_value4.begin(), min_weight_value4.end(), greater<ll>());
  ll weight1 = w[0];
  ll weight2 = w[0] + 1;
  ll weight3 = w[0] + 2;
  ll weight4 = w[0] + 3;
  vector<ll> sum1(min_weight_value1.size() + 1, 0);
  vector<ll> sum2(min_weight_value2.size() + 1, 0);
  vector<ll> sum3(min_weight_value3.size() + 1, 0);
  vector<ll> sum4(min_weight_value4.size() + 1, 0);
  for (int i = 1; i <= min_weight_value1.size(); i++) sum1[i] = sum1[i-1] + min_weight_value1[i-1];
  for (int i = 1; i <= min_weight_value2.size(); i++) sum2[i] = sum2[i-1] + min_weight_value2[i-1];
  for (int i = 1; i <= min_weight_value3.size(); i++) sum3[i] = sum3[i-1] + min_weight_value3[i-1];
  for (int i = 1; i <= min_weight_value4.size(); i++) sum4[i] = sum4[i-1] + min_weight_value4[i-1];
  ll ans = 0;
  rep(i,sum1.size()){
    rep(j,sum2.size()){
      rep(k,sum3.size()){
        rep(m, sum4.size()){
          if(weight1 * i + weight2 * j + weight3 * k + weight4 * m <= W){
            ans = max(ans, sum1[i] + sum2[j] + sum3[k] + sum4[m]);
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{  int s,h,d,m,s1;
    cin>>s;
    h=s/3600;
    d=s%3600;
    m=d/60;
    s1=d%60;

    cout<<h<<':'<<m<<':'<<s1<<endl;
    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

int main(){
    int N,a,b,A,B;
    string s;
    cin >> N >> a >> b >> A >> B;
    a--,b--,A--,B--;
    cin >> s;
    auto ok = [&](int l,int r){
        for(int i=l;i<r;i++){
            if(s[i]=='#' && s[i+1]=='#') return false;
        }
        return true;
    };
    if(!ok(a,A) || !ok(b,B)){
        puts("No");
        return 0;
    }
    if(A < B){
        puts("Yes");
        return 0;
    }else{
        for(int i=b;i<=B;i++) if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'){
            puts("Yes");
            return 0;
        }
        puts("No");
        return 0;
    }
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
#define ll long long
#define ull unsigned long long
#define db double
#define REP(i, lim) for(int i=0;i<lim;++i)
#define REPP(i, lim) for(int i=1;i<=lim;++i)
#define DEC(i, lim) for(int i=lim;i>=1;--i)
#define FOR(i,l,r)  for(int i=l;i<r;++i)
#define deBug cout<<"==================================="<<endl;
#define clr(s) memset(s, 0, sizeof(s))
#define lowclr(s) memset(s, -1, sizeof(s))
const int MAXN = 1000055;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
const db eps = 1e-9;

inline int sgn(db x) { return x<-eps ? -1 : x>eps; }
inline db sqr(db x) { return x*x; }



struct P {
    // information
    P() {}
    P(db _x, db _y) : x(_x), y(_y) {}
    db x, y;

    // operation
    P operator + (P p)   const{ return P(x+p.x, y+p.y); }
    P operator - (P p)   const{ return P(x-p.x, y-p.y); }
    P operator * (db d)  const{ return P(x*d, y*d); }
    P operator / (db d)  const{ return P(x/d, y/d); }

    db dot(P p) { return x * p.x + y * p.y; } // 点积
    db det(P p) { return x * p.y - y + p.x; } // 叉积

    // other
    void input() { scanf("%lf%lf", &x, &y); }
    void print() { printf("(%lf, %lf)\n", x, y); }

    db dis(P p) { return sqrt(sqr(x-p.x) + sqr(y-p.y)); }
    db dis2(P p) { return sqr(dis(p)); }
};

P getProjection(P a, P b, P p) {
    // (p1, q) 在 (p1, q2) 上的投影点
    P dir = b-a;
    return a + dir * ( dir.dot(p-a) / a.dis2(b) );
}

P getReflection(P a, P b, P p) {
    return getProjection(a, b, p) * 2 - p;
}

int main()
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
//    std::ios::sync_with_stdio(false); cin.tie(0);

    P a, b;
    a.input(); b.input();
    int Q;
    scanf("%d", &Q);
    while(Q--)
    {
        P p;
        p.input();
        P ans = getReflection(a, b, p);
        printf("%.10lf %.10lf\n", ans.x, ans.y);
    }


    return 0;
}


Measured memory_bytes: 3236
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdio>

using namespace std;

typedef long long ll;


#define rep(i,b) for(ll i=0;i<(b);++i)
#define rep1(i,b) for(ll i=1;i<=(b);++i)
#define vec vector
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;


int N, M;
int A[40][40];
int B[40];
int C;

int main() {
   cin >> N >> M >> C;
   rep1(i, M) {
      cin >> B[i];
   }
   int count = 0;
   rep(i, N) {
      int val = C;
      rep1(j, M) {
         cin >> A[i][j];
         val += A[i][j] * B[j];
      }
      count += ((val > 0) ? 1 : 0);
   }
   cout << count << endl;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    while 1:
        n,m = LI()
        if n == 0 and m == 0:
            break
        v = [[] for i in range(n)]
        for i in range(m):
            a,b = LI()
            a -= 1
            b -= 1
            v[a].append(b)
            v[b].append(a)
        bfs_map = [1 for i in range(n)]
        bfs_map[0] = 0
        f = [0 for i in range(n)]
        q = deque()
        q.append(0)
        fl = 1
        while q:
            if not fl:break
            x = q.popleft()
            for y in v[x]:
                if bfs_map[y]:
                    bfs_map[y] = 0
                    f[y] = (1-f[x])
                    q.append(y)
                else:
                    if f[y] == f[x]:
                        print(0)
                        fl = 0
                        break
        if fl:
            ans = []
            k = sum(f)
            if k%2 == 0:
                ans.append(k//2)
            k = len(f)-sum(f)
            if k%2 == 0:
                ans.append(k//2)
            ans = list(set(ans))
            ans.sort()
            print(len(ans))
            for i in ans:
                print(i)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    A()



Measured memory_bytes: 8480
N = int(input())
T,A=map(int,input().split())
H = list(map(int,input().split()))
goodi = 0
for i in range(1,N):
    if abs(A - (T - H[goodi]*0.006)) >  abs(A - (T - H[i]*0.006)):
        goodi = i
print(goodi+1)

Measured memory_bytes: 9172
#include<iostream>
#include<list>
#include<string>
using namespace std;

int main(){
    int n,x; cin>>n;
    list<int>data;
    list<int>::iterator it,l;
    string s;
    while(n--){
    cin>>s;
    if(s=="insert"){
        cin>>x;
        data.push_front(x);
    }
    else if(s=="delete"){
        cin>>x;
        for(it=data.begin(),l=data.end();it!=l;it++){
            if(*it==x){
                data.erase(it);
                break;
            }
        }
    }
    else if(s=="deleteLast"){
            data.pop_back();
      
    }
    else if(s=="deleteFirst"){
        data.pop_front();
    }
    }
    for(it=data.begin(),l=--data.end();it!=l;it++){
      cout<<*it<<" "; 
    }
    cout<<*it<<endl;
}


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

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  vector<int> take1(n + 1), take2(n + 1);
  for (int i = 1; i <= n; i++) {
    take1.at(i) = take2.at(i - 1) + 1;
    if (i >= 2 && s.at(i - 1) != s.at(i - 2)) {
      take1.at(i) = max(take1.at(i), take1.at(i - 1) + 1);
    }
    if (i >= 2) take2.at(i) = take1.at(i - 2) + 1;
    if (i >= 3 && s.at(i - 1) != s.at(i - 3)
        || i >= 4 && s.at(i - 2) != s.at(i - 4)) {
      take2.at(i) = max(take2.at(i), take2.at(i - 2) + 1);
    }
  }
  cout << max(take1.at(n), take2.at(n)) << endl;
}


Measured memory_bytes: 2180
import numpy as np

N,M = map(int,input().split())
Xs = sorted([int(i) for i in input().split()])

if N >= M:
    print(0)
elif N == 1:
    print(Xs[-1]-Xs[0])
else:
    margin = [Xs[i+1]-Xs[i] for i in range(len(Xs)-1)]
    margin = [(i,x) for i,x in enumerate(margin)]
    point = [x[0] for x in sorted(margin,key=lambda x:x[1],reverse=True)[:N-1]]
    move = 0
    move += Xs[point[0]] - Xs[0]
    for i in range(1,len(point)):
        move += Xs[point[i]] - Xs[point[i-1]+1]
    move += Xs[-1] - Xs[point[-1]+1]
    print(move)

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

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);

		if (n >= m) {
			System.out.println("0");
			return;
		}

		Integer x[] = new Integer[m];

		str = br.readLine().split(" ");
		for (int i = 0; i < m; i++) {
			x[i] = Integer.parseInt(str[i]);
		}

		Arrays.sort(x);

		int dist = Math.abs(x[m - 1] - x[0]);

		Integer diff[] = new Integer[m - 1];

		for (int i = 0; i < m - 1; i++) {
			diff[i] = Math.abs(x[i + 1] - x[i]);
		}

		Arrays.sort(diff, Comparator.reverseOrder());

		for (int i = 0; i < n - 1; i++) {
			dist -= diff[i];
		}

		System.out.println(dist);
	}
}


Measured memory_bytes: 48508
#include <cstdio>
#include <algorithm>
#include <functional>
#include <stack>
#include <cmath>
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define llong long long

int main() {
  char c;
  while((c = getc(stdin)) != EOF) {
    if(c <= 'z' && c >= 'a') putc(c-'a'+'A',stdout);
    else putc(c,stdout);
  }
  
  return 0;
}

Measured memory_bytes: 2492
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;


int main(){
  int i,j;
  string s;
  cin>>s;
  int n=s.size();
  VI v(26,0);
  VI w(n);
  int cnt=1;
  int t=0;
  for(i=n-1;i>=0;i--){
    if(v[s[i]-'a']==0) {
      v[s[i]-'a']=1;
      t++;
    }
    w[i]=cnt;
    if(t==26){
      t=0;
      v=VI(26,0);
      cnt++;
    }
  }
  
  string ans="";
  int po=0;
  while(1){
    v=VI(26,0);
    while(po<n&&w[po]==cnt){
      v[s[po]-'a']=1;
      po++;
    }
    for(i=0;i<26;i++){
      if(v[i]==0){
        ans+=i+'a';
        cnt--;
        break;
      }
    }
    if(cnt==0) break;
    while(po<n&&s[po]!=ans[ans.size()-1]){
      po++;
    }
    po++;
  }
  cout<<ans<<endl;

}


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

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;


int main(void){

int mm,dd;
int lday[] = {31,29,31,30,31,30,31,31,30,31,30,31};
string yob[7] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	
	while(cin >> mm >> dd ){
		if(mm == 0) break;
		int wkdd=dd;
		if( mm > 1) rep(i,mm-1) wkdd += lday[i];
//		cout << wkdd << endl;
		wkdd = wkdd % 7;
		cout <<  yob[wkdd] << endl;;
			
	}
	return 0;
}

Measured memory_bytes: 1196
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String[] s  = sc.next().split("");
        String[] t  = sc.next().split("");
        int count = 0;
        for(int i=0;i<s.length;i++){
            if(s[i].equals(t[i]))count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21716
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


char s1[1005],s2[1005];
int n1,n2;
int dp[1005][1005];

int main()
{
	scanf("%s%s",s1,s2);
	n1 = strlen(s1);
	n2 = strlen(s2);
	for(int i=0;i<=n1;i++)dp[i][0]=i;
	for(int i=0;i<=n2;i++)dp[0][i]=i;
	for(int i=0;i<n1;i++){
		for(int j=0;j<n2;j++){
			int a = (s1[i]==s2[j]?0:1);
			dp[i+1][j+1] = min({dp[i][j+1]+1,dp[i+1][j]+1,dp[i][j]+a});
		}
	}
	printf("%d\n",dp[n1][n2]);
	return 0;
}



Measured memory_bytes: 6660
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using pll = pair<long long, long long>;

int main() {
    int N; cin >> N;
    vector<pll> v(N);
    for (int i = 0; i < N; ++i) {
        long long a, l;
        cin >> a >> l;
        v[i] = {a - l, a + l};
    }

    // 区間を右端の小さい順にソート
    sort(v.begin(), v.end(), [](pll a, pll b) {
            return a.second < b.second;});

    // cur := 現在選んでいる区間のうち、最も右にあるやつの右端
    int res = 0;
    long long cur = -(1LL<<60);
    for (int i = 0; i < N; ++i) {
        if (cur > v[i].first) continue; // 被るやつは飛ばす
        ++res;
        cur = v[i].second;
    }
    cout << res << endl;
}


Measured memory_bytes: 1792
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val t = listOf(sc.nextLong() * 8, sc.nextLong() * 4, sc.nextLong() * 2, sc.nextLong())
    val n = sc.nextLong()

    if (n % 2 == 0L) {
        println(n / 2 * t.min()!!)
    } else {
        println(n / 2 * t.min()!! + t.subList(0, 3).min()!! / 2)
    }
}

Measured memory_bytes: 35912