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

using namespace std;

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

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

const int maxn = 1e5+5;

int num[maxn];
int dp[maxn];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;

	int n, k;
	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		cin >> num[i];
	}
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		dp[i] = INT_MAX;
		for (int j = 0; j <= k; j++) {
			if (i - j < 0)
				break;
			dp[i] = min(dp[i], dp[i - j] + abs(num[i] - num[i - j]));
		}
	}

	cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, k;
  	cin >> a >> b >> c >> k;
  	int ans = 0;
  	ans += min(a, k);
  	k -= min(a, k);
  	k -= min(b, k);
  	ans -= min(c, k);
  	cout << ans << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n,k;
  cin>>n>>k;
  if(k==1){
    cout<<0<<endl;
    return 0;
  }else{
    cout<<n-k<<endl;
    return 0;
  }
  return 0;
}


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

#define BIAS 20000
bool ab[BIAS * 2];
bool bc[BIAS * 2];
bool ca[BIAS * 2];

void init(const string& S, const string& T, bool *M) {
  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < T.size(); j++) {
      if (S[i] != '?' && T[j] != '?' && S[i] != T[j]) {
        M[i-j+BIAS] = true;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  string A, B, C;
  cin >> A >> B >> C;

  init(A, B, ab);
  init(B, C, bc);
  init(C, A, ca);
  int la = A.size();
  int lb = B.size();
  int lc = C.size();
  int a = 0;
  int ret = la + lb + lc;
  for (int b = -4000; b <= 4000; b++) {
    if (ab[b-a+BIAS]) continue;
    for (int c = -4000; c <= 4000; c++) {
      if (bc[c-b+BIAS] || ca[a-c+BIAS]) continue;
      int L = min(a, min(b, c));
      int R = max(a + la, max(b + lb, c + lc));
      ret = min(ret, R - L);
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void){
	int i,n,h,c,p;
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		scanf("%d ",&h);
		if(c<=h){
			c=h;
			p++;
		}
	}
	printf("%d",p);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int n,w;
    cin>>n>>w;
    int weight[n];
    long long int value[n];
    for(int i=0;i<n;i++)
        cin>>weight[i]>>value[i];
    long long int dp[n+1][w+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++){
            if(i==0||j==0) dp[i][j]=0;
            else if(weight[i-1]>j) dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(dp[i-1][j-1],value[i-1]+dp[i-1][j-weight[i-1]]);
        }
    }
   /* for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    cout<<dp[n][w];
    return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

void solve() {
	int n; cin >> n;
	vector<ll> v(n);
	for (ll &i : v)cin >> i;
	sort(v.begin(), v.end());
	int ans = 0;
	for (int i = 0; i < n; i++)for (int j = i + 1; j < n; j++)for (int k = j + 1; k < n; k++)if (v[i] != v[j] && v[j] != v[k])ans += (v[i] + v[j] > v[k]);
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll x, y;
    cin >> x >> y;
    
    ll ans = 0;
    while(x<=y)ans++, x*=2;
    cout << ans << endl;

}

Measured memory_bytes: 256
n=gets.to_i
a=gets.split.map &:to_i
b=gets.split.map &:to_i
m=[]
c=0
j=true
n.times do |i|
  g=a[i]
  if g>c
    m<< [true,g]
    c=g
  else
    m<< [false,g]
  end
end
c=0
(n-1).downto(0) do |i|
  g=b[i]
  if g>c
    if m[i][0]
      j=false if m[i][1]!=g
    else
      j=false if m[i][1]<g
      m[i]=[true,g]
    end
    c=g
  else
    if m[i][0]
      j=false if m[i][1]>g
    else
      m[i]=[false,[g,m[i][1]].min]
    end
  end
end
c=1
n.times do |i|
  if !m[i][0]
    c*=m[i][1]
    c%=10**9+7
  end
end
p j ? c:0

Measured memory_bytes: 30108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int A[N];

    rep(i,N){
        cin>>A[i];
    }
    sort(A,A+N);

    pair<int,int> ans[N-1];
    int cou=0;

    
    rep(i,N-2){
        if(A[N-2-i]>=0){
                ans[i]=make_pair(A[0],A[N-2-i]);
                A[0]=-A[N-2-i]+A[0];
        }else{
            ans[i]=make_pair(A[N-1],A[N-2-i]);
                A[N-1]=-A[N-2-i]+A[N-1];
        }

        
    }
    ans[N-2]=make_pair(A[N-1],A[0]);
    A[0]=A[N-1]-A[0];


    cout << A[0]<<endl;
    rep(i,N-1){
        
        cout << ans[i].first <<" " << ans[i].second << endl;
    }



    



}


Measured memory_bytes: 4224
import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = [-A[i] for i in range(N)]
heapq.heapify(A)

for i in range(M):
    a = heapq.heappop(A)
    if a == 0:
        heapq.heappush(A, 0)
    else:
        heapq.heappush(A, a/2)
A = [int(-A[i]) for i in range(N)]
print(sum(A))



Measured memory_bytes: 99864
//Password

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n;cin>>n;
    cout<<n*n*n<<nnn;
    return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<iostream>
using namespace std;
int val[10][10];
int Value(int a,int b,int c,int d,int e)
{
	int f=val[0][a];
	f=val[f][b];
	f=val[f][c];
	f=val[f][d];
	if(e==-1)
	{
		return f;
	}
	else
		return val[f][e];
}
bool Check(int a,int b,int c,int d,int e)
{
	for(int j=0;j<=9;j++)
	{
		if(a!=j)
		{
			if(Value(j,b,c,d,e)==0)
			{
				return false; 
			}
		}
	} 
	for(int j=0;j<=9;j++)
	{
		if(b!=j)
		{
			if(Value(a,j,c,d,e)==0)
			{
			//	cout<<"sdf"<<endl;
				return false; 
			}
		}
	}
	for(int j=0;j<=9;j++)
	{
		if(c!=j)
		{
			if(Value(a,b,j,d,e)==0)
			{
			//	cout<<"sfd"<<endl;
				return false; 
			}
		}
	}  
	for(int j=0;j<=9;j++)
	{
		if(d!=j)
		{
			if(Value(a,b,c,j,e)==0)
			{
			//	cout<<"ad"<<endl;
				return false; 
			}
		}
	}
	for(int j=0;j<=9;j++)
	{
		if(e!=j)
		{
			if(Value(a,b,c,d,j)==0)
			{
				return false; 
			}
		}
	}
	if((Value(b,a,c,d,e)==0&&b!=a)||(Value(a,c,b,d,e)==0&&b!=c)||(Value(a,b,d,c,e)==0&&c!=d)||(Value(a,b,c,e,d)==0&&e!=d))
	{
		return false;
	}  
	else
	{
		return true;
	}
}
int main(void)
{
	for(int i=0;i<10;i++)
	{
		for(int j=0;j<10;j++)
		{
			scanf("%d",&val[i][j]);
		}
	}
	int a,b,c,d;
	int sum=0;
	for(int i=0;i<=9999;i++)
	{
		a=i%10;
		b=i/10%10;
		c=i/100%10;
		d=i/1000%10;
	//	cout<<Value(a,b,c,d,-1)<<endl;
	//	cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl; 
		int e=Value(a,b,c,d,-1);
	//	cout<<Check(a,b,c,d,e)<<endl;
		if(Check(a,b,c,d,e)==false)
		{
			sum++;
		}
	}
	cout<<sum<<endl;
} 

Measured memory_bytes: 3236
//
// Created on 2020/05/31.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;

int main() {
    int n;
    cin>>n;
    ll ans = 1;
    vector<ll>A(n);
    for (int j = 0; j < n; ++j) {
        cin>>A[j];
        if(A[j] == 0){
            cout<<0<<endl;
            return 0;
        }
    }

    for (int i = 0; i < n; ++i) {
       if(ans > LINF/A[i]){
           cout<<-1<<endl;
           return 0;
       }
       ans *= A[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

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

    for(int i=1; i<10; i++){
        int f = a / i;
        if(a % i == 0 && f < 10 && f > 0){
            cout << "Yes ";
            return 0;
        }
    }

    cout << "No ";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        int[] a1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] a2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] a3 = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = int.Parse(Console.ReadLine());

        int[] b = new int[n];
        for (int i = 0; i < n; i++)
        {
            b[i] = int.Parse(Console.ReadLine());
        }

        int[] ba1 = Enumerable.Repeat<int>(0, 3).ToArray();
        int[] ba2 = Enumerable.Repeat<int>(0, 3).ToArray();
        int[] ba3 = Enumerable.Repeat<int>(0, 3).ToArray();
        for (int i = 0; i < n; i++)
        {
            int num1 = Array.IndexOf(a1, b[i]);
            if (num1 >= 0)
            {
                ba1[num1] = 1;
            }

            int num2 = Array.IndexOf(a2, b[i]);
            if (num2 >= 0)
            {
                ba2[num2] = 1;
            }

            int num3 = Array.IndexOf(a3, b[i]);
            if (num3 >= 0)
            {
                ba3[num3] = 1;
            }
        }

        int bingo = 0;
        //横検索
        if (ba1[0] == 1 && ba1[1] == 1 && ba1[2] == 1)
        {
            bingo = 1;
        }
        if (ba2[0] == 1 && ba2[1] == 1 && ba2[2] == 1)
        {
            bingo = 1;
        }
        if (ba3[0] == 1 && ba3[1] == 1 && ba3[2] == 1)
        {
            bingo = 1;
        }

        //縦検索
        if (ba1[0] == 1 && ba2[0] == 1 && ba3[0] == 1)
        {
            bingo = 1;
        }
        if (ba1[1] == 1 && ba2[1] == 1 && ba3[1] == 1)
        {
            bingo = 1;
        }
        if (ba1[2] == 1 && ba2[2] == 1 && ba3[2] == 1)
        {
            bingo = 1;
        }

        //ななめ検索
        if (ba1[0] == 1 && ba2[1] == 1 && ba3[2] == 1)
        {
            bingo = 1;
        }
        if (ba1[2] == 1 && ba2[1] == 1 && ba3[0] == 1)
        {
            bingo = 1;
        }


        if (bingo == 1)
        {
             Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
       

    }
}

Measured memory_bytes: 13280
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[])
{
    int a[3][3];
    int n;
    int b[10];
    bool c[3][3];

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            std::cin >> a[i][j];
            c[i][j] = false;
        }
    }

    std::cin >> n;

    for (int i = 0; i < n; i++) {
        std::cin >> b[i];
    }

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < n; k++) {
                if (a[i][j] == b[k]) {
                    c[i][j] = true;
                }
            }
        }
    }

    bool bingo = false;
    // row and col
    for (int i = 0; i < 3; i++) {
        if (c[0][i] && c[1][i] && c[2][i]) {bingo = true;}
        if (c[i][0] && c[i][1] && c[i][2]) {bingo = true;}
    }
    // diag
    if (c[0][0] && c[1][1] && c[2][2]) {bingo = true;}
    if (c[0][2] && c[1][1] && c[2][0]) {bingo = true;}

    if (bingo) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord
import qualified Data.Sequence as Seq

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)



main :: IO ()
main = do
    [n,k] <- r'
    [r,s,p] <- r'
    t <- getLine
    let nxt = drop k $ map rsp t
    print $ solve k Seq.empty t nxt (r,s,p) 0


solve :: Int -> Seq.Seq Char -> String -> String -> (Int,Int,Int) -> Int -> Int
solve _     ng     [] _    (r,s,p) ac = ac
solve count ng (t:tt) nxt  (r,s,p) ac
    | count > 0                 = solve (count-1) (ng Seq.|> rsp t) tt (stail nxt) (r,s,p)
                                    (ac +(case rsp t of 'r' -> r
                                                        's' -> s
                                                        'p' -> p))
    | Seq.index ng 0 /= rsp t   = solve count (Seq.drop 1 ng Seq.|> rsp t) tt (stail nxt) (r,s,p)
                                    (ac +(case rsp t of 'r' -> r
                                                        's' -> s
                                                        'p' -> p))
    | null nxt  = solve count (Seq.drop 1 ng Seq.|> t) tt (stail nxt) (r,s,p) ac
    | otherwise = solve count (Seq.drop 1 ng Seq.|> selNot (rsp t,head nxt) ) tt (stail nxt) (r,s,p) ac


stail [] = []
stail xs = tail xs

rsp :: Char -> Char
rsp 'r' = 'p'
rsp 's' = 'r'
rsp 'p' = 's'

selNot :: (Char,Char) -> Char
selNot t = case t of
    ('r','s') -> 'p'
    ('s','r') -> 'p'
    ('r','p') -> 's'
    ('p','r') -> 's'
    ('p','s') -> 'r'
    ('s','p') -> 'r'
    ('r','r') -> 'p'
    ('s','s') -> 'r'
    ('p','p') -> 's'




Measured memory_bytes: 28540
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace aoj1
{
    class Program
    {
        static void Main()
        {
            int[] num;
            for (int i = 1; ; i++)
            {
                num = IntInput();
                if (num[0] != 0)
                {
                    Console.WriteLine("Case {0}: {1}", i, num[0]);
                }
                else
                {
                    break;
                }
            }
        }

        static int[] IntInput()
        {
            string[] strs = Console.ReadLine().Split(' ');
            int[] numbers = new int[strs.Length];
            for (int i = 0; i < strs.Length; i++)
            {
                numbers[i] = int.Parse(strs[i]);
            }
            return numbers;
        }
    }
}

Measured memory_bytes: 5708
h,w=map(int,input().split())
a=[list(input()) for j in range(h)]

for p in range(w):
    f=True
    for q in range(h):
        if a[q][p]=="#":f=False
    if f:
        for y in range(h):a[y][p]=""
res=[]
for t in a:
    if t.count(".")+t.count("")!=len(t):res.append(t)
for t in res:
    print("".join(t))

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pt;

#define fi first
#define se second
#define lson (p<<1)+1
#define rson (p<<1)+2
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll a, b;

int main () {
    fastIO;
    cin >> a >> b;
    cout << a / __gcd(a, b) * b;
}


Measured memory_bytes: 256
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [long(input_raw[0]), long(input_raw[1])]
    is_red = [False for i in range(N+1)]
    is_red[1] = True
    ball_num = [1 for i in range(N+1)]
    for i in range(M):
        input_raw = read_func().strip().split()
        [x, y] = [long(input_raw[0]), long(input_raw[1])]
        ball_num[x] -= 1
        ball_num[y] += 1
        if is_red[x] == True:
            is_red[y] = True
        if ball_num[x] == 0:
            is_red[x] = False

    print sum(is_red)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7628
from collections import Counter
import itertools

n, *l = map(int, open(0).read().split())
c = Counter(l)
c_key = c.keys()
ans = 0
for v in itertools.combinations(c_key, 3):
    v_sorted = sorted(list(v))
    if v_sorted[0] + v_sorted[1] > v_sorted[2]:
        ans += c[v[0]]*c[v[1]]*c[v[2]]
print(ans)

Measured memory_bytes: 9328
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	int T,MT=INF;
	cin >> N;
	rep(i, 0, 5)
	{
		cin >> T;
		chmin(MT, T);
	}

	cout << 4 + (N + MT - 1) / MT << endl;

	return 0;
}



Measured memory_bytes: 256
import numpy as np
n,m = list(map(int,input().split()))
t = np.zeros(m,dtype=int)
count = 0
for i in range(n):
    a = list(map(int,input().split()))
    for j in range(1,a[0]+1):
        t[a[j]-1]+=1
for i in range(m):
    if t[i] == n:
        count+=1
print(count)

Measured memory_bytes: 12396
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		S = S.replace("eraser","");
        S = S.replace("erase","");
        S = S.replace("dreamer","");
        S = S.replace("dream","");

		if(S.length() == 0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 30556
#include<bits/stdc++.h>
using namespace std;
vector<int>height;
vector<int>cost;
int n;

int main()
{

    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        int temp;
        scanf("%d",&temp);
        height.push_back(temp);
        if(!i)
        {
            cost.push_back(0);
        }
        cost.push_back(INT_MAX);
    }

    for(int i=0; i<n; i++)
    {
        if(i+1<n)
        {
            int dif=abs(height[i]-height[i+1])+cost[i];
            if(cost[i+1]>dif)
                cost[i+1]=dif;

        }
        if(i+2<n)
        {
            int dif=abs(height[i]-height[i+2])+cost[i];
            if(cost[i+2]>dif)
                cost[i+2]=dif;

        }

    }
    cout<<cost[n-1]<<endl;

    return 0;
}


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

using namespace std;

int main (void) {
      int a = 0;
      int b = 0;
      int ans = 0;

      std::cin >> a;
      std::cin >> b;

      ans = a * b - a - b + 1;

      std::cout << ans << '\n';

      return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(void){
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    
    vector<ll> e(x*y);
    for (int i = 0; i < x; i++)
        for (int j = 0; j < y; j++)
            e[i*y+j] = a[i]+b[j];
    sort(e.begin(), e.end(), greater<ll>());
    
    vector<ll> f(min(x*y, k)*z);
    for (int i = 0; i < min(x*y, k); i++)
        for (int j = 0; j < z; j++)
            f[i*z+j] = e[i]+c[j];
    sort(f.begin(), f.end(), greater<ll>());
    
    rep(i, k) cout << f[i] << endl;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong A, B, C, K;
  cin >> A >> B >> C >> K;

  llong sum = 0;
  sum += min(A, K);
  K = max(0ll, K - A);
  K = max(0ll, K - B);
  sum -= min(C, K);

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
const int mod=1e9+7;
using namespace std;
ll n,k,s=1,ans=0;

int main(){
    cin>>n>>k;
    while(s-1<n){
        s=s*k;
        ans++;
    }
    cout<<ans<<endl;
    
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            int[] arr = new int[n+1];
            foreach (char c in s) if (c == '.') arr[0]++;
            for (int i=1; i<n+1; i++)
            {
                if (s[i-1] == '.') arr[i] = arr[i-1] - 1;
                else arr[i] = arr[i-1] + 1;
            }
            Array.Sort(arr);
            Console.WriteLine(arr[0]);
            
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 13216
import java.util.Scanner;
class Main{

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

    public void start(){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String letters[] = str.split("");
        int max = 0;
        for(int i = 0; i < letters.length; i++){
            int num = countLength(letters,i);
            if(num > max) max = num;
        }
        System.out.println(max);
    }

    public int countLength(String[] letters,int index){
        int count = 0;
        for(int i = index; i < letters.length;i++){
            if(letters[i].equals("A")||letters[i].equals("C")||letters[i].equals("T")||letters[i].equals("G")){
                count++;
            }else{
                return count;
            }
        }
        return count++;
    }
}

Measured memory_bytes: 23252
N = int(input())
SP = []
for i in range(N):
    s,p = input().split()
    SP.append([0,0])
    SP[i][0] = s
    SP[i][1] = -int(p)
SP_new = sorted(SP)
for i in SP_new:
    print(SP.index(i)+1)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <iomanip>
#include <tuple>
#include <queue>
#define ll long long int
#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()
using namespace std;
#define INF 1000000

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	vector<vector<int>> A(m);
	rep(i,0,n){
		int t1,t2;
		cin >> t1 >> t2;
		if (t1 > m)continue;
		A[m-t1].push_back(t2);
	}
	priority_queue<int> q;
	ll sum=0;

	rel(i,m,0){
		for(int b:A[i]){
			q.push(b);
		}
		if(!q.empty()){
			sum += q.top();
			q.pop();
		}
	}
	cout << sum << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<vector<int>> data(2, vector<int>(N));
  for(int i=0; i<2; i++){
    for(int j=0; j<N; j++){
      cin >> data.at(i).at(j);
    }
  }

  vector<vector<int>> dp(2, vector<int>(N));
  dp.at(0).at(0)= data.at(0).at(0);
  for(int j=1; j<N; j++){
    dp.at(0).at(j)= dp.at(0).at(j-1)+ data.at(0).at(j);
  }
  dp.at(1).at(0)= dp.at(0).at(0)+ data.at(1).at(0);

  for(int j=1; j<N; j++){
    dp.at(1).at(j)= max(dp.at(1).at(j-1), dp.at(0).at(j))+ data.at(1).at(j);
  }

  cout << dp.at(1).at(N-1) << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i,n)cin >> vec.at(i);
  sort(vec.begin(),vec.end());
  cout << vec.at(vec.size()-1)-vec.at(0) << endl;

	return 0;
}


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

int main()
{
    int K;
    std::cin >> K;

    int gcd[201][201];
    int count[201];

    for (int a = 1; a <= K; ++a) {
        for (int b = 1; b <= K; ++b) {
            gcd[a][b] = std::gcd<int, int>(a, b);
            ++count[gcd[a][b]];
        }
    }

    long long sum = 0;
    for (int c = 1; c <= K; ++c) {
        for (int n = 1; n <= K; ++n) {
            sum += count[n] * gcd[n][c];
        }
    }

    std::cout << sum;

    return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, std::vector<long long> A)
{
    double ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans += (double)1 / A[i];
    }

    cout << setprecision(15) << (double)1 / ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    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 H = sc.nextInt();
		int W = sc.nextInt();
		char[][]s = new char[H][W];
		for(int i = 0; i < H; i++) {
			String S = sc.next();
			for(int j = 0; j < W; j++) {
				s[i][j] = S.charAt(j);
			}
		}
		sc.close();
		int[][]b = new int[H][W];
		int[]dx = {0, 0, 1, 1, 1, -1, -1, -1};
		int[]dy = {1, -1, 0, 1, -1, 0, 1, -1};
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(s[i][j] == '#') {
					for(int k = 0; k < 8; k++) {
						int ny = i + dy[k];
						int nx = j + dx[k];
						if(ny >= 0 && ny < H && nx >= 0 && nx < W) {
							if(s[ny][nx] == '.') {
								b[ny][nx] ++;
							}
						}
					}
				}
			}
		}
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(s[i][j] == '#') {
					System.out.print("#");
				}else {
					System.out.print(b[i][j]);
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 22356
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int n = sc.intarr[0];
            int[] array = sc.intarr;

            double sum = 0;

            foreach(var a in array)
            {
                sum += 1.0 / a;
            }

            Console.WriteLine(1.0 / sum);
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13396
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (h, w) = readIntegerList()
    val map = Array(h) { readLine()!! }
    for (i in 0 until h) {
        for (j in 0 until w) {
            if (map[i][j] == '#') {
                if ((i - 1) in 0 until h && map[i - 1][j] == '#') {
                    continue
                }

                if ((i + 1) in 0 until h  && map[i + 1][j] == '#') {
                    continue
                }

                if ((j - 1) in 0 until w  && map[i][j - 1] == '#') {
                    continue
                }

                if ((j + 1) in 0 until w && map[i][j + 1] == '#') {
                    continue
                }

                println("No")
                return
            }
        }
    }
    println("Yes")
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 37720
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

// 計算量は O(NloglogN) らしい
vector<bool> sieve(int n) { // sieve : ふるい
    vector <bool> is_prime(n + 1, true);
    if (n >= 0) is_prime[0] = false;
    if (n >= 1) is_prime[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (!is_prime[i]) continue;
        for (int j = 2 * i; j <= n; j += i) {
            is_prime[j] = false;
        }
    }
    return is_prime;
}


// verified
//   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C&lang=jp
void AOJ_ALDS_1_C() {
    int n;
    cin >> n;
    vector <bool> is_prime = sieve(100000005);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int m;
        cin >> m;
        ans += is_prime[m];
    }
    cout << ans << "\n";
}


// verified
//   https://onlinejudge.u-aizu.ac.jp/beta/room.html#ACPC2018Day1/problems/C
void ACPC_2019_9_19_C() {
    int n;
    cin >> n;
    vector <bool> is_prime = sieve(n+2);
    int ans = 0;
    for (int i = 3; i <= n; i++) {
        ans += is_prime[i] & is_prime[i + 2];
    }
    cout << ans * 2 << "\n";
}


// verified
//   https://yukicoder.me/problems/no/843
void yuki843() {
    int n;
    cin >> n;
    vector <bool> is_prime = sieve(n+2);
    int ans = 0;
    if (n >= 2) ans++;
    for (int i = 3; i <= n; i++) {
        if (!is_prime[i]) continue;
        int sum = 2 + i;
        int s = sqrt(sum);
        if (s * s == sum && is_prime[s]) ans += 2;
    }
    cout << ans << "\n";
}

int main() {
    AOJ_ALDS_1_C();
    // ACPC_2019_9_19_C();
    // yuki843();
    return 0;
}


Measured memory_bytes: 14948
N,K,Q = map(int,input().split())

Score = [0]*N

for _ in range(Q):
    index = int(input())
    Score[index-1] = Score[index-1] + 1

#print(Score)

for _ in range(N):
    if (K - Q + Score[_]) > 0:
        print('Yes')
    else:
        print('No')

#print(N,K,Q)
#print(A)
#print(Score)


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

const int64_t MOD = 1'000'000'007; //'

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    map<string, int64_t> dp[101];
    static unordered_set<string> ng = {
        "AAGC", "GAGC", "CAGC", "TAGC",
        "AAGC", "AGGC", "ACGC", "ATGC",
        "AGAC", "AGGC", "AGCC", "AGTC",
        "AGCA", "AGCG", "AGCC", "AGCT",
        "AGAC", "GGAC", "CGAC", "TGAC",
        "AACG", "GACG", "CACG", "TACG"
    };
    static string b[4] = {"A", "G", "C", "T"};
    
    dp[1]["TTA"] = 1;
    dp[1]["TTG"] = 1;
    dp[1]["TTC"] = 1;
    dp[1]["TTT"] = 1;
    for(int i=2;i<=100;i++){
        for(auto dic:dp[i-1]){
            for(string s:b){
                string key = dic.first + s;
                if(ng.count(key)) continue;
                key = key.substr(1);
                dp[i][key] += dic.second;
                dp[i][key] %= MOD;
            }
        }
    }
    
    int n;
    cin >> n;
    int64_t ans = 0;
    for(auto cnt:dp[n]){
        ans = (ans + cnt.second) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
# WIP
s = input()
K = int(input())

minimum_canditates = sorted(set(s))
n_counted = 0

canditates = []


def add_canditate(target_chara):
    global n_counted

    canditates.append(target_chara)
    n_counted += 1
    for c in minimum_canditates:
        next_target = target_chara + c
        if n_counted < K and next_target in s:
            add_canditate(next_target)


for c in minimum_canditates:
    add_canditate(c)

print(canditates[K - 1])


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

using namespace std;

int main()
{
	int a,b,k;
	cin>>a>>b;
	
	if((a+b)%2 == 0)
	{
		cout<<(a+b)/2<<endl;
	}
	else
	{
		cout<<"IMPOSSIBLE"<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int nax = 1e6 + 5;
const int mod = 1e9 + 7;
int a[nax], b[nax];
int pewka[nax];
int main() {
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) scanf("%d", &a[i]);
	for(int i = 0; i < n; ++i) scanf("%d", &b[i]);
	/* for(int i = 0; i < n - 1; ++i) {
		if(a[i] > a[i+1] || b[i] < b[i+1]) {
			puts("0");
			return 0;
		}
	} */
	for(int i = 0; i < n; ++i) if(i == 0 || a[i] > a[i-1]) {
		pewka[i] = a[i];
	}
	for(int i = 0; i < n; ++i) if(i == n - 1 || b[i] > b[i+1]) {
		if(pewka[i] && pewka[i] != b[i]) {
			puts("0");
			return 0;
		}
		pewka[i] = b[i];
	}
	for(int i = 0; i < n; ++i) if(pewka[i] && pewka[i] > min(a[i], b[i])) {
		puts("0");
		return 0;
	}
	int ans = 1;
	/*for(int i = 0; i < n; ++i) {
		if(pewka[i]) b[i] = min(b[i], pewka[i]);
		if(i) b[i] = min(b[i], b[i-1]);
	}
	for(int i = n - 1; i >= 0; --i) {
		if(pewka[i]) a[i] = min(a[i], pewka[i]);
		if(i != n - 1) a[i] = min(a[i], a[i+1]);
	}*/
	for(int i = 0; i < n; ++i) if(!pewka[i])
		ans = (long long) ans * min(a[i], b[i]) % mod;
	printf("%d\n", ans);
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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

int f(int y){
    if(y <= 1911){
        cout << "M";
        return y - 1867;
    }
    if(y <= 1925){
        cout << "T";
        return y - 1911;
    }
    if(y <= 1988){
        cout << "S";
        return y - 1925;
    }
    cout << "H";
    return y - 1988;
}

signed main(void) {
    int e,y;
    cin >> e >> y;
    switch (e) {
        case 0: y = f(y);break;
        case 1: y += 1867;break;
        case 2: y += 1911;break;
        case 3: y += 1925;break;
        case 4: y += 1988;break;
    }
    cout << y << endl;
}



Measured memory_bytes: 3104
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define ll long long
ll n,a,b;
inline void read(ll &x)
{
	ll data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=(data<<3)+(data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
inline ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
}
int main()
{
	read(n);
	read(a);
	for(register int i=1;i<n;++i)
	{
		read(b);
		a=a/gcd(a,b)*b;
	}
	printf("%lld\n",a);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const int M=1e9+7;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
typedef long long ll;
typedef pair<int,int> PII;
map<string,int> mp;
vector<string> vec;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	
	int n;
	cin>>n;
	int ans=-INF;
	while(n--){
		string s;
		cin>>s;
		mp[s]++;
		ans=max(ans,mp[s]);
	}
	for(map<string,int>::iterator it = mp.begin(); it != mp.end(); it++){
		if(it->second==ans)
			vec.push_back(it->first);
	}
	sort(vec.begin(),vec.end());
	for(auto v:vec){
		cout<<v<<endl;
	}
	return 0;
}


Measured memory_bytes: 25584
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_8_C&lang=jp
  * Character - Counting Characters
  */
object Main {
  def main(args: Array[String]): Unit = {
    val lines = Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).mkString.toLowerCase
    val occurrences = ('a' to 'z').map(c => (c, lines.count(_ == c)))
    occurrences.foreach(occ => println(s"${occ._1} : ${occ._2}"))
  }
}

Measured memory_bytes: 44500
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <vector>

#ifdef GONGKUNPENG
#include <cassert>

#define _GG 1
#else
#define _GG 0
#endif

#define uint unsigned
#define vector std::vector
#define max(a, b) std::max(a, b)
#define min(a, b) std::min(a, b)
#define swap(a, b) std::swap(a, b)
#define sort(...) std::sort(__VA_ARGS__)
#define ms(a, v) memset(a, v, sizeof(a))
#define ufor(i, n) for (int i = 1; i < n; ++i)
#define sfor(i, n) for (int i = 1; i <= n; ++i)
#define tfor(i, n) for (int i = 0; i < n; ++i)

#if __cplusplus >= 201103L
using ll = long long;
using ull = unsigned long long;
#else
typedef long long ll;
typedef unsigned long long ull;
#endif

#define _GIO 1

#if _GIO
struct _gio
{
#define BFSZ 1 << 18
#define blank(x) (x == ' ' || x == '\t' || x == '\n' || x == '\r')

	char rcha;
	bool rneg;
#if _GG
#else
	char ruf[BFSZ], wuf[BFSZ], *r1, *r2, *w1;
#endif

	_gio()
	{
		rcha = ' ';
#if _GG
#else
		r1 = r2 = ruf, w1 = wuf;
#endif
	}

	~_gio()
	{
#if _GG
#else
		fwrite(wuf, 1, w1 - wuf, stdout);
#endif
	}

	inline void flush()
	{
#ifdef _GG
#else
		fwrite(wuf, 1, w1 - wuf, stdout), w1 = wuf;
#endif
	}

	inline int readc()
	{
#if _GG
		return getchar();
#else
		return (r1 == r2 && (r2 = (r1 = ruf) + fread(ruf, 1, BFSZ, stdin), r1 == r2)
					? -1
					: *r1++);
#endif
	}

	template <typename T, typename... Args>
	void read(T &x, Args &... args)
	{
		read(x), read(args...);
	}

	inline void read() {}

	inline void read(char *s)
	{
		while (blank(rcha))
			rcha = readc();
		while (!blank(rcha) && rcha > 0)
			*s++ = rcha, rcha = readc();
		*s = '\0';
	}

	inline void readl(char *s)
	{
		while (blank(rcha))
			rcha = readc();
		while (rcha != '\n' && rcha > 0)
			*s++ = rcha, rcha = readc();
		*s = '\0';
	}

	template <typename T>
	inline void read(T &x)
	{
		x = rcha = rneg = 0;
		while (!isdigit(rcha) && rcha != '-')
			rcha = readc();
		rcha == '-' && (rneg = true, rcha = readc());
		while (isdigit(rcha))
			x = (x << 3) + (x << 1) - 48 + rcha, rcha = readc();
		rneg && (x = -x);
	}

	inline void writec(const char &c)
	{
#if _GG
		putchar(c);
#else
		(w1 - wuf == BFSZ) && (fwrite(wuf, 1, BFSZ, stdout), w1 = wuf);
		*w1++ = c;
#endif
	}

	template <typename T, typename... Args>
	void write(const T &x, const Args &... args)
	{
		write(x), write(args...);
	}

	template <typename T, typename... Args>
	void writel(const T &x, const Args &... args)
	{
		write(x), write(args...);
		writec('\n');
	}

	inline void write() {}

	inline void write(const char &c) { writec(c); }

	template <typename T>
	void write(T x)
	{
		if (x < 0)
		{
			writec('-');
			write(-ll(x));
			return;
		}
		if (x > 9)
			write(x / 10);
		writec(x % 10 ^ 48);
	}

	inline void write(const char *s)
	{
		while (*s)
			writec(*s++);
	}
#undef BFSZ
} io;
#endif

int main()
{
	int a, b, c;
	io.read(a, b, c);
	io.writel(c, ' ', a, ' ', b);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(_) for _ in input().split()]
cumsum = [0]
for a in A:
    cumsum += [cumsum[-1] + a]
cumsum.sort()
ans = 0
count = 0
for i in range(N):
    if cumsum[i] == cumsum[i + 1]:
        count += 1
    if cumsum[i] != cumsum[i + 1] or i == N - 1:
        ans += count * (count + 1) // 2
        count = 0
print(ans)


Measured memory_bytes: 26136
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int a[5];
    rep(i, 5) {
        cin >> a[i];
    }
    rep(i, 5) {
        if (a[i] == 0) {
            cout << i+1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define int long long
using namespace std;

struct data {
  int x, y, h;
};

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

  data d[110];
  for (int i = 0; i < N; i++) {
    int x, y, h;
    cin >> x >> y >> h;
    d[i] = (data){x, y, h};
  }

  for (int Cx = 0; Cx <= 100; Cx++) {
    for (int Cy = 0; Cy <= 100; Cy++) {
      int H;
      for (int i = 0; i < N; i++) {
        if (d[i].h != 0) {
          H = d[i].h + abs(d[i].x - Cx) + abs(d[i].y - Cy);
          break;
        }
      }

      if (H < 1) {
        continue;
      }

      bool flag = false;
      for (int i = 0; i < N; i++) {
        if (d[i].h != max(H - abs(d[i].x - Cx) - abs(d[i].y - Cy), 0LL)) {
          flag = true;
          break;
        }
      }
      if (flag) {
        continue;
      } else {
        cout << Cx << " " << Cy << " " << H << endl;
        return 0;
      }
    }
  }
  return 0;
}

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


int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    if(a[0] == a[1])cout << a[2] << endl;
    else cout << a[0] << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256