akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <chrono>
#include <random>
#include <unordered_map>
#include <cassert>
#pragma GCC optimize("O3")
#pragma comment(linker, "STACK:36777216")
using namespace std;
using i64 = int64_t;
constexpr i64 MOD = 1e9 + 7;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
using vi = vector<i64>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<i64, i64>;

int main() {
    string s;
    cin >> s;
    cout << s.substr(0, s.size() - 8) << endl;
}


Measured memory_bytes: 256
n=int(input())
l=[int(i) for i in input().split()]
l.sort()
ll=[0]*(l[-1]+1)

for i in l:
    ll[i]+=1
for i in range(1,len(ll)):
    ll[i]+=ll[i-1]

ans=0
import itertools
for i,j in itertools.combinations(l,2):
    if max(i-j,j-i)<i+j-1:
        ans+=ll[min(len(ll)-1,i+j-1)]-ll[min(len(ll)-1,max(i-j,j-i))]
        if max(i-j,j-i)<i<i+j:
            ans-=1
        if max(i-j,j-i)<j<i+j:
            ans-=1
print(ans//3)




Measured memory_bytes: 44764
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	ll a , b, x;
	cin >> a >> b >> x;
	if(a==0) cout << (ll)(b/x)+1 << endl;
	else cout << (ll)(b/x) - (ll)((a-1)/x) << endl;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int H, N; cin >> H >> N;
	vector<int>A(N); rep(i, 0, N) { cin >> A[i]; }

	Yes(accumulate(all(A), 0ll) >= H);

	return 0;
}


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

using namespace std;

#define mod1 1000000007
#define mod2 998244353
#define int long long int
#define pii pair<int,int>
#define vpii vector<pii>
#define vi vector<int>
#define fi first
#define se second
#define psb push_back
#define ppb pop_back
#define fio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define all(x) x.begin(),x.end()
// #define endl "\n"

void solve()
{
	int l,r,d;
	cin>>l>>r>>d;
	cout<<(r/d - l/d + (l%d==0))<<endl;

}

