akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<endl;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

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

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

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

ll has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=bases[3];
		h2*=bases[1];
		h2+=a-'a';
		h2%=bases[4];
	}
	return h1*(MOD+13893829)+h2;
}

const int N=300010;
ll n,m,a,x,r;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829)+13893829);
	cin>>n>>m>>a>>x;
	cout<<n*m/2.L<<' ';
	if (a==n/2.L && x==m/2.L) cout<<1;
	else cout<<0;
}




Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
void solve(){
    int n, m;
    cin >> n >> m;
    vi a(n, -1);
    bool q = true;
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        if (a[x-1] == -1) a[x-1] = y;
        else if (a[x-1] != y) q = false;
    }
    if (!q) {
        cout << -1;
        return;
    }
    if (n == 1) {
        if (a[0] == -1) a[0] = 0;
        cout << a[0];
        return;
    }
    if (a[0] == -1) a[0] = 1;
    else {
        if (a[0] == 0) {
            cout << -1;
            return;
        }
    }
    for (int i = 1; i < n; ++i) {
        if (a[i] == -1) a[i] = 0;
    }
    for (int i = 0; i < n; ++i) cout << a[i];
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

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

using p_int = pair<int, int>;

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

    int N;
    cin >> N;

    int X[N];
    int Y[N];
    for (int i = 0; i < N; ++i) {
        cin >> X[i] >> Y[i];
    }
    vector<vector<int>> PQ;
    vector<int> Q;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i != j) {
                for (auto &pq: PQ) {
                    if (pq[0] == (X[i] - X[j]) && pq[1] == (Y[i] - Y[j])) {
                        pq[2]++;
                        break;
                    }
                }
                PQ.push_back({X[i] - X[j], Y[i] - Y[j], 1});
            }
        }
    }

    int ans = 0;
    for (auto pq: PQ) {
        ans = max(ans, pq[2]);
    }

    cout << N - ans << '\n';

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define ll long long int
#define FOR(i,a,b) for(ll (i)=(a);i<(ll)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,n)
#define outi(a) printf("%lld\n",(a))
#define prial(a) cout << a << endl;
#define line cout << endl;
#define pb push_back
using namespace std;
inline ll read()
{
    ll x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
    return x;
}
//****************************

int tt;
bool checkit(int a)
{
  if(a < 0) return true;
  return false;
}

//****************************
int solve(int i);
int main()
{
  solve(0);
}
int solve(int qa) 
{
  int a = read(), b = read();
  int arr[a];
  double sum = 0;
  rep(i,a) arr[i] = read() , sum += arr[i];
  sort(arr, arr+a, greater<int>());
  double lim = (0.25*sum);
  lim = lim/b;
  //cout << lim << endl;
  rep(i,b)
  if(arr[i] < lim)
  {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long N = sc.nextLong();
		int sqrtn = (int) Math.sqrt(N);
		long a = 0;

		for (long i = 1; i <= sqrtn;) {
			if (N % i == 0) {
				a = N / i;
			}
			i++;
		}

		long b = N / a;
		long ans = Math.max(a, b);
		int len = String.valueOf(ans).length();

		// 出力
		System.out.println(len);
	}
}


