akhauriyash/Code-Regression huggingface dataset:
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


void print_vec(vll a)
{
	cout << "start printing the vector\n";
	for (ll i = 0; i < a.size(); i++)
		cout << a[i] << " ";
	cout << "\n";
}
void print_mat(vector<vll> a)
{
	cout << "start printing the matrix\n";
	for (ll i = 0; i < a.size(); i++)
	{
		for (ll j = 0; j < a[i].size(); j++)
		{
			cout << a[i][j] << " ";
		}
		cout << "\n";
	}
}

/******************************************
* NUMBER THEORY ;) *
******************************************/



ll powermod(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}
ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i)
			res = (res * i) % mod;
		n /= mod;
	}
	res %= mod;
	return res;
}



void solve()
{
	ll n;
	cin >> n;
	vll arr(n);
	for (ll i  = 0; i < n; i++)
		cin >> arr[i];
	ll curr = 1;
	for (ll i = 0; i < n; i++)
	{
		if (arr[i] == curr)
			curr++;
	}
	if (curr == 1)
	{
		cout << -1 << "\n";
		return;
	}
	cout << n - curr + 1 << "\n";

}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
	solve();
	// }

	return 0;
}

Measured memory_bytes: 4784
import java.util.Scanner;

public class Main {

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

		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());

		if (A - B >= C ) {
			System.out.println("0");
		} else {
			System.out.println(C-(A-B));
		}

	}

}


