akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstdint>

using namespace std;

template <class T>
class FenwickTree {
    size_t n;
    vector<T> tree0, tree1;
    void update(vector<T> &tree, size_t i, T x) {
        while (i <= n) {
            tree[i] += x;
            i += i & -i;
        }
    }
    T query(vector<T> &tree, size_t i) {
        T res=0;
        while (i > 0) {
            res += tree[i];
            i -= i & -i;
        }
        return res;
    }
public:
    FenwickTree(size_t n, T e=0): n(n), tree0(n, e), tree1(n, e) {
        tree0 = vector<T>(n+1, e);
        tree1 = vector<T>(n+1, e);
    }
    void update(size_t l, size_t r, T x) {
        update(tree0, l+1, -x*l);
        update(tree1, l+1, x);
        update(tree0, r+1, x*r);
        update(tree1, r+1, -x);
    }
    T query(size_t l, size_t r) {
        T res=0;
        res += query(tree0, r) + query(tree1, r)*r;
        res -= query(tree0, l) + query(tree1, l)*l;
        return res;
    }
    T query(size_t l) {
        return query(l, l+1);
    }
};

int main() {
    size_t n;
    int q;
    scanf("%zu %d", &n, &q);

    FenwickTree<int64_t> tree(n);
    for (int i=0; i<q; ++i) {
        int op;
        scanf("%d", &op);

        if (op == 0) {
            size_t s, t;
            int64_t x;
            scanf("%zu %zu %lld", &s, &t, &x);
            tree.update(s-1, t, x);
        } else if (op == 1) {
            size_t s, t;
            scanf("%zu %zu", &s, &t);
            printf("%lld\n", tree.query(s-1, t));
        }
    }

    return 0;
}

Measured memory_bytes: 4740
//#include<bits/stdc++.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pb push_back

# define inOut(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
# define RESET(a) memset(a,0,sizeof(a))
# define MEMO(a) memset(a,-1,sizeof(a))
# define DEBUG puts("Debug-Has-Come-Until-Here")


typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int hitung[100004];

int main(){
	ios_base::sync_with_stdio(false);

	int n, i, j, mx = 0;
	memset(hitung, 0, sizeof hitung);
	cin >> n;
	while(n--){
		cin >> i;
		hitung[i]++;
	}
	for (i=1; i<100000; i++){
		mx = max(mx, hitung[i]+hitung[i-1]+hitung[i+1]);
	}
	cout << mx << endl;
	return 0;
}





Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long cnt[(int)1e3+5];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=2;i<=n;i++)
    {
        int m=i,k=sqrt(i);
        for(int j=2;j<=k;j++)
        {
            if(m%j==0)
            {
                while(m%j==0)
                {
                    cnt[j]++;
                    m/=j;
                }
            }
        }
        if(m>1) cnt[m]++;
    }
    long long ans=1;
    for(int i=2;i<=n;i++)
        if(cnt[i]) ans=((ans%mod)*((cnt[i]+1)%mod))%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
/*
 * (c) fushar (Ashar Fuadi)
*/

#include <bits/stdc++.h>

#define REP(i,n) for (int i = 0, _n = n; i < _n; i++)
#define FOR(i,a,b) for (int i = a, _b = b; i <= _b; i++)
#define FORD(i,b,a) for (int i = b, _a = a; i >= _a; i--)
#define RESET(c,v) memset(c, v, sizeof c)
#define ALL(c) c.begin(), c.end()
#define TT template<typename T>

using namespace std;
using ll = long long;

TT bool in_range(int x, int a, int b) { return a <= x && x < b; }

/***********************************************************/

const int MAXN = 50;

int N, P;

ll p2[MAXN+1], comb[MAXN+1][MAXN+1];

