akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  int n; cin>>n;
  std::vector<int> a(n);
  std::vector<int> b(n);
  std::vector<int> c(n-1);
  rep(i,n){
    cin >> a[i];
  }
  rep(i,n){
    cin >> b[i];
  }
  rep(i,n-1){
    cin >> c[i];
  }
  int ans = 0;
  rep(i,n){
    ans += b[a[i]-1];
    if (i != n && a[i]+1 == a[i+1]) ans += c[a[i]-1];
  }
  cout << ans << endl;
}


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

int main(){
    int n,m;
    cin>>n>>m;

    int sm = 0;
    for(int i = 0; i < m; i++){
        int t;cin>>t;
        sm+=t;
    }
    cout<<((n-sm)<0?-1:(n-sm));
}


Measured memory_bytes: 3568
n, m = map(int, input().split())
nums = [0] * n
check_flgs = [0] * n
cnt = 0
for _ in range(m):
    s, c = map(int, input().split())
    if check_flgs[s-1] == 0:
        nums[s-1] = c
        cnt += 1
        check_flgs[s-1] = 1
    elif check_flgs[s-1] != 0:
        if nums[s-1] == c:
            cnt += 1
            continue
        else:
            break
ans = ""
for num in nums:
    ans += str(num)
if cnt == m and n == 1:
    print(int(ans))
elif cnt == m and n >= 2 and nums[0] != 0:
    print(int(ans))
elif cnt == m and n >= 2 and nums[0] == 0 and check_flgs[0] == 0:
    print("1" + ans[1:])
else:
    print("-1")

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

using namespace std;

using ll = long long;
// const int mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(10);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        if (i < n - 1) {
            cout << A[i] << " ";
        } else {
            cout << A[i] << endl;
        }
    }
}

inline void solve() {
    int n;
    cin >> n;

    int pre = 0;

    REP(i, n) {
        int a, b;
        cin >> a >> b;

        if (a == b) {
            pre++;
            if (pre == 3) { cout << "Yes" << endl; return;}
        } else {
            pre = 0;
        }

    }
    cout << "No" << endl;
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3644
#include<iostream>

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	int hairetu[3];
	hairetu[0] = a + b;
	hairetu[1] = a - b;
	hairetu[2] = a * b;
	int x =-1000;
	
	for (int i = 0; i < 3; i++)
	{
		if (x < hairetu[i])
			x = hairetu[i];

	}
	cout << x << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int ii = a; ii <= (b); ++ii) 
