akhauriyash/Code-Regression huggingface dataset:
mod reader {
    use std::fmt::Debug;
    use std::str::FromStr;
    use std::collections::VecDeque;
    use std::io::{self, Read};

    fn _read_line() -> String {
        let mut buf = String::new();
        io::stdin().read_to_string(&mut buf);
        buf
    }

    fn _read_vec_deque_string() -> VecDeque<String> {
        _read_line().split_whitespace().map(|s| s.to_string()).collect()
    }

    pub struct Reader {
        buf: VecDeque<String>
    }

    impl Reader {
        pub fn new() -> Reader {
            Reader {buf: VecDeque::new()}
        }

        fn update_buf(&mut self) {
            if self.buf.is_empty() {
                self.buf = _read_vec_deque_string();
            }
        }

        pub fn next<T>(&mut self) -> T where T: FromStr, T::Err: Debug {
            self.update_buf();
            self.buf.pop_front().unwrap().parse::<T>().unwrap()
        }

        pub fn nextN<T>(&mut self, n: usize) -> Vec<T> where T: FromStr, T::Err: Debug {
            let mut vec: Vec<T> = Vec::with_capacity(n);
            for i in 0..n {
                vec.push(self.next());
            }
            vec
        }
    }
}

mod data {
    pub struct UnionFind {
        root : Vec<usize>
    }

    impl UnionFind {
        pub fn new(size : usize) -> UnionFind {
            UnionFind {root : (0..size).collect()}
        }

        pub fn find(&mut self, x : usize) -> usize {
            let xroot = self.root[x];
            if x != xroot {
                self.root[x] = self.find(xroot);
            }
            self.root[x]
        }

        pub fn unite(&mut self, x : usize, y : usize) {
            let xroot = self.find(x);
            self.root[xroot] = self.find(y);
        }

        pub fn same(&mut self, x : usize, y : usize) -> bool {
            self.find(x) == self.find(y)
        }
    }
}

fn with_large_stack(func : fn() -> ()) {
    use std::thread::Builder;
    let builder = Builder::new();
    let th = builder.stack_size(10000000);

    th.spawn(move || {
        func();
    }).unwrap().join();
}

fn main() {
    with_large_stack(_main);
}

fn _main() {
    let mut reader = reader::Reader::new();

    const SUM: usize = 10001;

    let n: usize = reader.next();
    let s: Vec<usize> = reader.nextN(n);

    let mut a: Vec<bool> = vec![false; SUM];
    a[0] = true;

    for x in s {
        for i in (0..SUM).rev() {
            if a[i] {
                a[i + x] = true;
            }
        }
    }

    for i in (0..SUM).rev() {
        if i == 0 || a[i] && (i % 10 != 0) {
            println!("{}", i);
            break;
        }
    }
}

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

void fibonacci(int);
unsigned int *A;


int main(){

  int num;

  scanf("%d", &num);

  fibonacci(num);
  return 0;

}

void fibonacci(int n){
  int i;

  A = malloc(sizeof(int)*n +1);
    
  A[0] = 1;
  A[1] = 1;

  for(i = 2; i < n+1; i++){
    A[i] = A[i-2]+A[i-1];
  }
    printf("%d\n", A[n]);
}



Measured memory_bytes: 2100
#include<stdio.h>
#include<vector>
using namespace std;
#define ll long long
vector<ll> a[100005];
ll n,m,h[100005],i,c,u,v,d[100005];
ll peak(ll val)
{
	bool ok=0;
	for (ll i=0;i<a[val].size();++i)
	if (h[val]<=h[a[val][i]]) ok=1;
	else d[a[val][i]]=1;
	if (!ok) 
	{
		//printf("%lld ",val);
		return 2;
	}
	else return 1;
}
int main()
{
	scanf("%lld%lld",&n,&m);
	for (i=1;i<=n;++i) scanf("%lld",&h[i]);
	for (i=1;i<=m;++i)
	{
		scanf("%lld%lld",&u,&v);
		a[u].push_back(v);
		a[v].push_back(u);
	}
	for (i=1;i<=n;++i) if (!d[i]) d[i]=peak(i);
	for (i=1;i<=n;++i) if (d[i]==2) ++c;
	printf("\n%lld",c);
}

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

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}

