akhauriyash/Code-Regression huggingface dataset:
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::HashSet;

fn main() {
    input!{
        n: usize,
        s: [chars; n]
    }
    let mut mem = vec![2; n];
    mem[0] = 0;
    if !dfs(0, &s, &mut mem) {
        println!("-1");
        return;
    }
    let mut ans = 0;
    for i in 0..n {
        ans = max(ans, bfs(i, &s));
    }
    if ans == 0 {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}

fn bfs(r: usize, s: &Vec<Vec<char>>) -> usize {
    let n = s.len();
    let mut q = vec![r];
    let mut set = HashSet::new();
    set.insert(r);
    let mut k = 0;
    while !q.is_empty() {
        let mut next = vec![];
        for &v in &q {
            for i in 0..n {
                if s[v][i] == '0' {
                    continue;
                }
                if !set.contains(&i) {
                    set.insert(i);
                    next.push(i);
                }
            }
        }
        k += 1;
        q = next;
    }
    k
}

fn dfs(r: usize, s: &Vec<Vec<char>>, mem: &mut Vec<usize>) -> bool {
    let n = s.len();
    for i in 0..n {
        if s[r][i] == '0' {
            continue;
        }
        if mem[i] == mem[r] {
            return false;
        } else if mem[i] == 2 {
            mem[i] = 1 - mem[r];
            if !dfs(i, s, mem) {
                return false;
            }
        }
    }
    true
}


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

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    vector<vector<int> > p;
    p.resize(n);
    REP(i,n){
      int m;
      cin >> m;
      p[i].resize(m);
      REP(j,m) cin >> p[i][j];
      SORT(p[i]);
    }
    vector<int> l;
    int ls;
    cin >> ls;
    l.resize(ls);
    REP(i,ls) cin >> l[i];
    SORT(l);
    vector<int> answer;
    REP(i,SZ(p)){
      int tmp=0;
      REP(j,SZ(l)){
	REP(k,SZ(p[i])){
	  if(l[j]==p[i][k]){
	    ++tmp;
	    break;
	  }
	}
      }
      if(tmp==SZ(l)) answer.PB(i+1);
    }
    if(SZ(answer)==1) cout << answer.front() << endl;
    else cout << -1 << endl;
  }
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;

