akhauriyash/Code-Regression huggingface dataset:
import bisect
import sys

lower_bound = bisect.bisect_left
upper_bound = bisect.bisect_right
INF = 0x3fffffff

n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(m)]

X = {-INF, INF}
Y = {-INF, INF}
for i in a:
    Y.add(i[2])
for i in b:
    X.add(i[0])

X = list(sorted(X))
Y = list(sorted(Y))
n = len(X) - 1
m = len(Y) - 1
wallx = [[False] * m for i in range(n)]
wally = [[False] * m for i in range(n)]

for x1, x2, y1 in a:
    x1 = lower_bound(X, x1)
    y1 = lower_bound(Y, y1)
    x2 = upper_bound(X, x2) - 1
    for i in range(x1, x2):
        wally[i][y1] = True

for x1, y1, y2 in b:
    x1 = lower_bound(X, x1)
    y1 = lower_bound(Y, y1)
    y2 = upper_bound(Y, y2) - 1
    for i in range(y1, y2):
        wallx[x1][i] = True

cow = [[False] * m for i in range(n)]
cx = upper_bound(X, 0) - 1
cy = upper_bound(Y, 0) - 1
cow[cx][cy] = True
q = [(cx, cy)]
ans = 0

while q:
    x, y = q.pop()
    if not x or not y:
        print("INF")
        sys.exit()
    ans += (X[x + 1] - X[x]) * (Y[y + 1] - Y[y])
    if x and not wallx[x][y] and not cow[x - 1][y]:
        cow[x - 1][y] = True
        q.append((x - 1, y))
    if y and not wally[x][y] and not cow[x][y - 1]:
        cow[x][y - 1] = True
        q.append((x, y - 1))
    if x + 1 < n and not wallx[x + 1][y] and not cow[x + 1][y]:
        cow[x + 1][y] = True
        q.append((x + 1, y))
    if y + 1 < m and not wally[x][y + 1] and not cow[x][y + 1]:
        cow[x][y + 1] = True
        q.append((x, y + 1))

print(ans)


Measured memory_bytes: 47140
#include<iostream>

using namespace std;

int main(){
	int x,y;
	while(cin >> x >> y){
		if(x == 0 && y == 0){
			break;
		}
		if(x > y){
			swap(x,y);	
		}
		cout << x << " " << y << endl;;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree< pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

Order_Set X;

const int mxn = 2e5+100;
const int Mod = 1e9+7;

int main()
{
    ios::sync_with_stdio(false);

    int n, k;
    cin>>n>>k;
    int arr[n+5];
    long long Ans = 0;
    for(int i=0 ; i<n ; i++) cin>>arr[i];
    sort(arr, arr+n, greater<int>());
    for(int i=0 ; i<n ; i++){
        if(k > i) continue;
        Ans+=arr[i];
    }
    cout<<Ans<<endl;

    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class Main {
	static List<List<Integer>> list;
	static int[] cnt;
	static int[] ans;
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int q = Integer.parseInt(sa[1]);
		list = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<>());
		}
		for (int i = 0; i < n - 1; i++) {
			sa = br.readLine().split(" ");
			int a = Integer.parseInt(sa[0]) - 1;
			int b = Integer.parseInt(sa[1]) - 1;
			list.get(a).add(b);
			list.get(b).add(a);
		}
		cnt = new int[n];
		for (int i = 0; i < q; i++) {
			sa = br.readLine().split(" ");
			int p = Integer.parseInt(sa[0]) - 1;
			int x = Integer.parseInt(sa[1]);
			cnt[p] += x;
		}
		br.close();

		ans = new int[n];
		dfs(0, -1, 0);

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < n; i++) {
			pw.println(ans[i]);
		}
		pw.flush();
	}

	static void dfs(int x, int p, int v) {
		v += cnt[x];
		ans[x] += v;
		for (int next : list.get(x)) {
			if (next != p) {
				dfs(next, x, v);
			}
		}
		v -= cnt[x];
	}
}


