akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M, K;
  cin >> N >> M >> K;
  vector<ll> A(N + 1, 0), B(M);
  for (ll i = 1; i <= N; ++i) {
    cin >> A.at(i);
  }
  for (ll i = 0; i < M; ++i) {
    cin >> B.at(i);
  }
  for (ll i = 0; i < N; ++i) {
    A.at(i + 1) += A.at(i);
  }
  for (ll i = 0; i < M - 1; ++i) {
    B.at(i + 1) += B.at(i);
  }
  ll ans = 0;
  for (ll i = 0; i <= N; ++i) {
    if (K - A.at(i) < 0) {
      break;
    }
    ll index = (ll)(upper_bound(B.begin(), B.end(), K - A.at(i)) - B.begin());
    // cout << index << "\n";
    ans = max(ans, i + index);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  int D,L;
  cin >> D >> L;
  cout << (D / L) + (D % L) << endl;
}



Measured memory_bytes: 3096
Scanf.(Array.(
  scanf" %d %d"@@fun n t->
    init n(fun _->scanf" %d"@@fun v->v)
    |> to_list |> List.rev |> of_list
    |> fold_left (fun (mx,u,c) v ->
      if mx<v then (v,u,c)
      else let w = mx-v in
        if w>u then (mx,w,1)
        else if w=u then (mx,u,c+1)
        else (mx,u,c)
    ) (0,0,0)
    |> (fun (_,_,c) -> print_int c)))

Measured memory_bytes: 8704
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	string s;
	cin >> s;
	int co = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1') {
			co++;
		}
	}
	cout << co << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

h = [2,4,5,7,9]
p = [0,1,6,8]
n = input()
if int(n[-1]) in h:
    print('hon')
elif int(n[-1]) in p:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 10352
L,R = list(map(int, input().split()))

MOD=[0] * (2019*2019)

def myidx(i,j):
    return i * 2019 + j

for i in range(2019):
    for j in range(i+1,2019):
        idx = myidx(i,j)
        MOD[idx] = (i*j) % 2019

#for i in range(2019):
#    idx = myidx(i,i)
#    MOD[idx] = 2019

MMM = []
MIN = 2019
Lmod = L % 2019
Rmod = R % 2019

if L+2019 <= R:
    for i in range(2019):
        for j in range(i+1,2019):
            idx = myidx(i,j)
            MIN = min(MIN, MOD[idx])
            #MMM.append(MOD[idx])
elif Lmod <= Rmod:
    for i in range(Lmod, Rmod+1):
        for j in range(i+1, Rmod+1):
            idx = myidx(i,j)
            MIN = min(MIN, MOD[idx])
            #MMM.append(MOD[idx])

elif Lmod > Rmod:
    for i in list(range(0,Rmod+1)) + list(range(Lmod, 2019)):
        for j in list(range(i+1,Rmod+1)) + list(range(max(Lmod,i+1), 2019)):
            idx = myidx(i,j)
            MIN = min(MIN, MOD[idx])
            #MMM.append(MOD[idx])

#MMM=list(set(MMM))
#MMM.sort()
#print(MMM.pop(0))
print(MIN)


Measured memory_bytes: 92932
#include <iostream>

using namespace std;

int main() {
    int d[5];
    for (int i = 0; i < 5; i++) {
        int temp;
        cin >> temp;
        d[i] = temp;
    }
    int k;
    cin >> k;
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < i; j++) {
            if (d[i] - d[j] > k) {
                cout << ":(";
                return 0;
            }
        }
    }
    cout << "Yay!";
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 A, B;
  cin >> A >> B;
  cout << A * B << endl;
}


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

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

    for(int i=0; i<n; ++i){
        int x, y, b, p;
        cin >> x >> y >> b >> p;
        int ret = x * b + y * p;
        ret = min(ret, (x * max(b, 5) + y * max(p, 2)) * 4 / 5);
        cout << ret << endl;
    }

    return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll x;

int main() {
    cin >> x;
    if (x % 11 == 0) cout << x / 11 * 2 << endl;
    else if (x - 11 * (x / 11) <= 6) cout << x / 11 * 2 + 1 << endl;
    else cout << x / 11 * 2 + 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	COMinit();
	int n, k; cin >> n >> k;
	rep(i, k) {
		int tmp = COM(n - k + 1, i + 1);
		tmp *= COM(k - 1, i);
		cout << tmp %MOD<< endl;
	}
	return 0;
}

