akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll a, b;
    cin >> a >> b;
    if((a+b)%2){
        cout << "IMPOSSIBLE" << endl;
    }else{
        cout << (a+b)/2 << endl;
    }
    return 0;
}

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

int digit(long a){
  int ans=0;
  while(a>0){
    a /= 10;
    ans++;
  }
  return ans;
}
int main(){
  long N,d=0;
  cin >> N;
  for(long i=1;i<=sqrt(N);i++){
    int a,b,c=digit(N)+1;
    if(N%i==0){
      a = i;
      b = N/i;
    }
    d = min(c,max(digit(a),digit(b)));
  }
  cout << d << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++){
    cin >> v.at(i);
  }
  int ans = 0, frag = 0;
  vector<vector<int>> data(0, vector<int>(3));
  for (int i = 0; i < N; i++){
    for (int j = i; j < N; j++){
      for (int k = j; k < N; k++){
        if(v.at(i) == v.at(j) || v.at(j) == v.at(k) || v.at(k) == v.at(i)){
          continue;
        }
        if (v.at(i) + v.at(j) > v.at(k) && v.at(j) + v.at(k) > v.at(i) && v.at(k) + v.at(i) > v.at(j)){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] aryb = new int[n - 1];
        int ans = 0;
        for (int i = 0; i < n - 1; i++) {
            int a = Integer.parseInt(sc.next());
            aryb[i] = a;
        }
        for (int i = n - 2; i >= 0; i--) {
            if (i == n - 2) {
                ans += aryb[i];
            }
            if (i == 0) {
                ans += aryb[i];
            } else {
                ans += Math.min(aryb[i], aryb[i - 1]);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {

    int a,b;
    int s,l;

    cin >> a;
    cin >> b;

    s = a*b;
    l = a*2+b*2;
    printf("%d %d\n",s,l);
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;

int main(){
    long long n, m;

    cin >> n >> m;

    priority_queue<long long> q;

    for(long long i = 0; i < n; i++){
        long long a;
        cin >> a;
        q.push(a);
    }

    for(long long i = 0; i < m; i++){
        long long maxv = q.top();
        q.pop();
        q.push(maxv/2);
    }

    long long sum = 0;

    while(!q.empty()){
        long long top = q.top();
        q.pop();
        sum += top;
    }

    cout << sum << endl;
    
    return 0;
}

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

int main() {
	string S, T;
	cin >> S >> T;
	string A = "", B = "";
	for (int i = 0; i < S.size(); i++) {
		if (i % 2 == 0) A += S[i];
		else B += S[i];
	}
	int NOW = 0;
	for (int i = 0; i < T.size(); i++) {
		if (NOW == A.size()) break;
		if (A[NOW] == T[i]) NOW++;
	}
	if (NOW == A.size()) {
		cout << "Yes" << endl;
		return 0;
	}
	NOW = 0;
	for (int i = 0; i < T.size(); i++) {
		if (NOW == B.size()) break;
		if (B[NOW] == T[i]) NOW++;
	}
	if (NOW == B.size()) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}


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

constexpr int INF = 1<<30;

int main() {
    int n;
    cin >> n;
    vector<int> w(n), s(2, 0);
    for(int i=0;i<n;i++){
        cin >> w[i];
        s[1] += w[i];
    }
    int ans = INF;
    for(int i=0;i<n-1;i++){
        s[0] += w[i];
        s[1] -= w[i];
        ans = min(ans, abs(s[0]-s[1]));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
void call(int n)
{
    int i = 1;

    while (1)
    {
        int x = i;
        if (x % 3 == 0)
        {
            cout << " " << i;
        }
        else
        {
            while (x)
            {
                if (x % 10 == 3)
                {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
        if (++i > n)
            break;
    }
    cout << endl;
}

int main(void)
{
    int n;
    cin >> n;
    call(n);
}


Measured memory_bytes: 3116
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top,s[1000];
void push(int x);
int pop();
int main(){
int a,b,top=0;
char s[100],c;
while(scanf("%s",s)!=EOF){
if(s[0]=='+'){
a=pop();
b=pop();
push(a+b);
}else if(s[0]=='-'){
b=pop();
a=pop();
push(a-b);
}else if(s[0]=='*'){
a=pop();
b=pop();
push(a*b);
}
else {
    push(atoi(s));
}
}
printf("%d\n",pop());
return 0;
}
void push(int x){
++top;
s[top]=x;
}
int pop(){
top--;
return s[top+1];
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define ll long long
#define debug(x) {cerr<<#x<<" = "<<(x)<<endl;}
#define M(x) memset(x,0,sizeof(x))
#define dalao main
using namespace std;
int dalao()
{
    ios::sync_with_stdio(false);
    ll n,x,t;
    cin>>n>>x>>t;
    if(n%x==0)
        cout<<(n/x)*t<<endl;
    else
        cout<<(n/x+1)*t<<endl;
    return 0;
}


Measured memory_bytes: 3608
# B
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
    for j in range(b+1):
        k = x - i*500 - j*100
        if k >= 0 and k // 50 <= c:
            count += 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define INF 1 << 30
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

int main()
{
  int n;
  while(cin>>n,n)
  {
    vector<vector<int> > T(n,vector<int>(n,0));
    int k=1, x=n/2+1, y=n/2;
    while(k<=n*n)
    {
      while(T[x][y]!=0)
      {
        x = (x+1)%n;
        y = (y-1)%n;
        y = y<0? y+n : y;
      }
      T[x][y] = k;
      x = (x+1)%n;
      y = (y+1)%n;
      k++;
    }
    REP(i,n){REP(j,n) printf("%4d",T[i][j]); printf("\n");}
  }
  return 0;
}

Measured memory_bytes: 3248
A,B,C,X,Y = map(int,input().split())

min_cost = 1000000000

if X <=Y:
    for i in range(0,2*Y +1,2):
        if 0<=i<=2*X:
            cost = i * C + (X - i//2)*A + (Y - i//2)*B
        elif i <= 2*Y:
            cost = i * C + (Y - i//2)*B
        if cost < min_cost:
            min_cost = cost
elif X >Y:
    for i in range(0,2*X +1,2):
        if 0<=i<=2*Y:
            cost = i * C + (X - i//2)*A + (Y - i//2)*B
        elif i <= 2*X:
            cost = i * C + (X - i//2)*A
        if cost < min_cost:
            min_cost = cost
print(min_cost)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define vout(v) for(int i=0;i<(int)v.size()-1;i++){cout<<v[i]<<" ";}cout<<v[v.size()-1]<<"\n";
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
const long long MOD=1000000007;
const long long INF = 1e18;
vector <ll> dp;

const string YES = "YES";
const string NO = "NO";

void solve_old(std::string S){
    regex re("(dreamer|dream|eraser|erase)*");
    if(regex_match(S, re)){
        cout << YES << "\n";
    }else{
        cout << NO << "\n";
    }
}

void solve(std::string S){
    regex re("(dreamer|dream|eraser|erase)*");
    cout << (regex_match(S, re) ? YES : NO) << "\n";
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 39808
//abc115_d.cpp
//Sat May 11 19:24:48 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll n,x;
	cin >> n >> x;

	x--;

	ll p = 1;
	ll b = 0;
	for (int i=1;i<=n;i++){
		p = 2*p+1;
		b = 2*b+2;
	}

	ll start = 0;
	ll end = p+b-1;
	ll ans = p;
	ll change = (p-1)/2;
	ll mid = 0;
	for (int i=0;i<n;i++){
		mid = start+(end-start)/2;
		if (x==mid){
			cout << ans-change << endl;
			return 0;
		}else if (x<mid){
			ans = ans - change - 1;
			start++;
			end = mid-1;
		}else{
			start = mid+1;
			end--;
		}
		change = (change-1)/2;
	}

	if (x < mid-1){
		ans--;
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

int main() {
  vector<string> vec;
  int times;
  bool stopper = true;
  string a, c;
  cin >> a;
  c = "";
  times = a.size();
  for(int i = 0; i < times; i++) {
    if(a[i] == 'A'||a[i] == 'G'||a[i] == 'C'||a[i] == 'T'){
      c += a[i];
      stopper = true;
      }
    else if (stopper){
      vec.push_back(c);
      stopper = false;
      c = "";
    }
  }
  vec.push_back(c);
  int b = 0;
  int vec_size = vec.size();
  for(auto& x:vec) {
    if (x.size() > b) {
      b = x.size();
    }
  }
  cout << b << endl;
}

Measured memory_bytes: 3592
# determines whether b is a subimage of a at start point (x,y)
def findMatch(x, y):
	for i in range(m):
		for j in range(m):
			if b[i][j] != a[i+x][j+y]:
				return False
	return True

# get size of picture A (NxN) and picture B (MxM)
n, m = map(int, raw_input().split())

# populate image a
a = []
for i in range(n):
	a.append(list(raw_input()))

# populate image b
b = []
for i in range(m):
	b.append(list(raw_input()))

# iterate over all possible start points to find valid subimage
found = False
for i in range(n-m+1):
	for j in range(n-m+1):
		if findMatch(i,j):
			found = True

if found:
	print ("Yes")
else:
	print ("No")

Measured memory_bytes: 2692
#include <stdio.h>
int hi[1000000];
int NT (int n, int key);
int main()
{
  int i,n,q,key,count=0;
  scanf ("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d",&hi[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if ( NT(n,key)==1 )
      count++;
  }
  printf ("%d\n",count);

  return 0;
}

int NT (int n, int key ){
  int l=0,m,r=n;
  while(l<r){
    m= (l+r)/2;
    if (hi[m]==key)
      return 1;
    else if(hi[m]<key)
      l=m+1;
    else if(key<hi[m])
      r=m;
  }
  return 0;
}



Measured memory_bytes: 2108
/*input
8
2
0
1
6
0
8
2
1
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int cnt[maxn];
bool red[maxn]={1};

int main()
{
	IOS;
	int n;
	cin>>n;
	ll ans=0;
	ll rem=0;

	while(n--){
		int x;
		cin>>x;
		if(rem&&x){
			x--;
			ans++;
		}
		ans+=x/2;
		rem=x%2; 
	}
	cout<<ans;

	return 0;
}


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

using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db long double
#define eps 1e-3
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define endl "\n"
const ll mod = 1e9 + 7;
const ll maxn = 2e5 + 10;
deque<ll> a, pos, neg;
db posd[maxn], negd[maxn];

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k, zero = 0;
    cin >> n >> k;

    _rep(i, 1, n) {
        ll x;
        cin >> x;
        if (x < 0) {
            neg.push_back(-x);
        } else if (x > 0) {
            pos.push_back(x);
        } else zero++;
    }

    sort(all(pos), greater<ll>());
    sort(all(neg), greater<ll>());

    ll res = 1;
    if ((k & 1) <= pos.size() && (neg.size()/2*2) + pos.size() >= k) {
        // 找正数
        pos.push_front(1);
        neg.push_front(1);

        _for(i, 1, pos.size()) {
            posd[i] = posd[i - 1] + log(pos[i]);
        }
        _for(i, 1, neg.size()) {
            negd[i] = negd[i - 1] + log(neg[i]);
        }
        int ind = 0;
        db ans = 0;
        for (int i = 0; i < neg.size() &&  i <= k; i += 2) {
            if ( k - i < pos.size() && posd[k - i] + negd[i] > ans) {
                ans = posd[k - i] + negd[i];
                ind = i;
            }
        }
        _rep(i, 1, ind) {
            res = (res * neg[i]) % mod;
        }
        _rep(i, 1, k - ind) {
            res = (res * pos[i]) % mod;
        }
        res = res % mod;
    } else if (zero) {
        res = 0;
    } else {
        sort(all(neg), [](ll a,ll b){
            return abs(a)<abs(b);
        });
        sort(all(pos));

        pos.push_front(1);
        neg.push_front(1);
        _for(i,1,pos.size()){
            posd[i] = posd[i-1] + log(pos[i]);
        }
        _for(i, 1, neg.size()){
            negd[i] = negd[i-1] + log(neg[i]);
        }
        db mn = oo;
        int ind = 0;
        for(int i = 1; i<=k && i < neg.size();i+=2){
            if( k-i >= 0 && k-i < pos.size() && mn > posd[k-i] + negd[i]){
                mn = posd[k-i] + negd[i];
                ind = i;
            }
        }
        _rep(i, 1, ind){
            res = res * (-neg[i])%mod;
            res = (res + mod)%mod;
        }
        _rep(i, 1, k-ind){
            res = (res*pos[i]%mod + mod)%mod;
        }


    }
    cout << (res + mod) % mod << endl;
}

Measured memory_bytes: 8512
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 998244353LL
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os, const set<T> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

vector<int> S;
int N;
ll K;
bool chk[200001];
int A[200001];
pii nxt[200000];
int F[200001];
int T[200001];
int CC[200001];

ll dist[200001];

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> N >> K;
    rep(i, N) cin >> A[i], CC[A[i]]++;
    fill(F+1, F+200001, N);

    repr(i, N, 0) {
        T[i] = F[A[i]];
        F[A[i]] = i;
    }

    rep(i, N) {
        if (CC[A[i]] == 1) nxt[i] = {(i+1)%N, N+1};
        else {
            if (T[i] < N) nxt[i] = {(T[i]+1)%N, T[i]-i+1};
            else nxt[i] = {F[A[i]]+1, N-i+F[A[i]]+1};
        }
        debug(nxt[i]);
    }

    K *= N;
    fill(dist, dist+N, INF);
    dist[0] = 0;
    int c = 0;
    ll cdist = 0;
    while(K >= nxt[c].se) {
        K -= nxt[c].se;
        cdist += nxt[c].se;
        c = nxt[c].fi;
        debug(c, K);
        if (dist[c] == INF) dist[c] = cdist;
        else {
            K %= cdist-dist[c];
        }
    }

    rep(i, K) {
        int t = A[(i+c)%N];
        if (not chk[t]) S.pb(t), chk[t] = true;
        else {
            while(chk[t]) chk[S.back()] = false, S.pop_back();
        }
    }

    repi(i, S) cout << i << ' ';
}

Measured memory_bytes: 8820
import sys
import numpy as np
import math
from collections import deque 
from functools import reduce

# input = sys.stdin.readline

n = int(input())

a = list(map(int, input().split()))

a_n = np.array(a)
cnt_np = np.zeros(n)

for an in a:
    cnt_np[an-1] += 1
for cnt in cnt_np:
    print(int(cnt))    
    

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

using namespace std;


void minimization()
{
  int n, k;
  cin >> n >> k;

  cout << ceil((float)(n - 1) / (float)(k - 1)) << "\n";
}


void linear_approximation()
{
  int n;
  cin >> n;
  vector<int> b(n);
  for (int i = 0; i < n; ++i)
  {
    int a;
    cin >> a;
    b[i] = a - (i + 1);
  }

  sort(b.begin(), b.end());

  int mid = b[n / 2];
  long long int ans = 0;
  for (int i = 0; i < n; ++i) ans += abs(mid - b[i]);
  cout << ans << "\n";

}


void modulo_summation()
{
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    ans += a - 1;
  }

  cout << ans << "\n";
}


//skip
void all_green()
{
  int d, g;
  cin >> d >> g;
  vector<int> p(d);
  vector<int> c(d);
  for (int i = 0; i < d; ++i) cin >> p[i] >> c[i];


}


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

  string s = "";
  if (n == 0) s = '0' + s;
  while (n != 0)
  {
    if (n % 2 != 0)
    {
      --n; //-２進数の整合性
      s = '1' + s;
    }
    else
    {
      s = '0' + s;
    }
    n /= -2;
  }

  cout << s << "\n";
}


int main()
{
  //minimization();
  //linear_approximation();
  //modulo_summation();
  //all_green();
  base_2_number();
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cstdio>

using namespace std;

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

static const double eps = 1e-8;

const int tx[4] = {+0,+1,+0,-1};
const int ty[4] = {-1,+0,+1,+0};

int main(){
  int n;
  while(~scanf("%d",&n)){
    priority_queue<int> que;
    for(int i = 0; i < n; i++){
      int num;
      scanf("%d",&num);
      que.push(num);
      while(que.size() > 4){
        que.pop();
      }
    }
    
    vector<int> cards;
    while(!que.empty()){
      cards.push_back(que.top());
      que.pop();
    }

    vector<int> res;
    for(int i = 0; i < cards.size(); i++){
      for(int j = 0; j < cards.size(); j++){
        if(i == j) continue;
        stringstream ss;
        ss << cards[i] << cards[j];
        res.push_back(atoi(ss.str().c_str()));
      }
    }
    sort(res.begin(),res.end());
    printf("%d\n",res[2]);
  }
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;


int main(){

    int N; cin>>N;
    vector<ll> L(N+1);
    L[0]=2;
    L[1]=1;

    for (int i = 2; i <= N; ++i) {
        L[i] = L[i-1]+L[i-2];
    }
    cout<<L[N]<<endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define dump(x)  cout << #x << " = " << (x) << endl;

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(4);
    cout << std::fixed;
    // freopen("ex.in","r",stdin);
    // freopen("ex.out","w",stdout);
    ll n;
    cin >> n;
    cout << n*n*n;


    cout << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 764
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
	int N,X;
	int *m;

	int sum = 0;
	int minmum = 1001;

	cin >> N >> X;

	m = new int[N];

	for(int i=0;i<N;i++)
	{
		cin >> m[i];
		sum += m[i];
		minmum = min(minmum,m[i]);
	}

	cout << (X - sum)/minmum + N << endl;

	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
switch_wiring = [0 for i in range(m)]
for i in range(m):
    switch_wiring[i] = list(map(int, input().split()))
    del switch_wiring[i][0]
p = list(map(int, input().split()))

pattern = []
for bit in range(1<<n):
    stock = []
    for i in range(n):
        mask = 2**(n-i-1)
        if mask & bit:
            stock.append(1)
        else:
            stock.append(0)
    pattern.append(stock)

count = 0
for on_off in pattern:
    truf = True
    for j in range(m):
        count_s = 0
        for k in switch_wiring[j]:
            if on_off[k-1] == 1:
                count_s += 1
        if count_s % 2 != p[j]:
            truf = False
            break
    if truf:
        count += 1

print(count)

Measured memory_bytes: 3316
#Union Find
class union_find:
    #初期化
    #根なら-size,子なら親の頂点
    # par = [-1]*N
    def __init__(self, N):
        self.par = [-1]*N

    #xの根を求める
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    #xとyの属する集合の併合
    def unite(self, x,y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return False
        else:
            #sizeの大きいほうがx
            if self.par[x] > self.par[y]:
                x,y = y,x
            self.par[x] += self.par[y]
            self.par[y] = x
            return True

    #xとyが同じ集合に属するかの判定
    def same(self, x,y):
        return self.find(x) == self.find(y)

    #xが属する集合の個数
    def size(self, x):
        return -self.par[self.find(x)]

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

import heapq
edges = []
heapq.heapify(edges)

XYI.sort(key=lambda x: x[0])
for j in range(1, N):
    px, py, pi = XYI[j-1]
    x, y, i = XYI[j]
    d = min(abs(x-px), abs(y-py))
    heapq.heappush(edges, (d, pi, i))

XYI.sort(key=lambda x: x[1])
for j in range(1, N):
    px, py, pi = XYI[j-1]
    x, y, i = XYI[j]
    d = min(abs(x-px), abs(y-py))
    heapq.heappush(edges, (d, pi, i))

uf = union_find(N)
ans = 0
while True:
    d, i, j = heapq.heappop(edges)
    if uf.same(i, j): continue
    uf.unite(i, j)
    ans += d
    if uf.size(i) == N: break

print(ans)

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


int main(){
    int A[5],B[5],tmp=0,sum=0;
    for (int i=0;i<5;++i) cin >> A[i];
    for (int i=0;i<5;++i){
        B[i] = 10-A[i]%10;
        if(B[i]==10)B[i]=0;
        tmp = max(B[i],tmp);
    }
    for(int i=0;i<5;++i) {
        if(B[i]==0) sum += A[i];
        else sum += int(A[i]/10+1)*10; 
    }
    cout << sum - tmp << endl;
}





Measured memory_bytes: 256
def main():

    N = int(input())
    D = []
    for _ in range(N):
        d = int(input())
        D.append(d)
    D = list(set(D))
    D.sort()
    count = 1
    for i in range(len(D) - 1, -1, -1):
        if D[i - 1] < D[i]:
            count += 1
        else:
            break
    print(count)


if __name__ == "__main__":
    main()

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

int main() {
    string s; cin >> s;
    int bits = 0;
    vector<int> dp(1<<26, 1e9);
    dp[0] = 0;
    for (char c : s) {
        bits ^= 1 << (c-'a');
        for (int i = 0; i < 26; ++i) {
            dp[bits] = min(dp[bits], dp[bits ^ (1<<i)] + 1);
        }
    }
    cout << max(1,dp[bits]) << endl;
    return 0;
}


Measured memory_bytes: 262788
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 3e4 + 1; int n;
char s[maxN];
int cnt[10][maxN], l[10][maxN];

struct PIN
{
  int a, b, c;
  bool operator<(const PIN &other) const
  {
    return a < other.a || (a == other.a && b < other.b) || (a == other.a && b == other.b && c < other.c);
  }
};

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    scanf(" %s", s);
    for (int i = 0; i < 10; i ++)
      l[i][n] = n;
    for (int i = n - 1; i >= 0; i --)
    {
      for (int j = 0; j < 10; j ++)
        l[j][i] = l[j][i + 1];
      l[s[i] - '0'][i] = i;
    }

    set<PIN> ans;
    for (int i = 0; i < n - 2; i ++)
      for (int j = 0; j < 10; j ++)
      {
        int pos = l[j][i + 1];
        if (pos == n) continue;
        for (int k = 0; k < 10; k ++)
          if (l[k][pos + 1] != n)
            ans.insert(PIN{s[i] - '0', j, k});
      }
    printf("%d\n", (int) ans.size());
  }
  return 0;
}

Measured memory_bytes: 1536
N = int(input())
X = list(map(int, input().split(" ")))

e = 0
ave = 0
for i in range(0, len(X)):
    ave += X[i]/len(X)

ave = int(ave+0.5)

for i in range(0,len(X)):
    energy = X[i] - ave
    e += energy ** 2

print(e)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;cin>>x;
  print(x?0:1);
  return 0;
}


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

int main(){
  int x,a,b; cin >>x>>a>>b;
  if(a>=b){
    cout << "delicious" << endl;
  }else if(a+x>=b){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//????????????????????????????????????
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
struct P {
    ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//??£??\???????????¨???
    ll to, cost;
};
struct S {//???????????±?????\???????????°
    int from, to, cost;
};
struct H {
    int x, y;
};
ll gcm(ll i, ll j) {//?????§??¬?´???°
    if (i > j) swap(i, j);
    if (i == 0) return j;
    return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
    return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad?????§?¨???????2??????????????¢
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int x,t;
	cin>>x>>t;
	cout<<max(0ll,x-t)<<endl;
    getchar(); getchar();
}


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

std::pair<int, int> a;

struct Order {
	int op, i, j, k;
};

std::vector<Order> ans;

void mul(int x, int p) {
	for (int i = 1; i <= p; ++i) {
		ans.push_back({0, x, x, x});
	}
}

void split(int x, int st) {
	ans.push_back({0, x, 3, 93});
	ans.push_back({0, 100, 101, 94});
	for (int i = 29; ~i; --i) {
		ans.push_back({0, 94, i + 3, 95});
		ans.push_back({1, 95, 93, 95});
		ans.push_back({0, 95, 100, st + i});
		mul(95, i);
		ans.push_back({0, 94, 95, 94});
	}
}

void land(int x, int y, int st) {
	ans.push_back({0, x, y, st});
	ans.push_back({1, 3, st, st});
}

int main() {
	ans.push_back({0, 0, 1, 3});
	ans.push_back({0, 3, 3, 3});
	ans.push_back({1, 0, 3, 3});
	for (int i = 1; i < 30; ++i) {
		ans.push_back({0, i + 2, i + 2, i + 3});
	}
	split(0, 33), split(1, 63);
	for (int i = 0; i < 30; ++i) {
		for (int j = 0; j < 30; ++j) {
			land(33 + i, 63 + j, 93);
			mul(93, i + j);
			ans.push_back({0, 2, 93, 2});
		}
	}
	printf("%d\n", (int)ans.size());
	for (auto v : ans) {
		printf("%c %d %d %d\n", v.op == 0 ? '+' : '<', v.i, v.j, v.k);
	}
}


Measured memory_bytes: 3808
//I Guds namn
#include <iostream>

using namespace std;

int main()
{
	int n; cin >> n;
	if(n == 1)
	{
		cout << "Hello World" << endl;
		return 0;
	}
	int m; cin >> n >> m;
	cout << n + m << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

const ll MAXN = 10000001;
ll F[MAXN];

int main()
{
    ll N;
    cin >> N;

    for (ll i=1;i<=N;++i)
    for (ll j=i;j<=N;j+=i)
    {
        ++F[j];
    }

    ll ans = 0;

    rep (i, N)
    {
        const ll k = i + 1;
        const ll f = F[i + 1];

        ans += k * f;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 81736
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#include <math.h>
#include <bits/stdc++.h>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int main() {
	int x;
	cin >> x;
	cout << x*x*x << endl;
}



Measured memory_bytes: 3108
#include <stdio.h>
#define rep(i, n) for ((i) = 0; (i) < (n); (i)++)
#define ll long long

int main(void) {
    int n, m, l;
    int i, j, k;
    scanf("%d %d %d", &n, &m, &l);

    ll matrixA[n][m];
    ll matrixB[m][l];
    ll matrixC[n][l];

    rep(i, n)
        rep(j, l) matrixC[i][j] = 0;
    
    rep(i, n)
        rep(j, m) scanf("%lld", &matrixA[i][j]);
    
    rep(i, m)
        rep(j, l) scanf("%lld", &matrixB[i][j]);

    rep(i, n)
        rep(j, l)
            rep(k, m) {
                matrixC[i][j] += matrixA[i][k] * matrixB[k][j];
            }
    
    rep(i, n) {
        rep(j, l) {
            printf("%lld", matrixC[i][j]);
            if (j < l - 1) printf(" ");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

pll top2(pll x, pll y) {
  vector<ll> s = { x.first, x.second, y.first, y.second };
  sort(s.begin(), s.end(), greater<ll>());
  return pll(s[0], s[1]);
}

int main(void) {
  ll N;
  cin >> N;
  vector<ll> A(1LL << N);
  REP(i, 0, 1LL << N) cin >> A[i];

  const ll INF = 1LL << 50;
  vector<pll> dp(1LL << N);
  REP(i, 0, 1LL << N) dp[i] = pll(i, 0);
  REP(i, 0, 1LL << N) {
    REP(j, 0, N) if(!(i & (1LL << j))) {
      pll x = dp[i | (1LL << j)], y = dp[i];
      vector<ll> s = { x.first, x.second, y.first, y.second };
      sort(s.begin(), s.end());
      s.erase(unique(s.begin(), s.end()), s.end());
      sort(s.begin(), s.end(), [&](ll p, ll q) { return A[p] > A[q]; });
      dp[i | (1LL << j)] = pll(s[0], s[1]);
    }
  }

  ll ans = 0;
  REP(i, 1, 1LL << N) {
    ans = max(ans, A[dp[i].first] + A[dp[i].second]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 10624
#include <iostream>
#include <cmath>
#include <stdlib.h>
using namespace std;

int calc(int i, int j, int** A,int H,int W);

int main(void){
  int H,W;
  cin>>H>>W;
  int** A;
  A=(int**)malloc(sizeof(int*)*H);
  for(int i=0;i<H;i++){
    A[i]=(int*)malloc(sizeof(int)*W);
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>A[i][j];
    }
  }
  int retval=1000100;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      retval=min(calc(i,j,A,H,W),retval);
    }
  }
  cout<<retval<<endl;
  return 0;
}

int calc(int i, int j, int** A,int H,int W){
  int retval=0;
  for(int n=0;n<W;n++){
    for(int m=0;m<H;m++){
      retval+=min(abs(i-m),abs(j-n))*A[m][n];
    }
  }
  return retval;
}



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

int main(int argc,char** argv)
{

	int n, k, cou =1, count =0;
	cin >> n >> k;
	if(n == 1){
		cout << 2 <<endl;
		return 0;
	}
	while( cou <= k && count <= n ){
		cou = cou *2;
		count++;
	}

	if(count == n ){
		cout << cou << endl;
		return 0;
	}
	else{
		for(int i = 0; i < n; i++){
			if( count == n ){
				cout << cou <<endl;
				return 0;
			}
			cou = cou + k;
			count++;
		}
	}

	return 0;

}


Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		a: usize,
		b: usize,
		mut cs: Chars,
	}

	if cs[a] != '-' {
		println!("No");
		return;
	}
	cs[a] = '0';
	for i in 0..a+b+1 {
		if !cs[i].is_digit(10) {
			println!("No");
			return;
		}
	}
	println!("Yes");
}



Measured memory_bytes: 2140
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int visit[10000010];
int main(){
	int k,temp=7,flag=0,ans=1;
	memset(visit,0,sizeof(visit));
	scanf("%d",&k);
	if(k%2==0){
		printf("-1\n");
	}
	else{
		while(1){
			if(temp%k==0&&temp/k>0){
				break;
			}
			else if(visit[temp]==1){
				flag=-1;
				break;
			}
			else{
				visit[temp]=1;
				temp=temp%k;
				temp=temp*10+7;
				ans++;
			}
		}
		if(flag==-1){
			printf("-1\n");
		}
		else{
			printf("%d\n",ans);
		}
	}
	return 0;
}

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

int main()
{
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> works;
    rep(i,n) {
        int a,b;
        cin >> a >> b;
        works.push_back({a,b});
    }
    sort(works.begin(),works.end());

    int ans = 0;
    int cur = 0;
    priority_queue<int> que;
    for(int i=m-1;i>=0;--i) {
        while(cur<n && works[cur].first+i <= m) {
            que.push(works[cur++].second);
        }            
        
        if(!que.empty()) {
            ans += que.top();
            que.pop();
        }
    }

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

Measured memory_bytes: 1908
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 500005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";

int main() {
    #ifndef ONLINE_JUDGE  
        freopen("input.txt", "r", stdin); 
        freopen("output.txt", "w", stdout); 
    #endif 
    ll n;
    cin>>n;
    while(n--) {
        cout<<"ACL";
    }
    cout<<endl;
    return 0;
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            var N = input[0];
            var Y = input[1] / 1000;
            var noAnswer = "-1 -1 -1";

            if (Y < N || 10 * N < Y)
            {
                Console.WriteLine(noAnswer);
                return;
            }

            for (int i = 0; i <= N; i++)
            {
                if (i * 10 > Y) continue;

                for (int j = 0; j <= N - i; j++)
                {
                    var sum = i * 10 + j * 5 + (N - i - j);
                    if (sum == Y)
                    {
                        Console.WriteLine(i + " " + j + " " + (N - i - j));
                        return;
                    }
                }
            }

            Console.WriteLine(noAnswer);
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <bitset>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <memory.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int f[100000];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%d",&f[i]);
		--f[i];
	}
	int res=0;
	for(int i=0;i<n;++i){
		int x=f[i];
		if(x<i)
			continue;
		if(f[x]==i)
			++res;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
  if(a < b) {
    a= b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if(a > b) {
    a= b;
    return 1;
  }
  return 0;
}
ll mod= 1e9 + 7;


struct segmenttree {
    ll INF = 0;//一応注意（題意に沿う）
    ll n;         // 葉の数
    vector<ll> dat; // 完全二分木の配列
    segmenttree(ll n_) : n(), dat(n_ * 4, INF) { // 初期化、数列n_個で宣言すると良い（例、segmenttree g(8);）
        ll x = 1;
        while (n_ > x) {
            x *= 2;
        }
        n = x;
    }
    void update(ll i, ll x) { //i: 更新したい数列の位置(0-index) x:更新する値
        i += n - 1; // i番目は、配列上では n-1+i 番目に格納されている
        dat[i] = x; // 葉の更新
        while (i > 0) {  // 親を辿りながら更新していく
            i = (i - 1) / 2;  // parent
            dat[i] = __gcd(dat[i * 2 + 1], dat[i * 2 + 2]);//足すのならdat+dat
        }
    }
    // [a,b)の最小値取得
    ll query(ll a, ll b) { return query_sub(a, b, 0, 0, n); }
    ll query_sub(ll a, ll b, ll k, ll l, ll r) {// k:現在見ているノードの位置  [l,r):dat[k]が表している区間
        if (r <= a || b <= l) {// 範囲外なら考えない
            return INF;
        } else if (a <= l && r <= b) { // 範囲内なので自身の値を返す
            return dat[k];
        } else {// 一部区間が被る時
            ll vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            ll vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return __gcd(vl, vr); //足すのならvl+vr
        }
    }
};



int main() {
  int n;
  ll ans=0;
  cin >> n;
  segmenttree g(n);
  ll k[n];
  rep(i,n){
    ll q;
    cin >> q;
    g.update(i,q);
    k[i]=q;
  }

  rep(i,n){
    g.update(i,0);
    chmax(ans,g.query(0,n));
    g.update(i,k[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 7184
def resolve():
    K,A,B = map(int,input().split())
    if A>=B or K<=A:
        print(K+1)
        return
    
    nokori = K-A+1
    diff = B-A

    sc = A+ + diff*(nokori//2) +(1 if nokori%2 ==1 else 0)
    print(max(sc,K+1))
resolve()


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

string a,b,c;

int main()
{
	cin>>a>>b>>c;
	if(a[a.length()-1]==b[0] && b[b.length()-1]==c[0])
	{
		puts("YES");
	}
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int T, X;
	
	cin >> T >> X;

	cout << (double)T / X << endl;

	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define int long
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
main(){
  int a,b,c,d,l,C,D,G;
  cin>>a>>b>>c>>d;
  l=c*d/gcd(c,d);
  C=b/c-(a-1)/c;
  D=b/d-(a-1)/d;
  G=b/l-(a-1)/l;
  cout<<b-(a-1)-(C+D-G)<<"\n";
}

Measured memory_bytes: 256
#include<stdio.h>
void BubbleSort(int array[],int N) //バブルソート(小さい順) O(N^2)
{
    int i, j, temp;
    for (i = 0;i < N - 1;i++) {
        for (j = 0;j < N - 1;j++) {
            if (array[j + 1] < array[j]) {
                temp = array[j];array[j] = array[j + 1];array[j + 1] = temp;
            }
        }
    }
}

int main()
{
  int N,K;
  scanf("%d %d",&N,&K);
  int p[1001],sum=0;
  for(int i=0;i<N;i++){scanf("%d",&p[i]);}
  
  BubbleSort(p,N);
  for(int i=0;i<K;i++){sum += p[i];}
  
  printf("%d",sum);
}

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

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

	int ans;
	for(int i=M/N; i>0; --i){
		if(M % i == 0) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256