akhauriyash/Code-Regression huggingface dataset:
# https://atcoder.jp/contests/dp/tasks/dp_h

mod = int(1e9+7)

fact = [1 for _ in range(200001)]
for i in range(2, 200001):
    fact[i] = fact[i-1] * i % mod

fraci = [None] * 200001
fraci[-1] = pow(fact[-1], mod-2, mod)

for i in range(-2, -200001-1, -1):
    fraci[i] = fraci[i+1] * (200001 + i + 1) % mod

def comb(a, b):
    if not a >= b >= 0:
        return 0
    return fact[a]*fraci[b]*fraci[a-b]%mod


h, w, n = [int(i) for i in raw_input().split()]
walls = []

for i in xrange(n):
    i, j = [int(i) for i in raw_input().split()]
    walls.append((i-1,j-1))
walls.append((h-1, w-1))

walls.sort()

def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def binomial(n, k):
    # n choose k mod p
    # (n, k) mod m = (n! * (k!)^-1 * ((n - k)!)^-1) mod m

    p = int(1e9) + 7
    first = 1
    for x in range(1, n+1):
        first = first * x % p

    second = 1
    for x in range(1, k+1):
        second = second * x % p

    third = 1
    for x in range(1, n-k+1):
        third = third * x % p

    output = first * modinv(second, p) * modinv(third, p) % p

    return output

f = [0] * len(walls) # ways to reach dest without going through f[i]

# print walls

for i in range(len(walls)):
    f[i] = comb(walls[i][0]+walls[i][1], walls[i][0])

# print f

# f[i] = no of ways to reach (h,w) without going walls[0..i]

p = int(1e9+7)
for i in range(len(walls)):
    for j in range(i+1, len(walls)):
        if walls[j][0] >= walls[i][0] and walls[j][1] >= walls[i][1]:
            f[j] -= f[i] * comb(walls[j][0]-walls[i][0]+walls[j][1]-walls[i][1], walls[j][0]-walls[i][0])
            f[j] %= p

# print f
print f[-1] % (int(1e9)+7)


Measured memory_bytes: 63220
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif
 
#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }
 
void largest_rectangle_in_a_histogram() {
    int N; cin >> N;
    vector<int> h(N); rep(i, 0, N) { cin >> h[i]; }
    using P = pair<int, int>;
    stack<P> st;
    st.emplace(-1, -1);
    int ans = 0;
    rep(i, 0, N) {
        if (st.top().first == h[i])
            continue;
        int pos = i;
        while (st.top().first >= h[i]) {
            chmax(ans, st.top().first*(i - st.top().second));
            pos = st.top().second;
            st.pop();
        }
        st.emplace(h[i], pos);
    }
    while (st.size()) {
        chmax(ans, st.top().first*(N - st.top().second));
        st.pop();
    }
    cout << ans << endl;
}
 
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    largest_rectangle_in_a_histogram();
    return 0;
}