Measured memory_bytes: 133808
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int n,ansa,ansb,a[100000],i;
int main(){
cin>>n;
for(i=0;i<n;i++){
cin>>a[i];
ansa=max(ansa,a[i]);}
sort(a,a+n);
for(i=0;i<n;i++){
if(a[i]!=ansa)
{int x=ansa/2;
if(abs(ansb-x)>=abs(a[i]-x))
ansb=a[i];}}
cout<<ansa<<' '<<ansb;
system("pause");
return 0;
}

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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int c = 1; c < n; c++){
        int ab = n - c;
        int temp = 0;
        int rest = 0;
        for(int a = 1; a*a <= ab; a++){
            if(a*a == ab){
                rest = 1;
            }else if(ab % a == 0){
                temp += 1;
            }
        }
        ans += temp*2 + rest;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int mulMod(long long a, long long b) {
    a *= b;
    a %= mod;
    return (int)a;
}
int addMod(int a, int b) {
    long long c = a + b;
    if(c >= mod) {
        c -= mod;
    }
    return (int)c;
}
vector<int> readArray(int n){
    vector<int> arr(n);
    for(int i=0; i<n; i++) {
        cin>>arr[i];
    }
    return arr;
}
void printArray(vector<int> &arr) {
    for(int a: arr)
        cout<<a<<" ";
    cout<<endl;
}

int main() {

    string x;
    cin>>x;
  	int n = x.length();
    long long c=0,bc=0,abc=0;
    int multi=1;
    reverse(x.begin(),x.end());
    for(int i=0;i<n;i++) {
        if(x[i]=='A') {
            abc=(abc+bc)%mod;
        }
        if(x[i]=='B') {
            bc=(bc+c)%mod;
        }
        if(x[i]=='C') {
            c=(c+multi)%mod;
        }
        if(x[i]=='?') {
            abc=(abc*3LL)%mod;
            abc=(abc+bc)%mod;
            bc=(bc*3LL)%mod;
            bc=(bc+c)%mod;
            c=(c*3LL)%mod;
            c=(c+multi)%mod;
            multi=(multi*3LL)%mod;
        }
    }
    cout<<(abc%mod)<<endl;
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

vector<ll> G[MAX_V];
ll d[2][MAX_V];

void dfs(ll T, ll V, ll cost) {
	d[T][V] = cost;
	rep(i, 0, G[V].size()) {
		if(d[T][G[V][i]] != INF) continue;
		dfs(T, G[V][i], cost + 1);
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	cin >> N;
	rep(i, 0, N - 1) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	rep(i, 0, 2) rep(j, 0, N) d[i][j] = INF;

	dfs(0, 0, 0);
	dfs(1, N - 1, 0);
	ll f = 0, s = 0;
	rep(i, 0, N) {
		if(d[0][i] <= d[1][i]) f++;
		else s++;
	}
	if(f > s) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
}


Measured memory_bytes: 40832
#include <iostream>

using namespace std;

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    int b[m], a[n][m];
    int ans = 0;

    for (int i = 0; i < m; i++) cin >> b[i];

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

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

    cout << ans << endl;
}



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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N; ++i){
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());
    int alice = 0;
    for (int i = 0; i < N; i += 2)
    {
        alice += A[i];
    }
    int bob = 0;
    for (int i = 1; i < N; i += 2)
    {
        bob += A[i];
    }

    cout << alice - bob << endl;

    return 0;
}

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

using namespace std;

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

typedef long long LL;

template<typename Type>
inline bool chkmin(Type &x , const Type &y) { return x > y ? (x = y , 1) : 0; }
template<typename Type>
inline bool chkmax(Type &x , const Type &y) { return x < y ? (x = y , 1) : 0; }

template<typename Type>
inline Type read(Type &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c))
        x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c))
        (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}

const int N = 1000000 + 5;
const int KCZ = 924844033 , g = 5;

int n , k , S , vis[N];
int x , l , r[N] , lim(1) ;

LL Ans , fac[N] , inv[N];

void add(LL &x , const LL &y) { x += y ; if(x >= KCZ) x -= KCZ; }
void sub(LL &x , const LL &y) { x -= y ; if(x < 0) x += KCZ; }

LL A[N] , B[N];

LL mp(LL x , LL y = KCZ - 2)
{
    LL res = 1;
    while(y)
    {
        if(y & 1) res = res * x % KCZ;
        x = x * x % KCZ;
        y >>= 1;
    }
    return res;
}

void DFT(LL *A , int type)
{
    rep(i , 0 , lim-1) if(i < r[i]) swap(A[i] , A[r[i]]);
    for(int mid = 1 ; mid < lim ; mid <<= 1)
    {
        LL Wn = mp(g , (KCZ - 1) / (mid * 2));
        for(int R = mid << 1 , j = 0 ; j < lim ; j += R)
        {
            LL w = 1;
            for(int k = 0 ; k < mid ; k++ , w = w * Wn % KCZ)
            {
                LL x = A[j+k] , y = w * A[j+k + mid] % KCZ;
                A[j+k] = x + y , A[j+k + mid] = x - y + KCZ;
                A[j+k] %= KCZ , A[j+k + mid] %= KCZ;
            }
        }
    }
    if(type == -1)
    {
        reverse(A + 1 , A + lim);
        LL ginv = mp(lim);
        rep(i , 0 , lim-1) A[i] = A[i] * ginv % KCZ;
    }
}

int now , vA , vB , cA , cB;

