akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#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())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int n, k;
map<int, int> memo;

int main() {
    cin >> n >> k;
    rep(i, n) {
        int a;
        cin >> a;
        memo[a]++;
    }
    vector<int> V;
    for(auto ite = memo.begin(); ite != memo.end(); ite++) {
        V.push_back(ite->second);
    }
    sort(ALL(V));
    int l = V.size();
    int ans = 0;
    if(l <= k) {
        ans = 0;
    } else {
        int n = l - k;
        rep(i, n) {
            ans += V[i];
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int A,B,C,K;
    cin >> A >> B >> C >> K;
    int cnt = 0;
    for (int i = 0; i < K; i++) {
        if (A > 0) {
            cnt = cnt + 1;
            A--;
            continue;
        } else if (B > 0) {
            cnt = cnt + 0;
            B--;
            continue;
        } else if (C > 0) {
            cnt = cnt - 1;
            C--;
            continue;
        }
    }
    cout << cnt << endl;
}


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

int main(void){
	int num;
	std::cin >> num;

	std::string event;
	int out = 0, runner = 0, point = 0;
	for(int i = 0; i < num; ++i){
		while(out < 3){
			std:: cin >> event;

			if(event == "OUT"){
				++out;		
			}else if(event == "HIT"){
				if(runner == 3){
					++point;
				}else{
					++runner;
				}
			}else if(event == "HOMERUN"){
				point += ++runner;
				runner = 0;
			}
		}
		std::cout << point << std::endl;
		out = 0, runner = 0, point = 0;
	}
	return 0;
}

Measured memory_bytes: 1204
//   Author:Arturia
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<ctime>
#include<cstdlib>
#include<string>
#include<queue>
#include<cmath>
#include<set>
#include<map>
#include<bitset>
#include<vector>
#define rep(x,a,b) for (int x=a;x<=(int)b;x++)
#define drp(x,a,b) for (int x=a;x>=(int)b;x--)
#define cross(x,a) for (int x=hd[a];~x;x=nx[x])
#define ll long long
#define inf (1<<29)
#define PII pair<int,int>
#define PDD pair<double,double>
#define mk(a,b) make_pair(a,b)
#define fs first
#define sc second
#define pb push_back
#define VI vector<int>
#define VS vector<string>
using namespace std;
inline ll rd(){
	ll x=0;int ch=getchar(),f=1;
	while (!isdigit(ch)&&(ch!='-')&&(ch!=EOF)) ch=getchar();
	if (ch=='-'){f=-1;ch=getchar();}
	while (isdigit(ch)){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}
inline void rt(ll x){
	if (x<0) putchar('-'),x=-x;
	if (x>=10) rt(x/10),putchar(x%10+'0');
		else putchar(x+'0');
}
const int maxn=2005;
int n,k,cnt,to[maxn<<1],nx[maxn<<1],hd[maxn];
void addedge(int u,int v){
	to[cnt]=v;nx[cnt]=hd[u];hd[u]=cnt++;
}
int tmp[maxn];
int f[maxn][maxn],ans;
void upd(int &x,int y){
	if (y>x) x=y;
}
void dp(int u,int fa){
	f[u][0]=1;
	cross(i,u){
		int v=to[i];
		if (v==fa) continue;
		dp(v,u);
		memcpy(tmp,f[u],sizeof tmp);
		rep(j,0,k) if (f[u][j]) rep(l,0,k-j-1) if (f[v][l]) upd(tmp[max(j,l+1)],f[u][j]+f[v][l]);
		memcpy(f[u],tmp,sizeof tmp);
	}
	rep(j,0,k) upd(ans,f[u][j]);
}
int main(){
	n=rd(),k=rd();
	memset(hd,-1,sizeof hd);
	rep(i,1,n-1){
		int u=rd(),v=rd();
		addedge(u,v),addedge(v,u);
	}
	dp(1,0);
	rt(n-ans),putchar('\n');
}

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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int r = 0; r <= N; ++r) {
    for (int g = 0; g <= N; ++g) {
      int b = (N - r * R - g * G) / B;
      if (b * B + r * R + g * G == N and b >= 0) ++ans;
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main (){
	
	int letter;
	char word [101];
	
	scanf ("%d", &letter);
	scanf ("%s", word);
	
	int len = strlen (word);
	if (len <= letter){
		
		printf ("%s", word);
		
	}else{
		
		for (int i = 0; i < letter; i++){
			
			printf ("%c", word[i]);
			
		}
		
		printf ("...\n");
	
	}

}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int sum[2][100000];

int main() {
  int n,m;
  cin>>n>>m;
  vector<tuple<int,int>> ss;
  REP(i,n){
    int s,t;
    cin>>s>>t;
    ss.emplace_back(s,t);
  }
  vector<int> p(m+1, 0);
  sum[0][0] = sum[1][0] = 0;
  REP(i,m) {
    cin>>p[i+1];
  }
  sort(begin(p),end(p));
  REP(i,m) {
    sum[i&1][i/2+1] = p[i+1] - p[i];
    if (i >= 2)
      sum[i&1][i/2+1] += sum[i&1][i/2];
  }
  int64_t ans = 0;
  REP(i,n){
    int s,t;
    tie(s,t)=ss[i];
    int inds = lower_bound(begin(p),end(p),s) - begin(p);
    int indt = lower_bound(begin(p),end(p),t) - begin(p);
    if (inds == indt) {
      ans += max(s,t) - min(s,t);
      continue;
    }
    int64_t ansl = 0;
    if (s > t) {
      ansl += s - p[inds - 1];
      if (((inds + indt) % 2) == 0)
        ansl += p[indt] - t;
      if ((inds % 2) == 1)
        ansl += sum[0][inds/2] - sum[0][(indt+1)/2];
      else
        ansl += sum[1][(inds-1)/2] - sum[1][indt/2];
    } else {
      ansl += p[inds] - s;
      if (((inds + indt) % 2) == 0)
        ansl += t - p[indt - 1];
      if ((inds % 2) == 1)
        ansl += sum[0][indt/2] - sum[0][(inds+1)/2];
      else
        ansl += sum[1][(indt-1)/2] - sum[1][inds/2];
    }
    //cout << ansl << endl;
    ans += ansl;
  }
  cout << ans << endl;
  return 0;
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int N;
  cin>>N;
  string s;
  cin>>s;
  int cnt(0);
  for(int i(0);i<N;i++){
    if(s[i] == 'W') cnt++;
  }
  int ans(0);
  for(int i(0);i<cnt;i++){
    if(s[N-i-1] == 'R') ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,n) for(int i=0;i<n;i++)
int main()
{
	string s,t;
	cin>>s>>t;
	int n=s.length();
	int m=t.length();
	if(n==0||n>10)
	cout<<"No"<<endl;
	else if(m!=n+1)
	cout<<"No"<<endl;
	else
	{
		int k=0;
		for(int i=0;i<n;i++)
		{
			if(s[i]!=t[i])
			{
				k=1;
				break;
			}
		}
		if(k==0)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3596
# ITP1_6_D
# ベクトルと行列の積

a = []
b = []
c = []
n, m  = map(int, input().split())
[a.append(list(map(int, input().split()))) for i in range(n)]
[b.append(int(input())) for i in range(m)]

for i in range(n):
    ab = 0
    for j in range(m):
        ab += a[i][j] * b[j]
    c.append(ab)

[print(i) for i in c]



Measured memory_bytes: 6028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int r =int.Parse(Console.ReadLine());
            int ans = 0;


            {
                Console.WriteLine(3 * r * r);
            }
            
        }
    }

}


Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<cmath>
#include<typeinfo>
#include<vector>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
int main(int argc, char const *argv[]) {
    int n,min=1e+9,max=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]<=min)min=a[i];
        if(a[i]>=max)max=a[i];
    }

    cout << max - min << endl;

}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n + m == 0) return 0;
    
    vector<int> x(m);
    for (int i = 0; i < n; i++) {
      int d, v;
      cin >> d >> v;
      d--;
      x[d] = max(x[d], v);
    }
    
    int ans = 0;
    for (int i = 0; i < m; i++) ans += x[i];
    
    cout << ans << '\n';
  }
}


Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl

const int MAX_V = 100000;
vector<vector<int>> fto(MAX_V);
vector<vector<int>> bto(MAX_V);
vector<int> col(MAX_V);
// mp[i] stores the number of vertices with i-th color.
unordered_map<int, int> mp;

void dfs(int v, int p, int c) {
  col[v] = c;
  mp[c]++;
  for(auto w : fto[v]) {
    if(col[w] >= 0) continue;
    dfs(w, v, c);
  }
  return;
}

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  fto.resize(n);
  bto.resize(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    fto[a].push_back(b);
    fto[b].push_back(a);
  }
  rep(i, k) {
    int c, d;
    cin >> c >> d;
    c--, d--;
    bto[c].push_back(d);
    bto[d].push_back(c);
  }
  col.resize(n);
  col.assign(n, -1);

  int ncol = 0;
  rep(i, n) {
    if(col[i] < 0) {
      dfs(i, -1, ncol);
      ncol++;
    }
  }
  rep(i, n) {
    int ans = mp[col[i]] - fto[i].size() - 1;
    for(auto j : bto[i])
      if(col[i] == col[j]) ans--;
    cout << ans;
    if(i != n - 1) cout << ' ';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 13440
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
#define MAX(a, b) ((ll)(a) > (ll)(b)) ? (a) : (b)
#define MIN(a, b) ((ll)(a) > (ll)(b)) ? (b) : (a)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 1000000007;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1}};


ll N, M;
ll cost[100005];
vector<ll> e[100005];

ll parent[100005];
ll vis[100005];
priority_queue < ll, std::vector<ll>, greater<ll>> q[100005];

void dfs(ll x, ll p) {
	parent[x] = p;

	q[p].push(cost[x]);
	rep(i, e[x].size()) {
		if(parent[e[x][i]] == -1)
		dfs(e[x][i], p);
	}


}



int main() {
	ll x, y;
	cin >> N >> M;

	rep(i, N)
		parent[i] = -1;


	rep(i, N)
		cin >> cost[i];


	rep(i, M) {
		cin >> x >> y;
		e[x].push_back(y);
		e[y].push_back(x);

	}

	rep(i, N) {
		if (parent[i] == -1) {
			dfs(i, i);
		}
	}


	if (M == N - 1) {
		cout << 0 << endl;
		return 0;
	}


	ll ans = 0, num_seibun = 0;
	vector<ll> rest;
	rep(i, N) {
		if (vis[parent[i]] == 0) {
			ans += q[parent[i]].top();
			q[parent[i]].pop();
			num_seibun += 1;
			vis[parent[i]] = 1;
			while (q[parent[i]].size() != 0) {
				rest.push_back(q[parent[i]].top());
				q[parent[i]].pop();
			}
		}
	}

	sort(rest.begin(), rest.end());

	if (rest.size() < (2 * (num_seibun-1) - num_seibun)) {
		cout << "Impossible" << endl;
		return 0;
	}

	rep(i, (2 * (num_seibun-1) - num_seibun)) {

		ans += rest[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 14068
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif



static void B_task();

int main()
{
	B_task();
	
	fflush(stdout);
	return 0;
}
static void B_task()
{
	char szS[500] = { 0 };

	scanf(" %s", szS);

	int len = strlen(szS);
	int lose = 0;
	for (int i = 0; i < len; i++) {
		if (szS[i] == 'x') {
			lose++;
		}
	}
	const char *ans = "YES";
	if (lose > 7) {
		ans = "NO";
	}

	printf("%s\n", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define mp make_pair
const int mod=1e9+7;

int a,b,c;
void solve()
{
  int n,x,y;
  cin>>n>>x>>y;
  map<pair<int,int>,int> m;
  for(int i=1;i<=n;i++)
  {
    for(int j=i+1;j<=n;j++)
    {
      a=min(abs(i-j),abs(x-i)+1+abs(y-j));
      b=min(a,abs(i-y)+1+abs(j-x));
      m[mp(i,j)]=b;
    }
  }
  map<pair<int,int>,int>::iterator it;
  map<int,int> um;
  ll c=0;
  for(it=m.begin();it!=m.end();it++)
  {
    um[it->second]++;
    c++;
  }
  map<int,int>::iterator i;
  ll cnt=0;
  for(i=um.begin();i!=um.end();i++)
  {
    cout<<i->second<<endl;
    cnt++;
  }
  ll f=n-1-cnt;
  for(int i=0;i<f;i++)
  cout<<0<<endl;
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 125312
n,m=gets.split.map(&:to_i)
xyzs=$stdin.read.split.map(&:to_i).each_slice(3)

tmp = Array.new(8) { Array.new }

xyzs.each do |x,y,z|
  # x,y,z=[x,y,z].map(&:abs)
  l = 0
  [-1,1].each do |i|
    [-1,1].each do |j|
      [-1,1].each do |k|
        tmp[l] << x*i+y*j+z*k
        l += 1
      end
    end
  end
end


if 0 < m
  ret = nil
  
  tmp.each do |ns|
    t = ns.sort_by{|n|-n}[0..m-1].inject(&:+)
    ret = t if !ret || ret < t
  end

  p ret
else
  p 0
end

Measured memory_bytes: 2040
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

const int MAX_N = 200050;
int H, W, N;
int X[MAX_N], Y[MAX_N];

int possible[MAX_N];

std::set<std::pair<int, int>> st;

int main(int argc, char **argv) {
    std::cin >> H >> W >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> X[i] >> Y[i];
    }

    for (int i = 1; i <= N; i++) {
        st.insert(std::pair<int, int>({X[i], Y[i]}));
    }

    for (int i = 1; i <= W; i++) {
        possible[i] = H;
    }
    possible[1] = 1;

    int cur_x = 1;
    int cur_y = 1;
    for (int i = 1; i <= H; i++) {
        if (st.find(std::pair<int, int>({i+1, cur_y})) != st.end()) {
            break;
        }
        cur_x++;
        if (st.find(std::pair<int, int>({cur_x, cur_y+1})) == st.end()) {
            cur_y++;
            possible[cur_y] = cur_x;
            //std::cout << "c:" << cur_y << " " << cur_x << std::endl;
        }
    }

    int ret = H;
    for (int i = 1; i <= N; i++) {
        if (X[i] > possible[Y[i]]) {
            ret = std::min(ret, X[i] - 1);
        }
    }

    std::cout << ret << std::endl;
    
    return 0;
}


Measured memory_bytes: 11904
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll x;
ll s[210];

ll dp[210][100100];

ll mod_pow(ll x, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

ll mod_inverse(ll x) {
    return mod_pow(x, mod-2);
}

const int max_n = 210;
ll fact[max_n];
ll fact_inv[max_n];
void calc_fact() {
    fact[0] = 1;
    for (ll i = 1; i < max_n; i++)
        fact[i] = (fact[i-1] * i) % mod;
    fact_inv[max_n-1] = mod_inverse(fact[max_n-1]);
    for (ll i = max_n-2; i >= 0; i--)
        fact_inv[i] = (fact_inv[i+1] * (i+1)) % mod;
}
ll mod_comb(ll n, ll k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return (fact[n] * fact_inv[k] % mod) * fact_inv[n-k] % mod;
}
ll mod_perm(ll n, ll k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return fact[n] * fact_inv[n-k] % mod;
}

ll calc(int pos, ll X) {
    if (dp[pos][X] < 0) {
        if (pos == 0) {
            dp[pos][X] = X % s[pos];
        } else {
            ll res = calc(pos-1, X%s[pos]);
            res += calc(pos-1, X) * pos;
            res %= mod;
            dp[pos][X] = res;
        }
    }
    return dp[pos][X];
}

ll solve() {
    sort(s, s+n);
    calc_fact();
    memset(dp, -1, sizeof(dp));
    
    return calc(n-1, x);
}

void input() {
    cin >> n >> x;
    for (int i = 0; i < n; i++) cin >> s[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 164480
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  long long N;
  scanf("%lld", &N);
  std::map<long long, int > mp;
  for (int i=2; (long long)i*i<=N; i++){
    while (N%i==0){
      mp[i]++;
      N=N/i;
    }
  }
  if (N!=1) mp[N]++;
  int ans =0;
  for (auto &entry:mp){
    int j=1;
    while (j*(j+1)/2<=entry.second){
      j++;
    }
    ans += j-1;
  }
  
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 3256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i< n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> state;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};
char field[50][50];
map<int, int> memo[40][40];

int main(){
  int H, W;
  int sx, sy, gx, gy;
  while(cin >> W >> H && (H || W)){
    rep(i, 40)rep(j, 40) memo[i][j].clear();
    fill(&field[0][0], &field[0][0] + 50 * 50, '#');
    rep(i, H)rep(j, W){
      cin >> field[i+1][j+1];
      if(field[i+1][j+1] == '@'){
	sx = j + 1;
	sy = i + 1;
	field[i+1][j+1] = '.';
      }
      if(field[i+1][j+1] == '<'){
	gx = j + 1;
	gy = i + 1;
	field[i+1][j+1] = '.';
      }
    }

    memo[sx][sy][0] = 0;
    queue<state> que;
    que.push(state(0, P(sx, sy)));
    int res = -1;
    while(!que.empty()){
      state s = que.front();
      que.pop();
      int mask = s.first;
      int x = s.second.first;
      int y = s.second.second;
      int c = memo[x][y][mask];
      //      cout << y << " " << x << " " << mask << " " << c << endl;
      if(x == gx && y == gy) {
	res = c;
	break;
      }
      rep(i, 4){
	int x2 = x + dx[i];
	int y2 = y + dy[i];
	if(field[y2][x2] == '.'){
	  if(memo[x2][y2].find(mask) == memo[x2][y2].end()) {
	    memo[x2][y2][mask] = c + 1;
	    que.push(state(mask, P(x2, y2)));
	  }
	}else if(islower(field[y2][x2])){
	  int mask2 = mask ^ (1 << (field[y2][x2] - 'a'));
	  if(memo[x2][y2].find(mask2) == memo[x2][y2].end()){
	    memo[x2][y2][mask2] = c + 1;
	    que.push(state(mask2, P(x2, y2)));
	  }
	}else if(isupper(field[y2][x2])){
	  if((mask & (1 << (field[y2][x2] - 'A')))
	     && memo[x2][y2].find(mask) == memo[x2][y2].end()){
	    memo[x2][y2][mask] = c + 1;
	    que.push(state(mask, P(x2, y2)));
	  }
	}
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 7220
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    for(int i = 0; i < 2; i++){
        if(s[i] != s[i + 1]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
struct Node{
  int no;
  int par;
  vector<Node*> child;
  void build(int i){
    no=i;par=i;
  }
};
struct UnionFind {
    int n;
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> group;
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
        n=N;
    }
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void calc(){
        group.resize(n,0);
        for(int i=0;i<n;i++){
            group[root(i)]++;
        }
    }
    int size(int x){
        return group[root(x)];
    }
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
 
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
 
};

signed main(){
    int n;cin>>n;
    vector<pair<P,int>> a(n);
    rep(i,n){
        cin>>a[i].first.first>>a[i].first.second;
        a[i].second=i;
    }
    sort(a.begin(),a.end());
    vector<Node> node(n);
    vector<pair<int,P>> edge;
    rep(i,n-1){
        node[a[i].second].child.push_back(&node[a[i+1].second]);
        node[a[i+1].second].child.push_back(&node[a[i].second]);
        edge.push_back({abs(a[i+1].first.first-a[i].first.first),{a[i].second,a[i+1].second}});
    }
    rep(i,n){
        swap(a[i].first.first,a[i].first.second);
    }
    sort(a.begin(),a.end());
    rep(i,n-1){
        node[a[i].second].child.push_back(&node[a[i+1].second]);
        node[a[i+1].second].child.push_back(&node[a[i].second]);
        edge.push_back({abs(a[i+1].first.first-a[i].first.first),{a[i].second,a[i+1].second}});
    }
    int res=0;
    int sm=1;
    sort(edge.begin(),edge.end());
    UnionFind tree(n);
    int cur=0;
    while(sm<n){
        P buf=edge[cur].second;
        if(!tree.same(buf.first,buf.second)){
            tree.unite(buf.first,buf.second);
            res+=edge[cur].first;
            ++sm;
        }
        ++cur;
    }
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 18864
def combinations(R, G, B, N):
    R, G, B, N = int(R), int(G), int(B), int(N)
    sorted_tuple = sorted((R, G, B), reverse=True)
    R = sorted_tuple[0]
    G = sorted_tuple[1]
    B = sorted_tuple[2]
    number_combos = 0

    for x in range(N // R + 1):
        for y in range((N - R * x) // G + 1):
            if (N - R * x - G * y) % B == 0:
                number_combos += 1
        
    return number_combos

R, G, B, N = input().split(' ')
print(combinations(R, G, B, N))

Measured memory_bytes: 3064
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, mut x, mut d) = (v[0], v[1], v[2]);
    if d == 0 {
        if x == 0 {
            println!("1");
            return;
        }
        println!("{}", n + 1);
        return;
    }
    if d < 0 {
        x *= -1;
        d *= -1;
    }
    let mut spans = HashMap::new();
    spans.entry(0).or_insert(vec![(0, 0)]);
    for i in 1..n + 1 {
        let modd = (d + (x * i) % d) % d;
        let mut span = spans.entry(modd).or_insert(Vec::<(i64, i64)>::new());
        let l = i * (i - 1) / 2;
        let r = n * (n - 1) / 2 - (n - i) * (n - i - 1) / 2;
        span.push(((x * i + l * d - modd) / d, (x * i + r * d - modd) / d));
    }
    let mut ans = 0;
    for spans_each_mod in spans.values() {
        let mut events = vec![];
        for &(l, r) in spans_each_mod {
            events.push((l, 0));
            events.push((r, 1));
        }
        events.sort();
        let mut l_count = 0;
        let mut start = 0;
        for (cur, kind) in events {
            if kind == 0 {
                if l_count == 0 {
                    start = cur;
                }
                l_count += 1;
            } else {
                l_count -= 1;
                if l_count == 0 {
                    ans += cur - start + 1;
                }
            }
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 26820
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	A := ScanInt(scanner)
	B := ScanInt(scanner)
	K := ScanInt(scanner)
	
	if B - A + 1 >= 2 * K {
    	for i := A; i < A + K; i++ {
    	    fmt.Println(i)
    	}
    	for i := B - K + 1; i <= B; i++ {
    	    fmt.Println(i)
    	}
    } else {
        for i := A; i <= B; i++ {
            fmt.Println(i)
        }
    }
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func ScanText(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

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

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

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}
 

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
vector<vector<int > > field;

int search(int i, int j, int k)
{
    if(k == 0){
        return 1;
    }
    int ans = 0;
    for(int l = 0; l < field[j].size(); l++){
        if(i == field[j][l]){
            continue;
        }
        ans += search(j, field[j][l], k - 1);
    }
    return ans + 1;
}


int main() {
    int n, k;
    cin >> n >> k;
    for(int i = 0; i <= n; i++){
        vector<int> in;
        field.push_back(in);
    }
    int in1[10000];
    int in2[10000];
    for(int i = 1; i <= n - 1; i++){
        cin >> in1[i] >> in2[i];
        field[in1[i]].push_back(in2[i]);
        field[in2[i]].push_back(in1[i]);
    }
    int ans_c = 0;
    if(k % 2 == 0){
        for(int i = 1; i <= n; i++){
            int rest = search(0, i, k / 2);
            ans_c = max(ans_c, rest);
        }
    } else {
        for(int i = 1; i <= n - 1; i++){
            vector<int>::iterator itr = find(field[in1[i]].begin(), field[in1[i]].end(), in2[i]);
            field[in1[i]].erase(itr);
            itr= find(field[in2[i]].begin(), field[in2[i]].end(), in1[i]);
            field[in2[i]].erase(itr);
            int rest = search(0, in1[i], k / 2) + search(0, in2[i], k / 2);
            ans_c = max(ans_c, rest);
            field[in1[i]].push_back(in2[i]);
            field[in2[i]].push_back(in1[i]);
        }
    }
    cout << n - ans_c << endl;


    return 0;
}

Measured memory_bytes: 512
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, a, b;
    cin >> n >> a >> b;

    cout << min(a * n, b) << endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a,b;
int main(){
	cin>>n>>a>>b;
	int c = min(a,b);
	int d = a+b-n;
	cout<<c<<" "<<max(0,d)<<endl;
}

Measured memory_bytes: 764
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int count = 0;
            for(int i = 0; i < 3; i++)
            {
                if(S[i]== 'o')
                {
                    count++;
                }
            }
            Console.WriteLine(700 + 100 * count);
        }
    }
}

Measured memory_bytes: 11092
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353


double A,B,H,M;

signed main(){
    scanf("%lf %lf %lf %lf",&A,&B,&H,&M);
    double ans=0;
    double angleH=M_PI*2.0*(H*60.0+M)/(60.0*12.0);
    double angleM=M_PI*2.0*M/60.0;
    double angle=abs(angleH-angleM);
    ans=sqrt(A*A+B*B-2*A*B*cos(angle));
    printf("%.15lf\n",ans);
    return 0;
}


Measured memory_bytes: 2496
#include <bits/stdc++.h>
using namespace std;
int cnt;
string a;
deque<char>dq;
signed main(){
    cin>>a>>a;
    for(char c:a){
        if(c==')'){
            if(cnt==0)dq.push_front('(');
            else cnt--;
        }
        else cnt++;
        dq.push_back(c);
    }
    for(char c:dq)putchar(c);
    while(cnt-->0)putchar(')');
    return 0;
}


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

int gcd(int a, int b){
  if(a < b) return gcd(b, a);
  if(b == 0){
    return a;
  }
  int r;
  while((r = a%b)){
    a = b;
    b = r;
  }
  return b;
}

int main() {
    ll N;
    cin >> N;
	vector<ll> A(N);
	rep(i, N) {
		cin >> A[i];
	}

	vector<int> SL(N + 1);
	for (int i = 0; i < N; i++) {
		SL[i + 1] = gcd(SL[i], A[i]);
	}

	vector<int> SR(N + 1);
	for (int i = N - 1; i >= 0; i--) {
		SR[i] = gcd(SR[i + 1], A[i]);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		int l = SL[i];
		int r = SR[i + 1];
		ans = max(ans, gcd(l, r));
	}

	cout << ans << endl;
}


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

int main(){
    int n;
    char s;
    bool f = false;

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> s;
        if(s == 'Y'){
            f = true;
        }
    }

    if(f){
        cout << "Four" << endl;
    }else{
        cout << "Three" << 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);
      int N = sc.nextInt();
      int[] A = new int[N];
      long sum = 0;
      HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
      for(int i=0;i<N;i++){
        A[i] = sc.nextInt();
        if(map.containsKey(A[i])){
          sum+=map.get(A[i]);
          map.put(A[i],map.get(A[i])+1);
        }else{
          map.put(A[i],1);
        }
      }
      for(int i=0;i<N;i++){
        System.out.println(sum-(map.get(A[i])-1));
      }
    }
}

Measured memory_bytes: 70496
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



bool check[100005];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  string str; cin >> str;
  
  for(ll i = 1; i<= str.size()-1; i++){
    ll s = str.size()-i;
    if(s % 2 == 1) continue;

    bool flag = true;
    rep(j,s/2){
      if(str[j] != str[j+s/2]){
	flag = false;
	break;
      }
    }
    if(flag) {
      cout << s << endl;
      return 0;
    }
  }
				       
  
  
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	int n, c;
	cin >> n >> c;
	int d[c][c];
	int color[3][c];
	rep(i,3)rep(j,c) color[i][j]=0;
	rep(i,c)rep(j,c) cin >> d[i][j];
	rep(i,n)rep(j,n){
		int x;
		cin >> x;
		color[(i+j)%3][x-1]++;
	}
	ll ans = INF;
	rep(i,c)rep(j,c)if(i!=j)rep(k,c)if(i!=k&&j!=k) {
		ll tmp = 0;
		rep(l,c) tmp += color[0][l]*d[l][i];
		rep(l,c) tmp += color[1][l]*d[l][j];
		rep(l,c) tmp += color[2][l]*d[l][k];
		chmin(ans, tmp);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
int main(){
	int k;
	cin>>k;
	int ans=0;
	for(int i=2;i<=k;i+=2)
	for(int j=1;j<=k;j+=2)
	ans++;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;


class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        //2つずつ
        List<int> hoge = new List<int>();
        for (int i = 1; i < 1000; i++)
        {
            if(n == (i * (i - 1)) / 2)
            {
                Console.WriteLine("Yes");
                Console.WriteLine(i);
                List<int>[] res = Enumerable.Repeat(0, i).Select(_ => new List<int>()).ToArray();
                int p = 1;
                for (int j = 0; j < i - 1; j++)
                {
                    for (int k = j + 1; k < i; k++)
                    {
                        res[j].Add(p);
                        res[k].Add(p);
                        p++;
                    }
                }
                Console.WriteLine(string.Join("\n", res.Select(x => $"{res[0].Count} {string.Join(" ", x)}")));
                return;
            }
        }
        Console.WriteLine("No");
    }
}

Measured memory_bytes: 23504
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
	char  x[100007];
	while(~scanf("%s",x))
	{
		int flag=0;
		int l =strlen(x);
		for(int i=0;i<l;)
		{
			if(x[i]=='e'){	
			if(x[i]=='e'&&i+5<=l)
			{
				if(x[i+1]=='r'&&x[i+2]=='a'&&x[i+3]=='s'&&x[i+4]=='e')
					i=i+5;
				else {

					flag=1;
					break;
				}
				if(i+1<=l&&x[i]=='r')
					i++;
			}
			else
			{
				flag=1;
				break;
			}
			}
			else{

			
			if(x[i]=='d'&&i+5<=l)
			{

				if(x[i+1]=='r'&&x[i+2]=='e'&&x[i+3]=='a'&&x[i+4]=='m')
					i+=5;
				else{
					flag=1;
					break;
				}
				if(i+2<=l&&x[i]=='e'&&x[i+1]=='r'&&(x[i+2]=='e'||x[i+2]=='d'||x[i+2]=='\0'))
				{
					i+=2;
				}
				
			}
			else
			{
				flag=1;
				break;
			}
		}
		}
		if(flag==1)
		{
			printf("NO\n");
		}
		else
			printf("YES\n");
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() {
  int A,ans;
  ans=0;
  int p;
  cin >>A;
  if(A<100){
  cout << "Bad"<<endl;
    return 0;
  }
  else if(A<1000){
  rep(i, 2){
    if(A%10==A/10%10){
      cout << "Bad"<<endl;
    return 0;
    }
    A/=10;
  }  
  }else {
  rep(i, 3){
    if(A%10==A/10%10){
      cout << "Bad"<<endl;
    return 0;
    }
    A/=10;
  }
  }
  cout << "Good"<<endl;
}

Measured memory_bytes: 256
import sys
import heapq
from functools import lru_cache


# \n
def input():
    return sys.stdin.readline().rstrip()


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

    n = N // 3

    @lru_cache(maxsize=None)
    def diff(s):
        count = 0
        for i in range(N):
            if A[i] == B[(i + s) % N]:
                count += 1

        if count == 0:
            print("Yes")
            L = []
            for i in range(N):
                L.append(B[(i + s) %N])
            print(*L)
            exit()

        return count

    l = 0
    r = N - 1
    diff(l)
    diff(r)

    while r - l > 2:
        a = diff(l + (r - l) // 3)
        b = diff(l + 2 * (r - l) // 3)
        if a > b:
            l = l + (r - l) // 3
        else:
            r =l + 2 * (r - l) // 3
    diff((l+r)//2)

    print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 126224
#include <stdio.h>

int main()
{
	int n; scanf("%d ",&n);
	int count=0;
	char s[n];
	for (int i = 0; i < n; ++i)
	{
		scanf("%c",&s[i]);
		if(s[i]=='R'){
			count++;
		}else{
			count--;
		}
	}

	if(count>0){
		printf("Yes\n");
	}else{
		printf("No");
	}
	return 0;
}


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

using namespace std;

int main(){
  int A, B, C;
  cin >> A; cin >> B; cin >> C;
  if((A==B && B==C) || (A!=B && B!=C && A!=C))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+7;
int f[maxn],s[maxn],x[maxn];
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x[i]);
		f[i]=max(f[i-1],x[i]);
	}
	for(int i=n;i>=1;i--)
	{
		s[i]=max(s[i+1],x[i]);
	}
	for(int i=1;i<=n;i++)
	{
		cout<<max(f[i-1],s[i+1])<<endl;
	}
}

Measured memory_bytes: 3968
n = int(input())
t = 0
x = 0
y = 0
flag = True
for i in range(n):
    ti, xi, yi = map(int, input().split())
    if ti % 2 != (xi + yi) % 2:
        flag = False
    elif abs(xi - x) + abs(yi - y) > ti - t:
        flag = False
    t, x, y = ti, xi, yi
if flag:
    print('Yes')
else:
    print('No')

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

#include <atcoder/segtree>
#define repp(i, l, r) for (long long i = (l); i < (r); i++)
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define per(i, n) for (long long i = (n); i >= 0; --i)
#define all(v) v.begin(), v.end()
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long int MOD = 1000000007;
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int, int>;
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;
}

const int MAX_A = 300005;

int op(int a, int b) { return max(a, b); }
int e() { return 0; }  //和の単位元は0

//ミョ(-ω- ?)
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    vector<int> a(n, 0);
    rep(i, n) cin >> a[i];
    segtree<int, op, e> dp(MAX_A);

    rep(i, n) {
        int x = a[i];
        int l = max(0, x - k);
        int r = min(x + k + 1, MAX_A);
        int now = dp.prod(l, r) + 1;
        dp.set(x, now);
    }
    cout << dp.all_prod() << "\n";
    cerr << "解説放送AC\n";
    return 0;
}

Measured memory_bytes: 9748
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,s,n) for(ll (i)=(s);(i)<(n);(i)++)
#define repd(i,s,n) for(ll (i)=(n-1);(i)>=(s);(i)--)
#define FOR(i,s,n) for(ll (i)=(s);(i)<=(n);(i)++)
#define all(x) x.begin(),x.end()
#define size(x) ((ll)(x).size()
#define PB push_back

int main(){
   int a,b,c,d;
   cin >> a >> b >> c >>d;
   while(1){
     c=c-b;
      if(c<1){
       cout << "Yes" << endl;
       return 0;
     }
     a=a-d;
     if(a<1){
       cout << "No" << endl;
       return 0;
     }
   }
}  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <atcoder/segtree>
#include <atcoder/dsu>

using namespace std;

int f(int a, int b){return a + b;}
int e(){return 0;}

int main(){
    int n;
    cin >> n;
    vector<int> X(n), Y(n);
    vector<array<int, 3>> Z(n);
    for (int i = 0; i < n; i++){
        cin >> X[i] >> Y[i];
        Z[i] = {--Y[i], --X[i], i};
    }
    
    sort(Z.begin(), Z.end());
    set<array<int, 2>> S, T;
    atcoder::dsu dsu(n);

    for (const auto &[y, x, i]: Z){
        if (S.size() == 0){
            S.insert({x, i});
            continue;
        }
        auto it = S.lower_bound({x, i});
        for (int j = 0; j < 50 and it != S.begin(); j++){
            --it;
            dsu.merge(i, (*it)[1]);
        }
        S.insert({x, i});
    }

    sort(Z.begin(), Z.end(), greater<array<int, 3>>());

    for (const auto &[y, x, i]: Z){
        if (T.size() == 0){
            T.insert({x, i});
            continue;
        }
        auto it = T.lower_bound({x, i});
        for (int j = 0; j < 50 and it != T.end(); j++){
            dsu.merge(i, (*it)[1]);
            ++it;
        }
        T.insert({x, i});
    }

    for (int i = 0; i < n; i++)
        cout << dsu.size(i) << endl;

}


Measured memory_bytes: 26760
#include <stdio.h>

int main() {
	int N, K;
	double p[200000] = { 0 };
	double	ans = 0.0, sum = 0.0;
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%lf", &p[i]);
	}
	for (int i = 0; i < N; i++) {
		p[i] = (p[i] + 1) / 2;
	}
	for (int j = 0; j < K; j++) {
		sum = sum + p[j];
	}
	ans = sum;
	for (int i = 0; i < N - K; i++) {
		sum = sum - p[i] + p[i + K];
		if (sum > ans) {
			ans = sum;
		}
	}
	printf("%f", ans);
	return 0;
}

Measured memory_bytes: 1664
n,m=map(int,input().split())
l=[[0]*2 for i in range(n)]
l[0][0]=1
for i in range(n-1):
    l[i+1][1]=1
for i in range(m):
    a,b=map(int,input().split())
    a=a-1
    b=b-1
    if l[a][0]>0:
        l[a][0]-=1
        l[b][0]+=1
    else:
        l[a][1]-=1
        l[b][1]+=1
    if l[b][0]>0:
        l[b][0]+=l[b][1]
        l[b][1]=0

ans=0
for i in range(n):
    if l[i][0]>0:
        ans+=1
print(ans)
       
        

Measured memory_bytes: 13172
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 100005

int main() {

	LL n, i, j,k,arr[MAX] = {0};

	cin>>n;

	for(i = 1; i <= 100; i++) {
		for(j = 1; j <= 100; j++) {
			for(k = 1; k <= 100; k++) {

				LL f = i*i + j*j + k*k + i*j + j*k + k*i;

				if(f < MAX) arr[f]++;
			}
		}
	}

	for(i = 1; i <= n;i++) {
		cout<<arr[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 4372
#include<bits/stdc++.h>
using namespace std;
#define N 2333
#define mod 924844033

int n,k,h[2*N],f[2*N][N],ans;

void pls(int &x,int y) {x=(x+y)%mod;}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();k=read();
	for (int i=1,t=0;i<=k;i++)
		h[t+=1+(n-i)/k]=1,h[t+=1+(n-i)/k]=1;
	f[0][0]=1;
	for (int i=0;i<=2*n;i++)
		for (int j=0;j<=n;j++){
			pls(f[i+1][j],f[i][j]);
			if (!h[i+1]) pls(f[i+2][j+1],f[i][j]);
		}
	for (int i=n,t=1;i>=0;i--,t=1ll*t*(n-i)%mod)
		ans=(ans+(i%2?-1ll:1ll)*f[2*n][i]*t)%mod;
	printf("%d\n",(ans+mod)%mod);return 0;
}

Measured memory_bytes: 37120
using System;
class Program
{
	static void Main(string[] args)
	{
       int N = int.Parse(Console.ReadLine());
       int K = int.Parse(Console.ReadLine());
       int X = int.Parse(Console.ReadLine());
       int Y = int.Parse(Console.ReadLine());
       int result = 0;
       if(K < N)
       {
          result += (K * X + (N-K) * Y);
       }
       else
       {
          result += (N * X);
       }
       Console.WriteLine(result);
	}
}



Measured memory_bytes: 11092