Measured memory_bytes: 5276
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void test_case();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	int n;
	cin >> n;
	vector < int > h(n);
	for (auto &el: h) {
		cin >> el;
	}
	int res = 0;
	while (*max_element(all(h)) != 0) {
		int mx = *max_element(all(h));
		for (int i = 0; i < n; ) {
			int foo = h[i];
			if (foo == mx) {
				while (i < n && h[i] == foo) {
					--h[i++];
				}
				++res;
			} else {
				++i;
			}
		}
	}
	cout << res << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> g(h,vector<char>(w));
  rep(i,h)rep(j,w)cin >> g[i][j];
  vector<bool> row(h,0);
  vector<bool> col(w,0);
  rep(i,h)rep(j,w)if(g[i][j]=='#'){
    row[i]=1;
    col[j]=1;
  }
  rep(i,h){
    if(!row[i])continue;
    rep(j,w){
      if(!col[j])continue;
      cout << g[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <numeric>
using namespace std;
//void inputer();
long long int A, B, C, D;
long long int lcm(long long int a, long long int b);

int main() {
	cin >> A >> B >> C >> D;
	long long int E = lcm(C, D);
	long long int  x1 = -((A - 1) / C)+ (B / C);;
	long long int  x2 = -((A - 1) / D)+ (B / D);
	long long int  x3 = -((A - 1) / E) + (B / E);
	long long int tmp = x1 - x3 + x2;
	long long int ans = (B - A + 1) - tmp;
	cout << ans;
	return 0;
}

long long int lcm(long long int a, long long int b) {
	long long int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return C/b * D;
}



/*#include <iostream>
#include <string>
#include <cmath>
#include <numeric>
using namespace std;
//void inputer();
int main() {
	return 0;
}*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int a[3];
string s;

int f(int &I){
	if(isdigit(s[I])) return s[I++]-'0';
	if(isalpha(s[I])) return a[s[I++]-'P'];
	if(s[I]=='-'){
		int t=f(++I);
		if(t==2) t=0;
		else if(t==0) t=2;
		return t;
	}
	int x=f(++I);
	char c=s[I];
	int y=f(++I);
	I++;
	if(c=='*') return min(x,y);
	else return max(x,y);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		cin>>s;
		if(s==".") break;
		int res=0;
		for(int i=0;i<27;i++){
			a[0]=i%3;
			a[1]=i/3%3;
			a[2]=i/9%3;
			int I=0;
			if(f(I)==2) res++;
		}
		cout<<res<<endl;
	}
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N, K; cin >> N >> K;
    cout << (N - K + 1) << endl;

    return 0;
}


Measured memory_bytes: 3564
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
x = list(itertools.permutations([i+1 for i in range(n)]))
a, b = 0, 0
for i, x in enumerate(x):
    if p == x: a = i
    if q == x: b = i
    if a and b: break
print(abs(a-b))


Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n,m;
    in(n,m);
    int k,s;
    vector2d(int,vec,m,n,0);
    rep(q,m){
        in(k);
        while(k--){
            in(s);
            vec[q][s-1]=1;
        }
    }
    vector<int> p(m);
    int ans=0;
    in(p);
    int sum,d;
    //debug("enter");
    for(int i=0;i<(1<<n);i++){
        bitset<32> on(i);
        d=0;
        rep(q,m){
            sum=0;
            for(int j=0;j<n;j++){
                if(on.test(j))sum+=vec[q][j];
            }
            if(sum%2==p[q])d++;
            else break;
        }
        if(d==m)ans++;
    }
    out(ans);
}

Measured memory_bytes: 3720
#include<iostream>
#include<numeric>
#include<vector>
using namespace std;

typedef long long ll;
const ll mod = 1e9+7;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;
    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> sub(k+1, 0);
    ll ans = 0;
    for(int g = k; g >= 1; g--){
        ll num = k/g;
        ll tmp = modpow(num, n, mod);
        ll add = (tmp-sub[g]+mod)%mod;
        ans += add*g;
        ans %= mod;
        for(int j = 1; j*j <= g; j++){
            if(g%j) continue;
            sub[j] = (sub[j]+add)%mod;
            if(j != g/j)    sub[g/j] = (sub[g/j]+add)%mod;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const long long INF = 1LL << 58;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
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()
{
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;

    vi lst;
    lst.resize(N);

    lst[0] = 0;
    REP(i, N - 1)
    {
        if (S[i + 1] == 'C' and S[i] == 'A')
        {
            lst[i + 1] = lst[i] + 1;
        }
        else
        {
            lst[i + 1] = lst[i];
        }
    }

    vi ans;
    ans.resize(Q);
    int l, r;
    REP(i, Q)
    {
        cin >> l >> r;
        ans[i] = lst[r - 1] - lst[l - 1];
    }
    REP(i, Q)
    cout << ans[i] << endl;

    // system("pause");
}

Measured memory_bytes: 2688
n = int(input())
V1 = list(map(int, input().strip().split()))
C1 = list(map(int, input().strip().split()))

sums = 0

for i in range(n):
    if V1[i] - C1[i]>0:
        sums+= V1[i] - C1[i]
print(sums)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

ll D, c[33], s[444][33], t[444], last[33] = {};
set<ll> s1[33], s2[33];

// vector<ll> score(ll t[]) {
//     ll i, j, sc = 0;
//     vector<ll> v;
//     v.pb(0);
//     for (i = 1; i <= D; i++){
//         sc += s[i][t[i]];
//         last[t[i]] = i;
//         for (j = 1; j <= 26;j++)
//             sc -= c[j] * (i - last[j]);
//         v.pb(sc);
//     }
//     return v;
// }

ll cost(ll k, ll dis){
    return k * dis * (dis - 1) / 2;
}

ll eval(ll d, ll q){
    ll bq = t[d];
    ll b = *s1[bq].upper_bound(d);
    ll a = *s2[bq].upper_bound(-d);
    ll sc = 0;
    sc -= s[d][bq];
    sc += s[d][q];
    ll l = d + a, r = b - d;
    sc += cost(c[bq], l);
    sc += cost(c[bq], r);
    sc -= cost(c[bq], l + r);
    b = *s1[q].upper_bound(d);
    a = *s2[q].upper_bound(-d);
    l = d + a, r = b - d;
    sc -= cost(c[q], l);
    sc -= cost(c[q], r);
    sc += cost(c[q], l + r);
    return sc;
}

int main(){
    ll i, j;
    cin >> D;
    for (i = 1; i <= 26;i++)
        cin >> c[i];
    for (i = 1; i <= D;i++)
        for (j = 1; j <= 26;j++)
            cin >> s[i][j];
    for (i = 1; i <= 26; i++){
        s1[i].insert(D + 1);
        s2[i].insert(0);
    }
    for (i = 1; i <= D;i++){
        ll ma = -1e9, p;
        for (j = 1; j <= 26; j++){
            if(c[j]*(i-last[j])+s[i][j]>ma){
                ma = c[j] * (i - last[j]) + s[i][j];
                p = j;
            }
        }
        t[i] = p;
        last[p] = i;
    }
    for (i = 1; i <= D;i++){
        s1[t[i]].insert(i);
        s2[t[i]].insert(-i);
    }
    for (i = 0; i < 100000;i++){
        ll ma = -1e9, p;
        ll d = i % 26 + 1;
        for (j = 1; j <= 26; j++){
            ll sc = eval(d, j);
            if(sc > ma){
                ma = sc;
                p = j;
            }
        }
        s1[t[d]].erase(d);
        s2[t[d]].erase(-d);
        s1[p].insert(d);
        s2[p].insert(-d);
        t[d] = p;
    }
    for (i = 1; i <= D;i++)
        cout << t[i] << endl;
}

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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int N, M;
    map<string, int> dic;
    cin >> N;
    rep(i, N)
    {
        string s;
        cin >> s;
        if (dic.count(s))
            dic[s]++;
        else {
            dic[s] = 1;
        }
    }
    cin >> M;
    rep(i, M)
    {
        string t;
        cin >> t;
        if (dic.count(t))
            dic[t]--;
        else {
            dic[t] = -1;
        }
    }

    int max = 0;
    for (auto p : dic) {
        if (p.second > max) {
            max = p.second;
        }
    }

    cout << max << endl;
}


Measured memory_bytes: 256
import Data.List
import Data.Array
import Data.Array.IO
import Data.Maybe
import Data.Bits
import Control.Monad
import Control.Applicative

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

listToTuple2 (a:b:_) = (a,b)
listToTuple3 (a:b:c:_) = (a,b,c)
listToTuple4 (a:b:c:d:_) = (a,b,c,d)



main :: IO ()
main = do
  n <- readLn :: IO Int
  putStrLn $ if or $ map (\x -> n-x >= 0 && mod (n-x) 4 == 0) (takeWhile (<=100) $ [0,7..]) then "Yes" else "No"

  return ()


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


int main() {
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    long long c0 = 0, c1 = 0;
    for (int d = 1; d*k <= 2*n; d++) {
        if (d%2) {
            c1++;
        } else {
            c0++;
        }
    }
    long long ans = -1;
    if (k%2 == 0) {
        ans = c0*c0*c0 + c1*c1*c1;
    } else {
        ans = c0*c0*c0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#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;}

int n,m,q;
vector<int>a,b,c,d;
int dfs(int index,vector<int>& A) {
    if(index==n) {
        int res = 0;
        rep(i,q) {
            if(A[b[i]] - A[a[i]] == c[i]) res += d[i];
        }
        return res;
    }
    int res = 0;
    for(int i = 1;i<=m;i++) {
        if(index>0 && i<A[index-1]) continue;
        A.push_back(i);
        int tmp = dfs(index+1,A);
        A.pop_back();
        res = max(res,tmp);
    }
    return res;
}

int main() {
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    rep(i,q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;b[i]--;
    }
    vector<int>A;
    int ans = dfs(0,A);
    cout << ans << endl;
}

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


public class Contest
{
	public static void Main()
	{
		int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));

//		int[] b = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] c = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] d = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));

		int ss = 0;
		int m = 0;
		for(int i=0; i<a.Length; i++) {
			if(m<a[i])m=a[i];
			ss+=a[i];
		}


		Console.WriteLine(ss-m);
	}
	
	private static int calc_main(int[] a,int[] b,int[] c,int[] d) {



		return 0;
	}




}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

int exmin(int a,int b){
    if(a==0){
        return b;
    }
    else{
        return min(a,b);
    }
}

signed main(){
    int H,N;
    int amax=0;
    cin >>H >>N;
    vector<vector<int>>vec(N,vector<int>(2));
    REP(i,N){
        cin >>vec[i][0] >>vec[i][1];
        amax=max(amax,vec[i][0]);
    }
    vector<int>dp(H+amax,0);
  	vector<bool>check(H+amax,false);
  	check[0]=true;
    int ans;
    REP(i,H+amax){
        REP(j,N){
            int z=i-vec[j][0];
            if(z>=0&&check[z]==true){
                dp[i]=exmin(dp[i],dp[z]+vec[j][1]);
              	check[i]=true;
            }
        }
        if(i==H&&check[i]==true){
            ans =dp[i];
        }
        if(i>H&&check[i]==true){
            ans =min(ans,dp[i]);
        }
    }
  	cout <<ans<<endl;
}

Measured memory_bytes: 384
/*
 * Created by Dipta Das on 
 * Title: []
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/
#include <bits/stdc++.h>
#define fin freopen("input", "r", stdin);
#define fout freopen("output", "w", stdout);
#define wt(x) cerr << #x << ": " << x << " ";
#define whatis(x) {cerr << #x << ": " << x << endl;}
#define whatis2(x, y) {wt(x); wt(y); cerr << endl;}
#define whatis3(x, y, z) {wt(x); wt(y); wt(z); cerr << endl;}
#define whatis4(x, y, z, a) {wt(x); wt(y); wt(z); wt(a); cerr << endl;}
using namespace std;

typedef long long ll; typedef unsigned long long ull; typedef long double ld;
const ll MOD = 1000000007; const ld PI = acos(-1.0);

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

    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.size();
    if (n <= k) {
        cout << s << endl;
    } else {
        for (int i = 0; i < k; ++i) cout << s[i];
        cout << "..." << endl;
    }


    return 0;
}


Measured memory_bytes: 3656
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        List<Integer> dRew=new ArrayList<Integer>();
        List<Integer> dRns=new ArrayList<Integer>();
        Integer tmpD=0;
        int comN,com1,com2;
        int[] diceN=new int[6];
        
        for(int i=0; i<6; i++)
            diceN[i]=scan.nextInt();
        
        dRns.add(diceN[4]);
        dRns.add(diceN[1]);
        dRew.add(diceN[3]);
        dRew.add(diceN[0]);
        dRew.add(diceN[2]);
        dRew.add(diceN[5]);
        
        //System.out.println(dRew+":"+dRns);
        
        comN=scan.nextInt();
        for(int i=0; i<comN; i++){
            com1=scan.nextInt();
            com2=scan.nextInt();
            
            if(dRns.indexOf(com1)!=-1){
                System.out.println(dRew.get((dRew.indexOf(com2)+(dRns.indexOf(com1)==0?1:3))%4));
            }
            else if(dRns.indexOf(com2)!=-1){
                System.out.println(dRew.get((dRew.indexOf(com1)+(dRns.indexOf(com2)==1?1:3))%4));
            }
            else{
                System.out.println(dRns.get((dRew.indexOf(com1)-dRew.indexOf(com2)+4)%4==1?1:0));
            }
            
        }
    }
}


Measured memory_bytes: 26064
s = input()

alphabet = ["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", ]

for i in alphabet:
    if i not in s:
        print(i)
        break
else:
    print("None")

Measured memory_bytes: 3188
X,Y = map(int,input().split())

if X == Y == 1:
    print(1000000)
else:
    if X <= 3 and Y <= 3:
        print(((4-X)+(4-Y))*10**5)
    else:
        print((4-min(X,Y))*10**5 if 4-(min(X,Y)) >= 0 else 0)

Measured memory_bytes: 9164
'''
参考
https://yamakasa.net/atcoder-abc-173-d/
図
https://github.com/ymo999/AtCoder/blob/master/2020/20200705_ABC173/ABC173_D.pdf
'''
import math

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

ans = 0
for i in range(1, N):
    idx = math.floor(i/2)           # 心地よさの和を算出するためのindex
    ans += A[idx]

print(ans)


Measured memory_bytes: 33012
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int gcd(int n, int m)
{
	if (m < n)
	{
		int temp = n;
		n = m;
		m = temp;
	}

	while (true)
	{
		int temp = n;
		n = m % n;
		m = temp;
		if (n == 0) return m;
	}
}

int N, K;
int A[100000];

void possible() { cout << "POSSIBLE" << endl;  }
void impossible() { cout << "IMPOSSIBLE" << endl; }

signed main()
{
	cin >> N >> K;
	REP(i, N) cin >> A[i];

	if (N == 1)
	{
		if (K == A[0]) possible();
		else impossible();
		return 0;
	}

	int g = gcd(A[0], A[1]);
	for (int i = 2; i < N; i++)
	{
		g = gcd(g, A[i]);
	}

	if (K % g == 0)
	{
		for (int i = 0; i < N; i++)
		{
			if (A[i] >= K)
			{
				possible();
				return 0;
			}
		}
	}

	impossible();
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int n,s1=0,s2=0,a,b;
	while(1){s1=0;s2=0;
	cin>>n;
	if(n==0)break;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(a>b)s1+=a+b;
		else if(a<b)s2+=a+b;
		else{
			s1+=a;
			s2+=b;
		}
	}
	cout<<s1<<" "<<s2<<'\n';}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 300000 + 5;
int a[N];

int main(){
	int a,b;
	cin >> a >> b;
	if(a > b)
		cout << -1 << endl;
	int flag = 0;
	for(int i = 10; i <= 1000; i++){
		int x = i * 0.08,y = i * 0.1;
		if(x == a && y == b){
			cout << i << endl;
			flag = 1;
			break;
		}
	}
	if(!flag)
		cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = sread();
    long state;
    foreach (c; S)
    {
        if (state == 0 && c == 'C')
            state = 1;
        if (state == 1 && c == 'F')
            state = 2;
    }
    writeln(state == 2 ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MAX_V = 6010, MAX_CAP = 2010;

int dist[MAX_V][MAX_CAP]; // ?????? ??????????????????
using tup = tuple<int, int, int>;

int dijkstra(int start, int goal, int cap, const vector<vector<pair<int, int>>>& G, const set<int>& LPG) {

    for (int i = 0; i < MAX_V; ++i) for (int j = 0; j < MAX_CAP; ++j) dist[i][j] = INF;
	cap *= 10; // 1L??§10km ????????§ 10???

	// ??????????????°????????????
	dist[start][cap] = 0;
	priority_queue<tup, vector<tup>, greater<tup>> que; // ?????¢ ?????? ?????????LPG
	que.push(make_tuple(0, start, cap));

	while(!que.empty()){

		int cost, u, lpg; // ?????¢ ?????? ?????????LPG
		tie(cost, u, lpg) = que.top(); que.pop();

		if(dist[u][lpg] < cost) continue; // ?????????????????????????¶????

		for (const auto& tmp : G[u]){
			int v = tmp.first, e = tmp.second;
			int nlpg = lpg - e; // ??????v?????§?????£??????????????????LPG
			int ncost = cost + e; // ??????v?????§?????£??????????????????????????¢
			if(nlpg < 0) continue; // LPG????¶??????????

			if(LPG.count(v)) { // ??????v???LPG??????????????§???
				if(dist[v][cap] > ncost) {
					dist[v][cap] = ncost; 
					que.push(make_tuple(ncost, v, cap)); // ??¬????????????????????????
				}
			}else{
				if(dist[v][nlpg] > ncost) {
					dist[v][nlpg] = ncost;
					que.push(make_tuple(ncost, v, nlpg));
				}
			}
		}
	}

	int ans = INF;
	for(int j = 0; j <= cap; j++) ans = min(ans, dist[goal][j]);
	return (ans != INF) ? ans : -1;

}

int main(void) {

	while(1) {
		int N, M, cap; cin >> N >> M >> cap;
		if(N == 0 && M == 0 && cap == 0) break;
		
		string src, dest;
		cin >> src >> dest;

		vector<string> c1(N), c2(N);
		vector<int> d(N);
		for (int i = 0; i < N; ++i) cin >> c1[i] >> c2[i] >> d[i];

		vector<string> s(M);
		for (int i = 0; i < M; ++i) cin >> s[i];
		
		set<string> city;
		city.insert(src), city.insert(dest);
		for (int i = 0; i < N; ++i) city.insert(c1[i]), city.insert(c2[i]);

		int cnt = 0;
		map<string, int> city2num; // ????????????????????????????????????
		for(const auto& t : city) city2num[t] = cnt++;

		set<int> lpg; // lpg??????????????§??????????????????
		for (int i = 0; i < M; ++i) lpg.insert(city2num[s[i]]);

		// ??°???????????????
		vector<vector<pair<int, int>> >  G(6010);
		for (int i = 0; i < N; ++i) {
			G[city2num[c1[i]]].push_back(make_pair(city2num[c2[i]], d[i]));
			G[city2num[c2[i]]].push_back(make_pair(city2num[c1[i]], d[i]));
		}

		cout << dijkstra(city2num[src], city2num[dest], cap, G, lpg) << endl;
	}

	return 0;
}

Measured memory_bytes: 75660
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n--){
    string a,b;
    cin >>a>>b;
    int num[900] = {0},tab = 0,i = 0;
    int as = a.size()-1;
    int bs = b.size()-1;
    int nmi = min(as,bs);
    int nma = max(as,bs);
    for(int x; i<=nma; i++){
      if(i<=nmi){x = tab+a[as-i]+b[bs-i]-'0'*2;}
      else if(as<bs){x = tab+b[bs-i]-'0';}
      else if(bs<as){x = tab+a[as-i]-'0';}
      tab = x/10;
      num[i] = x%10;
    }
    if(tab){num[nma+1] = tab;i++;}
    if(i>80){cout <<"overflow";}
    else{for(int x=i-1; x>=0; x--){cout <<num[x];}}
    cout <<endl;
  }
  return 0;
}

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

int main(void){
    int a, b, k;
    cin >> a >> b >> k;
    
    int i;
    for(i = a; i <= b; i++){
        if(!(i >= a + k && i <= b - k)){
            cout << i << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
char str[20];
char ans[20];
int length;
int main()
{
    char c;
    length=0;
    while(1)
    {
        c=getchar();
        if(c=='\n')
            break;
        if(c=='B')
        {
            if(length==0)
                continue;
            else
                length--;
        }
        else
        {
            str[length++]=c;
        }
    }
    for(int i=0;i<length;i++)
        printf("%c",str[i]);
    return 0;
}


Measured memory_bytes: 128
/*
created by Sanyam Singhal
/*/

#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define w(t) int t;	cin>>t while(t--)
#define triplet pair<int,pair<int,int>>
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
#define loop(i, k, n) for(ll i=k; i<n; i+=1)
#define loop2(i, k, n) for(ll i=k; i>=n; i--)

const ll inf = 1e18;

void take_fileIO(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  return;
}

void solve(){
  ll n, w;
  cin>>n>>w;

  vector<ll>weights(n+1), values(n+1);

  loop(i, 1, n+1)
    cin>>weights[i]>>values[i];

  ll maxval = n*1000;
  ll dp[n+1][maxval+1];

  for(int val=0; val<=maxval; val++)
    dp[0][val]=inf;
  
  for(int i=1; i<=n; i++)
    dp[i][0] = 0;
    
  int ans =  INT_MIN;
  // dp[0][0]=0;
  for(int i=1; i<=n; i++){
    for(int val=1; val<=maxval; val++){
      if(i==1){
        if(val == values[1])
          dp[1][val] = weights[1];
        else
          dp[1][val] = inf;
      }
      else{
        dp[i][val] = inf;
        if(values[i] <= val){
          dp[i][val] = min(dp[i-1][val], dp[i-1][val-values[i]] + weights[i]);
        }
        else
        {
          dp[i][val] = min(dp[i][val], dp[i-1][val]);
        }
      }
      if(dp[i][val] <= w)
        ans = max(ans, val);
    }
  }

  cout<<ans<<endl;

  // for(int i=0; i<=n; i++){
  //   for(int val=0; val<=maxval; val++){
  //     cout<<dp[i][val]<<" ";
  //   }
  //   cout<<endl;
  // }

  return;
}

int main(){

  fastIO;
  // take_fileIO();
  solve();

  return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N, K);
  VEC(ll, X, N);

  vl l, r;
  rep(i, 0, N) {
    if (X[i] < 0) {
      l.push_back(X[i] * -1);
    } else {
      r.push_back(X[i]);
    }
  }

  reverse(all(l));

  ll ans = LINF;
  rep(i, 0, K + 1) {
    int ln = i;
    int rn = K - i;
    if (ln > (int)l.size() || rn > (int)r.size()) {
      continue;
    }
    ll ld = ln ? l[ln - 1] : 0;
    ll rd = rn ? r[rn - 1] : 0;
    ll d = ld + rd + min(ld, rd);
    ans = min(ans, d);
  }

  print(ans);
}


Measured memory_bytes: 2424
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;

lint a[7];

int main(){
	for(int i=0; i<7; i++) cin >> a[i];
	lint ret = 0;
	for(int i=0; i<=10 && i<=a[0] && i<=a[3] && i<=a[4]; i++){
		lint p1 = a[0] - i;
		lint p2 = a[3] - i;
		lint p3 = a[4] - i;
		ret = max(ret, 2 * (p1 / 2 + p2 / 2 + p3 / 2) + 3 * i);
	}
	cout << ret + a[1];
}



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

int main(){
	int a[10000];
	int i=0;

	while(1){
		cin>>a[i];
		if(a[i]==0) break;
		i++;
	}
	i=0;
	while(1){
		if(a[i]==0) break;					
		cout<<"Case "<<i+1<<": "<<a[i]<<endl;
		i++;
	}
	return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define sec second
#define fir first
#define mo  998244353
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)
#define adiii\                               
  ios_base::sync_with_stdio(false);\                                      
  cin.tie(NULL);\
  cout.tie(NULL);									
 
ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}
ll gcd(ll a,ll b) {if (b == 0) return a;return gcd(b, a % b);}

int main(){
	adiii
	ll s,w;cin>>s>>w;
	if(w>=s) cout<<"unsafe";
	else cout<<"safe";


	
}


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 999999999;

int main(){
   int a,b,k;cin >> a >> b >> k;
   int ans[100];
   int count =0;
   for(int i=1;i<=100;i++){
      if(a%i==0 && b%i==0){
         ans[count++] = i;
      }
   }
   cout << ans[count-k];
   return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------

int main(void){
    int n, a, b;
    cin >> n >> a >> b;

    cout << min(a * n, b) << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
static long [][] dp;
static long[] v;
static int [] w;
static int n;
static int c;
	public static long solve(int i,int rmw){
        if(i==n||rmw==0){
        	return 0l;
        }
        if((long)dp[i][rmw]!=-1l){
        	return dp[i][rmw];
        }
     
       if(rmw<w[i]){
    	   return dp[i][rmw]=solve(i+1,rmw);
       }
         
      return  dp[i][rmw]=Math.max(v[i]+solve(i+1, rmw-w[i]),solve(i+1,rmw));
        
	}
	public static void main(String[] args) throws Exception {
		Scanner sc=new Scanner(System.in);
		 n=(int)sc.nextLong();
		 c=(int)sc.nextLong();
		 v=new long[n];
	 w=new int[n];
		for(int i=0;i<n;i++){
			w[i]=(int)sc.nextLong();
			v[i]=sc.nextLong();
		}
		dp=new long[n][c+1];
for(int i=0;i<n;i++){
	Arrays.fill(dp[i], (-1));
}


		System.out.println(solve(0,c));
 }


	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
 
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
 
		public boolean hasNext() {
			// TODO Auto-generated method stub
			return false;
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
	}}

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

int main() {
  string s;
  cin>>s;
  int b=0;
  std::vector<int> v(26,0);
for(int i=0;i<s.size();i++)v[(int)s[i]-97]++;
for(int i=0;i<26;i++){
  if(v[i]==0){b=i+1;break;}
}
if(b){b+=96;cout<<(char)b<<endl;}
else cout<<"None"<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template<typename T> class segtree {
private:
    int n,sz,h;
    vector<T> node, lazy;
    void eval(int k) {
        if(lazy[k]){
            node[k] += lazy[k];
            if(k < n) {
                lazy[k*2] += lazy[k], lazy[k*2+1] += lazy[k];
            }
            lazy[k] = 0;
        }
    }

public:
    segtree(vector<T>& v) : sz((int)v.size()), h(0) {
        n = 1;
        while(n < sz) n *= 2, h++;
        node.resize(2*n, numeric_limits<T>::min());
        lazy.resize(2*n, 0);
        for(int i = 0; i < sz; i++) node[i+n] = v[i];
        for(int i = n-1; i >= 1; i--) node[i] = max(node[2*i], node[2*i+1]);
    }
    void range(int a, int b, T x) {
        a += n, b += n - 1;
        for(int i = h; i > 0; i--) eval(a >> i), eval(b >> i);
        int ta = a, tb = b++;
        while(a < b){
            if(a & 1) lazy[a++] += x;
            if(b & 1) lazy[--b] += x;
            a >>= 1, b >>= 1;
        }
        while(ta >>= 1, tb >>= 1, ta){
            if(!lazy[ta]){
                eval(2*ta), eval(2*ta+1), node[ta] = max(node[2*ta], node[2*ta+1]);
            }
            if(!lazy[tb]){
                eval(2*tb), eval(2*tb+1), node[tb] = max(node[2*tb], node[2*tb+1]);
            }
        }
    }
    T query(int a, int b) {
        a += n, b += n - 1;
        for(int i = h; i > 0; i--) eval(a >> i), eval(b >> i);
        b++;
        T res1 = numeric_limits<T>::min(), res2 = numeric_limits<T>::min();
        while(a < b) {
            if(a & 1) eval(a), res1 = max(res1, node[a++]);
            if(b & 1) eval(--b), res2 = max(res2, node[b]);
            a >>= 1, b >>= 1;
        }
        return max(res1, res2);
    }
    void print(){for(int i = 0; i < sz; i++) cout<<query(i,i+1)<< " ";cout<<endl;}
};


int main(){
    int n,m;
    cin >> n >> m;
    vector<ll> v(n+2);
    segtree<ll> sg(v);
    vector<vector<pair<pair<ll,ll>,ll> > >  p(n+2);
    rep(i,m){
        ll l,r,a;
        cin >> l >> r >> a;
        p[r].push_back(MP(MP(l,r),a));
    }
    for(int i=1;i<=n;i++){
        ll k = sg.query(0,i);
        sg.range(i,i+1,k);
        for(auto x:p[i]){
            ll l = x.first.first;
            ll r = x.first.second;
            ll a = x.second;
            sg.range(l,r+1,a);
        }
        //sg.print();
    }
    
    cout << sg.query(0,n+1) << endl;
    return 0;
}

Measured memory_bytes: 22384
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

int a()
{
    std::string s;
    std::cin >> s;
    
    if(s[2] == s[3] && s[4] == s[5])
    {
        std::cout << "Yes";
    }
    else
    {
        std::cout << "No";
    }
    
    return 0;
}

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


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))


def gcd(a: int, b: int) -> int:
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)


