akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0
n = inp()
if 0<n and n<=9:
    ans = n
elif 10 <= n and n < 100:
    ans = 9
elif 100<= n and n<1000:
    ans = n-99+9
elif 1000 <= n and n < 10000:
    ans = 9+900
elif 10000<= n and n < 100000:
    ans = n- 9999 +900 +9
elif n == 100000:
    ans = 9+900+90000
print(ans)

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

int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());

    if(s < t)
        cout << "Yes" << '\n';
    else
        cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  int a, b, c, d; cin >> a >> b >> c >> d;
  bool turn = true;
  while(true) {
    if(turn) {
      c -= b;
      if(c <= 0) break;
    }else {
      a -= d;
      if(a <= 0) break;
    }
    turn = !turn;
  }
  cout << (turn ? "Yes": "No") << endl;
}

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

using namespace std;
typedef long long ll;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int cnt = 0;
    for (int i = 0; i < k; i++) {
        cnt += p[i];
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////
int n, m;
vector<int>V;
vector<vector<int>>G(10, vector<int>(10,0));
int ans = 0;
bool flag;
bool dfs(int a,int N) {
	if (N == n -1) {
		flag = true;
		return true;
	}
	if (G[a][V[N]]) {
		dfs(V[N], N + 1);
	}
	if (!flag)return false;
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b; cin >> a >> b;
		a--, b--;
		G[a][b] = 1;
		G[b][a] = 1;
	}
	for (int i = 1; i < n; ++i) {
		V.push_back(i);
	}
	sort(V.begin(), V.end());
	do {
		flag = false;
		if (dfs(0, 0)) {
			ans++;
		}
	} while (next_permutation(V.begin(), V.end()));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  ll n,a,b;
  
  cin >> n >> a >> b;
  
  if ((b-a)%2==0){
    cout << (b-a)/2 << endl;
  }else{
    cout << (b-a)/2 + min(a,n-b+1) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class B
{
	static void Main()
	{
		var s = Console.ReadLine();
		Console.WriteLine(string.Join("", s.Reverse()) == s && s.Substring(0, s.Length / 2) == s.Substring((s.Length + 1) / 2) ? "Yes" : "No");
	}
}


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

using namespace std;

const int N = 1e4+7;

int n;
char s[N];

int main()
{
    scanf("%d%s", &n, s);
    for (int i = 0, len = strlen(s); i < len; ++i) {
        s[i] = (s[i]-'A'+n)%26+'A';
    }
    printf("%s\n", s);
    return 0;
}


Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int K; cin >> K;
	vector<pair<int, int> > v(K);
	rep(i, K){
		int x, y; cin >> x >> y;
		v[i] = {y, x};
	}

	vector<int> ban;
	vector<pair<int, int> > ans;
	rep(i, 8) ban.push_back(i);
	sort(ALL(ban));
	do{
		bool ok2 =true;
		rep(i, K){
			bool ok = false;
			rep(j, ban.size()){
				pair<int, int> f = {j, ban[j]};
				if(f.first == v[i].first && f.second == v[i].second) ok = true;
			}
			if(!ok) ok2 = false;
		}
		if(!ok2) continue;

		bool flag = true;
		rep(i, 8){
			rep2(j, i+1, 8){
				pair<int, int> f = {i, ban[i]};
				pair<int, int> f2 = {j, ban[j]};
				if(abs(f.first - f2.first) == abs(f.second - f2.second)) flag = false;
			}
		}
		if(flag){
			rep(i, 8){
				ans.push_back({i, ban[i]});
			}
			break;
		}
	}while(next_permutation(ALL(ban)));

	string out[8];
	rep(i, 8){
		rep(j, 8){
			out[i].push_back('.');
		}
	}

	rep(k, 8){
		pair<int, int> f = ans[k];
		out[f.second][f.first] = 'Q';
	}

	rep(i, 8){
		cout<< out[i] << endl;
	}
}



Measured memory_bytes: 3200
n = int(input())
s = input()
R = set()
G = set()
B = set()
for i in range(n):
    if s[i] == 'R':
        R.add(i)
    elif s[i] == 'B':
        B.add(i)
    else:
        G.add(i)
ans = 0
for r in R:
    for g in G:
        ans += len(B)
        if 2*r - g in B:
            ans -= 1
        if 2*g - r in B:
            ans -= 1
        if not (r+g)&1 and (r+g)//2 in B:
            ans -= 1
print(ans)


Measured memory_bytes: 9540
from sys import stdin
input = stdin.readline

n = int(input())
A = list(map(int, input().split()))

A.sort()

is_ok = [False] * (10 ** 6 + 1)
is_exist = [False] * (10 ** 6 + 1)

for a in A:
    if is_exist[a]:
        is_ok[a] = False
    else:
        is_exist[a] = True
        is_ok[a] = True
        for i in range(1, 10 ** 6 // a + 1):
            if a * i <= 10 ** 6:
                is_exist[a * i] = True

print(is_ok.count(True))


Measured memory_bytes: 35632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

int main()
{
    long long n;
    scanf("%lld", &n);
    std::vector<long long> a(n);
    deque<ll> dq;
    for (int i = 0; i < n; i++)
    {
        ll x;
        cin >> x;
        if (i % 2 == 0)
        {
            dq.push_back(x);
        }
        else
        {
            dq.push_front(x);
        }
    }

    if (n % 2 != 0)
        reverse(dq.begin(), dq.end());

    REP(i, n)
    {
        if (i != (n - 1))
        {
            cout << dq.at(i) << " ";
        }
        else
        {
            cout << dq.at(i) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int n,k,sum=0,maxs=0,w[100010];//n物品k容量 
int f(int x)
{
	int num=1;
	for(int i=1,s=0;i<=n;i++)
	{
		if(s+w[i]<=x)s+=w[i];
		else {s=w[i];num++;}
	}
	return num;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) 
	{
		cin>>w[i];
		maxs=max(maxs,w[i]);
		sum+=w[i];
	}
	int l=maxs,r=sum+1,m,fm;
	while(r>l)
	{
		m=l+(r-l)/2;
		if(f(m)<=k)r=m;
		else l=m+1;
	}
	cout<<l<<endl;
}


Measured memory_bytes: 3480
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.StringTokenizer;

public class Main  implements Runnable {
	public static void main(String[] args) {
		new Thread(null, new Main(), "", 32 * 1024 * 1024).start(); //
	}
	public void run() {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());

		long ans = 0;
		for (int i = 1; i < n; i++) {
			ans += i;
		}
		out.println(ans);
		out.flush();
	}

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }
        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
    }
}

Measured memory_bytes: 22740
K = int(input())


def ns(n):
    ret, tmp = 0, n

    while tmp > 0:
        tmp, r = divmod(tmp, 10)
        ret += r

    return ret


ans, base = 0, 1
for _ in range(K):
    ans += base
    print(ans)

    if (ans + base) / ns(ans + base) > (ans + 10 * base) / ns(ans + 10 * base):
        base *= 10

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N, K, R, S, P; cin >> N >> K >> R >> S >> P;
    string T; cin >> T;

    map<char, int> m;
    m['s'] = R;
    m['p'] = S;
    m['r'] = P;
    m['x'] = 0;
    long long score = 0;
    repp(i,0,N) {
        if (i >= K && T[i] == T[i-K]) T[i] = 'x';
        else score += m[T[i]];
    }
    cout << score << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define elif else if
typedef long long ll;
typedef unsigned long long ull;
#define DEBUG(x) cout << (x) << endl

#define MODULE 1000000007

int n, k;
int arr[200005] = {0};
int ans = 0;
map<int, int> record;
ll cnt[200005] = {0};

void dfs(int pos)
{
    if (pos == n)
    {
        int tmp = arr[0];
        for (int i = 1; i < n; i++)
        {
            tmp = __gcd(tmp, arr[i]);
        }
        ans += tmp;
        record[tmp] += 1;
        return;
    }
    for (int i = 1; i <= k; i++)
    {
        arr[pos] = i;
        dfs(pos + 1);
    }
}

void test_db()
{
    record.clear();
    ans = 0;
    dfs(0);
}

ll quick_pow(ll a, ll b)
{
    ll base = a;
    ll ans = 1;
    while (b)
    {
        if (b & 1)
        {
            ans *= base;
            ans %= MODULE;
        }
        base *= base;
        base %= MODULE;
        b >>= 1;
    }
    return ans % MODULE;
}

void solve()
{
    for (int i = k; i >= 1;i--)
    {
        cnt[i] = quick_pow(k / i, n);
        for (int j = 2; j * i <= k;j++)
        {
            cnt[i] -= cnt[j * i];
        }
        ll tmp = (cnt[i] * i) % MODULE;
        ans += tmp;
        ans %= MODULE;
        while(ans<0)
        {
            ans += MODULE;
        }
    }
}

int main()
{
    for (int _ = 0;_<=0; _++)
    {
        scanf("%d %d", &n, &k);
        // test_db();
        // printf("%d\n", ans);
        // for (map<int, int>::iterator it = record.begin(); it != record.end();it++)
        // {
        //     printf("%d:%d\n", it->first, it->second);
        // }
        solve();
        printf("%d\n", ans%MODULE);
    }
    return 0;
}


Measured memory_bytes: 4584
/*input
7
3 1 4 1 5 9 2
*/
#include <bits/stdc++.h>
using namespace std;

int used[100005];

int main(){
	int n, i, x;
	cin >> n;
	for(i=0;i<n;++i){
		cin >> x;
		if(x > 0){
			used[x-1]++;
			used[x]++;
			used[x+1]++;
		}
		else{
			used[x]++;
			used[x+1]++;
		}
	}
	int mx = -1;
	for(i=0;i<100005;++i)
		mx = max(mx, used[i]);
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace contest20191025
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int p = int.Parse(s[0]);
            int q = int.Parse(s[1]);
            int r = int.Parse(s[2]);

            int[] n = { p + q,  p + r, q + r };
            int min = n[0];
            for(int i = 0; i < n.Length;i++)
            {
                if(min > n[i])
                {
                    min = n[i];
                }
            }

            Console.WriteLine(min);

        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdlib>

using namespace std;

int main(void)
{
   int k, a, b;
   cin >> k >> a >> b;

   for(int i = a; i <= b; i ++)
   {
        if (i % k == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
   }

   cout << "NG" << endl;

    return 0;
}

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

int main() {

int W, H, x, y, r;

cin >> W >> H >> x >> y >> r;

if( x < 0 || y < 0) {
cout << "No" << endl;
return 0;
}


if( (x+r) > W) {
cout << "No" << endl;
return 0;
}

if( (y+r) > H) {
cout << "No" << endl;
return 0;
}

cout << "Yes" << endl;


}


Measured memory_bytes: 3096
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int ans=(c-(a-b));
    if(ans<0)
    cout<<0<<"\n";
    else
    cout<<ans<<"\n";
    
}

Measured memory_bytes: 3564
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>

template<typename T> bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

template<typename T> bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;
ll modadd(ll a,ll b,ll mod=MOD){
    return (a%mod+b%mod)%mod;
}

ll modsub(ll a,ll b,ll mod=MOD){
    a%=mod;
    b%=mod;
    if(a>=b) return a-b;
    else return mod-b+a;
}

ll modmul(ll a,ll b,ll mod=MOD){
    return ((a%mod)*(b%mod))%mod;
}

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

ll moddiv(ll a,ll b,ll mod=MOD) {
    return modmul(a, modpow(b, mod-2));
}



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n,m;
    cin>>n>>m;
    vll x(n),y(m);
    for(ll i=0;i<n;i++)cin>>x[i];
    for(ll j=0;j<m;j++)cin>>y[j];
    
    sort(ALL(x));sort(ALL(y));
    
    ll a=0;
    for(ll i=0;i<n;i++){
        a=modadd(a,modmul(x[i],i-(n-1-i)));
    }
    
    ll b=0;
    for(ll i=0;i<m;i++){
        b=modadd(b,modmul(y[i],i-(m-1-i)));
    }
    
    cout<<modmul(a,b)<<endl;
    
    return 0;
}


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

using namespace std;
typedef long long ll;

unordered_set<ll> s[200010];
ll N,Q;
ll x[200010];
bool y[200010];

void dfs(ll n){
    y[n] = false;
    for(const auto& e : s[n]){
        if(!y[e]) continue;
        x[e] += x[n];
        dfs(e);
    }
}

int main(){
    cin >> N >> Q;
    ll a,b;
    for(int i=0;i<N-1;i++){
        cin >> a >> b;
        s[a-1].insert(b-1);
        s[b-1].insert(a-1);
    }
    for(int i=0;i<N;i++) x[i] = 0;
    for(int i=0;i<N;i++) y[i] = true;
    for(int i=0;i<Q;i++){
        cin >> a >> b;
        x[a-1] += b;
    }
    dfs(0);
    for(int i=0;i<N;i++){
        cout << x[i];
        if(i != N-1) cout << " "; 
    }
    cout << endl;
    return 0;
}

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

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define rep(n) for(ll i = 0 ; i<n ; i++) 
#define rep2(n) for(ll j=0 ; j<n ; ++j )
#define repd(n) for(ll i = n-1 ; i>=0 ; i--)
#define MOD 1000000007
#define pii pair<ll,ll>
#define vll vector<ll>
#define ff first
#define ss second
typedef vector<vector<ll> > mat;
#define nl "\n"
#define INF 0x3f3f3f3f
#define sz(a) a.size() 


void solve() {
	ll n ; cin>>n;
	ll s=0;
		s = s + 1000*(n/500); n = n%500;
		s = s + 5*(n/5) ; n=n%5;
	cout << s; 
}


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

	ll t=1;
	// cin>>t;
	rep(t) {
		solve() ; 
	}
	return 0;
}

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