void NTT()
{
    while(lim <= n + n)
        lim <<= 1 , l++;
    rep(i , 0 , lim - 1)
        r[i] = (r[i >> 1] >> 1) | ((i & 1) << (l - 1));
    DFT(A ,  1) , DFT(B , 1);
    rep(i , 0 , lim - 1)
        A[i] = mp(A[i] , cA) * mp(B[i] , cB) % KCZ;
    DFT(A , -1);
}

LL C(int n , int m)
{
    if(n < m) return 0;
    return fac[n] * inv[m] % KCZ * inv[n - m] % KCZ;
}

const int L = 1000000;

void init()
{
    fac[0] = 1;
    rep(i , 1 , L)
        fac[i] = fac[i - 1] * i % KCZ;
    inv[0] = 1;
    inv[L] = mp(fac[L]);
    per(i , L - 1 , 1)
        inv[i] = inv[i + 1] * (i + 1) % KCZ;
}

int main()
{
    read(n) , read(k) , init();
    rep(i , 1 , k)
    {
        if(vA == 0 || vA == (n - i) / k + 1)
            vA = (n - i) / k + 1 , cA += 2;
        else
            vB = (n - i) / k + 1 , cB += 2;
    }
    rep(i , 0 , vA) A[i] = C(vA - i , i);
    rep(i , 0 , vB) B[i] = C(vB - i , i);
    NTT();
    rep(i , 0 , n)
    {
        LL v = A[i] * fac[n - i] % KCZ;
        i & 1 ? sub(Ans , v) : add(Ans , v);
    }
    cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 22784
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

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

ans = 0
vi = h[0]

for i in range(n):
    if h[i] >= vi:
        ans += 1
        vi = h[i]
print(ans)



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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

long long gcd(long long a, long long b) {
    return b ? gcd(b, a % b) : a;
}

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

int n, m;
string s;

int main() {
    cin >> n >> m;
    Vl a(n);
    REP(i, n) cin >> a[i];
    REP(i, n) a[i] /= 2;

    ll x = 1;
    REP(i, n) x = lcm(x, a[i]);

    bool f = true;
    REP(i, n) {
        f &= x/a[i] % 2 == 1;
    }
    if (!f) std::cout << 0 << '\n';
    else std::cout << m/x - m/(2*x) << '\n';

    return 0;
}


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

int main() {
  long long n;
  cin >> n;
  
  vector<char> ans;
  while(n > 0) {
    char t = 'a' + (n - 1) % 26;
    ans.push_back(t);
    n = (n - (n - 1) % 26) / 26;
  }
  
  for (int i = ans.size()-1; i < ans.size(); i--) {
    cout << ans[i];
  }
  cout << endl;
  
  return 0;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<string>s(h);
    for(int i = 0;i < h;i++){
        cin >> s[i];
    }
    //上下左右の累積和をとる.

    int right[h][w],left[h][w];
    int up[h][w],down[h][w];

    //right & left
    for(int i = 0;i < h;i++){
        int rt= 0;
        int lt = 0;
        for(int j = 0;j < w;j++){
            if(s[i][j] != '#'){
                lt++;
            }else{
                lt = 0;
            }
            if(s[i][w-j-1] != '#'){
                rt++;
            }else{
                rt = 0;
            }
            left[i][j] = lt;
            right[i][j] = rt;
        }
    }
    // up& down
    for(int i = 0;i < w;i++){
        int ut = 0;
        int dt = 0;
        for(int j = 0;j < h;j++){
            if(s[j][i] != '#'){
                ut++;
            }else{
                ut = 0;
            }
            if(s[h-j-1][i] != '#'){
                dt++;
            }else{
                dt = 0;
            }
            down[j][i] = dt;
            up[j][i] = ut;
        }
    }

    int ans = 0;
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(s[i][j] == '#') continue;
            ans = max(ans,(up[i][j]+down[h-i-1][j]+right[i][w-j-1]+left[i][j]-3)); //重複している分を引く
        }
    }

    cout << ans << endl;



    
}

Measured memory_bytes: 66816
#include<cstdio>
int a[10005],s[10005];

