akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main() {
	long long int n, m, ans;
	cin >> n >> m;
	if (n == 1 && m==1) {
		ans = 1;
	}
	else if (n == 2 || m == 2) {
		ans = 0;
	}
	else if (n == 1) {
		ans = m - 2;
	}
	else if (m == 1) {
		ans = n - 2;
	}
	else {
		ans = (n - 2)*(m - 2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>

using namespace std;

const int MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep2(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


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

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


int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll ans = B - A + 1;
    ans -= (B / C - (A - 1) / C);
    ans -= (B / D - (A - 1) / D);
    ans += (B / lcm(C, D) - (A - 1) / lcm(C, D));
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static class Tree {
		public class Edge {
			int to, rev;

			public Edge(int to, int rev) {
				this.to = to;
				this.rev = rev;
			}
		}
		
		int V;
		ArrayList<ArrayList<Edge>> G;
		int root;
		int[] p;
		
		public Tree(int[] a, int[] b) {
			this.V = a.length+1;
			p = new int[V];
			distance = new int[V];
			
			G = new ArrayList<ArrayList<Edge>>();
			for(int i=0; i<V; i++) {
				G.add(new ArrayList<Edge>());
			}
			
			for(int i=0; i<V-1; i++) {
				G.get(a[i]).add(new Edge(b[i], G.get(b[i]).size()));
				G.get(b[i]).add(new Edge(a[i], G.get(a[i]).size()-1));
			}
			setRoot(0);
		}
		
		public void setRoot(int root) {
			this.root = root;
			distance[root] = 0;
			setRoot(root, -1);
		}
		public void setRoot(int cur, int parent) {
			p[cur] = parent;
			for(int i=0; i<G.get(cur).size(); i++) {
				int next = G.get(cur).get(i).to;
				if(next!=parent) {
					distance[next] = distance[cur]+1;
					setRoot(next, cur);
				}
			}
		}

		int[] distance;
		int getDiameter() {
			int f1 = getMostFar(root);
			int f2 = getMostFar(f1);
			return getDistance(f1, f2);
		}
		int getMostFar(int p) {
			setRoot(p);
			int far = 0;
			for(int i=1; i<V; i++) {
				if(distance[i]>distance[far])
					far = i;
			}
			return far;
		}
		
		int getDistance(int p1, int p2) {
			setRoot(p1);
			return distance[p2];
		}
	}
	

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N-1];
		int[] b = new int[N-1];
		for(int i=0; i<N-1; i++) {
			a[i] = sc.nextInt()-1;
			b[i] = sc.nextInt()-1;
		}
		
		Tree tree = new Tree(a, b);
		System.out.println((tree.getDiameter()-1)%3==0 ? "Second" : "First");
		sc.close();
	}
}


Measured memory_bytes: 134056
n     = gets.to_i # 山の数（奇数)
rains = gets.split.map(&:to_i) # 溜まった雨の量
# nが奇数であるとき　x = A5 - A4 + A3 - A2 + A1 - xが成り立つ。
# 移項すると 2x = A5 - A4 + A3 - A2 + A1
# xを求められたらあとは数珠つなぎに各点の降水量を求められる。
x2    = 0
(0 .. n - 1).each { |i| i.even? ? x2 += rains[i] : x2 -= rains[i] }
ans = Array.new(n)
ans[0] = x2 / 2
(0...n-1).each { |i| ans[i+1] = rains[i] - ans[i] }
ans.map! { |i| i *= 2}
puts ans.join(' ')

Measured memory_bytes: 14084
import sys
from functools import lru_cache


@lru_cache(maxsize=None)
def solve(n):
    ans = 0
    for i in range(1, 10*10):
        if n - i >= 0:
            ans += 1
            n -= i
        else:
            return(ans)


n = int(input())


if n == 1:
    print(0)
    sys.exit()


pf = {}
m = n
for i in range(2, int(m**0.5)+1):
    while m % i == 0:
        pf[i] = pf.get(i, 0)+1
        m //= i
if m > 1:
    pf[m] = 1

ans = list(pf.values())
ans = sum([solve(x) for x in ans])

print(ans)

Measured memory_bytes: 9876
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

n, m, l = map(int, input().split())
abc = []
for _ in range(m):
    abc.append(map(int, input().split()))
q = int(input())
st = []
for _ in range(q):
    st.append(map(int, input().split()))

adjacency_matrix = np.zeros((n, n))
for a, b, c in abc:
    adjacency_matrix[a-1, b-1] = c
    adjacency_matrix[b-1, a-1] = c

shotest = dijkstra(adjacency_matrix)
fuel_once = np.where(shotest <= l, 1, 0)
fuel_times = dijkstra(fuel_once-np.eye(n))

for s, t in st:
    ans = fuel_times[s-1][t-1]
    if np.isinf(ans):
        print(-1)
    else:
        print(int(ans) - 1)


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

//Function Macros:
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main()
{
    string S;
    cin >> S;
    rep(i, S.size())
    {
        if (i % 2 == 0 && S[i] == 'L')
        {
            cout << "No" << endl;
            return 0;
        }
        else if (i % 2 == 1 && S[i] == 'R')
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}
//===========================================

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

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;

  ll ans = 0;
  string t = "";
  for(int i = 0;i < s.size();i++){
    if(i+1 < s.size() && s[i] == 'B' && s[i+1] == 'C'){
      t += '*';
      i++;
    }
    else t += s[i];
  }
  
  ll cnt_a = 0;
  for(int i = 0;i < t.size();i++){
    if(t[i] == 'A'){
      cnt_a++;
    }
    else if(t[i] == '*'){
      ans += cnt_a;
    }
    else cnt_a = 0;
  }

  cout << ans << endl;
}

Measured memory_bytes: 776
#include <stdio.h>

int main(void) { 
	int a, b, d, r;
	double f;
	scanf("%d %d", &a, &b);
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	printf("%d %d %f\n", d, r, f);
	return 0;
}


Measured memory_bytes: 2044
#include <iostream>
using namespace std;
int main(){
	int cnt=0;
	string a;
	cin>>a;
	if(a.size()==1){
		cout<<0;
	return 0;
	}
	for(int i=0; i<a.size()/2; i++){
		if(a[i]!=a[a.size()-i-1]){
			cnt++;
		}
	}
	cout<<cnt;
}

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

typedef long long ll;

int main(){
  int n, x; cin >> n >> x;
  ll a[n]; for(int i=0; i<n; i++) cin >> a[i];

  ll ans=0;
  for(int i=1; i<n; i++){
    ll sum = a[i-1]+a[i];
    if(sum > x){
      a[i] -= min(a[i], sum-x);
      ans += sum-x;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    vs st(3);
    REP(i,3){
        cin>>st[i];
    }
    queue<int> q[3];
    REP(i,3){
        REP(j,st[i].size()){
            q[i].push(st[i][j]-'a');
        }
    }
    int now=0;
    while(1){
        if(q[now].size()==0){
            cout<<(char)('A'+now)<<endl;
            return 0;
        }
        int t=q[now].front();q[now].pop();
        now=t;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    ll n,k;
    cin>>n>>k;
    ll i,j;
    ll res=0;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;i<k;i++)
    {
        res+=a[i];
    }
    cout<<res<<"\n";
}
 

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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);

	int d,r;
	double f;

	d=a/b;
	r=a%b;
	f=(double)a/(double)b;

	printf("%d %d %f\n",d,r,f);
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <math.h>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstdlib>
#include <unordered_map>
#include <numeric>
#include <functional>
#include <limits.h>
#include <utility>
#include <stack>

using namespace std;

#define fs first
#define sc second

typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    int N, M, x[101000];
    P v[101000];
    cin >> N >> M;
    fill(x, x+101000, 0);
    for(int i = 0; i < N; i++){
        int y;  cin >> y;
        x[y]++;
    }

    for(int i = 0; i < 101000; i++){
        v[i] = P(0, 0);
    }
    for(int i = 0; i < 101000; i++){
        v[i % M].fs += x[i];
        v[i % M].sc += x[i] / 2;
    }

    bool check[101000];
    fill(check, check+101000, false);

    int res = 0;
    for(int i = 0; i < M; i++){
        if(check[i]){
            continue;
        }
        int opponent = (M - i) % M;
        if(opponent == i){
            res += v[i].fs / 2;
        }
        else{
            res += min(v[i].fs, v[opponent].fs);
            int maxIndex = v[i].fs > v[opponent].fs ? i : opponent;
            int minIndex = v[i].fs > v[opponent].fs ? opponent : i;
            res += min(v[maxIndex].sc, (v[maxIndex].fs - v[minIndex].fs) / 2);
        }
        check[i] = check[opponent] = true;
    }

    cout << res << endl;



    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 2e5+2;
unsigned long long nums[MAXN];
 
const long long MAXL = 1e18;
 
//判断a*b是否超过1e18
bool overflow(unsigned long long a, unsigned long long b) {
    //判断是否越界
    if (ULLONG_MAX / a < b) {
        return true;
    }
    //判断是否超过1e18
    unsigned long long ans = a*b;
    if (ans>MAXL) {
        return true;
    }
    return false;
}
 
int main() {
    int n;
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        scanf("%llu", &nums[i]);
        if (0==nums[i]) {
            printf("0\n");
            return 0;
        }
    }
 
    long long ans=1;
    for (int i=0; i<n; i++) {
        if (true == overflow(ans, nums[i])) {
            printf("-1\n");
            return 0;
        }
        ans *= nums[i];
    }// 
    printf("%llu", ans); 
    return 0;
}

Measured memory_bytes: 4504
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int s, w;
    cin >> s >> w;
    if(w >= s) output("unsafe");
    else output("safe");
    
    return 0;
}