int main() {
  int n,m;cin>>n>>m;
  vector<int> a(n),b(n),c(m),d(m);
  rep(i,n) cin>>a[i]>>b[i];
  rep(i,m) cin>>c[i]>>d[i];

  rep(i,n) {
    int dist = 1e9;
    int cp = -1;
    rep(j,m) {
      int dist_n = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if (dist > dist_n) {
        cp = j;
        dist = dist_n;
      }
    }
    cout << cp + 1 << endl;
  }
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;
typedef long long ll;
const int INF = 1e9;

int N;
int a[100001];
void solve(){
    int res = 0;
    for(int i=1;i<=N;i++){
        if(a[a[i]] == i)res++;
    }
    cout << res/2 << endl;
}

int main() {
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> a[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

pair<int64_t, int64_t> part[200005];

int main()
{
  int N;
  vector<int> A;

  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  vector<int> sorted_A(A);

  sort(sorted_A.begin(), sorted_A.end());

  int64_t total = 0;

  for (int i = 0; i < sorted_A.size(); i++) {
    static int64_t count = 1;

    if (i == sorted_A.size() - 1) {
      part[sorted_A[i]].first = count * (count - 1) / 2;
      if (count <= 1)
        part[sorted_A[i]].second = 0;
      else
        part[sorted_A[i]].second = (count - 1) * (count - 2) / 2;
      total += part[sorted_A[i]].first;
    }
    else if (sorted_A[i] != sorted_A[i + 1]) {
      part[sorted_A[i]].first = count * (count - 1) / 2;
      if (count <= 1)
        part[sorted_A[i]].second = 0;
      else
        part[sorted_A[i]].second = (count - 1) * (count - 2) / 2;
      total += part[sorted_A[i]].first;
      count = 1;
    }
    else {
      count++;
    }
  }

  for (int i = 0; i < A.size(); i++) {
    cout << fixed << total - part[A[i]].first + part[A[i]].second << endl;
  }

  return 0;
}


Measured memory_bytes: 6272
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let s: String = read();
    let t: String = read();
    let mut u: String = String::new();
    for i in 0..n { u = format!("{}{}{}", u, s.as_bytes()[i] as char, t.as_bytes()[i] as char); }
    println!("{}", u);
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int Slen = S.length();

		int min = 1000;
		int num = 0;
		for(int i=0;i<Slen-2;i++) {
			num = Integer.parseInt(S.substring(i, i+3));
			num = Math.abs(753-num);

			if(num < min) {
				min = num;
			}
		}

		System.out.println(min);

	}

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 5000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(){
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a.at(i);
    sort(all(a));
    cout<<a.back()-a.front()<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
int main(){
    ll n,x;
    cin >> n >> x;
    vector<ll>a(n);
    rep(i,n)cin >> a[i];
    sort(a.begin(),a.end());
    int ans = 0;
    int sum = 0;
    rep(i,n){
        sum += a[i];
        if(sum == x){
            cout << i + 1 << endl;
            break;
        }
        if(sum>x){
            cout << i << endl;
            break;
        }
        if(i==n-1){
            cout << n-1 << endl;
        }
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    static int mod = 1000000007;
    static long[] fac, finv, inv;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        sc.close();

        fac = new long[H+W];
        finv = new long[H+W];
        inv = new long[H+W];
        COMinit(H, W);

        long ans = 0;
        for(int i = 0; i <=H-A-1; i++){
            ans = (ans + COM(B+i-1, i)*COM(W-B-1+H-i-1, H-i-1)%mod)%mod;
        }
        System.out.println(ans);
    }

    static void COMinit(int H, int W) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < H+W; 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;
        }
    }

    static long COM(int n, int k){
        if(n < k)
            return 0;
        if(n < 0 || k < 0)
            return 0;
        return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
    }
    
}

Measured memory_bytes: 26068
#include<stdio.h>
int gcm(int a, int b)
{
    int r = a % b;
    while (r > 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int a[100005];
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    int ans = gcm(a[0], a[1]);
    for (i = 2; i < n; i++)
        ans = gcm(ans, a[i]);
    printf("%d\n", ans);
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    for(int i=111; i<=999; i += 111){
        if(n<=i){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
// @author : sam000013
 
#define int long long
 
#define PI 3.14159265
#define pb(x) push_back(x)
#define all(v) v.begin(), v.end()
#define endl cout<<"\n" 
#define dbg(x) cout<<#x<<" "<<x;endl;
#define bye endl;return
#define uni 1.000000
using namespace std;

const int mod = 1000000007;
template <typename T>

void debug(vector<T> x)
{
    for (auto e : x)
    {
        cout << e << " ";
    }
    cout << "\n";
}
/*


*/



void solve(){
    int n;
    cin>>n;
    int start = 0;
    bool ok = 0;
    for(int i=0; i<n; i++){
        int x,y;
        cin>>x>>y;
        if(x == y){
            start++;
        }else if(start > 0){
            start = 0;
        }
        if(start >= 3)
            ok = 1;
    }
    if(ok)
        cout<<"Yes\n";
    else
    {
        cout<<"No\n";
    }
    

}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //    cin >> t;
    for (int i = 1; i <= t; i++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
using namespace std;

int main() {
    stack<int> S;
    int a, b, x;
    string s;
    while (cin >> s) {
        if (s[0]=='+') {
            a=S.top(); S.pop();
            b=S.top(); S.pop();
            S.push(a+b);
        } else if (s[0]=='-') {
            b=S.top(); S.pop();
            a=S.top(); S.pop();
            S.push(a-b);
        } else if (s[0]=='*') {
            a=S.top(); S.pop();
            b=S.top(); S.pop();
            S.push(a*b);
        } else {
            S.push(atoi(s.c_str()));
        }
    }
    printf("%d\n",S.top());
    return 0;
}

Measured memory_bytes: 3352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] an = new int[n+2];
			for (int i = 1; i < n+1; i++) {
				an[i] = in.nextInt();
			}

			long sum = 0;
			for (int i = 0; i < n+1; i++) {
				sum += Math.abs(an[i+1]-an[i]);
			}

			for (int i = 1; i < n+1; i++) {
				if ((an[i-1] <= an[i] && an[i] <= an[i+1]) || (an[i-1] >= an[i] && an[i] >= an[i+1])) {
					out.println(sum);
				} else {
					out.println(sum - Math.abs(an[i]-an[i-1]) - Math.abs(an[i+1]-an[i]) + Math.abs(an[i+1]-an[i-1]));
				}
			}

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 46472
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9 + 7;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    while (1) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3640
A,B=map(int,input().split())
S=input()
num=list("0123456789")
flg_1=0
flg_2=1
if S[A]=="-":
    flg_1=1
for i in range(len(S)):
    if i!=A:
        if S[i] not in num:
            flg_2=0
print("Yes" if flg_1 and flg_2 else "No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;

using P = std::pair<int, int>;
using ll = long long;
using ld = double;

using bint = boost::multiprecision::cpp_int;


template<typename T, typename U>
std::istream& operator>>(std::istream& in, std::pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

const int MOD = 998244353;
int getSegTreeSize(int len) {
    if (len == 0)
        return 0;
    int ret, cnt = 0, memo = 1;
    while (memo < len) {
        memo *= 2;
        cnt++;
    }
    ret = 1 << (cnt + 1);
    return ret;
}
class RUQ {
  private:
    int size, length;
    std::vector<int> node;
    RUQ() {}
    int find(int return_index, int index, int left, int right) {
        if (node[index] != -1)
            return node[index];
        if ((left + right) / 2 < return_index)
            return find(return_index, index * 2 + 1, (left + right) / 2 + 1, right);
        return find(return_index, index * 2, left, (left + right) / 2);
    }
    void update(int left, int right, int element, int index, int i_left, int i_right) {
        if (element == node[index])
            return;
        if (left <= i_left && i_right <= right) {
            node[index] = element;
            return;
        }
        if (node[index] != -1) {
            node[index * 2] = node[index];
            node[index * 2 + 1] = node[index];
            node[index] = -1;
        }
        int middle = (i_left + i_right) / 2;
        if (middle >= left)
            update(left, right, element, index * 2, i_left, middle);
        if (middle < right)
            update(left, right, element, index * 2 + 1, middle + 1, i_right);
    }

  public:
    RUQ(int size,int def) {
        this->size = getSegTreeSize(size) / 2;
        this->length = getSegTreeSize(size);
        node.resize(this->length);
        fill(node.begin(), node.end(), def);
    }
    void update(int left, int right, int element) {
        update(left, right, element, 1, 1, size);
    }
    int find(int index) {
        return find(index, 1, 1, size);
    }
};

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int n,q;
    cin>>n>>q;
    int ans=(n-2)*(n-2);
    RUQ a(n,n),b(n,n);
    rep(i,q){
        int t,x;
        cin>>t>>x;
        if(t-1){
            int it=a.find(x);
            ans-=it-2;
            if(b.find(it-1)>x){
                b.update(0,it-1,x);
            }
        }
        else{
            int it=b.find(x);
            ans-=it-2;
            if(a.find(it-1)>x){
                a.update(0,it-1,x);
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 11380
N = int( input())
A = [ int( input()) for _ in range(N)]
now = 0
ans = 0
if A[0] != 0:
    ans = -1
else:
   for i in range(1,N):
       a = A[i]
       if a > i:
           ans = -1
           break
       elif now + 1 == a:
           ans += 1
           now += 1
       elif now >= a:
           ans += a
           now = a
       else:
           ans = -1
           break
print(ans)

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

typedef long long lint;
#define M 1000000007

lint pow(lint x,lint e){
    if(e==0) return 1;
    if(e==1) return x%M;
    return (pow((x*x)%M,e/2)*(e%2==1?x:1))%M;
}

int main(){
    lint H,W,A,B;
    cin >> H >> W >> A >> B;
    lint fact[200001],factinv[200001];
    fact[0]=factinv[0]=1;
    for(int i=1;i<=W+H;i++) fact[i]=(fact[i-1]*i)%M;
    for(int i=1;i<=W+H;i++) factinv[i]=pow(fact[i],M-2);

    lint sum=0;
    for(int i=1;i<=H-A;i++){
        lint X,Y;
        X=fact[B-2+i]*(factinv[i-1]*factinv[B-1]%M)%M;
        Y=fact[H+W-B-1-i]*(factinv[H-i]*factinv[W-B-1]%M)%M;
        sum+=X*Y%M;
        sum%=M;
    }

    cout << sum << endl;

    return 0;
}//

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
#define mod 1000000007
int n;
int a[200005];
int val[200005];
int b[200005];
vector <int> ans;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	f(i,1,n+1)
		cin>>a[i];
	for(int i=n;i>=1;i--)
	{
		b[i]^=a[i];
		if(b[i]==1)
		{
			ans.push_back(i);
			for(int j=2;j*j<=i;j++)
			{
				if(i%j==0)
				{
					if(j*j==i)
					{
						b[j]^=1;
					}
					else
					{
						b[j]^=1;
						b[i/j]^=1;
					}
				}
			}
			b[1]^=1;
		}
	}
	cout<<ans.size()<<endl;
	for(int i: ans)
		cout<<i<<" ";
	cout<<endl;
	return 0;
}

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

int main() {
    int R, C;
    cin >> R >> C;
    vector<string> s(R);
    for(int i = 0; i < R; ++i) {
        cin >> s[i];
    }
    vector<int> bitcount(1 << C);
    for(int i = 0; i < 1 << C; ++i) {
        bitcount[i] = __builtin_popcount(i);
    }

    vector<int> dp(1 << C, -1);
    dp[0] = 0;
    for(int i = 0; i < R; ++i) {
        for(int j = 0; j < C; ++j) {
            vector<int> nxt(1 << C, -1);
            for(int S = 0; S < (1 << C); ++S) {
                if(dp[S] == -1) {
                    continue;
                }
                int idx = bitcount[S & (1 << j) - 1];
                if(idx < s[i].size()) {
                    int t = dp[S];
                    if(idx > 0 && (S & 1 << (j - 1)) && s[i][idx - 1] == s[i][idx]) {
                        t++;
                    }
                    if(i > 0 && (S & 1 << j) && s[i][idx] == s[i - 1][s[i - 1].size() - bitcount[S >> j]]) {
                        t++;
                    }
                    nxt[S | 1 << j] = max(nxt[S | 1 << j], t);
                }
                if(C - j > s[i].size() - idx) {
                    nxt[S & ~(1 << j)] = max(nxt[S & ~(1 << j)], dp[S]);
                }
            }
            dp.swap(nxt);
        }
    }
    cout << 2 * *max_element(begin(dp), end(dp)) << endl;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A, B;
  A = 0;
  B = 0;
  vector<int> card(110);
  for(int i = 0; i < N; i++){
   cin >> card.at(i);
  }
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  
  for(int i = 0; i < N; i++){
   if(i % 2 == 0){
     A += card.at(i);
   }
    else{
     B += card.at(i); 
    }
  }
      cout << A - B << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
lli dp[100001];
vector <vector<lli> > par(100001);
lli max_dis(lli x){
	if(par[x].size()==0)
	return 0;
	if(dp[x]!=-1)
	return dp[x];
	for(lli i=0;i<par[x].size();i++){
		dp[x]=max(dp[x],max_dis(par[x][i])+1);
	}
	return dp[x];
}
int main(){
	lli n,m;
	cin>>n>>m;
	vector <vector<lli> > adj(n+1);
	lli x,y;
	for(lli i=0;i<m;i++){
		cin>>x>>y;
		par[y].push_back(x);
		adj[x].push_back(y);
	}
	for(lli i=0;i<=n;i++)
	dp[i]=-1;
	for(lli i=1;i<=n;i++){
		if(adj[i].size()==0){
			dp[i]=max(dp[i],max_dis(i));
		}
	}
	lli ans=0;
	for(lli i=1;i<=n;i++){
	ans=max(ans,dp[i]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 15104
#include<iostream>
using namespace std;
int gcd(int a,int b) {
  if(a<b) {
    int tmp=a;
    a=b;
    b=tmp;
  }
  if(a%b==0) return b;
  return gcd(b,a%b);
}

int main() {
  int a=0;
  int b=0;
  while(cin>>a>>b) {
    int n=gcd(a,b);
    cout<<n<<" "<<a/n*b<<endl;
  }
  return 0;
}



Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
const int N=3e3+5;
ll a[N][N],dp[N][N][4],n,m;
ll go(ll i,ll j,ll k)
{
    if(i==n+1 || j==m+1)
    {
        return 0;
    }
    else if(dp[i][j][k]!=-1)
    {
        return dp[i][j][k];
    }
    else if(k==3)
    {
        return go(i+1,j,0);
    }
    else
    {
        return dp[i][j][k]=max({go(i+1,j,0)+a[i][j],go(i,j+1,k+1)+a[i][j],go(i,j+1,k)});
    }
}
int main()
{
    ft
    ll t,i,j,k,l,r,p;
    cin>>n>>m>>k;
    memset(a,0,sizeof(a));
    memset(dp,-1,sizeof(dp));
    for(i=0;i<k;i++)
    {
        cin>>l>>r>>p;
        a[l][r]=p;
    }
    cout<<go(1,1,0)<<"\n";
    return 0;
}



Measured memory_bytes: 356856
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n, W;
    cin >> n >> W;

    vector<ll> w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];

    ll w0 = w[0];
    rep(i, n) w[i] -= w0;

    // dp[i][j][k]: i個までみたときのj個選んで重さが k (j+j*w0) である最大のvalue
    // 選んだ個数も保存しないといけない
    vector<vector<vector<ll> > > dp(
        n+1, 
        vector<vector<ll>>(n+1, vector<ll>(400)));

    repi(i, n+1) {
        rep(k, 400) {
            // i-1個目を選ぶ場合
            repi(j, n+1) {
                if (k-w[i-1] >= 0)
                    dp[i][j][k] = max(dp[i][j][k], dp[i-1][j-1][k-w[i-1]] + v[i-1]);
            }
            // i-1個目はスキップ
            repi(j, n+1) {
                dp[i][j][k] = max(dp[i][j][k], dp[i-1][j][k]);
            }
        }
    }

    ll res = 0;
    rep(j, n + 1) {
        rep(k, 400) {
            ll actualW = j * w0 + k;
            if (actualW <= W) {
                res = max(res, dp[n][j][k]);
            }
        }
    }

    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 35976
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int cost[10][10], ns, nl, res, vres[100], pres;

int dfs(int sum, int now, int *used, int *pass, int pos){
  //  printf("%d %d %d\n", sum, now, pos);
  int f = 1, ret = 0;
  rep(i, ns){
    if(i == now || used[now*10+i] || cost[now][i] == INF) continue;
    //    fprintf(stderr, "%d %d %d\n", now, i, cost[now][i]);
    f = 0;
    pass[pos] = i;
    used[now*10+i] = used[i*10+now] = 1;
    ret = max(ret, dfs(sum+cost[now][i], i, used, pass, pos+1));
    pass[pos] = 0;
    used[now*10+i] = used[i*10+now] = 0;
  }
  if(f && res < sum){
    res = sum;
    rep(i, pos) vres[i] = pass[i];
    //    rep(i, pres+1) printf("%d ", vres[i]); puts("");
    pres = pos;
  }
  return ret;
}

int main(){
  while(scanf("%d%d", &ns, &nl) && ns+nl){
    res = 0, pres = 0;
    rep(i, 10) rep(j, 10) cost[i][j] = INF;
    rep(i, nl){
      int s1, s2, d;
      scanf("%d%d%d", &s1, &s2, &d);s1--;s2--;
      cost[s1][s2] = cost[s2][s1] = d;
    }
    int sum = 0;
    rep(i, ns){
      //      fprintf(stderr, "%d\n", i);
      int used[100] = {}, pass[100] = {};
      pass[0] = i;
      sum = max(sum, dfs(0, i, used, pass, 1));
    }
    printf("%d\n", res);
    rep(i, pres) printf(i?" %d":"%d", vres[i]+1); puts("");
  }
  return 0;
}

Measured memory_bytes: 1196
n,k=[int(i) for i in input().split()]

#dp用の表
dp=[None for i in range(n+1)]

#nから1まで一つずつ埋めていく
for i in range(n):
    i=n-i
    if i>=k:
        dp[i]=0
    else:
        j=2*i
        if j<=n:
            dp[i]=dp[j]+1
        else:
            count=1
            while j<k:
                count+=1
                j=2*j
            dp[i]=count
            
# print(dp)

prob=0
for i in range(n):
    a=dp.pop()
    prob+=0.5**a
print(prob/n)


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

int main(){
	long long int n,m,k;
	cin>>n>>m>>k;
	vector<long long int>a(n),b(m),sum_a(n),sum_b(m);
	rep(i,n)cin>>a[i];
	rep(i,m)cin>>b[i];
	sum_a[0]=a[0];
	for(int i=1;i<n;i++)sum_a[i]=sum_a[i-1]+a[i];
	sum_b[0]=b[0];
	for(int i=1;i<m;i++)sum_b[i]=sum_b[i-1]+b[i];
	long long int rest;
	long long int max,value;
	max =(upper_bound(sum_b.begin(),sum_b.end(),k)-sum_b.begin());
	rep(i,n){
		rest = k - sum_a[i];
		if(rest<0)break;
		value = i+1 + (upper_bound(sum_b.begin(),sum_b.end(),rest)-sum_b.begin());
		if(max<value)max = value;
	}
	cout<<max<<endl;



	return 0;
}

Measured memory_bytes: 9572
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut a: Vec<usize> = vec![];
    for _ in 0..n {
        let ai = read();
        a.push(ai);
    }
    let mut cnt_one = 0;
    let mut cnt_two = 0;
    let mut cnt_four = 0;
    for i in 0..a.len() {
        let ai = a[i];
        if ai % 4 == 0 {
            cnt_four += 1;
        } else {
            if ai % 2 == 0 {
                cnt_two += 1;
            } else {
                cnt_one += 1;
            }
        }
    }
    if cnt_one <= cnt_four && cnt_two != 0 {
        println!("Yes");
    } else {
        if cnt_one <= cnt_four + 1 && cnt_two == 0 {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 100000;
int N;
int A[MAX_N+1];
ll prob[MAX_N+1];
ll fact[MAX_N+1];
ll probs[MAX_N+1];

//整数a,bに対し、ax + by = gcd(a,b) を満たす整数x,y,gcd(a,b) を計算する
int extgcd(int a, int b, int& x, int& y) {
  int d = a;
  if (b != 0) {
    d = extgcd(b, a%b, y, x);
    y -= (a/b) * x;
  } else {
    x = 1; y = 0;
  }
  return d;
}

//ax ≡ gcd(a,m) (mod m) を満たすxを計算する。
int mod_inverse(int a, int m) {
  int x, y;
  extgcd(a, m, x, y);
  return (m + x%m) % m;
}

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

  cin >> N;
  for (int i = 1; i <= N; ++i) cin >> A[i];


  fact[0] = 1;
  for (int i = 1; i <= N; ++i) {
    fact[i] = mod(fact[i-1]*i, MOD);
  }
  for (int i = 1; i <= N; ++i) {
    prob[i] = mod_inverse(i, MOD);
  }
  for (int i = 1; i <= N; ++i) {
    probs[i] = mod(probs[i-1]+prob[i], MOD);
  }

  ll ans = 0;
  for (int i = 1; i <= N; ++i) {
    ll t = mod(probs[i]+probs[N-i+1]-prob[1], MOD);
    ans = mod(ans+(t*A[i])%MOD, MOD);
  }

  ans = mod(ans*fact[N], MOD);
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 2944
/****************** 			***********************/
     /****************BSMRSTU*****************/
/***********BISMILLAHIR RAHMANIR RAHIM*************/
/*.................Mohammad Imran................*/
/*..................Dept Of CSE.................*/

#include<bits/stdc++.h>
#define ll long long
#define llu unsigned long long
#define pi acos(-1.0)
#define dd double
const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;
const int mod        = (int)1e9 + 7 ;
using namespace std;
int main(){
 	int N,cnt=0;
  	string str;
  	cin>>N;
  for(int i;i<N;i++){
    cin>>str;
    if(str=="Y")
      cnt++;
  }
  if(cnt>0)
    cout<<"Four"<<endl;
  else
    cout<<"Three"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    static ArrayList<Integer>[] list;
    static int[] parent;
    static int[] c;
    
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader(); 
        int N, Q; {int[] a = r.ii(); N = a[0]; Q = a[1];}
        c = new int[N+1];        
        parent = new int[N+1];
        list = new ArrayList[N+1];
        for(int i = 1; i <= N; i++)
            list[i] = new ArrayList<>();
            
        for(int i = 0; i < N-1; i++){
            int[] tmp = r.ii();
            int a = tmp[0];
            int b = tmp[1];
            list[a].add(b);
            list[b].add(a);
        }
        
        for(int i = 0; i < Q; i++){
            int[] tmp = r.ii();
            int p = tmp[0];
            int x = tmp[1];
            c[p] += x;
        }
        
        deleteRoot(1);

        StringBuilder sb = new StringBuilder();
        solve(1);
        for(int i = 1; i <= N; i++)
            sb.append(c[i]).append(" ");
        println(sb);
    }
    static void deleteRoot(int root){
        ArrayList<Integer> al = list[root];
        for(int i : al){            
            parent[i] = root;
            list[i].remove(list[i].indexOf(root));      
            deleteRoot(i);
        }
    }
    static void solve(int root){
        for(int i : list[root])
            c[i] += c[parent[i]];
        for(int i : list[root])
            solve(i);        
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 155180
import sys

N, K = map(int, sys.stdin.readline().split())
points = []
for _ in range(N):
    x, y = map(int, sys.stdin.readline().split())
    points.append((x, y))

area = float("inf")
x_sorted = sorted(points)
y_sorted = sorted(points, key = lambda x: x[1])
for i1 in range(N-1):
    for i2 in range(i1+1, N):
        for j1 in range(N-1):
            for j2 in range(j1+1, N):
                x_min = x_sorted[i1][0]
                x_max = x_sorted[i2][0]
                y_min = y_sorted[j1][1]
                y_max = y_sorted[j2][1]
                num = 0
                for i in range(N):
                    if x_min <= points[i][0] <= x_max and y_min <= points[i][1] <= y_max:
                        num += 1
                tmp_area = (x_max - x_min) * (y_max - y_min)
                if num >= K and tmp_area < area:
                    area = tmp_area
                
print(area)

Measured memory_bytes: 74756
#include <iostream>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  for(int i=0;i<c-a;i++)
  cout<<"R";
  for(int i=0;i<d-b;i++)
  cout<<"U";
  for(int i=0;i<c-a;i++)
  cout<<"L";
  for(int i=0;i<d-b;i++)
  cout<<"D";
  cout<<"D";
  for(int i=0;i<c-a+1;i++)
  cout<<"R";
  for(int i=0;i<d-b+1;i++)
  cout<<"U";
  cout<<"L";
  cout<<"U";
  for(int i=0;i<c-a+1;i++)
  cout<<"L";
  for(int i=0;i<d-b+1;i++)
  cout<<"D";
  cout<<"R";
  return 0;
  
  
  
  
  
}

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

int main() {
  int a,b;
  cin >> a >> b;
  int c[] = {1,3,1,2,1,2,1,1,2,1,2,1};
  
  if (c[a-1] == c[b-1])
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}

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

typedef long long ll;
ll n, ta[3], tb[3];
vector<ll> a[2], b[2];

ll f(ll p, ll q, ll r) {
	ll i, re = 0;
	if (r == a[p].size()) return q;
	if (r == a[p].size() - 1) return q / a[p][r] * b[p][r] + q % a[p][r];
	for (i = 0; i * a[p][r] <= q; i++) {
		re = max(re, f(p, q - i * a[p][r], r + 1) + i * b[p][r]);
	}
	return re;
}

int main()
{
	ll i;
	cin >> n;
    for (i = 0; i < 3; i++) scanf("%lld", &ta[i]);
    for (i = 0; i < 3; i++) scanf("%lld", &tb[i]);
	for (i = 0; i < 3; i++) {
		if (ta[i] < tb[i]) a[0].push_back(ta[i]), b[0].push_back(tb[i]);
		else if (ta[i] > tb[i]) a[1].push_back(tb[i]), b[1].push_back(ta[i]);
	}
    cout << f(1, f(0, n, 0), 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double lb;
const ll MOD=1;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
void IOS(){	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return ;}

ll dp[100005],n,u[100005];

ll f(int w){
	if(w>=n)return 0;
	if(dp[w]!=-1)return dp[w];
	return dp[w]=min(abs(u[w]-u[w+1])+f(w+1),abs(u[w]-u[w+2])+f(w+2));
}

int main(){
	memset(dp,-1,sizeof(dp));
	cin>>n;
	REP(i,n)cin>>u[i];
	u[n]=u[n-1];
	cout<<f(0);
	return 0;
}

Measured memory_bytes: 4096
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>

int testcase_ends() {
  int M;
  size_t T, P, R;
  scanf("%d %zu %zu %zu", &M, &T, &P, &R);
  if (M == 0 && T == 0 && P == 0 && R == 0) return 1;

  std::vector<std::vector<int>> a(T, std::vector<int>(P, -1));
  for (size_t i = 0; i < R; ++i) {
    int m, t, p, j;
    scanf("%d %d %d %d", &m, &t, &p, &j);
    --t, --p;
    if (a[t][p] >= 0) continue;
    if (j != 0) {
      --a[t][p];
      continue;
    }
    a[t][p] = -20 * (a[t][p]+1);
    a[t][p] += m;
  }

  std::vector<std::tuple<int, int, size_t>> res(T);
  for (size_t i = 0; i < T; ++i) {
    for (size_t j = 0; j < P; ++j) {
      if (a[i][j] < 0) continue;
      ++std::get<0>(res[i]);
      std::get<1>(res[i]) -= a[i][j];
    }
    std::get<2>(res[i]) = i+1;
  }
  std::sort(res.rbegin(), res.rend());
  for (size_t i = 0; i < T; ++i) {
    printf("%zu", std::get<2>(res[i]));
    if (i+1 == T) {
      putchar('\n');
    } else {
      int a0, p0;
      std::tie(a0, p0, std::ignore) = res[i];
      int a1, p1;
      std::tie(a1, p1, std::ignore) = res[i+1];
      if (std::make_pair(a0, p0) > std::make_pair(a1, p1)) {
        putchar(',');
      } else {
        putchar('=');
      }
    }
  }
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2748
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

bool isPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2){
    if (num % i == 0){
      return false;
    }
  }
  return true;
}

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

  string s;
  cin >> s;

  string ans = "";
  rep(i, 0, sz(s)){
    if(s[i] == '0') ans = ans + '0';
    else if(s[i] == '1') ans = ans + '1';
    else{
      if(sz(ans) == 0) continue;
      else ans.erase(ans.end()-1);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256