akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

ll func(ll n) {
	return n * (n - 1) / 2;
}

void solve() {
	ll n;
	cin >> n;
	vector<ll> v(n);
	rep(i,n) cin >> v[i];
	map<ll, ll> mp;
	rep(i,n) mp[v[i]]++;
	ll sum = 0;
	for (auto p: mp) sum += func(p.second);
	rep(i,n) {
		ll m = mp[v[i]];
		cout << sum - func(m) + func(m - 1) << endl;
	} 
}

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

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

long long x,y,a,b,c,tmp,a1,b1,c1,ans;

int main(){
    cin>>x>>y>>a>>b>>c;
    vector<long long> p;
    vector<long long> q;
    vector<long long> r;
    for(long long i=0;i<a;i++){
        cin>>tmp;
        p.push_back(tmp);
    }
    for(long long i=0;i<b;i++){
        cin>>tmp;
        q.push_back(tmp);
    }
    for(long long i=0;i<c;i++){
        cin>>tmp;
        r.push_back(tmp);
    }
    sort(p.begin(),p.end(),greater<long long>());
    sort(q.begin(),q.end(),greater<long long>());
    sort(r.begin(),r.end(),greater<long long>());
    //for(int i=0;i<a;i++)cout<<p[i]<<' ';cout<<endl;
    //for(int i=0;i<b;i++)cout<<q[i]<<' ';cout<<endl;
    //for(int i=0;i<c;i++)cout<<r[i]<<' ';cout<<endl;
    p.insert(p.begin(),2000000000);
    q.insert(q.begin(),2000000000);
    r.insert(r.begin(),2000000000);
    r.push_back(0);
    a1=x;
    b1=y;
    c1=0;
    while(min(p[a1],q[b1])<r[c1+1]){
        if(p[a1]<q[b1]){
            a1--;
            c1++;
        }
        else{
            b1--;
            c1++;
        }
    }
    ans=0;
    for(long long i=1;i<=a1;i++)ans+=p[i];
    for(long long i=1;i<=b1;i++)ans+=q[i];
    for(long long i=1;i<=c1;i++)ans+=r[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 3316
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(int i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N = 1e5 + 5;
const int OO = 1e9 + 7;
using namespace std;
int n, a[N], k;
int dp[N];

int solve(int i) {
    if (i == n - 1) re 0;
    if (i > n - 1) re OO;
    int &res = dp[i];
    if (~res) re res;
    res = abs(a[i + 1] - a[i]) + solve(i + 1);
    if (i < n - 2) {
        forr(j, 2, k) {
            res = min(res, abs(a[i + j] - a[i]) + solve(i + j));
        }
    }
    re res;
}

int main() {
    IO;
    cin >> n >> k;
    rep(i, 0, n) cin >> a[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0);


}



Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
#include <bitset>
#include <numeric>

using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};



int main(){
    int n;
    cin >> n;
    vector<ll> t(n), a(n);
    REP(i, n){
        cin >> t[i] >> a[i];
    }
    ll nt = t[0];
    ll na = a[0];
    FOR(i, 1, n){
        ll tmp = max((nt + t[i] - 1) / t[i], (na + a[i] - 1) / a[i]);
        nt = tmp * t[i];
        na = tmp * a[i];
    }
    cout << nt + na << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
#define BLACK 1
#define WHITE 0

int node[51][51];
int node_color[51];

int N;

void dfs(int node_num) {
    stack<int> S;
    S.push(node_num);
    node_color[node_num] = BLACK;

    while (! S.empty()) {
        int u = S.top();
        S.pop();

        for (int v = 0; v < N; v++) {
            if (node[u][v] == 1 && node_color[v] != BLACK) {
                S.push(v);
                node_color[v] = BLACK;
            }
        }
    }
}

int main() {
    int M, a, b, count = 0;
    cin >> N >> M;

    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        a--; b--;
        node[a][b] = 1;
        node[b][a] = 1;        
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (node[i][j] == 1) {
                for (int k = 0; k < N; k++) node_color[k] = WHITE;
                node[i][j] = 0;
                dfs(0);
                for (int k = 0; k < N; k++) {
                    if (node_color[k] == WHITE) {
                        count++;
                        break;
                    }
                }
                node[i][j] = 1;
            }
        }
    }

    cout << count << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


char buf[5];

int main(){

	scanf("%s",buf);

	if(buf[0] == buf[1] || buf[1] == buf[2] || buf[2] == buf[3]){

		printf("Bad\n");

	}else{

		printf("Good\n");
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
#define mod 1000000007

int ans=mod;
int a[103];
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	int su=0;
	cin>>n;
	f(i,0,n)
	{
		cin>>a[i];
		su+=a[i];
	}
	int bu=0;
	f(i,0,n+1)
	{
		int lu=su-bu;
		ans=min(ans,abs(lu-bu));
		bu+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;


int main() {
	int a, b;

	int i;


	cin >> a >> b;
	if (a < b) {
		for (i = 0; i < b; i++) {
			cout << a;
		}
	}
	else {
		for (i = 0; i < a; i++) {
			cout << b;
		}

	}
	}
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int LIM = 10;

int n;
int p[LIM];

int main(){
    cin >> n;
    int ans = 0;
    for(int i=0; i<n; i++){
        cin >> p[i];
        ans += p[i];
    }
    sort(p, p+n);
    cout << ans - p[n-1]/2 << endl;
    return 0;
}

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

typedef pair<int, int> P;

int N, M;

const int MAX_M = 10000;

int use_pc_num[MAX_M];          // 学生がログインしているPCの数
int use_start_time[MAX_M];      // 学生が現在使用しているPCの中で一番最初にログインした時刻

void solve(){
    int r, q;
    cin >> r;
    // initialize
    for(int i = 0; i < M; i++) use_pc_num[i] = use_start_time[i] = 0;
    vector<P> login_data[MAX_M];
    for(int i = 0; i < r; i++){
        int t, n, m, s;
        cin >> t >> n >> m >> s;
        if(s == 1){
            if(use_pc_num[m - 1]++ == 0) use_start_time[m - 1] = t;
        }else{
            if(use_pc_num[m - 1]-- == 1) login_data[m - 1].push_back(P(use_start_time[m-1], t));
        }
    }

    for(int i = 0; i < M; i++) sort(login_data[i].begin(), login_data[i].end());

    cin >> q;
    for(int i = 0; i < q; i++){
        int ts, te, m, ans = 0;
        cin >> ts >> te >> m;
        for(int i = 0; i < login_data[m - 1].size(); i++){
            P data = login_data[m - 1][i];
            // 重なっていないなら無視
            if(data.second < ts || data.first > te) continue;
            ans += min(te, data.second) - max(ts, data.first);
        }
        cout << ans << endl;
    }
}

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

    while(cin >> N >> M, N | M){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1516
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int dx[] = {0,1,0,-1,1,1,-1,-1};
int dy[] = {1,0,-1,0,-1,1,-1,1};

char ba[8][8];
int dfs(int y, int x, int d, int num) {
  char c = ba[y][x];

  int yy = y+dy[d];
  int xx = x+dx[d];

  if (yy<0||yy>=8||xx<0||xx>=8) return 0;
  if (ba[yy][xx] == c) {
    return dfs(yy,xx,d,num+1);
  } else if (ba[yy][xx] == '.'){
    return 0;
  } else {
    return num;
  }
}
int func(int y, int x, bool mami) {
  int res = 0;
  REP(k,8) {
    int yy = y+dy[k];
    int xx = x+dx[k];

    if (yy<0||yy>=8||xx<0||xx>=8)continue;
    if (mami && ba[yy][xx] == 'x' || !mami && ba[yy][xx] == 'o')
      res += dfs(yy,xx,k,1);
  }
  return res;
}

bool changedfs(int y, int x, int d, char c) {
  int yy = y+dy[d];
  int xx = x+dx[d];

  if (yy<0||yy>=8||xx<0||xx>=8) return 0;

  if (ba[yy][xx] == '.'){
    return 0;
  } if (ba[yy][xx] != c) {
    if (changedfs(yy, xx, d, c)) {
      ba[yy][xx] = c;
      return 1;
    } else {
      return 0;
    }
  } else {
    return 1;
  }
}

void change(int y, int x, char c) {
  REP(k,8) {
    changedfs(y,x,k,c);
  }
}


int main() {

  REP(i, 8) {
    REP(j,8) {
      cin >> ba[i][j];
    }
  }
  bool mami = 1;
  int ct = 0;
  bool f=1;
  while(ct++<100&&f) {
    int x,y,ma = 0;
    f = 0;
    REP(i, 8) {
      REP(j,8) {
        if (ba[i][j] == '.') {
          int tmp = func(i,j,1);
          if (tmp) {
            //printf("%d,%d %d\n",i,j,tmp );
          }
          if (ma < tmp) {
            ma = tmp;
            y = i;
            x = j;
          }
        }
      }
    }
    if (ma) {
      ba[y][x] = 'o';
      change(y,x,'o');
      f = 1;
    }
    // REP(i,8) {
    //   REP(j,8) {
    //     cout << ba[i][j];
    //   }
    //   cout << endl;
    // }
    // cout << endl;
    
    ma = 0;

    for (int i=7; i>=0; --i) {
      for (int j=7; j>=0; --j) {
        if (ba[i][j] == '.') {
          int tmp = func(i,j,0);
          if (tmp) {
//            printf("%d,%d %d\n",i,j,tmp );
          }

          if (ma < tmp) {
            ma = tmp;
            y = i;
            x = j;
          }
        }
      }
    }
    if (ma) {
      f = 1;
      ba[y][x] = 'x';
      change(y,x,'x');
    }

    // REP(i,8) {
    //   REP(j,8) {
    //     cout << ba[i][j];
    //   }
    //   cout << endl;
    // }
    // cout << endl;
  }
  REP(i,8) {
    REP(j,8) {
      cout << ba[i][j];
    }
    cout << endl;
  }
  
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int>
#define pqueue priority_queue
#define rep(a,n) for(int i=(a);i<(n);i++)
#define INF (int)1000000007

//setprecision()<<

using namespace std;

void fin(int n,vin &a){
    rep(0,n){
        cin>>a.at(i);
    }
}

signed main(){
    typedef pair<int,int> P;
    string S;
    cin>>S;
    if(S.at(2)==S.at(3) && S.at(4)==S.at(5)){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
//package com.company;

import java.io.*;
import java.util.*;

public class Main {

    public static class Task {


        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            String[] s = new String[n];
            int[] t = new int[n];
            for (int i = 0; i < n; i++) {
                s[i] = sc.next();
                t[i] = sc.nextInt();
            }
            String x = sc.next();
            for (int i = 0; i < n; i++) {
                if (x.equals(s[i])) {
                    int ss = 0;
                    for (int j = i + 1; j < n; j++) {
                        ss += t[j];
                    }
                    pw.println(ss);
                    return;
                }
            }
        }
    }

    static long TIME_START, TIME_END;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("input"));
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("input"));


        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.err.println("Memory increased: " + (usedMemoryAfter - usedMemoryBefore) / 1000000);
        System.err.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader s) throws FileNotFoundException {
            br = new BufferedReader(s);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

Measured memory_bytes: 20820
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  ll h;
  cin>>h;
  ll t=1,s=0;
  while(h>1){
    h/=2;
    s++;
  }
  rep(i,s){
    t=2*t+1;
  }
  cout<<t<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //d =「最終的に高橋くんが得る幸福度の総和」-「最終的に青木さんが得る幸福度の総和」として
    //高橋君はdを大きくしようとし
    //青木さんはdを小さくしようとする
    int n;
    cin>>n;
    int res=0;
    vector<pair<int,int>> p(n);
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        res-=b;
        p[i].first=a+b;
        p[i].second=a;
    }
    sort(All(p),greater<pair<int,int>>());
    for(int i=0;i<n;i+=2)res+=p[i].first;
    cout<<res<<endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long u64;
ll geti(){
    ll ret=0;char ch=getchar(),k=1;
    while((ch<'0' || ch>'9') && ch!='-')ch=getchar();
    if(ch=='-')k=0,ch=getchar();
    while(ch>='0' && ch<='9')ret=ret*10+ch-'0',ch=getchar();
    return k?ret:-ret;
}
const int N = 2000000;
const int base = 998244353;
ll n,last[27];
char s[N];
int main(){    scanf("%s",s+1); n=strlen(s+1);
    ll ans = 0;
    for(int i=1;i<=n;i+=1) {
        ans += i-last[s[i]-'a']-1;
        last[s[i]-'a']++;
    }
    cout << ans+1;
    return 0;
}


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

int main() {
    int n; cin>>n;
    vector<int> d(n);
    rep(i,n) cin>>d[i];
    sort(d.begin(),d.end());
    cout<<d[n/2]-d[n/2-1]<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
using ull = unsigned long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll MOD3 = 1e6;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<long double,long double> point;
typedef complex<long double> Point;
const ll MAX = 3000;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll s;
    cin >> s;
    ll ans = 0;
    COMinit();
    rep(i,1,1000){
        ll t = s;
        if (t < i*3) continue;
        t -= i*3;
        (ans += COM(t+i-1,i-1))%=MOD;
    }
    PRINT(ans);
}


Measured memory_bytes: 3720
#include <stdio.h>

int main() {
  int n, q, C = 0;
  int S[10000], T[500];
  int i, j;
  
  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", S+i);
    
  scanf("%d", &q);
  for(i = 0; i < q; i++) scanf("%d", T+i);

  for(i = 0; i < q; i++) {
    for(j = 0; j < n; j++) {
      if(T[i] == S[j]) {
	C++;
	break;
      }
    }
  }

  printf("%d\n", C);
  
  return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
using namespace std;
int N,ans;
char s[101];
bool s1[26];
int main(){
	scanf("%d %s",&N,s);
	ans=0;
	int a=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<=i;j++)	s1[s[j]-'a']=true;
		for(int j=i+1;j<N;j++){
			if(s1[s[j]-'a']){
				++a;
				s1[s[j]-'a']=false;
			}
		}
		if(a>ans)	ans=a;
		memset(s1,0,sizeof(s1));
		a=0;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<vector>
#define pb push_back
using namespace std;

int S;
int c[100005],g[100005],a[100005];
vector<int> r[100005];
int l;

int f(int x)
{
    int i,h=0;
    c[x]++;
    for(i=0;i<r[x].size();i++){
        if(c[r[x][i]])continue;
        g[r[x][i]]=x;
        h=max(h,f(r[x][i]));
    }
    h++;
    if(h==l&&g[x]!=1)h=0,S++;
    return h;
}

int main()
{
    int n,i;
    scanf("%d %d", &n, &l);
    for(i=1;i<=n;i++){
        scanf("%d", &a[i]);
    }
    if(a[1]!=1)a[1]=1,S++;
    g[1]=1;
    for(i=1;i<=n;i++){
        r[a[i]].pb(i);
    }
    f(1);
    printf("%d", S);
    return 0;
}


Measured memory_bytes: 13184
n = int(input())
for i in range(1, n + 1):
    if i % 3 == 0:
        print(" {}".format(i), end="")
        continue

    x = i
    while x > 0:
        if x % 10 == 3:
            print(" {}".format(i), end="")
            break
        else:
            x //= 10
print()



Measured memory_bytes: 5872
#include<stdio.h>
#define N 100

int main(){
  int n,i,j,k,l,d;
  int A[N+1], B[N+1], C[N+1][N+1];

  scanf("%d",&n);

  for(i = 1 ; i <= n ; i++){
    scanf("%d%d",&A[i],&B[i]);
  }

  for(i =1;i<=n;i++) C[i][i] = 0;

  for(l=2;l<=n;l++){
    for(i = 1 ; i <= n - l + 1 ; i++){
      j = i + l - 1;
      C[i][j] = 1000000000;
      for(k = i ; k <=  j - 1 ; k++){
	d = C[i][k] + C[k+1][j] + A[i] * B[k] * B[j];
	if(C[i][j] > d) C[i][j] = d;
      }
    }
  }

  printf("%d\n",C[1][n]);

  return 0;
}



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

using namespace std;

typedef long long ll;
const int maxn = (int) 1e5 + 1;

int n, m;
int ans;
int main(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        for(int j = 2; j * j <= i; j++){
            if(i % j == 0){
                if(i / j > 9){
                    continue;
                }
                int c = j * 10 + i / j;
                if(c <= m){
                    ans++;
                }
                int h = (i / j) * 10 + j;
                if(h <= m && c != h){
                    ans++;
                }
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
plus = dict()
minus = dict()
for i in range(n):
  num = i+1
  p = a[i] + num
  m = num - a[i]
  if p in plus:
    plus[p] += 1
  else:
    plus[p] = 1
  if (m) in minus:
    minus[m] += 1
  else:
    minus[m] = 1
c = 0
for v in plus.keys():
  if v in minus:
    c += plus[v] * minus[v]
print(c)

Measured memory_bytes: 56656
#include<bits/stdc++.h>
using namespace std;
int a[1000000+500];
int main(){
	int n;
	cin>>n;
	int cnt=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(!i){
			cnt+=a[i];
		}
		else if(a[i]>a[i-1])
			cnt+=a[i]-a[i-1];
	}
	cout<<cnt<<endl; 
}

Measured memory_bytes: 256
// Created by new_sm
//
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
string s,t;
cin>>s>>t;
int n=size(s);
int cnt=0;
for(int i=0;i<n;i++)
{
	if(s[i]!=t[i])
	cnt++;
}
cout<<cnt;
}
int main()
{
//code

fastio
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}



Measured memory_bytes: 3748
import java.util.*;

public class Main {
    static double result = 0;
    static int count = 0;
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int N = input.nextInt();
        int[][] arr = new int[N][2];

        for (int i = 0; i < N; i++) {
            arr[i] = new int[] {input.nextInt(), input.nextInt()};
        }
        perm(arr, new boolean[N], 0, 0, null);
        System.out.println(result/count);
    }

    static void perm(int[][] arr, boolean[] bt, double sum, int cNum, int[] prev) {
        if (cNum == arr.length) {
            result += sum;
            count++;
        }

        for (int i = 0; i < arr.length; i++) {
            if (!bt[i]) {
                bt[i] = true;
                if (cNum == 0 && prev == null) perm(arr, bt, sum, cNum+1, arr[i]);
                else perm(arr, bt, sum + distance(prev, arr[i]), cNum+1, arr[i]);
                bt[i] = false;
            }
        }
    }

    public static double distance(int[] p1, int[] p2){
        return Math.sqrt(Math.pow(Math.abs(p1[0] - p2[0]), 2) + Math.pow(Math.abs(p1[1] - p2[1]), 2));
    }
}

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

int main() {
  std::string x(4, ' ');
  scanf("%s", &x[0], x.size());
  int cnt = 0;
  for (int i = 0; i < 4; i++) {
    if (x[i] == '+')
      cnt++;
    else
      cnt--;
  }
  printf("%d", cnt);
}


Measured memory_bytes: 256
import numpy as np

h,w=map(int,input().split())
s=[list(input()) for i in range(h)]

s=np.array(s)
s=np.where(s=='.',1,0)

L=np.zeros((h,w),dtype=np.int)
R=np.zeros((h,w),dtype=np.int)
U=np.zeros((h,w),dtype=np.int)
D=np.zeros((h,w),dtype=np.int)

for i in range(w):
 L[:,i]=(L[:,i-1]+1)*s[:,i]
 R[:,-i-1]=(R[:,-i]+1)*s[:,-i-1]
for i in range(h):
 U[i]=(U[i-1]+1)*s[i]
 D[-i-1]=(D[-i]+1)*s[-i-1]

ans=np.max(L+R+U+D)-3
print(ans)

Measured memory_bytes: 250920
import java.util.*;
 
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    char[]n = N.toCharArray();
    
    int al = 0;
    int all = 0;
    for(int i=0; i<N.length(); i++){
        al += n[i];
        all = al - 48*N.length();
}
    int num = Integer.parseInt(N);

    if(num%all==0){
    System.out.println("Yes");
    }else{
    System.out.println("No");
    }
    }        
}

Measured memory_bytes: 35644
#include <stdio.h>

int main(){
	int n,m, i,j;
	scanf("%d %d", &n, &m);
	
	int a[100][100], b[100], c[100] = {0};
	for (i = 0;i < n; i++){
		for (j = 0;j < m; j++){
			scanf("%d", &a[i][j]);
		}
	}
	for (i = 0;i < m; i++){
		scanf("%d", &b[i]);
	}
	
	for (i = 0; i < n; i++){
		for (j = 0;j < m; j++){
			c[i] += a[i][j] * b[j];
		}
		printf("%d\n", c[i]);	
	}
	
	return 0;	
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a < b)
	{
		if (b < c) printf("Yes\n");
		else printf("No\n");
	}
	else printf("No\n");
	return 0;
}

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

int main()
{
    int n, x;
    while(1)
    {
        cin >> n >> x;
        if(n == 0 && x == 0)break;
        int count = 0;
        for(int i = 0; i < n-2; i++)
        {
            for (int j = i+1; j < n-1; j++)
            {
                for (int k = j+1; k < n; k++)
                {
                    if(i + j + k == x-3)count ++;
                }

            }

        }
        cout << count << endl;
    }
}


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

int main()
{
    int n;
    cin >> n;
    std::vector<int> a;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    std::sort(a.begin(), a.end());
    
    int sum = 0;
    for(int i=0; i<n; i++){
        int val = a[i];
        bool isPrime = true;
        for(int j=2; j<=std::sqrt(val); j++){
            //cout << val << " % " << j << endl;
            if(val%j == 0){
                isPrime = false;
                break;
            }
        }
        if(isPrime == true){
            //cout << val << " is Prime" << endl;
            sum++;
        }
    }

    cout << sum << endl;
   
}


Measured memory_bytes: 3152
# WIP
N, M = map(int, input().split())

if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M - 2 if M > 2 else 0)
elif M == 1:
    print(N - 2 if N > 2 else 0)
elif N > 2 and M > 2:
    print((N - 2) * (M - 2))
else:
    print(0)

"""
# An experiment
n_count_map = [[0 for _ in range(M)] for _ in range(N)]


def update(x, y):
    # Count
    n_count_map[y][x] += 1
    if y + 1 < N:
        n_count_map[y + 1][x] += 1
    if y - 1 >= 0:
        n_count_map[y - 1][x] += 1
    if x + 1 < M:
        n_count_map[y][x + 1] += 1
    if x - 1 >= 0:
        n_count_map[y][x - 1] += 1
    if y + 1 < N and x + 1 < M:
        n_count_map[y + 1][x + 1] += 1
    if y - 1 >= 0 and x - 1 >= 0:
        n_count_map[y - 1][x - 1] += 1
    if y + 1 < N and x - 1 >= 0:
        n_count_map[y + 1][x - 1] += 1
    if y - 1 >= 0 and x + 1 < M:
        n_count_map[y - 1][x + 1] += 1


for n in range(N):
    for m in range(M):
        update(m, n)

print(n_count_map)
"""


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll a,b,n,x;
    cin >> a >> b >> n;
    x = min(b-1,n);
    cout << (ll)floor( (a*x)/b) << endl;
}

Measured memory_bytes: 3660
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int main() {
	int n;
	string str;
	cin >> n >> str;
	int r = 0, b = 0;
	REP(i, n) {
		if (str[i] == 'R')r++;
		else b++;
	}
	if (r > b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
  int r,c;
  cin >> r >> c;
  int x[r][c];
  int sum_r[r] = {0};
  int sum_c[c] = {0};
  int sum = 0;
  REP(i,r) {
    REP(j,c) {
      cin >> x[i][j];
      sum_r[i] += x[i][j];
      sum_c[j] += x[i][j];
      sum += x[i][j];
    }
  }
  REP(i,r) {
    REP(j,c) {
      cout << x[i][j] << " ";
    }
    cout << sum_r[i] <<endl;
  }
  REP(i,c) {
    cout << sum_c[i] << " ";
  }
    cout << sum << endl;
  
  return 0;
}



Measured memory_bytes: 3128
function f(use, x, n, acc) {
    if (x > n) return acc;
    if (use === 0b111) acc += 1;
    acc += f(use | 0b001, x * 10 + 3, n, 0);
    acc += f(use | 0b010, x * 10 + 5, n, 0);
   acc += f(use | 0b100, x * 10 + 7, n, 0);
    return acc;
  }

  function Main(input) {
    var n = parseInt(input);
    console.log(f(0, 0, n, 0));
  }

  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 8652
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k>0){
        if(k%2==1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k/=2;
    }
    return ans;
}
ll inv(ll a){
	return powmod(a, MOD-2);
}
int main()
{
	int h, w, K;
	cin>>h>>w>>K;
	ll dp[8][101]={};
	K--;
	ll ct[9]={};
	ct[0]=ct[1]=1;
	ll f[9];
	f[0]=1;
	for(ll i=1; i<=w; i++) f[i]=f[i-1]*i%MOD;
	ll invf[9];
	invf[w]=inv(f[w]);
	for(ll i=w-1; i>=0; i--){
		invf[i]=invf[i+1]*(i+1)%MOD;
	}
	for(int i=1; i<w; i++){
		ct[i+1]=(ct[i]+ct[i-1])%MOD;
	}
	dp[0][0]=1;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			ll c=ct[w];
			if(j>0){
				ll c1=ct[j-1], c2=ct[w-j-1];
				c-=(c1*c2);
				dp[j-1][i+1]+=(dp[j][i]*c1*c2);
				dp[j-1][i+1]%=MOD;
			}
			if(j<w-1){
				ll c1=ct[j], c2=ct[w-j-2];
				c-=(c1*c2);
				dp[j+1][i+1]+=(dp[j][i]*c1*c2);
				dp[j+1][i+1]%=MOD;
			}
			dp[j][i+1]+=(dp[j][i]*c);
			dp[j][i+1]%=MOD;
		}
	}
	cout<<dp[K][h]<<endl;
	return 0;
}

