akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();
      int l = sc.nextInt();
      
      int[] a = new int[n];
      
      int sum = 0;
      int min = 400;
      int b = 0;
      for(int i = 0; i < n; i++) {
        a[i] = l;
        sum+= l;
        if(min > Math.abs(a[i])) {
          min = Math.abs(a[i]);
          b = a[i];
        }
        l++;
      }
      
           System.out.println(sum - b);
           
           
      
           

      
	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

vi flowers;

int calc(int l, int r, int height) {
  if (l >= r) return 0;

  int res = 0, mn = INF;
  for (int i = l; i < r; i++) {
    if (flowers[i] < mn) {
      mn = flowers[i];
    }
  }
  res += mn - height;
  int nl = l;
  for (int i = l; i < r; i++) {
    if (flowers[i] == mn) {
      res += calc(nl, i, mn);
      nl = i + 1;
    }
  }
  if (nl != r) {
    res += calc(nl, r, mn);
  }
  return res;
}

int main() {
  int N; cin >> N;
  flowers.assign(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> flowers[i];
  }

  int ans = calc(0, N, 0);
  cout << ans << endl;
  return 0;
}


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

using lint = long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

constexpr lint INF = 1'010'000'000'000'000'017LL;
constexpr lint MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(lint i = (start); i < end; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }

lint mod(lint val, lint m){ lint res = val % m; if(res < 0) res += m; return res;}
lint modinv(lint a, lint m) { lint b = m, u = 1, v = 0; while (b) { lint t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u;}
lint modpow(lint a, lint n, lint mod) { lint res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
// lint gcd(lint a, lint b){ if(a < b) swap(a, b); if(b == 0) return a; return gcd(b, a%b);}
// lint lcm(lint a, lint b){ return a * b / gcd(a, b);}


//---------------------------------------------------------------
lint gcd(lint x, lint y){
    if(x>y) swap(x, y);
    while(1){
        y %= x;
        swap(x, y);
        if(x==0) return y;
    }
}

void Main()
{
    lint N, M, ans;
    cin >> N >> M;
    vector<lint> a(N);
    REP(i, N){
        cin >> a[i];
        a[i] /= 2;
    }

    lint l;
        l = a[0];
    FOR(i, 1, N){
        l = l * a[i] / gcd(l, a[i]);
    }

    int f = 0;
    REP(i, N){
        if((l/a[i])%2 == 0) f = 1;
    }
    if(!f){
        ans = (1 + M / l)/2;
    }else{
        ans = 0;
    }
    cout << ans << endl;
}

//---------------------------------------------------------------
int main()
{
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    string s;
    cin>>s;
    bool ok=true;
    rep(i,s.size()){
        if((i+1)%2){
            if(s[i]=='L') ok=false;
        }else{
            if(s[i]=='R') ok=false;
        }
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())
adj = [ [] for _ in range(N)]
clr = [-1 for _ in range(N)]

#グラフ構築
for _ in range(1,M+1):
  u, v = map(int, input().split())
  u -= 1
  v -= 1
  adj[u].append((v,1))
  adj[v].append((u,1))

#二部グラフか否か判定  
vis = [0 for _ in range(N)]
q = deque([(0,0)])
is_bip = True
#print(clr)
while q:
  p, c = q.popleft()
  clr[p] = c
  vis[p] = 1
  for x, w in adj[p]:
    if vis[x] == 0:
      q.append((x,(w+c)%2))
      #print((x,(w+c)%2))
    else: 
      if (clr[x] + c) % 2 == 0:
        is_bip = False
        break
  if not is_bip:
    break
    
#ここから問題特有の処理
if is_bip:#二部グラフの場合
  apple = clr.count(0)
  orange = clr.count(1)
  #print(apple,orange,M)
  print(apple*orange-M)
  
else:#二部グラフでない場合
  print(N*(N-1)//2-M)
  

Measured memory_bytes: 110596
n=int(input())
a=[0]*n
b=[0]*n
c=[0]*n
ka=[-1]*n
kb=[-1]*n
kc=[-1]*n
for i in range(n):
  a[i],b[i],c[i]=map(int,input().split())

ka[0]=a[0]
kb[0]=b[0]
kc[0]=c[0]

for i in range(1, n):
  ka[i]=max(kb[i-1],kc[i-1])+a[i]
  kb[i]=max(ka[i-1],kc[i-1])+b[i]
  kc[i]=max(kb[i-1],ka[i-1])+c[i]

print(max(ka[n-1],kb[n-1],kc[n-1]))

Measured memory_bytes: 26740
#include <bits/stdc++.h>
#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)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x, y) (x = max(x,y))
#define mins(x, y) (x = min(x,y))
#define limit(x, l, r) max(l,min(x,r))
#define lims(x, l, r) (x = max(l,min(x,r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1ll<<x)-1)
#define dup(x, y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() {
    int x;
    scanf("%d", &x);
    return x;
}
template<typename T> inline istream &operator>>(istream &i, v(T) &v) {
    rep(j, sz(v))i >> v[j];
    return i;
}
template<typename T> string join(const v(T) &v) {
    stringstream s;
    rep(i, sz(v))s << ' ' << v[i];
    return s.str().substr(1);
}
template<typename T> inline ostream &operator<<(ostream &o, const v(T) &v) {
    if (sz(v))o << join(v);
    return o;
}
template<typename T1, typename T2> inline istream &operator>>(istream &i, pair<T1, T2> &v) { return i >> v.fi >> v.se; }
template<typename T1, typename T2> inline ostream &operator<<(ostream &o, const pair<T1, T2> &v) { return o << v.fi << "," << v.se; }
template<typename T> inline ll suma(const v(T) &a) {
    ll res(0);
    for (auto &&x : a) res += x;
    return res;
}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("NO"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int bs(ll x) {
    return pcnt(x) & 1;
}

int n;
ll n1;
vl ans;
void dfs(ll s, ll t, ll m) {
    if (pcnt(m) == n - 1) {
        ans.pb(s);
        ans.pb(t);
        return;
    }
    //s -> tで利用する必要がある軸
    ll x = s ^t;
    //bは増えた物の内、低軸
    //tへ行くうえで必ず必要
    ll b = x & -x;
    //mはこれまで切ってきた軸
    //b軸を切った
    m |= b;
    //miは残ってる軸
    ll mi = n1 ^m;
    //残ってる軸で最も下
    ll d = mi & -mi;
    //次はdへ行く
    mi -= d;
    //今行くものも含めて最も低次のもの
    ll e = mi & -mi;
    //移動先
    ll w = s ^d;
    if ((w ^ b) == t) w = s ^ e;
    dfs(s, w, m);
    dfs(w ^ b, t, m);
}

int main() {
    scanf("%d", &n);
    n1 = bn(n);
    ll a, b;
    cin >> a >> b;
    if (bs(a) == bs(b)) dame;
    dfs(a, b, 0);
    puts("YES");
    cout << ans << endl;
    return 0;
}






















Measured memory_bytes: 3704
#include "bits/stdc++.h"
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    for(int i=0;i<n;i++){
        cin >> b.at(i);
    }
    vector<int>c(n);
    for(int i=0;i<n;i++){
        c.at(i) = a.at(i)-b.at(i);
    }
    sort(c.begin(),c.end());
    reverse(c.begin(),c.end());
    int ans =0;
    for(int i=0;i<n;i++){
        if(c.at(i)>=0){
        ans+=c.at(i);
        }
        else{
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)

#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <cmath>
#include <map>
#include <array>
#include <set>
#include <queue>
#include <complex>
#include <iterator>
#include <random>
#include <time.h>
#include <tuple>
#include <functional>
#include <list>
#include <limits.h>
#define mp make_pair
#define ni(x) scanf("%d", &(x))
#define nii(x,y) scanf("%d%d",&(x),&(y))
#define mul(x,y) ((ll)(x)*(y)%mod)
#define mtp make_tuple
#define F(i,n) for(int i = 0; i < (n); i++)
#define FF(i,n) for(int i = 1; i <= (n); i++)
#define FE(i,n) for(int i = 0; i <= (n); i++)

#ifndef __GNUG__
int __builtin_popcount(int n) {
	int x = 0;
	while (n)n -= n&(-n), x++;
	return x;
}
#endif

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int mod = 1000000007;
const int inf = 2012345678;
const ll infl = 9012345678901234567;
const double pi = 3.1415926535897932384626433832795;
//----------------------------------------------------------------------------//

char b[60];

int main() {
#ifndef __GNUG__
	freopen("input.txt", "r", stdin);
#endif
	scanf("%s", b); int n = strlen(b);
	int lf = 15 - n, win = 0;
	F(i, n)if (b[i] == 'o')win++;
	if (win + lf >= 8)puts("YES");
	else puts("NO");
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps DBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, a[1010][1010], b[1010];
bool used[1010];
queue<P> que;
signed main() {
	cin >> n;
	rep(i, n) {
		rep(j, n - 1) {
			cin >> a[i][j];
			a[i][j]--;
		}
	}
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			if (a[i][0] == j && a[j][0] == i)que.push(make_pair(i, j));
		}
	}
	int ans = 1;
	while (!que.empty()) {
		P p = que.front();
		que.pop();
		if (used[p.first] || used[p.second]) {
			memset(used, 0, sizeof(used));
			ans++;
		}
		b[p.first]++; b[p.second]++;
		used[p.first] = true; used[p.second] = true;
		if (b[p.first] < n - 1 && b[a[p.first][b[p.first]]] < n - 1 && a[a[p.first][b[p.first]]][b[a[p.first][b[p.first]]]] == p.first) {
			que.push(make_pair(a[p.first][b[p.first]], p.first));
		}
		if (b[p.second] < n - 1 && b[a[p.second][b[p.second]]] < n - 1 && a[a[p.second][b[p.second]]][b[a[p.second][b[p.second]]]] == p.second) {
			que.push(make_pair(a[p.second][b[p.second]], p.second));
		}
	}
	bool f = true;
	rep(i, n) {
		if (b[i] != n - 1)f = false;
	}
	if (f)cout << ans << endl;
	else cout << -1 << endl;
}

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

typedef long long int ll;

const ll maxN = 1e4 + 11;

int main(){
    cin.sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    map<ll, ll> dp;
    for(ll i=1; i<=100; i++){
        for(ll j=1; j<=100; j++){
            for(ll k=1; k<=100; k++){
                ll q = i*i + j*j + k*k + i*j + j*k + i*k;
                dp[q] += 1;
            }
        }
    }
    for(ll i=1; i<=n; i++){
        cout << dp[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 6076
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=3e5+1e2;
int n;
int B,W;
int sum[maxn];

inline void file() {
	freopen("AGC026F.in","r",stdin);
	freopen("AGC026F.out","w",stdout);
}

inline int read() {
	int x=0,p=1;
	char c=getchar();
	while (!isdigit(c)) { if (c=='-') p=-1; c=getchar();}
	while (isdigit(c)) { x=(x<<1)+(x<<3)+(c-'0'); c=getchar();}
	return x*p;
}

inline bool check(int p) {
	int lst=0;
	for (int i=2;i<=n-1;i+=2)
		if (sum[i-1]-lst>=p) chkmin(lst,sum[i]);
	return sum[n]-lst>=p;
}

inline int calc() {
	int l=-2e9,r=2e9,ans=0;
	while (l+1<r) {
		int mid=(l+r)/2;
		if (check(mid)) chkmax(ans,mid),l=mid;
		else r=mid;
	}
	return ans;
}

int main() {
//	file();
	n=read();
	For (i,1,n) {
		int x=read();
		if (i&1) sum[i]=sum[i-1]+x,B+=x;
		else sum[i]=sum[i-1]-x,W+=x;
	}
	if (n%2==0) {
		printf("%d %d",max(B,W),min(B,W)); return 0;
	}
	int Ans=calc();
	printf("%d %d",W+Ans,B-Ans);
	return 0;
}

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

int main() {
	int N; cin >> N;
	string s; cin >> s;
	int z = 2;
	int b[310000];
	int e = 0, w = 0;
	for (int i = 0; i < N; i++) {
		b[i] = 0;
	}
	for(int i = 0; i < N-1; i++) {
		if (s[i] == 'W') {
			w++;
			b[i + 1] += w;
		}
		else b[i + 1] += w;
		if (s[N-i-1] == 'E') {
			e++;
			b[N-i-2] += e;
		}
		else b[N-i-2] += e;
	}
	sort(b, b + N);
	cout << b[0];
}

Measured memory_bytes: 1796
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
  S = input()
  if S == 'AC':
    ac += 1
  elif S == 'WA':
    wa += 1
  elif S == 'TLE':
    tle += 1
  elif S == 'RE':
    re += 1
print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))

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

#define int long long int
#define double long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define inf LLONG_MAX


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

	int res=inf;
	string s,t;
	cin>>s>>t;
	int n=s.size(),m=t.size();
	for(int i=0;i<n;i++)
	{
		if(i+m>n)
			break;
		int ans=0;
		for(int j=i,k=0;j<i+m;j++,k++)
		{
			if(s[j]!=t[k])
				ans++;
		}
		res=min(res,ans);
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    vector<ll>b(n+1);
    rep(i,n+1){
        ll k=i;
        ll cnt=0;
        while(k>=2){
            cnt+=k/2;
            k/=2;
        }
        b[i]=cnt;
    }
    vector<ll>a(n);
    rep(i,n){
        char s;cin>>s;
        a[i]=s-'0';
    }
    vector<ll>c(n-1);
    vector<ll>st(3);
    rep(i,n-1){
        c[i]=abs(a[i]-a[i+1]);
        st[c[i]]++;
    }
    if(n==2){
        cout<<c[0]<<endl;
        return 0;
    }
    if(st[1]){
        ll ans=0;
        rep(i,n-1){
            if((b[n-2]-b[i]-b[n-i-2])==0&&c[i]==1)ans+=1;
            //cout<<b[n-2]-b[i]-b[n-i-2]<<endl;
            ans%=2;
        }
        cout<<ans<<endl;
    }else{
        ll ans=0;
        rep(i,n-1){
            if((b[n-2]-b[i]-b[n-i-2])==0&&c[i]==2)ans+=1;
            ans%=2;
        }
        ans%=2;
        cout<<ans*2<<endl;
    }
}

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

int a, b;

int main() {
    scanf("%d%d", &a, &b);
    if (a + b == 15)
        putchar('+');
    else if (a * b == 15)
        putchar('*');
    else
        putchar('x');
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long l = scanner.nextLong();
        long[] a = new long[n];
        boolean hasMore = false;
        int keepIndex = 0;
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextLong();
            if (i > 0 && a[i] + a[i - 1] >= l) {
                hasMore = true;
                keepIndex = i - 1;
                break;
            }
        }
        if (!hasMore) {
            System.out.println("Impossible");
            return;
        }
        System.out.println("Possible");
        for (int i = 0; i < keepIndex; i++) {
            System.out.println(i + 1);
        }
        int last = keepIndex + 1;
        for (int i = n - 1; i > last; i--) {
            System.out.println(i);
        }
        System.out.println(last);
    }
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	long long m;
	int v,p;
	cin >> m >> v >> p;
	vector<long long> a(n);
	for(int i=0;i<n;i++) cin >> a[i];
	sort(a.begin(),a.end());
	//for(int i=0;i<n;i++) cout << a[i] << " ";
	//cout << "\n";
	
	int left=0,right=n-1;
	while(left<right){
		int mid=(left+right)/2;
		int ama=v-mid-1;
		if(ama<=0){
			ama=0;
		}
		vector<long long> b=a;
		b[mid]+=m;
		for(int i=0;i<min(p-1,ama);i++){
			b[n-1-i]+=m;
		}
		int last=n-1-min(p-1,ama);
		if(b[n-p]>b[mid]){
			left=mid+1;
			continue;
		}
		ama-=min(p-1,ama);
		/*if(ama>c.size()){
			left=mid+1;
			continue;
		}
		if(ama==c.size()){
			long long mx=c.back()+m;
			if(mx>b[ind]){
				left=mid+1;
				continue;
			}else{
				right=mid;
				continue;
			}
		}else{
			long long sum=0;
			for(int i=0;i<c.size();i++){
				sum+=min(m,b[ind]-c[i]);
			}
			if(sum<(ama*m)){
				left=mid+1;
				continue;
			}else{
				right=mid;
				continue;
			}
		}*/
		
		
		long long ken=ama*m;
		for(int i=mid+1;i<n;i++){
			long long sab=b[mid]-b[i];
			if(sab<=0) break;
			ken-=min(sab,m);
			b[i]+=min(sab,m);
		}
		if(ken>0){
			left=mid+1;
		}else{
			right=mid;
		}
		//cout << mid << " " << ama << " " << ken << "\n";
	}
	//cout << left << " " << right << "\n";
	cout << (n-left) << "\n";
	return 0;
}

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

int main() {
    double n, a[110], sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    double ave = sum / n;
    double mn = 1000;
    int b;
    for (int i = 0; i < n; i++) {
        if (mn > abs(ave - a[i])) {
            mn = abs(ave - a[i]);
            b = i;
        }
    }

    cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>str;
    rep(i,str.length()) if(str[i]=='g') sum++;
    if(str.length()%2) sum--;
    sum-=str.length()/2;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3772
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
    R, G, B, N = readline() |> split |> parseMap

    ans = 0
    for r in 0:div(N, R), g in 0:div(N-R*r, G)
        t = N - R*r - G*g
        t < 0 && continue
        mod(t, B) == 0 && (ans += 1)
    end

    println(ans)
end

main()


Measured memory_bytes: 110468
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define rep(a,n,b) for(int  i=a;i<n;i+=b)
#define rrep(a,n,b) for(int i=n;i>=a;i-=b)
#define iter(obj) for(auto x : obj) 
#define pb(i) push_back(i)
#define ff first
#define ss second
#define pchr(flag) cout<<(flag ? "YES" : "NO")
#define ll long long int
#define input freopen("input.txt","r",stdin)
#define op freopen("output.txt","w",stdout);
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
const int N = 2e5+7;
const int MOD  = 1000000007;
const float PI = 3.1415926535;
//33333333333;
int prime[N];
int arr[N];
void SieveOfEratosthenes(int n) 
{ 
     for (int p=2; p*p<=n; p++) {
        if (prime[p] == 0)  {
            for (int i=p*p; i<=n; i += p) 
                prime[i] = 1; 
        } 
    } 
} 
int main() 
{ 
	// input;
	fastio;
	int n;
	cin>>n;
	string a,b;
	cin>>a>>b;
	rep(0,n,1) {
		cout<<a[i]<<b[i];
	}
 }
 


Measured memory_bytes: 256
# frozen_string_literal: true

k, s = gets.split(' ').map!(&:to_i)

count = 0

loop_range = (0..k)
loop_range.each do |x|
  loop_range.each do |y|
    z = s - x - y
    count += 1 if z >= 0 && z <= k
  end
end

puts count


Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <stack>
#include <queue>
#include <string.h>

#define MAX_N 1000

using namespace std;

char str[100], res[100];

void reverse(char *str, char *res){
	for (int i = 0; i < strlen(str); i++)
	{
		res[i] = str[strlen(str)-i-1];
	}
	res[strlen(str)] = '\0';
}

void dfs(int l, int r, char *res){
	int prel = l;
	char tmp1[100], tmp2[100], count = 0;

	res[0] = '\0';
	if(l + 1 == r){
		res[0] = str[l];
		if(res[0] == '?') res[0] ='A';
		res[1] = '\0';
		return;
	}
	for (int i = l; i < r; )
	{
		if(str[i] == '+' || str[i] == '-' || (str[i] >= 'A' && str[i] <= 'Z') || str[i] == '?'){
			int j = i;
			while(str[j] == '+' || str[j] == '-') j++;
			if(i == l && j == r-1){
				res[0] = str[r-1];
				if(res[0] == '?'){
					res[0] = 'A';
				}else{
					for(int k = l; k < r-1; k++){
						if(str[k] == '+'){
							res[0]++;
							if(res[0] > 'Z'){
								res[0] = 'A';
							}
						}else{
							res[0]--;
							if(res[0] < 'A'){
								res[0] = 'Z';
							}
						}
					}
				}
				res[1] = '\0';
				break;
			}else{
				dfs(i, j+1, tmp1);
				strcat(res, tmp1);
				i = j+1;
			}
		}
		if(str[i] == '['){
			int j, count = 0;
			for (j = i; j < r; j++)
			{
				if(str[j] == '['){
					count++;
				}else if(str[j] == ']'){
					count--;
				}
				if(count == 0) break;
			}
			dfs(i+1, j, tmp1);
			reverse(tmp1, tmp2);
			strcat(res, tmp2);
			i = j+1;
		}
	}
}

int main(){
	while(1){
		cin >> str;
		if(str[0] == '.') break;
		dfs(0, strlen(str), res);
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    in(N);

    ld ans = 0;

    rep(_, N)
    {
        ld x;
        string u;

        in2(x, u);

        if (u == "JPY")
        {
            ans += x;
        }
        else
        {
            ans += 380000.0 * x;
        }
    }

    cout << setprecision(10) << setiosflags(ios::fixed);
    outl(ans);

    return 0;
}

Measured memory_bytes: 3772
N, W = map(int, input().split())
wv = []

for _ in range(N):
    wv.append(tuple(map(int, input().split())))

# dp[i][j] i 番目まで、 重さ j で最大化した価値
# 答え: dp[N][W]
# 初期: dp[0][j] = 0
#       dp[i][0] = 0
#
# dp[i+1][j] = 品物i+1 を使わない場合、 dp[i][j]
#               品物i+1 を使う場合、 dp[i][j-w_{i+1}] + v_{i+1}
# i

memo = {}

def dfs(i, j):
    if (i,j) in memo:
        return memo[(i,j)]

    if i < 0 or j <= 0:
        return 0

    ret = 0
    wi, vi = wv[i]
    if j-wi < 0:
        ret = dfs(i-1, j)
    else:
        ret = max(dfs(i-1, j), dfs(i-1, j-wi) + vi)

    memo[(i,j)] = ret

    return ret

print(dfs(N-1, W))


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

namespace TPBC2019
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split(' ').Select(int.Parse);
            Console.WriteLine(Calc.Result(ab));
        }
        
    }

    public class Calc
    {
        public static int Result(IEnumerable<int> ab)
        {
            var abmax = ab.Max();
            var abmin = ab.Min();
            var diff = abmax - abmin;

            if(diff == 0)
            {
                return abmax * 2;
            }else if (diff > 1)
            {
                return abmax + abmax - 1;
            }
            else
            {
                return abmax + abmin;
            }
        }
    }
}


Measured memory_bytes: 11348
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    // freopen("B.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, k;
    set<int> s;
    cin >> a >> b >> k;
    if (a + k - 1 >= b - k + 1)
    {
        rep(i, a, b + 1)
        {
            printf("%d\n", i);
        }
    }
    else
    {
        rep(i, a, a + k)
        {
            printf("%d\n", i);
        }
        rep(i, b - k + 1, b + 1)
        {
            printf("%d\n", i);
        }
    }

    return 0;
}

Measured memory_bytes: 3656
//レート924の人間が0完☀でした
//その人間が解説ACコードを書いたので
//よろしければお読みください

#include<bits/stdc++.h>
#include<iostream>
using namespace std;
 
using ll = long long;
using st = string;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define sz size()

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st s;
    cin>>s;
  ll k;
    cin>>k;
  ll ans=0;
  ll n=s.sz;
  ll count=1;
  ll head=0;
  ll end=0;
  FOR(i,1,n){
    
    if(s[i-1]==s[i]){
      count++;
    }
    
    else if(i==count){
      head=count;
      count=1;
    }
    
    else{
      ans+=count/2*k;
      count=1;
    }
    
    if(i==n-1){
      end=count;
    }  
  }

  if(count==n){
    ans=k*n/2;
  }
  
  else if(s[0]==s[n-1]){
    ans+=(head+end)/2*(k-1);
    ans+=head/2+end/2;
  }
  
  else{
    ans+=head/2*k;
    ans+=end/2*k;
  }
  
  cout<<ans<<endl;
  
}

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