int main() {
    p2[0] = 1;
    FOR(i, 1, MAXN) p2[i] = 2 * p2[i-1];

    FOR(i, 0, MAXN) {
        comb[i][0] = 1;
        FOR(j, 1, i) {
            comb[i][j] = comb[i-1][j] + comb[i-1][j-1];
        }
    }

    cin >> N >> P;

    int evens = 0, odds = 0;
    REP(i, N) {
        int x;
        cin >> x;
        if (x % 2) odds++;
        else evens++;
    }

    ll res = 0;
    for (int i = P; i <= odds; i += 2) {
        res += comb[odds][i];
    }
    res *= p2[evens];

    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


int solve(){

    int n;cin>>n;
    //int a[n];
    int ans=0;
    rep(1,n+1){
        int x;cin>>x;
        if(i%2 && x%2) ans++;
    }
    cout<<ans<<endl;


    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

vector<vector<int>> G(10010);
vector<bool> visited(10010);
vector<int> ans(10010), c(10010);
int id;

void dfs(int cv){
    visited[cv] = true;

    ans[cv] = c[id++];

    for(auto nv : G[cv]){
        if(!visited[nv]){
            dfs(nv);
        }
    }

    return ;
}

int main(){
    int n; cin>>n;
    for(int i=0; i<n-1; i++){
        int a, b; cin>>a>>b;
        a--, b--;
        G[a].eb(b);
        G[b].eb(a);
    }

    for(int i=0; i<n; i++) cin>>c[i];

    sort(c.begin(), c.end(), greater<int>());

    int sum = accumulate(c.begin(), c.end(), 0) - c[0];

    dfs(0);

    cout << sum << endl;
    for(int i=0; i<n; i++){
        cout << ans[i] << " \n"[i == n - 1];
    }
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  set<string> s;
  vector<string> v(N);
  rep(i, 0, N) {
    cin >> v[i];
    if (s.count(v[i])) {
      cout << "No" << endl;
      return 0;
    }
    s.insert(v[i]);
  }
  rep(i, 0, N - 1) {
    if (v[i].back() != v[i + 1][0]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
/*input
2
0 0
*/

#include <bits/stdc++.h>
 
using namespace std;

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con))) 
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)
 
using ll = long long;
using ss = stringstream;
using ul = unsigned long long;
 
template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) { 
  FH(it,s) 
    *it = tolower(*it); 
} 
 
inline void upper(string &s) { 
  FH(it,s) 
    *it = toupper(*it); 
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
} 

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n) 
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    int n;
    cin >> n;
    
    vector < ll > s(n + 1, 0);
    int x;
    for(int i = 1; i <= n; i ++) {
        cin >> x;
        s[i] = s[i - 1] + x;
    }
    sort(ALL(s));

    int i = 0;
    ll ans = 0;
    while(i <= n) {
        ll y = s[i];
        ll cnt = 0;
        while(s[i] == y and i <= n) {
            i ++;
            cnt ++;
        }
        ans += (cnt * (cnt - 1)) / 2;
    }
    cout << ans;
    nl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long
inline void read (int &x) {
	char ch = getchar(); int f = 0; x = 0;
	while (!isdigit(ch)) { if (ch == '-') f = 1; ch = getchar(); }
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); if (f) x = -x;
} const int N = 538; vector<int> a, b;
int n, s[N], t[N], u[N], v[N], res[N][N], num[N][N], ca[N], cb[N];
signed main() {
	read (n); 
	for (int i = 1; i <= n; ++i) read (s[i]);
	for (int i = 1; i <= n; ++i) read (t[i]);
	for (int i = 1; i <= n; ++i) read (u[i]);
	for (int i = 1; i <= n; ++i) read (v[i]);
	for (int i = 1; i <= n; ++i) {
		if (!s[i]) a.push_back (i);
		if (!t[i]) b.push_back (i);
	}
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j) {
			if (s[i] == 0 and t[j] == 0) num[i][j] = u[i] | v[j]; 
			else if (s[i] == 1 and t[j] == 1) num[i][j] = u[i] & v[j];
			else if (s[i] == 0) num[i][j] = u[i]; else num[i][j] = v[j];
		}
	srand (19260817);
	for (int T = 1; T <= 800; ++T) {
		bool ok = 1; //srand (T * time(NULL)); 
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= n; ++j) res[i][j] = num[i][j];
		for (int i = 1; i <= n; ++i) {
			if (!s[i]) continue;
			int tmp = 0;
			for (int j = 1; j <= n; ++j) tmp |= res[i][j];
			int qwq = u[i] - (u[i] & tmp); 
			while (qwq) {
				int m = qwq & (-qwq);
				if (b.size()) {
					int w = rand() % b.size();
					res[i][b[w]] |= m;
				} qwq -= m;
			}
		} for (int i = 1; i <= n; ++i) {
			if (!t[i]) continue;
			int tmp = 0;
			for (int j = 1; j <= n; ++j) tmp |= res[j][i];
			int qwq = v[i] - (v[i] & tmp); 
			while (qwq) {
				int m = qwq & (-qwq);
				if (a.size()) {
					int w = rand() % a.size();
					res[a[w]][i] |= m;
				} qwq -= m;
			}
		} for (int i = 1; i <= n; ++i) {
			if (s[i]) {
				int tmp = 0;
				for (int j = 1; j <= n; ++j) tmp |= res[i][j];
				if (tmp != u[i]) { ok = 0; break; }
			} else {
				int tmp = res[i][1];
				for (int j = 2; j <= n; ++j) tmp &= res[i][j];
				if (tmp != u[i]) { ok = 0; break; }
			}
		} for (int i = 1; i <= n; ++i) {
			if (t[i]) {
				int tmp = 0;
				for (int j = 1; j <= n; ++j) tmp |= res[j][i];
				if (tmp != v[i]) { ok = 0; break; }
			} else {
				int tmp = res[1][i];
				for (int j = 2; j <= n; ++j) tmp &= res[j][i];
				if (tmp != v[i]) { ok = 0; break; }
			}
		} if (!ok) continue;
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= n; ++j) cout << res[i][j] << ' '; puts ("");
		} return 0;
	} return puts ("-1"), 0;
}


