akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
  int N; cin >> N;
  vector<long long> a(N);
  long long maxN = 0;
  double halfN;
  for(int i = 0; i < N; ++i) {
    cin >> a[i];
    maxN = max(maxN, a[i]);
  }
  halfN = (double)maxN / 2.0;
  double dist = abs((double)a[0] - halfN);
  long long ans = a[0];
  for(int i = 0; i < N; ++i) {
    if(dist >= abs((double)a[i] - halfN)) {
      dist = abs((double)a[i] - halfN);
      ans = a[i];
    }
  }
  cout << maxN << " " << ans << endl;

  return 0;
}


Measured memory_bytes: 1152
N = int(input())

def dfs(s): # 文字列 s で始まる七五三数の個数
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく

Measured memory_bytes: 55004
#include<stdio.h>
int main(){
  int a=0;
  int b=0;
  int c=0;
  int M[10];
  int d=0;
  for(a=0;a<10;a++){
    scanf("%d",&M[a]);
  }
  for(a=0;a<10;a++){
    for(b=9;b>a;b--){
      if(M[b]>M[b-1]){
      c=M[b];
      M[b]=M[b-1];
      M[b-1]=c;
      }
    }
  }
  for(a=0;a<3;a++){
    printf("%d\n",M[a]);
  }
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<stdlib.h>

typedef struct range{
  int l,r;
} node;

int cmp(const void *a,const void *b){
  node *p=(node *)a;
  node *q=(node *)b;
  return (p->r-p->l)-(q->r-q->l);
}

void add(int *bit,int n,int index,int v){
  for(int i=index;i<=n;i+=i&-i) bit[i]+=v;
}

int sum(int *bit,int index){
  int res=0;
  for(int i=index;i>0;i-=i&-i) res+=bit[i];
  return res;
}

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  node *a=(node *)calloc(n,sizeof(node));
  int i;
  for(i=0;i<n;i++){
    int l,r;
    scanf("%d%d",&l,&r);
    a[i]=(node){l,r+1};
  }
  qsort(a,n,sizeof(node),cmp);
  int *bit=(int *)calloc(m+2,sizeof(int));
  int k=0;
  for(i=1;i<=m;i++){
    int ans=n-k;
    int j;
    for(j=i;j<=m;j+=i) ans+=sum(bit,j);
    printf("%d\n",ans);
    while(k<n && a[k].r-a[k].l<=i){
      add(bit,m+1,a[k].l,1);
      add(bit,m+1,a[k].r,-1);
      k++;
    }
  }
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 4860
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

map<ll, ll> mp;
void add(ll x) {
	if (mp.find(x) == mp.end()) {
		mp.insert({ x,1 });
	}
	else {
		mp[x]++;
	}
}

int main() {
	int Q; cin >> Q;
	ll bsum = 0;
	ll Lsum = 0, Rsum = 0;
	ll L = 0, R = 0;
	ll x;
	cin >> x; cin >> x >> bsum;
	Lsum += x;
	L++;

	add(x);
	auto itr = mp.find(x);

	ll N = 1;
	for (int q = 1; q < Q; q++) {
		int i; cin >> i;
		if (i == 2) {
			cout << itr->first << " " << L * itr->first - Lsum - R * itr->first + Rsum + bsum << endl;
		}
		else {
			ll a, b; cin >> a >> b;
			bsum += b;

			add(a);
			if (a <= itr->first) {
				L++;
				Lsum += a;
			}
			else {
				R++;
				Rsum += a;
			}
			N++;

			while (L < (N + 1) / 2) {
				itr++;
				L += itr->second;
				R -= itr->second;
				Lsum += itr->second * itr->first;
				Rsum -= itr->second * itr->first;
			}
			while (L - itr->second >= (N + 1) / 2) {
				L -= itr->second;
				R += itr->second;
				Lsum -= itr->second * itr->first;
				Rsum += itr->second * itr->first;
				itr--;
			}
		}
	}

	return 0;
}

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

const int MAX_N = 102;
int N;
ll W, w[MAX_N], v[MAX_N];
ll dp[MAX_N][MAX_N][400];

void solve()
{
	memset(dp,-1,sizeof(dp));
	dp[0][0][0]=0;
	for(int i=0;i<N;++i){
		ll we = w[i]-w[0], va = v[i];
		for(int j=0;j<=i;++j){
			for(int k=0;k<400;++k)if(dp[i][j][k]!=-1){
				dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k]);
				dp[i+1][j+1][k+we]=max(dp[i+1][j+1][k+we], dp[i][j][k]+va);
			}
		}
	}
	ll base = w[0];
	ll ans = 0;
	for(int j=1;j<=N;++j)for(int k=0;k<400;++k)if(dp[N][j][k]!=-1 && base*j+k<=W){
		ans = max(ans, dp[N][j][k]);
	}
	cout << ans << '\n';
}