struct Edge {
  int to, w;
  Edge(int t, int w) :to(t), w(w) {}
};

struct Tree {
  int N;
  vector<vector<Edge>> edges;

  Tree(int N) :N(N), edges(N) {}

  void addEdge(int a, int b) { addEdge(a, b, 1); }
  void addEdge(int a, int b, int w) { 
    edges[a].emplace_back(b, w);
    edges[b].emplace_back(a, w);
  }

  vector<int> parent, dep;
  void setParent(int n) {
    parent = vector<int>(N, -2);
    dep = vector<int>(N, 0);
    queue<int> q;
    parent[n] = -1;
    q.push(n);
    while (!q.empty()) {
      int v = q.front(); q.pop();
      for (Edge e : edges[v]) {
        if (parent[e.to] != -2) continue;
        parent[e.to] = v;
        dep[e.to] = dep[v] + 1;
        q.push(e.to);
      }
    }
  }
};

int main(){
  int N; cin >> N;
  Tree G(N);
  rep(i, N - 1) {
    int x, y; cin >> x >> y;
    x--; y--;
    G.addEdge(x, y);
  }
  G.setParent(0);
  vector<int> cnt(2);
  rep(i, N) cnt[G.dep[i] % 2]++;
  int maxcnt = 0;
  int max_d;
  rep(i, 2) {
    if (maxcnt < cnt[i]) {
      maxcnt = cnt[i];
      max_d = i;
    }
  }
  vector<int> now = {3,1,2};
  if (N - maxcnt < (N + 1)/3 ) {
    rep(i, N) {
      if (G.dep[i] % 2 == max_d) {
        if (now[1] <= N) {
          cout << now[1] << endl;
          now[1] += 3;
        } else if (now[2] <= N) {
          cout << now[2] << endl;
          now[2] += 3;
        } else {
          cout << now[0] << endl;
          now[0] += 3;
        }
      } else {
        cout << now[0] << endl;
        now[0] += 3;
      }
    }
  } else {
    rep(i, N) {
      if (G.dep[i] % 2 == max_d) {
        if (now[1] <= N) {
          cout << now[1] << endl;
          now[1] += 3;
        } else {
          cout << now[0] << endl;
          now[0] += 3;
        }
      } else {
        if (now[2] <= N) {
          cout << now[2] << endl;
          now[2] += 3;
        } else {
          cout << now[0] << endl;
          now[0] += 3;
        }
      }
    }
  }
} 

