akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
std::map<unsigned long long, unsigned> prime_factorize(unsigned long long x) {
	std::map<unsigned long long, unsigned> ret;
	for (unsigned i = 2; 1ULL * i * i <= x; i++) {
		while (x % i == 0) x /= i, ret[i]++;
	}
	if (x != 1) ret[x]++;
	return ret;
}
std::vector<unsigned long long> calc_divisors(unsigned long long x) {
	std::map<unsigned long long, unsigned> res = prime_factorize(x);
	std::vector<unsigned long long> ret; ret.push_back(1);
	for (std::pair<unsigned long long, unsigned> w : res) {
		int s = ret.size();
		unsigned long long mul = 1;
		for (int i = 0; i < w.second; i++) {
			mul *= w.first;
			for (int j = 0; j < s; j++) ret.push_back(ret[j] * mul);
		}
	}
	sort(ret.begin(), ret.end());
	return ret;
}
long long N;
int main() {
	cin >> N;
	vector<unsigned long long> v = calc_divisors(N);
	int ret = 999999999;
	for (int i = 0; i < v.size(); i++) {
		long long a = v[i], b = N / a;
		ret = min(ret, (int)to_string(max(a, b)).size());
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset; // order_of_key, find_by_order

int main() {
	 ios::sync_with_stdio(0);
	 cin.tie(0);
	 cout.tie(0);
	 ll mod = 1e9+7;
	 map<char, int> cnt;
	 string s;
	 int n;
	 cin >> n >> s;
	 for(auto i : s) cnt[i]++;
	 ll ans = 1;
	 for(auto i : cnt) {
		 i.second++;
		 ans = (ans*i.second)%mod;
	 }
	 cout << ans-1;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i <= (n); ++i)
#define rip(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
int main() {
	int a, b, c; cin >> a >> b >> c;
	int anss = c / a;
	int ans = anss * b;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	string s;
	string ans;
	
	cin>>s;
	
	ans += s[0];
	ans += s[1];
	ans += s[2];
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3644
def inpl(): return list(map(int, input().split()))

H, W = inpl()
ans = 0

C = [input() for _ in range(H)]
for i in range(2):
    L = [0]*H
    R = [0]*H
    Lk = []
    Rk = []
    for h in range(H):
        L[h] = C[h].find("B")
        R[h] = C[h].rfind("B")
        if L[h] >= 0:
            Lk.append(h)
        if R[h] >= 0:
            Rk.append(h)
    
    for lh in Lk:
        for rh in Rk:
            ans = max(ans, abs(L[lh] - R[rh]) + abs(lh - rh))

    if i == 0:
        C = ["".join(c) for c in zip(*C)]
        H, W = W, H

print(ans)


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

int main()
{
  string a, s;
  cin >> a >> s;
  if (a[0]==s[2]&&a[1]==s[1]&&a[2]==s[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
 
int a, b;
 
cin >> a >> b;
 
if(a < b){
 
    cout << "a < b" << "\n";

}
 else if(a > b){
 
    cout << "a > b" << "\n";
 
}
   else{
 
    cout << "a == b" << "\n";
 
}

}

Measured memory_bytes: 1124
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    string s, t;
    cin >> s >> t;
    ll ans = 0;

    for (ll i = 0; i < s.size(); i++)
    {
        if(s[i]!=t[i])
            ans++;
    }

    cout << ans << endl;
}

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

int main()
{
	int x, a, b;
	cin >> x >> a >> b;

	if (b - a <= 0)
	{
		cout << "delicious" << endl;
	}
	else if (b - a <= x)
	{
		cout << "safe" << endl;
	}
	else
	{
		cout << "dangerous" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 100005
using namespace std;
ll x[N],p[N],ans[N];
struct edge{
	int to,next;
	ll v;
}e[N];
int n,s,tot;
int head[N];
void add(int x,int y,ll v){
	e[++tot]=(edge){y,head[x],v};
	head[x]=tot;
}
void dfs(int x){
	for (int i=head[x];i;i=e[i].next)
		ans[e[i].to]=ans[x]+e[i].v,dfs(e[i].to);
}
int main(){
	scanf("%d%d",&n,&s);
	for (int i=1;i<=n;i++)
		scanf("%lld%lld",&x[i],&p[i]);
	int l=1,r=n;
	while (l<r)
		if (x[l]>=s) add(l,l+1,x[l+1]-x[l]),++l;
		else if (x[r]<=s) add(r,r-1,x[r]-x[r-1]),--r;
		else if (p[l]>=p[r]) p[l]+=p[r],add(l,r,x[r]-x[l]),--r;
		else p[r]+=p[l],add(r,l,x[r]-x[l]),++l;
	ans[l]=abs(x[l]-s); dfs(l);
	printf("%lld\n",max(ans[1],ans[n]));
}

Measured memory_bytes: 4480
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
//_____
#define pb emplace_back
#define fi first
#define se second
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout << (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)
typedef pair<int,int> pii;
#define let const auto
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
#define INF  0x3f3f3f3f
//_______

int N;
vector <pii> T[100010];
int d[100010];

//ret: mcos[] の最大値のインデックス
//s を始点としたとき、距離が最大になるノード番号
int bfs(let s)
{
   queue <int> Q;
   Q.emplace(s);
   memset( d, INF, sizeof(d) );
   d[s] = 0;
   int maxp = s;

   while (!Q.empty()) {
      let u = Q.front(); Q.pop();
      for (let e : T[u]) {
         if (d[e.se] == INF) {
            d[e.se] = d[u] + e.fi;
            Q.emplace(e.se);
            //最大距離のノード番号を更新
            if( d[maxp] < d[e.se] ) maxp = e.se;
         }
      }
   }
   return (maxp);
}

inline int diameter()
{
   /*
   let p = bfs(0);   //適当なノードから幅探
   let ansp = bfs(p);
   return ( d[ansp] );
   */
   return ( d[ bfs(bfs(0)) ] );
}

signed main()
{
   FAST();
   cin >> N;
   while (--N) {
      int s, t, w;
      cin >> s >> t >> w;
      T[s].pb( pii(w,t) );
      T[t].pb( pii(w,s) );
   }

   outl( diameter() );
}




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

int gcd(int a, int b, int c){
  if(b==0){
    if(c==0){
      return a;
    }
    return gcd(c, b, a%c);
  }
  return gcd(b, a%b, c);
}

int main(){
  int n;
  cin >> n;
  int sum = 0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      for(int k=1;k<=n;k++){
        sum+=gcd(i, j, k);
      }
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3624
import itertools,sys
def S(): return sys.stdin.readline().rstrip()
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
H,W = LI()
S = [S() for _ in range(H)]
dp = [[float('INF')]*W for _ in range(H)]
for i,j in itertools.product(range(H),range(W)):
    if i==0:
        if j==0:
            dp[i][j] = 1 if S[i][j]=='#' else 0
        else:
            dp[i][j] = dp[i][j-1]+(1 if S[i][j]=='#' and S[i][j-1]=='.' else 0)
    else:
        if i==0:
            dp[i][j] = dp[i-1][j]+(1 if S[i][j]=='#' and S[i-1][j]=='.' else 0)
        else:
            dp[i][j] = min(dp[i][j],dp[i][j-1]+(1 if S[i][j]=='#' and S[i][j-1]=='.' else 0))
            dp[i][j] = min(dp[i][j],dp[i-1][j]+(1 if S[i][j]=='#' and S[i-1][j]=='.' else 0))
print(dp[-1][-1])


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


int main() {
  string s, t;
  cin >> s >> t;
  int ans = t.size();
  for (int i = 0; i < (int) s.size() - t.size() + 1; ++i) {
    int cnt = 0;
    for (int j = i; j < i + t.size(); ++j)
      if (s[j] != t[j - i])
        cnt++;
    ans = min(ans, cnt);
  }
  cout << ans;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
void trace(int n, int arr[]){for(int i = 0; i < n; i++){cout << arr[i] << " ";} cout << endl << endl;}
int main()
{
    Hello
    int n, N = 1000;
    cin >> n;
    for(int i = 1; i <= 200; i++)
        if(i * N >= n)
            return cout << (i * N) - n, 0;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

ll n;
vll a(200000);

ll merge(ll l, ll mid, ll r) {
  ll cnt = 0;
  ll n1 = mid - l;
  ll n2 = r - mid;
  vll lv(n1+1, HIGHINF), rv(n2+1, HIGHINF);
  REP(i, n1) lv.at(i) = a.at(l + i);
  REP(i, n2) rv.at(i) = a.at(mid + i);
  ll i=0, j=0;
  rep(k, l, r) {
    if (lv.at(i) <= rv.at(j)) {
      a.at(k) = lv.at(i++);
    } else {
      a.at(k) = rv.at(j++);
      cnt += n1 - i;
    }
  }
  return cnt;
}

ll mergeSort(ll l, ll r) {
  ll v1, v2, v3;
  if (l + 1 < r) {
    ll mid = (l + r) / 2;
    v1 = mergeSort(l, mid);
    v2 = mergeSort(mid, r);
    v3 = merge(l, mid, r);
    return v1 + v2 + v3;
  } else return 0;
}

int main() {
  cin >> n;
  REP(i, n) cin >> a.at(i);
  ll ans = mergeSort(0, n);
  cout << ans << endl;
  return 0;
}



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

#define endl '\n'
#define ll long long
#define ld long double
#define fi first
#define se second
#define MP make_pair
#define pii pair<int, int>
#define pll pair<long long, long long>
#define mod (ll) (1e9 + 7)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) v.begin(), v.end()
#define dvec(v) for(auto i: v) cout << i << " "; cout << '\n';
#define gcd(a,b) __gcd(a, b)
#define lcm(a,b) ((a)*((b)/gcd(a,b)))
#define darr(a,n) for(int i=0; i<n;i++) cout << a[i] << " "; cout << '\n';
#define what_is(x) cerr << #x << " : " << x << '\n';


int main() {
    fast;
    int n; cin >> n;
    int dp[n+1][4];
    for (int i = 1; i <= n; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        if (i == 1) {
            dp[1][1] = a;
            dp[1][2] = b;
            dp[1][3] = c;
        }
        else {
            dp[i][1] = a + max(dp[i-1][2], dp[i-1][3]);
            dp[i][2] = b + max(dp[i-1][1], dp[i-1][3]);
            dp[i][3] = c + max(dp[i-1][1], dp[i-1][2]);
        }
    }
    cout << max({dp[n][1], dp[n][2], dp[n][3]}) << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<map>
#include<queue>
#include<string>

using namespace std;

map<string, int>mymap;
queue<string>que;
int d[] = {1, -1, 4, -4};
int a[10];

void bfs(){
    string cur;
    string nxt;
    que.push("01234567");
    mymap["01234567"] = 0;

    while(que.size()){
        string cur = que.front();
        que.pop();
        int p = (int)cur.find("0");
        for(int i = 0; i < 4; ++i){
            int np = p + d[i];
            if(0 <= np && np < 8 && !(p == 3 && d[i] == 1) && !(p == 4 && d[i] == -1)){
                nxt = cur;
                nxt[np] = '0';
                nxt[p] = cur[np];
                if(mymap.find(nxt) == mymap.end()){
                    mymap[nxt] = mymap[cur] + 1;
                    que.push(nxt);
                }
            }
        }
    }
    return ;
}

int main(){
    bfs();
    while (cin >> a[0]) {
    for (int i = 1; i < 8; ++i) {
      cin >> a[i];
    }
    string s = "";
    for (int i = 0; i < 8; ++i) {
      s += a[i] + '0';
    }
    if (mymap.find(s) == mymap.end())
      cout << -1 << endl;
    else
      cout << mymap[s] << endl;
    }
    return 0;
}



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

ll gcd(ll a, ll b) {
  return b?gcd(b,a%b):a;
}

ll prime(ll a){
  ll ans=1;
  for(ll i=2;i*i<=a;i++){
    if(!(a%i)){
      ans++;
      while(!(a%i)) a/=i;
    }
  }
  if(a>1) ans++;
  return ans;
}

int main(){
  cin>>x>>y;
  //cout<<gcd(x,y)<<endl;
  cout<<prime(gcd(x,y))<<endl;
}


Measured memory_bytes: 256
#include<stack>
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;(int) (n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;
int main(){
  int ans,a,b;
  cin >> a >> b;
  for(ans=0;(a!=8*ans/100 || b!=ans/10) && ans!=10000; ans++){
  }
  if(ans==10000) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    double a,b,h,m; cin >> a >> b >> h >> m;
    double d = m/60.0*2-(h+m/60.0)/6.0;
    cout << fixed << setprecision(16) << sqrt(a*a+b*b-2*a*b*cos(d*acos(-1))) << endl;
}

Measured memory_bytes: 4216
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
ll dpA[100001],dpB[100001],dpC[100001];
int main(){
    ll n;
    cin>>n;
    int a,b,c;
    for(int i=1;i<=n;i++){
        cin>>a>>b>>c;
        dpA[i]=max(dpA[i],a+dpB[i-1]);
        dpA[i]=max(dpA[i],a+dpC[i-1]);
        dpB[i]=max(dpB[i],b+dpA[i-1]);
        dpB[i]=max(dpB[i],b+dpC[i-1]);
        dpC[i]=max(dpC[i],c+dpA[i-1]);
        dpC[i]=max(dpC[i],c+dpB[i-1]);
    }
    cout<<max(dpA[n],max(dpB[n],dpC[n]))<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define vec vector
#define mst(a,b) memset(a,b,sizeof(a))
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define all(v) v.begin(),v.end()
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define nnf LLONG_MIN
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=(res*x);
        }
        x=(x*x);
        y=y/2;
    }
    return res;
}
 
 struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }

  size_t operator()(pair<uint64_t,uint64_t> x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);
  }
};

void get_time(auto start,auto end){
    double time_taken =  
      chrono::duration_cast<chrono::nanoseconds>(end - start).count(); 
  
    time_taken *= 1e-9;
    cout<<"\n";
    cout<<"Time taken : "<<fixed<<time_taken<<setprecision(6);
}




int main(){

   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

  auto start = chrono::high_resolution_clock::now();

  
 

/* #ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/

   ll n,i,q,x,y,s=0;
   cin>>n;

   ll cnt[100002]={0};

   for(i=0;i<n;i++){
    cin>>x;
    s+=x;
    cnt[x]++;
   }

   cin>>q;

   while(q--){

      cin>>x>>y;

      s-=cnt[x]*x;

      s+=cnt[x]*y;


      cnt[y]+=cnt[x];

      cnt[x]=0;

      cout<<s<<"\n";

   }




  auto end = chrono::high_resolution_clock::now();

  /*#ifndef ONLINE_JUDGE

   get_time(start,end); 

  #endif*/

    return 0;
 }

Measured memory_bytes: 4336
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		int time=sc.nextInt();

		int h=time/3600;
		int m=(time-h*3600)/60;
		int s=time%60;
		
		sc.close();
		
		System.out.println(h+":"+m+":"+s);
	}

}

Measured memory_bytes: 17224
n=int(input())

three_tmp = ["aac","b.c","bdd"]
four_tmp  = ["abcc","abdd","eegh","ffgh"]
five_tmp  = ["aabee","c.bff","cddgg","hij..","hij.."]
seven_tmp = ["aa..dee",".bb.d.f","..ccggf","h.iil..","h...lm.","...k.mn","jj.k..n"]

if n==2:
    print(-1)
elif n==3:
    for x in three_tmp:
        print(x)
elif n==4:
    for x in four_tmp:
        print(x)
elif n==5:
    for x in five_tmp:
        print(x)
elif n==6:
    for x in three_tmp:
        print(x+"."*3)
    for x in three_tmp:
        print("."*3+x)
elif n==7:
    for x in seven_tmp:
        print(x)
elif n==8:
    for x in four_tmp:
        print(x+"."*4)
    for x in four_tmp:
        print("."*4+x)
elif n==11:
    for x in four_tmp:
        print(x+"."*7)
    for x in seven_tmp:
        print("."*4+x)
else:
    res=n
    while res != 0:
        if res % 4 != 0:
            for x in five_tmp:
                print("."*(n-res) + x + "."*(res-5))
            res-=5
        else:
            for x in four_tmp:
                print("."*(n-res) + x + "."*(res-4))
            res-=4


Measured memory_bytes: 4084
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val dp = Array(3) { LongArray(n + 1) }

    for (i in 0 until n) {
        val xs = readLine()!!.split(' ').map { it.toLong() }
        for (j in 0 until 3) {
            dp[j][i + 1] = Math.max(dp[(j + 1) % 3][i] + xs[j], dp[(j + 2) % 3][i] + xs[j])
        }
    }

    println((0 until 3).map { dp[it][n] }.max())
}


Measured memory_bytes: 66308
N, K=map(int, input().split())
import math
def touhiwa(n):
  ans=0
  for i in range(1, n+1):
    r=max(0,math.ceil(math.log2(K/i)))
    ans+=0.5**(r)
  return ans
print(touhiwa(N)/N)
  

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

#define Abigail inline void
typedef long long LL;

const int N=100000;
const LL INF=(1LL<<60)-1;

int n;
LL a[N+9],f[N+9][2];

Abigail into(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i)
    scanf("%lld",&a[i]);
}

Abigail work(){
  f[1][0]=a[1];
  f[1][1]=-INF;
  for (int i=2;i<=n;++i){
  	f[i][0]=max(f[i-1][0]+a[i],f[i-1][1]+a[i]);
  	f[i][1]=max(f[i-1][0]-2*a[i-1]-a[i],f[i-1][1]+2*a[i-1]-a[i]);
  }
}

Abigail outo(){
  printf("%lld\n",max(f[n][0],f[n][1]));
}

int main(){
  into();
  work();
  outo();
  return 0;
}

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

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    ll n; cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    ll sum = 0;
    rep(i, n){
        ll tmp = a[i] - b[i];
        if(tmp < 0) tmp/=2;
        sum += tmp;
    }
    if(sum <= 0)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 384
a, b = map(int, input().split())

if a % 3 == 0:
    result = "Possible"
elif b % 3 == 0:
    result = "Possible"
else:
    if (a+b) % 3 == 0:
        result = "Possible"
    else:
        result = "Impossible"
print(result)

Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <algorithm>

using namespace std;

int main ()
{
  vector<int> p_vec;
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int p;
    cin >> p;
    p_vec.push_back(p);
  }
  sort(p_vec.begin(), p_vec.end());
  int total = 0;
  for (int i = 0; i < K; i++) {
    total += p_vec[i];
  }

  cout << total << '\n';

  return 0;
}


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

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

  int ans = 700;

  for (int i = 0; i < 3; i++)
  {
    if (S.at(i) == 'o')
      ans += 100;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
int n,aa,d;
int main(){
  cin>>n;
  ++n;
  int a[100001]={};
  for(int i=1;i<n;i++){
    cin>>aa;
    if(aa>100000) ++d;
    else ++a[aa];
  }
  for(int i=1;i<100001;i++){
    if(a[i]>=i)
      d+=a[i]-i;
    else
      d+=a[i];
  }
  cout<<d<<endl;
}


Measured memory_bytes: 640
using System;

namespace abc160_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            if (input[2] == input[3] && input[4] == input[5])
            {

                    Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.Read();
        }
    }
}

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

