akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define N 100005
int main()
{
	
	int n;
	cin>>n;
	int d[N];
	for(int i=0;i<n;i++)
		cin>>d[i];
	d[0]--;
	for(int i=1;i<n;i++)
		if(d[i]<d[i-1])
		{
			cout<<"No\n";
			return 0;
		}
		else d[i]=max(d[i-1],d[i]-1);
	cout<<"Yes\n";
	
	return 0;
}

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

int main() {
    int r, g, b, k;
    scanf("%d%d%d%d", &r, &g, &b, &k);
    for (int i = 0; i < k; i++) {
        if (b <= g || b <= r) {/* bが最大じゃないとき，bを2倍 */
            b *= 2;
        } else if (r >= g) {
            g *= 2;
        } else {
            b *= 2;
        }

        if (r < g && g < b) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

const ll N=1e5;
mat G(2*N+1);
vec al(2*N+1);
ll b,w,rec;

void dfs(ll f, ll cur, ll pre) {
  al[f]=1;
  if(cur) b++;
  else w++;
  for(ll t:G[f]) {
    if(t==pre) continue;
    if(al[t]) {
      rec++;
      continue;
    }
    dfs(t,1-cur,f);
  }
}

int main() {
  ll n;
  cin >> n;
  for(ll i=0;i<n;i++) {
    ll x,y;
    cin >> x >> y;
    G[x].push_back(y+N);
    G[y+N].push_back(x);
  }
  vec al(2*N+1);
  ll ans=0;
  for(ll i=1;i<=N;i++) {
    if(al[i]) continue;
    if(!G[i].size()) continue;
    b=0,w=0,rec=0;
    dfs(i,0,-1);
    ans+=b*w;
  }
  ans-=n;
  cout << ans << endl;
}

Measured memory_bytes: 17932
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k=0;
string s, t;


int main()
{
	int t;
	cin >> n>>t>>a;
	vector<int> h(n);
	rep(i, n)cin>>h[i];
	long double hikaku =100000000; int y=0;
	rep(i,n)
	{
		long double x = t - h[i] * 0.006;
		if(abs(a-x)<hikaku)
		{
			hikaku = abs(a-x); y = i + 1;
		}
	}
	cout << y << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition) cout << "Yes" << '\n'; else{ cout << "No" << '\n'; }
#define YES(condition) if(condition) cout << "YES" << '\n'; else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition) cout << "yes" << '\n'; else{ cout << "no" << '\n'; }




int main() {
    ll n, m;
    cin >> n >> m;
    set<ll> st;
    for(ll i = 1; i <= sqrt(m); i++){
        if(m % i == 0){
            st.insert(i);
            st.insert(m / i);
        }
    }
    ll ans = 1;
    for(auto &x : st){
        if(x * n <= m){
            ans = x;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int dp[10][1<<10][1000], n; //nの制約は自明だけど sはどれくら(ry
int rec( int now, int used,int sum){
  if( sum < 0 ) return 0;
  if( now == n ) return sum == 0;
  if(~dp[now][used][sum]) return dp[now][used][sum];
  int ret = 0;
  for(int i = 0 ; i < 10 ; i++ ){
    if((used >> i) & 1)
      ret += rec( now + 1, used&~(1 << i), sum - i * (now + 1));
  }
  return dp[now][used][sum] = ret;
}
int main(){
  int s;
  while(cin >> n >> s){
    fill_n( **dp, 10 * (1 << 10) * 1000, -1);
    cout << rec( 0, (1 << 10) - 1, s) << endl;
  }
}

Measured memory_bytes: 41160
#include <cstdio>           // printf(), scanf()
#include <set>

using namespace std;

const int MAX_N = 10000;
const int MAX_R = 5000;

void
solve(int n)
{
	int bins[MAX_N / 2];
	set<int> remains;
	int re[MAX_R];

	int ix = 0;
	for (int i = 1; i < n; ++i)
	{
		int r = (i * i) % n;

		if (remains.find(r) == remains.end())
		{
			remains.insert(r);
			re[ix++] = r;
		}
	}

	int m = (n - 1) / 2;
	for (int i = 1; i <= m; ++i)
		bins[i] = 0;

	for (int i = 0; i < ix; ++i)
	{
		for (int j = 0; j < ix; ++j)
		{
			if (i != j)
			{
				int d = re[i] - re[j];
				if (d < 0)
					d += n;

				if (d > m)
					d = n - d;

				bins[d]++;
			}
		}
	}

	for (int i = 1; i <= m; ++i)
		printf("%d\n", bins[i]);
}

int
main(int argc, char **argv)
{
	while (true)
	{
		int n;
		scanf("%d", &n);
		if (n == 0)
			break;

		solve(n);
	}

	return 0;
}

Measured memory_bytes: 2972
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
signed main(){
  Int a,b;
  cin>>a>>b;
  cout<<max({a+b,a-b,a*b})<<endl;
  return 0;
}


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

int main () {
	
	vector <long long int> v(3);
	long long int xa=0, xb=0, xc=0;

	set <vector<long long int> > sv;


	scanf("%lld %lld %lld", &v[0], &v[1], &v[2]);

	

	bool flag = 0;
	int cuenta = 0;
	while (true) {

		sort(v.begin(), v.end());
		//sv.insert(v);

		if (v[0]%2 == 0 && v[1]%2 == 0 && v[2]%2 == 0 && sv.find(v) == sv.end()) {
			sv.insert(v);

			xa = v[0]; xb=v[1]; xc=v[2];
			v[0] = (xb/2) + (xc/2);
			v[1] = (xa/2) + (xc/2);
			v[2] = (xa/2) + (xb/2);
			//printf("%lld %lld %lld\n", a, b, c); 
			cuenta++;
		}
		else {
			if (sv.find(v) != sv.end()) flag = 1;
			break;
		}

	}

	if (flag) printf("-1\n");
	else printf("%d\n", cuenta);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	int x,y,z;
	cin>>x>>y>>z;
	x=x-z;
	y=y+z;
	z=x/y;
	cout<<z;
	return 0;
}

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

int main()
{
    int n,c,t;
    cin>>n;
    c=0;
    t=0;
    for(int i=1;i<=n;i++)
    {
        if(i%2==1){
        for(int j=1;j<=i;j++)
        {
            if(i%j==0)
                c++;
        }
        if(c==8)
           t++;

        c=0;
        }
    }
    cout<<t<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REV(a) reverse(a.begin(),a.end())
#define SORT(a) sort(a.begin(),a.end())
#define inf (int)1e9
#define linf (ll)1e18
#define mod (inf+7)

int n,m;
ll d[111111];
vpii g[111111];
bool v[111111];

void dfs(int x){
		v[x]=1;
		FOR(i,0,g[x].size()){
				int to=g[x][i].second,val=g[x][i].first;
				if(v[to]){
						if(d[to]!=val+d[x]){
								cout<<"No\n";
								exit(0);
						}
						continue;
				}
				d[to]=d[x]+val;
				dfs(to);


		}



}

int main() {
		ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
		memset(v,0,sizeof(v));
		cin>>n;
		cin>>m;
		FOR(i,0,m){
				int l,r,d;
				cin>>l>>r>>d;
				g[l].push_back({d,r});
				g[r].push_back({-d,l});
		}
		FOR(i,1,n+1){
				if(!v[i]){
						dfs(i);
				}
		}
		cout<<"Yes\n";

		return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
#define INF 10000000000000LL
#define DIM 100007
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update> myset;
typedef  pair< long long, pair<long long, long long> > ppll;
ll n,m,c,x,x2,y2,e,h,k,res1,a1,a2,w,a3,y,z,a4,a5,a6,last,dist,LL,timer,start,finish,maxmask,newmax,reslast,tests,police,brothers;
string s,s1;
ld res;
ld mas[3007],dp[3007][3007];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>mas[i];
    }
    dp[1][1]=mas[1];
    dp[1][0]=1-mas[1];
    for(int i=2;i<=n;i++){
        for(int j=0;j<=i;j++){
            dp[i][j]=dp[i-1][j]*(1-mas[i])+dp[i-1][j-1]*mas[i];
        }
    }
    for(int i=(n+1)/2;i<=n;i++){
        res+=dp[n][i];
    }
    cout<<fixed<<setprecision(10)<<res<<endl;

}


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

int n,m,ans;
vector<int>x,y,z,p;

int find(int x){
    if(p[x]==x)return x;
    return p[x]=find(p[x]);
}
void merge(int x,int y){
    x--,y--;
   int rootx=find(x);
   int rooty=find(y);
   if(rooty!=rootx){
       p[rootx]=rooty;
       ans--;
   }
}
int solve(){
   rep(i,m)merge(x[i],y[i]);
   return ans;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);

cin>>n>>m;
rep(i,m){
    int xi,yi,zi;
    cin>>xi>>yi>>zi;
    x.push_back(xi);
    y.push_back(yi);
    z.push_back(zi);
}
p.resize(n);
rep(i,n){
    p[i]=i;
}
ans=n;
cout<<solve()<<endl;
return 0;
}

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

typedef long long int ll;
typedef pair<int, int> P;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

struct tuko {
  int s;
  int t;
  int x;
};

// ====================================================================

int main() {
  int n, q;
  cin >> n >> q;
  vector<tuko> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].s >> v[i].t >> v[i].x;
    v[i].s -= v[i].x;
    v[i].t -= v[i].x;
  }

  sort(v.begin(), v.end(), [](auto a, auto b) { return a.x < b.x; });

  int d;
  set<P> s;
  for (int i = 0; i < q; i++) {
    cin >> d;
    s.insert(make_pair(d, i));
  }

  vector<P> ans;
  for (int i = 0; i < n; i++) {  // 手前の工事区間から
    if (s.empty()) break;
    auto it = s.lower_bound(P(v[i].s, -1));  // 左端を探す
    while (it != s.end() && it->first < v[i].t) {
      ans.push_back(P(it->second, v[i].x));
      it = s.erase(it);
    }
  }
  while (!s.empty()) {
    ans.push_back(P(s.begin()->second, -1));
    s.erase(s.begin());
  }

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

  for (auto x : ans) {
    cout << x.second << endl;
  }
}


Measured memory_bytes: 15348
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;

#define _GLIBCXX_DEBUG
#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end())

void Add(ll &a, ll b){
    a=(a+b)%mod;
    return;
}

void Pro(ll &a, ll b){
    a=(a*b)%mod;
    return;
}


int main(){
    ll N,Q; cin>>N>>Q;
    set<P> x,y;
    x.insert(mp(0,0)); x.insert(mp(N,N));
    y.insert(mp(0,0)); y.insert(mp(N,N));
    ll ans=(N-2)*(N-2);
    rep(i,Q){
        ll a,t; cin>>a>>t;
        if(a==1){
            auto itr=x.upper_bound(mp(t,-INF));
            ans-=((*itr).second-2);
            y.insert(mp((*itr).second-1,t));
        }
        else{
            auto itr=y.upper_bound(mp(t,-INF));
            ans-=((*itr).second-2);
            x.insert(mp((*itr).second-1,t));
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 16088
h,n = map(int, input().split())
magic = []
INF = 10**8
 
for i in range(n):
    a,b = map(int, input().split())
    magic.append([a, b])
 
dp = [[INF for j in range(h+1)] for i in range(n+1)] #体力がjのモンスターをi番目の魔法までを使って倒せる消費魔力の最小値
 
for i in range(n):
    for j in range(h):
        if j+1 > magic[i][0]:
            dp[i+1][j+1] = min(dp[i][j+1], dp[i][j+1-magic[i][0]] + magic[i][1], dp[i+1][j+1-magic[i][0]] + magic[i][1])
        else:
            dp[i+1][j+1] = min(dp[i][j+1], magic[i][1])
            
print(dp[n][h]) 

Measured memory_bytes: 125916
//2020.1.9
//s1270188 xxxmk2
//alds1_08b

#include<stdio.h>
#include<stdlib.h>

//struct
struct node{
  int key;
  struct node *p, *l, *r;
};
typedef struct node *Node;

//prototype
void insert(int);
Node find(int,Node);
void pr_pre(Node);
void pr_in(Node);
void del_all(Node);

//global
Node root;

int main(){
  int num, i, j;
  char cmd[10];
  
  //input
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%s",cmd);

    if(cmd[0]=='i'){//insert
      scanf("%d",&j);
      insert(j);
    }
    
    else if(cmd[0]=='f'){//find
      scanf("%d",&j);

      if(find(j,root)!=NULL) printf("yes\n");
      else printf("no\n");
    }
      
    else if(cmd[0]=='p'){//print
      pr_in(root);
      printf("\n");
      pr_pre(root);
      printf("\n");
    }
  }

  del_all(root);
  return 0;
}

void insert(int n){
  Node x=root, y=NULL, z;

  z=malloc(sizeof(struct node));
  z->key=n;
  z->l=z->r=NULL;

  while(x!=NULL){
    y=x;
    if(z->key < x->key) x=x->l;
    else x=x->r;
  }
  z->p=y;

  if(y==NULL) root=z;
  else if(z->key < y->key) y->l=z;
  else y->r=z;
  
}

void pr_pre(Node data){
  printf(" %d",data->key);
  if(data->l!=NULL) pr_pre(data->l);
  if(data->r!=NULL) pr_pre(data->r);
}

void pr_in(Node data){
  if(data->l!=NULL) pr_in(data->l);
  printf(" %d",data->key);
  if(data->r!=NULL) pr_in(data->r);
}

void del_all(Node data){
  if(data->l!=NULL) del_all(data->l);
  if(data->r!=NULL) del_all(data->r);
  free(data);
}

Node find(int n,Node data){
  if(data->key == n) return data;

  if(data->key > n){
    if(data->l==NULL) return NULL;
    else return find(n,data->l);
  }
  
  if(data->key < n){
    if(data->r==NULL) return NULL;
    else return find(n,data->r);
  }
}




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

typedef long long LL;
typedef unsigned long long ULL;

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1

const int maxn = 4e5+7;
const int inf  = 2e9 + 7;
const int mod  = 1e9 + 7;

int main() {
#ifdef LOCAL
    freopen("sample.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    map<int,int>have;
    priority_queue<int>now;
    int n;
    scanf("%d",&n);
    while(n--)
    {
        int k;
        scanf("%d",&k);
        have[k]++;
        if(have[k]&&have[k]%2==0)
            now.push(k);

    }
    if(now.size()<2)
        cout<<0<<endl;
    else 
    {
        LL ans=now.top();
        now.pop();
        ans*=now.top();
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int n;
	cin >> n;
	using state = tuple<ll,ll,ll>;
	vector<state> ary;
	rep(i,n){
		ll a,b;
		cin >> a >> b;
		ary.push_back(state(a + b,a ,b));
	}

	sort(rbegin(ary),rend(ary));
	ll ans = 0LL;
	rep(i,n){
		ll ab,a,b;
		tie(ab,a,b) = ary[i];
		if(i & 1)
			ans -= b;
		else
			ans += a;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4724
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    long double L;
    cin >> L;

    L /= 3.0;
    cout << setprecision(10) << L * L * L << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,k,sum,ans,c[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
bool pd(int x)
{
	int a=0,b=0;
	vector<int>v;
	for(int i=1;i<=n;i++)
	{
		int y=c[i]%x;
		v.push_back(y);
	}
	sort(v.begin(),v.end());
	int l=0,r=n-1;
	while(l<=r)
	{
		if(a<=0)
		{
			a+=v[l];
			b+=v[l];
			l++;
		}
		else{
			a-=(x-v[r]);
			b+=(x-v[r]);
			r--;
		}
	}
	if(b>2*k)return 0;
	if(a!=0)return 0;
	return 1;
}
signed main()
{
	n=read();k=read();
	for(int i=1;i<=n;i++)
	{
		c[i]=read();
		sum+=c[i];
	}
	ans=1;
	for(int i=1;i*i<=sum;i++)
	if(sum%i==0)
	{
		if(pd(i))ans=max(ans,i);
		if(pd(sum/i))ans=max(ans,sum/i);	
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int num;
    cin >> num;
    int o = num % 10;
    if (o == 2 || o == 4 || o == 5 || o == 7 || o == 9)
    {
        cout << "hon" << endl;
    }
    else if (o == 0 || o == 1 || o == 6 || o == 8)
    {
        cout << "pon" << endl;
    }
    else if (o == 3)
    {
        cout << "bon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI; 
        double area = pi*r*r;
        double length = 2*pi*r;
        System.out.printf("%f %f", area, length);
        }
    }
 


Measured memory_bytes: 28268
//1.read question_2.read I/O_3.read test cases_4.read constraints(to decide TC of solution)_5.decide method_6.dry run_
//7.code_8.test_9.submit
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mod 1000000007
#define F first
#define S second
#define _READ freopen("input.txt","r", stdin);
#define pb push_back
#define MP make_pair
#define _FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{
    
    _FAST
    lli n,t,i,j,k,ans=0,flag=0,a,b,m;
    cin>>n;vector<double> v(n+1);
    for(i=1;i<=n;i++)
        cin>>v[i];
    vector<vector<double>> dp(n+1,vector<double>(n+1,0));
    dp[1][0]=1-v[1];
    dp[1][1]=v[1];
    for(i=2;i<=n;i++)
    {
        for(j=1;j<=i;j++)
        {
            dp[i][j]+=dp[i-1][j-1]*v[i]
                    +dp[i-1][j]*(1-v[i]);
        }
        dp[i][0]=dp[i-1][0]*(1-v[i]);
    }
    /*for(i=0;i<=n;i++)
    {
        for(j=0;j<=n;j++)
            cout<<dp[i][j]<<" ";
        cout<<"\n";
    }*/
    double o=0;
    for(i=0;i<=n;i++)
        if(i>n-i)
        o+=dp[n][i];
    cout<<setprecision(20)<<o;

    return 0;
}



Measured memory_bytes: 70784
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
const int maxn =10000+10;
#define INF 0x7fffffff

struct edge{
    int to,d,cost;
};
typedef pair<int,int> P;

int N,M;
vector<edge> G[maxn];
int d[maxn];

void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P> > que;
    fill(d,d+N,INF);
    d[s]=0;
    que.push(P(0,s));

    while(!que.empty()){
        P p=que.top();
        que.pop();

        int v=p.second;
        if(d[v]<p.first) continue;

        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.d){
                d[e.to]=d[v]+e.d;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    while(cin>>N>>M&&N){
        for(int i=0;i<N;i++){
            G[i].clear();
        }

        for(int i=0;i<M;i++){
            int u,v,x,cost;
            cin>>u>>v>>x>>cost;
            u--;
            v--;
            G[u].push_back((edge){v,x,cost});
            G[v].push_back((edge){u,x,cost});
        }

        dijkstra(0);

        int res=0;
        for(int i=1;i<N;i++){
            int tmp=INF;
            for(int j=0;j<G[i].size();j++){
                if(d[G[i][j].to]+G[i][j].d==d[i]){
                    tmp=min(tmp,G[i][j].cost);
                }
            }
            res+=tmp;
        }
        cout<<res<<endl;
    }
    return 0;
}

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

using namespace std;

main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int a, b, c;
	cin >> a>> b >> c;
	
	if(a + b + c >= 22)
		cout << "bust";
	else
		cout << "win";
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main(){
	int a = 0, b = 0, c=0, d[100000], e[100000],f=0,g=0,h=0, count = 0;
	char ac,uc[100000];
	string manji;
	cin >>a>>b ;
	for (int i = 0; a >= i; i++) {
		for (int j = 0; a >= i + j; j++) {
			if (i * 10000 + j * 5000 + (a - i - j) * 1000 == b)
			{
				cout << i << ' ' << j << ' ' << a - i - j << endl;
				return 0;
			}

		}
	}
	cout << -1 << ' ' << -1 << ' ' << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> a = new ArrayList<>();
        ArrayList<Integer> b = new ArrayList<>();
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            a.add(tmp);
        }
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            b.add(tmp);
        }
        int ret = 0;
        for (int i = 0; i < n; i++) {
            if (a.get(i) > b.get(i)) ret += a.get(i) - b.get(i);
        }
        System.out.println(ret);
    }
}


Measured memory_bytes: 23764
#include<stdio.h>
int main()
{
  int a,b,i,j;
  while(1)
	   {
  scanf("%d%d",&a,&b);
  if(a==0&&b==0){break;}

  for(i=1;i<=a;i++)
    {
      for(j=1;j<=b;j++)
	{
	  if(i>1&&i<a&&j<b&&j>1)printf(".");
	  else printf("#");
	}
      printf("\n");
    }
  printf("\n");
    
	   }
  return 0;
}



Measured memory_bytes: 2104
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(k);
    string s; cin >> s;
    if (s.size() <= k) {
        cout << s << endl;
    } else {
        rep(i, k) {
            cout << s[i];
        }
        cout << "..." << endl;
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3644
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(N * A, B) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int x=0;
	int a=0;
	int b=0;
	int days=0;
	cin >> x >> a >> b;
	days=b-a;
	if(days<=0){
		cout << "delicious" << endl;
	}else if(days<=x){
		cout << "safe" << endl;
	}else{
		cout << "dangerous" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
int main()
{
	cin >>n>>m;
	cout <<6-n-m;
	return 0;
} 

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

typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;

int main(void) {

  int N, M;
  std::string U[256];
  std::string T[256];

  std::cin >> N;
  for(int i = 0; i < N; ++i) {
    std::cin >> U[i];
  }
  std::cin >> M;
  for(int i = 0; i < M; ++i) {
    std::cin >> T[i];
  }

  int state = false;
  for(int i = 0; i < M; ++i) {
    for(int j = 0; j < N; ++j) {
      if( T[i] == U[j] ) {
        if( state ) {
          std::cout << "Closed by " << T[i] << std::endl;
        }
        else {
          std::cout << "Opened by " << T[i] << std::endl;
        }
        state = not state;
        goto label_1;
      }
    }
    std::cout << "Unknown " << T[i] << std::endl;
  label_1:;
  }
  
  return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <list>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>


using namespace std;

int main(){
    int a;
    string s;
    cin >> a >> s;

    if(a >= 3200) cout << s << endl;
    else          cout << "red" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, int> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
ll r(ll x){
    ll xdash = x;
    int cnt = 0;
    while(xdash != 0){
        cnt++;
        xdash /= 2;
    }
    return pow(2, cnt) - x;
}


int main(void){
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    A.push_back(INFL);
    sort(A.begin(), A.end());
    
    vector<pair<ll, int>> Apair(0);
    ll ad = A.at(0);
    int c = 1;
    for(int i = 1; i <= N; i++){
        if(A.at(i) != ad){
            Apair.push_back({ad, c});
            c = 1;
            ad = A.at(i);
        }else{
            c++;
        }
    }
    
    
    ll cnt = 0;
    for(int i = Apair.size() - 1; i >= 0; i--){
        while(Apair.at(i).second != 0){
            Apair.at(i).second--;
            ll now = Apair.at(i).first;
            ll R = r(now);
        
            int left = -1;
            int right = Apair.size();
            int mid;
            while(right - left > 1){
                mid = (left + right) / 2;
                if(Apair.at(mid).first > R){
                    right = mid;
                }else{
                    left = mid;
                }
            }
            if(left != -1 && Apair.at(left).first == R && Apair.at(left).second != 0){
                cnt++;
                Apair.at(left).second--;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 10468
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int kazu = 0;
  cin >> kazu;
  vector<int> oisisa(kazu);
  for(int i = 0;i <= kazu - 1;i++){
    cin >> oisisa[i];
  }
  int kotae = 0;
  for(int i = 0;i <= kazu - 1;i++){
    for(int j = i + 1;j <= kazu - 1;j++){
      kotae += oisisa[i] * oisisa[j];
    }
  }
  cout << kotae << endl;
  return 0;
}

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

char A[10][10];
bool flag = 0;
int H,W;
int bn = 0;
void dfs(int x,int y,int cnt){
	if(x==H-1&&y==W-1&&cnt == bn)flag = 1;
	if(A[x][y+1]=='#')dfs(x,y+1,cnt+1);
	if(A[x+1][y]=='#')dfs(x+1,y,cnt+1);
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> H >> W;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++){
		cin >> A[i][j];
		if(A[i][j]=='#')bn++;
	}
	dfs(0,0,1);
	if(flag)cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool visited[100010];
int main()
{
	int n,m;
	cin>>n>>m;
	int points=0,penalty=0;
	int count1[100010];
	int x; 
	string str;
	memset(count1,0,sizeof(count1));
	for(int i=0;i<m;i++)
	{
		cin>>x>>str;
		if(!visited[x])
		{
			
		
		if(str=="AC")
		{
			points++;
		visited[x]=true;
			penalty+=count1[x];
		}
		else
		count1[x]++;
		
}
	}
	cout<<points<<" "<<penalty;
}

Measured memory_bytes: 768
#!/usr/bin/env python
# coding: utf-8

# In[28]:


# N = int(input())
# a = []
# for i in range(N):
#     a.append(int(input()))


# In[30]:


# def func(x, a, history, cnt):
#     print(x, a[x-1], history)
#     if a[x-1] == 2:
#         print(cnt)
#     elif a[x-1] in history:
#         print(-1)
#     else:
#         history.append(a[x-1])
#         cnt += 1
#         func(a[x-1], a, history, cnt)
# func(1, a, [], 1)


# In[ ]:


n = int(input())
a = [int(input()) for _ in range(n)]
L = [0] * n
cnt = 0
i = 0
while True:
    if L[i] == 1:
        print(-1)
        break
    else:
        L[i] = 1
        i = a[i] - 1
        cnt += 1
        if i == 1:
            print(cnt)
            break



Measured memory_bytes: 7852
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

const int fact[10] = {0, 1, 2, 6, 24, 120, 720, 5040, 40320};

int main(){
    int n; cin >> n;
    vector<int> p(n);
	vector<pair<int, int>> m(n);
    iota( p.begin(), p.end(), 0 );
	for( int i = 0; i < n; ++i ){
		cin >> m[i].first >> m[i].second;
	}
	double ans = 0.0;
    do {
		double sum = 0.0;
        for( int i = 0; i <= n-2; ++i ){
			sum += (
				sqrt(
					(m[p[i]].first-m[p[i+1]].first)*(m[p[i]].first-m[p[i+1]].first)
					+ (m[p[i]].second-m[p[i+1]].second)*(m[p[i]].second-m[p[i+1]].second)
				)
			);
		}
		ans += sum/fact[n];
    } while( next_permutation( p.begin(), p.end() ) );
	cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,i;
	string s;
	cin>>a>>s;
	if(s.size()<=a)
	{
		cout<<s;
		return 0;
	}
	else
	{
		for(i=0;i<a;i++)
			cout<<s[i];
		cout<<"...";
	}
	return 0;
}

Measured memory_bytes: 3624
import math
M = 10**9+7
X,Y = map(int,input().split())
if (X+Y)/3 != (X+Y)//3:
    print(0)
    exit()
n = (X+Y)//3
r = Y-n
if r<0 or r>n:
    print(0)
    exit()
 
 
#nCr and Mod
def nCr(n, r, mod=10**9+7):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
 
print(nCr(n,r,M))

Measured memory_bytes: 3064
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let cv: Vec<char> = s.chars().collect();
    let mut ans = true;
    for i in 0..cv.len() {
        if i % 2 == 0 && cv[i] == 'L' {
            ans = false;
        } else if i % 2 != 0 && cv[i] == 'R' {
            ans = false;
        }
    }
    println!("{}", if ans { "Yes" } else { "No"});
}


Measured memory_bytes: 4352
//#include <bits/stdc++.h>
#include<vector>
#include<iostream>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
 
const LD eps=1e-10;
const long long INFLL=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	for(int i=0;i<q;i++)
		t*=p;
	return t;
}

template <typename T>
struct has_iter
{
	private:
		template <typename U>
		static constexpr true_type check(typename U::iterator*);
		template <typename U>
		static constexpr false_type check(...);

	public:
		static constexpr bool value = decltype(check<T>(nullptr))::value;
};


template<typename T, typename U = typename T::iterator>
void print(const T& container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}


extern void* enabler;
template<typename Head, typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<> void print<string>(const string& container)
{
	cout<<container<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec)
{
	for(T& x: vec) is >> x;
	return is;
}


template<typename T, typename U>
ostream& operator << (ostream& os, const pair<T, U>& p)
{
	os<<'('<<p.first<<", "<<p.second<<')';
	return os;
}

template<typename T>
vector<T> read(int n)
{
	vector<T> t(n);
	cin>>t;
	return t;
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}


template<unsigned int N> struct IsPrime {
	static const int size=(N>>5) + 1;
	unsigned int is_prime[size];
	constexpr IsPrime() : is_prime() {
		is_prime[0]=0x3;
		for(unsigned int i=2;i<N;i++)
		{
			if((is_prime[i>>5] & (1u<<(i&0x1f))) > 0)  continue;
			for(int j=i+i;j<N;j+=i)
				is_prime[j>>5]|=(1u<<(j&0x1f));
		}
	}
	constexpr bool operator[] (const int p) const
	{
		return (is_prime[p>>5] & (1u<<(p&0x1f))) == 0;
	}
};

template<int N> struct LikelyPrime {
	unsigned short sum[N+1];
	constexpr LikelyPrime(const IsPrime<N> pr) : sum() {
		for(int i=3;i<N;i++)
			sum[i+1]=sum[i]+(unsigned short)((pr[i] && pr[(i+1)/2])?1:0 );
	}
};

int main()
{
	io_speedup();
	constexpr IsPrime<100001> pr;
	constexpr LikelyPrime<100001> s(pr);
	int q;cin>>q;
	REP(i,q)
	{
		int l,r;
		cin>>l>>r;
		cout<<s.sum[r+1]-s.sum[l]<<endl;
		//print(s.sum[r+1]-s.sum[l]);
	}
}


Measured memory_bytes: 640
n=int(input())
h=list(map(int, input().split()))

l=[0]*n
l[1]=abs(h[1]-h[0])

for i in range(2,n):
  if abs(h[i]-h[i-1])+l[i-1] >= abs(h[i]-h[i-2])+l[i-2]:
    l[i]=abs(h[i]-h[i-2])+l[i-2]
  else:
    l[i]=abs(h[i]-h[i-1])+l[i-1]
  #print(l)

print(l[-1])

Measured memory_bytes: 20628
#include<iostream>
#include<cstring>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int A[] = new int[N + 1];

		for (int i = 1; i <= N; i++) {
			int rev = sc.nextInt();
			A[rev] = i;
		}
		for (int i = 1; i <= N; i++) {
			System.out.print(A[i] + " ");
		}
    }
}

Measured memory_bytes: 51272
#include<bits/stdc++.h>
using namespace std;
int i,j,k,m,n;
char s[200];
int main()
{
	scanf("%s",&s);
	for(int i=0;i<strlen(s);i++)
	{
		if(s[i]=='x') n++;
	}
	if(n>7) printf("NO");
	else printf("YES");
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            # 下を探しに行く
            ok = mid
        else:
            # 上を探しに行く
            ng = mid
    return ok

N = INT()
A = LIST()

def check1(m):
    sm = m
    for a in A:
        sm = (sm // a) * a
    return sm >= 2

def check2(m):
    sm = m
    for a in A:
        sm = (sm // a) * a
    return sm > 2

l = bisearch_min(0, 10**18, check1)
r = bisearch_min(0, 10**18, check2) - 1

# 2人にできない時はNG
if l > r:
    print(-1)
else:
    print(l, r)


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

	public static void main(String[] args) {
      
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []v = new int [n];
		int []c = new int [n];
		int []a = new int [n];
		
		for(int i = 0; i < n;i++) {
			v[i] = sc.nextInt();
		}
		for(int j = 0; j < n; j++) {
			c[j] = sc.nextInt();
			a[j] = v[j] - c[j];
		}		
		int ans = 0;
		for(int i = 0; i < n ; i++) {
			if (a[i] >= 0) {
				ans += a[i];
			}
				
		}
		System.out.println(ans);
	

	}

}


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

int main() {
  int N,Z=0;
  cin>>N;
  vector<pair<int,int>> p;
  vector<pair<int,int>> q;
  int A=0;
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    int a=S.size(),b=0,c=0;
    for(int j=0;j<a;j++){
      if(S.at(j)=='('){
        b++;
      }
      else{
        b--;
      }
      if(c>b){
        c=b;
      }
    }
    if(b>=0&&c==0){
      A+=b;
    }
    else if(b>=0){
      p.push_back(make_pair(c,b));
    }
    else{
      q.push_back(make_pair(c-b,b*(-1)));
    }
  }
  sort(q.begin(), q.end());
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  int P=p.size(),Q=q.size();
  for(int i=0;i<P;i++){
    if(A+p.at(i).first>=0){
      A+=p.at(i).second;
    }
    else{
      Z=1;
      break;
    }
  }
  if(Z==0){
    for(int i=0;i<Q;i++){
      if(A-q.at(i).second+q.at(i).first>=0){
        A-=q.at(i).second;
      }
      else{
        Z=1;
        break;
      }
    }
  }
  if(Z==0&&A==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
  
}

Measured memory_bytes: 7716
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

print(range(24)[(A+B)%24])


Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define READ(A, N) REP(i, N) { int a; cin >> a; A.emplace_back(a); }
#define ANS(ans) cout << ans << endl;

int
main()
{
  int A, B, C; cin >> A >> B >> C;

  if ((B / A) < C) { ANS(B / A); } else ANS(C);

  return 0;
}


Measured memory_bytes: 256
fn main() {
    let input: Vec<i32> = read_vec();
    let (a, b, c) = (input[0], input[1], input[2]);
    if c - (a - b) < 0 {
        let ans: i32 = 0;
        println!("{}", ans);
    } else {
        let ans: i32 = c - (a - b);
        println!("{}", ans);
    }
}





//**********************************************************************************************************************************************//

// 標準入力から一行を読み取り、指定の型に変換する関数
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec2<T: std::str::FromStr>(n: u64) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

// 10進数での各桁の和
pub fn sum_dights(x: isize) -> isize {
    if x % 10 == 0 {
        return 0
    }
    let m = x % 10;
    m + sum_dights((x - m) / 10)
}


Measured memory_bytes: 4352
import collections
import sys 
sys.setrecursionlimit(10**9)
def dfs(v):
    if cache.get(v):
        return cache[v]
    path=0
    for adj in g[v]:
        path=max(path,1+dfs(adj))
    cache[v]=path
    return path


n,m=map(int,input().split())
g=collections.defaultdict(list)
cache={}
path=0
for _ in range(m):
    u,v=map(int,input().split())
    g[u].append(v)
for v in range(1,n+1):
    path=max(path,dfs(v))
print(path)



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

int main(){
  int a, b;
  cin >> a >> b;
  int ans = b;
  if(a <= 5) ans *= 0;
  else if(a >= 6 && a <= 12) ans *= 0.5;
  else ans *= 1;
  cout << ans << endl;
  return 0;
}

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

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

namespace chrono = std::chrono;
using namespace std::literals;

[[gnu::constructor]]
void fast_iostream() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
}

template <class Num, class Pred>
Num upper_bound(Num  l, Num r, Pred&& is_good) {
    if (!is_good(l)) {
        return l;
    }
    while (r - l > 1) {
        int m = l + (r - l) / 2;
        if (is_good(m)) {
            l = m;
        } else {
            r = m;
        }
    }
    return r;
}

#define WHATIS(expr) #expr " = " << (expr)

int main() {
    std::string s; cin >> s;
    int n = s.length();
    int k = upper_bound(1, n + 1, [&s, n](int x) {
        int u = n - x;
        if (2 * u >= n) {
            return true;
        }
        char c = s[u];
        for (int i = u; i + u < n; ++i) {
            if (s[i] != c) {
                return false;
            }
        }
        return true;
    }) - 1;
    cout << k << endl;
}


Measured memory_bytes: 512
n, k = map(int, input().split())

# 入力をすべてソートしたあと、後の操作のために末尾にm個の要素を付け加える
m = k - 1
height = sorted([int(input()) for i in range(n)]) + [0] * m   # 0であれば他の操作に影響しない
ans = min([height[i+m] - height[i] for i in range(n)][0:-m])  # スライスで末尾２つを省略

# print(height)  # 確認用
print(ans)

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

int n;
string s, t;

int main(){
	cin >> n;
	cin >> s;
	cin >> t;
	
	int go = 0;
	for(int i = 0;i < n;i++){
		bool ok = true;
		for(int j = i;j < n;j++){
			if(s[j] != t[j - i])ok = false;
		}
		if(ok){
			go = n - i;
			break;
		}
	}
	for(int i = go;i < n;i++)s += t[i];
	
	cout << s.size() << endl;
	return 0;
	
}

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

bool isPair(char top, char input) {
    if ((top == '(' && input ==')') 
        || (top == '[' && input ==']')) {
        return true;
    } 
    return false;
}

void check(string str) {
    stack<char> st;

    for (int i = 0; i < str.size(); ++i) {
        if (!st.empty()) {
            char top = st.top();
            if (isPair(top, str[i])) {
                st.pop();
                continue;
            }
        }
        
        if (str[i] == '(' || str[i] == ')' 
            || str[i] == '[' || str[i] == ']') {
            st.push(str[i]);
        }
    }

    if( st.empty() ) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
}

int main() {
    string str;
    while(getline(cin, str), str.front() != '.') {
        check(str);
    }
    return 0;
}

Measured memory_bytes: 3148
# import sys
n, a, b, c, d = map(int, input().split())
s = list(input().replace(".", " "))

a -= 1
b -= 1
c -= 1
d -= 1

end = max(c, d)

for i in range(a, end):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        exit()
        # sys.exit(0)


if c > d and s[d-1] == "#":
    for i in range(b, d):
        if s[i-1] == " " and s[i] == " " and s[i+1] == " ":
            print("Yes")
            exit()
            # sys.exit(0)
    print("No")
    exit()
    # sys.exit(0)
else:
    print("Yes")
    exit()
    # sys.exit(0)

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

using namespace std;

int main()
{
    int a,b,i,r;
    cin>>a;
    for(i=1;i<=9;++i){

        b=a/i;
        r=a%i;
        if(b<=9 && r==0){

            cout<<"Yes"<<endl;
            return 0;

        }

    }
    cout<<"No"<<endl;

    return 0;


}


Measured memory_bytes: 256
x = gets.to_i

200.times do |a|
  200.times do |b|
    if a ** 5 + b ** 5 == x
      puts "#{a} -#{b}"
      exit
    end

    if a ** 5 - b ** 5 == x
      puts "#{a} #{b}"
    end
  end
end


Measured memory_bytes: 14392
import sys
sys.setrecursionlimit(10**9)
 
n, m = map(int, input().split())
 
root = [-1] * n
 
 
def r(x):
    if root[x] < 0:
        return x
    else:
        root[x] = r(root[x])
        return root[x]
 
 
def unite(x, y):
    x = r(x)
    y = r(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x
 
 
def size(x):
    return -1 * root[r(x)]
 
 
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    unite(a, b)
 
ans = 0
for i in range(n):
    ans = max(ans, size(i))
 
print(ans)

Measured memory_bytes: 35696
S = input()
if 'M' in S:
    print(6)
elif 'N' in S:
    print(7) 
elif 'H' in S:
    print(3)
elif 'U' in S:
    print(5)
elif 'W' in S:
    print(4)
elif 'F' in S:
    print(2)
elif 'A' in S:
    print(1)


Measured memory_bytes: 38256