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

constexpr int inf = 1e9;

int main() {
    int n; cin >> n;
    vector<vector<int>> d(n, vector<int>(n, inf));
    for(int i = 0; i < n; ++i) {
        string s; cin >> s;
        d[i][i] = 0;
        for(int j = 0; j < n; ++j) {
            if(s[j] == '1') {
                d[i][j] = 1;
            }
        }
    }

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

    int ans = -1;
    for(int i = 0; i < n; ++i) {
        int tans = 0;
        vector<vector<int>> vvs(n);
        for(int j = 0; j < n; ++j) {
            tans = max(tans, d[i][j]);
            if(j != i) {
                vvs[d[i][j]].push_back(j);
            }
        }
        bool check = true;
        for(auto const& vs : vvs) {
            const int sz = vs.size();
            for(int j = 0; j < sz; ++j) {
                for(int k = j + 1; k < sz; ++k) {
                    check &= d[vs[j]][vs[k]] != 1;
                }
            }
        }
        if(check) {
            ans = max(ans, tans + 1);
        }
    }
    cout << ans << endl;
}


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

int field[101][101];
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
int heights[] = {2, 4};
int widths[] = {4, 2};
int w, h;
int gx, gy;

bool isMaze(int y, int x) {
    if (y == gy && x == gx) {
        return true;
    }
    int c = field[y][x];
    field[y][x] = 0;
    for (int i = 0; i < 4; i++) {
        int ny = y + dy[i], nx = x + dx[i];
        if (1 <= ny && ny <= h && 1 <= nx && nx <= w && field[ny][nx] == c && isMaze(ny, nx)) {
            return true;
        }
    }
    return false;
}

int main() {
    while (true) {
        cin >> w >> h;
        if ((w | h) == 0) {
            break;
        }
        int sx, sy, n;
        cin >> sx >> sy >> gx >> gy >> n;
        memset(field, 0, sizeof(field));
        while (n--) {
            int c, d, x, y;
            cin >> c >> d >> x >> y;
            for (int i = 0; i < heights[d]; i++) {
                for (int j = 0; j < widths[d]; j++) {
                    field[y + i][x + j] = c;
                }
            }
        }
        if (field[sy][sx] > 0 && field[sy][sx] == field[gy][gx] && isMaze(sy, sx)) {
            cout << "OK" << endl;
        } else {
            cout << "NG" << endl;
        }
    }
}

Measured memory_bytes: 0
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

alias sread = () => readln.chomp();

void main()
{
    long[101][101] m;
    foreach (ref r; m)
        r[] = long.max;

    long N = lread;

    long[][] xyh;
    long[] g;
    foreach (i; 0 .. N)
    {
        auto tmp = aryread;
        xyh ~= tmp;
        if (1 <= tmp[2])
        {
            g = tmp;
        }
    }

    long[][] results;

    foreach (cx; 0 .. 101)
        foreach (cy; 0 .. 101)
        {
            auto gh = abs(g[0] - cx) + abs(g[1] - cy) + g[2];
            bool flag = true;
            foreach (q; xyh)
            {
                auto qh = gh - abs(q[0] - cx) - abs(q[1] - cy);
                qh = max(qh, 0);
                if (qh != q[2])
                {
                    flag = false;
                }
            }
            if (flag)
            {
                results ~= [cx, cy, gh];
            }
        }

    if (results.length == 1)
    {
        auto r = results[0];
        writefln("%d %d %d", r[0], r[1], r[2]);
    }
    else
    {
        writeln(results);
        throw new Error("");
    }
    // writefln("%d %d %d", X, Y, H);
}


Measured memory_bytes: 380
while True:
    m,f,r=map(int,input().split())
    if (m == -1 and f == -1 and r == -1):
        break
    if (m == -1 or f == -1):
        print("F")
    elif (80 <= m+f <= 100):
        print("A")
    elif (65 <= m+f):
        print("B")
    elif (50 <= m+f):
        print("C")
    elif (30 <= m+f):
        if (50 <= r):
            print("C")
        else:
            print("D")
    elif (m+f < 30):
        print("F")



Measured memory_bytes: 5596
num = int(input())
P =[]
L = [[],[],[]]
for _ in range(num):
    p = [int(x) for x in input().split()]
    P.append(p)
    for i in range(3):
        L[i].append(p[i])

for p in P:
    sum = 0
    for i in range(3):
        if L[i].count(p[i]) < 2:
            sum += p[i]
    print(sum)



Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

using P = pair<int, int>;

int dist(P a, P b)
{
    return abs(a.first - b.first) + abs(a.second - b.second);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    for (int i = 0; i < h; i++)
    {
        cin >> grid[i];
    }
    vector<P> rec;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (grid[i][j] == 'B')
            {
                rec.push_back(P(i, j));
            }
        }
    }
    int n = rec.size();
    int ans = 0;
    sort(ALL(rec));
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            chmax(ans, dist(rec[i], rec[j]));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3184
import sys
sys.setrecursionlimit(10**7)

