akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_b() {
	ll n, m;
	ll x, y;
	//ll a, b, c;
	ll k;
	string s;
	ll l_ans = 0;
	float f_ans = 0;
	string s_ans;

	cin >> n >> k;

	V p(n);
	rep(i, n) cin >> p[i];

	sort(ALL(p));

	rep(i, k) {
		l_ans += p[i];
	}

	cout << l_ans << "\n";

}

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

	solve_abc_b();

	return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;

const int N=200005;
const int P=1000000007;
const long long INFll=0x3f3f3f3f3f3f3f3fll;

struct edge{
	int v,len;
	edge *next;
}pool[5*N],*h[N];

int n,m,top=-1;
int S,T;
int _u[N],_v[N],_len[N];
int Inqwq[N],id[N],oscar;
long long dis[2][N];
long long cnt[2][N]; //0:S 1:T
long long ans;
queue <int> Q;

inline void addedge(int u,int v,int len){
	edge *tmp=&pool[++top];
	tmp->v=v;tmp->len=len;tmp->next=h[u];h[u]=tmp;
}

inline bool cmp(int x,int y){
	return dis[oscar][x]<dis[oscar][y];
}

#define upd(x,y) x+=(y),x%=P

#define sq(x) (((x)*(x))%P)

inline void spfa(int U,int type){
	oscar=type;
	for(int i=1;i<=n;i++) id[i]=i;
	for(int i=1;i<=n;i++) dis[type][i]=INFll,Inqwq[i]=false;
	dis[type][U]=0; Inqwq[U]=true;
	Q.push(U);
	while(Q.empty()==false){
		int u=Q.front(); Q.pop(); Inqwq[u]=false;
		for(edge *tmp=h[u];tmp!=NULL;tmp=tmp->next){
			int v=tmp->v;
			if(dis[type][v]>dis[type][u]+tmp->len){
				if(Inqwq[v]==false){
					Q.push(v);
					Inqwq[v]=true;
				}
				dis[type][v]=dis[type][u]+tmp->len;
			}
		}
	}
	cnt[type][U]=1;
	sort(id+1,id+n+1,cmp);
	for(int i=1;i<=n;i++){
		int u=id[i];
		for(edge *tmp=h[u];tmp!=NULL;tmp=tmp->next){
			int v=tmp->v;
			if(dis[type][u]+tmp->len==dis[type][v]) upd(cnt[type][v],cnt[type][u]);
		}
	}
	//for(int i=1;i<=n;i++) printf("%lld ",dis[type][i]); printf("\n");
}

/*
void bfs(){
	cnt[0][S]=1;
	cnt[1][T]=1;
	sort(id+1,id+n+1,cmp);
	for(int i=1;i<=n;i++){
		int u=id[i];
		for(edge *tmp=h[u];tmp!=NULL;tmp=tmp->next){
			int v=tmp->v;
			if(dis[u]+tmp->len==dis[v]) upd(cnt[0][v],cnt[0][u]);
		}
	}
	for(int i=n;i>=1;i--){
		int u=id[i];
		for(edge *tmp=h[u];tmp!=NULL;tmp=tmp->next){
			int v=tmp->v;
			if(dis[v]+tmp->len==dis[u])	upd(cnt[1][v],cnt[1][u]);
		}
	}
	ans=(cnt[0][T]*cnt[1][S])%P;
	for(int i=1;i<=n;i++) printf("%lld ",dis[i]); printf("\n");
	for(int i=1;i<=n;i++) printf("%lld ",cnt[0][i]); printf("\n");
	for(int i=1;i<=n;i++) printf("%lld ",cnt[1][i]); printf("\n");
}
*/

void init(){
	int x1,x2,x3;
	scanf("%d%d",&n,&m);
	scanf("%d%d",&S,&T);
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&x1,&x2,&x3);
		addedge(x1,x2,x3);
		addedge(x2,x1,x3);
		_u[i]=x1,_v[i]=x2;
		_len[i]=x3;
	}
	//for(int i=1;i<=n;i++) id[i]=i;
	spfa(T,1);
	spfa(S,0);
	ans=(cnt[0][T]*cnt[1][S])%P;
	//printf("%lld\n",ans);
	for(int i=1;i<=m;i++){
		int u=_u[i],v=_v[i];
		if(dis[0][u]>dis[0][v]) swap(u,v);
		if(dis[0][u]+_len[i]+dis[1][v]!=dis[0][T]) continue;
		if(2*dis[0][u]<dis[0][T] && dis[0][T]<2*dis[0][v]){
			
		//	printf("%d %d\n",u,v);
			
			upd(ans,P-sq((cnt[0][u]*cnt[1][v])%P));
		}
	}	
	for(int i=1;i<=n;i++){
		int u=i;
		if(dis[0][u]==dis[1][u] && 2*dis[0][u]==dis[0][T]){
			
		//	printf("%d \n",i);
			
			upd(ans,P-sq((cnt[0][u]*cnt[1][u])%P));
		}
	}
	printf("%lld\n",ans);
}

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

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


int main(){
    int n;
    cin >> n;
    double dp[n+1] = {0};
    dp[0] = 1;
    for(int i = 1; i <= n; i++){
        double p; cin >> p;
        for(int j = i; j>0; j--){
            dp[j] = dp[j-1] * p + dp[j] * (1-p);
        }
        dp[0] = dp[0]*(1-p);
    }
    double ans = 0;
    for(int i = 0; i <= n; i++){
        int heads = i;
        int tails = n-i;
        if(heads>tails)
            ans +=dp[i];
    }
    cout <<fixed<<setprecision(10)<<ans;
}


