akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);// 0==true 1をtrueにしたい
    for(int i=0;i<N;i++)
    {
        cin >> A.at(i);
    }

    int brite = A.at(0);

    int counter = 0;

    bool TF = true;

    vector<bool> bri(N,false);
    bri.at(0)=true;

    while(bri.at(1)!=true)
    {
        if(bri.at(brite-1)==true)
        {
            TF = false;
            cout << "-1" << endl;
            break;
        }
        bri.at(brite-1)=true;
        brite = A.at(brite-1);
        counter++;
    }

    if(TF==true)
    {
        cout << counter << endl;
    }

    return 0;
}

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

const int maxm = 100000 + 5;
const int maxn = 100000 + 5;

struct Edge{
  int to,next;
} G[maxm<<1];

int head[maxn],cnt = 0;
int color[maxn];
bool vis[maxn];

void Insert(int u,int v){
  G[++cnt].next = head[u];
  G[cnt].to = v;
  head[u] = cnt;
}

void Dfs(int u,int c){
  vis[u] = true;
  color[u] = c;
  for (int e = head[u];e; e = G[e].next) {
    int v = G[e].to;
    if (!vis[v]) {
      Dfs(v,c);
    }
  }
}

int main(){
  int n,m;
  scanf("%d %d",&n,&m);
  for (int i=1;i<=m; i++) {
    int u,v;
    scanf("%d %d",&u,&v);
    Insert(u,v);
    Insert(v,u);
  }
  for (int i=1; i<=n; i++) {
    if (!vis[i]) {
      Dfs(i,i);
    }
  }
  int q;
  scanf("%d",&q);
  for(int i=1; i<=q; i++){
    int u,v;
    scanf("%d%d",&u,&v);
    if (color[u]==color[v]) {
      printf("yes\n");
    }
    else {
      printf("no\n");
    }
  }
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, d, nw = 0, cnt = 1;
  cin >> n;
  d = n;
  string ps, s;
  cout << 0 << endl;
  cin >> ps;
  while(s != "Vacant") {
    if(d % 4)
      d = (d / 4 + 1) * 2;
    else
      d /= 2;
    cout << (nw + d) % n << endl;
    cin >> s;
    cnt++;
    if(ps != s && s != "Vacant") {
      if(d == 2) {
        cout << (nw + 1) % n << endl;
        cin >> s;
        cnt++;
      }
    } else {
      nw = (nw + d) % n;
      ps = s;
    }
    if(cnt > 20) return 0;
  }
}

Measured memory_bytes: 852
//https://blog.csdn.net/hesorchen
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define mod 1000000007
int main()
{
    string a, b;
    int c, d;
    string e;
    cin >> a >> b >> c >> d >> e;
    if (a == e)
    {
        cout << c - 1 << ' ' << d << endl;
    }
    else if (b == e)
        cout << c << " " << d - 1 << endl;
    else
        cout << c << " " << d << endl;

    return 0;
}


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

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

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

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

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
// using mP = pair<modint, modint>;

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




void solve() {
    string s, t; cin >> s >> t;
    int r = s.size()-1;
    int n = t.size();
    while(r-n >= -1){
        bool flg = true;
        rep(i, n){
            if(s[r-i] != '?' && s[r-i] != t[n-1-i]) flg=false;
        }
        if(flg) break;
        else r--;
    }

    if(r-n < -1){
        cout << "UNRESTORABLE" << endl;
    }else{
        rep(i, n){
            s[r-i] = t[n-1-i];
        }
        rep(i, s.size()){
            if(s[i] == '?') s[i] = 'a';
        }

        cout << s << endl;
    }
}

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


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

