akhauriyash/Code-Regression huggingface dataset:
//om namah shivaaay//
#include <bits/stdc++.h>
#define input int t;cin>>t;while(t--)
#define Om_namah_Shivaay ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout.precision(10)
 #define ll long long
 #define vi(x)  vector<int>vec(x)
 #define pb push_back
 #define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
 #define f(i, a, b) for (int i = 0; i<(b); i++)
 #define w(t) int t;cin>>t;while(t --)
#define fr(i, a, b) for (int i = (a); i >= (b); i--)
 #define PI 3.14159265358979323846264338327950L
 const int N=1e5 +5;
 using namespace std;
 int32_t main()
 {
    Om_namah_Shivaay;
  int a, b, h, m;
 scanf("%d%d%d%d", &a, &b, &h, &m);

 long double rad = PI * 2 * (
 (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long
double)m / 60.0);

 long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
b) * cosl(rad);

 printf("%20.20Lf\n", sqrtl(rsq));
}


Measured memory_bytes: 4232
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,b,e=0;cin>>a;
  map<ll,ll>c;
  rep(i,a){
    cin>>b;
    c[b]++;
  }
  for(auto i=c.begin();i!=c.end();i++)e+=i->second%2;
  cout<<e;
}



Measured memory_bytes: 33052
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/











int N, P[201010];
int dp[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> P[i];

    int ans = 0;
    rep(i, 0, N) {
        int p = P[i];
        dp[p] = dp[p - 1] + 1;
        chmax(ans, dp[p]);
    }

    cout << N - ans << endl;
}

Measured memory_bytes: 1792
N = int(input())
H = list(map(int,input().split()))

a= []
count = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    count+=1
  else:
    a.append(count)
    count = 0

a.append(count)
  
print(max(a))
  


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

