akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
 
#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define PER(i, N) for(int (i) = (N)-1; (i) >= 0; (i)--)
#define REP(i, N) for(int (i) = 0; (i) < (int)(N); (i)++)
 
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

ll n,k;

ll cnt(vector<int> rs, vector<int> gs, vector<int> bs, set<int> bsSet) {
	ll ans= 0;
	REP(r, rs.size()) {
		REP(g, gs.size()) {
			int i = rs[r], j = gs[g];
			if(j < i)
				continue;
			int diff= j-i;
			int atleast = j+1;
			auto it = lower_bound(bs.begin(), bs.end(), atleast);
			ans += bs.end()-it;
			if(bsSet.count(diff+j)) {
				ans--;
			}
		}
	}
	return ans;
}

void solve(istream& cin, ostream& cout) {
	cin >> n;
	string S;
	cin >> S;
	vector<int> rs,bs,gs;
	set<int> rsSet;
	set<int> gsSet;
	set<int> bsSet;
	REP(i, n) {
		if(S[i]== 'R'){
			rs.pb(i);
			rsSet.insert(i);
		} else if(S[i] == 'G') {
			gs.pb(i);
			gsSet.insert(i);
		} else {
			bs.pb(i);
			bsSet.insert(i);
		}
	}
	ll ans = cnt(rs, bs, gs, gsSet)+cnt(rs,gs,bs,bsSet)+cnt(gs,rs,bs,bsSet)+cnt(gs,bs,rs,rsSet)+cnt(bs,rs,gs,gsSet)+cnt(bs,gs,rs,rsSet);
	cout << ans<<endl;
}


int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	solve(cin, cout);
	/*
	{
		istringstream instr("2\n2\n14");
		solve(instr, cout);
	}
 */
	return 0;
}


Measured memory_bytes: 4364
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

void calc_plus(long long &sum,long long &cost,long long &a){
	cost+=(1-sum);
	a+=cost;
	sum=1;
}

void calc_minus(long long &sum,long long &cost,long long &a){
	cost+=(sum-(-1));
	a-=cost;
	sum=-1;
}

int main(){
	long long n;
	cin >> n;
	vector<long long> a(n,0),b(n,0),c(n,0);
	
	for(long long i=0;i<n;i++){
		cin >> a[i];
		c[i]=b[i]=a[i];
	}
	//+-+-
	long long cost_p=0,sum_p=0;
	for(long long i=0;i<n;i++){
		sum_p+=b[i];
		//1,3,5・・・奇数を１にする
		if(i%2==0){
			if(sum_p<0)calc_plus(sum_p,cost_p,b[i]);
		}
		//2,4,6・・・偶数を-１にする
		if(i%2==1){
			if(sum_p>0)calc_minus(sum_p,cost_p,b[i]);
		}
		//丁度0になった場合
		if(sum_p==0){
			cost_p++;
			if(i%2==0){
				sum_p=1;
				b[i]++;
			}else{
				sum_p=-1;
				b[i]--;
			}
		}
	}
	//-+-+
	long long cost_m=0,sum_m=0;
	for(long long i=0;i<n;i++){
		sum_m+=c[i];
		//1,3,5・・・奇数を-１にする
		if(i%2==0){
			if(sum_m>0)calc_minus(sum_m,cost_m,c[i]);
		}
		//2,4,6・・・偶数を１にする
		if(i%2==1){
			if(sum_m<0)calc_plus(sum_m,cost_m,c[i]);
		}
		//丁度0になった場合
		if(sum_m==0){
			cost_m++;
			if(i%2==0){
				sum_m=-1;
				c[i]--;
			}else{
				sum_m=1;
				c[i]++;
			}
		}
	}
	long long ans=min(cost_p,cost_m);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    ll h,w;
    cin >> h >> w;
    ll ans = h * w;
    for(ll i=0;i<2;i++){
        for(ll j=1;j<h;j++){
            ll s1,s2,s3;
            s1 = w * j;
            s2 = w * ((h-j)/2);
            s3 = w*h - s1 - s2;
            ans = min(ans,max({s1,s2,s3}) - min({s1,s2,s3}));

            s1 = w * j;
            s2 = (h-j) * (w/2);
            s3 = w*h - s1 - s2;
            ans = min(ans,max({s1,s2,s3}) - min({s1,s2,s3}));

        }
        swap(h,w);
    }
    cout << ans << endl;
    return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
 int n , m ;
  cin >> n >> m ;
  int ans = 0;
  
  ans += (n*(n-1))/2 ;
  ans += (m*(m-1))/2 ;
  
  cout << ans ;


}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long long int A, B, C;
    cin >> A >> B >> C;
    long long int AA = 0;
    bool ans = false;
    while (true) {
        AA += A;
        if (AA % B == C) {
            ans = true;
            break;
        }
        if (AA % B == 0) {
            break;
        }
    }
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}

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