Measured memory_bytes: 3652
import sys

def isPrime(n):
    for i in range(2,int(n**.5+1)):
        if n%i==0:
            return False
    return True

for n in sys.stdin:
    n=int(n)
    s=n-1
    while not isPrime(s):
        s-=1
    b=n+1
    while not isPrime(b):
        b+=1
    print(*[s,b])


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

int main(){
  int n,countR,countB;
  cin >> n;
  countR = 0; countB = 0;
  string s;
  cin >> s;
  
  for(int i = 0;i < n;i++){
	if(s.at(i) == 'R'){
      countR++;
    }else{
      countB++;
    }
  }
  if(countR > countB){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

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

int main() {
	double A, B, X, PI = 3.1415926535;
	cin >> A >> B >> X;
	X /= A;
	if (A * B / 2 > X) {
		double C = X * 2 / B;
		printf("%.12lf\n", asin(B / sqrt(B * B + C * C)) * 180 / PI);
	}
	else {
		X = A * B - X;
		double C = X * 2 / A;
		printf("%.12lf\n", asin(C / sqrt(A * A + C * C)) * 180 / PI);
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n, i, count = 0, real_count = 0;
    long long int data, prev = 0;

    scanf("%d", &n);

    for(i = 0; i<n; i++)
    {
        scanf("%d", &data);

        if(data <= prev)
            count++;

        if(count > real_count)
            real_count = count;

        if(data > prev)
            count = 0;

        prev = data;
    }

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

    return 0;
}


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

using ll=long long;



void solve(){
    int a,b;
    cin>>a>>b;
    if(a%3==0||b%3==0||(a+b)%3==0){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int x,y,z,n,m,s,t,f[300010],sta,stb,goc,god;
vector<int>v[300010];
void bfs(){
    fill(f,f+300010,INF);
    f[sta]=f[stb]=0;
    queue<int>q;
    q.push(sta);q.push(stb);
    while(!q.empty()){
        int p=q.front();
        q.pop();
        for(int e:v[p]){
            if(f[e]>f[p]+1){
                f[e]=f[p]+1;
                q.push(e);
            }
        }
    }

}
signed main(){
    cin>>x>>y>>z>>n>>m>>s>>t;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        b+=100000;
        if(i+1==s)sta=a,stb=b;
        v[a].pb(b);
        v[b].pb(a);
    }
    rep(i,m){
        int c,d;
        cin>>c>>d;
        c+=100000,d+=200000;
        if(i+1==t)goc=c,god=d;
        v[c].pb(d);
        v[d].pb(c);
    }
    bfs();
    int ans=min(f[goc],f[god]);
    if(ans==INF)puts("-1");
    else cout<<ans+1<<endl;
    return 0;
}



Measured memory_bytes: 21688
<?php
$n = intval(fgets(STDIN));

$l[0] = 2;
$l[1] = 1;
if($n == 0){
    echo 2;
}elseif($n == 1){
    echo 1;
}else{
    for($i = 0; $i <= $n - 2; $i++){
        $l[$i + 2] = $l[$i] + $l[$i+1];
    }
    echo $l[$n];
}


Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,a[101],sum=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if((i+1)%2!=0&&a[i]%2!=0)
		sum++;
	}
	cout<<sum;
	return 0;
}

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

int main() {
  vector<int> vec(3);
  cin >> vec[0] >> vec[1] >> vec[2];
  
  sort(vec.begin(), vec.end());
  
  if(vec[0]==5&&vec[1]==5&&vec[2]==7){
    cout << "YES" << endl;
  }
  
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#define ll long long

using namespace std;

const int mod=1e9+7;
int n,m;
ll dp[52][52][2660]={0};

int main()
{
    int i,j,k;
    cin>>n>>m;
    if(m%2)
    {
        puts("0");
        return 0;
    }
    dp[0][0][0]=1;
    dp[0][1][1]=1;
    for(i=0;i<n;i++)
        for(j=0;j<i+1;j++)
            for(k=0;k<m+1;k++)
            {
                ll now=dp[i][j][k];
                dp[i+1][j+1][k+j+1]=(dp[i+1][j+1][k+j+1]+now)%mod;
                dp[i+1][j][k+j]=(dp[i+1][j][k+j]+now)%mod;
                if(j>0)
                    dp[i+1][j-1][k+j-1]=(dp[i+1][j-1][k+j-1]+now*j%mod*j%mod)%mod;
                dp[i+1][j][k+j]=(dp[i+1][j][k+j]+now*j%mod*2)%mod;
            }
    printf("%lld\n",dp[n][0][m/2]%mod);
    /*for(i=0;i<=m;i++)
        printf("%lld ",dp[n-1][0][i]);
    puts("");
    for(i=0;i<=m;i++)
        printf("%lld ",dp[n][0][i]);
    puts("");*/
    return 0;
}


Measured memory_bytes: 53504
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#define ll long long
#define rei register int
#define bl putchar(' ')
#define ed putchar('\n')
#define Min(a,b) ((a)<(b)?(a):(b))
#define Max(a,b) ((a)>(b)?(a):(b))
#define Mabs(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define test std::cout<<"this:"
#define inf 0x7f7f7f7f
#define dinf 0x3f3f3f3f
#define llinf 0x7f7f7f7f7f7f7f7f
#define lldinf 0x3f3f3f3f3f3f3f3f
#define pai acos(-1)
#define inv inline void
#define read2(a,b) read(a),read(b)
#define read3(a,b,c) read(a),read(b),read(c)
#define read4(a,b,c,d) read(a),read(b),read(c),read(d)
template <typename QvQ>inv read(QvQ &x)
{
    x=0;int f=1;
    char c=getchar();
    for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
    for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
    x=x*f;
}
template <typename QvQ>inv write(QvQ x)
{
    if(x<0) x=-x,putchar('-');
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
using namespace std;
#define MAXN 100005
#define int ll
int n,a[MAXN],b[MAXN];
signed main()
{
	read(n);
	for(rei i=1;i<=n;++i) read(a[i]);read(a[n+1]);
	for(rei i=1;i<=n;++i) read(b[i]);
	ll ans=0;
	for(rei i=1;i<=n;++i)
	{
		if(b[i]>=a[i])
		{
			ans+=a[i];
			b[i]-=a[i];
			a[i]=0;
		}
		else
		{
			ans+=b[i];
			a[i]-=b[i];
			b[i]=0;
		}
		if(b[i]>=a[i+1])
		{
			ans+=a[i+1];
			b[i]-=a[i+1];
			a[i+1]=0;
		}
		else
		{
			ans+=b[i];
			a[i+1]-=b[i];
			b[i]=0;
		}
	}
	write(ans);
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

ll ucl(ll a,ll b){
    ll r;
    r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main(){
    int n;
    cin >> n;
    vector<int> v(n+1);
    for(int i=1; i<=n; i++){
        cin >> v[i];
        //cout << v[i] << endl;
    }
    ll x,y;
    x=(ll)v[1];
    for(int i=2; i<=n; i++){
        y=(ll)v[i];
        x=x*y/ucl(x,y);
      // cout << x << endl;
    }
    cout << x << endl;
    return 0;



}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

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

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    ll ans = min(A+B+1, C) + B;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//ll _(){
//    int n,x;
//    cin >> n >> x;
//    vi arr(n);
//    cin >> arr;
//    ll ans = 0;
//    ll t0 = max(0,arr[0]-x);
//    arr[0] -= t0;
//    ans += t0;
//    for(int i = 1; i < n; ++i){
//        ll ti = max(0,arr[i]+arr[i-1]-x);
//        arr[i] -= ti;
//        ans += ti;
//    }
//    return ans;
//
//}
//
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<int> vi;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
ll _(){
    int n,x;
    cin >> n >> x;
    vi arr(n);
    cin >> arr;
    ll ans = 0;
    ll t0 = max(0,arr[0]-x);
    arr[0] -= t0;
    ans += t0;
    for(int i = 1; i < n; ++i){
        ll ti = max(0,arr[i]+arr[i-1]-x);
        arr[i] -= ti;
        ans += ti;
    }
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


Measured memory_bytes: 640
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=2e9,MOD=1e9+7,MAX=1e4+1;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS;
    int n,k,res=0;
    cin>>n>>k;
    int a[n];
    lp(i,0,n)
        cin>>a[i];
    sort(a,a+n);
    lp(i,0,k)
        res+=a[i];
    cout<<res;
}

Measured memory_bytes: 3596
/******************************
 *                  _
 *  _|_ o._ o._  __|_| _. _|_
 * _>| ||| ||| |(_|| |(_|_>| |
 *               _|
 * @author Amirul islam
 * LCS Problem (DP sol)
 ******************************/

#include <cstdio>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stack>
#include <list>
#include <iostream>
#include <assert.h>

#define mem(x,y) memset(x,y,sizeof(x))
#define CLEAR(x) memset(x,0,sizeof(x))

#define pb push_back
#define Sort(v) sort(v.begin(),v.end())
#define _sort(s, n) sort(s, s+n)
#define sqr(x) ((x)*(x))

#define le 50001
#define ERR 1e-9
#define pi (2*acos(0))
#define PI 3.141592653589793

#define scanint(a) scanf("%d",&a)
#define scanLLD(a) scanf("%lld",&a)

typedef unsigned long long ll;
using namespace std;

/**********************End*******************/

const int MXN = 3005;
string s1, s2;
int cost[MXN][MXN], path[MXN][MXN], lcs[MXN];
int t, l1, l2, lcs_len;

inline void LCS_LENGTH() {
    for (int i = 1; i <= l1; cost[i][0] = 0, i++);
    for (int j = 1; j <= l2; cost[0][j] = 0, j++);

    for (int i = 1; i <= l1; i++) {
        for (int j = 1; j <= l2; j++) {
            if (s1[i-1] == s2[j-1]) {
                cost[i][j] = cost[i-1][j-1] + 1;
                path[i][j] = 1;
            }
            else if (cost[i-1][j] >= cost[i][j-1]) {
                cost[i][j] = cost[i-1][j];
                path[i][j] = 2;
            }
            else {
                cost[i][j] = cost[i][j-1];
                path[i][j] = 3;
            }
        }
    }
    lcs_len = cost[l1][l2];
}

inline void LCS() {
    int i = l1, j = l2, k = lcs_len-1;
    while (k >= 0) {
        if (path[i][j] == 1) {
            lcs[k] = s1[i-1];
            i--; j--; k--;
        }
        else if (path[i][j] == 2) i--;
        else if (path[i][j] == 3) j--;
    }
}

inline void LCS_PRINT() {
    if (lcs_len <= 0) cout << " ";
    else
        for (int i = 0; i < lcs_len; i++)
            cout << (char) lcs[i];
    cout << endl;
}

int main() {
    cin >> s1 >> s2;
    l1 = s1.length(); l2 = s2.length();
    LCS_LENGTH();
    LCS();
    LCS_PRINT();
}


Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <list>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> sum(N);
    for (int i = 0; i < N; i++)
    {
        int l, r;
        cin >> l >> r;
        sum[i] = r - l + 1;
    }
    cout << accumulate(sum.begin(), sum.end(), 0);

    return 0;
}

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

typedef pair<long long, long long> pll;

int main() {
	auto quadrant = [] (const pll& p) -> int {
		if (p.first >  0 && p.second >= 0) return 1;
		if (p.first <= 0 && p.second >  0) return 2;
		if (p.first <  0 && p.second <= 0) return 3;
		if (p.first >= 0 && p.second <  0) return 4;
		return 0;
	};
	int N;
	cin >> N;
	vector<pll> vectors(N);
	for (auto& vec : vectors) cin >> vec.first >> vec.second;
	sort(vectors.begin(), vectors.end(), [&] (const pll& a, const pll& b) {
		return quadrant(a) == quadrant(b) ? a.first * b.second - b.first * a.second > 0 : quadrant(a) < quadrant(b);
	});
	vector<long long> X(N), Y(N);
	for (int i = 0; i != N; ++i) X[i] = vectors[i].first, Y[i] = vectors[i].second;
	long long allx = accumulate(X.begin(), X.end(), 0LL), ally = accumulate(Y.begin(), Y.end(), 0LL);
	double res = hypot(allx, ally);
	for (int i = 0; i != N; ++i) for (int j = N; j != i; --j) {
		long long x = accumulate(X.begin() + i, X.begin() + j, 0LL);
		long long y = accumulate(Y.begin() + i, Y.begin() + j, 0LL);
		res = max(res, max(hypot(x, y), hypot(allx - x, ally - y)));
	}
	cout << fixed << setprecision(11) << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int a[5], b[5], sum=0, m=0;
    for(int i=0; i<5; i++) {
        cin >> a[i];
        if(a[i]%10==0) b[i] = a[i];
        else b[i] = a[i] + 10 - a[i]%10;
        sum += b[i];
        m = max(m, b[i]-a[i]);
    }
    cout << sum - m << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>

using namespace std;
int n;
string s;
int r, w;
int min_cnt = 1e9;

int main() {
    cin >> n >> s;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == 'R') {
            r++;
        }
    }

    min_cnt = r;
    // r : Red -> White
    // w : White -> Red
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == 'R') {
            r--;
        } else if (s[i] == 'W') {
            w++;
        }
        min_cnt = min(min_cnt, max(r, w));
    }
    printf("%d\n", min_cnt);
    return 0;
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int a,b,c,d;
  bool ok = false;
  cin >> a >> b >> c >> d;
  if(abs(a-b) <= d){
    if(abs(b-c) <= d){
      ok = true;
    }
  }
  else if(abs(a-c) <= d){
    ok = true;
  }

  if(ok == true){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int e[100],a,b,c;
	scanf("%d",&a);
	for(b=0;b<a;b++){
		scanf("%d",&e[b]);
	}
	for(a=a-1;a>0;a--){
		printf("%d ",e[a]);
	}
	printf("%d\n",e[0]);
	return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] s = new int[n];
        for(int i = 0; i < n; i++){
            s[i] = sc.nextInt();
        }
        Arrays.sort(s);
        int flag = 0;
        int wa = 0;
        for(int i = 0; i < n; i++){
            if(s[i] % 10 != 0){
                wa = s[i];
                flag = 1;
                break;
            }
        }
        int sum = 0;
        for(int i = 0; i < n; i++){
            sum = sum + s[i];
        }
        if(flag == 0){
            System.out.print(0);
        } else if(flag == 1 && sum % 10 == 0){
            System.out.print(sum - wa);
        } else {
            System.out.print(sum);
        }
    }
}

Measured memory_bytes: 21716
/* Preprocess */
#include <bits/stdc++.h>

#define pow(n) (n)*(n)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()


/* Field */
using namespace std;


/* Function */

int main (void) 
{

  /* Variable_Proclamation */
  int N;      // input
  int white;  // input
  int black;  // output

  int field;


  /* Input, Initialize */
  cin >> N;
  cin >> white; // input A


  /* Calculation */
  field = N * N;
  black = field - white;


  /* Output */
  cout << black << endl;


  return 0;

}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

int n;
string s;
ll dp[3005][3005];
const ll mod = (ll)1e9 + 7;

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
cin >> s;
dp[1][1] = 1;
for(int i = 2 ; i <= n ; ++i){
	for(int j = 1 ; j <= i ; ++j){
		if(s[i - 2] == '>'){
			dp[i][j] = (dp[i - 1][i - 1] - dp[i - 1][j - 1] + mod) % mod;
		}
		else{
			dp[i][j] = dp[i - 1][j - 1];
		}
	}
	for(int j = 2 ; j <= i ; ++j){
		dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
	}
}
cout << dp[n][n] << endl;

return 0;
}



