akhauriyash/Code-Regression huggingface dataset:
//#include<bist_stdc++.h>
#include <iostream>
#include <math.h>
#include <vector>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;

int gcd(int x, int y) {
    if(x % y == 0) {
        return y;
    } else {
        return gcd(y, x % y);
    }
}

bool IsPrime(int num) {
    if(num < 2)
        return false;
    else if(num == 2)
        return true;
    else if(num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for(int i = 3; i <= sqrtNum; i += 2) {
        if(num % i == 0) {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main() {
    int n, number, res = 0;
    cin >> n;
    rep(i, n) {
        cin >> number;
        if(IsPrime(number)) {
            res++;
        }
    }
    cout << res << endl;
}



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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    double y, x;
} p_t;

int main() {
    string a, b;
    cin >> a >> b;
    string s, t;
    s = "";
    t = "";
    for (int i = 0; i < stoi(b); i++) {
        s += a;
    }
    for (int i = 0; i < stoi(a); i++) {
        t += b;
    }
    dump(s < t ? s : t);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;
const int modint = 1000000007;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

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

  cout << ((x == 0)?1:0) << endl;
}



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

int pal(string s) {
  int n = s.length();
  int ans = 1;
  for (int i = 0; i <= n/2; i++) {
    if (s[i] != s[n-i-1]) {
      ans = 0;
      break;
    }
  }
  return ans;
}

int main(){
  string s;
  int a, b, n;
  cin >> s;
  n = s.length();

  int ans = 0;

  ans = pal(s) * pal(s.substr(0, (n-1)/2)) * pal(s.substr((n+3)/2-1, (n-1)/2));

  if (ans == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 1e6;
const int LOG = 61;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLMOD = 998244353;
const ll LLINF = 1e18;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vi cnt(n + 1);
    vi a(n);
    forn(i, n) cin >> a[i];
    vi ans;
    fornr(i, n + 1) {
        if (!i) break;
        int sum = 0;
        for (int j = i; j <= n; j += i) sum += cnt[j];
        if (sum % 2 != a[i - 1]) {
            ans.pb(i);
            cnt[i] = 1;
        }
    }
    cout << sz(ans) << "\n";
    for (int x : ans) cout << x << " ";
    cout << "\n";
}


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

using namespace std;
#define ll long long
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;

int main (){
    int n;
  	cin >> n;
    ll a[120000];
    cinf(n,a);
    int count = 0;
    bool k = false;
  	bool b = false;
    REP(i,n-1){
        if(a[i+1] - a[i] > 0){
            k = true;
            if(b){
                b = false;
              	k = false;
                count++;
            }
        }else if(a[i+1] - a[i] < 0){
            b = true;
            if(k){
                k = false;
              	b = false;
                count++;
            }
        }

    }
    cout << count + 1 << endl;



    return 0;
}

Measured memory_bytes: 1024
/**
*    author:  yuya1234
*    created: 09.07.2020 09:11:07
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  int n;
  cin>>n;

  double ans=n/1.08;

  if((int)((int)ans*1.08)==n)cout<<(int)ans<<endl;
  else if((int)(ceil(ans)*1.08)==n)cout<<ceil(ans)<<endl;
  else cout<<":("<<endl;

  return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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

int V,E,R;
#define INIT INF
typedef int Weight;
typedef pair<Weight,int> P;

struct Edge {
	int to;
	Weight cost;
	Edge(int to,Weight cost):to(to),cost(cost) {}
};

typedef vector< vector<Edge> > Graph;

bool operator<(const Edge &e,const Edge &f) {
	return e.cost!=f.cost?e.cost>f.cost:e.to<f.to;
}

void dijkstra(const Graph &G,int s,vector<Weight> &dist) {
	int n=(int)G.size();
	dist.assign(n,INIT);
	dist[s]=0;
	priority_queue< P,vector<P>,greater<P> > Q;
	Q.push(P(0,s));
	while(!Q.empty()) {
		P p=Q.top();Q.pop();
		int v=p.second;
		if(dist[v]<p.first) continue;
		for(auto e:G[v]) {
			if(dist[e.to]<=dist[v]+e.cost) continue;
			dist[e.to]=dist[v]+e.cost;
			Q.push(P(dist[e.to],e.to));
		}
	}
}

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

	cin>>V>>E>>R;
	Graph G(V);
	vector<Weight> dist(V,INIT);
	REP(i,E) {
		int u,v;Weight c;
		cin>>u>>v>>c;
		G[u].emplace_back(v,c);
	}
	dijkstra(G,R,dist);
	REP(i,V) {
		if(dist[i]==INIT) cout<<"INF"<<endl;
		else cout<<dist[i]<<endl;
	}

	return 0;
}



Measured memory_bytes: 13088
#include <bits/stdc++.h>		
using namespace std;
typedef long long int lli;

int main()
{
    	int n,m;
    	cin>>n>>m;
    	int ans = (n*(n-1)/(double)2 + m*(m-1)/(double)2);
    	cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
int N;
int T;
int X;
int main()
{
	scanf("%d %d %d", &N, &X, &T);
	printf("%d", ((int)(N/X)+(N%X==0?0:1))*T);
	return 0;
}

Measured memory_bytes: 3796
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


signed main(){
    string s;
    cin>>s;
    
    if(s=="A") cout<<"T"<<endl;
    if(s=="C") cout<<"G"<<endl;
    if(s=="G") cout<<"C"<<endl;
    if(s=="T") cout<<"A"<<endl;
}


Measured memory_bytes: 3556
from math import log10 as l
s=lambda f:sum(map(int,list(str(f))))
p=lambda a,j:(a//10**(j+1)+1)*10**(j+1)-1
n=int(input())
a=1
for i in range(n):
  print(a)
  if(a<9):
    a+=1
    continue
  a+=1
  k=[p(a,j) for j in range(int(l(a)))]
  o=[p(a,j)/s(p(a,j)) for j in range(int(l(a)))]
  a=k[o.index(min(o))]

Measured memory_bytes: 3572
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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 S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, K;
std::vector<P> ps;

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

  rep( i, N )
  {
    ll a, b;
    std::cin >> a >> b;

    ps.emplace_back( a, b );
  }

  std::sort( all(ps) );

  ll sum = 0;

  rep( i, ps.size() )
  {
    if( sum+ps[i].second >= K )
    {
      std::cout << ps[i].first << std::endl;

      return 0;
    }

    sum += ps[i].second;
  }

  return 0;
}

Measured memory_bytes: 2420
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();  
        char[] c = new char[26];
        String s = r.s();
        for(int i = 0; i < 4; i++)
            c[s.charAt(i)-'A']++;
        Arrays.sort(c);
        println(c[25] == 2 && c[24] == 2 ? "Yes" : "No");
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 21204
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

let ab=readInts()
let a=ab[0]
let b=ab[1]

if a==b{
  print(a)
}else if (a+b)%2==0{
  print((a+b)/2)
}else{
  print("IMPOSSIBLE")
}

Measured memory_bytes: 7928
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main{

static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line.split(" ")[0]);
int[] num=new int[n];
for(int i=0;i<n;i++) num[i]=Integer.parseInt(br.readLine());
int[] dp=new int[n];
dp[0]=num[0];
int len=1;
int ans=0;
for(int i=0;i<n;i++){
if(dp[len-1]<num[i]) dp[len++]=num[i];
else{
int index=Arrays.binarySearch(dp,0,len-1,num[i]);
if(index<0) index=~index;
dp[index]=num[i];
}
}
out.println(len);
}
out.flush();
}
}

Measured memory_bytes: 31708
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    string s; cin >> s;
	int n = s.size();
	if(s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
		return 0;
	}
	if(n != 26) {
		for(char a = 'a'; a <= 'z'; a++) {
			if(count(s.begin(), s.end(), a) == 0) {
				cout << s << a << endl;
				return 0;
			}
		}
	}
	string k = s;
	next_permutation(k.begin(), k.end());
	for(int i = 0; i < n; i++){
		if(s[i] != k[i]) {
			cout << k.substr(0, i + 1) << endl;
            system("pause");
			return 0;
		}
	}

    system("pause");
}

Measured memory_bytes: 504
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 100;
static const int INFTY = 1e6;

static const int NUMMAX = 300;


int main(){

  int N;
  int num;
  double ans;

  cin >> N;

  num = N / 2;
  if( N % 2 != 0 ) num++;

  ans = (double)num / (double)N;

  cout << ans << endl;

  return 0;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int IMF = 1'000'000'000; //1e9
const int MIL = -1;
const long long LIMF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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







int main(){
    int H1, M1, H2, M2, K; std::cin >> H1 >> M1 >> H2 >> M2 >> K;
    int d(60*H2+M2 - (60*H1+M1));
    std::cout << d - K << std::endl;
    return 0;
}


Measured memory_bytes: 3636
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int INF = (int)1e9;
const int maxN = 2e5 + 10;
int t[4 * maxN];
int lazy[4 * maxN];
void add(int v, int by) {
    t[v] += by;
    lazy[v] += by;
}
void merge(int v) {
    t[v] = max(t[2 * v], t[2 * v + 1]);
}
void push(int v, int tl, int tr) {
    if (tl != tr && lazy[v] != 0) {
        add(2 * v, lazy[v]);
        add(2 * v + 1, lazy[v]);
    }
    lazy[v] = 0;
}
void add(int v, int tl, int tr, int l, int r, int by) {
    if (l <= tl && tr <= r) {
        add(v, by);
        return;
    }
    push(v, tl, tr);
    if (l > tr || r < tl) return;
    int tm = (tl + tr) / 2;
    add(2 * v, tl, tm, l, r, by);
    add(2 * v + 1, tm + 1, tr, l, r, by);
    merge(v);
}
int getMax(int v, int tl, int tr, int l, int r) {
    if (l > r) return -INF;
    if (tl == l && tr == r) {
        return t[v];
    }
    push(v, tl, tr);
    int tm = (tl + tr) / 2;
    return max(getMax(2 * v, tl, tm, l, min(r, tm)), getMax(2 * v + 1, tm + 1, tr, max(tm + 1, l), r));
}

void build(int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = tl;
        return;
    }
    int tm = (tl + tr) / 2;
    build(2 * v, tl, tm);
    build(2 * v + 1, tm + 1, tr);
    t[v] = max(t[2 * v], t[2 * v + 1]);
}

int n, m;
int l[maxN], r[maxN];
vector < int > all[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> m;
    int mxl = 0;
    int mnr = m + 1;
    for (int i = 1; i <= m; i++) {
        cin >> l[i] >> r[i];
        mxl = max(mxl, l[i]);
        mnr = min(mnr, r[i]);
        all[l[i]].emplace_back(r[i]);
    }
    int mx = max(0, n - m);
    if (mxl < mnr) {
        mx = max(mx, n - (m + 1 - mnr + mxl));
    }
    build(1, 0, m + 1);
    for (int i = 0; i <= m; i++) {
        for (int v : all[i]) {
            add(1, 0, m + 1, 0, v, +1);
        }
        mx = max(mx, -i + getMax(1, 0, m + 1, i + 1, m + 1) - m - 1);
    }
    cout << mx;
    return 0;
}

Measured memory_bytes: 16128
#include<bits/stdc++.h>
#define maxn 100005
using namespace std;

int n,a[maxn],pos[maxn];
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		pos[a[i]]=i;
	}
	for(int i=1;i<=n;++i) 
	{
		printf("%d ",pos[i]);
	}
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i,N){
        cin >> v[i];
    }
    vector<int> v2;
    v2.reserve(N);
    std::sort(v.begin(),v.end());
    int mmax=*(v.rbegin());
    vector<int> dp(mmax+1);

    for(auto itr=v.begin(); itr!=v.end(); ++itr){
        int tmp=*itr;
        auto res = equal_range(itr, v.end(),tmp);

        if(dp[tmp]==0){
            if(itr==res.second-1){
                v2.push_back(tmp);
            }else{
                itr=res.second-1;
            }
            for(int i=1,tmp2=tmp; tmp2<=mmax; tmp2=tmp*(++i)){
                dp[tmp2]=1;
            }
        }
    }

    cout << v2.size() << endl;
    return 0;
}


Measured memory_bytes: 8596
use v6;
my @s = get().chomp.split('');
my @ans;

loop (my $i = 1; $i < @s.elems - 1; $i++) {
       	if ((@s[$i] eq 'B')and(0 < @ans.elems)) {
       		@ans.pop;
       	} elsif ((@s[$i] eq '0')or(@s[$i] eq '1')) {
       		@ans.push(@s[$i]);
       	}
}

for @ans -> $key {
       	print $key;
}
print "\n";

exit;

Measured memory_bytes: 69520
N=int(input())
h=list(map(int,input().split()))

water=0
alive=1
while alive:
    flag=1
    cnt=0
    for i in range(N):
        if h[i]!=0:
            cnt+=flag
            flag=0
        elif h[i]==0:
            flag=1
    alive=0
    for i in range(N):
        if h[i]>0:
            h[i]-=1
            alive=1
        else:
            h[i]=0
    if alive:
        water+=cnt
print(water)

Measured memory_bytes: 3064
import sys
def input():
    return sys.stdin.readline()[:-1]
N,Q=map(int, input().split())
S=input()
L=[None]*(N)
t=0
for i in range(N-1):
    L[i]=t
    if S[i]=="A" and S[i+1]=="C":
        t+=1
L[-1]=t
for i in range(Q):
    l,r=map(int,input().split())
    print(L[r-1]-L[l-1])

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

int main(){
  int n;
  string str;
  cin >> n >> str;
  int cnt = 0;
  for(int i = 0; i < n; i++){
    if(str[i] == 'R') cnt += 1;
  }
  if(cnt > n/2) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

vector< vector<int> > graph(100000);
queue<int> que; int N, d[100000], e[100000];

void bfs(){
	que.push(0);
	REP(i, 100000) d[i] = e[i] = INF;
	d[0] = 0; e[N-1] = 0;
	while(!que.empty()){
		int v = que.front(); que.pop();
		REP(i, graph[v].size()){
			if(d[graph[v][i]] == INF){
				que.push(graph[v][i]);
				d[graph[v][i]] = d[v]+1;
			}
		}
	}
	que.push(N-1);
	while(!que.empty()){
		int v = que.front(); que.pop();
		REP(i, graph[v].size()){
			if(e[graph[v][i]] == INF){
				que.push(graph[v][i]);
				e[graph[v][i]] = e[v]+1;
			}
		}
	}
}

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

	int a[100000], b[100000];
	cin >> N;
	REP(i, N-1) {
		cin >> a[i] >> b[i];
		graph[a[i]-1].push_back(b[i]-1);
		graph[b[i]-1].push_back(a[i]-1);
	}
	bfs();
	int f = 0, s = 0;
	REP(i, N){
		if(d[i] <= e[i]) f++;
		else s++;
	}
	cerr << f << endl << s << endl;
	if(f > s) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;

	return 0;
}


Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, i, j;
	cin >> num;
	vector<int> d(min(2 * num, 100004), 1);
	for (i = 2; i < d.size(); i++) {
		if (d[i]) {
			for (j = i << 1; j < d.size(); j += i) {
				d[j] = 0;
			}
		}
	}
	for (i = num; d[i] == 0; i++) {}
	cout << i << "\n";
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long a,b;
inline long long pd(long long x){
	if(x%4==0) return x;
	if(x%4==1) return 1;
	if(x%4==2) return x+1;
	if(x%4==3) return 0;
}
int main(){
	scanf("%lld%lld",&a,&b);
	printf("%lld\n",pd(a-1)^pd(b));
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int a[10001];
int main()
{
   int m,i,n=0;
   scanf("%d",&m);
   for(i=0;i<m;i++){
      scanf("%d",&a[i]);
      while(a[i]%2==0){
         a[i]/=2;
         ++n;
      }
   }
   printf("%d",n);
}


Measured memory_bytes: 256
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

inline void z_value(string s,vector<int> &z){
	int l=0,r=0;
	int len=sz(s);
	z.resize(len);
	z[0]=len;
	for(int i=1;i<len;++i){
		z[i]=i>r?0:(i-l+z[i-l]<z[l]?z[i-l]:r-i+1);
		while(i+z[i]<len && s[i+z[i]]==s[z[i]]) z[i]++;
		if(i+z[i]-1>r)r=i+z[i]-1,l=i;
	}
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	string s; cin>>s;
	vector<int> z;
	int ans=0;
	For(i,0,n-1){
		z_value(s,z);
		For(j,0,sz(z)-1){
			if(z[j]<=j) ans=max(ans,z[j]);
		}
		s.erase(0,1);
	}
	cout<<ans<<"\n";
	return 0;
}





























Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a[4];
    int k;
    bool flag = true;
    
    for(int i = 0; i < 5; i += 1){
        int b;
        cin >> b;
        a[i] = b;
    }
    cin >> k;
    
    for(int i = 0; i < 4; i += 1){
        for(int j = i + 1; j < 5; j += 1){
            if(a[j] - a[i] > k){
                flag = false;
                break;
            }
        }
    }
    
    if(flag){
        cout << "Yay!" << "\n";
    }else{
        cout << ":(" << "\n";
    }
}


Measured memory_bytes: 256
class Dice:
    def __init__(self):
        self.number = [i for i in range(6)]
        self.tmp = [i for i in range(6)]

    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5

    def next(self,direction):
        for i in range(6):
            self.tmp[i] = self.number[i]

        if direction == 'E':
            self.setNumber(self.tmp[3], self.tmp[1], self.tmp[0], self.tmp[5], self.tmp[4], self.tmp[2])
        elif direction == 'N':
            self.setNumber(self.tmp[1], self.tmp[5], self.tmp[2], self.tmp[3], self.tmp[0], self.tmp[4])
        elif direction == 'S':
            self.setNumber(self.tmp[4], self.tmp[0], self.tmp[2], self.tmp[3], self.tmp[5], self.tmp[1])
        elif direction == 'W':
            self.setNumber(self.tmp[2], self.tmp[1], self.tmp[5], self.tmp[0], self.tmp[4], self.tmp[3])
    def get_result(self):
        return self.number[0]

dice = Dice()
fig = list(map(int,input().split()))
dice.setNumber(fig[0],fig[1],fig[2],fig[3],fig[4],fig[5])
dire_str = str(input())

for str in dire_str:
    dice.next(str)

print(dice.get_result())









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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() //string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.14159265;
const ll MAX = 1e6;
long long fac[MAX], finv[MAX], inv[MAX];

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

// テーブルを作る前処理
void COMinit() //MODは素数じゃないとだよ！！
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  // COMinit();
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans = 0;
  ll n, a;
  cin >> n;
  vector<pll> p(n);
  rep(i, n)
  {
    cin >> a;
    p[i].first = a;
    p[i].second = i;
  }
  sort(all(p));

  rep(i, n)
  {
    if (i)
    {
      cout << " ";
    }
    cout << p[i].second + 1;
  }
  // cout << ans << endl;
}


Measured memory_bytes: 2432
N = gets.to_i
flg = 0

(0..N/7).each do |i|
  (0..N/4).each do |j|
    if 7 * i + 4 * j == N then
      flg = 1
    end
  end
end

if flg == 1 then
  puts "Yes"
else
  puts "No"
end

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

typedef long long ll;

int count_digit(ll n) {
  int digit = 0;
  while (n > 0) {
    ++digit;
    n /= 10;
  }
  return digit;
}

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

  int ans = 100;
  for (int i = 1; i <= sqrt(N); ++i) {
    if (N % i == 0) {
      int a = count_digit(i);
      int b = count_digit(N / i);
      ans = min(ans, max(a,b));
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S;
	getline(cin,S);
	REP(i,S.size()){
		if(S[i]>='A' && S[i]<='Z'){
			S[i] = tolower(S[i]);
		}
		else if(S[i]>='a' && S[i]<='z'){
			S[i] = toupper(S[i]);
		}
	}
	
	out(S);
	return 0;
}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
using   namespace std;
int main(){
    long long int n,m;
    cin>>n>>m;
    
    vector<int> a(m);
    long long int sum=0;
    
    for(int i=0;i<m;i++){
        cin>>a[i];
        sum+=a[i];
    }
    
    if(n-sum>=0)
        cout<<n-sum;
    else
        cout<<"-1";
        
    return 0;
}

Measured memory_bytes: 3644
//This Code was made by Chinese_zjc_.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <ctime>
// #include<windows.h>
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
int p[10005], tim[10005], cnt, n, ans = INF;
int power(int A, int B)
{
    int res = 1;
    while (B)
    {
        if (B & 1)
        {
            res *= A;
        }
        A *= A;
        B >>= 1;
    }
    return res;
}
void exgcd(int A, int B, int &x, int &y)
{
    if (B == 0)
    {
        x = 1;
        y = 0;
        return;
    }
    exgcd(B, A % B, x, y);
    int X = x, Y = y;
    x = -Y;
    y = -(X + A / B * Y);
}
void dfs(int now, int A, int B)
{
    if (now > cnt)
    {
        int x, y;
        exgcd(A, B, x, y);
        if (x <= 0)
        {
            int len = (-x) / B + 1;
            x += len * B;
            y += len * A;
        }
        if (y <= 0)
        {
            int len = (-y) / A + 1;
            x += len * B;
            y += len * A;
        }
        while (x > B && y > A)
        {
            x -= B;
            y -= A;
        }
        ans = min(ans, B * y);
        return;
    }
    dfs(now + 1, A * power(p[now], tim[now]), B);
    dfs(now + 1, A, B * power(p[now], tim[now]));
}
signed main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    n <<= 1;
    for (int i = 2; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            p[++cnt] = i;
            while (n % i == 0)
            {
                n /= i;
                ++tim[cnt];
            }
        }
    }
    if (n > 1)
    {
        p[++cnt] = n;
        tim[cnt] = 1;
        n /= n;
    }
    dfs(1, 1, 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int n;
    cin >> n;
    cout << (n-2)*180 << endl;
}

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

const int lim = 10e5 + 5;
const int INF = 10e9 + 5;

void maxSelf(long long &a, long long b) {
	a = max(a,b);
	return;
}

int main() {
	
	int i,N,W;
	cin>>N>>W;

	long long dp[lim]={0};

	for (i=0;i<N;i++) {
		int w,v;
		cin>>w>>v;
		for (int j=W-w;j>=0;j--) {
			maxSelf(dp[j+w],dp[j]+v);
		}
	}

	long long max1 = 0;
	for (i=0;i<=W;i++)
	if (dp[i]>max1) {
		max1=dp[i];
	} 

	cout<<max1<<"\n";



	return 0;
}

Measured memory_bytes: 8064
#include <stdio.h>

int main(void)

{


    int W,H,x,y,r,a;


    scanf("%d %d %d %d %d ",&W,&H,&x,&y,&r);


    a=0;


    if(x+r>W){


        a=1;


    }


    if(y+r>H){


        a=1;


    }


    if(r>x){


        a=1;


    }


    if(r>y){


        a=1;


    }


    if(a==0){


        printf("Yes\n");


    }


    else{


        printf("No\n");


    }


    return 0;


}

Measured memory_bytes: 588
#include<stdio.h>
typedef struct{
  int number;
  int son[2];//???
  int reach;
  int parent;
  int sibling;
  int degree;
  int height;
}node;
 
node B[10000];
int n;
int a;
int flag=0;
 
void preorder(int num){
  //  if(num!=a)printf(" ");
  printf(" %d",B[num].number);
  if(B[num].son[0]!=-1)preorder(B[num].son[0]);
  if(B[num].son[1]!=-1)preorder(B[num].son[1]);
 
}//OK
 
void inorder(int num){
  /* {
      printf(" %d",B[num].number);
      return;
      }*/
    if(B[num].son[0]!=-1)inorder(B[num].son[0]);
      printf(" %d",B[num].number);
  if(B[num].son[1]!=-1)inorder(B[num].son[1]);
 
  }
 
void postorder(int num){
   
  /* if(B[num].son[0]==-1){
    printf(" %d",B[num].number);
    return;
    }*/
if(B[num].son[0]!=-1)postorder(B[num].son[0]);
  /*  if(B[num].son[1]==-1){
    printf(" %d",B[num].number);
    return;
    }*/
  if(B[num].son[1]!=-1)postorder(B[num].son[1]);
  printf(" %d",B[num].number);
}//OK
 
int parent(int num){//parent input
  int i,j,r=-1;
  for(i=0;i<n;i++){
    for(j=0;j<2;j++){
      if(num==B[i].son[j]){
    r=i;
    return r;
      }
    }
  }
  return r;
}
 
int reach(int num){//reach input
  int i,r=0;
  for(i=0;i<n;i++){
    if(B[num].parent==-1)return r;
    else {
      num=B[num].parent;
      r++;
    }
  }
}
 
int sibling(int num){//sibling input
  int i,j,r=-1;
  for(i=0;i<n;i++){
    if(i!=num){
      if(B[num].parent==B[i].parent){
    r=i;
    return r;
      }
    }
  }
  return r;
}
 
int height(int num,int r,int parent){//height input
  //  printf("r = %d num = %d\n",r,num);
  if(parent==B[num].parent)r=0;
  if(B[num].son[0]==-1)return r;
  r++;
  r=height(B[num].son[0],r,parent);
  r=height(B[num].son[1],r,parent);
  
  return r;
}
 
int main(){
  int i,j,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    B[i].parent=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d",&a);
    B[a].number=a;
    for(j=0;j<2;j++){
      scanf("%d",&k);
      B[a].son[j]=k;
      B[k].parent=a;
      if(k==-1)B[a].degree=0;
      else B[a].degree=2;
    }
  }
 
  /*  for(i=0;i<n;i++){
    B[i].parent=parent(i);
  }
  */
   
  for(i=0;i<n;i++){
    B[i].reach=reach(i);
  }
   
  for(i=0;i<n;i++){
    B[i].sibling=sibling(i);
  }
   
  /*  for(i=0;i<n;i++){
    B[i].height=height(i,0,B[i].parent);
  }
  */
  for(i=0;i<n;i++){
    if(B[i].parent==-1){
      a=i;
      break;
    }
  }
  printf("Preorder\n");
   preorder(a);
  printf("\nInorder\n");
   inorder(a);
  printf("\nPostorder\n");
   postorder(a);
  printf("\n");
 
 
  return 0;
}

Measured memory_bytes: 620
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <list>
#include <map>
using namespace std;

#define MAX 200000

int main() {
	map<int,int> m;
	int d;
	int N;
	int M;
	int t;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &d);
//		if(i==0)
		if (m.find(d) == m.end()) {
			m.insert(make_pair(d, 1));
		}
		else {
			m[d]++;
		}
	}
//	for (int i = 0; i < N; i++) {
//		cout << m[3] << "\n";
//	}
	scanf("%d", &M);
	for (int i = 0; i < M; i++) {
		scanf("%d", &t);
		if (m.find(t) == m.end()) {
			printf("NO\n");
			break;
		}
		else {
			if (m[t] == 0) {
				printf("NO\n");
				break;
			}
			else {
				m[t]--;
			}
		}
		if(i==M-1) printf("YES\n");
	}
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5005,mod=1e9+7;
int n,a,b;
ll f[N],c[N][N],dp[N][2];
ll C(int n,int m)
{
    if(m==0||n==m) return 1;
    if(m==1) return n;
    if(c[n][m]) return c[n][m];
    return c[n][m]=(C(n-1,m-1)+C(n-1,m))%mod;
}
ll qpow(ll a,ll n)
{
    ll ans=1;
    for(;n;n>>=1,a=a*a%mod)if(n&1) ans=ans*a%mod;
    return ans;
}
int main()
{
    scanf("%d%d%d",&n,&a,&b);
    if(a>b) swap(a,b);
    f[1]=1;
    for(int i=1;i<b;i++)
    {
        f[i+1]=(f[i+1]+f[i])%mod;
        for(int j=a;i+j+1<=b;j++)
                f[i+j+1]=(f[i+j+1]+f[i])%mod;
    }
    dp[0][0]=dp[0][1]=1;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<i+a&&j<=n;j++)
            (dp[j][0]+=dp[i][1])%=mod;
        for(int j=i+1;j<i+b&&j<=n;j++)
            (dp[j][1]+=dp[i][0]*f[j-i+(i==0||j==n)])%=mod;
    }
    ll ans=qpow(2,n);
    ans=(ans-dp[n][0]-dp[n][1])%mod;
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}

Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;