Measured memory_bytes: 16104
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
    int che[3]={3,5,7};
    ll n;
    cin >> n;
    queue<ll>que;
    que.push(3);
    que.push(5);
    que.push(7);
    ll ans = 0;
    while(!que.empty()){
        ll now = que.front();
        que.pop();
        for(int i=0;i<3;i++){
            ll next = now*10+che[i];
            if(n<next)continue;
            que.push(next);
            vector<bool>w(3,false);
            while(next>0){
                ll keta = next%10;
                if(keta==3)w.at(0)=true;
                else if(keta==5)w.at(1)=true;
                else w.at(2)=true;
                next/=10;
            }
            if(w.at(0)&&w.at(1)&&w.at(2))ans++;
        }
    }
    cout << ans << endl;
}
    



Measured memory_bytes: 384
#include<cstdio>
using namespace std;
typedef long long ll;
const ll mode=1e9+7;
ll n,k,ans,l,r;
int main(){
	scanf("%lld%lld",&n,&k);
	for(ll i=k;i<=n+1;i++){
		l=(i*(i-1))/2;
		r=(2*n-i+1)*i/2;
		ans=(ans+r-l+1)%mode;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1732
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int x = in.nextInt();
			int a = in.nextInt();
			int b = in.nextInt();
			if(Math.abs(x - a) < Math.abs(x - b)) {
				out.println("A");
			} else {
				out.println("B");
			}
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

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

#define ll       long long
#define LL       long long
#define ull      unsigned ll
#define pii      pair<int, int>
#define pll      pair<ll, ll>
#define mp       make_pair
#define ff       first
#define ss       second
#define sz(s)    (int) s.size()
#define all(s)   s.begin(), s.end()

template<typename T> inline void smin(T &a, T b) {
    a = a < b ? a : b;
}
template<typename T> inline void smax(T &a, T b) {
    a = a > b ? a : b;
}

template<typename T> inline void Int(T &n) {
    n = 0;
    int f = 1;
    register int ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n *= f;
}
template<typename T, typename TT> inline void Int(T &n, TT &m) {
    Int(n), Int(m);
}
template<typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) {
    Int(n), Int(m, l);
}

#define error(args...) { string _s = #args; replace(all(_s), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {
    cout << endl;
}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}