struct P{
  double x,y;
};

void koch(int n,P a, P b){
  if(n==0){
    return ;
  }
  P s,t,u;
  double h=M_PI*60.0/180.0;
  s.x= (2.0*a.x+1.0*b.x)/3;
  s.y=(2.0*a.y+1.0*b.y)/3;
  t.x=(1.0*a.x+2.0*b.x)/3;
  t.y=(1.0*a.y+2.0*b.y)/3;
  u.x=s.x+(t.x-s.x)*cos(h)-(t.y-s.y)*sin(h);
  u.y=s.y+(t.x-s.x)*sin(h)+(t.y-s.y)*cos(h);
  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}

int main(){
  int n;
  cin>> n;
  P a,b;
  a.x=a.y=b.y=0.0;
  b.x=100.0;
  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);
}


Measured memory_bytes: 3132
#include <stdio.h>
#define max 200001
int main(void){
	int num[max]={0},i,n,temp,min;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&num[i]);
	}
	temp=num[1]-num[0];
	min=num[0];
	for(i=0;i<n;i++){
		if(min>num[i]) min=num[i];
		if(temp<num[i+1]-min && n>i+1) temp=num[i+1]-min;
	}
	printf("%d\n",temp);
	return 0;
}

Measured memory_bytes: 1388
#include <bits/stdc++.h>
using namespace std;
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define ff              first
#define ss              second
#define LCM(x,y)        (((x)/__gcd((x),(y)))*(y))
#define PI              acos(-1)
#define SZ(x)           x.size() - 1
#define waa             puts("ripon")
#define mem(a,b)        memset(a,b,sizeof(a))
#define rep(i,a,n)      for(int i=(int)(a);i<=(int)(n);i++)
#define per(i,n,a)      for(int i=(int)(n);i>=(int)(a);i--)
#define all(v)          v.begin(), v.end()
#define allr(v)         v.rbegin(), v.rend()
int dx[] = { 0, 1, 0, -1, -1, 1, 1, -1 };
int dy[] = { 1, 0, -1, 0, -1, -1, 1, 1 };
int overlap(int rs,int re,int qs,int qe){ if(rs>qe or re<qs) return 0; else if(qs<=rs and re<=qe) return 1; else return 2;} // 0 no, 1 total, 2 partial
void pvec(auto v){for(auto x:v){cout<<x<<" ";}cout<<endl;}
//*************useless stuff*************//