Measured memory_bytes: 23764
#include <stdlib.h>
#include <math.h>
int main(){
	int N,K;
	scanf("%d %d",&N,&K);
	if((N%2==0&&N/2>=K)||(N%2!=0&&(N+1)/2>=K)){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
}

Measured memory_bytes: 128
from collections import deque
import sys
from collections import defaultdict
import copy
# input = sys.stdin.readline



H, W = map(int, input().split())
C = [list(input()) for _ in range(H)]
gone = [[0] * W for _ in range(H)]
cot = 0
que = deque()

que_count = 0
for h in range(H):
    for w in range(W):
        if C[h][w] == "#":
            gone[h][w] = 1
            que.append((h,w))
            que_count += 1
            cot += 1
INF = 10 ** 9
go = [[1, 0], [0, 1], [-1, 0], [0, -1]]
ans  = 0
nq = 0
while cot != H*W:
    while que_count != 0 and cot != H*W:
        h,w = que.popleft()
        que_count -= 1

        for temp in go:
            # この時，実際に行くのかは不明
            gx,gy = temp
            nx = w + gx
            ny = h + gy

            if 0<= nx < W and 0<= ny < H and gone[ny][nx] != 1: #行って無かったら，行く
                # この時に実際に移動する
                gone[ny][nx] = 1
                que.append( (ny,nx))
                nq += 1
                cot += 1
    que_count = nq
    nq = 0
    ans += 1
print(ans)





Measured memory_bytes: 122076
n = int(input())
w = []
for i in range(n):
    w+=[input()]
count = [w[0]]
for i in range(1,n):
    if i != 0 and not (w[i] in count) and w[i - 1][-1] == w[i][0]:
        count.append(w[i])
        pass
    else:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

const int days[12] = {
  31,29,31,30,
  31,30,31,31,
  30,31,30,31
};

const char *date[7] = {
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturday",
  "Sunday"
};

int ans[12][31];

int main(){
  int d = 3;
  REP(i,12){
    REP(j,days[i]){
      ans[i][j] = (d++)%7;
    }
  }
  int a,b;
  while(cin>>a>>b,a)
    cout << date[ans[a-1][b-1]] << endl;

  return 0;
}

Measured memory_bytes: 0
n = int(input())
h = [int(s) for s in input().split()]

dp = [0] * n
dp[0],dp[1] = 0,abs(h[1]-h[0])

for i in range(2,n):
  dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),
              dp[i-2] + abs(h[i]-h[i-2]),
             )
 
print(dp[-1])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b ;
  string result_a = "";
  string result_b = "";
  
  ostringstream oss_a,oss_b;
  oss_a << a;
  
  for (int i = 0; i < b; i++){
    result_a += oss_a.str();
  }
  oss_b << b;
  for (int j = 0; j < a; j++){
    result_b += oss_b.str();
  }
  
  istringstream(result_a) >> a;
  istringstream(result_b) >> b;
  
  if(result_a <= result_b) {
    cout << result_a << endl;
  } else {
    cout << result_b << endl;
  }
}

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

typedef pair<int, int> P;
set<P> tem;

int main() {
  int n;
  cin >> n;
  
  for (int i = 0; i < n; ++i) {
    int h, m;
    cin >> h >> m;
    tem.insert(P(h, m));
  }
  
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int k, g;
    cin >> k >> g;
    tem.insert(P(k, g));
  }
  
  for (set< pair<int, int> >::iterator it = tem.begin(); it != tem.end(); ++it) {
    pair<int, int> t = *it;
    printf("%d:%02d", t.first, t.second);
    if (++it != tem.end()) { printf(" "); }
    --it;
  }
  printf("\n");
  
  return 0;
}

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

const ll MOD = (ll)1e9+7; //change it for other mods

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve(ll testnum)
{
    ll h,w,m;
    cin >> h >> w >> m;
    vll hts(h+1, 0), wts(w+1, 0);
    map<pll, ll> mp;
    for(ll i=0; i<m; i++) {
    	ll hh, ww;
    	cin >> hh >> ww;
    	mp[{hh, ww}] = 1;
    	hts[hh]++;
    	wts[ww]++;
    }
    ll mxh = 0, mxw = 0;
    for(ll i=1; i<=h; i++) {
    	if(hts[i] > mxh) {
    		mxh = hts[i];
    	}
    }
    for(ll i=1; i<=w; i++) {
    	if(wts[i] > mxw) {
    		mxw = wts[i];
    	}
    }
    vll mphts, mpwts;
    for(ll i=1; i<=h; i++) {
    	if(hts[i] == mxh) {
    		mphts.pb(i);
    	}
    }
    for(ll j=1; j<=w; j++) {
    	if(wts[j] == mxw) {
    		mpwts.pb(j);
    	}
    }
    ll mh_n = (ll)mphts.size();
    ll mw_n = (ll)mpwts.size();
    if(mh_n*mw_n > m) {
    	cout << mxh + mxw << "\n";
    	return;
    }
    for(ll i=0; i<mh_n; i++) {
    	for(ll j=0; j<mw_n; j++) {
    		if(mp[{mphts[i], mpwts[j]}] == 0) {
    			cout << mxh + mxw << "\n";
    			return;			
    		}
    	}
    }
    cout << mxh + mxw - 1 << "\n";
}