const int mod = (int) 1e9 + 7;

int add(int a, int b) {
    a += b;
    if(a >= mod) a -= mod;
    return a;
}
int sub(int a, int b) {
    a -= b;
    if(a <= 0) a += mod;
    return a;
}
int mul(int a, int b) {
    return (ll) a * b % mod;
}

const int inf = (int) 1e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int   N = (int) 3e3 + 5;

string s[N];
int dp[N][N];


int solve() {
    int n, m; Int(n, m);
    dp[0][0] = 1;
    for(int i = 0; i < n; i++) {
        cin >> s[i];
        for(int j = 0; j < m; j++) {
            if(i > 0 && s[i][j] == '.' && s[i - 1][j] == '.') dp[i][j] = add(dp[i][j], dp[i - 1][j]);
            if(j > 0 && s[i][j] == '.' && s[i][j - 1] == '.') dp[i][j] = add(dp[i][j], dp[i][j - 1]);
        }
    }
    printf("%d\n", dp[n - 1][m - 1]);
    return 0;
}

int main() {
    int test = 1, tc = 0;
    //Int(test);
    while(test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}




Measured memory_bytes: 12928
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	int num[200001] = {};
	int sum[200001] = {};
	int covered[200001] = {};
	for (int i = 1; i <= N; i++) {
		cin >> num[i];
		sum[num[i]]++;
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= sum[i] && i - j >= 0; j++) {
			covered[i - j]++;
		}
	}
	for (int i = 0; i < N; i++)if (!covered[i])ans++;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		int box = num[a];
		if (box - sum[box] >= 0) {
			covered[box - sum[box]]--;
			if (covered[box - sum[box]] == 0)ans++;
		}
		sum[box]--;
		sum[b]++;
		if (b - sum[b] >= 0) {
			covered[b - sum[b]]++;
			if (covered[b - sum[b]] == 1)ans--;
		}
		num[a] = b;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int a, p;
    cin>>a>>p;
    p += 3 * a;
    cout<<p/2;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <vector <ll>> matrix;