int main()
{
	int n,m,t,c=0;
	scanf("%d%d%d",&n,&m,&t);
	for(int i=1;i<=t;i++)
	{
		scanf("%d",&a[i]);
		for(int j=1;j<=a[i];j++)
		{
			s[j+c]=i;
		}
		c+=a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(i%2==1)
		{
			for(int j=1;j<=m;j++) printf("%d ",s[j+(i-1)*m]);
			printf("\n");
		}
		else
		{
			for(int j=m;j>=1;j--) printf("%d ",s[j+(i-1)*m]);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;
using ll=long long;

#define PRI(n) cout << n <<endl;
#define PRI2(n, m) cout << n << " " << m << endl;
#define PRI3(n, m, o) cout << n << " " << m<< " " << o << endl;

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

#define FOR(i, t, n)  for(int i = t; i <= (int)n; ++i)
#define FORInv(i, t, n)  for(int i = t; i >= (int)n; --i)

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

bool isPrime(ll x) {
    if (x == 0)return 0;
    if (x == 1)return 0;
    if (x == 2)return 1;
    if (x % 2 == 0)return 0;
    FOR(i, 3, x - 1) {
        if (x % i == 0)return 0;
    }
    return 1;
}

ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) FORInv (j, min(i, r), 1)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}

struct edge {
    int to, cost;
    bool flag = false;
};
int N, M;
string S;
vector<edge> X[100010];
bool B[100010];
int D[100010];

int main() {
    cin >> N;
    vector<int> P;
    REP(i, N + 1)if (isPrime(i))P.push_back(i);
    FOR(i,2, N) {
        for (int p :P) {
            int tmp = i;
            while (tmp % p == 0) {
                tmp /= p;
                D[p]++;
            }
        }
    }
    ll sum = 1;
    REP(i,N+1)sum = (sum *(D[i]+1))%MOD;
    PRI(sum)
    return 0;

}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

char mother[5] = { 'a','i','u','e','o' };

int main() {
	char c;
	cin >> c;
	for (int i = 0; i < 5; i++) {
		if (mother[i] == c) {
			puts("vowel");
			return 0;
		}
	}
	puts("consonant");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
#define MOD (int)1e9+7
int dx4[]={1,0,-1,0};
int dy4[]={0,-1,0,1};
typedef long long int ll;
typedef unsigned long long int ull;
ll gcd(ll x,ll y){if(!y)return x;return gcd(y,x%y);}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
void swap(ll *x,ll *y){ll tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    int a[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            scanf("%d",&a[i][j]);
        }
    }
    int n;scanf("%d",&n);
    int b[20];for(int i=0;i<n;i++)scanf("%d",&b[i]);

    int flg[3][3]={};
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(b[i]==a[j][k]){
                    flg[j][k]++;
                    goto END;
                }
            }
        }
        END:;
    }/*
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            printf("%d ",flg[i][j]);
        }
        printf("\n");
    }*/

    for(int i=0;i<3;i++){
        if(flg[i][0]&&flg[i][1]&&flg[i][2]){
            printf("Yes\n");
            return 0;
        }
    }
    for(int i=0;i<3;i++){
        if(flg[0][i]&&flg[1][i]&&flg[2][i]){
            printf("Yes\n");
            return 0;
        }
    }
    if(flg[0][0]&&flg[1][1]&&flg[2][2]){
        printf("Yes\n");
        return 0;
    }
    if(flg[0][2]&&flg[1][1]&&flg[2][0]){
        printf("Yes\n");
        return 0;
    }
    printf("No\n");
}

Measured memory_bytes: 128
N,M = map(int, input().split())

A = [0 for _ in range(N)]
for _ in range(M):
  a,b = map(int, input().split())
  a,b = a-1, b-1
  A[a] += 1
  A[b] += 1
  
for a in A:
  if a%2 == 1:
    print("NO")
    exit(0)
print("YES")

Measured memory_bytes: 9944
#include <stdio.h>
int prime[10000000+10];
void makep(int n){prime[0]=prime[1]=1;for(int i=2;i*i<=n;i++)if(!prime[i])for(int j=i*i;j<=n;j+=i)prime[j]=1;}

int main(){
	makep(10000005);
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++)if(!prime[i]&&!prime[i+2])ans++;
	printf("%d\n",ans*2);
}



Measured memory_bytes: 40860
#include <stdio.h>

int main(void) {
	int k, n;
	long long c = 0;
	int p[100010] = {};

	scanf("%d", &n);

	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &p[i]);
	}

	for (int i = 1; i <= n; i++)
	{
		if (p[i] == i)
		{
			c++;
			if (p[i + 1] == i + 1)
			{
				i++;
			}
		}
	}
	printf("%lld\n", c);

	return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
#define INF (ll)1e15
ll N,A,B;
pll pp[101010];
ll dp[5050][10101],ans;
ll i, j;
ll aaa(const ll& a,const ll& b ){
    return a - 1 == b * 2 ? 0 : a - 1 < b * 2 ? B : A;
}