ans = a[0]

for i in a:
    x = gcd(ans, i)
    if x < ans:
        ans = x


print(ans)


Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N; cin >> N;
  vector<int> A(N); rep(i,N) cin >>A[i];
  int start = 1;
  int ans = 0;
  rep(i,N){
    if(A[i]  == start){
      start++;
    }
    else{
      ans++;
    }
  }
  if(start==1) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define mp make_pair
#define elif else if
#define prev prev2
#define Edge pair <int, int>
#define next next2
#define u first
#define v second
#define int long long
typedef long long ll;
typedef long double ld;
const int MAXN = 1007, N = 1007, MAXM = 2e5 + 7;
vector<int> g[MAXM], gt[MAXM];
int a[MAXM], b[MAXM], c1[MAXM], c2[MAXM];
vector<int> topsort;
int vis[MAXM];
Edge ed[MAXM];
bool used[MAXM];
void dfs(int u) {
    used[u] = 1;
    for (int e : g[u]) {
        int v = ed[e].u ^ ed[e].v ^ u;
        if (!used[v]) dfs(v);
    }   
}   
void solve(int u) {
    memset(used, 0, sizeof used);
    used[u] = 1;
    for (int e : g[u]) {
        int v = ed[e].u ^ ed[e].v ^ u;
        if (used[v]) {
            c2[e] = 1;
        }       
        else {
            dfs(v);
        }   
    }   
    memset(used, 0, sizeof used);
    used[u] = 1;
    reverse(g[u].begin(), g[u].end());
    for (int e : g[u]) {
        int v = ed[e].u ^ ed[e].v ^ u;
        if (used[v]) {
            c2[e] = 1;
        }       
        else {
            dfs(v);
        }   
    }   
}   
void dfst1(int v) {
    vis[v] = 1;
    for (int e : g[v]) {
        int u = b[e];
        if (!vis[u])
            dfst1(u);
    }
    topsort.push_back(v);
}
int clr = 0;
void dfst2(int v) {
    vis[v] = clr;
    for (int e : gt[v]) {
        int u = a[e];
        if (!vis[u])
            dfst2(u);
    }
}
void solve() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
        --a[i];
        --b[i];
        g[a[i]].push_back(i);
        gt[b[i]].push_back(i);
    }
    for (int i = 0; i < n; ++i)
        if (!vis[i])
            dfst1(i);
    fill(vis, vis + n, 0);
    reverse(topsort.begin(), topsort.end());
    for (int v : topsort)
        if (!vis[v]) {
            ++clr;
            dfst2(v);
        }

    for (int i = 0; i < m; ++i) 
        c1[i] = (vis[a[i]] == vis[b[i]]);
    for (int i = 0; i < m; ++i) {
        ed[i] = {a[i], b[i]};
    }   
    for (int i = 0; i < n; ++i) {
        solve(i);
    }

    #ifdef HOME
    for (int i = 0; i < m; ++i) cout << c1[i] << ' '; cout << '\n';
    for (int i = 0; i < m; ++i) cout << c2[i] << ' '; cout << '\n';
    #endif

    for (int i = 0; i < m; ++i) {
        //cout << c1[i] << c2[i];
        if (c1[i] ^ c2[i]) {
            cout << "diff\n";
        }   
        else {
            cout << "same\n";
        }
    }   
    return;
}