vector<long long> enum_divisors(long long N) {
  vector<long long> res;
  for (long long i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      res.push_back(i);
      // 重複しないならば i の相方である N/i も push
      if (N / i != i) res.push_back(N / i);
    }
  }
  // 小さい順に並び替える
  sort(res.begin(), res.end());
  return res;
}

int main(){
    ll N;
    cin >> N;
    const auto &res = enum_divisors(N);
    ll out = 0;
    if (res.size() % 2 == 0) {
      ll x = res[res.size() / 2 - 1];
      ll y = res[res.size() / 2];
      out = x + y - 2;
    }
    else{
      out = res[res.size() / 2] * 2 - 2;
    }
    cout << out << endl;
    return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < s.size(); i++) {
    s += s.front();
    s.erase(0, 1);
    if (s == t) {
      cout << "Yes" << '\n';
      return 0;
    }
  }
  cout << "No" << '\n';
}


Measured memory_bytes: 3572
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define int long long
const int N=2e5+5;
#define ls x<<1
#define rs x<<1|1
#define lss ls,l,mid,ql,qr
#define rss rs,mid+1,r,ql,qr

int n,q,a,b,c[N];

struct xds{
    int mn[N<<2],flag[N<<2];

    void pushup(int x){
        mn[x]=min(mn[ls],mn[rs]);
    }