#define mREP(a,b) for (int i = a; i == (b); --i)
#define mod 1e9 + 7
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　　　 　 _... ..._
	　　　　　 , ´⌒ ⌒ヽ
	　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
	　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
	　　　　　　△ﾑ,8ﾑﾌつ
	　　　　　/(ﾝ_/＿ヽ＼
	　　　　 ～～i_ﾌ_ﾌ～´
	*/
	int n, a, b;
	cin >> n >> a >> b;
	if (abs(n - a) > abs(n - b)) {
		cout << "B" << endl;
	}
	else {
		cout << "A" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl

int a, b, c;
int main() {
    cin >> a >> b >> c;
    swap(a, b); swap(a, c);
    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define mex 1000005
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector<int> adj[mex];
#define pi 3.141592653589793238462643383279502884197169399375
	
int main(){
	int a,b,h,m;
	cin>>a>>b>>h>>m;
	int y=360,y1=30;
	double h1=h+(m*1.0)/60;
	double a1=y*h1,a2=y1*h1;
	int a3=a1/360;
	a1=a1-a3*360;
	double yy=abs(a1-a2);
	yy=min(yy,360-yy);
	//cout<<cos(yy*3.14159/180)<<endl;;
	double c=sqrt(a*a+b*b-2*a*b*cos(yy*pi/180));
	cout<<fixed<<setprecision(15)<<c;
  
}



Measured memory_bytes: 27660
//
// Created by munaiyi on 2020/3/19.
//

#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e5 + 5;
int h[maxn], mem;
struct {
    int v, next, id;
} e[maxn << 2];

void add(int u, int v, int id) {
    e[mem].v = v;
    e[mem].id = id;
    e[mem].next = h[u];
    h[u] = mem++;
}

int vis[maxn], d[maxn];
pair<int, int> dd[maxn];
int ans[maxn << 1];

int main() {
    memset(h, -1, sizeof(h));
    memset(vis, -1, sizeof(vis));
    memset(ans, -1, sizeof(ans));
    mem = 0;
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &d[i]);
        dd[i].first = d[i];
        dd[i].second = i;
    }
    sort(dd + 1, dd + 1 + n);
    for (int i = 0; i < m; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        add(u, v, i);
        add(v, u, i);
    }
    for (int i = 1; i <= n; i++) {
        if (vis[dd[i].second] + 1) continue;
        if (dd[i].first == dd[1].first) {
            for (int j = h[dd[i].second]; j + 1; j = e[j].next) {
                int v = e[j].v;
                if (d[v] == dd[1].first) {
                    if (vis[v] == -1) {
                        vis[v] = 0;
                    }
                    vis[dd[i].second] = vis[v] ^ 1;
                    ans[e[j].id] = dd[i].first;
                    break;
                }
            }
        } else {
            for (int j = h[dd[i].second]; j + 1; j = e[j].next) {
                int v = e[j].v;
                if (vis[v] + 1 && d[v] < d[dd[i].second]) {
                    vis[dd[i].second] = vis[v];
                    ans[e[j].id] = d[dd[i].second] - d[v];
//                    printf("%d %d %d sss %d\n", d[v], d[dd[i].second], e[j].id, ans[e[j].id]);
                    break;
                }
            }
            if (vis[dd[i].second] == -1) {
                for (int j = h[dd[i].second]; j + 1; j = e[j].next) {
                    int v = e[j].v;
                    if (vis[v] + 1 && d[v] == d[dd[i].second]) {
                        vis[dd[i].second] = vis[v] ^ 1;
                        ans[e[j].id] = d[dd[i].second];
                        break;
                    }
                }
            }
            if(vis[dd[i].second] == -1){
                for (int j = h[dd[i].second]; j + 1; j = e[j].next) {
                    int v = e[j].v;
                    if (d[v] == d[dd[i].second]) {
                        vis[v] = 0;
                        vis[dd[i].second] = vis[v] ^ 1;
                        ans[e[j].id] = d[dd[i].second];
                        break;
                    }
                }
            }
        }
//        printf("%d %d %d\n", dd[i].first, dd[i].second, vis[dd[i].second]);
        if (vis[dd[i].second] == -1) {
            printf("-1\n");
            return 0;
        }
    }
    for (int i = 1; i <= n; i++) {
        putchar(vis[i] ? 'B' : 'W');
    }
    putchar('\n');
    for (int i = 0; i < m; i++) {
        printf("%d\n", ans[i] == -1 ? 1000000000 : ans[i]);
    }
    return 0;
}

Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define pb push_back
#define md 1000000007
int main()
{
	fast;
	int n, m, k, flag = 0;
	cin >> k;
	cin >> n >> m;
	fr(i, n, m + 1)
	{
		if (i % k == 0)
			flag = 1;
	}
	if (flag == 1)
		cout << "OK";
	else
		cout << "NG";


	return 0;
}

Measured memory_bytes: 3640
import math
import operator as op
from functools import reduce
 
def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer / denom
"""
int(input())
map(int,input().split())
list(map(int,input().split()))
"""
 
 
            
       
 
t=1
for term in range(1,t+1):
    r=int(input())
    print(2*math.pi*r)

Measured memory_bytes: 9608
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(ReadLine());
        }

        public static long[] Reads()
        {
            return ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x,long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }

        public static long C(long n,long k)
        {
            long x=1;
            for (long i = 1; i <=k; i++)
            {
                x *= n - i + 1;
                x /= i;
            }
            return x;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var s = ReadLine();
            var q = Read();
            var c = 0;
            var ans =new string[500000];
            var left = 250000;
            var right = 250001+s.Length;
            for (int i = 250001; i < 250001+s.Length; i++)
            {
                ans[i] = s[i - 250001].ToString();
            }
            
            for (int i = 0; i < q; i++)
            {
                var r = ReadLine().Split();
                if (r[0] == "1")
                {
                    c++;
                }
                else if(c%2==0)
                {
                    if (r[1] == "1")
                    {
                        ans[left] = r[2];
                        left--;
                    }
                    else
                    {
                        ans[right] = r[2];
                        right++;
                    }
                }
                else
                {
                    if (r[1] == "2")
                    {
                        ans[left] = r[2];
                        left--;
                    }
                    else
                    {
                        ans[right] = r[2];
                        right++;
                    }
                }
            }
            if (c % 2 == 0)
            {
                for (int i = left+1; i < right; i++)
                {
                    Write(ans[i]);
                }
                WriteLine();
            }
            else
            {
                for (int i =right-1; i >left; i--)
                {
                    Write(ans[i]);
                }
                WriteLine();
            }
            
            


            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 30948
#include<stdio.h>
int main(){
    int a,b,c,i;
    while(scanf("%d%d",&a,&b) != EOF){
        c = a + b;
        for(i = 1;;i++){
            if(c < 10)break;
            c = c / 10;
        }
        printf("%d\n",i);
    }
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#define MAX_N 300

using namespace std;

int main(void){
	int dp[MAX_N + 1], n;
	vector<int> m2;

	for(int i = 1;i <= 17;i++){
		m2.push_back(i * i);
	}

	while(1){
		cin >> n;
		if(n == 0){
			break;
		}

		fill(dp,dp + MAX_N + 1,0);

		dp[0] = 1;
		for(int i = 0;i < m2.size();i++){
			for(int j = 0;j <= n - m2[i];j++){
				dp[j + m2[i]] += dp[j];
			}
		}
		cout << dp[n] << endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  while(N >> 0){
  char S;
  cin >> S;
  
  if(S == 'P'){
  }
  else if(S == 'W'){
  }
  else if(S == 'G'){
  }
  else{
  cout << "Four";
  break;
  }
  N--;
  if(N == 0){
  cout << "Three";
  }
  else{
  continue;
  }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    for(int i=len(s)-1;i>=0;i--){
      string t;
      rep(j,i) t.push_back(s[j]);
      if(len(t)%2!=0) continue;
      string a,b;
      rep(j,len(t)/2) a.push_back(t[j]);
      FOR(j,len(t)/2,len(t)) b.push_back(t[j]);
      //cout<<t<<' '<<a<<' '<<b<<endl;
      if(a==b){
        cout<<len(t)<<endl;
        return 0;
      }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int N;
Graph G;
vector<int> C;
int ci = 0;
vector<int> D;

void dfs(int v, int p){
  for (int nv : G[v]){
    if (nv == p) continue;
    dfs(nv, v);
  }
  D[v] = C[ci++];
}

int main() {
  cin >>N;
  G.assign(N, vector<int>());
  rep(i, N-1){
    int a,b; cin >>a >>b; a--; b--;
    G[a].push_back(b); G[b].push_back(a);
  }
  C.assign(N, 0);
  D.assign(N, 0);
  rep(i, N) cin >>C[i];
  sort(all(C));
  dfs(0, -1);
  int res = 0;
  rep(i, N-1) res += C[i];
  cout <<res <<endl;
  rep(i, N) cout <<D[i] <<endl;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
void matmul(ll a[3][3], ll b[3][3], ll ans[3][3]){
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      ans[i][j]=0;
      for(int k=0; k<3; k++){
        ans[i][j]+=(a[i][k]*b[k][j]);
        ans[i][j]%=MOD;
      }
    }
  }
}
void matpow(ll a[3][3], ll k, ll ans[3][3]){
  ll ap[3][3];
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      ap[i][j]=a[i][j], ans[i][j]=(i==j?1:0);
    }
  }
  while(k>0){
    ll ans1[3][3];
    if(k%2){
      matmul(ans, ap, ans1);
      for(int i=0; i<3; i++) for(int j=0; j<3; j++) ans[i][j]=ans1[i][j];
    }
    matmul(ap, ap, ans1);
    for(int i=0; i<3; i++) for(int j=0; j<3; j++) ap[i][j]=ans1[i][j];
    k/=2;
  }
}

int main()
{
	ll n; int m; cin>>n>>m;
  ll x[100002]; x[0]=0, x[m+1]=n;
  for(int i=1; i<=m; i++){
    cin>>x[i];
  }
  ll a[3][3]={{0, 1, 0}, {0, 0, 1}, {1, MOD-2, 4}}, ainv[3][3]={{2, MOD-4, 1}, {1, 0, 0}, {0, 1, 0}};
  ll s[2][100002][3];
  ll dp[2][100002];
  dp[0][0]=1, dp[1][0]=0;
  s[0][0][0]=1, s[0][0][1]=5, s[0][0][2]=18;
  s[1][0][0]=0, s[1][0][1]=0, s[1][0][2]=0;
  for(int i=1; i<=m+1; i++){
    ll apow[3][3], ainvp[3][3];
    matpow(a, x[i]-1, apow);
    matpow(ainv, x[i], ainvp);
    ll v[3];
    for(int j=0; j<3; j++){
      v[j]=(ainvp[j][0]+ainvp[j][1]*5+ainvp[j][2]*18)%MOD;
    }
    for(int p=0; p<2; p++){
      dp[p][i]=0;
      for(int j=0; j<3; j++) dp[p][i]+=(apow[0][j]*s[(p+1)%2][i-1][j]%MOD);
      dp[p][i]%=MOD;
      for(int j=0; j<3; j++){
        s[p][i][j]=(s[p][i-1][j]+v[j]*dp[p][i])%MOD;
      }
    }
  }
	cout<<(dp[1][m+1]-dp[0][m+1]+MOD)%MOD<<endl;
	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int x ; 
  cin >> x ; 
  if( x >= 2000 ){
    cout << 1 <<endl ; 
    return 0 ;
  }
  
  else{ 
    rep(i,20){
      rep(j,20){
        rep(k,20){
          rep(l,20){
            rep(m,20){
              rep(n,20){
                if( x == 100*i + 101*j + 102*k + 103*l + 104*m + 105*n ) {
                  cout << 1 <<endl ; ;
                  return 0 ;
                }
              }
            }
          }
        }
      }
    }
  }
 
  
  cout << 0 <<endl ;
  
                  
                  
                
    

}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

//ここから

void solve(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  int cnt=0;
  bool ok=true;
  while(ok){
    bool ng=false;
    rep(i,n){
      if(a[i]%2)ng=true;
      else a[i]/=2;
    }
    if(ng)ok=false;
    else ++cnt;
  }
  cout<<cnt;
}

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


Measured memory_bytes: 256
n=input()
if 1<=int(n[:2])<=12 and 1<=int(n[2:])<=12:
  print("AMBIGUOUS")
elif 1<=int(n[:2])<=12:
  print("MMYY")
elif 1<=int(n[2:])<=12:
  print("YYMM")
else:
  print("NA")

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, M;
    cin >> N >> M;
    unsigned long ans{0}, tmp{1};
    vector<unsigned long> inv(M + 2);
    inv[1] = 1;
    for(unsigned long i{2}; i < M + 2; ++i)inv[i] = MOD - MOD / i * inv[MOD % i] % MOD;
    for(unsigned long i{0}; i <= N; ++i){
        (ans = MOD + tmp - ans) %= MOD;
        if(i != N){
            (tmp *= N - i) %= MOD;
            (tmp *= inv[i + 1]) %= MOD;
            (tmp *= M - N + i + 1) %= MOD;
        }
    }
    cout << ans * tmp % MOD << endl;
    return 0;
}

Measured memory_bytes: 7068
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
typedef pair<int, int> P;

signed main(){
    int n,k;
    cin>> n >> k;
    vector<int> p(n);
    vector<int> c(n);
    rep(i,n) {
        cin >> p[i];
        p[i]--;
    }
    rep(i,n) cin >> c[i];
    int ma = -inf;
    rep(i,n) {
        vector<int> v(n,0);
        int nex = p[i];
        v[i]=1;
        deque<int> a;
        a.push_back(c[i]);
        int cyc = c[i];
        while(v[nex]==0) {
            v[nex]=1;
            a.push_back(c[nex]);
            cyc += c[nex];
            nex = p[nex];
        }
        int now = 0;
        int mm = a[0];
        rep(j,a.size()) {
            now += a[j]; 
            if(j+1>k) break;
            mm=now;
            if(cyc>0) mm += ((k-(j+1))/a.size())*cyc;
            ma = max(mm, ma);
            //cout << mm << endl;
        }
    }
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 3732
#include<stdio.h>
#include<math.h>
main(){
	double debt=100000;
	double tmp;
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		debt=debt*1.05;
		tmp=ceil(debt/1000);
		debt=tmp*1000;
	}
	printf("%.0f\n",debt);
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    vector<int> P(N);

    for (int i = 0; i < N; i++) cin >> S[i]>>P[i];

    vector<int> ans(N);
    for (int i = 0; i < N; i++) ans.at(i)=i+1;

    for (int i = 0; i < N; i++)
    {
        int min=i;
        for (int j = i; j < N; j++)
          if((S.at(j)<S.at(min)) ||(S.at(j) == S.at(min) && P.at(j)>P.at(min))) min=j;
        
        swap(S.at(i), S.at(min));
        swap(P.at(i), P.at(min));
        swap(ans.at(i), ans.at(min));
    }

  for (int i = 0; i < N; i++) cout << ans[i]<<endl;

  return 0;
}

Measured memory_bytes: 256
from operator import itemgetter
n,m = map(int,input().split())
a = [list(map(int,input().split()))for _ in range(m)]
a = sorted(a,key=itemgetter(1))
removed = -1
count = 0
for x,y in a:
    if x > removed :
        removed = y-1
        count += 1
print(count)

Measured memory_bytes: 29920
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N = 1e5 + 5;
int a[N], b[N];
int n, w;
ll mem[100][N];
int oo = 0x3f3f3f3f;
ll solve(int i, int rem){
    if(i == n)
        return 0;
    ll &ret = mem[i][rem];
    if(~ret)
        return ret;
    return ret = max(solve(i+1, rem), (rem>=a[i]?solve(i+1, rem-a[i]) + b[i] :0));
}

int main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false), cin.tie(0);
#endif
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    memset(mem, -1, sizeof(mem));
    cin>>n>>w;
    for(int i=0; i<n; i++)
        cin>>a[i]>>b[i];
    cout<<solve(0, w)<<'\n';
}