#define TC 0
#define mod 10000007
#define N 1000000

void solve(int T) {
    int h,w,n;
    cin>>h>>w>>n;
    int mx = max(h,w);
    cout<<(n+mx-1)/mx<<endl;
    return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    #ifdef LOCALDEF
        freopen("input.txt","r",stdin);
    #endif
    int T=1;
    if(TC) cin>>T;
    for(int t=1;t<=T;t++)   solve(t);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] ==s[2] )cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	int mcnt = 0;
	FOR(i, 0, n-1) {
		cin >> a[i];
		if (a[i] < 0) {
			mcnt++;
			a[i] *= -1;
		}
	}
	sort(ALL(a));
	if (mcnt % 2) {
		a[0] *= -1;
	}
	ll res = accumulate(ALL(a), 0LL);
	pv(res);
	return 0;
}

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

using namespace std;

int main() {
	// your code goes here
		int n;cin>>n;
		int finaltime;cin>>finaltime;
		int time_taken[n];
		int del[n];
		for(int i =0;i<n;i++) {
			cin>>time_taken[i];
			cin>>del[i];
		}
		long dp[finaltime+1][n+1][2];
		for(int i = 0;i<=finaltime;i++) {
			for(int j=0;j<=n;j++) {
				dp[i][j][0]=-1;
				dp[i][j][1]=-1;
			}
		}
		dp[0][0][0]=0;
		for(int i=0;i<n;i++) {//object
			for(int j=0;j<2;j++) {//last
				for(int k= 0;k<finaltime;k++) {//time
					int curr_time=time_taken[i];
					int curr_del=del[i];
					long curr_ans = dp[k][i][j];
					if(curr_ans!=-1) {
						if(k+curr_time<finaltime) {
							dp[k+curr_time][i+1][j]=std::max(dp[k+curr_time][i+1][j],curr_ans+curr_del);
						}
						dp[k][i+1][j]=std::max(dp[k][i+1][j],curr_ans);
						if(j==0) {
							dp[k][i+1][1]=std::max(curr_ans+curr_del,dp[k][i+1][1]);
						}
					}
				}
			}
		}
		long max= 0;
		for(int i=0;i<=n;i++) {
			for(int j=0;j<2;j++) {
				for(int k=0;k<=finaltime;k++) {
					max= std::max(max,dp[k][i][j]);
				}
			}
		}
		cout<<max;
	

	return 0;
}

