akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}


const int MAX=4010000;
long long fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
long long COM(int n,int k){
    if(n<k) return 0;
    if(n<0 or k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
ll fact_mod(ll n) {
    ll ret=1; 
    for(ll i=2;i<=n;i++) ret=ret*(i%mod)%mod;
    return ret;
} 
ll pow_mod(ll x, ll n){
    if(n==0) return 1;
    ll ret=pow_mod((x*x) % mod, n/2);
    if(n&1) ret=(ret*x)%mod;
    return ret;
}
//O(r)
ll combination_mod(ll n, ll r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    ll a=1;
    for(ll i=0;i<r;i++) a=a*((n-i)%mod)%mod;
    ll b=pow_mod(fact_mod(r), mod-2);
    return (a%mod)*(b%mod)%mod;
}
ll inv_mod(ll n){
    return pow_mod(n,mod-2);
}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    COMinit();

    int k;cin>>k;
    string s;cin>>s;
    int n=(int)s.size();

    ll ans=0;

    rep(i,k+1){
        ll rem=k-i;
        ll res=pow_mod(26,i)*COM(n-2+rem+1,rem)%mod*pow_mod(25,rem)%mod;
        ans+=res;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 98240
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main(){
  ll n;
  cin >> n;
  vl vec(n);
  ll ans = 0;
  rep(i, n){
    ll num;
	cin >> num;
    if(num > 2){
      if(num%2==0){
        ans += num/2-1;
        vec[i] = 2;
      }else{
        ans += num/2;
        vec[i] = 1;
      }
    }else{
      vec[i] = num;
    }
  }
  rep(i, n-1){
    if(vec[i] == 2){
      ans++;
    }else if(vec[i] == 1){
      if(vec[i+1] != 0){
        vec[i+1]--;
        ans++;
      }
    }
  }
  if(vec[n-1] == 2) ans++;
  cout << ans << endl;
  return 0;
}
      
      
      


Measured memory_bytes: 4052
#include <stdio.h>

int main(void) {
	int a,b,c,d,e;
	d=0;
	e=2;
	scanf("%d %d %d",&a,&b,&c);
	if(b<=c){
		d=d+2;
		b=c;
	}else{
		d=d+1;
	}
	while(a>e){
		int x;
		scanf("%d",&x);
		if(b<=x){
			d=d+1;
			b=x;
		}
		e=e+1;
	}
	printf("%d",d);
	return 0;
}

Measured memory_bytes: 128
function main(input) {
  const args = input.split("\n");
  const N = parseInt(args[0]);
  const A = args[1];
  const B = args[2];
  const C = args[3];
  let result = 0;
  for (let i = 0; i < N; i++) {
    // 同じ文字なら一点
    const r1 = A[i] === B[i] ? 1 : 0;
    const r2 = B[i] === C[i] ? 1 : 0;
    const r3 = C[i] === A[i] ? 1 : 0;
    switch (r1 + r2 + r3) {
      case 3:
      case 2:
        break;
      case 1:
        result += 1;
        break;
      case 0:
        result += 2;
        break;
    }
  }
  console.log(`${result}`);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
N = int(input())

info = []
for _ in range(N):
    x, y, h = map(int, input().split())
    info.append([h, x, y])

info.sort(reverse=True)

for c_x in range(101):
    for c_y in range(101):
        H = info[0][0] + abs(info[0][1] - c_x) + abs(info[0][2] - c_y)
        flag = True
        for i in range(1, N):
            if info[i][0] != max(H - abs(info[i][1] - c_x) - abs(info[i][2] - c_y), 0):
                flag = False
                break

        if flag:
            print(*[c_x, c_y, H])
            exit()

Measured memory_bytes: 3064
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int n,m,i,mx,cnt,j;
	char s[100][11],t[100][11];
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%s",s[i]);
	scanf("%d",&m);
	for(i=0;i<m;i++)	scanf("%s",t[i]);
	mx=0;
	for(i=0;i<n;i++)	{
		cnt=0;
		for(j=0;j<n;j++)	{
			if(strcmp(s[i],s[j])==0)	cnt++;
		}
		for(j=0;j<m;j++)	{
			if(strcmp(s[i],t[j])==0)	cnt--;
		}
		mx=max(mx,cnt);
	}
	printf("%d\n",mx);
    return 0;
}

Measured memory_bytes: 128
n = list(map(int, input().split()))
m = list(map(int, input().split()))

ans = 0
new_list = [0]
for i in range(n[0]):
  ans = ans + m[i]
  if ans <= n[1]:
    new_list.append(ans)
  elif ans > n[1]:
    break
    
print(len(new_list))
  

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

//macro
#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, n, m) for(int i = m; i < n; ++i)
#define LL long long

using namespace std;

typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

int main(){
	int n;
	string s, ans;
	cin >> n;
	cin >> s;
	ans = s;
	int zenka = 0;
	int kouka = 0;
	int ind = 0;
	REP(i, n){
		if(s[i] == '('){
			zenka++;
		}else if(s[i] == ')'){
			if(zenka != 0){
				zenka--;
			}else{
			ans.insert(ans.begin(), '(');	
			}
		}
	}
	REP(i, zenka){
				ans.push_back(')');
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

int64_t solve(int n, int m, std::vector<int> ls, std::vector<int> rs) {
  int l = 0;
  int r = n;
  for (int i = 0; i < m; ++i) {
    l = std::max(ls[i], l);
    r = std::min(rs[i] + 1, r);
  }
  return std::max(r - l, 0);
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  std::cin >> n;
  int m;
  std::cin >> m;
  std::vector<int> ls(m);
  std::vector<int> rs(m);
  for (int i = 0; i < m; i++) {
    std::cin >> ls[i];
    std::cin >> rs[i];
    ls[i]--;
    rs[i]--;
  }
  auto const res = solve(n, m, std::move(ls), std::move(rs));
  std::cout << res << std::endl;
  return 0;
}


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

int main() {
  int N, M;
  cin >> N;
  vector<int> T(N);
  for(int i = 0; i < N; i++) {
    cin >> T.at(i);
  }
  cin >> M;
  vector<int> P(M);
  vector<int> X(M);
  for(int i = 0; i < M; i++) {
    cin >> P.at(i) >> X.at(i);
  }
  long long sum = 0;
  for(int i = 0; i < N; i++) {
    sum += T.at(i);
  }
  for(int i = 0; i < M; i++) {
    cout << sum - T.at(P.at(i)-1) + X.at(i) << endl;
  }
}


Measured memory_bytes: 256
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
// https://atcoder.jp/contests/abc166/tasks/abc166_d
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll x;
    cin >> x;
    ll a,b;
    for(a = -120;a<=120;a++){
        for(b=-120;b<=120;b++){
            if(pow(a,5) - pow(b,5) == x){
                goto EXIT;
            }
        }
    }
    EXIT:
    cout << a << " " << b;
  
	return 0;
}

Measured memory_bytes: 4112
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
const int MOD=1e9+7;
const int INF=1<<29;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m=MOD){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
void solve(){
   int n;
   cin>>n;
   vector<int> v(n);
   for(auto& it:v){
	   cin>>it;
	   it--;
   }
   int cnt=accumulate(all(v),0);
   cout<<cnt<<endl;
    
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a;
	cin>>a;
	cout<<a+a*a+a*a*a<<"\n";
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
const int MOD = 998244353;
const int MAX_N = 200100;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += MOD - a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(MOD - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} c(200005);

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N, M, K;
    cin >> N >> M >> K;
    mint ans = 0;
    mint col = M;
    REP(i, N - 1 - K)
    {
        col *= M - 1;
    }
    for (int i = K; i >= 0; i--)
    {
        mint now = col;
        now *= c(N - 1, i);
        ans += now;
        col *= M - 1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6236
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    B = tuple(map(int, input().split()))

    n_2 = 0
    n_1 = 0
    for a, b in zip(A, B):
        if a > b:
            n_1 += (a - b)
        elif a < b:
            n_2 += (b - a + 1) // 2

    diff = sum(B) - sum(A)
    if diff < 0:
        ans = "No"
    elif n_1 <= diff and n_2 <= diff:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10480
N = int(input())
n = N
B = list(map(int,input().split()))
B = B[::-1]
A = []
for i in range(N):
    for m,b in enumerate(B):
        if (N-m == b):
            A.append(b)
            B.pop(m)
            N -= 1
            break
if len(A) == n:
    for a in A[::-1]:
        print(a)
else:
    print(-1)

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

int main()
{
    string S;
    cin >> S;
    if (S == "Sunny")
    {
        cout << "Cloudy" << endl;
    }
    else if (S == "Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else
    {
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,aa[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char c;
queue<int> que;
signed main(){
    cin>>n>>s;
    if(s.size()<=n){
        cout<<s;
    }else{
        rep(i,n){
            cout<<s[i];
        }
        cout<<"...";
    }
}

Measured memory_bytes: 10512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define mod 1000000007
ll dp[110][100100]={{0}};
ll dp2[110][100100]={{0}};
int main(){
int n,k;
cin>>n>>k;
vector<int>a(n);
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=0;i<=n;i++){dp[i][0]=1;dp2[i][0]=1;}
for(int i=1;i<=k;i++)dp2[0][i]=1;
for(int i=1;i<=n;i++){
    for(int j=1;j<=k;j++){
        dp[i][j]=(dp2[i-1][j]%mod-(((j-a[i]-1)<0)?0:(dp2[i-1][j-a[i]-1]))%mod+mod)%mod;
        dp2[i][j]=(dp2[i][j-1]%mod+dp[i][j]%mod)%mod;
        }
}
cout<<dp[n][k]%mod<<'\n';
return 0;}


Measured memory_bytes: 160000
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n;
  cin >> n;
  
  vector<int> p(n);
  int zen=1;
  int ki=1;
  rep(i,n){
  zen*=3;
  cin>>p[i];
    if(p[i]%2==0) ki*=2;
  }
  
  cout << zen-ki << endl;
  
}


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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int maxn = 5000+10;
const ll oo = numeric_limits<ll>::max();
int P[maxn],seen[maxn];
ll N,K,C[maxn];
vi graph[maxn];

int len(int u){
	seen[u] = 1;
	int res = 1;
	for(auto &v : graph[u]){
		if(seen[v])continue;
		res += len(v);
	}
	return res;
}
void dfs(int u,ll act,ll cnt,vector<ll> &vals){
	vals.pb(act);
	if(!cnt)return;
	for(auto &v : graph[u]){
		dfs(v,act+C[v],cnt-1,vals);
	}
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> K;
	forn(i,0,N){
		cin >> P[i]; P[i]--;
		graph[i].pb(P[i]);
	}
	forn(i,0,N)cin >> C[i];
	ll res = -oo;
	forn(i,0,N){
		ll Ktmp = K;
		forn(j,0,N)seen[j] = 0;
		ll lenCiclo = len(i);
		ll cntPuedo = min(lenCiclo,Ktmp);
		
		//cout << i+1 << ":D\n";
		//cout << lenCiclo << ' ' << cntPuedo << '\n';
		
		vector<ll> vals;
		dfs(i,0,cntPuedo,vals);
		
		forn(j,1,(int)vals.size())res = max(res,vals[j]);
		//for(auto &x : vals)cout << x << ' ';
		//cout << '\n';
		
		Ktmp -= cntPuedo;
		if(Ktmp > 0 && vals.back() > 0){
			forn(j,0,(int)vals.size()){
				ll cicloCompleto = vals.back();
				ll Ktmptmp = Ktmp-j;
				if(Ktmptmp < 0)break;
				ll resTmp = vals[j];
				ll cntCompletos = Ktmptmp/lenCiclo;
				cicloCompleto += ll(cntCompletos)*cicloCompleto;
				resTmp += cicloCompleto;
				res = max(res,resTmp);
				//cout << i << ' ' << j << ' ' << cntCompletos << ' ' << resTmp << '\n';
			}
		}
	}
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0; i < N; ++i) {
        cin >> C[i];
        for (int j = 0; j < M; ++j) {
            cin >> A[i][j];
        }
    }
    ll res = INF;
    for (int bit = 0; bit < (1<<N); ++bit) {
        vector<int> status(M, 0);
        ll money = 0;
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) {
                for (int j = 0; j < M; ++j) {
                    status[j] += A[i][j];
                }
                money += C[i];
            }
        }
        int tmp = 0;
        for (auto&& s : status) {
            if (s >= X) ++tmp;
        }
        if (tmp == M) {
            res = min(res, money);
        }
    }
    if (res != INF) cout << res << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3620
n = int(input())
a = list(map(int, input().split()))
boss_list = []

for i in range(n):
    boss_list.append(0)

for i in range(n-1):
    boss_number = a[i] - 1
    boss_list[boss_number] += 1

for i in range(n):
    print(boss_list[i])

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

int main(){
	int n,a,b,c,d;
  cin>>n;
  a=n/1000;
  b=(n-1000*a)/100;
  c=(n-1000*a-100*b)/10;
  d=n-1000*a-100*b-10*c;  
  if(a==b&&a==c&&c==d)
    cout<<"Yes"<<endl;
  else{
    if(a==b&&a==c||b==c&&c==d)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;    
  }
}

Measured memory_bytes: 256
// Example program
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main()
{
  int scores[6];
  for (int i = 0; i < 6; i++) {
      cin >> scores[i];
  }
  int total = scores[0] + scores[1] + scores[2] + scores[3] + scores[4] + scores[5] - min(scores[0], (min(scores[1], min(scores[2], scores[3])))) - min(scores[4], scores[5]);
  cout << total << endl;
}



Measured memory_bytes: 3088
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

    template <class T, class... Args>
    void impl(T&& v, Args&&... args)
    {
        cout << std::forward<T>(v) << ' ';
        impl(std::forward<Args>(args)...);
    }
    template <class T>
    void impl(T&& v)
    {
        cout << std::forward<T>(v);
    }

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class... Args>
    void operator()(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
        cout << '\n';
    }
    template <class... Args>
    void noreturn(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
    }
};

void prog()
{
    input in;
    output out;

    out(static_cast<char>(in.read<char>() + 1));
}

int main()
{
    prog();
    return 0;
}


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

int main()
{
    string ss;
    int si, s1, s2, s3;

    cin >> ss;
    si = stoi(ss);
    s1 = si / 100;
    s2 = (si - s1 * 100) / 10;
    s3 = (si - s1 * 100 - s2 * 10);
    cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		System.out.println("?a");
		ArrayList<String> list = new ArrayList<String>();
		while(true){
			String s = sc.next();
			if(list.contains(s)==true || s.length()==1 || s.charAt(0)!='a'){
				System.out.println("!OUT");
				break;
			}
			list.add(s);
			s = s.substring(1,2);
			if(s.compareTo("a")==0) s = "aa";
			System.out.println("?" + s + "a");
		}	
	}	
}

Measured memory_bytes: 17376
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  vector<string> S(3);
  FOR(i, 3) cin >> S[i];
  char now = 'a';
  while (S[now - 'a'] != "") {
    char nw = S[now - 'a'][0];
    S[now - 'a'] = S[now - 'a'].substr(1);
    now = nw;
  }
  print(string(1, now + 'A' - 'a'));
  return 0;
}

Measured memory_bytes: 256
from heapq import heappop, heappush
from copy import deepcopy
def main():
    N, M = map(int, input().split())
    INF = 10**9
    to = [[INF]*N for _ in range(N)]
    edges = []
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        to[a][b] = c
        to[b][a] = c
        edges.append((a, b, c))
    
    for i in range(N): to[i][i] = 0

    def floyd_warshall():
        for k in range(N):
            for i in range(N):
                for j in range(N):
                    to[i][j] = min(to[i][j], to[i][k]+to[k][j])
    
    floyd_warshall()
    ans = 0
    for a, b, c in edges:
        if to[a][b] != c:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) { return s + d + t; })
#define all(a) a.begin(), a.end()
#define degrees(a) a * 180.0 / M_PI;
#define radians(a) (a * M_PI) / 180.0;
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);

  int K;
  cin >> K;
  int odd = (K + 1) / 2;
  int even = K / 2;
  cout << odd * even << endl;
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>