int main()
{
    FAST_IO;
    #ifdef STIO 
      freopen("input.txt" , "r", stdin);
      freopen("output.txt" , "w", stdout);
    #endif
    ll t = 1;
    // cin >> t;
    for (ll i = 1; i <= t; i++) {
        // cout << "Case #" << i << ": ";
        solve(i);
    }
}

Measured memory_bytes: 34940
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N;
    cin>>N;
    double ans=3.14159;
    ans=2.0*ans*N;
    cout<<ans;	
	return 0;
}
 


Measured memory_bytes: 3804
s=list(input())
q=int(input())
cnt=1
sen=[]
matu=[]
for i in range(q):
    a=list(input().split())
    if a[0]=='1':
        cnt*=-1
    else:
        if a[1]=='1':
            if cnt==1:
                sen.append(a[2])
            else:
                matu.append(a[2])
        else:
            if cnt==1:
                matu.append(a[2])
            else:
                sen.append(a[2])
#print(cnt)
if cnt==-1:
    s=s[::-1]
ss=''.join(s)
if cnt==1:
    sen=sen[::-1]
sensen=''.join(sen)
if cnt==-1:
    matu=matu[::-1]
matumatu=''.join(matu)
if cnt==1:
    print(sensen+ss+matumatu)
else:
    print(matumatu+ss+sensen)


Measured memory_bytes: 76152
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		long N = GetInt();
		Console.WriteLine((N * (N - 1)) / 2);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

