akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define INF (int)1e8
 
using namespace std;
 
int main(){
    int n,m; cin >> n >> m;
    vector<int> d(n,0);
    vector<int> c(m,0);
    for(int i = 0; i < n; i++){ cin >> d[i];}
    for(int i = 0; i < m; i++){ cin >> c[i];}
 
    vector<int> prev(m,0);
    vector<int> now(m,INF);
 
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= i; j++){ now[j] = INF;}
        now[i] = d[i] * c[i] + (i > 0 ? prev[i-1] : 0);
        for(int j = i+1; j < m; j++){
            now[j] = min(prev[j-1] +d[i] * c[j], now[j-1]);
            //cerr << now[j] << " ";
        }
        //cerr << endl;
        swap(now, prev);
    }
    cout << prev[m-1] << endl;
 
    return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, Npow, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, color; vll path;
//***********//
int main() {
	ll Q;
	cin >> N >> Q;
	vector<tuple<ll, ll, ll>> E;
	for (i = 0; i < N; i++) {
		ll s, t, x;
		cin >> s >> t >> x;
		ll p = s - x;
		ll q = t - x;
		//E.push_back(tie(p, z, x));
		//E.push_back(tie(q, o, x));
		E.push_back(make_tuple(s-x,0,x));
		E.push_back(make_tuple(t-x,1,x));
	}
	sort(E.begin(),E.end());
	vpll D(Q);
	for (i = 0; i < Q; i++) {
		ll d;
		cin >> d;
		D[i]=make_pair(d,i);
	}
	sort(D.begin(), D.end());
	vl Ans(Q);
	multiset<ll> C;
	ll now = 0;
	for (i = 0; i < E.size(); i++) {
		while (now < Q) {
			if (get<0>(E[i]) <= D[now].first) break;
			if (C.size() > 0) Ans[D[now].second] = *C.begin();
			else Ans[D[now].second] = -1;
			now++;
			if (now >= Q) break;
		}
		if (get<1>(E[i]) == 0) C.insert(get<2>(E[i]));
		else C.erase(C.lower_bound(get<2>(E[i])));
	}
	for (i = now; i < Q; i++) {
		if (C.size() > 0) Ans[D[i].second] = *C.begin();
		else Ans[D[i].second] = -1;
	}
	for (i = 0; i < Q; i++) {
		cout << Ans[i] << endl;
	}
}


Measured memory_bytes: 25192
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <bitset>
using namespace std;

typedef long long LL;
const int M=1e5+5;
const int MB=60;

LL a[M];

int main()
{
	int n; scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%lld",&a[i]);
	// if xor (bit i) == 1 final 1
	// else == 0 gready to choose 1,1 pair
	LL all=0;
	for(int i=0;i<n;i++)
	    all^=a[i];
	for(int i=0;i<n;i++)
		a[i]=a[i]&(~all);
	// linear base
	int mr=0,j;
	for(int i=MB-1;i>=0;i--)
	{
		for(j=mr;j<n;j++)
			if(a[j]&(1LL<<i)) break;
		if(j==n) continue;
		swap(a[j],a[mr]);
		for(j=0;j<n;j++)
		{
			if(j!=mr&&a[j]&(1LL<<i))
				a[j]^=a[mr];
		}
		mr++;
	}
	//cout<<all<<endl;
	LL ans2=0;
	for(int i=0;i<mr;i++)
	{
		//bitset<64> bs(a[i]);
		//cout<<bs<<endl;
		ans2^=a[i];
	}
	printf("%lld\n",all+(ans2<<1));
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
  int x,y,d,amari;

  scanf("%d%d",&x,&y);

  if(x<y)
    {
      d=x;
      x=y;
      y=d;
    }

  amari=x%y;

  while(amari!=0)
    {
      x=y;
      y=amari;
      amari=x%y;
    }

  printf("%d\n",y);

  return 0;
}

  


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second