Measured memory_bytes: 9776
import java.util.Scanner;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n+1];
        for(int i = 2;i <= n;i++){
            boolean isPrime = true;
            for(int j = 2;j*j <= i;j++){
                if(i % j == 0){
                    isPrime = false;
                }
            }
            if(isPrime){
                for(int j = 1;j <= n;j++){
                    int x = j;
                    while(x % i == 0){
                        a[i]++;
                        x /= i;
                    }
                }
            }
        }
        long ans = 1;
        for(int i = 2;i <= n;i++){
            ans *= (a[i]+1);
            ans %= 1000000007;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <array>
using namespace std;
typedef long long ll;
#define tr(container, it) \
	for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c,x) ((c).find(x) != (c).end())   //O(log n) 
#define contains(c,x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define Ichar(_x) char _x;scanf("%c",&_x);
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define inc(a,b,x)(x)>a && (x)<b	
#define incE(a,b,x)(x)>=a && (x)<=b	
//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);


int main()
{
	stack<char> sc;
	string s;
	std::cin >> s;
	for (int i = 0; i < s.size(); ++i)
	{
		if(!sc.empty() && sc.top()=='S' && s[i]=='T')
		{
			sc.pop();
		}
		else { sc.push(s[i]); }
	}
	int i=0;
	while (!sc.empty())
	{
		sc.pop();
		++i;
	}
	std::cout << i;

	



}











Measured memory_bytes: 644
#include <stdio.h>

int IsPrime(int x) {
    if (x<2) return 0;
    else if (x==2) return 1;
    if (x%2==0) return 0;
    int i;
    for (i=3; i*i<=x; i+=2) {
        if (x%i==0) return 0;
    }
    return 1;
}
int ReadValue() {
    int value; 
    scanf("%d",&value);
    return value;
}
int solve(int n) {
    int ans=0;
    for (int i=0; i<n; i++) {
        int value=ReadValue();
        ans+=(IsPrime(value)?1:0);        
    }
    return ans;
}
void Display(int n) {
    printf("%d\n",solve(n));
}
int main() {
    int n=ReadValue();
    Display(n);
}


Measured memory_bytes: 2060
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
 int H;
  int N;
  cin >>H>>N;
  vector<int> vec(N);
  rep(i,N) {
    cin >>vec.at(i);
  }
  
  int count=0;
  rep(i,N) {
count +=vec.at(i);
  }
  
  
  
  if(H-count<=0) {
cout<<"Yes"<< endl;
  }