int main(void)
{
    int n, k;
    scanf("%d%d", &n, &k);

    int a;
    int i;
    
    int b[n + 1];
    for (i = 0; i < (n + 1); i++) {
        b[i] = 0;
    }

    for (i = 0; i < n; i++) {
        scanf("%d", &a);
        b[a]++;
    }
    qsort(b, n + 1, sizeof(int), cmp);

    while (k) {
        b[n + 1 - k] = 0;
        k--;
    }
    int sum = 0;
    for (i = 0; i < n + 1; i++) {
        sum += b[i];
    }
    printf("%d", sum);
    return 0;

}

Measured memory_bytes: 1788
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int[] a; readA(3, a);
  writeln(a.sort().uniq.walkLength);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;

  int ans=0;
  for(int i=0;i<n;i++){
    if(s[i]=='L')
      if(i-1>=0&&s[i-1]==s[i]) ans++;
    if(s[i]=='R')
      if(i+1< n&&s[i+1]==s[i]) ans++;
  }

  ans+=2*k;
  chmin(ans,n-1);
  cout<<ans<<endl;
  return 0;
}


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


def prime_set(N):
    """
    Nまでの素数のsetを返す
    """
    if N < 4:
        return ({}, {}, {2}, {2, 3})[N]
    Nsq = int(N ** 0.5 + 0.5) + 1
    primes = {2, 3} | set(chain(range(5, N + 1, 6), range(7, N + 1, 6)))
    for i in range(5, Nsq, 2):
        if i in primes:
            primes -= set(range(i * i, N + 1, i * 2))
    return primes


def prime_factorization(n):  # 素因数分解
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            cnt = 0
            while n % i == 0:
                cnt += 1
                n //= i
            res.append((i, cnt))
    if n > 1:
        res.append((n, 1))
    return res


N = int(input())
primes = {p: 0 for p in prime_set(100)}
for i in range(2, N + 1):
    pf = prime_factorization(i)
    for p, f in pf:
        primes[p] += f


n2 = n4 = n14 = n24 = n74 = 0
for v in primes.values():
    if v >= 74:
        n74 += 1
    if v >= 24:
        n24 += 1
    if v >= 14:
        n14 += 1
    if v >= 4:
        n4 += 1
    if v >= 2:
        n2 += 1

ans = 0
if n74:
    ans += n74
if n24:
    ans += n24 * (n2 - 1)
if n14:
    ans += n14 * (n4 - 1)
if n4 >= 2 and n2:
    ans += n4 * (n4 - 1) // 2 * (n2 - 2)

print(ans)

Measured memory_bytes: 9624
N = int(input())
A = [int(n) for n in input().split()]

A = sorted([n - i - 1 for i, n in enumerate(A)])

