akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;

int main(){
    string S; cin >> S;
    int n = S.size();

    vector<int> mod_counter(2019, 0);
    mod_counter[0] = 1;
    int mul = 1;
    int now = 0;
    for (int i = n - 1; i >= 0; i--){
        now = ((mul * (S[i] - '0') % 2019) + now) % 2019;
        mod_counter[now]++;
        mul =  (mul * 10) % 2019;
    }

    ll ans = 0;
    rep(i, mod_counter.size()){
        ll count = mod_counter[i];
        ans += count * (count-1) / 2;
    }

    cout << ans << endl;

}

Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int N,A[100010],B[100010],E[100010] = {0},visited[200010] = {0};
ll C[100010],ans[200010] = {0};

vector<pair<ll,int>> e;
vector<vector<pair<ll,int>>> v(200010);

int p[100010] = {0},r[100010] = {0};
ll s[100010] = {0};

void init(int N){
	for(int i=0;i<=N;++i){
		p[i] = i;
		s[i] = 1;
		E[i] = i;
	}
}

int root(int a){
	if(p[a] == a) return a;
	return (p[a] = root(p[a]));
}

bool is_same_set(int a,int b){
	return root(a) == root(b);
}

void unite(int a, int b){
	a = root(a);
	b = root(b);
	if(a==b) return;
	if(r[a]<r[b]){
		p[a] = b;
		s[b] += s[a];
		s[a] = s[b];
	}else{
		p[b] = a;
		s[a] += s[b];
		s[b] = s[a];
		if(r[a] == r[b]) r[a]++;
	}
}

void dfs(int n){
	visited[n] = 1;
	for(int i=0;i<v[n].size();i++){
		int t = v[n][i].second;
		ll cost = v[n][i].first;
		if(visited[t]==0){
			ans[t] = ans[n] + cost;
			dfs(t);
		}
	}
}