else {
cout <<"No"<< endl;
}
}

    
  


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
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*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  int n,m;
  cin>>n>>m;
  vi a(n);
  int sum=0;
  rep(i,n) {
    cin>>a[i];
    sum+=a[i];
  }
  int cnt=0;
  if(sum%(m*4)==0){
    rep(i,n){
      if(a[i]<sum/(4*m)) continue;
      cnt++;
    }
  }
  if(sum%(m*4)!=0){
    rep(i,n){
      if(a[i]<=sum/(4*m)) continue;
      cnt++;
    }
  }
  if(cnt>=m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    i64 N, K;
    read(N, K);

    vector<i64> cnt(K);
    reps(i, 1, N) {
        cnt[i % K] += 1;
    }

    i64 ans = 0;

    rep(a, K) {
        const int b = (K - a) % K;
        const int c = (K - a) % K;
        if ((b + c) % K != 0) continue;
        ans += cnt[a] * cnt[b] * cnt[c];
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int N,K; cin >> N >> K;

    cout << N - K + 1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
struct node{
	bool x,y;
};
int main()
{
	node ans[105];
	memset(ans,0,sizeof(ans));
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int maxn=max(max(a,b),max(c,d));
	for(int i=a;i<=b;i++)
	{
		ans[i].x=true;
	}
	for(int i=c;i<=d;i++)
	{
		ans[i].y=true;
	}
	int total=-1;
	for(int i=0;i<=maxn;i++)
	{
		if(ans[i].x&&ans[i].y) total++;
	}
	if(total==-1) cout<<0; else cout<<total;
	return 0;
}

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

struct edge {
    int a, b;
    double w;
};

class BellmanFord {    
    int n;
    vector<edge> edges;
    vector<double> d;

public:
    BellmanFord(int n) : n(n) {
        edges = vector<edge>(n);
        d = vector<double>(n, numeric_limits<double>::infinity());
    }

    void addEdge(int a, int b, double w) {
        assert(0 <= a && a < n && 0 <= b && b < n);
        edges.push_back({a, b, w});
        edges.push_back({b, a, w});
    }
    void addArc(int a, int b, double w) {
        assert(0 <= a && a < n && 0 <= b && b < n);
        edges.push_back({a, b, w});
    }

    // return true if has negative loop
    bool run(int a) {
        d[a] = 0;
        for (int i = 0; i < n; i++) {
            bool change = false;
            for (edge e: edges) {
                if (d[e.a] != numeric_limits<double>::infinity()) {
                    if (d[e.b] > d[e.a] + e.w) {
                        d[e.b] = d[e.a] + e.w;
                        change = true;
                    }
                }
            }
            if (!change) {
                return false;
            }
        }
        return true;
    }

    double dist(int a) {
        return d[a];
    }
};

int main() {
    int v, e;
    cin >> v >> e;
    double dist[v][v];
    BellmanFord g(v);
    for (int i = 0; i < v; i++) {
        for (int j = 0; j < v; j++) {
            if (i != j) {
                dist[i][j] = numeric_limits<double>::infinity();
            } else {
                dist[i][j] = 0;
            }
        }
    }

    for (int i = 0; i < e; i++) {
        int a, b, w;
        cin >> a >> b >> w;
        g.addArc(a, b, w);
        dist[a][b] = min(dist[a][b], double(w));
    }

    for (int i = 0; i < v; i++) {
        if (g.run(i)) {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    }

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

    auto format = [](double a) {
        if (a == numeric_limits<double>::infinity()) {
            return "INF"s;
        } else {
            return to_string(i64(a));
        }
    };

    for (int i = 0; i < v; i++) {
        cout << format(dist[i][0]);
        for (int j = 1; j < v; j++) {
            cout << " " << format(dist[i][j]);
        }
        cout << endl;
    }
}


Measured memory_bytes: 3484
/*  ex4_1
    yy8332  */

#include <stdio.h>
#include <math.h>


int main(void){
  float num1, num2, ans;

  //入力読み取り
  scanf("%f %f",&num1 ,&num2);

  ans = ceil(num1 / (num2 * 2 + 1));

  //出力
  printf("%.0f",ans);


  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define nl cout<<"\n"
#define endl "\n"
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c.size())
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define f first
#define s second

inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a; a%=b;return gcd(b,a);}
ll power(ll x, ll y){if(y == 0) return 1; ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x, ll ex , ll md) {ll ans = 1ll;while (ex > 0) {if (ex & 1ll) ans = (ans * x) % md; ex >>= 1ll;x = (x * x) % md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;

const ll N = 7;
ll n,  m , k , tot;
string s[N];
ll ans = 1;
bool vis[N][N];
bool check(ll x , ll y){
    rep(i , n){
        rep(j , m) vis[i][j] = 0;
    }
    ll ct = 0;
    vll a , b;
    while(x > 0){
        a.pb(x%2);
        x /= 2;
    }
    while(y > 0){
        b.pb(y%2);
        y /= 2;
    }
    vll r , c;
    for(ll i = 0 ; i < sz(a) ; i++) if(a[i] == 1) r.pb(i);
    for(ll i = 0 ; i < sz(b) ; i++) if(b[i] == 1) c.pb(i); 
    for(ll i= 0 ; i < sz(r) ; i++){
        ll row = r[i];
        for(ll j = 0 ; j < m ; j++){
            if(vis[row][j] == 0){
                if(s[row][j] == '#'){
                    vis[row][j] = 1;
                    ct++;
                }
            }
        }
    }
    for(ll i = 0 ; i < sz(c) ; i++){
        ll col = c[i];
        for(ll j = 0 ; j < n; j++){
            if(vis[j][col] == 0){
                if(s[j][col] == '#'){
                    vis[j][col] == 1;
                    ct++;
                }
            }
        }

    }
    ll rem = tot - ct;
    if(rem == k) return true;
    else return false;
}
void solve(){
    cin >> n >> m >> k;
    rep(i , n) cin >> s[i];
    rep(i , n){
        rep(j , m) if(s[i][j] == '#') tot++;
    }
    ll x1 = (1ll << n) - 1;
    ll x2 = (1ll << m) - 1;
    for(ll i = 0 ; i <= x1 ; i++ ){
        for(ll j = 0 ; j <= x2 ; j++){
            if(check(i , j)) ans++;
        }
    }
    cout << ans - 1 << endl;
}
int main(){
    IOS;
    cout << fixed << setprecision(20);
    ll NTC = 1;
    // cin >> NTC;
    ll PTC = 0;
    while(PTC++ < NTC){
        // cout << "Case #" << PTC << ":" << ' ';
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


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

#define INF (INT32_MAX/2)
typedef pair<int, int> P;

int main()
{
	int N, M, S, T;

	cin >> N >> M;
	vector<vector<int>> G( N );
	for( int i = 0; i < M; i++ ) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		G[u].push_back( v );
	}
	cin >> S >> T;
	S--;
	T--;

	vector<vector<int>> G1( N * 3 );
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < G[i].size(); j++ ) {
			int u0 = i;
			int u1 = u0 + N;
			int u2 = u1 + N;
			int v0 = G[i][j];
			int v1 = v0 + N;
			int v2 = v1 + N;
			G1[u0].push_back( v1 );
			G1[u1].push_back( v2 );
			G1[u2].push_back( v0 );
		}
	}
	priority_queue< P, vector<P>, greater<P> > que;
	vector<int> d( N * 3, INF );
	d[S] = 0;
	que.push( P( S, 0 ) );
	while( !que.empty() ) {
		P p = que.top();
		que.pop();
		int v = p.first;
		if( d[v] < p.second ) continue;
		for( int i = 0; i < G1[v].size(); i++ ) {
			int e = G1[v][i];
			if( d[e] > d[v] + 1 ) {
				d[e] = d[v] + 1;
				que.push( P( e, d[v] + 1 ) );
			}
		}
	}
	int ans = -1;
	if( d[T] != INF ) {
		ans = d[T] / 3;
	}

	cout << ans << endl;
}


Measured memory_bytes: 23296
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

void check(int a[3][3], bool flag[3][3], int num) {
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            if (a[i][j] == num) {
                flag[i][j] = true;
            }
        }
    }
}

int main() {
    int a[3][3];
    bool flag[3][3];
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> a[i][j];
            flag[i][j] = false;
        }
    }
    
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        check(a, flag, tmp);
    }
    
    for(int i = 0; i < 3; i++) {
        bool clear = true;
        for(int j = 0; j < 3; j++) {
            if(!flag[i][j]) {
                clear = false;
                break;
            }
        }
        if(clear) {
            cout << "Yes";
            return 0;
        }
    }
    for(int i = 0; i < 3; i++) {
        bool clear = true;
        for(int j = 0; j < 3; j++) {
            if(!flag[j][i]) {
                clear = false;
                break;
            }
        }
        if(clear) {
            cout << "Yes";
            return 0;
        }
    }
    if(flag[0][0] && flag[1][1] && flag[2][2]) {
        cout << "Yes";
        return 0;
    } else if(flag[0][2] && flag[1][1] && flag[2][0]) {
        cout << "Yes";
        return 0;
    } else {
        cout << "No";
    }
    return 0;
}

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

