akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
cout.precision(6);
cout.setf(ios::floatfield,ios::fixed);
ll n,i;
cin>>n;
vector<double>v;
double c=0,d;
for(i=0;i<n;i++)
{
    cin>>d;
    v.pb(d);
}
sort(v.begin(),v.end());
c=v[0];
for(i=1;i<n;i++)
{
    c=(c+v[i])/(double)2;
}
cout<<c<<endl;
}


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

int main(){
  int N,rank[8]={0,0,0,0,0,0,0,0};
  cin >> N; 
  int count=0;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    for(int j=0;j<8;j++){
      if(400*j<=a&&a<400*(j+1)) rank[j]=1;
    }
    if(a>=3200)count++;
  }
  int ans1=0,ans2;
  for(int i=0;i<8;i++) ans1+=rank[i];
  ans2=ans1+count;
  cout <<max(1,ans1) <<" "<<ans2<<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a, Ts... ts) {return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int num = 0;
    REP(i, s.size()) num += (s[i] == 'o'? 1 : 0);
    cout << (num >= 8 - (15 - (int)s.size()) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int a[3], b[3], c[4];

int main() {
    for (int i = 0; i < 3; ++i) {
        cin >> a[i] >> b[i];
        --a[i]; --b[i];
        c[a[i]]++;
        c[b[i]]++;
    }

    sort(c, c+4);
    bool res = c[0] == 1 && c[1] == 1 && c[2] == 2 && c[3] == 2;
    cout << (res ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 888
program sequence_sum
  implicit none
  integer(8) :: n, num, tmp, a(0:100000) = 0
  integer :: x, m, b(0:100000) = 0, period, offset, rem, i
  read(*,*) n, x, m
  tmp = m
  if (n <= 2 * m) then
    num = x
    rem = int(n)
    do i = 2, rem
      x = mod(int(x, 8) * x, tmp)
      if (x == 0) exit
      num = num + x
    end do
    write(*,'(i0)') num
    stop
  end if
  a(1) = x
  b(x) = 1
  do i = 2, m + 1
    x = int(mod(int(x, 8) * x, tmp))
    a(i) = a(i - 1) + x
    if (b(x) > 0) then
      offset = b(x) - 1
      period = i - offset - 1
      exit
    end if
    b(x) = i
  end do
  num = (n - offset) / period
  rem = int(n - offset - num * period)
  write(*,'(i0)') (a(offset + period) - a(offset)) * num + a(offset + rem)
end program sequence_sum

Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 H, N;
  cin >> H >> N;
  vector<i64> A(N), B(N);
  rep(i,0,N) {
    cin >> A[i] >> B[i];
  }
  vector<vector<i64>> dp(N + 1, vector<i64>(H + 1, 1e18));
  dp[0][0] = 0;
  rep(i,0,N) {
    rep(h,0,H + 1) {
      dp[i + 1][h] = std::min({ dp[i][h], dp[i][std::max(0ll, h - A[i])] + B[i], dp[i + 1][std::max(0ll, h - A[i])] + B[i] });
    }
  }
  cout << dp[N][H] << endl;
}


Measured memory_bytes: 78592
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll i, temp,t, n,j, a[200600], ans, pre;
bool cond;
char c;
string s;
int main()
{
    //I am Monim, a tiny creature of Allah
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
    }
    pre = a[0];
    for(i=1;i<n;i++)
    {
        if(pre>a[i])
            ans += pre-a[i];
        else
            pre = a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5176
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

long long M = 1e9 + 7;
typedef long long ll;
vector<ll> fac(300001);  //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n)
{ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while (n != 0)
    {
        if (n & 1)
            ans = ans * x % M;
        x = x * x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b)
{ //aCbをmod計算
    if (a == 0 && b == 0)
        return 1;
    if (a < b || a < 0)
        return 0;
    ll tmp = ifac[a - b] * ifac[b] % M;
    return tmp * fac[a] % M;
}

ll perm(ll a, ll b)
{
    if (a < b)
        return 0;
    ll tmp = ifac[a - b] % M;
    return tmp * fac[a] % M;
}

ll dupc(ll a, ll b)
{
    if (a == 0 && b == 0)
        return 1;
    if (a < 0 || b == 0)
        return 0;
    ll tmp = ifac[a - 1] * ifac[b] % M;
    return tmp * fac[a + b - 1] % M;
}
int main(void)
{
    long long n, k;
    cin >> n >> k;

    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i < 300000; i++)
    {
        fac[i + 1] = fac[i] * (i + 1) % M;              // n!(mod M)
        ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }

    for (int i = 1; i <= k; i++)
    {
        long long ans = 0;
        long long tmp = n - k + 1;
        ans = comb(n - k + 1, i) % M;
        //cout << "n-k+1Ci " << ans << endl;
        if (i > 1)
        {
            /* 
            long long k2 = k - i;
            if (k2 == 0)
            {
                cout << ans << endl;
                continue;
            }
            long long tmp2 = k2 + i - 1;
            for (long long j = 0; j < i; j++)
            {
                ans = (ans * (tmp2 - j)) % M;
            }
            for (int j = i - 1; j > 1; j--)
            {
                ans /= j;
            }
            */
            if (k - i > 0)
            {
                ans *= comb(k - 1, i - 1) % M;
            }
        }

        cout << ans % M << endl;
    }
}

Measured memory_bytes: 4992
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 2*(int)1e5+5;

long long a[N], b[N], n, k;

bool check(long long x) {
	long long ret = 0;
	for(int i=0;i<n;i++) {
		if(a[i]*b[i] > x) {
			long long more = a[i]*b[i] - x;
			long long del = (more + b[i] - 1) / b[i];
			ret += del;
		}
	}
	return ret <= k;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;	
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i=0;i<n;i++) cin >> b[i];
	sort(a, a+n);
	sort(b, b+n, greater<int>());
	long long l = 0, r = 1e18;
	while(l < r ) {
		long long mid = l + (r-l) / 2;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	cout << l;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

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

typedef long long LL;
typedef vector<int> VI;

int main() {
  int N;
  cin >> N;
  priority_queue<double, vector<double>,  greater<double>> q;
  int v;
  for (int i = 0; i < N; i++) {
    cin >> v;
    q.push((double)v);
  }
  while (q.size() > 1) {
    double v1 = q.top();
    q.pop();
    double v2 = q.top();
    q.pop();
    q.push((v1+v2)/2);
  }
  cout << fixed << setprecision(10) << q.top() << endl;
  return 0;
}


Measured memory_bytes: 256
def merge_unit(array1, array2, n1, n2):
    n = n1 + n2
    ret = [0] # outofindexを避けるため便宜上入れるが、たまたま呼び出し側で最初に0が必要なのでこのままにしとく
    csr1 = 0
    csr2 = 0
    for i in range(n):
        if csr1 >= n1:
            if not ret[-1] == array2[csr2]:
                ret.append(array2[csr2])
            csr2 += 1
        elif csr2 >= n2:
            if not ret[-1] == array1[csr1]:
                ret.append(array1[csr1])
            csr1 += 1
        else:
            if array1[csr1] < array2[csr2]:
                if not ret[-1] == array1[csr1]:
                    ret.append(array1[csr1])
                csr1 += 1
            else:
                if not ret[-1] == array2[csr2]:
                    ret.append(array2[csr2])
                csr2 += 1
    return ret

def main():
    N = int(input())
    A = [int(v) for v in input().split()]

    if all([v == 0 for v in A]):
        print(0)
        return

    tyou_t = []
    tyou_b = []
    next = 0 # ダウン 1 -> アップ
    for i in range(1, N):
        if next == 0 and A[i] - A[i - 1] < 0:
            tyou_t.append(A[i - 1])
            next = 1
        elif next == 1 and A[i] - A[i - 1] > 0:
            tyou_b.append(A[i - 1])
            next = 0

    if next == 0:
        tyou_t.append(A[-1])

    tyou_t.sort()
    tyou_b.sort()
    len_t = len(tyou_t)
    len_b = len(tyou_b)
    tyou = merge_unit(tyou_t, tyou_b, len_t, len_b)

    cnt_t = 0
    cnt_b = 0
    max_island = 1
    for x in tyou:
        while cnt_b < len_b and tyou_b[cnt_b] <= x:
            cnt_b += 1
        while cnt_t < len_t and tyou_t[cnt_t] <= x:
            cnt_t += 1
        island = 1 + cnt_b - cnt_t
        if max_island < island:
            max_island = island

    print(max_island)

if __name__ == '__main__':
    main()




Measured memory_bytes: 16688
#include<iostream>
#include<cmath>
using namespace std;
 
int main() {
	int len[3];
	int N;
	cin >> N;
	for (int j = 0; j < N; j++) {
		cin >> len[0] >> len[1] >> len[2];
		for (int i = 0; i < 3; i++) {
			len[i] = len[i] * len[i];
		}
		if (len[0] + len[1] == len[2] ||
			len[1] + len[2] == len[0] ||
			len[2] + len[0] == len[1])
		{
			cout << "YES\n";
		}
		else {
			cout << "NO\n";
		}
	}

    return 0;
}

Measured memory_bytes: 1120
# 2019-11-10 15:45:20(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    S, T = sys.stdin.read().split()

    convert = dict()
    
    flag = True
    for s, t in zip(S, T):
        if s in convert and convert[s] != t:
            flag = False
            break
        convert[s] = t

    # ここまでで対応表が完成
    # あとは異なる文字が同じ文字に変換されていないか確認
    after = convert.values()
    if len(after) != len(set(after)):
        flag = False
    

    print('Yes' if flag else 'No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    if(a+b > c+d) cout << "Left" << endl;
    else if(a+b == c+d) cout << "Balanced" << endl;
    else cout << "Right" << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define vec vector
#define mst(a,b) memset(a,b,sizeof(a))
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define all(v) v.begin(),v.end()
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define nnf LLONG_MIN
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=((res%mod)*(x%mod))%mod;
        }
        x=((x%mod)*(x%mod))%mod;
        y=y/2;
    }
    return res;
}
 
 struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }

  size_t operator()(pair<uint64_t,uint64_t> x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);
  }
};

