akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

#define mp make_pair


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

     // freopen("a.txt", "r", stdin);
   
      int n, k, c;
      string s;
      cin >> n >> k >> c >> s;
      
      vector<int> good;

      for (int i = 0; i < n; ++i) {
            if (s[i] == 'o') {
                  good.push_back(i);
            }
      }

      n = good.size();
      vector<int> dp(n);

      for (int i = n - 1; i >= 0; --i) {
            int it = upper_bound(good.begin(), good.end(), good[i] + c) - good.begin();
            if (it < good.size()) {
                  dp[i] = dp[it] + 1;
            }
            else {
                  dp[i] = 1;
            }
      }

      int when = -1e9, cnt = 0;

      for (int i = 0; i < n; ++i) {
            int L = upper_bound(good.begin(), good.end(), when + c) - good.begin();
            L = max(L, i + 1);
            int add = 0;
            if (L < good.size()) add = dp[L];
            if (add + cnt < k) {
                  cout << good[i] + 1 << "\n";
            }
            if (good[i] > when + c) {
                  when = good[i];
                  cnt++;
            }
      }

      return 0;
}

Measured memory_bytes: 3468
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;

bool cmp(const pair<long long, long long> &a, const pair<long long, long long> &b){
    return a.second < b.second;
}

int main(){
    long long n, m;
    cin >> n >> m;
    vector<pair<long long, long long> > a(m);
    for(int i = 0; i < m; ++i) cin >> a[i].first >> a[i].second;
    sort(a.begin(), a.end(), cmp);
    set<long long> ans;
    for(int i = 0; i < m; ++i){
        auto k = ans.lower_bound(a[i].first);
        if(k == ans.end() || *k >= a[i].second){
            ans.insert(a[i].second - 1);
        }
    }
    cout << ans.size();
}


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

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 2e5 + 5;

vector < int > V[N],v;

int H[N],T[N],A[N],n,m,i,j,x,y,ans;

void f(int x){
    v.pb(x);
    H[x] = 1;
    for(int i=0; i<V[x].size(); i++)
        if(!H[ V[x][i] ])
            f(V[x][i]);
}

int main(){
    cin >> n >> m;
    for(i=1;i<=n;i++) cin >> A[i];
    for(i=1;i<=m;i++){
        cin >> x >> y;
        V[x].pb(y); V[y].pb(x);
    }

    for(i=1;i<=n;i++){
        if(H[i]) continue;
        v.clear();
        f(i);
        for(j=0;j<v.size();j++)
            T[ A[ v[j] ] ] = 1;
        for(j=0;j<v.size();j++)
            if(T[ v[j] ])
                ans++;
        for(j=0;j<v.size();j++)
            T[ A[ v[j] ] ] = 0;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 12024
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#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;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
void solve(){

}

int main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    string t;
    cin>>t;
    t=="ABC"?cout<<"ARC"<<endl:cout<<"ABC"<<endl;

     return 0;

}
///Alhamdulillah



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    int n;cin>>n;
    int odd = 0,even = 0;
    rep(i,n){
        int a;cin>>a;
        if(a%2)odd++;
        else even++;
    }
    cout << (odd%2 ? "NO": "YES") << endl;

}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int n = 2e5 + 5;

int N;
int A[n], B[n];

int main(){
	cin >> N;
	for(int i = 0; i < N; ++i){
		cin >> A[i];
	}
	priority_queue<pair<int,int>> Q;
	for(int i = 0; i < N; ++i){
		cin >> B[i];
		if(B[i] > A[i])
			Q.push({B[i], i});
	}
	ll c = 0;
	while(!Q.empty()){
		int diff = Q.top().first;
		int i = Q.top().second;
		//cerr << "i: "<< i << " diff: "<< diff << endl;
		Q.pop();
		if(B[i] <= A[i])
			break;
		int nextV = max(B[(i+1)%N], B[(i+N-1)%N]);
		nextV = max(A[i], nextV);
		int nbS = B[(i+1)%N] + B[(i+N-1)%N];
		int cc = max(1, (B[i]-nextV)/nbS);
		B[i] -= cc*nbS;
		c+=cc;
		if(B[i] > A[i])
			Q.push({B[i], i});
		if(B[i] < 0)
			break;
	}
	bool v = true;
	for(int i = 0;i <N; ++i){
		v = v && (A[i] ==B[i]);
	}
	cout << (v?c:-1) << endl;
	return 0;
	
}


Measured memory_bytes: 3828
from collections import defaultdict



N,K = map(int, input().split())
A = list(map(int, input().split()))

