akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#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 each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  string s;
  cin >> s;
  string ans = "";
  for(char c :s){
    if(c == 'B'){
      if(not ans.empty()) ans.pop_back();
    }else{
      ans += c;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n;
    cin>>n;

    Vs s(n);
    rep(i,n)cin>>s[i];

    ll ans=0;

    ll lasta=0;
    ll beginb=0;
    ll both=0;

    rep(i,n){
        ll sl = s[i].length();
        if(s[i][0]=='B' && s[i][sl-1]=='A'){
            both++;
        }else if(s[i][0]=='B'){
            beginb++;
        }else if(s[i][sl-1]=='A'){
            lasta++;
        }

        rep(j,sl){
            if(j==0)continue;
            if(s[i][j]=='B' && s[i][j-1]=='A'){
                ans++;
            }
        }
    }

    if(lasta>0){
        ans += both;
        ans += min(lasta,beginb);
    }else{
        if(beginb>0){
            ans += both;
        }else{
            if(both>0){
                ans += both-1;
            }
        }
    }


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


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
ll gcd(ll a,ll b){
    return b ? gcd(b,a%b) : a;
}
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>> res;
    for(ll i=2;i*i<=n;i++){
        if(n%i) continue;
        res.emplace_back(i,0);
        while(n%i==0){
            n/=i;
            res.back().second++;
        }
    }
    if(n!=1) res.emplace_back(n,1);
    return res;
}
int main(){
    ll a,b;
    cin>>a>>b;
    ll g = gcd(a,b);
    auto f = factorize(g);
    int ans = f.size()+1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;

int pat[16][3] = {{1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, {5, 5, 5}, {6, 6, 6}, {7, 7, 7}, {8, 8, 8}, {9, 9, 9}, {1, 2, 3}, {2, 3, 4}, {3, 4, 5}, {4, 5, 6}, {5, 6, 7}, {6, 7, 8}, {7, 8, 9}};

int main(){
	
	int T;
	cin >> T;
	
	for(int loop = 0; loop < T; loop++){
		
		int count[9][3];
		int sum[9][3];
		int number[9];
		int color[9];
		
		for(int i = 0; i < 9; i++){
			cin >> number[i];
		}
		
		for(int i = 0; i < 9; i++){
			string str;
			cin >> str;
			if(str[0] == 'R'){
				color[i] = 0;
			}else if(str[0] == 'G'){
				color[i] = 1;
			}else{
				color[i] = 2;
			}
		}
		
		for(int i = 0; i < 9; i++){
			for(int j = 0; j < 3; j++){
				count[i][j] = 0;
			}
		}
		
		for(int i = 0; i < 9; i++){
			count[number[i]][color[i]]++;
		}
		
		bool flag = false;
		
		for(int i = 0; i < 48; i++){
			for(int j = 0; j < 48; j++){
				for(int k = 0; k < 48; k++){
					int index11 = i % 16;
					int index12 = i / 16;
					int index21 = j % 16;
					int index22 = j / 16;
					int index31 = k % 16;
					int index32 = k / 16;
					for(int l = 0; l < 9; l++){
						for(int m = 0; m < 3; m++){
							sum[l][m] = 0;
						}
					}
					for(int l = 0; l < 3; l++){
						sum[pat[index11][l]][index12]++;
						sum[pat[index21][l]][index22]++;
						sum[pat[index31][l]][index32]++;
					}
					bool flag2 = true;
					for(int l = 0; l < 9; l++){
						for(int m = 0; m < 3; m++){
							if(sum[l][m] != count[l][m]){
								flag2 = false;
							}
						}
					}
					if(flag2){
						flag = true;
					}
				}
			}
		}
		
		cout << flag << endl;
		
	}
	
	return 0;
}

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

using namespace std;

int main(){
  int X;
  cin >> X;
  
  long long a = 0;
  a += X / 500 * 1000;
  X %= 500;
  a += X / 5 * 5;
  
  cout << a << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int N = 0;
  cin >> N;

  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  };

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)

using namespace std;
using ull = unsigned long long;

const ull MOD = 1000000007;

int main(void)
{
    string S;
    cin >> S;
    int N = S.size();
    auto table = vc(int, 10);
    auto dp = vcd(vector<ull>, N + 1, vcd(ull, 13, 0));
    lpn(i, 10) table[i] = i;
    dp[0][0] = 1;
    int j, k, c;
    for (int i = 1; i <= N; i++)
    {
        if (S[N - i] == '?')
        {
            for (j = 0; j < 10; j++) for (k = 0; k < 13; k++) dp[i][(k+table[j]) % 13] = (dp[i][(k+table[j]) % 13] + dp[i-1][k]) % MOD;
        }
        else
        {
            c = (S[N - i] - '0');
            for (k = 0; k < 13; k++) dp[i][(k+table[c]) % 13] = (dp[i][(k+table[c]) % 13] + dp[i-1][k]) % MOD;
        }
        for (j = 0; j < 10; j++) table[j] = (table[j] * 10) % 13;
    }
    cout << dp[N][5] << endl;
    return 0;
}

Measured memory_bytes: 13696
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}

int main(){
ll N;
cin>>N;
vector<string> S(N);
ll m=0; ll a=0; ll r=0; ll c=0; ll h=0;
for(int i=0; i<N; ++i){
cin>>S[i];
if (S[i].at(0) == 'M') {m++;}
else if (S[i].at(0) == 'A') {a++;}
else if (S[i].at(0) == 'R') {r++;}
else if (S[i].at(0) == 'C') {c++;}
else if (S[i].at(0) == 'H') {h++;}
}
ll ans=0;
if(m>0&&a>0&&r>0){
ans+=m*a*r;
}
if(m>0&&a>0&&h>0){
ans+=m*a*h;
}
if(m>0&&a>0&&c>0){
ans+=m*a*c;
}
if(m>0&&c>0&&r>0){
ans+=m*c*r;
}
if(m>0&&h>0&&r>0){
ans+=m*h*r;
}
if(m>0&&h>0&&c>0){
ans+=m*h*c;
}
if(a>0&&r>0&&c>0){
ans+=c*a*r;
}
if(a>0&&r>0&&h>0){
ans+=h*a*r;
}
if(a>0&&c>0&&h>0){
ans+=h*a*c;
}
if(r>0&&c>0&&h>0){
ans+=h*c*r;
}
cout<<ans<<endl;
return 0;
}












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

using namespace std; 

int main() { 
  int K,S; 
  cin >> K >> S; 
  int res=0;
  for (int x = 0; x <= K; ++x) { 
    for (int y = 0; y <= K; ++y) {
       int z = S-x-y;
       if (z <= K && 0 <=z) ++res;
    } 
  } 
  cout << res << endl; 
} 

Measured memory_bytes: 3608
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

#[allow(unused_macros)]
macro_rules! debug {
    ($var:expr) => {
        match &$var { v => eprintln!(concat!(stringify!($var), "={:?}"), v) }
    };
    ($var:expr, $($vars:expr),*) => {
        match &$var { v => eprint!(concat!(stringify!($var), "={:?} "), v) }
        debug!($($vars),*);
    };
}

fn main() {
    let n: usize = input();
    let h: usize = input();
    let w: usize = input();
    let mut rca: Vec<(usize, usize, i32)> = (0..n).map(|_| (input(), input(), input())).collect();
    rca.sort_by_key(|&(_, _, a)| -a);

    let mut nedge = vec![0; h + w];
    let mut uf = UnionFind::new(h + w);
    let mut ans = 0;
    for &(r, c, a) in &rca {
        let (r, c) = (r - 1, h + c - 1);
        let pr = uf.find(r);
        let pc = uf.find(c);
        if pr != pc && uf.size[pr] + uf.size[pc] > nedge[pr] + nedge[pc] {
            uf.union(r, c);
            nedge[uf.find(r)] = nedge[pr] + nedge[pc] + 1;
            ans += a as i64;
        } else if pr == pc && uf.size[pr] > nedge[pr] {
            nedge[uf.find(r)] += 1;
            ans += a as i64;
        }
    }

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

struct UnionFind {
    parent: Vec<usize>,
    size: Vec<usize>,
}
#[allow(dead_code)]
impl UnionFind {
    fn new(n: usize) -> UnionFind {
        UnionFind {
            parent: (0..n).collect(),
            size: vec![1; n],
        }
    }
    fn find(&mut self, x: usize) -> usize {
        if self.parent[x] == x {
            x
        } else {
            let p = self.parent[x];
            self.parent[x] = self.find(p);
            self.parent[x]
        }
    }
    fn union(&mut self, x: usize, y: usize) -> bool {
        let mut x = self.find(x);
        let mut y = self.find(y);
        if x == y {
            false
        } else {
            if self.size[x] < self.size[y] {
                std::mem::swap(&mut x, &mut y);
            }
            self.parent[y] = x;
            self.size[x] += self.size[y];
            true
        }
    }
    fn size(&mut self, x: usize) -> usize {
        let p = self.find(x);
        self.size[p]
    }
}


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

typedef long long ll;

string a,s,t;                       //aは答え、sは読み込む文字列、tは分岐した文字列

void search(ll now, ll sum, string t){
    if(now == s.size()){
        if(sum == 7) a = t + "=7";
        return;
    }
    search(now+1, sum+s[now]-'0', t+'+'+s[now]);  //ch-'0'で数字から数値に変換
    search(now+1, sum-s[now]+'0', t+'-'+s[now]);
}
int main(){
    cin >> s;
    t = s[0];
    search(1, s[0]-'0', t);
    cout << a << endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  set<int> cnt;
  int free = 0;
  for(auto now : a){
    if(now > 3199){
      free++;
      continue;
    }
    
    int div = now / 400;
    cnt.insert(div);
  }
  
  int ans = cnt.size();
  if(ans == 0){
    ans = 1, free--;
  }
  cout << ans << " " << ans+free << endl;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
p2 = sorted(p)
num_diff = 0
for i in range(n):
    if p[i] != p2[i]:
        num_diff += 1
if num_diff == 0 or num_diff == 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 38256
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pm(m) for(auto itr=(m).begin();itr!=(m).end();itr++){itr->first<<" "<<itr->second<<"\n";}
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
#define bug(x) cout<<(x)<<" ";exit(0);
int mod = 1000000007;
int mod1 = 998244353;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int32_t main(){
	IO
	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
	double d,t,s;
	cin>>d>>t>>s;
	
	if(1.0*d/s >t )cout<<"No\n";
	else cout<<"Yes\n";
	
}

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

int main(){
    int n;
    cin >> n;
    int A[n], B[n], C[n-1];
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    for(int i = 0; i < n; i++){
        cin >> B[i];
    }
    for(int i = 0; i < n-1; i++){
        cin >> C[i];
    }
    int sumsat = 0;
    for(int i = 0; i < n; i++){
        sumsat += B[A[i]-1];
        if(A[i+1] == A[i] + 1){
            sumsat += C[A[i]-1];
        }
    }
    cout << sumsat << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

n = int(input())

d = defaultdict(int)
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            tmp = x**2 + y**2 + z**2 + x * y + y * z + z * x
            d[tmp] += 1

for i in range(1, n + 1):
    print(d[i])


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string s; cin >> s;
  string ans = "";
  
  rep(i,s.size()){
    if(s[i] == 'B' && ans.size()>0) ans.erase(ans.end()-1,ans.end());
    else if(s[i] != 'B') ans += s[i];
  }

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


Measured memory_bytes: 3584
#!/usr/bin/env python3

# import sys
# import math
# sys.setrecursionlimit(10**8)
# INF = float('inf')
# PI = math.pi()
# from functools import lru_cache
# @lru_cache(maxsize=None)

# n = int(input())
h1, m1, h2, m2, k = map(int, input().split())
# c = list(map(int, input().split()))
# s = [list(map(int,list(input()))) for i in range(h)]

if h1<=h2:
    ans = h2*60+m2 - (h1*60+m1) - k
else:
    ans = (24+h2)*60+m2 - (h1*60+m1) -k
print(ans)


Measured memory_bytes: 9164
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main()
{
	int N,x;
	cin >> N >> x;
	int res=0;
	vector<int> S(N);
	
	for (int i = 0; i < N; i++)
	{
		cin >> S.at(i);
		
	}
	sort(S.begin(), S.end());
	for (int i = 0; i < N; i++)
	{
		if (x >= S.at(i))
		{
			x -= S.at(i);
				res++;

		}
		else
		{
			break;
		}
		if (i == N - 1 && x > 0) {
			res--;
		}
	}

	cout << res<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ans,x;
map < int , bool > mp;
int main()
{
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d",&x);
		if(mp[x])
		{
			ans--;
			mp[x] = 0;
		}
		else
		{
			ans++;
			mp[x] = 1;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4864
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

int main(){
  ll N;
  cin >> N;
  ll query[N][2];
  rep(i, N) scanf("%lld %lld", query[i], query[i]+1);

  ll odd = ((query[0][0] + query[0][1]) % 2 + 2) % 2;
  rep(i, N){
    if(((query[i][0] + query[i][1]) % 2 + 2) % 2 != odd){
      odd = -1;
      break;
    }
  }

  if(odd == -1){
    cout << -1 << endl;
  }
  else if(odd){
    const ll m = 31;
    cout << m << endl;
    ll powm = 1;
    powm <<= m;
    ll d = 1;
    rep(i, m-1){
      printf("%lld ", d);
      d <<= 1;
    }
    printf("%lld\n", d);

    rep(i, N){
      ll u = (query[i][0] + query[i][1] + powm - 1) / 2;
      ll v = (query[i][0] - query[i][1] + powm - 1) / 2;
      ll mask = 1;
      rep(i, m){
        if(!(u & mask) && !(v & mask)) cout << 'L';
        if((u & mask) && (v & mask)) cout << 'R';
        if(!(u & mask) && (v & mask)) cout << 'D';
        if((u & mask) && !(v & mask)) cout << 'U';
        mask <<= 1;
      }
      cout << endl;
    }
  }
  else{
    const ll m = 31;
    cout << (m + 1 - odd) << endl;
    ll powm = 1;
    powm <<= m;
    ll d = 1;
    if(!odd) printf("%d ", 1);
    rep(i, m-1){
      printf("%lld ", d);
      d <<= 1;
    }
    printf("%lld\n", d);

    rep(i, N){
      ll u = (query[i][0] + query[i][1] + powm - odd) / 2;
      ll v = (query[i][0] - query[i][1] + powm - odd) / 2;
      ll mask = 1;
      if(!odd) cout << 'L';
      rep(i, m){
        if(!(u & mask) && !(v & mask)) cout << 'L';
        if((u & mask) && (v & mask)) cout << 'R';
        if(!(u & mask) && (v & mask)) cout << 'D';
        if((u & mask) && !(v & mask)) cout << 'U';
        mask <<= 1;
      }
      cout << endl;
    }
  }
  return 0;
}


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

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int N, K;
    cin >> N >> K;

    vector<int> p(N);
    rep(i, N) cin >> p[i];

    int X = *max_element(p.begin(), p.end());

    vector<int> sum(X + 1);
    rep(i, X) {
        sum[i + 1] = sum[i] + (i + 1);
    }

    vector<double> v(N);
    rep(i, N) {
        v[i] = (double)sum[p[i]] / p[i];
    }

    double ans = accumulate(v.begin(), v.begin() + K, (double)0);
    double res = ans;
    for (int i = K; i < N; ++i) {
        res -= v[i - K];
        res += v[i];
        ans = max(ans, res);
    }

    printf("%.10f\n", ans);
}

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

int main(){
  string s; cin >> s;
  string result="";
  for(int i=0; i<s.size(); i++){
    if(s[i]=='B'){
      if(result.size()>0){
        result.pop_back();
      }
    }else{
      result.push_back(s[i]);
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
import bisect
import sys
def inpl(): return [int(i) for i in input().split()]
def search(a,j):
    if D[j]:
        if D[j] == 1:
            return True
        else:
            return False
    H = defaultdict(lambda: 0)
    H[0] = True
    for i in a:
        for ni in H.copy().keys():
            if ni + i < K-j:
                H[ni+i] = True
                continue
            elif ni + i <= K-1:
                D[j] = 1
                return True
    D[j] = -1
    return False

N, K = inpl()
A = inpl()
A.sort()
A = A[:bisect.bisect_left(A,K)]
M = len(A)
D = defaultdict(lambda: 0)
if sum(A) < K:
    print(M)
    sys.exit()
if sum(A) == K:
    print(0)
    sys.exit()
lo = -1
hi = M
while hi - lo > 1:
    me = (hi+lo)//2
    B = A[:me] + A[me+1:]
    if search(B, A[me]):
        hi = me
    else:
        lo = me
print(hi)

Measured memory_bytes: 80988
main :: IO ()
main = do
  str1 <- getLine
  str2 <- getLine
  putStrLn $ solve str1 str2

solve :: String -> String -> String
solve s1 s2
  | s1 == s2 = "EQUAL"
  | length s1 >= length s2 && go s1 s2 = "GREATER"
  | otherwise = "LESS"
  where
    go _ [] = True
    go [] _ = False
    go (x:xs) (y:ys)
      | x == y = go xs ys
      | x > y = True
      | otherwise = False
    


Measured memory_bytes: 508
import java.util.Scanner;

public class Main {

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

        if (r < 1200) {
            System.out.println("ABC");
        } else if (r < 2800) {
            System.out.println("ARC");
        } else {
            System.out.println("AGC");
        }
    }

}


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

int N, K;

long double dfs(int score, long double rate){
    if(score >= K){
        return rate;
    }
    return dfs(score*2, rate / 2.0);
}

int main() {
  cin >> N >> K;
  
  long double total_rate = 0.0;
  for(int i=0;i<N;i++){
      total_rate += dfs(i+1, 1.0 / (long double)N);
  }

  cout << setprecision(20) << total_rate << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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; }
struct Card {
	char c;
	int v;
	Card() {}
	Card(int a) :v(a) {}
	bool operator<=(const Card &p) const{
		return v <= p.v;
	}
	bool operator==(const Card &p) const{
		return c == p.c&&v == p.v;
	}
};
istream &operator >> (istream &is, Card &p) {
	is >> p.c >> p.v;
	return is;
}
ostream &operator<<(ostream &os, Card &p) {
	os << p.c << " " << p.v;
	return os;
}
int partition(vector<Card>&a, int l, int r) {
	Card v = a[r];
	int i(l - 1);
	rep(j, l, r) {
		if (a[j]<=v) {
			swap(a[++i], a[j]);
		}
	}
	swap(a[i + 1], a[r]);
	return i + 1;
}
void quicksort(vector<Card>&a, int l, int r) {
	if (l < r) {
		int p = partition(a, l, r);
		quicksort(a, l, p - 1);
		quicksort(a, p + 1, r);
	}
}
template<typename T>
void merge(vector<T>&a, int l, int r) {
	int mid = (l + r) / 2;
	int n1 = mid - l, n2 = r - mid;
	vector<T>L(n1 + 1), R(n2 + 1);
	rep(i, 0, n1)L[i] = a[l + i];
	L[n1] = T(INF);
	rep(i, 0, n2)R[i] = a[mid + i];
	R[n2] = T(INF);
	int i(0), j(0);
	rep(k, l, r) {
		if (L[i] <= R[j])a[k] = L[i++];
		else a[k] = R[j++];
	}
}
template<typename T>
void mergesort(vector<T>&a, int l, int r) {
	if (r - l > 1) {
		int mid = (l + r) / 2;
		mergesort(a, l, mid);
		mergesort(a,mid, r);
		merge(a, l, r);
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<Card>c(N); rep(i, 0, N)cin >> c[i];
	vector<Card>cm(c), cq(c);
	quicksort(cq, 0, N - 1);
	mergesort(cm, 0, N);
	if (cq == cm)cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	rep(i, 0, N)cout << cq[i] << endl;
	return 0;
}

Measured memory_bytes: 5880
#include<stdio.h>
#include<string.h>
int main(void)
{
	char a[100];
	gets(a);
	for(int i=0;i<strlen(a)-1;i++)
		for(int j=i+1;j<strlen(a);j++)
			if(a[i]=='C'&&a[j]=='F')
				{
					printf("Yes\n");
					return 0;
				}
	printf("No\n");
	return 0;
}

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

void dfs(const vector<vector<int>> &to, const vector<int> &a, vector<int> &lis, vector<int> &ans, int v, int p) {
  int index = lower_bound(lis.begin(), lis.end(), a.at(v)) - lis.begin();
  int old = lis.at(index);
  lis.at(index) = a.at(v);
  ans.at(v) = lower_bound(lis.begin(), lis.end(), 1e9) - lis.begin();
  for (int c : to.at(v)) {
    if (c == p) continue;
    dfs(to, a, lis, ans, c, v);
  }
  lis.at(index) = old;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  vector<vector<int>> to(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    to.at(u).push_back(v);
    to.at(v).push_back(u);
  }
  vector<int> lis(n, 1e9), ans(n);
  dfs(to, a, lis, ans, 0, -1);
  for (int i = 0; i < n; i++) {
    cout << ans.at(i) << endl;
  }
}


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

typedef unsigned long long ll;
#define mod 1000000007
#define all(x) (x).begin(),(x).end()

void solve(){
  string s,t;
  cin>>s>>t;
  int cnt=t.size();
  for (int start = 0; start <= s.size() - t.size(); start++)
    {
        int diff = 0;
        for (int i = 0; i < t.size(); i++)
        {
            if (t[i] != s[start + i]) {
                diff++;
            }
        }
        cnt = min(cnt, diff);
    }
  cout<<cnt<<endl;  
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve(); 
  return 0;
}

Measured memory_bytes: 3556
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const int MOD = 1e9 + 7;



signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(a, a + n);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) cnt++;
    }
    if (cnt <= 2) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}

Measured memory_bytes: 256
kouho = [0]*(10**5+3)#-1は+2に格納

N = int(input())
a = list(map(int,input().split()))

for i in range(0,N,1):
    kouho[a[i]]+=1
    kouho[a[i]-1]+=1
    kouho[a[i]+1]+=1

print(max(kouho))


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

int main(void){
    int X;

    cin >> X;

    int sqrt2X = (int)sqrt(2.0*(double)X); //Chebyshev's theorem
    vector<int> primes;

    for(int i=2; i<=sqrt2X; i++){
        bool ifPrime = true;
        for(int p: primes){
            if(i%p==0){
                ifPrime=false;
                break;
            }
        }
        if(ifPrime)primes.push_back(i);
    }

    bool ifContinue = true;
    int pnext = X-1;
    while(ifContinue){
        ifContinue = false;
        pnext++;
        for(int p: primes){
            if(p >= pnext)break;
            if(pnext%p==0){
                ifContinue = true;
                break;
            }
        }
    }

    cout << pnext << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;

import java.lang.Math;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
import java.io.*;

public class Main{
	static int dp[][];
	static char[][]grid;
	static long ans = 0;
	static int mod = (int) (1e9+7);
	public static void main (String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int h = sc.nextInt();
		int w = sc.nextInt();
		grid = new char[h][w];
		dp = new int[h][w];
		for(int i = 0 ; i < h ; i++)
			grid[i] = sc.next().toCharArray();
        for(int i=0; i<h; i++){
            if(grid[i][0]=='#')
                break;
            dp[i][0]=1;
        }
        for(int j=0; j<w; j++){
            if(grid[0][j]=='#')
                break;
            dp[0][j]=1;
        }
        for(int i=1; i<h; i++){
            for(int j=1; j<w; j++) {
                if(grid[i][j]!='#')
                    dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
            }
        }
		pw.println(dp[h-1][w-1]);
		pw.close();
		}


	}
		

	


	
	
	
	
	 class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	 }
	

Measured memory_bytes: 38720
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


ll dp[101][2][10];
 
int main(){
    string s;
    cin >> s;
    int n = s.size();
    int m; cin >> m;

    dp[0][0][0] = 1;

    rep(i, n){
        rep(j, 2){
            rep(k, 4){
                int lim = j ? 9 : (s[i] - '0');
                for(int d=0; d<=lim; d++){
                    dp[i+1][j || d<lim][k + (d != 0)] += dp[i][j][k];
                }
            }
        }
    }

    ll ans = 0;
    ans += dp[n][1][m];
    ans += dp[n][0][m];

    cout << ans << endl;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int k,x; cin >> k >> x;

  for(int i = x-(k-1);i<=x+(k-1);i++){
    cout << i << " ";
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int S,C;
  cin>>S>>C;
  int ans;
  if(S*2>=C)
    ans=C/2;
  else{
    ans=S;
    C-=S*2;
    ans+=C/4;
  }
  cout<<ans<<endl;
  }


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

int main() {
  int N ;
  cin >> N ;

  vector<int> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
}

    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
   
    int c=1 ;
    for (int i = 0; i < N-1; i++) {
      if(vec.at(i)>vec.at(i+1)){
        c++;
      }
    }
  cout << c << endl;
        
    
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <queue> 
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
//#define int LL
#define db double
using namespace std;
const int N   = 233;
//const int mod = ;
const int INF =numeric_limits<int >::max();
#define For(n) for (int i=1;i<=n;++i)
#define rep(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}

int n,m,a[N],b[N],c[N],d[N];
int mp[N][N],ans,mat[N],vis[N];

int dfs(int u)
{
	rep(v,1,n) if (!vis[v]&&mp[u][v])
	{
		vis[v]=1;
		if (!mat[v]||dfs(mat[v]))
		{
			mat[v]=u;
			return 1;
		}
	}
	return 0;
}

signed main()
{
	read(n);
	rep(i,1,n) read(a[i]),read(b[i]);
	rep(i,1,n) read(c[i]),read(d[i]);
	rep(i,1,n)
	  rep(j,1,n) if (a[i]<c[j]&&b[i]<d[j]) mp[i][j]=1;
	rep(i,1,n) 
	{
		memset(vis,0,sizeof(vis));
		ans+=dfs(i);
	}
	return printf("%d",ans),0;
}


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

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

    long long n;
    cin >> n;
    vector<long long> A(n), B(n);

    vector<long long> C, D;
    for(long long i = 0; i < n; i++){
        cin >> A[i];
    }
    for(long long i = 0; i < n; i++){
        cin >> B[i];
        long long d = B[i] - A[i];
        if(d <= 0){
            C.push_back(d);
        }else if(d > 0){
            D.push_back(d);
        }
    }

    if(D.size() == 0){
        cout << 0 << endl;
        return 0;
    }

    sort(C.begin(), C.end());
    sort(D.begin(), D.end());

    long long ct = 0;
    for(long long i = 0; i < C.size(); i++){
        ct += C[i];
    }

    long long dt = 0;
    for(long long i = 0; i < D.size(); i++){
        dt += D[i];
    }
    
    if(-1 * ct < dt){
        cout << -1 << endl;
        return 0;
    }

    long long ans = D.size(), di = 0;
    for(long long i = 0; i < C.size(); i++){
        ans++;
        while(di < D.size()){
            long long f = D[di] + C[i];
            if(f < 0){
                C[i] += D[di];
                di++;
                if(di == D.size()){
                    cout << ans << endl;
                    return 0;
                }
            }else{
                D[di] += C[i];
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2936
import re

S2 = input()
T = input()

S_list = []

for j in range(len(S2) - len(T) + 1):
    if S2[j:(j + len(T))] == T:
        S_list.append(re.sub("\?", "a", S2))
    else:
        flag = 1
        tmp_S = ""
        for k in range(len(T)):
            if(S2[j + k] == T[k] or S2[j + k] == "?"):
                pass
            else:
                flag = 0
        if flag == 1:
            tmp = S2[:j] + T + S2[j + len(T):]
            S_list.append(re.sub("\?", "a", tmp))

if S_list == []:
    print("UNRESTORABLE")
else:
    print(sorted(S_list)[0])


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); 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;}
const long long MOD = 1000000007;
typedef long long ll;

ll n,a;
string s,t;
vector<vector<pair<ll,ll>>> v;

bool solve(int bit){
  rep(i,n){
    if(!(bit&(1<<i))) continue;
    for(auto p : v[i]){
      ll x=p.first, y=p.second;
      if(y==1 && !(bit&(1<<x))) return false;
      if(y==0 && bit&(1<<x)) return false;
    }
  }
  return true;
}

int main() {
  cin >> n;
  v.resize(n);
  rep(i,n){
    cin >> a;
    rep(j,a){
      ll x,y; 
      cin >> x >> y;  x--;
      v[i].emplace_back(x,y);
    }
  }
  ll ans=0;
  rep(i,1<<n)if(solve(i)){
    bitset<15> b=i;
    chmax(ans,(ll)b.count());
  }
  cout << ans << endl;
}

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

int main (){
    long long X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    
    long long memo = min(K, X/D);
    K -= memo;
    X -= memo*D;
    
    if(K%2) {
        cout << D - X << endl;
    } else {
        cout << X << endl;
    }




}


Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int ans;
int main(int argc, char* argv[]){
  long int a=0,b,c;
  scanf("%ld %ld %ld",&a,&b,&c);
  if (b+c<a) {
    printf("0");
    return 0;
  }
  printf("%d\n",(b+c)-a);
}


Measured memory_bytes: 128
//
//  main.c
//  ITP1_5_A
//
//  Created by k16031kk on 2018/05/21.
//  Copyright © 2018年 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int H=0, W=0;
    scanf("%d %d", &H, &W);
    while(H!=0 || W!=0) {
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
        scanf("%d %d", &H, &W);
    }
    
    return 0;
}



Measured memory_bytes: 2100
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N;

signed main() {
    cin >> N;

    vector<pii> v(N);
    rep(i,0,N) {
        int p; cin >> p;
        v[i] = make_pair(p, i);
    }

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

    int ans = 0;
    set<int> S;
    S.insert(-INF);
    S.insert(INF);
    rep(i,0,N) {
        // printf("value = %lld, index = %lld\n", i+1, v[i].second);
        auto r = S.upper_bound(v[i].second);
        auto l = r; l--;
        // printf("l = %lld, r = %lld\n", *l, *r);

        int cl = 1, cr = 1;
        if(abs(*r) == INF) cr = N - v[i].second;
        else cr = *r - v[i].second;

        if(abs(*l) == INF) cl = v[i].second + 1;
        else cl = v[i].second - *l;
        // printf("cl = %lld, cr = %lld\n", cl, cr);

        ans += v[i].first * cl * cr;
        S.insert(v[i].second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<cmath>
#include<cctype>
#include<algorithm>
using namespace std;
int main(){
	int a,p,x,y=0,sum=0;
	cin>>a>>p;
	sum=a*3+p;
	if(sum<2)cout<<0<<endl;
	else {
     cout<<sum/2<<endl;
	}
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let T: Vec<i64> = (0..N)
        .map(|_| {
                let mut line: String = String::new();
                std::io::stdin().read_line(&mut line).unwrap();
                line.trim().parse().unwrap()
        })
        .collect();

    fn gcd(a: i64, b: i64) -> i64 {
        if b == 0 {
            a
        } else {
            gcd(b, a % b)
        }
    }

    let ans = T[1..].iter().fold(T[0], |res, &t| res / gcd(res, t) * t);

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


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

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

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

    int64_t n, a, b;
    cin >> n >> a >> b;

    if (n < a + b - 1 or n > a * b) {
        cout << -1 << endl;
        return 0;
    }

    vector<int64_t> seq(n);
    map<int64_t, int> map;

    int next = 0;

    repeat (i, a) {
        int64_t e = a * b - a + i;
        seq[next++] = e;
        map[e] = 0;
    }

    int64_t num = n - (a + b - 1);

    for (int i = 1; i < b; i++) {
        int64_t e = a * b - a * (i + 1);
        seq[next++] = e;
        map[e] = 0;

        for (int j = 1; num > 0 and j < a; j++) {
            if (num > 0) {
                e++;
                num--;

                seq[next++] = e;
                map[e] = 0;
            }
        }
    }

    int id = 1;
    for (auto& mp : map) mp.second = id++;

    for (int64_t e : seq) {
        cout << map[e] << " ";
    }
    cout << endl;

    return 0;
}


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

struct day
{
  int kind[4];
  int order;
  int sum;
};

int n, k;
int a[100], b[100];
day dp[101];

int main()
{
  cin >> n >> k;
  for(int i = 0; i < k; i++)
    cin >> a[i] >> b[i];

  for(int i = 0; i < k; i++)
    dp[a[i]].order = b[i];

  //day 1
  if(dp[1].order)
    dp[1].sum = dp[1].kind[dp[1].order] = 1;
  else
    for(int i = 1; i <= 3; i++)
      dp[1].sum += dp[1].kind[i] = 1;

  //day 2
  if(dp[2].order)
    dp[2].sum = dp[2].kind[dp[2].order] = dp[1].sum;
  else
    for(int i = 1; i <= 3; i++)
      dp[2].sum += dp[2].kind[i] = dp[1].sum;

  //day 3
  for(int i = 3; i <= n; i++){
    if(dp[i].order){
      if(!dp[i - 1].kind[dp[i].order])
	dp[i].sum = dp[i].kind[dp[i].order] = dp[i - 1].sum;
      else
	dp[i].sum = dp[i].kind[dp[i].order] = dp[i - 1].sum - dp[i - 1].kind[dp[i].order] + dp[i - 2].sum - dp[i - 2].kind[dp[i].order];
    }
    else{
      for(int j = 1; j <= 3; j++){
	
	if(!dp[i - 1].kind[j])
	  dp[i].sum += dp[i].kind[j] = dp[i - 1].sum;
	else
	  dp[i].sum += dp[i].kind[j] = dp[i - 1].sum - dp[i - 1].kind[j] + dp[i - 2].sum - dp[i - 2].kind[j];
      }

      dp[i].sum %= 10000;
    }
  }

  cout << (dp[n].sum + 100000) % 10000 << endl;
  return 0;
}

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

const int N_MAX = 1e5, H_MAX = 1e9;

int n, k;
int h[N_MAX + 2];

int ans;

int main() {

    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> h[i];

    sort(h + 1, h + n + 1);

    ans = H_MAX;
    for(int i = k; i <= n; i++)
        ans = min(ans, h[i] - h[i - k + 1]);

    cout << ans << '\n';

    return 0;
}


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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        string S, T;
        cin >>S >>T;
        int s=S.size();
        int t=T.size();
        int N=s-t+1;
        int ANS=t;
        Rep0(i, N) {
                int A=0;
                Rep0(j, t)
                        if (S.at(i+j)!=T.at(j))
                                A++;
                ANS=min(ANS, A);
        }
        cout <<ANS <<endl;
        return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		java.util.Scanner scan = new Scanner(System.in);

		int masu = scan.nextInt();
		long[] height = new long[masu];
		boolean flg = false;
		long max = 0;

		for(int i=0;i<masu;i++) {
			height[i] = scan.nextLong();
		}

		for(int i=0;i<masu-1;i++) {
			max = Math.max(max,height[i]);
			if(height[i] > height[i+1]) {
				if(height[i]-1 > height[i+1] || height[i]-1 !=max-1) {
				flg = true;
				}
			}
		}
		System.out.println(flg?"No":"Yes");
		scan.close();
	}

}


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> b(m);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    
    for (int i = 0; i < n; i++) {
        int c = 0;
        for (int j = 0; j < m; j++) {
            c += (a[i][j] * b[j]);
        }
        printf("%d\n", c);
    }
}



Measured memory_bytes: 3304
N = int(input())
*A, = list(map(int, input().split()))
for i in range(N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(*A)


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

int main(){
  int N;
  cin>>N;
  int A[N+1];
  for(int i=0; i<N; i++) cin>>A[i];
  int flg = 1;
  for(int i=0; i<N; i++){
    if(A[i]%2==0) {
      if(A[i]%3!=0 && A[i]%5!=0){
        flg = 0;
      }
    }
  }
  flg == 1 ? printf("APPROVED\n") : printf("DENIED\n");
}


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

typedef long long ll;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b&&b==c){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int v[200];
ll mx;
int n,k;
void take (ll l, ll r){
    int mv = l + (n-r+1);
    if(mv<=k){
        priority_queue <ll> q;
        ll sum = 0;
        for(int i=1;i<=l;i++){
            sum += v[i];
            if(v[i]<0)q.push(v[i]*-1);
        }
        for(int i=n;i>=r;i--){
            sum += v[i];
            if(v[i]<0)q.push(v[i]*-1);
        }
        mx = max(mx,sum);
        mv = abs(mv-k);
        while(!q.empty()){
            if(mv>0){
                mv--;
                sum+=q.top();
                q.pop();
            }
            else break;
        }
        mx = max(mx,sum);
    }
}
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }
    for(int i=0;i<=n;i++){
        for(int j=n+1;j>i;j--){
            take(i,j);
        }
    }
    cout<<mx<<newl;

}


Measured memory_bytes: 256