akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <cstring>

#define ll long long
#define ld long double
#define HS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define INF 0x3f3f3f3f3f3f3f3f
#define point complex <double> 
#define pi acos(-1)
#define mod 1000000007


using namespace std;


int main() {
	HS;
	int n, m;
	cin >> n >> m;
	ll sum = 0,ans=0;
	map< int, int > cnt,zer;
	cnt[0] = 1;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		sum += x;
		ans += cnt[sum % m];
		cnt[sum % m]++;
	}
	cout << ans << endl;
	


	return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); 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--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    int n, m;
    cin >> n >> m;
    vector<int> s(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        s[a-1]++;
        s[b-1]++;
    }
    rep(i, n) cout << s[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	lint H, W, N;
	cin >> H >> W >> N;

	map<pair<int, int>, int> data;
	//vector<pair<lint, lint>> data;
	vector<lint> ans(10, 0);
	ans[0] = (H - 2) * (W - 2);

	for (int i = 0; i < N; i++)
	{
		lint tmp_x, tmp_y;
		cin >> tmp_x >> tmp_y;
		for (int j = max(tmp_x - 1, (lint)2); j <= min(tmp_x + 1, H - 1); j++)
		{
			for (int k = max(tmp_y - 1, (lint)2); k <= min(tmp_y + 1, W - 1); k++)
			{

				data[make_pair(j, k)]++;
			}
		}
	}

	for (auto pos : data)
	{

		ans[0]--;
		ans[pos.second]++;
	}
	for (auto out : ans)
	{
		cout << out << endl;
	}
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 56576
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;
typedef long long ll;

int main(){

 int n; cin>>n;

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

    int cnt=0,mini = 1e18;

 for(int i=0;i<n;i++)
 {
   mini = min(a[i],mini);
   if(mini == a[i])
        cnt++;
 }
  cout<<cnt<<endl;

 return 0;
}


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

int main(){
    int N; cin >> N;
    
    int ans=1;
    bool flag=false;
    rep(i,N){
        int a; cin >> a;
        if(ans==a){
            ans++;
            flag=true;
        }
    }
    if(flag){
        cout << N-(ans-1)<< endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a[3];
    int tmp = 0;
    for (int i = 0; i < 3; i++)
    {
        scanf("%d", &a[i]);
    }

    for (int i = 0; i < 3; i++)
    {
        for (int j = i + 1; j < 3; j++)
        {
            if (a[i] > a[j])
            {
                tmp = a[j];
                a[j] = a[i];
                a[i] = tmp;
            }
        }
    }

    printf("%d %d %d\n", a[0], a[1], a[2]);
    return 0;
}


Measured memory_bytes: 2008
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	string s, t; 
  	cin >> s >> t;
	int cnt = 0;
  	rep(i,3) if(s[i] == t[i]) cnt++;
	cout << cnt << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

int main()
{
 int n;
 cin>>n;
 vector <int> vec;
 for(int i=0;i<n-1;i++)
 {
     int x;
     cin>>x;
     vec.push_back(x);
 }
 vector <int> ans;
 ans.push_back(vec[0]);
 for(int i=1;i<n-1;i++)
 {
     ans.push_back(min(vec[i],vec[i-1]));
 }
 ans.push_back(vec[n-2]);
 long long sum=0;
 for(auto v:ans)
     sum+=v;
 cout<<sum;
}


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

using namespace std;
using ll = long long;
constexpr ll MOD = 998244353;
constexpr int NMAX = 200010;

ll fact[NMAX], invfact[NMAX];

ll modexp(ll b, ll e) {
	if (e == 0) return 1;
	else return (e & 1 ? b : 1) * modexp(b * b % MOD, e / 2) % MOD;
}

ll binom(int n, int r) {
	return fact[n] * invfact[r] % MOD * invfact[n - r] % MOD;
}

int main() {
	int n, m, k; scanf("%d %d %d", &n, &m, &k);
	fact[0] = 1;
	for (int i = 1; i < NMAX; ++i) fact[i] = fact[i-1] * i % MOD;
	invfact[NMAX - 1] = modexp(fact[NMAX - 1], MOD - 2);
	for (int i = NMAX - 2; i >= 0; --i) invfact[i] = invfact[i + 1] * (i + 1) % MOD;
	ll ans = 0;
	for (int s = 0; s <= k; ++s) {
		ll cTerm = m * binom(n - 1, s) % MOD * modexp(m - 1, n - 1 - s) % MOD;
		ans = (ans + cTerm) % MOD;
	}
	printf("%lld\n", ans);
	return 0;
}


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

int main(){
  string s;
  cin >> s;
  if(s=="SUN")cout << 7 << endl;
  if(s=="MON")cout << 6 << endl;
  if(s=="TUE")cout << 5 << endl;
  if(s=="WED")cout << 4 << endl;
  if(s=="THU")cout << 3 << endl;
  if(s=="FRI")cout << 2 << endl;
  if(s=="SAT")cout << 1 << endl;
  //if(s=="SUN")cout << 7 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <climits>
#include <algorithm>
#include <cmath>
#include <string>
#include <fstream>
#include <ctime>
#include <cstdlib>
using namespace std;

int maxvalues(int a,int b,int c,int k)
{
	int enfazla=0;
	if((k-a)>0)
	{
		enfazla+=a;
		k-=a;
	}
	else{
		enfazla+=k;
		return enfazla;
	}
	if((k-b)<=0)
	{
		return enfazla;
	}
	else if((k-b)>0)
	{
		enfazla-=(k-b);
	}
	return enfazla;
}



int main()
{
	int enfazla=0;
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	cout<<maxvalues(a,b,c,k);
	return 0;
}

Measured memory_bytes: 3624
//submitted by Himj
  #include<bits/stdc++.h>
  #define ll long long
  #define mod 1000000007
  #define pb push_back
  #define fi first
  #define se second
  #define fr(i,s,e) for(i=s;i<e;i++)
  #define ms(arr,val) memset(arr,val,sizeof(arr))
  using namespace std;

  const int mxn=2e5+1;

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

    int t=1;
    //cin>>t;
      while(t--){
        int n,i;
        cin>>n;
        double arr[n];
        string s;
        double ans=0,bit=0;
        fr(i,0,n)
        {
          cin>>arr[i];
          cin>>s;
          if(s[0]=='J')
            ans+=arr[i];
          else bit+=arr[i];
        }
        ans+=bit*380000.0;
        cout<<ans;
        
         
      }
    return 0;
    }



Measured memory_bytes: 256
N = input()
l = len(N)
ans = 0

if l == 1:
    ans = int(N)
elif l == 2:
    ans = 9
elif l == 3:
    ans =  int(N) + 9 - 99
elif l == 4:
    ans = 909
elif l == 5:
    ans = int(N)+ 909 - 9999
else:
    ans = 90909
    
print(ans)

Measured memory_bytes: 9092
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
queue<int>q;
vector<int>E[N];
int n,m,ans;
int dp[N],indegree[N];
signed main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) 
	{
		int x,y;
		scanf("%d%d",&x,&y);
		E[x].push_back(y); 
		indegree[y]++;
	}
    for (int i=1;i<=n;i++) 
		if(!indegree[i]) 
			q.push(i);
    while(!q.empty()) 
	{
    	int u=q.front(); 
		q.pop();
    	for(int i=0;i<E[u].size();i++) 
		{
			int uu=E[u][i];
			indegree[uu]--;
			if(!indegree[uu]) 
			{
				dp[uu]=dp[u]+1;
				q.push(uu);
			}
		}
	}
	int maxn=0;
	for(int i=1;i<=n;i++) 
		maxn=max(maxn,dp[i]);
	printf("%d\n", maxn);
	return 0;
}