int main(){
	string s;
	bool f=false;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(i%2==0&&s[i]=='L'){
			f=true;
		}else if(i%2==1&&s[i]=='R'){
			f=true;
		}
	}
	if(f==true){
		cout<<"No"<<endl;
	}
	else{
				cout<<"Yes"<<endl;
	}
		

   return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int L = sc.nextInt();
		int R = sc.nextInt();

		sc.close();

		R = Math.min(L + 2019, R);

		int ans = Integer.MAX_VALUE;
		for(int x=L;x<R;x++) {
			for(int y=x+1;y<=R;y++) {
				if(x==y)continue;
				
				int m = (int)(((long)x * y) % 2019);
				ans = Math.min(ans, m);
			}
		}
		out.println(ans);

	}

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


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
    v1 a(1001, 0);
    for(int i = 1; i <1001; i++){
        a[i] = a[i-1] + i;
    }
    int n, k;
    cin >> n >> k;
    vector<double> q(n+1, 0);
    q[0] = 0;
    for(int i = 1; i<=n; i++){
        int p; 
        cin >> p;
        double sum = static_cast<double>(a[p]) / static_cast<double>(p) + q[i-1];
        q[i] = sum;
    }
    int j = 0;
    double ans = 0;
    for(int i = k; i <= n; i++){
        ans = max(ans, q[i]-q[j]);
        j++;
    }
    cout <<fixed << setprecision(15) <<  ans << endl;


}

Measured memory_bytes: 4768
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <cmath>
#include <cstdint>

#include <queue>
using namespace std;

inline namespace atcoder {
    using i32 = int32_t; using u32 = uint32_t;
    using i64 = int64_t; using u64 = uint64_t;
    using f32 = float; using f64 = double;

    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;
}

