akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
smaller = 0
diffs = []
for i in range(N):
    if A[i] < B[i]:
        ans += 1
        smaller += B[i] - A[i]
    elif A[i] >= B[i]:
        diffs.append(A[i] - B[i])

if ans == 0:
    print(ans)
    exit()

diffs.sort(reverse=True)
for d in diffs:
    if smaller <= d:
        ans += 1
        smaller -= d
        break
    else:
        ans += 1
        smaller -= d
else:
    print(-1)
    exit()

print(ans)

Measured memory_bytes: 81328
// *********************************************************************************
// *                        MURTAZA MUSTAFA KHUMUSI                                *
// *                        NIT-DGP,CSE - 2019-2023                                *
// *********************************************************************************

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007;
#define loop(i, a, n) for (int i = a; i < n; i++)
#define loop1(i, b, n) for (int i = b; i <= n; i++)
#define loopit(a) for (auto it = a.begin(); it != a.end(); it++)
#define ms(a, b) memset(a, b, sizeof(a))
#define pb(a) push_back(a)
#define MP make_pair
#define pi pair<int, int>
#define ff first
#define ss second
#define bloop(i, a, b) for (int i = a; i > b; i--)
#define bloop1(i, a, b) for (int i = a; i >= b; i--)
#define PQ priority_queue<int> pq;
#define MPQ priority_queue<pi, vector<int>, greater<pi>> mpq;
#define io                        \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);
const int maxm = 100001;

bool cmp(pi &l, pi &r)
{
    if (l.ff == r.ff)
        return l.ss < r.ss;

    return l.ff < r.ff;
}

void solve()
{
    int h, w, m;
    cin >> h >> w >> m;
    int ans = 0;

    vector<int> row, col;

    vector<int> adj[h + 1];

    int mr = INT_MIN, mc = INT_MIN;

    int r[h + 1], c[w + 1];
    ms(r,0);
    ms(c,0);

    loop(i, 0, m)
    {
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        r[a]++;
        c[b]++;
    }

    loop1(i, 1, h)
    {
        mr = max(mr, r[i]);
    }
    loop1(i, 1, h)
    {
        if (mr == r[i])
            row.pb(i);
    }
    loop1(i, 1, w)
    {
        mc = max(mc, c[i]);
    }
    loop1(i, 1, w)
    {
        if (mc == c[i])
            col.pb(i);
    }

    ans = mr + mc;
    int dif = 1;

    loop(i, 0, row.size())
    {
        int cur = row[i];
        int ch = 0;
        for (const auto &v : adj[cur])
        {
            if (binary_search(col.begin(), col.end(), v))
                ch++;
            if (ch == col.size())
                break;
        }

        if (ch != col.size())
        {
            dif = 0;
            break;
        }
    }
    cout << ans - dif << "\n";
}
int main()
{
    io;

    solve();

    return 0;
}


Measured memory_bytes: 26024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;

int main(){
  int n;
  cin >> n;
  queue<ll> q;
  rep1(i,9) q.push(i);
  int cnt = 0;
  while(1){
    cnt ++;
    ll x = q.front();
    q.pop();
    if(cnt == n){
      cout << x << endl;
      return 0;
    }
    int m = x%10;
    if(m>0) q.push(10*x + m - 1);
    q.push(10*x + m);
    if(m<9) q.push(10*x + m + 1);
  }
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] a = sc.next().split("");
        String[] b = sc.next().split("");
        if (a.length > b.length) {
            System.out.println("GREATER");
            return;
        }
        if (a.length < b.length) {
            System.out.println("LESS");
            return;
        }
        for (int i = 0; i < a.length; i++) {
            if (Integer.parseInt(a[i]) > Integer.parseInt(b[i])) {
                System.out.println("GREATER");
                return;
            }
            if (Integer.parseInt(a[i]) < Integer.parseInt(b[i])) {
                System.out.println("LESS");
                return;
            }
        }
        System.out.println("EQUAL");
    }

}


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

using namespace std;
typedef long long ll;
ll gys(ll x, ll y){
    return y==0?x:(x>y?gys(y,x%y):gys(x,y%x));
}

int main()
{
    ll a,b;
    cin >> a >>b;
    cout << a/gys(a,b)*b;
    return 0;
}


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

typedef long long LL;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb push_back

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int mod = 1e9 + 7;
const int maxn = 1e7 + 10;
const int oo = 0x7fffffff;

