akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <vector>
#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
using lli = long long int;
std::vector<lli> A, pS, S;

int main(void){
    int n, k; scanf("%d%d", &n, &k);
    A.resize(n); REP(i, n) scanf("%lld", &A[i]);
    pS.resize(n+1); pS[0] = 0; REP(i, n) pS[i+1] = (A[i] > 0) ? pS[i] + A[i] : pS[i];
    S.resize(n+1); S[0] = 0; REP(i, n) S[i+1] = S[i] + A[i];
    lli res = 0;
    // [0, x) and [x,x+k) and [x+k, n)
    for(int x = 0; x + k <= n; ++x){
        lli p = pS[x] + pS[n] - pS[x+k];
        lli q = S[x+k] - S[x]; if(q < 0) q = 0;
        if(res < p + q) res = p + q;
    }
    printf("%lld\n", res);
    return 0;
}

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

int main(void)
{
    int a, b, c;

    cin >> a >> b >> c;

    if(a == b && a == c) cout << 1 << endl;
    else if(a == b || a == c || b == c) cout << 2 << endl;
    else cout << 3 << endl;

    return 0;
}



Measured memory_bytes: 3580
long M=1e9+7,m[1<<18],h,w,a,s;p(a,b)long a,b;{return b?p(a*a%M,b/2)*(b%2?a:1)%M:1;}main(i){for(*m=1;i<1<<18;)m[i]=m[i-1]*i++%M;for(scanf("%d%d%d%d",&h,&w,&a,&i);i<w;)s=(s+m[h-a-1+i]*p(m[h-a-1],M-2)%M*p(m[i],M-2)%M*m[a+w-i-2]%M*p(m[a-1],M-2)%M*p(m[w-1-i++],M-2)%M)%M;printf("%d",s);}