int main(){
	cin >> N;
	init(N);
	if(N==1){
		cout << 0 << endl;
		return 0;
	}
	for(int i=1;i<=N-1;i++){
		cin >> A[i] >> B[i] >> C[i];
		e.push_back({C[i],i});
	}
	sort(e.begin(),e.end());
	for(int i=N-2;i>=0;i--){
		int t = e[i].second;
		ll cost = e[i].first;
		v[t+N].push_back({cost*s[root(B[t])],E[root(A[t])]});
		v[t+N].push_back({cost*s[root(A[t])],E[root(B[t])]});
		unite(A[t],B[t]);
		E[root(A[t])] = t+N;
	}
	dfs(N+e[0].second);
	for(int i=1;i<=N;i++){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 21232
# pp = list(map(int, input().split()))
n = int(input())

def cross(a, b):
    return a[0]*b[1]-a[1]*b[0]

def length(vector):
    ans = 0
    for i in vector:
        ans += i**2
    return ans**(1/2)
    
def dot(a, b):
    n = len(a)
    if n != len(b):
        return None
    ans = 0
    for i, j in zip(a, b):
        ans += i*j
    return ans

    
for i in range(n):
    a,b,c,d,e,f,g,h= list(map(int, input().split()))
    s1 = (c-a,d-b)
    s2 = (g-e,h-f)
    d1 = abs(cross(s1, (e-a,f-b)))/length(s1)
    d2 = abs(cross(s1,(g-a,h-b)))/length(s1)
    t = d1/(d1+d2)
    ans = ((e*(1-t)+g*t),(f*(1-t)+h*t))
    print(f'{ans[0]:.8f} {ans[1]:.8f}')


Measured memory_bytes: 5704
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
const LL inf=1LL<<60;
LL n,d,a[200010];
struct node{
	LL c1,c2,k1,k2;
	node() {}
	node(LL a,LL b,LL c,LL d) {c1=a;c2=b;k1=c;k2=d;}
};
LL fa[200010];
LL findfa(LL x) {return fa[x]==x?x:fa[x]=findfa(fa[x]);}
struct Node{
	LL x,y,c;
}e[200010];LL len=0;
struct trnode{
	LL lc,rc;
	node c;
}tr[400010];LL tot=0;
node update(node lc,node rc)
{
	node c;
	c.c1=min(lc.c1,rc.c1);
	c.k1=lc.c1<rc.c1?lc.k1:rc.k1;
	c.k2=lc.c2<rc.c2?lc.k2:rc.k2;
	c.c2=min(lc.c2,rc.c2);
	return c;
}
void change(LL x,LL l,LL r,LL k,node c)
{
	if(l==r) {tr[x].c=c;return;}
	LL mid=(l+r)/2;
	if(k<=mid) change(tr[x].lc,l,mid,k,c);
	else change(tr[x].rc,mid+1,r,k,c);
	tr[x].c=update(tr[tr[x].lc].c,tr[tr[x].rc].c);
}
node findans(LL x,LL l,LL r,LL fl,LL fr)
{
	if(fl>fr) return node(inf,inf,1,1);
	if(l==fl&&r==fr) return tr[x].c;
	LL mid=(l+r)/2;
	if(fr<=mid) return findans(tr[x].lc,l,mid,fl,fr);
	if(fl>mid) return findans(tr[x].rc,mid+1,r,fl,fr);
	return update(findans(tr[x].lc,l,mid,fl,mid),findans(tr[x].rc,mid+1,r,mid+1,fr));
}
LL bt(LL l,LL r)
{
	LL x=++tot;
	if(l!=r)
	{
		LL mid=(l+r)/2;
		tr[x].lc=bt(l,mid);
		tr[x].rc=bt(mid+1,r);
		tr[x].c=update(tr[tr[x].lc].c,tr[tr[x].rc].c);
	}
	else tr[x].c=node(l*d+a[l],-l*d+a[l],l,l);
	return x;
}
vector<int> vec[200010];
bool cmp(Node a,Node b) {return a.c<b.c;}
bool vis[200010];
int main()
{
	scanf("%lld %lld",&n,&d);
	for(LL i=1;i<=n;i++) fa[i]=i;
	for(LL i=1;i<=n;i++) scanf("%lld",&a[i]);
	bt(1,n);LL num=n;
	LL ans=0;
	while(num!=1)
	{
		memset(vis,false,sizeof(vis));
		for(LL i=1;i<=n;i++) vec[i].clear();
		for(LL i=1;i<=n;i++) vec[findfa(i)].push_back(i);
		len=0;
		for(LL i=1;i<=n;i++)
			if(findfa(i)==i)
			{
				for(LL j=0;j<vec[i].size();j++)
				{
					LL y=vec[i][j];
					change(1,1,n,y,node(inf,inf,y,y));
				}
				for(LL j=0;j<vec[i].size();j++)
				{
					LL y=vec[i][j];
					node c1=findans(1,1,n,1,y-1);
					node c2=findans(1,1,n,y+1,n);
					LL C1=c1.c2+y*d+a[y],C2=c2.c1-y*d+a[y];
					if(C1<C2) e[++len].x=i,e[len].y=c1.k2,e[len].c=C1;
					else e[++len].x=i,e[len].y=c2.k1,e[len].c=C2;
				}
				for(LL j=0;j<vec[i].size();j++)
				{
					LL y=vec[i][j];
					change(1,1,n,y,node(y*d+a[y],-y*d+a[y],y,y));
				}
			}
		sort(e+1,e+len+1,cmp);
		for(LL i=1;i<=len;i++)
		{
			LL tx=findfa(e[i].x),ty=findfa(e[i].y);
			if(vis[tx]) continue;
			vis[tx]=true;
			if(tx!=ty)
			{
				ans+=e[i].c;
				fa[tx]=ty;num--;
			}
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 46968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

#define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()
#define sz(x) ((long long)x.size())
#define arr array

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e10;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}

void pre(){

}

#define int long long 

void solve(){  

    int n;
    cin >> n;
    vector<pair<int,int>> arr;

    for(int i=1;i<=n;i++){
        long double x;
        cin >> x;
        long long y = (long long)(x*1e9+0.5);
        ll c2=0,c5=0;
        while(y%2==0){
            c2++;
            y /= 2;
        }
        while(y%5==0){
            c5++;
            y /= 5;
        }
        arr.pb({c2,c5});
    }
    map<pair<int,int>,int> MAP;
    int ans=0;
    for(auto it : arr){
        for(auto x : MAP){
            if(it.ff + x.ff.ff >= 18 and it.ss + x.ff.ss >= 18)
                ans += x.ss;
        }
        MAP[it]++;
    }
    cout << ans;

}   

int32_t main(){
    #ifndef ONLINE_JUDGE
    freopen("input00.txt","r",stdin);
    #endif
    IOS;
    pre();
    ll T = 1;   
    //cin>>T;
    ll tt = 1;
    while(T--){  
        //cout << "Case #" << tt << ": "; 
        tt++;
        solve();
    }
    return 0;
}

Measured memory_bytes: 7540
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % MOD, n/2);
        if(n % 2 == 1) res = res * x % MOD;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[n-k] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};

Combination cb(1000010);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X,Y;
    cin >> X >> Y;
    if((X + Y) % 3 != 0){
        print(0);
        return 0;
    }
    if(X > Y){
        if(X > 2*Y){
            print(0);
            return 0;
        }
    }else{
        if(Y > 2*X){
            print(0);
            return 0;
        }
    }
    ll a = (2*Y-X)/3;
    ll b = (2*X-Y)/3;
    ll ans = cb.nck(a+b, a);
    print(ans);

    

}

Measured memory_bytes: 22632
k, n = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a.append(k+a[i])
right = [0]

for i in range(1, 2*n):
    right.append(right[-1] + a[i] - a[0])

ans = abs(a[0] - a[-2])
for i in range(1, n+1):
    ans = min(ans, abs(a[i] - a[n+i-1]))
print(ans)




Measured memory_bytes: 38348
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.in(),r=t.in(),n=0,i=0;i<=e;i++)for(var s=0;s<=e;s++){var o=r-i-s;0<=o&&o<=e&&n++}console.log(n)}}]);