#define endl "\n"
#define mt make_tuple
#define mp make_pair

template <typename T1, typename T2>
bool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}
template <typename T1, typename T2> 
bool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}
template <typename T>
T sqr(T a) {return a * a;}

const int mod = 1e9 + 7;
template <typename T1, typename T2>
void modadd(T1 &a, const T2 &b) {
    a += b;
    
    if (a >= mod)
        a -= mod;
}

mt19937 rng(20010709);
const int INF = 1000000001;
const int N = 100005;

int n, m, used[100005];
int down[N], up[N];
vector <int> e[N];

void dfsDown(int v);
void dfsUp(int v);

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

	cin >> n >> m;

	for (int i = 1; i < n; i++) {
		int x, y;
		cin >> x >> y;
		e[x].push_back(y);
		e[y].push_back(x);
	}

    dfsDown(1);
    fill(used, used + N, 0);
    up[1] = 1;
    dfsUp(1);

    for (int i = 1; i <= n; i++)
        cout << down[i] * 1LL * up[i] % m << endl;

    cout << endl << endl;

    return 0;
}

void dfsDown(int v) {
	used[v] = 1;
    down[v] = 1;

	for (auto it : e[v]) {
		if (!used[it]) {
			dfsDown(it);
            down[v] = down[v] * 1LL *  (down[it] + 1) % m;
		}
	}
}