template<typename T> T read() {
	T n(0), f(1);
	char ch = getchar();
	for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
	for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

LL N, A, B;
int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif

    cin >> N >> A >> B; 
    if(N == 1 && A != B) return puts("0"), 0;
    if(A > B) return puts("0"), 0;

    printf("%lld\n", ((N-1)*B + A) - ((N-1)*A + B) + 1);

    return 0;
}


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

using namespace std;

int n;
int a[100002];
int b[100002];
long long ans;

int main()
{
    scanf("%d",&n);
    for(int i = 1;i <= n + 1;i++)
        scanf("%d",&a[i]);
    for(int i = 1;i <= n ;i++)
        scanf("%d",&b[i]);
    b[n + 1] = 0;
    for(int i = 1;i <= n + 1;i++)
    {
        if(b[i] > a[i])
        {
            ans += a[i];
            b[i] -= a[i];
            if(b[i] >= a[i + 1])
            {
                ans += a[i + 1];
                a[i + 1] = 0;
            }
            else
            {
                ans += b[i];
                a[i + 1] -= b[i];
            }
        }
        else
            ans += b[i];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-06-20 16:51:27
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 3e3 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 998244353; // 1e9 + 9;

ll A , B , C , D , dp[MAXN][MAXN];

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

    cin >> A >> B >> C >> D;
    dp[A][B] = 1;
    for(ll i = A ; i <= C ; i++){
        for(ll j = B ; j <= D ; j++){
            if(i == A && j == B)    continue;
            dp[i][j] = (dp[i - 1][j] * j + dp[i][j - 1] * i - dp[i - 1][j - 1] * (i - 1) * (j - 1)) % MOD + MOD;
            dp[i][j] %= MOD;
        }
    }
    cout << dp[C][D] << endl;

    return 0;
}
/*

*/


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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

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

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

template<typename T>
struct edge {
    int src, to;
    T cost;
};

template<typename T>
using Graph = vector<vector<edge<T>>>;

using State = string::const_iterator;

int parseHash(State &begin, int n) {
    if (*begin == '[') {
        ++begin;
        char op = *begin;
        ++begin;
        int left = parseHash(begin, n), right = parseHash(begin, n);
        assert(*begin == ']');
        ++begin;
        if (op == '+') {
            return left | right;
        }
        if (op == '*') {
            return left & right;
        }
        if (op == '^') {
            return left ^ right;
        }
    }
    if (*begin == 'a') {
        ++begin;
        return n / 1000 % 10;
    }
    if (*begin == 'b') {
        ++begin;
        return n / 100 % 10;
    }
    if (*begin == 'c') {
        ++begin;
        return n / 10 % 10;
    }
    if (*begin == 'd') {
        ++begin;
        return n / 1 % 10;
    }
}

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

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    for (;;) {
        string s;
        cin >> s;
        if (s == ".") break;

        map<int, int> cnt;
        REP(i, 10000) {
            State begin = s.begin();
            ++cnt[parseHash(begin, i)];
        }

        State begin = s.begin();
        int p;
        cin >> p;
        int hash = parseHash(begin, p);

        cout << hash << ' ' << cnt[hash] << endl;
    }

    return 0;
}




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

#define ll long long
#define ld long double
#define ull unsigned long long

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"

using namespace std;

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

    int A, B;
    cin >> A >> B;

    cout << (A + B) % 24 << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<ctime>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<bitset>
#define ll long long 
#define ull unsigned long long 
#define mem(a) memset(a,0,sizeof(a)) 
#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define EXIT exit(0)
#define all(a) (a).begin(),(a).end()
//loop 
#define For(i,a,b) for(int i=(a);i<(b);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define cFor(i,a,b) for(int i=(a);i>(b);i--)
#define cFOR(i,a,b) for(int i=(a);i>=(b);i--)
#define lFor(i,a,b) for(ll i=(a);i<(b);i++)
#define lFOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define lcFor(i,a,b) for(ll i=(a);i>(b);i--)
#define lcFOR(i,a,b) for(ll i=(a);i>=(b);i--)
//debug
#define dbg(a) cout<<#a<<"="<<a<<endl
#define inthis cout<<"--------this\n"
//operator
#define pb push_back
#define ins insert
#define era erase
#define fin find 
//pair
#define pr pair
#define mkp(a,b) make_pair(a,b)
#define fi first
#define se second
//vector
#define vec vector
#define vi vector<int>
#define vii vector<vector<int>>
//map
#define mp map
////map int
#define mpii map<int,int>
#define mpib map<int,bool>
#define mpic map<int,char>
#define mpis map<int,string>
#define mpil map<int,long long>
////map long long 
#define mpll map<long long,long long>
#define mplb map<long long,bool>
#define mplc map<long long,bool>
#define mpls map<long long,string>
#define mpli map<long long,int>
////map char
#define mpci map<char,int>
#define mpcb map<char,bool>
#define mpcl map<char,long long>
////map string
#define mpsi map<string,int>
#define mpsb map<string,bool>
#define mpsl map<string,long long>
//iterator
#define ivec(a) vector<a>::iterator
#define iset(a) set<a>::iterator 
#define imp(a,b) map<a,b>::iterator