Measured memory_bytes: 140928
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
/* 素因数分解 */
map<ll, ll> factList;
void primeFactor(ll n)
{
	if ((n % 2) == 0){
		while((n % 2) == 0) {
			factList[2]++;
			n = n / 2;
		}
	}

	for(ll i = 3; i <= sqrt(n); i += 2){
		while ((n % i) == 0){
			factList[i]++;
			n = n / i;
		}
	}

	if (n != 1) {
		factList[n]++;
	}
}

int main()
{
	int N;
	cin >> N;
	
	for (int i = 1; i <= N; i++) {
		primeFactor(i);
	}

	// 0乗分を加算
	vector<int> factCnt;
	for (auto& factOne : factList) {
		factOne.second++;
		factCnt.emplace_back(factOne.second);
	}

	int ans = 0;
	ll factCntTotal = factCnt.size();
	for (ll i = 0; i < factCntTotal; i++) {
		for (ll j = 0; j < factCntTotal; j++) {
			for (ll k = j + 1; k < factCntTotal; k++) {
				if (i != j && j != k && k != i) {
					if (3 <= factCnt[i] && 5 <= factCnt[j] && 5 <= factCnt[k]) {
						ans++;
					}
				}
			}
		}
	}

	for (ll i = 0; i < factCntTotal; i++) {
		for (ll j = 0; j < factCntTotal; j++) {
			if (i != j) {
				if (3 <= factCnt[i] && 25 <= factCnt[j]) {
					ans++;
				}
				if (5 <= factCnt[i] && 15 <= factCnt[j]) {
					ans++;
				}
			}
		}
	}

	for (ll i = 0; i < factCntTotal; i++) {
		if (75 <= factCnt[i]) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

perms = []
x = [i for i in range(1, N + 1)]
def perm(start):
    if start == N:
        perms.append(x.copy())
        return
    for i in range(start, N):
        x[i], x[start] = x[start], x[i]
        perm(start + 1)
        x[i], x[start] = x[start], x[i]
perm(0)
perms = sorted(perms)

a, b = 0, 0
for i in range(len(perms)):
    R = perms[i]
    for j in range(len(P)):
        if P[j] != R[j]:
            break
    else:
        a = i

    for j in range(len(Q)):
        if Q[j] != R[j]:
            break
    else:
        b = i
print(abs(a - b))


Measured memory_bytes: 15152
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int d[500][500];
int n,m;
int a[maxn];
int b[maxn];
int c[maxn];
int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	gbtb;
	cin>>n>>m;
	repd(i,1,m)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	repd(i,1,n)
	{
		repd(j,1,n)
		{
			d[i][j] = d[j][i] = i==j?0:inf;
		}
	}
	repd(k,1,m)
	{
		repd(i,1,n)
		{
			repd(j,1,n)
			{
				d[i][j]=d[j][i]=min(d[j][i],d[i][a[k]]+d[b[k]][j]+c[k]);
			}
		}
	}
	int ans=0;
	repd(k,1,m)
	{
		if(d[a[k]][b[k]]!=c[k])
		{
			ans++;
		}
	}
	cout<<ans<<endl;



    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();}
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9')
{*p = *p * 10 + ch - '0';}}}