void dfsUp(int v) {
    vector <int> pref(e[v].size() + 2), suff(e[v].size() + 2);
    pref[0] = up[v];
    suff[suff.size() - 1] = 1;
    used[v] = 1;

    for (int i = 0; i < e[v].size(); i++)
        pref[i + 1] = pref[i] * 1LL * (used[e[v][i]] ? 1 : (down[e[v][i]] + 1)) % m;

    for (int i = e[v].size() - 1; i > -1; i--)
        suff[i + 1] = suff[i + 2] * 1LL * (used[e[v][i]] ? 1 : (down[e[v][i]] + 1)) % m;

    for (int i = 0; i < e[v].size(); i++) {
        if (!used[e[v][i]]) {
            up[e[v][i]] = (1 + pref[i] * 1LL * suff[i + 2]) % m;
            dfsUp(e[v][i]);
        }
    }
}

Measured memory_bytes: 15744
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}
	void doIt() {
		solveB();
	}
	void solveA() {
		int N = sc.nextInt();
		String ans = "Christmas";
		for(int i = N; i < 25; i++) {
			ans += " Eve";
		}
		System.out.println(ans);
	}
	void solveB() {
		int N = sc.nextInt();
		int [] p = new int[N];
		for(int i = 0; i < N; i++) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		int ans = 0;
		for(int i = 0; i < N-1; i++) {
			ans +=p[i];
		}
		ans += p[N-1]/2;
		System.out.println(ans);
		
	}
}