Measured memory_bytes: 23764
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100000
using namespace std;
int n,a[MAXN+5];
int gcd(int a,int b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
bool DFS()
{
	int cnt[2]={};
	for(int i=1;i<=n;i++)
		cnt[a[i]%2]++;
	if(cnt[0]%2==1)
		return true;
	if(cnt[1]>=2)
		return false;
	for(int i=1;i<=n;i++)
		if(a[i]%2==1)
		{
			if(a[i]==1)
				return false;
			a[i]--;
		}
	int d=0;
	for(int i=1;i<=n;i++)
		d=gcd(d,a[i]);
	for(int i=1;i<=n;i++)
		a[i]/=d;
	if(DFS()==false)
		return true;
	return false;
}
int main()
{
//	freopen("game.in","r",stdin);
//	freopen("game.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	if(DFS()==true)
		printf("First\n");
	else
		printf("Second\n");
	return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python3

import sys

DEBUG = False

def solve():
    return


def read_int_list(sep = " "):
    return [int(s) for s in sys.stdin.readline().rstrip().split(sep)]

def read_int():
    return int(sys.stdin.readline())

def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    w, h, x, y = read_int_list()
    nr_ans = 1
    center_point = (h / 2, w / 2)
    if abs(center_point[0] - y) < 1e-9 and abs(center_point[1] - x) < 1e-9:
        nr_ans = 2
    print("%f %d" % (w * h / 2, nr_ans - 1))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  if (n == 1)
    cout << "Hello World" << endl;
  else {
    int a, b;
    cin >> a >> b;
    cout << a+b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
    using namespace std;
    int main(){
        int N;cin>>N;int max=1;int a[N];int count[100000+9]={};
        for(int i=0;i<N;++i){cin >> a[i];}
        for(int i=0;i<N;++i){count[a[i]]++;}
        for(int i=0;i<N;++i){if(count[i]+count[i+1]+count[i+2]>max)max=count[i]+count[i+1]+count[i+2];}               
        cout<<max;
    }

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

void solve(int M, int K) {
  if(K >= (1 << M)) {
    cout << -1 << endl;
    return;
  }

  if(M == 0) {
    if(K != 0) {
      cout << - 1 << endl;
      return;
    }
    cout << 0 << " " << 0 << endl;
  }else if(M == 1){
    if(K != 0) {
      cout << - 1 << endl;
      return;
    }
    cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
  }else{
    vector<int> tmp;
    REP(i, 1 << M) if(i != K) tmp.push_back(i);
    vector<int> ans(1 << (M + 1));

    REP(i, (1 << M) - 1) ans[i] = tmp[i];
    ans[(1 << M) - 1] = K;
    reverse(ALL(tmp));
    REP(i, (1 << M) - 1) ans[i + (1 << M)] = tmp[i];
    ans[(1 << (M + 1)) - 1] = K;

    REP(i, 1 << (M + 1)) {
      if(i) cout << " ";
      cout << ans[i];
    }
    cout << endl;
  }
}

int main(){
  int M, K;
  cin >> M >> K;
  solve(M, K);
  return 0;
}


Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
#define sorted(a) sort(a.begin(), a.end());
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long unsigned int ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen(".testcase", "r", stdin);
#endif

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

  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  sorted(L);

  int n, ans = 0;
  for (int i = 0; i < N - 2; i++) {
    for (int j = i + 1; j < N - 1; j++) {
      n = distance(L.begin(), lower_bound(ALL(L), L[i] + L[j]));
      ans += n - (j + 1);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
D = [[] for i in range(N)]
for i in range(M):
    p, y = map(int, input().split())
    D[p-1].append((y, i))
ans = [None]*M
for i, d in enumerate(D):
    d.sort()
    for k, (y, j) in enumerate(d):
        ans[j] = "%06d%06d" % (i+1,k+1)
print(*ans, sep='\n')


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

int main(){
int a,b;
  cin>>a>>b;
  vector<vector<char>> c(a+2,vector<char>(b+2,'#'));
  for(int i=1;i<a+1;i++){
    for(int j=1;j<b+1;j++)
      cin>>c.at(i).at(j);
  }
  for(int i=0;i<a+2;i++){
    for(int j=0;j<b+2;j++){
      cout<<c.at(i).at(j);
      if(j==b+1)
        cout<<endl;
    }
  }
}


Measured memory_bytes: 256
"""
演算子は要素とセットでモノイドを形成するようなものでなければならない。
すなわち、結合律が成り立ち単位元が存在する必要がある。

equalityはsetを高速化するために使う。めんどい場合はNoneにしてもOK
"""
class SegmentTree:

    @classmethod
    def all_identity(cls, operator, equality, identity, size):
        return cls(operator, equality, identity, [identity]*(2 << (size-1).bit_length()))

    @classmethod
    def from_initial_data(cls, operator, equality, identity, data):
        size = 1 << (len(data)-1).bit_length()
        temp = [identity]*(2*size)
        temp[size:size+len(data)] = data
        data = temp

        for i in reversed(range(size)):
            data[i] = operator(data[2*i],data[2*i+1])
        return cls(operator, equality, identity, data)

    # これ使わずファクトリーメソッド使いましょうね
    def __init__(self, operator, equality, identity, data):
        if equality is None:
            equality = lambda a,b: False
        self.op = operator
        self.eq = equality
        self.id = identity
        self.data = data
        self.size = len(data)//2

    def _interval(self, a, b):
        a += self.size
        b += self.size
        ra = self.id
        rb = self.id

        data = self.data
        op = self.op
        while a < b:
            if a & 1:
                ra = op(ra,data[a])
                a += 1
            if b & 1:
                b -= 1
                rb = op(data[b],rb)
            a >>= 1
            b >>= 1
        return op(ra,rb)

    def __getitem__(self, i):
        if isinstance(i, slice):
            return self._interval(
                                    0 if i.start is None else i.start,
                                    self.size if i.stop is None else i.stop)
        elif isinstance(i, int):
            return self.data[i+self.size]

    def __setitem__(self, i, v):
        i += self.size
        data = self.data
        op = self.op
        eq = self.eq
        while i and not eq(data[i],v):
            data[i] = v
            v = op(data[i^1],v) if i & 1 else op(v,data[i^1])
            i >>= 1

    def __iter__(self):
        return self.data[self.size:]

from operator import eq

N = int(input())

B = sorted((v,-i) for i,v in enumerate(int(input()) for _ in range(N)))
B = [-i for v,i in B]
i_j = {j:i for i,j in enumerate(B)}

st = SegmentTree.from_initial_data(min, equality=eq, identity=N, data=B)

visit_cnt = 0
cnt = 0
while visit_cnt < N:
    j = 0
    while True:
        i = st[j:]
        if i == N:
            break
        j = i_j[i]
        visit_cnt += 1
        st[j] = N
    cnt += 1

print(cnt)





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

typedef long long ll;

const ll Inf = 1000000000000000001ll;

int n;
ll a;
ll res = 1;

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n && res > 0; i++) {
        scanf("%lld", &a);
        if (a <= Inf / res) res *= a;
        else res = Inf;
    }
    if (res >= Inf) printf("-1\n");
    else printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 3792
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

	vector<ll> A(N);
	rep(i, N) cin >> A[i];

	sort(all(A));

	//例えばa > b > c > d > eとして
	//b d a e c
	//と並べると
	//答え= (b - d) + (a - d) + (a - e) + (c - e)
	//　　= 2a + b + c - 2d - 2e
	//となる。つまり大きい数字や小さい数字をほかの数字で挟んだほうが有利。
	//（端の数字は1回しか寄与しない）
	//あとは端から順番に
	//・（Aグループ）大きいほうは2倍して足す
	//・（Bグループ）小さいほうは2倍して引く
	//・（Cグループ）真ん中の2個（両端）は小さいほうを引く、大きいほうを足す
	//とすればよい。
	//Nが奇数の場合はAグループとBグループの個数が異なるため（Cグループは2個固定）
	//Aグループが多い場合、Bグループが多い場合でそれぞれ計算して最大を採用。
	if (N % 2 == 0)
	{
		ll ans = 0;

		rep(i, N / 2 - 1) ans += -2 * A[i];
		ans += -A[N / 2 - 1];
		ans += A[N / 2];
		repl(i, N / 2 + 1, N) ans += 2 * A[i];

		cout << ans << endl;
	}
	else
	{
		//Aが多いパターン
		ll ans1 = 0;

		rep(i, N / 2 - 1) ans1 += -2 * A[i];
		ans1 += -A[N / 2 - 1];
		ans1 += -A[N / 2];
		repl(i, N / 2 + 1, N) ans1 += 2 * A[i];

		//Bが多いパターン
		ll ans2 = 0;

		rep(i, N / 2) ans2 += -2 * A[i];
		ans2 += A[N / 2];
		ans2 += A[N / 2 + 1];
		repl(i, N / 2 + 2, N) ans2 += 2 * A[i];

		cout << max(ans1, ans2) << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <random>
#include <algorithm>
#include <chrono>
#include <map>
#define tNow chrono::duration_cast<msec>(chrono::system_clock::now().time_since_epoch())
#define INF (1 << 30)
using namespace std;

typedef chrono::milliseconds msec;

int d, lastVal = -INF, bestVal = -INF, times = 0, groups = 0, updates = 0, positiveUpdates = 0;
vector<int> c(27), cur, ans;
vector< vector<int> > s;

int calc() {
    int sum = 0;
    vector<int> last(27, 0);
    for (int i = 1; i <= d; ++i) {
        sum += s.at(i).at(cur.at(i));
        last.at(cur.at(i)) = i;
        for (int j = 1; j <= 26; ++j) sum -= c.at(j) * (i - last.at(j));
    }
    return sum;
}

void update(int curVal) {
    lastVal = curVal;
    if (bestVal < curVal) {
        bestVal = curVal;
        ans = cur;
        ++positiveUpdates;
    }
    ++updates;
}

int main() {
    random_device r;
    msec st = tNow;
    msec lm = st + chrono::milliseconds(1980);
    cin >> d;
    s = vector< vector<int> >(d + 1, vector<int>(27));
    cur.resize(d + 1);
    for (int i = 1; i <= 26; ++i) cin >> c.at(i);
    for (int i = 1; i <= d; ++i) for (int j = 1; j <= 26; ++j) cin >> s.at(i).at(j);
    mt19937 m(r());
    for (int i = 1; i <= d; ++i) cur.at(i) = m() % 26 + 1;
    update(calc());
    // cur = {0, 1, 17, 13, 14, 13};
    // update(calc());
    // cout << bestVal << endl;
    // for (int i = 1; i <= d; ++i) cout << ans.at(i) << endl;

    while (tNow < lm) {
        ++groups;
        mt19937 m(r());
        for (int i = 0; i < 100; ++i) {
            int changeAt = m() % d + 1, changeTo = m() % 26 + 1, changedFrom = cur.at(changeAt);
            if (changedFrom == changeTo) continue;
            cur.at(changeAt) = changeTo;
            int curVal = calc();
            if (m() % max(1, (lastVal - curVal) / 24) == 0) update(curVal);
            else cur.at(changeAt) = changedFrom;
            ++times;
        }
    }

    for (int i = 1; i <= d; ++i) cout << ans.at(i) << endl;
    msec ed = tNow;
    #ifdef ___DEBUG
    cout << "Best Value: " << bestVal << endl;
    cout << "Best Score: " << max(bestVal + 1000000, 0) << endl;
    cout << "Tried: " << times << "times, " << groups << "groups\n";
    cout << "Updated: " << updates << "times\n";
    cout << (ed - st).count() << "ms\n";
    #endif
    return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
set<string> q;
int main(){
string a;int k;cin>>a>>k;
for (int i=0;i<a.size();++i){
  string tmp="";
  for (int j=i;j<a.size();++j){
    tmp.push_back(a[j]);
    q.insert(tmp);
    if (q.size()>k) q.erase(--q.end());
    } 
  }
cout<<*q.rbegin();
}

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

std::string solve(const std::string& s) {
  const std::string odd = "RUD";
  const std::string even = "LUD";

  for (auto i = 0u; i < s.size(); ++i) {
    if ((i + 1) % 2 == 0) {
      if (std::find(even.begin(), even.end(), s[i]) == even.end()) {
        return "No";
      }
    } else {
      if (std::find(odd.begin(), odd.end(), s[i]) == odd.end()) {
        return "No";
      }
    }
  }
  return "Yes";
}

int main()
{
  std::string s;
  std::cin >> s;

  std::cout << solve(s) << std::endl;
}


Measured memory_bytes: 256
from math import ceil
import sys
input = sys.stdin.readline

def main():
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))

    l = 0
    r = 10**10

    while (r-l) > 1:
        x = (l+r) // 2

        c = 0

        for a in A:
            c += ceil(a / x)

        if c-N <= K: r = x
        else: l = x

    c = 0

    for a in A:
        c += ceil(a / r)

    if c-N <= K: print(r)
    else: print(l)

if __name__ == '__main__':
    main()

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;



int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    int N;
    cin >> N;
    vi D(N);
    rep(i, N){
        int d;
        cin >> d;
        D[i] =d;
    }
    int s = 0;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            s+=D[i]*D[j];
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N; string S; cin >> N >> S;
    int left = 0;
    int right = 0;
    for (int i=0; i<N; i++) {
        if (S[i] == '(') right++;
        else if (right == 0) left++;
        else right--;
    }
    string ans = "";
    for (int i=0; i<left; i++) ans += "(";
    ans += S;
    for (int i=0; i<right; i++) ans += ")";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc128/tasks/abc128_a
A, P = read_ints()
print((A * 3 + P) // 2)


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    ll n;
    cin >> n;
    ll mine = 1e+16;
    for(int i = 0; i < 5; ++i){
        ll foo;
        cin >> foo;
        chmin(mine, foo);
    }

    ll ans = 5;
    n -= mine;
    if(n > 0)   ans += ceil((double)n / mine);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>


int main() 
{
    int a, b, c, x, t, sum = 0, bb;
    int imin, imax, y, z;
    
    scanf("%d%d%d%d", &a, &b, &c, &x);
    
    x /= 50, bb = b << 1;
    if(x & 1){
        if((c & 1) == 0) c--;	
    }
    else{
        if(c & 1) c--;
    }
        
    imin = 0;
    t = (x - bb - c) / 10;
    if(x - bb - c > 0 && (x - bb - c) % 10 != 0) t++;
    if(t > imin) imin = t;
    imax = a;
    t = x / 10;
    if(t < imax) imax = t;
    
    if(imax < imin){
    	puts("0");
    	return 0;
	}
	sum = imax - imin + 1;
	
	if(x < c) t = -1;
    else t = (x - c) / 10;
    if(t >= imin){
    	if(t > imax) t = imax;
    	y = (x - 10 * t - c) >> 1;
    	z = (x - 10 * imin - c) >> 1;
    	sum -= ((y + z) * (t - imin + 1)) >> 1;
	}
	
	if(x >= bb) t = (x - bb) / 10 + 1;
	else t = 0;
	if(t <= imax){
		if(t < imin) t = imin;
		y = (x - 10 * t) >> 1;
		z = (x - 10 * imax) >> 1;
		sum += ((y + z) * (imax - t + 1)) >> 1;
		sum += (t - imin) * b;
	}
	else sum += (imax - imin + 1) * b;
	printf("%d\n", sum);
	
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int table[200][200] = {{0}};
    int c,r;
    cin >> r >> c;
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin >> table[i][j];
        }
    }
    for(int i = 0; i < r+1; i++){
        int sum = 0;
        for(int j = 0; j < c; j++){
            sum += table[i][j];
        }
        table[i][c] = sum;
    }
    
    for(int j = 0;j < c+1; j++){
        int sum = 0;
        for(int i = 0; i < r; i++){
            sum += table[i][j];
        }
        table[r][j] = sum;
    }
    
    for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c; j++){
            cout << table[i][j] << " ";
        }
        cout << table[i][c] << endl;
    }
}



Measured memory_bytes: 3256
import math


def main():
    N = int(input())
    A = list(map(int, input().split()))

    B = list(map(abs, A))
    C = [a for a in A if a < 0]
    if len(C) % 2 == 0:
        print(sum(B))
    else:
        print(sum(B) - min(B)*2)
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 15020
a,b,c=gets.split.map(&:to_f)
c=c/180 *Math::PI
d=Math.sqrt(a**2+b**2-2*a*b*Math.cos(c))
l=a+b+d
s=a*b/2*Math.sin(c)
h=b*Math.sin(c)
p s,l,h


Measured memory_bytes: 6912
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

ll INF = 1000000000000000000;

int main() {
    ll a;
    cin >> a;
    string s;
    cin >> s;
    int b = (s[0]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
    // cout << b << endl;
    ll ans = a*b/100;
    cout << ans << endl; 
}



Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>

char s[3001],t[3001];
long long dp[3001][3001];

long long max(long long a,long long b) {return a>b?a:b;}

void LCS(int L1,int L2)
{
  for(int i=0;i<=L1;i++)
  {
    for(int j=0;j<=L2;j++)
    {
      if(i==0||j==0)
        dp[i][j]=0;
      else if(s[i-1]==t[j-1])
        dp[i][j]=dp[i-1][j-1] +1;
      else
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
  }
  long long index=dp[L1][L2];
  char lcs[index+1];
  lcs[index]='\0';
  int i=L1,j=L2;
  while(i>0&&j>0)
  {
    if(s[i-1]==t[j-1])
    {
      lcs[index-1]=s[i-1];
      i--;j--;index--;
    }
    else if(dp[i-1][j]>dp[i][j-1])
      i--;
    else j--;
  }
  printf("%s",lcs);
}

int main()
{
  for(int i=0;i<3001;i++)
    for(int j=0;j<3001;j++)
      dp[i][j]=-1;
  scanf("%s%s",s,t);
  int L1=strlen(s),L2=strlen(t);
  LCS(L1,L2);
  return 0;
}


Measured memory_bytes: 70528
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
ans=0
for i in range(N):
  A=list(map(int,input().split()))
  d=0
  for j,k in zip(A,B):
    d+=j*k
  if d>-C:
    ans+=1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int x;
    cin >> x;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int ans=0;
    int mx=0;
    for(int i=0; i<n; i++){
        mx += a[i];
        if(x >= mx){
            ans++;
        }else{
            break;
        }
    }
    if(ans == n && x != mx) ans--;
    cout << ans << endl;
}




Measured memory_bytes: 256
// バケット法による解
#include <iostream>
using namespace std;

int main(){
  int N;
  int d[110];
  cin >> N;
  for(int i=0;i<N;i++) cin >> d[i];
  
  int num[110] = {0};
  for(int i=0;i<N;++i) {
    num[d[i]]++;
	}

	int res =0;
	for(int i=0;i<=100;++i) {
    if(num[i]){
      ++res;
	}
    }
cout << res <<endl;
}

Measured memory_bytes: 256
from bisect import *
n, m, k = map(int, input().split())
A = [0]
for x in map(int, input().split()):
    if A[-1]+x > k: break
    A.append(A[-1]+x)
B = [0]
for x in map(int, input().split()):
    if B[-1]+x > k: break
    B.append(B[-1]+x)

ans = 0
for i in range(len(A)):
    j = bisect_right(B, k-A[i]) - 1
    ans = max(ans, i+j)

# print(k)
# print(A)
# print(B)
print(ans)


Measured memory_bytes: 39712
#include <stdio.h>

int main(void) {

  long h,n;
  scanf("%ld %ld", &h, &n);
  long a[n],b[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld %ld", &a[i], &b[i]);
  }
  long need[h+1];
  for (long i = 1; i <= h; i++) {
    need[i] = -1;
  }
  long mp;
  for (long i = 1; i <= h; i++) {
    for (long j = 0; j < n; j++) {
      if (a[j] >= i) {
        mp = b[j];
      } else {
        mp = need[i-a[j]]+b[j];
      }
      if (need[i] == -1 || mp < need[i]) {
        need[i] = mp;
      }
    }
  }
  printf("%ld\n", need[h]);

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,x,c;
  c=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>x;
    c+=min(x,k-x);
  }
  cout<<c*2<<endl;
}

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

void show(int *A,int n) {
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}


void trace(int *A, int N) {
	int i;
	for (i = 0; i < N; i++) {
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}


//void insertSort(int *A,int n) {
//	int t;
//	for (int i = 1; i < n; i++) {
//		int j = i;
//		while (A[j - 1] > A[j]) {
//			t = A[j];
//			A[j] = A[j - 1];
//			A[j - 1] = t;
//			j--;
//		}
//		show(A, n);
//	}
//}

void insertSort(int A[], int N) {
	int j, i, v;
	for (i = 1; i < N; i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}

int main() {
	int n, A[1000];

	cin >> n;
	for (int i = 0; i < n; i++) cin >> A[i];
	trace(A, n);
	insertSort(A,n);

	return 0;
}

Measured memory_bytes: 3232
# https://atcoder.jp/contests/apc001/tasks/apc001_b


import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
rr = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


N = read_a_int()
A = read_ints()
B = read_ints()

'''
aiとbiについて
ai<=biのとき→必ず等しくできる
ai>biのとき→ai-biをbiに加算してやっと等しくなれる。#Aのどこかに余分な2*(ai-bi)を加算しなくてはいけない(バラけてもokだけど)
余分な分を吸収してくれるような数字を探したい

→
まずai>biについてをai-biの合計n1を計算する(1を足した回数。これと同じ数2をAに足さないと行けない)
次に、ai+2<=biの各要素についてbi-ai(>=2)を計算し、n1を0に消費できるか計算する。
消費できればYes、できなればNo
(n1を0にした時点では数列は等しくなっていないが、ai<biについて1回以上の操作を追加することで必ず等しくできることが保証できる)
'''

n1 = 0  # bに+1する回数
for a, b in zip(A, B):
    if a > b:
        n1 += a - b

for a, b in zip(A, B):
    if a + 2 <= b:
        n1 -= (b - a) // 2


print("Yes" if n1 <= 0 else "No")


Measured memory_bytes: 40432
#n = int(input())
x, a, b = map(int, input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

if a >= b:
    ans = 'delicious'
elif a+x >= b:
    ans = 'safe'
else:
    ans = 'dangerous'
print(ans)


Measured memory_bytes: 9088
#include<stdio.h>
int main (){
	int Sec,h,m,s;
	scanf("%d",&Sec);
	if(0<=Sec && Sec<=86400){
	h=Sec/(60*60);
	m=(Sec-h*60*60)/60;
	s=Sec-m*60-h*60*60;
	printf("%d:%d:%d\n",h, m, s);
	}else{
	printf("NOT\n");
	}
	return 0;
}

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

int main(){
    int n,k; cin >> n >> k;
    int a[51];
    rep(i,n) cin >> a[i];
    sort(a, a+n, greater<int>());
    int ans=0;
    rep(i,k){
        ans+=a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

struct RollingHash {
    static const ll b1 = 1007, b2 = 2009;
    static const ll mod1 = 1000000007, mod2 = 1000000009;
    vll h1, h2, p1, p2;

    RollingHash(const string &s) {
        ll n = s.size();
        h1.assign(n + 1, 0);
        h2.assign(n + 1, 0);
        p1.assign(n + 1, 1);
        p2.assign(n + 1, 1);
        for (int i = 0; i < n; ++i) {
            h1[i + 1] = (h1[i] * b1 + s[i]) % mod1;
            h2[i + 1] = (h2[i] * b2 + s[i]) % mod2;
            p1[i + 1] = (p1[i] * b1) % mod1;
            p2[i + 1] = (p2[i] * b2) % mod2;
        }
    }
    
    inline pll get(ll l, ll r) const {
        ll res1 = h1[r] - h1[l] * p1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        ll res2 = h2[r] - h2[l] * p2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return make_pair(res1, res2);
    }
};

void show(pll p) {
    cout << p.first << ' ' << p.second << endl;
}

bool check(RollingHash& rh, ll m) {
    ll n = rh.h1.size() - 1;
    map<pll, ll> mp;
    vpll vp;
    bool ret = false;
    for(ll i = m; i + m <= n; i++) {
        pll p = rh.get(i, i + m);
        vp.push_back(p);
        mp[p]++;
    }
    for(ll i = 0; i < vp.size(); i++) {
        pll p = rh.get(i, i + m);
        if(mp[p] > 0) ret = true;
        mp[vp[i]]--;
        if(ret) break;
    }
    return ret;
}

void solve() {
    ll n;
    string s;
    cin >> n >> s;
    RollingHash rh(s);
    ll ok = 0, ng = n;
    while(ng - ok > 1) {
        ll mid = (ok + ng) / 2;
        if(check(rh, mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 952
#include<bits/stdc++.h>
using namespace std;
int main()
{

	int a;
	vector<int> vec(5);
	int N = 5;
	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
	}
	for (int i = 0; i < N; i++) {
		if (vec.at(i) == 0)
			a = i;
	}

	cout << a+1  << endl;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <typeinfo>
#include <stdlib.h>

#define ll long long

using namespace std;

int main(int argc, char* argv[]){
  int n, tmp_n, divide=0;
  cin >> tmp_n;
  n = tmp_n;
  while(tmp_n>0){
    divide += tmp_n%10;
    tmp_n /= 10;
  }
  if(n % divide == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#import<cstdio>
#define P(x) (1<<x)
#define M(a,b) (a=a<b?a:b)
int main(){int n,i,j,T,dp[1<<17],t[20][20];for(;scanf("%d",&n),n;printf("%d\n",dp[P(n)-1])){for(i=0;i<P(n);)dp[i++]=1<<30;for(j=0;j<n;j++)for(i=0;i<n+1;)scanf("%d",t[j]+i++);for(dp[0]=T=0;T<P(n);T++)for(j=0;j<n;j++)for(i=0;i<n;i++)if(!(T&P(j)))M(dp[T+P(j)],dp[T]+t[j][(T&P(i))?i+1:0]);}}

Measured memory_bytes: 1020
<?PHP
fscanf(STDIN, "%d", $a);
$k=array_reverse(explode(" ", fgets(STDIN)));

$h=$k[0];

foreach($k as $v){
  if($h<$v-1){
    echo 'No';
    exit;
  }elseif($h==$v-1){
    
  }else{
   $h=$v;
  }
}
echo 'Yes';


Measured memory_bytes: 30908
import java.util.*;

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

        String[] aiueo = {"a", "i", "u", "e", "o"};
        if (Arrays.asList(aiueo).contains(s)){
          System.out.println("vowel");
        } else {
          System.out.println("consonant");
      }
    }
}

Measured memory_bytes: 9556
#include <stdio.h>

#define WHITE 0
#define BRACK 1
#define inf 1000000000
#define NIL -1

int n,d[101],pi[101],color[101],G[101][101],count = 0;

int prim(int r)
{
  int u,mincost,i,v;
  for(u = 1;u <= n;u++)
    {
      d[u] = inf;
      pi[u] = NIL;
      color[u] = WHITE;
    }
  d[r] = 0;
  while(1)
    {
      mincost = inf;
      for(i = 1;i <= n;i++)
	{
	  if(color[i] != BRACK && d[i] < mincost)
	    {
	      mincost = d[i];
	      u = i;
	    }
	}
      if(mincost == inf)
	{
	  break;
	}
      color[u] = BRACK;
      for(v = 1;v <= n;v++)
	{
	  if(color[v] != BRACK && G[u][v] < d[v] && G[u][v] != -1)
	    {
	      pi[v] = u;
	      d[v] = G[u][v];
	    }
	} 
    }
  for(i = 1;i <= n;i++)
	{
	  if(pi[i] != NIL)
	    {
	      count = count + G[i][pi[i]];
	    }
	}
  return count;
}

int main()
{
  int i,j,answer;
  
  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++)
    {
      for(j = 1;j <= n;j++)
	{
	  scanf("%d",&G[i][j]);
	}
    }

  answer = prim(1);

  printf("%d\n",answer);
  
  return 0;
}


Measured memory_bytes: 2052
#include<iostream>
#include<cstdlib>
#include<climits>
#define ll long long int 
using namespace std;
int main()
{ 
   ll n,k;
   cin>>n>>k;
   ll a[n],d[n];
   for(int i=0;i<n;i++)
   {
   	cin>>a[i];
   }
   
   d[0]=0;
   
   if(1<n)
   d[1]=abs(a[1]-a[0]);
   
   
   for(int i=2;i<n;i++)
   {
   	d[i]=INT_MAX;
   	int k1=0;
   	for(int j=i-1;j>=0;j--)
   	{
   	    	if(k1==k)break;
   	    	k1++;
   	    	
   	    	d[i]=min(d[i],abs(a[j]-a[i])+d[j]);
   	    	
    }
   	
   }
   
   cout<<d[n-1];
   
	
}

Measured memory_bytes: 1792
import sys
def sosa(x):
    return x*2
A,B,C=map(int,input().split())
K=int(input())
for i in range(K+1):
    if A>=B:
        B=sosa(B)
    elif B>=C:
        C=sosa(C)
    else:
        break
else:
    print("No")
    sys.exit()
print("Yes")

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
int n,a[51],k,ans;
int main()
{
	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> a[i];
	sort(a+1,a+1+n);
	for (int i = 1; i <= k; i++)
		{
			ans += a[n-i+1];
		}
	cout << ans;	
	return 0;
 } 


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(li i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}
void print2(li a){
  while(a){ printf("%d",a%2); a/=2; } printf("\n");
}

int main(){
  int n; cin >>n;
  vector<int> a(n),b(n);
  rep(i,n) cin >>a[i];
  rep(i,n) cin >>b[i];
  
  auto val
    =[&](int idx,int pos){
       //       if(df)print("val",idx,pos);
       return ((idx-pos)&1?b:a)[idx];
     };
  
  vector<vector<li>> dp(1LL<<n,vector<li>(n,-1));

  rep(i,n){
    dp[1LL<<i][i]=i;
  }
  
  rep(bs,1LL<<n){    // dp[bs]の更新
    int cnt=__builtin_popcount(bs);
    if(cnt<=1) continue;
    if(df) print2(bs);
    
    int c0=0;
    rep(i,n){        // dp[bs][i]の更新   
      li i2=1LL<<i;
      if(!(i2&bs)){
        c0++;
        continue;
      }
      li m=-1;
      rep(j,n){      // dp[bs-i2][j]からもらったとき。
        li j2=1LL<<j;
        if(dp[bs-i2][j]==-1) continue;   // bs-i2まで更新できん
        //        if(df) print(val(j,cnt-2),val(i,cnt-1));
        if(val(j,cnt-2)>val(i,cnt-1)) continue; // 単調じゃなくなる
        li tmp=dp[bs-i2][j]+c0;
        m=((m<0)?tmp:min(tmp,m));
      }
      dp[bs][i]=m;
    }
    if(df) print(dp[bs]);
      
    
  }
  li m=-1,lim=(1LL<<n)-1;
  if(df)print(dp[lim]);
  rep(i,n){
    if(dp[lim][i]<0)continue;
    m=((m<0)?dp[lim][i]:min(dp[lim][i],m));
  }
  print(m);
}


Measured memory_bytes: 47360
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int K = s.nextInt();
		int sum = 0;
		
		int[] I = new int[N];
		
		for(int i=0;i<N;i++){
			 I[i] = s.nextInt();	 
		}
		Arrays.sort(I);
		int h = I.length;
		
		for(int j=1;j-1<K;j++){
			sum = sum + I[h-j];
		}
		System.out.println(sum);
		
	}
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(void)
{
	int number, count, a, max_a, min_a;
	long total_a;
	
	scanf("%d", &number);

	scanf("%d", &a);

	for (count = 0, max_a = a, min_a = a, total_a = a; count < number - 1; count++)
	{
		scanf("%d", &a);

		total_a = total_a + a;

		if (max_a < a)
		{
			max_a = a;
		}

		if (min_a > a)
		{
			min_a = a;
		}
	}

	printf("%d %d %ld\n", min_a, max_a, total_a);

	return 0;
}


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

int dp[20][500][2048];

int main()
{
	dp[0][0][0] = 1;
	for (int i = 0; i < 10; i++){
		for (int j = 0; j <= 330; j++){
			for (int k = 0; k < 2048; k++){
				if (dp[i][j][k]){
					for (int l = 0; l <= 9; l++){
						if ((~k) & (1 << l)){
							dp[i + 1][j + (i + 1) * l][k | (1 << l)] += dp[i][j][k];
						}
					}
				}
			}
		}
	}
	
	int n, s;
	while (scanf("%d %d", &n, &s) != EOF){
		if (s > 330){
			puts("0");
			continue;
		}
		
		int sum = 0;
		for (int i = 0; i < 2048; i++){
			sum += dp[n][s][i];
		}
		printf("%d\n", sum);
	}
	
	return 0;
}

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

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << endl;
#define endl "\n"
#define MOD (int) 1e9+7
#define inf (int) (1e18)

void solve(){
    ll n,m,k;
    cin>>n>>m>>k;
    ll a[n+1],b[m+1];
    a[0]=b[0]=0;

    for(ll i=1;i<=n;i++){
        cin>>a[i];
        a[i]+=a[i-1];
    }
    for(ll i=1;i<=m;i++){
        cin>>b[i];
        b[i]+=b[i-1];
    }

    ll ans=0;
    for(ll i=0;i<=n;i++){
        if(a[i]>k)
            break;
        ans=max(ans,i+(upper_bound(b,b+m+1,k-a[i])-b-1LL));
    }
    cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t=1;
    // cin >> t;
    for(long int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6784
var fs = require('fs');

var inputs = fs.readFileSync('/dev/stdin', 'utf8').split('\n');
var num = Number(inputs[0]);
var wnums = inputs[1].split(' ').map(function (i) {return Number(i);});
var minimum = null;
for (var t = 1; t < num; t++) {
  var sub = wnums.slice(0, t).reduce(function(c,i) {return c+i;}) - wnums.slice(t).reduce(function(c,i) {return c+i});
  if (sub < 0) {
    sub = -sub;
  }
  if (minimum === null || minimum > sub) {
    minimum = sub;
  }
}
console.log(minimum);

Measured memory_bytes: 7624
N,M = map(int,input().split())
st = [tuple(map(int,input().split())) for i in range(N)]
ch = [tuple(map(int,input().split())) for i in range(M)]

ans = []
for sx,sy in st:
    minci = 1
    mind = float('inf')
    for i,(cx,cy) in enumerate(ch):
        d = abs(sx-cx) + abs(sy-cy)
        if d < mind:
            mind = d
            minci = i+1
    ans.append(str(minci))
print(*ans, sep='\n')


Measured memory_bytes: 3064
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
#define maxn 310
using namespace std;
using namespace __gnu_pbds;
const double PI=acos(-1.0);
const double eps=1e-6;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
ll g[maxn][maxn],g2[maxn][maxn];
int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int n,m,l;
    while(cin>>n>>m>>l){
        for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) g[i][j]=INFL;
        for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) g2[i][j]=INFL;
        for(int i=1;i<=n;i++) g[i][i]=0LL;
        for(int i=1;i<=n;i++) g2[i][i]=0LL;
        for(int i=1;i<=m;i++){
            int u=read(),v=read(),w=read();
            if(w<=l) g[u][v]=g[v][u]=(ll)w;
        }
        for(int k=1;k<=n;k++)
            for(int i=1;i<=n;i++)
                for(int j=1;j<=n;j++)
                    if(g[i][k]<INFL && g[k][j]<INFL)
                        g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
        for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) if(g[i][j]<=l) g2[i][j]=1LL;
        for(int k=1;k<=n;k++)
            for(int i=1;i<=n;i++)
                for(int j=1;j<=n;j++)
                    if(g2[i][k]<INFL && g2[k][j]<INFL)
                        g2[i][j]=min(g2[i][j],g2[i][k]+g2[k][j]);
        int q=read();
        for(int i=1;i<=q;i++){
            int s=read(),t=read();
            if(g2[s][t]<INFL) printf("%lld\n",g2[s][t]-1);
            else cout<<-1<<endl;
        }
    }
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf ll(1e12);
bool comp(pair<int,int> p1,pair<int,int> p2)
{
	if((((float)p1.first)/p1.second)>(((float)p2.first)/p2.second))return true;
	else return false;
}
int main()
{
	int n,h,a,b;
	cin>>h>>n;
	ll cst=0,ct=0;
	vector < pair<ll,ll> > v(n);
	int i,j;
	for(i=0;i<n;i++)
	{
		cin>>a>>b;
		v[i].first=a;
		v[i].second=b;
	}
//	sort(v.begin(),v.end(),comp);cout<<v[0].first<<" "<<v[0].second<<endl;
//	while(h>=v[0].first)
//	{
//		h-=v[0].first;
//		cst=cst+v[0].second;ct++;
//	}
//	cout<<cst<<endl;
	ll dp[n+1][h+1];
	for(i=0;i<=n;i++)dp[i][0]=0;
	for(j=0;j<=h;j++)dp[0][j]=inf;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=h;j++)
		{
			if(j>=v[i-1].first)
			dp[i][j]=min(dp[i-1][j],dp[i][j-v[i-1].first]+v[i-1].second);
			else
			dp[i][j]=min(dp[i-1][j],v[i-1].second);
		}
	}
	cst=dp[n][h];cout<<cst<<endl;
}

Measured memory_bytes: 78464
from math import gcd
n = int(input())
li = []
for i in range(n):
    s = input()
    if '.' in s:
        a, b = s.split('.')
        t = 10 ** len(b)
        li.append((int(a) * t + int(b), t))
    else:
        li.append((int(s), 1))
p = [[0] * 35 for _ in range(35)]
cnt = 0
for i in range(n):
    x, y = li[i]
    g = gcd(x, y)
    x //= g
    y //= g
    if y == 1:
        cnt += 1
    li[i] = x
    a1, b1 = 0, 0
    while x % 2 == 0:
        a1 += 1
        x //= 2
    while x % 5 == 0:
        b1 += 1
        x //= 5
    a2, b2 = 0, 0
    while y % 2 == 0:
        a2 += 1
        y //= 2
    while y % 5 == 0:
        b2 += 1
        y //= 5
    p[a1 - a2 + 9][b1 - b2 + 9] += 1
ans = 0
for i in range(0, 35):
    for j in range(0, 35):
        for a in range(max(0, 18 - i), 35):
            for b in range(max(0, 18 - j), 35):
                ans += p[i][j] * p[a][b]
print((ans - cnt) // 2)


Measured memory_bytes: 92124
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
//#include<string>
//#include<sstream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
    int d;
    scanf("%d",&d);
    if(d==25) printf("Christmas\n");
    else if(d==24) printf("Christmas Eve\n");
    else if(d==23) printf("Christmas Eve Eve\n");
    else if(d==22) printf("Christmas Eve Eve Eve\n");
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
#include <cmath>
using namespace std;

int is_palindrome(string s) {
  return equal(s.begin(), s.begin() + s.length() /2, s.rbegin());
}
int main(){
  string s;
  cin >> s;
  int n = s.size();
  int k = ((n+3)/2)-1;
  if(n%2 == 0) cout<< "No";
  else{
    if (!is_palindrome(s)) cout << "No";
    else if (!is_palindrome(s.substr(0,(n-1)/2))) cout << "No";
    else if (!is_palindrome((s.substr(k,n)))) cout << "No";
    else cout <<"Yes" ;

  }
}

Measured memory_bytes: 256
n = int(input())
nl = {}
for _ in range(n-1):
  a, b = map(int, input().split())
  if a-1 in nl:
    nl[a-1].append(b-1)
  else:
    nl[a-1] = [b-1]
  if b-1 in nl:
    nl[b-1].append(a-1)
  else:
    nl[b-1] = [a-1]

fenl = [-1 for _ in range(n)]
sunl = [-1 for _ in range(n)]
fenl[0] = 1
sunl[-1] = 1
now = [0]
while now:
  tmp = []
  for _n in now:
    for nxt in nl[_n]:
      if fenl[nxt] == -1:
        tmp.append(nxt)
        fenl[nxt] = fenl[_n] + 1
  now = tmp

now = [n-1]
while now:
  tmp = []
  for _n in now:
    for nxt in nl[_n]:
      if sunl[nxt] == -1:
        tmp.append(nxt)
        sunl[nxt] = sunl[_n] + 1
  now = tmp

fm, sm = 0, 0
for i in range(n):
  if fenl[i] <= sunl[i]:
    fm += 1
  else:
    sm += 1

if fm <= sm:
  print('Snuke')
else:
  print('Fennec')


Measured memory_bytes: 37568
#include <stdio.h>
#include <stack>
int main(void)
{
    using namespace std;
    stack<int> stk;
    int n;
    while(scanf("%d",&n)==1)
    {
        if(!n)
        {
            printf("%d\n",stk.top());
            stk.pop();
        }
        else
        {
            stk.push(n);
        }
    }
    return 0;
}

Measured memory_bytes: 1036
#include<iostream>
#include<algorithm>
using namespace std;
int main () {
  int n;cin>>n;
  long long int b[n-1],sum=0;
  for (int i=0;i<n-1;i++) cin>>b[i];
  for (int j=0;j<n-2;j++) {
    sum+=min(b[j],b[j+1]);}
  sum+=b[0];sum+=b[n-2];
  cout<<sum<<endl;
}

Measured memory_bytes: 256