Measured memory_bytes: 69120
import bisect
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans=0
for i in range(n):
    ans+=bisect.bisect_left(A,B[i])*(n-bisect.bisect_right(C,B[i]))
print(ans)

Measured memory_bytes: 23360
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
    ll l,r;
    cin>>l>>r;
    if(r-l>=2019)
    {
        cout<<0<<endl;
        return 0;
    }
    ll ans{2018};
    for(ll i=l;i<r;i++)
    {
        for(ll j = i+1;j<=r;j++)
        {
            ans = min(ans,((i*j)%2019));
        }
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string N;
    cin >> N;
    reverse(N.begin(),N.end());

        if(N[0]=='3'){
            cout << "bon" << endl;
        }else if(N[0]=='0' || N[0]=='1' || N[0]=='6' || N[0] == '8'){
            cout << "pon" << endl;
        }else{
            cout << "hon" << endl;
        }
    return 0;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long[] A = new long[N];
        long[] xor = new long[N+2];
        long[] sum = new long[N+2];
        sum[N+1] = -810;
        for (int i=0;i<N;i++) {
            A[i] = Long.parseLong(sc.next());
            xor[i+1] = xor[i]^A[i];
            sum[i+1] = sum[i] + A[i];
        }

        int right = 0;
        long ans = 0L;
        for (int left=0;left<N;left++) {
            while (sum[right+1]-sum[left]==(xor[right+1]^xor[left])) {
                right++;
            }
            ans += (long)(right-left);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 66360
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	cout << (n==3||n==5||n==7?"YES":"NO") << endl;
}

Measured memory_bytes: 256
nnk = input().split(" ")
n = int(nnk[0])
k = int(nnk[1])

hs = [int(input()) for l in range(n)]
hs.sort()

hmmm = []
for m in range(n-k+1):
    hmmm.append(hs[k+m-1] - hs[m])

hmmm.sort()
print(hmmm[0])

Measured memory_bytes: 11288
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

const (
	maxBufsize = 1000000
)

func inputs(lines int, rdr *bufio.Reader) []string {
	var strSlice []string

	//rdr := bufio.NewReaderSize(os.Stdin, maxBufsize)

	for i := 0; i < lines; i++ {

		line := ReadLine(rdr)
		strSlice = append(strSlice, line)

	}

	return strSlice
}

// ReadLine is to read long line
func ReadLine(rdr *bufio.Reader) string {
	buf := make([]byte, 0, maxBufsize)
	for {
		l, p, e := rdr.ReadLine()

		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}

	return string(buf)
}

//DivideConvertInt is to divide and convert
func DivideConvertInt(line string, num int) []int {
	tmp := strings.Split(line, " ")

	intSlice := make([]int, num)

	for i := 0; i < num; i++ {
		intTmp, _ := strconv.Atoi(tmp[i])
		intSlice[i] = intTmp
	}

	return intSlice
}

func abs(a, b int) int {
	if (a - b) > 0 {
		return a - b
	} else {
		return b - a
	}
}

func main() {
	rdr := bufio.NewReaderSize(os.Stdin, maxBufsize)
	line0 := inputs(1, rdr)

	line0Int := DivideConvertInt(line0[0], 2)

	X := line0Int[0]
	N := line0Int[1]

	if N == 0 {
		fmt.Println(X)
		return
	}

	line1 := inputs(1, rdr)
	pn := DivideConvertInt(line1[0], N)

	absDiff := make([]int, N)
	dictNum := make(map[int][]int, N)
	for i := 0; i < N; i++ {
		absDiff[i] = abs(X, pn[i])
		dictNum[absDiff[i]] = append(dictNum[absDiff[i]], pn[i])
	}

	sort.Ints(absDiff)

	cntDiff := make([]int, 100)

	for i := 0; i < N; i++ {
		cntDiff[absDiff[i]]++
	}

	if cntDiff[0] == 0 {
		fmt.Println(X)
		return
	}

	for i := 1; i < N; i++ {
		if cntDiff[i] == 0 {
			fmt.Println(X - i)
			return
		} else if cntDiff[i] == 1 {
			if (X - i) == dictNum[i][0] {
				fmt.Println(X + i)
				return
			} else {
				fmt.Println(X - i)
				return
			}
		}
	}

	fmt.Println(X - absDiff[N-1] - 1)

}


Measured memory_bytes: 1892
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_A&lang=jp
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

class Point{
private:
    double x;
    double y;
public:
    double getX(){return x;};
    double getY(){return y;};
    void setPoint(double inX, double inY){x = inX; y = inY;};
    void disp(){printf("%.12f %.12f\n", x,y);}
};

/*
void Projection(Point P1, Point P2, Point P, Point Output){
    double ax = P2.getX() - P1.getX();
    double ay = P2.getY() - P1.getY();
    double bx = P.getX() - P1.getX();
    double by = P.getY() - P1.getY();
    double dot = ax*bx + ay*by;
    double length = ax*ax + ay*ay;

    double outX = ax * dot/length;
    double outY = ay * dot/length;

    Output.setPoint(outX, outY);
    Output.disp();
}*/


int main(){
    int n;
    double inX, inY;
    Point P, P1, P2, Output;
    cin >> inX >> inY;
    P1.setPoint(inX, inY);
//    P1.disp();
    cin >> inX >> inY;
    P2.setPoint(inX, inY);
//    P2.disp();
    cin >> n;
    double ax = P2.getX() - P1.getX();
    double ay = P2.getY() - P1.getY();
    double length = ax*ax + ay*ay;
    for(int i=0; i<n; i++){
        cin >> inX >> inY;
        P.setPoint(inX, inY);
        //Projection(P1, P2, P, Output);
        //Output.disp();
        double bx = P.getX() - P1.getX();
        double by = P.getY() - P1.getY();
        double dot = ax*bx + ay*by;

        double outX = ax * dot/length + P1.getX();
        double outY = ay * dot/length + P1.getY();

        Output.setPoint(outX, outY);
        Output.disp();
    }
    return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  vi a(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(all(a));
  reverse(all(a));
  a[0]/=2;
  int sum=0;
  rep(i,n){
    sum+=a[i];
  }
  cout<<sum<<endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int N;cin>>N;
    vector<int>A(N),B(N),C(N);
    REP(i,N)cin>>A[i];
    REP(i,N)cin>>B[i];
    REP(i,N)cin>>C[i];
    sort(A.begin(),A.end());
    sort(C.begin(),C.end());
    int ans=0;
    REP(i,N){
        int b=B[i];
        auto d=lower_bound(A.begin(),A.end(),b);
        auto e=upper_bound(C.begin(),C.end(),b);
        ans+=(d-A.begin())*(C.end()-e);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5612
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

using namespace std;
typedef long long ll;
int main()
{
  string s,t;
  cin >> s >> t;
  
	int m,n;
	int ans=0;
	cin >> m >> n;
  string u;
  cin >> u;


  
	if(u==s) cout << m-1 << " " << n << endl;
	else cout << m << " " << n-1 << endl;
}

Measured memory_bytes: 256
a = int(input())
b, c = map(int, input().split())
A = list(map(int, input().split()))
tem = 0
st = 0
st2 = 0
for i in range(a):
    tem = c-(b-A[i]*0.006)
    tem = abs(tem)
    if i == 0:
        st = tem
    else:
        if st < tem:
            st = st
        else:
            st = tem
            st2 = i
print(st2+1)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);

    rep(i, N) cin >> a[i];
    vector<int> s = a;
    sort(s.rbegin(), s.rend());

    rep(i, N) {
        int ans = s[0];
        if (s[0] == a[i])
            ans = s[1];
        cout << ans << endl;
    }
}

Measured memory_bytes: 3200
#include <cstdio>
#include <complex>
#include <cmath>
using namespace std;

typedef complex<double> xy_t;

xy_t P[110];

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }

int main(){
    int n = 0;
    double x, y;
    // "Control + d"??§?????¢
    while(~scanf("%lf, %lf", &x, &y)){
        P[n++] = xy_t(x, y);
    }
    double sum = 0.0;
    for(int i=0; i+2<n; ++i){
        xy_t a=P[0], b=P[i+1], c=P[i+2];
        sum += cross_product(b-a, c-a) / 2;
    }
    printf("%.6f\n", abs(sum));
}

Measured memory_bytes: 2656
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	sum := 0
	x := n
	for n > 0 {
		sum += n % 10
		n /= 10
	}
	if x%sum == 0 {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
  cin >> n;
  long double ans = 0;
  for (int i = 0; i < n; i++) {
    long double x;
    string s;
    cin >> x >> s;
    if (s == "JPY") ans += x;
    else ans += x * 380000;
  }
  cout << setprecision(20) << fixed << ans << endl;
	return 0;	 
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.root=[-1]*n
        self.rank=[-1]*n

    def Find_Root(self,x):
        if self.root[x]<0:return x
        else:
            self.root[x]=self.Find_Root(self.root[x])
            return self.root[x]

    def Unite(self,x,y):
        x=self.Find_Root(x)
        y=self.Find_Root(y)

        if x==y:return
        elif self.rank[x]>self.rank[y]:
            self.root[x] +=self.root[y]
            self.root[y]=x
        else:
            self.root[y] +=self.root[x]
            self.root[x]=y
            if self.rank[x]==self.rank[y]:
                self.rank[y] +=1

    def isSameGroup(self,x,y):
        return self.Find_Root(x)==self.Find_Root(y)

    def Count(self,x):
        return -self.root[self.Find_Root(x)]

    def members(self,x):
        root=self.Find_Root(x)
        return [i for i in range(self.n) if self.Find_Root(i)==root]

    def address(self):
        return[i for i,j in enumerate(self.root) if j<0]

    def group_members(self):
        return {i:self.members(i) for i in self.address()}

    def size(self,x):
        return -self.root[self.Find_Root(x)]


n,m,k=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(m)]
CD=[list(map(int,input().split())) for _ in range(k)]

A=UnionFind(n+1)
C=[[] for _ in range(n+1)]
D=[[] for _ in range(n+1)]

for a,b in AB:
    A.Unite(a,b)
    C[a] +=[b]
    C[b] +=[a]

for c,d in CD:
    if A.isSameGroup(c,d):
        D[c] +=[d]
        D[d] +=[c]

ans=[]
for i in range(1,n+1):
    ans +=[A.size(i)-len(C[i])-len(D[i])-1]

print(*ans)

Measured memory_bytes: 75144
def main
  button = [
    [''],
    ['.', ',', '!', '?', ' '],
    ['a', 'b', 'c'],
    ['d', 'e', 'f'],
    ['g', 'h', 'i'],
    ['j', 'k', 'l'],
    ['m', 'n', 'o'],
    ['p', 'q', 'r', 's'],
    ['t', 'u', 'v'],
    ['w', 'x', 'y', 'z'],
  ]

  n = gets.chomp.to_i
  n.times do
    outstr = ''
    input = gets.chomp
    push = 0
    num = 0
    input.each_char do |c|
      if c == '0'
        outstr << button[push][num-1] unless push == 0
        push = 0
        num = 0
      else
        push = c.to_i
        num = (num + 1) % button[push].size
      end
    end
    puts outstr
  end
end

main

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

set<ll> G[1010];
vector<ll> H[1010];
vector<ll> mark(1010, -1);
ll cnt[2];

bool is_bipartite(ll now, ll now_mark){
	if(mark[now]!=-1) return (mark[now]==now_mark);
	mark[now] = now_mark;
	cnt[now_mark]++;
	bool flag = true;
	REP(i, H[now].size()){
		ll next = H[now][i];
		flag &= is_bipartite(next, 1-now_mark);
	}
	return flag;
}


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

    ll N, M;
    cin >> N >> M;
    REP(i, M){
    	ll A, B;
    	cin >> A >> B;
    	A--;B--;
    	G[A].insert(B);
    	G[B].insert(A);
    }
    REP(i, N){
    	REP(j, N){
            if(i == j) continue;
    		if(G[i].find(j) == G[i].end()) H[i].push_back(j);
    	}
    }

    /*
    REP(i, N){
        dump(i)
        REP(j, H[i].size()) cout << H[i][j] << " ";
        cout << endl;
    }
    */

    vector<pll> shima;
    REP(i, N){
    	if(mark[i] != -1) continue;
    	cnt[0] = 0;
    	cnt[1] = 0;
    	if(is_bipartite(i, 0)){
            shima.push_back({cnt[0], cnt[1]});
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    //REP(i, shima.size()) cout << shima[i].first << " " << shima[i].second << endl;

    ll S = shima.size();
    ll dp[1000][1000];
    REP(i, 1000)REP(j, 1000) dp[i][j] = 0;

    dp[0][0] = 1;
    REP(i, S){
        REP(j, 1000){
            if(dp[i][j] == 1){
                dp[i+1][j+shima[i].first] = 1;
                dp[i+1][j+shima[i].second] = 1;
            }
        }
    }
    ll mi = (1ll << 60);
    REP(i, 1000){
        if(dp[S][i] == 1) mi = min(i*(i-1)/2 + (N-i)*(N-i-1)/2, mi);
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 31104