Measured memory_bytes: 3796
#include<stdio.h>
#include<math.h>

int main(void)
{
	int i,j,k,n,d,count=0,sum=0;
	int x[11][11];
	
	scanf("%d%d",&n,&d);
	for(i=0;i<n;i++){
		for(j=0;j<d;j++)
			scanf("%d",&x[i][j]);
	}
	for(i=0;i<n-1;i++){
		for(j=1;j+i<n;j++){
			for(k=0;k<d;k++){
				sum+=(x[i][k]-x[i+j][k])*(x[i][k]-x[i+j][k]);
			}
			if(sqrt(sum)-(int)sqrt(sum)==0)
					count++;
			sum=0;
		}
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;



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

    string s,t;
    cin >> s >> t;
    vector<char> S(s.size()),T(t.size());
    rep(i,s.size()) S.at(i)=s.at(i);
    rep(i,t.size()) T.at(i)=t.at(i);

    sort(S.begin(),S.end());
    sort(T.begin(),T.end());
    reverse(T.begin(),T.end());
    string x={},y={};

    rep(i,s.size()) x+=S.at(i);
    rep(i,t.size()) y+=T.at(i);

    if(x<y) cout << "Yes" << endl;
    else cout << "No" << endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, m, t = 0; ulint s = 0;
  cin >> n >> m;
  vector<pii> v(n);
  rep(i, n) cin >> v[i].fi >> v[i].se;
  sort(v.begin(), v.end());
  priority_queue<int> p;
  rep(i, m){
    if(t < n){
      while(v[t].fi < i+2){
        p.push(v[t].se);
        ++t;
        if(t == n) break;
      }
    }
    if(!p.empty()){
      s += p.top();
      p.pop();
    }
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 1660
#include <stdio.h>
#include <stdlib.h>

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

int main(void)
{
    int N, i, j, tmp;
    int A[200001];
    long long int B[200002];
    int A_sort[200001];
    long long int sum=0, sum_tmp;

    scanf("%d",&N);

    for(i=0; i<N; i++){
        scanf("%d",&A[i]);
        A_sort[i] = A[i];
    }

    for(i=0; i<200002; i++){
        B[i] = 1;
    }

    
    qsort(A_sort,N,sizeof(int),compare_int);
    //何個並んでるかのカウントをする
    for(i=0; i<N-1; i++){
        tmp = A_sort[i];
        if(A_sort[i] == A_sort[i+1]){
            B[tmp]++;
        }
    }
/*
    for(i=0; i<N; i++){
        printf("B[%d] = %lld\n",i,B[i]);
    }
*/
    //sumの計算
    for(i=0; i<N+1; i++){
        sum += (B[i]*(B[i]-1))/2;
    }


    //出力
    for(i=0; i<N; i++){
        sum_tmp = sum;
        tmp = A[i];
        if(B[tmp] == 1){
            printf("%lld\n",sum);
        } else {
            sum_tmp -= (B[tmp]*(B[tmp]-1))/2;
            sum_tmp += ((B[tmp]-1)*(B[tmp]-2))/2;
            printf("%lld\n",sum_tmp);
        }
    }

    return 0;
}

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

using namespace std;

#define local
#ifdef local

template<class T>
void _E(T x) { cerr << x; }

void _E(double x) { cerr << fixed << setprecision(6) << x; }

void _E(string s) { cerr << "\"" << s << "\""; }

template<class A, class B>
void _E(pair<A, B> x) {
    cerr << '(';
    _E(x.first);
    cerr << ", ";
    _E(x.second);
    cerr << ")";
}

template<class T>
void _E(vector<T> x) {
    cerr << "[";
    for (auto it = x.begin(); it != x.end(); ++it) {
        if (it != x.begin()) cerr << ", ";
        _E(*it);
    }
    cerr << "]";
}

void ERR() {}

template<class A, class... B>
void ERR(A x, B... y) {
    _E(x);
    cerr << (sizeof...(y) ? ", " : " ");
    ERR(y...);
}

#define debug(x...) do { cerr << "{ "#x" } -> { "; ERR(x); cerr << "}" << endl; } while(false)
#else
#define debug(...) 114514.1919810
#endif
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f3f
#define ll long long
#define db long double
#define eps 1e-3
#define bin(x) cerr << bitset<10>(x) << endl
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define endl "\n"
const ll mod = 1e9 + 7;
const ll maxn = 2e5 + 10;
const db pi = acos(-1.0);

ll qpow(ll a, ll b) {
    ll ret = 1;
    for (; b; a = a * a % mod, b >>= 1) {
        if (b & 1) {
            ret = ret * a % mod;
        }
    }
    return ret;
}

vector<ll> f(maxn), invf(maxn);

ll inv(ll a) {
    return qpow(a, mod - 2);
}

void prework() {
    f[0] = 1;
    _rep(i, 1, maxn - 1) {
        f[i] = f[i - 1] * i % mod;
    }
    invf[maxn - 1] = qpow(f[maxn - 1], mod - 2);
    for (ll i = maxn - 2; i >= 0; i--) {
        invf[i] = invf[i + 1] * (i + 1) % mod;
    }
}

ll C(ll n, ll m) {
    if (n > m || m < 0)return 0;
    if (n == 0 || m == n) return 1;
    ll res = (f[m] * invf[m - n] % mod * invf[n]) % mod;
    return res;
}

ll dp[maxn][2];

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll x, k, d;
    cin >> x >> k >> d;
    ll mx = x + k * d, mn = x - k * d;
    ll res = oo;
    if (mx > 0 && mn > 0) {
        res = mn;
    } else if (mx < 0 && mn < 0) {
        res = -mx;
    } else {
        x = abs(x);
        ll y = x / d;
        k -= y;
        if (k & 1) {
            res = min(abs(x - y * d - d), abs(x - y * d + d));
        } else {
            res = abs(x - y * d);
        }

    }
    cout << res << endl;

}


Measured memory_bytes: 6284
N = gets.to_i
a = gets.split(" ").map(&:to_i).sort
b = Array.new(a[-1] + 1, true)
ans = 0

(N - 1).times do |i|
    next if b[a[i]] == false
    v = a[i] * 2
    while v <= a[-1] do
        b[v] = false
        v += a[i]
    end
    b[a[i]] = false if a[i] == a[i + 1]
end

a.each do |x|
    ans += 1 if b[x] == true
end
puts ans

Measured memory_bytes: 38272
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (int)n;i++)
#define repb(i,n) for(int i = (int)n;i >= 0;i--)
#define reps(i,m,n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i,m,n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v,n) sort(v,v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[]) {
    int a,b,c;
    cin>>a>>b>>c;

    if(a==b&&b==c){
        cout<<"Yes"<<endl;
        return 0;
    }

    else{
         cout<<"No"<<endl;
         return 0;

    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <stdio.h>
#include <iomanip>
using namespace std;

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

#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()

int main()
{
	int n, a = 0;
	cin >> n;
	for (int i = 1; i <= n; i++)
		if (i & 1) a++;
	cout << fixed << setprecision(8) << 1.0 * a / n << endl;
}


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

#define REP(i,n,m) for(int i=n;i<m;i++)
#define REPR(i,n,m) for(int i=n;i>m;i--)
#define ALL(v) v.begin(),v.end()
#define elif else if
using ll=long long;

int gcd(int x,int y){
    int a;
    while(y!=0){
        a=x%y;
        x=y;
        y=a;
    }
    return x;
}

/*--- lcm a*b/gcd(a,b) ---*/

/*----------template----------*/

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

    cout<<a*b/gcd(a,b)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    long long k, n, dmax;
    cin >> k >> n;
    vector<long long> as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }
    dmax = k - as[n - 1] + as[0];
    for (int i = 0; i < n - 1; i++) {
        dmax = std::max(dmax, as[i + 1] - as[i]);
    }
    cout << k - dmax << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <unordered_map>
using namespace std;

int main()
{
	int n, k;
    cin >> n >> k;
	long long count = k;
	for (int i = 1; i < n; i++) {
		count *= (k - 1);
	}
	cout << count << endl;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  for ( int i = 0; i < 1000000000; i++  ){
    if (n - pow(k, i) < 0 ){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if a[i]!=a[j] and a[j]!=a[k]:
        if a[i]+a[j]>a[k]:
          ans+=1
print(ans)

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

#define ll long long

using namespace std;

int main() {
	int n; cin >> n;
	ll res = 0;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 1; i < n; ++i) {
		res += max(a[i-1] - a[i], (ll)0);
		a[i] = max(a[i], a[i-1]);
	}
	cout << res;
}

Measured memory_bytes: 4836
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define mod 1000000007
#define MAX 100005
using namespace std;
//char nc()
//{
//	static char buf[100000],*p1=buf,*p2=buf;
//	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
char nc(){return getchar();}
int read()
{
	int x=0,y=1;
	char c=nc();
	while(!isdigit(c))
	{
		if(c=='-')y=-1;
		c=nc();
	}
	while(isdigit(c))
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=nc();
	}
	return x*y;
}
int n,lst[3],sm[MAX];
char s[MAX];
long long f[MAX];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	bool flag=false;
	for(int i=1;i<=n;i++)
	{
		if(i>1&&s[i]==s[i-1]) flag=true;
		sm[i]=(sm[i-1]+(s[i]-96))%3;
	}
	if(!flag) return puts("1"),0;  //abababa....
	for(int i=1;i<=n;i++)  //我们如果倒序考虑s,那么除了第一个串以外(即除最短划分外,额外包含一个sm%3==0的前缀),其余一定是最短划分 
	{
		f[i]=(f[lst[(sm[i]+1)%3]]+f[lst[(sm[i]+2)%3]]+(sm[i]?1:0))%mod; //新增a,新增b,成为一个新的串
		lst[sm[i]]=i;  //对于lst,abababa...出现一定早于余数相同的a/b,因此合法 
	}
	printf("%lld",f[n]);
	return 0;
}


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

int main() {
  string S;
  cin >> S;

  int counter =0;
  
  for(int i=0 ; i < 3 ; ++i ){
    for(int j=i+1 ; j < 4 ; ++j ){
    	if(S[i]==S[j]) ++counter;
    }
  }
  
  if(counter == 2) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <stack>
#include <vector>
#include <map>
#include <string>
#include <string.h>
#include <cstring>
#include <queue>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;

ll Sack[101][100001] = { 0 };
ll weights[101];
ll values[101];

ll KnapSack(ll N, ll W) 
{
	if (N == 0)
	{
		return 0;
	}
	if (W == 0)
	{
		return 0;
	}

	if (Sack[N][W] == 0) {
		if (W - weights[N] < 0)
		{
			Sack[N][W] = KnapSack(N - 1, W);
			return Sack[N][W];
		}
		else
		{
			Sack[N][W] = max(KnapSack(N - 1, W), KnapSack(N - 1, W - weights[N]) + values[N]);
			return Sack[N][W];
		}
	}
	else
		return Sack[N][W];
}

int main()
{
	ll N, W;
	cin >> N >> W;
	for (int i = 1; i <= N; i++) 
	{
		cin >> weights[i] >> values[i];
	}
	cout << KnapSack(N, W);
}

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

int main() {
  long A,B;
  cin >> A >> B;
  if(A>=13){
    cout << B;
  }
  if(A<=12&&A>5){
    cout << B/2;
  }
  if(A<=5){
    cout << 0;
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	int INF = 1 << 28;
	int n;
	int map[][];
	int w[];
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			n = sc.nextInt();
			if(n == 0) break;
			map =  new int[n][4];
			for(int i=0;i<n;i++) for(int j=0;j<4;j++){
				map[i][j] = sc.nextInt();
			}
			w = new int[n+1];
			fill(w, -1);
			int max = 0;
			for(int i=0;i<n;i++) {
				max = max(max, solve(i) );
			}
			System.out.println(max);
		}
	}
	
	int solve(int i) {
//		debug(i);
		if( w[i] >= 0 ) return w[i];
		int l = map[i][2] != 0? solve(map[i][2]-1): 1;
		int r = map[i][3] != 0? solve(map[i][3]-1): 1;
		int wait = 0;
		wait = lcm(l * map[i][0], r * map[i][1]);
//		debug(l, r, l*map[i][0], r*map[i][1], wait);
		wait = wait / map[i][0] + wait / map[i][1];
		return w[i] = wait;
		
	}
	
	int lcm(int x, int y) {
		int x_ = x;
		int y_ = y;
		int z = x_ % y_;
		while(z != 0) {
			x_ = y_;
			y_ = z;
			z = x_ % y_;
		}
		return x / y_ * y;
		
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

int main(){

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

    int x,n,t;
    cin>>n>>x>>t;
    cout<<(n+x-1)/x*t<<endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  for (int i = 0; i < a; ++i) cin >> p.at(i);
  for (int i = 0; i < b; ++i) cin >> q.at(i);
  for (int i = 0; i < c; ++i) cin >> r.at(i);
  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  sort(r.begin(), r.end());
  priority_queue<int, vector<int>, greater<int>> s, t;
  for (int i = 0; i < x; ++i) {
    s.push(p.at(a-i-1));
  }
  for (int i = 0; i < y; ++i) {
    t.push(q.at(b-i-1));
  }
  for (auto ri : r) {
    int si = s.top();
    int ti = t.top();
    if (si < ti) {
      if (ri > si) {
        s.pop();
        s.push(ri);
      }
    } else {
      if (ri > ti) {
        t.pop();
        t.push(ri);
      }
    }
  }
  long long ans = 0;
  while (!s.empty()) {
    ans += s.top();
    s.pop();
  }
  while (!t.empty()) {
    ans += t.top();
    t.pop();
  }

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



Measured memory_bytes: 2552
import java.util.*;
import java.io.*;
public class Main{
   public static void main(String[] main) throws Exception{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st = new StringTokenizer(br.readLine());
      PrintWriter out = new PrintWriter(System.out);
      int n = Integer.parseInt(st.nextToken());
      st = new StringTokenizer(br.readLine());
      int[] a = new int[n];
      long sum = 0;
      HashMap<Integer,Long> freq = new HashMap<Integer,Long>();
      for(int i = 0; i < n; i++) {
    	  a[i] = Integer.parseInt(st.nextToken());
    	  sum += a[i];
    	  if(freq.keySet().contains(a[i]))
    		  freq.put(a[i],freq.get(a[i])+1);
    	  else
    		  freq.put(a[i],(long)1);
      }
      st = new StringTokenizer(br.readLine());
      int q = Integer.parseInt(st.nextToken());
      for(int i = 0; i < q; i++) {
          st = new StringTokenizer(br.readLine());
          int b = Integer.parseInt(st.nextToken());
          int c = Integer.parseInt(st.nextToken());
    	  if(freq.keySet().contains(b)) {
    		  sum += freq.get(b)*(c-b);
    		  if(freq.keySet().contains(c)) {
    			  freq.put(c, freq.get(c) + freq.get(b));
    		  }
    		  else
    			  freq.put(c,freq.get(b));
              freq.remove(b);
    	  }
    	  out.println(sum);
      }
      out.close();
   }
}

Measured memory_bytes: 60028
x, y = map(int, input().split())

def whichone(x):
    a = [1, 3, 5, 7, 8, 10, 12]
    b = [4, 6, 9, 11]
    if x in a:
        return 0
    if x in b:
        return 1
    return 2

x = whichone(x)
y = whichone(y)

if x == y:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
const int MAX = 3000;
template<class T> bool chmax(T &a, const T b) {if (a<b) {a=b; return true;} return false;}

int main() {
	int N, T;
	cin >> N >> T;
	int A[MAX], B[MAX];
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}
	int dp_L[MAX+2][MAX+2] = {}, dp_R[MAX+2][MAX+2] = {};
	for (int i = 1; i <= N; i++) {
		int a = A[i-1], b = B[i-1];
		for (int j = 1; j <= T; j++) {
			dp_L[i][j] = dp_L[i-1][j];
			if (j - a >= 0) chmax(dp_L[i][j], dp_L[i-1][j-a] + b);
		}
	}
	for (int i = N; i >= 1; i--) {
		int a = A[i-1], b = B[i-1];
		for (int j = 1; j <= T; j++) {
			dp_R[i][j] = dp_R[i+1][j];
			if (j - a >= 0) chmax(dp_R[i][j], dp_R[i+1][j-a] + b);
		}
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		int b = B[i-1];
		for (int j = 0; j < T; j++) {
			int now = b + dp_L[i-1][j] + dp_R[i+1][T-1-j];
			ans = max(ans, now);
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


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

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}
/*
レート 1-399：灰色
レート 400-799：茶色
レート 800-1199：緑色
レート 1200-1599：水色
レート 1600-1999：青色
レート 2000-2399：黄色
レート 2400-2799：橙色
レート 2800-3199：赤色
*/

ll pnt[] = {1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200};

void solve()
{
  ll N; cin >> N;
  vector<ll> a(N); rep(i, N) cin >> a[i];

  ll ans1 = 0;
  ll ans2 = 0;
  vector<ll>cnt(8,0);
  ll ov3200 = 0;

  rep(i, N) {
    rep(j, 8) {
      if(pnt[j] <= a[i] && a[i] < pnt[j + 1]) cnt[j] = 1;
    }
    if(a[i] >= 3200) ov3200 ++;
  }
  rep(i, 8) ans1 += cnt[i];
  ans2 = ans1 + ov3200; 
  if(ans1 == 0 && ov3200 > 0) ans1 = 1;
  
  cout << ans1 << " " << ans2 << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    bool r = true;
    int n= s.size();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            r= false;
            break;
        }

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


            r= false;
            break;
        }
    }
    for(int i=((n+3)/2)-1;i<n;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            r= false;
            break;
        }
    }
    if(r==true)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d>0?i<n:i>n;i+=d)
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    ll n; cin >> n;
    vector<ll> A(n);
    rep(i, n){
        cin >> A[i];
        A[i] -- ;
    }

    ll res = 0;
    rep(i, n){
        ll j = A[i];
        res += A[j] == i;
    }
    res /= 2;
    cout << res << endl;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int sumone = 0;
		if(s[0] == '1') {
			sumone++;
		}
		if(s[1] == '1') {
			sumone++;
		}
		if(s[2] == '1') {
			sumone++;
		}
		System.out.println(sumone);
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	int A, B; cin >> A >> B;
	int cnt = 0;
	B--;
	while (B > 0) {
		B++;
		B -= A;
		cnt++;
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

void main(){

    while(true){
	int n = readln().chomp().to!int;
	if(n==0) break;
	int[] k = readln().split().to!(int[]);
	int len = to!int(k.length);
	bool flg = false;
	foreach(i;k) {
	    if(i<1) len--;
	    if(i >= 2) flg = true;
	}
	if(flg){
	    len++;
	    writeln(len);
	}else{
	    writeln("NA");
	}
    }

}

Measured memory_bytes: 6636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());

            var half = N / 2;

            var ans = 0L;

            for(var i = 1; i < N + 1; i++)
            {
                for (var j = 1; j < N - i + 1; j++)
                {
                    var mod = N - i * j;

                    if(mod > 0)
                    {
                        ans++;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            Console.WriteLine(ans);
        
        }
    }
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}


signed main(){
    int N;cin>>N;
    vector<string>S(N);
    rep(i,N)cin>>S[i];
    int cnt=0;
    rep(i,N){
        if(S[i]=="A")cnt++;
        else cnt--;
        if(cnt<0){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<(cnt==0?"YES":"NO")<<endl;
    return 0;
}

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

template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}

int main(int argc, char *argv[])
{
	int n,m,q;
	cin >> n >> m >> q;
	vector<int> a(q), b(q), c(q), d(q);
	for (int i = 0; i < q; i++) {
		cin >> a[i]>> b[i] >> c[i] >> d[i];
		a[i]--;b[i]--;
	}
	vector<int> A(n,1);
	int ans = 0;
	auto dfs = [&](auto&& dfs, int v) -> void{
		while (A[v] <= m) {
			if (v == n-1) {
				int tmp = 0;
				for (int i = 0; i < q; i++) {
					tmp += A[b[i]] - A[a[i]] == c[i] ? d[i] : 0;
				}
				chmax(ans,tmp);
			}
			else {
				if (A[v+1] < A[v]) {
					A[v+1] = A[v];
				}
				dfs(dfs, v+1);
			}
			A[v]++;
		}
		A[v] = 1;
		return;
	};
	dfs(dfs, 0);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3188
fun main(args : Array<String>) {
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
    val pairAandB = mutableListOf<Pair<Int, Int>>()

    (1..N).forEach {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        pairAandB.add(Pair(a,b))
    }

    pairAandB.sortBy { it.first }

    var totalCost = 0L
    var count = 0L

    pairAandB.forEach {
        var cost = it.first
        var remainder = it.second
        while(remainder > 0) {
            totalCost += cost
            remainder--
            count++
            if (count == M.toLong()) {
                println(totalCost)
                return
            }
        }
    }
    println(totalCost)
}



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

typedef long long int ll;

int sizeS;
string s;
ll pot[100010], memo[100010][15];

ll mod(ll a, ll b) {
	return ((a % b) + b) % b;
}

ll powMod(ll a, ll n, ll m) {
	ll result = 1;
	while (n) {
		if (n & 1)
			result = mod(result * a, m);
		a = mod(a * a, m);
		n >>= 1;
	}
	return result;
}

ll dp(int pos, int sum) {
	if (pos == sizeS and sum % 13 == 5) return 1;
	if (pos == sizeS and sum % 13 != 5) return 0;
	if (memo[pos][sum] != -1) return memo[pos][sum]; 
	ll ans = 0;
	if (s[pos] != '?') {
		int d = s[pos] - '0';
		d = mod(d * pot[pos], 13);
		ll newSum = mod(sum + d, 13);
		ans = mod(ans + dp(pos + 1, newSum), 1e9 + 7);
	}
	else {
		for (int i = 0; i < 10; i++) {
			ll newSum = sum;
			ll d = mod(i * pot[pos], 13);
			newSum = mod(newSum + d, 13);
			ans = mod(ans + dp(pos + 1, newSum), 1e9 + 7);
		}
	}
	memo[pos][sum] = ans;
	return ans; 
}

int main() {

	cin >> s;
	reverse(s.begin(), s.end());
	sizeS = s.size();
	for (int i = 0; i < sizeS; i++) {
		pot[i] = powMod(10, i, 13);
	}
	memset(memo, -1, sizeof(memo));
	cout << dp(0, 0) << "\n";
	return 0;
}

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

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++)
    {
        cin >> X[i];
    }
    vector<int> temp(X);
    sort(X.begin(), X.end());
    int medi = X[int(N / 2) - 1];
    for (int i = 0; i < N; i++)
    {
        if (temp[i] <= medi)
        {
            cout << X[int(N / 2)] << endl;
        }
        else
        {
            cout << medi << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<double, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	auto dsum = [&](auto it1, auto it2) {
		vector<int> b(n);
		for (int i = 1; i < n - 1; ++i) {
			b[i] = (i % 2 == 0) ? *it1++ : *it2++;
		}
		b[0] = *it1;
		b[n - 1] = *it2;
		ll res = 0;
		rep(i, n - 1) res += abs(b[i + 1] - b[i]);
		return res;
	};
	ll ans = max(dsum(a.begin(), a.rbegin()), dsum(a.rbegin(), a.begin()));
	cout << ans << endl;
 	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;
const int N = 200005, M = 1000005;
const long long mod = 998244353ll;
int n, m = 0, a[N], cnt[M];
long long vec1[M], vec2[M], vec[M], inv[M], ans = 0ll;
int main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++) m = max(m, a[i]);
	for (int i = 1; i <= m; i++) cnt[i] = 0;
	for (int i = 1; i <= n; i++) cnt[a[i]]++;
	inv[1] = 1ll;
	for (int i = 2; i <= m; i++) inv[i] = (mod / i) * (mod - inv[mod % i]) % mod;
	for (int i = 1; i <= m; i++) {
		vec1[i] = 0ll;
		for (int j = i; j <= m; j += i) {
			vec1[i] = (vec1[i] + 1ll * cnt[j] * j) % mod;
			vec2[i] = (vec2[i] + 1ll * cnt[j] * j % mod * j) % mod;
		}
		vec[i] = (vec1[i] * vec1[i] + mod - vec2[i]) % mod;
		vec[i] = vec[i] * inv[2] % mod;
	}
	for (int i = m; i >= 1; i--) {
		for (int j = 2 * i; j <= m; j += i) {
			vec[i] = (vec[i] + mod - vec[j]) % mod;
		}
		ans = (ans + vec[i] * inv[i]) % mod;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 36224
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	string S;
	cin >> S;
	rep(i, S.size()) {
		if(i%2 == 0) {
			if(S[i] != 'R' && S[i] != 'U' && S[i] != 'D') {
				cout << "No" << endl;
				return 0;
			}
		} else {
			if(S[i] != 'L' && S[i] != 'U' && S[i] != 'D') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;

}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>


int main() {
	int n; std::cin >> n;
	std::cout << (n - 2) * 180 << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int s[111];
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int n=max(a,max(b,max(c,d)));
	for (int i=a; i<b; i++){
		s[i]++;
	}
	for (int i=c; i<d; i++){
		s[i]+=2;
	}	
	int ans=0;
	for (int i=0; i<=n; i++){
		if (s[i]==3)ans++;
	}
	cout<<ans;
	return 0;
}

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

int ucrid(int a,int b){
    if(a<b) swap(a,b);
    while(1){
        if(b==0) break;
        int r = a%b;
        a = b;
        b = r;
    }
    return a;
}

int gcd(int a,int b,int c){
    int ans;
    ans = ucrid(ucrid(a,b),c);
    return ans;
}

int main(){
    int K;
    cin >>K;
    long long sum =0;
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int k=1;k<=K;k++){
                sum += gcd(i,j,k); 
            }
        }
    }
    cout <<sum<<endl;
}

Measured memory_bytes: 3632
/*************************************************************************
    > File Name: B.cpp
    > Author: PumpkinYing
    > Created Time: 2018/8/18 20:06:27
 ************************************************************************/

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
typedef long long ll;

int work(int x)
{
	int cnt = 0;
	for(int i = 1;i <= x;i++) if(x%i == 0) cnt++;
	return cnt;
}

int main()
{
	int n;
	scanf("%d",&n);
	int ans = 0;
	for(int i = 1;i <= n;i++) 
		if(i%2 == 1 && work(i) == 8) ans++;
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define FOUND '1'
#define NOT_FOUND '0'

int binarySearch(int [1000000], int, int);

int main(){
  int i, n, q, count = 0;
  int S[1000000], T[1000000];

  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++){
    if(binarySearch(S, T[i], n) == FOUND) count++;
  }
  
  printf("%d\n",count);

  return 0;
}

int binarySearch(int A[], int key, int n){
  int left = 0, right = n, mid;

  while(left < right){
    mid = (left + right) / 2;

    if(A[mid] == key) return FOUND;

    else if(key < A[mid]) right = mid;

    else left = mid + 1;
  }
  
  return NOT_FOUND;    
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<int> f(n,1);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if (h[a] > h[b]) f[b] = 0;
        else {
            f[a] = 0;
            if (h[a] == h[b]) f[b] = 0;
        }
    }
    int ans = accumulate(f.begin(), f.end(), 0);
    cout << ans << endl;
    return 0;
}

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

const int N = 1e6 + 5;
#define F first
#define S second

int main(){
    ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
    ll n  , w;
    cin >> n >> w;
    ll dd[101][w+1];
    memset(dd , 0 , sizeof(dd));

    vector<pair<ll , ll > > v;

    for (int i = 0; i < n; ++i) {
        ll x , y;
        cin >> x >> y;
        v.push_back({x , y});
    }

    for(int i = 0 ; i <= w ; i ++) {
        if(i >= v[0].F)
            dd[0][i] = v[0].S;
    }

    for(int i = 1 ; i < n ; i ++) {
        for(int j = 1 ; j <= w ; j ++) {
            if(j < v[i].F)
                dd[i][j] = dd[i-1][j];
            else {
                dd[i][j] = max(dd[i-1][j] , dd[i-1][j - v[i].F] + v[i].S);
            }
        }
    }


    cout << dd[n-1][w];

}

Measured memory_bytes: 79232
#include <iostream>
#include <string>
#define N 8
using namespace std;

string m[N];

void bomb(int x,int y){
	if(!(0<=x&&x<N&&0<=y&&y<N))return;
	if(m[x][y]!='1')return;
	m[x][y]='0';
	bomb(x+1,y);
	bomb(x+2,y);
	bomb(x+3,y);
	bomb(x-1,y);
	bomb(x-2,y);
	bomb(x-3,y);
	bomb(x,y+1);
	bomb(x,y+2);
	bomb(x,y+3);
	bomb(x,y-1);
	bomb(x,y-2);
	bomb(x,y-3);
}
int main(void){
	int n;
	int x,y;
	cin>>n;
	for(int X=1;X<=n;X++){
		int c=0;
		for(int i=0;i<N;i++)cin>>m[i];
		cin>>y>>x;
		bomb(x-1,y-1);
		cout<<"Data "<<X<<":"<<endl;
		for(int i=0;i<N;i++){
				cout<<m[i]<<endl;
		}
	}
}

Measured memory_bytes: 3144
import sys
#sys.exit()
#sorted( ,reverse=True)
#N = int(input())
#S,T = map(int, input().split())
A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]