if N % 2 == 0:
    b = A[N // 2]
else:
    b = A[(N - 1) // 2]

diff = [abs(n - b) for n in A]
sad = sum(diff)

print(sad)

Measured memory_bytes: 26020
// atcoder/arc070/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  lli k;
  while (cin >> n >> k) {
    vector<lli> a(n);
    cin >> a;
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    set<bool> vis;

    int mx = 0;
    for (int i = 0; i < n; ++i) {
      lli sum = 0;
      for (int j = i; j < n; ++j) {
        if (k <= sum + a[j]) {
          setmax(mx, j + 1);
        } else {
          sum += a[j];
        }
      }
    }
    cout << n - mx << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
list1 = list(input())
k = k-1
if list1[k] == "A":
    list1[k] = "a"
elif list1[k] == "B":
    list1[k] = "b"
elif list1[k] == "C":
    list1[k] = "c"

print("".join(list1))

Measured memory_bytes: 38256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#define MOD 2019
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}


int main()
{
    lli i,j,l,r,ans;
    scanf("%lld%lld",&l,&r);
    lli m = (l-1) / 2019;
    lli n = r / 2019;
    if(n-m >= 2 || l==0){
        ans = 0;
    } else {
        lli min = 2019;
        for(i=l; i<r; i++) {
            for(j=i+1; j<=r; j++) {
                min = MIN(min, (i*j)%2019);
                //if((i*j)%2019 == 0)printf("%d %d\n",i,j);
            }
        }
        ans = min;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>

using namespace std;

int main()
{
    int a,b,c;
    scanf( "%d %d %d\n", &a, &b, &c );
    a *= 10;
    c *= 10;
    c += 5;
    int num = c / a;
    printf( "%d\n", b * num );
    return 0;
}

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

using namespace std;

const int H = 1000 + 7;

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;

int main() {
  int n;
  cin >> n;
  cout << 180 * n - 360 << endl;
  return 0;
}
/*
 && ((i > 0 && s[i - 1][j] == '#') || (i < h - 1 && s[i + 1][j] == '#') || (j > 0 && s[i][j - 1] == '#') || (j < w - 1 && s[i][j + 1] == '#'))
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#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)
const lint mod=1e9+7;


int main()
{
  int n;
  cin >> n;
  std::vector<pint> red(n);
  REP(i,n) cin >> red[i].first >> red[i].second;
  std::vector<pint> blue(n);
  REP(i,n) cin >> blue[i].first >> blue[i].second;

  // y座標で降順ソート
  sort(red.begin(),red.end(),[](const pint &alpha,const pint &beta){return alpha.second > beta.second;});
  // x座標で昇順ソート
  sort(blue.begin(),blue.end(),[](const pint &alpha,const pint &beta){return alpha.first < beta.first;});
  lint cnt = 0;
  REP(i,n){
    REP(j,red.size()){
      // 青点よりx,y座標が小さい赤点の中でy座標最大の物を選ぶ
      if(red[j].first < blue[i].first && red[j].second < blue[i].second){
        red.erase(red.begin()+j);
        cnt++;
        break;
      }
    }
  }

  cout << cnt << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    char c;
    cin >> a >> c >> b;
    switch (c){
        case '+':
            cout << a+b << endl;
            break;
        case '-':
            cout << a-b << endl;
            break;
    }
    return 0;
}


Measured memory_bytes: 256
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import itertools
n,m,q = ma()
abcd = []
ls = [i+1 for i in range(m)]
for i in range(q):
    abcd.append(list(ma()))

ans = 0
for A in  itertools.combinations_with_replacement(ls,n):
    tmp = 0
    for a,b,c,d in abcd:
        if A[b-1] - A[a-1] ==c:
            tmp +=d
    ans = max(ans,tmp)
print(ans)


Measured memory_bytes: 73504
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

int A[200010] = {0};//実際の値
int C[200010] = {0};//なん周目で出てきたか
int L[200010] = {0};//最後にその数が出てきた場所
int D[200010] = {0};//次までに進む距離
int main()
{
	ll N,K;
	ll i,j,k;
	ll ans = 0;
	ll mod = 1000000007;
	cin>>N>>K;
	for(i=0;i<N;++i)
	{
		cin >> A[i];
		C[i] = -1;
		L[i] = -1;
		D[i] = -1;
	}
	for(i=0;i<N*2;++i)
	{
		j = i%N;
		if(L[A[j]] > -1)
		{
			D[L[A[j]]%N] = (i-L[A[j]]+1);
		}
		L[A[j]] = i;
	}
	ll pos = 0;
	ll end = N*K; 
	while(pos < end)
	{
		j = pos%N;
		k = pos/N;
		if(C[j]==-1)
		{
			C[j] = k;
			if(pos+D[j] > end)
			{
				break;
			}
			pos += D[j];
		}
		else
		{
			pos += N*((K-k)/(k-C[j]))*(k-C[j]);
			break;
		}
	}
	while(pos+D[pos%N] < end)
	{
		pos += D[pos%N];
	}
	i = pos%N;
	while(i < N)
	{
		if(i+D[i]>N)
		{
			cout << A[i] << " ";
			++i;
		}
		else
		{
			i += D[i];
		}
	}
	cout << endl;

	return 0;
}




















Measured memory_bytes: 4608
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    int ans = 0;
    if(n>1){
        ans += n*(n-1)/2;
    }
    if(m>2){
        ans += m*(m-1)/2;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3696
T=input()

res = ""
for i in range(len(T)) :
    if (T[i] != "?") :
        res += T[i]
        continue
    res += "D"

    # if (i != 0) :
    #     if (T[i-1] == "P") :
    #         res += "D"
    #     else :
    #         res += "D"

print(res)


Measured memory_bytes: 9452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}



const int inf = 1e9;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<vector<pii>> g(n + 1,vector<pii>());
	rep(i,n - 1){
		int a,b;cin >> a >> b;
		g[a].pb(mp(b,1));
		g[b].pb(mp(a,1));
	}
	vector<int> c(n + 1, -1);
	int k;cin >> k;
	rep(i,k){
		int a,b;cin >> a >> b;
		c.at(a) = b;
		g[0].pb(mp(a,b));
	}
	vector<int> dist(n + 1,inf);
	priority_queue<pii,vector<pii>,greater<pii>> q;
	dist.at(0) = 0;
	q.push(mp(0,0));
	while(!q.empty()){
		pii p = q.top();q.pop();
		int v = p.second;
		if(dist.at(v) < p.first) continue;
		rep(i,g.at(v).size()){
			pii e = g.at(v).at(i);
			if(dist.at(e.first) > dist.at(v) + e.second){
				dist.at(e.first) = dist.at(v) + e.second;
				q.push(mp(dist.at(e.first), e.first));
			}
		}
	}
	rep(i,n) if(c.at(i + 1) == -1) c.at(i + 1) = dist.at(i + 1);
	queue<int> que;
	vector<bool> visited(n + 1);
	visited.at(1) = true;
	que.push(1);
	bool ok = true;
	while(!que.empty()){
		int cur = que.front();que.pop();
		rep(i,g.at(cur).size()){
			int next = g.at(cur).at(i).first;
			if(abs(c.at(cur) - c.at(next)) != 1){
				ok = false;
				break;
			}
			if(!visited.at(next)){
				que.push(next);
				visited.at(next) = true;
			}
		}
	}
	if(ok){
		cout << "Yes" << endl;
		rep(i,n) cout << c.at(i + 1) << endl;
	}
	else cout << "No" << endl;
}


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

const int maxn = 1e5 + 10;
int n, a[maxn], res;

int main() {
	scanf("%d", &n);
	for(int i = 1; i < n; ++i) {
		scanf("%d", &a[i]);
	}	
	res = a[1] + a[n - 1];
	for(int i = 2; i < n; ++i) {
		res += min(a[i], a[i - 1]);
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}


//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

int main(){
  int K;string S;cin>>K>>S;
  if(S.size()<=K)cout<<S<<endl;
  else{
    cout<<S.substr(0,K);
    cout<<"..."<<endl;
  }

}






Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  int ans = 0;
  while(true){
    bool c = true;
    rep(i,n){
      if(a.at(i)&1){
        c=false;
      }
    }
    if(c){
      ans++;
      rep(i,n){
        a.at(i)=a.at(i)>>1;
      }
    }else{
      break;
    }
  }
  cout << ans << endl;
}


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

// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}
 
const int MAX = 510000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    COMinit();
    ll v1 = 1;
    for (ll i = n; i > n - a; i--) {
        v1 *= i;
        v1 %= MOD;
    }
    ll v2 = 1;
    for (ll i = n; i > n - b; i--) {
        v2 *= i;
        v2 %= MOD;
    }
    v1 *= finv[a];
    v2 *= finv[b];
    v1 %= MOD;
    v2 %= MOD;
    ll ans = modpow(2, n, MOD) - 1 - v1 - v2;
    ans += 10 * MOD;
    ans %= MOD;
    //cout << v1 * finv[a] << " " << v2<< "\n";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    string s = to_string(n);
    int res = 0;
    for(auto i:s){
        res+=i-'0';
    }
    if(n%res){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
s = [input() for i in range(N)]

a = [0] * N
b = [0] * N

ans = 0
for i in range(N):
    if s[i][0] == "B":
        b[i] = 1
    if s[i][-1] == "A":
        a[i] = 1
    for j in range(0,len(s[i])-1):
        if s[i][j] == "A" and s[i][j+1] == "B":
            ans += 1

special = 0

for i in range(N):
    if a[i] == 1 and b[i] == 1:
        special += 1
        a[i] = 0
        b[i] = 0


counta = a.count(1)
countb = b.count(1)



if counta == 0 and countb == 0 and special > 0:
    ans += special - 1
else:
    ans += min(counta + special, countb + special)


print(ans)

Measured memory_bytes: 3828
#include<stdio.h>

int main()
{
  int r,g,b,tmp,R,G,ans;

  scanf("%d %d %d",&r,&g,&b);

  R=100*r;
  G=10*g;
  tmp=R+G+b;

  ans=tmp%4;

  if(ans==0)printf("YES");
  else printf("NO");

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>

#define ll long long

using namespace std;

int INF=10000;
int H, W;
int c[10][10];
int d[10];
bool used[10];
int sum = 0;

int min_d()
{
    int min_num = -1;
    int min = INF;
    for (int i=0; i<=9; i++) {
        if (!used[i] && d[i] < min) {
            min_num = i;
            min = d[min_num];
        }
    }
    return min_num;
}



int main()
{
    cin >> H >> W;
    int A[H+1][W+1];

    for (int i=0; i<=9; i++) {
        for (int j=0; j<=9; j++) {
            cin >> c[i][j];
        }
    }

    for (int i=1; i<=H; i++) {
        for (int j=1; j<=W; j++) {
            cin >> A[i][j];
        }
    }

    for (int i=0; i<=9; i++) {
        d[i] = INF;
        used[i] = false;
    }
    d[1] = 0;

    while (true) {
        int to = min_d();

        if (to < 0) {
            break;
        }

        used[to] = true;

        for (int i=0; i<=9; i++) {
            if (!used[i]) {
                d[i] = min(d[i], c[i][to] + d[to]);
            }
        }
    }
    for (int i=1; i<=H; i++) {
        for (int j=1; j<=W; j++) {
            if (A[i][j] >= 0) {
                sum += d[A[i][j]];
            }
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
typedef long long ll;
ll n,h,w,a,b,ans=0;
int main(){
	cin>>n>>h>>w;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(a>=h && b>=w) ans++;
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 256
#include <limits.h>
#include <iostream>
#include <vector>

int bubbleSort(std::vector<int> &data, int dataLength);
int main(void)
{
    int dataLength = 0;         // データ数
    // データ数を入力
    std::cin >> dataLength;

    std::vector<int> data(dataLength);   // ソートデータ

    for (int i = 0; i < dataLength; i++) {
        std::cin >> data[i];
    }

    int swapCnt = bubbleSort(data, dataLength);

    std::cout << data[0];
    for (int k = 1; k < dataLength; k++) {
        std::cout << " " << data[k];
    }
    std::cout << "\n";
    std::cout << swapCnt << "\n";

    return 0;
}

int bubbleSort(std::vector<int> &data, int dataLength)
{
    int swapCnt = 0;
    bool flag = true;

    
    for (int i = 0; i < dataLength - 1; i++) {
        for (int j = dataLength - 1; j > i; j--) {
            if (data[j] < data[j - 1]) {
                int temp = data[j];
                data[j] = data[j - 1];
                data[j - 1] = temp;
                swapCnt++;
            }
        }
    }

    return swapCnt;
}



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

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main()
{
    int n,i,j,min,k;
    static int h[100000];

    scanf("%d",&n);
    scanf("%d",&k);
    for(i=0;i<n;i++){
        scanf("%d",&h[i]);
    }

    qsort(h,sizeof(h)/sizeof(int),sizeof(int),asc);

    min=10000000000;
    for(i=0;i<100000-(k-1);i++){
        if((min>abs(h[i]-h[i+(k-1)]))&&(h[i]!=0)){
            min=abs(h[i]-h[i+(k-1)]);
        }
    }

    printf("%d\n",min);

    return 0;
}

Measured memory_bytes: 892
#input
a, b = map(int, input().split())

# 最大公約数
def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

n = gcd(a, b)
pf = factorization(n)
if pf == [[1, 1]]:
    print("{}".format(len(pf)))
else:
    print("{}".format(len(pf)+1))

Measured memory_bytes: 3064
#include <stdio.h>
int ren(int n){
    int same=1,m_same=0;
    int d=-1;
    while(n){
        if(n%10==d){
            same++;
        }else{
            same=1;
        }
        if(same>=m_same){
            m_same=same;
        }
        d=n%10;
        n=n/10;
    }
    return m_same;
}
int check(int n){
    return ren(n)>=3;
}
int main(void){
    // Your code here!
    int n;
    scanf("%d",&n);
    if(check(n)){
        puts("Yes");
    }else{
        puts("No");
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 400000000
using namespace std;

typedef pair<int, int> P;

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    int x[n + 1];
    fill(x, x+n+1, 0);
    int i = 0;
    for (; i < n; i++) {
        int t;
        scanf(" %d", &t);
        if (t >= 0) {
            x[++i] = t;
            break;
        }
        x[i] = -t;
    }
    i++;
    for (; i <= n; i++) {
        scanf(" %d", x+i);
    }
    int ans = INF;
    for (int i = k; i <= n; i++) {
        ans = min(ans, min(x[i] * 2 + x[i - k], x[i] + x[i - k] * 2));
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<queue>
#define inf 10000001
#define f first
#define s second
using namespace std;

int n,m,map[100][100];
bool B[10001];

int prim(int a)
{
  priority_queue<pair<int,int> > PQ;
  int d[100],color[100];
  for(int i=0;i<n;i++){
    d[i]=inf;
    color[i]=0;
  }
  d[0]=0;
  PQ.push(make_pair(0,0));
  color[0]=0;
  while(!PQ.empty()){
    pair<int,int> p=PQ.top();PQ.pop();
    int u=p.s;
    color[u]=2;

    if(d[u]<p.f*(-1))continue;

    for(int i=0;i<n;i++){
      if(color[i]==2 || map[u][i]==inf)continue;
      if(a<=map[u][i] && d[i]>map[u][i]){
	d[i]=map[u][i];
	PQ.push(make_pair(d[i]*(-1),i));
	color[i]=1;
      }
    }
  }
  int b=0;
  for(int i=0;i<n;i++)b=max(b,d[i]);
  return b-a;
}
int main()
{
  int a,b,c,ans;
  while(1){
    cin>>n>>m;
    if(n+m==0)break;

    for(int i=0;i<10001;i++)B[i]=false;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++)map[i][j]=inf;
    }
    
    for(int i=0;i<m;i++){
      cin>>a>>b>>c;
      map[a-1][b-1]=c;
      map[b-1][a-1]=c;
      B[c]=true;
    }
    
    ans=inf;
    for(int i=0;i<10001;i++){
      if(B[i])ans=min(prim(i),ans);
    }
    if(ans>100001)cout<<"-1"<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

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

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define debug_interval ','
#define dump_interval endl
#define debug_toggle 0

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}

int a,b,w;

int main(){
    ios::sync_with_stdio(false);
    cin>>w>>a>>b;
    if(w+a<b)dump(b-w-a);
    else if(b+w<a)dump(a-b-w);
    else dump(0);
  }

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

int BOARD[50][50];

int main()
{
    int h,w,flag=0;
    string s;
    cin >> h >> w;
    for(int i=0;i<h;i++){
        cin >> s;
        for (int j=0;j<w;j++){
            if(s[j]=='.'){
                BOARD[i][j]=0;
            } else{
                BOARD[i][j]=1;
            }
        }
    }

    // for(int i=0;i<h;i++){
    //     for(int j=0;j<w;j++){
    //         cout << BOARD[i][j];
    //     }
    //     cout << endl;
    // }

    for(int i=1;i<h-1;i++){
        for(int j=0;j<w;j++){
            if(BOARD[i][j]==1){
                if(j==0){
                    if(BOARD[i+1][j]!=BOARD[i][j]&&BOARD[i-1][j]!=BOARD[i][j]&&BOARD[i][j+1]!=BOARD[i][j]){
                        flag=1;
                    }
                }else if(j==w-1){
                    if(BOARD[i+1][j]!=BOARD[i][j]&&BOARD[i-1][j]!=BOARD[i][j]&&BOARD[i][j-1]!=BOARD[i][j]){
                        flag=1;
                    }
                }else{
                    if(BOARD[i+1][j]!=BOARD[i][j] && BOARD[i][j]!=BOARD[i-1][j] && BOARD[i][j]!=BOARD[i][j+1] && BOARD[i][j]!=BOARD[i][j-1]){
                        flag = 1;
                    }
                }
            }
            
        }
    }

    if(flag==0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
    }

    return 0;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  int N, ans=0;
  cin >> N;
  VI d(N);
  REP(i,N) {
    cin >> d.at(i);
  }
  REP(i,N) {
    REP(j,N) {
      if(i == j) {
        continue;
      }
      else {
        ans += d.at(i) * d.at(j);
      }
    }
  }
  ans /= 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
function Main(input) {
    input = input.split('\n');
    var arr = input[0].split(' ').map(Number);
    var a = arr[0];
    var b = arr[1];

    if(a*b % 2 != 0) console.log('Yes');
    else console.log('No');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22204
#include "bits/stdc++.h"
using namespace std;
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;

const double PI = 3.141592653589793;


int main() {
	// fios;
	int n;
	cin >> n;
	map<int, int> mp;
	for(int i = 2, inp; i <= n; i++) {
		cin >> inp;
		mp[inp]++;
	}
	for(int i = 1; i<=n; i++) {
		cout << mp[i] << endl;	
	}
	// puts("");
}

Measured memory_bytes: 12980
#include <iostream>
#include <vector>

using namespace std;

int d[7][7] = {    // front, top
  0, 0, 0, 0, 0, 0, 0,   // 0
  0, 0, 4, 2, 5, 3, 0,   // 1  
  0, 3, 0, 6, 1, 0, 4,   // 2
  0, 5, 1, 0, 0, 6, 2,   // 3
  0, 2, 6, 0, 0, 1, 5,   // 4
  0, 4, 0, 1, 6, 0, 3,   // 5
  0, 0, 3, 5, 2, 4, 0,   // 6
};

int main(int argc, char* argv[]) {
  vector<int> dice;

  for (int i = 0; i < 6; i++) {
    int in; cin >> in;
    dice.push_back(in);
  }
  
  int q; cin >> q;

  for (int i = 0; i < q; i++) {
    int top, front; cin >> top >> front;

    int f = -1, t = -1;
    for (int j = 0; j < 6; j++) {
      if (dice[j] == top) {
	t = j+1;
      } else if (dice[j] == front) {
	f = j+1;
      }
    }
    cout << dice[d[f][t]-1] << endl;
  }

  return 0;
}

Measured memory_bytes: 1212
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int a[4],b[2];
    rep(i,0,4)cin>>a[i];
    rep(i,0,2)cin>>b[i];
    sort(a,a+4); sort(b,b+2);
    cout<<a[1]+a[2]+a[3]+max(b[0],b[1])<<endl;
}


/*
abcdea

/root
a.txt
bunp.html
/desktop
r.txt
fsharp.cs
dp.cpp
/users
bison.txt

root r.txt
users r.txt
users a.txt

desktop/r.txt
../r.txt
../../a.txt
*/



Measured memory_bytes: 3148
M = 10**9 + 7
s = int(input()) - 3

f = [1]
for i in range(1, s + 1):
  f.append(f[-1] * i % M)

r = 0
for k in range(s // 3 + 1):
  r += f[s] * pow(f[k], M - 2, M) * pow(f[s - k], M - 2, M)
  s -= 2

print(r % M)


Measured memory_bytes: 9140
import sys
from bisect import bisect_right

import numpy as np

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, M, K = map(int, input().split())
    A = [0] + list(map(int, input().split()))
    B = [0] + list(map(int, input().split()))
    a = np.cumsum(A)
    b = np.cumsum(B)

    ans = 0
    for i in range(N + 1):
        time = a[i]
        if time > K:
            continue
        idx = bisect_right(b, K - time)
        tmp = i + idx - 1
        if tmp > ans:
            ans = tmp

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 59916
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];
    println!("{} {}", a * b, 2 * (a + b));
}



Measured memory_bytes: 5024
#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include <iostream>
#define stop(x) {cout<<x<<endl;exit(0);}
#define all(x) x.begin(),x.end()
#define szz(s) int(s.size())
#define endl '\n'
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
typedef long long ll;
using namespace std;

void file() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    if (freopen("input.txt", "r", stdin));
    if (freopen("output.txt", "w", stdout));
#endif
}


int main()
{
    file();

    int n;
    cin >> n;
    cout << 2 * acos(-1) * n << endl;

    


}


Measured memory_bytes: 3236
#include<stdio.h>
int main(){
  int a,b,c,t;
  scanf("%d %d %d", &a,&b,&c);
  if(a>b){
    t=a;
    a=b;
    b=t;
  }
  if(b>c){
    t=b;
    b=c;
    c=t;
  }
 if(a>b){
    t=a;
    a=b;
    b=t;
  }
 printf("%d %d %d\n", a,b,c);
  return 0;
}

Measured memory_bytes: 596
def f_e():
    n, *p = map(int, open(0).read().split())
    p = sorted([(v, i) for i, v in enumerate(p)])
    *l, = range(-1, n-1)
    *r, = range(1, n+1)
    a = 0
    for v, i in p:
        l0, r0 = l[i], r[i]
        l1 = l[l0] if l0>-1 else l0
        r1 = r[r0] if r0<n else r0
        a += ((l0-l1)*(r0-i)+(r1-r0)*(i-l0))*v
        if l0>-1:
            r[l0]=r0
        if r0<n:
            l[r0]=l0
    print(a)

if __name__ == "__main__":
    f_e()


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

using namespace std;

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

  int N, u, v; cin>>N>>u>>v;
  u--; v--;
  vector<int> tree[N];
  for (int i = 0; i < N-1; i++) {
    int a,b; cin>>a>>b;
    a--; b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  auto get_dists = [&](int f) {
    queue<pair<int, int>> qs;
    qs.push({f, 0});
    vector<int> dists(N, -1);
    while (not qs.empty()) {
      auto q = qs.front(); qs.pop();
      dists[q.first] = q.second;
      for (auto t : tree[q.first]) {
        if (dists[t] != -1)
          continue;
        qs.emplace(t, q.second+1);
      }
    }
    return dists;
  };
  auto dfu = get_dists(u);
  auto dfv = get_dists(v);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (tree[i].size() > 1)
      continue;
    if (dfu[i] < dfv[i]) {
      ans = max(ans, dfv[i]-1);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template <typename T>void read(T &x){
	x = 0; int f(1); char c = getchar();
	for(;!isdigit(c);c = getchar()) if(c == '-') f = -1;
	for(;isdigit(c);c = getchar()) x = x*10+c-'0';
	x *= f;
}
ll x;
int main(){
	read(x);
	for(ll a(-1000);a <= 1000;++a)
		for(ll b(-1000);b <= 1000;++b){
			ll tmp;
			tmp = a*a*a*a*a;
			tmp -= b*b*b*b*b;
			if(tmp == x){
				printf("%lld %lld\n",a,b);
				return 0;
			}
		}
	return 0;
}

Measured memory_bytes: 3696
/**
 *    author:  tourist
 *    created: 20.11.2019 13:56:07       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    --a[i];
  }
  vector<long long> k(m + 1);
  vector<long long> b(m + 1);
  auto Add = [&](int from, int to, int kk, int bb) {
    k[from] += kk;
    b[from] += bb;
    k[to + 1] -= kk;
    b[to + 1] -= bb;
  };
  for (int i = 0; i < n - 1; i++) {
    if (a[i + 1] >= a[i]) {
      int diff = a[i + 1] - a[i];
      Add(0, a[i], 0, diff);
      Add(a[i] + 1, a[i + 1], -1, a[i + 1] + 1);
      Add(a[i + 1] + 1, m - 1, 0, diff);
    } else {
      int diff = a[i + 1] - a[i] + m;
      Add(a[i + 1] + 1, a[i], 0, diff);
      Add(a[i] + 1, m - 1, -1, diff + a[i] + 1);
      Add(0, a[i + 1], -1, a[i + 1] + 1);
    }
  }
  for (int i = 0; i < m; i++) {
    k[i + 1] += k[i];
    b[i + 1] += b[i];
  }
  long long ans = (long long) 9e18;
  for (int i = 0; i < m; i++) {
    ans = min(ans, i * k[i] + b[i]);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

void solve(int n, vector<int> p) {
    int ret = 0;
    bool flag = true;
    for (int i = 0; i < n; i++) {
        if (flag && p[i] == i+1) {
            ret++;
            flag = false;
        } else {
            flag = true;
        }
    }
    std::cout << ret << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    int n;

    gettimeofday(&start,NULL);

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

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 1024