Measured memory_bytes: 7372
def main():
    k, a, b = map(int, input().split())
    print(solve(k, a, b))

def solve(k, a, b):
    if b - a <= 2:
        return k + 1
    
    if (k - a + 1) % 2 == 0:
        n = (k - a + 1) // 2
        return a + (b - a) * n
    else:
        n = (k - a + 1) // 2
        return a + (b - a) * n + 1

main()


Measured memory_bytes: 3060
f = int(input())
ls = [int(x) for x in input().split()]
a = c = max1 = k =0
while k < len(ls)-1:
    for a in range(k, len(ls)-1):
        if ls[a] < ls[a + 1]:
            break
        c = c + 1
    if c > max1:
        max1 = c
    k = a + 1
    c = 0
print(max1)

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

using namespace std;
using LL = long long;

int n, K;
string s;

int make_R() {
	int k = K;
	int result = 0;
	for (int i = 0; i + 1 < n; i ++) {
		if (s[i] == s[i + 1]) result ++;
	}

	vector< pair< int, int> > vec;

	int l = -1, r = -1;
	for (int i = 0; i < n; i ++) {
		if (s[i] == 'L') {
			if (l == -1) l = i;
			r = i;
		}
		else {
			if (l != -1) vec.emplace_back(l, r);
			l = r = -1;
		}
	}
	if (l != -1) {
		vec.emplace_back(l, r);
	}
	int m = vec.size();
	if (vec.empty()) return result;

	for (int i = 1; i < m - 1 && k > 0; i ++) {
		k --;
		result += 2;
	}

	if (k > 0) {
		k --;
		result += 2;
		if (vec[0].first == 0) result --;
		if (vec[0].second == n - 1) result --;
	}

	if (k > 0 && m > 1) {
		result += 2;
		if (vec[m - 1].first == 0) result --;
		if (vec[m - 1].second == n - 1) result --;
	}
	return result;
}

int make_L() {
	int k = K;
	int result = 0;
	for (int i = 0; i + 1 < n; i ++) {
		if (s[i] == s[i + 1]) result ++;
	}

	vector< pair< int, int> > vec;

	int l = -1, r = -1;
	for (int i = 0; i < n; i ++) {
		if (s[i] == 'R') {
			if (l == -1) l = i;
			r = i;
		}
		else {
			if (l != -1) vec.emplace_back(l, r);
			l = r = -1;
		}
	}
	if (l != -1) {
		vec.emplace_back(l, r);
	}
	int m = vec.size();
	if (vec.empty()) return result;

	for (int i = 1; i < m - 1 && k > 0; i ++) {
		k --;
		result += 2;
	}

	if (k > 0) {
		k --;
		result += 2;
		if (vec[0].first == 0) result --;
		if (vec[0].second == n - 1) result --;
	}

	if (k > 0 && m > 1) {
		result += 2;
		if (vec[m - 1].first == 0) result --;
		if (vec[m - 1].second == n - 1) result --;
	}
	return result;
}

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

	cin >> n >> K >> s;
	int best = max(make_R(), make_L());
	cout << best << endl;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
