akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;


int main()
{
    int n; cin >> n;
    vector<int> x(n + 1);
    vector<int> y(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> x[i];
    }

    copy(x.begin(), x.end(), y.begin());
    sort(y.begin(), y.end());

    for(int i = 1; i <= n; i++){
        if(x[i] <= y[n/2]){
            cout << y[n/2 + 1] << endl;
        }
        else{
            cout << y[n/2] << endl;
        }
    }
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <cstdio>
#include <math.h>
#include <utility>
#include <list>
#include <functional>
#include <queue>
using namespace std;

#define ll long long
#define vecint vector<int>
#define Pii pair<int, int>

#define REP(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define print(a) cout << a << endl

#define MOD 1000000007
#define NIL -1

int A,B,C;

void solve(){
    if(C>=A&&C<=B){
        print("Yes");
    }else{
        print("No");
    }
    return;
}



int main(){
    cin>>A>>B>>C;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <tuple>
#include <map>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using lli = long long int;
using pii = std::pair<int, int>;

// UnionFind 木 ; 頂点 = 0, 1, 2, ...,  n-1
class UnionFindTree{
private:
    using Vint = std::vector<int>;
    const int n; // 集合の大きさ
    Vint Parent; // 親のインデックスを指し示す
    Vint SetSize; // 各集合の大きさ(要素数)を保持する関数
public:
    // コンストラクタ
    UnionFindTree(int nn): n(nn){
        SetSize.resize(n, 1);
        Parent.resize(n);
        // 初めは, 全ての頂点は根である
        for(int i = 0; i < n; ++i) Parent[i] = i;
    }
    // デコンストラクタ
    ~UnionFindTree(void){}
    // 頂点 x の属する集合の根を返す関数
    int rootOf(int x){
        // x が 根であるなら終了
        if(Parent[x] == x) return x;
        // そうでないなら, 親を属する集合の根に付け替える
        return Parent[x] = rootOf(Parent[x]);
    }
    // 頂点 x, y を併合する
    void unite(int x, int y){
        int root_x = rootOf(x);
        int root_y = rootOf(y);
        // 異なる集合に属する場合
        if(root_x == root_y) return;
        if(SetSize[root_x] < SetSize[root_y]) std::swap(root_x, root_y);
        Parent[root_y] = root_x;
        SetSize[root_x] += SetSize[root_y];
    }
    // 頂点 x, y が 同じ集合に属しているかを判定する
    bool sameSet(int x, int y){
        return rootOf(x) == rootOf(y);
    }
    // 頂点 x の属する集合の要素数
    int sizeOf(int x){
        return SetSize[rootOf(x)];
    }
};


int main(void){
    int n, k, l; scanf("%d%d%d", &n, &k, &l);
    UnionFindTree A(n), B(n);
    REP(i, k){
        int a, b; scanf("%d%d", &a, &b); a--; b--;
        A.unite(a, b);
    }
    REP(i, l){
        int a, b; scanf("%d%d", &a, &b); a--; b--;
        B.unite(a, b);
    }
    std::map<pii, int> C;
    REP(i, n) C[pii(A.rootOf(i), B.rootOf(i))]++;
    REP(i, n){
        printf("%d", C[pii(A.rootOf(i), B.rootOf(i))]);
        putchar(i == n - 1 ? '\n' : ' ');
    }
    return 0;
}

Measured memory_bytes: 15104
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL

struct Edge {
	int from, to;
	ll w;
};
typedef vector<vector<Edge>> Graph;

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


bool BellmanFord(Graph g, int s, vector<ll>& dis) { //is huheiro aru
#define INF 10000000000000LL
	fill(ALL(dis), INF);
	dis[s] = 0;
	REP(cc, g.size()*10) {

		REP(v, g.size()) {
			for (auto e : g[v]) {
				if (cc >= g.size() && e.to == g.size()-1 && dis[e.to] > dis[e.from] + e.w) return 1;
				dis[e.to] = min(dis[e.to], dis[e.from] + e.w);
			}
		}

	}


	return 0;
}

signed main(void) {
	ll n, m;
	cin >> n >> m;

	vector<ll> x(n), y(m);

	REP(i, n) {
		cin >> x[i];
	}

	REP(j, m) {
		cin >> y[j];
	}

	ll A = 0, B = 0, C = 0,D = 0, E= 0;

	rep(i, 1, m + 1) {
		(B += y[i-1])%=MODU;
		(C += i * y[i-1])%= MODU;

		(A += y[i-1] * (i - 1))%= MODU;
	}
	rep(i, 1, n + 1) {
		(D += x[i - 1] * (i - 1)) %= MODU;
		(E += (n - i) * x[i - 1]) %= MODU;
	}
	cout << ((((A - m * B + C)%MODU) * (D - E) % MODU) + MODU)%MODU << endl;
	return 0;
}



Measured memory_bytes: 1792
def bubble_sort(elems: list) -> list:
    swap_num = 0
    for i in range(0, len(elems)):
        for j in range(len(elems) - 1, i, -1):
            if elems[j] < elems[j - 1]:
                elems[j], elems[j - 1] = elems[j - 1], elems[j]
                swap_num += 1
    return [elems, swap_num]


if __name__ == "__main__":
    elem_num = int(input())
    elems = list(map(lambda x: int(x), input().split()))
    elems, swap_num = bubble_sort(elems)
    print(" ".join([str(elem) for elem in elems]))
    print(f"{swap_num}")



Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}

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

  int h, w;
  cin >> h >> w;
  vt<string> a(h);
  rep(i, 0, h) cin >> a[i];

  vt<string> red(h), blue(h);
  rep(i, 0, h) {
    red[i] = '#';
    blue[i] = '.';
    if(i % 2) {
      red[i] += string(w - 2, '#');
      blue[i] += string(w - 2, '.');
    }
    else {
      red[i] += string(w - 2, '.');
      blue[i] += string(w - 2, '#');
    }
    red[i] += '.';
    blue[i] += '#';
  }

  rep(i, 0, h) {
    rep(j, 0, w) {
      if(a[i][j] == '#') red[i][j] = blue[i][j] = '#';
    }
  }

  rep(i, 0, h) cout << red[i] << endl;
  cout << endl;
  rep(i, 0, h) cout << blue[i] << endl;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int a, b, c;
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == 'a') a++;
        if(S[i] == 'b') b++;
        if(S[i] == 'c') c++;
    }
    if(max(a, max(b, c)) - min(a, min(b, c)) <= 1) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 512