Measured memory_bytes: 6528
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int K = sc.nextInt();
        int X = sc.nextInt();

        if(500*K >= X)
        {
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
        // 出力
        //System.out.println();
    }
}

Measured memory_bytes: 21844
N=int(input())
ls=[int(s) for s in input().split()]
ls.reverse()
for i in range(1,N):
  if ls[i]<=ls[i-1]:
    continue
  if ls[i]==ls[i-1]+1:
    ls[i]-=1
  else:
    print('No')
    break
else:
  print('Yes')

Measured memory_bytes: 14224
import sys
sys.setrecursionlimit(1000000)
s=input()
#print(s)
l=[-1 for _ in range(len(s)+1)]
def aa(ix,v): #ixはlベース
# print(ix,v,l)
  if (ix>= len(s) and v==1) or (ix==0 and v==0-1):
    return
  if v==1 and s[ix]=="<" and l[ix+1]<=l[ix]:
    l[ix+1]=l[ix]+1
    aa(ix+1,1)
  elif v==-1 and s[ix-1]==">" and l[ix-1]<=l[ix]:
    l[ix-1]=l[ix]+1
    aa(ix-1,-1)
  return

for i in range(0,len(s)):
  if i ==0 and s[0]=="<":    
    l[0]=0
    aa(i,1)
  elif i==len(s)-1 and s[-1]==">":
    l[-1]=0
    aa(i+1,-1)
  elif s[i]==">" and s[i+1]=="<":
    l[i+1]=0
    aa(i+1,1)
    aa(i+1,-1)

print(sum(l))



Measured memory_bytes: 439444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    string S; cin >> S;

    if (S == "Sunny") cout << "Cloudy" << endl;
    if (S == "Cloudy") cout << "Rainy" << endl;
    if (S == "Rainy") cout << "Sunny" << endl;
} 

Measured memory_bytes: 256
typedef  long long ll;
#include <bits/stdc++.h>
using namespace std;
ll MOD;
long long modpow(long long a, long long n) {
      long long res = 1;
      while (n > 0) {
          if (n & 1) res = res * a % MOD;
          a = a * a % MOD;
          n >>= 1;
      }
      return res;
  }