using namespace std;
/*
const int maxsize=
struct edge{
	int nod,nxt;
			
}e[maxsize<<1];
int nume=0,pa[maxsize],head[maxsize];
void add(int u,int v){
	e[++nume].nod=v;
	e[nume].nxt=head[u];
	head[u]=nume;
}
void init(){
	
}
bool vis[maxsize];
void bfs(){
	
}
void dfs(){

}
*/

int main(){
	fio;
	int n,r;
	cin>>n>>r;
	if(n>=10)
		cout<<r<<endl;
	else
		cout<<r+100*(10-n)<<endl;	
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){

	int A, B;

	scanf("%d %d", &A, &B);

	if (A> 12) {
		printf ("%d\n",  B);
	}
	else if (A>=6 && A <= 12) {
		printf ("%d\n",  B/2);
	}
	else {
		printf ("0\n");
	}
	return 0;
}

Measured memory_bytes: 256
import sys
x,y=map(int,input().split())

if (x+y)%3 != 0:
    print(0)
    sys.exit()

tmp=(x+y)//3
x=x-tmp
y=y-tmp
sosu=10**9+7
if x<0 or y<0:
    print(0)
    sys.exit()

def combination(x,y):
    n=x+y
    r=min(x,y)
    upper=1
    lower=1
    for i in range(r):
        upper=(upper*(n-i))%sosu
        lower=(lower*(i+1))%sosu
    return (upper * pow(lower,sosu-2,sosu))%sosu
print(combination(x,y))

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)

	fmt.Println(strings.ToLower(toAlphabet(n)))
}

func toAlphabet(self int) string {
	n := self % 26
	if n == 0 {
		n = 26
	}
	s := string(n+64)

	if self == n {
		return s
	}
	return toAlphabet((self - n ) / 26) + s
}


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

const int A = 1000005;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> c(A);
    
    for (int i = 0; i < n; i++ ) {
        cin >> a[i];
        c[a[i]]++;
    }
    int pairwise = true;
    for (int i = 2; i < A; i++) {
        int cnt = 0;
        for (int j = i; j < A; j += i) {
            cnt += c[j];
            if (cnt > 1) {
                pairwise = false;
                break;
            }
        }
    }
    if (pairwise) {
        cout << "pairwise coprime" << endl;
        return 0;
    } else {
        int g = 0;
        for (int i = 0; i < n; i++) {
            g = gcd(g, a[i]);
            if (g == 1) {
                cout << "setwise coprime" << "\n";
                return 0;
            }
        }
    }
    cout << "not coprime" << "\n";
    return 0;
}

Measured memory_bytes: 11056
#include <iostream>

using namespace std;
typedef long long ll;

int main(void) {
	int num, i, ans = 0, k;
	ll a, b;
	cin >> num >> k >> a;
	for (i = 1; i < num; i++) {
		scanf("%lld", &b);
		if (a + b >= k) {
			ans = i;
			break;
		}
		a = b;
	}
	if (ans == 0) {
		printf("Impossible\n");
	}
	else {
		printf("Possible\n");
		for (i = 1; i < ans; i++)
			printf("%d\n", i);
		for (i = num - 1; i >= ans; i--)
			printf("%d\n", i);
	}
	return 0;
}

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

int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c;

    if(a>b){
        d = a;
        a = b;
        b = d ;     
    }

    if(b>c){
        e = b;
        b = c;
        c = e;
    }

    if(a>b){
        f = a;
        a = b;
        b = f;
    }



    cout << a <<" " <<b << " " << c << endl;


    return 0;

}


Measured memory_bytes: 3068
a, b, n = map(int, input().split())


def fl(n):
    global a, b
    return (a * n) // b