Measured memory_bytes: 6400
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	ll Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;
	H = min(2 * Q, H);
	S = min(S, 2 * H);
	if (D < 2 * S) {
		Q = D * (N / 2) + S * (N % 2);
	}
	else {
		Q = S * N;
	}
	cout << Q << endl;


}


Measured memory_bytes: 256
#include<stdio.h>
#define N 501
#define WHITE 0
#define GRAY 1
#define BLACK 2

static const int INFTY = (1<<21);

int n,M[N][N];
int color[N],d[N],f[N],t;

void visit(int u){
  int v;
  color[u]=GRAY;
    d[u]=++t;
  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(color[v]==WHITE){
      visit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++t;
}

void dfs(){
  int i,u;
  for(i=0;i<n;i++) color[i]=WHITE;
  t=0;
  for(u=0;u<n;u++){
    if(color[u]==WHITE) visit(u);
  }
  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
}

int main(){
  int u,k,v; 
  int i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++) M[i][j]=0;
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j= 0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();

  return 0;
}



Measured memory_bytes: 2088
#include<stdio.h>
int main(void)
{
	char number[11];
	int i = 0,c=0,n;

	while (scanf("%s",number,11) != EOF)
	{
		n = 10;
			for (i = 0; i+1 < n; i++) {
				if(n==10)
				  c = (number[i] - '0' + number[i + 1] - '0') % 10;
				else
			      c = (number[i] + number[i + 1]) % 10;
				number[i] = c;
					if (i == n - 2) {
						i = -1;
						n = n-1;
					}
			}
			printf("%d\n", number[0]);
		}
	return 0;
}

Measured memory_bytes: 540
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


const long long MAX = numeric_limits<long long>::max();