using namespace std;

int main() {
	ios_base :: sync_with_stdio(false);
	string s1, s2;
	cin >> s1 >> s2;
	s2.pop_back();
	if (s1 == s2) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
#define MAXN 2010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e9 + 7;

int main (){
    ios_base::sync_with_stdio(false);
    string s;
    int ans = 0, n;
    cin >> s;
    n = s.size();

    for (int i=0; i<n-1; i++){
        if (s[i] != s[i+1]) ans++;
    }

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n;
double num[105];
double tmp;
int main () {
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>num[i];
		tmp+=1/num[i];
	}
	tmp=1/tmp;
	printf("%.5lf\n",tmp);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		System.out.print(s.charAt(0));
		System.out.print(s.length()-2);
		System.out.println(s.charAt(s.length()-1));
	}

}

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

using namespace std;


struct nod {
  int a,b;
} p[100002];

bool cmp (nod a, nod b) {
  return a.a - a.b > b.a - b.b;
}

int n, x, y, z;

long long ans, maxx = -1e18, sum, sp1[100002], sp2[100002];
priority_queue<int,vector<int>,greater<int>> pq;

int main()
{
  cin >> x >> y >> z;
  n = x + y + z;
  for(int i = 1; i <= n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    p[i] = {a - c, b - c};
    ans += c;
  }
  sort(p + 1, p + n + 1, cmp);
  for(int i = 1; i < x; i++) {
    pq.push(p[i].a);
    sum += p[i].a;
  }
  for(int i = x; i <= n;i++) {
    pq.push(p[i].a);
    sum += p[i].a;
    while(pq.size() > x) {sum -= pq.top(); pq.pop();}
    sp1[i] = sum;
  }
  while(!pq.empty()) pq.pop();
  sum = 0;
  for(int i = n - y + 2; i <= n; i++) {
    pq.push(p[i].b), sum += p[i].b;
  }
  for(int i = n - y + 1; i > 0; i--) {
    pq.push(p[i].b), sum += p[i].b;
    while(pq.size() > y) {sum -= pq.top(); pq.pop();}
    sp2[i] = sum;
  }
  for(int i = x; i <= n - y; i++)
    maxx = max(maxx, sp1[i] + sp2[i + 1]);
  cout << maxx + ans;
  return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
 
int main(){
	int i = 0;
	double a[4], b[4];
 
	scanf("%lf %lf %lf", &a[0], &a[1], &a[2]);
 
	if(a[0] == a[1] && a[1] == a[2] && (long long int)a[0] % 2 == 0 && (long long int)a[1] % 2 == 0 && (int long long)a[2] % 2 == 0) {
		printf("-1");
	}

	else {
		while ((long long int)a[0] % 2 == 0 && (long long int)a[1] % 2 == 0 && (int long long)a[2] % 2 == 0) {
		
			b[0] = a[0];
			b[1] = a[1];
			b[2] = a[2];

			a[0] = b[1] / 2 + b[2] / 2;
			a[1] = b[2] / 2 + b[0] / 2;
			a[2] = b[0] / 2 + b[1] / 2;

			i++;
		}
	printf("%d", i);
	}

 
}

Measured memory_bytes: 128
def main():
  n, a, b = map(int, input().split())
  if (b - a) % 2 == 0:
    ans = (b - a)//2
  else:
    ans = min(a-1, n-b) + 1 + (b - a - 1)//2
  print(ans)


if __name__ == '__main__':
  main()


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

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 1e5 + 10;

int A[N];

struct cmp{
	bool operator () (int x, int y){
		return A[x] > A[y];
	}
};

priority_queue<int, vector<int>, cmp> q;
int n, m;

int fa[N];
int find(int x){
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}

bool vis[N];

int main(){

	scanf("%d%d", &n, &m);

	if(n == m + 1){
		puts("0");
		return 0;
	}
		
	For(i, 1, n) scanf("%d", &A[i]), fa[i] = i;
	For(i, 1, n) q.push(i);
	For(i, 1, m){
		int u, v;
		scanf("%d%d", &u, &v);
		++u, ++v;
		fa[find(u)] = find(v);
	}

	long long ans = 0;
	int s = n - m - 2, cnt = 0;

	while(!q.empty()){
		int i = q.top(), o = find(i); q.pop();
		if(vis[o] && cnt < s) ++cnt, ans += A[i];
		else if(!vis[o]) vis[o] = true, ans += A[i];
	}
	
	if(cnt == s) printf("%lld\n", ans);
	else puts("Impossible");

	return 0;
}

Measured memory_bytes: 1660
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	cin >> N >> K;
	string s;
	cin >> s;
	s[K - 1] += 'a' - 'A';
	cout << s << endl;
	return 0;
}


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