ll inv_mul(ll x, ll y){
     return (x % MOD* modpow(y,MOD-2))%MOD;
 }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n,p;
    std::cin >> n>>p;
    MOD = p;
    
    string s;
    std::cin >> s;
    
    vector<ll> sum(n+1,0);
    
    if(p==2){
        ll ans = 0;
        for (int i = 0; i < n; i++) {
            if((s[i]-'0')%2==0){
                ans+=i+1;
            }
        }
        std::cout << ans << std::endl;
        return 0;
    }else if(p==5){
        ll ans = 0;
        for (int i = 0; i < n; i++) {
            if((s[i]-'0')%5==0){
                ans+=i+1;
            }
        }
        std::cout << ans << std::endl;
        return 0;
    }
    
    for (int i = 0; i < n; i++) {
        int x = s[i]-'0';
        sum[i+1] = (sum[i]*10+x)%p;
    }
    
    map<ll,ll> lis;
    lis[0]++;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        int x = s[i]-'0';
        ans += lis[inv_mul((x+sum[i]*10)%p,modpow(10,i))];
        lis[inv_mul(sum[i+1],modpow(10,i))]++;
    }
    
    std::cout << ans << std::endl;
}


Measured memory_bytes: 2580
def greedy():
    global qhsd, n
    ret = 0
    ret += (n//2)*qhsd[-1]
    ret += (n % 2)*qhsd[-2]
    return ret


qhsd = [int(x) for x in input().split()]
n = int(input())
for i in range(1, 4):
    qhsd[i] = min(qhsd[i-1]*2, qhsd[i])
print(greedy())


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

int main(){
    string weather[3] = {"Sunny","Cloudy","Rainy"};
    string tw;
    cin >> tw;
    for(int i=0;i<3;i++){
        if(tw==weather[i]) cout << weather[(i+1)%3];
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int pc(int i) {
	return __builtin_popcount(i);
}
int arr[1<<17];
int getl(int n, int i) {
	return (n >> (i+1)) << (i+1);
}
int getr(int n, int i) {
	return n ^ ((n >> i) << i);
}
int rmbit(int n, int i) {
	return (getl(n, i) >> 1) | getr(n, i);
}
int addbit(int n, int i, bool p) {
	return ((n >> i) << (i+1)) | getr(n, i) | (p ? (1 << i) : 0);
}
void f(int n, int a, int b, int l) {
	if(n == 1) {
		arr[l] = a;
		arr[l+1] = b;
		return;
	}
	for(int i=0; i<n; i++) {
		if((a&(1<<i)) == (b&(1<<i))) continue;
		int ap = rmbit(a, i), bp = rmbit(b, i), c = ap^1;
		f(n-1, ap, c, l);
		f(n-1, c, bp, l+(1<<(n-1)));
		for(int j=l; j<l+(1<<n); j++)
			arr[j] = addbit(arr[j], i, j<(l+(1<<(n-1))) ? a&(1<<i) : b&(1<<i));
		return;
	}
	assert(0);
}
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	if((pc(a)&1) == (pc(b)&1)) {
		return !(cout << "NO");
	}
	cout << "YES\n";
	f(n, a, b, 0);
	for(int i=0; i<(1<<n); i++) {
		cout << arr[i] << ' ';
	}
}

Measured memory_bytes: 1536
#include <iostream>

#define N_MAX 100
#define M_MAX 100000
#define NIL -1

using namespace std;

int n;
int a[N_MAX],dp[N_MAX][M_MAX];

//can make m after a[i] or not
bool solve(int i,int m){
  if(dp[i][m]!=NIL) return dp[i][m];
  if(m==0){
    dp[i][m]=1;
  }else if(i>=n){
    dp[i][m]=0;
  }else if(solve(i+1,m)){
    dp[i][m]=1;
  }else if(solve(i+1,m-a[i])){
    dp[i][m]=1;
  }else{
    dp[i][m]=0;
  }
  return dp[i][m];
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<=M_MAX;j++){
      dp[i][j]=NIL;
    }
  }
  for(int i=0;i<n;i++) cin >> a[i];
  int q; cin >> q;
  for(int i=0;i<q;i++){
    int x; cin >> x;
    if(solve(0,x)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef int64_t ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

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; }

void solve(int N, int K) {
  if (K > (N - 1) * (N - 2) / 2) {
    cout << -1 << endl;
    return;
  }

  int M = N - 1 + (N - 1) * (N - 2) / 2 - K;
  cout << M << endl;
  REP(i, N - 1) cout << 1 << " " << (i + 2) << endl;
  int cnt = N - 1;
  for (int i = 2; i <= N; i++) for (int j = i + 1; j <= N; j++) {
    if (cnt == M) return;
    cout << i << " " << j << endl;
    cnt++;
  }
}

int main(){
  int N, K;
  cin >> N >> K;
  solve(N, K);
  return 0;
}



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

int main()
{
  int num1,num2,num3;
  num3 = 0;
  cin >> num1 >> num2;

  if(num1 == 1 && num2 == 2)
  {
    num3 = 3;
  }
  else if(num1 == 1 && num2 == 3)
  {
    num3 = 2;
  }
  else if(num1 == 2 && num2 == 3)
  {
    num3 = 1;
  }
  else if(num1 == 2 && num2 == 1)
  {
    num3 = 3;
  }
  else if(num1 == 3 && num2 ==2)
  {
    num3 = 1;
  }
  else
  {
    num3 = 2;
  }
  cout << num3 << endl;
}


Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

std::vector<int> sieve(int n) {
  std::vector<int> res(n);
  std::iota(res.begin(), res.end(), 0);
  for (int i = 2; i * i < n; ++i) {
    if (res[i] < i) continue;
    for (int j = i * i; j < n; j += i)
      if (res[j] == j) res[j] = i;
  }
  return move(res);
}

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  auto sv = sieve(N + 1);



  i64 result = 0;
  FOR(i, 1, N + 1) {
    int n = i;
    map<int, int> mp;
    while (n > 1) {
      mp[sv[n]]++;
      n /= sv[n];
    }
    for (auto p : mp) {
      n *= p.second + 1;
    }
    result += (i64)i * n;
  }
  cout << result;

  /*
  vector<int> as(N + 1);
  as[1] = 1;
  vector<map<int, int>> bs(N + 1);
  FOR(i, 2, N + 1) {
    //bs[i][1] = 1;

    if (sv[i] == i) {
      bs[i][i] = 1;
    }
    else {
      bs[i] = bs[i / sv[i]];
      bs[i][sv[i]]++;
    }

    /*
    debug(i);
    for (auto p : bs[i]) {

      cout << p.first << ":" << p.second << newl;
    }
  }
  
  i64 result = 0;
  FOR(i, 1, N + 1) {
    int n = 1;
    for (auto p : bs[i]) {
      n *= p.second + 1;
    }
    result += (i64)i * n;
  }
  cout << result;
  */
}
#endif


Measured memory_bytes: 42188
import java.util.*;

public class Main {

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

    int ax = Math.abs(x-a);
    int bx = Math.abs(x-b);

    if (ax > bx) {
      System.out.println("B");
    } else {
      System.out.println("A");
    }

  }

}