Measured memory_bytes: 23252
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      
      //入力
      String S = sc.next();
      int N = S.length();
      
      char[] a =S.toCharArray();
      int count =0;
      
      //違う文字の数を探す
      for(int i =0; i<N/2; i++){
       if(a[i]!=a[N-1-i]){
         count++;
         }
      }
      //出力
       System.out.print(count);
    }
}

Measured memory_bytes: 21844
import java.io.PrintWriter;
import java.util.*;

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

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[M];
		int[] b = new int[M];

		for(int i=0; i<M; i++) {
			a[i] = sc.nextInt()-1;
			b[i] = sc.nextInt()-1;
		}

		int MAXD = 10;
		int[][] dp = new int[N][MAXD+1];
		
		int Q = sc.nextInt();
		int[] c = new int[Q+1];
		for(int i=0; i<Q; i++) {
			int v = sc.nextInt()-1;
			int d = sc.nextInt();
			c[i+1] = sc.nextInt();
			dp[v][d] = Math.max(dp[v][d], i+1);
		}
		
		for(int i=MAXD; i>0; i--) {
			for(int j=0; j<M; j++) {
				dp[a[j]][i-1] = Math.max(dp[a[j]][i-1], dp[b[j]][i]);
				dp[b[j]][i-1] = Math.max(dp[b[j]][i-1], dp[a[j]][i]);
			}
			for(int j=0; j<N; j++) {
				dp[j][i-1] = Math.max(dp[j][i-1], dp[j][i]);
			}
		}
		
		for(int i=0; i<N; i++)
			pw.println(c[dp[i][0]]);
		
		sc.close();
		pw.close();
	}
}


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

struct P
{
    int x,y;

    bool operator<(const P &a)const{
        if(x!=a.x) return x>a.x;
        return y<a.y;
    }
};


vector<int> v[11111];
vector<int> v1;
//bitset<4001000> b;
int i,n,m,k,a,d,b,c;
int e;
long long o[1211112];
int l[11111];
int j[11131];

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
int px[10]={-1,1,1,-1,1,1,-1,-1},py[10]={1,1,-1,-1,1,-1,1,-1};
long long mod=1000003,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<int> se[33],s1;

//priority_queue<P> q[2];
queue<int> q;
string r,r1;

//char r1[110],r[331];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int> p;
//v.resize(unique(v.begin(),v.end())-v.begin());

bool as(P a,P b)
{
    //if(a.x!=b.x)
    return a.x<b.x;

}


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng();
long long f(long long x,long long y)
{
    long long p=1;
    for(;y;y/=2,x*=x,x%=mod)
        if(y%2) p*=x,p%=mod;
    return p;
}

int main()
{
   scanf("%d",&a);
   o[0]=1;
   for(int t=1;t<=mod;t++)
    o[t]=o[t-1]*t%mod;
   for(int t=1;t<=a;t++)
   {
       scanf("%d %d %d",&b,&n,&m);
       if(n==0)
       {
           printf("%lld\n",f(b,m)%mod);
           goto qwe;
       }
       c=f(n,mod-2)*b%mod;
       if(c==0||(c+m-1)>=mod) puts("0");
       else
       {
           printf("%lld\n",o[m+c-1]*f(o[c-1],mod-2)%mod*f(n,m)%mod);
       }
       qwe:;
   }
}




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

int N, M, Q, v[100001], d[100001], c[100001];
vector<int> E[100001];
int dp[11][100001];

void dfs(int v, int d, int c) {
  if(dp[d][v] == -1) dp[d][v] = c;
  if(d == 0) return;
  if(dp[d - 1][v] == -1) dfs(v, d - 1, c);
  for(int i = 0; i < E[v].size(); i++) if(dp[d - 1][E[v][i]] == -1) dfs(E[v][i], d - 1, c);
}

int main(void) {
  cin >> N >> M;
  REP(i, 1, M) {
    int a, b; cin >> a >> b;
    E[a].push_back(b);
    E[b].push_back(a);
  }
  cin >> Q;
  REP(i, 1, Q) cin >> v[i] >> d[i] >> c[i];

  REP(i, 0, 10) REP(j, 1, N) dp[i][j] = -1;
  for(int i = Q; i > 0; i--) dfs(v[i], d[i], c[i]);

  REP(i, 1, N) cout << (dp[0][i] == -1 ? 0 : dp[0][i]) << endl;

  return 0;
}


Measured memory_bytes: 12800