signed main() {

    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #endif

    ios_base::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 27904
x, y  = map(int, input().split())
mod = 10**9+7

def comb(n, r, mod):
    n1 = n+1
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer*(n1-i)%mod # combの分子
        denom = denom*i%mod #combの分母
    return numer*pow(denom, mod-2, mod)%mod #(n!*(r**(mod-2)%mod))%mod
    #a/b mod p = (a*(1/b) mod p)なので1/b(b**-1)を求めたい（つまりcombの分母）
    #(b**(p-2)*b mod p) = 1 なので
    #b**-1 = b**-2 mod p　が成立！！！
    #return内のpowがb**-1を求める部分

if (x+y)%3 != 0 or (2*x-y)//3 < 0 or (2*y-x)//3 < 0:
    print(0)
else:
    n = (2*x-y)//3
    m = (2*y-x)//3
    print(comb(n+m, min(n, m), mod))


#TLE解
# from collections import deque

# X, Y = map(int, input().split())

# knight = [(1, 2), (2, 1)]
# dp = [[0 for _ in range(Y+1)] for _ in range(X+1)]
# dp[0][0] = 1

# que = deque([(0, 0)])

# while que:

#     x, y = que.pop()
#     for x1, y1 in knight:
#         if x+x1 > X or y+y1 > Y:
#             continue
#         dp[x+x1][y+y1] += dp[x][y]
#         que.append((x+x1, y+y1))
#     # print(que)
# print(dp[X][Y]%1000000007)
# # print(dp)

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


ll div_2(ll x)
{
	ll ret=0;
	while(x%2==0)
	{
		x/=2;
		ret++;
	}
	return ret;
}
int main()
{
	int N;
	cin>>N;
	ll ans=0;
	rep(i,N)
	{
		ll a;
		cin>>a;
		ans+=div_2(a);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256