Measured memory_bytes: 2176
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	temp := make([]int, n)
	max := 0
	for i, _ := range a {
		fmt.Scan(&a[i])
		temp[i] = a[i]
		max = Max(max, a[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	for i := 0; i < n; i++ {
		if temp[i] == max {
			fmt.Println(a[1])
		} else {
			fmt.Println(max)
		}
	}
}

func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

Measured memory_bytes: 10496
#include<stdio.h>
int main()
{
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    int i, j;
    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= m; j++)
        {
            if (i*m + j * n - 2 * i * j == k)
            {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
import itertools
import math
import fractions
import functools
l = [0]*(10**5+1)
r = [0]*(10**5+1)
 
n = int(input())
v = list(map(int, input().split()))
 
for i in range(n):
    if i % 2 == 0:
        l[v[i]] += 1
    else:
        r[v[i]] += 1
 
max_l = l.index(max(l))
max_r = r.index(max(r))
count = 0
 
if max_l == max_r:
    for i in range(len(r)):
        if r[i] == r[max_r]:
            r[i] = 0
        if l[i] == l[max_l]:
            l[i] = 0
if max(l) > max(r):
    max_l = l.index(max(l))
else:
    max_r = r.index(max(r))
 
for i in range(n):
    if i % 2 == 0 and v[i] != max_l:
        count += 1
    if i % 2 != 0 and v[i] != max_r:
        count += 1
print(count)

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

using namespace std;


int main()
{
	int val, n, q;
	int s[10000], t[500];

	cin >> n;
	for (int i = 0; i<n && cin >> val; ++i) s[i] = val;

	cin >> q;
	for (int j = 0; j < q && cin >> val; ++j) t[j] = val;

	int count = 0;
	for (int j = 0; j < q; ++j){
		for (int i = 0; i < n; ++i){
			if (s[i] == t[j]){
				count++;
				break;
			}
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3112
from bisect import bisect_right

N, M = map(int, input().split())
S = [N - i for i, s in enumerate(input()) if s == '0']
S = S[::-1]

ans = []
now = 0
while now < N:
    i = bisect_right(S, now + M) - 1

    if S[i] == now:
        print('-1')
        exit()

    ans.append(S[i] - now)
    now = S[i]

print(*ans[::-1])


Measured memory_bytes: 10248
# -*- coding: utf-8 -*-
n = int(input())
an = list(map(int, input().split()))
count = 0
while True:
	amari = list(map(lambda x: x % 2, an))
	an = list(map(lambda x: x / 2, an))
	if 1 in amari:
		break
	else:
		count += 1
print(count)


Measured memory_bytes: 2940
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int n = Integer.parseInt(scan.nextLine());
	long factorial = 1;
	for (int i = n; i > 0; i--) {
	    factorial *= i;
	}
	System.out.println(factorial);
    }
}

Measured memory_bytes: 26112
// Template Headers {{{
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<long long>; using vvll = vector<vll>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}
// Preprocessing & "Global" variables {{{
struct Solver {
	Solver() {}
	int solve();
};
// }}}

int Solver::solve() {
	int n, x, t; cin >> n >> x >> t;
	cout << (n + x - 1) / x * t << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	Solver solver;
	#ifdef JUDGE_MULTI_CASE
		int t; cin >> t; for (int i = 1; i <= t; i++)
	#endif
	solver.solve();
	// cout << "Case #" << i << ": ", solver.solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


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

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
typedef long long ll ;
typedef long double ldb ;
 
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl "\n"
 
#define all( x ) x.begin(),x.end()
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );

int main( ) {
	timesaver ;
	int s, w;
	cin >> s >> w;
	if(w >= s)
		cout << "unsafe";
	else
		cout << "safe";
	return 0;
}

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


void solve(long long N, std::string S, std::string T){
    for(int i = 0; i < N; ++i){
        cout << S[i] << T[i];
    }
    cout << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(N, S, T);
    return 0;
}


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

typedef long long ll;
typedef long double ld;

#define n1		      "\n"
#define B                     begin()
#define E                     end()
#define F                     first
#define S                     second
#define pb                    push_back
#define pf                    push_front
#define popb                  pop_back()
#define popf                  pop_front()

const int BIG=1e5+55;
const int BIGG=1e9+7;
const ll BIGGE=1e12+55;
const double SML=(1e-7);

using namespace std;

    int n;
    ll sum;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL);
    cout.tie(NULL);
    cin >>n;
    for (int i=0; i<=n; i++) {
        if (i % 3 == 0 || i % 5 == 0)
            continue;
        sum += i;
    }
    cout <<sum;


    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using u32 = uint32_t;

int main()
{
	std::vector<std::string> w;
	w.reserve(3);
	w.push_back("Sunny");
	w.push_back("Cloudy");
	w.push_back("Rainy");

	std::string in;
	std::cin >> in;

	auto it = std::find(w.begin(), w.end(), in);

	it++;
	if(it==w.end()) {
		it = w.begin();
	}

	std::cout << *it << "\n";
	
	return 0;
}

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

#define sz(x) (int)x.size()
#define ld long double
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

const ll INF = 1e18;

ll n, res = 0;
vector<ll> v, a;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    n++;
    v.assign(n, 0);
    a.assign(n, 0);
    for(int i = 0; i < n; ++i){
        cin >> v[i];
    }
    if(v[0] > 1){
        cout << -1;
        return 0;
    }
    if(v[0] == 1){
        if(n > 1) cout << -1;
        else cout << 1;
        return 0;
    }
    //num nodes with nonzero children at level i
    a[0] = 1;
    for(int i = 1; i < n; ++i){
        a[i] = a[i - 1] * 2 - v[i];
        a[i] = min(a[i], INF);
        if(a[i] < 0){
            cout << -1;
            return 0;
        }
    }
    ll cnt = 0;
    for(int i = n - 1; i >= 0; --i){
        a[i] = min(a[i], cnt);
        cnt += v[i];
    }
    for(int i = 1; i < n; ++i){
        // cout << v[i] << " " << a[i] << " " << a[i - 1] << '\n';
        if(v[i] + a[i] < a[i - 1] || v[i] + a[i] > 2 * a[i - 1]){
            // cout << v[i - 1] << " " << v[i] << " " << a[i] << " " << i << "\n";
            cout << -1;
            return 0;
        }
    }
    // cout << sz(a) << " " << sz(v) << "\n";
    // for(auto i : a) cout << i << " ";
    // cout << "\n";
    // for(auto i : v) cout << i << " ";
    // cout << "\n";
    for(auto i : a) res += i;
    for(auto i : v) res += i;
    cout << res;
    return 0;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
int main(){
    int n;
    cin >> n;
    map<string,int> mp;
    for(int i = 0; i < n; i++) {
	string s;
	cin >> s;
	mp[s]++;
    }
    cout << "AC x " << mp["AC"] << "\n";
    cout << "WA x " << mp["WA"] << "\n";
    cout << "TLE x " << mp["TLE"] << "\n";
    cout << "RE x " << mp["RE"] << "\n";
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
        using namespace std;
        #define int long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 998244353 
        #define inf 2e18

        bool compare(pair<int,int> a,pair<int,int> b){
            if(a.first==b.first)
                return a.second<b.second;
            return a.first<b.first;
        }

        signed main() {
 
  
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        int n;
        cin>>n;

        int val=100;
        int yr=0;
        while(val<n){
            val=val+val*0.01;
            yr++;
        }
        cout<<yr;

        return 0;
    }

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    mat C(10, vec(10, 0));
    REP(i,1,N+1) {
        string s = to_string(i);
        ++C[s[0]-'0'][s[SZ(s)-1]-'0'];
    }

    ll cnt = 0;
    REP(i,0,10) {
        REP(j,0,10) cnt += C[i][j] * C[j][i];
    }
    PR(cnt);

    return 0;
}

/*



*/

Measured memory_bytes: 3680
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#pragma endregion

int main(){
    int n;
    cin >> n;
    vector<int> p(n), q(n), target(n);
    REP(i, n) cin >> p[i];
    REP(i, n) cin >> q[i];
    iota(ALL(target), 1);

    int p_num;
    int q_num;

    int cnt = 1;
    do {
        if (target==p) {
            p_num = cnt;
            break;
        }
        cnt++;
    } while (next_permutation(ALL(target)));
    sort(ALL(target));
    cnt = 1;
    do {
        if (target==q) {
            q_num = cnt;
            break;
        }
        cnt++;
    } while (next_permutation(ALL(target)));

    cout << abs(p_num-q_num) << endl;

    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <set>
#include <regex>

using namespace std;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define DEBUG(_debuged) cerr << #_debuged << ":" << _debuged << endl;

struct L
{
	int t;
	int x;
	int y;
};

vector<int> loadn(int n)
{
	vector<int> v(n);
	REP(i, n)
		cin >> v[i];
	return v;
}

uint64_t modpower(const unsigned int N, const unsigned int K, const unsigned int MOD)
{
	uint64_t ret = 1;
	uint64_t k2 = N;
	REP(i, 31)
	{
		if ((K >> i) & 0x1)
		{
			ret *= k2;
			ret = ret % MOD;
		}
		k2 = (k2 * k2) % MOD;
	}
	return ret;
}

class ModCombinationMemo
{
public:
	const unsigned int N;
	const unsigned int MOD;
	vector<uint64_t> memo = { 1 };

	ModCombinationMemo(uint32_t N, uint32_t MOD)
		: N(N), MOD(MOD)
	{
	}

	uint64_t c(uint64_t k)
	{
		if (memo.size() > k)
		{
			return memo[k];
		}

		FOR(i, memo.size(), k + 1)
		{
			const auto number = (memo[i - 1] * (N - i + 1)) % MOD;
			const auto reverceDeon = modpower(i, MOD - 2, MOD);
			memo.push_back(number * reverceDeon % MOD);
		}

		return memo[k];
	}
};

uint64_t c(const unsigned int N, const unsigned int K, const unsigned int MOD)
{
	if (K == 0)
	{
		return 1;
	}

	uint64_t n = 1, k = 1;

	REP(i, K)
	{
		n *= N - i;
		k *= i + 1;

		n = n % MOD;
		k = k % MOD;
	}

	uint64_t powerk = modpower(k, MOD - 2, MOD);

	return (n * powerk) % MOD;
}

unsigned trailing_zeros(unsigned n)
{
	if (!n)
		return -1;
	unsigned int c = 32; // c will be the number of zero bits on the right
	n &= -(signed)n;
	if (n)
		c--;
	if (n & 0x0000FFFF)
		c -= 16;
	if (n & 0x00FF00FF)
		c -= 8;
	if (n & 0x0F0F0F0F)
		c -= 4;
	if (n & 0x33333333)
		c -= 2;
	if (n & 0x55555555)
		c -= 1;
	return c;
}

unsigned int digitssum(uint64_t source) {
	int result = 0;

	while (source > 0) {
		result += source % 10;
		source /= 10;
	}

	return result;
}

struct oishisa
{
	int64_t x;
	int64_t y;
	int64_t z;
};

int64_t cint()
{
	int64_t i;
	cin >> i;
	return i;
}

int main(int argc, char *argv[], char *envp[])
{
	int64_t i(cint());

	cout << ((i % digitssum(i) == 0) ? "Yes" : "No") << endl;
}
/*

int main(int argc, char *argv[], char *envp[])
{
	int i = 0;
	REP(n, 4) {
		char sign;
		cin >> sign;
		i += (sign == '+' ? +1 : -1);
	}
	cout << i;
}
/*
int main(int argc, char *argv[], char *envp[])
{
	const int K(cint());

	
	int result = 0;
	
	for (uint64_t target = 1; result < K; target++) {
		FOR(s, 1, 127) {
			int minimum = target + 1;
			while(digitssum(minimum) != s) {
				minimum += 
			}

			if (target * digitssum(minimum) > minimum * digitssum(target)) {
				goto b;
			}
		}

		cout << target << endl;
		result++;

	b:;
		
	}

	return 0;
}
*/

Measured memory_bytes: 256
#!/usr/bin/python
#coding: utf-8

from collections import Counter

N, K = map(int, raw_input().split())
l = map(int, raw_input().split())

s = list(set(l))
num = range(len(s))
if len(s) <= K: print 0
else:
    counter = Counter(l)
    nums = counter.values()
    sousa = len(s)-K
    nums.sort()
    print sum(nums[:sousa])


Measured memory_bytes: 39780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

ll N, A, B;
vector<ll> h(100005);

bool check(int k){
    ll tmp = 0;
    for(int i=0; i<N; i++){
        if(h[i]-B*k <= 0) continue;
        tmp += max(0LL,(h[i]-B*k-1)/(A-B) + 1);
    }

    if(tmp <= k) return true;
    else return false;
}

int solve(){
    int left = 0, right = 1000000000;
    int mid;
    while(right - left > 1){
        mid = (left+right)/2;
        bool v = check(mid);
        if(v) right = mid;
        else left = mid;
    }

    return right;
}

int main(){
    cin >> N >> A >> B;
    for(int i=0; i<N; i++) cin >> h[i];

    cout << solve() << endl;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}

ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

void solve(){
  ll k;
  cin>>k;
  queue<string>q;
  vector<string>ans;
  rep(i,9)q.emplace(to_string(i+1));
  while(!q.empty()){
    string s=q.front();
    q.pop();
    ans.pb(s);
    if(s.size()>=11)continue;
    for(int i=-1;i<=1;++i){
      if(s.back()-'0'+i>=10)continue;
      if(s.back()-'0'+i<0)continue;
      q.emplace(s+to_string(s.back()-'0'+i));
    }
  }
  cout<<ans[k-1];
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 40684
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

vector<ll> adj[M];
ll ar[M],cnt[M];

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

	ll m,i,j,n,t,ans,b = 0;

	m = 1e6;
	for(i=1;i<=m;++i)
	{
		for(j=i;j<=m;j+=i)
			adj[j].pb(i);
	}

	cin >> n;
	for(i=1;i<=n;++i)
	{
		cin >> ar[i];
		cnt[ar[i]]++;
	}
	for(i=1;i<=n;++i)
	{
		ans = 0;
		for(auto v:adj[ar[i]])
			ans += cnt[v];
		if(ans == 1)
			b++;
	}
	cout << b << endl;
}

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

int main(void) {
	int m, n;
	int i;

	while (1) {
		bool ans[7400000] = {};
		cin >> m >> n;

		if (m == 0 && n == 0) {
			break;
		}

		for (i = m;; i++) {
			if (!ans[i]) {
				if (n == 0) {
					cout << i << endl;
					break;
				}
				n--;
				int j = i;
				while (j < 7400000)
				{
					ans[j] = true;
					j += i;
				}
			}
		}
	}

	return 0;
}


Measured memory_bytes: 10216
#include<stdio.h>
int IsPrime(int);

main(){
  int x,i,y,a,t=0;

  scanf("%d",&x);
  
  for(i = 0;i < x;i++){
    scanf("%d",&y);
    a = IsPrime(y);
    t += a;
  }
  printf("%d\n",t);

  return 0;
}
int IsPrime(int n){
    int i;
 
    if(n < 2)
        return 0;
    else if(n == 2)
        return 1;
 
    if(n % 2 == 0)
        return 0;
 
    for(i = 3; i <= n / i; i += 2)
         if(n % i == 0)
            return 0;
    return 1;
}

Measured memory_bytes: 596
/**************************************************
 * Atcoder problems
 * Contest No :085
 * Problem No :C
 * File Name  :program.cs
 * Create date:2020/07/12
 *
 * Copyright 2020 Shunichi Sato,All Rights Reserved.
**************************************************/
using System;
class Program
{
    static void Main(string[] args)
    {
        // 枚数・金額の入力
        String[] nums = Console.ReadLine().Split(' ');
        int N = int.Parse(nums[0]);
        int Y = int.Parse(nums[1]);
        // 金額判定
        int x = -1;
        int y = -1;
        int z = -1;
        for(int a= 0;a<=N;a++){
            for(int b = 0;a+b <=N;b++){
            int c = N - a - b;
            int sum = 10000 * a + 5000* b+ 1000 * c;
                if (sum == Y)
                {
                    x = a;
                    y = b;
                    z = c;
                }
            }
        }
        // 結果出力
        Console.WriteLine(x + " " + y + " " + z);
    }
}


Measured memory_bytes: 17868
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll a, b, c;
  cin >> a >> b >> c;

  cout << (a % 2 == 0 || b % 2 == 0 || c % 2 == 0 ? 0 : min({a * b, b * c, c * a})) << '\n';




  
  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
dp=[0]*n
for i in range(1,n):
  if i==1:
    dp[i]=abs(a[i]-a[i-1])
  else:
    dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]))
print(dp[-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
using namespace std;
#define MAXN 200005
#define INF 0x3f3f3f3f
#define MS(x, i) memset(x, i, sizeof x)
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define MOD 1000000007
#define NOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

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


int a[MAXN];
int dp[MAXN];

inline ll read() {
    ll ret = 0, sgn = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if(ch == '-') sgn = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        ret = ret*10 + ch - '0';
        ch = getchar();
    }

    return ret*sgn;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;


constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
	template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
	template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
	template<typename T> void chadd(T& a, T b) { a = a + b; }

	void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

	void CCout(long long x, const char* end = "\n") { std::cerr << x << end; }
	template <typename T> void CCout(const T& x, const char* end = "\n") { std::cerr << x << end; }
	template <typename T> void CCout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cerr << x[i] << (i == sz - 1 ? end : sep); } }

	// 標準入出力
	struct inp {
		std::size_t sz;
		inp(std::size_t _sz = 1) : sz(_sz) {}
		template <typename T> operator T () const { T a; std::cin >> a; return a; }
		template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
		template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
	};

	inp inp1; // input one
}