vector<long long> dp, paty;
long long dfs(long long N, long long X){
    long long ans = 0; 
    if(X == 1 && N == 0) return 1;
    else if(X == 1) return 0;
    if(X == dp[N]) return paty[N];
    if(X > dp[N] / 2 + 1) ans += dfs(N - 1, X - dp[N] / 2 - 1) + 1 + paty[N] / 2;
    else if(X == dp[N] / 2 + 1) ans += paty[N] / 2 + 1;
    else ans += dfs(N - 1, X - 1);
    return ans;
}
int main(){
    long long N;
    cin >> N;
    long long X;
    cin >> X;
    dp.resize(N + 1), paty.resize(N + 1);
    dp[0] = 1;
    paty[0] = 1;
    for(int i = 1; i < N + 1; i++){
        dp[i] = dp[i - 1] * 2 + 3;
        paty[i] = paty[i - 1] * 2 + 1;
    }
    cout << dfs(N, X) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void) {
  int A, B, ans, i;

  ans = 0;
  
  scanf ("%d %d", &A, &B);
  
  for (i = 0; i < 2; i++) {
    if (A > B) {
      ans = ans + A;
      A--;
      } else {
      ans = ans + B;
      B--;
      }
    }

    printf ("%d", ans);
    
    return 0;
}

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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