Measured memory_bytes: 21588
#include <stdio.h>

int main(void)
{
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a<b){
		printf("a < b\n",a,b);
		}
	
	else if(a>b){
		printf("a > b\n",a,b);
		}
		
	else
	    printf("a == b\n",a,b);
	
	return 0;
}
	


Measured memory_bytes: 2048
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) { new MainClass().solve(); }

        Scanner cin = new Scanner();


        string S;
        void solve() {
            S = cin.next();

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < S.Length;i++){
                if (S[i] == '0')
                    sb.Append("0");
                else if (S[i] == '1')
                    sb.Append("1");
                else if(sb.Length!=0)
                    sb.Length--;
            }

            string ans = sb.ToString();

            Console.WriteLine(ans);

        }
        class Scanner {
            string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
            public Scanner() { nextBuffer = new string[0]; BufferCnt = 0; }
            public string next() {
                if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                BufferCnt = 0;
                return nextBuffer[BufferCnt++];
            }
            public int nextInt() { return int.Parse(next()); }
            public long nextLong() { return long.Parse(next()); }
            public double nextDouble() { return double.Parse(next()); }
        }
        class Mathf {
            private int mod = 1000000007;//10^9+7
            public int Mod { get; set; }
            public Mathf() { }
            public Mathf(int mod) { this.mod = mod; }
            public long Pow(long a, long b) {
                if (b == 0) return 1;
                if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
                else return Pow(a * a % mod, b / 2) % mod;
            }
            public long Fact(long n) { return n != 0 ? (n % mod * (Fact(n - 1) % mod) % mod) : 1; }
            public long C(long n, long r) {if (r == 0 || n == r) return 1;
                else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod;}
        }
    }
}

Measured memory_bytes: 13140
import java.util.*;
import java.io.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int x = 7%k;
    int count = 1;
    while(x!=0 && count<=(int)(1e6+1)) {
        x = ((x*10)%k + 7)%k;
        count++;
    }
    if(count>=(int)(1e6+1)) System.out.println(-1);
    else System.out.println(count);
  }
}

Measured memory_bytes: 35840
#include<bits/stdc++.h>
using namespace std;
struct edge{ int to,cost; };
 
double p;
int N;
vector<edge> G[100005];
 
double x[100005];
 
void dfs(int pos,int prev){
  x[pos]=0;
  for(int i=0;i<(int)G[pos].size();i++){
    edge e=G[pos][i];
    if(e.to==prev)continue;
    dfs(e.to,pos);
    x[pos]+=(double)(x[e.to]+e.cost)*p;
  }
}
 
double solve(int pos,int prev){
  double res=x[0];
  for(int i=0;i<(int)G[pos].size();i++){
    edge e=G[pos][i];
    if(e.to==prev)continue;
    res+=( solve(e.to,pos) + e.cost )*p;
  }
  return res;
}
 
int main(){
  cin>>p;
  cin>>N;
  for(int i=0;i<N-1;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--,b--;
    G[a].push_back( (edge){b,c} );
    G[b].push_back( (edge){a,c} );
  }
  dfs(0,-1);
  /*
  for(int id=0;id<N;id++){
    printf("%d %.10f\n", id,x[id]);
  }
  */
  printf("%.10f\n", solve(0,-1));
  return 0;
}

Measured memory_bytes: 17304
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se sceond
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007

using namespace std;

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