int main() {

	size_t n = inp1;
	vector<int> a = inp(n);

	multiset<int> num;

	num.insert(a[0]);

	Rep(i, 1, n) {
		auto itr = num.lower_bound(a[i]);
		if (itr == num.begin()) {
			// 存在しない
			num.insert(a[i]);
			continue;
		}

		num.erase(--itr);
		num.insert(a[i]);

		// 3 5 6   <- 4
	}

	Cout(num.size());

	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <typeinfo>
#include <algorithm>
#include <cctype>
using namespace std;

bool is_digits(const string &str) {
    return str.find_first_not_of("0123456789") == string::npos;
}

int main() {
    string tmp;
    int to, toto;
    vector<string> v;
    stack<int> sta;
    while (cin >> tmp) {
        v.push_back(tmp);
    }

    vector<string>::iterator p;
    for (p=v.begin(); p!=v.end(); p++) {
        if (is_digits(*p)) {
            sta.push(stoi(*p));
        } else {
            to = sta.top(); sta.pop();
            toto = sta.top(); sta.pop();
            if (*p == "+") {
                sta.push(toto + to);
            } else if (*p == "-") {
                sta.push(toto - to);
            } else if (*p == "*") {
                sta.push(toto * to);
            }
        }
    }

    cout << sta.top() << endl;
    return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

string getLcs(string& s, string& t) {
    int m = s.size(), n = t.size();
    vector<vector<int>> dp_value(m+1, vector<int>(n+1, 0));
    for (size_t i=1; i < s.size()+1; ++i) {
        for (size_t j=1; j < t.size()+1; ++j) {
            if (s[i-1] == t[j-1]) {
                dp_value[i][j] = dp_value[i-1][j-1] + 1;
            }else{
                dp_value[i][j] = max(dp_value[i-1][j], dp_value[i][j-1]);
            }
        }
    }

    string ans = "";
    int count = dp_value[s.size()][t.size()];
    int ki = s.size(), kj = t.size();
    while (count > 0) {
        if (s[ki-1] == t[kj-1]) {
            ans = s[ki-1] + ans;
            --ki;
            --kj;
            --count;
            continue;
        }
        if (dp_value[ki-1][kj] > dp_value[ki][kj-1]) {
            --ki;
        }else{
            --kj;
        }
    }
    return ans;
}

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

    // SOURCE
    string ans = getLcs(s, t);

    // OUTPUT
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35584
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = -float('inf')
for s in range(N):
    S = []
    i = P[s] - 1
    S.append(C[i])
    while i != s:
        i = P[i] - 1
        S.append(S[-1] + C[i])
    if K <= len(S):
        score = max(S[:K])
    elif S[-1] <= 0:
        score = max(S)
    else:
        score1 = S[-1] * (K // len(S) - 1)
        score1 += max(S)
        score2 = S[-1] * (K // len(S))
        r = K % len(S)
        if r != 0:
            score2 += max(0, max(S[:r]))
        score = max(score1, score2)
    ans = max(ans, score)
print(ans)


Measured memory_bytes: 99320
#include<iostream>
#include <algorithm>
#define syso(s) std::cout<<s<<endl;
#define sc(i) std::cin>>i;
using namespace std;
int main() {
	int a, b, h;
	sc(a); sc(b); sc(h);
	syso((a+b)*h/2)
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    val result = experiment(n)

    println(result)
}

fun experiment(n : Int) : String {
    // nの素因数分解
    // 1)2と3以外の約数→-1
    // 2)3の数>2の数→-1
    // 3)3の数 + (3の数 - 2の数)が答え

    val amari = n % 1000

    val result = if (amari > 0) 1000 - n % 1000 else 0

    return result.toString()
}


Measured memory_bytes: 34480
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int N;
  string S;
  cin >> N >> S;
  int countl = 0, countr = 0;
  int lastl = -1;
  int add = 0;
  string ans;
  for(int i=0; i<N; i++){
    if(S[i] == '('){
      countl++;
      ans += S[i];
      lastl = i + add;
    } else {
      if(countl < countr+1){
        ans = '(' + ans;
        countl++;
        lastl++;
        add++;
      }
      countr++;
      ans += S[i];
    }
  }
  for(int i=0; i<countl-countr; i++)
    ans += ')';
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 100005  //check the limits, man
int main()
{
    int i,n,x,y;
    ll a,b,k;
    in(n);
    a=1,b=1;
    rep(i,n)
    {
        in2(x,y);
        if(y>=b && x>=a)
            k=1;
        else if(y>=b && x<a)
            k=((a-1)/x)+1;
        else if(y<b && x>=a)
            k=((b-1)/y)+1;
        else
            k=1+max(((b-1)/y),((a-1)/x));
        a=x,a*=k,b=y,b*=k;
    }
    llout(a+b);
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	int		a,b,c,d,i,j,k,n,m,x,y,ans = 0;
	cin >> n;
	vector<vector<int>>	ab(n+1);
	vector<int> A(n+1),B(n+1);
	for(i=0;i<n-1;i++) {
		cin >> a >> b;
		ab[a].push_back(b);
		ab[b].push_back(a);
		A[i] = a;
		B[i] = b;
	}
	for(i=1;i<=n;i++) {
		ans = max(ans , (int)ab[i].size());
	}
	queue<int> que;
	map<ll,int> hen;
	set<int> tmp;
	que.push(1);
	while(!que.empty()) {
		c = que.front();
		que.pop();
		tmp.clear();
		//cout << "c:"<< c << endl;
		for(j=0;j<ab[c].size();j++) {
			ll key;
			d = ab[c][j];
			if (c > d) key = (ll)d*1000000 + c;
			else key = (ll)c*1000000 + d;
			//cout << "key:" << key << endl;
			if (hen.count(key)) tmp.insert(hen[key]);
		}
		x = 1;
		for(j=0;j<ab[c].size();j++) {
			ll key;
			d = ab[c][j];
			if (c > d) key = (ll)d*1000000 + c;
			else key = (ll)c*1000000 + d;
			if (!hen.count(key)) {
				while(tmp.count(x)) x++;
				hen[key] = x;
				//cout << key << " " << x << " " << j << endl;
				tmp.insert(x++);
				que.push(d);
			};
		}
	}
	cout << ans << endl;
	for(i=0;i<n-1;i++) {
		ll key;
		c = A[i]; d = B[i];
		if (c > d) key = (ll)d*1000000 + c;
		else key = (ll)c*1000000 + d;
		cout << hen[key] << endl;
	}

	return 0;
}


Measured memory_bytes: 13056
import numpy as np
def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

n,d=map(int,input().split())

x=[]
for i in range(n):
    row = input().split()
    for i in range(len(row)):
        row[i]=int(row[i])
    x.append(row)
#print(x[0][1])
count = 0
for i in range(n-1):
    a=np.array(x[i])
    for j in range(i,n):
        if(i==j):
            continue
        b=np.array(x[j])
        l = np.linalg.norm(a-b)
        #print(l)
        if(is_integer(l)):
            count += 1

print(count)

Measured memory_bytes: 12496
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll a[2000];
ll b[2000][2000];
int main(void){
    ll n, x; cin >> n >> x; for(ll i = 0;i < n;i++)cin >> a[i];
    for(ll i = 0;i < n;i++){
        b[i][0] = a[i];
        for(ll j = 1;j < n;j++){
            if(b[i][j-1] > a[(n+i-j)%n]){
                b[i][j] = a[(n+i-j)%n];
            }else{
                b[i][j] = b[i][j-1];
            }
        }
    }
    ll ans = -1;
    for(ll i = 0;i < n;i++){
        ll sum = i*x;
        for(ll j = 0;j < n;j++)sum += b[j][i];
        if(ans == -1 || ans > sum)ans = sum;
        /*for(ll j = 0;j < n;j++)printf("%3lld ", b[j][i]);
        printf("\n");*/
    }
    cout << ans << endl;
 	return 0;
}


Measured memory_bytes: 31488
while s = gets
  nums = s.split.map(&:to_f)
  a, b, c, d, e, f = nums
  x = (c * e - b * f) / (a * e - b * d)
  y = (a * f - c * d) / (a * e - b * d)
  x = x.round(3)
  y = y.round(3)
  x = x != 0 ? x : 0
  y = y != 0 ? y : 0
  puts sprintf("%.3f %.3f", x, y)
end

Measured memory_bytes: 6188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,ans;
bool b[100005];
vector<int> g[100005];
void dfs(int x){
	b[x]=true;
	for(int i=0;i<g[x].size();i++)
		if(!b[g[x][i]])dfs(g[x][i]);
}
int main(){
	cin >> n >> m;
	for(int i=0;i<m;i++){
		int x,y,z;
		cin >> x >> y >> z;
		x--,y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for(int i=0;i<n;i++)
		if(!b[i])dfs(i),ans++;
	cout << ans;
    return 0;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vi a(n);
    REP(i, n) cin >> a[i];
    SORT(a);
    int ans = 0;
    REP(i, k) ans += a[i];
    cout << ans << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <unistd.h>
#include <random>

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end())
#define DOUBLECHANGE(count) cout << setprecision(count)
#define REV(vec) reverse(vec.begin(),vec.end())
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

long long int factorial(long long int a){
    long long int ans = 1;
    for(int i = 0;i < a;i++){
        ans *= i+1;
    }
    return ans;
}

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      long long int N, M;
      cin >> N >> M;
      vector<long long int> card (N);
      for(long long int i = 0;i < N;i++){
          cin >> card[i];
      }
      vector<pair<long long int,long long int>> replace (M);
      for(long long int i = 0;i < M;i++){
          cin >> replace[i].second >> replace[i].first;
      }
      SORT(card);
      SORT(replace);
      REV(replace);
      long long int position = 0;
      for(long long int i = 0;i < M;i++){
          if(card[position] >= replace[i].first){
              break;
          }
          else{
              for(long long int j = 0;j < replace[i].second;j++){
                  if(card[position] >= replace[i].first){
                      break;
                  }
//                  cout << card[position] << "(" << position << ") to " << replace[i].first << "(" << i << ")" << endl;
                  card[position] = replace[i].first;
                  position++;
              }
          }
      }
      long long int ans = 0;
//      cout << endl;
      for(int i = 0;i < N;i++){
//          cout << card[i] << endl;
          ans += card[i];
      }
      cout << ans << endl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<string>
#define sc(n) scanf("%d",&n)
#define sc2(x,y) scanf("%d %d",&x,&y)
#define fornt(i,n) for(i=0; i<n; ++i)
using namespace std;


int main ()
{
    int i,c=0;
  string s,t;
  cin>>s;
  cin>>t;
  fornt(i,s.size())
  {
      if(s[i]!=t[i])
      ++c;
  }
  printf("%d\n",c);
}


Measured memory_bytes: 3584
// ABC131
// A - Security
#include<bits/stdc++.h>

using namespace std;

int main(){
    string s;
    cin >> s;
    if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]) cout << "Bad" << endl;
    else cout << "Good" << endl;
    return 0;
}


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

main() {
  string s; cin >> s;
  int l = 0, r = s.length() - 1;
  int ans = 0;
  while (l <= r) {
    if (s[l] == s[r]) {
      l++; r--;
    } else {
      if (s[l] == 'x') {
        l++;
        ans++;
      } else if (s[r] == 'x') {
        r--;
        ans++;
      } else {
        ans = -1;
        break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n;
    string s;
    cin >> n >> s;
    if(n%2==1){
        cout <<"No" << endl;
    }
    else if(s.substr(0,n/2) == s.substr(n/2,n/2)){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 3552
#include<stdio.h>
#define NUM 200


int main() {
	int i;
	int num = 0, ans = 0;
	int len;
	char s[NUM];

	scanf("%d",&len);
	scanf("%s", s);

	for (i = 0;i < len;i++) {
		if (s[i] == 'I') {
			num++;
			if (ans < num)
				ans = num;
		}
		else
			num--;
	}

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


	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 k,n;
    cin >> k >> n;
    int32 mx = 0;
    vector<int32> a(n);
    REP(i,n){
        cin >> a[i];
    }
    REP(i,n-1){
        mx = max(mx, a[i+1] - a[i]);
    }
    mx = max(mx, k - (a[n-1] - a[0]));
    ANS(k - mx);
    return 0;
}

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

const int MAX_BOOK = 12;

bool can_reach_goal(vector<int> &algos, int goal)
{
  for (int i = 0; i < algos.size(); i++)
  {
    if (algos.at(i) < goal)
    {
      return false;
    }
  }
  return true;
}

int calc_money(bitset<MAX_BOOK> &buy_book, vector<vector<int>> &books, int algo_num, int goal)
{
  int money = 0;
  vector<int> algos = vector<int>(algo_num);
  for (int i = 0; i < books.size(); i++)
  {
    if (!buy_book.test(i))
    {
      continue;
    }
    money += books.at(i).at(0);
    for (int algo = 0; algo < algo_num; algo++)
    {
      algos.at(algo) += books.at(i).at(1 + algo);
    }
  }
  if (can_reach_goal(algos, goal))
  {
    return money;
  }
  return -1;
}

int main()
{
  int book_num, algo_num, goal;
  cin >> book_num >> algo_num >> goal;
  vector<vector<int>> books(book_num, vector<int>(algo_num + 1));
  for (int i = 0; i < book_num; i++)
  {
    for (int j = 0; j < algo_num + 1; j++)
    {
      cin >> books.at(i).at(j);
    }
  }

  int ans = 1000000000;
  for (int i = 0; i < (1 << book_num); i++)
  {
    bitset<MAX_BOOK> buy_book(i);
    int tmp_ans = calc_money(buy_book, books, algo_num, goal);
    if (tmp_ans != -1)
    {
      ans = min(ans, tmp_ans);
    }
  }
  if (ans == 1000000000)
  {
    ans = -1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636