int32_t main()
{
	fio;
	int t;
	// cin>>t;
	t=1;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3636
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
#define _v1 CONCAT(qyw1, __LINE__) // unique name in same line (otherwise use __COUNTER__)
#define _v2 CONCAT(qyw2, __LINE__)
#define forbits(i, m) for (int _v1 = m, i = __builtin_ctz(_v1); _v1 != 0; _v1 ^= _v1 & -_v1, i = __builtin_ctz(_v1))
#define forsubm(s, m) for (int s = m; s >= 0; s = !s ? -1 : m & (s - 1))
int __nextXZW(int v){int t=v|(v-1);int w=(t+1)|(((~t&-~t)-1)>>(__builtin_ctz(v)+1));return w;}
#define ksets(i, n, k) for (int i = (1u << k) - 1, max = i << (n - k); i <= max; i = __nextXZW(i))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n; cin >> n;
  int cnt = 0;
  rep (i, n) {
    int x, y; cin >> x >> y;
    if (x == y) cnt++;
    else cnt = 0;
    if (cnt == 3) {
      cout << "Yes" << '\n';
      return 0;
    } 
  }
  cout << "No" << '\n';

  return 0;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define poly vector<ll>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
inline ll read(){
	ll x=0;char ch=getchar();bool d=1;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') d=0;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return d?x:-x;
}
inline void write(ll x){
	if(x<0) x=-x,putchar('-');
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=2e5+5,mo=1e9+7;
int fac[N],inv[N];
int C(int n,int m){
	if(n<m) return 0;
	return (ll)fac[n]*inv[m]%mo*inv[n-m]%mo;
}
int S(int sx,int sy,int tx,int ty){
	return C(tx+ty-sx-sy,tx-sx);
}
int ksm(int x,int p){
	int res=1;
	for(;p;p>>=1,x=(ll)x*x%mo){
		if(p&1) res=(ll)res*x%mo;
	}
	return res;
}
void init(int n){
	For(i,fac[0]=1,n) fac[i]=(ll)fac[i-1]*i%mo;
	inv[n]=ksm(fac[n],mo-2);
	Rep(i,n-1,0) inv[i]=(ll)inv[i+1]*(i+1)%mo;
}
int main(){
	int n=read(),m=read(),h=read(),w=read();
	if(w==m) return putchar('0'),0;
	init(N-1);int ans=S(1,1,n,m);
	For(i,n-h+1,n){
		int t=(ll)S(1,1,i,w)*S(i,w+1,n,m)%mo;
		ans=(ans-t+mo)%mo;
	}
	cout<<ans;
}

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

using namespace std;

const int MAX_N = 100000;

int N, M;
int C[MAX_N];
vector< int > g[MAX_N], r[MAX_N];

bool v[MAX_N], bipartite[MAX_N];
int comp[MAX_N], sum[2][MAX_N], cc[MAX_N];
vector< int > order;
vector< int > decomp[MAX_N];

int dp[2][MAX_N];

void dfs(int idx)
{
  if(v[idx]) return;
  v[idx] = true;
  for(auto &to : g[idx]) dfs(to);
  order.push_back(idx);
}

void rdfs(int idx, int ptr)
{
  if(~comp[idx]) return;
  comp[idx] = ptr;
  decomp[ptr].push_back(idx);
  for(auto &to : r[idx]) rdfs(to, ptr);
}

bool dfs2(int idx, bool color, int ptr)
{
  if(~cc[idx]) return (cc[idx] != color);
  cc[idx] = color;
  sum[color][ptr] += C[idx];
  bool flag = false;
  for(auto &to : g[idx]) {
    if(comp[to] == comp[idx]) flag |= dfs2(to, !color, ptr);
  }
  return (flag);
}

int main()
{
  scanf("%d %d", &N, &M);
  for(int i = 0; i < N; i++) {
    scanf("%d", &C[i]);
  }
  for(int i = 0; i < M; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    r[b].push_back(a);
  }

  for(int i = 0; i < N; i++) dfs(i);
  reverse(begin(order), end(order));
  int ptr = 0;
  memset(comp, -1, sizeof(comp));
  for(auto &u : order) {
    if(comp[u] == -1) rdfs(u, ptr++);
  }

  memset(cc, -1, sizeof(cc));
  for(int i = 0; i < ptr; i++) {
    bipartite[i] = dfs2(decomp[i][0], false, i);
  }
  
  memset(dp, -1, sizeof(dp));
  dp[cc[0]][comp[0]] = sum[cc[0]][comp[0]];

  int ret = 0;
  for(int i = 0; i < ptr; i++) {

    if(bipartite[i]) {
      if(dp[0][i] == -1 && dp[1][i] == -1) continue;
      int beet = 0;
      if(~dp[0][i]) beet = max(beet, dp[0][i] + sum[1][i]);
      if(~dp[1][i]) beet = max(beet, dp[1][i] + sum[0][i]);
      dp[0][i] = dp[1][i] = beet;
    }

    for(auto &curr : decomp[i]) {
      for(int j = 0; j < 2; j++) {
        if(dp[j][i] == -1) continue;
        for(auto &next : g[curr]) {
          if(comp[curr] == comp[next]) continue;
          int real = cc[curr] ^cc[next] ^j ^1;
          dp[real][comp[next]] = max(dp[real][comp[next]], dp[j][i] + sum[real][comp[next]]);
        }
      }
    }

    ret = max(ret, dp[0][i]);
    ret = max(ret, dp[1][i]);
  }

  printf("%d\n", ret);
}

Measured memory_bytes: 27072
import java.util.Scanner;

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

		// 入力値の取得
		long N = sc.nextLong();
		long K = sc.nextLong();
		
		long rem = N % K;
		
		// 結果の出力
		System.out.println(K - rem > rem? rem : K - rem);

		sc.close();
	}

}


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

typedef long long ll;
typedef std::pair<ll, ll> P;

constexpr ll INF = 1e15;
constexpr ll mod = 1e9+7;

#define rep(i,n) for(int i = 0; i < int(n); i++)
using namespace std;

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