void solve(long long H, long long N, std::vector<long long> A, std::vector<long long> B){
  long long t = MAX;
  long long a;
  // vector<vector<long long>> dp(H, vector<long long>());
  vector<long long> dp(H+1, -1);
  dp[H] = 0;
  for (long long i = H; i >= 0 ; --i) {
    for (int j = 0; j < N; ++j) {
      long long target = max(0LL, i-A[j]);
      if (dp[i] < 0) {continue;};
      if (dp[target] < 0) {
        dp[target] = dp[i] + B[j];
      }
      dp[target] = min(dp[target], dp[i] + B[j]);
    }
  }
  std::cout << dp[0] << std::endl;
}

int main(){
  long long H;
  scanf("%lld",&H);
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  std::vector<long long> B(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
    scanf("%lld",&B[i]);
  }
  solve(H, N, std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
  char c;
  cin >> c;
  if(c == 'a'){
  cout << "vowel" << endl;
  }
  else if(c == 'i'){
  cout << "vowel" << endl;
  }
  else if(c == 'u'){
  cout << "vowel" << endl;
  }
  else if(c == 'e'){
  cout << "vowel" << endl;
  }
  else if(c == 'o'){
  cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

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

int ans = 0;

int main(){
	int N; cin >> N;
	string S; cin >> S;
	for(int st=0; st<N; st++){
		vector<int> z(N-st, 0);
		string s = S.substr(st);
		int L = 0;
		for(int i=1; i<s.size(); i++){
			if(L + z[L] > i + z[i-L]) z[i] = z[i-L];
			else{
				int j = max(0, L + z[L] - i);
				while(i+j < s.size() && s[i+j] == s[j]) j++;
				z[i] = j;
				L = i;
			}
		}
		for(int en=1; en<s.size(); en++){
			if(ans < min(en, z[en])) ans = min(en, z[en]);
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int n;
    scanf("%d", &n);
    int sides[3];
    for (int i = 0; i < n; i++){
	cin >> sides[0] >> sides[1] >> sides[2];
	sort(sides, sides+3);
	printf("%s\n", (sides[0]*sides[0] + sides[1]*sides[1] == sides[2]*sides[2] && sides[2] < sides[1] + sides[2])? "YES" : "NO");
    }
}

Measured memory_bytes: 0
from collections import deque
n = int(input())
g = [[]for i in range(n)]
for _ in range(n-1):
  a, b, c = map(int, input().split())
  g[a-1].append([b-1,c])
  g[b-1].append([a-1,c])
ans = [0 for i in range(n)]
v = [-1 for i in range(n)]
v[0] = 0
d = deque([0])
while len(d):
  x = d.popleft()
  for i,j in g[x]:
    if v[i] == -1:
      d.append(i)
      b = ans[x] +j
      ans[i] = b
      if b%2 ==1:
        v[i] = 1
      else:
        v[i] = 0
print("\n".join(map(str,v)))

Measured memory_bytes: 58672
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>
#include <fstream>
#include <cfloat>
#include <complex>
using namespace std;
int main() {
	int k; cin >> k;
	int single = 7 % k;
	int twice = 77 % k;
	int count = 1;
	while (single != 0 && single != twice) {
		single = (single * 10 + 7) % k;
		twice = (twice * 100 + 77) % k;
		++count;
	}
	if (single == 0) {
		cout << count << '\n';
	}
	else {
		cout << "-1\n";
	}
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;

int dp[10001];//dp[i]:i与えるのに必要な最小魔力
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}

signed main(){
  int h,n;cin>>h>>n;
  for(int i=1;i<10001;i++)dp[i]=INF;
  while(n--){
    int a,b;cin>>a>>b;
    for(int i=0;i<10001;i++)chmin(dp[min(i+a,h)],dp[i]+b);
  }
  int ans=INF;
  for(int i=h;i<10001;i++)chmin(ans,dp[i]);
  cout<<ans<<endl;
}


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

using namespace std;

const int MAX_N = 1e5 + 10;

int n;
long long a, b;
long long h[MAX_N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    long long c = a - b;
    long long L = 0;
    long long R = 1e9 + 10;
    while (R - L > 1) {
        long long M = (R + L) / 2;
        long long cnt = 0;
        for (int i = 0; i < n; i++) {
            if (h[i] - M * b > 0) {
                cnt += (h[i] - M * b + c - 1) / c;
            }
        }
        if (cnt > M) {
            L = M;
        } else {
            R = M;
        }
    }
    cout << R << "\n";
}



Measured memory_bytes: 1024
n=int(input())
memo=[0for i in range(n)]
def lucas(n):
    memo = [0]*(n+1)

    def _lucas(n):
        if n == 0:
            return 2
        if n==1:
            return 1
        if memo[n] != 0:
            return memo[n]
        memo[n] = _lucas(n-1) + _lucas(n-2)
        return memo[n]

    return _lucas(n)
print(lucas(n))

Measured memory_bytes: 3060
from sys import stdin
input = stdin.readline

n = int(input())
a = list(map(int, input().split()))

a_max=max(a)
a_max_half=a_max/2
tmp=a[0]
if n==2:
    print(max(a),min(a))
    exit()
for i in range(1,n):
    if abs(a[i]-a_max_half)<abs(tmp-a_max_half):
        tmp=a[i]
print(a_max,tmp)


Measured memory_bytes: 14008
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,d,e,f;
  cin>>a>>b;
  cin>>c>>d;
  cin>>e>>f;
  if(a==c||a==d){
    if(a==e||a==f){
      cout<<"NO";
    }
    else{
      cout<<"YES";
    }
  }
  else if(b==c||b==d){
    if(b==e||b==f){
      cout<<"NO";
    }
    else{
      cout<<"YES";
    }
  }
  else if(a==e||a==f){
    if(a==c||a==d){
      cout<<"NO";
    }
    else{
      cout<<"YES";
    }
  }
  else if(b==e||b==f){
    if(b==c||b==d){
      cout<<"NO";
    }
    else{
      cout<<"YES";
    }
  }
}

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

ll extGDC(ll a, ll b, ll &x, ll &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  
  ll d = extGDC(b, a % b, y, x);
  y -= a / b * x;
  return d;
}

int main() {
  ll N;
  cin >> N;
  
  vector<ll> T(N);
  for (int i = 0; i < N; i++) {
    cin >> T.at(i);
  }
  
  ll ans = 1;
  ll x, y;
  for (int i = 0; i < N; i++) {
    ll gdc = extGDC(ans, T.at(i), x, y);
    ans = ans / gdc * T.at(i);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define w first
#define v second
#define ii pair<ll , ll>
using namespace std;

string s , t;
const int N = 3010;
int m ,n;
int mem[N][N];

int dp(int i , int j){
	if(i == n || j == m) return 0;
	int &ret = mem[i][j];
	if( ret!= -1 ) return ret;
	ret = 0;
	if(s[i] == t[j]) ret = 1 + dp(i+1 , j+1);
	return ret = max({
			ret,
			dp(i+1 , j),
			dp(i , j+1)
	});
}

void getpath(int i , int j){
	if(i == n || j == m) return;
	int &ret = mem[i][j];
	if(s[i] == t[j]){
		printf("%c" , s[i]);
		getpath(i+1 , j+1);
		return;
	}
	if(mem[i+1][j] > mem[i][j+1]) getpath(i+1 , j);
	else getpath(i , j+1);
}
int main(){
	memset(mem , -1, sizeof mem);
	cin>>s>>t;
	n = s.length();
	m = t.length();
	//printf("%d\n" , dp(0,0));
	dp(0,0);
	getpath(0,0);
}



Measured memory_bytes: 36096
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
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)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

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

int main(){
	int n,m;
	cin>>n>>m;
	vector<int> coin(m);
	rep(i,m)cin>>coin[i];
	sort(all(coin));
	vector<vector<int>> dp(m+1, vector<int>(n+1,inf));
	rep(i,m+1)dp[i][0] = 0;
	for(int i = 1; i<=m; ++i){
		for(int j = 1; j<=n; ++j){
			if(coin[i-1] > j){
				dp[i][j] = dp[i-1][j];
			}else{
				chmin(dp[i][j], dp[i-1][j]);
				chmin(dp[i][j], dp[i][j-coin[i-1]]+1);
			}
		}
	}
	cout<<dp[m][n]<<endl;
	return 0;
}



Measured memory_bytes: 7124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC
{
	class Program
	{
		static void Main(string[] args)
		{
			int D;
			D = int.Parse(Console.ReadLine());
			string s = "Christmas";
			for (int i = 0; i < 25 - D; i++)
			{
				s += " Eve";
			}
			Console.WriteLine(s);

			Console.ReadKey();
		}
	}
}


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

int main() {
  int n, ans, m, k;
  cin >> n;
  cin >> m;
  n--;
  ans = 1;
  while (n--) {
    cin >> k;
    if (k >= m) {
      ans++; 
      m = k;
    }
  }
  printf("%d\n", ans);
  return 0;}


Measured memory_bytes: 256
#include <vector>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
typedef long long ll;
using namespace std;
typedef vector<ll> vll; typedef set<ll> sll; typedef map<ll,ll> mll;
int bitct(long long r) {int c=0; for(; r; r&=r-1) c++; return c;}
long long gcd(long long x, long long y) {return x ? gcd(y%x,x) : y;}
long long choose(long long n, long long q) { if(n==0 || q==0) return 1;
  if (q==1) return n; else return ( choose(n, q-1) * (n-q+1 ) /q); }
template<typename T> ostream& operator << (ostream &o,vector<T> v) {o<<"[";
  int i=0,s=v.size();for(;i+1<s;i++)o<<v[i]<<", ";if(s)o<<v[i];o<<"]";return o;}
template<typename K, typename V> ostream& operator << (ostream &o,
  unordered_map<K, V> m) {o<<"{";for(auto i:m)o<<i.first<<" -> "<< i.second <<
  ", "; o<<"}";return o;}
template<typename K, typename V> ostream& operator << (ostream &o, map<K, V> m)
  {o<<"{";for(auto i:m)o<<i.first<<" -> "<< i.second << ", "; o<<"}";return o;}
template<typename K> ostream& operator << (ostream &o, set<K> m)
  {o<<"{";for(auto i:m)o<<i<< ", "; o<<"}";return o;}
template<typename K> ostream& operator << (ostream &o, unordered_set<K> m)
  {o<<"{";for(auto i:m)o<<i<< ", "; o<<"}";return o;}
template<typename T> ostream& printv(vector<T> v) {int i=0,s=v.size();
  for(;i+1<s;i++)cout<<v[i]<<" ";if(s)cout<<v[i];return cout;}

int main() {
  ios_base::sync_with_stdio(false);
  string S ;
  cin >> S ;

  bool fail=false;
  ll ct=0;
  ll l=0, r=S.size()-1;
  while(1) {
    if(l>r) {fail=true; break;}
    if(l==r) break;
    if(S[l]==S[r]) {
      if(r==l+1) break;
      l++;r--;
      continue;
    }
    if(S[l] != S[r] && S[l] == 'x') {
      ct++;
      l++;
    } else if(S[l] != S[r] && S[r] == 'x') {
      ct++;
      r--;
    } else {
      fail=true;
      break;
    }

  }

  if(fail)
    cout << -1 << endl;
  else
    cout << ct << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<map>
#include<queue>
#define N 9

using namespace std;

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

struct Puzzle{
  int field[N];
  int blank;
  int num;

  bool operator < (const Puzzle& a) const{
    for(int i = 0; i < N; i++){
      if(a.field[i] == field[i]) continue;
      return field[i] >  a.field[i];
    }
    return false;
  }
};

bool check(Puzzle puz){
  for(int i = 0; i < N; i++){
    if(puz.field[i] != i+1) return false;
  }
  return true;
}

int bfs(Puzzle puz){
  queue<Puzzle> que;
  map<Puzzle, bool> mp;

  que.push(puz);
  mp[puz] = true;

  while(!que.empty()){
    Puzzle p = que.front(); que.pop();
    if(check(p) == true) return p.num;
    int x = p.blank % 3;
    int y = p.blank / 3;
    for(int i = 0; i < 4; i++){
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(nx < 0 || 2 < nx || ny < 0 || 2 < ny) continue;
      Puzzle tmp = p;
      swap(tmp.field[p.blank], tmp.field[3 * ny + nx]);
      tmp.blank = 3 * ny + nx;
      if(mp[tmp] == false){
    mp[tmp] = true;
    tmp.num++;
    que.push(tmp);
      }
    }
  }
  return -1;
}

signed main(){
  Puzzle puz;

  for(int i = 0; i < N; i++){
    cin >> puz.field[i];
    if(puz.field[i] == 0){
      puz.field[i] = N;
      puz.blank = i;
    }
  }

  puz.num = 0;
  int b = bfs(puz);
  cout << b << endl;
}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;


void solve(long long N, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
    ll tot = 0;
    int pre = 0;
    pre = A[0];
    tot += B[pre];

    for(int i=1;i<N;i++){
        int next = A[i];
        tot+= B[next];
        if(next - pre == 1){
            tot += C[next-1];
        }
        pre = next;
    }
    cout<<tot<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        A[i]--;
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    std::vector<long long> C(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&C[i]);
    }
    solve(N, std::move(A), std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cstdio>


int main(void){
  int n, k;
  std::cin >> n >> k;
  long double p[n+1];
  for(int i=1; i<=n; i++){
    p[i] = 1.0/n;
  }
  long double num[n+1];
  for(int i=1; i<=n; i++){
    num[i] = std::max(int(std::ceil(std::log2(k/1.0L/i))), 0);
  }



  long double ret = 0;
  for(int i=1, last=-1; i<=n;i++){
    if(last!=-1) ret *= static_cast<long double>(std::pow(2, -(last-num[i])));
    ret += 1.0L/n;
    last = num[i];
  }
  ret *= static_cast<long double>(std::pow(2, -num[n]));

  std::printf("%.16Lf\n", ret);

  return 0;
}


Measured memory_bytes: 3328