int main(){
    scanf("%lld%lld%lld", &N,&A,&B);
    fornum(i,0,N){
        ll p;
        scanf("%lld", &p);
        pp[i] = {p,i};
    }
    sort(pp, pp + N);
    fornum(i,0,N){
        ll minn = INF;
        fornum(j,0,N*2+1){
            if(j%2){
                dp[i + 1][j] = minn + aaa(j, pp[i].second);
                minn = min(dp[i][j],minn);

            }else{
                minn = min(dp[i][j],minn);
                dp[i + 1][j] = minn + aaa(j, pp[i].second);
            }
        }
    }
    ans = INF;
    fornum(i,0,N*2+1){
        ans = min(ans, dp[N][i]);
    }
    printf("%lld", ans);

    return 0;
}

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

typedef pair<int, int> pii;
int N, M;
vector<vector<pii> > adj;
vector<int> fir;
vector<vector<int> > Rmask;
vector<vector<int> > prec;
vector<int> cost;

vector<vector<int> > cc;
int dp(int u, int mask) {
    int &ret = cc[u][mask];
    if(ret != -1) return ret;

    if(mask == (1<<N) - 1) return u == N - 1? 0 : -1e9;

    ret = -1e9;
/*
    cout << u << endl;
    for(int i = 0; i < N; i++) {
        cout << ((mask & (1 << i))? 1 : 0);
    }
    cout << endl;
//*/
    if(mask & (1 << u)) {
        for(int i = 0; i < adj[u].size(); i++) {
            int v = adj[u][i].first;
            int d = adj[u][i].second;
            if(mask & (1<<v)) continue;

            ret = max(ret, d + dp(v, mask));
        }
        return ret;
    }
    else {
        for(int i = 0; i < Rmask[mask].size(); i++) {
            int mask2 = Rmask[mask][i];
            ret = max(ret, cost[mask2] + dp(u, mask ^ mask2));
        }
    }

    return ret;
}

int tot = 0;

int main() {
    scanf("%d %d", &N, &M);

    adj.resize(N);
    for(int i = 0; i < M; i++) {
        int u, v, w; scanf("%d %d %d", &u, &v, &w);
        u--; v--;
        adj[u].push_back(pii(v, w));
        adj[v].push_back(pii(u, w));

        tot += w;
    }

    fir.resize((1<<N));
    for(int i = 1; i < (1<<N); i++) {
        for(int j = 0; j < N; j++) {
            if(i & (1<<j)) {
                fir[i] = j;
                break;
            }
        }
    }

    prec = vector<vector<int> >(N, vector<int>((1<<N), -1));
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < (1<<N); j++) {
            if(j & (1<<N)) continue;

            prec[i][j] = 0;
            for(int a = 0; a < adj[i].size(); a++) {
                int x = adj[i][a].first;
                int d = adj[i][a].second;

                if(j & (1<<x)) {
                    prec[i][j] += d;
                }
            }
        }
    }

    Rmask.resize((1<<N));
    for(int i = 0; i < (1<<N); i++) {
        vector<int> rem;
        int cnt = 0;
        for(int j = 0; j < N; j++) {
            if(i & (1<<j)) continue;
            rem.push_back(j);
            cnt++;
        }
        for(int j = 0; j < (1<<cnt); j++) {
            if(j==0) Rmask[i].push_back(0);
            else Rmask[i].push_back(Rmask[i][ j - (1<<fir[j]) ] + (1<<rem[ fir[j] ]));
        }
    }

    cost.resize((1<<N));
    for(int i = 0; i < (1<<N); i++) {
        cost[i] = 0;
        for(int j = 0; j < N; j++) {
            if(!(i & (1 << j))) continue;
            for(int k = 0; k < adj[j].size(); k++) {
                int x = adj[j][k].first;
                int d = adj[j][k].second;

                if(!(i & (1 << x))) continue;

                cost[i] += d;
            }
        }
        cost[i] /=2;
    }

    cc = vector<vector<int> >(N, vector<int>((1<<N), -1));
    printf("%d", tot - dp(0, 0));
}


Measured memory_bytes: 63868
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

template<int index>
bool comp(tuple<ll, ll, ll, ll> a, tuple<ll, ll, ll, ll> b) {
	return get<index>(a) < get<index>(b);
}

int vector_finder(std::vector<ll> vec, ll number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return index;
	}
	else { // 発見できなかったとき
		return 0;
	}
}


int len(int x) {
	return (int)log10(x) + 1;
}


int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

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

	vector<int> tmp({ A + B,A - B,A * B });

	cout << vmax(tmp) << endl;


ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}
/*

*/




Measured memory_bytes: 504
#include <stdio.h>

int main(void){
	int N;
	scanf("%d", &N);

	int H[N];

	for (int i = 0; i < N; ++i)
	{
		scanf("%d", &H[i]);
	}

	int sikiti=H[0];
	int canSee=1;

	for (int i = 0; i < N; ++i)
	{
		if(i>0){
			if(sikiti<=H[i]){
				canSee++;
				sikiti=H[i];
			}
		}
	}

	printf("%d\n", canSee);
}