int main() {
	makel(a);
	makel(b);
	makel(c);
	say(min(a + 2*b + 1, b + c));
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<complex>

using namespace std;


const long long int mod=1000000007;
int main(){
	cout << fixed << setprecision(18);
	string str[300];
	char ch;
	long long int n,c,x[200000]={},v[200000],left[200000]={},left2[200000]={},right[200000]={},right2[200000]={},res=0;
	cin>>n>>c;
	for(int i=1;i<=c;i++)
	{
		cin>>x[i]>>v[i];
		left[x[i]]++;
		left[v[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(left[i]%2==1)
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
}


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



int counter(int x){
    if(x==0) return 0;
    else return counter(x >> 1) + (x & 1);
}

void solve(){
    int n;
    int a[20];
    int x[20][20];
    int y[20][20];
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        for(int j = 1; j <= a[i]; ++j){
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int bits = 1; bits < (1 << n); bits++){
        bool ok = true;
        for(int i = 1; i <= n; i++){
            if(!(bits & (1 << (i-1)))) continue;
            for(int j = 1; j <= a[i]; j++){
                if(((bits >> (x[i][j] - 1)) ^ y[i][j]) & 1) ok = false;
            }
        }
        if(ok) ans = max(ans, counter(bits));
        
    }
    cout << ans << endl;

}
int main(){
  solve();
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> road(2), cnt(n);
	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < 2; j++)
		{
		cin >> road.at(j);
		cnt.at((road.at(j))-1)++;
		}
	}

	for (int i = 0; i < n; i++)
	{
		cout << cnt.at(i) << endl;
	}

}


Measured memory_bytes: 3608
#include <iostream>
#include <cmath>

using namespace std;
using ll=long long;
int main(){// 答え見た後
    ll n, s;
    cin >> n >> s;
    if(n==s){
        cout << (n+1);
        return 0;
    }else if(n<s){
        cout << "-1";
        return 0;
    }
    ll sqrtn = (ll)sqrt((double)n);
    for(ll b=2;b<=sqrtn;++b){
        ll val=0;
        ll m=n;
        while(m!=0){
            val+=m%b;
            m = m/b;
        }
        if(val==s){
            cout << b;
            return 0;
        }
    }
    for(ll p=sqrtn;p>=1;--p){
        if((n-s)%p!=0)
            continue;
        ll b=(n-s)/p+1;
        
        ll val=0;
        ll m=n;
        while(m!=0){
            val+=m%b;
            m = m/b;
        }
        if(val==s){
            cout << b;
            return 0;
        }
    }
    if(s==1)
        cout << n;
    else
        cout << "-1";
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    for (char i = 'a'; i <= 'z'; i++) {
        if (s.find(i) == -1) {
            cout << i;
            return 0;
        }
    }
    cout << "None";
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  i64 ans = 0;
  int N, x;
  cin >> N >> x;
  vi32 a(N); cin >> a;
  rep(i, N - 1) {
    int sum = a[i] + a[i + 1];
    if (sum > x) {
      ans += sum - x;
      a[i + 1] = max(a[i + 1] - (sum - x), 0);
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 640
// ※※※ 解答不能 ※※※
// 正答者のソースを勉強する.
// kmjp氏
// https://atcoder.jp/contests/abc140/submissions/7408341
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

LL S[1<<18];

int main(){
    int N;
    scanf("%d", &N);
    for(int i = 0; i < (1<<N); i++) scanf("%lld", &S[i]);
    sort(S, S + (1<<N));
    int M = (1<<N) - 1;
    multiset<int> T;
    for(int i = 0; i < M; i++) T.insert(S[i]);
    
    vector<int> V;
    V.push_back(S[M]);
    for(int i = 0; i < N; i++){
        vector<int> W = V;
        for(auto& v : V){
            auto it = T.lower_bound(v);
            if(it == T.begin()){
                printf("%s\n", "No");
                return 0;
            }
            it--;
            W.push_back(*it);
            T.erase(it);
        }
        sort(W.begin(), W.end());
        reverse(W.begin(), W.end());
        swap(V, W);
    }
    printf("%s\n", "Yes");
    return 0;
}

Measured memory_bytes: 14592
#include <cstdio>
#include <vector>
#define R second.second
#define Z(i,a,b,c)v.insert(v.begin()+i,make_pair(a,make_pair(b,c)))
using namespace std;
main(){
	int W,Q,d,w,i;char s[2];
	for(;scanf("%d%d",&W,&Q),W;puts("END")){ //some case Q==0
		vector<pair<int,pair<int,int> > >v;
		for(Z(0,-2,0,0),Z(1,-1,W,0);Q;Q--)
			if(scanf("%s",s),*s-'w'){
				for(scanf("%d%d",&d,&w),i=0;~v[i].first;i++)if(v[i+1].second.first-v[i].R>=w){Z(i+1,d,v[i].R,v[i].R+w);printf("%d\n",v[i].R);break;}
				if(v[i].first==-1)puts("impossible");
			}else for(scanf("%d",&d),i=0;i<v.size();i++)if(v[i].first==d){v.erase(v.begin()+i);break;}
	}}

Measured memory_bytes: 1044
n = int(input())
s = []
all_ac = 0
for i in range(n):
    s.append(int(input()))
    all_ac += s[-1]
s.sort()
if((all_ac % 10) == 0):
    for x in s:
        if(x % 10 != 0):
            all_ac -= x
            break
if((all_ac % 10) == 0):
    print(0)
else:
    print(all_ac)


Measured memory_bytes: 3060
/*

    idea: start from the end and try to reach the beginning taking the longest jumps possible.

*/


#include<bits/stdc++.h>


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 1;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;
vi ans , v;

void solve(int testCase){

    scanf("%d %d" , &n , &m);

    string s;
    cin >> s;

    /// to start from the end
    reverse(s.begin() , s.end());

    /// store all positions of 0's
    for(int i = 0 ; s[i] ; i ++){
            if(s[i] == '0'){
                    v.push_back(i);
            }
    }

    // initial position
    int pos = 0;

    while( pos != n ){

            // farthest place I can go
            int nxt = upper_bound(v.begin() , v.end() , pos + m) - v.begin() - 1;

            // if I'm still in my place => no solution
            if(v[nxt] == pos){
                    printf("-1\n");
                    return;
            }

            // insert the length of the jump into the answer
            ans.push_back(v[nxt] - pos);

            // update position
            pos = v[nxt];
    }

    // print the answer backwards: from begin to end.
    reverse(ans.begin() , ans.end());

    for(int A : ans)printf("%d " , A);
    printf("\n");

}

main(){

    int t = 1;
    //scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

typedef long long ll;
#define REP(i, n) for(ll i = 0 ; i < n; i++)

#define DEBUG(fmt, ...)
//#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    ll M;

    cin >> N >> M;
    vector<ll> array(N, 0);

    REP(i, N){
        cin >> array[i];
    }

    sort(array.begin(), array.end());
    multimap<ll,ll> changes;
    REP(i, M){
        ll B, C;
        cin >> B >> C;
        changes.insert(make_pair(C,B));
    }

    ll index = 0;
    ll total = 0;
    for( auto it = changes.rbegin(); it != changes.rend(); it++ ){
        ll C = it->first;
        ll B = it->second;
        DEBUG("C B = %lld %lld", C, B);
        for( ll i = 0; i < B && (index+i) < array.size(); i++){
            total += max(array[index+i], C);
            DEBUG("total += %lld", max(array[index+i], C));
        }
        index+=B;
        if( index >= array.size()){
            break;
        }
    }

    for( ll i = index; i < array.size(); i++ ){
        total += array[i];
        DEBUG("total+=array[i] (%llu)", array[i]);
    }

    cout << total << endl;
}


Measured memory_bytes: 9344
// AOJ 0299 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0299)
#include<cstdio>
#include<algorithm>
#define rep(i,a) for(ll i=0;i<(a);++i)

typedef long long ll;

const int MAX_M = 10000;

ll N, M, p;
ll d[MAX_M];

int main()
{
	scanf( "%lld%lld%lld", &N, &M, &p );
	rep( i, M )
	{
		scanf( "%lld", d+i );
		d[i] = (d[i]-p+N)%N;
	}

	std::sort( d, d+M );

	ll ans = N-1;
	rep( i, M )
		ans = std::min( ans, std::min( d[i]+std::min( d[M-1]-d[i], (d[i]+N-d[(i+1)%M])%N ), N-d[i]+std::min( d[i]-d[0], (N-d[i]+d[(i-1+M)%M])%N ) ) );

	printf( "%lld\n", ans*100 );

	return 0;
}

Measured memory_bytes: 1116
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        System.out.println(dfs(n, new Integer[n + 1]));
    }

    private static int dfs(int target, Integer[] dp) {
        if (target == 0) {
            return 0;
        }
        if (dp[target] != null) {
            return dp[target];
        }
        int maxNine = 1, maxSix = 1;
        while (maxNine * 9 <= target) {
            maxNine *= 9;
        }
        while (maxSix * 6 <= target) {
            maxSix *= 6;
        }
        return dp[target] = Math.min(1 + dfs(target - maxNine, dp), 1 + dfs(target - maxSix, dp));
    }

    static final class Utils {
        public static void shuffleSort(int[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffleSort(long[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffle(int[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void shuffle(long[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void swap(int[] arr, int i, int j) {
            final int t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        public static void swap(long[] arr, int i, int j) {
            final long t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        private Utils() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 33028
#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() {
    string s;
    cin >> s;
    if(s == "ABC")cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3624
k = int(input())
if k % 50 == 0:
    ans = [50 + (k // 50) - 1] * 50
else:
    mm = k % 50
    base = 50 + 50 - mm
    k -= mm
    k = k // 50
    lul = 50 - mm - 1 + k
    k += base
    ans = [k] * mm + [lul] * (50 - mm)

print(50)
print(' '.join([str(x) for x in ans]))


Measured memory_bytes: 38384
N = int(input())
A = list(map(int, input().split()))

count = 1
first = True
isIncrease = False
for i in range(1, len(A)):
    if first == True:
        if A[i] > A[i - 1] :
            isIncrease = True
            first = False
        elif A[i] < A[i - 1] : 
            isIncrease = False
            first = False
    else:
        if isIncrease == True and A[i] < A[i - 1]:
            isIncrease = False
            count += 1
            first = True
        elif isIncrease == False and A[i] > A[i - 1]:
            isIncrease = True
            count += 1
            first = True
            
print(count)

Measured memory_bytes: 14252
import Data.List
import Data.Maybe

main = do
    n <- readLn
    p <- map read . words <$> getLine
    q <- map read . words <$> getLine
    let sorted_comb = sort $ permutations [1 .. n]
    let a = elemIndex p sorted_comb
    let b = elemIndex q sorted_comb
    print $ abs $ fromJust b - fromJust a

Measured memory_bytes: 21756
#include<bits/stdc++.h>
#define M 10001
using namespace std;
int n,k,t,u,v,l,d,c,x,a,s[M];
 
int main(){
  cin>>n>>k>>t>>u>>v>>l;
  for(int i=0;i<n;i++)cin>>d,s[d]=1;
  for(int i=0;i<l;i++){
    if(s[i])
      if(!x||k==c)x=v*t;
      else c++;
    else if(!x&&c)c--,x=v*t;
    if(x)a++,x--;
  }
  printf("%.8f\n",a*1.0/v+(l-a)*1.0/u);
  return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a) - 1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i -  1) * 10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}
 
struct IoSetup {
  	IoSetup() {
    	cin.tie(nullptr);
    	ios::sync_with_stdio(false);
    	cout << fixed << setprecision(15);
  	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

int N, X, T;

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

	cout << (N / X + !!(N % X)) * T << endl;
	
	return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int N, pow=1;
    cin >> N;
    
    vector<double> vec;
    for(int i=0; i<N; i++) {
        double v;
        cin >> v;
        vec.push_back(v);
        if(i==0) continue;
        pow *= 2;
    }
    
    sort(vec.begin(), vec.end());
    
    // double ans=(double)vec[0]/pow;
    // for(int i=1; i<N; i++) {
    //     ans += (double)vec[i]/pow;
    //     pow /= 2;
    // }
    
    double ans=vec[0];
    for(int i=1; i<N; i++) {
        ans += (double)vec[i];
        ans /= 2;
    }

    cout << ans << endl;

    return 0;
    
}

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

void answer1() {
  cin.tie(0);
	ios_base::sync_with_stdio(false);

  int N, Y;
  cin >> N >> Y;

  // x + y + z = N &&
  // 10000 * x + 5000 * y + 1000 * z == Y
  bool can_continue = true;
  for (int x = 0; x <= Y / 10000; x++) {
    if (x > N) {
      break;
    }
    int x_made = x * 10000;

    for (int y = 0; y <= Y / 5000; y++) {
      int y_made = x_made + y * 5000;
      if (y_made > Y || x + y > N){
        break;
      }

      for (int z = 0; z <= Y / 1000; z++) {
        int z_made = y_made + z * 1000;
        if (z_made > Y || x + y + z > N) {
          break;
        } else if (z_made == Y && x + y + z == N){
          printf("%d %d %d\n", x, y, z);
          can_continue = false;
        }
      }
      if (! can_continue){
        break;
      }
    }
    if (! can_continue){
      break;
    }
  }
  if (can_continue) {
    printf("%d %d %d\n", -1, -1, -1);
  }
}

void answer2() {
  cin.tie(0);
	ios_base::sync_with_stdio(false);

  int N, Y;
  cin >> N >> Y;

  // x + y + z = N &&
  // 10000 * x + 5000 * y + 1000 * z == Y
  bool can_continue = true;
  for (int x = 0; x <= Y / 10000; x++) {
    if (x > N) {
      break;
    }
    int x_made = x * 10000;

    for (int y = 0; y <= Y / 5000; y++) {
      int y_made = x_made + y * 5000;
      if (y_made > Y || x + y > N){
        break;
      }

      int z = N - x - y;
      int z_made = y_made + z * 1000;
      if (z_made == Y) {
        printf("%d %d %d\n", x, y, z);
        can_continue = false;
        break;
      }
    }
    if (! can_continue){
      break;
    }
  }
  if (can_continue) {
    printf("%d %d %d\n", -1, -1, -1);
  }
}

void answer3() {
  cin.tie(0);
	ios_base::sync_with_stdio(false);

  int N, Y;
  cin >> N >> Y;

  bool is_found = false;
  for (int x = 0; x <= Y / 10000; x++) {
    if (x > N) {
      break;
    }

    int nokori_maisu = N - x;
    int nokori_kingaku = Y - x * 10000;

    // 連立方程式
    // |- y + z == nokori_maisu
    // |- 5000 * y + 1000 * z == nokori_kingaku
    // => 4000 * y == nokori_kingaku - 1000 * nokori_maisu && yは整数
    // => (nokori_kingaku - 1000 * nokori_maisu) % 4000 == 0

    if ((nokori_kingaku - 1000 * nokori_maisu) % 4000 == 0) {
      int y = (nokori_kingaku - 1000 * nokori_maisu) / 4000;
      int z = N - x - y;
      if (z < 0 || y < 0) {
        continue;
      }
      printf("%d %d %d\n", x, y, z);
      is_found = true;
      break;
    }
  }
  if (! is_found) {
    printf("%d %d %d\n", -1, -1, -1);
  }
}

int main() {
  //answer1(); // 実行時間制限超過
  //answer2(); // 二重for文
  answer3(); // 連立方程式を利用してfor文一つ
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;
using ll  = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(i, ini));
    return move(vec);
}
template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

int main() { 
    int N = In<int>();
    vector<int> As(N), Bs(N), Cs(N - 1);
    for(int i = 0; i < N; i++)   As[i] = In<int>();
    for(int i = 0; i < N; i++)   Bs[i] = In<int>();
    for(int i = 0; i < N-1; i++) Cs[i] = In<int>();

    int ans = 0, last = -2;
    for(int i = 0; i < N; i++) {
        if(last == As[i]-1){
            ans += Cs[last-1];
        }
        ans += Bs[i];
        last = As[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def chg(s,n):
    res=""
    for i in s:
        o=ord(i)
        if 97<=o<=122:
            if o+n<=122:
                res+=chr(o+n)
            else:
                res+=chr(o+n-26)
        else:
            res+=i
    return res

while True:
    try:
        s=input()
        for i in range(25,-1,-1):
            c=chg(s,i)
            e=c.split()
            if "the" in e or "this" in e or "that" in e:
                print(c)
                break
    except:
        break

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back

ll n, p;

int main() {
	cin >> n >> p;
	ll c[2] = {1, 0};
	for (ll i = 0; i < n; ++i) {
		ll x;
		cin >> x;
		if (x % 2 == 1) {
			c[0] = c[1] = c[0] + c[1];
		} else {
			c[0] *= 2;
			c[1] *= 2;
		}
	}
	
	cout << c[p] << endl;
	
	return 0;
}


Measured memory_bytes: 256
main(i,N,T,E,x,y){for(scanf("%d%d%d",&N,&T,&E),i=1;i<=N;i++){for(scanf("%d",&x),y=0;y<T-E;y+=x);if(y<=T+E){printf("%d\n",i);break;}}if(i>N)puts("-1");exit(0);}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
  
int main()
{
  ll n, d, ans=1;
  cin >> n >> d;
  while(ans*(2*d+1) < n)
  {
    ++ans;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const ll MAX_N = 1000000;
int N;
ll T[100];

int arr[MAX_N + 1];
vint primes;

void Eratosthenes(){

    rep(i, MAX_N+1) arr[i] = 1;

	for(int i = 2; i <= sqrt(MAX_N); i++){
		if(arr[i] == 1){
			for(int j = 0; i * (j + 2) <= MAX_N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for(int i = 2; i <= MAX_N; i++){
		if(arr[i] == 1){
			primes.push_back(i);
		}
	}
}


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

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

int main() {
	cin >> N;
	rep(i, N) cin >> T[i];
    sort(&T[0], &T[N]);

    ll ret = T[0];
    rep(i, N-1){
        ret = lcm(ret, T[i+1]);
    }
    cout << ret << endl;

    /*
	Eratosthenes();


    if (T[N-1] >= MAX_N * 2){
        ll ret = 0;
        while(true){
            ret += T[N-1];
        }
    }
    else{
        // sieve
    }
     */

	// rep(i, primes.size()) cerr << primes[i] << endl;

	/*
	ll ret = 1;
	ll d = 2;
	while(true){
		bool flg = false;
		rep(i, N){
			if(T[i] % d == 0) {
				T[i] /= d;
				flg = true;
			}
			if(flg){
				ret *= d;
			}
			else{
				d++;
			}
		}


	}
	 */
}

Measured memory_bytes: 256
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                String S = scan.next();
                String T = scan.next();
                
                int cnt=0;
                for(int i=0; i<S.length();i++){
                    char a = S.charAt(i);
                    char b = T.charAt(i);
                    if(!(a==b)){
                        cnt++;
                    }
                }
                System.out.println(cnt);
        }               
}


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

int main() {
  long long n, d;
  cin >> n >> d;
  int count = 0;
  for (long long i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    if (x*x + y*y <= d*d) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3620
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
B=get_i
ans=[]
N.times do|i|
  if B[i]>i+1
      puts "-1"
      exit
  end  
  ans.insert(B[i]-1,B[i])
end
puts ans

Measured memory_bytes: 14236
#include <stdio.h>
 
int main(void) {
  
  int N;
  int H[101];
  
  scanf("%d", &N);
  for(int i = 0; i < N; ++i) scanf("%d", &H[i]);
  
  int max_height = H[0];
  int view_count = 1;
  for(int i = 1; i < N; ++i) {
    if(max_height <= H[i]) {
      view_count++;
      max_height = H[i];
    }
  }
 
  printf("%d", view_count);
  
  return 0;
  
}

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

namespace AtCoder.Contests.ABC164
{
    /// <summary>
    /// 
    /// </summary>
    static class D
    {
        static void Main(string[] args)
        {
            var s = Next();

            var counts = new Dictionary<int, int>();
            counts[0] = 1;
            var mod = 2019;

            var m10 = 1;
            var num = 0;
            for (int i = s.Length - 1; i >= 0; i--)
            {
                num = (num + m10 * (s[i] - '0')) % mod;
                if (counts.ContainsKey(num)) counts[num]++;
                else counts[num] = 1;

                m10 = (m10 * 10) % mod;
            }

            Console.WriteLine(counts.Values.Select(x => x * (x - 1) / 2).Sum());
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 27420
#include<iostream>

using namespace std;

const int seki[] = {6000 , 4000 , 3000 , 2000};

int main(void)
{
	int input[4];
	
	for (int i = 0; i < 4; i++)
	{
		int index;
		cin >> index;
		
		cin >> input[i];
		input[i] = input[i] * seki[index - 1];
	}	
	
	for (int i = 0; i < 4; i++)
	{
		cout << input[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
import Control.Monad
import Control.Applicative
import Numeric

main = do
  [a,b] <- map read . words <$> getLine
  let d = div a b :: Int
      r = mod a b 
      f = (realToFrac a) / (realToFrac b) :: Double
  putStrLn $ show d ++ " " ++ show r ++ " " ++ showFFloat (Just 5) f "" 

Measured memory_bytes: 3796