int main(void){
    int n;
    cin >> n;
    
    vector<int> a(n);
    rep(i, n){
        cin >> a.at(i);
    }
    
    pair<int, int> p;
    int max_1 = 0, max_2 = 0;
    
    rep(i, n){
        if(a.at(i) > max_1){
            max_1 = a.at(i);
            p.first = max_1;
            p.second = i;
        } else if(a.at(i) > max_2){
            max_2 = a.at(i);
        }
    }
    
    rep(i, n){
        if(p.second != i){
            cout << p.first << endl;
        } else {
            cout << max_2 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2432
#define _USE_MATH_DEFINES
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<utility>
#include<map>
#include<climits>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
#include<cmath>
#include<iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<int,P>MP;
typedef vector<vector<int>> MX;

const ll MOD=1e9+7;
const int INF = 1000000000;


int main()
{
	int N;
	priority_queue<int,deque<int>,greater<int>>Q;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int t;
		cin>>t;
		Q.push(t);
	}
	while(Q.size()>1)
	{
		int t1=Q.top();Q.pop();
		int t2=Q.top();Q.pop();
		if(t2%t1)Q.push(t2%t1);
		Q.push(t1);
	}
	cout<<Q.top()<<endl;
}




Measured memory_bytes: 3968
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
const int MAX_N = 100000;
const int MAX_V = 1e9;
int N;
int X[MAX_N], L[MAX_N];
pair<int, int> ps[MAX_N];

int main() {
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> X[i] >> L[i];
  }

  for(int i = 0; i < N; i++) {
    ps[i] = make_pair(X[i] + L[i], X[i] - L[i]);
  }
  sort(ps, ps+N);

  int cur = -MAX_V;
  int ans = 0;
  for(int i = 0; i < N; i++) {
    if(cur <= ps[i].second) {
      ans++;
      cur = ps[i].first;
    }
  }
  cout << ans << endl;

  return 0;
}


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

const int Inf = 0x7fffffff;
typedef vector<int> VI;

int main() {
    int N, K;
    cin >> N >> K;
    VI v(N), DP(N, Inf);
    for (int& i : v) cin >> i;
    DP[0] = 0;
    DP[1] = abs(v[0] - v[1]);
    for (int i = 2; i < N; ++i) {
        for (int j = max(0, i-K); j < i; ++j)
            DP[i] = min(DP[j]+abs(v[i] - v[j]), DP[i]);
    }
    cout << DP[N-1] << endl;
}

Measured memory_bytes: 1024
package main

import (
   "fmt"
   "os"
   "bufio"
   "strconv"
   "sort"
)

const MaxBuf = 200100
var buf []byte
var sc = bufio.NewScanner(os.Stdin)

func init() {
   sc.Split(bufio.ScanWords)
   sc.Buffer(buf,MaxBuf)
}

func readString() string {
   sc.Scan()
   return sc.Text()
}

func readInt64() int64 {
   sc.Scan()
   r,_ := strconv.ParseInt(sc.Text(),10,64)
   return r
}

func readInt() int {
   sc.Scan()
   r,_ := strconv.Atoi(sc.Text())
   return r
}

func main() {
	s := readString()
	t := readString()

	ms := make(map[rune][]int)
	for i,c := range s { 
	    ms[c] = append(ms[c],i)
	}
	imp := false
	loop := 0
	c := -1

	for _,v := range t {
		if len(ms[v]) == 0 {
			imp = true
			break
		}
		idx := sort.SearchInts(ms[v],c+1)
		if idx == len(ms[v]) {
			loop++
			c = ms[v][0]
		} else {
			c = ms[v][idx]
		}
	}

	ans := loop * len(s) + c + 1
	if (imp) {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#include<random>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;



/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

#define int long long

void solve(){

	int n;
	cin>>n;
	int ans = 0;
	for(int i = 1 ; i <= n ; ++i){

		if((i%3==0 )|| (i%5==0))
			continue;
		ans+=i;
	}

	cout<<ans<<endl;
}

signed main(){

    fast;
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t ; ++i){

    	solve();
    	
    	//cout<<"Case #"<<i<<": ";
    }
}


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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x)*(x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    int n, k, m;
    while (cin >> n >> k >> m, n|k|m) {
        vi stones(n);
        REP(i, n) stones[i] = i+1;
        int idx = m-1;
        REP(i, n-1) {
            stones.erase(stones.begin()+idx);
            idx = (idx + k-1) % stones.size();
        }
        cout << stones[0] << endl;
    }
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             3005

double dp[N][N];
double p[N];

int solve(){
    int n; cin>>n;
    for (int i = 0; i < n; ++i)
    {
        cin>>p[i];
    }
    dp[0][0]=1-p[0];
    dp[0][1]=p[0];
    for (int i = 1; i <= n; ++i)
    {
        for(int j=0; j< N; j++){
            dp[i][j]+=(1-p[i])*dp[i-1][j];
            if(j)
                dp[i][j]+=p[i]*dp[i-1][j-1];
        }
    }
    double ans=0;
    for (int i = (n+1)/2; i <= n; ++i)
    {
        ans+=dp[n][i];
    }
    cout<<fixed<<setprecision(10)<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 74240
#include<stdio.h>
#include<string.h>
#include<stdbool.h>

void dice_change_east(int d2[6])
{
  int t = d2[2];
  d2[2] = d2[0];
  d2[0] = d2[3];
  d2[3] = d2[5];
  d2[5] = t;

}


void dice_change_south(int d2[6])
{
  int t = d2[1];
  d2[1] = d2[0];
  d2[0] = d2[4];
  d2[4] = d2[5];
  d2[5] = t;

}

void dice_change_rotate(int d2[6])
{
  int t = d2[3];
  d2[3] = d2[1];
  d2[1] = d2[2];
  d2[2] = d2[4];
  d2[4] = t;
}
bool compare(int d[6],int d2[6])
{
  int f,s;
  int i;

  f = d[0];
  s = d[1];

  for(i = 0;i < 4; i++)
    {
      if(d2[1] == s)
	break;

      dice_change_south(d2);
    }

  if(d2[1] != s)
    {
      for(i = 0;i < 4;i++)
	{
	  if(d2[1] == s)
	    break;

	  dice_change_rotate(d2);
	}
    }

  /*if(d->men[1] != v)
    return hantei;*/
  if (d2[1] != s)
    return false;

  for (i = 0;i < 4;i++)
    {
      if (d2[0] == f)
	break;

      dice_change_east(d2);
    }

  for (i = 0;i < 6;i++)
    {
      if (d[i] != d2[i])
	break;
    }

  /*if (i == 6){
    hantei = 1;
    return hantei;
  }
  else
  return hantei;*/

  //if((d[0] == d2[0]) && (d[1] == d2[1]) && (d[2] == d2[2]) && (d[3] == d2[3]) && (d[4] == d2[4]) && (d[5] == d2[5]))
  // hantei = 1;
  if(i == 6)
    return true;
  else
    return false;
  //return hantei;
}


bool solve(int dice[100][6], int n)
{
  for(int i = 0;i < n-1;i++)
    {
      for(int j = i + 1;j < n;j++)
	{
	  if(compare(dice[i],dice[j]))
	    return false;
	}
    }
  return true;
}


int main()
{

  int i,j;
  int dice[100][6];
  int n;
  /*int s[6];
  int d[6];
  int hantei;*/

  scanf("%d",&n);
  for (i = 0; i < n; i++)
    {
      for (j = 0; j < 6; j++)
	scanf("%d", &dice[i][j]);
    }

  //compare(s,d,n);

  //if((d.men[0] == s.men[0]) && (d.men[1] == s.men[1]) && (d.men[2] == s.men[2]) && (d.men[3] == s.men[3]) && (d.men[4] == s.men[4]) && (d.men[5] == s.men[5]))
  /*  if(hantei == 1)
    printf("Yes\n");
  else
  printf("No\n"); */
  printf("%s\n",solve(dice,n)? "Yes" : "No");

  return 0;
}


Measured memory_bytes: 2100
#include <cstdio>
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(void){
    string input;
    
    while(getline(cin, input), !cin.eof()){
        double r;
        
        sscanf(input.c_str(), "%lf\n", &r);
        
        printf("%lf %lf\n", (r * r * M_PI), (r * 2 * M_PI));
    }
    return(0);
}



Measured memory_bytes: 3288
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    cout << !!(m1 != m2) << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

const ll MAX_N = 1 << 20;
const ll INF = pow(2, 31) - 1;
ll n;
vector<ll> dat(MAX_N, 0);
vector<ll> delay(MAX_N, 0);

void init(ll _n) {
  ll temp = 1;
  while (_n >= temp) {
    temp *= 2;
  }
  n = temp;
}

void evaluate(ll k) {
  dat.at(k) += delay.at(k);
  if (delay.at(k) == 0 || k >= n - 1) {
    delay.at(k) = 0;
    return;
  }
  delay.at(k * 2 + 1) += delay.at(k);
  delay.at(k * 2 + 2) += delay.at(k);
  delay.at(k) = 0;
}

void update(ll x, ll y, ll s, ll k = 0, ll l = 0, ll r = n) {
  evaluate(k);
  if (r <= x || y <= l) {
    return;
  }
  if (x <= l && r <= y) {
    delay.at(k) += s;
    evaluate(k);
  }
  else {
    update(x, y, s, k * 2 + 1, l, (l + r) / 2);
    update(x, y, s, k * 2 + 2, (l + r) / 2, r);
    dat.at(k) = min(dat.at(k * 2 + 1), dat.at(k * 2 + 2));
  }
}

ll query(ll x, ll y, ll k = 0, ll l = 0, ll r = n) {
  evaluate(k);
  if (r <= x || y <= l) {
    return INF;
  }
  if (x <= l && r <= y) {
    return dat.at(k);
  }
  else {
    ll lm = query(x, y, k * 2 + 1, l, (l + r) / 2);
    ll rm = query(x, y, k * 2 + 2, (l + r) / 2, r);
    return min(lm, rm);
  }
}

int main() {
  ll q;
  cin >> n >> q;
  init(n);
  for (ll i = 0; i < q; ++i) {
    ll com , x, y;
    cin >> com >> x >> y;
    if (com == 0) {
      ll s;
      cin >> s;
      update(x, y + 1, s);
    }
    else {
      cout << query(x, y + 1) << "\n";;
    }
    // for (ll i = 0; i < n * 2 - 1; ++i) {
    //   cout << dat.at(i) << " ";
    // }
    // cout << "\n";
  }
}



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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long n;
  scanf("%lld", &n);
  long long k;
  scanf("%lld", &k);

  ll c = min(n, k - 1);
  double under = double(c) / double(n);
  double ans = 1 - under;

  rep(i, 1, c + 1) {
    double a = double(k) / double(i);
    double count = ceil(log2(a));
    ans += (1 / double(n)) * pow(0.5, count);
  }

  putf(ans, 10);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

template <class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 256
/*
 *  Lang    : C++
 *  Author  : little_angel
 */
#include <bits/stdc++.h>

using namespace std;
#define int long long

int tree[1000100];

void upd(int v, int tl, int tr, int pos, int val) {
    if (tl == tr)tree[v] = val;
    else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)upd(2 * v, tl, tm, pos, val);
        else upd(2 * v + 1, tm + 1, tr, pos, val);
        tree[v] = max(tree[2 * v], tree[2 * v + 1]);
    }
}

int search(int v, int tl, int tr, int l, int r) {
    if (tl >= l && tr <= r)return tree[v];
    if (l > r || tl > tr || tr < l || tl > r)return 0;
    int tm = (tl + tr) / 2;
    return max(search(2 * v, tl, tm, l, min(tm, r)), search(2 * v + 1, tm + 1, tr, min(tm + 1, l), r));
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin >> n;
    vector<int> a(n), h(n);
    for (int i = 0; i < n; ++i) cin >> h[i];
    for (int i = 0; i < n; ++i) cin >> a[i];

    vector<int> dp(n + 1);
    for (int flower = 0; flower < n; ++flower) {
        dp[h[flower]] = search(1, 0, n, 0, h[flower] - 1) + a[flower];
        upd(1, 0, n, h[flower], dp[h[flower]]);
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
}

Measured memory_bytes: 11136
def solve() : 
  time = list()
  
  N = int(input())
  
  time = list(map(int, input().split()))
  
  M = int(input())
  
  for i in range(M) : 
    p, x = tuple(map(int, input().split()))
    
    ans = time.copy()
    ans[p - 1] = x
    sum = 0
    for j in range(len(ans)) :
      sum += ans[j]
    print(sum)
    
solve()

Measured memory_bytes: 3060
a = gets.to_i
n = 0
if a>=105 then
  n=n+1
end
if a>=135 then
  n=n+1
end
if a>=165 then
  n=n+1
end
if a>=189 then
  n=n+1
end
if a>=195 then
  n=n+1
end
print(n,"\n")

Measured memory_bytes: 1788
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    int ans = power(2, n) - 1 + mod;
    ans %= mod;
    int cnta = 1, cntb = 1;
    rep(i, a) cnta = Mul(cnta, n - i);
    rep(i, a) cnta = Div(cnta, i + 1);
    rep(i, b) cntb = Mul(cntb, n - i);
    rep(i, b) cntb = Div(cntb, i + 1);
    //cout << cnta << " " << cntb << endl;
    ans -= cnta;
    ans -= cntb;
    ans += mod * 2;
    ans %= mod;
    cout << ans << endl;

    return 0;
}


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

int main() {
    long N, X;
    cin >> N >> X;
    vector<vector<long>> maxLead {};
    long border = 0;
    for (int i=0; i<N; i++) {
        long b, l, u;
        cin >> b >> l >> u;
        long s = b * l + (X - b) * u;
        maxLead.push_back(vector<long> {s, b, l, u});
        border += b * l;
    }
    sort(maxLead.rbegin(), maxLead.rend());

    vector<long> sumMaxLead {};
    {
        long prevSum=0;
        for (int i=0; i<N; i++) {
            long curSum = prevSum + maxLead[i][0];
            sumMaxLead.push_back(curSum);
            prevSum = curSum;
        }
    }

    long min_e = LONG_MAX;
    for (int i=0; i<N; i++) {
        long s = maxLead[i][0];
        long b = maxLead[i][1];
        long l = maxLead[i][2];
        long u = maxLead[i][3];

        long num_line = 0;
        long left_s = 0;
        // Case 0
        if (s >= border) {
            num_line = 0;
            left_s = border;
        } else {
            // Case pos left
            if (sumMaxLead[i] >= border) {
                int p = lower_bound(sumMaxLead.begin(), sumMaxLead.end(), border - s) - sumMaxLead.begin();
                num_line = p + 1;
                left_s = border - sumMaxLead[p];
            // Case pos right
            } else {
                int p = lower_bound(sumMaxLead.begin(), sumMaxLead.end(), border) - sumMaxLead.begin();
                num_line = p;
                left_s = border - (sumMaxLead[p] - s);
            }
        }
        long e = num_line * X;
        if (left_s <= 0) {
            e = e;
        } else if (left_s <= b * l) {
            e += (left_s-1)/l + 1;
        } else {
            e += b + (left_s - b * l - 1)/u + 1;
        }
        min_e = min(min_e, e);
        //cout << "i: " << i << ", b: " << b << ", l: " << l << ", u: " << u << ", s: " << s << endl;
        //cout << "left_s: " << left_s << ", num_line: " << num_line << ", min_e: " << min_e << endl;
    }

    cout << min_e << endl;
}



Measured memory_bytes: 9520
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N;
int me[40000],enemy[40000];

void func(){

	for(int i = 0; i < N; i++)scanf("%d",&me[i]);
	for(int i = 0; i < N; i++)scanf("%d",&enemy[i]);

	sort(me,me+N,greater<int>() );
	sort(enemy,enemy+N,greater<int>());

	int me_index = 0,me_win_count = 0,enemy_index = 0;
	int ans = BIG_NUM;


	for(int i = 0; i < N-1; i++){

		if(me[me_index] > enemy[enemy_index]){
			me_win_count++;
			me_index++;
		}else{
			me_index++;
			enemy_index++;
		}
		if(me_win_count > (i+1)/2){
			ans = (i+1);
			break;
		}
	}

	if(ans == BIG_NUM){
		printf("NA\n");
	}else{
		printf("%d\n",ans);
	}
}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int INF=2e9;
const double PI=acos(-1);


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

    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(),d.end());
    cout << d[n/2]-d[n/2-1] << endl;
     
    return 0;   
}