"""
・K以下の非負整数の範囲で〜：桁DP感ある
・XORをとる：桁ごとに確認できる
・Xを選んで、f = X xor A1 + X xor A2 + ... + X xor AN
　 -> それぞれのAと毎回 xor 取るのではなく、桁ごとに xor を取ることができる　←　超重要のはず
　 -> A1 ~ AN の各桁（2進数の時の）に1が立っているのが何個あるか数えておく


遷移
dp[i][1] -> dp[i+1][1] : i-1桁目まででK未満が確定していれば、i桁目に1,0どちらを選んでもK未満
dp[i][0] -> dp[i+1][1]  : i-1桁目まででKと一致している場合、Kのi桁目が1なら、Xで0を選べば遷移できる
dp[i][0] -> dp[i+1][0]  : i桁目まで一致させる場合
"""

d = defaultdict(int)
for a in A:
    for i in range(45):
        if a & (1 << i):
            d[i] += 1

# dp[i+1][j] : Xをi桁目まで決めた時に、Kのi桁目までと厳密に一致するか（j=1でK未満）しないかの場合について、fの最大値
dp = [[-1 for _ in range(2)] for _ in range(45+1)]
# 初期化（何も見てない時のfの最大は0）
dp[0][0] = 0

for i in range(45):

    # Kの左からi番目に1が立ってるかどうか
    if K & (1 << (45 - 1 - i)):
        is_one = True
    else:
        is_one = False

    # Xの左からi桁目に1,0を設定した時にfが増加する量
    p0 = (2**(45-1-i)) * d[45-1-i]
    p1 = (2**(45-1-i)) * (N - d[45-1-i])

    # dp[i][1] -> dp[i+1][1] はXのi桁目に1,0を使えるから、より多い方を採用
    if dp[i][1] != -1:
        dp[i+1][1] = dp[i][1] + max(p1, p0)

    # dp[i][0] -> dp[i+1][1] はKのi桁目が1なら可能
    if dp[i][0] != -1:
        if is_one:
            dp[i+1][1] = max(dp[i+1][1], dp[i][0] + p0)
    
    # dp[i][0] -> dp[i+1][0] 
    if dp[i][0] != -1:
        if is_one:
            dp[i+1][0] = dp[i][0] + p1
        else:
            dp[i+1][0] = dp[i][0] + p0
    


print(max(dp[-1]))