int main(void){
  int x,y,t;
  while (1){
    cin >> x >> y;
    if (x == 0 && y == 0){
      break;
    }
    if (x>y){
      t = x;
      x = y;
      y = t;
    }
    cout << x << " " << y << endl;
  }
  return 0;
}


Measured memory_bytes: 3092
import java.util.Scanner;

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

        while (true) {
            int n = sc.nextInt();
            int s = sc.nextInt();
            if (n + s == 0) {
                break;
            }
            System.out.println(dfs(n, 0, s));
        }
        sc.close();
    }

    private static int dfs(int depth, int start, int left) {
        if (depth == 0) {
            return left == 0 ? 1 : 0;
        }
        int result = 0;
        for (int i=start; i<10; ++i) {
            result += dfs(depth - 1, i + 1, left - i);
        }
        return result;
    }
}


Measured memory_bytes: 26120
#[allow(dead_code)]
fn rd() -> String {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().to_owned()
}

/// 1行の文字を空白で分割してVec<T>にする。
#[allow(dead_code)]
fn rd_vec<T : std::str::FromStr>() -> Vec<T> {
    rd().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

/// 1つの要素を入力で受け取る
#[allow(dead_code)]
fn rd_one<T : std::str::FromStr>() -> T {
    rd().parse().ok().unwrap()
}

/// 複数回read_splitを行う
#[allow(dead_code)]
fn rd_vec_mul<T : std::str::FromStr>(count : i32) -> Vec<Vec<T>> {
    (0..count).map(|_| rd_vec()).collect()
}

/// Vecを1列で出力する
#[allow(dead_code)]
fn op_vec<T : std::fmt::Display>(item : Vec<T>, splitter : char) {
    let cnt = item.len();
    let mut c = 0;
    for i in item.iter() {
        c+=1;
        if cnt > c {print!("{}{}", i, splitter);} else {println!("{}", i);}
    }
}

fn main() {
    let input : f32 = rd_one();
    let b = input as i32;
    println!("{}", (((b + 1) / 2) as f32) / input);
}



Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<queue>

int main() {
	int n;
	std::cin >> n;
	std::vector<int>a(n);
	for (int i = 0; i < n; i++)std::cin >> a[i];

	for (int i = 0; i < n - 1; i++) {
		int rem;
		do {
			rem = a[i+1] % a[i];
			a[i+1] = a[i];
			a[i] = rem;
		} while (rem != 0);
	}
	printf("%d\n", a[n - 1]);
}

Measured memory_bytes: 1020
data Weekday = Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday deriving (Show,Eq,Enum)

main = do
    str <- getLine
    if head str == '0' then return ()
                       else do
                           let [month,day] = map read.words $ str
                           print $ getWeekday 2 month day
                           main

daysOfMonth :: [Int]
daysOfMonth = [31,29,31,30,31,30,31,31,30,31,30,31]

getWeekday :: Int -> Int -> Int -> Weekday
getWeekday offset month day = toEnum $ ((elapsedDay `mod` 7) + offset) `mod` 7
    where elapsedDay = day + (sum.take (month-1) $ daysOfMonth)

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

using namespace std;

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;

    if ((r <= x && x <= w - r) && (r <= y && y <= h - r))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3108
#!/usr/bin/env python3
import math

def main():
    Q = int(input())
    l = []
    r = []
    for i in range(Q):
        na = list(map(int, input().split()))
        l.append(na[0])
        r.append(na[1])

    r_max = 100000
    primes = [True for i in range(r_max)]
    like_numbers = [0 for i in range(r_max)]

    primes[0] = primes[1] = False
    max_i = int(math.sqrt(r_max))
    i = 2
    while i <= max_i:
        primes[i] = True
        for j in range(i * i, r_max, i):
            primes[j] = False
        while i <= max_i:
            i += 1
            if primes[i]:
                break

    for i in range(3, r_max, 2):
        if primes[i] and primes[int((i + 1) / 2)]:
            like_numbers[i] = 1

    c = 0
    for i in range(3, r_max, 2):
        if like_numbers[i]:
            c += 1
        like_numbers[i] = c


    for i in range(Q):
        if l[i] == 1:
            print(like_numbers[r[i]])
        else:
            print(like_numbers[r[i]] - like_numbers[l[i] - 2])

if __name__ == '__main__':
    main()



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

int main(){
	string s,t;
	cin >> s >> t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());
	if(s < t){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
    return 0;
}



Measured memory_bytes: 256
D, G = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(D)]
plst = [0] * D
ans = 0
for i in range(D):
    ans += p[i][0]