    void pusha(int x,int a){
        mn[x]+=a; flag[x]+=a;
    }

    void pushdown(int x){
        if(flag[x]) pusha(ls,flag[x]),pusha(rs,flag[x]),flag[x]=0;
    }

    void modify(int x,int l,int r,int ql,int qr,int c){
        if(ql>qr) return;
        if(ql<=l and r<=qr) return pusha(x,c),void();
        int mid=l+r>>1; pushdown(x);
        if(ql<=mid) modify(lss,c);
        if(mid<qr) modify(rss,c);
        pushup(x);
    }

    int query(int x,int l,int r,int ql,int qr){
        if(ql<=l and r<=qr) return mn[x];
        int mid=l+r>>1,ans=1e18; pushdown(x);
        if(ql<=mid) ans=min(ans,query(lss));
        if(mid<qr) ans=min(ans,query(rss));
        return ans;
    }
}A,B;

void build(int x,int l,int r){
    if(l==r)
        return A.mn[x]=abs(l-b)-l,B.mn[x]=abs(l-b)+l,void();
    int mid=l+r>>1;
    build(ls,l,mid),build(rs,mid+1,r);
    A.pushup(x),B.pushup(x);
}

void modify(int x,int l,int r,int ql,int qr,int c){
    if(l==r) return A.mn[x]=c-l,A.flag[x]=0,B.mn[x]=c+l,B.flag[x]=0,void();
    int mid=l+r>>1; A.pushdown(x),B.pushdown(x);
    ql<=mid?modify(lss,c):modify(rss,c);
    A.pushup(x),B.pushup(x);
}

