akhauriyash/Code-Regression huggingface dataset:
//
//AtCoder Beginner Contest 169
//B - Multiplication 2
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;
const ll MAX = 1e18;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<ll> a(n);
    bool incZero = false;
    REP(i, n) {
        cin >> a[i];
        if (a[i] == 0) incZero = true;
    }

    if (incZero) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    REP(i, n){
        ll bef  = ans;
        ans *= a[i];
        if (ans > MAX) {
            ans = -1;
            break;
        }

        if (ans<0) {
            ans = -1;
            break;
        }

        if (ans < bef) {
            ans = -1;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4000
#include<iterator>
#include<algorithm>
#include<bits/stdc++.h>
#define M 1000000007
#define C 998244353
using namespace std;
typedef unsigned long long int ll;
//typedef int64_t ll;

ll factorial(ll n){
    ll prod = 1;
    for(ll i=1;i<=n;i++){
        prod = prod*(i);
    }
    return prod;
}
ll combinations(int n, int r)
{
    if(n<r){
        return 0;
    }
    else{
        // p holds the value of n*(n-1)*(n-2)...,
        // k holds the value of r*(r-1)...
        long long p = 1, k = 1;

        // C(n, r) == C(n, n-r),
        // choosing the smaller value
        if (n - r < r)
            r = n - r;

        if (r != 0) {
            while (r) {
                p *= n;
                k *= r;

                // gcd of p, k
                long long m = __gcd(p, k);

                // dividing by gcd, to simplify product
                // division by their gcd saves from the overflow
                p /= m;
                k /= m;

                n--;
                r--;
            }

            // k should be simplified to 1
            // as C(n, r) is a natural number
            // (denominator should be 1 ) .
        }

        else
            p = 1;

        // if our approach is correct p = ans and k =1
        return p;
    }
}
void solve(){
    ll n,m,t,res=0,i,k,j,d;
    cin >> n >> k;
    set <ll> a;
    for(i=0;i<k;i++){
        cin >> d;
        for(j=0;j<d;j++){
            cin >> m;
            a.insert(m);
        }
    }
    cout << n - a.size() << "\n";
}

int main()
{
    ll t = 1;
    //cin >> t;
    //cin.ignore();
    for(ll f=0;f<t;f++){
        solve();
    }
}


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

using namespace std;

struct UnionFind
{
  vector<int> data;
  UnionFind(int sz):data(sz, -1){};
  int size(int x) { return -data[find(x)]; }  
  int find(int x) { return data[x] < 0 ? x : data[x] = find(data[x]); }
  bool same(int x, int y) { return find(x) == find(y); }  
  int unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x != y) {
      if(data[x] < data[y]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return -data[x];
  }
};

int main()
{
  int N, K, L;
  cin >> N >> K >> L;
  UnionFind road(N), line(N);
  for(int i = 0; i < K; i++) {
    int p, q;
    cin >> p >> q; p--, q--;
    road.unite(p, q);
  }
  for(int i = 0; i < L; i++) {
    int r, s;
    cin >> r >> s; r--, s--;
    line.unite(r, s);
  }
  typedef pair<int, int> P;
  map<P, int> cnt;
  for(int i = 0; i < N; i++) {
    cnt[P(road.find(i), line.find(i))]++;
  }
  for(int i = 0; i < N; i++) {
    if(i) cout << " ";
    cout << cnt[P(road.find(i), line.find(i))];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 13568
S,T = input().split() #文字列のの複数一行入力
A,B = map(int,input().split()) #数値の複数一行入力(形は覚える)
U = input() #文字列の入力

if U == S: #もしUとSが同じだった場合

    print(A-1,B) #(問題文より、)Aから1引いてAとBを出力

else: #そうでなかった場合(UとTが同じだった場合)

    print(A,B-1) #Bから1引いてAとBを出力

'''例
入力
S = red , T = blue
A = 3 , B = 4
U = red

UはSと同じだから,Sに対応するAから1引いてA(2)とB(4)を出力する

出力
2 4
'''

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

int main(){
  int n;cin>>n;
  vector<int> a(2*n);
  for(int i=0;i<2*n;++i)cin>>a[i];
  sort(a.begin(),a.end());
  int64_t ans=0;
  for(int i=0;i<n;++i)
    ans+=min(a[2*i],a[i*2+1]);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	

s = list(input())
if(s.count('A') >= 1 and s.count('B') >= 1):
	print('Yes')
else:
	print('No')

Measured memory_bytes: 5100
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i,k,n) for(int i=k;i<n;i++)
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(200001);
    REP(i,0,n){
        int x;
        cin >> x;
        a[x]++;
    }
    sort(a.begin(),a.end(),greater<int>());
    long cnt = 0;
    REP(i,k,n) cnt+=a[i];
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int a,b;
    cin>>a>>b;
    if (a<=8 && b<=8)
        cout<<"Yay!\n";
    else
        cout<<":(\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

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

using namespace std;
int main(){
	int a[2];
	int n[2][4];
	
	rep(i,2)rep(j,4)scanf("%d",&n[i][j]);
	
	a[0]=0;
	a[1]=0;
	
	rep(i,2)rep(j,4)a[i]+=n[i][j];
	
	printf("%d\n",max(a[0],a[1]));
	
}

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

int bubbleSort(int A[],int n){
  int i,j,c=0,t;
  bool flag=1;
  for(i=0;flag;i++){
    flag=0;
    for(j=n-1;j>=i+1;j--){
      if(A[j]<A[j-1]) {
	t=A[j];
	A[j]=A[j-1];
	A[j-1]=t;
	c++;
	flag=1;
      }
    }
  }
  return c;
}

int main(){

  int A[100];
  int n,i,c;

  i=0;
  while(1){
    cin>>n;
    if(1<=n&&n<=100){
      while(1){
	if(n==i) break;
	cin>>A[i];
	if(0<=A[i]&&A[i]<=100) i++;
      }
      break;
    }
  }

  c=bubbleSort(A,n);

  for(i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<A[i];
  }
  cout<<endl;
  cout<<c<<endl;

  return 0;
}





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

using namespace std;

#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int MOD = 1000000007;
const int INF = 1000000007;

ll dp[2002][2002];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin >> n;
    pll arr[n+1];
    for(int i=1; i<=n; i++)
    {
        cin >> arr[i].f;
        arr[i].s = i;
    }

    sort(arr+1, arr+n+1);
    ll ans = 0;
    for(int i=n; i>=1; i--)
    {
        for(int j=1; j <= n+1-i; j++)
        {
            dp[j-1][i+j-1] = max(dp[j-1][i+j-1], dp[j-1][i+j] + abs(arr[i].s - (i+j-1)) * arr[i].f);
            dp[j][i+j] = max(dp[j][i+j], dp[j-1][i+j] + abs(arr[i].s - j) * arr[i].f);
            //cout << arr[i].f << " " << dp[j][i+j] << "\n";
            ans = max(ans, max(dp[j-1][i+j-1], dp[j][i+j]));
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 26288
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Takahashi&#39;s Basics in Education and Learning
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_K = 18;
const int N = 3;

/* typedef */

typedef long long ll;
typedef ll vec[N];
typedef vec mat[N];

/* global variables */

ll ts[MAX_K + 1], ls[MAX_K + 1];

/* subroutines */

inline void initvec(vec a) { memset(a, 0, sizeof(vec)); }
inline void initmat(mat a) { memset(a, 0, sizeof(mat)); }

inline void unitmat(mat a) {
  initmat(a);
  for (int i = 0; i < N; i++) a[i][i] = 1;
}

inline void copymat(const mat a, mat b) { memcpy(b, a, sizeof(mat)); }

inline void mulmatmod(const mat a, const mat b, mat c, int mod) {
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) {
      c[i][j] = 0;
      for (int k = 0; k < N; k++)
        c[i][j] = (c[i][j] + a[i][k] * b[k][j] % mod) % mod;
    }
}

inline void powmatmod(const mat a, ll b, mat c, int mod) {
  mat s, t;
  copymat(a, s);
  unitmat(c);

  while (b > 0) {
    if (b & 1) {
      mulmatmod(c, s, t, mod);
      copymat(t, c);
    }

    mulmatmod(s, s, t, mod);
    copymat(t, s);
    b >>= 1;
  }
}

inline void mulmatvecmod(const mat a, const vec b, vec c, int mod) {
  for (int i = 0; i < N; i++) {
    c[i] = 0;
    for (int j = 0; j < N; j++)
      c[i] = (c[i] + a[i][j] * b[j] % mod) % mod;
  }
}

void printmat(const mat a) {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (j) putchar(' ');
      printf("%lld", a[i][j]);
    }
    putchar('\n');
  }
}

ll powmod(ll a, ll b, int mod) {  // a^b % mod
  ll pm = 1;
  while (b > 0) {
    if (b & 1) pm = (pm * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return pm;
}

/* main */

int main() {
  ll l, a, b;
  int m;
  scanf("%lld%lld%lld%d", &l, &a, &b, &m);

  ts[0] = 1;
  for (int k = 0; k < MAX_K; k++) ts[k + 1] = ts[k] * 10;
  //printf("%lld\n", ts[MAX_K]);

  for (int k = 0; k <= MAX_K; k++) {
    ll l0 = -1, l1 = l;
    while (l0 + 1 < l1) {
      ll l2 = (l0 + l1) / 2;
      if (a + b * l2 >= ts[k]) l1 = l2;
      else l0 = l2;
    }
    ls[k] = l1;
    //printf("ls[%d]=%lld\n", k, l1);
  }

  ll sum = 0;
  for (int k = 0; k < MAX_K; k++) {
    ll l0 = ls[k], l1 = ls[k + 1];
    if (l0 == l1) continue;

    ll t1 = ts[k + 1] % m;
    mat ma, mb;
    ma[0][0] = t1; ma[0][1] = 1; ma[0][2] = 0;
    ma[1][0] = 0;  ma[1][1] = 1; ma[1][2] = b % m;
    ma[2][0] = 0;  ma[2][1] = 0; ma[2][2] = 1;
    powmatmod(ma, l1 - l0, mb, m);

    vec va, vb;
    va[0] = 0; va[1] = (a + b * l0) % m; va[2] = 1;
    mulmatvecmod(mb, va, vb, m);

    sum = (sum * powmod(t1, l1 - l0, m) % m + vb[0]) % m;
    //printf("%lld-%lld: %lld\n", l0, l1, vb[0]);
  }

  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
#define MOD 1000000007
//scanf("%d", &a) '\n'

int main() {
	string s;
	cin >> s;
	int n = s.size();
	if (s[0] != 'k') { cout << "NO"; return 0; }
	if (s[n-1] != 'e') { cout << "NO"; return 0; }
	reverse(s.begin(), s.end());
	if(s.substr(0,6)=="ecneye"){ cout << "YES"; return 0; }
	if (s.substr(0, 5) == "ecney"&&s[n-2]=='e') { cout << "YES"; return 0; }
	if (s.substr(0, 4) == "ecne"&&s.substr(n-3,2)== "ye") { cout << "YES"; return 0; }
	if (s.substr(0, 3) == "ecn"&&s.substr(n - 4, 3) == "eye") { cout << "YES"; return 0; }
	if (s.substr(0, 2) == "ec"&&s.substr(n - 5, 4) == "neye") { cout << "YES"; return 0; }
	if (s.substr(n - 6,5) == "cneye") { cout << "YES"; return 0; }
	cout << "NO";
	
}
	

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

using namespace std;

typedef pair<int, int> PII;
typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pct __builtin_popcount

#define N 100010

int n, m;
int a[N], b[N];
int p[N*2], L;

int ac(int x) {
	if (x >= 0) return a[x];
	else return b[-x-1];
}

bool cmp(int x, int y) {
	return ac(x) < ac(y);
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i ++)
		cin >> a[i];
	for (int i = 0; i < m; i ++)
		cin >> b[i];
	for (int i = 0; i < n; i ++)
		p[L++] = i;
	for (int i = 0; i < m; i ++)
		p[L++] = -i-1;
	sort(p, p+L, cmp);
	int nn = 0, nm = 0;
	ll S = 0;
	for (int i = 0; i < L; i ++) {
		int u = ac(p[i]);
		if (p[i] >= 0) {
			S += (ll)u*(m-nm+1);
			nn++;
		} else {
			S += (ll)u*(n-nn+1);
			nm++;
		}
	}
	cout << S << endl;
	return 0;
}

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

int N, M, E[10][10];

bool is_valid(int* order) {
  REP(i, 1, N - 1) {
    if(!E[order[i]][order[i + 1]]) return false;
  }
  return true;
}

int main(void) {
  cin >> N >> M;
  REP(i, 1, N) REP(j, 1, N) E[i][j] = 0;
  REP(i, 1, M) {
    int a, b; cin >> a >> b;
    E[a][b] = 1;
    E[b][a] = 1;
  }

  int order[10];
  REP(i, 1, N) order[i] = i;

  long cnt = 0;
  do {
    if(is_valid(order)) cnt++;
  } while(next_permutation(order + 2, order + N + 1));

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
# include <stdio.h>
int main (void)
{   int A = 0;int B = 0;
    int temp;
    scanf("%d",&A);
    scanf("%d",&B);
    temp = A + B;
    if (A - B > temp)temp = A - B;
    if (A * B > temp)temp = A * B;
    printf("%d\n",temp);
    return 0;
}

Measured memory_bytes: 128
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, n, m;
    cin>>n>>m;
    double v[n];
    double sum=0;
    Ff(i,0,n)
    {
        cin>>v[i];
        sum+=v[i];
    }
    double mini=sum/(double)(4*m);
    ll cnt=0;
    Ff(i,0,n)
    {
        if(v[i]>=mini)
        cnt++;
    }
    if(cnt>=m)
    cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 7680
program test
implicit none
integer(8)::n,a,b,k,ans
read*,n,a,b
k=n/(a+b)
ans=k*a
	if(n-k*(a+b) < a)then
    	print*,ans+n-k*(a+b)
    else 
    	print*,ans+a
    end if
end program test

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define LiangJiaJun main
using namespace std;
string s;
int n,k;
int LiangJiaJun(){
	cin>>n>>k>>s;
	s[k-1]=s[k-1]-'A'+'a';
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = sorted(map(int, input().split()), reverse=True)

answer = 0
consume = N
for a in A:
    if consume == N:
        consume -= 2
        if N > 1:
            answer += a
        continue
    elif consume > 1:
        answer += a * 2
        consume -= 2
        continue
    elif consume == 1:
        answer += a
        consume -= 1
        continue
    else:
        break

print(answer)

Measured memory_bytes: 30872
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(All(a));
    cout << a[n - 1] - a[0] << endl;
}

Measured memory_bytes: 256
from collections import OrderedDict
N = int(input())
A = list(map(int, input().split()))
R = {"gray": 0, "brown": 0, "green": 0, "light": 0, "blue": 0, "yellow": 0, "orange": 0, "red": 0}
S = OrderedDict([("gray", 400), ("brown", 800), ("green", 1200), ("light", 1600), ("blue", 2000), ("yellow", 2400), ("orange", 2800), ("red", 3200)])
for a in A:
    for r, s in S.items():
        if a < s:
            R[r] += 1
            break
num = len([r for r, n in R.items() if n != 0])
other = N - sum([n for r, n in R.items() if n != 0])
if num == 0:
    print(1, N)
    exit()
print(num, num + other)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  ll A, B;
  cin >> A >> B;
  ll ans = A + B;
  if (ans % 2 == 0) cout << ans/2 << '\n';
  else cout << "IMPOSSIBLE" << '\n';
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n){
		int point[2];
		enum {
			A,
			B,
		};
		int sum[2] = {0,0};
		for (int i = 0; i < n; i++) {
			cin>>point[A]>>point[B];
			if (point[A]>point[B]) {
				for (auto j : point) {
					sum[A]+=j;
				}
			} else if(point[A] == point[B]) {
				for (int j = 0; j < 2; j++) {
					sum[j]+=point[j];
				}
			} else {
				for (auto j : point) {
					sum[B]+=j;
				}
			}
		}
		cout<<sum[A]<<" "<<sum[B]<<endl;
		cin>>n;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(){
    
    int x,y,surplus;
    int exchangeNumber;
    
    scanf("%d %d",&x,&y);
    
    if(x<y){
        exchangeNumber = x;
        x = y;
        y = exchangeNumber;
    }
    
    while(1){
        surplus = x % y;
        if(surplus == 0) break;
        x = y;
        y = surplus;
    }
    
    printf("%d\n",y);
    
    return 0;
}

Measured memory_bytes: 592
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        a: [i64; 5],
    }
    let ans: i64 = a.iter().map(|&b| ((b - 1) / 10 + 1) * 10).sum();
    let ans = ans - a.iter().map(|&b| 9 - (b - 1) % 10).max().unwrap();
    println!("{}", ans);
}

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

int main() {
    int N;
    scanf("%d", &N);
    
    int F[44];
    F[0] = 1; F[1] = 1;
    
    for (int i = 2; i <= N; i++) {
        F[i] = F[i - 2] + F[i - 1];
    }
    
    printf("%d\n", F[N]);

    return 0;
}



Measured memory_bytes: 3228
using System;

public class AtCoder{
	public static void Main(){
		string so;
		so = Console.ReadLine().Trim();
		int n = so.Length;
		string[] s = new string[n];
		for (int i=0; i<n; i++){
			s[i] = so.Substring(i,1);
		}
		int[] sn = new int[n];
		bool f = true;
		int c = 0;
		
		string[] sj = new string[26];
		for (int i=0; i<n; i++){
			for (int j=0; j<26; j++){
				if(s[i] == sj[j]){
					sn[i] = j;
					f = false;
				}
			}
			if(f){
				sj[c] = s[i];
				sn[i] = c;
				c++;
			}
			f = true;
		}
		
		string tot;
		tot = Console.ReadLine().Trim();
		string[] t = new string[n];
		for (int i=0; i<n; i++){
			t[i] = tot.Substring(i,1);
		}
		int[] tn = new int[n];
		f = true;
		c = 0;
		
		string[] tj = new string[26];
		for (int i=0; i<n; i++){
			for (int j=0; j<26; j++){
				if(t[i] == tj[j]){
					tn[i] = j;
					f = false;
				}
			}
			if(f){
				tj[c] = t[i];
				tn[i] = c;
				c++;
			}
			f = true;
		}
		
		f = true;
		for(int k=0; k<n; k++){
			if(sn[k] != tn[k]) f = false;
		}
		
		if(f){
			Console.WriteLine("Yes");
		} else {
			Console.WriteLine("No");
		}
	}
}


Measured memory_bytes: 33624
// OBツ嘉ッツ嘉債宿2011 Day3 F : Beautiful Currency

#include <iostream>
#include <cstdio>
#include <stdlib.h>

using namespace std;

int main(){
	int N;
	int a[20];
	while(cin >> N){
		for(int i=0;i<N;i++) cin >> a[i];
		static double dp[2][200001];
		for(int i=1;i<=200000;i++){
			dp[0][i] = abs(a[0]-i)/(double)a[0];
		}
		int cur = 0, next = 1;
		for(int i=1;i<N;i++){
			for(int j=0;j<=200000;j++) dp[next][j] = 1e12;
			for(int j=1;j<=200000;j++)
				for(int k=j;k<=200000;k+=j)
					dp[next][k] = min(dp[next][k], max(dp[cur][j], abs(a[i]-k)/(double)a[i]));
			swap(cur, next);
		}
		double res = 1e12;
		for(int i=1;i<=200000;i++) res = min(res, dp[cur][i]);
		printf("%.10lf\n", res);
	}
}

Measured memory_bytes: 3952
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const pairint& firstElof, const pairint& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
string s;
std::vector<pair<int,string> > v;
std::cin >> x;
std::cout << x*x*x << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI acos(-1)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b;
    while(cin>>a>>b)
    {
        for(int i=(b-a)+1;i<=(a+b-1);i++)
        {
            if(i!=(b-a+1))
                cout<<" ";
            cout<<i;
        }
        cout<<endl;

    }
    return 0;
}


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

#define sp ' '
#define endl '\n'
#define st first
#define nd second
#define sz(x) ((long long int)x.size())
#define pb push_back
#define pob pop_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << '\n'
#define prs(XX) cout << XX << ' '
#define TEST cout << "TEST\n";

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;

const long long int MOD = 1e9 + 7;
const long long int INF = 2e9 + 13;
const long long int mINF = -2e9 - 13;
const double PI = acos(-1.0);
const double EPS = 1e-9;

ll mx(ll x, ll y){ return (x>y?x:y); }
ll mn(ll x, ll y){ return (x<y?x:y); }

void max_self(ll &x, ll y){ x = mx(x, y); }
void min_self(ll &x, ll y){ x = mn(x, y); }
void add(ll &x, ll y){ x%=MOD; x += (y%MOD); x %= MOD; }
void mul(ll &x, ll y){ x%=MOD; x *= (y%MOD); x %= MOD; }

ll us(ll n, ll x, ll m){
    if(x == 0) return 1;
    ll a = us(n, x>>1, m);
    return (((a*a)%m)*(x&1?n:1))%m;
}

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    //freopen(".gir", "r", stdin);
    //freopen(".cik", "w", stdout);
    //
    ll n; cin >> n;
    if(n&1) cout << ((n>>1) + 1) << endl;
    else cout << (n>>1) << endl;

    return 0;
}

//cikisir



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  bool p_ac[100005] = {false};
  int p_tbac[100005] = {0};

  int prob, sub;
  cin >> prob >> sub;

  int correct = 0;
  int penalty = 0;
  while (sub--) {
    int pnum;
    string stat;
    cin >> pnum;
    cin >> stat;

    if (stat == "WA") {
      if (!p_ac[pnum]) {
        p_tbac[pnum]++;
      }
    } else {
      if (!p_ac[pnum]) {
        p_ac[pnum] = true;
	correct++;
        penalty += p_tbac[pnum];
      }
    }
  }

  cout << correct << " " << penalty << endl;
  return 0;
}


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

const int MAXN = 55;
const int INF = 1e9+7;
int n;
int a[MAXN];
vector<pair<int,int>> res;

int findMax()
{
    int ret,tmp = -INF;
    for(int i = 1; i <= n; ++i)
    {
        if(a[i] > tmp)
        {
            tmp = a[i];
            ret = i;
        }
    }
    return ret;
}

int findMin()
{
    int ret,tmp = INF;
    for(int i = 1; i <= n; ++i)
    {
        if(a[i] < tmp)
        {
            tmp = a[i];
            ret = i;
        }
    }
    return ret;
}
//让后边的那个变大
void solveO()
{
    int index = findMax();
    for(int i = 1; i <= n; ++i)
        res.push_back(make_pair(index,i));
    for(int i = 2; i <= n; ++i)
        res.push_back(make_pair(i-1,i));
}
//让前边那个变小
void solveT()
{
    int index = findMin();
    for(int i = 1; i <= n; ++i)
        res.push_back(make_pair(index,i));
    for(int i = n-1; i >= 1; --i)
        res.push_back(make_pair(i+1,i));
}

int main()
{
    int maxn = -INF,minn = INF;
    bool increase = true;
    scanf("%d",&n);
    for(int i = 1; i <= n; ++i)
    {
        scanf("%d",&a[i]);
        maxn = max(maxn, a[i]);
        minn = min(minn, a[i]);
        if(i > 1 && a[i] < a[i-1])
            increase = false;
    }
    if(increase)
    {
        puts("0");
        return 0;
    }
    if(maxn + minn > 0) solveO();
    else solveT();
    printf("%d\n",res.size());
    for(int i = 0; i < res.size(); ++i)
        printf("%d %d\n",res[i].first, res[i].second);
    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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

  string ans = "";
  int openCnt = 0;
  int closeCnt = 0;

  for (int i = N - 1; i >= 0; i--) {
    if (S[i] == ')') {
      closeCnt++;
      ans = ")" + ans;
    }
    if (S[i] == '(') {
      openCnt++;
      ans = "(" + ans;
      if (openCnt > closeCnt) {
        closeCnt++;
        ans += ")";
      }
    }
  }

  while (openCnt != closeCnt) {
    openCnt++;
    ans = "(" + ans;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np
a = int(input())
if(a > 7):
	c = np.zeros(a)
	for i in range(7):
		if(i == 3 or i == 6):
			c[i] = 1
	#print(c)
	for i in range(7, c.shape[0]):
		if(c[i-4] == 1 or c[i-7] == 1):
			c[i] = 1
	if(c[-1] == 1):
		print("Yes")
	else:
		print("No")
else:
	if(a == 4 or a == 7):
		print("Yes")
	else:
		print("No")
		

Measured memory_bytes: 15596
import java.util.Scanner;

/**
 * Created by Harry on 3/31/20.
 */
//https://atcoder.jp/contests/dp/tasks/dp_a
public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] cost = new int[n];
        for(int i=0; i<n; i++){
            cost[i] = scanner.nextInt();
        }
        System.out.println(findMinCost(n, cost));
    }

    public static int findMinCost(int n, int[] cost){
        int[] dp = new int[n+1];
        for(int i=2; i<=n; i++){
            dp[i] = Math.min(dp[i-1]+Math.abs(cost[i-2]-cost[i-1]), i-3>=0?dp[i-2]+Math.abs(cost[i-3]-cost[i-1]):Integer.MAX_VALUE);
        }
        return dp[n];
    }
}


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