using namespace std;

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;*/
    
    const int mod = 1000000007;

    int n,m;cin>>n>>m;
    set<int> s;
    for(int i=0;i<m;i++){
        int a;cin>>a;
        s.insert(a);
    }
    vector<long long> dp(n+1);
    dp[0]=1;
    if(s.find(1)==s.end()){
        dp[1]=1;
    }
    for(int i=2;i<=n;i++){
        if(s.find(i)!=s.end())continue;
        dp[i]=(dp[i-1]+dp[i-2])%mod;
    }
    cout<<dp[n];
    
    /*#ifndef ONLINE_JUDGE
        cout << "\nTime Elapsed : " << 1.0 * clock() << " ms\n";
    #endif*/
    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define MOD 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll n,a,b;
    cin >>n>>a>>b;

    ll ans;
    ll cma= 1;
    rep(i,a){
        cma = (cma*(n-i))%MOD;
    }
    //cout << cma << endl;
    rep(i,a){
        cma = cma*modinv(i+1, MOD) % MOD ;
    }
    //cout << cma << endl;
    ll cmb= 1;
    rep(i,b){
        cmb = (cmb*(n-i))%MOD;
    }
    //cout << cmb << endl;
    rep(i,b){
        cmb = cmb*modinv(i+1, MOD) % MOD ;
    }
    //cout << cmb << endl;
    ans = (modpow(2,n,MOD)-cma-cmb-1)%MOD;
    if(ans<0){
        ans+=MOD;
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3576
#include<stdio.h>
int par[200005];
int root(int n)
{
	if (par[n] != n)
		par[n] = root(par[n]);
	return par[n];
}
void uni(int x, int y)
{
	x = root(x);
	y = root(y);
	if (x != y)
		par[x] = y;
	return;
}
int main()
{
	int n, q;
	scanf("%d %d", &n, &q);
	int i;
	for (i = 0; i < n; i++)
		par[i] = i;
	int t, u, v;
	for (i = 0; i < q; i++)
	{
		scanf("%d %d %d", &t, &u, &v);
		if (t == 0)
			uni(u, v);
		else if (root(u) == root(v))
			printf("1\n");
		else
			printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 2228
#include <iostream>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, a[100008], b[100008], c[100008];

bool compare(vector<ll> a, vector<ll> b){return a[0] > b[0];}

int main() {
	cin >> n;
	vector<vector<ll>> c(n+1, vector<ll>(3));
	
	for(ll i = 1; i <= n; i++){
		cin >> c[i][1] >> c[i][2];
		c[i][0] = c[i][1] + c[i][2];
	}
	
	sort(c.begin()+1, c.end(), compare);
	//for(ll i = 1; i <= 3; i++){cout << c[i][0] << c[i][1] << c[i][2] << endl;}
	
	ll ans = 0;
	for(ll i = 1; i<= n; i++){
		if(i%2 == 1){ans += c[i][1];}
		else{ans -= c[i][2];}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int max = 0;
		int min = 1 << 16;
		int[] num = new int[n];
		for (int i = 0; i < n; i++) {
			int t = scanner.nextInt();
			num[i] = t;
			max = Math.max(max, t);
			min = Math.min(min, t);
		}
		boolean[] b = new boolean[n];
		int[] sortnum = Arrays.copyOf(num, n);
		Arrays.sort(sortnum);
		List<Integer> list = new ArrayList<Integer>();
		for (int t : sortnum)
			list.add(t);
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if(b[i])
				continue;
			int s = 0;
			int an = 0;
			int cur = i;
			int m = max;
			while (true) {
				b[cur] = true;
				an++;
				int v = num[cur];
				m = Math.min(m, v);
				s += v;
				cur = list.indexOf(v);
				if (b[cur])
					break;
			}
			int aa = s + (an - 2) * m;
			int bb = s + m + (an + 1) * min;
			ans += Math.min(aa, bb);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int dx = x2-x1, dy = y2-y1;
    cout << x2-dy << " " << y2+dx << " ";
    cout << x1-dy << " " << y1+dx << endl;
}

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

int main() {
	char ch[1400];
	int count[26];
	for(int i = 0;i < 26;i++)
		count[i] = 0;
	while(cin >> ch){
		for(int i = 0;i < strlen(ch);i++){
			if('a' <= ch[i] - '0' <= 'z'){
				int num = ch[i] - 'a';
				count[num]++;
			}
			if('A' <= ch[i] - '0' <= 'Z'){
				int num = ch[i] - 'A';
				count[num]++;
			}
		}
	}
	for(int i=0; i<26; i++){
        cout << (char)(i + 'a') << " : " << count[i] << endl;
	}
	return 0;
}

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


int main()
{
    long long n;cin>>n;
    long long sum = 0;
    for(long long i=1; i<=n; i++)
    {
        if( i%3 != 0 && i%5 != 0 )
            sum = sum + i;
    }
    cout<<sum;
}

Measured memory_bytes: 3592
#include <cstdio>
using namespace std;
int m=0;
int f(int n)
{
    int temp=1;
    while(n)
    {
		temp=n%10;
		m+=temp;
        n=n/10;
        
    }
    return temp;
}
int main()
{
    int a,num;
    scanf("%d",&a);
    f(a);
    if(a%m==0)
    {
    	printf("Yes");
    }
    else
    {
    	printf("No");
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	double h;
	vector<double> high;
	while(cin>>h){
		high.push_back(h);
	}
	double a=high[0],b=high[0];
	for(int i=0;i<high.size();i++){
		a=max(a,high[i]);
		b=min(b,high[i]);
	}
	cout<<a-b<<endl;
	return 0;
}

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

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define all(x) x.begin(),x.end()

const int INF=INT_MAX;
const ld PI=acos(-1);//3.1415926535897932384626433
const ld E=2.71828183;
const int MOD=1e9+7;

vi bfs(vector<vi>adj,int src){
    //adjacency list, not-weighted, possibly directed ,src is 1-indexed, adj[0].size()=0!!!
    //for n vertices, adj.size()=n+1. (constructed via push_back() ).

    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return dst;
}
vi bfsParents(vector<vi>adj,int src){
    vi parents=vi(adj.size(),INF);
    parents[src]=-1;
    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                parents[nbr]=c;
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return parents;
}
vi shortestPath(vector<vi>adj,int src,int dst){
    vi bfsParetns=bfsParents(adj,src);
    vi ans;
    while(src!=dst){
        if(bfsParetns[src]==INF)
            return {};
        ans.push_back(src);
        src=bfsParetns[src];
    }
    return ans;
}
int powMod(int base,int exp,int mod){
    //(base^exp) %mod
    int ans=1;
    for(int i=0; i<exp; i++)
        ans=((ans%mod)*(base%mod))%mod;
    return ans;
}
vi divisorsOf(int n){
    //vector of divisors of n (inc. 1 , excl.n)
    vi ans;
    for(int i=1; i*i<=n; i++){
        if(n%i==0)
            ans.push_back(i);
        if(i*i!=n && i!=1)
            ans.push_back(n/i);
    }
    return ans;
}
int gcd(int a,int b){
    if(a%b==0)
        return b;
    else
        return gcd(b,a%b);
}

ld log (ld a,ld b){return log(b)/log(a);}
ll power(ll base, ll exp){
    ll res=1;
    while(exp){
        exp--;
        res*=base;
    }
    return res;
}
void solve();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
        solve();
    return 0;
}
void solve (){
    int n,k;
    cin >> n >> k;
    vi v(n);
    for(int i=0; i<n; i++)
        cin >> v[i];
    sort(all(v));
    int sum=0;
    for(int i=0; i<k; i++)
        sum+=v[i];
    cout << sum << "\n";

}

Measured memory_bytes: 3628
fun solve(H:Int, N:Int, As:List<Int>) {
    var ans = "No"
    if (As.sum() >= H) {
        ans = "Yes"
    }
    println(ans)
}

fun main() {
//    val S = readLine()!!
//    val N = readLine()!!.toInt()
    val (H, N) = readLine()!!.split(" ").map { it.toInt() }
    val As = readLine()!!.split(" ").map { it.toInt() }
    solve(H, N, As)
}

Measured memory_bytes: 50784
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <cstdio>
#include <algorithm>

using namespace std;

/**
 * main
 */
int main () {
  int A, B, C, D;
  scanf("%d %d %d %d", &A, &B, &C, &D);
  int left = max(A, C);
  int right = min(B, D);
  printf("%d\n", (left < right) ? right - left : 0);
}


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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(int64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

// 最小公倍数lcm=m*n/gcd
uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// nCm
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

signed main() {
  int64_t q, t, f;
  string s = "";
  cin >> s;
  
  while(s.length()>=2){
    string head = s.substr(0,2);
    s = s.substr(2,s.length()-2);
    if(head.compare("hi")!=0){
  cout << "No" << endl;

      return 0;
    }
  }
  if(s.length()==0){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int x,y,w;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0 && y==0)break;
		if(x>y){
			w=x;
			x=y;
			y=w;
		}
		printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 1776
#include <stdio.h>

int main(void)
{
  	int N=0;
  	int N1=0,N2=0,N3=0;
  
  	scanf("%d",&N);
  	N1=N/100;
  	N2=(N%100)/10;
  	N3=(N%100)%10;
  
  	if(N1==7){
    puts("Yes");
    }else if(N2==7){
    puts("Yes");
    }else if(N3==7){
    puts("Yes");
    }else{
    puts("No");
    }
  
  	return 0;
  
}


Measured memory_bytes: 2080
#include <stdio.h>

int main(void)
{
	int i, n, a, b, c1, c2;
	
	while (scanf("%d", &n), n != 0){
		a = 0;
		b = 0;
		
		for (i = 0; i < n; i++){
			scanf("%d %d", &c1, &c2);
			
			if (c1 > c2){
				a += c1 + c2;
			}
			else if (c1 < c2){
				b += c1 + c2;
			}
			else {
				a += c1;
				b += c2;
			}
		}
		
		printf("%d %d\n", a, b);
		
	}
	
	return (0);
}

Measured memory_bytes: 600
let [| total; usedCount |] = stdin.ReadLine().Split() |> Array.map int
let candles = stdin.ReadLine().Split() |> Array.map int

//let distance sortedCandles =
//    min (sortedCandles |> Array.head |> abs) (sortedCandles |> Array.last |> abs)
//    |> (+) ((sortedCandles |> Array.head) - (sortedCandles |> Array.last) |> abs)
let distance (head,last) =
    min (head |> abs) (last |> abs)
    |> (+) (last-head |> abs)

// 配列のコピーにコストがかかっているように思われるので、配列に直にアクセスする
let headLastIPairs =
    [| for i in usedCount-1..total-1 -> i - (usedCount-1), i |]

headLastIPairs
|> Seq.map (fun (i1,i2) -> candles.[i1],candles.[i2])
//|> Seq.windowed usedCount
|> Seq.map distance
|> Seq.min
|> stdout.WriteLine

Measured memory_bytes: 31452
n = int(input())
botan = [int(input()) for i in range(n)]
light = 0 # 1番目のボタンが初め光ってる
count = 0

for i in range(n):
    light = botan[light] - 1
    if light == 1:
        break
    
if i == n - 1:
    print(-1)
else:
    print(i + 1)

Measured memory_bytes: 7084
#include <stdio.h>

int main()
{
  int t[10] ,x , n=0;
  while(scanf("%d", &x) != EOF)
    {
      if(x != 0)
        {
          t[n] = x;
          n++;
        }
      else
        {
          printf("%d\n", t[n-1]);
          n--;
        }
    }
  return 0;
}

Measured memory_bytes: 600
fun main(args: Array<String>) {
    val (n, a, b, c) = readLine()!!.split(" ").map { it.toInt() }
    var ln = mutableListOf<Int>()
    for (i in 1..n){
        val j = readLine()!!.toInt()
        ln.add(j)
    }
    println(dfs(0, 0, 0, 0, n, a, b, c, ln))
}

fun dfs(cur: Int, tmp_a: Int, tmp_b: Int, tmp_c: Int, n: Int, a: Int, b: Int, c: Int, ln: List<Int>): Int {
    if (cur == n) {
        if (listOf<Int>(tmp_a, tmp_b, tmp_c).min()!! > 0) {
            return Math.abs(tmp_a - a) + Math.abs(tmp_b - b) + Math.abs(tmp_c - c) - 30
        } else {
            return 100000000
        }
    } else {
        val ret0 = dfs(cur + 1, tmp_a, tmp_b, tmp_c, n, a, b, c, ln)
        val ret1 = dfs(cur + 1, tmp_a + ln[cur], tmp_b, tmp_c, n, a, b, c, ln) + 10
        val ret2 = dfs(cur + 1, tmp_a, tmp_b + ln[cur], tmp_c, n, a, b, c, ln) + 10
        val ret3 = dfs(cur + 1, tmp_a, tmp_b, tmp_c + ln[cur], n, a, b, c, ln) + 10
        return listOf<Int>(ret0, ret1, ret2, ret3).min()!!
    }
}


Measured memory_bytes: 46912
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      m: usize,
   }
   let ans = match (n, m) {
      (1, 1) => 1,
      (1, _) => m-2,
      (_, 1) => n-2,
      (2, _) => 0,
      (_, 2) => 0,
      _ => (n-2)*(m-2),
   };
   println!("{}", ans);
}


Measured memory_bytes: 4352