akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>

int main(void)
{
  int S,W;

  scanf("%d%d",&S,&W);

  if(W>=S)
  {
    printf("unsafe");
    return 0;
  }

  printf("safe");

  return 0;
}


Measured memory_bytes: 1736
/**
 *    author: apurba_debnath
**/
#include <bits/stdc++.h>


#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;


using namespace std;

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

    int n, ac = 0, wa = 0, tle = 0, re = 0;
    string s;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        if (s == "AC")
            ac++;
        else if (s == "WA")
            wa++;
        else if (s == "TLE")
            tle++;
        else if (s == "RE")
            re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<bits/stdc++.h> 
using namespace std;
int a[33]={1,1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
    int n;
    cin>>n;
    cout<<a[n-1]<<endl;
}

Measured memory_bytes: 256
import collections
import math
def calculateProb(counts):
    ways = 0
    for key in counts.keys():
        if counts[key] < 2:
            continue
        else:
            val = counts[key]
            ret = val*(val-1)/2
            ways += ret
    return ways

def getfact(val):
    if val < 2:
        return 0
    return val*(val-1)/2


n = int(input())

values = list(map(int, input().split(' ')))
counts = collections.Counter(values)

ways = calculateProb(counts)
for k in range(n):
    curVal = values[k]
    count = counts[curVal]
    temp = ways
    ways = ways - getfact(count)  + getfact(count - 1)
    print(int(ways))
    ways = temp

Measured memory_bytes: 26024
import java.util.Scanner;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigInteger m = BigInteger.ONE;

        int n = sc.nextInt();
        BigInteger[] input = new BigInteger[n];
        for (int i = 0; i < n; i++) {
            input[i] = sc.nextBigInteger();
            m = m.multiply(input[i]);
        }

        m = m.subtract(BigInteger.ONE);

        BigInteger ans = BigInteger.ZERO;
        for (int i = 0; i < n; i++) {
            ans = ans.add(m.mod(input[i]));
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 46700
n = int(input())
ans = [0]*n
a_l = list(map(int,input().split()))
for i in range(n):
    ans[a_l[i] - 1] = i+1

w=""
for i in range(n):
    if(i==(n-1)):
        break
    w += (str(ans[i]) + " ")

w += str(ans[n-1])
print(w)

Measured memory_bytes: 14580
import math

n, k = map(int, input().split())

prob = 0

if n < k:
    for  i in range(1, n+1):
        prob += 0.5**math.ceil(math.log2(k/i)) * (1/n)
    print(prob)
else:
    for  i in range(1, k):
        prob += 0.5**math.ceil(math.log2(k/i)) * (1/n)
    print(prob + (n-k+1)/n)


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn=55;
char ch[maxn][maxn];
int n,m;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
bool check(int x,int y){
	if(x>=0&&x<n&&y>=0&&y<m) return 1;
	return 0;
}
int main(){
	int i,j;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%s",ch[i]);
	}
	int flag=1;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(ch[i][j]=='#'){
				int tt=0;
				for(int k=0;k<4;k++){
					int xx=i+dx[k],yy=j+dy[k];
					if(check(xx,yy)&&ch[xx][yy]=='#'){
						tt=1;break;
					}
				}
				if(!tt){
					flag=0;break;
				}
			}	
		}
		if(!flag) break;
	}
	if(!flag) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    int a[N];
    REP(i, N) cin >> a[i];

    int b[N];
    for (int i = N; i >= 1; --i) {
        int s = a[i - 1];
        int itr = i * 2;
        while (itr <= N) {
            s ^= b[itr - 1];
            itr += i;
        }
        b[i - 1] = s;
    }
    int c = 0;
    REP(i, N) {
        if (b[i] == 1) c++;
    }
    cout << c << endl;
    if (c > 0) {
        c = 0;
        REP(i, N) {
            if (b[i] == 1) {
                if (c == 0) cout << (i + 1);
                else cout << " " << (i + 1);
                c++;
            }
        }
        cout << endl;
    }
    return 0;
}


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

int main()
{
    long N,K,X,Y,z,pro;
    scanf("%ld %ld %ld %ld",&N,&K,&X,&Y);
    if(K<=N)
    {
        z=K*X;
        pro=(N-K)*Y;
        printf("%ld\n",z+pro);
    }
   else{z=N*X;
        printf("%ld\n",z);
        }
    return 0;
}