int a[100010];

int main(){
    int N,T,e,q,maxn=0;
    cin>>N>>T;
    for(int i=0;i<N;i++){
        cin>>e>>q;
        a[e]++;
        a[q]--;
    }
    for(int i=1;i<=T+1;i++){
        a[i]+=a[i-1];
        maxn=max(maxn,a[i-1]);
    }
    cout<<maxn<<endl;
    return 0;
}



Measured memory_bytes: 3464
import java.util.*;

public class Main {
    private final static Main main = new Main();

    public static void main(String[] args) {
        main.contest();
    }

    private void contest() {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long res = Long.MAX_VALUE;
        for (long i=1; i*i<=n; ++i) {
            if (n%i != 0) {
                continue;
            }
            res = Math.min(res, Math.max(String.valueOf(i).length(), String.valueOf(n/i).length()));
        }
        System.out.println(res);
    }
}


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

int main() {
  int n; cin >> n; bool flag=false;
 int t = 3;
  while(t!=0){
  	if(n%10==7){
      flag = true;
      break;}
    n/=10;
    t--;
  }
  if(flag)
    cout << "Yes\n";
  else
     cout << "No\n";
  return 0;
  }


Measured memory_bytes: 3636
function Main(input) {
    let answer = 0;
    let list = input.split("\n");
    let row = list[0].split(" ")
    let N = parseInt(row[0], 10);
    let D = parseInt(row[1], 10);
    let x = 0;
    let y = 0;

    for (let i=1; i<=N; i++) {
        row = list[i].split(" ");
        x = parseInt(row[0], 10);
        y = parseInt(row[1], 10);
        if (x**2 + y**2 <= D**2) {
            answer++;
        }
    }
    console.log(answer);
}

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