int main() {

char ch;
cin>>ch;

if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
    cout<<"vowel";
    else
        cout<<"consonant";
    
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007

ll N,Q;
string S;
ll l[100010];
ll r[100010];
vector<ll> Log;

int main() {
    cin >> N >> Q;
    cin >> S;
    rep(i,Q) cin >> l[i] >> r[i];
    rep(i,N-1){
        if (S[i] == 'A' && S[i+1] == 'C'){
            Log.push_back(i);
        }
    }
    rep(i,Q){
        ll le = lower_bound(Log.begin(),Log.end(),l[i]-1) - Log.begin();
        ll ri = lower_bound(Log.begin(),Log.end(),r[i]-1) - Log.begin();
        cout << ri-le << endl;
    }
    return 0;
}


Measured memory_bytes: 3064
#include<stdio.h>
 
main(){
    int n, d, x;
    int a[101];
    int i;
    int t;
 
    // 整数の入力
    scanf("%d", &n);
    // スペース区切りの整数の入力
    scanf("%d %d",&d, &x);
 
    for(i = 1; i <= n; i++){
        scanf("%d", &a[i]);
    }
 
    t=x;
    for(i = 1; i <= n; i++){
        t += 1 + (d - 1) / a[i];
    }
    
    // 出力
    printf("%d\n", t);
}

Measured memory_bytes: 128
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use nalgebra::{min, max};

#[fastout]
fn main() {
    input! {
    n: usize,
    xu: [(f64, String);n]
    }
    let mut ans = 0.0;
    for i in 0..n {
        let (x, u) = &xu[i];
        if u == "JPY" {ans += x}
        else {
            ans += 380000.0 * x;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2176
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<time.h>
#include<string.h>

int main(void){

  int N;
  int i;
  int j;
  int ch_no;
  int temp_P;
  char temp[11];


  scanf("%d",&N);

  struct data{
    int no;
    char shop[11];
    int P;
  } shoplist[N];

  for(i=0; i<N; i++)
  {
    shoplist[i].no = 0;
    strcpy(shoplist[i].shop,"null");
    shoplist[i].P = 0;
  }

  for(i=0; i<N; i++)
  {
    shoplist[i].no = i + 1;
    scanf("%s",shoplist[i].shop);
    scanf("%d",&shoplist[i].P);
  }

/*  for(i=0; i<N-1; i++){
    for(j=N-1; j>i; j--){
      len1 = strlen(shoplist[j].shop);
      len2 = strlen(shoplist[j-1].shop);

      if(len1 < len2 || (len1 == len2 && strcmp(shoplist[j].shop, shoplist[j-1].shop) < 0))
      {
        strcpy(temp,shoplist[j].shop);
        strcpy(shoplist[j].shop,shoplist[j-1].shop);
        strcpy(shoplist[j-1].shop,temp);
        ch_no = shoplist[j].no;
        shoplist[j].no = shoplist[i].no;
        shoplist[i].no = ch_no;
      }
    }
  }
*/

for(j=0;j<N;j++){
  for(i=1; i<N; i++){
    if(strcmp(shoplist[i-1].shop, shoplist[i].shop) > 0)
    {
      strcpy(temp,shoplist[i-1].shop);
      strcpy(shoplist[i-1].shop,shoplist[i].shop);
      strcpy(shoplist[i].shop,temp);

      ch_no = shoplist[i-1].no;
      shoplist[i-1].no = shoplist[i].no;
      shoplist[i].no = ch_no;

      temp_P = shoplist[i-1].P;
      shoplist[i-1].P = shoplist[i].P;
      shoplist[i].P = temp_P;
    }
  }
}

for(j=0;j<N;j++){
  for(i=1; i<N; i++){
    if(strcmp(shoplist[i-1].shop, shoplist[i].shop) == 0 && shoplist[i-1].P < shoplist[i].P)
    {
      ch_no = shoplist[i-1].no;
      shoplist[i-1].no = shoplist[i].no;
      shoplist[i].no = ch_no;

      temp_P = shoplist[i-1].P;
      shoplist[i-1].P = shoplist[i].P;
      shoplist[i].P = temp_P;
    }
  }
}

  for(i=0; i<N; i++){
    printf("%d\n",shoplist[i].no);
  }
  return 0;
}


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

using namespace std;
typedef long long nagai;

nagai calc(int n, nagai c, vector<nagai> x, vector<nagai> v)
{
	vector<nagai> pref(n + 1);
	for (int i = 0; i < n; ++i)
		pref[i + 1] = pref[i] + v[i];
	vector<nagai> back(n);
	for (int i = 0; i < n; ++i)
		back[i] = pref.back() - pref[i] - (c- x[i]);
	for (int i = n - 1; i > 0; --i)
		back[i - 1] = max(back[i - 1], back[i]);
	nagai ans = 0;
	for (int forw = 0; forw < n; ++forw)
	{
		ans = max(ans, pref[forw + 1] - x[forw]);
		if (forw + 1 < n)
			ans = max(ans, pref[forw + 1] - 2 * x[forw] + back[forw + 1]);
	}
	return ans;
}
int main()
{
	ios::sync_with_stdio(false);
	int n;
	nagai c;
	cin >> n >> c;
	vector<nagai> x(n), v(n);
	for (int i = 0; i < n; ++i)
		cin >> x[i] >> v[i];
	nagai ans = calc(n, c, x, v);
	for (auto& y : x)
		y = c - y;
	reverse(x.begin(), x.end());
	reverse(v.begin(), v.end());
	ans = max(ans, calc(n, c, x, v));
	cout << ans << '\n';
}


Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define vec_all(vec) vec.begin(), vec.end()

template<typename T>

vector<T> accum_sum(vector<T> a) {
    T l = a.size();
    vector<T> ret(l);

    ret[0] = a[0];

    repr(i, 1, l) {
        ret[i] = a[i] + ret[i - 1];
    }

    return ret;
}

bool is_prime(int p) {
    if (p == 1) {
        return false;
    }
    int sq_p = (int) sqrt(p);
    repr(i, 2, sq_p + 1) {
        if (p % i == 0) {
            return false;
        }
    }

    return true;
}

int main() {
    int p;
    cin >> p;
    
    vector<int> q_start(p + 1);
    vector<int> q_end(p + 1);

    rep(i, p) {
        cin >> q_start[i];
        cin >> q_end[i];
    }

    int max_q_end = *max_element(vec_all(q_end));

    vector<int> is_like_vec(max_q_end + 1, 0);
    vector<int> is_prime_vec(max_q_end + 1, 0);

    repr(i, 1, max_q_end + 1) {
        if (is_prime(i)) {
            is_prime_vec[i] = 1;
            if (is_prime_vec[(i + 1) / 2] == 1) {
                is_like_vec[i] = 1;
            }
        }
    }

    vector<int> a_sum;
    a_sum = accum_sum(is_like_vec);

    rep(i, p) {
        int l = q_start[i];
        int r = q_end[i];

        cout << a_sum[r] - a_sum[l - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
using P  = pair<int,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
const int NMAX = 2000;

vector<ll> fac(NMAX+1);
vector<ll> inv(NMAX+1);
vector<ll> fnv(NMAX+1);
vector<ll> power(NMAX+1);

void com_init(){
    
    fac[0]=1LL;
    fac[1]=1LL;
    inv[0]=0LL;
    inv[1]=1LL;
    fnv[0]=1LL;
    fnv[1]=1LL;
    
    for(int i=2; i<NMAX+1; i++){
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - (MOD/i) * inv[MOD%i] % MOD;
        fnv[i] = fnv[i-1] * inv[i] % MOD;
    }
    return;
}

ll combi(int n, int k){
    if(n<k)return 0LL;
    if(k<0 || n<0 )return 0LL;
    
    return fac[n] * (fnv[k]*fnv[n-k] % MOD) % MOD;
}

void pow_init(int M){
    
    power[0] = 1;
    for(int i=1; i<NMAX+1; i++){
        power[i] = power[i-1] * M % MOD;
    }
    return;
}


int main(){
    com_init();
    ll s;
    cin >> s;
    
    ll ans = 0;
    
    for(int i=1; i<=s/3; i++){
        ans += combi(s-2*i-1, i-1);
        ans %= MOD;
        //cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,m;
  cin>>n>>m;
  vll s(m),c(m);
  rep(i,m){
    cin>>s[i]>>c[i];
  }
  ll k;
  if(n==1) k=10;
  if(n==2) k=100;
  if(n==3) k=1000;
  rep(i,k){
    ll kk=0;
    ll keta;
    keta=sz(to_string(i));
    if(keta!=n) continue;
    rep(j,m){
      if(keta<s[j]) break;
      ll cu=keta-s[j];
      if(cu==0){
        ll f=i%10;
        if(f==c[j])kk++;
      }
      else if(cu==1){
        ll f=i/10;
        f%=10;
        if(f==c[j])kk++;
      }
      else{
        ll f=i/100;
        if(f==c[j]) kk++;
      }
    }
    if(kk==m){
      COUT(i);
      return 0;
    }
  }
  COUT(-1);
}

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

#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)

using namespace __gnu_pbds;
using namespace std;

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif


std::mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int ri(int a, int b) {
    return uniform_int_distribution<int>(a, b)(rng);
}

ll power(ll x, ll y, ll p){
   ll res = 1;
   x = x % p;
   while (y > 0) {
      if (y & 1)
         res = (res * x) % p;
      y = y >> 1;
      x = (x * x) % p;
   }
   return res;
}

const ll INF = (ll)(8e18);
const ll MOD = (ll)(1e9 + 7);
const ll HMOD = (ll)4222234727;
const ll Hashprime = (ll)31;

const int maxn = 100100;

int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    while(t--){
       ld d,T,s; cin >> d >> T >> s;
       if((d / s) <= T) cout << "Yes" << '\n';
       else cout << "No" << '\n';
    }
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}
//g++ -DLOCAL -std=c++17 -Wshadow -Wall -o "c" "comp.cpp" -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=200000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}

class Edge{
public:
	long long from;
	long long to;
	long long w;
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long N;
	cin>>N;
	long long num=0;
	long long i=1;
	while(1){
		num+=i;
		if(num>=N)break;
		i++;
	}
	cout<<i<<endl;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	int N; cin >> N;
	vvint G(N);	
	for (int i = 0; i < N-1; i++) {
		int p, q;
		cin >> p >> q; --p, --q;
		G[p].push_back(q);
		G[q].push_back(p);
	}
	
	int maxd = 0;
	function<int(int, int)> dfs = [&](int u, int prev) {
		int ret = (int)(G[u].size() == 2);
		vint dat;
		for (auto &v : G[u]) {
			if (v != prev) dat.push_back(dfs(v, u));
		}

		sort(begin(dat), end(dat), greater<>());
		int maxv = 0;
		if (dat.size() >= 1) {
			maxv = dat[0];
			if (dat.size() >= 2) chmax(maxd, dat[0] + dat[1]);
		}
		chmax(maxd, ret + maxv);
		return (ret + maxv);
	};

	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (G[i].size() == 1) cnt++;
	}
	dfs(0, -1);
	cout << cnt + maxd << endl;
	return (0);
}


Measured memory_bytes: 5760
mod = 10**9+7
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
A_inv = [pow(a, mod-2, mod) for a in A]
m = A[0]
for a in A[1:]:
    m = m*a//gcd(m, a)
m%=mod
ans = 0
for a in A_inv:
    ans+=m*a
    ans%=mod
print(ans)



Measured memory_bytes: 67688
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"

using namespace std;

ll sum(ll x){
	return x*(x +1)/2;
}

int main(){
// 	freopen("input.txt","r",stdin);
// 	freopen("output.txt","w",stdout);
	ll n;
	cin >> n;
	ll h[n];
	for(ll i = 0;i < n;i++) cin >> h[i];
	ll dp[n + 1];
	dp[0] = 0;
	dp[1] = 0;
	dp[2] = abs(h[1] - h[0]);
	for(ll i = 3;i <= n;i++){
		dp[i] = min(dp[i - 2] + abs(h[i - 1] - h[i - 3]),dp[i - 1] + abs(h[i - 1] - h[i - 2]));
	}
	cout << dp[n];
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define INTXT std::ifstream in ("input.txt"); std::cin.rdbuf(in.rdbuf());
#define INF 1e9

using namespace std;
typedef long long ll;
static const ll MOD = 1000000007LL;

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

  int max_l = 0;
  int min_r = INF;
  REP(i, m){
    int l, r;
    cin >> l >> r;
    max_l = max(l, max_l);
    min_r = min(r, min_r);
  }
  cout << max(min_r - max_l + 1, 0) << endl;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pii;

template<typename T>
using pq_gt = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using pq_lt = priority_queue<T, vector<T>, less<T>>;

#define se second
#define fi first
#define pb push_back

int main() {
    ios::sync_with_stdio(false);
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    long double sma = -1;
    int wa, wb;
    for(int i = 0; i <= 30; i++) {
    	for(int j = 0; j <=30; ++j) {
    		for(int k = 0; k<=100; ++k) {
    			for(int l = 0; l<=100; ++l) {
    				long double tot = 100*a*i+100*b*j+k*c+l*d;
    				long double wtot= 100*a*i+100*b*j;
    				if(wtot > 0 && tot <= f) {
    					long double temp = 100*(k*c+l*d)/wtot;
    					if(temp <=  e) {
    						if(temp > sma) {
    							sma=  temp;
    							wa = 100*a*i+100*b*j+k*c+l*d;
    							wb = k*c + l*d;
    						}
    					}
    				}
    			}
    		}
    	}
    }
    //cout<<temp<<endl;
    cout<<wa<<" "<<wb<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int K,X;
    cin>>K>>X;
    cout<< ((500 * K >= X) ? "Yes":"No")<<endl;
    
}

Measured memory_bytes: 256
class Node():
    def __init__(self, id, key, parent, left, right):
        self.id = id
        self.key = key
        self.parent = parent
        self.left = left
        self.right = right
    def show(self):
        print 'node %d: key = %d,' % (self.id, self.key),
        if self.parent:
            print 'parent key = %d,' % self.parent, 
        if self.left:
            print 'left key = %d,' % self.left,
        if self.right:
            print 'right key = %d,' % self.right,
        print ''

def calcParent(key):
    if key == 1:
        return None
    else:
        return data[int(key/2) - 1]

def calcLeft(key):
    if 2 * key < n + 1:
        return data[2 * key - 1]
    return None

def calcRight(key):
    if 2 * key < n:
        return data[2 * key]
    return None
        
n = int(raw_input())
data = map(int, raw_input().split())
node_list = []
for i in range(n):
    this_id = i + 1
    node_list.append(Node(i+1, data[i], calcParent(this_id), calcLeft(this_id), calcRight(this_id)))

for i in node_list:
    i.show()

Measured memory_bytes: 6480
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<double, ll> P;

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
vector<vector<ll>> dp(101, vector<ll>(10001, 0));
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

ll N, W;
vector<ll> A;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> W;
  vector<ll> v(N), w(N);
  rep(i, N) {
    cin >> v[i] >> w[i];
  }
  // dp[i+1][j] = max(dp[i][j], dp[i+1][j-w[i]]+v[j])
  rep(i, N) {
    rep(j, W+1) {
      if (j < w[i]) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = max(dp[i][j], dp[i+1][j-w[i]]+v[i]);
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define ff first
#define ss second
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
#define d(a,b,c) cout<<a<<" "<<b<<" "<<c<<'\n'
#define IO ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define mem(a, b) memset(a,b,sizeof(a))

const int oo = 1e9+7;

int main()
{
    int n, m, x; cin >> n >> m >> x;
    int a[n][m], c[n];
    for(int i = 0; i < n; i++)
    {
        cin >> c[i];
        for(int j = 0; j < m; j++)
            cin >> a[i][j];
    }
    int nn = pow(2, n)-1;
    int res = oo;
    for(int i = 1; i <= nn; i++)
    {
        int k = i;
        vector<int>bt;
        for(int j = 0; j < n; j++)
            if(k & (1 << j))
                bt.pb(j);
        int al[m], sum = 0;
        memset(al, 0, sizeof(al));
        for(int j = 0; j < bt.size(); j++)
        {
            sum += c[bt[j]];
            for(int l = 0; l < m; l++)
                al[l] += a[bt[j]][l];
        }
        bool ok = true;
        for(int j = 0; j < m; j++)
            if(al[j] < x)
                ok = false;
        if(ok)
            res = min(res, sum);
    }
    if(res == oo)
        cout << -1 << endl;
    else cout << res << endl;

    return 0;
}












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

const int MAX = 1000000;  // 最大の頂点数
vector<int> G[MAX];     // A[i] : i から延びる辺の先の点の集合
int indeg[MAX];         // indeg[i] : i へ延びる辺の数
int depth[MAX];         // depth[i] : iの入次数0の点からの最大距離
int V;                  // 頂点数

// トポロジカルソート
vector<int> topologicalSort() {
    vector<int> ret;
    queue<int> que;
    for (int i = 0; i < V; i++) {
        if (indeg[i] == 0) que.push(i);
    }
    while (!que.empty()) {
        int v = que.front();
        que.pop();

        ret.push_back(v);
        for (auto w : G[v]) {
            indeg[w]--;
            if (indeg[w] == 0) que.push(w);
            depth[w] = max(depth[w], depth[v] + 1);
        }
    }
    return ret;
}
// 閉路判定
bool hasCycle() {
    return V != topologicalSort().size();
}


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

    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        int prev;
        for (int j = 1; j <= N - 1; j++) {
            int cur;
            cin >> cur;
            if (j == 1) {
                prev = cur;
                continue;
            }
            int pnode = min(i, prev) + (max(i, prev) - 1) * N;
            int cnode = min(i, cur) + (max(i, cur) - 1) * N;

            G[pnode].push_back(cnode);
            indeg[cnode]++;
            prev = cur;
        }
    }
    V = N * N;
    if (hasCycle())
        cout << -1 << endl;
    else
        cout << *max_element(depth, depth + V) + 1 << endl;

    return 0;
}


Measured memory_bytes: 55152
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

int main(){

  int cf = 0, cs = 0, num;

  for(int i = 0 ; i < 3 ; i++){
   
    cin >> num;
    if(num == 5) cf++;
    else if(num == 7) cs++;
  }

  if(cf == 2 && cs == 1) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
 ll n,m,i,ans,c,x,y;
 cin>>n;
 ll a=0,w=0,t=0,r=0;
 while(n--){
   string s;
   cin>>s;
   if(s[0]=='A')a++;
   else if(s[0]=='W')w++;
   else if(s[0]=='T')t++;
   else r++;
 }
  cout<<"AC x "<<a<<"\n";
  cout<<"WA x "<<w<<"\n";
  cout<<"TLE x "<<t<<"\n";
  cout<<"RE x "<<r<<'\n';
}


Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main() {

  int n, odd = 1, p, ans = 0, old = 0, a, b, c;
  cin >> a >> b >> c;
  if(a + b >= c){
    cout << b + c;
  }else{
    cout << b + (a + b) + 1;
  }
  return 0;
}


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


int main() {
  string S;
  cin >> S; 
  int minN = 999;
  for (int i = 0; i+2 < S.size(); i++)
  {
    int num = 0;
    num = (S[i]-'0')*100 + (S[i+1]-'0')*10 + (S[i+2]-'0');
    minN = min(minN, abs(753-num));
  }
  
  cout << minN << endl;

}

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

int main(){
  int N;
  cin >> N;
  int L=0,U=1000,x;
  for(int i=0;i<N;i++){
    cin >> x;
    L=max(L,x);
    U=min(U,x);
  }
  cout << L-U;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n ;
  int ans{};
  int a;
  for(int i=1; i<=n; i++){
    cin >> a;
    if(i%2 != 1) continue;
    if(a%2 == 1) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3556
import java.util.*;

public class Main {
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    if(n!=0){
		int a, b;
		int sumA = 0;
		int sumB = 0;
		for(; n>0; n--){
		    a = kbd.nextInt();
		    b = kbd.nextInt();
		    if(a>b) sumA += (a+b);
		    else if(b>a) sumB += (a+b);
		    else {
			sumA += a;
			sumB += b;
		    }
		}
		System.out.println(sumA+" "+sumB);
	    }
	}
    }
}

Measured memory_bytes: 12000
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] x = new int[m];
        for (int i = 0; i < m; i++) {
            x[i] = sc.nextInt();
        }
        Arrays.sort(x);
        int[] xAbs = new int [m];
        for (int i = 0; i < m - 1; i++) {
            xAbs[i] = Math.abs(x[i] - x[i+1]);
        }
        Arrays.sort(xAbs);
        int sum = 0;
        for (int i = 0; i < xAbs.length - n + 1; i++) {
            sum += xAbs[i];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 48096
using System;

class Program
{	
	static void Main()
	{
		string S = Console.ReadLine();
		string T = Console.ReadLine();
		
		bool[,]dp = new bool[28,28];
		bool[,]dp2 = new bool[28,28];
		
		for(int i = 0; i < S.Length; i++)
		{
			dp[(S[i] - 'a'),(T[i] - 'a')] = true;
			dp2[(T[i] - 'a'),(S[i] - 'a')] = true;
		
		}
		for(int i = 0; i < 28; i++)
		{
			bool tmp = false;
			for(int j = 0; j < 28; j++)
			{
				if(dp[i, j] == true)
				{
					if(tmp == true)
					{
						Console.WriteLine("No");
						return;
					}
					else tmp = true;
				}
			}
		}
		
		for(int i = 0; i < 28; i++)
		{
			bool tmp = false;
			for(int j = 0; j < 28; j++)
			{
				if(dp2[i, j] == true)
				{
					if(tmp == true)
					{
						Console.WriteLine("No");
						return;
					}
					else tmp = true;
				}
			}
		}
		
		Console.WriteLine("Yes");
	}
}

Measured memory_bytes: 12512
#include <stdio.h>
#include <math.h>

typedef struct P {
	double x, y;
} Point;

void koch(int n, Point a, Point b) {
	if (n == 0) return;
	Point s, t, u;

	double th = M_PI * 60.0 / 180.0;

	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

	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() {
	Point a, b;
	int n;

	scanf("%d",&n);

	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;

	printf("%.8f %.8f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);

	return 0;
}


Measured memory_bytes: 1988
import java.util.Scanner;
class Main
{
 public static void main(String args[])
 {
 Scanner scan=new Scanner(System.in);
 int n=scan.nextInt();
 
 char s[][]={{'.',',','!','?',' '},
             {'a','b','c'},
			 {'d','e','f'},
			 {'g','h','i'},
			 {'j','k','l'},
			 {'m','n','o'},
			 {'p','q','r','s'},
			 {'t','u','v'},
			 {'w','x','y','z'},
			 };
 for(int i=0;i<n;i++)
 {
  String str=scan.next();
  String ans="";
  for(int j=0;j<str.length();j++)
  {
   int count=-1,select=0,waru=3;
   while(str.charAt(j)!='0')
   {
    count++;
	j++;
   }
   if(count==-1)continue;
   select=Integer.parseInt(str.charAt(j-1)+"")-1;
   if(select==0)waru=5;
   if(select==6||select==8)waru=4;
   ans+=s[Integer.parseInt(str.charAt(j-1)+"")-1][count%waru];
  }
  System.out.println(ans);
 }
 
 }
}

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

using namespace std;


int main(){
    int64_t A, B;
    cin >> A >> B;
    int64_t min1 = A*100/8, min2 = B*10;
    int64_t max1 = (A+1)*100/8, max2 = (B+1)*10-1;
    int64_t res;
    if(min1*8/100 < A) min1++;
    if(max1*8/100 == A+1) max1--;
    if(min1 > min2) res = min1;
    else res = min2;
    if(max1 < min2 || max2 < min1) cout << "-1\n";
    else cout << res << endl;
    return 0;
}

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

using namespace std;

const int MOD = 1000000007;

int main(){
    const int maxSize = 100001;
	vector<long long> inv(maxSize);
	vector<long long> invSum(maxSize);
    vector<long long> fact(maxSize);
	vector<long long> factInv(maxSize);
	for(int i=0;i<2;i++) inv[i] = fact[i] = invSum[i] = 1;
	for(int i=2;i<maxSize;i++){
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
        fact[i] = fact[i-1] * i % MOD;
        invSum[i] = (invSum[i-1] + inv[i]) % MOD;
	}
    int N; cin >> N;
    vector<long long> A(N);
    for(auto& t : A) cin >> t;
    long long res = 0;
    for(int i=0;i<N;i++){
        res = (res + A[i] * (invSum[N-i] + invSum[i+1] + MOD - 1)) % MOD;
    }
    res = (res * fact[N]) % MOD;
    cout << res << endl;
}

Measured memory_bytes: 4224
n, m = map(int, input().split())
road=[[] for i in range(n)]

# road[i]はi番目の部屋とつながってる部屋番号のリスと
for i in range(m):
    a, b = map(int, input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)

from collections import deque

todo=deque([0]) # 処理すべき点の番号を入れる
mae=[-1]*n # 前にどこにおったか
visited=[False]*n # その点に行ったかどうか
mae[0]=0
visited[0]=True

# 幅優先探索
while todo:
    now=todo.popleft() # やることリストから現在地を取得
    for next in road[now]:
        if visited[next]: # もう訪れてたらスルー
            continue
        visited[next]=True # 訪れてなかったら訪れたことにする
        mae[next]=now # nextの前の地点を代入
        todo.append(next) # nextが次の現在地の候補となる


if False in visited:
    print("No")
else:
    print("Yes")
    [print(i+1) for i in mae[1:]]
            

Measured memory_bytes: 36424
#pragma GCC optimize("Ofast")
// #include<bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <chrono> 
#include <algorithm>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns the iterator to kth largest element.(0-based) 
#define int long long 
#define pb push_back
// #define endl "\n"
#define all(con) con.begin(),con.end()
#define fi first
#define se second
#define sz(x) (int)x.size()
typedef long double ld ;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define rp(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=1;i<=n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif
int gcd(int a,int b){return __gcd(a,b);}
int lcm(int a,int b){return (a*b)/(__gcd(a,b));}
const int mod=1e9+7;
const int inf=2e18;
int hcf(int a,int b){if(a==0)return b;return hcf(b%a,a);}
int modpow(int n,int p,int mod){n=n%mod;int result=1;while(p>0){if(p&1)result=result*n%mod;n=n*n%mod;p>>=1;}return result;}
const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
int fact[N], invfact[N];
int pow(int a,int b,int m){int ans=1;while(b){if(b&1)ans=(ans*a)%m;b/=2;a=(a*a)%m;}return ans;}
int modinv(int k){return pow(k, MOD-2, MOD);}
void combinatorics(){fact[0]=fact[1]=1;for(int i=2;i<N;i++){fact[i]=fact[i-1]*i;fact[i]%=MOD;}invfact[N-1]=modinv(fact[N-1]);for(int i=N-2;i>=0;i--){invfact[i]=invfact[i+1]*(i+1);invfact[i]%=MOD;}}
int nCr(int x, int y){if(y>x)return 0;int num=fact[x];num*=invfact[y];num%=MOD;num*=invfact[x-y];num%=MOD;return num;}
void dream();
int32_t main(){
        ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
        srand(chrono::high_resolution_clock::now().time_since_epoch().count());
        cout<<setprecision(6);
        #ifndef ONLINE_JUDGE
        // freopen("in.txt", "r", stdin);
        // freopen("out.txt", "w", stdout);
    	#endif
        // combinatorics();
        int ttt=1;
        // cin>>ttt;
        while(ttt--){
                dream();
        }
        return 0;
}
void dream(){
        int n,m;
        cin>>n>>m;
        if(n<=8&&m<=8) {
                cout<<"Yay!";
        }
        else {
                cout<<":(";
        }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a[200] = {};
	int b[200] = {};
	int c[200] = {};
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	int sc[200] = {};
	for(int i = 0;i<n;i++){
		bool flag = true;
		for (int j = 0; j < n; j++) {
			if (i != j) {
				if (a[i] == a[j]) {
					flag = false;
					break;
				}
			}
		}
		if (flag == true) {
			sc[i] += a[i];
		}
	}
	for (int i = 0; i<n; i++) {
		bool flag = true;
		for (int j = 0; j < n; j++) {
			if (i != j) {
				if (b[i] == b[j]) {
					flag = false;
					break;
				}
			}
		}
		if (flag == true) {
			sc[i] += b[i];
		}
	}
	for (int i = 0; i<n; i++) {
		bool flag = true;
		for (int j = 0; j < n; j++) {
			if (i != j) {
				if (c[i] == c[j]) {
					flag = false;
					break;
				}
			}
		}
		if (flag == true) {
			sc[i] += c[i];
		}
	}
	for (int i = 0; i < n; i++) {
		cout << sc[i] << endl;
	}
	
	return 0;
}

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

int solve() {

}

int main() {
	int l, r, d;
	cin >> l >> r >> d;
	int cnt=0;
	rep(i,r-l+1) {
		if((l+i)%d==0) cnt++;
	}
	cout << cnt << endl;
}


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

using namespace std;

int main()
{
    long long n, x, t;

    cin >> n >> x >> t;

    long long T;

    if (n % x == 0)
     T = (n / x) * t;
    else
     T = ((n / x) + 1) * t;

    std::cout << T << std::endl;
}

Measured memory_bytes: 3608
import time
from bisect import bisect_left
t = time.time()
H,W,m = map(int,input().split())
h = [0]*(H+1)
w = [0]*(W+1)
c = [[-1,10**6] for i in range(H+1)]
for i in range(m):
    a,b = map(int,input().split())
    h[a] += 1
    w[b] += 1
    c[a].append(b)
mh = max(h)
mw = max(w)
hkouho = []
wkouho = []
for i in range(H+1):
    if h[i] == mh:
        hkouho.append(i)
for i in range(W+1):
    if w[i] == mw:
        wkouho.append(i)
for i in range(H+1):
    c[i].sort()
# print(hkouho)
# print(wkouho)
for i in hkouho:
    for j in wkouho:
        # print(c[i],i,j,bisect_left(c[i],j))
        if c[i][bisect_left(c[i],j)] != j:
            print(mh+mw)
            exit()
        if time.time()-t > 2.7:
            print(mh+mw-1)
            exit()
print(mh+mw-1)

Measured memory_bytes: 82332
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll a[110];
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a!=c)cout<<1;
    else cout<<0;
}


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

    int S, W;
    cin >> S >> W;

    if (W >= S) {
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }

return 0;
}

Measured memory_bytes: 3620
building = [[[0]*10 for i in range(3)] for j in range(4)]


n = int(input())
for i in range(n):
    b,f,r,v = map(int,input().split())
    building[b-1][f-1][r-1] += v
    
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' {}'.format(building[i][j][k]),end = '')
        print()
    if i < 3:
        print('#'*20)
        


Measured memory_bytes: 5624
def main():

    N = int(input())
    ans = ""
    p = 1
    while N > 0:
        N -= 1
        ans += chr(N % 26 + ord('a'))
        N -= N % 26
        N //= 26
    return ans[::-1]

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 9180
import java.util.Scanner;

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

    	Scanner scanner=new Scanner(System.in);


    	int x500=scanner.nextInt();
    	int x100=scanner.nextInt();
    	int x50=scanner.nextInt();
    	int target=scanner.nextInt();


    	int result=0;
    	for(int i=0;i<=x500;i++) {

    		for(int j=0;j<=x100;j++) {

    			for(int k=0;k<=x50;k++) {

    				if(target==(500*i+100*j+50*k)){
    					result++;
    				}


    			}

    		}
    	}

    	System.out.println(result);

    	scanner.close();


    }

}

Measured memory_bytes: 21844
using System;
using System.Linq;
class Program {
    static void Main (string[] args) {
        // 整数の入力
        int N = int.Parse (Console.ReadLine ());
        // var s = Console.ReadLine ();
        // if (N >= 3200) {
        //     Console.Write (s);
        // } else {
        //     Console.Write ("red");
        // }
        // int[] numbers = new int[N];
        float ans = 0;
        string[] input = Console.ReadLine ().Split (' ');
        int[] numbers = input
            .Select (int.Parse)
            .ToArray ();
        for (int i = 0; i < N; i++) {
            //  numbers[i] = int.Parse (Console.ReadLine ());
            ans += (float)1 / numbers[i];
        }
        Console.Write ((float)1 / ans);

        // int cnt = 1;
        // int tmp1 = numbers[0]; //見始め
        // int tmp = numbers[1];
        // for (int i = 1; i < N; i++) {
        //     if (numbers[i] < tmp) {
        //         cnt += 1;
        //         if (numbers[i] <= tmp1) {
        //             cnt += 1;
        //             tmp1 = numbers[i];
        //         }
        //         tmp = numbers[i];
        //     } else if (numbers[i] == tmp) {
        //         cnt += 1;
        //     } else {

        //     }
        // }
        // Console.WriteLine (cnt);
        // // int D = int.Parse (Console.ReadLine ());
        // string[] input = Console.ReadLine ().Split (' ');
        // int[] numbers = input
        //     .Select (int.Parse)
        //     .ToArray ();
        // int N = numbers[0];
        // int D = num[1];
        // int X = 2*D+1;
        // int cnt = 1;

        // while(true){
        //     if(cnt*X / N >= 1){
        //         break;
        //     }else{
        //         cnt += 1;
        //     }
        // }
        // スペース区切りの整数の入力
        // string[] input = Console.ReadLine ().Split (' ');

        // int[] numbers = input
        // .Select (int.Parse)
        // .ToArray ();
        // int count = 0;

        // while (true) {
        //     bool ck = cheCk (a, numbers);
        //     if (check) {
        //         numbers = Divide (a, numbers);
        //         count += 1;
        //     } else {
        //         break;
        //     }
        // }
        //出力
        // Console.WriteLine (cnt);
    }

    // public static bool Check (int a, int[] numbers) {
    //     bool check = true;
    //     for (int i = 0; i < a; i++) {
    //         if (numbers[i] % 2 != 0) {
    //             check = false;
    //         }
    //     }
    //     return check;
    // }

    // public static int[] Divide (int a, int[] num){ 
    //     for (int i = 0; i < a; i++) {
    //         numbers[i] /= 2;
    //     }
    //     return numbers;
    // }
}

Measured memory_bytes: 13268
#include <iostream>
#include <climits>
#include <string>
#include <cstring>
#include <stack>

using namespace std;

char s[1000];

string solve()
{
	stack<char> st;

	for(int i = 0; s[i] != '.'; i++)
	{
		if( s[i] == '(' )
		{
			st.push('(');
		}
		else if( s[i] == '[' )
		{
			st.push('[');
		}
		else if( s[i] == ')' )
		{
			if( !st.empty() && st.top() == '(' )
				st.pop();
			else
				st.push(')');
		}
		else if( s[i] == ']' )
		{
			if( !st.empty() && st.top() == '[' )
				st.pop();
			else
				st.push(']');
		}
	}

	if( st.empty() && st.empty() )
		return "yes";
	else 
		return "no";
}

int main()
{
	while( cin.getline(s,sizeof(s)), s[0] != '.' )
		cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 896
from collections import deque
while True:
  t, n = map(int, input().split())
  if t == 0:break
  bans = {tuple(map(int, input().split())) for _ in range(n)}
  sx, sy = map(int, input().split())
  vec = ((0, 1), (1, 1), (1, 0), (0, -1), (-1, -1), (-1, 0))
  que = deque()
  que.append((t, sx, sy))
  reached = set()
  reached.add((sx, sy))
  while que:
    turn, x, y = que.popleft()
    if turn == 0:continue
    for dx, dy in vec:
      nx, ny = x + dx, y + dy
      if (nx, ny) not in reached and (nx, ny) not in bans:
        reached.add((nx, ny))
        que.append((turn - 1, nx, ny))
  print(len(reached))


Measured memory_bytes: 6472
N,D = map(int,input().split())
xy = [list(map(int,input().split()))for _ in range(N)]
ans = []
cnt = 0 
for i in range(len(xy)):
    ans.append((xy[i][0]**2+xy[i][1]**2)**0.5)
for j in ans:
    if j<=D:
        cnt+=1
print(cnt)

Measured memory_bytes: 53880
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


int ans[1000000];
int sum[1000000];

int main(){
  int N, K;
  string s;
  cin >> N >> K;
  cin >> s;
  int now = 1;
  int cnt = 0;
  vector<int> v;
  if(s[0] == '0'){
    v.push_back(0);
    now--;
    cnt++;
  }
  else cnt++;
  for(int i = 1; i < N; i++){
    if(s[i] == (char)(now + '0')){
      cnt++;
    }
    else{
      now ^= 1;
      v.push_back(cnt);
      cnt = 1;
    }
  }
  if(cnt) v.push_back(cnt);
  // rep(i,v.size())cout << v[i] << endl;
  int add = 2*K+1;
  vector<int> sum(v.size()+1);
  for(int i = 0; i < v.size(); i++){
    sum[i+1] = v[i] + sum[i];
  }

  
 
  int ans = 0;
  for(int i = 0; i < sum.size(); i+=2){
    int l = i;
    int r = min(i + add,int(sum.size())-1);
    int tmp = sum[r] - sum[l];
    ans = max(ans,tmp);
  }
  cout << ans << endl;
}




Measured memory_bytes: 1272