Measured memory_bytes: 1708
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

  vector<vector<int>> A(N, vector<int>(10));
  REP(i, N) REP(j, 10) cin >> A[i][j];

  vector<vector<int>> P(N, vector<int>(11));
  REP(i, N) REP(j, 11) cin >> P[i][j];

  int ans = -INF;
  FOR(bit, 1, (1<<10)){
    int ret = 0;
    REP(i, N){
      int cnt = 0;
      REP(j, 10){
        if(A[i][j] && ((bit >> j)&1)) cnt++;
      }
      ret += P[i][cnt];
    }
    chmax(ans, ret);
  }

  cout << ans << "\n";

  return 0;
}

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

int main()
{
	int n, a, b, c;
	vector<int> add;
	
	scanf("%d%d%d%d", &n, &a, &b, &c);
	add.resize(n);
	for(int i = 0; i < n; ++i) {
		scanf("%d", &add[i]);
	}
	
	sort(add.begin(), add.end());
	
	int cal = c;
	int cost = a;
	
	for(int i = n - 1; i >= 0; --i) {
		if((cal / cost) <= (cal + add[i]) / (cost + b))
			cal += add[i], cost += b;
		else
			break;
	}
	
	printf("%d\n", cal / cost);
	
	return 0;
}

Measured memory_bytes: 1048
import itertools



n = int(input())

k, *list_b = map(int, input().split())

list_d = []

for k in range(len(list_b) + 1):

    for tuple_e in itertools.combinations(list_b, k):
        d = 0

        for bit in tuple_e:
            d += 2 ** bit

        list_d.append((d, tuple_e))


for d, tuple_e in sorted(list_d):
    if tuple_e:
        print(f"{d}: ", end="")
        print(*tuple_e)
    else:
        print(f"{d}:")



Measured memory_bytes: 67324
// C - Remainder Minimization 2019

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;


int main(){
	int L, R;
	cin >> L >> R;

	if (R - L >= 2019) {
		cout << 0 << endl;
		return 0;
	}

	int N = R - L + 1;
	vector<int> A(N);
	for (int i=0; i<N; i++) {
		A[i] = (L + i) % 2019;
	}

	int ans = INF;
	for (int i=0; i<N; i++) {
		for (int j=i+1; j<N; j++) {
			ans = min(ans, (A[i] * A[j]) % 2019);
		}
	}

	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

typedef __int128 lll;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n; cin >> n;

    bool ya = false;
    ll res = 1;
    F0R(i,n) {
        ll x; cin >> x;

        if (ya && x == 0) res = 0;
        if (lll((lll)res*(lll)x) > lll(1e18)) {
            ya = true;
        } else {
            res *= x;
        }
    }

    if (ya && res != 0) res = -1;

    cout << res << "\n";

}


Measured memory_bytes: 3644
n,k=map(int, input().split())
xlist=list(map(int, input().split()))
ans=10**20
for i in range(n-k+1):
  ans=min(abs(xlist[i]-xlist[i+k-1])+min(abs(xlist[i]),abs(xlist[i+k-1])),ans)
print(ans)

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

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int long long

using namespace std;
const int INF = 2e16;
const int MB = 20;
const int MOD = 1e9 + 7;

void solve() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	bool f = true;
	while (a > 0 && c > 0) {
		if (f) c -= b;
		else a -= d;
		f = !f;
	}
	cout << (a > 0 ? "Yes" : "No");
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	//srand(time(0));
	int t = 1;
	//int t;
	//cin >> t;
	while (t--) solve();
}

Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b;
	bool f=false;
	cin>>a>>b;
	for(int i=0;i<1000000000;i++){
		if(abs(a-i)==abs(b-i)){
			cout<<i<<endl;
			f=true;
		}
	}
	if(f==false)cout<<"IMPOSSIBLE"<<endl;
	return 0;
}



Measured memory_bytes: 256
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve(){
    ll a,b;cin>>a>>b;
    cout<<max(0ll,a-2*b)<<endl;
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

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

//    ll t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3628
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, K; cin >> N >> K;
    string S; cin >> S;
    ll cnt = 0;
    rep(i, N-1){
        if(S[i] != S[i+1]) cnt++;
    }
    ll rem = max(cnt-2*K, 0ll);
    cout << N-1-rem << endstr;
    return 0;
}


Measured memory_bytes: 512
A = list(input())
if A == A[::-1]:
    pass
else:
    print("No")
    exit()