Measured memory_bytes: 12160
from sys import stdin

N = int(stdin.readline().rstrip())
vac = []
for i in range(N):
    vac.append([int(x) for x in stdin.readline().rstrip().split()])
dp = [[0]*3 for _ in range(N+1)]
for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + vac[i][k])
print(max(dp[N]))

Measured memory_bytes: 70620
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string s;
int k,u,p,c;
int main(void){
  cin >> s;
  for(int i = 0; i < (int)s.size(); i++){
    switch(s[i]){
    case 'K': k++;break;
    case 'U': u++;break;
    case 'P': p++;break;
    case 'C': c++;break;
    }
  }
  cout << min(k,min(u,min(p,c))) << endl;
}

Measured memory_bytes: 1188
//author:emre yazicioglu

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define fori(a,b,c) for(ll a = b;a < ll(c);a++)
#define ford(a,b,c) for(ll a = b;a >= ll(c);a--)
#define pb push_back

const int N = 2e6 + 7;
ll n,m,k,ans,cur,ar[N];
string str;
vector<ll> v;
double sum;

int main(){

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

	// freopen("../in.txt","r",stdin);
	// freopen("../out.txt","w",stdout);
	ll g = 0;
	cin >> n;
	fori(i,0,n){
		cin >> ar[i];
		sum += double(1.0/ar[i]);
	}
	printf("%0.6lf",(1.0/sum));


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 200005
using namespace std;
int a[M],mx1,mx2,n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]>=mx1)mx2=mx1,mx1=a[i];
		else if(a[i]>=mx2)mx2=a[i];
	} 
	for(int i=1;i<=n;i++){
		if(a[i]==mx1)printf("%d\n",mx2);
		else printf("%d\n",mx1);
	}
	return 0;
}