Measured memory_bytes: 20792
n,a,b = map(int,input().split())
if n%(a+b) == 0:
    print((n//(a+b))*a)
elif n%(a+b) <= (a-1):
    print((n//(a+b))*a+n%(a+b))
else:
    print((n//(a+b))*a+a)

Measured memory_bytes: 3064
N,M,L = map(int, input().split())
Edges = [map(int, input().split()) for i in range(M)]
Q = int(input())
Queries = [map(int, input().split()) for i in range(Q)]

INF = 10**18
# 初期化
d = [[INF]*N for i in range(N)]
for i in range(N):
    d[i][i] = 0
for a,b,c in Edges:
    a -= 1
    b -= 1
    # 多重辺の場合はMIN
    d[a][b] = c
    d[b][a] = c
# 最適化(わーしゃゆふよいど)
for k in range(N):
    for i in range(N):
        # 左右は対称だろう
        for j in range(i+1,N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])
            d[j][i] = d[i][j]

# 初期化2
d2 = [[INF]*N for i in range(N)]
for i in range(N):
    d2[i][i] = 0
for i in range(N):
    for j in range(N):
        # 給油できるところに辺を張る
        if d[i][j] <= L:
            d2[i][j] = 1
for k in range(N):
    for i in range(N):
        for j in range(i+1,N):
            d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j])
            d2[j][i] = d2[i][j]
            

#query
for a,b in Queries:
    s = min(a,b)-1
    t = max(a,b)-1
    
    ans = d2[s][t]
    if ans == INF:
        ans = 0
    print(ans-1)

Measured memory_bytes: 107480
from collections import defaultdict


def main():
    num_box, num_people = map(int, input().split())
    data = list(map(int, input().split()))

    dp = defaultdict(int)
    dp[0] += 1
    count = 0
    for i in range(num_box):
        count += data[i]
        count %= num_people
        dp[count] += 1

    ans = 0
    for ele in dp.values():
        if ele >= 2:
            ans += (ele - 1) * ele // 2

    print(ans)





if __name__ == '__main__':
    main()


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

main()
{
    int a,b; cin>>a>>b;
    if(b&1)
    {
        cout << "No" << "\n";
        return 0;
    }

    b/=2;
    if(a<=b and 2*a>=b) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

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

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	vector<int>B(N);
	vector<int>C(N - 1); 
	vector<int>D;
	for (int n = 0 ;n<N;++n) {
		cin >> A[n];
		if (0 != n) {
			if (A[n]-1 == A[n-1]) {
				D.push_back(A[n-1]);
			}
		}
	}
	int ans = 0;	
	for (int n = 0; n < N; ++n) {
		cin >> B[n];
		ans += B[n];
	}	
	for (int n = 0; n < N - 1; ++n) {
		cin >> C[n];
	}	
	for (int n = 0; n < D.size(); ++n) {
		ans += C[D[n]-1];
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 3580
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long int a,b,k;
    cin>>a>>b>>k;
    if(a > k){
        cout<< a-k << " " << b <<endl;
    }
    else if((b-(k-a))>0){
        cout<< "0" << " " << (b-(k-a)) <<endl;
    }
    else {
        cout<< "0" << " " << "0" <<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  int ans=0;
  int l,r;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>l>>r;
    if(l>r){
      l-=r;
      ans+=l;
	ans++;
	}else{
      r-=l;
	ans+=r;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
  string n;
  cin>>n;
  if(n.at(0) == '7' || n.at(1) == '7' || n.at(2) == '7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" <<endl;
  }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

class SegmentTree
{
 private:
    int sz;
    vector<int> data;
 public:
    SegmentTree(int n){
        sz=1;
        while(sz<n) sz*=2;
        data.assign(2*sz,0LL);
    }
    void add(int k,int x){
        k+=sz;
        data[k]+=x;
        for(;k>1;k>>=1){
            data[k>>1]=data[k]+data[k^1];
        }
    }
    int get(int l,int r){
        int vl=0,vr=0;
        for(l+=sz,r+=sz;l<r;l>>=1,r>>=1){
            if(l&1) vl+=data[l++];
            if(r&1) vr+=data[--r];
        }
        return vl+vr;
    }
};

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

    int N,Q; cin>>N>>Q;
    SegmentTree seg(N);
    while(Q--){
        int q,x,y; cin>>q>>x>>y;
        x--;
        if(q==0) seg.add(x,y);
        else cout<<seg.get(x,y)<<endl;
    }
    return 0;
}


Measured memory_bytes: 4804
#include<bits/stdc++.h>
#define pb push_back
#define PI acos(-1)
#define mp make_pair
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y)
#define maxn 100010
#define S second
#define ll long long int
#define inf 1000002014
#define infl 1000000000000020000ll
#define mod 1000000007
#define clrs(x) memset(x,0,sizeof x)
#define sz(x) (int) x.size()
#define pi pair< int,int >
#define pii pair<pi,int>
#define pu push
#define ld long double
#define trace1(x)  cerr << #x << ": " << x << endl
#define trace2(x, y)  cerr << #x << ": " << x << " | " << #y << ": " << y << endl
using namespace std;
int main(int argc, char const *argv[])
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll x;
    cin>>x;
    if(x<=6)
    {
        cout<<"1\n";
        return 0;
    }
    else if(x<11)
    {
            cout<<"2\n";
        return 0;
    }
    else
    {
        ll q = x/11;
        ll ans = 2*q;
        ll done = q*11;
        x-=done;
        if(x==0)
        {
            cout<<ans<<"\n";
            return 0;
        }
        if(x<=6)
            ++ans;
        else if(x<=10)
            ans+=2;
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

using namespace std;

struct Edge {
    int to;
    int64 money;
    int64 time;
};

vector<Edge> graph[50];
int64 cost[50][50 * 50 + 1];
int64 C[50], D[50];
int N, M, S;

void Dijkstra() {
    using T = tuple<int64, int, int>;   // (cost, node, ginka)
    priority_queue<T, vector<T>, greater<T>> pque;

    for (int u = 0; u < 50; u++) {
        for (int c = 0; c <= 2500; c++) {
            cost[u][c] = (1LL << 60);
        }
    }
    cost[0][min(S, 50 * 50)] = 0;
    pque.emplace(cost[0][min(S, 50 * 50)], 0, min(S, 50 * 50));

    while (!pque.empty()) {
        int64 c;
        int u, g;
        tie(c, u, g) = pque.top(); pque.pop();

        if (c > cost[u][g]) continue;

        int ng = min(50 * 50, g + (int)C[u]);

        if (cost[u][ng] > c + D[u]) {
            cost[u][ng] = c + D[u];
            pque.emplace(cost[u][ng], u, ng);
        }

        for (const Edge& e : graph[u]) {
            if (e.money > g) continue;
            if (cost[e.to][g - e.money] <= c + e.time) continue;
            cost[e.to][g - e.money] = c + e.time;
            pque.emplace(cost[e.to][g - e.money], e.to, g - e.money);
        }
    }
}

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

    cin >> N >> M >> S;

    for (int i = 0; i < M; i++) {
        int U, V, A, B;
        cin >> U >> V >> A >> B;
        U--; V--;
        graph[U].push_back((Edge){ V, A, B });
        graph[V].push_back((Edge){ U, A, B });
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i] >> D[i];
    }

    Dijkstra();

    for (int u = 1; u < N; u++) {
        int64 ans = cost[u][0];
        for (int i = 0; i <= 2500; i++) {
            ans = min(ans, cost[u][i]);
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 5880
#include<iostream>
#include<stdio.h> // %lf
using namespace std; //or std::cin et al.

int main() {
	double r;
	double PI = 3.141592653589;
	cin >> r;
    printf("%lf %lf\n",PI*r*r,2*PI*r);
	return 0;
}


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

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

  int X[100];
  int Y[100];
  int H[100];
  for(int i = 0; i < N; i++) {
    scanf("%d %d %d", &X[i], &Y[i], &H[i]);
  }

  int init;
  for(init = 0; init < N; init++) {
    if(H[init] != 0) break;
  }

  for(int x = 0; x <= 100; x++) {
    for(int y = 0; y <= 100; y++) {
      int height = H[init] + abs(X[init] - x) + abs(Y[init] - y);

      int flag = 0;
      for(int i = 0; i < N; i++) {
	int tmpH = height - abs(x - X[i]) - abs(y - Y[i]);
	if(tmpH < 0) tmpH = 0;
	if(tmpH != H[i]) {
	  flag = 1;
	  break;
	}
      }
	
      if(flag == 0) {
	printf("%d %d %d\n", x, y, height);
	return 0;
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      (int)1e9+7
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;

int main(){
	int n;
	cin>>n;
	
	vi e,o;
	REP(i,n){
		int v;
		cin>>v;
		if(i%2) o.push_back(v);
		else e.push_back(v);
	}
	sort(ALL(e));
	e.push_back(-1);
	sort(ALL(o));
	o.push_back(-1);
	
	
	vector<pii> p(4);
	REP(i,4) p[i]=make_pair(-1,0);
	int cnt=1;
	for(int i=1;i<e.size();++i){
		if(e[i-1]==e[i]) cnt++;
		else{
			if(cnt>p[0].second){
				p[1]=p[0];
				p[0]=make_pair(e[i-1],cnt);
			}else if(cnt>p[1].second){
				p[1]=make_pair(e[i-1],cnt);
			}
			cnt=1;
		}
	}
	cnt=1;
	for(int i=1;i<o.size();++i){
		if(o[i-1]==o[i]) cnt++;
		else{
			if(cnt>p[2].second){
				p[3]=p[2];
				p[2]=make_pair(o[i-1],cnt);
			}else if(cnt>p[3].second){
				p[3]=make_pair(o[i-1],cnt);
			}
			cnt=1;
		}
	}
	
	//REP(i,4) printf("%d %d\n",p[i].first,p[i].second);//!!!
	
	if(p[0].first==p[2].first){
		if(p[0].second+p[3].second>p[1].second+p[2].second){
			cout<<n-p[0].second-p[3].second<<endl;
		}else cout<<n-p[1].second-p[2].second<<endl;
	}else cout<<n-p[0].second-p[2].second<<endl;
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
    i64 n;
    cin >> n;
    i64 ans = 0;
    if (n % 2 == 0) {
        for (i64 x = 5; x <= n; x *= 5) {
            ans += n / 2 / x;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

ll N, M, K;
int main(void){
    int Q;
    cin >> Q;
    ll com, x, y;
    cin >> com >> x >> y;
    ll ans = y, cnt = 1;
    multiset<ll> all;
    all.insert(x);
    auto mid = all.begin();
    for(int i = 1; i < Q; i++){
        cin >> com;
        if(com == 1){
            cin >> x >> y;
            if(cnt % 2 == 1){
                if(x >= *mid){
                    ans += x - *mid;
                    all.insert(x);
                }else{
                    ans += *mid - x;
                    all.insert(x);
                    mid--;
                }
            }else{
                if(x >= *mid){
                    all.insert(x);
                    mid++;
                    ans += x - *mid;
                }else{
                    ans += *mid - x;
                    all.insert(x);
                }
            }
            cnt++;
            ans += y;
        }else{
            cout << *mid << " " << ans << endl;
        }
    }
}


Measured memory_bytes: 9600
n = int(input())
a, b = [list(map(int, input().split())) for i in range(2)]

ans = 0
for i in range(n):
  ans += min(a[i], b[i])
  b[i] = max(0, b[i]-a[i])
  ans += min(a[i+1], b[i])
  a[i+1] = max(0, a[i+1]-b[i])
print(ans)

Measured memory_bytes: 18624
// cout << "Case #" << test << ": ";
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<ll> a(n), rui(n + 1, 0);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    for(int i = 0; i < n; i++) {
        rui[i + 1] = rui[i] + a[i];
    }
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        int prev = i + 1;
        int now = upper_bound(all(a), 2 * rui[prev]) - a.begin();
        // cout << prev << "**" << now << endl;
        while(now != prev) {
            prev = now;
            now = upper_bound(all(a), 2 * rui[prev]) - a.begin();
            // cout << prev << ":" << now << endl;
        }
        ans += (now == n);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define SE second
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define mp make_pair
#define ll long long
#define LLI long long int
#define REP(i,a,b) for(long long i=a;i<b;i++)
#define PER(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define Arrays(a, size) sort((a), (a)+(size))
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
using namespace std;

int _dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
int _dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };

vector<ll>A;
vector<pair<ll,ll>> pairs;
ll n,m;
int main(){
    cin>>n>>m;
    for(ll i=0;i<n;i++) {
        ll a;
        cin >> a;
        A.pb(a);
    }
    SORT(A);
    for(ll i=0;i<m;i++) {
        ll b, c;
        cin >> b >> c;
        pairs.pb(make_pair(c, b));
    }
    RSORT(pairs);
    ll inserted=0,move=0;
    for(ll i=0;i<m;i++){
    ll c=pairs[i].first,b=pairs[i].second;
    ll temp=lower_bound(A.begin()+inserted,A.end(),c)-(A.begin()+inserted);
    //cout<<temp<<endl;
    for(ll j=0;j<min(b,temp);j++){
        A.at(j+move)=c;
        inserted++;
    }
    move=inserted;
    }
    ll sum=0;
    for(ll i=0;i<A.size();i++){
        //cout<<A.at(i)<<endl;
        sum+=A.at(i);
    }
    cout<<sum<<endl;
};

Measured memory_bytes: 3188
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)
int count(const string& ref, const string& target) {
  int cnt = 0;
  int pos = ref.find(target);
  const int target_size = target.size();

  while (pos != string::npos) {
    ++cnt;
    pos = ref.find(target, pos + target_size);
  }
  return cnt;
}

bool in(int target, int max) { return 0 <= target && target < max - 1; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<string> S(N);
  int at_sum = 0;
  vector<pair<bool, bool>> BorA(N, make_pair(false, false));
  int rel_num = 0;
  int Bnum = 0;
  int Anum = 0;
  REP(i, N) {
    cin >> S[i];
    at_sum += count(S[i], "AB");
    if (S[i].front() == 'B') ++Bnum;
    if (S[i].back() == 'A') ++Anum;
    if (S[i].front() == 'B' || S[i].back() == 'A') {
      ++rel_num;
    }
  }
  // cout << Anum << " " << Bnum << " " << at_sum <<" "<<rel_num<< endl;
  int addable_num = min(Anum, Bnum);
  if (addable_num == rel_num && rel_num !=0) --addable_num;
  cout << at_sum + addable_num << endl;

  return 0;
}


Measured memory_bytes: 1144
s = list(input())
removed = False
removing = False
for i in range(len(s)):
    last = list("keyence")
    j = i
    while j < len(s):
        if s[j] == last[0]:
            del last[0]
            if not last:
                print("YES")
                exit()
        else:
            j += 1
            break
        j += 1
    # 残り文字がlast = enceみたいになるので
    # sの末尾がlast = enceになっていればOK
    if i == 0 and j + len(last) <= len(s) and s[len(s)-len(last):] == last:
        print("YES")
        exit()
print("NO")

Measured memory_bytes: 3064
while True:
  try:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
  except EOFError:
    break
  vec_b = [x2-x1, y2-y1]
  vec_c = [x3-x1, y3-y1]
  vec_p = [xp-x1, yp-y1]
  a = (vec_p[0]*vec_c[1] - vec_p[1]*vec_c[0]) / (vec_b[0]*vec_c[1] - vec_b[1]*vec_c[0])
  b = (vec_p[0]*vec_b[1] - vec_p[1]*vec_b[0]) / (vec_b[1]*vec_c[0] - vec_b[0]*vec_c[1])
  if ((a > 0) and (b > 0) and (a+b < 1)):
    print("YES")
  else:
    print("NO")


Measured memory_bytes: 5592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;
    int[] counts;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        counts = new int[3];
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if (a % 2 != 0) {
                counts[0]++;
            } else if (a % 4 != 0) {
                counts[1]++;
            } else {
                counts[2]++;
            }
        }
        solve();
    }

    void solve() {
        if (counts[0] + Math.min(counts[1], 1) <= counts[2] + 1) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

inline long int c() {
  long int N, M;
  cin >> N >> M;
  if (N < M) swap(N, M);
  if (N == 1 and M == 1) return 1;
  if (N >= 2 and M == 1) return N - 2;
  if (M == 2) return 0;
  return (N - 2) * (M - 2);
}

inline long int d() {
  long int N;
  long int K;
  cin >> N >> K;
  if (K == 0) return N * N;
  long int count = 0;
  for (long int b = K + 1; b <= N; ++b) {
    long int x = (N - K) / b;
    long int y = (N - b + 1) / b;
    if (x != y) {
      count += (b - K) * (x+1) - (b - (N - b + 1) % b);
    } else {
      count += (b - K) * (x+1);
    }
  }
  return count;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << d() << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    ll n; cin >> n;
    int M = 10000;
    vector<int> v(M);
    map<int, int> mp;
    for (int x = 1; x <= 100; x++) {
        for (int y = 1; y <= 100; y++) {
            for (int z = 1; z <= 100; z++) {
                int ans = x*x + y*y + z*z + x*y + y*z + z*x;
                mp[ans]++;
            }
        }
    }
    rep1(i,n+1) {
        cout << mp[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 5472
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    
    vector<int> a(M);
    vector<int> b(M);
    
    vector<int> ans(N);
    
    for(int i = 0; i < M; i++){
        cin >> a.at(i) >> b.at(i);
        a.at(i)--;//indexed変換
        b.at(i)--;//
        ans.at(a.at(i))++;//カウント
        ans.at(b.at(i))++;
    }
    
    for(int i = 0; i < N; i++){
        cout << ans.at(i) << endl;
    }
}


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

typedef long long int lli;

int main(){
	lli ans=0;
	lli A, B;
	int N, x[100005];
	scanf("%d %lld %lld", &N, &A, &B);
	for(int i=0; i<N; ++i)
		scanf("%d", x+i);
	for(int i=1; i<N; ++i)
		ans += min(B, A * (x[i] - x[i-1]));
	printf("%lld\n", ans);
}


Measured memory_bytes: 512
a,b,c = map(int,input().split())
k = int(input())
for i in range(k):
    if b <= a:
        b = b*2
        continue
    if b>a and c<=b:
        c = c*2
    if b>a and c>b:
        print("Yes")
        exit()
    

print("No")

    

Measured memory_bytes: 61884
import java.util.*;
public class Main { 
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int N = stdIn.nextInt();
			int M = stdIn.nextInt();
			if(N == 0 && M == 0) break;
			int r = stdIn.nextInt();
			int[] a = new int[M];
			boolean[][] time = new boolean[M][2001];
			int last = -1;
			int lastm = -1;
			int lasts = -1;
			for(int i = 0; i < r; i++) {
				int t = stdIn.nextInt();
				int n = stdIn.nextInt();
				int m = stdIn.nextInt();
				int s = stdIn.nextInt();
				
				if(s == 1) {
					if(a[m-1] == 0) {
						time[m-1][t] = true;
						if(last == t && lastm == m && lasts != s) {
							time[m-1][t] = false;
						}
					}
					a[m-1]++;
				}
				if(s == 0) {
					if(a[m-1] == 1) {
						time[m-1][t] = true;
						if(last == t && lastm == m && lasts != s) {
							time[m-1][t] = false;
						}
					}
					a[m-1]--;
				}
				last = t;
				lastm = m;
				lasts = s;
			}
			int q = stdIn.nextInt();
			for(int i = 0; i < q; i++) {
				int ts = stdIn.nextInt();
				int te = stdIn.nextInt();
				int m = stdIn.nextInt();
				int count = 0;
				boolean nowUse = false;
				
				for(int j = 0; j < 2001; j++) {
					if(nowUse && time[m-1][j]) {
						nowUse = false;
					}
					else if(!nowUse && time[m-1][j]) {
						nowUse = true;
					}
					if(nowUse && j >= ts && j < te) {
						count++;
					}
					
					if(j >= te) break;
					
				}
				System.out.println(count);
				
			}
		}
	}
}

Measured memory_bytes: 119564
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define ll long long int
#define pii pair<int, int>
#define mod 1000000007
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, m, u, v, z = 0;
    bool b[9][9] = {};
    cin >> n >> m;
    vector<int> a;
    fr(m) cin >> u >> v, b[u][v] = b[v][u] = 1;
    fr1(n) a.push_back(i);
    do {
        bool y = 1;
        for (int i = 1; i < n; i++) if (!b[a[i - 1]][a[i]]) y = 0;
        if (y) z++;
        next_permutation(a.begin(), a.end());
    } while (a[0] == 1);
    cout << z << '\n';
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int h, w;
	for(;;){
		cin >> h;
		cin >> w;
		if(0 == h && 00 == w){break;}
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
  string s;
  cin>>s;
  if(s[2]==s[3] && s[4]==s[5])
  {
   cout<<"Yes"; 
  }
  else
    cout<<"No";
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3644
<?php
error_reporting(0);
//$N = explode(" ",trim(fgets(STDIN)));
$N = trim(fgets(STDIN));
//list($H,$W) = explode(" ",trim(fgets(STDIN)));
for($i=0;$i<$N;$i++) {
  $v = trim(fgets(STDIN));
  if ($v[0]=='M'||$v[0]=='A'||$v[0]=='R'||$v[0]=='C'||$v[0]=='H') {
    $S[]=$v;
  }
}
$S = array_unique($S);
foreach($S as $v) {
  $V[]=$v[0];
}
$cn = array_count_values($V);
$res=0;
//3つづつの組み合わせ数を足し合わせればいい？
if (isset($cn["M"])&&isset($cn["A"])&&isset($cn["R"])) {
  $res += $cn["M"]*$cn["A"]*$cn["R"];
}
if (isset($cn["M"])&&isset($cn["A"])&&isset($cn["C"])) {
  $res += $cn["M"]*$cn["A"]*$cn["C"];
}
if (isset($cn["M"])&&isset($cn["A"])&&isset($cn["H"])) {
  $res += $cn["M"]*$cn["A"]*$cn["H"];
}
if (isset($cn["M"])&&isset($cn["R"])&&isset($cn["C"])) {
  $res += $cn["M"]*$cn["R"]*$cn["C"];
}
if (isset($cn["M"])&&isset($cn["R"])&&isset($cn["H"])) {
  $res += $cn["M"]*$cn["R"]*$cn["H"];
}
if (isset($cn["M"])&&isset($cn["C"])&&isset($cn["H"])) {
  $res += $cn["M"]*$cn["C"]*$cn["H"];
}
if (isset($cn["A"])&&isset($cn["R"])&&isset($cn["C"])) {
  $res += $cn["A"]*$cn["R"]*$cn["C"];
}
if (isset($cn["A"])&&isset($cn["R"])&&isset($cn["H"])) {
  $res += $cn["A"]*$cn["R"]*$cn["H"];
}
if (isset($cn["A"])&&isset($cn["C"])&&isset($cn["H"])) {
  $res += $cn["A"]*$cn["C"]*$cn["H"];
}
if (isset($cn["R"])&&isset($cn["C"])&&isset($cn["H"])) {
  $res += $cn["R"]*$cn["C"]*$cn["H"];
}
printf("%d\n",$res);


Measured memory_bytes: 39628
def main():
    A, B, C, D = list(map(int, input().split()))
    candiv_C = num_can_div(A, B, C)
    candiv_D = num_can_div(A, B, D)
    candiv_lcm = num_can_div(A, B, lcm(C, D))

    print(B-A+1 - candiv_C - candiv_D + candiv_lcm)

def num_can_div(A, B, x):
    return B//x - (A-1)//x

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

main()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,y; cin >> n >> y;
    for(int i = 0; i <= n; i++){
        int m = n-i;
        for(int j = 0; j <= m; j++){
            int k = m-j;
            if(i*10000+j*5000+k*1000 == y) {cout << i << " " << j << " " << k << endl; return 0;}
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <fstream>
#include <algorithm>
#include <queue>
#include <cassert>
#include <stack>

using namespace std;

void print(vector<int> &b) {
    for (auto i : b) {
        cout << i << " ";
    }
}


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


    int n, c = 0;
    string s;
    cin >> n >> s;
    for (char i : s) {
        if (i == 'R') {
            c++;
        }
    }
    cout << (c > s.size() / 2 ? "Yes" : "No");
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    vvi card(3, vi(3));
    rep(i, 3) rep(j, 3) cin >> card[i][j];
    int n;
    cin >> n;
    V(V(bool)) mark(3, V(bool)(3, false));
    rep(i, n) {
        int b;
        cin >> b;
        rep(i, 3) rep(j, 3) if(b==card[i][j]) mark[i][j] = true;
    }

    int res = false;
    rep(i, 3) {
        if(mark[i][0]&&mark[i][1]&&mark[i][2]) res = true;
        if(mark[0][i]&&mark[1][i]&&mark[2][i]) res = true;
    }
    if(mark[0][0]&&mark[1][1]&&mark[2][2]) res = true;
    if(mark[0][2]&&mark[1][1]&&mark[2][0]) res = true;

    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <math.h>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

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

	vector<ll> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];

	sort(a.begin(), a.end(), greater<ll>());

	ll ans = 0;
	for (int i = 1; i < n; i++) {
		ans += a[i / 2];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4840
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え
    import decimal
    #N = int(input())
    A,B =  input().split()
    A=decimal.Decimal(A)
    B = decimal.Decimal(B)
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    print(math.floor(A*B))




if __name__ == "__main__":
    main()

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

int main(){
    int m, n;
    scanf("%d%d", &n,&m);
    if(n == 1 || m == 1) cout<<"1\n";
    else{
        long long c = ((long long)n*(long long)m + 1)*.5;
        cout<<c<<'\n';
    }

    return 0;
}

Measured memory_bytes: 3772
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() { 
    int h,w;cin >> h >> w;
    vvc mp(h,vc(w));
    vvi a(h,vi(w)),b(h,vi(w));
    rep(i, h) rep(j, w) {
        cin >> mp[i][j];
        if(mp[i][j]=='#')a[i][j]=0,b[i][j]=0;
    }
    
    rep(i, h) {
        int count = 0;
        rep(j, w) {
            int k = j;
            while(j<w&&mp[i][j]!='#'){
                count++;
                j++;
            }
            for(;k<j;k++)a[i][k]=count;
            count=0;
        }
    }
    rep(j, w) {
        int count = 0;
        rep(i, h) {
            int k = i;
            while(i<h&&mp[i][j]!='#'){
                count++;
                i++;
            }
            for(;k<i;k++)b[k][j]=count;
            count=0;
        }
    }
    /*rep(i, h) {
        rep(j, w) {
            cout << a[i][j];
            if(j==w-1)cout << endl;
            else cout <<' ';
        }
    }
    cout << endl;
    rep(i, h) {
        rep(j, w) {
            cout << b[i][j];
            if(j==w-1)cout << endl;
            else cout <<' ';
        }
    }*/
    int ma = -1;
    rep(i, h) rep(j, w) chmax(ma,a[i][j]+b[i][j]);
    cout << ma-1 << endl;
    return 0;
}

Measured memory_bytes: 70048
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
	int n, k, i;
	int x[100000];
	scanf("%d%d", &n, &k);
	for(i=0; i<n; i++){
		scanf("%d", x+i);
	}
	int l=n-k+1;
	int min=INT_MAX;
	for(i=0; i<l; i++){
		int now;
		if(x[i]>=0){
			now = x[i+k-1];
		}else if(x[i+k-1]<=0){
			now = -x[i];
		}else if(-x[i]<=x[i+k-1]){
			now = -x[i]*2 + x[i+k-1];
		}else{
			now = x[i+k-1]*2 - x[i];
		}
		if(now<min) min=now;
	}
	printf("%d\n", min);
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll MOD = 1000000007;
ll INF =1<<30;

int main(){
    int a,b;
    cin >> a>>b;
    if(a+b==15) cout << '+' <<endl;
    else if(a*b==15) cout << '*' <<endl;
    else cout << 'x' <<endl;
}

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

using namespace std;

int main(){
  int w,d;
  while(cin >> w >> d,w) {
    int cntw[21]={},cntd[21]={};
    int h;
    for(int i=0;i<w;++i) cin >> h,cntw[h]++;
    for(int i=0;i<d;++i) cin >> h,cntd[h]++;
    int ans=0;
    for(int i=0;i<=20;++i)
      ans+=i*max(cntw[i],cntd[i]);
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 2980
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        vector<string> s(8);
        for(int i=0; i<8; ++i){
            if(!(cin >> s[i]))
                return 0;
        }

        int dy[] = {3, 0, 2, 1, 2, 1};
        int dx[] = {0, 3, -1, 2, 1, -1};

        bool ok = false;
        for(int i=0; i<8; ++i){
            for(int j=0; j<8; ++j){
                if(ok || s[i][j] == '0')
                    continue;
                for(int k=0; k<6; ++k){
                    if(i+dy[k] < 8 && 0 <= j+dx[k] && j+dx[k] < 8 && s[i+dy[k]][j+dx[k]] == '1'){
                        cout << (char)('B' + k) << endl;
                        ok = true;
                        break;
                    }
                }
                if(!ok){
                    cout << 'A' << endl;
                    ok = true;
                }
            }
        }
    }
}

Measured memory_bytes: 0