#cnt = 0
#cnt += 1

for i in range(5):
    if A[i] ==0:
        print(i+1)
        break


#print(N)
#print(S,T)
#print(A)
#print('Yes')
#print('No')
#print(cnt)

Measured memory_bytes: 9032
#include <bits/stdc++.h>
#define inf 1e9
//#define N 100100
using namespace std;
//int a[N];
int main()
{
	/*
	int t,ans=0;
	cin>>t;
	while(t--)
	{
	    
    }
	*/
	int ans=0;
	string a,b;
	cin>>a>>b;
	int len=a.length();
	for (int i=0;i<len;i++)
	{
		if (a[i]==b[i]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
      	char[] t = sc.next().toCharArray();
      	int count = 0;
      	for(int i = 0; i < 3; i++){
        	if(s[i] == t[i]) count++;
        }
      	System.out.println(count);
    }
}

Measured memory_bytes: 35708
#include<stdio.h>
#define SIZE 1210

int main(){
    char x[SIZE];
    int str[26]={0},i=0,num=0;

    while(fgets(x,SIZE,stdin) != NULL){
        for(i = 0;x[i]!=NULL;i++){
            if(x[i] >='a' && 'z'>=x[i]){
                num=x[i]-'a';
                str[num]++;
            }else if(x[i] >='A' && 'Z'>=x[i]){
                num=x[i]-'A';
                str[num]++;
            }
        }
    }


    for(i=0;i<26;i++)
        printf("%c : %d\n",i+'a',str[i]);

return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int a,b,c;
    a=0;
    b=0;
    c=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='a')a++;
        else if(s[i] == 'b')b++;
        else c++;
    }
    if(max(max(a,b),c)-min(min(a,b),c)<= 1)cout << "YES"<<endl;
    else cout << "NO" <<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision() <<