def dfs(u, g, visited):
    if (visited[u]): return 0
    visited[u] = True

    res = 1
    for v in g[u]:
        res += dfs(v, g, visited)

    return res


def main():
    n,m = map(int, input().split())
    g = [ [] for _ in range(n+1) ]
    for _ in range(m):
        a,b = map(int, input().split())
        g[a].append(b)
        g[b].append(a)

    visited = [False] * (n+1)
    ans = 0;
    for i in range(1, n+1):
        if (visited[i]): continue
        ans = max(ans, dfs(i, g, visited))

    print(ans)

main()


Measured memory_bytes: 222024
def ABC_161_B():
    N,M = map(int, input().split())
    A = list(map(int, input().split()))

    count = 0
    sum = 0

    for i in range(N):
        sum += A[i]

    for i in range(N):
        if A[i] >= (sum/(4*M)):
            count += 1

    if count >= M:
        print('Yes')
    else:
        print('No')
        
if __name__ == '__main__':

    ABC_161_B()

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var K, A, B int
	fmt.Scan(&K, &A, &B)
	for i := A; i <= B; i++ {
		if i%K == 0 {
			fmt.Println("OK")
			return
		}
	}
	fmt.Println("NG")
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    int n;
    cin >> n;
    if (n%10 == 3) cout << "bon" << endl;
    else if (n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
    return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> ans;
    int sum = 0;
    
    for(int i = 1; i <= n; ++i) {
        if(sum + i < n) {
            ans.push_back(i);
            sum += i;
        } else {
            if(sum + i == n) {
                ans.push_back(i);
                break;
            } else {
                int dif = sum + i - n;
                ans[dif - 1] = i;
                break;
            }
        }
    }

    for(auto temp : ans)
        cout << temp << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d,e;
    while(scanf("%lld",&a)==1)
    {
        cin>>b>>c;
        d=a-b;
        e=d%c;
        cout<<e<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
c = [0]*(n-1)
s = [0]*(n-1)
f = [0]*(n-1)

for i in range(n-1):
    c[i], s[i], f[i] = map(int, input().split())

def dfs(eki,t):
    if eki == n-1:
        return t

    cc = c[eki]
    ss = s[eki]
    ff = f[eki]

    m = max(0,-(-t+ss)//ff)
    if t < ss:
        return dfs(eki+1, ss+cc)
    else:
        return dfs(eki+1, -(-t//ff)*ff+cc)

for i in range(n):
    print(dfs(i,0))


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

int main() {
  int n;
  cin >> n;
  int cnt;
  int res = 0;
  
  for (int i = 1; i <= n; i += 2) {
    cnt = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) {
        cnt++;
      }
    }
    if (cnt == 8) {
      res++;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
N,K=(int(i) for i in input().split())
h = [int(i) for i in input().split()]
c = [0]*N
for i in range(1,N):
    jumpmax = min(i,K)
    c[i] = min([abs(h[i]-h[i-j])+c[i-j] for j in range(1,jumpmax+1)])
print(c[N-1])

Measured memory_bytes: 52576
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll INF=1e15;
const int MAX_N=1<<18;

int m;
ll dat[2][2*MAX_N-1];
 
void init(int m_){
	m=1;
	while(m<m_) m*=2;
	for(int i=0; i<2*m-1; i++){
		dat[0][i]=INF;
		dat[1][i]=INF;
	}
}
 
void update(int i, int k, ll a){
	k+=m-1;
	dat[i][k]=a;
	while(k>0){
		k=(k-1)/2;
		dat[i][k]=min(dat[i][k*2+1], dat[i][k*2+2]);
	}
}

ll query(int i, int a, int b, int k, int l, int r){
	if(r<=a || b<=l) return INF;
	if(a<=l && r<=b){
		return dat[i][k];
	}else{
		ll vl=query(i, a, b, k*2+1, l, (l+r)/2);
		ll vr=query(i, a, b, k*2+2, (l+r)/2, r);
		return min(vl, vr);
	}
}

int main()
{
	int n, q, a, b;
	cin>>n>>q>>a>>b;
	a--; b--;
	init(n);
	ll dp[200001];
	fill(dp, dp+n, INF);
	int x[200001];
	for(int i=0; i<q; i++){
		cin>>x[i];
		x[i]--;
	}
	if(q==1){
		cout<<min(abs(x[0]-b), abs(x[0]-a))<<endl;
		return 0;
	}
	dp[a]=min(dp[a], (ll)abs(x[0]-b));
	dp[b]=min(dp[b], (ll)abs(x[0]-a));
	update(0, a, dp[a]-a);
	update(1, a, dp[a]+a);
	update(0, b, dp[b]-b);
	update(1, b, dp[b]+b);
	for(int i=1; i<q; i++){
		ll mn=query(0, 0, x[i]+1, 0, 0, m)+(ll)x[i]-(ll)abs(x[i]-x[i-1]);
		mn=min(query(1, x[i], n, 0, 0, m)-(ll)x[i]-(ll)abs(x[i]-x[i-1]), mn);
		dp[x[i-1]]=min(dp[x[i-1]], mn);
		update(0, x[i-1], dp[x[i-1]]-x[i-1]);
		update(1, x[i-1], dp[x[i-1]]+x[i-1]);
	}
	ll s=0;
	for(int i=1; i<q; i++) s+=(ll)abs(x[i]-x[i-1]);
	ll ans=INF;
	for(int i=0; i<n; i++){
		ans=min(ans, dp[i]+s);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10752
// author:-*mdragneell*

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

#define ll long long
#define ld long double
#define pb push_back
#define pi  pair<int,int>
#define pl  pair<ll,ll>

int const N=1001;
ll min(ll x,ll y) { if(x<y) return x; else return y; }
ll max(ll x,ll y) { if(x>y) return x; else return y; }

ll cache[N][N],n,m;
char a[N][N];
ll mod=1e9+7;

ll paths(ll i,ll j)
{
	if(i==1&&j==1&&a[i][j]=='.') return 1;
	if(cache[i][j]!=-1) return cache[i][j];
	if(a[i][j]=='#') return 0;

	ll temp=0;

	if(i==1) return temp=paths(i,j-1)%mod;
	else if(j==1) return temp=paths(i-1,j)%mod;

	else temp=(paths(i-1,j)+paths(i,j-1))%mod;
	return cache[i][j]=temp;


}



int main()
{
	ll i,j;
	cin>>n>>m;
	memset(cache,-1,sizeof(cache));
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			cin>>a[i][j];

	cout<<paths(n,m)<<endl;

}


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

using namespace std;
typedef long long ll;

#define out(ans) cout << ans << endl
#define in(n) cin >> n
#define floop(i, N) for (ll i = 0; i < N; i++)
#define floop1(i, N) for (ll i = 1; i <= N; i++)
#define floopi(i, j, N) for (ll j = i + 1; j < N; j++)

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

constexpr ll inf = 1e18;

void solve();

int main()
{
    solve();
}

void solve()
{
    ll n;
    in(n);
    ll a[n][3];
    floop(i, n)
    {
        floop(j, 3)
        {
            in(a[i][j]);
        }
    }
    ll dp[n + 1][3];
    floop(i, n + 1)
    {
        floop(j, 3)
        {
            dp[i][j] = 0;
        }
    }
    floop(i, n)
    {
        floop(j, 3)
        {
            floop(k, 3)
            {
                if (j == k)
                {
                    continue;
                }
                chmax(dp[i + 1][j], dp[i][k] + a[i][j]);
            }
        }
    }
    ll ans = 0;
    floop(i, 3)
    {
        chmax(ans, dp[n][i]);
    }
    out(ans);
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 100;
const ll inf = 2e18, mod = 1e9 + 7;

int h, w, d[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
char a[maxn][maxn];
bool vis[maxn][maxn];

bool isValid(int x, int y)
{
	if (0 <= x && x < h)
		return (0 <= y && y < w);
	return false;
}

void dfs(int x, int y)
{
	vis[x][y] = true;
	int nowx, nowy;
	for (int i = 0; i < 4; i++)
	{
		nowx = x + d[i][0];
		nowy = y + d[i][1];
		if (isValid(nowx, nowy) && !vis[nowx][nowy])
			dfs(nowx, nowy);
	}
}

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

	cin >> h >> w;
	for (int i = 0; i < h; i++)
		cin >> a[i];
	
	int cnt = 0, comp = 0;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cnt += (a[i][j] == '#');
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (a[i][j] == '#' && !vis[i][j])
				dfs(i, j), comp++;
	cout << ((cnt == h + w - 1 && comp == 1) ? "Possible" : "Impossible") << endl;
}



Measured memory_bytes: 256
import numpy as np

N = int(input())
T, A = map(int, input().split())
H = [int(i) for i in input().split()]
H = np.array(H)

C = T - H*0.006
A = np.ones_like(H)*A

delta = C - A
delta = delta**2

print(np.argmin(delta) + 1)

Measured memory_bytes: 21900
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,k;
  	ci(n>>k);
  if(n>=2*k-1) co("YES")
    else co("NO")
    }

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

int main() {
	int n;
	cin >> n;

	long res = 0;

	unordered_map<int, int> count;

	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		count[a]++;
	}

	for (auto && kv : count) {
		if (kv.first <= kv.second) {
			res += kv.second - kv.first;
		} else {
			res += kv.second;
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 4260
// Template Headers {{{
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<long long>; using vvll = vector<vll>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}
// Preprocessing & "Global" variables {{{
struct Solver {
	Solver() {}
	int solve();
};
// }}}


int Solver::solve() {
	string s, t; cin >> s >> t;
	if (s.length() < t.length()) swap(s, t);
	int n = s.size() + t.size();
	int l = 0, r = 0;
	for (int i = 0; i < n; i++) {
		if (i & 1)
			cout << t[r++];
		else
			cout << s[l++];
	}
	cout << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	Solver solver;
	#ifdef JUDGE_MULTI_CASE
		int t; cin >> t; for (int i = 1; i <= t; i++)
	#endif
	solver.solve();
	// cout << "Case #" << i << ": ", solver.solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


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

int n, m, p, x, y, ac[100005], wa[100005];
char s[5];
int main() {
	cin>> n>> m;
	while(m--) {
		scanf("%d %s", &p, s);
		if(s[0]=='A' && !ac[p]) ac[p] = 1;
		else if(s[0]=='W' && !ac[p]) wa[p]++;
	}
	for(int i=1; i<=n; i++) {
		x += ac[i]==1;
		if(ac[i]) y += wa[i];
	}
	cout<< x<< ' '<< y;
	return 0;
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int ue[n],sita[n];
    rep(i,0,n) cin >> ue[i];
    rep(i,0,n) cin >> sita[i];
    int ans=0;
    rep(i,0,n){
        bool ss = true;
        int tmp = 0;
        rep(j,0,n){
            if(ss) tmp += ue[j];
            else tmp += sita[j];
            if(i==j){ ss = false; tmp += sita[j]; }
        }
        ans = max(ans,tmp);
    }
    cout << ans << endl;

}

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

long long A[300005];

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

    for(int i=1; i<=3*N; i++)
        cin >> A[i];

    sort(A+1, A+1+N*3);

    long long ans = 0;

    for(int i=3*N-1; i>=N; i-= 2)
        ans += A[i];

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


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

int main(){
    int n;
    
    while(cin >> n,n){
        int h,m,dm,lcnt=0,dcnt=0,mcnt = 0,ll=0,dd=0,mm=0;
        for(int i = 0 ; i < n ; i++){
            scanf("%d:%d %d" ,&h ,&m ,&dm);
            if((2 <= h && h < 11) || (15 <= h && h < 18)) continue;
            if(h < 2) h += 24;
            int t = h*60+m,dt = h*60+dm;
            if(dt < t) dt += 60;
            int a = dt-t;
        
            if(11 <= h && h <= 14){
                lcnt++;
                if(a <= 8) ll++;
            }
            else if(18 <= h && h <= 20){
                dcnt++;
                if(a <= 8) dd++;
            }
            else if(21 <= h && h <= 25){
                mcnt++;
                if(a <= 8) mm++;
            }
        }
        if(!lcnt) cout << "lunch no guest" << endl;
        else cout << "lunch " << ll*100/lcnt << endl;
        if(!dcnt) cout << "dinner no guest" << endl;
        else cout << "dinner " << dd*100/dcnt << endl;
        if(!mcnt) cout << "midnight no guest" << endl;
        else cout << "midnight " << mm*100/mcnt << endl;
    }
    
    return 0;             
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
#define ll long long
#define repd(i, st, ed) for (int i = (st); i <= (ed); ++i)
int n;
int m;
std::vector<int> v[maxn];
ll path[maxn];
void dfs(int x, int pre, ll num)
{
    path[x] = num;
    for (auto y : v[x])
    {
        if (y == pre)
        {
            continue;
        }
        dfs(y, x, num | (1ll << y));
    }
}
ll info[maxn];
int readint() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}

int main()
{
    //freopen("D:\\code\\text\\input.txt","r",stdin);
    //freopen("D:\\code\\text\\output.txt","w",stdout);
    n = readint();
    repd(i, 1, n - 1)
    {
        int x = readint();
        int y = readint();
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1, 0, 0ll);
    m = readint();
    repd(i, 0, m - 1)
    {
        int x = readint();
        int y = readint();
        info[i] = (path[x] ^ path[y]);
    }
    int maxstate = (1 << m) - 1;
    ll ans = 0ll;
    repd(i, 0, maxstate)
    {
        ll num = 0ll;
        int cnt = 0;
        repd(j, 0, m - 1)
        {
            if (i & (1 << j)) {
                cnt++;
                num |= info[j];
            }
        }
        int free = n - 1 - __builtin_popcountll(num);
        ans += (1ll << free) * (cnt & 1 ? -1ll : 1ll);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double LD; 
typedef long long ll; 
#define int ll 
#define ff(i,a,b) for (int i = a; i < b; i++) 
#define bf(i,a,b) for (int i = a; i >= b; i--) 
#define all(v) v.begin(),v.end() 
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define F first 
#define S second
#define pb push_back
#define mp make_pair
#define lb lower_bound   
#define ub upper_bound
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define one cout<<"-1"<<endl
#define pi 3.141592653589793238
#define intmx INT_MAX 
#define intmi INT_MIN
#define MOD 1000000007
int mod(int x){
    return ((x%MOD + MOD)%MOD);
}
int add(int a,int b){
    return mod(mod(a)+mod(b));
}
int mul(int a,int b){
    return mod(mod(a)*mod(b));
}
int power(int n,int m){
    int ans=1;
    if(m==0)
    return 1;
    while(m>0){
        if(m%2!=0){
            ans=(ans*n)%MOD;
        }
        n=(n*n)%MOD;
        m=m/2;
    }
    return (ans+MOD)%MOD;
}

int dp[2001];
int func(int n){
    ff(i,6,n+1){
        ff(j,3,i+1){
            dp[i]=add(dp[i],dp[i-j]);
        }
    }
    
    return dp[n];
}
void solve(){
   int n;
   cin>>n;
   dp[0]=dp[3]=dp[4]=dp[5]=1;
   dp[1]=dp[2]=0;
   cout<<func(n);
}
signed main() {
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3640
from functools import reduce

N = int(input())
A = [int(input()) for _ in range(N)]

# 数列の末尾から構築する
ans, _ = reduce(
    lambda acc, i: (
        (
            -1 if acc[0] == -1 or A[i] < acc[1] - 1 or A[i] > i else
            acc[0] if A[i] == acc[1] - 1 else
            acc[0] + A[i]
        ),
        A[i]
    ),
    reversed(range(N)),
    (0, 0)
)

print(ans)


Measured memory_bytes: 11544
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		String[] W = new String[N];
		for(int i = 0; i < N; i++) {
			W[i] = scan.next();
		}

		if (kaburi(W)) {
			System.out.println("No");
			return;
		}

		for (int i= 0; i < W.length-1; i++) {
			if(!W[i].substring(W[i].length()-1).equals(W[i+1].substring(0,1))) {
				System.out.println("No");
				return;
			}
		}

		System.out.println("Yes");
	}

	public static boolean kaburi(String[] W) {
		for (int i = 0; i < W.length-1; i++) {
			for (int j = i+1; j < W.length; j++) {
				if (W[i].equals(W[j])) {
					return true;
				}
			}
		}
		return false;
	}
}


Measured memory_bytes: 22612
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,a[20][20],val[70000],dp[70000];

LL dfs(int mask)
{
  if(dp[mask]!=-1e18) return dp[mask];
  int num=__builtin_popcount(mask);
  if(num==0) return dp[mask]=0;
  rep(i,1<<num)
  {
    int tmp=0,now=0;
    rep(j,n)
    {
      if((mask&(1<<j))>0)
      {
        tmp|=((i>>now)&1)<<j;
        now++;
      }
    }
		if(tmp==0) continue;
    dp[mask]=max(dp[mask],val[tmp]+dfs(mask-tmp));
  }
  return dp[mask];
}

int main()
{
  cin>>n;
  rep(i,n) rep(j,n) cin>>a[i][j];
  rep(i,1<<n) rep(j,n) for(int k=j+1;k<n;k++) if((i&(1<<j))>0&&(i&(1<<k))>0) val[i]+=a[j][k];
  rep(i,69995) dp[i]=-1e18;
  cout<<dfs((1<<n)-1)<<endl;
  return 0;
}

Measured memory_bytes: 1280
// Problem : A - Registration
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
#define mod 1000000007
int lcm(int x,int y){
	return x/__gcd(x,y)*y;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a,b;
    cin>>a>>b;
    b.pop_back();
    if(a==b)cout<<"Yes"<<endl;
    else{
    	cout<<"No"<<endl;
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector <int64_t> a(n+1);
  a.at(0)=2 ;
  a.at(1)=1 ;
  for (int i=2 ; i<=n ; i++){
    a.at(i)=a.at(i-1)+a.at(i-2);
  }
  cout << a.at(n) << endl;
}

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

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

Measured memory_bytes: 256
import math
N = int(input())
sqrt_N = int(math.sqrt(N))

ans = float('inf')
for i in range(1,sqrt_N+1):
  if N % i == 0:
    if ans > max(len(str(i)),len(str(int(N/i)))):
      ans = max(len(str(i)),len(str(int(N/i))))

print(ans)

Measured memory_bytes: 3060
def solve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for _ in range(m)]

    cnt = [0]*n
    for j in range(m):
        a, b = ab[j]
        if h[a-1] < h[b-1]:
            cnt[a-1] -= 1
        elif h[b-1] < h[a-1]:
            cnt[b-1] -= 1
        elif h[a-1] == h[b-1]:
            cnt[a-1] -= 1
            cnt[b-1] -= 1

    
    return cnt.count(0)




print(solve())


Measured memory_bytes: 31916
W, H, N = [int(i) for i in input().split()]
xya_list = []
for i in range(N):
    xya_list.append([int(j) for j in input().split()])

area = [[0 for i in range(H)] for j in range(W)]
for xya in xya_list:
    x_i = xya[0]
    y_i = xya[1]
    a_i = xya[2]
    if a_i == 1:
        for x in range(W):
            for y in range(H):
                if x < x_i:
                    area[x][y] = 1
    if a_i == 2:
        for x in range(W):
            for y in range(H):
                if x >= x_i:
                    area[x][y] = 1
    if a_i == 3:
        for x in range(W):
            for y in range(H):
                if y < y_i:
                    area[x][y] = 1
    if a_i == 4:
        for x in range(W):
            for y in range(H):
                if y >= y_i:
                    area[x][y] = 1

ct = 0
for x in range(W):
    for y in range(H):
        if area[x][y] == 0:
            ct += 1
print(ct)

Measured memory_bytes: 3188
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
d, e = map(int, input().split())
if d in a and e in a:
    print("Yes")
elif d in b and e in b:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda: list(map(int, input().strip().split()))

MOD = 10**9 + 7

def main():
	x, k, d = read()
	if abs(x) >= k*d:print(abs(x) - k*d);return
	if x%d == 0:print([d, 0][(k - abs(x)//d)%2 == 0]);return
	y = abs(x)%d
	print([y, abs(y-d)][(k - abs(x)//d) %2])



if __name__ == "__main__": 
	main()

Measured memory_bytes: 9484
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict(list)
#import bisect
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,m = readInts()
    shop = []
    for i in range(n):
        mon,num = readInts()
        shop.append([mon,num])
    shop = sorted(shop,key = lambda x:x[0])# お金でソートする 昇順(小さい物順)
    now = 0
    cost = 0
    for i in range(n):
        mon,num = shop[i]
        # 展開
        if now < m: # 今何本あるか
            buy = min(num,m - now) # 何本か?
            cost += mon * buy
            now += buy
        if now == m:
            break
    print(cost)

if __name__ == '__main__':
  main()


Measured memory_bytes: 65752
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
typedef long long int lli;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<bool> vb;
long long int max(long long int a,long long int b){
  if(a>b)
    return a;
  else
    return b;
}
long long int min(long long int a,long long int b){
  if(a<b)
    return a;
  else
    return b;
}
long long int binpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
    }
  return res;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
 
//############################ENDOFTEMPLATE############################


bool check(int x,vlli& a,vlli &b,int k){
  int n = a.size();
  int m = b.size();
  
  bool flag = false;
  for(int i = min(x,n),j = x-min(x,n);i>=0,j<=min(x,m);i--,j++){
    lli tme = (i>0?a[i-1]:0) + (j>0?b[j-1]:0);
    if(tme<=k)
      flag = true;
  }

  return flag;

}

void solve(){
  int n,m,k;
  cin>>n>>m>>k;

  vlli a(n),b(m);
  for(int i = 0;i<n;i++){
    cin>>a[i];
  }
  for(int i = 0;i<m;i++){
    cin>>b[i];
  }
  for(int i = 1;i<n;i++){
    a[i] = a[i-1]+a[i];
  }
  for(int i = 1;i<m;i++){
    b[i] = b[i-1]+b[i];
  }

  int x = -1;
  for(int z = n+m+1;z>=1;z/=2){
    while(check(x+z,a,b,k)) x+=z;
  }

  //for(int i = 1;i<=n+m;i++){
    //cout<<check(i,a,b,k)<<" ";
  //}
  //cout<<endl;
  cout<<x;
}
 
 
 
 
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  //freopen("moobuzz.in","r",stdin);
  //freopen("moobuzz.out","w",stdout);
  int t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pi pair<int,int>
#define ll long long
#define rep(i,a,b) for(int i=int(a); i<=int(b);i++)
#define repv(vec,v) for(v=(vec).begin(); v!=(vec).end();v++)
#define sz(vec) (int)(vec).size()
#define PB push_back
#define F first
#define S second

ll comb2(ll n){ // n! / ((n-2)! * 2!)
	return n*(n-1)/2;
}

int main(){
	int n;
	cin >> n;
	vi vec(n);
	map<ll,ll> a;
	rep(i,0,n-1){
		cin >> vec[i];
		if(a.find(vec[i]) == a.end()){
			a.insert({vec[i],1});
		} else
			a[vec[i]]++;
	}
	map<ll,ll> sum;
	rep(i,0,n-1){
		if(sum.find(a[vec[i]]) != sum.end())
			cout << sum[a[vec[i]]] << "\n";
		else{
			ll s = 0;
			//cout << "-------\n";
			for(auto m: a){
				//cout << m.F << " " << m.S << endl;
				if(m.F == vec[i])
					s += comb2(m.S-1);
				else
					s += comb2(m.S);
			}
			sum.insert({a[vec[i]], s});
			cout << s << "\n";
		}
	}

	return 0;
}


Measured memory_bytes: 10240
import java.util.*;

public class Main {


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

        long n = sc.nextLong();

        long ans = 0;

        for (int i = 0; i < 10000000; i++) {

            if(n >= 500) {
                n -= 500;
                ans += 1000;
                continue;
            }

            if(n >= 5) {
                n -= 5;
                ans += 5;
                continue;
            } else {
                break;
            }


        }

        System.out.println(ans);

        sc.close();
    }

}

Measured memory_bytes: 23892
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <bitset>
#define SIZE 2005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

bitset <SIZE> left[SIZE];
bitset <SIZE> right[SIZE];
bool A[SIZE][SIZE];
char mp[SIZE][SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++) scanf("%s",&mp[i]);
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<i;j++)
		{
			int a=mp[i][j]-'0';
			A[i][j]=(a==1);
			A[j][i]=(a==0);
		}
	}/*
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++) printf("%d",A[i][j]);
		puts("");
	}*/
	for(int i=n-1;i>=0;i--)
	{
		left[i][i]=true;
		right[i][i+1]=true;
		bitset <SIZE> X;
		for(int j=i+1;j<n;j++)
		{
			if((left[j]&right[i]).any())
			{
				//printf("%d %d\n",i,j);
				if(A[i][j]) right[i]|=right[j];
				else
				{
					left[j][i]=true;
					X[j]=true;
				}
			}
			if((X&left[j]).any())
			{
				left[j][i]=true;
				X[j]=true;
			}
		}
	}/*
	puts("");
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++) printf("%d",left[i][j]?1:0);
		puts("");
	}*/
	int ret=0;
	for(int i=0;i<n;i++)
	{
		if(left[i][0]&&right[i][n])
		{
			ret++;
			//printf("%d\n",i);
		}
	}
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,j,z1,z2,maxn=0,to;
	string s,s1,s2;
	bool a[26],b[26];
	cin>>n>>s;
	for(i=1;i<n;i++)
	{
		s1=s2="";
		to=0;
		for(j=0;j<i;j++)
			s1+=s[j];
		for(j=i;j<n;j++)
			s2+=s[j];
		z1=s1.size();
		z2=s2.size();
		for(j=0;j<26;j++)
			a[j]=b[j]=false;
		for(j=0;j<z1;j++)
			a[s1[j]-'a']=true;
		for(j=0;j<z2;j++)
			b[s2[j]-'a']=true;
		for(j=0;j<26;j++)
			if(a[j]&&b[j])
				to++;
		maxn=max(maxn,to);
	}
	cout<<maxn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a[5], b[5]={1,2,3,4,5}, x;
	for(int i=0; i< 5; i++){
		cin >> a[i];
		if(a[i]!=b[i]) x=i+1;
	}
	cout << x << endl;
}

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


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

  int ans = 0;
  for (int i = 0; i <= 9; ++i) {
    for (int j = 0; j <= 9; ++j) {
      for (int k = 0; k <= 9; ++k) {
	char tmp[3] = {(char)(i + '0'), (char)(j + '0'), (char)(k + '0')};
	int cur = 0;
	for (int x = 0; x < n; ++x) {
	  if (cur < 3 && s[x] == tmp[cur]) {
	    cur++;
	  }
	}
	if (cur == 3) ans++;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
typedef pair< int , int> P;
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){
  if(checkyear%4==0){
    if(checkyear%100!=0||checkyear%400==0)
    return true;
  }
  return false;
}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const P& firstElof, const P& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
int a=0,b=0;
std::cin >> x>>y>>z>>w;
if(abs(x-z)<=w)std::cout << "Yes" << '\n';
else if(abs(x-y)<=w&&abs(y-z)<=w)std::cout << "Yes" << '\n';
else std::cout << "No" << '\n';
}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = LI()

    ans = 0
    m = A[0]
    for i in range(N - 1):
        ans += max(m - A[i+1], 0)
        m = max(A[i+1], m)

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 34124
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>

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

char ToUpper(char cX) { return toupper(cX); }
char Tolower(char cX) { return tolower(cX); }

const long long INF = 1LL << 60;
const long long MOD = 1000000007;

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

vector<vector<ll>> dp;

ll gcd(ll x, ll y)
{
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

ll gcd_vec(vector<ll> &a) {
	ll res = 0;
	for (ll i = 0; i < a.size(); i++) {
		res = gcd(res, a[i]);
	}

	return res;
}

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

ll lcm_vec(vector<ll> &a) {
	ll res = a[0];
	for (ll i = 0; i < a.size(); i++) {
		res = lcm(res, a[i]);
	}
	return res;
}
int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n, 0);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}

	cout << lcm_vec(a) << endl;
	return 0;
}



Measured memory_bytes: 3088
#include<stdio.h>
int check_mentsu(int n, int *num, int begin)
{
	int i, r;
	if (n == 0)
		return 1;
	for (i = begin; i < 9; i ++) {
		if (num[i] >= 3) {
			num[i] -= 3;
			r = check_mentsu(n-1, num, begin);
			num[i] += 3;
			if (r)
				return 1;
		}
	}
	for (i = begin; i+3 <= 9; i ++) {
		if (num[i] && num[i+1] && num[i+2]) {
			num[i] --, num[i+1] --, num[i+2] --;
			r = check_mentsu(n-1, num, begin);
			num[i] ++, num[i+1] ++, num[i+2] ++;
			if (r)
				return 1;
		}
	}
	return 0;
}
int check(int *num)
{
	int i, r;
	for (i = 0; i < 9; i ++) {
		if (num[i] >= 2) {
			num[i] -= 2;
			r = check_mentsu(4, num, 0);
			num[i] += 2;
			if (r)
				return 1;
		}
	}
	return 0;
}
int main()
{
	int c, i, f;
	while (c=fgetc(stdin), c!=EOF) {
		int num[9] = {0};
		for (i = 0; i < 13; i ++) {
			num[c-'1']++;
			c = fgetc(stdin);
		}
		f = 0;
		for (i = 0; i < 9; i ++) {
			if (num[i] < 4) {
				num[i] ++;
				if (check(num)) {
					if (f)
						putchar(' ');
					f = 1;
					putchar('1'+i);
				}
				num[i] --;
			}
		}
		if (!f)
			putchar('0');
		putchar('\n');
	}
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    vector<ll> A;
    string S;
    cin >> S;
    A.resize(S.size() + 1);
    for(ll i = 0;i < S.size();i++) {
        if(S[i] == '<') A[i + 1] = A[i] + 1;
    }
    for(ll i = S.size() - 1;i >= 0;i--) {
        if(S[i] == '>') A[i] = max(A[i], A[i + 1] + 1);
    }
    cout << accumulate(A.begin(), A.end(), 0LL) << endl;
    return 0;
}


Measured memory_bytes: 4740
#include<iostream>
using namespace std;
int main(){
  int h[100],w[100];
  int i=0;
  while(1){
    cin>>h[i]>>w[i];
    if(h[i]==0&&w[i]==0){
      break;
    }
    i++;
  }
  for(int j=0;j<i;j++){
    for(int k=0;k<h[j];k++){
      for(int l=0;l<w[j];l++){
	if(k%2==1&&l%2==1){
	  cout<<'#';
	    }else if(k%2==1&&l%2==0){
	  cout<<'.';
	    }
	if(k%2==0&&l%2==1){
	  cout<<'.';
	}else if(k%2==0&&l%2==0){
	  cout<<'#';
	}
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return(0);
}

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


int32_t main() {
	int n , k , ans = INT_MAX;
	cin >> n >> k;
	int a[n];
	for(int i  =0;i<n;++i) cin >> a[i];
	sort(a,a+n);
	// for(auto x:a) cout << x << endl;
	for(int i=0;i<=n-k;i++) {
		// cout << a[i] << ' ' << a[i+k-1] << endl;
		ans = min(ans , a[i+k-1] - a[i]);
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 640
#include<iostream>
 
using namespace std;
int main()
{
	int a,b,x;
	cin >> a >> b >> x;
	for(int i=0; i<x; i++){
		if(i % 2 == 0){
			if(a % 2 == 0){
				a /= 2;
				b += a;
			}
			else{
				a--;
				a /= 2;
				b += a;
			}
		}else{
			if(b % 2 == 0){
				b /= 2;
				a += b;
			}
			else{
				b--;
				b /= 2;
				a += b;
			}
		}
	}
	
	cout << a << " " << b << endl;
	
	return 0;
}


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

int main(){
	int n;
	cin >> n;
    int ans = 0;
    rep(j, n){
      int k = j+1;
      int cou = 0;
      for(int i=1; i*i<=k; i++){
        if(k%i == 0) cou += 2;
      }
      if(cou == 8 && k%2 == 1) ans++;
    }
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
using namespace std;
#define df 0
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define chmax(a,b) if((a)<(b)) {a=(b);}
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

li inv(int a){
  if(a==1)return 1;
  return ((MOD-MOD/a)*inv(MOD%a))%MOD;
}

void lcm(int a,map<int,int>& fact){
  map<int,int> temp;
  while(a%2==0) {
    temp[2]++;
    a/=2;
  }
  int n=3,sq=9;
  while(sq<=a){
    if(df)printf("(%d,%d)->",a,n);
    while(a%n==0){
      temp[n]++;
      a/=n;
    }
    if(df)printf("%d\n",a);
    sq+=4*n+4;
    n+=2;
  }
  if(a!=1)temp[a]++;
  for(auto x:temp){
    if(df){
      printf("[%d]:%d ",x.first,x.second);
    }
    chmax(fact[x.first],x.second);
  }
  if(df) cout << endl;
}

int main(){
  if(df) printf("*debug mode*\n");
  int n; cin >>n;
  li ans=0;

  
  map<int,int> fact;
  rep(i,n){
    int a; cin >>a;
    li iv=inv(a);
    if(df) printf("%d(%ld):",a,iv);
    (ans+=inv(a))%=MOD;
    lcm(a,fact);
  }
  for(auto x: fact){
    rep(i,x.second){
      (ans*=x.first)%=MOD;
    }
  }
  cout << ans;

  if(df){
    repa(i,21,30){
      cout << inv(i) << endl;
      lcm(i,fact);
    }
  }
}

/// confirm df==0 ///


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		char c;
		cin >> c;
		if (c == 'Y'){
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
	return  0;
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main(void){
    int n, h, w;
   cin >> n>> h >> w;
   int a[n], b[n];
   for(int i = 0; i < n; i ++){
       cin >> a[i] >> b[i];
   }
   int count = 0;
  for(int i = 0; i < n; i ++){
      if(a[i] >= h && b[i] >= w){
          count++;
      }
  }
  cout << count;
}

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

#define int long long

#define inf (int)1000000007

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trrep(i, n) for(int i = (n); i >= 0; i--)

signed main() {
  int n, a, b;
  cin >> n >> a >> b;
  int x;
  cin >> x;
  int all = 0;
  rep(i, n - 1) {
    int y;
    cin >> y;
    all += min((y - x) * a, b);
    x = y;
  }
  cout << all << endl;
}


Measured memory_bytes: 256