akhauriyash/Code-Regression huggingface dataset:
"""
準備度の余剰分を不足分に充てる。
なるべく余剰分が大きいものから割り振っていく。
"""
N = int(input())
A_LI = list(map(int, input().split()))
B_LI = list(map(int, input().split()))
shortage_list = []
surplus_list = []
for i in range(N):
    if A_LI[i] == B_LI[i]:
        # 余剰(不足)分0のやつがリストに入ることを避けたいのでこうしとく↓
        continue
    elif A_LI[i] < B_LI[i]:
        shortage_list.append(B_LI[i] - A_LI[i])
    else:
        surplus_list.append(A_LI[i] - B_LI[i])
shortage_list.sort(reverse=True)
surplus_list.sort(reverse=True)
if sum(shortage_list) > sum(surplus_list):
    print(-1)
else:
    if len(shortage_list) == 0:
        print(0)
        exit()
    shortage_idx = 0
    surplus_idx = 0
    shortage = shortage_list[0]
    surplus = surplus_list[0]
    surplus_change_cnt = 1
    while shortage_idx < len(shortage_list):
        tmp = min(shortage, surplus)
        shortage -= tmp
        surplus -= tmp
        # 0以下になったらおかわりする
        if shortage <= 0:
            shortage_idx += 1
            if shortage_idx == len(shortage_list):
                break
            shortage += shortage_list[shortage_idx]
        elif surplus <= 0:
            surplus_idx += 1
            if shortage_idx == len(shortage_list):
                break
            surplus += surplus_list[surplus_idx]
            surplus_change_cnt += 1
    print(len(shortage_list) + surplus_change_cnt)


Measured memory_bytes: 97624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)