signed main(){
    scanf("%lld%lld%lld%lld",&n,&q,&a,&b); c[0]=a;
    build(1,1,n);
    for(int i=1;i<=q;i++){
        scanf("%lld",&c[i]);
        int now=min(A.query(1,1,n,1,c[i])+c[i],B.query(1,1,n,c[i],n)-c[i]);
        modify(1,1,n,c[i-1],c[i-1],now);
        A.modify(1,1,n,1,c[i-1]-1,abs(c[i]-c[i-1]));A.modify(1,1,n,c[i-1]+1,n,abs(c[i]-c[i-1]));
        B.modify(1,1,n,1,c[i-1]-1,abs(c[i]-c[i-1]));B.modify(1,1,n,c[i-1]+1,n,abs(c[i]-c[i-1]));
    } int ans=1e18;
    for(int i=1;i<=n;i++)
        ans=min(ans,A.query(1,1,n,i,i)+i);
    printf("%lld\n",ans); return 0;
}


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

int n, A, B, C;
int l[8] = {0};
int cost = 1000000;
int how_many_bamboos = 0;
void dfs(int i, int a, int b, int c){
    if(i == n){
        if(a*b*c == 0) return ;
        cost = min (cost ,10*max(0,how_many_bamboos-3) + abs(a-A) + abs(b-B) + abs(c-C));
    }
    else{
        dfs(i+1,a,b,c);
        how_many_bamboos += 1;
        dfs(i+1,a+l[i],b,c);
        dfs(i+1,a,b+l[i],c);
        dfs(i+1,a,b,c+ l[i]);
        how_many_bamboos -= 1;
    }
}