def dfs(n):
    global ans
    if n == D:
        cnt = 0
        total = 0
        for i in range(D):
            if plst[i] == 0:
                continue
            elif plst[i] == 1:
                cnt += p[i][0]
                total += (100 * (i + 1) * p[i][0]) + p[i][1]
        for j in range(D):
            if plst[j] == 2:
                for k in range(p[j][0] - 1):
                    total += (100 * (j + 1))
                    cnt += 1
                    if total >= G:
                        ans = min(ans, cnt)
        if total >= G:
            ans = min(ans, cnt)
        return

    for i in range(3):
        plst[n] = i
        dfs(n + 1)
    return

dfs(0)
print(ans)

Measured memory_bytes: 56668
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s)
	for i := 0; i < len(s); i++ {
		if s[i] == '0' || s[i] == '1' {
			t += string(s[i])
		} else if s[i] == 'B' && len(t) > 0 {
			t = t[:len(t)-1]
		}
	}
	fmt.Println(t)
}


Measured memory_bytes: 512
import sys

S = input()

while len(S) > 0:
    if len(S) < 5:
        print('NO')
        sys.exit(0)
    third = S[-3]
    if third == 'e':
        if len(S) < 5 or S[-5:] != 'dream':
            print('NO')
            sys.exit(0)
        S = S[:-5]
        continue
    if third == 'a':
        if len(S) < 5 or S[-5:] != 'erase':
            print('NO')
            sys.exit(0)
        S = S[:-5]
        continue
    if third == 'm':
        if len(S) < 7 or S[-7:] != 'dreamer':
            print('NO')
            sys.exit(0)
        S = S[:-7]
        continue
    if third == 's':
        if len(S) < 6 or S[-6:] != 'eraser':
            print('NO')
            sys.exit(0)
        S = S[:-6]
        continue
    else:
        print('NO')
        sys.exit(0)