Measured memory_bytes: 128
import math

N, D = input().split()
count = 0

for i in range(int(N)):
	x, y = input().split()
	x = int(x)
	y = int(y)
	d = x**2 + y**2
	d = math.sqrt(d)
	if d <= int(D):
		count +=1
	

print(count)

Measured memory_bytes: 9196
using System;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int mod = n % 10;
            string output = "";

            if(mod == 3)
            {
                output = "bon";
            }else if(mod <= 1 || mod == 6 || mod == 8)
            {
                output = "pon";
            }else{
                output = "hon";
            }
            Console.WriteLine(output);
        }
    }
    //2回位使ったら追加する
    class MyLibrary
    {
        public static int[] ToIntArray(string[] stringArray)
        {
            int length = stringArray.Length;
            int[] intArray = new int[length];
            for (int i = 0; i < length; i++)
            {
                intArray[i] = int.Parse(stringArray[i]);
            }
            return intArray;
        }
    }
}


Measured memory_bytes: 27532
#include<stdio.h>
#include<stdlib.h>
  
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
  
Node root;
  
void insert(int k){  
  Node a = root;
  Node b = NIL;
  Node c;
  
  c = malloc(sizeof(struct node));
  c->key = k;
  c->left = NIL;
  c->right = NIL;
  
  while(a != NIL){
    b = a;
    if(c->key < a->key){
      a = a->left;
    }
    else a = a->right;
  }
  
  c->parent = b;
  if(b == NIL) {
    root = c;  
  }
  else if(c->key < b->key){
    b->left = c;
  }
  else b->right = c;
}
  
  
void inorder(Node n){
  if(n->left != NIL){
    inorder(n->left);
  }
  printf(" %d",n->key);
  if(n->right != NIL){
    inorder(n->right);
  }
  
}
void preorder(Node n){
  printf(" %d",n->key);
  if(n->left!= NIL){
    preorder(n->left);
  }
  if(n->right!= NIL){
    preorder(n->right);
  }
    
}
  