Measured memory_bytes: 256
n,m,p = map(int,input().split())
graph = [[] for _ in range(n)]
INF = float("inf")
dist = [INF]*n
dist[0] = 0

for _ in range(m):
	f,t,c = map(int,input().split())
	graph[f-1].append((t-1,p-c))
#print(graph)

for _ in range(n):
	update = False
	for f,e in enumerate(graph):
		for t,c in e:
			if dist[f] != INF and dist[t] > dist[f] + c:
				dist[t] = dist[f] + c
				update = True
	if not update:
		break
else:
	prev = dist[-1]
	for _ in range(n):
		update = False
		for f,e in enumerate(graph):
			for t,c in e:
				if dist[f] != INF and dist[t] > dist[f] + c:
					dist[t] = dist[f] + c
					update = True
		if not update:
			break
	if dist[-1] != prev:
		print(-1)
		exit()
#print(dist)

print(max(0,dist[-1]*(-1)))

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

int main() {
  int N;
  cin>>N;
  vector<int> p={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
  vector<int> q(15);
  for(int i=0;i<15;i++){
    int X=p.at(i);
    while(N>=X){
      q.at(i)+=N/X;
      X*=p.at(i);
    }
  }
  int A=0,B=0,C=0,D=0,E=0;
  for(int i=0;i<15;i++){
    if(q.at(i)>=74){
      E++;
    }
    if(q.at(i)>=24){
      D++;
    }
    if(q.at(i)>=14){
      C++;
    }
    if(q.at(i)>=4){
      B++;
    }
    if(q.at(i)>=2){
      A++;
    }
  }
  cout<<E+B*(B-1)*(A-2)/2+C*(B-1)+D*(A-1)<<endl;
  
}

Measured memory_bytes: 256
#!/usr/bin/env python3

s = input()
d = {'a': 0, 'b': 0, 'c': 0}
for i in s:
    d[i] += 1

# print(d)

if ((d['a']==d['b'] and d['b']==d['c']) or \
    (d['a']==d['b']+1 and d['b']==d['c']) or \
    (d['b']==d['a']+1 and d['a']==d['c']) or \
    (d['c']==d['a']+1 and d['a']==d['b']) or \
    (d['a']==d['b'] and d['a']==d['c']+1) or \
    (d['a']==d['c'] and d['a']==d['b']+1) or \
    (d['b']==d['c'] and d['b']==d['a']+1)):
    print('YES')
else:
    print('NO')


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()

int main() {
    int H, W, N;
    cin >> H >> W;
    cin >> N;
    int A[N];
    REP(i, N) {
        cin >> A[i];
    }
    int index = 0;
    int res[H][W];
    REP(i, H) {
        if(i%2) {
            for(int j = 0;j < W;j++) {
                if(A[index] == 0) {
                    index++;
                }
                res[i][j] = index + 1;
                A[index]--;
            }
        }else{
            for(int j = W - 1;0 <= j;j--) {
                if(A[index] == 0) {
                    index++;
                }
                res[i][j] = index + 1;
                A[index]--;
            }
        }
    }
    REP(i, H) {
        REP(j, W) {
            cout << res[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define endl '\n';

#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 {
#ifndef 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__) << "] "

const int mod = 1000000000 + 7;

void solve() {
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	for (int &i : v) cin >> i;
	sort(v.begin(), v.end());
	int sum = 0;
	for (int i = 0; i < k; i++) sum += v[i];
	cout << sum << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}


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

const int N = 10010;

int a[N];

int main(){
    srand((unsigned) time(NULL));
    int n;
    scanf("%d", &n);
    int gcd = 0;
    for (int i = n; i >= 0; -- i){
        scanf("%d", &a[i]);
    }
    for (int i = n; i >= 0; -- i){
        gcd = std::__gcd(gcd, a[i]);
    }
    gcd = std::abs(gcd);
    std::set <int> ans;
    for (int i = 2; i * i <= gcd; ++ i){
        if (gcd % i == 0){
            ans.insert(i);
            while (gcd % i == 0){
                gcd /= i;
            }
        }
    }
    if (gcd > 1){
        ans.insert(gcd);
    }
    std::vector <int> possible;
    if (a[0]){
        gcd = std::abs(a[0]);
        for (int i = 2; i * i <= gcd; ++ i){
            if (gcd % i == 0){
                if (i < N) {
                    possible.push_back(i);
                }
                while (gcd % i == 0){
                    gcd /= i;
                }
            }
        }
        if (gcd > 1 && gcd < N){
            possible.push_back(gcd);
        }
    }
    else{
        for (int i = 2; i < N; ++ i) {
            bool flag = true;
            for (int j = 2; j * j <= i; ++j) {
                if (i % j == 0) {
                    flag = false;
                    break;
                }
            }
            if (!flag) {
                continue;
            }
            possible.push_back(i);
        }
    }
    for (auto i : possible){
        if (ans.count(i)){
            continue;
        }
        std::vector <int> vec(i);
        for (int j = 0; j < i; ++ j){
            vec[j] = j;
        }
        std::random_shuffle(vec.begin(), vec.end());
        bool flag = true;
        for (auto u : vec){
            int sum = 0;
            for (int j = n; j >= 0; -- j){
                sum = (sum * u + a[j]) % i;
            }
            if (sum){
                flag = false;
                break;
            }
        }
        if (flag){
            ans.insert(i);
        }
    }
    for (auto u : ans){
        printf("%d\n", u);
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
template<class T> inline bool chmax(T& a, 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 1; } return 0; }

int main() {
    int N;
    cin >> N;
    cout << 2*N/__gcd(2,N) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int N;
    cin >> N;
    ll B[N-1];
    for(int i=0;i<N-1;i++)
        cin >> B[i];

    ll A[N], ans = 0;
    A[0] = B[0];
    ans += A[0];
    for(int i=1;i<N;i++){
        if(i<N-1)
            A[i] = min(B[i-1], B[i]);
        else
            A[i] = B[i-1];
        ans += A[i];
    }

    cout << ans << endl;

}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}
void solve(){
    ll a,b;
    cin>>a>>b;
    cout<<(a<=b?"unsafe":"safe")<<en;
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    if (65<=N&&N<91){
        cout<<"1"<<endl;
        
    }else if ( 96 <N&& N<123){
        cout<<"2"<<endl;
        
    }else{
        cout<<"0"<<endl;
    }
}


Measured memory_bytes: 3104
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0;i<(n);i++)

int cmpint(const void *a,const void *b){
  return *(int *)b-*(int *)a;
}

int main(){
  int n;
  int a[100];
  scanf("%d",&n);
  rep(i,n){
    scanf("%d",&a[i]);
  }
  qsort(a,n,sizeof(a[0]),cmpint);
  int alice=0;
  int bob=0;
  rep(i,n){
    if(i%2==0){
      alice+=a[i];
    }else{
      bob+=a[i];
    }
  }
  printf("%d\n",alice-bob);
  return 0;
}


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

using namespace std;

int Compare(const string &a, const string &b)
{
    if (a.size() != b.size()) {
        return a.size() < b.size() ? -1 : 1;
    }

    for (size_t i = 0; i < a.size(); i += 1) {
        if (a[i] != b[i]) {
            return a[i] < b[i] ? -1 : 1;
        }
    }
    return 0;
}

int main()
{
    string a, b;
    getline(cin, a);
    getline(cin, b);

    auto cmp = Compare(a, b);
    if (cmp > 0) {
        cout << "GREATER\n";
    } else if (cmp == 0) {
        cout << "EQUAL\n";
    } else {
        cout << "LESS\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
 
using namespace std;
 
#define li long long int
#define ld long double
const int MX1=1e5+5;
const int MX2=1e6+5;
const li inf=1e18;
const li mod=1e9+7;
 
li power(li a,li b){li res=1;while(b){if(b%2)res=(res*a)%mod;
a=(a*a)%mod;b/=2;}return res;}
 
li mmi(li a){return power(a,mod-2);}
 
li cntbit(li n){li cnt=0;while(n){n&=(n-1);cnt++;}return cnt;}

li x,y;

void solve(){
	cin>>x>>y;
	if(x%y==0){
		cout<<"-1";
	}else{
		cout<<(y+1)*x;
	}
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256