print('YES')

Measured memory_bytes: 9164
n,w = map(int,input().split())
item = [list(map(int,input().split())) for i in range(n)]

dp = [[0]*(w+1) for i in range(n+1)]

for i in range(1,n+1):
  for j in range(1,w+1):
    if item[i-1][0] <= j:
      dp[i][j] = max(dp[i-1][j-item[i-1][0]]+item[i-1][1],dp[i-1][j])
    else:
      dp[i][j] = dp[i-1][j]
print(dp[n][w])


Measured memory_bytes: 120172
#include<iostream>
#include<algorithm>

int main(){
    int N,C;
    std::cin >> N >> C;

    int D[30][30] = {0};
    for (int i=0;i<C;i++) {
        for (int j=0;j<C;j++) {
            std::cin >> D[i][j];
        }
    }

    int cCnt[3][30] = {0};
    for (int i=0;i<N;i++) {
        for (int j=0;j<N;j++) {
            int tmp;
            std::cin >> tmp;  
            cCnt[(i+j)%3][tmp-1]++;
        }
    }

    int ans = 1<<30;
    for (int i=0;i<C;i++) {
        for (int j=0;j<C;j++) {
            if (i!=j) {
                for (int k=0;k<C;k++) {
                    if (k!=i && k!=j) {
                        int tmp=0;
                        for (int l=0;l<C;l++) tmp+=D[l][i]*cCnt[0][l];
                        for (int l=0;l<C;l++) tmp+=D[l][j]*cCnt[1][l];
                        for (int l=0;l<C;l++) tmp+=D[l][k]*cCnt[2][l];
                        ans = std::min(ans,tmp);
                    }
                }
            }
        }
    }

    std::cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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 main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll>a(n),num(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
        num[a[i]]++;
    }
    ll all = 0;
    rep(i,n){
        all += num[i]*(num[i]-1)/2;
    }
    rep(i,n){
        ll ans = all-(num[a[i]]-1);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 6376
#include<bits/stdc++.h>
using namespace std;
int main() {
 string s,t;
 cin>>s>>t;
 int z,x;
 cin>>z>>x;
 string h;
 cin>>h;
 if(s==h)
 {
   z=z-1;
   cout<<z<<" "<<x<<endl;
 }
 else if(t==h)
 {
     cout<<z<<" "<<x-1<<endl;
 }


   return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

const lint INF=1LL<<61;

int main(){
	int n; cin>>n;
	vector<int> a(n);
	rep(i,n) cin>>a[i];

	lint ans=INF;
	for(int a0:{1,-1,a[0]}) if(a0!=0) {
		lint tmp=abs(a0-a[0]),sum=a0;
		for(int i=1;i<n;i++){
			sum+=a[i];
			if(sum-a[i]>0){
				if(sum>=0){
					tmp+=sum+1;
					sum=-1;
				}
			}
			else if(sum-a[i]<0){
				if(sum<=0){
					tmp+=1-sum;
					sum=1;
				}
			}
		}
		ans=min(ans,tmp);
	}
	cout<<ans<<endl;

	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int c = a + b;
    if(c%2) cout << "IMPOSSIBLE" << endl;
    else cout << c / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
cnt = int()
for i in reversed(range(1, max(h)+1)):
    tmp = list()
    for j in h:
        if i <= j:
            tmp.append(1)
        else:
            tmp.append(0)
    #print(tmp)
    if tmp[0]==1:
        cnt += 1
    for j in range(1, n):
        if tmp[j]-tmp[j-1] == 1:
            cnt += 1

print(cnt)


Measured memory_bytes: 3060
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
ps = list(map(int, input().split()))
uf = UnionFind(n)
for i in range(m):
    x, y = map(int, input().split())
    uf.union(x-1, y-1)
res = 0
for i in range(n):
    if uf.same(ps[i]-1,i):
       res += 1
print(res)

Measured memory_bytes: 20328
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	as := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
	}
	sort.Ints(as)
	max := as[len(as)-1]

	for i := 0; i < n-1; i++ {
		d := as[i+1] - as[i]
		if d > 0 {
			as = append(as, d)
		}
	}

	if len(as) == 1 {
		if as[0] == k {
			fmt.Println("POSSIBLE")
		} else {
			fmt.Println("IMPOSSIBLE")
		}
		return
	}

	g := gcd(as[0], as[1])
	for i := 2; i < len(as); i++ {
		g = gcd(g, as[i])
	}

	if k <= max && (max-k)%g == 0 {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	r := a % b
	for r != 0 {
		a = b
		b = r
		r = a % b
	}
	return b
}


Measured memory_bytes: 6784
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>

#define PI 3.14159265359

#define INF 1000000;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)

using namespace std;


/*
class ElectronicPetEasy
{
public:
	string isDifficult(int st1, int p1, int t1, int st2, int p2, int t2)
	{
		
	}
};
*/


bool isRight(char c)
{
	string rightChars = "yuiophjklnm";
	
	if (rightChars.find(c) != string::npos)
	{
		return true;
	} else {
		return false;
	}
}


int main()
{
	string inp;
	
	while (cin >> inp, inp != "#")
	{
		bool flag = isRight(inp[0]);
		int ans = 0;
		
		for (int i=1; i<inp.length(); i++)
		{
			if (flag != isRight(inp[i]))
			{
				ans++;
				flag = !flag;
			}
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1188
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

def f(x):
    return x*x

N = list(get_input())
for l in range(len(N)):
    d = int(N[l])
    n = int(600 / d)
    S = 0
    for i in range(n-1):
        #print(d+d*i, f(d+d*i))
        S = S + d*f(d+d*i)
    print(S)



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

#define forsn(i,s,n) for(tint i=(s);i<(tint)(n); i++)
#define forn(i,n) forsn(i,0,n)
#define dforn(i,n) for(tint i = tint(n)-1; i >= 0; i--)
#define debug(x) cout << #x << " = "  << x << endl

using namespace std;

typedef long long tint;

random_device rd;
mt19937 gen(rd());

uniform_int_distribution<tint> dis(1, 10000);

void imprimirVector (vector<tint> v)
{
	if (!v.empty())
	{ 
		tint p = tint(v.size());
		cout << "[";
		forn(i,p-1)
			cout << v[i] << ",";
		cout << v[p-1] << "]" << endl;
	}
	else
		cout << "[]" << endl;
}

int main()
{
	#ifdef ACMTUYO
		assert(freopen("entrada.in", "r", stdin));
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	tint x;
	while (cin >> x)
	{
		tint c500 = x/500;
		x -= c500*500;
		tint c5 = x/5;
		cout << 1000*c500 + 5*c5 << "\n";
	}
	
	
	return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

class UnionFind {
  vector<int> a;
public:
  UnionFind(int n) { REP(i, 0, n) a.push_back(i); }
  int find(int i) { return a[i] == i ? i : (a[i] = find(a[i])); }
  bool unite(int i, int j) {
    if(find(i) == find(j)) return false;
    a[find(i)] = find(j);
    return true;
  }
};

int N, M, A;
double P[100];
bool r[100];

int main(void) {
  while(cin >> N, N) {
    UnionFind uf(N);
    REP(i, 0, N) r[i] = false;
    REP(i, 0, N) {
      cin >> P[i] >> M;
      REP(j, 0, M) {
        cin >> A;
        uf.unite(i, A - 1);
        r[A - 1] = true;
      }
    }

    bool p[100];
    REP(i, 0, N) p[i] = false;
    vector<int> q[100];
    vector<int> s[100];
    REP(i, 0, N) {
      p[uf.find(i)] = true;
      if(!r[i]) q[uf.find(i)].push_back(i);
      else s[uf.find(i)].push_back(i);
    }

    double ans = 1;
    REP(i, 0, N) if(p[i]) {
      if(q[i].size() == 0) {
        double d = 1;
        REP(j, 0, s[i].size()) d *= P[s[i][j]];
        ans *= (1 - d);
      } else {
        REP(j, 0, q[i].size()) ans *= (1 - P[q[i][j]]);
      }
    }
    printf("%.8lf\n", ans);
  }


  return 0;
}

Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n,k;
cin >> n >> k;
set<ll> a;
for(ll i = 0; i < k; i++){
    ll di;
    cin >> di;
    for(ll j = 0; j < di; j++){
        ll b;
        cin >> b;
        a.insert(b);
    }
}
cout << n - a.size() << endl;
}

Measured memory_bytes: 3648
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		
		long power=1;
		
		for(int i=1;i<=n;i++) {
			
			power=power*i%1000000007;
			
		}
		
		System.out.println(power);
		
		sc.close();


	}



}



Measured memory_bytes: 23508
#include <cmath>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long lint;

lint gcd(lint a, lint b)
{
	return (!b ? a : gcd(b, a % b));
}

lint lcm(lint a, lint b)
{
	if (a < b) swap(a, b);
	return (a / gcd(a, b) * b);
}

int main()
{
	int n;
	lint v[16], d[16], a[16];
	
	while (scanf("%d", &n) && n){
		lint dl = 1;
		lint common;
		for (int i = 0; i < n; i++){
			scanf("%lld %lld", d + i, v + i);
			common = gcd(d[i], v[i]);
			d[i] /= common; v[i] /= common;
			dl = lcm(dl, d[i]);
		}
		
		common = dl / d[0] * v[0];
		for (int i = 0; i < n; i++){
			a[i] = dl / d[i] * v[i];
			common = gcd(common, a[i]);
		}
		
		for (int i = 0; i < n; i++){
			printf("%lld\n", a[i] / common);
		}
	}
	
	return (0);
}

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


int main() {
    int N, M;
    cin >> N >> M;
    vector<int> X(M), D(M-1);
    for(int i=0; i<M; i++) cin >> X[i];

    //コマが座標より大きい
    if(N >= M) {
        cout << 0 << endl;
        return 0;
    }

    sort(X.begin(), X.end());
    for(int i=0; i<M-1; i++) {
        D[i] = abs(X[i]-X[i+1]);
    }

    sort(D.begin(), D.end());
    int count = 0;
    for(int i=0; i<M-N; i++) {
        count += D[i];
    }
    cout << count << endl;
}

Measured memory_bytes: 3964
n,m=map(int,input().split())
s=input()
l=[0]*m
a,t,p=0,0,1
if 10%m:
  for i in s[::-1]: l[t%m]+=1; t+=int(i)*p; a+=l[t%m]; p=p*10%m
else:
  a=sum(i+1 for i in range(n) if int(s[i])%m<1)
print(a)

Measured memory_bytes: 3500
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#include<queue>
#define INF 1000000009;
#define inl long long
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
int kaizyo(int a) {
	long long ans = 1;
	for (int i = a; i > 0; i--) {
		ans *= i;
		ans = ans % 1000000007;
		//cout << ans << endl;
	}
	ans = ans % 1000000007;
	return ans;
}

int main() {
	int N = 0;
	string W ;
	cin >> N >> W;
	if (N >= 3200) {
		cout << W<< endl;
		return 0;
	}
	else {
		cout << "red" << endl;
		return 0;
	}
	return 0;
}





Measured memory_bytes: 256
x, n = map(int, input().split())
p = list(map(int, input().split()))
sa = float("inf")
for i in range(-100, 201):
    if i not in p:
        sa = min(sa, abs(i - x))
if x - sa not in p and x + sa not in p:
    print(x - sa)
elif x - sa in p and x + sa not in p:
    print(x + sa)
elif x - sa not in p and x + sa in p:
    print(x - sa)


Measured memory_bytes: 61884
#include <iostream>

int main() {
  int A, B;
  std::cin >> A >> B;
  if (A > B) {
    std::cout << 2 * A - 1 << std::endl;
  } else if (A < B) {
    std::cout << 2 * B - 1 << std::endl;
  } else {
    std::cout << 2 * A << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;


//int main(){
//  set<string> str;
//  string s;
//  cin>>s;
//  int x;
//  cin>>x;
//  str.insert(s);
//
//  for(int i=0; i<s.size(); i++){
//    for(int j=0; i+j<s.size(); j++){
//      string st;
//      int y=0;
//      cout<<"i = "<<i<< "  J = "<<j<<en
//      for(int k=i; k<=i+j; k++){
//        st[y++]=s[k];
//        cout<<"st["<<y-1<<"] = "<<s[k]<<en
//      }
//      string sst=st.substr(i,j);
//      str.insert(sst);
//    }
//  }
//
//  int i=0;
//  for(set<string>::iterator it=str.begin(); it!=str.end(); it++){
//    i++;
//    string ss=*it;
//    cout<<"ss = "<<ss<<en
//    if(i==x) {
//      cout<<ss<<en
//      break;
//    }
//  }
//}

#define MAX 1000000
#define front 1
#define back 0
int line[MAX];
struct muki{
  int fro,bac;
};

muki L[MAX];

int main(){
  int n;
  cin>>n;
  for(int i=0; i<n; i++){
    char ch;
    cin>>ch;
    if(ch=='W') line[i]=back;
    else line[i]=front;
  }
  
  L[0].fro=0;
  for(int i=1; i<n; i++){
    int j=line[i-1]==front ? 1:0;
    L[i].fro=L[i-1].fro+j;
  }
  L[n-1].bac=0;
  for(int i=n-2; i>=0; i--){
    int j=line[i+1]==back ? 1:0;
    L[i].bac=L[i+1].bac+j;
  }
//
//  for(int i=0; i<n; i++){
//    cout<<"前 = "<<L[i].fro<<en
//    cout<<"後ろ = "<<L[i].bac<<en
//  }
  
  int ans=0;
  for(int i=0; i<n; i++){
    ans=max(ans,L[i].bac+L[i].fro);
  }
  cout<<n-1-ans<<en
}


Measured memory_bytes: 8448
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll a, ll n, ll m = mod) {
	a %= m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

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


void solve() {
	ll x; cin >> x;
	ll cur = 100;
	int ans = 0;
	while (cur < x) {
		ans++;
		cur += cur / 100;
	}
	cout << ans << "\n";
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	//experi();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}

Measured memory_bytes: 7748
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 1000000000
#define EPS 1.0e-10

using namespace std;

typedef long long ll;

int a[5];
int b[5];

int main()
{
	while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
		for (int i = 0; i < 4; i++) {
			cin >> b[i];
		}
		int hit = 0;
		int blow = 0;
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (a[i] == b[j]) {
					if (i == j)hit++;
					else blow++;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

Measured memory_bytes: 3084