int main()
{
    IOS;
    ll n;
    cin>>n;
    string s;
    cin>>s;
    repf(i,0,s.length())
    {
        s[i]=(s[i]-'A'+n)%26+'A';
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;



public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] Aline = new int[N];
		int[] Bline = new int[N];

		Aline[0] = sc.nextInt();
		for (int i = 1; i < N; i++) {
			Aline[i] += sc.nextInt() + Aline[i-1];
		}


		Bline[0] = sc.nextInt();
		for (int i = 1; i < N; i++) {
			Bline[i] += sc.nextInt() + Bline[i-1];
		}
		int max = 0;
		int amount = 0;
		for (int i = 0; i < N; i++) {
			if (i == 0) {
				amount = Aline[i] + Bline[N-1];
			}else {
				amount = Aline[i] + Bline[N-1] - Bline[i-1];
			}

			max = Math.max(max, amount);

		}
		System.out.println(max);

	}
}


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

using namespace std;

typedef long long ll;

const ll mod = 1e9+7;
const int N = 2e5;

ll iv[N+1];

ll po(ll b, ll p){
    ll r =1;
    for(; p; b=b*b%mod, p/=2)
        if(p&1)
            r = r*b%mod;
    return r;
}
ll nck(ll n, ll k){
    ll ans = 1;
    for(int i=1; i<=k; i++)
        ans = ans*(n-i+1)%mod*iv[i]%mod;
    return ans;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    iv[1] =1;
    for(int i=2; i<=N; i++)
        iv[i] =mod-mod/i*iv[mod%i]%mod;
    ll ans = po(2, n)-1;
    cout << (ans+2*mod-nck(n, a)-nck(n, b)+mod)%mod;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

void solve(int m, ll k){
    printf("(m,k) = (%d,%lld)\n", m,k);
    int n = pow(2,m);
    vector<int> v;
    rep(i,n){
        v.push_back(i);
        v.push_back(i);
    }
    int cnt = 0;
    do{
        bool ng = false;

        rep(r,n*2){
            rep(l,r){
                if(v[l] != v[r]) continue;
                int sum = 0;
                for(int i = l; i <= r; i++){
                    sum ^= v[i];
                }
                if (sum != k) {
                    ng = true;
                    break;
                }
            }
            if (ng) break;
        }
        if(!ng){
            cnt++;
        }
    }while(next_permutation(all(v)));
    cout << cnt << endl;
}

int main(void){
    int m;
    ll k;
    cin >> m >> k;
    ll n = pow(2LL,m);
    if (k >= n || (m == 1 && k == 1)) {
        cout << -1 << endl;
        return 0;
    }
    vector<int> v;
    if (m <= 1) {
        rep(i,m+1){
            v.push_back(i);
            v.push_back(i);
        }
    } else {
        v.push_back(k);
        rep(i,n){
            if (i == k) continue;
            v.push_back(i);
        }
        v.push_back(k);
        rep(i,n){
            int j = n-1-i;
            if (j == k) continue;
            v.push_back(j);
        }
    }
    rep(i,n*2){
        cout << v[i] << (i < n*2-1 ? " " : "\n");
    }
    return 0;
}


Measured memory_bytes: 2932
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
int ans = 1000000007;
int N, A, B, C; 
vector<int> l; 
void dfs(int mp, int i, int a, int b, int c) {
  if(i == N) {
    if(a == 0 || b == 0 || c == 0) return;
    int tmp = abs(A - a) + abs(B - b) + abs(C - c) + mp;
    if(ans > tmp) ans = tmp;
    return;
  }
  dfs(mp, i + 1, a, b, c);
  if(a == 0) dfs(mp, i + 1, a + l[i], b, c);
  else dfs(mp + 10, i + 1, a + l[i], b, c);
  if(b == 0) dfs(mp, i + 1, a, b + l[i], c);
  else dfs(mp + 10, i + 1, a, b + l[i], c);
  if(c == 0) dfs(mp, i + 1, a, b, c + l[i]);
  else dfs(mp + 10, i + 1, a, b , c + l[i]);
}
int main() {
  cin >> N;
  cin >> A >> B >> C;
  l.resize(N); REP(i, N) cin >> l[i];
  dfs(0, 0, 0, 0, 0);
  cout << ans << endl;
}

Measured memory_bytes: 3596
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        int sum = 0;

        for(int i = 0;i<n;i++){
            p[i] = sc.nextInt();
        }

        Arrays.sort(p);
        
        sum +=(p[n-1]/2);

        for(int i =0;i<n-1;i++){
            sum+=p[i];
        }

        System.out.println(sum);



    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
const double PI = acos(-1.0);
const long mod = 1000000007;

int main() {
  int n;
  cin >> n;
  for(int i = n/1.1; i <= n; i++) {
    if((int)(i*1.08) == n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}


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

int main(){
    ll n;
    int i,j;
    cin>>n;

    ll m=n*2;
    ll a=1;
    while(a*a<=m) a++;
    a--;
    if(a*(a+1)==m){
        vector<ll> v[a+1];
        ll k=a+1;
        ll loop=1;

        for(i=0;i<k;i++){
            for(j=i+1;j<k;j++){
                v[i].push_back(loop);
                v[j].push_back(loop);
                loop++;
            }
        }

        /*
        ll comb=(1<<2) -1;
        ll loop=1;
        while(comb< 1<<k){
            for(i=0;i<k;i++){
                if(comb>>i &1==1) v[i].push_back(loop);
            }
            loop++;
            ll x=comb&-comb;
            ll y=comb+x;
            comb=((comb&~y)/x>>1)|y;
        }*/

        cout<<"Yes"<<endl;
        cout<<k<<endl;
        for(i=0;i<k;i++){
            cout<<k-1;
            for(j=0;j<v[i].size();j++) {
                cout<<" "<<v[i][j];
            }
            cout<<endl;
        }  
    }
    
  /*if(n==1) {
        cout<<"Yes"<<endl;
        cout<<2<<endl;
        cout<<"1 1"<<endl;
        cout<<"1 1"<<endl;
    }
    else if(n==3){
        cout<<"Yes"<<endl;
        cout<<3<<endl;
        cout<<"2 1 2"<<endl;
        cout<<"2 3 1"<<endl;
        cout<<"2 2 3"<<endl;
    }*/
    else {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3200
n, m = map(int, input().split()) #n: 展望台の数, m: 道の数
height = list(map(int, input().split())) #高さリスト.nコある.
ans_set = set(range(1, n+1))

for i in range(m):
  a, b = map(int, input().split())
  if height[a-1] >= height[b-1]:
    ans_set.discard(b)	#setのdiscardは存在しない場合は何もしない.
  if height[a-1] <= height[b-1]:
    ans_set.discard(a)
    
print(len(ans_set))

Measured memory_bytes: 22524
A, B, C, K = [int(n) for n in input().split()]
c = 0
k = K
c += min(A, K)
K -= min(A, K)
if K==0:
    print(c)
else:
    K -= B
    if K==0:
        print(c)
    else:
        c -= K
        print(c)


Measured memory_bytes: 9184
#include <cstdio>
#include <algorithm>
#define SIZE 33554432
char Key[128];
int Hash;
char* c;
#define HASH(A) c = A; Hash = 1; while(*c){ Hash <<= 2; Hash += Key[*c]; ++c;}
using namespace std;
int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    Key['A'] = 0;
    Key['C'] = 1;
    Key['G'] = 2;
    Key['T'] = 3;
    bool* dic = new bool[SIZE];
    fill(dic, dic + SIZE, false);
    int n;
    std::scanf("%d\n", &n);
    char str[21];
    for (int i = 0; i < n; ++i) {
        fgets(str, 21, stdin);
        if (str[0] == 'i') {
            HASH(str + 7)
                dic[Hash] = true;
        }
        else {
            HASH(str + 5)
                puts((dic[Hash] ? "yes" : "no"));
        }
    }
    return 0;
}

Measured memory_bytes: 35408
package main

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

func main() {
	N := nextInt()

	min := N
	for i := 2; i*i <= N; i++ {
		if N%i != 0 {
			continue
		}

		v := N / i
		num := max(v, i)
		if num < min {
			min = num
		}
	}

	fmt.Println(len(fmt.Sprint(min)))
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	if x < y {
		return x
	}

	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}

	return y
}

// ---------- Util.


Measured memory_bytes: 640
import math

def read_input():
    a, b = input().split()
    return a, b

def submit():
    a, b = read_input()
    t = a + b
    t = int(t)

    root_t = math.floor(math.sqrt(t))
    if root_t*root_t == t:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    submit()


Measured memory_bytes: 38512
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto H = s[1];
    auto D = s[2];

    auto F = new long[](N+1);
    F[0] = F[1] = 1;
    foreach (i; 2..N+1) F[i] = F[i-1] * i % MOD;
    long co = 0;
    foreach (i; 1..N+1) co = (co + F[i]) % MOD;

    auto dp = new long[](H+1);
    dp[0] = F[N];

    auto st = new LazySegmentTree!(long, long, (a,b)=>(a+b)%MOD, (a,b)=>(a+b)%MOD, (a,b)=>(a+b)%MOD, (a,b)=>a*b%MOD, 0L, 0L)(H+1);
    st.update(0, 0, 1);

    foreach (i; 0..H) {
        if (i == 0) {
            st.update(i+1, min(i+D, H), F[N]);
        } else {
            long tmp = st.query(i, i);
            st.update(i+1, min(i+D, H), tmp*co%MOD);
        }
    }

    st.query(H, H).writeln;
}

class LazySegmentTree(T, L, alias opTT, alias opTL, alias opLL, alias opPrd, T eT, L eL) {
    T[] table;
    L[] lazy_;
    int n;
    int size;

    this(int n) {
        this.n = n;
        size = 1;
        while (size <= n) size <<= 1;
        size <<= 1;
        table = new T[](size);
        lazy_ = new L[](size);
        table[] = eT;
        lazy_[] = eL;
    }

    void push(int i, int a, int b) {
        if (lazy_[i] == eL) return;
        table[i] = opTL(table[i], opPrd(lazy_[i], b - a + 1));
        if (i * 2 + 1 < size) {
            lazy_[i*2] = opLL(lazy_[i*2], lazy_[i]);
            lazy_[i*2+1] = opLL(lazy_[i*2+1], lazy_[i]);
        }
        lazy_[i] = eL;
    }

    T query(int l, int r) {
        if (l > r) return eT;
        return query(l, r, 1, 0, n-1);
    }

    T query(int l, int r, int i, int a, int b) {
        if (b < l || r < a) return eT;
        push(i, a, b);
        if (l <= a && b <= r) {
            return table[i];
        } else {
            return opTT(query(l, r, i*2, a, (a+b)/2), query(l, r, i*2+1, (a+b)/2+1, b));
        }
    }

    void update(int l, int r, L val) {
        if (l > r) return;
        update(l, r, 1, 0, n-1, val);
    }

    void update(int l, int r, int i, int a, int b, L val) {
        if (b < l || r < a) {
            push(i, a, b);
        } else if (l <= a && b <= r) {
            lazy_[i] = opLL(lazy_[i], val);
            push(i, a, b);
        } else {
            push(i, a, b);
            update(l, r, i*2, a, (a+b)/2, val);
            update(l, r, i*2+1, (a+b)/2+1, b, val);
            table[i] = opTT(table[i*2], table[i*2+1]);
        }
    }
}

Measured memory_bytes: 45776
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, K, a[200000], b[1 << 19];
ll s[200001], res;
vector<lP>v;

void add(int x) {
	int t = x + (1 << 18);
	while (t) {
		++b[t];
		t >>= 1;
	}
}
int find(int l, int r, int k, int p, int q) {
	if (p <= l&&r <= q)
		return b[k];
	if (q <= l || r <= p)
		return 0;
	return find(l, (l + r) / 2, k * 2, p, q) + find((l + r) / 2 + 1, r, k * 2 + 1, p, q);
}

int main() {
	cin >> N >> K;
	for (int i = 0; i != N; ++i) {
		cin >> a[i];
		a[i] -= K;
		s[i + 1] = s[i] + a[i];
	}
	for (int i = 0; i != N + 1; ++i)
		v.push_back(mkp(s[i], i));
	sort(v.begin(), v.end());
	for (int i = 0; i != v.size(); ++i) {
		res += find(0, (1 << 18) - 1, 1, 0, v[i].second);
		add(v[i].second);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 10352
#include<iostream>

using namespace std;

int main()
{
    int a,b,c;
    int cnt=0;

    cin>>a>>b>>c;
    for(int i=a;i<=b;i++)
    {
        if(c%i==0)
        {
            cnt++;
        }
    }

    cout<<cnt<<endl;

    return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define print(a) cout<<(a)<<endl;
#define to_ll(b) stoll(b)
#define MOD 1000000007

int main(){
	int a,b,c,k,ans; cin>>a>>b>>c>>k;
	ans=0;
	rep(i,0,k){
		if(a>0){
			ans++;
			a--;
			continue;
		}
		else if(b>0){
			b--;
			continue;
		}
		else ans--;
	}
	cout<<ans;
			
	
	
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
void fail() { cout << -1 << '\n'; exit(0); }
// const int INF  = 1<<30;
const ll INFll = 1ll<<61;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  int n; cin >> n;
  V a(n), b(n); cin >> a >> b;

  const int M = 51;

  VVll dist(M, Vll(M, INFll));
  rep(i, M) rep2(k, 1, M) chmin(dist[i][i%k], 1ll<<k);
  rep(i, M) chmin(dist[i][i], 0ll);

  ll S = 0;
  while (true) {
    rep(i, M) rep2(k, 1, M) if (S>>k&1) chmin(dist[i][i%k], 0ll);
    VVll dp(M, Vll(M, INFll));
    rep(i, M) {
      dp[i][i] = 0;
      drep(j, M) rep(k, M) chmin(dp[i][j], dp[i][k] + dist[k][j]);
    }

    ll cmax = 0;
    rep(i, n) chmax(cmax, dp[a[i]][b[i]]);
    if (cmax == INFll) fail();
    if (cmax == 0) break;
    int k = fLog2(cmax);
    S |= (1ll<<k);
  }

  cout << S << '\n';
  return 0;
}


Measured memory_bytes: 3668
require 'prime'

def _divisors(primes, k)
  Enumerator.new do |y|
    if primes.size == k
      y << 1
    else
      p, e = primes[k]
      _divisors(primes, k + 1).each {|d|
        (e + 1).times {|e1|
          y << p ** e1 * d
        }
      }
    end
  end
end

def divisors(n)
  _divisors(Prime.prime_division(n), 0).to_a.sort
end

n = gets.to_i
arr = divisors(n)
min = 1000000001
arr.each do |r|
  l = n / r
  max = [r.to_s.length, l.to_s.length].max
  min = [min, max].min
end
puts min

Measured memory_bytes: 2300
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    ll x; cin >> x;
    ll ans = 0;
    ld capital = 100;
    for(ll i = 1; i <= 4000; i++){
        capital += floor(capital * 0.01);
      
        if (floor(capital) >= x) {ans = i; break;}
    }
    //deb(capital);
    cout << ans;
    return 0;
}


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

int main() {

	int n, k;
	cin >> n >> k;

	string s;
	cin >> s;

	s[k-1] += 'a' - 'A';	//大文字を小文字に変換．逆なら-=

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	map<int, int> m;
	rep(i, n){
		int a;
		cin >> a;
		a /= 400;
		if(a > 8) a = 8;
		m[a]++;
	}
	int mn, mx;
	mn = mx = 0;
	for(auto p : m){
		if(p.first < 8){
			mn++;
			mx++;
		}else{
			if(mn == 0)mn++;
			mx += p.second;
		}
	}
	cout << mn << " " << mx << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 998244353;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

string S;
int N;
ll dp[200009][2][3][3];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>S;
    N=S.size();
    
    if(N<=7){
        set<string> T,R;
        T.insert(S);
        while(T.size()){
            set<string> U;
            for(auto t:T){
                R.insert(t);
                rep(i,N-1){
                    if(t[i]!=t[i+1]){
                        string a=t;
                        a[i]=a[i+1]='a'+'b'+'c'-a[i]-a[i+1];
                        if(R.count(a)==0){
                            U.insert(a);
                            R.insert(a);
                        }
                    }
                }
            }
            T=U;
        }
        cout1(R.size())
        return 0;
    }
    
    int cnt[3]={};
    int tot=0;
    rep(i,N){
        int c=S[i]-'a';
        cnt[c]++;
        tot+=c;
    }
    
    rep(i,3)if(cnt[i]==N){
        cout1(1)
        return 0;
    }
    
    dp[1][0][0][0]=1;
    dp[1][0][1][1]=1;
    dp[1][0][2][2]=1;
    FOR(i,1,N){
        rep(j,2)rep(x,3)rep(y,3)rep(z,3){
            (dp[i+1][j|(x==z)][z][(y+z)%3]+=dp[i][j][x][y])%=MOD;
        }
    }
    
    ll ret=1;
    rep(i,3) ret+=dp[N][1][i][tot%3];
    rep(i,N-1)if(S[i]==S[i+1]){
        ret--;
        break;
    }
    cout1(ret%MOD)
}

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

int main() {
  string S;
  cin >> S;
  int count = 0;
  for (int i = 0; i < S.length(); i++) {
    for (int j = 0; j < S.length(); j++) {
      if (S.at(i) == S.at(j)) {
        count++;
      }
    }
  }
  count -= S.length();
  if (count>0) {
    cout << "no";
  }
  else {
    cout << "yes";
  }
}

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

int main(){
    ll i, j;
    string s, t;
    cin >> s >> t;
    vector<ll> c_idx[26];
    for(i = 0; i < s.length(); i++){
        c_idx[s[i] - 'a'].push_back(i);
    }
    ll next[26][s.length()];
    for(i = 0; i < 26; i++){
        ll k = 0;
        if(c_idx[i].size() == 0)
            continue;
        for(j = 0; j < c_idx[i].size(); j++){
            ll t = c_idx[i][j];
            while(k < t){
                next[i][k] = t;
                k++;
            }
        }
        while(k < s.length()){
            next[i][k] = c_idx[i][0];
            k++;
        }
    }
    ll a = 0;
    j = s.length() - 1;
    for(i = 0; i < t.length(); i++){
        if(c_idx[t[i] - 'a'].size() == 0){
            a = -1;
            break;
        }
        ll n = next[t[i] - 'a'][j];
        if(n <= j){
            a += n + s.length() - j;
        }
        else{
            a += n - j;
        }
        j = n;
    }
    cout << a << endl;
}

Measured memory_bytes: 21824
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;

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

	cin >> N >> M;
	cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define LL long long
#define MOD 1e9+7
#define pi acos(-1.0)
#define ULL unsigned long long
#define mem_1(str) memset(str,-1,sizeof(str))
#define mem0(str) memset(str,0,sizeof(str))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
using namespace std;
const int maxn = 110;
const int INF = 0x3f3f3f3f;
char str1[1000],str2[1000];
int main()
{
	int i;
	while(scanf("%s",str1))
	{
		if(str1[1]=='\0'&&str1[0]=='.') break;
		else 
		{
			int flag=0,flag2=0;
			int q=0;
			scanf("%s",str2);
			for(i=0;str1[i]!='\0';i++,q++)
			{
				if(str1[i]==str2[q])
				{
					if(str1[i]=='"')
					{
						i++;q++;
							while(str1[i]!='"')
						{
							if(str1[i]!=str2[q]) 
							{
								flag++;
								break;
							}
							q++;
							i++;
						}
						if(str1[i]=='"'&&str2[q]!='"')
							flag++;
						while(str2[q]!='"')
							{
								q++;
							}
						while(str1[i]!='"')
						{
							i++;
						}
						
						
				    }		
				}
				else if(str2[q]=='\0') break;
				else 
				{
					flag2=1;
					break;
				}
			}
			if(str1[i]=='\0'&&str2[q]!='\0'||str1[i]!='\0'&&str2[q]=='\0')
			{
				printf("DIFFERENT\n");
			}
			else if(flag==1&&flag2==0)
			{
				printf("CLOSE\n");
			}
			else if(flag>1||flag2==1)
			{
				printf("DIFFERENT\n");
			}
			else
			{
				printf("IDENTICAL\n");
			}
		}
		mem0(str1);
		mem0(str2);
	}
	return 0;
}


Measured memory_bytes: 3144