int main() {
        int N;
        cin >> N;
        while (N != 0) {
                int A, AT = 0;
                int B, BT = 0;

                rep(n, N) {
                        cin >> A >> B;
                        if (A == B) {
                                AT += A;
                                BT += B;
                        } else {
                                if (A > B) {
                                        AT += A + B;
                                } else {
                                        BT += A + B;
                                }
                        }
                }
                cout << AT << " " << BT << endl;
                cin >> N;
        }

        return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <list>
using namespace std;

int main()
{

	int a, b;

    cin >> a >> b;

    if(a + b == 15) cout << '+' << endl;

    else if(a * b == 15) cout << '*' << endl;

    else cout << 'x' << endl;

    

	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

string f(bool b) {
	if (b)return "+";
	else return "-";
}

int main() {
	makes(s);
	int a[3];
	int aa = s[0] - '0';
	rep(3)a[i] = s[i + 1] - '0';
	For(bit, (1 << 3)) {
		int cnt = aa;
		For(i, 3) {
			if (bit&(1 << i)) {
				cnt += a[i];
			}
			else cnt -= a[i];
		}
		if (cnt == 7) {
			cout << aa;
			rep(3)cout << f(bit&(1 << i)) << a[i];
			say("=7");
			re;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  string ans = (10*g+b)%4 == 0 ? "YES" : "NO";
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main() {
 
  int n, i, b, f, r, v, count=0;
  int house[5][4][11] = {};
 
  cin >> n;
 
  for(i = 0; i < n; i++){
    cin >> b >> f >> r >> v;
    house[b][f][r] += v;
  }
 
   
  for(b = 1; b <= 4; b++){
    for(f = 1; f <= 3; f++){
      for(r = 1; r <= 10; r++){
    cout << " " << house[b][f][r];
      }
      cout << endl;
    }
    if(count < 3) cout << "####################" << endl;
    count++;
  }
 
  return 0;
   
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 1000000000000000000
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    int N;
   cin>>N;
    ll a[1000000],ans=1;
    loop(i,0,N){
        cin>>a[i];
        if(a[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    loop(i,0,N){
        if(a[i]>mx/ans){
            cout<<-1<<endl;
            return 0;
        }else {
            ans*=a[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 4408
ans :: [(Int,Int)] -> (Int,Int)
ans dt =
  let s = sum $ map (\(a,b) -> a*b) dt
      n = sum $ map (\(a,b) -> b) dt
      i = length dt
      a'= (n*10) `div` i
      a = if a' `mod` 10 >= 5
          then a' `div` 10 + 1
          else a' `div` 10
  in
    (s,a)

split :: String -> (Int,Int)
split text =
        let Just i = lookup ',' $ zip text [0..]
            a = read $ take i text
            b = read $ drop (i+1) text
        in
          (a,b)

main = do
    c <- getContents
    let s = map split $ lines c
        o = ans s
    print $ fst o
    print $ snd o

Measured memory_bytes: 3552
//header{{{
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/trie_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) begin(x),end(x)
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7;
constexpr int mod2 = 998244353;
 
template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}
 
    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};
 
template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
template <class T> using Set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class K, class V> using Umap = gp_hash_table<K, V>;
using Trie = trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update>;
 
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }
 
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max({a * c, a * d, b * c, b * d}) << '\n';

    return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

const int MAX_V = 10e4;

struct edge
{
    int to, cap, rev;
};

std::vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap)
{
    G[from].push_back(edge{to, cap, (int)G[to].size()});
    G[to].push_back(edge{from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f)
{
    if (v == t)
        return f;
    used[v] = true;
    for (int i = 0; i <(int)G[v].size(); i++)
    {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0)
        {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0)
            {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t)
{
    int flow = 0;
    for (;;)
    {
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if (f == 0)
            return flow;
        flow += f;
    }
}

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

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

    while (true)
    {
        for (int i = 0; i < MAX_V; i++)
        {
            G[i].erase(G[i].begin(), G[i].end());
            used[i] = false;
        }
        int m, n;
        cin >> m >> n;
        if (m == 0 && n == 0)
            break;
        bool can[1000][1000]; //can[i][j]:b[i]???r[j]?????????????????????
        int b[1000], r[1000];
        for (int i = 1; i <= m; i++)
            cin >> b[i];
        for (int i = 1; i <= n; i++)
            cin >> r[i];
        for (int i = 1; i <= m; i++)
        {
            for (int j = 1; j <= n; j++)
            {
                can[i][j] = (gcd(b[i], r[j]) > 1);
            }
        }
        int s = m + n + 1, t = s + 1;

        for (int i = 1; i <= m; i++)
        {
            add_edge(s, i, 1);
        }

        for (int i = 1; i <= n; i++)
        {
            add_edge(m + i, t, 1);
        }

        for (int i = 1; i <= m; i++)
        {
            for (int j = 1; j <= n; j++)
            {
                if (can[i][j])
                {
                    add_edge(i, m + j, 1);
                }
            }
        }
        cout << max_flow(s, t) << endl;
    }
}


Measured memory_bytes: 12352
/**
       **********    ************
	  Author : Avi J Patel
	  University : DAIICT
       **********    ************
**/
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 1844674407370955161
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define min_heap priority_queue<int, vector<int>, greater<int>>
#define max_heap priority_queue<int>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> 

bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    if(a.ss < b.ss) return true; 
    else if(a.ss==b.ss) return a.ff<b.ff;
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.ff<b.ff) return true;
	else if(a.ff==b.ff) return a.ss<b.ss;
	else return false;
} 
bool sortff_resortss(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.ff<b.ff) return true;
	else if(a.ff==b.ff) return a.ss>b.ss;
	else return false;
}
bool sortbystring(const string &a, const string &b)
{
	string c=a+b;
	string d=b+a;
	if(c>=d) return true;
	else return false;
}

ll modi(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 
ll Logn(ll  n, ll r) 
{ 
    return (n > r - 1) ? 1 + Logn(n / r, r) : 0; 
} 

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 

  
int main()
{
	FAST
	int t=1;
//	cin>>t;
	while(t--)
	{	
		int n,m;
		cin>>n>>m;
		cout<<(n*(n-1))/2+(m*(m-1))/2;
	}
	return 0;
}
















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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

int main() {
    ll n, x, d;
    cin >> n >> x >> d;

    if (d == 0) {
        if (x == 0) {
            cout << 1 << endl;
        } else {
            cout << n + 1 << endl;
        }
        return 0;
    }

    map<int, vector<P>> mp;
    rep(i, n + 1) {
        ll s = x * i;
        ll l = i * (i - 1) / 2;
        ll r = l + i * (n - i);
        s += l * d;
        r -= l;
        mp[(s + (d << 30)) % d].emplace_back(s, r);
    }
    ll ans = 0;
    for (auto p : mp) {
        auto a = p.second;
        int m = a.size();
        rep(i, m) a[i].first = (a[i].first - p.first) / d;
        vector<P> ev;
        rep(i, m) {
            ev.emplace_back(a[i].first, 1);
            ev.emplace_back(a[i].first + a[i].second + 1, -1);
        }
        sort(ev.begin(), ev.end());
        ll count = 0, pre = -INF;
        for (auto e : ev) {
            ll len = e.first - pre;
            if (count) ans += len;
            count += e.second;
            pre = e.first;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 25440
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    const int T = 5;
    ll n; cin >> n;
    vector<ll> t(T);
    REP(i,T) cin >> t[i];
    ll mt = t[0];
    REP(i,T) mt = min(mt,t[i]);
    ll tc = (n + mt-1) / mt;
    OUT(tc + 4LL)

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		long T = reader.nextLong();
		long ans = T;
		long[] arr = new long[N];
		arr[0] = reader.nextLong();
		for (int i = 1; i < N; i++) {
			arr[i] = reader.nextLong();
			ans += Math.min(T, arr[i]-arr[i-1]);
		}

		System.out.println(ans);
		reader.close();

	}
}

Measured memory_bytes: 64020
#include <bits/stdc++.h>
#define MAX 100010
using namespace std;
int main(void){
    long long a,b,x;
    cin >>a>>b>>x;
    long long between=b-a+0;
    long long fmod=a%x;
    long long ans=(fmod+between)/x;
    if(fmod==0){
        ans++;
    }
    cout << ans<<endl;
 
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int cnt=0;
  rep(i, 3) {
    if(S[i] == T[i]) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 764
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort(reverse=True)
f.sort()

ori = [0] * n
for i in range(n):
    ori[i] = a[i]*f[i]

ok = max(ori)
ng = -1
mid = (ok+ng) // 2
while ok - ng > 1:
    cnt = 0
    flg = 0
    for i in range(n):
        if ori[i] > mid:
            cnt += (a[i] - mid // f[i])
        if cnt > k:
            flg = 1
            break
    if flg:
        ng = mid
    else:
        ok = mid
    mid = (ok + ng) // 2

print(ok)


Measured memory_bytes: 120908
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner in = new Scanner(System.in);
		int A = in.nextInt();
		int B = in.nextInt();
		System.out.println(
				(A>=13)? B:
				(A>=6)? B/2:
						0);
	}

	public static void main(String[] args) {
		new Main().solve();
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n&&n){
    int cnt=0;
    for(int i=1;i<=n/2;++i){
      int sum=i,x=i,flag=0;
      while(sum<n){
	++x;
	sum+=x;
	flag=1;
      }
      if(sum==n&&flag) ++cnt;
    }
    cout<<cnt<<endl;
  }	
  return 0;
}



Measured memory_bytes: 2972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int N, M;
	cin >> N;
	int T[101];
	int goukei = 0;
	rep1(i, N) {
		cin >> T[i];
		goukei += T[i];
	}
	
	cin >> M;
	rep(i, M) {
		int P, X;
		cin >> P >> X;
		co(goukei - T[P] + X);
	}

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111

	void solve(){

		

		ini(n);
		int rick = 0;
		FOR(i,1,n+1){
			int tmp = 0;
			if(i%2 == 0)continue;
			FOR(i1,1,i+1){
				if(i%i1 == 0)tmp++;
			}
			if(tmp == 8)rick++;
		}
		out(rick);
		








	}	























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


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

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto N = RD;
	auto P = RDA;

	long ans;
	long x = long.max;
	foreach (i; 0..N)
	{
		if (P[i] <= x)
			++ans;
		x.chmin(P[i]);
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 11536
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<queue>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i,n) {
    int a;
    cin >> a;
    while( a % 2 == 0 ) ++vec[i], a /= 2;
  }
  sort(ALL(vec));
  deque<int> arr;
  int s = 0, t = n-1;
  while( s <= t ) {
    if( s == t ) arr.push_back(vec[s++]);
    else {
      arr.push_back(vec[s++]);
      arr.push_back(vec[t--]);
    }
  }
  //rep(i,n) cout << arr[i] << " "; puts("");
  rep(i,n-1) {
    int sum = arr[i] + arr[i+1];
    if( sum >= 2 ) {}
    else { puts("No"); return 0; }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 1024
k, n = map(int,input().split())
A = list(map(int,input().split()))
ans = 10**9
ans = min(ans, A[-1] - A[0])

for i in range(1, len(A)):
    ans = min(ans, A[-1] - A[i] + k - A[-1] + A[i-1])
print(ans)

Measured memory_bytes: 25840
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    long X=gl();
	    long a=Math.floorDiv(X, 500);
	    long b=Math.floorDiv(X%500, 5);
	    System.out.print(a*1000+b*5);
//        if (s.equals(s0.reverse().toString()) && s1.toString().equals(s1.reverse().toString()) && s2.toString().equals(s2.reverse().toString())) {
//    	    System.out.print("Yes");
//        }else {
//        	System.out.print("No");
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35604
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
import bisect #二部探索
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化
mod = 10**9 + 7
INF = 10**9 + 7

def main():
    a,b,c,d = list(map(int,input().split()))
    print(max(a*c, a*d, b*c, b*d))
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 27180
#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() {
	int A, B, X;
	cin >> A >> B >> X;
	string ans = "NO";
	if (A <= X && X <= A + B) ans ="YES";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3620
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    auto len = vector<int>();
    auto i = 0;
    while (s[i] == '1')
        ++i;
    const auto offset = i;

    while (i < n) {
        auto i0 = i;
        for (++i; i<n && s[i] == s[i0]; ++i)
            (void)0;
        len.push_back(i - i0);
    }

    auto sum = vector<int>(len.size() + 1);
    sum[0] = 0;
    for (i = 0; i < len.size(); ++i)
        sum[i + 1] = sum[i] + len[i];

    auto cnt_max = offset;

    for (i = 0; i < len.size(); i += 2) {
        auto j = i + 2 * k - 1;
        if (j > len.size() - 1)
            j = len.size() - 1;

        auto cnt = sum[j + 1] - sum[i];

        if (i == 0)
            cnt += offset;
        else
            cnt += len[i - 1];

        if (j % 2 == 0 && j + 1 < len.size())
            cnt += len[j + 1];

        cnt_max = max(cnt_max, cnt);
    }

    cout << cnt_max << endl;
    return 0;
}


Measured memory_bytes: 4132
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
string s;
cin>>s;
ll ans=0;
for(int i=0;i<4;i++){
    if(s.at(i)=='+'){
        ans++;
    }else{
        ans--;
    }
}
cout<<ans<<endl;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin >> N;
  vector<int> B(N-1);
  for(int i=0;i<N-1;++i)cin>>B[i];
  long long ans = B[0];
  for(int i=1;i<N-1;++i){
    ans += min(B[i-1],B[i]);
  }
  ans += B[N-2];
  cout << ans << endl;  
}

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

int R, ABC, ARC, AGC;

int main () {
	cin >> R;
	if ((R >= 0 && R<= 4208)){
		if (R < 1200){
			cout << "ABC" << endl;
		} 
		else if (R < 2800){
			cout << "ARC" << endl;
		} else {
			cout << "AGC" << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
 
 
int main () {
    int r,g,b;

    cin >> r >> g >> b;

    if((100*r + 10*g + b) % 4 == 0)cout << "YES" << endl;
    else cout << "NO" <<  endl;


}

    


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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> price_que;
  int total_price = 0;
  REP(i,n) {
    int price = in();
    price_que.push(price);
    total_price += price;
  }
  REP(i,m) {
    int max_price = price_que.top();
    price_que.pop();
    price_que.push(max_price/2);
    total_price -= ceil(max_price / 2.0);
  }
  cout << total_price;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int k, q;
  cin >> k >> q;
  vi32 d(k);
  cin >> d;
  rep(qi, q) {
    int n, x, m;
    cin >> n >> x >> m;
    i64 all = n - 1;
    i64 fst = x;
    i64 lst = x;
    i64 tst = 0;
    rep(i, k) {
      if (n - 2 - i < 0) break;
      i64 c = (n - 2 - i) / k + 1;
      lst += c * (d[i] % m);
      tst += c;
    }
    i64 div = lst / m - fst / m;
    i64 zero = 0;
    rep(i, k) if (d[i] % m == 0) {
      if (n - 2 - i < 0) break;
      zero += (n - 2 - i) / k + 1;
    }
    i64 ans = all - div - zero;
    cout << ans << endl;
  }
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int ab = a + b;
			String str = ab + "";
			System.out.println(str.length());

		}

	}
}

Measured memory_bytes: 20464
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  vector<i64> v(n), c(n);
  for (i64 i = 0; i < n; i++)
    cin >> v[i];
  for (i64 i = 0; i < n; i++)
    cin >> c[i];
  i64 ans = 0;
  for (i64 i = 0; i < n; i++)
    if (c[i] < v[i])
      ans += v[i] - c[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c)%mod;
    if (b&1) return (c*a)%mod;
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)3e5+5;
const int Q = 301;

int cnt[(int)1e6+5];
void prime(int n) {
    for (int i=2; i*i<=n; i++) {
        int c = 0;
        while (n%i==0) {
            c++;
            n/=i;
        }
        cnt[i] = max(cnt[i], c);
    }
    if (n>1) cnt[n] = max(cnt[n], 1);
}
void solve() {
    int a,n;
    ll l=1, sum = 0;
    cin>>n;
    REP(i,1,n) {
        cin>>a;
        prime(a);
        //l = (((l*a)%mod)*power(gcdll(l,a),mod-2))%mod;
        sum = (sum + power(a,mod-2))%mod;
    }
    REP(i,2,(int)1e6) {
        l = (l*power(i,cnt[i]))%mod;
    }
    sum = (l*sum)%mod;
    cout<<sum;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        //cout<<"\n";
    }
}


Measured memory_bytes: 2816
#include <iostream>
using namespace std;
const int INF = 1<<29;
const int MAX_V = 110;
const int MAX_E = 1100;

int N, M;
int a[MAX_E], b[MAX_E], c[MAX_E];
int dist[MAX_V][MAX_V]; 

int main() {
    cin >> N >> M;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            dist[i][j] = INF;
        }
        dist[i][i] = 0;
    }

    for (int i = 0; i < M; ++i) {
        cin >> a[i] >> b[i] >> c[i];
        --a[i], --b[i];
        dist[a[i]][b[i]] = c[i];
        dist[b[i]][a[i]] = c[i];
    }

    for (int k = 0; k < N; ++k)
        for (int i = 0; i < N; ++i)
            for (int j = 0; j < N; ++j)
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

    int res = 0;
    for (int i = 0; i < M; ++i) {
        if (c[i] > dist[a[i]][b[i]]) ++res;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
int main () {
  int s;
  cin >> s;
  vector<int> v (1000, 0);
  int result = 1;
  while (v[s] == 0) {
  	v[s]++;
    if (s % 2 == 0)
      s = s / 2;
    else
      s = 3 * s + 1;
    result++;
  }
  cout << result;
}

Measured memory_bytes: 256
var input = [];
var data = [];
process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on('data', function(chunk){
   input = chunk.toString("utf8").split("\n");
});
process.stdin.on('end', function(){
    for (var i = 0; i < input.length; i++) {
        data[i] = input[i].split(" ");
        var a = parseInt(data[i].shift());
        var b = parseInt(data[i].shift());
        if(!isNaN(a + b)) {
            console.log(String(a + b).length)
        }
    }
});

Measured memory_bytes: 16340
n,m=map(int,input().split())
A=sorted(list(map(int,input().split())))

# M回の握手の幸福度最大化
# X以上になる握手を全て採用したときに、M通りを越える
# Xの最大値を求める

import bisect

ok=-1
ng=(10**10)+1

# x以上の握手をm通り以上作れるか
def isOk(x,m):
  cnt=0
  # 左手をループする
  for i in range(len(A)):
    left=A[i]
    minright=x-left
    # minright以上の数を数える
    cnt+=n-bisect.bisect_left(A,minright)
    if cnt>=m:
      return True
  return cnt>=m

while abs(ok-ng)>1:
  mid=abs(ok+ng)//2
  if isOk(mid,m):
    ok=mid
  else:
    ng=mid

x=ok
# x以上となる幸福度を足し合わせる
# 足し合わせた握手がMを越える場合、xぴったりを足し過ぎている

# 効率化のため累積和を作成
Asum=[0]+A
for i in range(1,len(Asum)):
  Asum[i]=Asum[i-1]+Asum[i]
  
# Aの添字i以降を全て足すときは、
# Asum[-1]-Asum[i]

ans=0
cnt=0
for i in range(len(A)):
  left=A[i]
  minright=x-left
  start=bisect.bisect_left(A,minright)
  cnt+=n-start
  ans+=left*(n-start)+(Asum[-1]-Asum[start])
  
if cnt>m:
  ans-=(cnt-m)*x
  
print(ans)


Measured memory_bytes: 56068
N,M = map(int,input().split())

k=[]
s=[]

for i in range(M):
    switch = list(map(int,input().split()))
    k.append(switch[0])
    s.append(switch[1:])
    
p = list(map(int,input().split()))


count = 0
for i in range(2**N):
    lighton_num = 0
    for m in range(M):
        switchon_num = 0
        for j in range(k[m]):
            
            if (i>>(s[m][j]-1)) &1== 1:
                switchon_num+=1
            
        
        if switchon_num%2 == p[m]:
            lighton_num += 1
        # print(bin(i), m, j,switchon_num,p[m], lighton_num, count)
        
    if lighton_num == M:
        count += 1

print(count)

Measured memory_bytes: 73576
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////


int main(){fastio
    ll n,k;cin>>n>>k;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll dp[2][n];memset(dp,0,sizeof(dp));
    rep(i,0,n-1)dp[0][i]=a[i];
    rep(i,0,k-1){
        ll nxt=(i+1)&1;
        ll now=i&1;
        rep(j,0,n-1){
            dp[nxt][j]=0;
        }
        rep(j,0,n-1){
            dp[nxt][max(0,j-dp[now][j])]++;
            if(j+dp[now][j]+1<=n-1)dp[nxt][j+dp[now][j]+1]--;
        }
        rep(j,1,n-1)dp[nxt][j]+=dp[nxt][j-1];
        bool f=true;
        rep(j,0,n-1)if(dp[nxt][j]!=n){
            f=false;break;
        }
        if(f){
            rep(j,0,n-1)cout<<n<<" ";
            exit(0);
        }
    }
    rep(j,0,n-1)cout<<dp[k&1][j]<<" ";
    
    return 0;
}


Measured memory_bytes: 8340