int main(){
  int n,i,x;
  char rom[20];
  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ){
    scanf("%s", rom);
    if ( rom[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( rom[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

 

Measured memory_bytes: 24036
#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; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

int main() {
  int64_t N, K;
  cin >> N >> K;
  vector<int64_t>H(N,0);
  REP(i,N) cin >> H[i];

  sort(ALL(H));
  REP(i,K) H.pop_back();
  int64_t sum = 0;
  REP(i,N-K) sum += H[i];

  cout << sum << endl;

}

Measured memory_bytes: 1792
n = gets.to_i
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i

m = [a,b,c,d,e].min

if n % m == 0
  puts n / m + 4
else
  puts n / m + 5
end

Measured memory_bytes: 1788
n = int(input())
h = tuple(map(int, input().split()))

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

Measured memory_bytes: 14108
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    void print(vector<int> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    void print(vector<vector<int> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};

//--global--//



//----------//

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    ll a, b;
    cin >> a >> b;
    ll ans = 0;
    if(abs(a - b) > 10){
        ll tmp = 0;
        ll a2 = a;
        ll b2 = b;
        if(a2 %2 == 1){ 
            ans ^= a2;
            a2++;
        }
        if(b2 %2 == 0){ 
            ans ^= b2;
            b2--;
        }
        tmp = (b2+1 - a2) / 2 % 2;
        // cout << a2 << ", " << b2 << endl;
        // cout << tmp << endl;
        ans ^= tmp;
    }
    else{
        for(ll i=a; i<=b; i++){
            ans ^= i;
        }
    }

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


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

int main() {
  ll s,c; cin >> s >> c;
  ll a = min(s, c / 2);
  ll b = (c - (a*2)) / 4;
  cout << a+b << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
const int maxn=200050;
const int mod=1e9+7;
int n,cnt=0;
struct nod {
	int x,v,v1;
};
nod a[maxn];
queue<int>q;
int l[maxn],r[maxn],dp[maxn];
inline bool cmp(nod x,nod y){
	return x.v<y.v;
}
inline bool cmp1(nod x,nod y){
	return x.x<y.x;
}
inline void ini(){
	int ma=0,mi=99999999;
	for(register int i=1;i<=n;i++){
		if(ma<a[i].v1)ma=a[i].v1;
		if(mi>a[n+1-i].v1)mi=a[n+1-i].v1;
		r[i]=ma,l[n+1-i]=mi;
	}
}
inline void calc(){
	int sum=1;
	l[0]=1,dp[0]=1,q.push(0),n++;
	l[n]=r[n]=n;
	for(register int i=1;i<=n;i++){
		while(!q.empty()&&l[i]>r[q.front()]+1){
			sum-=dp[q.front()],sum=(sum+mod)%mod,q.pop();
		}
		dp[i]=sum;
		sum=(sum+dp[i])%mod;
		q.push(i);
	}
	printf("%d\n",dp[n]);
}
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++)
		scanf("%d%d",&a[i].x,&a[i].v);
	sort(a+1,a+n+1,cmp);
	for(register int i=1;i<=n;i++)
		a[i].v1=(a[i].v==a[i-1].v)?a[i-1].v1:++cnt;
	sort(a+1,a+n+1,cmp1);
	ini();
	calc();
}

Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int main(){
    int n;
    string s;
    cin >> n >> s;
    int count = 0;
    for(int i = 0;i < n - 2;i++){
        string t = s.substr(i,3);
        if(t == "ABC") count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++)
    cin >> S[i];
  vector<long> a(26);
  for (int i = 0; i < N; i++)
    a[S[i][0] - 'A']++;
  long ans = 0;
  ans += a['M' - 'A'] * a['A' - 'A'] * a['R' - 'A'];
  ans += a['M' - 'A'] * a['A' - 'A'] * a['C' - 'A'];
  ans += a['M' - 'A'] * a['A' - 'A'] * a['H' - 'A'];
  ans += a['M' - 'A'] * a['R' - 'A'] * a['C' - 'A'];
  ans += a['M' - 'A'] * a['R' - 'A'] * a['H' - 'A'];
  ans += a['M' - 'A'] * a['C' - 'A'] * a['H' - 'A'];
  ans += a['A' - 'A'] * a['R' - 'A'] * a['C' - 'A'];
  ans += a['A' - 'A'] * a['R' - 'A'] * a['H' - 'A'];
  ans += a['A' - 'A'] * a['C' - 'A'] * a['H' - 'A'];
  ans += a['R' - 'A'] * a['C' - 'A'] * a['H' - 'A'];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6144
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,x,i,flag=1;
    scanf("%d %d",&a,&b);
    if(b==100)
        x=a*1000+b;
    else if(b>=10)
        x=a*100+b;
    else
        x=a*10+b;
    for(i=1;i<=1000;i++)
    {
        if(i*i==x)
            {printf("Yes");
        flag=0;
        break;}
    }
    if(flag==1)
        printf("No");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   ll a, b, k;
   cin >> a >> b >> k;
   if (a >= k){
      cout << a-k << endl;
      cout << b << endl;
   }
   else if (a+b >= k){
      cout << 0 << endl;
      cout << a+b-k << endl;
   }
   else{
      cout << 0 << endl;
      cout << 0 << endl;
   }
   
}

Measured memory_bytes: 3628
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

void rsortr_u32(void *base, const int count){
	uint32_t *a=base;
	uint32_t *b=malloc(count*sizeof(uint32_t));
	int c[0x100];
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(0<<3))&0xFF]++; } for(int i=0xFE; i>=0; i--) c[i]+=c[i+1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(0<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(1<<3))&0xFF]++; } for(int i=0xFE; i>=0; i--) c[i]+=c[i+1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(1<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(2<<3))&0xFF]++; } for(int i=0xFE; i>=0; i--) c[i]+=c[i+1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(2<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(3<<3))&0xFF]++; } for(int i=0xFE; i>=0; i--) c[i]+=c[i+1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(3<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	free(b);
}
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }

int d[100000];

int bs(int k, int l, int r){
	while(l<=r){
		int m=(l+r)/2;
		if(d[m]<k) r=m-1; else l=m+1;
	}
	return l;
}

int main(void){
	int n=nextint();
	for(int i=0; i<n; i++){
		d[i]=-1;
		int a=nextint();
		int j=bs(a,0,i-1);
		d[j]=a;
	}
	int ans=bs(0,0,n-1);
	printf("%d\n", ans);
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main{

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

		int[] N= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};



		System.out.println(N[K-1]);
	}
}

Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    string S;
    cin >> S;
    ll cnt = 0;
    for (char c : S) {
        if (c == 'x') cnt++;
    }

    if (cnt < 8) cout << "YES\n";
    else cout << "NO\n";
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define ll long long
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}


ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  string S;
  cin >> S;
  stack<char> st;
  for(int i = 0; i < S.size(); i++){
    if(S[i] == 'B'){
      if(!st.empty()) st.pop();
    }
    else st.push(S[i]);
  }
  string ans = "";
  while(!st.empty()){
    ans += st.top();
    st.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}