using namespace std;

int n,k;
ll T[100000];

int check(ll P) {
    int i = 0;
    for(int j = 0; j < k; j++) {
        ll s = 0;
        while(s + T[i] <= P) {
            s += T[i];
            i++;
            if(i == n) return n;
        }
    }
    
    return i;
}

int solve() {
    ll left = 0;
    ll right = 100000L * 100000L;
    ll mid;
    while(right - left > 1) {
        mid = (left + right) / 2;
        int v = check(mid);
        if(v >= n) right = mid;
        else left = mid;
    }
    
    return right;
}

int main(){
    cin >> n >> k;
    rep(i,n) cin >> T[i];
    
    ll ans = solve();
    cout << ans << endl;
}



Measured memory_bytes: 3900
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void){
    ll n;
    cin >> n;
    ll sum = 0;
    vector<ll> c;
    c.push_back(0);
    ll a;
    ll MAX;
    for(ll i = 1; i <= n; i++){
        c.push_back(c[i-1]+i);
        if(c[i-1]<n && c[i]>=n){
            a = c[i]-n;
            MAX = i;
        }
    }
    //cout << a << endl;
    vector<bool> ans(MAX+1, true);
    for(ll i = 0; i <= MAX; i++){
        //cout << i << endl;
        bool check = true;
        for(ll j = i+1; j <= MAX; j++){
            if(c[j]-c[i]==a){
                check = false;
                for(ll k = i+1; k <= j; k++)
                    ans[k] = false;
                break;
            }
        }
        if(check==false)
            break;
    }
    for(ll i = 1; i <= MAX; i++){
        if(ans[i]==true)
            cout << i << endl;
    }
    return 0;
}


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

