akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <ctime>

using namespace std;

#define LOCAL 0
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1& arg1){
    cerr << name << ": " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1& arg1, Args&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " /";
    __f(comma + 1, args...);
}

template <class T> bool mini(T& a, T b) { return a > b ? (a = b, 1) : 0; }
template <class T> bool maxi(T& a, T b) { return a < b ? (a = b, 1) : 0; }

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int INF = 1e9 + 7;

int main() {
#if LOCAL
    freopen("CP.inp", "r", stdin);
//    freopen("CP.out", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a, b; cin >> a >> b;
    cout << max(0, a - 2 * b) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_T = 100010;
 
int main() {
    ll n, C;
    cin >> n >> C;
    
    vvl v(C, vl(MAX_T));  // v[i][j] : チャンネルiで時刻jに番組があるなら1
    rep(loop, n) {
        ll s, t, c;
        cin >> s >> t >> c;
        s--;  c--;
        v[c][s]++;
        v[c][t]--;
    }
    
    rep(i, C) {
        rep(j, MAX_T-1) {
            v[i][j+1] += v[i][j];
        }
    }
 
    ll ans = 0;
    rep(j, MAX_T) {
        ll cnt = 0;
        rep(i, C) {
            if(v[i][j]) {
                cnt++;
            }
        }
        chmax(ans, cnt);
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 24704
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
int main()
{
    int n,m,size;
    double heikin,sum,hensatotal,test,hensa;
    while(true){
    std::vector<int> list={0};
    hensatotal=0;
    sum = 0;
    std::cin >> n;
    if(n==0)break;
    for(int a=0;a<n;a++){
        std::cin >> m;
        list.push_back(m);
        //list[a]=m;
    }
    size = list.size()-1;
    for (int i = 0; i < size+1; i++){
        sum =(sum+list[i])*1.000000000;
    }
//   std::cout << sum << "   " << size<< std::endl;
    heikin=sum/size;
    for (int z = 1; z < size+1; z++){
        test = (list[z]-heikin)*(list[z]-heikin);
//        std::cout << list[z] << "-" << heikin << "   ";
        hensatotal=hensatotal+test;
//        std::cout << hensatotal << std::endl;

    }
    hensa=hensatotal/size;
    hensa=sqrt(hensa);
//    std::cout << std::endl;
//    std::cout << hensatotal << std::endl;
//    std::cout << hensa << std::endl;
    printf("%.8f\n",hensa);
    list.clear();
    list.shrink_to_fit();
    }
    return 0;
}

Measured memory_bytes: 3260
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

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

int main()
{
    int a, b, c, t;
    cin >> a >> b;
    t = b;
    while (t)
    {
        t /= 10;
        a *= 10;
    }
    c = a + b;
    for (int i = 4; i < 317; i++)
    {
        if (c == i * i)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

const ll INF = 1001001001001;

int main() {
  ll n;
  cin >> n;
  ll ans = INF;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) ans = min(ans, i + n / i - 2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize(3,"Ofast","inline")
// #pragma GCC optimize(2)
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <list>
#include <cstdlib>
#include <bitset>
#include <assert.h>
#include <time.h>
#include <iomanip>
// #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
// char buf[(1 << 21) + 1], * p1 = buf, * p2 = buf;
// #define int long long
#define lowbit(x) (x & (-x))
#define lson root << 1, l, mid
#define rson root << 1 | 1, mid + 1, r
#define pb push_back
typedef unsigned long long ull;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> VI;
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define SZ(x) ((int)((x).size()))
#define bug puts("BUG")
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-6;
template <class T>
inline void read(T &x)
{
    int sign = 1;char c = getchar();x = 0;
    while (c > '9' || c < '0'){if (c == '-')sign = -1;c = getchar();}
    while (c >= '0' && c <= '9'){x = x * 10 + c - '0';c = getchar();}
    x *= sign;
}
#ifdef LOCAL
    FILE* _INPUT=freopen("input.txt", "r", stdin);
    // FILE* _OUTPUT=freopen("output.txt", "w", stdout);
#endif
using namespace std;
const int maxn = 2e5 + 10;
const int DEG = 64;
ll des[maxn][DEG];
int main()
{
    ll n, v, k;
    read(n), read(k);
    for (int i = 1; i <= n; ++i)
    {
        read(des[i][0]);
    }
    for (int i = 1; i < DEG; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            des[j][i] = des[des[j][i - 1]][i - 1];
        }
    }
    int cur = 1;
    for (int i = 0; k; k >>= 1, ++i)
    {
        if (k & 1)
            cur = des[cur][i];
    }
    printf("%lld\n",cur);
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int a,b;

signed main() {
    cin >> a >> b;
    if (a%b == 0) cout << -1 << endl;
    else cout << a*(b-1) << endl;
}












Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

int main() {
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  if(a == 0) {
    cout << 1 << endl;
  }
  if(b == 0) {
    cout << 2 << endl;
  }
  if(c == 0) {
    cout << 3 << endl;
  }
  if(d == 0) {
    cout << 4 << endl;
  }
  if(e == 0) {
    cout << 5 << endl;
  }
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int r;

int main(void) {
  // Here your code !
  scanf("%d", &r);

  printf("%d", 3 * r * r);
  
  return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  string S;
  cin >> S;
  vector<pair<int,int> > V;
  pair<int,int> LR;
  LR.first=1;
  LR.second=1;
  for(int i=0;i<N-1;i++){
    if(S[i]==S[i+1]){
      LR.first+=1;
    }else {
      V.push_back(LR);
      LR.first=1;
      LR.second*=-1;
    }
  }
  K++;
  V.push_back(LR);
  long long int sum=-1;
  for(vector<pair<int,int> >::iterator e=V.begin();e!=V.end();e++){
    if(K>0){
      sum+=e->first;
      if (e->second==1){
        K--;
      }
    } else {
      if (e->first>1){
        sum+=e->first-1;
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 1528
from collections import*
import sys


class UnionFind(object):
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return


input = sys.stdin.readline
n, k, l = map(int, input().split())

ro_cl = UnionFind(n)
ra_cl = UnionFind(n)
d = defaultdict(int)

# =================================================================

# なぜかスライスを使うとエラーになる。原因不明。
# w = [list(map(int, input().split())) for i in range(k+l)]
# ro = w[:k]
# ra = w[l:]
# for p, q in ro:
#     ro_cl.union(p-1, q-1)
# for p, q in ra:
#     ra_cl.union(p-1, q-1)

# =================================================================

for i in range(k):
    p, q = map(int, input().split())
    ro_cl.union(p-1, q-1)
for i in range(l):
    p, q = map(int, input().split())
    ra_cl.union(p-1, q-1)

# =================================================================

for i in range(n):
    d[(ro_cl.find(i), ra_cl.find(i))] += 1
print(*[d[(ro_cl.find(i), ra_cl.find(i))]for i in range(n)])

Measured memory_bytes: 108124
use std::io::Read;
use std::i32;
use std::char;

fn match_i(s: &Vec<char>, i: i32) -> bool {
  let mut p = 0;
  for j in 0..3 {
    let d = i / (10 as i32).pow((2-j) as u32) % 10;
    if let Some(q) = s[p..].iter().position(|c| *c == char::from_digit(d as u32, 10).unwrap()) {
      p = p + q + 1;
    } else {
      return false;
    }
  }
  true
}

fn main() {
  let mut buf = String::new();
  std::io::stdin().read_to_string(&mut buf).unwrap();
  let mut iter = buf.split_whitespace();
  let n: usize = iter.next().unwrap().parse().unwrap();
  let s: Vec<char> = iter.next().unwrap().chars().collect::<Vec<_>>();
  
  let ans = (0..1000).filter(|i| match_i(&s, *i)).count();

  println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
// #include <vector>
// #include <algorithm>
// #include <numeric>
// #include <queue>
// #include <cmath>
// #include <set>
// #include <map>
// #include <iomanip>

// #define MOD 1000000007
// #define INF 1000000001

using namespace std;
// typedef unsigned long long ull;
typedef long long ll;

void p_() {
    cout << "\n";
}
template<class Head, class... Body>
void p_(Head head, Body... body) {
    cout << head << ",";
    p_(body...);
}


int main(int argc, char const *argv[]) {
    string S;
    cin >> S;
    int l;
    for (l = S.length()-1; l >= 0; --l) {
        if (l % 2 != 0) continue;
        string s = S.substr(0, l);
        // cout << s << endl;
        if (s.substr(0, l/2) == s.substr(l/2, l/2)) {
            break;
        }
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;const int M=1<<21;vector<int>x[M];long long d[M],n,m,a,b,s,t,q,w,i,V[M],W[M],S;queue<int>Q;void B(int P){memset(d,1,M);d[P]=0;Q.push(P);while(Q.size()){w=Q.front();Q.pop();for(i=0;i<x[w].size();i++){if(d[x[w][i]]>M){d[x[w][i]]=d[w]+1;Q.push(x[w][i]);}}}}main(){cin>>n>>m>>s>>t;for(i=0;i<m;i++){cin>>a>>b;x[a].push_back(b);x[b].push_back(a);}B(s);q=d[t];for(i=1;i<=n;i++)if(d[i]<M)V[d[i]]++;B(t);for(i=1;i<=n;i++)if(d[i]<M)W[d[i]]++;for(i=0;i<q;i++)S+=V[i]*W[q-i-2];cout<<S<<endl;}

Measured memory_bytes: 58324
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        String[] s = new String[n];
        for(int i = 0; i < n; i++){
            s[i] = sc.next();
        }
        Arrays.sort(s);
        StringBuilder sd = new StringBuilder();
        for(String v: s){
            sd.append(v);
        }
        System.out.println(sd.toString());
    }
}

Measured memory_bytes: 22100
#include <iostream>
#include <algorithm>

void print(int* A, int n)
{
	std::cout << A[0];
	for (int i=1; i<n; i++) std::cout << " " << A[i];
	std::cout << std::endl;
}

int main()
{
	int n; std::cin >> n;
	
	int* A = new int[n];
	std::string buf;
	for (int i=0; i<n; i++) std::cin >> A[i];
	
	int* B = new int[n];
	for (int i=0; i<n; i++) B[i] = A[i];

	if (std::prev_permutation(A, A+n)) print(A, n);
	print(B, n);
	if (std::next_permutation(B, B+n)) print(B, n);
	
	delete[] A;
	delete[] B;
	
	return 0;
}



Measured memory_bytes: 3108
S = input()
N = len(S)+1
A = [0]*N

for i in range(N-1):
  if S[i] == '<':
    A[i+1] = A[i]+1
    
for i in range(N-2, -1, -1):
  if S[i] == '>':
    A[i] = max(A[i], A[i+1]+1)
    
print(sum(A))

Measured memory_bytes: 23336
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
bool can[8][8];
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		can[u][v] = can[v][u] = 1;
	}
	int perm[8];
	int ans = 0;
	for (int i = 0; i < N; i++) perm[i] = i;
	do {
		bool ok = 1;
		for (int i = 0; i + 1 < N; i++) {
			if (!can[perm[i]][perm[i + 1]]) {
				ok = 0;
				break;
			}
		}
		if (ok) ans++;
	} while (next_permutation(perm + 1, perm + N));
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>

std::pair<int, int> hope[1001][1001];

int main() {
	int n, k;
	std::cin >> n >> k;

	for (int i = 0; i < n; ++i) {
		int x, y;
		char c;
		std::cin >> x >> y >> c;

		if ((c == 'W') == (x % (k * 2) < k == y % (k * 2) < k))
			++hope[x % k + 1][y % k + 1].first;
		else
			++hope[x % k + 1][y % k + 1].second;
	}

	for (int i = 1; i <= k; ++i) {
		for (int j = 1; j <= k; ++j) {
			hope[i][j].first += hope[i - 1][j].first + hope[i][j - 1].first - hope[i - 1][j - 1].first;
			hope[i][j].second += hope[i - 1][j].second + hope[i][j - 1].second - hope[i - 1][j - 1].second;
		}
	}

	auto getVal = [&](bool isWhite, int ax, int ay, int bx, int by) {
		if (bx < ax || by < ay)
			return 0;

		if (isWhite)
			return hope[bx][by].first - hope[bx][ay - 1].first - hope[ax - 1][by].first + hope[ax - 1][ay - 1].first;
		else
			return hope[bx][by].second - hope[bx][ay - 1].second - hope[ax - 1][by].second + hope[ax - 1][ay - 1].second;
	};

	int ans = 0;
	for (int i = 1; i <= k; ++i) {
		for (int j = 1; j <= k; ++j) {
			int a = getVal(true, 1, 1, i - 1, j - 1) + getVal(true, i, j, k, k) + getVal(false, 1, j, i - 1, k) + getVal(false, i, 1, k, j - 1);
			int b = getVal(false, 1, 1, i - 1, j - 1) + getVal(false, i, j, k, k) + getVal(true, 1, j, i - 1, k) + getVal(true, i, 1, k, j - 1);

			if (a > ans)
				ans = a;
			if (b > ans)
				ans = b;
		}
	}

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

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define rep(X,Y) for(int X=0;X<(Y); ++X)

using namespace std;

typedef long long ll;

int main(){
  ll r,w,c,d;
  while(cin>>r>>w>>c>>d, r){
    int re=0;
    while(r<w*c) r+=d, ++re;
    cout<<re<<endl;
  }
  return 0;
}

Measured memory_bytes: 3088
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n; cin>>n; 
    int res[n+1];
    for (int i=1;i<=n;i++){
        cin>>res[i];
    }
    sort(res+1,res+n+1); 
    if (res[n/2]==res[(n/2)+1]) cout << 0 << endl;
    else cout << (res[n/2+1]-res[n/2]) << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4340
import math

A, B, H, M = map(int, input().split())
minute = H * 60 + M
hour_rad = 0.5 * minute
min_rad = 6 * M
if abs(hour_rad - min_rad) > 180:
    rad = 360 - abs(hour_rad - min_rad)
else:
    rad = abs(hour_rad - min_rad)

answer = math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(rad)))
print(answer)

Measured memory_bytes: 9448
#include<bits/stdc++.h>
using namespace std;
string s;
int n, q;
char a[200010], b[200010];
 
bool binarySearch(int mid, int forward)
{
    if(mid > n-1 || mid < 0)
    {
        return 1;
    }
    int cur = mid;
    int ind = 0;
    for(int i=1; i<=q; i++)
    {
        // cout << i << " " << cur << endl;
        if(s[cur] == a[i])
        {
            if(b[i] == 'L')
            {
                cur --;
            }
            else
            {
                cur ++;
            }
        }
        if((cur == n && !forward) || (cur == -1 && forward))
        {
            break;
        }
    }
    if(cur == -1 && forward)
    {
        return 1;
    }
    else if(cur == n && !forward)
    {
        return 1;
    }
    else
    {
        return 0;
    }
    
}
 
int main()
{
    cin >> n >> q;
    cin >> s; 
    for(int i=1; i<=q; i++)
    {
        cin >> a[i] >> b[i];
    }
    int low = 0, high = n-1, mid;
    int forwardAns = -1;
    while(low <= high)
    {
        mid = (low + high)/2;
        // cout << "mid " << mid << endl;
        if(binarySearch(mid, 1))
        {
            low = mid + 1;
            forwardAns = mid;
        }
        else
        {
            high = mid - 1;
        }
    }
 
    // cout << forwardAns << endl;
    low = 0, high = n-1;
    int backwardAns = n;
    while(low <= high)
    {
        mid = (low + high)/2;
        // cout << "mid " << mid << " " << low << " " << high << endl;
        if(binarySearch(mid, 0))
        {
            high = mid-1;
            backwardAns = mid;
        }
        else
        {
            low = mid + 1;
        }
    }
    // cout << backwardAns << endl;
    if(backwardAns <= forwardAns)
    {
        cout << n << endl;
    }
    else
    {
        cout << n - (forwardAns + 1 + (n-backwardAns)) << endl;
    }
    return 0;
}

Measured memory_bytes: 900
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n;
ll a[200010];
ll d1[200010], d2[200010];
set<pair<int, int>> st;
ll ans = 1000000000000000000;

signed main() {
	cin >> n; 
	for (int i = 1; i <= n; i++)cin >> a[i];
	d1[1] = 1;
	st.insert(make_pair(1, 1000000000));
	for (int i = 2; i <= n; i++) {
		ll p = a[i - 1], q = a[i];
		ll cnt = 0;
		d1[i] = d1[i - 1] + 1;
		while (p < q) {
			p *= 4;
			cnt += 2;
		}
		int k = i;
		if (cnt) {
			while (cnt) {
				pair<int,int> t = *st.rbegin();
				if (cnt <= t.second) {
					d1[i] += cnt * (k - t.first);
					st.erase(t);
					if (cnt < t.second)st.insert(make_pair(t.first, t.second - cnt));
					cnt = 0;
				}
				else {
					d1[i] += cnt * (k - t.first);
					st.erase(t);
					cnt -= t.second;
					k = t.first;
				}
			}
		}
		else {
			while (p >= q * 4) {
				cnt += 2;
				q *= 4;
			}
			st.insert(make_pair(i, cnt));
		}
	}
	st.clear();
	st.insert(make_pair(n, 1000000000));
	for (int i = n - 1; i >= 1; i--) {
		d2[i] = d2[i + 1];
		ll p = a[i], q = a[i + 1];
		ll cnt = 0;
		while (q < p) {
			cnt += 2;
			q *= 4;
		}
		int k = i;
		if (cnt) {
			while (cnt) {
				pair<int, int> t = *st.begin();
				if (cnt <= t.second) {
					d2[i] += cnt * (t.first - k);
					st.erase(t);
					if (cnt < t.second)st.insert(make_pair(t.first, t.second - cnt));
					cnt = 0;
				}
				else {
					d2[i] += cnt * (t.first - k);
					st.erase(t);
					k = t.first;
					cnt -= t.second;
				}
			}
		}
		else {
			while (p * 4 <= q) {
				cnt += 2;
				p *= 4;
			}
			st.insert(make_pair(i, cnt));
		}
	}
	for (int i = 0; i <= n; i++)ans = min(ans, d1[i] + d2[i + 1]);
	cout << ans << endl;
}

Measured memory_bytes: 17604
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());

	int[] x = new int[n];
	int[] y = new int[n];
	for (int i = 0; i < n; i++)
	{
	    var tmp = ReadIntArray();
	    x[i] = tmp[0];
	    y[i] = tmp[1];
	}

	double total = 0.0;
	for (int i = 0; i < n-1; i++)
	{
	    for (int j = i + 1; j < n; j++)
	    {
		long dx = (long)(x[i] - x[j]);
		long dy = (long)(y[i] - y[j]);
		double dist = Math.Sqrt((double)(dx*dx + dy*dy));
		total += dist;
	    }
	}

	WriteLine(2.0 * total / n);
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define MOD 1000000007
#define vec(a) vector<int>a
using namespace std;

bool isPrime(ll n)
{
	if(n==1||n==2||n==3||n==5||n==7)
		return 1;
	else
	{
		ll i,j,k,l,m;
		for(i=2;i<=sqrt(n);i++)
		{
			if(n%i==0)
				return 0;
		}
		return 1;
	}
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	ll arr[3];
	cin>>arr[0]>>arr[1]>>arr[2];
	sort(arr,arr+3);
	cout<<arr[0]+arr[1];
	return 0;
}
	

Measured memory_bytes: 3652
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}

int main(void) {

  int s, w;
  cin >> s >> w;
  if (w >= s) cout << "unsafe" << endl;
  else cout << "safe" << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

double inv(double x)
{
	return 1.0/x;
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin>>n;
	vll a(n);
	rep(i, n) cin>>a[i];

	double ans = 0.0;
	rep(i, n) ans += inv(a[i]);

	cout << setp(12) << inv(ans) << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 524289
using namespace std;
int s[maxn][20],t[maxn][20];
int dpl[maxn],dpr[maxn],tag[maxn],n,v,x[maxn],y[20],mx,p;
int main(){
	scanf("%d%d",&n,&v);
	y[p++]=v;
	do{y[p++]=v/=2;}while(v);
	for(int i=1;i<=n;++i)scanf("%d",&x[i]);
	for(int i=0;i<p;++i)
		for(int j=1,k,l;j<=n;j=k){
			for(k=j+1;k<=n&&x[k]-x[k-1]<=y[i];k++);
			for(l=j;l<k;l++)s[l][i]=k-1,t[l][i]=j;
//			printf("[%d,%d,%d,(%d,%d)]",y[i],j,k-1,x[k],x[k-1]);
		}
	dpl[0]=0,dpr[0]=n+1;
	for(int i=1;i<(1<<p);i++)if(~i&1){
		dpl[i]=0,dpr[i]=n+1;
		for(int j=0;j<p;++j)if(i&(1<<j))
			dpl[i]=max(dpl[i],dpl[i^(1<<j)]>=n?n:s[dpl[i^(1<<j)]+1][j]),
			dpr[i]=min(dpr[i],dpr[i^(1<<j)]<=1?1:t[dpr[i^(1<<j)]-1][j]);
//		printf("[l=%d,r=%d]\n",dpl[i],dpr[i]);
	}
	for(int i=0;i<(1<<p);++i)if(~i&1){
		int l=dpl[i],r=dpr[(1<<p)-1-i-1];
//		printf("[%d,%d,%d]",l,r,s[l+1][0]);
		if(l+1>=r)tag[1]++;
		else if(s[l+1][0]+1>=r)tag[t[l+1][0]]++,tag[s[l+1][0]+1]--;
	}
	for(int i=1;i<=n;++i){
		mx+=tag[i];
		if(mx>0)puts("Possible");
		else puts("Impossible");
	}
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
long long X[200000], Y[200000];
int main () {
    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        int A;
        cin >> A;
        if (A+i < N) {
            X[A+i]++;
        }
        if (i-A > 0) {
            Y[i-A]++;
        }
    }
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        ans += X[i]*Y[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 6744
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
     ll n;
     cin>>n;
     map<ll,ll> m;
     rep(i,n){
         ll a;
         cin>>a;
         m[a]++;
     }
    vector<ll> v;
     ll ans = 0;
    for(auto &&a:m){
        v.push_back(a.first);
    }

    if(m.size()<3){
        cout<<0<<endl;
        return 0;
    }
    int vn = v.size();

    sort(v.rbegin(),v.rend());
    for(int i=0;i<vn;i++){
        int a = v[i];
        for(int j=i+1;j<vn;j++){
            int b =v[j];
            for(int k=j+1;k<vn;k++){
                if(a<b+v[k]){
                    ans+=m[a]*m[b]*m[v[k]];
                }
            }

        }
    }
    cout<<ans<<endl;





return 0;
}


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

#define ll long long
#define pi pair<int, int>
#define mkp make_pair
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD =  1e9 + 7;
int arr[mxn];
ll n, m, k, q;
string s, t;


template <typename T>
struct math{
    //Georgioss
    vector<T> get_divisors(T num){
        vector<T> divisors;
        for(T i = 1; i * i <= num; i++){
            if(num % i == 0){
                divisors.push_back(i);
                if(i * i != num) divisors.push_back(num / i);
            }
        }
        sort(divisors.begin(), divisors.end());
        return divisors;
    }

    vector<T> get_prime_factors(T num){
        vector<T> prime_factors;
        while((num & 1) == 0){
            prime_factors.push_back(2);
            num >>= 1;
        }
        for(T i = 3; i * i <= num; i += 2){
            while(num % i == 0){
                prime_factors.push_back(i);
                num /= i;
            }
        }
        if(num > 2){
            prime_factors.push_back(num);
        }
        return prime_factors;
    }

    vector<bool> get_sieve(int num){
        vector<bool> sieve(num + 1, true);
        sieve[0] = sieve[1] = false;
        for(int i = 2; i * i <= num; i++){
            if(sieve[i]){
                for(int j = i * i; j <= num; j += i){
                    sieve[j] = false;
                }
            }
        }
        return sieve;
    }

    T gcd(T A, T B){
        return (B == 0) ? A : gcd(B, A % B);
    }

    T lcm(T A, T B){
        return A * B / gcd(A, B);
    }

    T POW(T A, T B, T res = 1){
        while(B){
            if(B & 1) res = res * A % MOD;
            A = A * A % MOD;
            B >>= 1;
        }
        return res;
    }

    bool prime(T num){
        for(T i = 2; i * i <= num; i++)
            if(num % i == 0) return false;
        return true;
    }
};

//Math<Type> M;


void solve(){
    math<ll> m;
    cin >> n;
    vector<ll> v = m.get_prime_factors(n);
    map<ll, int> mp;
    int res = 0;
    for (auto x : v) mp[x]++;
    for (auto x : mp) {
        int num = x.sc;
        int curr = 0;
        int cnt = 0;
        for (int i = 1; true; i++) {
            curr += i;
            if (curr > num) break;
            cnt++;
        }
        res += cnt;
    }
    cout << res << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    while(T--) solve();
    return 0;
}


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

int main(){
  ll n; cin>>n;
  n*=100;
  if(n%108==0){
    cout<<(n/108);
  }else if(((n/108)*108)/100==n/100){
    cout<<(n/108);
  }else if(((n/108+1)*108)/100==n/100){
    cout<<(n/108)+1;
  }else if(((n/108-1)*108)/100==n/100){
    cout<<(n/108)-1;
  }else if(((n/108+2)*108)/100==n/100){
    cout<<(n/108)+2;
  }else if(((n/108-2)*108)/100==n/100){
    cout<<n/108-2;
  }else{
    cout<<":(";
  }

  }


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int k,n,a,c[200002],ans=0,i,p=0,j;
	scanf("%d%d",&n,&k);
	for(i=0;i<200001;i++)
	c[i]=0;
	for(i=0;i<n;i++){
		scanf("%d",&a);
		c[a]++;
			}
			p=n-k;
			i=1;
			j=0;
			while(p!=0){
				if(c[i]==j){
				p--;
				ans+=j;
				}
				if(i==n){
				i=0;
				j++;
				}
				i++;
			}
			printf("%d",ans);
			return 0;
			}

Measured memory_bytes: 896
import collections


class Solution:
    def solve(self, s, queries):
        mQueue = collections.deque([ch for ch in s])

        revCount = 0

        for query in queries:
            if query[0] == 1:
                revCount += 1
            elif query[0] == 2:
                if revCount % 2 == 0:
                    if query[1] == '1':
                        mQueue.appendleft(query[2])
                    else:
                        mQueue.append(query[2])
                else:
                    if query[1] == '1':
                        mQueue.append(query[2])
                    else:
                        mQueue.appendleft(query[2])

        if revCount % 2 == 0:
            return "".join(mQueue)
        else:
            return "".join(reversed(mQueue))


sol = Solution()

s = input().strip()
q = int(input().strip())

queries = []

for i in range(q):
    query = list(input().strip().split())
    query[0] = int(query[0])

    queries.append(query)

print(sol.solve(s, queries))


Measured memory_bytes: 35328
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll INF = -1e18;
const int I=2001;
int input() {int x; cin>>x; return x;}

int main(){
  int n,k; cin>>n>>k;
  ll a[n]; for(int i=0;i<n;i++) cin>>a[i];
  ll an=3.1415926535e14;
  for(int i=0;i<(1<<n);i++) {
    ll sm=0, hi=0, kk=0; bool p[n];
    for(int j=0;j<n;j++) {
      if (i & (1<<j)) p[j]=true, kk++;
      else p[j]=false;
    }
    if (kk < k) continue;
    for(int j=0;j<n;j++) {
      ll sz=a[j];
      if (p[j]) {
        sm += max(0LL, hi-sz+1);
        //cerr<<j<<" "<<hi<<" "<<sz<<" "<<hi-sz+1<<endl;
        sz = max(a[j], hi+1);
      }
      //cout<<hi<<" "<<sz<<" ";
      hi=max(hi,sz);
      //cout<<hi<<" "<<sz<<endl;
    }
    //cout<<i<<" "<<sm<<endl;
    an = min(an,sm);
  }
  cout<<an<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    double pi = 3.14159265358979323846;
    ll a, b, h, m;
    cin >> a >> b >> h >> m;
    double minutes = h*60+m;

    double angle =fabs((60*h - 11*m) * pi / 360);
    double ans = sqrt(a*a+b*b - 2 *a*b*cos(angle));
   cout.setf(ios::fixed);
    cout << setprecision(16) << ans << endl;
    return 0;
}





Measured memory_bytes: 4076
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()) {
			String str = scanner.nextLine();
			char[] ab = str.toCharArray();
			int i;
			for(i = 1; i <= 26; i++) {
				String str2 = Caesar(ab,i);
				if((str2.indexOf("the ") != -1)
						|| (str2.indexOf("this ") != -1)
						|| (str2.indexOf("that ") != -1)) {
					System.out.println(str2);
				}
			}
		}
		scanner.close();
	}

	static String Caesar(char[] str, int key) {

		int i;
		String str2 = "";
		char tmp = 0;
		for(i = 0; i < str.length; ++i){
			if(97 <= str[i] && str[i] <= 122 ) {
				tmp = (char) ((char) ((char) ((str[i] % 97) + key) % 26) + 97);
			}else {
				tmp = str[i];
			}
			str2 = str2 + tmp;
		}
		return str2;
	}

}




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

typedef long long lint;
typedef long double ldouble;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

const int MAX_N = (int)1e5 + 10;
vector<bool> isPrime(MAX_N, true);

void eratosthenes(int N){
    rep(i, 2){
        isPrime[i] = false;
    }
    for(int i = 2 ; i * i <= N ; i++){
        if(isPrime[i]){
            for(int j = 2 ; i * j <= N ; j++){
                isPrime[i*j] = false;
            }
        }
    }
    return;
}

int main(){
    eratosthenes(MAX_N-1);
    vector<int> sum(MAX_N);
    sum[0] = 0;
    REP(i, 1, MAX_N){
        if(isPrime[i] && isPrime[(i+1)/2]){
            sum[i] = 1;
        }
        sum[i] += sum[i-1];
    }
    int q;
    cin >> q;
    rep(i, q){
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l-1] << endl;
    }
    return 0;
}

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

lst_A = []

for i in range(5):
    lst_A.append(input())
    lst_A[i] = int(lst_A[i])

lst_A.sort()

ans = N // lst_A[0]

if N % lst_A[0]:

    ans += 1

ans += 4

print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

int main(void)
{
  int N;
  int a;
  int b=0;
  scanf("%d",&a);
  scanf("%d",&N);
  if(a+N==15){
    printf("+");
    b=1;
  }else if(a*N==15){
    printf("*");
   b=1;
  }

 if(b==0)
  printf("x");

  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/rdmd
import std.stdio: stdin, lines, writeln;
import std.ascii: newline;
import std.conv: to;
import std.array: split;


void main()
{
   int[2] a;
   foreach (string line; lines(stdin))
   {
      if(line == newline) break;
         else
         {
            a = to!(int[])(split(line));
            writeln((a[0]+a[1]));
         }
   }
}

Measured memory_bytes: 964
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
typedef long long ll;

int main() {
	int n;
	cin>>n;
	vector<int> a(n), b(n), c(n);
	int dp[n][3];
	for(int i  = 0; i < n; i++) {
		cin>>a[i]>>b[i]>>c[i];
	}
	dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0];
	for(int i = 1; i < n; i++) {
		dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
	}
	cout<<max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]))<<endl;
	return 0;
}


Measured memory_bytes: 2560
use proconio::marker::Bytes;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: Bytes,
    }
    let m: i64 = 2019;
    let mut v: Vec<i64> = vec![0; m as usize];
    let mut tmp: i64 = 0;
    let mut ans: i64 = 0;
    let mut k: i64 = 1;
    v[0] = 1;
    for i in 0..s.len() {
        let i = s.len() - 1 - i;
        let c = (s[i] - '0' as u8) as i64;
        tmp = (tmp + c * k) % m;
        k = (k * 10) % m;
        ans += v[tmp as usize];
        v[tmp as usize] += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2396
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(2);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define sp " "
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI=3.141592653589793;

bool ok[10];

void solve()
{
	string s;
	cin>>s;
	vector <char> ans;

	for(char c : s)
	{
		if(c=='B' && ans.size()>0)
		{
			ans.pop_back();
		}
		else if(c!='B')ans.push_back(c);
	}

	for(char c : ans) cout << c;
}

int32_t main()
{
	FastIO;
	Fast_D;
	int T;
	T=1;
	while(T--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define setbits(x)  __builtin_popcountll(x)
#define mod 1000000007
#define v(n) vector<int> v(n)
#define w(x) int x;cin>>x;while(x--)
#define ps(x,y) fixed<<setprecision(y)<<x
#define f(i,j,n) for(int i=j;i<=n;i++)
#define  FAST ios_base::sync_with_stdio(0);cin.tie(0);cin.tie(0);
void c_p_c(){
    ios_base::sync_with_stdio(0);cin.tie(0);cin.tie(0);
   /* #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
}
int main(){
    c_p_c();
    int n,t=0;
    cin>>n;
    v(n);
    f(i,0,n-1)
     cin>>v[i];
    if(n<=2)
     cout<<"0";
    else
   { f(i,0,n-1){
        f(j,0,n-1){
            f(k,0,n-1){
                if((v[i]+v[j])>v[k] && (v[j]+v[k])>v[i] && (v[k]+v[i])>v[j]&&v[i]<v[j]&&v[j]<v[k])
                 t++;
            }
        }
    }cout<<t;}
}   
    
    
     

     
   









Measured memory_bytes: 3660
n,x,m=map(int,input().split())
l=[0]*m
s=[0]*m
t=p=0
while l[x]<1:
  t+=1
  l[x]=t
  s[x]=s[p]+x
  p=x
  x=pow(p,2,m)
T=t+1-l[x]
S=s[p]+x-s[x]
d,m=divmod(n-l[x],T)
print(S*d+s[l.index(l[x]+m)])

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T, typename E>
class SegTree{
	using F = function<T(T, T)>;
	using G = function<T(T, E)>;
	int32 n;
	F f;
	G g;
	T d0; // e0:F
	vector<T> node;
public:
	SegTree(int32 _n, F f, G g, T d0):f(f), g(g), d0(d0){
		init(_n);
	}
	SegTree(vector<T> v, F f, G g, T d0):f(f), g(g), d0(d0){
		node = v;
		init(v.size());
		for(int32 i = n-2;i >= 0;i--){
			node[i] = f(node[i*2+1], node[i*2+2]);
		}
	}

	void init(int32 _n){
		n = 1;
		while(n < _n) n *= 2;
		node.resize(2*n-1, d0);
	}

	void update(int32 k, E x){
		k += n-1;
		node[k] = g(node[k], x);
		while(k){
			k = (k-1)/2;
			node[k] = f(node[k*2+1], node[k*2+2]);
		}
	}

	T query(int32 a, int32 b, int32 k=0, int32 l=0, int32 r=-1){
		if(r < 0) r = n;
		if(b <= l || r <= a) return d0;
		if(a <= l && r <= b) return node[k];
		return f(query(a, b, k*2+1, l, (l+r)/2), query(a, b, k*2+2, (l+r)/2, r));
	}
};

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int32 n, q;
	cin >> n >> q;
	SegTree<int64, int64> sg(n,
		[](int64 a, int64 b){return min(a, b);},
		[](int64 a, int64 b){return b;}, (1LL<<31)-1);
	REP(i, q){
		int64 com, x, y;
		cin >> com >> x >> y;
		if(com == 0) sg.update(x, y);
		else cout << sg.query(x, y+1) << endl;
	}
}



Measured memory_bytes: 4900
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
typedef long long ll;

using namespace std;

class Edge
{
	public:
	int cost;
	int next;

	Edge(int n,int c)
	{
		next=n;
		cost=c;
	}
};
int A[300][300];
int L[100000];
int R[100000];
map<int,pair<int,int>> mp;
int cost[90001];

int main()
{
	int h,w,d,q;
	ll ans=0;
	cin>>h>>w>>d;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin>>A[i][j];
			mp[A[i][j]]=make_pair(j,i);
		}
	}
	cin>>q;
	for(int i=0;i<q;i++)
	{
		cin>>L[i]>>R[i];
	}
	for(int j=0;j<d;j++)
	{
		cost[j]=0;
		for(int i=j+d;i<90001;i+=d)
		{
			cost[i]=cost[i-d]+(abs(mp[i].first-mp[i-d].first)+abs(mp[i].second-mp[i-d].second));
		}
	}

	for(int i=0;i<q;i++)
	{
		ans = cost[R[i]]-cost[L[i]];
		cout<<ans<<endl;
	}
	return 0;
}

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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  int N;
  string s;
  cin >> N >> s;

  vector<int> vec(N, INF);
  int x[] = {0, 0, 1, 1};
  int y[] = {0, 1, 0, 1};
  REP(_, 4){
    vec[0] = x[_];
    vec[1] = y[_];
    FOR(i, 1, N-1){
      // hituzi
      if(vec[i] == 1){
        if(s[i] == 'o') vec[i+1] = vec[i-1];
        else vec[i+1] = 1-vec[i-1];
      }else{
        if(s[i] == 'x') vec[i+1] = vec[i-1];
        else vec[i+1] = 1-vec[i-1];
      }
    }
    int ans = 0;
    if(vec[N-1] == 1){
      if(s[N-1] == 'o' && vec[N-2] == vec[0]) ans++;
      if(s[N-1] == 'x' && vec[N-2] != vec[0]) ans++;
    }else{
      if(s[N-1] == 'x' && vec[N-2] == vec[0]) ans++;
      if(s[N-1] == 'o' && vec[N-2] != vec[0]) ans++;
    }
    if(vec[0] == 1){
      if(s[0] == 'o' && vec[N-1] == vec[1]) ans++;
      if(s[0] == 'x' && vec[N-1] != vec[1]) ans++;
    }else{
      if(s[0] == 'x' && vec[N-1] == vec[1]) ans++;
      if(s[0] == 'o' && vec[N-1] != vec[1]) ans++;
    }
    if(ans == 2){
      REP(i, N){
        if(vec[i]) cout << "S";
        else cout << "W";
      }
      cout << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}

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

int main(){
    long long n;
    cin >> n;
    
    int ans = 10;
    
    for(int i = 1; i <= sqrt(n); i++) {
     if(n % i == 0) {
      int keta = 0;
      long long syou = n / i;
         while(syou > 0) {
             syou /= 10;
          keta++;
         }
         ans = min(ans, keta);
     }
    }
    cout << ans;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256