Measured memory_bytes: 256
function Main(input) {
	var ST = input.split("\n");
	var S = ST[0].split("");
	var T = ST[1].split("");
	
	var cnt = 0;
	for (var i = 0; i < S.length; i++){
		if (S[i] === T[i]) {
			cnt++;
		}
	}
	
	console.log(cnt);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vvi g(n);
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	if (k & 1) {
		queue<int> q;
		vi d(n);
		int ans = INF;
		REP(i, n) {
			REP(j, g[i].size()) {
				q.push(g[i][j]);
				q.push(i);
				REP(k, n)d[k] = INF;
				d[i] = 0;
				d[g[i][j]] = 0;
				while (!q.empty()) {
					int p = q.front(); q.pop();
					REP(k, g[p].size()) {
						if (chmin(d[g[p][k]], d[p] + 1)) {
							q.push(g[p][k]);
						}
					}
				}
				int cnt = 0;
				REP(i, n) if (d[i] > k / 2)cnt++;
				chmin(ans, cnt);
			}
		}
		cout << ans << endl;
	}
	else {
		queue<int> q;
		vi d(n);
		int ans = INF;
		REP(i, n) {

			q.push(i);
			REP(k, n)d[k] = INF;
			d[i] = 0;
			while (!q.empty()) {
				int p = q.front(); q.pop();
				REP(k, g[p].size()) {
					if (chmin(d[g[p][k]], d[p] + 1)) {
						q.push(g[p][k]);
					}
				}
			}
			int cnt = 0;
			REP(i, n) if (d[i] > k / 2)cnt++;
			chmin(ans, cnt);

		}
		cout << ans << endl;
	}
}

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

int main() {
  char c,d;
  cin>>c;
  d=c+1;
  cout<<d<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
int main() {
    int n, l;
    scanf("%d%d",&n,&l);
    int ice[n],dp[n];
    pair<int, int> row[n];
    for (int i=0; i<n; i++) {
        scanf("%d",&ice[i]);
        row[i].first=ice[i];
        row[i].second=i;
    }
    sort(row, row+n);
    int res=0;
    for (int i=n-1; i>=0; i--) {
        int k=row[i].second, k1=row[i].second-1, k2=row[i].second+1;
        dp[k]=0;
        if (k1>=0&&ice[k1]==0) dp[k]=dp[k1];
        if (k2<n&&ice[k2]==0) dp[k]=max(dp[k], dp[k2]);
        dp[k]+=l-ice[k];
        ice[k]=0;
        res=max(res,dp[k]);
    }
    printf("%d\n",res);
}

Measured memory_bytes: 2276
#include <stdio.h>
long long p = 998244353;
long long ans;
long long n, s;
long long a[3000];
long long dp[3001];
int main() {
	scanf("%lld%lld", &n, &s);
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
	}
	dp[0] = 1;
	for (long long i = 0; i < n; i++) {
		for (long long j = s; j > 0; j--) {
			if (j + a[i] <= s) {
				dp[j + a[i]] += dp[j];
			}
		}
		dp[a[i]] += i + 1;
		for (int i = 0; i <= s; i++)dp[i] %= p;
		ans += dp[s];
		ans %= p;
	}
	printf("%lld\n", ans);
}

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

int main() {
    int a, b,c,e,d;
    d=0;
    cin >>e;
    a=e/100;
    c=(e-100*a)%10;
    b=(e-100*a-c)/10;
    if(a==1){
    	d++;
    }
    if(b==1){
    	d++;
    }
    if(c==1){
    	d++;
    }
    cout << d <<endl;
 }


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

typedef int64_t s64;

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int m = ri();
	std::multiset<int> hen[n];
	for (int i = 0; i < m; i++) {
		int a = ri() - 1;
		int b = ri() - 1;
		hen[a].insert(b);
		hen[b].insert(a);
	}
	bool res = true;
	for (int i = 0; i < n; i++) {
		while (hen[i].size()) {
			int head = *hen[i].begin();
			hen[i].erase(hen[i].find(head));
			hen[head].erase(hen[head].find(i));
			while (head != i) {
				int prev_head = head;
				if (!hen[prev_head].size()) {
					res = false;
					break;
				}
				head = *hen[prev_head].begin();
				hen[prev_head].erase(hen[prev_head].find(head));
				hen[head].erase(hen[head].find(prev_head));
			}
			if (!res) break;
		}
		if (!res) break;
	}
	std::cout << (res ? "YES" : "NO") << std::endl;
	return 0;
}


Measured memory_bytes: 14336
#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; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();


int main(){
  int h,n;cin>>h>>n;
  int sum=0;
  REP(i,n){
    int a; cin>>a;
    sum+=a;
  }
  if (sum>=h)
  cout <<"Yes"<< endl;
  else 
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a,b = inpl()
p = inpl()
d = defaultdict(int)
for i in p:
    if i <= a:
        d[0] += 1
    elif a < i <= b:
        d[1] += 1
    else:
        d[2] += 1
print(min(d[0],d[1],d[2]))

Measured memory_bytes: 38512