Measured memory_bytes: 81788
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>


int main () {
    int n, d;
    std::cin >> n >> d;

    std::vector<std::vector<int> > x(n);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            int a;
            std::cin >> a;
            x[i].push_back(a);
        }
    }

    int ans = 0;
    for (int i= 0; i < n - 1; i++) {
        for (int j = i + 1; j < n;j ++) {
            int di = 0;
            for (int k = 0; k < d; k++)
            {
                di += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }

            int dii = int(std::sqrt(di));
            double did = std::sqrt(di);
            if(dii == did) {
                ans++;
            }
        }
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
*H, = map(int,input().split())
AB = [list(map(int,input().split())) for _ in [0]*M]

ans = [None]*N
IH = sorted(enumerate(H),key = lambda x: (-x[1],x[0]))
E = [[] for _ in [0]*N]
for a,b in AB:
    a -=1
    b -= 1
    E[a].append(b)
    E[b].append(a)

for i,h in IH:
    if ans[i] == None:
        h = H[i]
        for j in E[i]:
            ans[j] = False
            if H[j] >= h:
                ans[i] = False
        if ans[i] == None:
            ans[i] = True
print(ans.count(True))

Measured memory_bytes: 59480
def Shiritori(n , wli):

    ans = "Yes"

    if len(set(wli)) != len(wli):
        ans = "No"
    else:
        last = (wli[0])[0]
        for i in wli:
            if last != i[0]:
                ans = "No"
                break
            last = i[-1]

    return ans

def main():
    n = int(input())
    wli = [str(input()) for i in range(n)]
    print(Shiritori(n , wli))

if __name__ == '__main__':
    main()

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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define yes "Yes"
#define yse "Yes"
#define no "No"

#define pb push_back
#define mp make_pair

#define list_itr list<ll>::iterator

#define rep(i, l, n) for (int i = (l); i < n; i++)
#define rep_cs(i, l, n) for (int i = (l); i <= n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(v.begin(), v.end());
// int sum = accumulate(v, v + v.size(), 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

using Graph = vector<vector<int>>;
Graph G;
vector<bool> seen;
void dfs(const Graph &G, int v)
{
    seen[v] = true;

    for (auto next_v : G[v])
    {
        if (seen[next_v])
            continue;
        dfs(G, next_v);
    }
}

bool binary_search(int a[], int n, int key)
{
    int left = 0;
    int right = n;
    int middle;
    while (left < right)
    {
        middle = (left + right) / 2;
        if (key == a[middle])
        {
            return true;
        }

        if (key > a[middle])
        {
            left = middle + 1;
        }
        else if (key < a[middle])
        {
            right = middle;
        }
    }
    return false;
}

int n, a[10000000];

int main()
{
    int q, key;
    int sum = 0;

    cin >> n;
    rep(i, 0, n) cin >> a[i];
    cin >> q;
    rep(i, 0, q)
    {
        cin >> key;
        if (binary_search(a, n, key))
        {
            sum++;
        }
    }
    cout << sum << endl;
}


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

int main(){

    int n;
    cin >> n;
    int formerx = 0;
    int formery = 0;
    int formertime = 0;

    for(int i=0; i<n; i++){
        int t,x,y;
        cin >> t >> x >> y;
        int dist, disx, disy;
        dist = t - formertime;
        disx = abs(x - formerx);
        disy = abs(y - formery);
        
        if(dist < disx + disy){
            cout << "No" << endl;
            return 0;
        }

        if(dist % 2 == (disx + disy)%2){
            formertime = t;
            formerx = x;
            formery = y;
            continue;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

// constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
// constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    int l = 0, r = n - 1;
    while (l < r) {
        if (s[l] == 'R') {
            ++l;
            continue;
        }
        if (s[r] == 'W') {
            --r;
            continue;
        }
        swap(s[l], s[r]);
        ++cnt;
    }
    VI cs(n);
    RREP(i,0,n) {
        if (i == n - 1) cs[i] = s[i] == 'R';
        else cs[i] = cs[i+1] + (s[i] == 'R');
    }
    REP(i,l,n) if (cs[i] > 0 && s[i] == 'W') {
        s[i] = 'R';
        ++cnt;
    }
    cout << cnt << endl;
    dump(s);
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 4448
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
#define pi acos(-1)
using namespace std;
ll n ;
ll w[109],val[109];
ll dp[109][1000009];
ll weight;
ll call(ll ind,ll cnt )
{
    if(ind==n) return 0;
    ll &ret=dp[ind][cnt];
    if(ret!=-1) return ret;
    ll sum=0,sum1=0;
    if(cnt+w[ind]<=weight) sum+=call(ind+1,cnt+w[ind])+val[ind];
    sum1=call(ind+1,cnt);
    return ret=max(sum,sum1);
}
int  main()
{
    memset(dp,-1,sizeof dp);
    cin>>n>>weight;
    for(ll i=0;i<n;i++)
    {
        cin>>w[i]>>val[i];
    }
    cout<<call(0,0)<<endl;
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)

const int MOD = 1e9+7;
const int MAXN = 5e3+5;

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n,m;
    cin >> n >> m;
    if(n == m) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  long long ans=K;
  if(N==1){
    cout<<ans<<endl;
    return 0;
  }
  for(int i=0;i<N-1;i++){
    ans=ans*(K-1);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

S, W = LI()
if S <= W:
    print("unsafe")
else:
    print("safe")

Measured memory_bytes: 10792
import java.util.*;
import java.awt.geom.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int n = sc.nextInt();
			int[] x = new int[5];
			int[] y = new int[5];
			Line2D.Double[] s = new Line2D.Double[4];
			for(int i=0;i<n;i++){
				for(int j=0;j<5;j++){
					x[j] = sc.nextInt();
					y[j] = sc.nextInt();
				}
				s[0] = new Line2D.Double(x[0],y[0],x[1],y[1]);
				s[1] = new Line2D.Double(x[1],y[1],x[2],y[2]);
				s[2] = new Line2D.Double(x[2],y[2],x[0],y[0]);
				s[3] = new Line2D.Double(x[3],y[3],x[4],y[4]);
				
				int ans = 1;
				for(int j=0;j<3;j++){
					if(s[j].intersectsLine(s[3])==false) ans = -ans;
				}
				
				if(ans==1) System.out.println("OK");
				else System.out.println("NG");
			}
		}	
	}	
}

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

char s;
int p, n, t = 0, a = 0, i = 0;

int main()
{
    while (cin >> p >> s >> n) {
        t += p * n;
        a += n;
        i++;
    }

    a = (a + i / 2) / i;

    cout << t << endl << a << endl;
}



Measured memory_bytes: 3008
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
using ll = long long;

template <int M, bool IsPrime = false> class Modulo {
  int n;
  static typename std::enable_if<IsPrime, ll>::type inv(ll a, ll p) {
    return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
  }

public:
  Modulo() : n(0) { ; }
  Modulo(int m) : n(m) {
    if (n >= M)
      n %= M;
    else if (n < 0)
      n = (n % M + M) % M;
  }
  Modulo(ll m) {
    if (m >= M)
      m %= M;
    else if (m < 0)
      m = (m % M + M) % M;
    n = m;
  }
  explicit operator int() const { return n; }
  explicit operator ll() const { return n; }
  bool operator==(const Modulo &a) const { return n == a.n; }
  Modulo &operator+=(const Modulo &a) {
    n += a.n;
    if (n >= M) n -= M;
    return *this;
  }
  Modulo &operator-=(const Modulo &a) {
    n -= a.n;
    if (n < 0) n += M;
    return *this;
  }
  Modulo &operator*=(const Modulo &a) {
    n = (ll(n) * a.n) % M;
    return *this;
  }
  Modulo operator+(const Modulo &a) const {
    Modulo res = *this;
    return res += a;
  }
  Modulo operator-(const Modulo &a) const {
    Modulo res = *this;
    return res -= a;
  }
  Modulo operator-() const { return Modulo(0) - *this; }
  Modulo operator*(const Modulo &a) const {
    Modulo res = *this;
    return res *= a;
  }

  Modulo operator^(ll m) const {
    if (m == 0) return Modulo(1);
    const Modulo a = *this;
    Modulo res = (a * a) ^ (m / 2);
    return m % 2 ? res * a : res;
  }
  typename std::enable_if<IsPrime, Modulo>::type
  operator/(const Modulo &a) const {
    return *this * inv(ll(a), M);
  }
  typename std::enable_if<IsPrime, Modulo>::type operator/=(const Modulo &a) {
    return *this *= inv(ll(a), M);
  }

  friend bool is_zero(const Modulo &x) { return int(x) == 0; }
  friend int abs(const Modulo &x) { return int(x); }

  static Modulo fact(int n, bool sw = true) {
    static std::vector<Modulo> v1 = { 1 }, v2 = { 1 };
    if (n >= (int)v1.size()) {
      const int from = v1.size(), to = n + 1024;
      v1.reserve(to);
      v2.reserve(to);
      for (int i = from; i < to; ++i) {
        v1.push_back(v1.back() * Modulo<M, true>(i));
        v2.push_back(v2.back() / Modulo<M, true>(i));
      }
    }
    return sw ? v1[n] : v2[n];
  }
  static Modulo comb(int a, int b) {
    if (b < 0 || b > a) return 0;
    return Modulo::fact(a, true) * Modulo::fact(b, false) *
           Modulo::fact(a - b, false);
  }
};
using Mod = Modulo<1000003, true>;

int main(void)
{
  ll q;
  cin >> q;
  vector<Mod> f(1000003);
  f[0] = Mod(1);
  FOR(i,1,1000004) f[i] = f[i-1]*i;
  REP(i,q) {
    ll x, d, n;
    cin >> x >> d >> n;
    if(!d) {
      cout << (ll)(Mod(x)^n) << endl;
      continue;
    }
    Mod lm = Mod(x) / d - 1;
    ll l = (ll)lm;
    ll r = l+n;
    if(r>1000003) r=1000003;
    ll answer = (ll)(f[r] / f[l] * (Mod(d)^n));
    cout << answer << endl;
  }
  return 0;
}



Measured memory_bytes: 4736
#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>;
 
int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if (S == U) A--;
  else B--;
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define pu(n) cout << n;
#define mod 1000000007


int i,j,k,l;
static const int MAX_N=10e5;
int main(void){
	long long x,k,d;cin >> x >> k >> d;
	x=(x>0?x:-x);
	if(k<=x/d){
		puts(x-k*d);
	}else{
		k=k-x/d;
		x=x%d;
		if(k%2==1){
			puts(d-x);
		}else{
			puts(x);
		}
	}
	return 0;
}


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

int main(){
	double a, sum;
	while (cin >> a){
		sum = 0;
		for (int i = 1; i <= 10; i++){
			sum += a;
			if (i % 2 == 0) a /= 3;
			else a *= 2;
		}
		printf("%.16f\n", sum);
	}
	return 0;
}

Measured memory_bytes: 1236
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(long long i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll>pll;

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

    int ans;
    ans=(N+A-1)/A*B;
    ans=min(ans,(N+C-1)/C*D);

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



Measured memory_bytes: 3084
import java.io.*;
import java.util.*;
public class Main{

    private static void solver(InputReader sc, PrintWriter out) throws Exception {
      int n = sc.nextInt();
     int m = sc.nextInt();
     out.println(n<=m ? "unsafe" : "safe" );

    }
    private static int gcd(int a, int b){
        if(b==0)
            return a;
        return gcd(b, a%b);
    }
    public static void main(String[] args) throws Exception {
        // long start =  System.nanoTime();
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();


    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
}
class Pair  implements  Comparable<Pair>{
    int x;
    int y;
    int z;

    Pair(int x, int y, int z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y, z);
    }

    @Override
    public int compareTo(Pair o) {
        return this.x-o.x;
    }
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;
using graph = mat;
using edge = pair<ll,ll>;
using wgraph = vector<vector<edge>>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll N;
    cin >> N;
    vec_str S(N);
    REP(i,0,N) cin >> S[i];

    sort(ALL(S));
    string t;
    ll cnt = 1;
    REP(i,1,N) {
        if(S[i-1] != S[i]) ++cnt;
    }
    _PR(cnt);


    return 0;
}

/*



*/

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
#define pb push_back
#define M6 1000009
#define M5 500009
#define pi 3.14159265
#define epsilon 1e-6
ll power(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=(res*x)%M;
        n/=2;
        x=(x*x)%M;
    }
    return res;
}
// ll sp[M6*10];
// void sieve(){
//     for(int i=2;i<M6*10;i++) sp[i]=i;
//     for(int i=2;i*i<M6*10;i++){
//         if(sp[i]!=i) continue;
//         for(int j=i*2;j<M6*10;j+=i) {
//             if(sp[j]==j) sp[j]=i;
//         }
//     }
// }
ll n,m,A[M5];
ld K[M5],C[M5];
bool same(ld a,ld b){
    return fabs(a-b)<epsilon;
}
int  main()
{   ios_base::sync_with_stdio (0), cin.tie (0);
    //sieve();
    //init();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll tc=1,t=0,i,j,k,l,r,a,b,c;
    //cin>>tc;
    while(t++<tc){
        //cout<<"Case #"<<t<<": ";
        cin>>n;
        ll ans=0;
        for(i=1;i<=n;i++){
            j=i,c=0;
            while(j){
                c++;
                j/=10;
            }
            if(c&1) ans++;
        }
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 256
n,a,b = map(int,input().split())
mons=[0 for i in range(n)]
for i in range(n):
    mons[i] = int(input())

def can_defeat(n):
    global mons
    global a
    global b
    base = b*n
    sup = 0
    for m in mons:
        if m-base > 0:
            sup += (m-base)//(a-b)+min((m-base)%(a-b),1)
    if sup <= n:
        return True
    else:
        return False

def bin_search(eval_func,left,right):
    if right-left <= 2:
        for i in range(left,right+1):
            if eval_func(i):
                return i
    mid = (left+right)//2
    if eval_func(mid):
        return bin_search(eval_func,left,mid)
    elif eval_func(right):
        return bin_search(eval_func,mid,right)

print(bin_search(can_defeat,0,int(1e10)))

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

int main(){
	string s;                                           
	
	cin>>s;                                          
	                       
	int y=(s[5]-'0')*10+s[6]-'0';
	                  
	if(y<=4){
		cout<<"Heisei"<<endl;
	}else{                         
		cout<<"TBD"<<endl;
	}
	return 0;
}                              

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine().toLowerCase();
		String[ ] tList = new String[10];
		int cnt = 0;
		String t;
		while (!(t = br.readLine()).equals("END_OF_TEXT")) {
			tList = t.split(" ");
			for (String target : tList) {
				if (target.equalsIgnoreCase(w)) cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 24152
#include <iostream>
#include <string>
#include <locale>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{
    string s, p;
    getline(cin, s);
    getline(cin, p);
    if ((s + s).find(p) != string::npos)
    {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}


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

int main() {
	int N, M, a[50], b[50], c[50], d[50];
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> c[i] >> d[i];
	}
	for (int i = 0; i < N; i++) {
		int minD = abs(a[i] - c[0]) + abs(b[i] - d[0]);
		int minN = 0;
		for (int j = 1; j < M; j++) {
			if (minD > abs(a[i] - c[j]) + abs(b[i] - d[j])) {
				minD = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				minN = j;
			}
		}
		cout << minN + 1 << endl;
	}
}

Measured memory_bytes: 256