signed main() {
    long long h, w, ans = 0;
    cin >> h >> w;
    vector<vector<char>> as(h, vector<char>(w));
    vector<vector<long long>> dp(h, vector<long long>(w));
    REP(i, h) {
        REP(j, w) { cin >> as[i][j]; }
    }
    dp[0][0] = 1;
    REP(i, h) {
        REP(j, w) {
            if (as[i][j] == '#') {
                continue;
            }
            if (i == 0 && j == 0) {
                continue;
            }
            if (i == 0) {
                dp[i][j] = dp[i][j - 1];
                dp[i][j] %= mod;
                continue;
            }
            if (j == 0) {
                dp[i][j] = dp[i - 1][j];
                dp[i][j] %= mod;
                continue;
            }
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
            dp[i][j] %= mod;
        }
    }
    cout << dp[h - 1][w - 1] << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> p(N + 1);
  for (int i = 1; i <= N; ++i)
    cin >> p[i];

  string ans = "NO";
  int count = 0;
  for (int k = 1; k <= N; ++k)
    if (p[k] == k)
      ++count;
  if (count == N)
    ans = "YES";

  for (int i = 1; i <= N; ++i) {
    for (int j = i + 1; j <= N; ++j) {
      vector<int> p2 = p;
      swap(p2[i], p2[j]);
      int count = 0;
      for (int k = 1; k <= N; ++k)
        if (p2[k] == k)
          ++count;
      if (count == N)
        ans = "YES";
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, n) for (int i = 1; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    
    int ans = -1000, d = 1000000;
    for (int i = -100; i < 200; ++i) {
        bool flag = true;
        rep(j, N) {
            if (i == p[j]) flag = false;
        }
        if (flag) {
            if (abs(i - X) < d) {
                ans = i;
                d = abs(i - X);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void)
{    
    ll k, s;
    cin >> k >> s;
    ll r = 0;
    
    rep(i, k+1) {
        rep(j, k+1) {
            if(s-i-j >= 0 && s-i-j <= k) r++;
        }
    }
    
    mes(r);
	
    
    
    
    
    
    
    
    
    
}

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

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    int m, p, d;
    cin >> m >> p >> d;
    vector<string> draw(d);
    for (int i = 0; i < d; ++i)
      cin >> draw[i];

    int pos = m;
    for (int i = 0; i < d; ++i) {
      if (pos-2 >= 0 && draw[i][pos-2] == '1')
	--pos;
      else if (pos-1 < n-1 && draw[i][pos-1] == '1')
	++pos;
    }

    if (pos == p) {
      cout << "0" << endl;
      continue;
    }

    bool reach = false;
    for (int i = 0; i < d && !reach; ++i) {
      for (int j = 0; j < n-1 && !reach; ++j) {
	if (draw[i][j] != '0')
	  continue;

	if ((j-1 < 0 || draw[i][j-1] == '0') &&
	    (j+1 >= n-1 || draw[i][j+1] == '0')) {
	  draw[i][j] = '1';

	  pos = m;
	  for (int k = 0; k < d; ++k) {
	    if (pos-2 >= 0 && draw[k][pos-2] == '1')
	      --pos;
	    else if (pos-1 < n-1 && draw[k][pos-1] == '1')
	      ++pos;
	  }
	  
	  if (pos == p) {
	    cout << i+1 << " " << j+1 << endl;
	    reach = true;
	  }
	  draw[i][j] = '0';
	}
      }
    }

    if (!reach)
      cout << "1" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int, input().split()))

flag = True
for i in range(n):
    if a[i] % 2 == 0 and (a[i] % 3 != 0 and a[i] % 5 != 0):
        flag = False
if flag:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
s = input()
a = 'abcdefghijklmnopqrstuvwxyz'
b = [i for i in a if i not in s]
if s == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
elif b:
    print(s + b[0])
else:
    for i in range(1, len(s) + 1):
        if s[-i:][0] != sorted(s[-i:], reverse=True)[0]:
            b = [j for j in a if j not in s[:-i+1] and j > s[-i:][0]][0]
            if i == 26:
                print(chr(ord(s[0]) + 1))
            else:
                print(s[:-i] + b)
            break


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
char s[110];
int n,cur,maxn;
int main()
{
    cin>>n>>s;
    for(int i=0;i<n;++i)
    {
        if(s[i]=='I') cur++;
        else cur--;
        maxn=max(maxn,cur);
    }
    cout<<maxn<<endl;
    return 0;
}

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

using namespace std;
#define ll long long

vector<int> A;

int N;

void dfs(ll &ans, ll current_num, bool seven, bool five, bool three){
    if(current_num > N){
        return;
    }

    if(seven && five && three) ans++;

    dfs(ans, current_num * 10 + 7, true, five, three);
    dfs(ans, current_num * 10 + 5, seven, true, three);
    dfs(ans, current_num * 10 + 3, seven, five, true);
}

int main(void){
    cin >> N;

    ll ans = 0;
    dfs(ans, 0, false, false, false);

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

Measured memory_bytes: 256
//package Contest042;

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static  void main(String []args)
    {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
            int n = sc.nextInt();
            out.println(( (n*(n+1))/2));
        out.close();
    }
}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main()
{
  string s,t;
  int i,count=0;
  cin>>s;
  cin>>t;
  for(i=0; i<s.size(); i++)
  {
    if(s[i]==t[i])
      count++;
  }
  cout<<count;
  return 0;
}
    

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

//gcdをユークリッド互除法で求める。O(log n)
int euclid(int x, int y){
    if(min(x, y) ==  0) return max(x, y);
    else return euclid(max(x, y)% min(x, y) , min(x, y));
}
//

int main() {
	ll ans = 0;
	int tmp;
	int a, b;
	cin >> a >> b;
	int g = euclid(a,b);
	ans = (ll)a / g;
	ans *= (ll)b;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <bitset>
using namespace std;
inline int read(void){
	int x = 0 ; char c = getchar() ;bool f = 0; 
	while(c > '9' || c < '0') f |= (c=='-') ,c = getchar();
	while(c <= '9' && c >= '0') x = x * 10 + c - '0' , c = getchar();
	return f? -x : x;
}
const int N = 4e2+5, M = 1e5+5;
bitset<N> s[N];
int n, m, u[M], v[M], d[N], ans;
int main()
{
    n = read(), m = read();
    for(int i = 1; i <= m; ++i) u[i] = read(), v[i] = read();
    for(int i = 1; i <= n; ++i)
    {
        s[i][i] = 1;
        for(int j = m; j; --j)
            if(s[i][u[j]]&&s[i][v[j]]) d[i] = 1, j = 1;
            else if(s[i][u[j]]) s[i][v[j]] = 1;
            else if(s[i][v[j]]) s[i][u[j]] = 1;
    }
    for(int i = 1; i <= n; ++i)
    {
        if(d[i]) continue;
        for(int j = i+1; j <= n; ++j)
            if(!d[j]&&(s[i]&s[j]).none()) ++ans;
    }
    printf("%d\n", ans);
    return 0;
}//orzlch 

Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma optimization_level 3
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define pb push_back 
#define f first
#define s second
#define min3(a, b, c) min(min(a, b), c)
#define max3(a, b, c) max(max(a, b), c)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

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

const int INF = 1e9;
//const ll INF = 1e18;
const ll mod = 1000000007;
// const ll mod = 998244353;

void solve(int tc){
	int n;
	cin >> n;
	vector<ld> p(n+1);
	for(int i = 1; i <= n; i++)
		cin >> p[i];

	vector<vector<ld>> dp(n+1, vector<ld>(n+1, 0));

	dp[0][0] = 1;
	for(int i = 1; i <= n; i++)
		dp[0][i] = dp[0][i-1]*(1-p[i]);

	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			dp[i][j] = p[j]*dp[i-1][j-1] + (1-p[j])*dp[i][j-1];
	ld ans = 0;
	for(int i = n/2 + 1; i <= n; i++)
		ans += dp[i][n];

	cout << fixed << setprecision(10) << ans << "\n";
}

int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	
	int tc = 1;
	//cin >> tc;
	for (int t = 0; t < tc; t++) solve(t);

	return 0;
}

Measured memory_bytes: 73704
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B;
    cin>>A>>B;
    int ans=A+B;
    int ans1=A-B;
    int ans2=A*B;
    if(ans>=ans1&&ans>=ans2)
    {
        cout<<ans<<endl;
    }
    else if(ans1>=ans&&ans1>=ans2)
    {
        cout<<ans1<<endl;
    }
    else
    {
        cout<<ans2<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<unordered_map>

int main(void)
{
  std::string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  std::unordered_map<char, int> charToIndex;
  for(int index = 0; alphabet.size() > index; ++index)
  {
    charToIndex.emplace(alphabet.at(index), index);
  }
  alphabet += alphabet;
  
  int n = 0;
  std::cin >> n;
  std::string str;
  std::cin >> str;
  for(char c : str)
  {
    std::cout << alphabet[charToIndex.at(c) + n];
  }
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  string ans = "Yes";
  if (A % 2 == 0 || B % 2 == 0) {
    ans = "No";
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
		int n;
		cin>>n;
		int b[n-1];
		for(int i=0;i<n-1;i++)
		{
				cin>>b[i];
		}
		int sum=0;
		sum+=b[0];
		for(int i=1;i<n-1;i++)
		{
				sum+=min(b[i-1],b[i]);
		}
		sum+=b[n-2];
		cout<<sum;
}

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

#define each(i, c) for (auto& i : c)

typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x * y) / gcd(x, y);
}

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

  vector<ll> a(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
    a[i] /= 2;
  }

  ll l = a[0];
  for (ll i = 1; i < n; ++i) {
    l = lcm(l, a[i]);
  }
  
  each (i, a) {
    if ((l / i) % 2 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  cout << ((m / l) + 1) / 2 << endl;

  return 0;
}

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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

int main() {
  cout << setprecision(18);
  u64 N;
  cin >> N;
  set<string> S;
  for (u32 i = 0; i < N; ++i) {
    string tmp;
    cin >> tmp;
    S.insert(tmp);
  }
  cout << S.size() << endl;
  return 0;
}

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

int main() {
	long long n,a,b,ans;
	cin >> n >> a >> b;
	ans=a*(n/(a+b));
	n-=(a+b)*(n/(a+b));
	ans+=min(a,n);
	cout << ans << endl; 
	return 0;
}

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


int main()
{
    int n, ans = 0, ma = -1;
    cin >> n;
    vector<int> k(n);
    for(int i = 0;i < n;i++){
        cin >> k[i];
        ma = max(ma,k[i]);
    }

    for(int i = 0;i < ma;i++){
        int cnt = 0;
        
        for(int j = 0;j < n - 1;j++){
            if(k[j] == 0 && k[j + 1] != 0) cnt++;
        }

        if(cnt % 2 == 0){
            if(k[0] != 0){
                cnt++;
            }
        }
        else{
            if(k[0] != 0){
                cnt++;
            }
        }

        for(int j = 0;j < n;j++){
            if(k[j] - 1 < 0){

            }
            else{
                k[j]--;
            }
        }

        ans += cnt;
    }

    cout << ans;

    return 0;
}


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

public class Main {
    static final int mod = (int) (1e9 + 7);

    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt(), k = sc.nextInt();
        int[] cnt = new int[k + 1];
        int ans = 0;
        for (int i = k; i > 0; i--) {
            cnt[i] = modPow(k / i, n);
            for (int j = i + i; j <= k; j += i)
                cnt[i] = add(cnt[i], -cnt[j]);
            ans = add(ans,mult(i,cnt[i]));
        }
        out.println(ans);
        out.flush();
        out.close();
    }

    static int modPow(int b, int e) {
        int res = 1;
        while (e > 0) {
            if (e % 2 != 0) res = mult(res, b);
            b = mult(b, b);
            e >>= 1;
        }
        return res;
    }

    static int add(int a, int b) {
        int c = a + b;
        if (c >= mod) c -= mod;
        if (c < 0) c += mod;
        return c;
    }

    static int mult(long a, int b) {
        return (int) (a * b % mod);
    }

    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        boolean ready() throws IOException {
            return br.ready();
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        int nextChar() throws IOException {
            return next().charAt(0);
        }

        int[] nextIntArray(int n) throws IOException {
            int[] ans = new int[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextInt();
            return ans;
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

    }
}


Measured memory_bytes: 33348
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<stack>
#include<queue>

using namespace std;

int bubble_sort(int *a, int n)
{
	bool flag = true;
	int cou = 0;
	while (flag) {
		flag = false;
		for (int j = n - 1; j >= 1; j--) {
			if (a[j] < a[j - 1]) {
				int k = a[j];
				a[j] = a[j - 1];
				a[j - 1] = k;
				flag = true;
				cou++;
			}
		}
	}
	return cou;
}

int main()
{
	int n;
	cin >> n;
	int a[105];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = bubble_sort(a, n);

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

	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

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

int X,Y;
const int MOD = 1000000007;
const int MAX = 1000100;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main()
{
	cin >> X >> Y;

	int a = -1, b = 0;

	{
		pair<int, int> p(0, 0);

		int a_ = 0, b_ = 0;
		while ((X - p.first) * 2 > Y - p.second) {
			p.first += 2;
			p.second += 1;
			a_++;
		} 

		if ((X - p.first) * 2 == Y - p.second) {
			b_ += X - p.first;

			a = a_;
			b = b_;
		}
	}

	{
		pair<int, int> p(0, 0);

		int a_ = 0, b_ = 0;
		while ((Y - p.second) * 2 > X - p.first) {
			p.second += 2;
			p.first += 1;
			a_++;
		} 

		if ((Y - p.second) * 2 == X - p.first) {
			b_ += Y - p.second;

			a = a_;
			b = b_;
		}
	}

	if (a == -1) {
		cout << 0 << endl;
		return 0;
	}

	COMinit();
	cout << COM(a + b, a) << endl;
}


Measured memory_bytes: 23680
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		ArrayList<Integer> x = new ArrayList<Integer>();
		ArrayList<Integer> y = new ArrayList<Integer>();
		ArrayList<Integer> z = new ArrayList<Integer>();
		int[][] in = new int[n][6];
		for(int i=0;i<n;i++){
			for(int j=0;j<6;j++){
				in[i][j] = sc.nextInt();
				if(j%3==0 && !x.contains(in[i][j])) x.add(in[i][j]);
				else if(j%3==1 && !y.contains(in[i][j])) y.add(in[i][j]);
				else if(j%3==2 && !z.contains(in[i][j])) z.add(in[i][j]);
			}
		}
		Collections.sort(x);
		Collections.sort(y);
		Collections.sort(z);
		
		int xc = x.size();
		int yc = y.size();
		int zc = z.size();
		long[][][] cnt = new long[zc][yc][xc];
		
		for(int i=0;i<n;i++){
			int x1 = x.indexOf(in[i][0]);
			int y1 = y.indexOf(in[i][1]);
			int z1 = z.indexOf(in[i][2]);
			int x2 = x.indexOf(in[i][3]);
			int y2 = y.indexOf(in[i][4]);
			int z2 = z.indexOf(in[i][5]);
			for(int a=z1;a<z2;a++){
				for(int b=y1;b<y2;b++){
					for(int c=x1;c<x2;c++){
						cnt[a][b][c]++;
					}
				}
			}
		}
		
		long ans = 0;
		for(int i=0;i<zc-1;i++){
			for(int j=0;j<yc-1;j++){
				for(int s=0;s<xc-1;s++){
					if(cnt[i][j][s]>=k){
						long xx = x.get(s+1)-x.get(s);
						long yy = y.get(j+1)-y.get(j);
						long zz = z.get(i+1)-z.get(i);
						ans += xx*yy*zz;
					}
				}
			}
		}
		System.out.println(ans);
	}	
}

Measured memory_bytes: 32256
import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int x = sc.nextInt();
        int num500 = x / 500;
      	int num50 = x % 500 / 5;
      	System.out.println(num500 * 1000 + num50 * 5);
    }
 }

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

void Main()
{
	int A, B;
	cin >> A >> B;
	int l_max = A + B;
	l_max = max(l_max, A - B);
	l_max = max(l_max, A * B);
	cout << l_max;
}
 
int main()
{
	Main();
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = 0;
        int b = 0;
        char[] s = sc.next().toCharArray();
        for (char c : s) {
            if(c == 'R') r++;
            else b++;
        }

        System.out.println(r > b ? "Yes" : "No");
        sc.close();
    }

}


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

int main() {
int64_t A, B, C, X, Y;
cin >> A >> B >> C >> X >> Y;
C *= 2;
int Apiza, Bpiza, Cpiza;
  
const int64_t zero = 0;
int64_t nedan = 0;
int64_t ans = 9223372036854775806;
for( int64_t i = 0; i < 100001; i++ ){
    nedan = C*i + A*max(zero, X-i) + B*max(zero, Y-i);
    if( ans > nedan ){
      ans = nedan;
       Apiza = max(zero, X-i);
		Bpiza = max(zero, Y-i);
  		Cpiza = i*2;
    }
}
cout << ans << endl;
 // cout << Apiza << endl;
  //cout << Bpiza << endl;
  //cout << Cpiza << endl;
}


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

using namespace std;

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

// GCD(a, b) x LCM(a, b) = ab
// LCM(a, b, c) = LCM(LCM(a, b), c)
int main() {
  int n;
  cin >> n;
  int a;
  int lcm = 1;
  for (int i = 0; i < n; i++) {
    cin >> a;
    int g = gcd(lcm, a);
    lcm = lcm * a / g;
  }
  cout << lcm << endl;
  return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define fi first
#define se second
#define NAME "data"
using namespace std;
typedef long long LL;
typedef double DB;
typedef pair <LL, LL> pLL;
const int NMAX = 1e5+3;


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(NAME".inp", "r", stdin);
    //freopen(NAME".out", "w", stdout);
    int a, b, c, n, res = 0;
    cin >> a >> b >> c >> n;
    for(int i = 0; i <= n; ++i)
    for(int j = 0; j <= n; ++j) {
        int x = n - a*i - b*j;
        if(x >= 0 && x%c == 0) res++;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,a,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    hin(a);
  }
  for(i=a=0;i<n;i++){
    if(i%2==hout()%2)a++;
  }
  printf("%d\n",a/2);
  return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    m += (m == 100);
    if(!n)cout << m << endl;
    else cout << m * (intl)pow(100,n) << endl;
    return 0;
}

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

#define first  fs
#define second se
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, char s = '\n') { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	string s;

	cin >> s;

	int a = 0;
	while (s[a] != 'A') a++;
	int b = s.size();
	while (s[--b] != 'Z');

	cout << b - a + 1 << endl;

}



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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long x = long.Parse(Console.ReadLine());
            long result = 0;
            long yokin = 100;
            while (x > yokin)
            {
                yokin += yokin / 100;

                result++;
            }
            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27500
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	bool bj=0;
	while(n >= 0)
	{
		if(n%4 == 0)
		{
			bj = 1;
			break;
		}
		n -= 7;
	}
	if(bj)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);