int main() {
    int n, m, k; cin >> n >> m >> k;
    vvec<int> friends(n), blocks(n);
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        friends[a - 1].push_back(b - 1);
        friends[b - 1].push_back(a - 1);
    }
    for (int i = 0; i < k; ++i) {
        int c, d; cin >> c >> d;
        blocks[c - 1].push_back(d - 1);
        blocks[d - 1].push_back(c - 1);
    }

    vec<int> fgroup, findex(n, -1);
    for (int i = 0; i < n; ++i) {
        if (findex[i] != -1) continue;
        int cidx = fgroup.size();
        fgroup.resize(fgroup.size() + 1);
        fgroup[cidx] = 1;
        findex[i] = cidx;

        queue<int> que;
        que.push(i);
        while (!que.empty()) {
            int c = que.front(); que.pop();

            for (auto e : friends[c]) {
                if (findex[e] != -1) continue;
                ++fgroup[cidx];
                findex[e] = cidx;
                que.push(e);
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        int ans = (fgroup[findex[i]] - 1) - friends[i].size();

        for (auto e : blocks[i]) {
            ans -= findex[i] == findex[e];
        }

        cout << ans << (i != n - 1 ? " " : "");
    }
    cout << endl;
}



Measured memory_bytes: 14972
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define mem(x) memset(x,0,sizeof x)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=3e5+10;

    vc<pii> a[N];char str[N];
    void main()
    {
        int a=qread(),b=qread(),c=qread();
        if(a+b+c>=22) puts("bust"); else puts("win");
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 7296
#include <iostream>
#include <stdlib.h>
#include <cmath>

using namespace std;

int main() {
	int a, b;
	cin >> a>>b;
	if (a <= 8 && b <= 8) {
		cout << "Yay!";
	}
	else {
		cout << ":(";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b) cout<<c<<endl;
  if(c==b) cout<<a<<endl;
  if(a==c) cout<<b<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int P,J,i,min,a;
	int Pmin=2000;
	int Jmin=2000;
	
	for( i=0 ; i<3 ; i++){
		scanf("%d",&P);
		if(Pmin>P){
			Pmin=P;
		}
	}
	for( a=0 ;a<2;a++){
		scanf("%d",&J);
		if(Jmin>J){
			Jmin=J;
		}
	}
	min=Jmin+Pmin-50;
	printf("%d\n",min);
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    double x[8],y[8];
    cin>>n;
    rep(i,n) cin>>x[i]>>y[i];
    vec A;
    rep(i,n) A.push_back(i);
    double sum=0,b=0;
    do{
        rep(i,n-1) sum+=sqrt((x[A[i]]-x[A[i+1]])*(x[A[i]]-x[A[i+1]])+(y[A[i]]-y[A[i+1]])*(y[A[i]]-y[A[i+1]]));
        b++;
    }while(next_permutation(all(A)));
    cout<<setprecision(10)<<sum/b;
}

Measured memory_bytes: 3828
M = 201
X, N = map(int, input().split())
A = list(map(int, input().split()))


def solve():
    memo = [0] * M
    for a in A:
        d = a - X
        if d >= 0:
            memo[d*2] = 1
        else:
            memo[-d*2-1] = 1
    for i, m in enumerate(memo):
        if m == 0:
            if i % 2 == 0:
                return i//2 + X
            else:
                return -(i+1)//2 + X

if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;
bitset<4000020> f;

int main() {
    int n;
    cin >> n;
  	f[0]=1;
  	int sum=0;
    rep(i,n){
        int a;
      	cin >> a;
      	f |= f << a;
      	sum+=a;
    }
    for(int i=(sum-1)/2+1;i<sum+1;i++){
        if(f[i]){
            cout << i;
            return 0;
        }
    }
}

/*



 */



Measured memory_bytes: 1664
#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 int long long
#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 bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1000000000;

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;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
  cout << fixed;
  cout << setprecision(12);
  
  double a, b;
  cin >> a >> b;
  double ret = a * b;
  ret /= 3.305785;
  cout << ret << endl; 
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3272
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const ll MAXN = 1e18;
int main() {
	int n; cin >> n;
	ll a[n] = {};
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	ll ans = 1;
	for (int i = 0; i < n; i++) {
		if ((__int128)ans * a[i] > MAXN) {
			cout << -1 << "\n";
			return 0;
		}
		ans *= a[i];
	}
	cout << ans << "\n";
}

Measured memory_bytes: 4380
#include <stdio.h>
const int N = 2e5+5;
int pow2[N][3];
int f[N][3];
char s[N];
int getans(int x) {
	int ans = 0;
	while (x) {
		int tmp = x;
		int cnt = 0;
		while (tmp) {
			if (tmp & 1)
				cnt++;
			tmp>>=1;
		}
		ans++;
		x = x%cnt;
	}
	return ans;
}
int main()
{
	int n;
	scanf("%d%s",&n,s);
	int mod[3] = {0,0,0};
	for (int i = 0;i < n;i++)
		if (s[i] == '1')
			mod[0]++;
	mod[1] = mod[0]+1;
	mod[2] = mod[0]-1;
	for (int j = 0;j < 3;j++) if (mod[j]!=0)
	{
		pow2[0][j] = 1%mod[j];
	}
	for (int i = 1;i<=n+1;i++)
		for (int j = 0;j< 3;j++) if (mod[j]!=0)
		{
			pow2[i][j] = pow2[i-1][j]*2%mod[j];
			if (i!=n+1)
			{
				f[i][j] = f[i-1][j]*2%mod[j];
				f[i][j] = (f[i][j] + (s[i-1]=='1'))%mod[j];
			}
		}
	for (int i = 0;i< n;i++)
	{
		int tmp = 0;
		int ans = 0;
		if (s[i]=='1') {
			if (mod[2]==0) {ans = 0;}
			else {
				tmp = ((f[n][2]-pow2[n-i-1][2])%mod[2]+mod[2])%mod[2];
				ans = 1 + getans(tmp);
			}
		}
		else {
			tmp = (f[n][1]+pow2[n-i-1][1])%mod[1];
			ans = 1 + getans(tmp);
		}
		printf("%d\n",ans);
	}
	return 0;
}

/*
10110111001011011001110
6002382
 */

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

using namespace std;

int main() {
    string s;
    while (cin >> s) {
        int sz = s.size();
        string ans = "";
        for (int i = 0; i < sz; i++) {
            if (s[i] != '@') ans += s[i];
            else {
                int cnt = s[++i] - '0';
                i++;
                while (cnt--) ans += s[i];
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
const ll INF = 1e17;
const int max_v = 1e3+1;

vector<vector<ll>> d(max_v, vector<ll>(max_v,INF));
int v;

void warshall_floyd(){
  rep(k, v){
    rep(i, v){
      rep(j, v) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
  }
}

int main(){
  rep(i,max_v) d[i][i] = 0;
  int m, r;
  cin >> v >> m >> r;
  int p[r];
  rep(i,r) {
    cin >> p[i];
    p[i]--;
  }
  rep(i,m){
    int a, b; ll c;
    cin >> a >> b >> c;
    a--; b--; 
    d[a][b] = c; d[b][a] = c;
  }
  warshall_floyd();
  sort(p,p+r);
  ll ans = INF;
  do{
    ll l = 0;
    rep(i,r-1) l += d[p[i]][p[i+1]];
    ans = min(ans,l);
  } while(next_permutation(p,p+r));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8064
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
arrA = list(map(int,input().split()))
# arrA = np.array(input().split(),dtype=np.int64)

ans = [0] * (N+1)

for i in arrA:
    ans[i] += 1

ans = ans[1:]
print(*ans,sep="\n")
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 32232
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  int k,a,b;
  cin>>k>>a>>b;
  rep2(i,a,b+1){
    if(i%k==0){
      cout<<"OK"<<endl;
      return 0;
    }  
  }
  cout<<"NG"<<endl;
return 0;
}



Measured memory_bytes: 3632
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n;
  rd(n);
  auto a = readln.split.to!(int[]);

  long ans = 0;
  for (int i = 0, j = 0, s = 0; i < n; s ^= a[i++]) {
    while (j < n && ((s & a[j]) == 0)) {
      s ^= a[j++];
      ans += (j - i);
    }
  }
  writeln(ans);
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 11612
#include <iostream>
int main(){
	int a1,a2,a3,a4;
	int a[4],b[4],c;
	while(std::cin>>a1>>a2>>a3>>a4){
		int o=0,i=0;
			for(int v=0;v<4;v++){
			std::cin>>b[v];
		}
		
			for(int p=0;p<4;p++){
				if(a1==b[p]){
					if(0==p){
						o++;
					}else{
						i++;
					}
					}	if(a2==b[p]){
					if(1==p){
						o++;
					}else{
						i++;
					}
				}
						if(a3==b[p]){
					if(2==p){
						o++;
					}else{
						i++;
					}
					}	if(a4==b[p]){
					if(3==p){
						o++;
					}else{
						i++;
					}
				}
			}
		
	

		std::cout<<o<<" "<<i<<std::endl;
	}
	return 0;


}

Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
int main() {
    int a,b,c,ans=0,temp,i,j,k;
    cin>>a>>b>>k;
temp=max(a,b);
vector<int> yakusu;
    for(i=1;i<=temp;i++){
        if(a%i==0&&b%i==0){
            ans++;
          //  cout << i << endl;
            yakusu.push_back(i);
        }
    }
    std::cout << yakusu[ans-k] << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 998244353;
const int MAX = 300000;

long long fac[MAX], finv[MAX], inv[MAX];
long long modpow(long long x,long long n,long long mod){
    long long res = 1;
    while(n > 0) {
        if(n & 1) (res *= x) %= mod;
        (x *= x) %= mod;
        n>>=1;
    }
    return res;
}

long long modinv(long long x, long long mod){
    return modpow(x, mod - 2, mod); }
// テーブルを作る前処理
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 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    COMinit();
    for (ll i = 0; i < k+1;i++){
        ll tmp = (m % MOD);
        tmp *= modpow(m - 1, n - i - 1, MOD);
        tmp %= MOD;
        tmp *= COM(n - 1, i);
        tmp %= MOD;
        ans += tmp;
        ans %= MOD;
    }
        cout << ans << endl;
}

Measured memory_bytes: 10660
// aribon1-6_c
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define debug(x) cout << #x << ": " << (x) << endl
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define all(x) x.begin(), x.end()
#define INF ((1 << 16)-1)
#define MOD (1000000007)
#define print(arr, n) REP(i, n) cout << arr[i] << " ";

struct PreMain {PreMain(){std::cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    std::ifstream in("../arg.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int K, S;
    cin >> K >> S;

    ll ans = 0;
    REP(x, K+1){
        REP(y, K+1){
            if (0 <= S - x - y && S - x - y <= K) {
                ans++;
            }
        }
    }

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




Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll abs=0;
    vector<ll> L(N,0);
    for(ll i=0;i<N;++i)cin>>L[i];
    for(ll i=0;i<N;++i)
            for(ll j=i+1;j<N;++j)
                for(ll k=j+1;k<N;++k){
                    ll a=L[i];
                    ll b=L[j];
                    ll c=L[k];
                    if(a!=b&&b!=c&&a!=c&&a+b>c&&b+c>a&&a+c>b)abs++;
                }
prt(abs);
    return 0;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

string f(ll n) {
    if (n == 0) return "";
    n--;
    return f(n/26) + string(1, 'a'+n%26);
}

int main() {
  ll n;
  cin >> n;
  cout << f(n) << endl;
}



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


int32_t main() {
    ios_base::sync_with_stdio(0);


    int q;
    cin >> q;

    while (q--) {
        int a, b;

        cin >> a >> b;

        if (a > b) swap(a, b);

        if (a == b) {
            cout << 2*(a-1) << "\n";
            continue;
        }

        int c = a*b;
        int p = 0;
        int q = 0;

        while (p*p < a) p++;
        while (q*q < b) q++;
        p--; q--;
        int s = p*q;

        s--;

        while (s*s < c) s++;

        s--;

        cout << 2*s - 2 + (s*(s+1) < c) << "\n";
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define reps(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(i, n) reps(i, 0, n)
#define deps(i, a, n) for (int i = (a); i >= (n); --i)
#define dep(i, n) deps(i, n, 0)
#define max(p, q) ((p) > (q) ? (p) : (q))
#define min(p, q) ((p) < (q) ? (p) : (q))
#define inf 2147483647
#define int long long

signed main()
{
	int h, w, n, sr, sc, m[4];
	string s, t;

	cin >> h >> w >> n;
	cin >> sr >> sc;
	cin >> s;
	cin >> t;

	m[0] = 1;
	m[1] = w;
	m[2] = 1;
	m[3] = h;

	deps (i, n - 2, 1)
	{
		if (s[i] == 'L') m[0]++;
		else if (s[i] == 'R') m[1]--;
		else if (s[i] == 'U') m[2]++;
		else m[3]--;

//		if (sc < m[0] || m[1] < sc || sr < m[2] || m[3] < sr)  {cout << "NO" << endl; return 0;}
		if (m[0] == m[1] || m[2] == m[3])  {cout << "NO" << endl; return 0;}

		if (t[i - 1] == 'L') m[1] = min(m[1] + 1, w);
		else if (t[i - 1] == 'R') m[0] = max(m[0] - 1, 1);
		else if (t[i - 1] == 'U') m[3] = min(m[3] + 1, h);
		else m[2] = max(m[2] - 1, 1);
	}
	if (s[0] == 'L') m[0]++;
	else if (s[0] == 'R') m[1]--;
	else if (s[0] == 'U') m[2]++;
	else m[3]--;
	if (sc < m[0] || m[1] < sc || sr < m[2] || m[3] < sr)  {cout << "NO" << endl; return 0;}
	cout << "YES" << endl;
}


Measured memory_bytes: 4028
#include<iostream>
using namespace std;
int main()
{
     long long a,b,c,k,l,m;
     cin>>a>>b>>c>>k;
     if(a>=k)
     {
         cout<<k<<endl;
     }
     else
     {
         l=k-a;
         if(b>=l)
         {
             cout<<a<<endl;
         }
         else
         {
             m=l-b;
             cout<<(a-m)<<endl;
         }
     }
     return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll A, B;
    cin >> A >> B;

    if(A<=8 && B<=8){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int st[101];
int ft[101];
int main(){
  int t;
  int n;
  while(cin>>t&&t){
    cin>>n;
    for(int i=0;i<n;i++)cin>>st[i]>>ft[i];
    int sum=0;
    for(int i=0;i<n;i++){
      sum+=max(0,ft[i]-st[i]);
    }
    if(sum>=t)cout<<"OK"<<endl;
    else cout<<t-sum<<endl;
  }

  return 0;
}

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

int main(void) {
    int N;
    int i = 0;
    cin >> N;

    for(;N != 1;i++) {
        N >>= 1;
    }

    if(i == 0) {
        cout << 1 << "\n";
    } else {
        cout << (1 << i) << "\n";;
    }

    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(void){
  long long n;
  cin>>n;
  vector<string> s(n+1);
  for(int i=0;i<n;++i){
    cin>>s[i];
  }
  sort(s.begin(),s.end()-1);
  int max=1,count=1,anss=0;
  vector<string> l(n);
  
  for(int i=1;i<=n;++i){
    if(s[i]==s[i-1]){
      count++;
    }
    else{
      if(count==max){
        l[anss]=s[i-1];
        ++anss;
      }
      if(count>max){
        max=count;
        anss=0;
        l[anss]=s[i-1];
        ++anss;
      }
      count=1;
    }
  }
  vector<string> ans(anss);
  for(int i=0;i<anss;++i){
    ans[i]=l[i];
  }
  sort(ans.begin(),ans.end());
  for(int i=0;i<anss;++i){
    cout<<ans[i]<<endl;
  }
}


Measured memory_bytes: 18560
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,m;
	std::cin >> n >> m;
	std::vector<std::pair<int,int> > bombs;
	bombs.reserve(n);
	rep(i,n) {
		int a,b;
		std::cin >> a >> b;
		bombs.emplace_back(a,b);
	}
	std::vector<std::pair<int,int> > codes;
	rep(i,m) {
		int a,b;
		std::cin >> a >> b;
		codes.emplace_back(a,b);
	}
	std::sort(all(bombs));
	std::vector<int> xors(n+1);
	xors[0] = bombs[0].second; xors[n] = bombs[n-1].second;
	rep(i,n-1) {
		xors[i+1] = bombs[i].second^bombs[i+1].second;
	}
	debug(xors);
	std::map<std::pair<int,int>, int> map;
	std::vector<std::vector<int> > g(n+1,std::vector<int>());
	std::vector<int> bombs2(n);
	rep(i,n) {
		bombs2[i] = bombs[i].first;
	}
	debug(bombs2);
	rep(i,m) {
		int a = std::lower_bound(all(bombs2),codes[i].first)-bombs2.begin();
		int b = std::upper_bound(all(bombs2),codes[i].second)-bombs2.begin();
		map[std::make_pair(a,b)] = i;
		map[std::make_pair(b,a)] = i;
		if(a==b) continue;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	debug(n,m);
	std::set<int> set;
	std::vector<int> went(n+1,false);
	std::function<int(int,int)> dfs = [&] (int i, int par) -> int {
		int impossible = false;
		went[i]=true;
		debug(i,par);
		for(int to: g[i]) {
			if(went[to]) continue;
			if(dfs(to,i)) impossible = true;
		}
		if(xors[i]) {
			if(par==-1) return 1;
			xors[par]^=1;
			set.emplace(map[std::make_pair(i,par)]);
		}
		return impossible;
	};
	debug(went);
	rep(i,n+1) {
		if(went[i]) continue;
		went[i]=true;
		if(dfs(i,-1)) {
			print(-1);
			return 0;
		}
	}
	print(set.size());
	for(auto x:set) {
		std::cout << x+1 << ' ';
	}
	std::cout << ENDL;
	return 0;
}


Measured memory_bytes: 53356
#include <iostream>
//#include <assert.h>
//#include <vector>
//#include <algorithm>
#include <string>
//#include <functional>
//#include <cmath>


int main(){
    int32_t N;
    std::cin >> N;
    if(N % 2 != 0){
        std::cout << "No" << std::endl;
        return 0;
    }
    int32_t half_size = N / 2;
    std::string S;
    std::cin >> S;
    std::string first = S.substr(0, half_size);
    std::string second = S.substr(half_size);
    if(first == second){
        std::cout << "Yes" << std::endl;
    }
    else{
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define N 500009
#define M (L+R)/2
#define inf 999999999999
#define mod 1000000007
#define pb push_back
#define ll long long

ll n;

int main() {
    
    ios::sync_with_stdio(0);
    
    cin>>n;
	if(n==3 || n==5 || n==7){
      cout<<"YES"<<endl;
    } else {
       cout<<"NO"<<endl;
    } 



return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

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

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    int a,b,c;
    cin >> a >> b >> c;

    if(a+b==c || a+c==b || b+c==a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import math
n = int(input())
state = [n, 0, 0, 0, 0, 0]
capacities = [int(input()) for _ in range(5)]
for i in range(1, 5):
    if capacities[i - 1] < capacities[i]:
        capacities[i] = capacities[i - 1]
print(4+math.ceil(n/capacities[4]))


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

#define ll long long
#define f first
#define s second
#define sd(x)			scanf("%d",&x)
#define schar(x)		scanf("%c\n",&x)
#define slld(x)			scanf("%lld",&x)
#define sf(x)			scanf("%lf",&x)
#define pb				push_back
#define pll				pair<ll,ll>
#define FOR(i,m)		for(i=0;i<m;i++)
#define ROF(i,m)		for(i=m;i>=0;i--)
#define FILL(v, p)		memset(v,p,sizeof v)
#define CASE(x)			printf("Case %lld:\n",x)
#define all(x)			x.begin(),x.end()
#define endl			"\n"
#define NL				printf("\n")
#define print(x)		printf("%d\n",x)
#define PI				2*acos(0.0)
#define EPS				0.000000000000001
#define INF				1LL<<62
#define MAX				100005
#define MOD				1000000007

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

	string str;
	cin >> str;

	map<char,ll> cnt;

	for(int i=0;i<n;i++)
	{
		cnt[str[i]]++;
	}

	ll ans=1;

	for(auto id=cnt.begin();id!=cnt.end();id++)
	{
		ans=(ans%MOD * (id->s +1)%MOD)%MOD;
	}

	cout << ans-1 << endl;

	return 0;
}


Measured memory_bytes: 512
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
 
		Scanner sc  = new Scanner(System.in);

		int o= 0 ,p = 0,q = 0;
		int a = 0, b = 0, c = 0;
		char ch;
		String str;
		
        int N = Integer.parseInt(sc.next());
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int AB = A+B;
        String S = sc.next();
        char[] c1 = S.toCharArray();
        

        while(true){
           
           if(c1[a]=='a' && AB > b )
           {
               System.out.println("Yes"); 
               b++;
           }
           else if(c1[a]=='b' && AB > b && c < B)
           {
               System.out.println("Yes"); 
               b++;
               c++;
           }
           else
           {
                System.out.println("No"); 
           }
           
           
            a++;
            if(a==N)break;
        }


       // System.out.print();
        System.out.println();
	}
}

Measured memory_bytes: 24008
#pragma gcc optimize (o3)
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define ll long long
#define ld long double
#define U unsigned
#define pi acos(-1)

using namespace std;

const ll N = 3e3+5, mod = 998244353;

ll n;
ld dp[N][N], arr[N];

ld solveI()
{
    for(int i = n/2+1 ; i <= n ; i++) dp[n][i] = 1;
    for(int i = n-1 ; i >= 0 ; i--)
    {
        for(int j = n-1 ; j >= 0 ; j--)
        {
            dp[i][j] = arr[i]*dp[i+1][j+1] + (1.0-arr[i])*dp[i+1][j];
        }
    }
    return dp[0][0];
}

int main()
{
    cin>>n;
    for(int i = 0 ; i < n ; i ++) cin>>arr[i];
    cout<<fixed<<setprecision(9)<<solveI();
    return 0;
}


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

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

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 2e5+10;

string S;
bool ok[MAX];

bool check(int A, int C) {
    REP (i, MAX) ok[i] = false;
    ok[A] = true;
    for (int i = A+1; i <= C; i++) {
        if (S[i-1] == '.') {
            if (ok[i-1] || (i-2 > 0 && ok[i-2])) ok[i] = true;
        }
    }
    return ok[C];
}

int main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D >> S;

    bool ans = check(A, C);
    ans = ans && check(B, D);
    if (D < C) {
        bool t = false;
        for (int i = B-1; i < D; i++) {
            t = t || (S[i-1] == '.' && S[i] == '.' && S[i+1] == '.');
        }
        ans = ans & t;
    }

    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 772
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using P = pair <int, int>;
 
 
int main(){
    
  int a ,b;
  cin >> a >>b;
  char s[12];
  cin >> s;

  if (s[a]!='-'){cout << "No" <<endl;
  return 0;
  }
  rep(i,a){
     if (!( '0' <= s[i]&& s[i] <= '9'))
{
puts ("No"); return 0;
}
  }
  for(int i = a+1;i<a+b+1;++i){
    if (!( '0' <= s[i]&& s[i] <= '9'))
{
puts ("No"); return 0;
}
  }
  cout << "Yes" <<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int sum = 0;
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] p = new int[n];

		for(int i = 0; i < n; i++) p[i] = sc.nextInt();
		Arrays.sort(p);
		for(int j = 0; j < k; j++) sum += p[j];

		System.out.println(sum);
	}
}

Measured memory_bytes: 38772
use proconio::{input, marker::Usize1};

fn chmax(a: &mut i32, b: i32) { *a = (*a).max(b); }
fn rotate(x: &mut usize, y: &mut usize, z: &mut usize) {
    let w = *x;
    *x = *y;
    *y = *z;
    *z = w;
}

struct DP {
    l12: Vec<Vec<i32>>,
    l1_max: Vec<i32>,
    l2_max: Vec<i32>,
    max: i32,
    n: usize,
}

impl DP {
    fn new(n: usize) -> DP {
        DP {
            l12: vec![vec![i32::min_value(); n + 1]; n + 1],
            l1_max: vec![i32::min_value(); n],
            l2_max: vec![i32::min_value(); n],
            max: i32::min_value(),
            n: n,
        }
    }
    fn set(&mut self, l1: usize, l2: usize, v: i32) {
        if l2 != self.n {
            chmax(&mut self.l12[l1][l2], v);
            chmax(&mut self.l12[l2][l1], v);
            chmax(&mut self.l1_max[l2], v);
            chmax(&mut self.l2_max[l2], v);
        }
        chmax(&mut self.l1_max[l1], v);
        chmax(&mut self.l2_max[l1], v);
        chmax(&mut self.max, v);
    }
}

fn main() {
    input! {
        n: usize,
        a: [Usize1; n * 3],
    }

    let mut dp = DP::new(n);
    dp.set(a[0], a[1], 0);
    let mut mc = 0;
    for i in 1..n {
        let (mut x, mut y, mut z) = (a[i * 3 - 1], a[i * 3], a[i * 3 + 1]);
        if x == y && x == z {
            mc += 1;
        } else {
            let mut q = vec![];
            for _ in 0..3 {
                for l in 0..n {
                    let mut v = dp.l1_max[l];
                    if y == z {
                        v = v.max(dp.l12[y][l] + 1);
                    }
                    q.push((x, l, v));
                }
                let mut v = dp.max;
                if y == z {
                    v = v.max(dp.l1_max[y] + 1);
                }
                q.push((x, n, v));

                let v = dp.max.max(dp.l12[z][z] + 1);
                q.push((x, y, v));
                rotate(&mut x, &mut y, &mut z);
            }
            for (x, y, v) in q {
                dp.set(x, y, v);
            }
        }
    }
    let l = a[3 * n - 1];
    let v = dp.max.max(dp.l12[l][l] + 1);
    println!("{}", v + mc);
}


Measured memory_bytes: 18112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

bool isPowerOf2(int n) {
    while(n % 2 == 0) {
        n /= 2;
    }
    return n == 1;
}

int main() {
    int N; cin >> N;
    if(isPowerOf2(N)) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    vector<pii> edges;
    // make chain [1' - 2' - 3' - 1 - 2 - 3]
    edges.push_back({N + 1, N + 2});
    edges.push_back({N + 2, N + 3});
    edges.push_back({N + 3, 1});
    edges.push_back({1, 2});
    edges.push_back({2, 3});
    // connect {2*k} - {2*k + 1} to 1
    for(int i = 4; i <= N - 1; i += 2) {
        // 1 - i - (i+1) & 1 - (i+1)' - i'
        edges.push_back({1, i});
        edges.push_back({i, i + 1});
        edges.push_back({1, N + i + 1});
        edges.push_back({N + i + 1, N + i});
    }
    if(N % 2 == 0) {
        int a = 1, b = 1;
        while(true) {
            if(a < N) a <<= 1;
            else break;
        }
        a >>= 1;
        b = N^a^1;
        // connect N - a - 1 - b' - N'
        edges.push_back({N, a});
        edges.push_back({N + b, N + N});
    }
    for(auto &e : edges) {
        cout << e.first << " " << e.second << "\n";
    }
}


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

int main()
{
    int cnt;
    string s;
    cin>>s;
    if(s[0]=='1') cnt++;
    if(s[1]=='1') cnt++;
    if(s[2]=='1') cnt++;
    
    cout<<cnt<<endl;
    return 0;    
}

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

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)

typedef long long ll;

int main()
{
    int N;
    int a[101];
    cin >> N;
    FOR(i,0,N){
        cin >> a[i];
    }

    sort(a, a + N, greater<int>());
    int Alice=0;
    int Bob=0;
    FOR(i,0,N){
        if(i%2 == 0)Alice += a[i];
        else Bob += a[i];
    }

    cout << Alice - Bob << endl;
}



Measured memory_bytes: 256
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
#ifndef ONLINE_JUDGE
    scanf("%lld", &a);
#else
    scanf("%I64d", &a);
#endif
    return a;
}

int a[100000];

int main() {
    int n = gi();
    for (int i = 0; i < n; i++)
        a[i] = gi();

    sort(a, a+n);

    int p = 0, q = n-1;
    ll s = a[q] - a[p];
    while (q-p > 2) {
        s += (a[q] - a[p+1]) + (a[q-1] - a[p]);
        p++;
        q--;
    }

    if (q-p == 2)
        s += MAX(a[q] - a[q-1], a[p+1] - a[p]);

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 640
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;

int main()
{
    IOS();
   
    ll n,i=0,j;
    cin>>n;
    ll a[n];
    f(i,0,n)   
        cin>>a[i];
    i=0;
    j=n-1;
    ll s1=0,s2=0;
    while(i<=j)
    {
        if(s1<s2)
        {
            s1+=a[i];
            i++;
        }
        else
        {
            s2+=a[j];
            j--;
        }
    }
    ll diff=abs(s1-s2);
    cout<<diff<<'\n';
    
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ll N;
    char S;
    ll state;
    ll ans = 0;

    cin >> N;

    state = 0;
    for(ll i = 0; i < N; i++){
        cin >> S;
        if(state == 0){
            if(S == 'A'){
                state = 1;
            }
        }else if(state == 1){
            if(S == 'B'){
                state = 2;
            }else if(S == 'A'){
                state = 1;
            }else{
                state = 0;
            }
        }else{
            if(S == 'C'){
                ans++;
                state = 0;
            }else if(S == 'A'){
                state = 1;
            }else{
                state = 0;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256