def fr(n):
    global a, b
    return a * (n // b)


def f(n):
    return fl(n)-fr(n)


target = n - ((n+1) % b)

print(f(target) if target > 0 else f(n))


Measured memory_bytes: 9176
import re

S = input()
m = re.search(r"(?P<year>\d{4})/(?P<month>\d{2})/(?P<date>\d{2})", S)
year = int(m.group("year"))
month = int(m.group("month"))
date = int(m.group("date"))

if year < 2019:
    print("Heisei")
elif year > 2019:
    print("TBD")
elif month < 4:
    print("Heisei")
elif month > 4:
    print("TBD")
elif date <= 30:
    print("Heisei")
else:
    print("TBD")


Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll sq(ll x) {
    double y = double(x);
    double s = sqrt(y);
    ll t = (ll)s;

    if(t * t == x) {
        return t;
    }
    else if((t + 1) * (t + 1) == x) {
        return t + 1;
    }
    else {
        return -1;
    }
}

int main() {

    //cout << sq(24) << endl;
    ll a, b, c;
    cin >> a >> b >> c;

    if(c - a - b < 0) {
        cout << "No" << endl;
    }
    else {
        if(4 * a * b < (c - a - b) * (c - a - b)) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
/*
ID: Barry Wang
LANG: C++11
TASK: 
*/
#include <bits/stdc++.h>
using namespace std;
/*---define tricks---*/
#define ALL(v) v.begin(),v.end()
#define UN(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())
#define FILL(x,y) memset(x,y,sizeof(x))
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define revsort(b,e) sort(b,e),reverse(b,e)
#define X first
#define Y second
#define Chtolly return 0
/*---define types---*/
typedef long long ll;
typedef list<int> li;
typedef queue<int> qi;
typedef deque<int> dqi;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef unsigned int uint;
/*---define variables---*/
const int inf=(1<<29);
int n,k;
int p[200005];
double ans; 
double sum[200005];
/*---define function---*/

inline double S(int x){
	return double(x*(x+1)/2);
}

/*---main code---*/
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;++i){
		cin>>p[i];
		sum[i]=sum[i-1]+S(p[i])/p[i];
		if(i>=k){
			ans=max(ans,sum[i]-sum[i-k]);
		}
	}
	cout<<fixed<<setprecision(12)<<ans<<'\n';
	return 0;
}


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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> p(n);
    for (size_t i = 0; i < n; i++) cin >> p[i];

    for (size_t i = 0; i < n-1; i++) {
        if (p[i] >= p[i+1]) break;
        if (i == n-2) {
            cout << "YES" << endl;
            return 0;
        }
    }

    bool ok = false;
    for (size_t i = 0; i < n; i++) {
        for (size_t j = i+1; j < n; j++) {
            swap(p[i], p[j]);
            for (size_t k = 0; k < n-1; k++) {
                if (p[k] >= p[k+1]) break;
                if (k == n-2) ok = true;
            }
            swap(p[i], p[j]);
        }
    }

    if (ok) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

struct UnionFind{
    vector<int> par;
    UnionFind(int32 n){
        par = vector<int>(n, -1);
    }

    int root(int x){
        if(par[x] < 0)return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y)return;
        par[x] += par[y];
        par[y] = x;
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }

    int deg(int x){
        return -par[root(x)];
    }
};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,m,k;
    cin >> n >> m >> k;
    UnionFind uf = UnionFind(n);
    vector<int32> a(m), b(m);
    REP(i,m){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        uf.unite(a[i],b[i]);
    }
    vector<int32> ans(n);
    REP(i,n){
        ans[i] = uf.deg(i)-1;
    }
    REP(i,k){
        int32 c,d;
        cin >> c >> d;
        c--;d--;
        if(uf.same(c,d)){
            ans[c]--;
            ans[d]--;
        }
    }
    REP(i,m){
        ans[a[i]]--;
        ans[b[i]]--;
    }
    REP(i,n){
        if(i != 0)cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3968
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);

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


    return 0;
}


Measured memory_bytes: 888
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

/*考えを書くスペース
  累乗和で解く

  ・総和を求める
  ・取り消すところの一つ先を見る
*/
//main.cpp----------------------------
#define max_n 100000

void solve();
int dfs(int,int);

int n;
int a[2][101];

int main() {
  cin >> n;
  rep(i, 2) {
    rep(j, n) cin >> a[i][j];
  }

  solve();

  return 0;
}

void solve() {

  cout << dfs(0, 0) << endl;
}

