akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

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

  ll x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  vector<ll> green(a);
  vector<ll> red(b);
  vector<ll> white(c);
  for(int i=0; i<a; ++i){
    cin>>green[i];
  }
  for(int i=0; i<b; ++i){
    cin>>red[i];
  }
  for(int i=0; i<c; ++i){
    cin>>white[i];
  }

  sort(green.rbegin(), green.rend());
  sort(red.rbegin(), red.rend());
  sort(white.rbegin(), white.rend());
  multiset<ll> v1, v2;
  for(int i=0; i<min(x,a); ++i){ v1.insert(green[i]); }
  for(int i=0; i<min(y,b); ++i){ v2.insert(red[i]); }
  int ptr = 0;
  while( v1.size() != x ){
    if( ptr == c ){ break; }
    v1.insert(white[ptr++]);
  }
  while( v2.size() != y ){
    if( ptr == c ){ break; }
    v2.insert(white[ptr++]);
  }
  assert(v1.size() == x);
  assert(v2.size() == y);

  multiset<ll> tot;
  for(auto i : v1){ tot.insert(i); }
  for(auto i : v2){ tot.insert(i); }

  while( ptr < c ){
    int val = white[ptr];
    if( val > *tot.begin() ){
      tot.erase(tot.begin());
      tot.insert(val);
      ++ptr;
    }else{
      break;
    }
  }

  ll ans = 0;
  for(auto i : tot ){ ans += i; }
  cout << ans << '\n';


	return 0;
}


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

int main(){
while(1){
	bool a[100000+2];
	fill(a,a+100002,false);
	int n,k,b,ans=0;
	scanf("%d%d",&n,&k);
if(n==0&&k==0)break;
	for(int i=0;i<k;i++){
		scanf("%d",&b);
		a[b]=true;
	}
	int c=0,d=0;
	if(a[0]){
		for(int i=1;i<n+1;i++){
			if(a[i])d++;
			if(!a[i]){
				if(c+d+1>ans)ans=c+d+1;
				if(a[i+1]){
					c=d;
					d=1;
				}
				if(!a[i+1]){
					c=0;
					d=0;
				}
				i++;
			}
		}
		if(c+d+1>ans)ans=c+d+1;
	}
	if(!a[0]){
		for(int i=1;i<n+1;i++){
			if(a[i])d++;
			if(!a[i]){
				if(ans<d)ans=d;
				d=0;
			}
		}
	}
	printf("%d\n",ans);
}
}

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