from collections import Counter
from itertools import product

n,m,q  = map(int,input().split())
rails=[tuple(map(int,input().split())) for i in range(m)]
qs=[tuple(map(int,input().split())) for i in range(q)]

xlist = [[0 for j in range(n)] for i in range(n)]
sumlist = [[0 for j in range(n+1)] for i in range(n)]
for (l,r),i in Counter(rails).items():
    xlist[l-1][r-1]=i


for (i,j) in product(range(n),range(n)):
    sumlist[i][j+1]=sum(xlist[i][0:j+1])


for (p,q) in qs:
    ans = 0
    for i in range(p-1,q):
        ans = ans+sumlist[i][q]-sumlist[i][p-1]
    print(ans)


Measured memory_bytes: 123736
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

std::vector<std::string> split(const std::string &s, const std::string &delim) {
  using string = std::string;
  std::vector<string> v;
  string::size_type pos = 0;
  while (pos != string::npos) {
    string::size_type p = s.find(delim, pos);
    if (p == string::npos) {
      v.push_back(s.substr(pos));
      break;
    }
    v.push_back(s.substr(pos, p - pos));
    pos = p + delim.size();
  }
  return v;
}

main {
  int n, t;
  cin >> n >> t;
  V<P<string, int>> out;
  V<tuple<int, string, int>> v(n);
  rep(i, n) {
    string a, b, c, d;
    cin >> a >> b >> c >> d;
    vs v1 = split(a, ":"), v2 = split(c, ":");
    v[i] = make_tuple(stoi(v1[0]) * 60 + stoi(v1[1]), b, stoi(v2[0]) * 60 + stoi(v2[1]));
  }
  loop(i, 1, n) {
    int d = get<0>(v[i]) - get<2>(v[i - 1]);
    if (d >= t) out.emplace_back(get<1>(v[i]), d);
  }
  cout << out.size() << endl;
  for (auto &p : out) cout << p.first << ' ' << p.second << endl;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N;

bool check(int k)
{
    int mx = k % 10;
    k /= 10;
    while (k > 0)
    {
        if (k % 10 != mx - 1)
            return false;
        mx = k % 10;
        k /= 10;
    }
    return true;
}

int main()
{
    cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++)
        cin >> v[i];
    vector<int> sub;
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            sub.push_back(v[i] * v[j]);
        }
    }
    sort(sub.rbegin(), sub.rend());
    for (auto &M : sub)
    {
        if (check(M) == true)
        {
            cout << M << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 4964
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define ff first
#define ss second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vc vector<char> 
#define vll vector< pair<ll,ll> > 
#define pr pair<ll,ll>
#define mps map<string ,ll>
#define mpc map<char ,char>
#define mpl map<ll,ll>
#define tpl tuple<ll,ll,ll>
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;
//	   cin>>t;
	      while(t--)
{


/*
needed*/
ll n,m,j,k,l,i;
string s;
cin>>s;
l=s.length();
map<char ,ll >M;
fo(i,l)
M[s[i]]=0;
for(i=1;i<=l;i++)
{
	if(M[s[i-1]]&&i-M[s[i-1]]<=2&&i-M[s[i-1]]>0)
	{
		cout<<M[s[i-1]]<<" "<<i;
	//	break;
	return 0;
	}
	M[s[i-1]]=i;
}
cout<<-1<<" "<<-1;
ee;


}
return 0;
}



Measured memory_bytes: 3784
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }

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