void get_time(auto start,auto end){
    double time_taken =  
      chrono::duration_cast<chrono::nanoseconds>(end - start).count(); 
  
    time_taken *= 1e-9;
    cout<<"\n";
    cout<<"Time taken : "<<fixed<<time_taken<<setprecision(6);
}

  
  int dp[1000][1000];

int main(){

   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

  auto start = chrono::high_resolution_clock::now();

  
 

 /*#ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/

  int h,w;
  cin>>h>>w;
  char  ch;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>ch;
      if(i==0&&j==0)dp[i][j]=1;
      else{
        if(ch=='#')dp[i][j]=0;
        else{
          if(i>=1)dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
          if(j>=1)dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
        }
      }
    }
  }
  cout<<dp[h-1][w-1];
   


   



  auto end = chrono::high_resolution_clock::now();

 /* #ifndef ONLINE_JUDGE

   get_time(start,end); 

  #endif*/

    return 0;
 }

Measured memory_bytes: 7528
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long long int gcd(long long int a, long long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long long int lcm(long long int a, long long int b){
  return a * b / gcd(a, b);
}

#define TRUE 1
#define FALSE 0
#define MAX_NUM 100002
typedef struct pp{
  char c;
  int h;
  int w;
}P;

int top = 0;
P *Stack = NULL;
P *tmp = NULL;


void initialize(){
  Stack = (P *)calloc(MAX_NUM, sizeof(P));
  top = 0;
}

void finalize(){
  if(Stack != NULL){
    free(Stack);
    Stack = NULL;
  }
}

int isEmpty(){
  if(top <= 0){
    return TRUE;
  }else{
    return FALSE;
  }
}

int isFull(){
  if(top > MAX_NUM - 1){
    return TRUE;
  }else{
    return FALSE;
  }
}

int push(P x){
  fprintf(stderr, "pushするのは%c (h, w) = (%d, %d)\n", x.c, x.h, x.w);
  //printf("push x = %d\n",x);
  if(isFull() != FALSE){
    //    fprintf(stderr, "pushしたのは%d top = %d\n", Stack[top], top);
    printf("Error! Overfllow\n");
    return 0;
  }else{
    top++;
    if(Stack != NULL){
      Stack[top] = x;
    }
    return 0;
  }
}

P pop(){
  if(isEmpty() != FALSE){
    printf("Error! Underfllow\n");
    return *tmp;
  }else{
    top--;
    // return では取りだす値を返す
    //    fprintf(stderr, "popしたのは%d top = %d\n", Stack[top + 1], top);
    return Stack[top+1];
  }
}

// min
int main(void){
  int n = 0;
  char s[101];
  int ans = 0;

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

  // 偶数でなければNo
  if(n % 2 != 0 ){
    printf("No\n");
    return 0;
  }

  // 文字列比較する
  for(int i = 0; i < n / 2; i++){
    if(s[i] != s[(n / 2) + i]){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  
  return 0;

}



Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
AB = [LIST() for _ in range(N)]

cnt = 0
for A, B in AB[::-1]:
	if (A+cnt)%B != 0:
		cnt += B-(A+cnt)%B
print(cnt)


Measured memory_bytes: 30280
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

void solve();

void solve(int N, int K, string S) {
  char x = tolower(S[K - 1]);
  S[K - 1] = x;
  cout << S << endl;
}

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  solve(N, K, S);
  return 0;
}


Measured memory_bytes: 256
from fractions import gcd


def lcm(a, b):
    return a * b // gcd(a, b)


n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
MAX = 10 ** 6

l = 1
for e in a:
    l = lcm(l, e)

l %= mod

inv = [1] * (MAX + 1)
for i in range(2, MAX + 1):
    inv[i] = inv[mod % i] * (mod - mod // i) % mod

ans = 0
for e in a:
    ans += l * inv[e]
    ans %= mod

print(ans)


Measured memory_bytes: 45152
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m,l,i;
string s;
cin>>s;
l=s.length();
n=(l-1)/2;
m=(l+3)/2;
for(i=0;i<l;i++)
{
if(s[i]!=s[l-i-1])
{
 cout<<"No"<<endl;
 return 0;
}
}
for(i=0;i<n;i++)
{
if(s[i]!=s[n-i-1])
{
 cout<<"No"<<endl;
 return 0;
}
}
for(i=m;i<l;i++)
{
if(s[i]!=s[l-i-1])
{
 cout<<"No"<<endl;
 return 0;
}
}
cout<<"Yes"<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <limits.h>
#include <numeric>
#include <math.h>
using namespace std;
 
 
int main(){
    int A,B;
    cin >> A >> B;

    
    if((B-1)%(A-1)==0)cout << (B-1)/(A-1) <<endl;
    else cout << (B-1)/(A-1)+1 <<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long N, long long X, std::vector<long long> m){
    REP(i, N) X -= m[i];
    sort(m.begin(), m.end());
    cout << (X / m[0]) + N << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    std::vector<long long> m(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&m[i]);
    }
    solve(N, X, std::move(m));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF (long long)1 << 61
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
typedef vector<LL> LV;

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

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

LL lcm(LL number1,LL number2){	return number1 * number2 / gcd(number1,number2);}


int main(){
    LL l,r; cin >> l>>r;
    
    LL lm = l%2019,rm=r%2019;
    if(2019-lm <= r-l){
        cout << 0 << endl;
    }else{
        LL ans=INF;
        FOR(i,lm,rm){
            FOR(j,i+1,rm+1){
                if(ans>(i*j)%2019) ans = (i*j)%2019;
            }
        }
        cout << ans << endl;


    }

    return 0;

}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <stack>
#include <list>

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,b,n) for(int i=b;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

const float PI = 3.1415926;
static const int INFTY = (1<<30);

using namespace std;

typedef long long ll;
typedef long double ld;

int n, maxn, maxdis;
int main() {
  while(cin >> n, n) {
    maxn = 0; maxdis = 0;
    rep(i, n) {
      int p, d0, d1;
      cin >> p >> d0 >> d1;
      if(maxdis < d0 + d1) {
        maxn = p;
        maxdis = d0 + d1;
      }
    }

    cout << maxn << " " << maxdis << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define M 3000010
#define rep(i,x,y) for(int i=(x);i<=(y);++i)
inline int read(){
	char ch=getchar();int x=0,f=1;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while('0'<=ch&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
int fa[M];
int A[M],B[M],C[M];
bool v[2][M];
int n,m,q,MOD;
inline int Find(int x){
	return fa[x]==x?x:fa[x]=Find(fa[x]);
}
inline void Union(int x,int y){
	if(Find(x)!=Find(y)){
		fa[Find(x)]=Find(y);
	}
}
int main() {
	n=read(),m=read(),q=read(),MOD=read();
	rep(i,1,m){
		A[i]=read()-1,B[i]=read()-1,C[i]=read();
	} 
	int g=0;
	if(m>=2){
		g=abs(C[1]-C[2]);
	}
	rep(i,3,m){
		g=__gcd(g,abs(C[1]-C[i]));
	}
	if(!g)g=MOD;
	MOD=__gcd(3*g,MOD);
	int R=C[1]%g;
	//cerr<<R<<" "<<MOD<<" "<<g<<endl; 
	rep(i,0,6*n){
		fa[i]=i;
	}
	rep(i,1,m){
		C[i]=(C[i]-R)/g;
		rep(k,0,2)rep(r,0,1){
			int st=k*2+r,en=((k*2+C[i])%3)*2+(1-r);
			Union(A[i]*6+st,B[i]*6+en);
			Union(A[i]*6+en,B[i]*6+st);
		}
	}
	int now=R;
	while(!v[0][now]){
		v[0][now]=1;
		now=4*now%MOD; 
	}
	now=R*2%MOD;
	while(!v[1][now]){
		v[1][now]=1;
		now=4*now%MOD;
	}
	while(q--){
		int s=read()-1,t=read()-1,r=read();
		bool res=0;
		rep(k,0,2)rep(p,0,1){
			int tmp=(R+r-k*g)%MOD;
			if(tmp<0)tmp+=MOD;
			if(Find(t*6)==Find(s*6+k*2+p)){
				if(v[p][tmp])res=1;
			}
		}
		if(res)puts("YES");
		else puts("NO");
	}
} 

Measured memory_bytes: 11648
n = int(input())+1
inp1 = list(map(int, input().split()))
inp2 = list(map(int, input().split()))
inp3 = list(map(int, input().split()))
c, val = 0, 1
for i in range(n-1):
    c = (inp2[inp1[i] - val])+c
    if i > 0 and inp1[i] == inp1[i-val] + val:
        c = (inp3[inp1[i-val] - val])+c
print(c)


Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const long long MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す//計算量は0(log(max(a,b))
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す//計算量は0(log(max(a,b))
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す//計算量は0(log(y))
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す//計算量は0(sqrt(a))
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N,AC=0,WA=0,TLE=0,RE=0;
  cin>>N;
  for(int i=0;i<N;i++){
    string s;
    cin>>s;
    if(s=="AC"){AC++;}
    if(s=="WA"){WA++;}
    if(s=="TLE"){TLE++;}
    if(s=="RE"){RE++;}
  }
  cout<<"AC x "<<AC<<endl;
  cout<<"WA x "<<WA<<endl;
  cout<<"TLE x "<<TLE<<endl;
  cout<<"RE x "<<RE<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++){
    int b;
    cin >> b;
    a[i] = b - 1;
  }
  int ans = 0;
  int cnt = 0;
  while(1){
    if(cnt == 1){
      cout << ans << endl;
      return 0;
    }
    if(ans >= n){
      cout << -1 << endl;
      return 0;
    }
    ans++;
    cnt = a[cnt];
  }
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N, M; cin >> N >> M;
        vector<vector<int>> E(N);
        vector<vector<int>> rE(N);
        rep(i, N - 1 + M) {
            int a, b; cin >> a >> b;
            a--; b--;
            E[a].push_back(b);
            rE[b].push_back(a);
        }
        int root = -1;
        {
            rep(i, N) if(rE[i].size() == 0) {
                assert(root == -1);
                root = i;
            }
        }


        vector<int> parent(N, -2);
        vector<int> depth(N, -1);
        set<int> resolved;
        map<int, vector<int>> wait;
        map<int, vector<int>> wait2;

        function<void(int, int)> go = [&] (int now, int prev) {
            if(rE[now].size() > 1 and not resolved.count(now)) {
                wait[now].push_back(prev);
                if(wait[now].size() == rE[now].size()) {
                    wait2[now] = wait[now];
                    wait.erase(now);
                }
                return;
            }
            parent[now] = prev;
            depth[now] = (prev < 0 ? 0 : depth[prev]) + 1;
            for(int nxt : E[now]) {
                go(nxt, now);
            }
        };
        vector<pii> front = { make_pair(root, -1) };
        do {
            for(auto p : wait2) {
                if(p.second.size() < rE[p.first].size()) continue;
                int min_u = p.second[0];
                for(int u : p.second) {
                    if(depth[u] > depth[min_u]) min_u = u;
                }
                resolved.insert(p.first);
                front.emplace_back(p.first, min_u);
                wait2.erase(p.first);
            }
            for(pii p : front) go(p.first, p.second);
            front.clear();
        } while(wait2.size());

        rep(i, N) {
            cout << parent[i] + 1 << endl;
        }

        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 18816
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define REP(i, n) for (ll i=0; i<(ll)n; ++i)
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

vll dist(100000, 0);
V<bool> visited(100000, false);
V<V<P<ll, ll>>> nodes(100000, V<P<ll, ll>>());

void dfs(ll i, ll d) {
  dist.at(i) = d % 2;
  for (ll j=0; j<nodes.at(i).size(); j++) {
    if (!visited.at(nodes.at(i).at(j).first)) {
      visited.at(nodes.at(i).at(j).first) = true;
      dfs(nodes.at(i).at(j).first, d + nodes.at(i).at(j).second);
    }
  }
}

int main() {
  ll n; cin >> n;
  REP(i, n-1) {
    ll u, v, w; cin >> u >> v >> w;
    nodes.at(u-1).push_back({v-1, w});
    nodes.at(v-1).push_back({u-1, w});
  }
  dfs(0, 0);
  REP(i, n) cout << dist.at(i) % 2 << endl;
  return 0;
}


Measured memory_bytes: 10240
use proconio::input;

fn main() {
  input! {
    n: usize,
    m: usize,
    gate: [(usize, usize);m]
  }
  
  let mut left = gate[0].0;
  let mut right = gate[0].1;
  
  for (l, r) in gate {
    left = std::cmp::max(left, l);
    right = std::cmp::min(right, r);
  }
  
  if right < left {
    println!("0");
  } else {
    println!("{}", right - left + 1);
  }
}

Measured memory_bytes: 4572
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;


int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,k,s;
    cin >> n >> k >> s;
    vi res(n);
    rep(i,n){
        if(i<k){
            res.at(i) = s;
        }else{
            if(s!=1000000000){
                res.at(i) = s+1;
            }else{
                res.at(i) = s-1;
            }
        }
        cout << res.at(i) << endl;
    }
    // Sが10^9のパターンを考慮する
}


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

int main(void){
int n;
scanf("%d",&n);
if(n%10==3){printf("bon\n");}
else if(n%10==0||n%10==1||n%10==6||n%10==8){printf("pon\n");}
else{printf("hon");}
}


Measured memory_bytes: 1732
import java.util.*;

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

    String str = sc.next();
    int w = sc.nextInt();

    for (int i=0; i < str.length(); i+=w) {
      System.out.print(str.charAt(i));
    }
  }
}


Measured memory_bytes: 22228
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var n = long.Parse(Console.ReadLine());

        var nums = Console.ReadLine().Split(' ');
        var array = new long[nums.Count()];
        
        for(var i = 0; i < nums.Count(); i++)
        {
            array[i] = long.Parse(nums[i]);
        }

        var hasStock = false;
        long money = 1000;
        long stockCount = 0;

        for(var i = 1; i< n + 1; i++)
        {
            if (i != n)
            {
                if (!hasStock)
                {
                    if (array[i - 1] < array[i])
                    {
                        stockCount = money / array[i - 1];
                        money = money % array[i - 1];
                        hasStock = true;
                    }
                }
                else
                {
                    if (array[i - 1] > array[i])
                    {
                        money = money + array[i - 1] * stockCount;
                        stockCount = 0;
                        hasStock = false;
                    }
                }
            }
            else
            {
                if(stockCount > 0)
                {
                    money = money + array[i - 1] * stockCount;
                }
            }

        }
        Console.WriteLine(money);
        Console.ReadLine();
    }


}




Measured memory_bytes: 18820
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    long double sum = 0.0;
    long double x[11];
    string u[11];
    rep(i, n) cin >> x[i] >> u[i];
    rep(i,n){
        if(u[i]=="BTC")
            sum += x[i] * 380000;
            else
                sum += x[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
x,y = map(int,input().split())
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]

if x in A:
  if y in A:
    print('Yes')
  else:print('No')
elif x in B:
  if y in B:
    print('Yes')
  else:print('No')
elif x == y == 2:
  print('Yes')
else:print('No')

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

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

    int ans = 0;
    for (int i = 0; i < n-1; i++) {
        for (int k = i+1; k < n; k++) {
            ans += (d[i]*d[k]);
        }
    }

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

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int count = 0;
    for (int i = 0; i < H; i++) {
      String s = sc.next();
      for (int j = 0; j < W; j++) {
        if (s.charAt(j) == '#') {
          count++;
        }
      }
    }
    System.out.println(count == W+H-1 ? "Possible" : "Impossible");
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <stdio.h>

#include <cmath>
#include <vector>
using namespace std;

const double EPS = 1e-10;

double add(double a, double b){
    if(abs(a + b) < EPS * (abs(a) + abs(b)))return 0;
    return a + b;
}

struct Pt {
    double x, y;
    Pt(){}
    Pt(double x, double y):x(x), y(y){}
    Pt operator + (Pt p){return Pt(add(x, p.x), add(y, p.y));}
    Pt operator - (Pt p){return Pt(add(x, -p.x), add(y, -p.y));}
    Pt operator * (double d){return Pt(x * d, y * d);}
    double dot(Pt p){return add(x * p.x, y * p.y);}
    double det(Pt p){return add(x * p.y, -y * p.x);}
    double norm(){return x*x+y*y;}
    double abs(){return sqrt(norm());}
};
typedef Pt Vc;

struct Ln {
    Pt p1, p2;
    Ln(){}
    Ln(double x1, double y1, double x2, double y2):p1(Pt(x1, y1)), p2(Pt(x2, y2)){}
    Ln(Pt p1, Pt p2):p1(p1), p2(p2){}
    Pt project(Pt p){
        Pt base = p2 - p1;
        double r = base.dot(p - p1) / base.norm();
        return p1 + base * r;
    }
    Pt reflect(Pt p){
        return p + Pt(project(p) - p) * 2.0;
    }
};

void CGL1A(){
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    Ln line(x1, y1, x2, y2);
    int n;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        double x, y;
        scanf("%lf %lf", &x, &y);
        Pt p = line.project(Pt(x, y));
        printf("%.10f %.10f\n", p.x, p.y);
    }
}

void CGL1B(){
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    Ln line(x1, y1, x2, y2);
    int n;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        double x, y;
        scanf("%lf %lf", &x, &y);
        Pt p = line.reflect(Pt(x, y));
        printf("%.10f %.10f\n", p.x, p.y);
    }
}