int main()
{
	cin >> N >> W;
	for(int i=0;i<N;++i){
		cin >> w[i] >> v[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 36132
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

	int INF = 50001;

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

	int N[n + 1];
	int M[m];
	for (int i = 0; i < m; ++i) {
		int coin;
		scanf("%d", &coin);
		M[i] = coin;
	}
	//15 6
	//1 2 7 8 12 50
	for (int i = 1; i <= n; ++i) {
		N[i] = INF;
	}
	N[0] = 0;

	for (int i = 0; i < m; ++i) {
		for (int j = M[i]; j <= n; ++j) {
			N[j] = min(N[j], N[j - M[i]] + 1);
		}
	}

	cout << N[n] << endl;

	return 0;
}

Measured memory_bytes: 3344
#include <iostream>
#include <math.h>
#include <strings.h>
using namespace std;

int main()
{
int X,i,b;
b=0;
cin >>X;
while(true){

    for(i=2;i<X;i++) {
        if(X%i==0){
            b=1;
            break;
        }
    }
    if(b==1){
        X++;
        b=0;
    }else{
        cout<<X;
        break;
    }

} 
return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

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

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digitsum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int getdigit(ll a) {
	return to_string(a).size();
}
int countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

int main() {
	IOS;
	int n;
	cin >> n;
	vector<int> v(n);
	ll a4 = 0, a1 = 0;
	REP(i, n) {
		cin >> v[i];
		if (v[i] % 4 == 0)a4++;
		if (v[i] % 2 == 1)a1++;
	}
	bool ok = true;
	if (a4 + a1 < n && a1 > a4)ok = false;
	if (a4 + a1 == n && a1 - a4 > 1)ok = false;
	cout << (ok ? "Yes" : "No") << endl;
}



Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	double ans;
	if(n%2==1)
	{
		double tmp=n;
		ans=(tmp+1)/2;
		ans/=tmp;
		printf("%lf",ans);
	}
	else
	{
		double tmp=n;
		ans=(1/2);
		cout<<"0.5000000000"<<endl;
	}
	return 0;
	
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val inputNum = readLine()?.split(" ").orEmpty()
    val numA = inputNum[0].toInt()
    val numB = inputNum[1].toInt()

    val postal = readLine().orEmpty()
    val reg = "\\d{$numA}-\\d{$numB}"
    val checkR = Regex(reg)
    val a = checkR.matchEntire(postal)?.value
    var result = "Yes"

    if(a.isNullOrBlank()){
        result = "No"
    }
    println(result)
}

Measured memory_bytes: 37864
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

int main()
{
	ll a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;

	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
const int mod=998244353;
typedef long long ll; 
int main(){
	int n,s=0;
	cin>>n;
	for(int i=1;i<n;i++){
		for(int j=i;j<n;j+=i)s++;
	}
	cout<<s;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  char buf[1024];
  int N,M;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d", &N, &M);

  printf("%d\n", (N*3+M)/2);

  return 0;
}


Measured memory_bytes: 128
N = int(input())
V = [list(map(int,input().split())) for k in range(N)]
T = 1
A = 1

for k in V:
    t = max(T//k[0],A//k[1])
    if t*k[0] < T or t*k[1] < A:
        t += 1
    T = k[0]*t
    A = k[1]*t

print(T+A)

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

typedef long long int lli;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef priority_queue <int, vector <int>, greater <int> > min_pq;

const int MOD	= 1e9 + 7;

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define init(a)         memset(a,0,sizeof(a))    
#define pb              push_back  
#define all(a)          a.begin(),a.end()  
#define loop(i,n)       for(int i=0;i<n;i++)  
#define loops(i,s,n)    for(int i=s;i<n;i++)
#define rloop(i,n)      for(int i=n-1;i>=0;i--)
#define rloops(i,s,n)   for(int i=n-1;i>=s;i--)

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }


double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
//---------------------------------------------------------------------------------------------


int main(){
    fastio;


    int n,k;
    cin >> n >> k;
    
    int h[n];
    loop(i,n){
        cin >>h[i];
    }
    sort(h, h+n);
    lli ans = 0;
    rloop(i,n){
        if(k > 0){
            k--;
        }
        else{
            ans += h[i];
        }
    }
    cout<<ans<<endl;
    // cout<<"Execution time : "<<tick()<<"\n";

    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int i,a,b,m[3];
	scanf("%d %d",&a,&b);
	for(i=0;i<3;i++){
		m[0]=a+b;
		m[1]=a-b;
		m[2]=a*b;
	}
	sort(m,m+3);
	printf("%d\n",m[2]);
	return 0;
}
	

Measured memory_bytes: 1684
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
int main(){
	int n;
	bool flg=false;
	cin >>n;
	rep (i,9)
		rep(j,9){
			flg |= (i+1)*(j+1)==n;
		}
	if (flg)
		cout <<"Yes"<<endl;
	else
		cout <<"No"<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
using namespace std;
long long C;
int A[200001];
int main() {
    int N,K; cin >> N >> K;
	for(int i=0; i<N; i++) cin >> A[i];
	sort(A, A+N);
	for(int i=0; i<(N-K); i++) C += A[i];
    cout << C << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int w[300001],e[300001];
int main(){
	int N,min=3333333,ans=0,p,l,r;
	string S;
	cin>>N>>S;
	if(S[0]=='W') w[0]=1;
	else e[0]=1;
	for(p=1;p<N;p++){
		if(S[p]=='W') w[p]=w[p-1]+1;
		else w[p]=w[p-1];
		if(S[p]=='E') e[p]=e[p-1]+1;
		else e[p]=e[p-1];
	}
	/*
	for(p=0;p!=N;p++){
		cout<<w[p]<<" ";
	}
	cout<<endl;
	for(p=0;p!=N;p++){
		cout<<e[p]<<" ";
	}
	*/
//--------------------
	for(p=0;p<N;p++){
		if(p==0){l=0;r=e[N-1]-e[p];}
		if(p==N-1){l=w[N-2];r=0;}
		if(p!=0&&p!=N-1){l=w[p-1];r=e[N-1]-e[p];}
		ans=l+r;
		if(ans<min) min=ans;
	}
	cout<<min;
	return 0;
}

Measured memory_bytes: 2948
n = gets.chomp.to_i
ary = gets.split(" ").map(&:to_i).sort.reverse
ans = 0

(n-2).times do |i|
	j = i + 1
	k = n - 1
	while j < k
		if ary[i] < ary[j] + ary[k]
			ans += k - j
			j += 1
		else
			k -= 1
		end
	end
end

puts ans

Measured memory_bytes: 1912
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
  a[i] -= i + 1
a = sorted(a)

def calc(mid):
  res = 0
  for i in a:
    res += abs(i-mid)
  return res

if n%2==1:
  res = calc(a[n//2])
else:
  res = float('inf')
  if (a[n//2-1]+a[n//2])%2==0:
    res = calc((a[n//2-1]+a[n//2])//2)
  else:
    mid = (a[n//2-1]+a[n//2]) // 2
    res = min(calc(mid), calc(mid+1))

print(res)


Measured memory_bytes: 25744
#include<iostream>
using namespace std;
typedef long long ll;

ll dp[55][55][2505];
ll x[55];

int main() {
    ll N, A, X = 0;
    cin >> N >> A;
    for (int i = 1; i <= N; i++) {
        cin >> x[i];
        X = max(x[i], X);
    }
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            for (int k = 0; k <= X * N; k++) {
                if (i == 0 && j == 0 && k == 0) dp[i][j][k] = 1;
                else if (i >= 1 && x[i] > k) dp[i][j][k] = dp[i - 1][j][k];
                else if (i >= 1 && j >= 1 && x[i] <= k) dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]];
                else dp[i][j][k] = 0;
            }
        }
    }
    ll count = 0LL;
    for (int i = 1; i <= N; i++) {
        count += dp[N][i][i * A];
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 55424
a = int(input())
counta = 0
for i in range(1,a+1):
    if i%3 == 0 and i%5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        counta += i
print(counta)

Measured memory_bytes: 9168
import itertools
n = int(input())
data = []
for x in range(n):
    for y in range(int(input())):
        k, l = map(int, input().split())
        data.append((x, k - 1, l))
ans = 0
for i in itertools.product([1,0], repeat=n):
    s = sum(list(i))
    for g in data:
        if i[g[0]] == 1 and i[g[1]] != g[2]:
            s = 0
            break
    ans = max(ans, s)
print(ans)

Measured memory_bytes: 3064
#include <stack>
#include <iostream>
#include <algorithm>
#define pb push_back
#define sp " "
#define sl "\n"
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;

const int N=1e6+5,mod=1000000007;
int n,m,a[N],b[N],c[N],d,vs[N];
int main() {
	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);
	cin>>n>>m;
	for (int i=1;i<=n&&cin>>a[i];i++);
	for (int i=1;i<=m&&cin>>b[i]>>c[i];i++);
	for (int i=1;i<=m;i++) {
		if (a[b[i]]<=a[c[i]]) vs[b[i]]=1;
		if (a[c[i]]<=a[b[i]]) vs[c[i]]=1;
	}
	for (int i=1;i<=n;i++) if (vs[i]==0) d++;
	cout<<d;
	return 0;
}


Measured memory_bytes: 5160
#include <iostream>
#include <string>
#include <set>
#include <unordered_map>
#include <vector>
#include <utility>
#include <cassert>
#include <algorithm>
#include <cstring>

using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
using pii64 = pair<int64_t, int64_t>;

int main(int argc, char *argv[]) {
  int N, X;
  cin >> N >> X;
  int count = 0;
  int h = 0;
  for(int i = 0; i < N; i++){
    if(h <= X) count++;
    int tmp;
    cin >> tmp;
    h += tmp;
  }
  if(h <= X) count++;
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    auto n = readLong();
    auto d = readLongs();
    auto m = readLong();
    auto t = readLongs();
    d.sort();
    t.sort();
    size_t di = 0;
    long cnt;
    foreach(i; iota(m)) { 
        while(di < d.length && d[di] < t[i]) {
            ++di;
        }
        if(di < d.length && d[di] == t[i]) {
            ++cnt;
            ++di;
        } else {
            writeln("NO");
            return;
        }
    }
    writeln("YES");

}



Measured memory_bytes: 20312
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

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

    ll n;
    cin >> n;

    ll s = 100;
    ll ans = 0;
    while (s < n)
    {
        s += s / 100;
        ans++;
    }
    cout << ans << endl;
}

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

int main(){
  int n;
  cin>>n;
  ll vec[n][2];
  for(int i=0;i<n;i++){
    ll a,b;
    cin>>a>>b;
    vec[i][0]=a-b;
    vec[i][1]=a+b;
  }
  ll x=1e10;
  ll y=-1e10;
  for(int i=0;i<n;i++){
    x=min(x,vec[i][0]);
    y=max(y,vec[i][0]);
  }
  ll ans=abs(y-x);
  x=1e10;
  y=-1e10;
  for(int i=0;i<n;i++){
    x=min(x,vec[i][1]);
    y=max(y,vec[i][1]);
  }
  ans=max(ans,abs(y-x));
  cout<<ans<<endl;
}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MOD = 1e9 + 7;

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

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

int main() {
	ios_base::sync_with_stdio(false);

	int n;
	cin >> n;

	vector<int> primes;
	fori(i, 2, n + 1) {
		bool p = true;
		fori(j, 2, i) {
			if(i % j == 0) {
				p = false;
			}
		}
		if(p) {
			primes.push_back(i);
		}
	}

	int ans = 1;
	for(auto &each : primes) {
		int p = each;
		int e = 0;
		while(p <= n) {
			e += n / p;
			p *= each;
		}
		ans = mult(ans, e + 1);
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
#include <cstdlib>
using namespace std;
int main(){
    
    int N,M,x,ans=0;
    int y[102];
    cin >> N ;
    vector<string>  blue(N);
    for(int i = 0; i < N; i++){
        cin >> blue[i];
        y[i] = blue[i].size();
        y[i]--;
    }  
    for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++){
            if(blue[i] == blue[j]){
                goto dame;
            }
        }
    }
    for(int i = 0; i < N-1; i++){
        if(blue[i][y[i]] != blue[i+1][0]){
            goto dame;
        }
    }
    cout << "Yes" << endl;
    goto end;
    dame:
    cout << "No" << endl;
    end:
    return 0;
}

Measured memory_bytes: 256
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        l: f64,
    }

    println!("{}", (l / 3.) * (l / 3.) * (l / 3.));
}


Measured memory_bytes: 4352
#include <stdio.h>
 
#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

typedef struct{
  int u;
  int k;
  int v[N];
}Graph;

int n, time, top, u;
int color[N], G[N][N];
Graph F[N];
int d[N], f[N];

void dfs(void);
void visit(int);
int push(int);
int pop(void);
int isEmpty(void);
int isFull(void);

int main()
{

  int i, j;

  scanf("%d", &n);

  for(i=1; i<=n; i++){
    for(j=1; j<=n; j++){
      G[i][j] = 0;
    }
  }

  for(i=1; i<=n; i++){
    scanf("%d%d", &F[i].u, &F[i].k);
    for(j=1; j<=F[i].k; j++){
      scanf("%d", &F[i].v[j]);
      G[F[i].u][F[i].v[j]] = 1;
    }    
  }

  dfs();

  for(i=1; i<=n; i++){
    printf("%d %d %d\n", F[i].u, d[i], f[i]);
  }

  return 0;
}

void dfs(void){

  int u;

  for(u=1; u<=n; u++){
    color[u] = WHITE;
  }

  time = 0;

  for(u=1; u<=n; u++){
    if(color[u] == WHITE){
      visit(u);
    }
  }
}

void visit(int u){

  int v;

  color[u] = GRAY;
  d[u] = ++time;

  for(v=1; v<=n; v++){
    if(G[u][v] == 1){
      if(color[v] == WHITE){
	visit(v);
      }
    }
  }

  color[u] = BLACK;
  f[u] = ++time;

}

Measured memory_bytes: 676
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef pair<int, int> pii;
typedef double lf;
typedef long long ll;
const int inf=0x3f3f3f3f, mod=1000000007;

inline int read()
{
    int x=0,f=1; char ch=getchar();
    for (; ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') f=-1;
    for (; ch>='0' && ch<='9'; ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}

int main()
{
    double n, a, x, ans=0.0;
    cin >> n >> a >> x;
    for (; n; n--)
    {
        ans+=a+(2*n-1)/2*x;
        a=((2*n+2)*a+5*x)/(2*n);
        x=(n+2)*x/n;
    }
    printf("%.10f\n",ans);
    return 0;
}


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

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

  string n, m;
  cin >> n;

  m = n;
  reverse(m.begin(), m.end());

  if (m == n) cout << "Yes\n";
  else cout << "No\n";

  return (0);
}


Measured memory_bytes: 3644
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn dfs(vs: &Vec<Vec<(usize, i64)>>, dist: &mut Vec<i64>, v: usize) {
  for &(u, c) in &vs[v] {
    if dist[u] >= 0 {
      continue;
    }
    dist[u] = dist[v] + c;
    dfs(vs, dist, u);
  }
}

fn main() {
  input! {
    n: usize,
    es: [(usize1, usize1, i64); n - 1],
    q: usize,
    k: usize1,
    qs: [(usize1, usize1); q],
  }
  let mut vs = vec![vec![]; n];
  for (a, b, c) in es.into_iter() {
    vs[a].push((b, c));
    vs[b].push((a, c));
  }
  let mut dist = vec![-1; n];
  dist[k] = 0;
  dfs(&vs, &mut dist, k);
  for (x, y) in qs.into_iter() {
    println!("{}", dist[x] + dist[y]);
  }
}


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

namespace ConsoleApp15
{
    class Class350
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var A = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
            }
            var B = new int[N];
            Array.Copy(A, B, N);
            Array.Sort(B);
            for(int i = 0; i < N; i++)
            {
                Console.WriteLine(A[i]==B[N-1]?B[N-2]:B[N-1]);
            }
        }
    }
}


Measured memory_bytes: 17876
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
ll N;
  cin >>N;
  
  vl A(N+2);
  A.at(0)=0;
  A.at(N+1)=0;
  repl(i,1,N+1) {
    cin>>A.at(i);
  }
  
  
  
  vl b(N+1);
  rep(i,N+1) {
    b.at(i)=abs(A.at(i+1)-A.at(i));
  }
  ll sum=0;
  rep(i,N+1) {
    sum +=b.at(i);
  }
  
  vl c(N);
  
  rep(i,N) {
c.at(i)=sum+abs(A.at(i+2)-A.at(i))-abs(A.at(i+1)-A.at(i))-abs(A.at(i+2)-A.at(i+1));
  }
  
  
  rep(i,N) {
cout<<c.at(i)<<endl;
  }
  
  
  
}
  
  
        
      
    
    
    
    
  

Measured memory_bytes: 3584
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    s = ns()
    t = ns()
    ans = len(t)
    for i in range(len(s) - len(t) + 1):
        tmp = 0
        for j in range(len(t)):
            if s[i + j] == t[j]:
                tmp += 1
        ans = min(ans, len(t) - tmp)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9132
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){

    double A,B,H,M;
    cin >> A >> B >> H >> M;
    double Hrad = (M_PI*(H/6) + (M_PI/6) * (M/60));
    double Mrad = (M_PI*(M/30));

    double Dist = sqrt((A*sin(Hrad)-B*sin(Mrad))*(A*sin(Hrad)-B*sin(Mrad))+(A*cos(Hrad)-B*cos(Mrad))*(A*cos(Hrad)-B*cos(Mrad)));
    cout << fixed << setprecision(15) << Dist << endl;

    return 0;
}


Measured memory_bytes: 4136
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class E
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (X, Y, A, B, C) = Scanner.Scan<int, int, int, int, int>();
            var P = Scanner.ScanEnumerable<long>().OrderByDescending(x => x).Take(X).ToArray();
            var Q = Scanner.ScanEnumerable<long>().OrderByDescending(x => x).Take(Y).ToArray();
            var R = Scanner.ScanEnumerable<long>().OrderByDescending(x => x).ToArray();

            var answer = P.Concat(Q).Concat(R).OrderByDescending(x => x).Take(X + Y).Sum();
            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 53528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;

int main(){
	string s;cin>>s;
	int ans=0;
	for(int i=0,j=s.length()-1;i<j;i++,j--){
		if(s[i]!=s[j]){
			ans++;
		}
	}
	cout<<ans;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n, k;
string s;

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

  cin>>n>>k;
  cin>>s;
  vector<pair<int,int>> v;
  v.push_back({0,0});
  for (int i=0; i<n; ) {
    int j=i;
    if (s[i]=='0') {
      i++;
      continue;
    }
    while (j<n && s[j]=='1') j++;
    v.push_back({i,j-1});
    i=j;
  }
  v.push_back({n-1,n-1});

  int N = v.size();
  if (k >= N+1) out(n);

  int ans = 0;
  for (int i=k; i<N; i++) {
    auto past = v[i-k];
    int l = past.first;
    int r = v[i].second;
    ans = max(ans, r-l+1);
  }
  

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


Measured memory_bytes: 1020
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int n,m;
    cin>>n>>m;
    vector<int> v(m);
    rep(i,m){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    vector<int> v1;
    for(int i=0;i<m-1;i++){
        v1.push_back(v[i+1]-v[i]);
    }
    sort(v1.rbegin(),v1.rend());
    int ans=0;
    for(int k=n-1;k<v1.size();k++){
        ans+=v1[k];
    }
    cout<<ans<<endl;





    return 0;
}


Measured memory_bytes: 1276
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N = int(input())
    C = input()
    l = 0
    r = N-1
    count = 0
    while l < N and C[l] == 'R':
        l += 1
    while 0 <= r and C[r] == 'W':
        r -= 1
    while l < r:
        C = C[:l] + C[r] + C[l+1:r] + C[l] + C[r+1:]
        count += 1
        while l < N and C[l] == 'R':
            l += 1
        while 0 <= r and C[r] == 'W':
            r -= 1

    print(count)
    

main()


Measured memory_bytes: 9940
#include<bits/stdc++.h>
//#include<tr1::unordered_map>
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,a,n) for(int i=n;i>=a;--i)
#define pb push_back
#define fi first
#define se second
#define io std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
const int  maxn=1e6+50;
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
ll qpow(ll a,ll n)
{
    ll r=1%P;
    for (a%=P; n; a=a*a%P,n>>=1)if(n&1)r=r*a%P;
    return r;
}
struct node
{
  int a[26];
  int b[26];
  //int num;
};
node tree[maxn];
int pre[maxn];
int cnt;
int ans;
void add(string x)
{ int cur=0;
  int flag=0;
  for(int i=0;i<x.size();i++)
  { 
      int now=x[i]-'a';
      if(!tree[cur].a[now]) {
        tree[cur].a[now]=++cnt;
        pre[cnt]=cur;
      }
      cur=tree[cur].a[now];
      //tree[cur].num++;
  }
  int len=x.size()-1;
  int cntt[26];
  memset(cntt,0,sizeof(cntt));
  while(cur)
  {
        int pe=pre[cur];
        int now=x[len]-'a';
          if(!cntt[now])
          {
            cntt[now]++;
          }
        for(int i=0;i<26;i++)
        {
          if(cntt[i])
            tree[pe].b[i]++;
        }
        cur=pre[cur];
        len--;
  }
}
string a[maxn];
bool cmp(string x,string y)
{
  return x.size()>y.size();
}
int main()
{ io;
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
  }
  sort(a+1,a+1+n,cmp);
  for(int i=1;i<=n;i++)
  {
    reverse(a[i].begin(),a[i].end());
    int cur=0;
    int flag=0;
    for(int j=0;j<a[i].size()-1;j++)
      {
        char x=a[i][j];
        int now=x-'a';
        if(!tree[cur].a[now]) {flag=1;break;}
        cur=tree[cur].a[now];
      }
    if(flag) { add(a[i]);continue;}
    int last=a[i].back()-'a';
    ans+=tree[cur].b[last];
    add(a[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 242628
N = gets.to_i
A = gets.split.map(&:to_i)

denied = false
A.each do |a|
  next if a.odd?
  if a%3 != 0 && a%5 != 0
    denied = true
    break
  end
end
if denied
  puts 'DENIED'
else
  puts 'APPROVED'
end


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
long long INF = 10000000000000000;
int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> E(n);
  for (int i = 0; i < m; i++){
    int u, v, s;
    cin >> u >> v >> s;
    u--;
    v--;
    E[u].push_back(make_pair(s, v));
    E[v].push_back(make_pair(s, u));
  }
  vector<pair<int, long long>> f(n);
  f[0] = make_pair(1, 0);
  vector<bool> used(n, false);
  used[0] = true;
  queue<int> Q;
  Q.push(0);
  while (!Q.empty()){
    int v = Q.front();
    Q.pop();
    for (auto P : E[v]){
      int s = P.first;
      int w = P.second;
      if (!used[w]){
        used[w] = true;
        f[w] = make_pair(- f[v].first, s - f[v].second);
        Q.push(w);
      }
    }
  }
  long long x = -1;
  bool ok = true;
  for (int v = 0; v < n; v++){
    for (auto P : E[v]){
      int s = P.first;
      int w = P.second;
      int sum1 = f[v].first + f[w].first;
      long long sum2 = f[v].second + f[w].second;
      if (sum1 == 0){
        if (sum2 != s){
          ok = false;
        }
      }
      if (sum1 == 2){
        if ((s - sum2) % 2 != 0){
          ok = false;
        } else {
          long long x_tmp = (s - sum2) / 2;
          if (x_tmp <= 0){
            ok = false;
          } else {
            if (x == -1 || x == x_tmp){
              x = x_tmp;
            } else {
              ok = false;
            }
          }
        }
      }
      if (sum1 == -2){
        if ((sum2 - s) % 2 != 0){
          ok = false;
        } else {
          long long x_tmp = (sum2 - s) / 2;
          if (x_tmp <= 0){
            ok = false;
          } else {
            if (x == -1 || x == x_tmp){
              x = x_tmp;
            } else {
              ok = false;
            }
          }
        }
      }
    }
  }
  if (!ok){
    cout << 0 << endl;
  } else if (x != -1){
    for (int i = 0; i < n; i++){
      if (f[i].first * x + f[i].second <= 0){
        ok = false;
      }
    }
    if (!ok){
      cout << 0 << endl;
    } else {
      cout << 1 << endl;
    }
  } else {
    long long ub = INF;
    long long lb = 1;
    for (int i = 0; i < n; i++){
      if (f[i].first == 1){
        lb = max(lb, - f[i].second + 1);
      }
      if (f[i].first == -1){
        ub = min(ub, f[i].second - 1);
      }
    }
    if (lb <= ub){
      cout << ub - lb + 1 << endl;
    } else {
      cout << 0 << endl;
    }
  }
}

Measured memory_bytes: 11456
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
  using ll=long long;
  ll A,B,K;
  cin>>A>>B>>K;
  if(A>=K)
    cout<<A-K<<" "<<B<<endl;
  else if(B-K+A<0)
    cout<<"0"<<" "<<"0"<<endl;
  else
    cout<<"0"<<" "<<B-K+A<<endl;
}
    

Measured memory_bytes: 3620
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*; 
import java.util.*;
import java.util.regex.*;
/*
	  br = new BufferedReader(new FileReader("input.txt"));
	  pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
	  br = new BufferedReader(new InputStreamReader(System.in));
	  pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
	private static BufferedReader br;
	private static StringTokenizer st;
	private static PrintWriter pw;

	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		//int qq = 1;
		int qq = Integer.MAX_VALUE;
		//int qq = readInt();
		for(int casenum = 1; casenum <= qq; casenum++)	{
			int n = readInt();
			int[] l = new int[n];
			for(int i = 0; i < n; i++) {
				l[i] = readInt();
			}
			TreeSet<Long> ret = new TreeSet<Long>();
			long low = 2;
			long high = (long)1e18;
			while(low <= high) {
				long mid = (low+high)/2;
				long orig = mid;
				for(int out: l) {
					mid -= mid%out;
				}
				if(mid == 2) {
					ret.add(orig);
					break;
				}
				else if(mid > 2) {
					high = orig-1;
				}
				else {
					low = orig+1;
				}
			}
			pw.flush();
			if(ret.isEmpty()) {
				pw.println(-1);
				continue;
			}
			low = 2;
			high = (long)1e18;
			while(low != high) {
				long mid = (low+high)/2;
				long orig = mid;
				for(int out: l) {
					mid -= mid%out;
				}
				if(mid >= 2) {
					if(mid == 2)
						ret.add(orig);
					high = orig;
				}
				else {
					low = orig+1;
				}
			}
			low = 2;
			high = (long)1e18;
			while(low != high) {
				long mid = (low+high+1)/2;
				long orig = mid;
				for(int out: l) {
					mid -= mid%out;
				}
				if(mid <= 2) {
					if(mid == 2)
						ret.add(orig);
					low = orig;
				}
				else {
					high = orig-1;
				}
			}
			pw.println(ret.first() + " " + ret.last());
		}
		exitImmediately();
	}

	private static void exitImmediately() {
		pw.close();
		System.exit(0);
	}

	private static long readLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private static double readDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	private static int readInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	private static String nextLine() throws IOException  {
		if(!br.ready()) {
			exitImmediately();
		}
		st = null;
		return br.readLine();
	}

	private static String nextToken() throws IOException  {
		while(st == null || !st.hasMoreTokens())  {
			if(!br.ready()) {
				exitImmediately();
			}
			st = new StringTokenizer(br.readLine().trim());
		}
		return st.nextToken();
	}
}

Measured memory_bytes: 42508
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#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++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    char X, Y;
    cin >> X >> Y;
    if (X > Y)
    {
        cout << ">" << endl;
    }
    else if (X < Y)
    {
        cout << "<" << endl;
    }
    else
    {
        cout << "=" << endl;
    }
}


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

Measured memory_bytes: 588
// https://atcoder.jp/contests/abc088/tasks/abc088_a
#include <bits/stdc++.h>
using namespace std;

int main(void){
  int N,A;
  cin >> N >> A;

  int res = N % 500;
  if (res <= A)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

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


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m;
	cin>>n>>m;
	vector<pair<ll, ll> > a(m);
	for(int i = 0; i < m; i++)
	{
		cin>>a[i].fi>>a[i].se;
	}
	sort(a.begin(), a.end());
	ll x = a[0].fi, y = a[0].se;
	// cout<<x<<" "<<y<<endl;
	for(int i = 1; i < m; i++)
	{
		x=max(x, a[i].fi);
		y=min(y, a[i].se);
		// if(xa[i].fi)
		// {

		// }
		// else
	}
	// cout<<y<<" "<<x<<endl;
	cout<<max(y-x+1, 0ll)<<endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 10000000000000000
int n,m;
ll start[100005];
ll goal[100005];
ll d[100005];
pair<ll,ll> qwe[100005];
struct edge{
	int to; ll cost;
	edge(int a,int b):to(a),cost(b){}
};
vector<edge>vec[100005];
void dijkstra(int s){
	priority_queue<P,vector<P>,greater<P> > que;
	que.pu(mp(0,s));
	fill(d,d+n,INF);
	d[s]=0;
	while(!que.empty()){
		P p=que.top(); que.pop();
		int V=p.second;
		if(d[V]<p.first) continue;
		for(int i=0;i<vec[V].size();i++){
			edge e=vec[V][i];
			if(d[e.to] > d[V]+e.cost){
				d[e.to]=d[V]+e.cost;
				que.push(mp(d[e.to],e.to));
			}
		}
	}
}
vector<ll>seg[1<<18];
ll limits,limite;
void update1(vector<ll> x,int a){
	seg[a+(1<<17)-1]=x;
}
void update(){
		for(int i=(1<<17)-2;i>=0;i--){
		seg[i].resize(seg[i*2+1].size()+seg[i*2+2].size());
		merge(seg[i*2+1].begin(),seg[i*2+1].end(),seg[i*2+2].begin(),seg[i*2+2].end(),seg[i].begin());
		}
}
int sum(int a,int b,int k,int l,int r){
	if(l>b || a>r){
		return 0;
	}else if(a<=l && r<=b){
		int rp=lower_bound(seg[k].begin(),seg[k].end(),limite)-seg[k].begin();
		return seg[k].size()-rp; 
	}else{
		return sum(a,b,k*2+1,l,(l+r)/2)+sum(a,b,k*2+2,(l+r)/2+1,r);
	}
}
int main(){
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b;
		ll c;
		scanf("%d %d %lld",&a,&b,&c);
		vec[a].pb(edge(b,c)); vec[b].pb(edge(a,c));
	}
	dijkstra(0);
	for(int i=0;i<n;i++){
		start[i]=d[i];
	}
	dijkstra(n-1);
	for(int i=0;i<n;i++){
		goal[i]=d[i];
		qwe[i]=mp(start[i],goal[i]);
	}
	sort(qwe,qwe+n);
	for(int i=0;i<n;i++){
		vector<ll>er; er.pb(qwe[i].second);
		update1(er,i); start[i]=qwe[i].first;
	}
	update();
	int Q;
	scanf("%d",&Q);
	for(int i=0;i<Q;i++){
		scanf("%lld %lld",&limits,&limite);
		int eo=upper_bound(start,start+n,limits)-start;
		printf("%d\n",sum(0,eo-1,0,0,(1<<17)-1));
	}
}

Measured memory_bytes: 36592
n = int(input())
h = list(map(int, input().split()))
h = h[::-1]
count = 0
for i in range(1, n):
    if h[i]-h[i-1]==1:
        h[i]+=-1
    elif h[i]-h[i-1]>=2:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define re register
#define int long long
#define ll long long
#define M 1000000007
using namespace std;
inline int read() {
	re int t=0;
	re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0') {
		t=(t<<3)+(t<<1)+v-48;
		v=getchar();
	}
	return t;
}
inline int ksm(re int x,re int y,re int z){
	int sum=1;
	while(y){
		if(y&1)sum*=x,sum%=z;
		x*=x,x%=z;
		y>>=1;
	}
	return sum;
}
int work(int n,int m) {
	int ans=1;
	for(int i=1; i<=m; ++i)ans=ans*(n-m+i)%M*ksm(i,M-2,M)%M;
	return ans;
}
long long n,k,ans,a,b;
signed main() {
	n=read();
	a=read();
	b=read();
	printf("%lld",((ksm(2,n,M)-1-work(n,a)-work(n,b))%M+M)%M);
}


Measured memory_bytes: 256