LL a,b,c,d;
void input() {
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
}

void solve() {
	LL e = lcm(c,d);
	printf("%lld\n", (b-a+1) - (b/c - (a-1)/c) - (b/d - (a-1)/d) + (b/e - (a-1)/e));
}

int main( int argc, char *argv[] ) {
	input();
	solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int

int ans[500*500 + 10] = {0};
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;cin >> n;
    vpii dis(n);
    FOR(i, n)cin >> dis[i].first, dis[i].second = i + 1;
    sort(dis.begin(), dis.end());
    int sum = 0;
    int top = 1;
    FOR(i, dis.size()){
        int val = dis[i].second;
        int pos = dis[i].first;
        ans[pos] = val;
        sum += val;
        if(pos < sum){
            cout << "No";
            return 0;
        }
        FOR(j, val - 1){
            while(ans[top] != 0)top++; 
            ans[top] = val;
        }
    }

//    FOR1(i, n*n)cout << ans[i] << " ";cout <<endl;

    FOR(i, dis.size()){
        int val = dis[i].second;
        while(ans[top] != 0)top++;
        if(top < dis[i].first){
            cout << "No";
            return 0;
        }
        FOR1(j, n - dis[i].second){
            while(ans[top] != 0)top++;
            ans[top] = val;
        }
    }
    cout << "Yes" << endl;
    FOR1(i, n*n){
        cout << ans[i] << " ";
    }

}




Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{ll to,cost;};
const int inf = 1<<27;
const ll INF = 1LL<<60;
const int COMBMAX = 1001001;
const ll MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (ll)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (ll)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
ll mpow(ll a, ll n, ll mod = MOD){ll res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> ll bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> void sortTwoVecter(vector<T1> &f, vector<T2> &s, bool isReverse = false){
    vector<pair<T1, T2>> p;
    rep(i, f.size()) p.emplace_back(make_pair(f[i], s[i]));
    if (!isReverse) sort(p.begin(), p.end());
    else sort(p.rbegin(), p.rend());
    rep(i, f.size()) tie(f[i], s[i]) = p[i];
    return;
}

int main(){
    ll X, Y, Z; cin >> X >> Y >> Z;
    pt(Z, X, Y);
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
n,a,b = [int(x) for x in stdin.readline().rstrip().split()]

saisyou = a*(n-1)+b
saidai = b*(n-1)+a

if n == 1 and a!= b:
    print(0)
    exit()
elif a > b:
    print(0)
    exit()
else:
    print(saidai-saisyou+1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <stdio.h>

using namespace std;

const int INF = 1e9 + 5;

int main(){

    int n;
    scanf("%d", &n);
    int k;
    scanf("%d", &k);
    vector<int> h(n);
    for(int &x : h){
        scanf("%d", &x);
    }

    vector<int> dp(n, INF); 
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
         for(int j = i + 1; j <= k + i ; ++j){  
            if(j < n){
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[n-1]);

    return 0;
}

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

#define int long long

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

int N, A, B;

signed main() {
    cin >> N >> A >> B;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int sum = i / 10000 + i % 10000 / 1000 + i % 1000 / 100 + i % 100 / 10 + i % 10;
        if (A <= sum && sum <= B) {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using ll = long long;
using p = std::pair<ll, ll>; // 円, 本数

int main(){
    ll n, m;
    std::cin >> n >> m;
    std::vector<p> goods(n);
    for(int i = 0; i < n; i++){
        std::cin >> goods[i].first >> goods[i].second;
    }
    std::sort(goods.begin(), goods.end());

    ll num = 0;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(num + goods[i].second >= m){
            ans += (m - num) * goods[i].first;
            break;
        }else{
            num += goods[i].second;
            ans += goods[i].first * goods[i].second;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


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

int N;
vector<long long> A, B;

int main() {
    while (cin >> N) {
        A.resize(N+1); B.resize(N);
        for (int i = 0; i < N+1; ++i) cin >> A[i];
        for (int i = 0; i < N; ++i) cin >> B[i];

        long long res = 0;
        for (int i = 0; i < N; ++i) {
            long long left = min(A[i], B[i]);
            res += left;
            A[i] -= left;
            B[i] -= left;

            long long right = min(A[i+1], B[i]);
            res += right;
            A[i+1] -= right;
            B[i] -= right;
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

#define PI 3.14159265359

int main() {
    
    cout << fixed << setprecision(9);

    double a, b, x;
    cin >> a >> b >> x;

    double half = a * a * b / 2;
    double theta;
    if (x <= half) {
        theta = 90.0 - atan((2*x)/(a*b*b)) * 180 / PI;
    } else {
        theta = 90.0 - atan((a*a*a)/(2*(a*a*b-x))) * 180 / PI;
    }

    cout << theta;
}




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

int main(){
    int H,W;cin>>H>>W;
    int info[H][W];
    int count=0;
    rep(i,H){
        string S;cin>>S;
        rep(j,W){
            char s=S[j];
            if(S[j]=='#')info[i][j]=-1;
            else{
                info[i][j]=INF;
                count++;
            }
        }
    }
    info[0][0]=1;
    const int dy[4]={0,1,0,-1},dx[4]={1,0,-1,0};
    queue<pair<int,int>> que;
    que.push(make_pair(0,0));
    while(que.size()){
        int p=que.front().first,q=que.front().second;
        que.pop();
        rep(i,4){
            if(0<=p+dy[i] and p+dy[i]<H and 0<=q+dx[i] and q+dx[i]<W){
                if(info[p+dy[i]][q+dx[i]]==INF){
                    que.push(make_pair(p+dy[i],q+dx[i]));
                    info[p+dy[i]][q+dx[i]]=min(info[p+dy[i]][q+dx[i]],info[p][q]+1);
                }
            }
        }
    }
    if(info[H-1][W-1]==INF)cout<<-1<<endl;
    else cout<<count-info[H-1][W-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int b[3]={},n,f=0;
	string a;
	cin>>n>>a;
	for(int i=0;i<n;i++) 
	{
		--a[i];
		if(a[i]=='1') f=1;
		b[a[i]-'0']+=(((n-1)&i)==i);
	}
	if(b[1]&1) puts("1");
	else if(!f&&(b[2]&1)) puts("2");
	else puts("0");
	return 0;
}

Measured memory_bytes: 1412
i = list(map(int, input().split()))
K = i[0]
N = i[1]

s = list(map(int, input().split()))

m = K

for i in range(N - 1):
  t = max(abs(s[i] - s[i + 1]), K - abs(s[i] - s[i + 1]))
  if t <= m:
     m = t

if max(abs(s[0] - s[N - 1]), K - abs(s[0] - s[N - 1])) <= m:
  m = max(abs(s[0] - s[N - 1]), K - abs(s[0] - s[N - 1]))

print(m)

Measured memory_bytes: 77516
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Harshad
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class A {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n,m; in>>n>>m;
        char arr[n][m];
        for(int i=0; i<n; ++i)
            for(int j=0; j<m; ++j)
                in>>arr[i][j];

        for(int i=0; i<n; ++i){
            for(int j=0; j<m; ++j){
                if(arr[i][j]=='#'){
                    out<<arr[i][j];
                    continue;
                }
                int num=0;
                if(j+1<m) num+=(arr[i][j+1]=='#');
                if(i+1<n) num+=(arr[i+1][j]=='#');
                if(j-1>-1) num+=(arr[i][j-1]=='#');
                if(i-1>-1) num+=(arr[i-1][j]=='#');
                if(j+1<m && i+1<n) num+=(arr[i+1][j+1]=='#');
                if(j+1<m && i-1>-1) num+=(arr[i-1][j+1]=='#');
                if(j-1>-1 && i-1>-1) num+=(arr[i-1][j-1]=='#');
                if(i+1<n && j-1>-1) num+=(arr[i+1][j-1]=='#');
                out<<num;
            }
            out<<"\n";
        }

	}
};


int main() {
	A solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import numpy as np

N,K = [int(i) for i in input().split()]
n = np.array([int(i) for i in input().split()])
n=np.sort(n)

mn = n[np.where(n<0)]
mz = n[np.where(n==0)]
mp = n[np.where(n>0)]

#cn = len(mn)
##cp = len(mp)
#cz = len(mz)
#tcn = cn*cp

#if cn*cp < K <= cn*cp + (N-cz)*cz + cz*(cz-1)//2:
#    print(0)
#    exit(0)

M = 10**18
m = -1*M-1
pos = 0

while M-m > 1:
    a = 0
    pos=(M+m)//2
    a+=np.searchsorted(n,pos//mp,side="right").sum()
    if pos >= 0: a+=len(mz)*N
    a+=N*len(mn) - np.searchsorted(n,-(-pos//mn),side="left").sum()
    a-=np.count_nonzero(n*n <= pos)
    a=a//2
    if a >= K:
        M=pos
    else:
        m=pos
#print(M,m)
print(M)


Measured memory_bytes: 32304
let () =
  let (n, a, b) = Scanf.sscanf (input_line stdin) "%d %d %d" (fun n a b -> (n, a, b)) in
  if n * a <= b then
    (print_int (n * a);
     print_newline ())
  else
    (print_int b;
     print_newline ())    


Measured memory_bytes: 384
#include <stdio.h>
int main() {
	int H, W;
	 while (1){
		scanf("%d%d", &H, &W);
		if (H == 0 && W == 0)
			break;
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	 return 0;
}

Measured memory_bytes: 2552
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;

int S[100001];
int N;

bool binary(int q, int left, int right){
    int mid = (left + right)/2;
    if (right - left == 1) return (S[left] == q);
    
    if (S[mid] > q) {
        return binary(q, left, mid);
    }else{
        return binary(q, mid, right);
    }
}

int main(){
    int q,Noq;
    cin >> N;
    
    for (int i = 0; i < N; i++) scanf("%d",&S[i]);
    
    cin >> Noq;
    int count = 0;
    
    for (int i = 0; i < Noq; i++) {
        scanf("%d",&q);
        if (binary(q,0,N)) count++;
    }
    
    printf("%d\n",count);
    
    return 0;
}

Measured memory_bytes: 1616
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when usesing getline(cin, s)
        while(T--)
        {
            ll k;
            int ans=-1,i,j;
            cin>>k;
            ll z=7;
            for(i=1;i<=10000000;++i)
            {
                if(z%k==0)
                {
                    ans=i;
                    break;
                }
                z=(z*10)+7;
                z=z%k;
            }
            cout<<ans<<endl;
        }
        return 0;
    }


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

int main() {
int n,z,w,a[2000];
cin>>n>>z>>w;
for(int i=0;i<n;i++){
    cin>>a[i];
}
if(n==1){
    cout<<abs(w-a[0])<<endl;
}else{
    cout<<max(abs(a[n-1]-a[n-2]),abs(w-a[n-1]));
}
	return 0;
}

Measured memory_bytes: 256
from heapq import heappop,heappush,heapify
def main(n,s):
  from collections import Counter
  cs=Counter(s)
  key=sorted(cs)
  # 最大の体力をkとする
  # 根つき木。葉と枝。
  # 体力kのスライムは根。1のスライムは葉
  # 1は最大2**(n-1)。
  # 体力k-1の親はkのスライム
  # 体力k-1のスライムがn個なら、kのスライムは毎秒k-1を作った。
  # 逆にn個未満なら、k-1未満のスライムを作った秒がその差だけある
  # 体力kは子をn個持てる。体力k-1は子をn-1個持てるものが一個、n-2個持てるものが1個、。。。
  # 体力k-2は難しい。1秒時点で作られたならn-1個子を持てる。その場合、k-1でn-1の子を持てるものはいなくなる。
  # これは考慮しなくてもいいか。k-3のスライムはk,k-1,k-2のどれから生まれたかを考慮しなくてもいい
  if cs[key[-1]]!=1:return 'No'
  if len(key)<n+1:return 'No'
  now=1
  tt=[-n]
  ntt=[]
  for x in key[::-1]:
      #print(now)
      if now<cs[x]:return 'No'
      now-=cs[x]
      for _ in range(cs[x]):
          if not tt:break
          tmp=heappop(tt)
          tmp*=-1
          now+=tmp
          for i in range(1,tmp):
            ntt.append(-i)
      while ntt:
        heappush(tt,ntt.pop())
  return 'Yes'

n=int(input())
s=list(map(int,input().split()))
print(main(n,s))
s.sort()
#print(n)
#print(*s,sep=' ')


Measured memory_bytes: 144516
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n;
char tmp[maxn];
string s;

int read() {
  if (scanf("%s", tmp) < 1) {
    return false;
  }
  s = tmp;
  n = sz(s);
  return true;
}

void solve() {
  int l = 0, r = n;
  int res = 0;
  while (l < r - 1) {
    if (s[l] == 'x') {
      if (s[r - 1] == 'x') {
        l++;
        r--;
      } else {
        l++;
        res++;
      }
    } else {
      if (s[r - 1] == 'x') {
        r--;
        res++;
      } else {
        if (s[l] != s[r - 1]) {
          printf("-1\n");
          return;
        } else {
          l++;
          r--;
        }
      }
    }
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include<math.h>
using namespace std;
 int main(){
   int a,b;
   cin >> a >>b;
  if(a*b%2==0) cout << "No" <<endl;
   else cout << "Yes" <<endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int A, B;
	cin >> A >> B;

	cout << (A - 1) * (B - 1) << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main()
{
    map<char, string> str_map;
    cin >> str_map['a'];
    cin >> str_map['b'];
    cin >> str_map['c'];

    char index = 'a';
    char tmp_char;

    while (true) {
        tmp_char = str_map[index][0];
        str_map[index].erase(str_map[index].begin());
        index = tmp_char;
        if (str_map['a'].empty() || str_map['b'].empty() || str_map['c'].empty()) {
            break;
        }

    }

    while (true) {
        if (str_map[index].empty()) {
            cout << char(index - 32) << endl;
            break;
        }
        tmp_char = str_map[index][0];
        str_map[index].erase(str_map[index].begin());
        index = tmp_char;
    }

    return 0;
}

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

map<int, pair<int, int>> st;
long long ans[100005];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		int tmp;
		scanf("%d", &tmp);
		auto &&p = st[tmp];
		p.second++;
		if (p.first == 0) p.first = i;
		else p.first = min(p.first, i);
	}

	while (st.rbegin()->second.first != 1)
	{
		auto ri1 = st.rbegin();
		auto ri2 = next(ri1);
		int diff = ri1->first - ri2->first;
		ans[ri1->second.first] += diff * 1ll * ri1->second.second;
		ri2->second.second += ri1->second.second;
		ri2->second.first = min(ri2->second.first, ri1->second.first);
		st.erase(prev(st.end()));
	}

	for (auto &&e : st)
	{
		ans[1] += e.first * 1ll * e.second.second;
	}

	for (int i = 1; i <= n; i++) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 8064
import java.util.*;

class Main{           
    
   public static void main(String[] args){
     
       Scanner sc = new Scanner(System.in);                                                          
       
       String S = sc.next();
       
       if(S.contains("AC")){
           System.out.println("Yes");
           return;
       }else{
           System.out.println("No");
           return;
       }
       
   }
   
 }
  

        

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

int main(void){
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    
    list<ll> b;
    bool toggle = true;
    for (auto x : a) {
        toggle ? b.push_back(x) : b.push_front(x);
        toggle ^= true;
    }
    
    if (toggle == false) reverse(b.begin(), b.end());
    for (auto x : b) cout << x << ' ';
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 11044
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#define LINF 1e18
#define INF 1e9

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> attend(N + 5);
  for (int i = 1; i <= N; i++) {
    int A;
    cin >> A;
    attend[A] = i;
  }

  for (int i = 1; i <= N; i++) {
    cout << attend[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1152
//https://atcoder.jp/contests/abc076/tasks/abc076_c
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
using namespace std;
bool f=0,ans=0;
string s,t,ts,mn;
int i,j;
int main()
{
	cin>>s;
	cin>>t;
	for (i=0;i<s.length();i++) mn+='z';
	for (i=0;i+t.length()<=s.length();i++)
	{
		if (s[i]!='?' && s[i]!=t[0]) continue;
		bool subf=1;
		for (j=1;j<t.length();j++)
		{
			if (s[i+j]!='?' && s[i+j]!=t[j])
			{
				subf=0;
				continue;
			}
		}
		if (subf)
		{
			ts=s;
			for (j=0;j<t.length();j++) ts[i+j]=t[j];
			for (j=0;j<ts.length();j++)
			{
				if (ts[j]=='?') ts[j]='a';
			}
			if (ts<mn) mn=ts;
			ans=1;
		}
	}
	if (ans) cout<<mn;
	else printf("UNRESTORABLE\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repn(i,a,b)   for(ll i=a;i>=b;i--)
#define F first
#define S second
#define qi queue<ll>
#define pii pair<ll,ll>
#define vi vector<ll>
#define si set<ll>
#define vii vector<pii>
#define mi multiset<ll>
#define mii multiset<pii>
#define MI map<ll,ll>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define mod 998244353
#define mod2 998244353

// size_t f= str.find(string s,0); find s in str from start
// if found then (f != string::npos)
// m.insert({x,y}); m[x]=y;

int fexp(int a, int b){int ans = 1;while(b){if(b&1) ans = ans*a%mod2; b/=2;a=a*a%mod2;}return ans;}
int inverse(int a, int p){return fexp(a, p-2);}

signed main(){
    IOS
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int x,y;
  	cin>>x>>y;
  	if((y-(2*x))>=0 && (x-((y-(2*x))/2))>=0){
      if((y-(2*x))%2==0){cout<<"Yes";}
      else{cout<<"No";}
    }
  	else{cout<<"No";}
    return 0;
}


Measured memory_bytes: 3632
a,b = map(int, input().split())
s = input()

nums = ["0","1","2","3","4","5","6","7","8","9"]
for i in range(a+b+1):
    if i == a:
        if s[a] != "-":
            print("No")
            quit()
    else:
        if not s[i] in nums:
            print("No")
            quit()
print("Yes")


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
  int N, M;  cin >> N >> M;
  int H[N];  for(int i = 0; i < N; i++)  cin >> H[i];
  int A[M], B[M];
  int notGoodFlag[N];
  for(int i = 0; i < N; i++)  notGoodFlag[i] = 0;
  int answer = N;
  for(int i = 0; i < M; i++)  cin >> A[i] >> B[i];
  for(int i = 0; i < M; i++){
    if(H[A[i]-1] > H[B[i]-1])  notGoodFlag[B[i]-1] = 1;
    else if(H[A[i]-1] < H[B[i]-1]) notGoodFlag[A[i]-1] = 1;
    else notGoodFlag[A[i]-1] = notGoodFlag[B[i]-1] = 1;
  }
  for(int i = 0; i < N; i++){
    if(notGoodFlag[i] == 1)  answer--;
  }
  cout << answer << endl;
}

Measured memory_bytes: 4756
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1e18;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define all(x) (x).begin(), (x).end()

ll N;

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

    cin >> N;
    vector<ll> P(N);
    vector<ll> Q(N);
    vector<ll> dict(N);

    rep(i, N) {
        cin >> P[i];
    }
    rep(i, N) {
        cin >> Q[i];
    }
    rep(i, N) {
        dict[i] = i+1;
    }

    ll a = 0;
    ll b = 0;
    ll cnt = 0;
    do {
        cnt++;
        if (P==dict) {
            a = cnt;
        }
        if (Q==dict) {
            b = cnt;
        }
    } while(next_permutation(all(dict)));

    cout << abs(b-a) << endl;
    return 0;
}


Measured memory_bytes: 256
#line 1 "test/aoj/NTL_1_C.text.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_C"

#define call_from_test
#line 1 "test/aoj/../../math/euclidean-algorithm.cpp"
#include <cassert>
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

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

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

#ifndef call_from_test
int main() {
  assert(gcd(18, 24) == 6);
  assert(lcm(18, 24) == 72);
  // aとbの順序が逆でもok
  assert(gcd(7, 3) == 1);
  // aとbの順序が逆でもok
  assert(lcm(7, 3) == 21);
  // intを超える範囲でも問題なく計算できる
  assert(gcd(123456789123456789, 987654321987654321) == 9000000009);

  // 全てのassertを通過したら表示される
  cout << "ok" << endl;
}
#endif
#line 5 "test/aoj/NTL_1_C.text.cpp"
#undef call_from_test

int main() {
  int n;
  cin >> n;
  ll ans = 1;
  for (int i = 0; i < n; ++i) {
    ll a;
    cin >> a;
    ans = lcm(ans, a);
  }
  cout << ans << endl;
}



Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int[][] list = new int[a + 1][b + 1];
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				list[i][j] = scanner.nextInt();
			}
		}
		for (int i = 0; i < a; i++) {
			int sum = 0;
			for (int j = 0; j < b; j++) {
				sum += list[i][j];
			}
			list[i][b] = sum;
		}
		for (int i = 0; i < b + 1; i++) {
			int sum = 0;
			for (int j = 0; j < a; j++) {
				sum += list[j][i];
			}
			list[a][i] = sum;

		}

		for (int i = 0; i <= a; i++) {
			for (int j = 0; j <= b; j++) {
				if (j == 0)
					System.out.print(list[i][j]);
				else
					System.out.print(" " + list[i][j]);

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

Measured memory_bytes: 39436
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define rep2(i,start,end) for(ll i = start; i < end; i++)
#define dwn(i,n) for(int i = n; i >= 0; i--)
#define dwn2(i,start,end) for(ll i = start; i >= end; i--)
#define pll pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define pdl pair<double, ll>
const ll N = 4e5 + 200;
const ll INF = 0x3f3f3f;
const ll mod = 1e9 + 7;


int main(){
	ll n;
	cin>>n;
	vector<pair<ll,ll> > v(n);
	vector<ll> vs(n);
	map<ll,ll> mp;
	rep(i,n){
		cin>>v[i].first>>v[i].second;
		vs[i] = i;
		mp[i] = i;
	}
	ll k = 0;
	double sum = 0;
	do{
		
		for(int i = 1; i < n; i++){
			double tmp1 = (v[mp[vs[i]]].first - v[mp[vs[i-1]]].first)* (v[mp[vs[i]]].first - v[mp[vs[i-1]]].first);
			double tmp2 = (v[mp[vs[i]]].second - v[mp[vs[i-1]]].second)* (v[mp[vs[i]]].second - v[mp[vs[i-1]]].second);
			sum += sqrt(tmp1+tmp2);
		}
//		cout<<sum<<endl;
		k++;
	}while(next_permutation(vs.begin(),vs.end()));
	printf("%.7lf\n",sum/(1.0*(k)));

	return 0;
}






Measured memory_bytes: 256
n= int(input())
p= list(map(int,input().split()))
s=''
for i in range(n):
    if p[i]!=i+1:s=s+'-'
    else:s=s+'@'
count=0
pre=''
num=[]
for i,c in enumerate(s):
    if c=='@':count+=1
    else:
        if count>0:
            num.append(count)
            count=0
    if i==n-1 and c=='@':num.append(count)
g=0
for c in num:g+= -1 * (-1*c // 2)
print(g)

Measured memory_bytes: 14008
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,m;
char z[20]={'0','1','2','3','4','5','6','7','8','9','A','b','C','D','E','F','G','H','I','J'};
void turn(int n)
{
    if (n==0) return;
    else
	{
        if (n>0||n%(-2)==0)
		{
			turn(n/(-2));
			cout<<z[n%(-2)];
			return;
		}
        else
		{
			turn(n/(-2)+1);
			cout<<z[2+n%(-2)];
			return;
		}
    }
}
int main()
{
    cin>>n;
    if(n==0)
	{
		cout<<0;
		return 0;
	}
    turn(n);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;

int main()
{
    /*ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);*/
    //freopen("output.txt","w+",stdout);
    //freopen("input.txt","r+",stdin);
    int n,k,idx1,ans=INF;
    cin>>n>>k;
    vector<int> v(n);
    for(int i=0;i<n;i++)
        cin>>v[i],
        idx1=(v[i]==1?i:idx1);
    int l=max(0,idx1-k+1),r=min(n-1,l+k-1);
    for(;l<=idx1&&r<n;l++,r++)
        ans=min(ans,1+(int)ceil((double)l/(k-1))+(int)ceil((double)(n-1-r)/(k-1)));
    cout<<ans;
    return 0;
}
/* 3 3
   1 2 3
*/


Measured memory_bytes: 3684
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

        int N = scanner.nextInt();

        List<Integer> list = new ArrayList();
        for (int i = 0; i < N; i++) {
            list.add(scanner.nextInt());
        }

        int result = 0;
        while(shouldContinue(list)) {
            List<Integer> newList = new ArrayList<>(list.size());
            for (int value : list) {
                newList.add(value / 2);
            }
            list = newList;
            result++;
        }

        System.out.println(result);
    }

    private static boolean shouldContinue(List<Integer> list) {
        boolean hasPositive = false;
        for (int value : list) {
            if (value % 2 != 0) {
                return false;
            }
            if (!hasPositive && value > 0) {
                hasPositive = true;
            }
        }
        return hasPositive;
    }
}

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

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    set<string> a;
    int n; cin >> n;
    string s, t;
    rep(i,n){
        cin >> s >> t;
        if(s == "insert") a.insert(t);
        if(s == "find"){
            if(a.count(t)) cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 29800
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

//NodePointer listSearch(int key){
//  /* your code */
//}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->next->prev = t->prev;
  t->prev->next = t->next;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if (t == nil) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer x = nil->next;

  for(x = nil->next; x != nil; x = x->next) {
    if (x->key == key) {
      if (x->next == nil)
        deleteLast();
      else if (x->prev == nil)
        deleteFirst();
      else
        deleteNode(x);
      break;
    }
  }
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  x->prev = nil;

  nil->next->prev = x;
  nil->next = x;

}


int main(void)
{
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;

  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {
      insert(key);
      np++;
      size++;
    } else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L' ) deleteLast();
      } else {
        delete(key);
        nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll n,a,b;

int main(){
	cin>>n>>a>>b;
  ll t=b-a+1;
  if(t%2!=0)cout<<"Alice"<<endl;
  else cout<<"Borys"<<endl;
	return 0;
}


Measured memory_bytes: 256