int main(){
    cin >> n >> A >> B >> C;
    for (int i = 0; i < n; i++)
    {
        cin >> l[i];
    }
    dfs(0,0,0,0);
    cout << cost << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const int N=3005;
const double PI=acos(-1);
int n,L;
double t[N];
int main()
{
	scanf("%d%d",&n,&L);
	for(int i=1;i<=n;i++)
		scanf("%lf",&t[i]);
	double ansx=0,ansy=0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
	    {
			int cnt=j-i-1;
			ansx+=cos((t[i]+t[j])/L*PI)*(n-2*cnt-2),ansy+=sin((t[i]+t[j])/L*PI)*(n-2*cnt-2);
		}
	ansx/=1LL*n*(n-1)*(n-2)/6,ansy/=1LL*n*(n-1)*(n-2)/6;
	printf("%.15lf %.15lf",ansx,ansy);
	return 0;
}

Measured memory_bytes: 4132
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;

const int maxn = 100010;
int A[maxn],pre[maxn],N,T,best;

inline int gi()
{
	char ch; int ret = 0,f = 1;
	do ch = getchar(); while (!(ch >= '0'&&ch <= '9')&&ch != '-');
	if (ch == '-') f = -1,ch = getchar();
	do ret = ret*10+ch-'0',ch = getchar(); while (ch >= '0'&&ch <= '9');
	return ret*f;
}

int main()
{
	// freopen("B.in","r",stdin);
	// freopen("B.out","w",stdout);
	N = gi(); T = gi();
	for (int i = 1;i <= N;++i) A[i] = gi();
	pre[0] = 1<<30;
	for (int i = 1;i <= N;++i) pre[i] = min(pre[i-1],A[i]);
	for (int i = 1;i <= N;++i) best = max(best,A[i]-pre[i]);
	int ans = 0;
	for (int i = 1;i <= N;++i) if (A[i]-pre[i] == best) ++ans;
	cout << ans << endl;
	return 0;
}


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

int main()
{
	int a, b;
	cin >> a >> b;
	cout << ((a + 11) % 13 > (b + 11) % 13 ?  "Alice" : ((a + 11) % 13 < (b + 11) % 13 ? "Bob" : "Draw")) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.BigDecimal;

public class Main {
	public static void main(String[] args) {  
  		Scanner sc = new Scanner(System.in);
		double T = sc.nextInt();
      	double X = sc.nextInt();
      	BigDecimal bd = new BigDecimal(T / X);
      	System.out.println(bd.setScale(10, BigDecimal.ROUND_UP));
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
# define ll long long
# define mo 1000000009
# define maxi 100005
using namespace std;
ll dp[101][maxi]={0};
ll knap(ll v[],ll w[],ll n,ll k)
{
	if(n==0||w==0)
	return 0;
	if(dp[n-1][k]!=0)
	return dp[n-1][k];
	if(w[n-1]>k)
	dp[n-1][k]=knap(v,w,n-1,k);
	else
	dp[n-1][k]=max(knap(v,w,n-1,k),v[n-1]+knap(v,w,n-1,k-w[n-1]));
	return dp[n-1][k];
}
int main()
{
	ll n,k;
	cin>>n>>k;
	ll w[n],v[n];
	for(ll i=0;i<n;i++)
	{
		cin>>w[i]>>v[i];
	}
	ll ans=knap(v,w,n,k);
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 78080
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int x[111];
  cin>>n;
  for(int i=0;i<n;i++)cin>>x[i];
  
  sort(x,x+n,greater<int>());
  cout<<x[0]-x[n-1]<<endl;
}

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

K = int(input())
limit_list = []
upper_limit = 9
limit_list.append(upper_limit)
t_dict = {i: 1 for i in range(10)}
# 2桁目の場合
s_dict = {k: 3 for k in range(1, 9)}
s_dict[9] = 2
s_dict[0] = 2
upper_limit = upper_limit + sum(s_dict.values()) - s_dict[0]
limit_list.append(upper_limit)
ww_dict = {1: t_dict, 2: s_dict}  # 2桁目

i = 3
max_limit = 10 ** 5
while upper_limit <= max_limit:
    # 3桁目
    w_dict = {
        k: ww_dict[i - 1][k - 1] + ww_dict[i - 1][k] + ww_dict[i - 1][k + 1]
        for k in range(1, 9)
    }
    w_dict[0] = ww_dict[i - 1][0] + ww_dict[i - 1][1]
    w_dict[9] = ww_dict[i - 1][8] + ww_dict[i - 1][9]
    ww_dict[i] = w_dict
    upper_limit = limit_list[-1] + sum(w_dict.values()) - w_dict[0]
    limit_list.append(upper_limit)
    i += 1

# K = 208644

for i, l in enumerate(limit_list):
    if l >= K:
        keta = i + 1
        break

keta_list = list(range(1, keta + 1))

ans_list = []

# i-1桁目のMAX値
t = limit_list[keta - 2]

if keta == 1:
    ans_list = [K]
else:
    for i in keta_list[::-1]:
        # i桁目の数字を決めたい
        if i == keta_list[-1]:
            # iが最大桁の場合の候補の数字
            number_list = list(range(1, 10))
        else:
            if ans_list[-1] == 9:
                max_n = 9
            else:
                max_n = ans_list[-1] + 1
            min_n = 0 if ans_list[-1] == 0 else ans_list[-1] - 1
            number_list = list(range(min_n, max_n + 1))
        for n in number_list:
            if i == 1:
                w = t + 1
            else:
                w = t + ww_dict[i][n]
            if w >= K:
                ans_list.append(n)
                break
            # 超えていなかったら更新
            t = w

ans = "".join([str(i) for i in ans_list])
print(ans)


Measured memory_bytes: 3192