Measured memory_bytes: 62592
N, M = map(int, input().split())
Lmax = 0
Rmin = 10**5 + 1
for n in range(M):
  L, R = map(int, input().split())
  if L > Lmax:
    Lmax = L
  if R < Rmin:
    Rmin = R

gate = Rmin - Lmax + 1
if gate < 0:
  print("0")
else:
  print(gate)

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


int main() 
{
    string S,T;
    cin >> S >> T;
    int A,B;
    cin >> A >> B;
    string U;
    cin >> U;
    
    if (U == S) {
        cout << A-1 << " " << B << endl; 
    }else if (U == T) {
        cout << A << " " << B-1 << endl;
    }else{
        cout << A << " " << B << endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() 
{   int k,a,b;
    cin>>k;
    cin>>a;
    cin>>b; 
    while(a<=b)
    {
    	if(a%k==0)
    	{
    		cout<<"OK"<<endl;
    		return 0;
    	}
    	a++;
    }
    cout<<"NG";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};



int main(){
  int N;cin>>N;
  int l[1005],r[1005];
  for(int t=0;t<N;t++)cin>>l[t]>>r[t];

  int sum=0;
  for(int t=0;t<N;t++){
    sum+=r[t]-l[t]+1;
  }

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int dp[110];

struct bar{
	int blen,rlen;
	int blue,red;
	bar(){}
	bar(int p,int q,int a,int b):rlen(p),blen(q),red(a),blue(b){}
};

bar bars[110];

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

int rec(int v)
{
	if(dp[v]!=-1) return dp[v];
	int p=bars[v].rlen,q=bars[v].blen;
	int r=bars[v].red,b=bars[v].blue;
	if(r==-1&&b==-1)
	{
		dp[v]=p+q;
		return dp[v];
	}
	if(r==-1)
	{
		int mb=rec(b);
		int d=gcd(p,mb);
		int a=mb/d;
		dp[v]=(p+q)*a;
		return dp[v];
	}
	else if(b==-1)
	{
		int mr=rec(r);
		int d=gcd(q,mr);
		int a=mr/d;
		dp[v]=(p+q)*a;
		return dp[v];
	}
	int mb=rec(b),mr=rec(r);
	int d=gcd(mb,p);
	int a=mb/d;
	int mb1=p*a,mr1=q*a;
	int d1=gcd(mr,mr1);
	int A=mr/d1;
	dp[v]=A*(mb1+mr1);
	return dp[v];
}

int main()
{
	int N;
	while(1)
	{
	scanf("%d",&N);
	if(N==0) break;
	for(int i=0;i<N;i++)
	{
		int p,q,a,b;
		scanf("%d%d%d%d",&p,&q,&a,&b);
		a--;b--;
		int d=gcd(p,q);
		p/=d;q/=d;
		bars[i]=bar(p,q,a,b);
	}
	memset(dp,-1,sizeof(dp));
	int ans=0;
	for(int i=0;i<N;i++)
	{
		ans=max(ans,rec(i));
	}
	printf("%d\n",ans);
	}
	return 0;
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ


//ソートされたA[left~mid]とA[mid+1~right]をくっつける関数
void merge(double* A, int left, int mid, int right, double* B){
    int i,j,k;
    double tmp;

    //kは一時的な配列Bの現在の添字、iは前半A[left~mid]、jは後半A[mid+1~right]を指す添字
    k=left; i=left; j=mid+1;
    while(k<=right){
        if(j>right) tmp=A[i++]; //前半のみにデータがある
        else if(i>mid) tmp=A[j++]; //後半のみにデータがある
        else if(A[i]<=A[j]) tmp=A[i++]; //前半の方が小さい
        else tmp=A[j++]; //後半の方が小さい

        B[k++]=tmp;
    }
    for(i=left;i<=right;i++) A[i]=B[i]; //元の配列に戻す
}

//A[left]~A[right]までの配列を昇順にマージソートする関数
void merge_sort(double* A, int left, int right, double*B){
    int mid;

    if(left<right){
        mid=(left+right)/2;
        merge_sort(A,left,mid,B); //A[left]~A[mid]までを再帰的にソート
        merge_sort(A,mid+1,right,B); //A[mid+1]~A[right]までを再帰的にソート
        merge(A,left,mid,right,B); //分割した二つをくっつける
    }
}

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

    //v[0]~v[N-1]に格納する
    double* v;
    NEW(v,N);
    for(int i=0;i<N;i++){
        scanf("%lf",&v[i]);
    }

    //マージソート用の仮配列
    double* u;
    NEW(u,N);
    //vをマージソート
    merge_sort(v,0,N-1,u);
    free(u);

    for(int i=0;i<=N-2;i++){
        v[i+1]=(v[i]+v[i+1])/2;
    }

    double ans=v[N-1];
    printf("%lf\n",ans);

    return 0;
}

//300点

Measured memory_bytes: 384
#include<stdio.h>

int H;

void swap(int *a, int *b){
	int tmp;
	tmp=*a;
	*a=*b;
	*b=tmp;
}

void maxHeapify(int A[],int i){
	int largest=i;
	int l=2*i;
	int r=2*i+1;
	if(l<=H && A[l]>A[largest]){
		largest=l;
	}
	if(r<=H && A[r]>A[largest]){
		largest=r;
	}
	if(largest!=i){
		swap(&(A[i]),&(A[largest]));
		maxHeapify(A,largest);
	}
}

void buildMaxHeap(int A[]){
	int i;
	for(i=H/2;i>=1;i--){
		maxHeapify(A,i);
	}
}

int main(void){
	int A[500001];
	int i;
	scanf("%d",&H);
	for(i=1;i<=H;i++){
		scanf("%d",&A[i]);
	}
	buildMaxHeap(A);
	for(i=1;i<=H;i++){
		printf(" %d",A[i]);
	}printf("\n");
	return 0;
}

	

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

using namespace std;

#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>

typedef long long ll;

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

int main() {
  int N, X;
  cin >> N >> X;
  vi pos(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> pos[i];
    pos[i] = abs(pos[i] - X);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = gcd(pos[i], ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
n=int(input())
s1=input()
s2=input()
comb=0
tateyoko=''
i=0
while i<n:
  if i==0:
    if s1[0]==s2[0]:
      comb+=3
      tateyoko='tate'
      i+=1
    else:
      comb+=6
      tateyoko='yoko'
      i+=2
  elif s1[i]==s2[i]:
    i+=1
    if tateyoko=='tate':
      comb*=2
      comb%=1000000007
    else:
      tateyoko='tate'
  else:
    i+=2
    if tateyoko=='tate':
      tateyoko='yoko'
      comb*=2
      comb%=1000000007
    else:
      comb*=3
      comb%=1000000007
print(comb)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int main() {
  int k, t;
  cin >> k >> t;

  V<int> a(t);
  rep(i, t) cin >> a[i];

  V<P> p = {{0, 0}};
  rep(i, t) p.push_back({a[i], i + 1});

  V<int> b = {0};
  int ans = 0;
  rep(i, k) {
    sort(p.rbegin(), p.rend());
    if (p[0].first == 0) break;
    if (b.back() != p[0].second) {
      b.push_back(p[0].second);
      p[0].first--;
    } else {
      if (p[1].first > 0) {
        b.push_back(p[1].second);
        p[1].first--;
      } else {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3712
/**-------------------------
|--------From A.R.A--------|
-------------------------**/
 
#include <bits/stdc++.h>
 
#define ll            long long int
#define pb            push_back
#define ull           unsigned long long int
#define endl          "\n"
#define sz(c)         (c).size()
#define sall(c)       sort((c).begin(),(c).end())
#define rsall(c)      sort((c).rbegin(),(c).rend())
#define rev(c)        reverse((c).begin(),(c).end())
#define FOR(i,n)      for(ll i=0;i<n;i++)
#define max3(a,b,c)   max(max(a,b),c)
#define min3(a,b,c)   min(min(a,b),c)
#define input(a,i,n)  for(ll i=0;i<n;i++){      cin>>a[i];}
#define output(a,i,n) for(ll i=0;i<n;i++){cout<<a[i]<<" ";}
 
using namespace std;
int64_t R=1;
void solution(){
    int64_t a,b,sum=0,c=0;
    cin>>a>>b;
    if(b==1){cout<<"0"<<endl;return;}
    while(true){
        sum=sum+a;c++;
        if(sum>=b){cout<<c<<endl;return;}
        sum--;
    }
}
int main()
{
    FOR(i,R){solution();}
    return 0;
}

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


//c++ templte for help............................................................................................................................................
typedef long long ll;

//template<typename... T>
//void print1(T... t){
	//((cout<<t<<" "),...);
//}

//template<typename... T>
//void print2(T... t){
		//vector<vector<ll>> ans={t...};
		//for(ll i=0;i<(ll)ans.size();i++){
			//if(i!=0) cout<<"\t\t";
			//else cout<<"\t";
			//for(ll j=0;j<(ll)ans[i].size();j++){
				//cout<<ans[i][j]<<" ";
			//}
			//if(i!=(ll)ans.size()-1)
			//cout<<endl;
		//}
//}	
//#define deb(...) cout<<" [ "#__VA_ARGS__<<" : "; print1(__VA_ARGS__); cout<<"]"<<endl; 
//#define vdeb(...) cout<<" [ "#__VA_ARGS__<<" : "; print2(__VA_ARGS__); cout<<"]"<<endl;





	
 
//for loop
//#define fo(i,n) for(int i=0;i<(ll)n;i++)
//#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
//template<typename T>
//void printV(T vec){
	//fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	//cout<<endl;
	//}
	
 
#define M 998244353
const int INF=1e9+5;
 
//iterate map
//template<typename T>
//void itR(T map){
	 //for(auto itr=map.begin();itr!=map.end();itr++){
				//deb(itr->first,itr->second);
			//}
	//cout<<endl;
//}
 
 
 
//c++ template for help...........................................................................................................................................



ll solve(){
	int n,k;
	cin>>n>>k;
	
	vector<int> vec(n);
	for(int i=0;i<n;i++){
		cin>>vec[i];
	}
	
	sort(vec.begin(),vec.end());
	ll sum=0;
	for(int i=0;i<k;i++){
		sum+=vec[i];
	}
	return sum;
}

int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(50);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	
	 // TESTCASE KO DEKH KA BHAUT SARA CONDITION GENERATE MAT KRO 
	 // PAPER PD CONFIRM HO JAO THORA JADA TIME HI KYU NA LGA
	 // greedy ma jadatr exceptional case check kr ke dekh lo
	 
	 // WHILE DOING THE QUESTION OF DYNAMIC PROGRAMMING GREEDY KA TRAH SOCHNA BAND KRO
	 // DP M DATA KA BHI USE KRNA PDTA HA BE BHULO MT 
	 // DP BHI WO LEETCODE WALE MATRIX KA QUESTION KI TARAH HA
	 // CONSTRAIN WILL BE THE DIMENSION OF DP
	 // DP MA STATE PTA KRO AUR PHIR FUNCTION GENERATE KRO
	 // OBJECT KO CHOOSE KIA YA NAE KIA AGAR KIA TO KYA HOGA AUR NAE KIA TO KYA HOGA
	 // KYA KYA CHEJ IMPORTANT HA WO STATE BN JAGA AUR HUM LOG STATE KO CHANGE KR SKTA HA JYSA KNPSACK 2 WALE PROBLEM MA KIA THA
	 

	 
	//ll testCase;
	//cin>>testCase;
	//for(ll tt=0;tt<testCase;tt++){
		//solve();
		ll ans=solve();
		cout<<ans<<endl;
	//}
	return 0;
}


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

#define pb push_back
#define fi first
#define se second
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pii pair<int,int>

const int mod=1e9+7;
int lowbit(int x) {return x&(-x);}

int n;
int g[23][23];
int f[(1<<22)];

int main(){
	scanf("%d",&n);
	for (int i=0;i<n;i++)
		for (int j=0;j<n;j++) scanf("%d",&g[i][j]);
	f[0]=1;
	for (int i=1;i<(1<<n);i++) {
		int cur=__builtin_popcount(i)-1;
		for (int j=0;j<n;j++) 
			if (g[cur][j]==1&&((i>>j)&1)) {
				int mask=i^(1<<j);
				f[i]+=f[mask];
				f[i]%=mod;
			}
	}
	cout<<f[(1<<n)-1];
	return 0;
}


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

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

  set<int> se;
  int a;
  for (int i=0; i<n; i++) {
    cin >> a;
    auto it = se.find(a);
    if (it == se.end())
      se.insert(a);
    else
      se.erase(it);
  }

  cout << se.size() << endl;
  return 0;
}

Measured memory_bytes: 4864
/*

                                  In the name of Allah, Most Gracious, Most Merciful


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

//*** constant value ***
const long double PI = 3.141592653589793238;
const double EPS = 1e-6 ;
//*** constant value ***

//****** define ********
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define dd double
#define vll vector<ll>
#define vs vector<string>
#define fn(i,n) for(ll i = 0; i<n; i++)
#define f(i,a,b) for(i=a;i<b;i++)
#define f1(i,a,b) for(i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vpl vector<pll>
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define tt cout<<"Came here"<<endl;
//****** define ********
void solve()
{


}

int main()
{
    IOS;
    ll n,x,t;
    cin>>n>>x>>t;

    ll ans = ceil((n*1.0)/x) * t;
    printf("%lld\n",ans);

return 0;
}



Measured memory_bytes: 3752
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a+b>=c)
	{
		printf("Yes\n");
	}	
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#include <time.h> 
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y);
#define sz(x) (int)(x.size())
#define nax 200010
#define inf 1001000100
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pc pair<char ,int>
#define pi pair<int ,int>
#define pii pair <pi,pi>
using namespace std;
int h[nax];
int b[nax];
ll tree[4 * nax];

void update(int node, int pos, ll val, int st, int en)
{
    if(st == en)
    {
        tree[node] = val;
        return;
    }
    int mid = (st + en) / 2;
    if(pos <= mid) // lef
      update(node + node , pos, val, st, mid);
    else
      update(node + node + 1 , pos, val, mid + 1, en);
    tree[node] = max(tree[node + node] , tree[node + node + 1]);
}

ll query(int node, int x, int y, int st, int en)
{
  if(st > y || en < x)
    return 0;
  if(st >= x && en <= y)
    return tree[node];
  int mid = (st + en) >> 1;
  ll l_ans = query(node + node, x , y, st, mid);
  ll r_ans = query(node + node + 1, x , y, mid + 1, en);
  return max(l_ans, r_ans);
}

int main(int argc, char const *argv[])
{
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  int n;
  sd(n);
  for(int i = 0; i < n; i++)
    sd(h[i]);
  for(int i = 0; i < n; i++)
    sd(b[i]);

  ll fans = 0;
  for(int i = 0; i < n; i++)
  {
      ll cur = query(1, 0 , h[i] - 1, 0, nax - 1) + b[i];
      update(1, h[i], cur, 0, nax - 1);
      fans = max(fans, cur);
  }
  printf("%lld\n", fans);
  return 0;
}

Measured memory_bytes: 7936
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <map>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define INF 1e10
typedef long long ll;
typedef long double ld;
int main(){
    ll n; cin>>n;
    vector<ll> v(3*n);
    REP(i,3*n)cin>>v[i];
    sort(ALL(v),greater());
    ll sum=0;
    REP(i,n){
        sum+=v[i*2+1];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 5632
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll H,W;
    cin >> H >> W;
    ll i,j,k,l;
    string S[H];
    for(i=0;i<H;i++){
        cin >> S[i];
    } 
    ll d[H*W][H*W];
    for(i=0;i<H*W;i++){
        for(j=0;j<H*W;j++){
             d[i][j]=100000;
        }
    }
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            if(i!=H-1&&S[i][j]=='.'&&S[i+1][j]=='.'){
                d[i*W+j][(i+1)*W+j]=1;
                d[(i+1)*W+j][i*W+j]=1;
            }
            if(j!=W-1&&S[i][j]=='.'&&S[i][j+1]=='.'){
                d[i*W+j][i*W+j+1]=1;
                d[i*W+j+1][i*W+j]=1;
            }
            d[i*W+j][i*W+j]=0;
        }
    }
    for(k=0;k<H*W;k++){
        for(i=0;i<H*W;i++){
            for(j=0;j<H*W;j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    ll ans=0;
    for(i=0;i<H*W;i++){
        for(j=0;j<H*W;j++){
            if(S[i/W][i%W]=='.'&&S[j/W][j%W]=='.'){
                ans=max(ans,d[i][j]);
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 1536