using namespace std;
using ll = long long;

int main() {
    ll a,b,c,k;
    ll sum=0;
    cin>>a>>b>>c>>k;
    if(a>=k) sum=k;
    else if((a+b)>=k) sum=a;
    else if((a+b+c)>=k){
        sum+=a;
        k-=a;
        k-=b;
        for(int i=0;i<k;i++){
            sum--;
        }
    }
    cout<<sum;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#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 each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
ll factorial(ll a){return a < 2 ? 1 : factorial(a - 1) * a;}
ll summation(ll a){return a < 1 ? 0 : (a * a + a) / 2;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const string ALPHABETS = "abcdefghijklmnopqrstuvwxyz";
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//ll dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
ll n, m, x, y, z, w, h;
string s, t;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> x >> y >> z){
        ll ans = 0, tmp = 0, cnt = 0, mx = -INF, mn = INF;
        ll a[] = {}, b[] = {}, c[] = {};
        vll v;
        if(max({x, y, z}) % 2){
            print(max({min(x, y), min(y, z), min(z, x)}) * min({x, y, z}));
        }else{
            print(0);
        }
    }
}


Measured memory_bytes: 256
/*--ILRS-- sr4saurabh  */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define popb pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=10000000+6;
#define M_PI           3.14159265358979323846
//--------------------------------------------