B=len(A)
C = A[0:(B-1)//2]
if C == C[::-1]:
    pass
else:
    print("No")
    exit()
C = A[(B+3)//2-1:]
if C == C[::-1]:
    pass
else:
    print("No")
    exit()
print("Yes")

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

int main() {
  int N,M;

  cin >> N >> M;

  vector<int> a(M),b(M),count(N,0);

  for(int i=0; i<M; i++) {
      cin >> a.at(i) >> b.at(i);
  }

  for(int i=0; i<M; i++) {
      for(int j=0;j<N;j++) {
          if(a.at(i) == j+1 || b.at(i) == j+1) count.at(j)++;
      }
  }

  for(int i=0; i<N; i++) {
      cout << count.at(i) << endl;
  }
}

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

using namespace std;
int main()
{
    int ara[102];
    int n, i;
    cin >> n;
    for(i=0; i<n; i++) cin >> ara[i];
    sort(ara, ara+n);

    int dif = ara[n-1] - ara[0];
    cout << dif << endl;
    return 0;
}


Measured memory_bytes: 256
#include<complex>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
#include<map>
#include<sstream>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<deque>
#include<queue>
#include<climits>
#include<list>
#include<stack>
#include<ctime>
#define all(n) n.begin(),n.end()
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define Iter(c) __typeof__((c).begin())
#define foreach(i,c) for(Iter(c) i = (c).begin();i != (c).end();++i)
#define pb push_back
#define INF (1<<27)
#define EPS 1e-10
#define equals(a,b) (fabs((a)-(b)) < EPS)

using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef unsigned long long ull;
typedef long long ll;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};


int main(){

  int N;
  cin >> N;
  int K;
  cin >> K;
  rep(i,K){
    int a,b;
    cin >> a >> b;
    a = min(a,N-a+1),b = min(b,N-b+1);
    if(min(a,b)%3 == 0)cout << 3 << endl;
    else cout << min(a,b)%3 << endl;
  }

return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#include <iomanip>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;

LL a[7];
int main()
{
    LL n;
    cin >> n ;
    for(int i = 1; i <= 5; i++)
        cin >> a[i];
    LL ans = 5;
    LL Min = *min_element(a+1, a+6);
    if(Min < n){
        ans += (n - Min) / Min;
        if(n % Min)
            ans ++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  rep(i, n-2) {
    if(s.at(i) == 'A') {
      if(s.at(i+1) == 'B') {
        if(s.at(i+2) == 'C') {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
signed main(){
	string s;
	cin>>s;
	if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])cout<<"Bad"<<endl;
	else cout<<"Good"<<endl;;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8

if __name__ == "__main__":
    n, m = map(int, input().split())

    connected_1 = []
    connected_n = []

    for _ in range(m):
        a, b = map(int, input().split())
        if a == 1:
            connected_1.append(b)
            continue
        elif a == n:
            connected_n.append(b)
            continue
        elif b == 1:
            connected_1.append(a)
            continue
        elif b == n:
            connected_n.append(a)
            continue
        else:
            continue

    if len(set(connected_1).intersection(set(connected_n))) >= 1:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


Measured memory_bytes: 21816
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();
        int sumb = 0;
        int sumc = 0;

        if(K >= A) {
            sumb = K - A;
            if(sumb > 0) {
                sumc = K - A - B;
            }
            System.out.println(A - sumc);
        } else System.out.println(K);
    }
}

Measured memory_bytes: 35756
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e;

    ll res = 0;
    rep(i, n){
        res += a[i] / 2;
        if(a[i] % 2 and i + 1 < n and a[i + 1] > 0){
            res++;
            a[i + 1]--;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

int main(){
	int N;
	int M;
	int flag_sum = 0;
	bool flag = false;

	string *A = NULL;
	string *B = NULL;

	cin >> N >> M;

	A = new string[N];
	B = new string[M];

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

		for(int j = 0; j < M; j++){
			cin >> B[j];
		}

	for(int i = 0; i <= N - M; i++){
		for(int j = 0; j <= N - M; j++){
			flag_sum = 0;
			for(int s = 0; s < M; s++){
				if(A[i+s].substr(j, M) == B[s]){
					flag_sum++;
				}
			}
			if(flag_sum == M){
				flag = true;
				break;
			}
		}
		if(flag){
			break;
		}
	}

	if(flag){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	delete[] A;
	delete[] B;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
void func(int,int,int,int );
int main(void)
{
	long long int n,m,x,y,z,mm,nn,nm;
	int i,j,k,flg;
	scanf("%lld %lld",&n,&m);
	flg=1;
	m=m/1000; 
//printf("n=%d m=%d\n",n,m);
	for(i=0;i<=n;i++){
		if(m-10*i>=0){
			mm=m-10*i; nn=n-i;
//printf("nn=%d mm=%d\n",nn,mm);
			if(5*nn-mm>=0){
				nm=5*nn-mm;
//printf("nm=%lld\n",nm);
				if(nm%4==0 && nn-(nm/4)>=0){
						flg=0; x=i; z=nm/4; y=nn-z;
//printf("%lld %lld %lld\n",x,y,z);
				}
			}
		}
	}
	if(flg==0) printf("%lld %lld %lld\n",x,y,z);
	else printf("-1 -1 -1\n");
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

    vector<pair<ull,ull>> xy(N);
    for(int i=0; i<N; i++)
        cin >> xy[i].first >> xy[i].second;

    vector<vector<pair<ull,ull>>> pq(N);
    for(int i=0; i<N; i++) {
        pq[i] = vector<pair<ull,ull>>(N);
        pq[i][i].first = pq[i][i].second = 0;
        for(int j=0; j<N; j++) {
            pq[i][j].first = xy[j].first - xy[i].first;
            pq[i][j].second = xy[j].second - xy[i].second;
        }
    }

    map<pair<ull,ull>,int> pq_count;
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            if(pq[i][j]==pair<ull,ull>(0,0))
                continue;
            pq_count[pq[i][j]]++;
        }
    }

    int max_count = 0;
    for (auto i : pq_count)
        if(max_count < i.second)
            max_count = i.second;

    cout << N - max_count << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int n;
int sum = 0;
inline int f(int n){
    int ans = 0;
    while(n){
        ans += n%10;
        n/=10;
    }
    return ans;
}
int main()
{
    std::ios::sync_with_stdio(false);
    cin>>n;
    int mmin = 0x3f3f3f3f;
    for(int i=1;i<n/2 + 1;i++){
        int f1 = f(n-i);
        int f2 = f(i);
        if(mmin > f1+f2)
            mmin = f1 + f2;
    }
    cout<<mmin<<endl;
    return 0;
}


Measured memory_bytes: 256
////////////////////////////////////////////////////////////////
//
//    (☝ ՞ਊ ՞)☝ << Be accept!!
//
//    C++ format for competitive professional v1.0
//
//    GCC is recommendation.
//
////////////////////////////////////////////////////////////////
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<time.h>
#include<random>
#include<map>
#include<thread>
#include<tuple>
#include<boost/multiprecision/cpp_int.hpp>
#define rep(i,n) for(int i = 0;i < n;i++)
using ll = long long;
using namespace std;
using namespace boost::multiprecision;//cpp_int
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
int inline setup(void) {//set
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	return 0;
}
int lenght(char* str){//getcharlengh
	int i = 0;
	while (str[i]) {
		i++;
	}
	return i;
}
int gcd(long long a, long long b) {
	if (a < b)return gcd(b, a);
	long long r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
#define DEBUG
int main(int argc, const char* argv[]) {
	setup();
		
	int n, m;
	cin >> n >> m;
	if (n == m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

//関数
    
    
    
//main関数
int main() {
    
    
    //入力
    string s;
    cin>>s;
    
    
    
    
    
    
    //計算
    int d=200;//>100
    for(int x='a';x<='z';x++){
        int dx=0,count=0;
        bool first=true;
        for(int i=0;i<s.size();i++){
            if(s.at(i)==x){
                if(first){
                    first=false;
                    count*=2;
                }
                
                dx=max(count,dx);
                count=0;
            }else{
                count++;
            }
            dx=max(count*2,dx);
        }
        
        d=min(d,dx);
    }
    
    //出力
    cout<<(d+1)/2<<endl;
}

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

int main(){
  int N; cin>>N;
  if(N<105){
    cout<<0<<endl;
    return 0;
  }
  else if(N>=105&&N<135){
    cout<<1<<endl;
    return 0;
  }
  else if(N>=135&&N<165){
    cout<<2<<endl;
    return 0;
  } 
  else if(N>=165&&N<189){
    cout<<3<<endl;
    return 0;
  }
  else if(N>=189&&N<195){
    cout<<4<<endl;
    return 0;
  }
  else if(N>=195){
    cout<<5<<endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define int long long
int32_t main()
{
	int a,b,c,n;
	cin>>a>>b>>c>>n;

	if(a>=n){
		cout<<n<<'\n';
	}
	else if(a+b>=n){

		cout<<a<<'\n';
	}
	else{

		int sum=a;
		n-=a+b;
		sum-=(n);
		cout<<sum<<'\n';
	}
	


	return 0;
}


Measured memory_bytes: 3616
/*
    ALWAYS REMMEMBER:
        NEVER GIVE UP !
        DON'T MESS WITH ME !!!
        "" THE EXPERT IN ANYTHING WAS ONCE A BEGINNER ""
*/

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;

void solve()
{
    ld l;
    cin >> l;
    
    sp(10);
    
    cout << l*l*l/27;
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
using namespace std;

int main(void)
{
    //string a,b;
    int a,b,c,d;
    int i=0;
    //char a,b='.';
    cin>>a;
    cout<<24+24-a;
    return 0;
}



Measured memory_bytes: 256
/* nothing is impossible */
#include <bits/stdc++.h> 
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;                                                                                                  
ll mpow(ll a,ll b){a=a%MOD;ll res=1;while(b>0){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b=b>>1;}return res%MOD;}             

int main()
{ 
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("input.txt", "r", stdin);
//freopen("output.txt","w",stdout);
ll n;
cin>>n;
ll a[n];
forn(i,n) cin>>a[i];
ll ans=0;
ll s=1;
forn(i,n-1)
{
  if(a[i]==a[i+1])
  {
    s++;
  }
  else {
    ans+=s/2;
    s=1;
  }
}
ans+=s/2;
cout<<ans;
return 0;
}   

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

using namespace std;
#define int long long
#define endl '\n'


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1; // cin >> t;
    for (; t; t--) {
        int l, r, d;
        cin >> l >> r >> d;
        int ans = 0;
        for (int i = 1; d * i <= r; i++) {
            if (i * d >= l && i * d <= r) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
#define s(all)   s.begin(),s.end()
#define rep(i,n) for(long long i=0;i<n;i++)
#define ll       long long

int main() {
  double ans=0;
  double x=-1;
  double sum=0;
  ll n=0;
  double k=0;
  cin>>n>>k;
  vector<int> p(n);
  rep(i,n)cin>>p[i];
  rep(l,k)sum+=p[l];
  cerr<<"sum at "<<1<<":"<<sum<<endl; 
  x=sum;
  for(int j=0;j<(n-k);j++){
    sum-=p[j];
    sum+=p[j+k];
    cerr<<"sum at "<<j+2<<":"<<sum<<endl;
    x=max(x,sum);
  }
  ans=(x/2)+(k/2);
  cout<<fixed<<setprecision(15) <<ans;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int x, a, b;
int main(){
	while(~scanf("%d %d %d", &x, &a, &b)){
		int t = x - a;
		printf("%d\n", t % b);
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int w,h;
	int i,j,k,l;
	int hum[26][26];
	cin>>h>>w;
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			cin>>hum[i][j];
		}
	}
	int sum;
	int MIN=INT_MAX;
	int n,m;
	for(m=1;m<=h;m++){
		for(n=1;n<=w;n++){
			sum=0;
			for(i=1;i<=h;i++){
				for(j=1;j<=w;j++){
					sum+=min(abs(i-m),abs(j-n))*hum[i][j];
				}
			}
			MIN=min(MIN,sum);
		}
	}
	cout<<MIN<<endl;
	return 0;
}
			


Measured memory_bytes: 3132
import heapq

def main():
    N = int(input())
    a = list(map(int, input().split()))

    left = [0] * (3 * N)
    right = [0] * (3 * N)

    tmp = 0
    q = []
    for i in range(N):
        heapq.heappush(q, a[i])
        tmp += a[i]
    left[N-1] = tmp
    for i in range(N, 2*N):
        heapq.heappush(q, a[i])
        left[i] = left[i-1] + a[i] - heapq.heappop(q)
    
    tmp = 0
    q = []
    for i in range(N*3-1, N*2-1, -1):
        heapq.heappush(q, -a[i])
        tmp += a[i]
    right[2*N] = tmp
    for i in range(2*N-1, N-1, -1):
        heapq.heappush(q, -a[i])
        right[i] = right[i+1] + a[i] + heapq.heappop(q)
    
    ans = left[N-1] - right[N]
    for i in range(N, 2*N):
        ans = max(ans, left[i]-right[i+1])
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 37212
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    class UnionFind:
        def __init__(self, N: int):
            """
            N:要素数
            root:各要素の親要素の番号を格納するリスト.
                 ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
            rank:ランク
            """
            self.N = N
            self.root = [-1] * N
            self.rank = [0] * N

        def __repr__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

        def find(self, x: int) -> int:
            """頂点xの根を見つける"""
            if self.root[x] < 0:
                return x
            else:
                while self.root[x] >= 0:
                    x = self.root[x]
                return x

        def union(self, x: int, y: int) -> int:
            """x,yが属する木をunion"""
            # 根を比較する
            # すでに同じ木に属していた場合は何もしない.
            # 違う木に属していた場合はrankを見てくっつける方を決める.
            # rankが同じ時はrankを1増やす
            x = self.find(x)
            y = self.find(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 same(self, x: int, y: int) -> bool:
            """xとyが同じグループに属するかどうか"""
            return self.find(x) == self.find(y)

        def count(self, x):
            """頂点xが属する木のサイズを返す"""
            return - self.root[self.find(x)]

        def members(self, x):
            """xが属する木の要素を列挙"""
            _root = self.find(x)
            return [i for i in range(self.N) if self.find == _root]

        def roots(self):
            """森の根を列挙"""
            return [i for i, x in enumerate(self.root) if x < 0]

        def group_count(self):
            """連結成分の数"""
            return len(self.roots())

        def all_group_members(self):
            """{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す"""
            return {r: self.members(r) for r in self.roots()}
        
    N,M,K=MI()
    uf=UnionFind(N)
    F=[0]*N
    B=[0]*N
    
    for i in range(M):
        a,b=MI()
        a-=1
        b-=1
        F[a]+=1
        F[b]+=1
        uf.union(a,b)
        
    for i in range(K):
        a,b=MI()
        a-=1
        b-=1
        if uf.same(a,b):
            B[a]+=1
            B[b]+=1
        
    ans=[]
    for i in range(N):
        aaa=uf.count(i)-1
        aaa-=F[i]+B[i]
        ans.append(aaa)
        

        
    print(' '.join(map(str, ans)))

main()


Measured memory_bytes: 92320
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,h[100010];
bool C(int x){
	long long num=0;
	for (long long i=0;i<n;i++){
		long long lbound=0,rbound=x;
		while (lbound<rbound){
			long long mid=(lbound+rbound)/2;
			if (a*mid+b*(x-mid)>=h[i])
				rbound=mid;
			else
				lbound=mid+1;
		}
		num+=lbound;
	}
	if (num<=x) return 1;
	return 0;
}
int main(){
	cin>>n>>a>>b;
	for (long long i=0;i<n;i++) cin>>h[i];
	sort(h,h+n);
	long long lbound=1,rbound=1e9;
	while (lbound<rbound){
		long long mid=(lbound+rbound)/2;
		if (C(mid)==1)
			rbound=mid;
		else
			lbound=mid+1;
	}
	cout<<lbound<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

//Istiyak Hossain

int main()
{
    int i, n, arr[1000];

    scanf("%d", &n);

    for(i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
    }

    for(i = n - 1; i >= 0; i--)
    {
        printf("%d", arr[i]);
        if(i)printf(" ");
    }
    printf("\n");


    return 0;
}



Measured memory_bytes: 1984
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define ll long long
#define M 1000000007
#define N 100010
#define D 110
using namespace std;

ll n,d,l,dg[N],dp[N][D];
string k;

ll solve(int pos,int cnt,bool lmt)
{
    if(!lmt && dp[pos][cnt]!=-1) return dp[pos][cnt];
    if(pos==l) return dp[pos][cnt]=(cnt==0);
    ll up=lmt?dg[pos]:9;
    ll ret=0;
    for(int i=0;i<=up;i++)
    {
        ret+=solve(pos+1,(cnt+i)%d,(i==dg[pos])&&lmt);
        ret%=M;
    }
    if(!lmt) dp[pos][cnt]=ret;
    return ret;
}

int main()
{
    cin>>k>>d; l=k.length(); 
    FOR(i,0,k.length()) dg[i]=k[i]-'0';
    memset(dp,-1,sizeof(dp));
    cout<<(solve(0,0,1)-1+M)%M<<'\n';

    return 0;
}

Measured memory_bytes: 87040
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String w = sc.next();
    char[] a = {'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'};
    int[] check = new int[26];
    int out =0;
    for (int j =0; j<26; j++) {
      for (int i =0; i< w.length(); i++) {
        if (w.charAt(i) == a[j]){
          check[j]++;
        }
      }
    }
    for (int i=0 ; i<26; i++) {
      if(check[i] % 2 != 0){
        out++;
      }
    }
    if (out != 0) {
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }
  }
}

Measured memory_bytes: 35812
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());//昇順ソート
#define usort(a) sort(a.rbegin(),a.rend());//降順ソート

using namespace::std;

int jo(ll int a, ll int b){//累乗
    ll int num=1;
    rep(i,0,b) num=num*a;
    return num;
}
char tobig(char s){//char大文字化
  return (s-0x20);
}
char tolow(char s){//char小文字化
  return (s+0x20);
}
int ctoi(char a){//char->int
  if('0'<=a&&a<='9') return (a-'0');
  return -1;
}

int gcd(ll int a,ll int b) {//最大公約数
  if(a<b) return gcd(b,a);
  int c;
  while ((c=a%b)) {
    a=b;
    b=c;
  }
  return b;
}
int lcm(ll int a,ll int b){//最小公倍数
 return (a*b)/gcd(a,b);
}


int main(){
  int X,Y; cin>>X>>Y;
  int ans=0;
  if(X==1) ans+=300000;
  else if(X==2) ans+=200000;
  else if(X==3) ans+=100000;

  if(Y==1) ans+=300000;
  else if(Y==2) ans+=200000;
  else if(Y==3) ans+=100000;
  
  if(ans==600000) ans+=400000;
  
  cout<<ans;

}




// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(x,a,b) for(x=a;x<b;x++)
#define SIZE
typedef long long int ll;
using namespace std;
ll i,j;

int main(){
	ll n,a;
	cin>>n>>a;
	cout<<n*n-a<<endl;
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int _a, _b, _c;
    cin >> _a >> _b >> _c;
    int a = max(_a, max(_b, _c)), b, c;
    if (a == _a) {
      b = _b;
      c = _c;
    } else if (a == _b) {
      b = _a;
      c = _c;
    } else if (a == _c) {
      b = _b;
      c = _a;
    }
    if (a * a == b * b + c * c) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
    
  }
  return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    int N;  cin >> N;
    vector<int> A(N), B(N-1);
    for(int i=0; i<N-1; i++) cin >> B[i];
    for(int i=1; i<N-1; i++){
        A[i] = min(B[i], B[i-1]);
    }
    A[0] = max(A[1], B[0]);
    A[N-1] = max(A[N-2], B[N-2]);

    int ans = 0;
    for(int i=0; i<N; i++){
        ans += A[i];
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		string s,a,b;
		cin>>s;
		int cur=0;
		char c;
		int q,x,y;
		cin>>q;
		while(q--){
			cin>>x;
			if(x==1){
				cur=1-cur;
			}
			else{
				cin>>y>>c;
				if(cur==0){
					if(y==1){
						a+=c;
					}
					else
					b+=c;
				}
				else{
					if(y==1)
					b+=c;
					else
					a+=c;
				}
			}
		}
		if(cur==0){
			reverse(a.begin(),a.end());
			cout<<a<<s<<b;
		}
		else{
			reverse(b.begin(),b.end());
			reverse(s.begin(),s.end());
			cout<<b<<s<<a;
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int arr[n];
     int val=0,ans1=0,ans=0;
    for(int i=0;i<n;i++){
        cin >> arr[i];
        val+=arr[i];
    }
    int val2 = val/n;
   int val1 = (val/n) + 1;
    for(int i=0;i<n;i++){
        ans += (arr[i]-val1)*(arr[i]-val1);
    }
    for(int i=0;i<n;i++){
        ans1 += (arr[i]-val2)*(arr[i]-val2);
    }
    cout << min(ans,ans1);
    return 0;
}


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

using namespace std;

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	/*
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	*/
	int n;
	cin >> n;
	if(n == 1){
		cout << "Hello World";
		exit(0);
	}
	else{
		int a,b;
		cin >> a >> b;
		cout << a+b;
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(vector<int>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}


//CODE
void solve(void)
{
  int N;
  cin>>N;
  map<int,int> mp;
  for (int i = 0; i < N; i++)
  {
    int A;
    cin>>A;
    auto itr = mp.find(A);
    if(itr == mp.end())
    {
      mp[A] = 1;
    }
    else
    {
      itr->second++;
    }

    
  }
  int ANS = 0;
  for (int i = 0; i < mp.size(); i++)
  {
    static auto itr = mp.begin();
    int A = itr->first;
    int B = itr->second;
    if( A > B)
    {
      ANS += B;
    }
    else if( B > A)
    {
      ANS += B - A;
    }
    // vector<int> C = {A,B,ANS};
    // DEBUG(C);
    itr++;

  }
  cout<<ANS<<endl;
  
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1 << 28
#define EPS 1e-10
#define PI acos(-1)

using namespace std;

struct Point 
{
    double x, y;
    Point(double x=0, double y=0) : x(x), y(y) {}
    
	double distance (const Point &o) const 
	{
        return sqrt((x - o.x) * (x - o.x) + (y - o.y) * (y - o.y));
    }

    Point operator+(const Point &o) const 
	{
        return Point(x+o.x, y+o.y);
	}

 
    Point operator-(const Point &o) const 
	{
        return Point(x-o.x, y-o.y);
    }
 	
    Point operator*(const double m) const 
	{
   	   return Point(x*m, y*m);
    }

    Point operator/(const double d) const 
	{
       return Point(x/d, y/d);
    }

    double cross(const Point &o) const 
	{
       return x * o.y - y * o.x;
    }
 
    double dot(const Point &o) const 
	{
        return x * o.x + y * o.y;
    }
 
    double atan() const 
	{
        return atan2(y, x);
    }

    double norm() const 
	{
        return sqrt(dot(*this));
    }

	double area_abs(const Point &a,const Point &b) const
	{
		double t = (a.x - x) * (b.y - y);
		double t2 = (a.y - y) * (b.x - x);
		double areas = abs(t-t2);
		return areas/2;
	}

	//符号付き面積
	double area(const Point &a,const Point &b)
	{
		return ((a.x - x) * (b.y - y)) + ((b.x - x) * (y - a.y));
	}
	//線分abが自身の含まれているのかどうか判断する
	int between(const Point &a,const Point &b)
	{
		if(area(a,b) != 0) return 0;

		if(a.x != b.x)
		{
			return ((a.x <= x) && (x <= b.x) || (a.x >= x) && (x >= b.x));
		}
		else
		{
			return ((a.y <= y) && (y <= b.y) || (a.y >= y) && (y >= b.y));
		}
	}

	double distance_seg(const Point& a,const Point& b)
	{
		if((b-a).dot(*this-a) < EPS) 
		{
			return (*this-a).norm();
		}
		if((a-b).dot(*this-b) < EPS)
		{
			return (*this-b).norm();
		}
		return abs((b-a).cross(*this-a)) / (b-a).norm();
	}

	//点a,b,cからなる三角形の中に自身が含まれているかどうか
	bool hitPolygon(const Point& a,const Point& b,const Point& c)
	{
		double t = (b-a).cross(*this-b);
		double t2 = (c-b).cross(*this-c);
		double t3 = (a-c).cross(*this-a);
		
		if((t > 0 && t2 > 0 && t3 > 0) || ( t < 0 && t2 < 0 && t3 < 0))
		{
			return 1;
		}

		return 0;
	}
};
//多角形の面積
//0 = n-1;
double areOfPoint(const vector<Point> &p)
{
	double sum = 0.0;
	rep(i,p.size()-1)
	{
		sum += p[i].x * p[i+1].y - p[i+1].x * p[i].y;
	}

	return abs(sum/2);
}


int main()
{
	int n,m;
	while(cin >> n && n)
	{
		vector<Point> a,b;
		double theta = 0,temp,x,y;

		a.push_back(Point(1,0));
		b.push_back(Point(1,0));

		rep(i,n-1)
		{
			cin >> temp;
			theta += temp;
			
			x = cos(theta*PI/180);
			y = sin(theta*PI/180);

			a.push_back(Point(x,y));
		}

		a.push_back(Point(1,0));

		theta = 0;
		cin >> m;
		rep(i,m-1)
		{
			cin >> temp;
			theta += temp;
			
			x = cos(theta*PI/180);
			y = sin(theta*PI/180);

			b.push_back(Point(x,y));
		}
		b.push_back(Point(1,0));

		double areaA = areOfPoint(a);
		double areaB = areOfPoint(b);

		if(areaA == areaB)
		{
			cout << 0 << endl;
		}
		else if(areaA > areaB)
		{
			cout << 1 << endl;	
		}
		else if(areaA < areaB)
		{
			cout << 2 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1240
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <string>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long int ll;

int main(void){
  ll q,h,s,d,n;
  cin>>q>>h>>s>>d>>n;
  q*=4;
  h*=2;
  if(d/2<min({q,h,s})){
    if(n%2==0) cout<<d*n/2<<endl;
    else cout<<d*(n/2) + min({q,h,s})<<endl;
  }
  else cout<<n*min({q,h,s})<<endl;
  return 0;
}


Measured memory_bytes: 256