using namespace std;

int main(){
  int c[3][3];
  // int a[3][3];
  // int b[3][3];
  int total=0;

  bool flag=true;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> c[i][j];
      total = total+c[i][j];
    }
  }

  for(int i=0;i<2;i++){
    // cout << c[i][0] - c[i+1][0] << endl;
    // cout << c[i][1] - c[i+1][1] << endl;
    // cout << c[i][2] - c[i+1][2] << endl;
    if(c[0][i] - c[0][i+1] != c[1][i] - c[1][i+1] || (c[1][i] - c[1][i+1] != c[2][i] - c[2][i+1]) ){
      //cout << "flag" << endl;
      flag=false;
    }
    if(c[i][0] - c[i+1][0] != c[i][1] - c[i+1][1] || (c[i][1] - c[i+1][1] != c[i][2] - c[i+1][2]) ){
      flag=false;
      //cout << "flag" << endl;
    }
  }


  if(total%3!=0){
    flag=false;
  }

  if(flag==true){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


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

int main(){
  string s;
  cin>>s;
  for(ll bit=0;bit<(1<<4);bit++){
    ll sum=0;
    for(ll i=0;i<4;i++){
      if(bit & (1<<i)){
        sum+=s[i]-'0';
      }else{
        sum-=s[i]-'0';
      }
    }
    if(sum==7){
      cout<<s[0]<<(bit&(1<<1)?"+":"-")<<s[1]<<(bit&(1<<2)?"+":"-")<<s[2]<<(bit&(1<<3)?"+":"-")<<s[3]<<"=7"<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int main()
{
	int k;
	scanf("%d", &k);

	vector<int> dist(k, -1);

	dist[1] = 1;

	deque<int> q;

	q.push_back(1);

	while (!q.empty())
	{
		auto now = q.front();
		q.pop_front();

		if (now == 0)
		{
			printf("%d\n", dist[0]);
			break;
		}

		int ten = (now * 10) % k;

		if (dist[ten] == -1 || dist[ten] > dist[now])
		{
			dist[ten] = dist[now];
			q.push_front(ten);
		}

		int next = (now + 1) % k;
		if (dist[next] == -1)
		{
			dist[next] = dist[now] + 1;
			q.push_back(next);
		}
	}

	return 0;
}

Measured memory_bytes: 896
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    B = list(map(int, input().split()))
    ans = B[0] + B[-1]
    for i in range(1, N-1):
        ans += min(B[i], B[i-1])
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

//typedef long long int;

int n, cnt[3],flag;

int t(int a) 
{
	int ans = 0;
	while (!(a % 2)) {
		++ans;
		a = a / 2;
	}
	return ans;
}

int main()
{
	cin >> n;
	int a;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		int ans = t(a);
		if (ans <= 2) {
			++cnt[ans];
		}
		else {
			++cnt[2];
		}
	}
	if (!cnt[1]) {
		if (cnt[2]) {
			cnt[2] = cnt[2] - cnt[0] + 1;
			if (cnt[2] >= 0) {
				flag = 1;
			}
		}
	}
	else {
		if (cnt[2] >= cnt[0]) {
			flag = 1;
		}
	}
	if(flag) {
		cout << "Yes" << endl;
	}
	else {
			cout << "No" << endl;
	}
//	system("pause");
	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline
    from math import hypot
    from collections import deque

    N, K = map(int, input().split())
    XYC = [tuple(map(int, input().split())) for _ in range(N)]

    dq = deque([(0, 0, 1000.0)])

    ans = 10**18
    while dq:
        X, Y, r = dq.popleft()
        c_hypot = [c * hypot(max(abs(X - x) - r, 0), max(abs(Y - y) - r, 0)) for x, y, c in XYC]
        c_hypot.sort()
        if ans * 0.9999995 > c_hypot[K-1]:
            c_hypot = [c * hypot(X - x, Y - y) for x, y, c in XYC]
            c_hypot.sort()
            if c_hypot[K-1] < ans:
                ans = c_hypot[K-1]

            r /= 2
            dq += [
                (X + r, Y + r, r),
                (X - r, Y + r, r),
                (X + r, Y - r, r),
                (X - r, Y - r, r),
            ]
    print(ans)

main()

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define REPi(n) for(int i=0;i<n;i++)
#define REPj(n) for(int j=0;j<n;j++)

using namespace std;

int main(){
    int a,b;
    int ans=-1;
    cin >> a >> b;
    for(int i=1;i<=1000;i++){
        if(i*8/100>a-1&&i*8/100<=a&&i/10>b-1&&i/10<=b){
            ans=i;
            break;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#B
n,k = map(int,input().split())
d = []
a = []
for _ in range(k):
    d.append(int(input()))
    a.append(list(map(int,input().split())))
    
s = [0 for _ in range(n)]

for i in range(k):
    for j in range(d[i]):
        s[a[i][j] - 1] += 1
        
print(s.count(0))

Measured memory_bytes: 9192
N, M = map(int,input().split())
alist = []
for i in range(M):
    a,b=input().split()
    alist.append([int(a),int(b)])
p = 1
for i in range(M):
    if [alist[i][0],alist[i][1]] == [1,0]:
        p = p*0
for i in range(M-1):
    for j in range(i+1,M):
        if alist[i][0] == alist[j][0] and alist[i][1] != alist[j][1]:
            p = p*0
q = [0 for i in range(N)]
q[0] = 1
for i in range(M):
    q[alist[i][0]-1] = alist[i][1]
for i in range(N):
    q[i] = str(q[i])
if M == 0:
    if N == 1:
        print(0)
    else:
        x = 10**(N-1)
        print(x)
elif M == 1 and alist[0] == [1,0] and N == 1:
    print(0)
else:
    if p == 0:
        print(-1)
    else:
        print(int(''.join(q)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#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--)
typedef ll GCD_TYPE;
GCD_TYPE gcd(GCD_TYPE a,GCD_TYPE b){
    if(b == 0)
        return a;
    return gcd(b,a % b);
}

ull t[1000];
int main(){
    ull n;
    scanf("%llu",&n);
    REP(i,n)
        scanf("%llu",t + i);

    ll ans = t[0];

    FOR(i,1,n){
        ll g = gcd(ans,t[i]);
        ans = ans / g * t[i];
    }
    printf("%llu\n",ans);
    return 0;
}


Measured memory_bytes: 256
<?php

# C - Prison

fscanf(STDIN, "%d %d", $N, $M);

# カードの端を作成
$card_begin = 1;
$card_end = $N;

# ゲートを取得
for ( $i = 1 ; $i <= $M ; $i++ ) {
    fscanf(STDIN, "%d %d", $begin, $end);
    if ($begin >= $card_begin) {
        $card_begin = $begin;
    }
    if ($end <= $card_end) {
        $card_end = $end;
    }
    if ($card_begin > $card_end) {
        echo 0;
        exit;
    }
}

echo count(range($card_begin, $card_end));


Measured memory_bytes: 8696
#include <iostream>

using namespace std;

const int N = 2e5 + 10;
int n, a[N], Max = 0;
long long ans = 0;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", a + i);
	Max = a[1];
	for (int i = 2; i <= n; i++) {
		if (Max <= a[i])
			Max = a[i];
		else
			ans += Max - a[i];
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 4536
H, W, N = gets.split.map{|i|i.to_i}
black = Hash.new{0}
N.times{
    row, col = gets.split.map{|i|i.to_i - 1}
    (-2 .. 0).each{|y|
        r = row + y
        next if r < 0
        next if r >= H - 2
        (-2 .. 0).each{|x|
            c = col + x
            next if c < 0
            next if c >= W - 2
            black[[r, c]] += 1
        }
    }
}
count = Array.new(10){0}
black.each_value{|v|
    count[v] += 1
}
count[0] = (H - 2) * (W - 2) - count.inject(:+)
puts count


Measured memory_bytes: 105468
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
using ll = long long int;

int main(){
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);

    ll ans;
    if ((x+d-1) / d <= k){
        k -= x / d;
        if (k % 2 == 0)ans = x % d;
        else ans = d - (x%d);
    }
    else{
        ans = x - k * d;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}

int main(void) {
  ll N, M;
  cin >> N >> M;
  P p[MAX];
  ll i;
  
  for(i=0; i<N; i++) {
    ll d, m;
    cin >> d >> m;
    p[i]={d, m};
  }
  sort(p, p+N);
  
  priority_queue<ll> q;
  ll ans=0;
  ll x=0;
  for(ll day=1; day<=M; day++) {
    
    while(p[x].ft==day) {
      q.push(p[x].sc);
      x++;
    }
    
    if(q.empty()) continue;
    ans+=q.top(); q.pop();
  }
  
  pt(ans);
    
}


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

int main() {
	int n; cin >> n;
	vector<int>vec;
	rep(i, n) {
		int a; cin >> a;
		vec.push_back(a);
	}
	sort(vec.begin(), vec.end());
	vector<string>ans;
	rep(i, min(n, 4)) {
		rep(j, min(n, 4)) {
			if (i == j)continue;
			ans.push_back(to_string(vec[i]) + to_string(vec[j]));
		}
	}
	sort(ans.begin(), ans.end());
	stable_sort(ans.begin(), ans.end(), [](string a, string b) {return a.size() < b.size(); });
	cout << ans[2] << endl;
	return 0;
}

Measured memory_bytes: 3360
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007

int main() {
    intt n;
    scanf("%lld", &n);
    vector<intt> mster(n+1);
    rep(i,n+1) scanf("%lld", &mster.at(i));
    vector<intt> yush(n+1, 0);
    rep(i,n) scanf("%lld", &yush.at(i));
    intt ans=0;
    rep(i,n) {
        intt c=min(mster.at(i), yush.at(i));
        ans+=c; yush.at(i)-=c;
        int d=min(mster.at(i+1), yush.at(i));
        ans+=d; mster.at(i+1)-=d;
    }
    printf("%lld\n", ans);
}


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

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

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

template <typename T>
struct RMQ {//normal
    const T INF = numeric_limits<T>::max();
    int n;         
    vector<T> dat; 
    RMQ(int n_) : n(), dat(n_ * 4, 0) { 
        int x = 1;
        while (n_ > x) {
            x *= 2;
        }
        n = x;
    }
 
    void update(int i, T x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;  
            dat[i] = max(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }
 
    // the minimum element of [a,b)
    T query(int a, int b) { return query_sub(a, b, 0, 0, n); }
    T query_sub(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return 0;
        } else if (a <= l && r <= b) {
            return dat[k];
        } else {
            T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return max(vl, vr);
        }
    }
};

int main(){
    ll N,K;
    cin>>N>>K;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    RMQ<ll> cnt(300005);
    rep(i,N){
        ll a = cnt.query(max(0LL,A[i]-K),min(300005LL,A[i]+K+1));
        cnt.update(A[i],a+1);
    }
    ll ans = cnt.query(0,300005);
    cout<<ans<<endl;
}

Measured memory_bytes: 14916