signed main(){
    
    CGL1B();
    
    return 0;
}


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

MOD = 10**9 + 7

S1, S2 = 0, 0
for a in A:
    S1 += a
    S2 += a * a % MOD
    S1 %= MOD
    S2 %= MOD

print(((S1*S1%MOD-S2+MOD) % MOD) * pow(2,MOD-2,MOD) % MOD)



Measured memory_bytes: 31680
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())


vector < pair<LL, double> > v;
int k;

void init() {
	// v.push_back(make_pair(1, 1));
	// for (int i = 2; i < 6666666; i++) {
	// 	int s = 0;
	// 	int tmp = i;
	// 	while(tmp) {
	// 		s += tmp%10;
	// 		tmp /= 10;
	// 	}
	// 	double su = (double)i/s;
	// 	while(v[SZ(v)-1].second > su) v.pop_back();
	// 	v.push_back(make_pair(i, su));
	// }
	// REP(i, SZ(v)) {
	// 	OUT2(v[i].first, v[i].second);
	// }
}

void input() {
	cin >> k;
}

void solve() {
	v.push_back(make_pair(1, 1));
	LL i = 2;
	LL offset = 1;

	while(1) {
		LL s = 0;
		LL tmp = i;
		while(tmp) {
			s += tmp%10;
			tmp /= 10;
		}
		double su = (double)i/s;
		if (v[SZ(v)-1].second > su) {
			i -= offset * 2;
			offset *= 10;
			v.pop_back();
		} else {
			v.push_back(make_pair(i, su));
			if (SZ(v) > k + 20) {
				REP(j, k) cout << v[j].first << endl;
				return ;
			}
		}
		i += offset;
	}
}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (int i = 0; i < v.size(); ++i)
    {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < v.size() - 1; ++i)
    {
        os << v[i] << " ";
    }
    if (v.size() > 0)
    {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int main()
{
    int n;
    cin >> n;
    vll a(n);
    cin >> a;
    REP(i,n){
        if (a[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    
    ll ans = 1;
    REP(i,n){
        if (ans > ll(1e18)){
            cout << -1 << endl;
            return 0;
        }
        if ( ans > ll(1e18) / a[i]){
            cout << -1 << endl;
            return 0;
        }else{
            ans *= a[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4028
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1145141919
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int h,w,n,a[16384]={0},i,j,p,c=1,res[128][128];
    scanf("%d%d%d",&h,&w,&n);
    for(i=1;i<=n;i++){scanf("%d",&a[i]);}
    for(i=1;i<=h;i++){
        for(j=1;j<=w;j++){
            if(i%2==0){p=w-j+1;}
            else{p=j;}
            while(1){
                if(a[c]==0){c++;}else{break;}
            }
            res[i][p]=c;a[c]--;
        }
    }
    for(i=1;i<=h;i++){
        for(j=1;j<=w;j++){
            if(j==w){printf("%d\n",res[i][j]);}else{printf("%d ",res[i][j]);}
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int MOD=MOD2;

int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
           int l;
           cin>>l;
           ld x=1.0000*l/3;
           ld ans=x*x*x;
           precise(10)<<ans<<endl;
      } 
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int[] matches = {0,2,5,5,4,5,6,3,7,6};
		int[] map = new int[M];
		for (int i = 0; i < M; i++) {
			map[i] = sc.nextInt();
		}
		
		String[] dp = new String[N+1];
		Arrays.fill(dp, "");
		for (int i = 2; i <= N; i++) {
			for (int j = 0; j < M; j++) {
				int count = matches[map[j]];
				if (i < count) {
					continue;
				}
				
				String now = dp[i-count].isEmpty() ? Integer.toString(map[j]) : maxString(dp[i-count], map[j]); 
				
				if (now.length() == 1 && i != count) 
					continue;
				
				
				if (comp(dp[i], now) < 0) {
					dp[i] = now;
				}
			}
		}
		
		System.out.println(dp[N]);
	}
	
	static String maxString(String s, int j) {
		
		int index = -1;
		for (int i = 0; i < s.length(); i++) {
			if (Character.getNumericValue(s.charAt(i)) <= j) {
				index = i;
				break;
			}
		}
		
		if (index == -1) {
			s += Integer.toString(j);
		} else {
			s = s.substring(0,index) + Integer.toString(j) + s.substring(index);
		}
		
		return s;
	}
	
	static int comp(String a, String b) {
		if (a.length() != b.length()) {
			return a.length() - b.length();
		}
		
		for (int i = 0; i < a.length(); i++) {
			if (a.charAt(i) != b.charAt(i)) {
				return a.charAt(i) - b.charAt(i);
			}
		}
		
		return 0;
	}
		
}



Measured memory_bytes: 347236
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
ll a[101010];
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}
int main() {
    cin>>n;
    REP(i, 0, n) cin>>a[i];

    sort(a, a+n);
    reverse(a, a+n);

    ll ans=a[0];
    REP(i, 1, n){
        ans=gcd(ans, a[i]);
    }

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

Measured memory_bytes: 1024
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
cnt = 0
for i in range(n):
  a=list(map(int,input().split()))
  tmp=0
  for j in range(m):
    tmp += a[j]*b[j]
  tmp += c
  if tmp > 0:
    cnt += 1
print(cnt)

Measured memory_bytes: 9192
x,y = input().split()
a_list = ["1","3","5","7","8","10","12"]
b_list = ["4","6","9","11"]
ans = "No"
if x in a_list and y in a_list:
	ans = "Yes"
elif x in b_list and y in b_list:
	ans = "Yes"
print(ans)

Measured memory_bytes: 3060
int main()
{
	int a;
	int b;
	
	/* ????????? */
	a = 0;
	b = 0;
	
	/* ???????????? */
	scanf( "%d %d", &a, &b );
	
	/* ???????????? */
	if( a > b ){
		printf( "a > b\n" );
	}
	else if( a < b ){
		printf( "a < b\n" );
	}
	else{
		printf( "a == b\n" );
	}
	
	return 0;
}

Measured memory_bytes: 580