int dfs(int x, int y) {

  if(x<0||x>=2||y<0||y>=n) return 0;

  int res = max(dfs(x+1, y)+a[x][y], dfs(x, y+1)+a[x][y]);

  return res;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long min = Math.min(a, b);
        long max = Math.max(a, b);
        sc.close();
        if ((min - max) % 2 == 0) {
            System.out.println((max - min) / 2);
            return;
        }
        // 奇数の場合
        long right = n - max;
        long left = min - 1;
        if (right > left) {
            min = 1;
            max -= left;
            long ans = left + (max / 2);
            System.out.println(ans);
        } else {
            max = n;
            min += right;
            long ans = right + 1 + ((max - (min + 1)) / 2);
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
 
// maximum
// long long int cnt = 10;
// printf("%ld", cnt * cnt * cnt * cnt * cnt * cnt * cnt * cnt * cnt * cnt);
// 1000000000

//  for(long long test = 100; test < 140; test++) cout << " index :" << test << " " << test * test * test * test * test << endl;
// plus index :119 23863536599
// plus index :120 24883200000
// 1019663401
// 1000000000
int main(){
    long long X;
    cin >> X;
    for( long long i = -120; i < 120; i++) {
        for( long long j = - 120; j < 120; j++) {
            if( i * i * i * i * i  - j * j * j * j * j == X) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0; 
}

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

int main() {
  long long A, B, K; cin >> A >> B >> K;
  if(A <= K) {
    cout << 0 << " " << max(0LL, B-(K-A)) << endl;
  } else {
    cout << A - K << " " << B << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,w;
vector<long long>wt;
vector<long long>v;
long long mem[100001][101];
long long dp(long long w,long long i)
{
        if(w==0)
        return 0;
        if(w<0)
        return -10000000000;
        if(i==n)
        return 0;
        if(mem[w][i]!=-1)
        return mem[w][i];
        mem[w][i]=max(v[i]+dp(w-wt[i],i+1),dp(w,i+1));
        return mem[w][i];
}
int main()
{
    memset(mem,-1,sizeof(mem));
    cin>>n>>w;
    long long i;
    wt.resize(n);
    v.resize(n);
    for(i=0;i<n;i++)
    cin>>wt[i]>>v[i];
    mem[w][0]=dp(w,0);
    cout<<mem[w][0]<<endl;
    return 0;
}


Measured memory_bytes: 79104
#include<stdio.h>
int main(void){
	
	int money,i,n,k,num;
	
	money = 100000;
	
	scanf("%d",&n);
	
	for( i=0;i<n;i++ ){
		
		money *= 1.05;
		num = money /1000;
		k = money % 1000;
		
		if( k > 0 ){
			
			money = (num * 1000) + 1000;
			
		}
		
	}
	
	printf("%d\n",money);
	
	return 0;
}

Measured memory_bytes: 592
from collections import Counter
from copy import deepcopy
N, M = map(int, input().split())
A = [list(map(int, input().split()))[::-1] for _ in range(N)]
ok = N+1
ng = 0
def check(med, B):
    NG = set()
    for _ in range(N):
        CS = Counter([b[-1] for b in B])
        flag = True
        for k, v in CS.items():
            if v > med:
                NG.add(k)
                flag = False
        if flag:
            return True
        if len(NG) == M:
            return False
        for b in B:
            for _ in range(M):
                if b[-1] not in NG:
                    break
                b.pop()
while abs(ok - ng) > 1:
    B = deepcopy(A)
    med = (ok + ng)//2
    if check(med, B):
        ok = med
    else:
        ng = med

print(ok)


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

typedef long long ll;

int main() {
    set<int> a,b;
    int n, m;
    cin >> n;
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        a.insert(x);
    }
    cin >> m;
    for(int i=0; i<m; i++){
        int x;
        cin >> x;
        b.insert(x);
    }
    
    vector<int> c;
    set_intersection(a.begin(), a.end(), b.begin(), b.end(), back_inserter(c));
    
    for(int i=0; i<c.size(); i++){
        cout << c[i] << endl;
    }
    
}



Measured memory_bytes: 21932
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! p {
    ($($x:expr),*) => {
        $(println!("{:?}", $x);)*
    };
}
macro_rules! pr {
    ($($x:expr),*) => {
        $(println!("{}", $x);)*
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn main() {
    input! {
        s:String,
        t:String,
        mut a:i32,
        mut b:i32,
        u:String
    }
    if s == u {
        a -= 1;
    } else if t == u {
        b -= 1;
    } else {
        unreachable!()
    }
    p!(a,b);
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	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;
}

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

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll N;
	std::cin >> N;

	ll ans = 0;
	repeq(i, 1, N) {
		ll A;
		std::cin >> A;
		if (i & 1 && A & 1) {
			ans++;
		}
	}

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


Measured memory_bytes: 3584
var fs = require("fs");
var buffer = fs.readFileSync(0); // STDIN_FILENO = 0
var lines = buffer.toString().split('\n');

function solve(lines) {
  var N = lines[0];
  var lineNo = 1;
  var dict = {};
  var word;
  var max = 1;
  for(var i = 0; i < N; i++){
    word = lines[lineNo++]
    if(dict.hasOwnProperty(word)){
      dict[word]++;
      if(dict[word] > max) {
        max = dict[word];
      }
    }else{
      dict[word] = 1;
    }
  }
  var words = Object.keys(dict);
  var key;
  var results = [];
  for(var i = 0; i < words.length; i++){
    key = words[i];
    if(dict[key] == max){
      results.push(key)
    }
  }
  results.sort();
  for(var i = 0; i < results.length; i++){
    console.log(results[i])
  }
}

solve(lines);



Measured memory_bytes: 90180
#Half and Half
A,B,C,X,Y=map(int,input().split())
if X>=Y:
    more=X
    more_price=A
    less=Y
else:
    more=Y
    more_price=B
    less=X
if more_price>=C*2:
    price=C*2*more
else:
    if A+B>=2*C:
            price=C*2*less+(more-less)*more_price
        
    else:
        price=A*X+B*Y
print(price)



Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
import itertools


def solve(N: int, x: "List[int]", y: "List[int]"):
    indices = [i for i in range(N)]
    permutations = itertools.permutations(indices)

    distances = []
    for permutation in permutations:
        total_distance = 0
        for i in range(0, N - 1):
            f, t = permutation[i : i + 2]
            distance = ((x[t] - x[f]) ** 2 + (y[t] - y[f]) ** 2) ** 0.5
            total_distance += distance
        distances.append(total_distance)
    result = sum(distances) / len(distances)

    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, x, y)


if __name__ == "__main__":
    main()


Measured memory_bytes: 4404
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

import qualified Data.List as L

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  h <- getInt
  solve h

solve :: Int -> IO ()
solve h = do
  let n = 1
      a = solve' n h
      r = sum [2^(i-1) | i <- [1 .. a]]
  print r

solve' :: Int -> Int -> Int
solve' n h = do
  let x = h `div` 2
    in if h > 1 then solve' (n+1) x else n

Measured memory_bytes: 380
# F_2 ^nの基底クラス
class F2n:
    # LISTを受け取ってbasisを生成する.(掃き出し法)
    def __init__(self,LIST):
        self.basis = []
        for ele in LIST:
            for vec in self.basis:
                ele = min(ele, vec^ele)
            if ele:
                self.basis.append(ele)
    # basisに要素eleを追加できるなら追加しTrueを返す. 追加できないなら何もせず,Falseを返す.
    def Add(self, ele):
        for vec in self.basis:
            ele = min(ele, ele^vec)
        if ele:
            self.basis.append(ele)
            return True
        else:
            return False

def solve():
    n=int(input())
    a=list(map(int,input().split()))[::-1]
    s=input()[::-1]
    h=F2n([])
    for i in range(n):
        if h.Add(a[i]):
            if s[i]=="1":
                print(1)
                return
    print(0)
t=int(input())
for _ in range(t):
    solve()

Measured memory_bytes: 9224
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func Factorial(N int) (F, Finv, Inv []int) {
  F = make([]int, N + 1)
  Finv = make([]int, N + 1)
  Inv = make([]int, N + 1)
  F[0] = 1
  F[1] = 1
  Finv[0] = 1
  Finv[1] = 1
  Inv[0] = 1
  Inv[1] = 1
  for i := 2; i < N + 1; i++ {
    F[i] = F[i - 1] * i % p
    Inv[i] = p - Inv[p % i] * (p / i) % p
    Finv[i] = Finv[i - 1] * Inv[i] % p
  }
  return
}

const p = 1000000007

func main() {
  N := NextInt()
  X := NextIntVec()
  F, Finv, _ := Factorial(N)
  D := make([]int, N)
  for i := 1; i < N; i++ {
    D[N - 1 - i] = X[N - 1] - X[N - 1 - i]
  }
  E := 0
  for i, d := range D {
    E += ((d * F[i] % p) * Finv[i + 1]) % p
    E %= p
  }
  Write(E * F[N - 1] % p)
  Output()
}

Measured memory_bytes: 7680
N = int(input())

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def factorization(n):
    if (n == 1):
        return []

    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

#print(factorization(N))

list_a = factorization(N)
count = 0
for i in range(len(list_a)):
    num = list_a[i][1]
    cal = 1
    while(num > 0):
        
        num -= cal
        cal += 1
        if(num < 0) :
            break
        
        count += 1

        #print(num,count)

print(count)

        


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

int N;

void dfs( string s, char cm )
{
	if( s.size() == N ) {
		cout << s << endl;
	}
	else {
		for( char c = 'a'; c <= cm; c++ ) {
			char cc = cm;
			if( c == cm ) cc = cm + 1;
			dfs( s + c, cc );
		}
	}
}

int main()
{
	cin >> N;

	dfs( "", 'a' );

}


Measured memory_bytes: 1536
n = int(input())
p = list(map(int, input().split()))
ps = sorted(p)

c = 0
ans = 'YES'
for i in range(0, len(p)):
  if p[i] != ps[i]:
    c += 1
    if c > 2:
      ans = 'NO'
      break

print(ans)


Measured memory_bytes: 38384
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

def solve(N):
    dp = [0] * (len(N) + 1)

    for i, e in enumerate(N):
        if int(e) + dp[i] >= 6:
            dp[i] = 10 - (int(e) + dp[i])
            dp[i+1] += 1
        elif int(e) + dp[i] == 5 and i < len(N)-1 and int(N[i+1]) >= 5:
            dp[i] = 5
            dp[i+1] += 1
        else:
            dp[i] += int(e)
    return dp

def digit_sum(n):
    tmp = 0
    while n:
        tmp += n % 10
        n //= 10
    return tmp

def greedy(N):
    ans = INF
    bestp = None
    for p in itertools.product(range(10), repeat=len(N)+1):
        n = 0
        for i in range(len(p)):
            n += p[i] * (10 ** i)
        intN = 0
        for i in range(len(N)):
            intN += int(N[i]) * (10 ** i)
        if n >= intN:
            if ans > digit_sum(n) + digit_sum(n - intN):
                ans = digit_sum(n) + digit_sum(n - intN)
                bestp = p
    return ans, bestp

# def main():
#     it = 1000
#     for N in range(1, it+1):
#         tmp = list(str(N))[::-1]
#         dp = solve(tmp)

#         ans1, (ans2, p) = sum(dp), greedy(tmp)
#         if ans1 != ans2:
#             print(N, dp, p, ans1, ans2)


def main():
    N = SL()[::-1]
    dp = [0] * (len(N) + 1)

    for i, e in enumerate(N):
        if int(e) + dp[i] >= 6:
            dp[i] = 10 - (int(e) + dp[i])
            dp[i+1] += 1
        elif int(e) + dp[i] == 5 and i < len(N)-1 and int(N[i+1]) >= 5:
            dp[i] = 5
            dp[i+1] += 1
        else:
            dp[i] += int(e)
    print(sum(dp))

if __name__ == '__main__':
    main()

Measured memory_bytes: 142796
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  st s;
  ci(s);
  st a = "";
  rep(i, sz(s)){
    if(s.at(i) == '0'){
      a += '0';
    }
    else if(s.at(i) == '1'){
      a += '1';
    }
    else{
      if(sz(a) != 0){
        a.erase(sz(a) - 1);
      }
    }  
  }
  co(a);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  int x[m],y[m];
  for(int i=0;i<m;i++){
    cin>>x[i]>>y[i];
    x[i]--;
    y[i]--;
  }
  int ko[n];
  fill(ko,ko+n,1);
  bool red[n];
  fill(red,red+n,false);
  red[0]=true;
  for(int i=0;i<m;i++){
    if(ko[x[i]]==1&&red[x[i]]){
      red[x[i]]=false;
      red[y[i]]=true;
      ko[x[i]]--;
      ko[y[i]]++;
    }
    else if(ko[x[i]]>1&&red[x[i]]){
      red[y[i]]=true;
      ko[x[i]]--;
      ko[y[i]]++;
    }
    else{
      ko[x[i]]--;
      ko[y[i]]++;
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(red[i])ans++;
  }
  cout<<ans;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int N;
  cin >> N;
  vector<int> P(N), Q(N), A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> P.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> Q.at(i);
  }
  for (int i = 0; i < N; i++) {
    A.at(i) = i + 1;
  }
  for (int i = 0; i < N; i++) {
    B.at(i) = i + 1;
  }
  int a = 1;
  int b = 1;

  do {
    if (P == A) {
      break;
    }
    else {
      a++;
    }
  } while (next_permutation(A.begin(), A.end()));

  do {
    if (Q == B) {
      break;
    }
    else {
      b++;
    }
  } while (next_permutation(B.begin(), B.end()));

  cout << max(a - b, b - a) << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		list.add(1);
		for(int i = 6; i<=n; i*=6) list.add(i);
		for(int i = 9; i <= n; i *= 9) list.add(i);
		Collections.sort(list);
		Collections.reverse(list);
		System.out.println(count(n));
	}

	static Map<Integer, Integer> map = new HashMap<>();
	static List<Integer> list = new ArrayList<>();
	public static int count(int n) {
		if(map.containsKey(n)) return map.get(n);
		if(n == 0) return 0;
		int min = n;
		for(int i : list.parallelStream().filter(i -> i <= n).collect(Collectors.toList())) {
			int count = 1;
			count += count(n-i);
			if(min > count) min = count;
		}

		map.put(n, min);
		return min;
	}
}

Measured memory_bytes: 105644
S = input()
flag = True
if S[0] != 'A':
    flag = False
elif 'C' not in S[2:len(S)-1]:
    flag = False
s2 = S.replace('C', '', 1)
if 'C' in s2:
    flag = False
    
if flag:
    s2 = s2.replace('A', '', 1)
    if s2.islower():
        flag = True
    else:
        flag = False
if flag:
    print('AC')
else:
    print('WA')



Measured memory_bytes: 3060
import math
import itertools
import statistics
#import numpy as np
import collections

#n = int(input())
#a, b, c, d = list(map(int, input().split()))
n = int(input())
m = 0
max_idx = -1
for i in range(1, n+1):
    n = i
    count = 0
    while n==n//1:
        n /= 2
        count += 1
    
    if count >= m:
        m = count
        max_idx = i
    #print(count)


print(max_idx)
    

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

int N,M,K;
int a[300];
int b[300][300];
int cnt[300];

int s[200000],t[200000];

int A[300];
int B[300][300];
bool check(int x){
  for(int i=0;i<M;i++){
    A[i]=a[i];
  }
  for(int i=0;i<N;i++){
    cnt[i]=0;
    for(int j=0;j<M;j++){
      B[i][j]=b[i][j];
      cnt[i]+=b[i][j];
    }
  }
  
  for(int i=0;i<x;i++){
    int p=s[i],q=t[i];
    A[q]--;
    if(A[q]<0)return false;
    
    B[p][q]--;
    cnt[p]--;
    if(cnt[p]==0){
      for(int j=0;j<M;j++)
        A[j]+=b[p][j];
    }
  }
  
  bool update=true;
  while(update){
    update=false;
    for(int i=0;i<N;i++){
      if(cnt[i]==0)continue;
      bool flg=true;
      for(int j=0;j<M;j++)
        if(A[j]<B[i][j])flg=false;
      if(!flg)continue;
      
      cnt[i]=0;
      for(int j=0;j<M;j++)
        A[j]+=(b[i][j]-B[i][j]);
      update=true;

    }
  }
  
  for(int i=0;i<N;i++){
    if(cnt[i]>0)return false;
    assert(cnt[i]==0);
  }
  return true;
}

int main(){
  scanf("%d %d %d",&N,&M,&K);
  for(int i=0;i<M;i++)scanf("%d",&a[i]);
  for(int i=0;i<N;i++)
    for(int j=0;j<M;j++)
      scanf("%d",&b[i][j]);

  for(int i=0;i<K;i++){
    scanf("%d %d",&s[i],&t[i]);
    s[i]--;
    t[i]--;
  }
  
  int left=0,right=K,mid;
  while(left<right){
    mid=(left+right)/2;
    if(check(mid))left=mid+1;
    else right=mid;
  }
  
  if(check(K))left=-1;
  printf("%d\n",left);
  return 0;
}

Measured memory_bytes: 5456
#include <bits/stdc++.h>
using namespace std;
long long dp[200][200005];
int main()
{
    long long w,n,a[200005],i,j,k,b[200005],c[200005];
    cin>>n>>w;
    for(i=0;i<n;i++){
        cin>>a[i]>>b[i];
        
    }
    for (i = 0; i <= n; i++) 
   { 
       for (j = 0; j <= w; j++) 
       { 
           if (i==0 || j==0) 
               dp[i][j] = 0; 
           else if (a[i-1] <= j) {
                dp[i][j] = max(b[i-1] + dp[i-1][j-a[i-1]],  dp[i-1][j]); 
           }
           else
                 dp[i][j] = dp[i-1][j]; 
       
       }
   } 
    cout<<dp[n][w];
    
}


Measured memory_bytes: 159232