int main() {
	int n;
	int ans = 0;
	cin >> n;
	rep(i, n) { cout << "ACL"; }
	cout << endl;
}


Measured memory_bytes: 3632
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100;
int n;
int a[MAX_N];

int main() {
  cin >> n;
  rep(i,n) cin >> a[i];

  ll ans = 0, sum = 0;
  rep(i,n) sum += a[i];
  ll x = sum / n;

  ll t = 0;
  rep(i,n) t += (x-a[i]) * (x-a[i]);
  ans = t;
  ++x; t = 0;
  rep(i,n) t += (x-a[i]) * (x-a[i]);
  ans = min(ans, t);

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main(void)
{
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for(int &x : h){
    cin >> x;
  }
  sort(h.begin(), h.end());
  int min = h[K-1] - h[0];
  for(int i = 0; i < N - K + 1; i++){
    int sub = h[i+K-1] - h[i];
    if(sub < min){
      min = sub;
    }
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

#define MAX_LENGTH 32

int main(void)
{
        char line[MAX_LENGTH];
        int a,b;
        double da,db;

        fgets(line, sizeof(line), stdin);
        sscanf(line, "%lf %lf", &da, &db);
        a = da;
        b = db;

        printf("%d ", a / b);
        printf("%d ", a % b);
        printf("%lf\n", da / db);

        return 0;
}

Measured memory_bytes: 656