int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    for(int i = 0; i < k; i++){
        if(i%2==0){
            if(a%2==1){
                a--;
                b += a/2;
                a -= a/2;
            }else{
                b += a/2;
                a -= a/2;
            }
        }else{
            if(b%2==1){
                b--;
                a += b/2;
                b -= b/2;
            }else{
                a += b/2;
                b -= b/2;
            }

        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    vector<pair<int, int>> m(n);
    for (auto i = 0; i < n; i++) cin >> m[i].first >> m[i].second;

    vector<int> num(n);
    iota(num.begin(), num.end(), 0);

    double dist = 0; int count = 0;
    do {
        for (auto i = 1; i < (int)num.size(); i++) {
            dist += hypot((double)(m[num[i]].first - m[num[i - 1]].first), (double)(m[num[i]].second - m[num[i - 1]].second));
        }
        count++;
    } while(next_permutation(num.begin(), num.end()));
    // cout << dist << " " << count << endl;

    cout << fixed << setprecision(10) << dist / count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

constexpr ll INF = 1LL << 62;
constexpr ll MOD = 1e9 + 7;

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

    ll N;
    cin >> N;
    vector<ll> T(N), A(N);
    for (auto&& t : T) {
        cin >> t;
    }
    for (auto&& a : A) {
        cin >> a;
    }

    vector<ll> H(N);
    for (ll i = 0; i < N; i++) {
        H[i] = min(T[i], A[i]);
    }

    vector<ll> tv(N), av(N);
    tv[0] = H[0];
    av.back() = H.back();
    for (ll i = 1; i < N; i++) {
        tv[i] = max(tv[i - 1], H[i]);
    }

    for (ll j = N - 2; j >= 0; j--) {
        av[j] = max(av[j + 1], H[j]);
    }

    if (tv != T || av != A) {
        cout << 0 << endl;
        return 0;
    }

    vector<ll> G(N, 0);
    G[0] = 1;
    G[N - 1] = 1;
    ll i = 1;
    while (i < N - 1 && H[i + 1] >= H[i]) {
        if (H[i] == H[i - 1]) {
            G[i] = H[i];
        } else {
            G[i] = 1;
        }
        i++;
    }

    ll j = N - 2;
    while (j >= i) {
        if (H[j] == H[j + 1]) {
            G[j] = H[j];
        } else {
            G[j] = 1;
        }
        j--;
    }

    ll ans = 1;
    for (auto g : G) {
        ans *= g;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 4992
#include <iostream>


using namespace std; 

int main() { 
	int a,b,c;
    
    cin>>a>>b>>c;
    
    if( a < c && b > c){
    	cout<<"Yes"<<endl;
    }else if(a > c && b < c){
    	cout<<"Yes"<<endl;
    }else{
    	cout<<"No"<<endl;
    }
    
}

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

s = input()

ans = True
if n%2 == 1 :
  ans = False
else :
  j = n//2
  i, k = 0, j
  while i < j:
    if s[i] != s[k]:
      ans = False
    i+=1
    k+=1
if ans :
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
def bubbleSort(c):
    for i in range(0, len(c) - 1):
        for j in range(len(c)-1, i, -1):
            if c[j][1] < c[j-1][1]:
                c[j], c[j-1] = c[j-1], c[j]


def selectionSort(c):
    for i in range(0, len(c)):
        minj = i
        for j in range(i, len(c)):
            if c[j][1] < c[minj][1]:
                minj = j
        c[i], c[minj] = c[minj], c[i]


def isStable(c1, c2):
    for i in range(0, len(c1)):
        if c1[i][0] != c2[i][0]:
            return False
    return True


import copy
n = int(input())
c1 = input().split()
c2 = copy.copy(c1)

bubbleSort(c1)
selectionSort(c2)
print(*c1)
print("Stable")
print(*c2)
print("Stable") if isStable(c1, c2) else print("Not stable")



Measured memory_bytes: 6344
import math

a, b, x = map(int, input().split())

s = x / a

if s >= a * b / 2:
    h = (a * b - s) * 2 / a
    radian = math.atan2(h, a)
else:
    w = s * 2 / b
    radian = math.atan2(b, w)
ans = math.degrees(radian)
print(ans)


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

using namespace std;
#define REP(i, n) for(int i=0; i < (int)(n); ++i)
#define REPR(i, n) for(int i=n; i>= 0; --i)
#define FOR(i, m, n) for(int i=m; i<(n); ++i)

using ll = long long;

int H, W, K;
vector<string> s;

int main(){
    cin >> H >> W >> K;
    s.resize(H);
    REP(i, H){
        cin >> s[i];
    }
    vector<bool> isBery(W+1, true);
    REP(i, W){
        bool flag = false;
        REP(j, H){
            if(s[j][i] == '#'){
                flag = true;
            }
        }
        isBery[i] = flag;
    }
    vector<vector<int>> ans(H, vector<int>(W, 0));
    int cnt = 1;
    if(isBery[0]){
        REP(i, W){
            if(isBery[i]){
                int first = 0;
                while(s[first][i] =='.'){
                    ans[first][i]=cnt;
                    first++;
                }
                ans[first][i] = cnt;
                first++;
                FOR(j, first, H){
                    if(s[j][i] =='#'){
                        cnt++;
                    }
                    ans[j][i] = cnt;
                }
                cnt++;
            }
            else{
                REP(j, H){
                    ans[j][i] = ans[j][i-1];
                }
            }
        }
    }
    else{
        int after = 0;
        while(!isBery[after]){
            after++;
        }
        FOR(i, after, W){
            if(isBery[i]){
                int first = 0;
                while(s[first][i] =='.'){
                    ans[first][i]=cnt;
                    first++;
                }
                ans[first][i] = cnt;
                first++;
                FOR(j, first, H){
                    if(s[j][i] =='#'){
                        cnt++;
                    }
                    ans[j][i] = cnt;
                }
                cnt++;
            }
            else{
                REP(j, H){
                    ans[j][i] = ans[j][i-1];
                }
            }
        }
        REPR(i, after-1){
            REP(j, H){
                ans[j][i] = ans[j][i+1];
            }
        }
    }
    REP(i, H){
        REP(j, W){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    

    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  int n, m, X, Y; cin >> n >> m >> X >> Y;
  vector<int> x(n), y(m);
  rep(i, n) {
    cin >> x.at(i);
  }
  rep(i, m) {
    cin >> y.at(i);
  }

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());

  for(int i=x.at(n-1)+1; i<=y.at(0); i++) {
    if (X < i && i <= Y) {
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
}

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

string S,T;
bool flag;
int main() {
  flag=true;
  cin>>S;
  cin>>T;
  for(int i=0;i<S.size();i++){
      if(flag){
        if(T==S.substr(S.size()-i, i)+S.substr(0, S.size()-i)){
            cout<<"Yes"<<"\n";
            flag=false;
        }
      }
  }
  if(flag){
      cout<<"No"<<"\n";
  }
}

Measured memory_bytes: 256
import numpy as np	
import sys
stdin = open(0)
N,M = (stdin.readline()).split()
N = int(N)
M = int(M)
sc = []
ans = np.array([-1,-1,-1])
for i in range(M):
  sc.append(stdin.readline().split())
sc = np.array(sc, dtype='int')

# error input
if (N<1)|(N>3):
  print(-1)
  sys.exit()
if (M<0)|(M>5):
  print(-1)
  sys.exit()
for i in range(M):
  if(sc[i,0]>N)|(sc[i,0]<1):
    print(-1)
    sys.exit()
  if(sc[i,1]>9)|(sc[i,1]<0):
    print(-1)
    sys.exit()
  
#conflict
for i in range(M):
  for j in range(i+i,M):
    if ((sc[i,0] == sc[j,0]) & (sc[i,1] != sc[j,1])):
      print(-1)
      sys.exit()

ans = np.array([-1,-1,-1])
for i in range(M):
  ans[sc[i,0]-1] = sc[i,1]

if N==1:
  if(ans[0]==-1):
    answer = 0
  else:
    answer = ans[0]
  print(answer)
  sys.exit()
elif N==2:
  if(ans[0]==-1):
    ans[0]=1
  elif(ans[0]==0):
    print(-1)
    sys.exit()
  if(ans[1]==-1):
    ans[1] =0
  answer = ans[0]*10+ans[1]
  print(answer)
  sys.exit()
else:
  if(ans[0]==0):
    print(-1)
    sys.exit()
  elif(ans[0]==-1):
    ans[0] = 1
  if(ans[1]==-1):
    ans[1]=0
  if(ans[2]==-1):
    ans[2]=0
  answer = ans[0]*100+ans[1]*10+ans[2]
  print(answer)
  sys.exit()
  


Measured memory_bytes: 12504
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <limits>
#include <bitset>
#include <map>

using namespace std;

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

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

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;
}

signed main() {
    string S; cin >> S;
    
    vector<int> ans(S.length(), 0);

    int Rcount = 0;
    int lastRpos = 0;

    rep(i, S.length()) {
        if (S[i] == 'R') {
            Rcount++;
            lastRpos = i;
        }
        else {
            ans[i-1] += Rcount-Rcount / 2;
            ans[i] += Rcount / 2;
            Rcount = 0;
            if ((i - lastRpos) % 2 == 0) {
                ans[lastRpos] ++;
            }
            else {
                ans[lastRpos + 1]++;
            }
        }
    }
    rep(i, S.length()) {
        cout << ans[i] << " ";
    }
    cout << endl;
}
 

Measured memory_bytes: 1104
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

int n,t,ans;int v[210000];
signed main(){
  cin>>n>>t;rep(i,n)cin>>v[i];
  rep(i,n-1){
    ans += min(t, v[i+1]-v[i]);
  }
  ans += t;
  cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.InputMismatchException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try {
			Scanner scanner = new Scanner(System.in);
			int x = scanner.nextInt();

			int i = 25 - x;

			System.out.print("Christmas");

			for (; i > 0; i--) {
				System.out.print(" Eve");
			}

			System.out.println();
			scanner.close();
		} catch (InputMismatchException e) {
			System.out.println("整数を入力してください。");
		}
	}

}


Measured memory_bytes: 19796
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize
 
#define sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define F0R(i, a) for (ll i = 0; i < (a); i++)
#define FORR(i, a, b) for (ll i = a; i >= (b); i--)
#define F0RR(i, a) for (ll i = a; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
 
using pii = pair<ll, ll>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;
 
ll gcd(ll a,ll b)
{
    if(b==0)return a;
    else return gcd(b,a%b);
}
ll po(ll a,ll b)
{
    ll ans = 1;
    while(b--)
        ans*=a;
    return ans;
}
ll pom(ll a,ll b,ll mod)
{
    if(b==0)return 1;
    ll k = pom(a,b/2,mod);
    if(b%2==0)return (k*k)%mod;
    else return ((k*k)*mod*a)%mod;
}
 
ll sqdist(ll a,ll b,ll c,ll d)
{
    return (a-c)*(a-c)+(b-d)*(b-d);
}


void solve()
{
    ll a,b;
    cin>>a>>b;
    if(500*a>=b)cout<<"Yes";
    else cout<<"No";
                                                                                           
}

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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    // ll t;
    //cout<<"Y"<<endl;
    //cin>>t;
    //while(t--)
        solve();
}

Measured memory_bytes: 256
#include <cstdio>
#include <unordered_map>
#include <algorithm>
#include <cctype>

#define fin stdin
#define fout stdout

#define x first
#define y second

#define ll long long

#define LIM (10LL * 1000 * 1000 * 1000)
#define MAXR 100000
#define MAXC 3200
#define MAX0 452

#define MAXN 100000

#define BUF_SIZE 1<<17

int pos = BUF_SIZE;
char buf[BUF_SIZE];

inline char nextch(){
    if(pos == BUF_SIZE) fread(buf, BUF_SIZE, 1, fin), pos=0;
    return buf[pos ++];
}

inline ll read(){
    ll x = 0;
    char ch = fgetc(fin);
    while(!isdigit(ch)) ch=fgetc(fin);
    while(isdigit(ch)){
        x = 10 * x + ch - '0';
        ch = fgetc(fin);
    }
    return x;
}

struct myc{
    int x;
    ll y;
};

std::unordered_map <ll, int> p2;
std::unordered_map <ll, myc> mp;

int pr[MAX0 + 1];
bool c[MAXR + 1];

ll t[MAXN + 1];
int k;

inline void add(ll a, ll b){
    auto &u = mp[a];
    u.x ++;
    u.y = b;

    if(u.x == 1)
        t[++ k] = a;
}

inline void inmult(ll &a, ll b){
    if(a > 0){
        a *= b;
        if(a > LIM)
            a = -1;
    }
}

int main(){
    for(int i = 2; i * i <= MAXR; i ++)
        if(c[i] == 0)
            for(int j = i * i; j <= MAXR; j += i)
                c[j] = 1;

    for(int i = 2;  i <= MAXC; i ++)
        if(c[i] == 0)
            pr[++ pr[0]] = i;

    //printf("%d", pr[0]);

    for(int i = MAXC + 1; i <= MAXR; i ++)
        if(c[i] == 0)
            p2[1LL * i * i] = i;

    int n = read();

    int ans = 0;
    bool cub = 0;
    for(int i = 1; i <= n; i ++){
        ll x = read(), imag = 1, rev = 1;

        int q = 1;
        while(q <= pr[0] && x != 1){
            int s = 0;
            while(x % pr[q] == 0)
                s ++, x /= pr[q];
            s %= 3;
            if(s > 0){
                for(int j = 0; j < s; j ++)
                    imag *= pr[q];
                for(int j = 0; j < 3 - s; j ++)
                    inmult(rev, pr[q]);
            }
            q ++;
        }

        if(x == 1){
            if(rev == -1) ans ++;
            else if(rev == 1) cub = 1;
            else add(imag, rev);
        }else{
            int u = p2[x];
            if(u == 0){
                if(x <= MAXR){
                    inmult(rev, x);
                    inmult(rev, x);
                    if(rev == -1) ans ++;
                    else add(imag * x, rev);
                }else ans ++;
            }else{
                inmult(rev, u);
                if(rev == -1) ans ++;
                else add(imag * x, rev);
            }
        }
    }

    ans += cub;

    for(int i = 1; i <= k; i ++){
        auto &u = mp[t[i]];
        if(u.x){
            auto &v = mp[u.y];
            ans += std::max(u.x, v.x);
            v.x = 0;
            u.x=0;
        }
    }

    fprintf(fout, "%lld\n", ans);

    return 0;
}


Measured memory_bytes: 11464
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;

int main(){

	int D;
	string ans = "";

	cin >> D;

	ans = (D == 25) ? "Christmas" : ans;
	ans = (D == 24) ? "Christmas Eve" : ans;
	ans = (D == 23) ? "Christmas Eve Eve" : ans;
	ans = (D == 22) ? "Christmas Eve Eve Eve" : ans;

	cout << ans << endl;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
INF = 10**10
MOD = 10**9 + 7
X = int(input())
d = 100
for i in range(4000):
    d = int(d * 1.01)
    if d >= X:
        print (i+1)
        exit()



Measured memory_bytes: 9168
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v(n,0);
    rep(i,n)cin >> v[i];
    sort(all(v));
    // dump(v)

    ll cnt=0;
    for(int b_i=1; b_i<n; b_i++){
        for(int a_i=0; a_i<b_i; a_i++){
            int idx = lower_bound(all(v), v[a_i]+v[b_i]) - v.begin();
            // ddd(a_i, b_i, idx)
            // d(idx - (b_i+1) );
            cnt+=idx - (b_i+1);
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 1e6 + 6, L = 30, mod = (int) 0;
int mark[N], go[N][L], ed[N], par[N], st[N], tot;
vector<int> adj[N];
int find(int x) { return x == par[x]? x: par[x] = find(par[x]); }
void unite(int x, int y) { par[find(x)] = find(y); }

void dfs(int v, int p = -1) {
    mark[v] = 1;
    st[v] = tot++;
    for (int u : adj[v])
        dfs(u, v);
    ed[v] = tot;
}
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    memset(go, 63, sizeof go);
    string s;
    cin >> s;
    int n = (int) s.size();
    for (int j = n - 1; j >= 0; --j) {
        go[j][s[j] - 'a'] = j + 1;
        for (int k = s[j] - 'a' + 1; k <= 26; ++k) {
            if (go[j][k - 1] < n) {
                int nx = go[go[j][k - 1]][k - 1];
                go[j][k] = nx;
            }
        }
        for (int k = 0; k < 26; ++k) {
            int nx = go[j][26];
            if (nx < n) {
                go[j][k] = min(go[j][k], go[go[j][26]][k]);
            }
        }
        if (go[j][26] <= n) {
            adj[go[j][26]].push_back(j);
        }
    }
    for (int j = n; j >= 0; --j) {
        if (!mark[j]) {
            dfs(j);
        }
    }
    int q;
    cin >> q;
    while (q--) {
        int l, r;
        cin >> l >> r;
        --l;
        if (st[r] <= st[l] && st[l] < ed[r]) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
}


Measured memory_bytes: 179996
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10
	
#階乗#
lim = 50  #必要そうな階乗の限界を入力
fact = [1] * (lim+1)
for n in range(1, lim+1):
	fact[n] = n * fact[n-1] % mod

#階乗の逆元#
fact_inv = [1]*(lim+1)
fact_inv[lim] = pow(fact[lim], mod-2, mod)
for n in range(lim, 0, -1):
	fact_inv[n-1] = n*fact_inv[n]%mod

def C(n, r):
	return (fact[n]*fact_inv[r]%mod)*fact_inv[n-r]%mod


	
N, P = MAP()
A = LIST()

a = [x%2 for x in A]
cnt_0 = a.count(0)
cnt_1 = a.count(1)

ans = 2**cnt_0

if P == 0:
	c = 0
	for i in range(cnt_1//2 + 1):
		c += C(cnt_1, 2*i)
	print(ans*c)
elif P == 1:
	c = 0
	for i in range((cnt_1-1)//2 + 1):
		c += C(cnt_1, 2*i+1)
	print(ans*c)



Measured memory_bytes: 10480
#include "bits/stdc++.h"

//#include <unordered_map>

//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
//#include <algorithm>
//#include <cstring>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define repir(i,a,b) for(int i=(a)-1, i##_first=(b); i>=i##_first; --i)
#define repr(i,n) repir(i,n,0)
#define repir_(i,a,b) for(int i=(a), i##_first=(b); i>=i##_first; --i)
#define repr_(i,n) repir_(i,n,0)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
//template<typename T> T vpop(vector<T> *v) {
//	T res = v->back();
//	v->pop_back();
//	return res;
//}
//char vpop(string *v) {
//	char res = v->back();
//	v->pop_back();
//	return res;
//}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> lvec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
dx8[8] = { 0,1,1,1,0,-1,-1,-1 },
dy8[8] = { 1,1,0,-1,-1,-1,0,1 },
dx4[4] = { 0,1,0,-1 },
dy4[4] = { 1,0,-1,0 };

template<class T>inline bool maxi(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main(){
	setc;

	lint a,b;cin>>a>>b;

	//Yes(a<=8&&b<=8);
	coc(a<=8&&b<=8, "Yay!", ":(");
	gc();
}

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

int int_cmp(const int *a, const int *b)
{
    if (*a < *b)
        return (-1);
    else if (*a > *b)
        return (1);
    return (0);
}

int main () {
int f[1001];
int F[1001];
int N,i,V,d,count;
N=1001;
f[0]=2;
f[1]=3;
for( i = 2; i < 1001; i++){
        f[ i] = f[ i-1] + f[ i-2];
        f[ i] = f[ i] % N;
        }
for( ; ~scanf("%d %d",&V,&d); ){
        count = 1;
        for( i = 0; i < V; i++ )
                F[ i] = f[ i ];
        qsort( F, V, sizeof(int), (int(*)(const void*, const void*))int_cmp);
        for(i = 1; i < V; i++)
                if( F[ i] - F[ i - 1] > d - 1)
                        count++;
        printf( "%d\n" , count);
        }
}

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

int main()
{
	int a, b, c, d, n, iCount;

	while( cin >> n ){
		iCount = 0;

		for( a=0;a<=9;a++ ){
			for( b=0;b<=9;b++ ){
				for( c=0;c<=9;c++ ){
					for( d=0;d<=9;d++ ){
						if( (a+b+c+d) == n )
							iCount++;
					}
				}
			}
		}

		cout << iCount << endl;

	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
static const int INF = 1e9;

int erace(int n, vector<int> v, int num, int c){//?????????????????°?????????????????°???????????????????????????????????´??? ?????????????????????
	int n_tmp = n;//?????£???????????????????????????
	int l = num;//??????????????´????????????
	int r = num + 1;
	int color = c;//???????????´????????°?????????????????????
	while(1){
		int cnt = 0;//????????°????????£?¶???????????????°
		//?????´???????????????????????£?¶????????????????
		while(0 <= l && v[l] == color){
      		cnt++;
      		l--;//??????????????°???
    	}
    	//?????´???????????????????????£?¶????????????????
    	while(r < n && v[r] == color){//n??????????????£????????°??£???
      		cnt++;
      		r++;//??????????????°???
    	}
   		if(cnt >= 4){
    		n_tmp -= cnt;//??£?¶?????????°??????????¶????
    		if(v[l] == v[r]){
	    		color = v[l];//?¬?????¶???????????????´??°??????
	    	}
    		else break;//?¶???????????????????????????????????????§???????????°???????????\????¶????????????¨?????????
    	}else{
    		break;//???????¶???????????????°???????????\????¶????????????¨?????????
    	}
	}
	return n_tmp;
}

int main(void){
	while(1){
		int n; scanf("%d", &n);
		if(n == 0) return 0;
		vector<int> v(n);
		rep(i, n) scanf("%d", &v[i]);
		int ans = INF;//?????????
		//??¨??¢?´¢
		rep(i, n){//?????????????????¨????????????
			int tmp = v[i];
			//???????????????
			reps(j, 1, 4){//???????????????
				if(tmp == j) continue;
				v[i] = j;
				ans = min(ans, erace(n, v, i, j));
			}
			v[i] = tmp;//??????????????????????????????
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3276
using System;

namespace _075b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] HW = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            bool[,] masu = new bool[HW[0]+2,HW[1]+2];
            for(int i = 1; i< HW[0]+1;i++){
                string s = Console.ReadLine();
                for(int j = 1; j < HW[1]+1;j++){
                    if(s[j-1]=='#'){
                        masu[i,j]=true;
                    }
                }
            }
            
            for(int i = 1; i < HW[0]+1; i++){
                for(int j = 1; j < HW[1]+1; j++){
                    int ret = 0;
                    for(int k = -1; k<=1;k++){
                        for(int l = -1; l <=1;l++){
                            if(masu[i+k,j+l])ret++;
                        }
                    }
                    Console.Write(masu[i,j]?"#":ret.ToString());
                }
                Console.WriteLine();
            }


        }
    }
}

Measured memory_bytes: 11220
package main
import "fmt"
func main () {
  var a, b, c, d, ans int
  fmt.Scan(&a)
  fmt.Scan(&b)
  fmt.Scan(&c)
  fmt.Scan(&d)
  if a < b {
    ans += a
  } else {
    ans += b
  }
  if c < d {
    ans += c
  } else {
    ans += d
  }
  fmt.Println(ans)
}

Measured memory_bytes: 512
a, b = map(int,input().split())

if a%2 == 0:
    a_list = [(a//2)*25+i for i in range(13)]
else:
    a_list = [(a//2)*25+i+13 for i in range(12)]

b_list = [10*b + i for i in range(10)]

flag = 0

for i in range(len(b_list)):
    for j in range(len(a_list)):
        if a_list[j] == b_list[i]:
            print(a_list[j])
            flag = 1
        if flag == 1:
            break
    if flag == 1:
        break

if flag == 0:
    print(-1)


Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    int n, i, j, b=0, m=0, x;
    
    scanf("%d\n", &n);
    
    for(i = 1; i <= n; i++) {
        x = 0;
        if (i % 3 == 0) 
            x = 1;
        j = i;
        while (j > 0) {
            if(j % 10 == 3) {
                x = 1;
                break;
            }
            j /= 10;
        }
        if (x == 1)
            printf(" %d", i);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2104
import copy

S=input()  #数値入力 「N」だけの入力のとき
n=len(S)
a = []
for i in range(n):
	a.append(S[i])
result = 0
for bit in range(1 << (n-1)):
	a_tmp = []
	a_tmp.clear()
	a_tmp = copy.copy(a)
	count = 0
	for i in range(n-1):
		if(bit & (1 << i)):
			a_tmp.insert(i+count+1,'+')
			count = count + 1
	a_eval = ''.join(a_tmp)
	result = result + eval(a_eval)
print(result)

Measured memory_bytes: 3572
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(numberOfDivisors(a,b,c));
    }
    public static int numberOfDivisors(int a, int b, int c){
        int count = 0;
        for(int i = a; i <= b; i++){
            if(c % i == 0){
                count++;
            }
        }
        return count;
    }
}


Measured memory_bytes: 26240
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

input = raw_input()
N = int(input)
aVec = raw_input().split(" ")
a = []

for i in aVec:
    a.append(float(i))


#平均を算出
mean = sum(a) / N

#平均に最も近い値を算出(平均を引いたときの最小値を出す)
near_mean = []

for i in a:
    near_mean.append(abs(i - mean))

#平均値に最も近い値のフレーム番号(0始まり)を出力
#同じ値が複数ある場合は最初のインデックスを返す必要があるが、index関数はそういう仕様なので問題ない
print near_mean.index(min(near_mean))

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

map<string, string> mp = {{"A", "T"}, {"T", "A"}, {"C", "G"}, {"G", "C"}};
string b;

int main() {
    cin >> b;
    cout << mp[b] << endl;
}

Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,k,L,f[10005],ans;
char c[10005];
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i)scanf(" %c",c+i);
    char C='z';
    for(int i=1;i<=n;++i)C=min(C,c[i]);
    if(k>20){
        for(int i=1;i<=n;++i)printf("%c",C);
        printf("\n");
        return 0;
    }
    for(int i=1;i<=n;++i)c[n*2+1-i]=c[i];
    for(int i=1;i<=n*2;++i){
        if(c[i]!=C) continue;
        if(i>1&&c[i-1]==C)f[i]=f[i-1]+1;
        else f[i]=1;
        L=max(L,f[i]);
    }
    int _=L;
    for(int i=1;i<k;++i){
        _*=2;
        if(_>=n) break;
    }
    if(_>=n){
        for(int i=1;i<=n;++i)printf("%c",C);
        printf("\n");
        return 0;
    }
    _=n-_;
    for(int i=n+1;i<=n*2;++i){
        if(f[i]<L) continue;
        if(!ans){
            ans=i;
            continue;
        }
        int t=0;
        for(int j=0;j<_;++j){
            if(c[ans-j-L]==c[i-j-L]) continue;
            if(c[ans-j-L]<c[i-j-L])t=1;
            else t=2;
            break;
        }
        if(t==2)ans=i;
    }
    for(int i=1;i<=n-_;++i)printf("%c",C);
    for(int i=0;i<_;++i)printf("%c",c[ans-i-L]);
    printf("\n");
    //system("pause");
    return 0;
}


Measured memory_bytes: 256
import math

a, b, h, m = map(int, input().split())

ha = (h*60+m)/360 * math.pi
ma = m/30 * math.pi
sh, ch = math.sin(ha), math.cos(ha)
sm, cm = math.sin(ma), math.cos(ma)
print(((a*sh-b*sm)**2+(a*ch-b*cm)**2)**(1/2))

Measured memory_bytes: 9488
import java.io.*;

class Main{
    
        public static int max(int i, int k){
            if(k < i){
                return i;
            }else{
                return k;
            }

        }

    public static void main(String[] args){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {       
                    String line = reader.readLine();
                    String[] strAry = line.split(" ");

                    int[] a = new int[strAry.length];

                    for(int i = 0; i < strAry.length; i ++){
                        a[i] = Integer.parseInt(strAry[i]);
                    }
                    int x = a[0];
                    int y = a[1];

                    if(y > x){
                        int k = y;
                        y = x;
                        x = k;
                    }

                    int yaku = 0, k = 1;
                    for(int i = 0; i <= (x % y); i++){

                        int m = x % k;
                        int n = (x % y) % k;
                        if((m == 0) && (n == 0)){
                            yaku = k;
                        }
                        k += 1;
                    }

                    if(x == y){
                        yaku = x;
                    }

                    System.out.println(yaku);
            
                            
        } catch (IOException e) {
            //TODO: handle exception
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 24556
#include <iostream>
#include <array>
#include <algorithm>

const unsigned N = 3;

int main()
{
  std::array<unsigned, N> a;
  for(unsigned n=0; n<N; ++n)
  {
    std::cin >> a[n];
  }
  std::sort(a.begin(), a.end());
  
  std::cout << ((a[0] + a[1] == a[2]) ? "Yes" : "No") << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll M = 998244353;
ll pow(ll a, ll b)
{
    ll r = 1;
    while (b)
    {
        if (b % 2)
            r = (r * a) % M;
        a = (a * a) % M;
        b /= 2;
    }
    return r;
}
int main()
{
    ll n, p = 1;
    cin >> n;
    vector<ll> d(n), f(n);
    for (ll &e : d)
        cin >> e, f[e]++;
    if (d[0] || f[0] > 1)
        return cout << 0, 0;
    for (ll i = 1; i < n; i++)
        p = (p * pow(f[i - 1], f[i])) % M;
    cout << p;
    return 0;
}

Measured memory_bytes: 1920
N = int(input())						# 5
H = [ list(map(int, input().split())) for _ in range(N) ]

#print(H)

dp = [[0,0,0] for _ in range(N)]


def chmax(dp,i,j, x):
	b = (dp[i][j]<x)
	if b: dp[i][j]=x
	return b


for i in range(N):
	for j in range(3):
		for k in range(3):
			if j==k: continue
			chmax(dp,i,j, H[i][j] + (dp[i-1][k] if i>0 else 0))

print( max(dp[-1]) )

#print(dp)


Measured memory_bytes: 47344
#include <bits/stdc++.h>
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>

//define
#define trav(i,v)   for(auto i: v)
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()

//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 1000000007;
const long long inf = 1e18;
 
using namespace std;

int root_n;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

void always_ignore_function_name()
{
    int n;
    cin>>n;
    ll ans=0;
    int cnt1=0, cnt2=0;
    vll l(n+1), r(n+1), k(n+1);
    vector<pair<int, ll>> v1,v2;
    set<pair<int, ll>> s1,s2;
    repu(i,1,n)
    {
        cin>>k[i]>>l[i]>>r[i];
        // ans+=l[i];
        if(r[i]>l[i])
        {
            cnt1++;
            v1.pb(mp(k[i],r[i]-l[i]));
            ans+=l[i];
        }
        else if(l[i]>r[i])
        {
            v2.pb(mp(k[i],l[i]-r[i]));
            ans+=r[i];
        }
        else
        {
            ans+=r[i];
        }
        if(r[i]>l[i])
            s1.insert(mp(k[i],r[i]-l[i]));
        else
            s2.insert(mp(k[i],l[i]-r[i]));
    }
    sort(all(v1));
    sort(all(v2));
    int pos=v1.size(), pos1=0;
    multiset<ll> s;
    repu(i,1,n)
    {
        while(pos1<pos && v1[pos1].fi<i)
        {
            s.insert(-v1[pos1].se);
            pos1++;
        }
        if(i>n-pos)
        {
            if(s.empty())
                continue;
            auto aa=s.begin();
            ans+=-(*aa);
            s.erase(aa);
        }
    }
    while(!s.empty())
        s.erase(s.begin());
    pos1=v2.size();
    pos=pos1-1;
    repd(i,n,1)
    {
        while(pos>=0 && v2[pos].fi>=i)
        {
            s.insert(-v2[pos].se);
            pos--;
        }
        if(i<=pos1)
        {
            if(s.empty())
                continue;
            auto aa=s.begin();
            ans+=-(*aa);
            s.erase(aa);
        }
    }
    cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        always_ignore_function_name();
        tt++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 27876
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int x=0;
  int y;
  int d=0;
  vector<int>vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
    x+=vec.at(i);
  }
y=(double)x/n+0.5;
  for(int i=0;i<n;i++){
    d+=(y-vec.at(i))*(y-vec.at(i));
  }
  cout<<d<<endl;
}
    


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    int a,b;
    char c;
    cin >> a >> c >>b;

    if(c=='+')cout << a+b << endl;
    else cout << a-b << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef pair<int, int> pi;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vint a(n);
    for (int i = 1; i <= 200; i++)
    {
        for (int j = 1; j <= 200; j++)
        {
            for (int k = 1; k <= 200; k++)
            {
                int val = i * i + j * j + k * k + i * j + j * k + k * i;
                if (val <= n)
                {
                    a[val - 1]++;
                }
            }
        }
    }
    fr(i, 0, n)
    {
        cout << a[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#define _GLIBCXX_DEBUG//.at(i)を[i]と書いても許される
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
int  n ;

int main(){
	cin>>n;
	vector<int> a(n);
	int ans = 1;//種類の最大値
	int minans = 1;
	rep(i,n){
	int A;
	cin >>A;
	A /= 400;
	if(A>=8){
		A=8;
	}
	a[i]=A;
	}
	SORT(a);
		for(int i = 1 ; i<n; i++){
		if(a[i]!=a[i-1]&&a[i]<8){
			ans++;
			minans++;
		}	
		else if (a[i]==8){
			ans++;
		}
		}
		cout<<minans<<" "<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

string T = "AKIHABARA_";

void solve() {
	string s; cin >> s; s.pb('_');
	int i = 0, j = 0;
	while(i < szz(T)) {
		if(j == szz(s)) { puts("NO"); return; }
		if(T[i] == s[j]) ++i, ++j;
		else if(T[i] == 'A') ++i;
		else { puts("NO"); return; }
	}
	puts("YES");
	
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int is_prime(int a){
	int i;
	for(i = 2; i*i <= a; i++){
		if(a%i == 0) return 0;
	}
	return a != 1;
}

int main(){
	int n,i;
	int count = 0;
	int a[10000];
	scanf("%d",&n);
	for(i = 0; i < n; i++){
		scanf("%d",&a[i]);
		if(is_prime(a[i])) count++;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 632