//--------------------------------------------





//============================================
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
       freopen ("INPUT.txt" , "r" , stdin);
       freopen ("OUTPUT.txt", "w" , stdout);
    #endif

	//THE WATER WAS DEEP, I DROWNED AND THEN CAME FLOATING UP,DEAD!!

	
        int n ;
        cin>>n;
        int ans = 0 ;
        ll arr[n];
        for(int i = 0 ; i < n ;i++)
          cin>>arr[i];

        sort(arr,arr+n);

        for(int i = 0 ; i < n ; i++)
        {
          for(int j = i+1 ; j < n ; j++)
          {
            for(int k = j+1 ; k < n ;k++)
              if(arr[i]+arr[j] > arr[k] && arr[j]>arr[i] && arr[k]>arr[j])
                ans++;
          }
        }

        cout<<ans<<'\n';





return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

i64 sgn(i64 x){
    return x/abs(x);
}

void solve(){
    i64 n;
    cin >> n;
    vector<i64> a(n);
    rep(i,0,n) cin >> a[i];
    i64 ans=inf64;
    rep(j,0,2){
        i64 sum=0,cnt=0,p=j==0?-1:1;
        rep(i,0,n){
            sum+=a[i];
            if(sum==0 or sgn(sum)!=p){
                cnt+=abs(sum)+1;
                sum=p;
            }
            p*=-1;
        }
        ans=min(ans,cnt);
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
using namespace std;
char a[100009];
unsigned long long dp1[100009];
unsigned long long dp3[100009];
unsigned long long dp2[100009];
unsigned long long sum=0;
unsigned long long wenhao=1;
#define mood(x)  ((x)%(1000000000+7)) 
int main()
{
	ios::sync_with_stdio(false);
	cin>>(a+1);
	int len=strlen(a+1);
	
	for(int i=1;i<=len;i++)
	{	dp1[i]=dp1[i-1];
		dp2[i]=dp2[i-1];
		dp3[i]=dp3[i-1];
		if(a[i]=='A')
		{
			dp1[i]+=wenhao;
			dp1[i]=mood(dp1[i]);
		}
		else if(a[i]=='B')
		{
			dp2[i]=mood((mood(dp1[i-1])+mood(dp2[i])));
		}
		else if(a[i]=='C')
		{
			dp3[i]=mood((mood(dp2[i-1])+mood(dp3[i])));
		}
		else if(a[i]=='?')
		{   
		 
			
			dp1[i]=mood(dp1[i-1]*3+wenhao);
			dp2[i]=mood(dp2[i-1]*3+dp1[i-1]);
			dp3[i]=mood(dp3[i-1]*3+dp2[i-1]);
			wenhao*=3;
			wenhao=mood(wenhao);
		}
		
	}
	cout<<mood(dp3[len])<<endl;

	return 0;
}

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

int euclid(int a, int b) {
	int cnt = 0;
	while (a != 0 && b != 0) {
		if (a >= b) { a = a%b; }
		else { b = b%a; }
		cnt++;
	}
	return cnt;
}

int main() {
	int x, y;
	while (true) {
		cin >> x >> y;
		if (x + y == 0) { break; }
		cout << __gcd(x, y) << ' ' << euclid(x, y) << endl;
	}
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.nextLine();
		String p = scanner.nextLine();
		s = s + s;
		if (s.contains(p)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		scanner.close();
	}

}



Measured memory_bytes: 26308
n=int(input())
A=list(map(int, input().split(" ")))
count=0

xors=0
sums=0
r=0
for l in range(n):
    while (r != n and xors^A[r] == sums+A[r]):
        sums += A[r]
        xors ^= A[r]
        r += 1
    count+=r-l
    xors^=A[l]
    sums-=A[l]
print(count)


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

int main(){
	cout.precision(13);
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> cur(1 << n), nxt(1 << n);
	for(int i = 0;i < (1 << n); ++i){
		cin >> cur[i];
	}
	for(int num = 0;num < n; ++num){
		for(int i = 0;i < cur.size(); i+=2){
			int nxtv = (cur[i] == cur[i+1]?cur[i]:abs(cur[i]-cur[i+1]));
			nxt[i/2] = nxtv;
		}
		cur.swap(nxt);
	}
	cout << cur[0] << '\n';
}


Measured memory_bytes: 2432