Measured memory_bytes: 3780
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main() {
	int i;
	for (i = 1; ; i++) {
		int a;
		scanf("%d", &a);
		if (a == 0) {
			break;
		}
		printf("Case %d: %d\n", i, a);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
int main(){
	int a,b;cin>>a>>b;
	int n;cin>>n;
	for(int i = 0; n > i; i++){
		int A,B;cin>>A>>B;
		if(!(b<=A || B<=a)){
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}


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

int main(){
  int a,b,c;
  bool product;
  cin >> a >> b >> c;
  if(a * b * c == 25*7){
    cout << "YES" << endl << flush;
  }else{
    cout << "NO" << endl << flush;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vc vector<int>
#define um unordered_map<int,int>
#define ll long long 
#define rep(i,a,b) for(__typeof(a) i=a; i<b; i++)
#define si(a) a.size()
#define all(a) a.begin(),a.end()
#define ss(a) a.second
#define ff(a) a.first
#define M 1000000
#define pb push_back
#define repit(i,a) for(auto i=a.begin(); i!=a.end(); i++)
#define take(arr,n) for(int i=0;i<n;i++)cin>>arr[i]
#define out(arr,n) for(int i=0;i<n;i++)cout<<arr[i]<<' '
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define reprev(i,b,a) for(__typeof(b) i=b; i>=a; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define doublearray vector<vector<int>>
#define mod 1000000007
using namespace std;
ll max(ll a, ll b){ return a>b?a:b; }
ll min(ll a, ll b){ return a<b?a:b; }
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
int main(){
    fastio;
   	ll x,k,d; cin>>x>>k>>d;
   	x = abs(x);
   	if(x/d>k) cout<<x-k*d<<endl;
   	else{
   	    ll r = k - (x/d);
   	    if(r&1){
   	        cout<<abs(x-((x/d)+1)*d)<<endl;
   	    }
   	    else{
   	        cout<<x-(x/d)*d<<endl;
   	    }
   	}
    return 0;
}





Measured memory_bytes: 3524
n = int(input())
xu = list(input().split() for _ in range(n))
m = 0.0
for i in range(n):
  if xu[i][1] == 'JPY':
    m = m + int(xu[i][0])
    xu[i][0]
  else:
    m = m + 380000.0*float(xu[i][0])
print(m)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define VSORT(v) sort(v.begin(), v.end());
using namespace std;
int main()
{
  string s, t;
  cin >> s >> t;
  vector<int> buc_s(26), buc_t(26);
  for (int i = 0; i < (int)s.length(); i++)
  {
    buc_s[s[i] - 'a']++;
    buc_t[t[i] - 'a']++;
  }
  VSORT(buc_s);
  VSORT(buc_t);

  for (int i = 0; i < 26; i++)
  {
    if (buc_s[i] != buc_t[i])
    {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";

  return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    vector<ll> idx;
    ll n = len(s);
    rep(i, n - 1) {
        if ((s[i] == 'R') && (s[i + 1] == 'L')) {
            idx.push_back(i);
        }
    }
    vector<ll> ans(n, 0);
    rep(i, n) {
        auto it = lower_bound(all(idx), i);
        if (s[i] == 'L') it--;
        ll diff = abs(i - *it);
        if (diff % 2 == 0) {
            ans[*it]++;
        }
        else {
            ans[*it + 1]++;
        }
    }
    rep(i, n) printf("%lld%s", ans[i], (i == (n - 1)) ? "\n" : " ");
    return 0;
}


Measured memory_bytes: 1864
#include <iostream>
#include <vector>
#include <algorithm>
#define llong long long
#define For(i,a,b) for(int i=(a);i<(b);i++)
#define Rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){
  int N; cin >> N;
  vector<int> A(N), B(N), C(N);
  Rep(i, N) cin >> A[i];
  Rep(i, N) cin >> B[i];
  Rep(i, N) cin >> C[i];
  
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  vector<int> Ax(N, 0), Bx(N, 0), Cx(N, 0);
  int cntA=0, cntB=0, cntC=0;
  int total=0;

  long long ans = 0;
  Rep(i, N){
      long long cnt;
      cnt = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
      cnt *= N - (upper_bound(C.begin(), C.end(), B[i]) - C.begin());
      ans += cnt;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2688
#include<stdio.h>

int main(){
  long long int  A,B,N;
  scanf("%lld %lld %lld", &A, &B, &N);
  if(N >= B )
    N = B-1;
    long long int ans = A *(N%B) /B;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1672
#include <iostream>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <utility>

using namespace std;

typedef long long int lli;

typedef pair<lli, lli> pii;
typedef vector<lli> vi;
typedef set<lli> si;
typedef unordered_map<lli, lli> umii;
typedef unordered_set<lli> usi;

lli mod = 1000000007;

void dispvec(si arr)
{
    si::iterator itr = arr.begin();
    while (itr != arr.end())
    {
        cout << *itr << " ";
        itr++;
    }
    cout << endl;
}

struct CustomCompare
{
    //stable sort by first then second both in increasing
    bool operator()(const pair<float, lli> &i, const pair<float, lli> &j)
    {
        return i.first < j.first;
    }
};

lli min(lli a, lli b)
{
    return a < b ? a : b;
}
lli max(lli a, lli b)
{
    return a > b ? a : b;
}

void solve()
{
    int n;
    lli W;
    cin >> n;
    cin >> W;
    vi w(n + 1);
    vi v(n + 1);
    lli totalval = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> w[i] >> v[i];
        totalval += v[i];
    }
    lli inf = 1e18L + 5;
    vector<vector<lli>> dp(n + 1, vector<lli>(totalval + 1, inf));
    for (lli i = 0; i <= totalval; i++)
    {
        // dp[0][i] = 0;
    }
    for (lli i = 0; i <= n; i++)
    {
        dp[i][0] = 0;
    }
    for (int i = 1; i <= n; i++)
    {
        // int flag = 0;
        for (lli j = 1; j <= totalval; j++)
        {
            if (j - v[i] >= 0)
            {
                // flag = 1;
                dp[i][j] = min(dp[i - 1][j], w[i] + dp[i - 1][j - v[i]]);
            }
            else
            {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    lli ans = 0;
    for (lli i = 1; i <= totalval; i++)
    {
        if (dp[n][i] <= W)
        {
            ans = max(ans, i);
        }
    }
    cout << ans << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("/home/mufaddal/Mufaddal/Programs/Competitive/input", "r", stdin);
    freopen("/home/mufaddal/Mufaddal/Programs/Competitive/output", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    int i = 1;
    while (i <= t)
    {
        solve();
        i++;
    }

    return 0;
}

Measured memory_bytes: 82988
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

int main(){
  double l, ans, hen;
  cin >> l;
  hen = l/3;
  ans = hen * hen * hen;
  cout << fixed << setprecision(12) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main() 
{ 
char a[4];
for(int i=0;i<4;i++)
{
cin>>a[i];
}
if(a[0]==a[1]&&a[0]==a[2]&&a[0]==a[3])
cout<<"Yes";
else if(a[0]==a[1]&&a[0]==a[2])
cout<<"Yes";
else if(a[1]==a[2]&&a[1]==a[3])
cout<<"Yes";

else
cout<<"No";
return 0;  
}

Measured memory_bytes: 3620
N = int(input())
dp = [None] * (N + 1)

def fib(n):
    if dp[n] != None:
        return dp[n]
    if n == 0 or n == 1:
        dp[n] = 1
    else:
        dp[n] = fib(n - 2) + fib(n - 1)
    return dp[n]

print(fib(N))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	long long a,b,tmp;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
	 	scanf("%lld%lld",&a,&b);
		if(a>b)
			swap(a,b);
		if(a==b||a+1==b)
			printf("%lld\n",2*(a-1));
		else
		{
			tmp=(long long)sqrt(a*b);
			if(tmp*tmp==a*b) tmp--;
			if (tmp*(tmp+1)>=a*b)
				printf("%lld\n",2*tmp-2);
			else
				printf("%lld\n",2*tmp-1);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 3e4 + 1;
int a[N];
int m = 0;
vector<int> v[3];
bool used[N], good[N];

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

    int n;
    cin >> n;

    if (n == 3) {
        cout << "2 5 63" << "\n";
        return 0;
    }


    for (int i = 4; i <= 30000 && n > 0; i++) {
        if (i % 2 == 0 || i % 3 == 0) {
            v[i % 3].push_back(i);
            good[i] = true;
        }
    }

    used[2] = used[3] = true;
    n -= 2;

    for (int i = 0; i <= v[1].size(); i++) {
        bool ok = false;
        for (int j = 0; j <= v[2].size(); j++) {
            if ((i + j + j) % 3 == 1 && i + j < n &&
                (i + j + v[0].size()) >= n) {

                for (int k = 0; k < i; k++) {
                    used[v[1][k]] = true;
                    n--;
                }
                for (int k = 0; k < j; k++) {
                    used[v[2][k]] = true;
                    n--;
                }
                for (int k = 0; n > 0; k++) {
                    used[v[0][k]] = true;
                    n--;
                }
                ok = true;
                break;
            }
        }
        if (ok)
            break;
    }

    int s = 0;

    for (int i = 0; i < N; i++) {
        if (used[i]) {
            s += i;
        }
    }

    if (s % 2) {
        for (int j = 4; j < N; j++) {
            if (used[j]) {
                for (int k = 4; k < N; k++) {
                    if (!used[k] && good[k]) {
                        if (((k ^ j) & 1) && (j - k) % 3 == 0) {
                            used[j] = false;
                            used[k] = true;
                            break;
                        }
                    }
                }
                if (!used[j])
                    break;
            }
        }
    }

    for (int i = 1; i < N; i++) {
        if (used[i])
            cout << i << " ";
    }

    return 0;
}

Measured memory_bytes: 640
n=int(input())
X=[]
Y=[]
A=[0]*n
for i in range(n):
  A[i]=int(input())
  a=A[i]
  x=[0]*a
  y=[0]*a
  for j in range(a):
    x[j],y[j]=[int(s) for s in input().split()]
  X.append(x)
  Y.append(y)
  
s=0
for i in range(2**n):
  c=0
  d=0
  B=[0]*n
  for j in range(n):
    if((i >> j) & 1):
      c=c+1
      B[j]=1
  for k in range(n):
    if B[k]==1:
      for j in range(A[k]):
        if Y[k][j]!=B[X[k][j]-1]:
          d=-1
          break
    if d<0:
      break
  if s<c and d==0:
    s=c
      
      
print(s)         




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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int c[100][100];

int main()
{
	memset(c, 0, sizeof(c));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int H, W; cin >> H >> W;
	int N; cin >> N;
	vector<int> a(N, 0);
	rep (i, N){
		cin >> a[i];
	} // end rep

	vector<int> seq; seq.clear();
	rep (i, N){
		rep (j, a[i]){
			seq.push_back(i + 1);
		} // end rep
	} // end rep

	int k = 0;
	rep (i, H){
		if (i % 2 == 0){
			for (int j = 0; j < W; ++j){
				c[i][j] = seq[k];
				++k;
			} // end for
		}else{ // if (i % 2 != 0)
			for (int j = W - 1; j >= 0; --j){
				c[i][j] = seq[k];
				++k;
			} // end for
		} // end if
	} // end rep

	rep (i, H){
		rep (j, W){
			cout << c[i][j] << (j != W - 1 ? ' ' : '\n');
		} // end rep
	} // end rep

	return 0;
}

Measured memory_bytes: 512
package main

import "fmt"

func readAction(s string) string {
	var str string
	for _, runeValue := range s {
		switch runeValue {
		case '0':
			str += "0"
		case '1':
			str += "1"
		case 'B':
			if str != "" {
				sc := []rune(str)
				str = string(sc[:(len(sc) - 1)])
			}
		}
	}
	return str
}

func main() {
	var s string
	fmt.Scan(&s)
	str := readAction(s)
	fmt.Println(str)
}


Measured memory_bytes: 512
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

use std::cmp;
use std::collections::BinaryHeap;

fn solve(ab: &Vec<(usize, usize)>) -> usize {
    let n = ab.len();
    let mut v = vec![];
    for (i, &(a, b)) in ab.iter().enumerate() {
        v.push((a, i));
        v.push((b, i));
    }
    v.sort();

    let mut used_count = vec![0; n];
    let mut ans = 0;
    for i in 0..n {
        let (x, i) = v[i];
        used_count[i] += 1;
        ans += x;
    }

    for i in 0..n {
        if used_count[i] == 2 {
            return ans;
        }
    }

    let mut min = 1e15 as usize;

    for i in 0..n {
        assert_eq!(used_count[i], 1);
        let (a, b) = ab[i];
        let ans = ans - cmp::min(a, b);
        let (w, j) = v[n];
        if j == i {
            let (w, _) = v[n + 1];
            min = cmp::min(min, ans + w);
        } else {
            min = cmp::min(min, ans + w);
        }
    }
    min
}

fn main() {
    input!(n: usize, ab: [(usize, usize); n]);

    let ans0: usize = ab.iter().map(|&(a, _)| a).sum();
    let ans1: usize = ab.iter().map(|&(_, b)| b).sum();
    let ans2 = solve(&ab);
    println!("{}", cmp::min(cmp::min(ans0, ans1), ans2));
}


Measured memory_bytes: 15088
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/9/2018
 
 15:45-
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const LL Inf=1e15;
const int MAX_N=200+1;
int V,M,R;
LL mx[MAX_N][MAX_N];
int rs[8];

void solve() {
  REP(k,V)REP(i,V)REP(j,V) SMIN(mx[i][j],mx[i][k]+mx[k][j]);
  VI P(R);REP(i,R)P[i]=i;
  LL res=Inf;
  do {
    LL d=0;
    REP(i,R-1) {
      int u=rs[P[i]],v=rs[P[i+1]];
      d+=mx[u][v];
    }
    SMIN(res,d);
  } while(next_permutation(P.begin(),P.end()));
  
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>V>>M>>R;
  
  REP(i,V)REP(j,V)mx[i][j]=i==j?0:Inf;
  
  REP(i,R) cin>>rs[i],rs[i]--;
  REP(i,M) {
    int u,v; LL d; cin>>u>>v>>d;
    --u,--v;
    mx[u][v]=mx[v][u]=d;
  }
  solve();
  return 0;
}


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

int main() {
  long x,n,ans=0,g=99999;
  cin >> x >> n;
  vector<long> p(1000);
  vector<bool> a(100,true);
  for(long i=0;i<n;i++) cin >> p[i];
  for(long i=0;i<n;i++) a[p[i]-1]=false;

  for(long i=-1000;i<1000;i++) {
    if(i>0&&i<=100) {
      if(abs(x-i)<g&&a[i-1]) ans=i,g=abs(x-i);
    } else {
      if(abs(x-i)<g) ans=i,g=abs(x-i);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;

#define LL long long int
#define uLL unsigned long long int

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SLL(a) scanf("%lld",&a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SC(a) scanf("%c",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)
#define PLL(a) printf("%lld",a)
#define PCASE(kk) printf("Case %d: ",kk++)
#define PCASENL(kk) printf("Case %d:\n",kk++)
#define NL puts("")

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define pii pair<int,int>

template<typename T>inline T POW(T B,T P)
{
    if(P==0) return 1;
    if(P&1) return B*POW(B,P-1);
    else return SQR(POW(B,P/2));
}
template <class T> inline T BMOD(T p,T e,T m)
{
    T ret=1;
    while(e)
    {
        if(e&1) ret=(ret*p)%m;
        p=(p*p)%m;
        e>>=1;
    }
    return (T)ret;
}
template <typename T>inline T ModInv (T b,T m)
{
    return BMOD(b,m-2,m);
}
template<typename T>inline T ABS(T a)
{
    if(a<0)return -a;
    else return a;
}
template<typename T>inline T gcd(T a,T b)
{
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<typename T>inline T lcm(T a,T b)
{
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a,-b);
    return a*(b/gcd(a,b));
}


//for(__typeof(pp.begin()) i=pp.begin(); i!=pp.end(); i++ )

//knight and king move....



//int Dx[]={-2,-1,1,2,1,2,-2,-1};
//int Dy[]={-1,-2,2,1,-2,-1,1,2};
int dx[]= {-1,1,0,0};
int dy[]= {0,0,-1,1};
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
/////////////


int main()
{
    double a,b,c,res;
    cin>>a>>b>>c;

    res=(a+b)*c;
    res/=2.0;

    printf("%0.0lf\n",res);

    return 0;
}


Measured memory_bytes: 256
def dfs(i):
    global ns,flags,a
    if flags[i]:
        return []
    flags[i]=True
    out=[a[i]]
    for n in ns[i]:
        out.extend(dfs(n))
    return out
        

line=input().split()
N=int(line[0])
M=int(line[1])
a=input().split()
ns={}
for i in range(N):
    a[i]=int(a[i])
    ns[i]=[]


for i in range(M):
    line=input().split()
    x=int(line[0])
    y=int(line[1])
    ns[x].append(y)
    ns[y].append(x)

flags=[False for i in range(N)]
sets=[]
for i in range(N):
    if not flags[i]:
        sets.append(dfs(i))

if len(sets)==1:
    print ("0")
    exit(0)
if (len(sets)-1)*2>N:
    print ("Impossible")
    exit(0)

        
tot=0
for s in sets:
    s.sort()
    tot+=s[0]
more=(len(sets)-1)*2-len(sets)
al=[]
for s in sets:
    for p in s[1:]:
        al.append(p)
al.sort()
for i in range(more):
    tot+=al[i]
print(tot)


Measured memory_bytes: 38552