int main() {
    ll n, m;
    cin >> n >> m;
    ll count = 1LL << m;
    ll sum = (m * 1900) + (n - m) * 100;
    sum *= count;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <istream>
#include <unordered_set>
#include <unordered_map>
#include <random>
#include <time.h>
#include <chrono>
#include <cstdio>
#include <fstream>
using namespace std;
#define ll long long
#define ld long double
#define all(x) x.begin() , x.end()
#define deb(z) cout << #z << ' ' << z << '\n';
#define pb push_back
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("test.txt" , "r" , stdin);
    //freopen("jump.out" , "w" , stdout);
    ll n;
    cin >> n;
    vector <ll> p(n);
    for(auto &x : p) {
        cin >> x;
    }
    vector <ll> dp(n - n % 2);
    dp[0] = p[0];
    dp[1] = p[1];
    for(int i = 2; i < dp.size(); i++) {
        if(i % 2) {
            dp[i] = p[i] + max(dp[i - 2] , dp[i - 3]);
        } else {
            dp[i] = p[i] + dp[i - 2];
        }
    }
    ll ans = max(dp[dp.size() - 1] , dp[dp.size() - 2]);
    if(n % 2) {
        ll tmp = 0;
        for (int i = dp.size() - 1; i >= 0; i -= 2) {
            ans = max(ans, p.back() + tmp + (i - 2 >= 0 ? dp[i - 2] : 0));
            tmp += p[i - 1];
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 6368
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int N,X;
    cin >> N >> X;
    if(X==1 || X==2*N-1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    int ans[2*N-1];
    X--;
    for(int i=N-1;i<2*N-1;i++){
        ans[i]=X+1;
        X=(X+1)%(2*N-1);
    }
    for(int i=0;i<=N;i++){
        ans[i]=X+1;
        X=(X+1)%(2*N-1);
    }
    rep(i,2*N-1) cout << ans[i] << endl;
}

Measured memory_bytes: 4412
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n, m;

struct TheKey
{
	int cost;
	int size;
	int b[20];
	bool c[20];
	long long cMask;
};

TheKey keys[1010];
std::vector<TheKey> keyTypes[20];	//keyTypes[i]表示，第i个有解 

long long fullMask;

bool hasSolution[20];

bool compare(const TheKey &a, const TheKey &b)
{
	if (a.cost == b.cost)
	{
		return a.size < b.size;
	}
	else
	{
		return a.cost < b.cost;
	}
}

int maxCost = 100000010;

int costMap[10000];

void doSearch(int curCost, long long curMask)
{
	if (curMask == fullMask) {
		if (curCost < maxCost) {
			maxCost = curCost;
			costMap[curMask] = curCost;
		}
		return ;
	}
	else if (curCost >= maxCost) {
		return ;
	}
	else {
		for (int i = 0 ; i < m ; i++)
		{
			int newCost = curCost + keys[i].cost;
			int newMask = curMask | keys[i].cMask;
			
			if (costMap[newMask] == -1)
			{
				costMap[newMask] = newCost;
				doSearch(newCost, newMask);
			}
			else
			{
				int oldCost = costMap[newMask];
				if (newCost < oldCost)
				{
					costMap[newMask] = newCost;
					doSearch(newCost, newMask);
				}
			}
		}
	}
}

int main()
{
	scanf("%d%d", &n, &m);
	fullMask = 0;
	for (int i = 0 ; i < n ; i++)
		fullMask = fullMask * 2 + 1;
		
	memset(costMap, -1, sizeof(costMap));
		
	for (int i = 0 ; i < m ; i++)
	{
		scanf("%d%d", &(keys[i].cost), &(keys[i].size));
		
		int t;
		for (int j = 0 ; j < keys[i].size ; j++)
		{
			scanf("%d", &t);
			keys[i].b[j] = t;
			keys[i].c[t] = true;
			hasSolution[t] = true;
		}
		
		keys[i].cMask = 0;
		for (int j = 1 ; j <= n ; j++)
		{
			keys[i].cMask = keys[i].cMask * 2;
			if (keys[i].c[j] == true)
				keys[i].cMask++;
		}
		
		keyTypes[keys[i].b[0]].push_back(keys[i]);		
	}
	
	for (int i = 1 ; i <= n ; i++)
	{
		if (hasSolution[i] == false)
		{
			printf("-1\n");
			return 0;
		}
		
//		sort(keyTypes[i].begin(), keyTypes[i].end(), compare);
	}
	
	doSearch(0, 0);
	
	printf("%d\n", costMap[fullMask]);

	
	return 0;
}


Measured memory_bytes: 640
import heapq
import sys
#input = sys.stdin.readline().strip
N, M = map(int, input().split())
clist = []
HQ = [[] for _ in range(N)]
for i in range(M):
    p, y = map(int, input().split())
    clist.append((p, y))
    heapq.heappush(HQ[p - 1], y)

cmap = {}
for p, q in enumerate(HQ):
    cnt = 0
    for i in range(len(q)):
        y = heapq.heappop(q)
        cmap[str(p) + '_' + str(y)] = i + 1

for p, y in clist:
    idx = cmap[str(p - 1) + '_' + str(y)]
    print('{0:06d}'.format(p) + '{0:06d}'.format(idx))


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

string s, t;
int ss[100005];
int tt[100005];

int main() {
    std::ios::sync_with_stdio(false);
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    inc(i, 0, n){
        ss[i+1] = ss[i] + (s[i] == 'A' ? 1 : 2);
    }
    inc(i, 0, m){
        tt[i+1] = tt[i] + (t[i] == 'A' ? 1 : 2);
    }

    int q;cin >> q;
    inc(i, 0, q){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        string ans = "YES";
        if((ss[b]-ss[a-1])%3 != (tt[d]-tt[c-1])%3) ans = "NO";
        cout << ans << endl;
    }
    return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

struct UFweight
{
    int i;
    vector<int> par;
    vector<int> size;
    vector<int> rank;
    vector<ll> diff_weight;
    UFweight(int n, ll sum_unity = 0){
        par.resize(n);  rank.resize(n); size.resize(n); diff_weight.resize(n);
        for(i = 0;i < n;++i){
            par.at(i) = i;
            rank.at(i) = 0;
            size.at(i) = 1;
            diff_weight.at(i) = sum_unity;
        }
    }
    
    int root(int x){
        if(par.at(x) == x){
            return x;
        }else{
            int r = root(par.at(x));
            diff_weight.at(x) += diff_weight.at(par.at(x));
            return par.at(x) = r;
        }
    }

    ll weight(int x){
        root(x);
        return diff_weight.at(x);
    }

    ll get_diff(int x, int y){
        return weight(y) - weight(x);
    }
    
    // weight(y) - weight(x) = wとなるようにmerge
    bool merge(int x, int y, ll w){
        w += weight(x); w -= weight(y);
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            ll weight_diff = get_diff(rx, ry);
            if(weight_diff == w) return true;
            else return false;
        }

        if(rank.at(rx) < rank.at(ry)){
            swap(rx,ry);
            w *= -1;
        }
        if(rank.at(rx) == rank.at(ry)) ++rank.at(rx);
        par.at(ry) = rx;
        diff_weight.at(ry) = w;
        size.at(rx) += size.at(ry);

        return true;
    }
    
    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    
    int get_size(int x){
        return size.at(root(x));
    }
};

int main()
{
    ll i,j;
    while(true){
        ll n,m;
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        UFweight ufw(n);
        for(i = 0;i < m;++i){
            char c;
            cin >> c;
            if(c == '!'){
                ll a,b,w;
                cin >> a >> b >> w;
                --a;    --b;
                ufw.merge(a, b, w);
            }else{
                ll a,b;
                cin >> a >> b;
                --a;    --b;
                if(ufw.same(a,b)){
                    ll w = ufw.get_diff(a,b);
                    cout << w << endl;
                }else{
                    cout << "UNKNOWN" << endl;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4760
M, K = map(int, input().split())

if M <= 1 and K == 0:
    a = sum([[i, i] for i in range(2 ** M)], [])

elif 2 <= M and K < 2 ** M:
    a  = [K] + [i for i in range(2 ** M - 1, -1, -1) if i != K]
    a += [K] + [i for i in range(2 ** M) if i != K]

else:
    a = [-1]

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

Measured memory_bytes: 31632
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.List.Split
import Data.Char

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

fix x = round (x * 100000)

mss (a:as) = mss' a a as
  where
    mss' r _ [] = r
    mss' r t (a:as) = mss' (max r $ max nt a) nt as
      where nt = max 0 t+a

main = do
    n <- getInt
    when (n/=0) $ do
        replicateM n getInt >>= print . mss >> main

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mp(x,y) make_pair(x,y)
const int nax=1800;
void solve(){
    ll n;
    cin>>n;
    for(ll i=-nax;i<=nax;i++){
        for(ll j=-nax;j<=nax;j++){
            ll g=pow(i,5)-pow(j,5);
            if(g==n){
                cout<<i<<" "<<j<<'\n';
                return ;
            }
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int tc;
    tc=1;
    while(tc--){
        solve();
    }
return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for(int i = 0; i < n; i++) cin >> l.at(i);
  int c = 0;
  for(int i = 0; i < n; i++) {
    for(int j = i + 1; j < n; j++) {
      for(int k = j + 1; k < n; k++) {
        if(l.at(i) != l.at(j) && l.at(j) != l.at(k) && l.at(k) != l.at(i)) {
          bool I = 0, J = 0, K = 0;
          if( (l.at(j) + l.at(k)) > l.at(i) ) I = 1;
          if( (l.at(i) + l.at(k)) > l.at(j) ) J = 1;
          if( (l.at(i) + l.at(j)) > l.at(k) ) K = 1;
          if(I && J && K) c++;
        }
      }
    }
  }
  cout << c << endl;
}

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

int main() {
	int n;
  	cin >> n;
    n = n%10;
    string s = "hon";
    if(n==3){
      s = "bon";
    }else if(n==0 || n==1 || n==6 || n==8){
      s = "pon";
    }
    cout << s << endl;
}


Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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


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

    int N = S.size();

    vector<int> num(2020);
    num[0] = 1;
    int res = 0, ans = 0, carry = 1;
    for(int i = N-1; i >= 0; --i){
        res = (res + (S[i]-'0')*carry) % 2019;
        carry = (10*carry) % 2019;
        ans += num[res];
        ++num[res];
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int n;

int main()
{
    cin>>n;
    if (n<600) cout<<8;
    else if (n<800) cout<<7;
    else if (n<1000) cout<<6;
    else if (n<1200) cout<<5;
    else if (n<1400) cout<<4;
    else if (n<1600) cout<<3;
    else if (n<1800) cout<<2;
    else if (n<2000) cout<<1;
    return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>
#include <math.h>
#include <vector>

using namespace std;

int main(){

	int n,tmp,sum=0,tmp_min;
	scanf("%d",&n);
	int table[n][n],check[n],num_of_group=0,parent,child;
	vector<int> Group;

	for(int i=0;i<n;i++){
		for(int k=0;k<n;k++){
			scanf("%d",&tmp);
			table[i][k]=tmp;
		}
		check[i]=0;
	}

	Group.push_back(0);
	check[0]=1;
	num_of_group = 1;
	while(num_of_group<n){
		tmp_min=2001;

		for(int i=0;i<num_of_group;i++){
			for(int k=0;k<n;k++){
				if(table[Group[i]][k]!=-1&&check[k]==0&&table[Group[i]][k]<tmp_min){
					tmp_min = table[Group[i]][k];
					parent=Group[i];
					child = k;
				}
			}
		}
		Group.push_back(child);
		sum+=table[parent][child];
		check[child]=1;
		num_of_group++;
	}

	printf("%d\n",sum);

    return 0;
}



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

int main(void){
    int N,A;

    cin >> N >> A;
    N %= 500;

    if(N <= A)
        cout << "Yes" << endl;
    
    else
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3564
#include <iostream>
using namespace std;
int main(){
	int a,b;
  cin>>a;
  cin>>b;
  if( a!= 1 && b!= 1){
  cout<<"1"<<endl;
  }
  else if( a!= 2 && b!= 2){
  cout<<"2"<<endl;
  }
  else if( a!= 3 && b!= 3){
  cout<<"3"<<endl;
  }
  return 0;
}
  


Measured memory_bytes: 256
N, M = map(int, input().split())
g = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)


memo = {}
all_use = (1 << N) - 1


def rec(v, use):
    if use == all_use:
        return 1

    key = (v, use)
    if key in memo:
        return memo[key]

    res = 0
    for u in g[v]:
        if (use >> u) & 1 == 1:
            continue

        use = use ^ (1 << u)
        res += rec(u, use)
        use = use ^ (1 << u)

    memo[key] = res
    return res


print(rec(0, 1))

Measured memory_bytes: 3064
H,W = map(int,input().split())
M = []
for i in range(H):
  M.append(input())
d = {}
d[(1,1)]=0
flag = False
for j in range(1,W):
  if flag or M[0][j]=="#":
    d[(1,j+1)] = 0
    flag = True
    continue
  d[(1,j+1)]=1
flag = False
for j in range(1,H):
  if flag or M[j][0]=="#":
    d[(j+1,1)] = 0
    flag = True
    continue
  d[(j+1,1)]=1
for l in range(1,H):
  for m in range(1,W):
    if M[l][m]==".":
      d[(l+1,m+1)]=(d[(l,m+1)]+d[(l+1,m)])%(1000000007)
    else :
      d[(l+1,m+1)] = 0
print(d[(H,W)])

Measured memory_bytes: 195808
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    long long int ans = 0;
    long long int xa, bx, ba;
    xa = bx = ba = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j+1 < s[i].size(); j++) {
            if (s[i][j] == 'A' && s[i][j+1] == 'B') {
                ans++;
                j++;
            }
        }
        int sz = s[i].size();
        if (s[i][0] == 'B' && s[i][sz-1] == 'A') {
            ba++;
        } else if (s[i][0] == 'B') {
            bx++;
        } else if (s[i][sz-1] == 'A') {
            xa++;
        }
    }
    if (ba > 0) {
        ans += ba-1;
        if (bx > 0) {
            ans++;
            bx--;
        }
        if (xa > 0) {
            ans++;
            xa--;
        }
    }
    
    ans += min(xa, bx);

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

Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))


vector<Int> a;
vector<Int> sum;
Int n;

int main(){
  cin >> n;
  a = vector<Int>(n);
  sum = vector<Int>(n, 0);
  for(Int i = 0;i < n;i++)cin >> a[i];
  sort(a.begin(), a.end());
  for(Int i = 0;i < n;i++){
    if(i == 0)sum[i] = a[i];
    else sum[i] = sum[i-1] + a[i];
  }
  Int res = 0;
  if(n % 2 == 0){
    Int l = sum[n/2 - 1];
    Int r = sum[n-1] - l;
    res = (r - l) * 2 - (a[n/2] - a[n/2-1]);
  }
  else{
    Int l = sum[n/2 - 1];
    Int r = sum[n-1] - sum[n/2];
    Int c = a[n/2];
    res = (r-l)*2 - (a[n/2+1] - a[n/2-1]) + max(c - a[n/2-1], a[n/2+1] - c);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1792
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    mut a:usize,
    mut b:usize,
    c:usize,
    }
    for i in 0..c {
        if i%2==0 {
            if a%2==1{a-=1;a/=2;b+=a;}
            else {a/=2;b+=a}
        }
        else {
            if b%2==1{b-=1;b/=2;a+=b;}
            else {b/=2;a+=b}
        }
    }
    println!("{} {}",a,b)
}

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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, m;
  std::cin >> n >> m;

  if (m / 2 <= n) {
    std::cout << m / 2 << std::endl;
  } else {
    auto i = n;
    m -= 2 * i;
    std::cout << i + m / 4 << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1000000007;
signed main() {
	int n, ok = 0, ans = 1; cin >> n; string s, t; cin >> s >> t;
	for (int h = 0; h < n; h++) {
		if (s[h] == t[h]) {
			if (ok == 0) { ans *= 3; } if (ok == 1) { ans *= 2; } ok = 1;
		}
		else {
			if (ok == 0) { ans *= 6; } if (ok == 1) { ans *= 2; } if (ok == 2) { ans *= 3; } ok = 2; h++;
		} ans %= mod;
	} cout << ans % mod << endl; return 0;
}

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


int main() {
	
	int a, b, k, cnt=0, i=1;
	cin >> a >> b >> k;
	while(1){
		if(a%i==0 && b%i==0) cnt++;
		if(i==max(a,b)) break;
		i++;
	}
	int cnt2=0;
	i=1;
	while(1){
		if(a%i==0 && b%i==0) cnt2++;
		if(cnt2==cnt-k+1){
			cout << i << endl;
			break;
		}
		i++;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

N,K = map(int,input().split())
H = np.array(input().split(), dtype=np.int64)

N,K,H

dp = np.zeros(N,dtype=np.int64)
for i in range(1,N):
    L = max(0,i-K)
    dp[i] = np.min(np.abs(H[i] - H[L:i]) + dp[L:i])

answer = dp[-1]
print(answer)

Measured memory_bytes: 21760
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 105;

int n;
int arr[N];

long long f(int x) {
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int h = abs(arr[i] - x);
    ans += 1ll * h * h;
  }
  return ans;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  int l = 1, r = *max_element(arr, arr + n), ans = 1;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (f(mid) < f(mid + 1)) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  cout << f(l) << endl;
  return 0;
}


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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int n; cin >> n;
  vector<int> a(n); cin >> a;
  int nex = 1;
  rep(i, n){
    if(a[i] == nex){
      nex++;
    }
  }
  if(nex == 1){
    cout << -1 << endl;
  }else{
    cout << n - (nex - 1) << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
s = input()
k = int(input())
substrings = set()
index = []
for ss in sorted(list(s)):
  index_list = [n for n, v in enumerate(s) if v == ss]
  for i in index_list:##初期位置
    for j in range(1,min(k+1,len(s)-i+1)):##長さ
      substrings.add(s[i:i+j])
  if len(substrings) >= k:
    break
print(sorted(list(substrings))[k-1])

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

typedef long long ll;
typedef pair <int , int> pii;

const int N = 2e5+10 , mod = 1e9+7;

int a[N] , mark[N];

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int x , n;
   cin >> x >> n;
   for(int i = 0 ; i < n ; i++){
      int xx;
      cin >> xx;
      mark[xx] = true;
   }
   int val = -1 , mn = mod;
   for(int i = 0 ; i <= 101 ; i++){
      if(!mark[i] && abs(x - i) < mn){
         mn = abs(x - i);
         val = i;
      }
   }
   cout << val;
   return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

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; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    string a, b; cin >> a >> b;
    int n = stoi(a + b);
    repi(i, 2, 10000) {
        if(n % i == 0 && n / i == i) {
            print("Yes");
            return 0;
        }
    }
    print("No");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<ll, ll>;
// Welcome to my source code!

const int MAX_N = 100;
const int INF = 1e9;

int n;
int d[MAX_N], f[MAX_N];
vector<int> g[MAX_N];

int t = 1;

void dfs(int v) {
    if (d[v] == INF) d[v] = t++;
    for (auto u : g[v]) {
        if (d[u] == INF) dfs(u);
    }
    if (f[v] == INF) f[v] = t++;
}

int main() {
    fill(d, d+MAX_N, INF);
    fill(f, f+MAX_N, INF);
    cin >> n;
    for (int i = 0, u, k; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0, v; j < k; j++) {
            cin >> v;
            v--;
            g[u].push_back(v);
        }
    }
    for (int i = 0; i < n; i++) dfs(i);
    for (int i = 0; i < n; i++) {
        cout << i + 1 << ' ' << d[i] << ' ' << f[i] << endl;
    }
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
double eps = 1e-8;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    ll a;
    cin >> a;
    string b;
    cin >> b;
    if(a == 0 || b == "0.00") {
        cout << 0 << endl;
        return 0;
    }
    b = b.substr(0,b.size()-3)+b.substr(b.size()-2);
    ll bb = stol(b);
    ll ans = a*bb;
    ans /= 100;
    cout << ans << endl;
}

Measured memory_bytes: 3656
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    ll a,k; cin>>a>>k;
    vec<ll> m(a);
    for(int q=0; q<a; q++) cin>>m[q];
    sort(m.begin(), m.end());
    ll o = 0;
    for(int q=0; q<k; q++) o += m[q];
    cout<<o;
}

Measured memory_bytes: 3664
using System;
using System.Linq;

namespace arc099_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.ReadLine();
            x[0] -= x[1];
            Console.WriteLine((x[0] + x[1] - 2) / (x[1] - 1) + 1);
        }
    }
}


Measured memory_bytes: 13408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
int main(){
    long long n;
    cin >> n;
    long long a;
    long long b[n+1];
    b[0] = 0;
    rep(i,n){
        cin >> a;
        b[i+1] = b[i]+a;
    }
    sort(b,b+n+1);
    long long tem = b[0];
    long long p = 1;
    long long ans = 0;
    for(int i = 1;i<n+1;i++){
        if(b[i] == tem){
            p++;
        }
        else{
            ans = ans + p*(p-1)/2;
            p = 1;
            tem = b[i];
        }
    }
    ans = ans + p*(p-1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdio.h>
using namespace std;
#define ll long long
int main(int argc, char const *argv[])
{
    ll x, y;
    cin >> x >> y;
    int cnt = 0;
    while (x <= y) {
        x *= 2;
        cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstdio>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
    0,
    343474715,
    0,
    0,
    0,
    0,
    499999999,
    0,
    0,
    0,
    495113154,
    675365680,
    0,
    0,
    0,
    0,
    0,
    0,
    2,
    19,
    173224800,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    833484826,
};

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc_unlocked(i + '0', stdout);
}
 
int main(void) {
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int m = (a + b + c) % 29;
    puti(arr[m]);
    fputc_unlocked('\n', stdout);
    return 0;
}

Measured memory_bytes: 1632
s = input()

S = '0' + s
N = len(s)


# 葉から順に構築
def f():
    res = []
    r = 1
    C = []
    for i in range(2, N + 1):
        if S[i] == '0':
            C.append(i)
        else:
            res.append((r, i))
            r = i
            for c in C:
                res.append((r, c))
            C = []
    for c in C:
        res.append((r, c))
    return res


ans = (
    '-1' if S[1] == '0' or S[N] == '1' or any(
        S[i] != S[N - i]
        for i in range(1, N)
    ) else
    '\n'.join(
        '{} {}'.format(u, v)
        for u, v in f()
    )
)

print(ans)


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

int main() {
  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<int>());

  int slen = s.length();
  int tlen = t.length();

  int N = min(slen, tlen);

  bool enabling = false;
  for (int i = 0; i < N; i++) {
    if (s.at(i) < t.at(i)) {
      enabling = true;
      break;
    } else if (s.at(i) > t.at(i)) {
      enabling = false;
      break;
    }

    // 一方の文字列の末尾に到達した場合
    if (i == (N - 1)) {
      if (slen >= tlen) {
        enabling = false;
      } else {
        enabling = true;
      }
    }
  }

  cout << (enabling ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<int(n);i++)
const int INF=100000000;

int main(){
	string s;
	ll ans=0,b=0,p=0;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='B')continue;
		ans+=i-p;
		p++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
 int kiro,s,ksum,ssum,n;
 double h;
 ksum=ssum=n=0;
 while(scanf("%d,%d",&kiro,&s)!=EOF){
  ksum+=kiro*s;
  n++;
  ssum+=s;
 }
 h=(double)ssum/(double)n;
 if((h-(double)((int)h))>=0.5) s=(int)h+1;
 else s=(int)h;
 printf("%d\n%d\n",ksum,s);
 return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  VVI A(N,VI(N));
  rep(i,N) rep(j,N) cin>>A[i][j];
  ll ans=0;
  rep(i,N) rep(j,N){
    if(i<=j) continue;
    int cnt=0;
    rep(k,N){
      if(A[i][k]+A[k][j]<A[i][j]){
        cout<<-1<<endl;
        return 0;
      }else if(A[i][k]+A[k][j]==A[i][j]){
        cnt++;
      }
    }
    if(cnt==2) ans+=A[i][j];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] c = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                c[i][j] = Integer.parseInt(sc.next());
            }
        }
        for (int i = 0; i <= c[0][0]; i++) {
            int b1 = c[0][0] - i;
            int b2 = c[0][1] - i;
            int b3 = c[0][2] - i;
            if (c[1][0] - b1 != c[1][1] - b2 || c[1][1] - b2 != c[1][2] - b3) {
                continue;
            }
            if (c[2][0] - b1 != c[2][1] - b2 || c[2][1] - b2 != c[2][2] - b3) {
                continue;
            }
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 23124
#include<iostream>
using namespace std;
int V,E,R,S[500010],T[500010],D[500010];
int C[100010];
const int Inf=10000*100000+100;
int main()
{
    cin>>V>>E>>R;
    for(int i=0;i<E;i++)
    {
        cin>>S[i]>>T[i]>>D[i];
    }
    for(int i=0;i<V;i++)
    {
        C[i]=Inf;
    }
    C[R]=0;
    for(int t=0;t<V;t++)
    {
        bool update=false;
        for(int i=0;i<E;i++)
        {
            int s=S[i],t=T[i],d=D[i];
            if(C[s]<Inf&&C[s]+d<C[t])
            {
                C[t]=C[s]+d;
                update=true;
            }
        }
        if(!update)
            break;
    }
    for(int i=0;i<V;i++)
    {
        if(C[i]!=Inf)
            cout<<C[i]<<endl;
        else
            cout<<"INF"<<endl;
    }
    return 0;
}


Measured memory_bytes: 9100
#include <stdio.h>
#include <string.h>

char s[100001];
int l;

int main() {
	scanf("%s",s);
	l=strlen(s);
	int res=0;
	for(int i=1;i<l;i++) {
		if(s[i]!=s[i-1]) res++;
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int H, N, A[100005];

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

	for (int i = 0; i < N; i++) {
		H -= A[i];
		if (H <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main(){
	int n;
	scanf("%d", &n);
	int AC = 0, TLE = 0, RE = 0, WA = 0;
	
	char con[10];
	for (int i = 0; i < n; i++){
		scanf("%s", con);
		if (strcmp(con, "WA") == 0) WA++;
		if (strcmp(con, "TLE") == 0) TLE++;
		if (strcmp(con, "RE") == 0) RE++;
		if (strcmp(con, "AC") == 0) AC++;
	}
	printf("AC x %d\n", AC);
	printf("WA x %d\n", WA);
	printf("TLE x %d\n", TLE);
	printf("RE x %d\n", RE);
	return 0;
}

Measured memory_bytes: 1732