Measured memory_bytes: 2432
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a; cin>>a;
  if(a==1)cout<<"Hello World"<<endl;
  else{
    int b,c; cin>>b>>c;
    cout<<b+c<<endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

ll n;
lvector vec(n,0);
vector<lvector> G(n);

void dfs(ll v,ll p=-1) {
  for(ll u:G[v]) {
    if(u==p) continue;
    vec[u]+=vec[v];
    dfs(u,v);
  }
  return;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll q,a,b,p,x;cin>>n>>q;
  vec.resize(n),G.resize(n);
  rep(i,n-1) {
    cin>>a>>b;
    a--,b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  rep(i,q) {
    cin>>p>>x;p--;
    vec[p]+=x;
  }
  dfs(0);
  rep(i,n) print(vec[i]);
  return 0;
}

Measured memory_bytes: 24320
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
#define ff first
#define ss second
#define Clear(x) memset(x,0,sizeof(x))
#define all(x) (x).begin(),(x).end()

void checkpoint1()
{
	/******think more code less******/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

bool comp(pair< ll,ll > &a,pair< ll,ll > &b)
{
	if(a.ff!=b.ff)
		return a.ff<b.ff;
	else
	{
		if(a.ss>b.ss)
			return b.ss<a.ss;
		else if(a.ss<b.ss)
			return a.ss<b.ss;
	}
	return a.ff>b.ff;
}

ll powe(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1)
		{
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b>>=1;
	}
	return res;
}

int main()
{
	checkpoint1();
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
	ll ans=0,op=a[0];
	for(ll i=1;i<n;i++){
		op=max(op,a[i]);
		ans+=max(0LL,op-a[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
   struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
  int main(){
      lint v,e;
      cin>>v>>e;
    tuple <lint,lint,lint> x[e];
    rep(i,e){
        lint a,b,c;
        cin>>a>>b>>c;
        x[i]=make_tuple(c,a,b);
    }
    sort(x,x+e);
    UnionFind tree(v);
    lint ans=0;
    rep(i,e){
        lint a,b,c;
        tie(a,b,c)=x[i];
        if(tree.same(b,c)){
           // tree.unite(b,c);
        }else{
            ans+=a;
            tree.unite(b,c);
        }
    }
    cout<<ans<<endl;
   
    }
     
  



Measured memory_bytes: 5500
/*#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'

using namespace std;

vector<vector<int>> d;
vector<int> lis, ans;

void DFS(int vertex, int parent){
    lis.push_back(-1);
    ans[vertex] = lis.back();
    for (int q: d[vertex]){
        if (q != parent){
            DFS(q, vertex);
        }
    }
    lis.pop_back();
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int q = 0; q < n; q++){
        cin >> a[q];
    }
    d.assign(n, {});
    ans.assign(n, 0);
    for (int q = 0; q < n-1; q++){
        int x, y;
        cin >> x >> y;
        d[x-1].push_back(y-1);
        d[y-1].push_back(x-1);
    }
    DFS(0, -1);
    for (int q: ans){
        cout << q << endl;
    }
    return 0;
}*/
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m;
    cin >> n >> m;
    for (int q = 1; q <= m; q++){
        cout << q << ' ';
        if (n % 2 == 1 || q <= (m+1)/2){
            cout << n-q+1 << endl;
        }else{
            cout << n-q << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c,d;
	vector<LL> v1;
	cin>>n;
	a=0;
	for(i=0;i<n;i++){
		cin>>b;
		if(i>=2)a^=b;
		v1.push_back(b);
	}
	b=0,d=0,c=v1[0]+v1[1];
	for(i=0;i<45;i++){
		k=0;
		if(a&((LL)1<<i))k++;
		if(c&((LL)1<<i))k++;
		if(k==1){
			c-=(LL)1<<i;
			for(j=i-1;j>=0;j--){
				if(d&((LL)1<<j)){
					cout<<-1<<endl;
					return 0;
				}
				d|=((LL)1<<j);
				if(b&((LL)1<<j)){
					b-=((LL)1<<j);
				}else{
					break;
				}
			}
			if(j<0){
				cout<<-1<<endl;
				return 0;
			}
		}
		if(c&((LL)1<<i)){
			b|=(LL)1<<i;
		}
	}
	for(i=45;i>=0;i--){
		if(~b&((LL)1<<i))continue;
		if(d+((LL)1<<i)<=v1[0])d+=(LL)1<<i;
	}
	if(d>v1[0] || d==0)cout<<-1<<endl;
	else cout<<v1[0]-d<<endl;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys
import math

def solve(H: int):
    n = int(math.log(H, 2))
    
    a = 1
    sum = 0
    for _ in range(0, n + 1):
        sum += a
        a *= 2
    
    print(sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    solve(H)

if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll ap[100100], bp[100100], cp[100100];
ll a, b, m;
ll x[100100], y[100100];

int main(void)
{
    cin >> a >> b >> m;
    REP(i, a) cin >> ap[i];
    REP(i, b) cin >> bp[i];
    REP(i, m) cin >> x[i] >> y[i] >> cp[i];
    ll lowa = INF, lowb = INF, lowab = INF;
    REP(i, a) {
        lowa = min(lowa, ap[i]);
    }
    REP(i, b) {
        lowb = min(lowb, bp[i]);
    }
    REP(i, m) {
        lowab = min(lowab, ap[x[i]-1] + bp[y[i]-1] - cp[i]);
    }
    ll res ;
    res = min(lowa + lowb, lowab);
    cout << res << endl;
}


Measured memory_bytes: 4096
"""
シミュレートしてみればわかるが、高橋君は青木君よりも自分の方が近いようなノードのうち、青木君から最も遠いノードに向かって逃げるのが最善手。
そのようなノードをXとおくと、青木君と高橋君が鉢合わせるノードはXの一つ手前のノードになる。
したがって、青木君が動かす手の数はXまでの手数-1となる。
"""
from collections import deque
N,u,v = map(int,input().split())
edges = [[] for _ in range(N+1)]
for _ in range(N-1):
    a,b = map(int,input().split())
    edges[a].append(b)
    edges[b].append(a)

takahashiDist = [None]*(N+1)
que = deque([(u,0)])
while que:
    n,step = que.popleft()
    takahashiDist[n] = step
    for nx in edges[n]:
        if takahashiDist[nx] == None:
            que.append((nx,step+1))


aokiDist = [None]*(N+1)
que = deque([(v,0)])
while que:
    n,step = que.popleft()
    aokiDist[n] = step
    for nx in edges[n]:
        if aokiDist[nx] == None:
            que.append((nx,step+1))
ans = 0
for i in range(1,N+1):
    if aokiDist[i] > takahashiDist[i]:
        ans = max(ans,aokiDist[i]-1)
print(ans)

Measured memory_bytes: 91988
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
    int m;  //?????£??????????????°
    int h;  //?????£?????????????????????
    int len;    //??????
    int i;  //??°??????????????°
    int j;  //??°?????????
    char ch[201];   //??????????????????
    char tmp1[201]; //???????????????
    char tmp2[201]; //???????????????
    char *pch;
    char *ptmp1;
    char *ptmp2;
    
    for(i = 0; i < 201; i++)
    {
        ch[i] = 0;
        tmp1[i] = 0;
        tmp2[i] = 0;
    }
    
    
    while(1)
    {
        scanf("%s", ch);
        len = strlen(ch);
        if(strstr(ch, "-"))
        {
            break;
        }
        
        scanf("%d", &m);
        pch = ch;
        ptmp1 = tmp1;
        ptmp2 = tmp2;
        for(i = 0; i < m; i++)
        {
            scanf("%d", &h);
            strncpy(ptmp1, pch, h);
            strncpy(ptmp2, (pch + h), len - h);
            
            //printf("tmp1 %s\n", tmp1);
            //printf("tmp2 %s\n", tmp2);
            
            strcpy(ch, strcat(tmp2, tmp1));
            //printf("ch %s\n", ch);
            
            for(j = 0; j < 201; j++)
            {
                tmp1[j] = 0;
                tmp2[j] = 0;
            }
        }
        printf("%s\n", ch);
    }
    return 0;
}

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

int N, A[101] = {};

int64_t cost(int ave){
  int64_t sum = 0;
  
  for (int i = 0; i < N; i++){
    sum += (A[i] - ave) * (A[i] - ave);
  }
  return sum;
}


int main(){
  int S = 0, ave = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++){
    cin >> A[i];
    S += A[i];
  }
  
  if (S % N == 0){
    cout << cost(S/N) << endl;
  }else{
    cout << min(cost(S/N), cost(S/N+1)) << endl;
  }
}

Measured memory_bytes: 256
@s = gets.chomp

def dfs(i,sum,ans)
  if i == 4
    if sum == 7
      puts ans + "=7"
      exit
    end
  else
    dfs(i+1,sum + @s[i].to_i,ans + "+" + @s[i])
    dfs(i+1,sum - @s[i].to_i,ans + "-" + @s[i])
  end
end

dfs(1,@s[0].to_i,@s[0])

Measured memory_bytes: 1788
fn main() {
    let buf = io::read_string();
    let mut sc = io::Scanner::new(&buf);
    let mut n: i64 = sc.read();
    let mut k = 1i64;
    let mut res = String::new();

    if n == 0 {
        res.push('0');
    }
    while n != 0 {
        if (n - k) % (2 * k).abs() == 0 {
            res.push('1');
            n -= k;
        } else {
            res.push('0');
        }
        k *= -2;
    }
    println!("{}", res.chars().rev().collect::<String>());
}

#[allow(dead_code)]
mod io {
    use std;
    use std::io::Read;
    use std::str::{FromStr, SplitWhitespace};
    pub struct Scanner<'a> {
        pub iter: SplitWhitespace<'a>,
    }
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            self.iter
                .next()
                .unwrap()
                .parse()
                .ok()
                .expect("parsing failed")
        }
        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read()).collect()
        }
    }
    pub fn read_string() -> String {
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
}


Measured memory_bytes: 4352
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace AOJ2
{
    class Program
    {
        static void Main()
        {

            var param = int.Parse(Console.ReadLine());
            while (param != 0)
            {
                var taroCard = Read(param).OrderBy(x => x).ToList();

                var hanakoCard = Enumerable.Range(1, param * 2).Except(taroCard).OrderBy(x => x).ToList();
                var filedCard = 0;

                while (hanakoCard.Count != 0)
                {
                    var kouho = taroCard.Where(x => filedCard < x).FirstOrDefault();
                    filedCard = kouho;
                    taroCard.Remove(kouho);
                    if (taroCard.Count == 0) break;
                    kouho = hanakoCard.Where(x => filedCard < x).FirstOrDefault();
                    filedCard = kouho;
                    hanakoCard.Remove(kouho);
                }
                Console.WriteLine(hanakoCard.Count);
                Console.WriteLine(taroCard.Count);
                param = int.Parse(Console.ReadLine());
            }


        }

        private static IEnumerable<int> Read(int loop)
        {
            for (int i = 0; i < loop; i++)
            {
                yield return int.Parse(Console.ReadLine());
            }
        }
    }
}

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

class lazy_segtree {
    private:
        int size;
        vector<int> node,lazy;
    public:
        lazy_segtree(int n_) {
            size=1;
            while (size<n_) size*=2;
            node.resize(2*size, 0);
            lazy.resize(2*size, 0);
        }

        void setlazy(int k, int v) {
            if (k>=2*size-1) return ;
            lazy[k] += v;
            node[k] += v;
        }

        void push(int k) {
            if (k>=2*size-1) return ;
            if (lazy[k] == 0) return ;
            setlazy(k * 2 + 1, lazy[k]);
            setlazy(k * 2 + 2, lazy[k]);
            lazy[k] = 0;
        }

        void range_add(int queryL,int queryR,int val,int k=0,int nodeL=0,int nodeR=-1) {
            if (nodeR==-1) nodeR=size;
            if (nodeR<=queryL || queryR<=nodeL) return ;
            if (queryL<=nodeL && nodeR<=queryR) {
                setlazy(k,val);
                return ;
            }
            else {
                push(k);
                int nodeM=(nodeL+nodeR)/2;
                range_add(queryL,queryR,val,k*2+1,nodeL,nodeM);
                range_add(queryL,queryR,val,k*2+2,nodeM,nodeR);
                return ;
            }
        }

        int get_node(int queryL,int queryR,int k=0,int nodeL=0,int nodeR=-1) {
            if (nodeR==-1) nodeR=size;
            if (nodeR<=queryL || queryR<=nodeL) return -1;
            if (queryL<=nodeL && nodeR<=queryR) return node[k];
            else {
                push(k);
                int nodeM=(nodeL+nodeR)/2;
                int ret1=get_node(queryL,queryR,k*2+1,nodeL,nodeM);
                int ret2=get_node(queryL,queryR,k*2+2,nodeM,nodeR);
                if (ret1!=-1) return ret1;
                else if(ret2!=-1) return ret2;
            }
        }
};

int n,q;

int main(){
    cin >> n >> q;
    lazy_segtree ls(n);
    for (int i=0; i<q; i++) {
        int que,s,t,x,idx;
        cin >> que;
        if (que==0) {
            cin >> s >> t >> x;
            ls.range_add(s-1,t,x);
        }
        else {
            cin >> idx;
            cout << ls.get_node(idx-1,idx) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}
void YES_NO(bool f) {
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
}

template <typename T>
void deb1(T x) {
  cout << x << "\n";
}

template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  rep(i, n) {
    int tmp;
    cin >> tmp;
    ans += 2 * min(abs(k - tmp), tmp);
  }
  out(ans);
}
int main(void) { solve(); }

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

int main(){
	// sengen
	int a,b,c;
	// nyuryoku
	cin >> a >> b >> c;
	// keisan
	int amari = a%b;
	for(int i=1;i<=b;i++){
		if(i*a%b == c){
			cout << "YES";
			break;
		}
		if(i == b){
			cout << "NO";
			break;
		}
	}
}

Measured memory_bytes: 256
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>


using namespace std;

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

        cout<<r*r<<endl;
    }


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

int main() {
    //input
    int n;
    cin >> n;
    //
    vector<pair<int,int>> tasks;

    for(int i=0;i<n;i++){
        int a,b;
        cin >> a >> b;
        tasks.emplace_back(b,a);
    }

    sort(tasks.begin(),tasks.end());
    int sum = 0;
    bool flag = true;
    for (auto task : tasks){
        sum += task.second;

        if(sum > task.first){
            flag = false;
            break;
        }
    }

    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 2420
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,x;
    map <ll,ll> m;
    cin>>n;
    for(i=1;i<n;++i){
    	cin>>x;
    	m[x]++;
	}
	for(i=1;i<=n;++i){
		cout<<m[i]<<'\n';
	}
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int s, w; cin>>s>>w;
    if(w>=s) out("unsafe");
    else out("safe");
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
using namespace std;


signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int N;
    cin >> N;
    int A[N];
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int l[N + 1], r[N + 1];
    l[0] = 0;
    r[N] = 0;
    int neg = 1;
    for (int i = 0; i < N; i++ ) {
        l[i + 1] = l[i] + neg * A[i];
        neg *= (-1);
    }
    neg = 1;
    for (int i = N; i >= 1; i-- ) {
        r[i - 1] = r[i] + neg * A[i - 1];
        neg *= (-1);
    }
    for (int i = 0; i < N; i++) {
        cout << abs(r[i] - l[i]) << " ";
    }
    cout << endl;



    return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>

double s[100000], t[50000];

void intAryScan(double b[], int size)
{
  int i;
  for(i = 0; i < size; i++){
    scanf("%lf", &b[i]);
  }
  return;
}

int main()
{
  int c, i, j, mid, n, q;

  scanf("%d", &n);
  intAryScan(s, n);
  scanf("%d", &q);
  intAryScan(t, q);

  c = 0;
  for(i = 0; i < q; i++){
	mid = n/2;
	if(s[mid] < t[i]){
      for(j = mid + 1; (j < n) && (s[j] < t[i]); j++)
		 ;
	  if(j < n && t[i] == s[j]){
		  c++;
	  }
	}else if(t[i] < s[mid]){
	  for(j = 0; (j < mid) && (s[j] < t[i]); j++)
		 ;
	  if(j < mid && t[i] == s[j]){
		  c++;
	  }
	}else if(s[mid] == t[i]){
		c++;
	}
  }
  printf("%d\n", c);

  return(0);
}

Measured memory_bytes: 1804
import java.util.Scanner;

public class Main {

	static  Scanner in = new Scanner(System.in);
	
	public static void main(String[] args) {
		
		int n, ct = 0;
		n = in.nextInt();
		String ch;
		ch = in.next();
		
		for(int i = 0; i < n - 1; i++)
		{
			if(ch.charAt(i) == ch.charAt(i + 1))
			{
				
			}
			else
			{
				ct++;
			}
		}
		System.out.println(ct + 1);
	}

}


Measured memory_bytes: 25060
#include <stdio.h>
int main()
{
    int a, b, c, as[4];
    scanf("%d %d %d", &a, &b, &c);
    if (a<=b)
    {
        as[0]=a;
        as[1]=b;
    }
    else
    {
        as[0]=b;
        as[1]=a;
    }
    if(as[1]<=c)
    {
        as[2]=c;
    }
    else
    {
        as[2]=as[1];
        as[1]=c;
    }
    if (as[0]>as[1])
    {
        as[3] = as[0];
        as[0]=as[1];
        as[1]= as[3];
    }
    printf("%d %d %d\n", as[0],as[1],as[2]);

    return 0;

}



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

constexpr int LEN = 105;
bool ga[LEN][LEN];

void bfs(int d[], const int n){
	queue<int> q;
	q.push(0);
	d[0] = 0;
	while(q.size()){
		int id = q.front(); q.pop();
		rep(i, n){
			if(ga[id][i] && d[i] < 0){
				d[i] = d[id] + 1;
				q.push(i);
			}
		}
	}
	return;
}

int main(){
	int d[LEN];
	memset(d, -1, LEN*sizeof(int));
	memset(ga, 0, LEN*LEN*sizeof(bool));
	int n; cin >> n;
	rep(i, n){
		int u, k; cin >> u >> k;
		rep(j, k){
			int v; cin >> v;
			ga[u-1][v-1] = 1;
		}
	}

	bfs(d, n);
	rep(i, n) cout << i+1 << ' ' << d[i] << endl;

	return 0;
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  bool ye=0;
  rep(i,n){
    char a; cin>>a;
    if(a=='Y')
    ye=1;
  }
  if(ye)
  cout<<"Four"<<endl;
  else
  cout<<"Three"<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#define rep(x, l, r) for(int x = l; x <= r; x++)
#define repd(x, r, l) for(int x = r; x >= l; x--)
#define clr(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define MAXN 25
#define fi first
#define se second
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
const int INF = 1 << 30;
const int p = 1000000009;
int lowbit(int x){ return x & (-x);}
int fast_power(int a, int b){ int x; for(x = 1; b; b >>= 1){ if(b & 1) x = 1ll * x * a % p; a = 1ll * a * a % p;} return x % p;}

const int dic[4][2] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
queue<pii> que;
int n, m;
int dis[MAXN][MAXN];
char st[MAXN];
bool a[MAXN][MAXN], vis[MAXN][MAXN];

void bfs(int sx, int sy){
	que.push(mp(sx, sy));
	clr(vis, 0);
	vis[sx][sy] = 1;
	dis[sx][sy] = 0;
	while(!que.empty()){
		int ux = que.front().fi, uy = que.front().se;
		que.pop();
		rep(i, 0, 3){
			int vx = ux + dic[i][0], vy = uy + dic[i][1];
			if(vx < 1 || vy < 1 || vx > n || vy > m || vis[vx][vy] || a[vx][vy]) continue;
			vis[vx][vy] = 1;
			dis[vx][vy] = dis[ux][uy] + 1;
			que.push(mp(vx, vy));
		}
	}
}

int main(){
	scanf("%d%d", &n, &m);
	rep(i, 1, n){
		scanf("%s", st);
		rep(j, 1, m) a[i][j] = st[j - 1] == '#';
	}
	int ans = 0;
	rep(i, 1, n)
		rep(j, 1, m){
			if(a[i][j]) continue;
			bfs(i, j);
			rep(k, 1, n)
				rep(l, 1, m){
					if(a[k][l]) continue;
					ans = max(ans, dis[k][l]);
				}
		}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n + 1];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		int[] b = new int[n];
		for (int i = 0; i < b.length; i++) {
			b[i] = sc.nextInt();
		}
		sc.close();

		long ans = 0;
		for (int i = n - 1; i >= 0; i--) {
			if (a[i + 1] + a[i] < b[i]) {
				ans += a[i + 1] + a[i];
				a[i] = 0;
			} else {
				ans += b[i];
				if (a[i + 1] < b[i]) {
					a[i] -= b[i] - a[i + 1];
				}
			}
		}
		System.out.println(ans);
	}
}


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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    vector <int> a(n);
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
    }
    k=min(n,k);
    sort(a.begin(),a.end());
    for(int i=0;i<k;++i)
    {
        a.erase(a.begin()+a.size()-1);
    }
    int s=0;
    for(int i=0;i<a.size();++i)
    {
        s+=a[i];
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 1792
N,T = map(int,input().split())
X = list(map(int,input().split()))

ans = 0
for i in range(N):
 if(i != N-1):
  if(X[i]<X[i+1]<X[i]+T): ans += X[i+1] - X[i]
  else: ans += T
 elif(i == N-1):
  ans += T
print(ans)

Measured memory_bytes: 26708
N, M = map(int,input().split())

A = []
for i in range(N):
    A.append(input())

B = []
for i in range(M):
    B.append(input())

for i in range(N-M+1):
    for j in range(N-M+1):
        for k in range(M):
            if A[i+k][j:j+M] != B[k]:
                break
            if k == M-1:
                print("Yes")
                exit()

print("No")

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;

int main() {
	ll n, a;

	cin >> n >> a;

	cout << n * n - a << endl;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> s(N+2);
    vector<string> vs(N+2);
    vs[0] = "kogakubu10gokan";
    s[N+1] = 51;

    for (int i = 1; i <= N; i++) {
        cin >> s[i] >> vs[i];
    }

    string ans;
    for (int i = 1; i <= N+1; i++) {
        if (s[i-1] <= M && M < s[i]) {
            ans = vs[i-1];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3192
n = gets.to_i
n.times{
  xa, ya, ra, xb, yb, rb = gets.split.map(&:to_f)
  rab = Math.sqrt((xb - xa)**2 + (yb - ya)**2)
  if rab > ra + rb
    puts "0"
  elsif rb > rab + ra
    puts "-2"
  elsif ra > rab + rb
    puts "2"
  else
    puts "1"
  end
}

Measured memory_bytes: 8664
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int num;
    cin >> num;
    int box[51];
    for(int i=0;i<num;i++){
        cin >> box[i];
    }
    int judge = 0;
    for(int i=0;i<num;i++){
        if(i+1!=box[i]){
            judge ++;
        }
    }
    if((judge == 0)||(judge == 2)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
	x += y;
	if( x >= m )
		x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
	x -= y;
	if( x < 0 )
		x += m;
}

int main() 
{
	#ifdef gupta_samarth
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	fastio();

	int n;
	cin>>n;

	vector<array<int,3>>points(n);
	for(int i=0;i<n;i++)
		cin>>points[i][0]>>points[i][1], points[i][2] = i;
	sort(points.begin(),points.end());

	vector<int>ans(n);

	dsu d(n);

	stack<int>st;
	for(int i=0;i<n;i++)
	{
		while( !st.empty() && points[i][1] < points[st.top()][1] )
			st.pop();
		if( !st.empty() )
			d.merge(points[i][2], points[st.top()][2]);
		st.push(i);
	}
	while( !st.empty() )
		st.pop();

	for(int i=n-1;i>=0;i--)
	{
		while( !st.empty() && points[i][1] > points[st.top()][1] )
			st.pop();
		if( !st.empty() )
			d.merge(points[i][2], points[st.top()][2]);
		st.push(i);
	}
	while( !st.empty() )
		st.pop();


	sort(points.begin(),points.end(),[&](auto a, auto b){
		return a[1] < b[1];
	});

	for(int i=0;i<n;i++)
	{
		while( !st.empty() && points[i][0] < points[st.top()][0] )
			st.pop();
		if( !st.empty() )
			d.merge(points[i][2], points[st.top()][2]);
		st.push(i);
	}
	while( !st.empty() )
		st.pop();

	for(int i=n-1;i>=0;i--)
	{
		while( !st.empty() && points[i][0] > points[st.top()][0] )
			st.pop();
		if( !st.empty() )
			d.merge(points[i][2], points[st.top()][2]);
		st.push(i);
	}
	while( !st.empty() )
		st.pop();


	for(int i=0;i<n;i++)
		cout<<d.size(i),nl;

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


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

#define MAX 10000

int main(void)
{
	int rank[3] = {0,0,0};
	int mount_data;
		
	for(int i=0;i<10;i++)
	{
		cin>>mount_data;
		if(mount_data > rank[0])
		{
			rank[2] = rank[1];
			rank[1] = rank[0];
			rank[0] = mount_data;
		}
		else if(mount_data > rank[1])
		{
			rank[2] = rank[1];
			rank[1] = mount_data;
		}
		else if(mount_data > rank[2])
		{
			rank[2] = mount_data;
		}
	}
	
	for(int i=0;i<3;i++)
	{
		cout<<rank[i]<<endl;
	}
return 0;		
}

Measured memory_bytes: 1160
import copy

n = input()
a = {'7','5','3'}
for _ in range(len(n)-1):
    b = copy.copy(a)
    for s in a:
        for i in (7,5,3):
            b.add(s + str(i))
    a = b
a = {i for i in a if not ('3' not in i or '5' not in i or '7' not in i)}

n = int(n)
a = {i for i in a if int(i)<=n}
print(len(a))

Measured memory_bytes: 12184
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	string s;
	cin>>s;
	int len=s.length();
	while(len>0)
	{
		if(len>=5)
		{
			if(s.substr(len-5,5)=="dream"||s.substr(len-5,5)=="erase")
			{
				len-=5;
				continue;
			}
		}
		if(len>=6)
		{
			if(s.substr(len-6,6)=="eraser")
			{
				len-=6;
				continue;
			}
		}
		if(len>=7)
		{
			if(s.substr(len-7,7)=="dreamer")
			{
				len-=7;
				continue;
			}
		}
		if(len!=0)
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}

	cout<<"YES"<<endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int main(){
    ll n,k;
    cin>>n>>k;
    if(k > (n-1)*(n-2)/2){
        puts("-1");
    }else{
        vector<pii> V;
        vector<pii> es;
        FOR(i,1,n)es.push_back(pii(0,i));
        FOR(i,1,n)FOR(j,i+1,n)V.push_back(pii(i,j));
        while(V.size() > k){
            pii P = V.back(); V.pop_back();
            es.push_back(P);
        }
        printf("%d\n",es.size());
        for(pii P : es){
            printf("%d %d\n", P.first+1, P.second+1);
        }
    }
    return 0;
}


Measured memory_bytes: 384