int main(){
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  long long count=0;
  for(int i=0; i<=N/R; i++){
    if(i*R>N) break;
    if(i*R==N){
      count++;
      continue;
    }
    for(int j=0; j<=N/G; j++){
      if(i*R+j*G>N) break;
      if(i*R+j*G==N) count++;
      else if((N-i*R-j*G)%B==0) count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = list(input())
cntA = 0; cntB = 0
for s in S:
    if s == 'a' and cntA+cntB < A+B:
        print('Yes')
        cntA += 1
    elif s == 'b' and cntA+cntB < A+B and cntB < B:
        print('Yes')
        cntB += 1
    else:
        print('No')


Measured memory_bytes: 4712
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    set<int> st;

    REP(i,N){
        int d; cin>>d;
        st.insert(d);
    }
    cout<<st.size()<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
namespace my_std{
	using namespace std;
	#define Rint register int
	#define FOR(i,a,b) for(register int i=(a);i<=(b);++i)
	#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
	#define GO(x,i,v) for(register int i=p[x].head,v;i;i=e[i].link)
	#define PII pair<int,int>
	#define MP make_pair
	typedef long long LL;
	typedef double DB;
	inline int read(){
		char c=getchar();int ans=0,f=1;
		while(c>'9'||c<'0'){ f^=(c=='-'); c=getchar(); }
		for(;c<='9'&&c>='0';c=getchar()) ans=ans*10+(c^48); return f?ans:-ans;
	}
	const int mod = 1e9 + 7;
	int gcd(int x,int y){
		if(x<y) swap(x,y);
		return !y?x:gcd(y,x%y);
	}
	inline void inc(int &x,const int &y){ x+=y; if(x>=mod) x-=mod; }
	inline int ksm(int x,LL y){ int res=1; for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) res=1ll*res*x%mod; return res; }
	#define FILE(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
}
using namespace my_std;

LL a[200010],n,ans,pre,sum=1145141919;
bool flag=0;

int main(){
	n=read();
	FOR(i,1,n) a[i] = read() , ans += abs(a[i]);
	FOR(i,1,n){
		if(a[i]<0) ++pre;
		sum = min(sum,abs(a[i]));
		if(a[i]==0) flag = 1;
	}
	if((pre&1)&&!flag) printf("%lld",ans - sum * 2);
	else printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

L = [5 ** i for i in xrange(1, 10)]

for line in stdin:
    n = int(line)
    if not n:
        break
    print(sum(n // i for i in L))

Measured memory_bytes: 4220
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[105][100005];


ll DPRF(ll n, ll val, ll w[], ll v[]){
    if(n==1){
        if(val==0) return 0;
        if(val==v[0]) return w[0];
        else return INT_MAX;
    }
    if(dp[n][val]!=-1) return dp[n][val];
    ll op1=DPRF(n-1,val,w,v);
    ll op2=(val>=v[n-1]) ? DPRF(n-1,val-v[n-1],w,v)+w[n-1] : INT_MAX;
    return dp[n][val]=min(op1,op2);
}

ll tellMeMaxV(ll n, ll W, ll w[], ll v[]){
    ll ans=0;
    for(ll val=1;val<=100000;val++){
        if(DPRF(n,val,w,v)<=W) ans=val;
    }
    return ans;
}

int main(){
    ll n,W; cin>>n>>W;
    ll w[n],v[n];
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    
    cout<<tellMeMaxV(n,W,w,v);
    
}


Measured memory_bytes: 85692
n, m = map(int, input().split())

ball = [1] * n
flag = [True] + [False] * (n - 1)

for i in range(m):
	x, y = map(int, input().split())
	x, y = x-1, y-1

	if ball[x] > 0:
		ball[x] -= 1
		ball[y] += 1

		if flag[x] == True:
			flag[y] = True
		if ball[x] == 0:
			flag[x] = False
	else:
		continue

print(sum(flag))

Measured memory_bytes: 48520
#include<iostream>
#define Pr 259999
using namespace std;

bool prime[260000];
void eratos() {
	for (int i = 0;i <=Pr;i++)prime[i] = true;

	prime[0] = prime[1] = false;
	for (int i = 2;i*i <= Pr;i++) {
		if (prime[i]) {
			for (int j = i*2;j <= Pr;j+=i) {
				prime[j] = false;
			}
		}
	}
}

int main() {
	int a;
	eratos();
	while (cin >> a, a) {
		int ans = 0;
		for (int i = a+1;i <= a * 2;i++) {
			if (prime[i])ans++;
		}
		cout << ans << endl;
	}
}

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

int main()
{ 
  int n, m, c, a, sum_ab, ans = 0;
  vector<int> b(20);

  cin >> n >> m >> c;
  for (int i = 0; i < m; i++)
    cin >> b[i];
  for (int i = 0; i < n; i++)
  {
    sum_ab = c;
    for (int j = 0; j < m; j++)
    {
      cin >> a;
      sum_ab += a * b[j];
    }
    if (sum_ab > 0)
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n= int(input())

ac=0
wa=0
tle=0
re=0

l=[]

for i in range(n):
    t=input()
    if(t=='AC'):
        ac=ac+1
    elif(t=='WA'):
        wa=wa+1
    elif(t=='TLE'):
        tle=tle+1
    elif(t=='RE'):
        re=re+1
  
print('AC x '+ str(ac))
print('WA x '+ str(wa))
print('TLE x '+ str(tle))
print('RE x '+ str(re))

Measured memory_bytes: 9220
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}


int main(){
    ll a,b,c,k,ans=0;
    cin >> a >> b >> c >> k;
    ans+=min(k,a);
    k-=a+b;
    if (k>0){
        ans-=k;
    }
    cout << ans << endl;
    return 0;
}
 
 


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

typedef long long int ll;

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll left = (4*a*b);
    ll right = (c-a-b)*(c-a-b);
    if(a+b>=c) right = 0;
    
    if(left<right) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = str(input())

count = 0
i = 0
while i < N - 2:
    if S[i] == 'A' and S[i + 1] == 'B' and S[i + 2] == 'C':
        count += 1
        i += 3
    else:
        i += 1
print(count)

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int ans_total = 0;
  for(int x=0; x<N; x++){
    ans_total += vec.at(x);
  }
  
  int gap = 10000;
  for(int j=0; j<N; j++){
     int ans_l = 0;
     int ans_r = 0;
    for(int k=0; k<=j; k++){
      ans_l = ans_l + vec.at(k);
    }
    ans_r = ans_total - ans_l;
    if(abs(ans_l - ans_r) < gap){
      gap = abs(ans_l - ans_r);
    }
  }
  cout << gap << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
long long INF=9999999999;
int main(void){
    long long x,y,a,b,c;
    cin>>x>>y;
    long long ax,ay;
    ax=ay=INF;
    for(int i=0;i<x;i++){
        a=i*y;b=(x-i)*(y/2);c=(x-i)*(y-y/2);
        ax=min(ax,max(max(a,b),c)-min(min(a,b),c));
        a=i*y;b=(x-i)/2*y;c=((x-i)-(x-i)/2)*y;
        ax=min(ax,max(max(a,b),c)-min(min(a,b),c));
    }
    for(int i=0;i<y;i++){
        a=i*x;b=(y-i)*(x/2);c=(y-i)*(x-x/2);
        ay=min(ay,max(max(a,b),c)-min(min(a,b),c));
        a=i*x;b=(y-i)/2*x;c=((y-i)-(y-i)/2)*x;
        ay=min(ay,max(max(a,b),c)-min(min(a,b),c));
    }
    cout<<min(ax,ay);
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}



signed main(){
	
	ll n,ans = 0;
	cin >> n;
	ll a[n] = {},b[n] = {},c[n-1] = {};
	
	rep(i,0,n){
		cin >> a[i];
	}
	rep(i,0,n){
		cin >> b[i];
	}
	rep(i,0,n-1){
		cin >> c[i];
	}
	
	
	rep(i,0,n){
		ans += b[a[i]-1];
		
		if(i > 0){
			if(a[i] == a[i-1] + 1){
				ans += c[a[i-1]-1];
			}
		}
	}
	
	cout << ans << endl;
	
    return 0;
}

Measured memory_bytes: 256
/**
 *    author:  nasimnoob
**/

#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

//----------------------------------------------------------//

typedef long long                       ll;
typedef unsigned long long              ull;
typedef long double                     ld;

//-----------------------------------------------------------//

#define      cube(x)                    (x*x*x)
#define      sqr(x)                     (x*x)
#define      PI                         acos(-1)

//-----------------------------------------------------------//

int main()
{
    char s[10000];
    int a,b,c,i,n,l=0,k=0;
    cin>>s;
    if(s[0]=='A' && s[1]=='B' && s[2]=='C')
        cout<<"ARC"<<endl;
    else
        cout<<"ABC"<<endl;
    return 0;
}




Measured memory_bytes: 3572
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    double a, b;

    a = sc.nextDouble();
    b = sc.nextDouble();
    out.println(a * b / 3.305785);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 18360
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#ifdef on_linux
	#include <sys/resource.h>
#endif

#ifdef dobby_is_a_free_elf
	#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
	#define trace(...) 0;
#endif

using namespace std;
using namespace __gnu_pbds;


#define all(x)                  (x).begin(), (x).end()
#define between(i,x,y)          ((i) >= (x) && (i) <= (y))
#define DECIMAL(n)              cout << fixed << setprecision(n)
#define fi                      first
#define lbd                     lower_bound
#define mem0(x)                 memset(x, 0, sizeof (x))
#define mem1(x)                 memset(x, -1, sizeof (x))
#define mp                      make_pair
#define pb                      push_back
#define pf                      push_front
#define ppb                     pop_back
#define ppf                     pop_front
#define sc                      second
#define sqr(a)                  ((a) * (a))
#define sz(x)                   (int)((x).size())
#define ubd                     upper_bound

#define int                     long long

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

template <typename T>
using ordered_set = tree<T, null_type,
      less<T>,
      rb_tree_tag,
      tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0
// order_of_key(k) returns count of elements strictly smaller than k


const long double PI = 3.14159265358979323846264338;
const double eps = 1e-10;
#ifdef int
	const long long INF = 1e18;
#else
	const long long INF = 1e9;
#endif
const int32_t fftmod = 998244353;
const int32_t MOD = 1000000007;
const int32_t N = 1e5 + 10;
const int32_t NN = 1e6 + 10;



inline void elf_magic(int testcase)
{
	int x;
	cin >> x;
	cout << (!x);

	return;
}

int32_t main()
{
	#ifdef on_linux
	rlimit cpu_time {.rlim_cur = 2, .rlim_max = RLIM_INFINITY};
	setrlimit(RLIMIT_CPU, &cpu_time);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int TESTS = 1;
	//cin >> TESTS;
	for (int i = 1; i <= TESTS; ++i) {
		// cout << "Case #" << i << ": ";
		elf_magic(i);
		if (i != TESTS)	{ cout << '\n'; }
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
    ll n = 100;
    ll k, c = 0;
    cin>>k;
    while(n<k){
        n = n + (n*(1.0/100.00));
        c++;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10;
int x[maxn],xx[maxn],w[maxn];
int i,j,k,l,r,s,t,n,m;
ll c; 
int main(){
    scanf("%d%d%d",&n,&l,&t);
    fo(i,1,n) scanf("%d%d",&x[i],&w[i]);
    fo(i,1,n){
        if (w[i]==2) w[i]=-1;
        r=x[i]+w[i]*t;
        if (r>0) (c+=r/l)%=n;
        else if (r<0) (c+=(r+1)/l-1)%=n;
        xx[i]=(r%l+l)%l;
    }
    sort(xx+1,xx+n+1);
    c=(c+n)%n;
    fo(i,c+1,n) printf("%d\n",xx[i]);
    fo(i,1,c) printf("%d\n",xx[i]);
}


Measured memory_bytes: 2304
#include <iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    char p[N];

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

    char ans = p[0];
    //cout << ans << endl;
    for(int i = 1; i < N; i++){
        if(ans == 'T' && p[i] == 'T') ans = 'T';
        else if(ans == 'T' && p[i] == 'F') ans = 'F';
        else if(ans == 'F' && p[i] == 'T') ans = 'T';
        else ans = 'T';
        //cout << i << ". " << ans << endl;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3196
from collections import deque
import numpy as np
N,K = (int(x) for x in input().split())
S = input()
count = []
d = deque(list(S))

now = d.popleft()
cum = 1
for i in range(len(S)-1):
    popped = d.popleft()
    if popped == now:
        cum += 1
    else:
        count.append(cum)
        now = popped
        cum = 1
count.append(cum)
points = [i-1 for i in count]
cs1 = np.array(count).cumsum()
cs2 = np.array(points).cumsum()

if len(count) // 2 <= K:
    print(N-1)
else:
    m = 0
    for i in range(len(count)-2*K):
        if i == 0:
            c = cs1[2*K] - 1
            d = cs2[-1] - cs2[2*K]
        elif i == len(count) - 2*K + 1:
            c = cs1[-1] - cs1[-2*K-2] - 1
            d = cs2[-2*K-2]
        else:
            c = cs1[2*K+i] - cs1[i-1] - 1
            d = cs2[i-1] + (cs2[-1]-cs2[2*K+i])
        m = max(m,c+d)
    print(m)

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


using namespace std;

typedef long long ll;
const double eps = 1e-9;



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

        ll x,k,d;
    cin>>x>>k>>d;

        if(x<0)
        {
            x*=-1;
        }
            ll moves = x/d;
            if(k<=moves)
            {
                cout<<x-(k*d)<<endl;
            }
            else
            {
                 ll ans;
            if((k-moves) % 2 == 0)
            {
                ans = x-(moves*d);

            }
            else
            {
                ans = llabs(x-(moves*d) - d);
            }
            cout<<ans<<endl;
            }








}

/*
 ll x,k,d;
    cin>>x>>k>>d;
    if(x==0)
    {
        if(k%2)
        {
            cout<<x+d<<endl;;
        }
        else
        {
            cout<<0<<endl;
        }
    }
    else if(x>0)
    {
        if(x-k*d>=0)
        {
            cout<<x-k*d<<endl;
        }
        else
        {
           ll moves = x/d;
            ll ans;
            if((k-moves) % 2 == 0)
            {
                ans = x-moves*d;

            }
            else
            {
                ans = llabs(x-moves*d - d);
            }
            cout<<ans<<endl;

        }


    }
    else if(x<0)
    {
        if(x+k*d<=0)
        {
            cout<<x+k*d<<endl;
        }
        else
        {
           ll moves = x/d * -1;
            ll ans;
            if((k-moves) % 2 == 0)
            {
                ans = x+moves*d;

            }
            else
            {
                ans = llabs(x+moves*d + d);
            }
            cout<<ans<<endl;

        }
    }

*/


Measured memory_bytes: 3628
#if 1
  #include <bits/stdc++.h>
#else
  #include "../../../../bits/stdc++.h"
#endif

#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define REP(i,n) FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))

using namespace std;

using pii =  pair<int, int>;
using ll = long long;

#define pb push_back
#define mp make_pair
#define ft first
#define sd second

int A, B, C, D;

bool a[102];
bool b[102];

int c;

int main(){
  cin.tie(0);
  
  cin>>A>>B>>C>>D;

  REP(i, B-A)a[i+A] = true;
  REP(i, D-C)b[i+C] = true;

  REP(i, 101) {
    if(a[i]&&b[i])c++;
  }

  cout<<c<<endl;

  return 0;
}


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

int main () {
    int H, W;  cin >> H >> W;
    vector<string> s(H);   
    for(int i = 0; i < H; i++){
        cin >> s[i];
        cout << s[i] << endl;
        cout << s[i] << endl;
    }
    return 0;
}

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

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

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let v = read_vec::<usize>();
    let r = v[0];
    let c = v[1];

    let mut v_total = vec![0u32; c + 1];
    for _i in 0..r {
        let mut v = read_vec::<u32>();
        let sum = v.iter().sum::<u32>();
        v.push(sum);

        for j in 0..c + 1 {
            v_total[j] += v[j];
        }

        println!("{}", v.iter().map(|x| x.to_string()).collect::<Vec<String>>().join(" "));
    }
    println!("{}", v_total.iter().map(|x| x.to_string()).collect::<Vec<String>>().join(" "));
}



Measured memory_bytes: 5052
import java.util.*;

public class Main {
	
	public static String[] kommaReader(String sc) {
		String line = sc;
		String[] array = line.split(",");
		return array;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] a = new int[w+1];
		for(int i=1; i<=w; i++) a[i]=i;
		for(int i=0; i<n; i++){
			String text = sc.next();
			String[] ch = kommaReader(text);
			int x = Integer.parseInt(ch[0]);
			int y = Integer.parseInt(ch[1]);
			int t = a[x]; 
			a[x] = a[y];
			a[y] = t;
		}
		for(int i=1; i<=w; i++) System.out.println(a[i]);
	}

}

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

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

typedef long long ll;
typedef long double ld;

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

string solve(const vector<ll> &A) {
  ll N = A.size();
  ll k = 0LL;
  REP(i,N) k += A[i];
  ll tmp = N * (N + 1LL) / 2LL;
  if(k % tmp) return "NO";
  k /= tmp;

  vector<ll> b(N);
  REP(i,N) b[i] = k - (A[(i + 1) % N] - A[i]);
  REP(i,N) {
    if(b[i] % N || b[i] < 0) return "NO";
  }
  return "YES";
}

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  REP(i,N) cin >> A[i];

  cout << solve(A) << endl;
  return 0;
}



Measured memory_bytes: 1920
def solve():
    from sys import stdin
    f_i = stdin
    
    def rec(i):
        if i == 0:
            return 0
        
        tray = cups[n - i]
        if tray == 'A':
            return rec(i - 1)
        elif tray == 'B':
            return 2 * 3 ** (i - 1) - 1 - rec(i - 1)
        else:
            return rec(i - 1) + 2 * 3 ** (i - 1)
    
    while True:
        n, m = map(int, f_i.readline().split())
        if n == 0:
            break
        
        cups = [None] * n
        for tray in 'ABC':
            itr = map(int, f_i.readline().split())
            next(itr)
            for i in itr:
                cups[i-1] = tray
        
        num = rec(n)
        ans = min(num, 3 ** n - 1 - num)
        if ans <= m:
            print(ans)
        else:
            print(-1)

solve()


Measured memory_bytes: 5600
import java.util.Scanner;

class Main {

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

        String s = stdIn.next();

        char[] charArray = s.toCharArray();

        boolean end = false;

        for (int i = 0; i < charArray.length; i++) {
            if (end == false) {
                for (int j = charArray.length - 1; i < j; j--) {
                    if (end == false) {
                        if (charArray[i] == charArray[j]) {
                            System.out.println("no");
                            end = true;
                        }
                    }
                }
            }

        }
        if (end == false) {
            System.out.println("yes");
        }
    }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(b-a == c-b){
        System.out.println("YES");
    }else{
        System.out.println("NO");
    }
  }
}


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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

int gcd(int a, int b){return (a % b)? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}

void solve_A(){
    int k;
    cin >> k;

    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k-1];
}

void solve_B(){
    ll h, w;
    cin >> h >> w;

    ll H = h/2, W = w/2;
    ll _H = (h+1)/2, _W = (w+1)/2;
    
    if(w == 1 || h == 1) cout << 1;
    else cout << _H * _W + H*W;

}

int main(void){
    solve_B();
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long N, std::string S, std::string T){
    for (int i = 0; i < N; i++)
    {
        cout << S[i] << T[i];
    }
    
    cout << endl;
    
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(N, S, T);
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N, W;
    cin >> N >> W;
    vl v(N), w(N);
    rep(i, N){
        cin >> v[i] >> w[i];
    }

    vll dp(N+10, vl(W+10));
    //dp[i][j]:=左からi個の品物から、バックの容量がjを超えないように選んだときの価値の合計の最大値
    rep(i, W+1) dp[0][i] = 0;
    
    rep(i, N){
        rep(j, W+1){
            if(j >= w[i]) dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j]);
            else dp[i+1][j] = dp[i][j];
        }
    }

    cout << dp[N][W] << endl;
}


Measured memory_bytes: 11612
#include<iostream>
#include<string.h>
using namespace std;
const int tam = 55;
long long n, a, x[tam], ans;

long long memo[tam][1000][60];

long long solve(int idx, int sum, int quantity){
    if(idx == n) return ((quantity != 0) && (sum % quantity == 0) && (sum / quantity == a));
    long long & ans = memo[idx][sum][quantity];
    if(ans != -1) return ans;
    ans = 0;
    ans += solve(idx + 1, sum + x[idx], quantity + 1);
    ans += solve(idx + 1, sum, quantity);
    return ans;
}

int main(){
    cin >> n >> a;
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    for(int i = 0; i < tam; i++){
        for(int j = 0; j < 1000; j++){
            for(int k = 0; k < 60; k++){
                memo[i][j][k] = -1;
            }
        }
    }
    // idx - suma - cuántos llevo
    cout << solve(0, 0, 0) << '\n';
    return 0;
}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  lol n, p, a[55], gu = 1, ki = 0;
  cin >> n >> p;
  reps(i, n){
    cin >> a[i];
  }
  reps(i, n){
    if(a[i] % 2 == 1){
      lol nasu = gu;
      gu += ki;
      ki += nasu;
    } else {
      gu *= 2;
      ki *= 2;
    }
  }
  if(p == 1){
    cout << ki << '\n';
  } else {
    cout << gu << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
<?php
  list($N, $x) = explode(" ", trim(fgets(STDIN)));

  $a = explode(" ", trim(fgets(STDIN)));

  $ans = 0;
  $sum = [];
  $sum[0] = $a[0];
  for($i=1; $i<$N; $i++){
//    echo $sum[$i-1]." ".$ans." ";
    if($sum[$i-1] + $a[$i] > $x){
      if($sum[$i-1] > $x){
        $ans += $a[$i];
        $ans += $sum[$i-1]-$x;
        $sum[$i] = 0;
      }else{
        $ans += ($sum[$i-1] + $a[$i] - $x);
        $sum[$i] =  $x - $sum[$i-1];
      }
    }else{
      $sum[$i] = $a[$i];
    }
  }

  echo $ans;

Measured memory_bytes: 27976
import std.stdio, std.string, std.algorithm, std.range, std.conv, std.typecons, std.math;
void main(){
    auto N = readln.chomp.to!int;
    auto As = readln.split.to!(int[]);
    auto groups = sort(As).group.array;
    ulong single = groups.length;
    auto multi = As.length - groups.length;
    writeln(single + (multi+1) % 2 - 1);
}

Measured memory_bytes: 4144
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

N = read()

(T, X, Y) = (0, 0, 0)

for i in range(N):
  (t, x, y) = reads()
  d = abs(X-x) + abs(Y-y)
  if d <= t - T and (t - T - d)%2 == 0:
    (T, X, Y) = (t, x, y)
    continue
  else:
    print("No")
    exit()

print("Yes")


Measured memory_bytes: 4196
#include<iostream>
#include<vector>
using namespace std;
int findNum(vector<int> &v){
	int s = 0;
	int len = v.size();
	int step = 1;
	for (int i = len - 2; i >= 0; i--){
		int count = 0;
		step *= (len - i - 1);
		for (int j = i + 1; j < len; j++){
			if (v[j] < v[i]) 
				count++;
		}
		s += (step*count);
	}
	return s + 1;
}
int main(){
	int N;
	cin >> N;

	vector<int> v(N, 0);
	for (int i = 0; i<N; i++) cin >> v[i];
	int n1 = findNum(v);
	for (int i = 0; i<N; i++) cin >> v[i];
	int n2 = findNum(v);
	int ans = n1>n2 ? n1 - n2 : n2 - n1;
	cout << ans << endl;
	return 0;
}

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

dp=[2000000000 for i in range(n)]
dp[0]=0
for i in range(n):
    
    for j in range(k+1):
        #print(i,j)
        if i+j>=n:
            break
        else:
            dp[i+j]=min(abs(h[i+j]-h[i])+dp[i],dp[i+j])
            #print(dp[i+j])
print(dp[n-1])

Measured memory_bytes: 56544
//
//  main.cpp
//  B-red_or_blue
//
//  Created by david chong on 8/21/19.
//  Copyright © 2019 david chong. All rights reserved.
//

#include <iostream>
#include <map>

using namespace std;

int main(int argc, const char * argv[]) {
    
//    freopen("input.in", "r", stdin);
    
    int t;
    char c;
    
    map<char, int> myMap;
    
    cin >> t;
    
    while(t--) {
        cin >> c;
        myMap[c]++;
    }
    
    if(myMap['R'] > myMap['B']) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 練習１
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] array = line.Split(' ');

            var N = int.Parse(array[0]);
            var R = int.Parse(array[1]);

            if (N >= 10)
            {
                Console.WriteLine(R);
            }
            else
            {
                var r = R + (100 * (10 - N));
                Console.WriteLine(r);
            }
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h> 
     
    #include<random>  
     
    #define int long long  
     
    #define pp pair<int,int>  
     
    #define ss second  
     
    #define ff first  
     
    #define pb push_back  
     
    #define mod 1000000007  
     
    using namespace std;  
     
    void fastio()  
     
    {    
     
      
     
      #ifndef ONLINE_JUDGE                  
     
      freopen("INPUT.txt","r",stdin);              
     
      freopen("OUTPUT.txt","w",stdout);              
     
      #endif    
     
         ios_base :: sync_with_stdio(false);   
     
         cin.tie(NULL) ;                             
     
          cout.tie(NULL);                              
     
       } 
     
       
     
    signed main()  {    
     
            fastio();         
     
             int t=1;           
     
              // cin>>t;                
     
               while(t--)                  
     
                  {                        
     
                       int n;
     
                       cin>>n;
     
                       int a[n],b[n+1];
     
                       for(int i=0;i<n;i++){
     
                       cin>>a[i];
     
                       b[a[i]]=i+1;
     
                       }
     
                       for(int i=1;i<=n;i++)
     
                       cout<<b[i]<<" ";
     
                   }  
     
                          
     
                                
     
        }     

Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

void solve(){
    int n,x,t;
    cin>>n>>x>>t;
    ll times = n/x;
    times+=(n%x>0);
    cout<<times*t<<'\n';
}
int main(){
    IOS;
    int tt;
    tt = 1;
    // cin>>tt;
    while(tt--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
	
	int n,a,i;
	long max,min,goukei=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(i==0){
			max=a;
			min=a;
		}if(max<a){
			max=a;
		}if(min>a){
			min=a;
		}
		goukei+=a;
	}
	printf("%ld %ld %ld\n",min,max,goukei);
	
	return 0;
}


Measured memory_bytes: 2080
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vec vector<int>
#define vecll vector<ll>

using namespace std;
///////////////////////////////////////////////////////////



ll ans = 0;
ll bi = 1;

void f(ll h) {
    if (h == 1)
        ans++;
    if (h > 1) {
        f(h/2);
        bi *= 2;
        ans += bi;
    }
}

int main() {
    ll h;
    cin >> h;

    f(h);
    cout << ans << endl;




    return 0;
}

Measured memory_bytes: 256
n = int(input())
flag=0
lst = [int(i) for i in input().split()][:n]
for i in lst:
    if i%2==0 and i%3!=0 and i%5!=0:
        flag=1 
    else:
        continue
if flag==1:
    print("DENIED")
else:
    print("APPROVED")
    
    

Measured memory_bytes: 2940
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.14159265358979323846
#define MOD 1000000007
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

void solve()
{
	ll n;
	cin>>n;
	ll t=n/15;
	cout<<n*800-t*200;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    vec[i] = num;
  }
  int count = 0;
  for(int i=1; i<n-1; i++){
    vector<int> three(3);
    three[0] = vec[i-1];
    three[1] = vec[i];
    three[2] = vec[i+1];
    int max = 0;
    int maxj;
    for(int j=0; j<3; j++){
      if(three[j] > max){
        max = three[j];
        maxj = j;
      }
    }
    if(maxj == 0){
      if(three[1] > three[2]){
        count++;
      }
    }
    if(maxj == 2){
      if(three[1] > three[0]){
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}
      
     
    
    

Measured memory_bytes: 256
n,k = map(int,input().split())
mod = 10**9+7
def pm(a,b):
  return pow(a,b,mod)
table = [0 for i in range(k+1)]
for i in range(1,k+1)[::-1]:
  x = k//i
  table[i] = pm(x,n)
  for j in range(2,x+1):
    table[i] = (table[i]-table[j*i])%mod
ans = 0
for i in range(1,k+1):
  ans = (ans+i*table[i])%mod
print(ans)

Measured memory_bytes: 73856
import itertools
n=int(input())
p=[int(x)-1 for x in input().split()]
q=[int(x)-1 for x in input().split()]

a=-1
b=-1
for i,case in enumerate(itertools.permutations(range(n))):
  if all([1 if p[i]==case[i] else 0 for i in range(n)]):
    a=i
  if all([1 if q[i]==case[i] else 0 for i in range(n)]):
    b=i
  if a >= 0 and b >= 0:
    break
print(abs(a-b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

int main()
{
    int n,a,x=0;
    cin>>n;
    rep(i,n)cin>>a,x+=a-1;
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static exMath;
using static exReadLine;


class Program
{
    static void Main(string[] args)
    {
        long H;
        longReadLine(out H);
        long ans = 1;
        long h = H / 2;
        long t = 2;
        while(h >= 1)
        {
            ans += t;
            t *= 2;
            h /= 2L;
        }
        WriteLine(ans);
    }
}

static class exReadLine
{
    public static void intReadLine(out int a)
    {
        a = int.Parse(ReadLine());
    }
    public static void intReadLine(out int a, out int b)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void intReadLine(out int a, out int b, out int c)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void intReadLine(out int a, out int b, out int c, out int d)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }

    public static void longReadLine(out long a)
    {
        a = long.Parse(ReadLine());
    }
    public static void longReadLine(out long a, out long b)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void longReadLine(out long a, out long b, out long c)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void longReadLine(out long a, out long b, out long c, out long d)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }
}

static class exMath
{
    // 最大公約数
    public static int Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
    public static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    // 最小公倍数
    public static long Lcm(int a, int b)
    {
        return BigMul(a, b) / Gcd(a, b);
    }
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
ll n,m,x,y;
vector<ll> edge[110000];
ll dp1[110000],dp2[110000];
ll ans[110000];
void dfs1(int x,int last=-1){
    ll prod=1;
    for(auto to:edge[x]){
        if(to==last) continue;
        dfs1(to,x);
        prod=prod*dp1[to]%m;
    }
    dp1[x]=prod+1;dp1[x]%=m;
}
void dfs2(int x,int last=-1){
    if(last==-1) dp2[x]=1;
    vector<ll> lcnt(edge[x].size(),1);
    vector<ll> rcnt(edge[x].size(),1);
    for(ll i=0;i<(int)edge[x].size();i++){
        int to=edge[x][i];
        if(i-1>=0) lcnt[i]=lcnt[i-1];
        if(to==last) continue;
        lcnt[i]*=dp1[to];lcnt[i]%=m;
    }
    for(ll i=(int)edge[x].size()-1;i>=0;i--){
        int to=edge[x][i];
        if(i+1<rcnt.size()) rcnt[i]=rcnt[i+1];
        if(to==last) continue;
        rcnt[i]*=dp1[to];rcnt[i]%=m;
    }
    for(ll i=0;i<(int)edge[x].size();i++){
        int to=edge[x][i];
        if(to==last) continue;
        ll rest=1;
        if(i-1>=0) rest=rest*lcnt[i-1]%m;
        if(i+1<(int)edge[x].size()) rest=rest*rcnt[i+1]%m;
        dp2[to]=(dp2[x]*rest+1)%m;
        dfs2(to,x);
    }
}
void dfs3(int x,int last=-1){
    ans[x]=dp2[x];
    for(auto to:edge[x]){
        if(to==last) continue;
        ans[x]*=dp1[to];
        ans[x]%=m;
        dfs3(to,x);
    }
}
int main(){
    cin >> n >> m;
    rep(i,n-1){
        cin >> x >> y;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    dfs1(1);
    dfs2(1);
    dfs3(1);
    for(int i=1;i<=n;i++){
        cout << ans[i] << endl;
    }
    return 0;
}

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

#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    if(s == "ABC"){
        cout << "ARC\n";
    }
    else{
        cout << "ABC\n";
    }
}



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

int main() {
	int n, x;
	cin >> n >> x;
	vector<int> l(n + 1, 0);
	for (int i = 1; i <= n; i++) {
		cin >> l.at(i);
	}

	int a = 0, ans = 0;
	for (int i = 0; i < l.size(); i++) {
		a = a + l.at(i);
		if (a <= x) ans++;
	}
	cout << ans << endl;
}


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



int main() {
	string s;
	cin >> s;
	int ans = 0, pre = -1;
	int num[2];
	fill(num, num + 2, 0);
	for (int i = 0; i < s.size(); i++) {
	//	cout << num[0] << "  " << num[1] << "  " << ans << endl;
		if (s[i] == '0') {
			if (pre == 1&&num[1]!=0){				num[0] = 0;
			}
			pre = 0;
			if (num[1] > 0) {
				num[1]--;
				ans += 1;
			}
			else {
				num[0]++;
			}
		}
		else {
			if (pre == 0&&num[0]!=0) {
				num[1] = 0;
			}
			pre = 1;
			if (num[0] > 0) {
				num[0]--;
				ans += 1;
			}
			else {
				num[1]++;
			}
		}
	}
	cout << ans * 2 << endl;
	return 0;
}


Measured memory_bytes: 512