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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

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

int n;
int a[16][16];
int dp[(1LL<<16)];
bool vis[(1LL<<16)];

int calc(int msk){
  int ans = 0;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      if((msk & (1LL << i)) and (msk & (1LL << j))) ans += a[i][j];
    }
  }
  return ans;
}

void print(int msk){
  for(int i=0; i<n; i++){
    if((1LL<<i) & msk) cout << 1;
    else cout << 0;
  }
  cout << " ";
}

int solve(int msk){
  if(msk == 0) return 0;
  if(vis[msk]) return dp[msk];
  vis[msk] = true;
  dp[msk] = calc(msk);
  
  for(int submsk = msk; submsk > 0; submsk = (submsk-1) & msk){
    int submsk2 = ((msk^submsk) & msk);
    dp[msk] = max(dp[msk], solve(submsk) + solve(submsk2));
  }
  //print(msk);
  //cout << dp[msk] << endl;
  return dp[msk];
}
 
int32_t main(){
  DESYNC;
  cin >> n;
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      cin >> a[i][j];
    }
  }
  for(int i=0; i<(1LL<<n); i++){
    vis[i] = false;
  }
  cout << solve((1LL<<n)-1) << endl; 
}



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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll w, h;
    cin >> w >> h;

    vector<ll> costx(w), costy(h);
    for(auto&& i : costx) cin >> i;
    for(auto&& i : costy) cin >> i;

    ll ans = 0;
    auto fn = [](const pair<ll,int>& a, const pair<ll,int>& b){return a.first > b.first;};
    priority_queue<pair<ll,int>, vector<pair<ll,int>>, decltype(fn)> que(fn);

    for(auto i : costx){
        que.push(make_pair(i, 0));
    }
    for(auto i : costy){
        que.push(make_pair(i, 1));
    }

    ll cntx = h+1, cnty = w+1;
    while(!que.empty()){
        auto p = que.top();
        que.pop();
        if(p.second == 0){
            ans += p.first * cntx;
            cnty = max(0LL, cnty - 1);
        }else{
            ans += p.first * cnty;
            cntx = max(0LL, cntx - 1);
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  
  int N; cin >> N; int64_t sum = 0;
  
  vector<int64_t> vec(5, 0);
  
  string title = "MARCH";
  
  for (int i = 0; i < N; i++) {
    
    string S; cin >> S; char head = S.at(0);
    
    for (int j = 0; j < title.size(); j++) {
      if (head == title.at(j)) vec.at(j)++;
    }
    
  }
  
  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 4; j++) {
      for (int k = j + 1; k < 5; k++) {
        sum += vec[i] * vec[j] * vec[k];
      }
    }
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 3628
//This Code was made by Chinese_zjc_.
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<bitset>
#include<cmath>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<set>
#include<time.h>
// #include<windows.h>
#define int long long
#define PI 3.14159265358979323
#define INF 0x3fffffffffffffff
using namespace std;
int a[1000005],n,from[1000005],gcd;
bool isnp[1000005],app[1000005],all=true;
void work(int now)
{
    while(now>1)
    {
        int f=from[now];
        while(now%f==0)
        {
            now/=f;
        }
        if(app[f])
        {
            all=false;
            return;
        }
        app[f]=true;
    }
}
signed main()
{
    ios::sync_with_stdio(false);
    for(int i=2;i<=1000000;++i)
    {
        if(isnp[i])
        {
            continue;
        }
        from[i]=i;
        for(int j=i*i;j<=1000000;j+=i)
        {
            isnp[j]=true;
            from[j]=i;
        }
    }
    cin>>n;
    cin>>a[1];
    gcd=a[1];
    work(a[1]);
    for(int i=2;i<=n;++i)
    {
        cin>>a[i];
        work(a[i]);
        gcd=__gcd(a[i],gcd);
    }
    if(all)
    {
        cout<<"pairwise coprime"<<endl;
    }
    else if(gcd==1)
    {
        cout<<"setwise coprime"<<endl;
    }
    else
    {
        cout<<"not coprime"<<endl;
    }
    return 0;
}

Measured memory_bytes: 21188
#include <bits/stdc++.h> 
using namespace std; 
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(void) {
    io;
    int n, a, b;
    cin >> n >> a >> b;
    int result;
    if (n*a < b) result = n*a;
    else result = b;
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 3608
"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};module.exports=I;

function main(input) {
  const o = new I(input, String);

  let date = o.a();
  if (date <= "2019/04/30") {
    console.log("Heisei");
  } else {
    console.log("TBD");
  }

}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<
	T,
	null_type,
	less<T>,
	rb_tree_tag,
	tree_order_statistics_node_update>;

// gives the number of keys with value strictly less than x
#define lesscount(x) order_of_key(x)
// gives the iterator to kth element (starting from 0)
#define kthiterator(x) find_by_order(x)

#define clock_starts() clock_t begin = clock()
#define clock_ends() clock_t end = clock()
#define print_running_time() double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC; \
printf("Elapsed Time : %.10f second(s)\n", elapsed_secs)
#define readfile(s) freopen(s, "r", stdin)
#define writefile(s) freopen(s, "w", stdout)
#define debug(s) cout<< #s <<" = "<< s <<endl
#define all(v) (v).begin(), (v).end()
#define KeepUnique(v) (v).erase( unique(all(v)), v.end() )
#define cin_cout_is_cool ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PrintBinary(n) cout << #n << " = " << bitset<64>(n) << endl
#define MEMSET(a,val) memset(a, val, sizeof a)
#define PB push_back
#define endl '\n'
#define cin(n) scanf("%d", &n)
#define popcount(x) __builtin_popcount((x))
#define popcountll(x) __builtin_popcountll((x))

inline int myrand(int l, int r) {
	int ret = rand(); ret <<= 15; ret ^= rand();
	if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
	return ret;
}
template <typename F, typename S>
ostream& operator << (ostream& os, const pair< F, S>& p) {
    return os<<"(" <<p.first<<", "<<p.second<<")"; }

typedef pair<int, int> ii;
template<typename T> using min_pq =
	priority_queue<T, vector<T>, greater<T> >;

template<typename T>T max(T a_,T b_,T c_) { return max(a_,max(b_,c_)); }
template<typename T>T min(T a_,T b_,T c_) { return min(a_,min(b_,c_)); }
template<typename T>T min(T a_,T b_,T c_, T d_) { return min(min(a_, b_),min(c_,d_)); }
template<typename T>T max(T a_,T b_,T c_, T d_) { return max(max(a_, b_),max(c_,d_)); }

//int dx[] = {-1, +0, +1, +0};
//int dy[] = {+0, +1, +0, -1};

template<typename T> inline T ceil(T num, T d)
{ return (T)(num/d) + (num%d>(T)0 ? (T)1 : (T)0); }
#define block_no(idx) 		(idx/BLOCK_SIZE)
#define block_starting(idx) (block_no(idx)*BLOCK_SIZE)
#define block_ending(idx) 	(min(n, block_no(idx)*BLOCK_SIZE+BLOCK_SIZE-1))
#define block_rank(idx) 	(idx%BLOCK_SIZE)



int32_t main () {
	//readfile("input.in");
	//writefile("output.out");
	typedef long long ll;
	ll n, m;
	cin>>n>>m;
	if(n > m) swap(n, m);
	if(n == 1 and m == 1) cout<<"1 "<<endl;
	else if(n == 1) cout<<m-2LL<<endl;
	else cout<<(n - 2) * (m - 2)<<endl;
	return 0;
}

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main()
{
    string S;
    cin >> S;

    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i)
        reverse(divide[i].begin(), divide[i].end());

    bool can = true;
    for (int i = 0; i < S.size();)
    {
        bool can2 = false;
        for (int j = 0; j < 4; ++j)
        {
            string d = divide[j];
            if (S.substr(i, d.size()) == d)
            {
                can2 = true;
                i += d.size();
            }
        }
        if (!can2)
        {
            can = false;
            break;
        }
    }

    if (can)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var N = Console.ReadLine();
        var isDream = false;
        var isErase = false;
        var isEr = false;
        var ans = "YES";
        var dream = "dream";
        var erase = "erase";
        for (int i= N.Length-1; 0<=i;--i)
        {

            if (N[i] == 'r') isEr = true;
            else if (N[i] == 'e') isErase = true;
            else if (N[i] == 'm') isDream = true;
            else
            {
                ans = "NO";
                break;
            }
            if (isDream)
            {
                for (int j=3;0<=j;--j)
                {
                    --i;
                    if (i < 0 || N[i] != dream[j])
                    {
                        ans = "NO";
                        break;
                    }
                }
                isDream = false;
            }
            if (isErase)
            {
                for (int j = 3; 0 <= j; --j)
                {
                    --i;
                    if (i < 0 || N[i] != erase[j])
                    {
                        ans = "NO";
                        break;
                    }
                }
                isErase = false;
            }
            if (isEr)
            {
                --i;
                if (i < 0 || N[i]!='e')
                {
                    ans = "NO";
                    break;
                }
                --i;
                if (i < 0 || (N[i]!='m'&&N[i]!='s'))
                {
                    ans = "NO";
                    break;
                }
                if(N[i] == 'm')
                {
                    for (int j = 3; 0 <= j; --j)
                    {
                        --i;
                        if (i < 0 || N[i] != dream[j])
                        {
                            ans = "NO";
                            break;
                        }
                    }
                }else if (N[i] == 's')
                {
                    for (int j = 2; 0 <= j; --j)
                    {
                        --i;
                        if (i < 0 || N[i] != erase[j])
                        {
                            ans = "NO";
                            break;
                        }
                    }
                }
                isEr = false;
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11232
#include <cstdio>
#include <string>
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
inline int rd(){
    int x=0,p=1;
    char a=getchar();
    while((a<48||a>57)&&a!='-')a=getchar();
    if(a=='-')p=-p,a=getchar();
    while(a>47&&a<58)x=(x<<1)+(x<<3)+(a&15),a=getchar();
    return x*p;
}
const int N=1002;
int n,a[N];
string s[N],str;
ll ans=0;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>s[i]>>a[i];
	cin>>str;
	for(int i=1,flag=0;i<=n;i++){
		ans+=flag*a[i];
		if(str==s[i])flag=1;
	}
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

int a[105];
int cnt[105];
vector<int> ans;

int main(){
    cin.tie(0); 
    int N; cin >> N;

    for (int i = 1; i <= N; i++){
        cin >> a[i];
        cnt[i] = i;
    }
    for (int i = N; i >= 1; i--){
        for (int j = N; j >= 1; j--){
            int flag = 0;
            if (a[j] == cnt[j]){
                ans.push_back(a[j]);
                for (int k = j; k <= N; k++){
                    cnt[k]--;
                }
                flag = 1;
            }
            if (flag) break;
        }
    }
    if (ans.size() != N){
        cout << -1 << endl;
        return 0;
    }
    for (int i = ans.size()-1; i >= 0; i--){
        cout << ans[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 888
use itertools::Itertools;

fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        k: usize,
        s: [String; h],
    }
    let mut r = 0;

    let mut c = vec![vec!['.'; w]; h];
    for i in 0..h {
        let si: Vec<char> = s[i].chars().collect();
        for j in 0..w {
            c[i][j] = si[j];
        }
    }
    for i in 0..h {
        let i_s = (0..h).combinations(i);
        for ii in i_s {
            let mut c = c.clone();
            for iii in ii {
                for j in 0..w {
                    c[iii][j] = '.';
                }
            }
            for j in 0..w {
                let j_s = (0..w).combinations(j);
                for jj in j_s {
                    let mut c = c.clone();
                    for jjj in jj {
                        for i in 0..h {
                            c[i][jjj] = '.';
                        }
                    }
                    let mut cn = 0;
                    for i in 0..h {
                        for j in 0..w {
                            if c[i][j] == '#' {
                                cn += 1;
                            }
                        }
                    }
                    if cn == k {
                        r += 1;
                    }
                }
            }
        }
    }
    println!("{}", r);
}


Measured memory_bytes: 2200
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

a = [0] * (10 ** 5 + 5)
for i in range(1, 10**5+1):
    a[i] = a[i-1]
    if is_prime(i) and is_prime((i+1) // 2):
        a[i] += 1
Q = ni()
for i in range(Q):
    l, r = na()
    print(a[r] - a[l-1])

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

int main(){
	string s ; cin >> s ;
	int l,r ;
	for(int i=0;i<s.size();i++){
		if(s.at(i)=='A'){
			l = i ;
			break ;
		}
	}
	for(int i=s.size()-1;i>=0;i--){
		if(s.at(i)=='Z'){
			r = i ;
			break ;
		}
	}
	cout << r-l+1 << endl ;
}

Measured memory_bytes: 640
N, Y = map(int, input().split())

# 合計金額=Y となったとき is_match = 1
is_match = 0

for i in range(N + 1):
    if is_match == 1:
        break

    for j in range(N + 1 - i):
        if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
            is_match = 1
            print(i, j, N - i - j)
            break

if is_match == 0:
    print(-1, -1, -1)


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

using namespace std;

const int N=2e5+5;
long long a[N],b[N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    long long i,H,n,q,W,x,y,black;
    cin >> n >> q;
    for(i=1;i<=n;i++)a[i]=b[i]=n;
    H=W=n;
    black=(n-2)*(n-2);
    while(q--)
    {
        cin >> x >> y;
        if(x == 1)
        {
            if(y < W)
            {
              for(i=y;i<W;i++)b[i]=H;
              W=y;
            }
            black-=b[y]-2;
        }
        else
        {
            if(y < H)
            {
              for(i=y;i<H;i++)a[i]=W;
              H=y;
            }
            black-=a[y]-2;
        }
    }
    cout << black;
    return 0;
}


Measured memory_bytes: 6716
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;

using ll = long long;

string s;

ll N;

ll ans = 0;

int main() {
	cin >> s;
	N = s.length();
	for (int i = 0; i < N; i++) {
		if (i % 2) {
			if (s[i] == '0')ans++;
		}
		else {
			if (s[i] == '1')ans++;
		}
	}
	if (ans > (N / 2))cout << N - ans;
	else cout << ans;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


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


Measured memory_bytes: 256
import numpy as np
from itertools import product

N, M = map(int, input().split())
S = np.zeros((M, N))  # (M, N), switch

for i in range(M):
    k, *s = map(int, input().split())
    s = [x - 1 for x in s]
    S[i, s] = 1
p = np.array(list(map(int, input().split())), dtype=np.int)

cnt = 0
for i in product([0, 1], repeat=N):
    a = np.array(i, dtype=np.int)  # N,
    b = (np.dot(S, a) % 2).astype(np.int)
    if np.all(b == p):
        cnt += 1
print(cnt)

Measured memory_bytes: 22172
a = input()

if a == 'SUN':
  print(7)
elif a == 'MON':
  print(6)
elif a == 'TUE':
  print(5)
elif a == 'WED':
  print(4)
elif a == 'THU':
  print(3)
elif a == 'FRI':
  print(2)
elif a == 'SAT':
  print(1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, ans = 0;
    cin >> n;
    for(int i = 1; i <= n; i ++ ){
        int a;
        cin >> a;
        if(a % 2 == 1 && i % 2 == 1) {
            ans ++;
        }
    }
    cout << ans << endl;;
    return 0;
}




Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    long long M = 1000000007;

    string t, b;
    cin>>t>>b;

    vector<long long> T(b.size()+1);
    T[0] = 1LL;

    for (int i=0; i<(int)t.size(); i++)
    {
        vector<long long> P = T;
        for (int j=0; j<(int)b.size(); j++)
            if (b[j] == t[i])
                T[j+1] += P[j],
                T[j+1] %= M;
    }

    cout<<T[b.size()]<<endl;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int ans,n,h[200005],k;
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	sort(h+1,h+n+1);
	for(int i=1;i<=n-k;i++)
		ans+=h[i];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
import sys

N=int(input())
if N<=2:
  print(1)
  sys.exit(0)

xylist=[]
for i in range(N):
  x,y=map(int,input().split())
  xylist.append((x,y))
xylist.sort()
#print(xylist)

pqset=set()
for i in range(N):
  x1,y1=xylist[i]
  for j in range(i+1,N):
    x2,y2=xylist[j]
    p=x2-x1
    q=y2-y1
    pqset.add((p,q))
#print(len(pqset))
    
answer=50
for p,q in pqset:
  comp_num=N
  for i in range(N):
    x1,y1=xylist[i]
    for j in range(i+1,N):
      x2,y2=xylist[j]
      if p==x2-x1 and q==y2-y1:
        comp_num-=1
        
  answer=min(answer,comp_num)
    
print(answer)

Measured memory_bytes: 3188
N = int(input())
S = list(input())
R = [0]*N
W = [0]*N
for i in range(N):
    if S[i]=="R":
        R[i]+=1
    else:
        W[i]+=1

sumR = sum(R)

ans = sumR-sum(R[:sumR])

print(ans)

Measured memory_bytes: 15044
using System;
namespace ITP1_1_D
{
    class Program
    {
        static void Main(string[] args)
        {
           var S = int.Parse(Console.ReadLine());
           var h = S / 3600;
           var m = S / 60 - h * 60;
           var s = S - h * 3600 - m * 60;
           Console.WriteLine("{0}:{1}:{2}", h, m, s);
        }
    }
}


Measured memory_bytes: 17984
# input
n = int(input())
s = []
for i in range(n):
  tmp = list(input())
  tmp.sort()
  s.append("".join(tmp))
s.sort()
s.append("SENTINEL")

# main
ans = 0
cnt = 1
for i in range(n):
  if s[i] == s[i+1]:
    cnt += 1
  if cnt > 1 and s[i] != s[i+1]:
    ans += cnt * (cnt-1) // 2
    cnt = 1

# output
print(ans)
    

Measured memory_bytes: 10616
n = int(input())
a_list = list(map(int,input().split()))

a_dict = {}

for a in a_list:
    if a not in a_dict:
        a_dict[a] = 1
    else:
        a_dict[a] += 1

values = list(a_dict.values())
double = sum(values) - len(values)
# print(values,double)

print(len(a_list) - (double//2 + double%2)*2)

Measured memory_bytes: 17396
N, W = map(int, input().split())

def npsk_1(N, W):
    w, v = [0]*N, [0]*N 
    for _ in range(N):
        w[_], v[_] = map(int, input().split())
    
    dp = [[0]*(W+1) for _ in range(N+1)]
    
    for i in range(N):
        for j in range(W+1):
            if j - w[i] >= 0:
                dp[i+1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i])
            else:
                dp[i+1][j] = dp[i][j]
    
    print(dp[-1][-1])

npsk_1(N, W)

Measured memory_bytes: 118640
#include <stdio.h>

typedef struct {
  char suit;
  int num;
  int id;
} Card;

void bubble ( Card a[], int N );
void selection( Card b[], int N );

void swap ( Card *x, Card *y ) {
  Card temp = *y;
  *y = *x;
  *x = temp;
}

void trace ( Card x[], int N ) {
  int f = 0;
  char ns[] = "Not stable"; char s[] = "Stable";
  for ( int i = 0; i < N ; i++ ) {
    printf ( "%c", x[i].suit );
    printf ( "%d", x[i].num );
    if ( x[i].num == x[i+1].num && x[i].id > x[i+1].id ) f = 1;
    if ( i == N - 1 ) break;
    printf( " " );
  }
  putchar ( '\n' );
  printf ( "%s\n", f ? ns : s );
}

void bubble ( Card a[], int N ) {
  for ( int i = 0; i < N - 1; i++ ) {
    for (int j = N - 1; j > i ; j-- ) {
      if ( a[j].num < a[j-1].num ) {
        swap ( &a[j], &a[j-1] );
      }
    }
  }
  trace ( a, N );
}

void selection ( Card b[], int N ) {
  for ( int i = 0; i < N - 1; i++ ) {
    int minj = i;
    for ( int j = i; j < N; j++ ) {
      if ( b[j].num < b[minj].num ) {
        minj = j;
      }
    }
    swap ( &b[minj], &b[i] );
  }
  trace ( b, N );
}

int main ( void ) {
  Card a[36], b[36];
  int i, N;
  scanf ( "%d", &N );
  for ( i = 0; i < N; i++ ) {
    scanf ( " %c%d", &a[i].suit, &a[i].num );
    a[i].id = i;
    b[i] = a[i];
  }

  bubble ( a, N );
  selection ( b, N );
}



Measured memory_bytes: 2136
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main() {
	int N, A, B;
	vector<int> P;
	int temp;
	vector<int> count(3);
	int ans = 0;

	cin >> N;
	cin >> A >> B;

	for(int i = 0; i < N; i++){
		cin >> temp;

		if(temp <= A){
			count[0]++;
		}
		else if(((A+1) <= temp) && (temp <= B)){
			count[1]++;
		}
		else{
			count[2]++;
		}
	}

	int min = *min_element(count.begin(), count.end());
	ans  = min;

	cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
bool ok(string s)
{
	forn(i,s.size())
		if(s[i]!=s[s.size()-i-1])return 0;
	return 1;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	if(ok(s)&&ok(s.substr(0,(s.size()-1)/2))&&ok(s.substr((s.size()+3)/2-1)))cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n,ans=0;
  cin>>n;
  int v[n],c[n];
  rep(i,n){
    cin>>v[i];
  }
  rep(i,n){
    cin>>c[i];
  }
  rep(i,n){
    if(v[i]>=c[i]){
      ans+=v[i]-c[i];
    }
  }
  cout<<ans;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

from heapq import heappop, heappush
def solve():
    N = int(input())
    Ls = [[] for _ in range(N)]
    Rs = [[] for _ in range(N)]
    base = 0
    for _ in range(N):
        k, l, r = mapint()
        if l>=r:
            Ls[k-1].append(l-r)
            base += r
        else:
            if N-k!=0:
                Rs[N-k-1].append(r-l)
            base += l
    return base + calculate(Ls, N) + calculate(Rs, N)


def calculate(lis, N):
    queue = []
    for i in range(N):
        for x in lis[i]:
            heappush(queue, x)
        while len(queue)>i+1:
            heappop(queue)
    return sum(queue)


T = int(input())
for t in range(T):
    print(solve())

Measured memory_bytes: 106768
#include <bits/stdc++.h>
using namespace std;
#define sci1(a) scanf("%d",&a)
#define sci2(a,b) scanf("%d %d",&a,&b)
#define sci3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define scs(s) scanf("%s",s)
#ifndef GET_MACRO

#define GET_MACRO(__1,__2,__3,NAME,...) NAME

#endif // GET_MACRO
#define ll long long
#define sci(...) GET_MACRO(__VA_ARGS__,sci3,sci2,sci1)(__VA_ARGS__)
#define LSB(i) ((i)&(-i))
#define mp(a,b) make_pair(a,b)
#define bit_set0(m,i) (m&(~(1<<i)))

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    priority_queue<double,vector<double>, greater<double> > pq;
    int n,tmp,i;
    double t1,t2,t;
    sci(n);
    for(i=0;i<n;i++){
        sci(tmp);
        pq.push((double)tmp);
    }
    while(!pq.empty()){
        t1=pq.top();
        pq.pop();
        t2=pq.top();
        pq.pop();
        if(pq.empty()){
            printf("%lf\n",(t1+t2)/2.0);
            return 0;
        }
        pq.push((t1+t2)/2.0);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007
#define ll long long
#define db double
#define pb push_back
#define F first
#define S second
#define vl vector<ll>
#define vvl vector<vl>
#define pii pair<int,int>
#define mkp make_pair

int main()
{
	ll N,W;
	cin >> N >> W;
	ll w[N],val[N];
	
	for(ll i=0;i<N;i++)
	{
		cin >> w[i] >> val[i];
	}
	
	ll dp[W+5],dptemp[W+5];
	memset(dp,0,sizeof(dp));
	memset(dptemp,0,sizeof(dptemp));
	
	/*for(ll i=1;i<=W;i++)
	{
		dp[i]=(min(1,(i/w[0])))*val[0];
	}*/
	
	for(ll i=0;i<N;i++)
	{
		for(ll j=1;j<=W;j++)
		{
			dptemp[j]=dp[j];
			if(j>=w[i])
			{
				dptemp[j]=max(dp[j],val[i]+dp[j-w[i]]);
			}
		}
		for(ll j=1;j<=W;j++)
		{
			dp[j]=dptemp[j];
		}
	}
	
	cout << dp[W] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "
#define MAX_V (1000 * 100 + 1)

int     main()
{
	ll n, m;
	cin >> n >> m;
	vector<ll> w(n), v(n);
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}
	vector<vector<ll>> dp(n+1, vector<ll>(MAX_V, INF));
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < MAX_V; j++) {
			if (j - v[i] < 0)
			{
				dp[i+1][j] = dp[i][j];
				continue ;
			}
			dp[i+1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
		}
	}
	ll ans;
	for (int j = MAX_V-1; j >= 0; j--) {
		if (dp[n][j] <= m)
		{
			ans = j;
			break ;
		}
	}
	cout << ans << endl;
}





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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;
const int MAX_N = 2000;

ll fact[MAX_N+100];
ll frev[MAX_N+100];

ll rev(ll a, ll p){
    if(p == 0) return 1;
    ll tmp = rev(a, p/2);
    tmp = tmp * tmp % MOD;
    if(p % 2 == 1) tmp = tmp * a % MOD;
    return tmp;
}


void calc_fact(){
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }
}


ll comb(int n, int k){
    if(n < 0 || k < 0 || n < k) return 0;
    if(n == 0 || k == 0) return 1;
    return fact[n] * frev[k] % MOD * frev[n-k] % MOD;
}

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

    //in main function
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }

    for(int m = 1; m <= K; m++){
        ll ans = 1;
        ans *= comb(N-K+1, m);
        ans %= MOD;

        ans *= comb(K-1, m-1);
        ans %= MOD;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(void)
{
    double a, b, C;
    double c;
    double S, L, h;
 
    scanf("%lf %lf %lf", &a, &b, &C);
    C = C / 360 * 2 * M_PI; // to radian
 
    S = a * b * sin(C) / 2;
    printf("%f\n", S);
 
    c = sqrt(a * a + b * b - 2 * a * b * cos(C));
    L = a + b + c;
    printf("%f\n", L);
 
    h = b * sin(C);
    printf("%f\n", h);
 
    return (0);
}


Measured memory_bytes: 2048
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [N] = r.nn()

    const s = r.s()
    // const hasR = s.split('').some((c) => c === 'R')
    // const hasW = s.split('').some((c) => c === 'W')

    // if (!hasR || !hasW) {
    //   return 0
    // }

    let si = 0
    let ei = N - 1
    let res = 0

    while (si < ei) {
      while (s[si] === 'R') si++
      while (s[ei] === 'W') ei--
      if (si > ei) break

      si++
      ei--
      res++
    }

    return res
  }

  const _io = (i = 0) => {
    const str: string = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map((v) => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map((line) => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}


Measured memory_bytes: 32664
def main():
    n,m=map(int,input().split())
    CARD=[0]*(n+1)
    for i in range(m):
        L,R=map(int,input().split())
        CARD[L-1]+=1
        CARD[R]-=1
    ans=0
    for i in range(n):
        if CARD[i]==m:ans+=1
        CARD[i+1]=CARD[i+1]+CARD[i]

    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 47416
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

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

  vector<int> idx[10];
  rep(i, n) {
    int m = s[i] - '0';
    idx[m].push_back(i);
  }

  int ans = 0;
  rep(i, 10) {
    auto itri = upper_bound(idx[i].begin(), idx[i].end(), -1);
    if (itri == idx[i].end()) continue;
    int idxi = *itri;
    rep(j, 10) {
      auto itrj = upper_bound(idx[j].begin(), idx[j].end(), idxi);
      if (itrj == idx[j].end()) continue;
      int idxj = *itrj;
      rep(k, 10) {
        auto itrk = upper_bound(idx[k].begin(), idx[k].end(), idxj);
        if (itrk != idx[k].end()) ans++;
      }
    }
  }

  cout << ans << endl;

  
  return 0;
}

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

int main()
{
	string S;
	cin >> S;
	bool flag = false;
	for (int i = 0; i < 3; i++) {
		if (S[i] == S[i + 1]) flag = true;
	}
	puts(flag ? "Bad" : "Good");
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var nab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = nab[0];
            var a = nab[1];
            var b = nab[2];

            if((b - a - 1) % 2 == 0)
            {
                Console.WriteLine("Borys");
            }
            else
            {
                Console.WriteLine("Alice");
            }
        }
    }
}


Measured memory_bytes: 28220
#include <iostream>
using namespace std;
#define MAX 123456

int main()
{
	int n;
	int a[2 * MAX + 1];
	int counter;
	
	a[0] = 0;
	a[1] = 0;
	for (int i = 2; i < 2 * MAX + 1; i++) {
		a[i] = 1;
	}
	
	int j = 2;
	while (j < 2 * MAX) {
		if (a[j] == 0) {
			j++;
		} else {
			for (int k = j *2; k < 2 * MAX + 1; k += j)
				a[k] = 0;
			j++;
		}
	}
	
	while (1) {
		cin >> n;
		if (n == 0) {
			break;
		}
		counter = 0;
		for (int i = n + 1; i <= 2 * n; i++)
			if (a[i])
				counter++;
		cout << counter << "\n";
	}
		
	return 0;
}

Measured memory_bytes: 2124
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int[] b = new int[m];
		int[][] a = new int[n][m];
		int answer = 0;
		for(int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
			int total = c;
			for(int j = 0; j < m; j++) {
				a[i][j] = sc.nextInt();
				total += a[i][j]*b[j];
			}
			if(total > 0) answer++;
		}
		System.out.println(answer);
	}

}


Measured memory_bytes: 22100
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
using ll = long long;

ll solve(std::string l, std::string r){
    std::string alphabet = "abcdefghijklmnopqrstuvwxyz";
    std::vector<std::vector<bool>> cnt(26,std::vector<bool>(2, false));
    for(int i=0; i<l.size(); ++i){
        for(int j=0; j<26; ++j){
            if(l[i]==alphabet[j]) cnt[j][0]=true;
        }
    }
    for(int i=0; i<r.size(); ++i){
        for(int j=0; j<26; ++j){
            if(r[i]==alphabet[j]) cnt[j][1]=true;
        }
    }
    ll ret=0;
    for(int i=0; i<26; ++i){
        if(cnt[i][0]&&cnt[i][1]) ++ret;
    }
    return ret;
}

int main(){
    ll n; std::cin >> n;
    std::string s; std::cin >> s;

    ll ans = 0;
    for(int i=1; i<n; ++i){
        std::string l = s.substr(0,i);
        std::string r = s.substr(i);
        ans = std::max(ans, solve(l, r));
    }
    std::cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
    int n, i, j, done, count = 0;
    int A[N];
    scanf("%d", &n);

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

    done = 1;
    if (n < 2)
    {
        trace(A, n);
        printf("%d\n", count);
        return 0;
    }
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < n - 1 - i; j++)
        {
            if (A[j] > A[j + 1])
            {
                A[j] = A[j + 1] ^ A[j];
                A[j + 1] = A[j + 1] ^ A[j];
                A[j] = A[j + 1] ^ A[j];
                done = 0;
                count++;
            }
        }
        if(done == 1)
            break;
    }
    
    trace(A, n);
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 1816
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# 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;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

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

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, m, k;
ll a[N];
 
ll ans;
set < pair < ll, int > > s;
set < int > id;
 
 
int main () {
   	SpeedForce;
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		s.insert({a[i], i});
		id.insert(i);
    }	
 
    id.insert(0);
    id.insert(n+1);
 
    for (int i = 1; i <= n / 2; i ++) {
    	auto it = *s.rbegin();
    	s.erase(it);
    	//cout << it.F << ' ' << it.S << '\n';
    	ans += it.F;
    	id.erase(it.S);
 
    	auto l = *(--id.lower_bound(it.S));
    	auto r = *id.lower_bound(it.S);
 
    	if (l > 0) {
    		a[it.S] -= a[l];
    		id.erase(l);
    		s.erase({a[l], l});
 
    	}
    	if (r <= n) {
    		a[it.S] -= a[r];
    		id.erase(r);
    		s.erase({a[r], r});
 
    	}
    	a[it.S] *= -1ll;
 
    	if (l >= 1 && r <= n) {
    		s.insert({a[it.S], it.S});
    		id.insert(it.S);
    	}
 
    //	cout << ans << '\n';
    }
    cout << ans << '\n';
    return Accepted;
}

// B...a

Measured memory_bytes: 27064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	ll ans = 0;
	int j = n - 1;
	for (int i = 1; i < n;++i) {
		if (i >= j ) break;
		ans++;
		--j;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, i;
	int a[100] = {0};

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

	for (i = n; i > 0; i--){
		printf("%d", a[i - 1]);
		if (i != 1) putchar(' ');
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 604
i = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
b = gets.chomp.split(" ").map(&:to_i)
c = gets.chomp.split(" ").map(&:to_i)
sum = 0
(0..i-1).each do |n|
    sum += b[n]
    if a[n]+1 == a[n+1]
        sum +=c[a[n]-1]
    end
end
puts sum

Measured memory_bytes: 1788
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	int x=1, i;
	for (i=0;i<a;i++) {
		x*=100;
	}
	if (b==100) {
		printf("%d", (b+1)*x);
	}
	else {
		printf("%d", b*x);
	}
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>
using namespace std;

int main(){
	int d,y;
	int sum;
	while(cin >> d){
		sum = 0;
		for(int i = d;i <= 600-d ;i +=d){
			y = pow(i,2);
			sum += d*y;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(){
    int n,x;
    cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3==0||i%10==3){
            cout<<" "<<i;
        }else{
            x=i;
            while(1){
                x/=10;
                if(x){
                    if(x%10==3){
                        cout<<" "<<i;
                        break;
                    }
                }else{
                    break;
                }
            }
           
        }
    }
    cout<<endl;
    return 0;
}

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

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

void solve() {
    int n;
    cin >> n;

    cout << 1 - n << endl;
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int t = 1;
    //cin >> t;

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

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

using namespace std;

int main() {
    int n;
    int edge[1000][3];
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> edge[i][0] >> edge[i][1] >> edge[i][2];
        sort(edge[i], edge[i] + 3);
    }
    
    for (int i = 0; i < n; i++) {
        int *tmp = edge[i];
        if (pow(tmp[0], 2) + pow(tmp[1], 2) == pow(tmp[2], 2)) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    
    return 0;
}


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  cout << a * b << '\n';
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int n,q,a,b,c;
main(){
	cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;i++)cin>>v[i];
	cin>>q;
	while(q--){
		cin>>a>>b>>c;
		if(!a)cout<<(*min_element(v.begin()+b,v.begin()+c))<<endl;
		else cout<<(*max_element(v.begin()+b,v.begin()+c))<<endl;
	}
}


Measured memory_bytes: 3104
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		int n = s.length();
		int gbcou = 0;
		int gwcou = 0;
		int kbcou = 0;
		int kwcou = 0;
		for(int i = 0; i < n; i++){
			int tmp = Integer.parseInt(s.substring(i,i+1));
			if(i%2==0){
				if(tmp == 0){
					gbcou++;
				}else{
					gwcou++;
				}
			}else{
				if(tmp == 0){
					kbcou++;
				}else{
					kwcou++;
				}
			}
		}
		int gk = 0;
		int kk = 0;
		int gkk = 0;
		int kkk = 0;
		//System.out.println(gbcou + "," + gwcou+ ","+kbcou + "," +kwcou);
		if(kbcou >= kwcou){
			kk = 1;
			kkk = kbcou-kwcou;
		}else{
			kk = 0;
			kkk = kwcou-kbcou;
		}
		if(gbcou >= gwcou){
			gk = 1;
			gkk = gbcou-gwcou;
		}else{
			gk = 0;
			gkk = gwcou-gbcou;
		}
		if(gk != kk){
			System.out.print(Math.min(kbcou,kwcou)+Math.min(gbcou,gwcou));
		}else{
			if(gkk >= kkk){
				kk = 1 - kk;
			}else{
				gk = 1 - gk;
			}
			System.out.print((kk == 0?kbcou:kwcou)+(gk == 0?gbcou:gwcou));
		}
	}
}


Measured memory_bytes: 29796
#include <bits/stdc++.h>
#include<iostream>
#include <string>
using namespace std;
 
int main() {
    int A,B,M;

    cin >> A >> B >> M;
    vector<int>a(A);
    vector<int>b(B);

    for(int i = 0;i < A;i++){
        cin >> a.at(i);
    }
    for(int i = 0;i < B;i++){
        cin >> b.at(i);
    }
    int m[M][3];
   
  	for(int i = 0;i < M;i++){
		for(int j = 0;j < 3;j++){
          cin >> m[i][j];
        }
    }
  
    int tmp,x,y,z,ans(9999999);
   for(int i = 0; i < M;i++){
        x = m[i][0];
        y = m[i][1];
        z = m[i][2];
      	x--;
      	y--;
        tmp = a[x] + b[y] - z; 
        ans = min(ans,tmp);
    }
   
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    tmp = a.at(0) + b.at(0);

    ans = min(ans,tmp);

    cout << ans;
   
    
}


Measured memory_bytes: 2176