akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=3005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        
        vector<string> S(N);
        for(int i=0;i<N;i++){
            cin>>S[i];
        }
        
        for(int i=0;i<N;i++){
            for(int j=S[i].size()-1;j>=0;j--){
                if(S[i][j]=='.'){
                    S[i][j]='+';
                    break;
                }
            }
        }
        
        for(int i=0;i<N;i++){
            for(int j=0;j<S[i].size();j++){
                if(S[i][j]=='.'){
                    int a=i,b=i;
                    while(a>=0&&S[a].size()>j&&(S[a][j]=='.'||S[a][j]=='|'||S[a][j]==' ')) a--;
                    while(b<N&&S[b].size()>j&&(S[b][j]=='.'||S[b][j]=='|'||S[b][j]==' ')) b++;
                    if(a>=0&&S[a].size()>j&&S[a][j]=='+'&&b<N&&S[b].size()>j&&S[b][j]=='+') S[i][j]='|';
                    else S[i][j]=' ';
                }
            }
        }
        
        for(int i=0;i<N;i++){
            cout<<S[i]<<endl;
        }
    }
}



Measured memory_bytes: 3376
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
    string S, P;
    cin >> S >> P;
    S = S + S;
    cout << (S.find(P) == string::npos ? "No" : "Yes") << endl;
}


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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;

struct bipartiteGraph {
    int L, R;
    vector<vector<int>> adj;
    vector<int> mate;
    bipartiteGraph(int L, int R) : L(L), R(R), adj(L+R), mate(L+R, -1) { }
    void add_edge(int u, int v) {
        adj[u].push_back(v+L);
        adj[v+L].push_back(u);
    }
    int maximum_matching() {
        vector<int> visited(L);
        function<bool(int)> augment = [&](int u) { // DFS
            if (visited[u]) return false;
            visited[u] = true;
            for (int w: adj[u]) {
                int v = mate[w];
                if (v < 0 || augment(v)) {
                    mate[u] = w;
                    mate[w] = u;
                    return true;
                }
            }
            return false;
        };
        int match = 0;
        for (int u = 0; u < L; ++u) {
            fill(visited.begin(),visited.end(), 0);
            if (augment(u)) ++match;
        }
        return match;
    }
    int lPartner(int l){return mate[l]-L;}
    int rPartner(int r){return mate[r+L];}
};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  ll A[N];
  vll po,ne;
  for(ll i=0;i<N;i++){
    cin>>A[i];
    if(A[i]>=0)po.push_back(A[i]);
    else ne.push_back(A[i]);
  }
  if(N==2){
    cout<<max(A[0],A[1])-min(A[0],A[1])<<endl;
    cout<<max(A[0],A[1])<<" "<<min(A[0],A[1])<<endl;
    return 0;
  }
  sort(po.begin(),po.end());
  sort(ne.begin(),ne.end());
  vector<pair<ll,ll>> ans;
  ll pf=0,nf=0;
  if((ll)po.size()==N){
    ll neg=po[pf++];
    ll pos=po.back();po.pop_back();
    ans.emplace_back(neg,pos);
    ne.push_back(neg-pos);
  }else if((ll)ne.size()==N){
    ll pos=ne.back();ne.pop_back();
    ll neg=ne[nf++];
    ans.emplace_back(pos,neg);
    po.push_back(pos-neg);
  }else{
    ll pos=po.back();po.pop_back();
    ll neg=ne.back();ne.pop_back();
    if(po.size()-pf>ne.size()-nf){
      ans.emplace_back(neg,pos);
      ne.push_back(neg-pos);
    }else{
      ans.emplace_back(pos,neg);
      po.push_back(pos-neg);
    }
  }
  for(ll i=1;i<N-1;i++){
    ll pos,neg;
    if(po.size()-pf>0){
      pos=po.back();po.pop_back();
    }else{
      pos=ne.back();ne.pop_back();
    }
    if(ne.size()-nf>0){
      neg=ne[nf++];
    }else{
      neg=po[pf++];
    }
    if(po.size()-pf>ne.size()-nf){
      ans.emplace_back(neg,pos);
      ne.push_back(neg-pos);
    }else{
      ans.emplace_back(pos,neg);
      po.push_back(pos-neg);
    }
  }
  cout<<po[pf]<<endl;
  for(ll i=0;i<N-1;i++){
    cout<<ans[i].first<<" "<<ans[i].second<<endl;
  }
  return 0;
}


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

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

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

int main() {
    int K;
    cin >> K;

    long long int ans = 0;
    for (int a = 1; a <= K; ++a) {
        for (int b = a; b <= K; ++b) {
            for (int c = b; c <= K; ++c) {
                if (a == b && b == c) {
                    ans += a;
                    continue;
                }
                if (a == b) {
                    ans += 3 * gcd(a, b, c);
                    continue;
                }
                if (b == c) {
                    ans += 3 * gcd(a, b, c);
                    continue;
                }
                ans += 6 * gcd(a, b, c);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3528
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
int n,k,ans;
int a[111111];
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n){
		if(a[i]%2==1&&i%2==0)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3540
N, H = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]

A, B = [], []
for a, b in AB:
  A.append(a)
  B.append(b)

maxA = max(A)
B_stack = []
for b in B:
  if b > maxA:
    B_stack.append(b)
B_stack.sort()
B_stack = B_stack[::-1]

answer = 0
for b in B_stack:
  H -= b
  answer += 1
  if H <= 0:
    print(answer)
    exit()

answer += -(-H // maxA)
print(answer)

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

#define se second
#define fi first
#define mk(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define MOD 1000000007

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

int N,X,Y;
int C[200010],W[200010];
vector<pii> V[200010];
ll F[200010] = {1},R[200010] = {0};
int all;

int mem[200010] = {0};
vector<int> f;
bool visit[200010] = {0};

vector<int> G[200010];

void DFS(int v)
{
    if(visit[v])return;
    visit[v] = true;
    all++;
    if(mem[C[v]] == 0)f.pb(v);
    mem[C[v]]++;
    for(int i = 0; i < G[v].size(); i++)DFS(G[v][i]);
    return;
}

ll POW(ll a,ll b)
{
    if(b == 0)return 1;
    ll res = POW(a * a % MOD,b / 2);
    if(b & 1)res = res * a % MOD;
    return res;
}

ll con(ll a,ll b)
{
    if(a < b)return 0;
    return (F[a] * R[b] % MOD) * R[a - b] % MOD;
}

int main()
{
    scanf("%d%d%d",&N,&X,&Y);
    for(int i = 0; i < N; i++)
    {
        int c,w;
        scanf("%d%d",&c,&w);
        C[i] = c;
        W[i] = w;
        V[c].pb(mk(w,i));
    }

    int cou = 0;

    for(int i = 1; i <= 200000; i++)if(V[i].size() != 0)cou++;

    if(cou == 1)
    {
        printf("1\n");
        return 0;
    }

    for(int i = 1; i <= 200000; i++)
    {
        int MIN = 1000000010;
        for(int j = 0; j < V[i].size(); j++)
        {
            MIN = min(MIN,V[i][j].fi);
        }
        for(int j = 0; j < V[i].size(); j++)
        {
            if(V[i][j].fi + MIN <= X)W[V[i][j].se] = MIN;
        }
    }
    int MIN = 1000000010,c1,c2,n1,n2;
    for(int i = 0; i < N; i++)
    {
        if(W[i] < MIN)
        {
            MIN = W[i];
            c1 = C[i];
            n1 = i;
        }
    }
    for(int i = 0; i < N; i++)
    {
        if(C[i] != c1 && W[i] + MIN <= Y)
        {
            G[i].pb(n1);
            G[n1].pb(i);
        }
    }
    MIN = 1000000010;
    for(int i = 0; i < N; i++)
    {
        if(C[n1] == C[i])continue;
        if(W[i] < MIN)
        {
            MIN = W[i];
            n2 = i;
            c2 = C[i];
        }
    }
    for(int i = 0; i < N; i++)
    {
        if(C[i] != c2 && W[i] + MIN <= Y)
        {
            G[i].pb(n2);
            G[n2].pb(i);
        }
    }

    for(int i = 1; i <= 200010; i++)F[i] = (F[i - 1] * i) % MOD;
    for(int i = 0; i <= 200010; i++)R[i] = POW(F[i],MOD - 2);

    ll ans = 1;

    for(int i = 0; i < N; i++)
    {
        if(visit[i])continue;
        all = 0;
        DFS(i);
        ans = ans * F[all] % MOD;
        for(int i = 0; i < f.size(); i++)
        {
            ans = ans * R[mem[C[f[i]]]] % MOD;
            mem[C[f[i]]] = 0;
        }
        while(f.size())f.pop_back();
    }

    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 27508
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var h = o.a();
  var w = o.a();
  var s = o.r(h,1);
  var a = Array(h).fill(0).map(a=>Array(w).fill(0));
  a[0][0] = -1;
  var ans = 0;
  for(var i = 0; i < h; i++)ans += s[i].match(/\./g).length;
  var p = [[0,0]];
  h--; w--;
  for(i = 1;;i++){
    if(p.length === 0)return -1;
    var t = [];
    while(p.length){
      var x = p.pop(), y = x[0]; x = x[1];
      if(y === h && x === w)return ans - i;
      if(y && a[y-1][x] === 0 && s[y-1][x] === "."){
        a[y-1][x] = i; t.push([y-1,x]);
      }
      if(y < h && a[y+1][x] === 0 && s[y+1][x] === "."){
        a[y+1][x] = i; t.push([y+1,x]);
      }
      if(x && a[y][x-1] === 0 && s[y][x-1] === "."){
        a[y][x-1] = i; t.push([y,x-1]);
      }
      if(x < w && a[y][x+1] === 0 && s[y][x+1] === "."){
        a[y][x+1] = i; t.push([y,x+1]);
      }
    }
    p = t;
  }
}

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int n; cin >> n;
    int ans = 1, max_cnt = 0;
    for(int i = 1; i <= n; i++){
        int cnt = 0;
        if(i % 2) continue;
        int x = i;
        while(x % 2 == 0){
            x >>= 1;
            cnt++;
        }
        if(cnt > max_cnt){
            max_cnt = cnt;
            ans = i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//
//  sublime text 3,
//  emre yazicioglu
//

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair <double, double> pll;
typedef vector <ll> vll;
#define pb push_back
#define fi first
#define se second
#define INF (ll) 1e18 + 7
#define MOD (ll) 1e9 + 7

const int N = 2e6 + 7;
ll mn = INF, mx = -INF;
ll n, m, k, s, q, t;
ll a, b, c, d, e;
ll cur, sum, cnt;
ll ar[N], fg[N], dp[N];
string str; bool h[N];
pll p[N]; vll v;
double ans;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);

  // freopen("../in.txt","r",stdin);
  // freopen("../out.txt","w",stdout);

  cin >> n;
  for(int i = 1; i <= n; i++)
    cin >> p[i].first >> p[i].second;
  for(int i = 1; i <= n; i++)
    for(int j = 1; j <= n; j++)
      ans += sqrt((p[i].first - p[j].first) * (p[i].first - p[j].first) + (p[i].second - p[j].second) * (p[i].second - p[j].second)); 
  printf("%.8lf", ans / n);
}

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

using namespace std;

const long long r = 1e9 + 7;

long long p[401][401], sum[401][401], d[401][401];
int a[401], b[401];

int main() {
	for (int i = 1; i <= 400; ++i) {
		p[i][0] = 1;
		for (int j = 1; j <= 400; ++j)
			p[i][j] = p[i][j - 1] * i % r;
	}
	for (int i = 0; i <= 400; ++i)
		for (int j = 1; j <= 400; ++j)
			sum[i][j] = (sum[i][j - 1] + p[j][i]) % r;

	int n, c;
	scanf("%d %d", &n, &c);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &b[i]);

	d[0][0] = 1;
	for (int i = 1; i <= n; ++i)
		for (int j = 0; j <= c; ++j)
			for (int k = 0; k <= j; ++k)
				d[i][j] = (d[i][j] + d[i - 1][j - k] * (sum[k][b[i]] - sum[k][a[i] - 1] + r)) % r;

	printf("%lld", d[n][c]);

	return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int n,m,tot,a[maxn];
int main(){
	cin>>m>>n;
	if(~m&1){
		cout<<m/2<<" ";
		for(int i=2;i<=n;++i){
			cout<<m<<" ";
		}
	}
	else if(m==1){
		for(int i=1;i<=(n+1)/2;++i){
			cout<<1<<" ";
		}
	} 
	else{
		for(int i=1;i<=n;++i)a[i]=m/2+1;
		for(int x=n/2,p;x;--x){
			for(p=n;a[p]==0&&p;--p);
			if(--a[p++])for(int i=p;i<=n;++i)a[i]=m;
		}
		for(int i=1;i<=n;++i){
			if(!a[i])break;
			cout<<a[i]<<" ";
		}
	}
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  vector<int> c(n);
  
  rep(i,2){
    int cnt = 0;
    rep(j,n){
      if(s[j]=='R'){
        cnt++;
      }else{
        c[j] += cnt/2;
        c[j-1] += (cnt+1)/2;
        cnt = 0;
      }
    }
    reverse(c.begin(),c.end());
    reverse(s.begin(),s.end());
    rep(k,n){
      if(s[k]=='R')s[k]='L';
      else s[k] = 'R';
    }
  }
  rep(i,n){
    printf("%d\n",c[i]);
  }
}


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

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

    int64_t ans = 0;
    if (n % 2 == 0) {
        for (int64_t i = 5; i <= n / 2; i *= 5) {
            ans += n / 2 / i;
        }
    }

    cout << ans << endl;
}


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

int main() {
	int h, n;
	cin >> h >> n;
	int a[n];
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}

	string ans = "No";
	if (h <= sum) {
		ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    string hoge;
    int list[3] = {0,0,0};
    cin >> hoge;
    for(char& c : hoge){
        list['c'-c]++;
    }
    for(int i = 0; i< 3; i++){
        if(list[i] == 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  int x,a,b;
  cin >> x >> a >> b;
  int flag1=0,flag2=0;
  if(a>=b)
    flag1=1; //delicious
  int t1 = x+a;
  if(t1>=b)
    flag2=1; //not ache
  if(flag1==1){
    cout << "delicious" << endl;
  }
  else if(flag1==0 && flag2==1){
    cout << "safe" << endl;
  }
  else{
    cout << "dangerous" << endl;
  }
  return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;
using ll = long long;
using P = pair<int, int>;

ll euk(ll a, ll b) {
  if (b == 0) return a;
  return euk(b, a % b);
}

ll lcm(ll a, ll b) { return a * b / euk(a, b); }

void Main() {
  int n;
  ll m;
  cin >> n >> m;
  vector<ll> A(n);
  rep(i, n) cin >> A[i];
  rep(i, n) A[i] /= 2;
  int sec = 0;
  while (1) {
    int pa = A[0] % 2;
    REP(i, 1, n) if (A[i] % 2 != pa) {
      cout << 0 << endl;
      return;
    }
    if (pa == 1) break;
    rep(i, n) A[i] /= 2;
    sec++;
  }
  ll L = A[0];
  REP(i, 1, n) {
    L = lcm(L, A[i]);
    if (L * (1 << sec) > m) {
      cout << 0 << endl;
      return;
    }
  }
  L *= (1 << sec);
  cout << (m / L + 1) / 2 << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define li long long
#define itn int

using namespace std;

inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

int main(){

	string s;
	cin >> s;
	int k;
	cin >> k;
	int n = s.length();
	for (int i = 0; i < n; i++) {
		if (s[i] == 'a') {
			continue;
		}
		if (k >= (int)('z' - s[i]) + 1) {
			k -= (int)('z' - s[i]) + 1;
			s[i] = 'a';
		}
	}
	s.back() += k % 26;
	if (s.back() > 'z') {
		s.back() -= 26;
	}

	cout << s << "\n";

	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<deque>
#include<set>
using namespace std;

using ll = long long;
const int INF = 1001001001;

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

int main(void)
{
  ll n, m;
  cin >> n >> m;
  ll total = 0;
  rep(i,m) {
    ll tmp;
    cin >> tmp;
    total += tmp;
  }
  ll result = (n - total < 0) ? -1 : n - total;
  cout << result << endl;;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;

int n;
char a[N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> a;
    n = strlen(a);
    bool z = false;
    int ans = 1;
    int u = 1;
    for (int i = 1; i < n; ++i)
    {
        if (u == 2)
        {
            u = 1;
            ++ans;
            if (z)
            {
                u = 2;
                z = false;
            }
        }
        else if (u == 1)
        {
            if (a[i] != a[i - 1])
            {
                ++ans;
            }
            else
            {
                u = 2;
                z = true;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>

using namespace std;

const int INF=1e8;

int N,M,X;
int C[13];
int A[13][13];

int understanding[13];
int cost=INF;

void BFS(int cur,int amount){
    if (cur>N){
        bool ok=true;
        for(int i=1;i<=M;i++) if (understanding[i]<X) ok=false;
        if (ok) cost=min(amount,cost);
        return;
    }

    BFS(cur+1,amount);
    int dup[13];
    for(int i=1;i<=M;i++) dup[i]=understanding[i];
    for(int i=1;i<=M;i++) understanding[i]+=A[cur][i];
    BFS(cur+1,amount+C[cur]);
    for(int i=1;i<=M;i++) understanding[i]=dup[i];
}

int main(){
    scanf("%d%d%d",&N,&M,&X);
    for(int i=1;i<=N;i++){
        scanf("%d",C+i);
        for(int j=1;j<=M;j++){
            scanf("%d",A[i]+j);
        }
    }

    BFS(1,0);

    if (cost==INF) puts("-1"); else printf("%d\n",cost);

    return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    string s;
    cin >> s;

    for (auto& c : s) {
        c = 'x';
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;


int main(){
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
}


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

int main(void){
    string s;
    cin >> s;
    
    int c0=0, c1=0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '0') c0++;
        else c1++;
    }
    cout << 2 * min(c0, c1) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)




int main() {
	string s;
	std::cin >> s;

	map<char, ll> max_distance;
	map<char, ll> pre_idx;
	rep(i, 0, s.size()) {
		max_distance[s[i]] = max(max_distance[s[i]], i - pre_idx[s[i]]);
		pre_idx[s[i]] = i+1;
	}

	ll min_cnt = s.size() + 1;
	char c;
	for (auto itr = pre_idx.begin(); itr != pre_idx.end(); itr++) {
		max_distance[itr->first] = max(max_distance[itr->first], (ll)s.size() - itr->second);
		if (min_cnt > max_distance[itr->first]) {
			min_cnt = max_distance[itr->first];
			c = itr->first;
		}
	}
	std::cout << min_cnt << endl;


	return 0;
}


Measured memory_bytes: 256
N,X = map(int,input().split())
x = list(map(int,input().split()))
x = sorted([abs(i-X) for i in x])

y = x[0]
for  i in range(1,N):
    z = x[i]
    y,z = max(y,z),min(y,z)
    while z!=0:
        y,z = z,y%z
print(y) 

Measured memory_bytes: 20008
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int k,i,j,f=0;
    string s,ans;
    cin>>s;
    cin>>k;
    set<string> subs;
    for (i=0;i<s.size();i++)
    {
        for (j=1;j<=k;j++)
            subs.insert(s.substr(i,j));
    }
    for (string a: subs)
    {
        k--;
        if (k==0)
        {
            ans=a;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
// make pair, tuple
// __gcd(int, int)
// bool isPrime(int n){
//       if(n <= 1)return false;
//       if(n <= 3)return true;
//       if(n % 2 == 0 || n % 3 == 0)return false;
//       for(int i = 5;i * i <= n;i += 6){
//             if(n % i == 0 || n % (i + 2) == 0)return false;
//       }
//       return true;
// }
// int countSubString(string s, string temp){
//       int ans = 0;
//       size_t f = s.find(temp);
//       while(f != string::npos){
//             ans++;
//             f = s.find(temp, f + 1);
//       }
//       return ans;
// }

int main(){
    int n,m;cin >> n >> m;
    int mi[n + 5];
    int wc[n + 5];
    for(int i = 0;i < n + 5;i++){
        mi[i] = 0;
        wc[i] = 0;
    }
    int ac = 0;
    int wa = 0;
    for(int i = 0;i < m;i++){
        int t;cin >> t;
        string s;cin >> s;
        if(s == "WA" && mi[t] == 0){
            wc[t]++;
        }
        else if(s == "AC" && mi[t] == 0){
            ac++;
            wa += wc[t];
            mi[t] = 1;
        }
    }
    cout << ac << " " << wa;
}

Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                {
                    let mut out = Vec::<u8>::new();
                    solve($input,&mut out);
                    let out_str =str::from_utf8(&out).unwrap();
                    assert_eq!(&out_str, &$output);
                }
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        #[allow(unused_mut)]
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr,str) => {
        $iter.next().unwrap()
    };

    ($iter:expr, $t:tt) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    let mut out = std::io::stdout();

    solve(&stdin!(), &mut out);
}
fn solve<W: std::io::Write>(src: &str, out: &mut W) {
    macro_rules! out {
        ($fmt:expr) => {{
            let _ = out.write_fmt(format_args!($fmt));
        }};
        ($fmt:expr, $($args:tt)*) => {{
            let _ = out.write_fmt(format_args!($fmt, $($args)*));
        }};
    }
    macro_rules! outln {
        ($fmt:expr) => {{
            out!(concat!($fmt,"
"));
        }};
        ($fmt:expr, $($args:tt)*) => {{
            out!(concat!($fmt, "
"), $($args)*);
        }};
    }
    input! {
        source = src,
        x:isize,
    }

    outln!("{}", if x >= 30 { "Yes" } else { "No" });
}
test! {}


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

using namespace std;

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

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

long long n,x;

long long rec(long long len, long long bounce) {
	if (bounce == 0) return -len;

	long long times = len / bounce;
	return times * bounce * 2 + rec(bounce, len%bounce);
}

int main() {
	scanf("%lld %lld", &n, &x);

	printf("%lld\n", n + rec(x,n-x));
}

Measured memory_bytes: 256
sides = list(map(int, input().split()))
while sides != [0, 0]:
    line0 = '#' * sides[1]
    lines = '#' + '.' *(sides[1] - 2) + '#\n'
    lines *= sides[0]-2
    print(line0)
    print(lines, end = '')
    print(line0 + '\n')
    sides = list(map(int, input().split()))


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

int main(){
    double a, b, C;
	cin >> a >> b >> C;
	C *= 3.1415926536 / 180;
	
	double S = a * b / 2 * sin(C);
	double c2= a*a + b*b - cos(C) * 2 * a * b;
	double h = b * sin(C);
	
	cout << fixed << setprecision(8);
	cout << S << "\n";
	cout << sqrt(c2) + a + b << "\n";
	cout << h << "\n";
	cout << flush;
	
	return 0;
}


Measured memory_bytes: 3516
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))

s = [0,0,0]

for i in p:
    if(i <= a):s[0] += 1
    elif(i <= b):s[1] += 1
    else:s[2] += 1
print(min(s))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mod 1000000007
#define vll vector<ll>
#define inf 1e9 +7
#define pll pair<ll,ll>
#define ff first 
#define ss second 
#define PI acos(-1)
#define prm 998244353
#define endl '\n'
using namespace std;

int main()
{
    fastio; 
    ll T=1;
    //cin>>T; 
    while(T--)
    {
    	ll n,x,t;
    	cin>>n>>x>>t;
    	if(n%x==0)cout<<(n/x)*t;
    	else cout<<(n/x)*t+t;
    }
}



Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()

int N, M;
bool graph[8][8];
int ans = 0;

void dfs(int v, int visited) {
		visited |= (1<<v);
		if(__builtin_popcount(visited) == N) {
				ans++;
				return;
		}

		for (int v2 = 0; v2 < N; v2++) {
				if (!graph[v][v2]) continue;
				if (visited & (1<<v2)) continue;
				dfs(v2, visited);
		}
}

int main() {
		cin >> N >> M;
		for (int i = 0; i < M; i++) {
				int a, b;
				cin >> a >> b;
				a--; b--;
				graph[a][b] = graph[b][a] = true;
		}

		dfs(0, 0);
		cout << ans << endl;
		return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vii;
typedef long long ll;
 
#define  modu 1000000007


int main() {
    
    {
        string s;
        cin>>s;
        int n=s.size(),ca=0,cb=0,cc=0;
        for(int i=0;i<n;i++)
        {
            if(s[i]=='a')
            ca++;
            else if(s[i]=='b')
            cb++;
            else if(s[i]=='c')
            cc++;
        }
        if(ca==1 && cb==1 && cc==1)
            cout<<"Yes";
        else
            cout<<"No";
        

    }
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  multiset<int>st;
  int ans=0;
  rep(i,n){
    int a;
    scanf("%d",&a);
    auto it=st.lower_bound(a);
    if(it==st.begin()){
      ans++;
      st.insert(a);
    }
    else{
      it = prev(it);
      st.erase(it);
      st.insert(a);
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        execute(br);
    }

    private static void execute(BufferedReader br) throws Exception {
        while (true) {
            String str = br.readLine();
            if (str.equals("-")) { break; }
            int m = Integer.parseInt(br.readLine());
            for (int i = 0; i < m; i++) {
                int n = Integer.parseInt(br.readLine());
                str = shuffle(str, n);
            }
            System.out.println(str);
        }
    }

    private static String shuffle(String str, int n) {
        String fromInitialsToN = str.substring(0, n);
        String fromN1ToEnd = str.substring(n, str.length());
        return fromN1ToEnd + fromInitialsToN;
    }
}

Measured memory_bytes: 24504
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <fstream>

using namespace std;

ifstream fin("../data.txt");

long long x, a, b, ans;

int main() {

  cin >> a >> b >> x;
  ans = b/x - a/x;
  if (a%x == 0) ans++;
  cout << ans;

  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

int main()
{
    int k;
    string s;
    cin >> k >> s;
    if (s.length() <= k)
    {
        cout << s << endl;
    }
    else
    {
        cout << s.substr(0, k) << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main()
{
   IOS;
   string s;
   cin >> s;
   int n=s.length();
   int p1=0,p2=0;
   for(int i=0;i<n;i++){
       if(s[i]=='A')++p1;
       else ++p2;
   }
   int k=n/2;
   if((p1==k&&p2==k+1)||(p1==k+1&&p2==k)){
       cout<<"Yes";
   }
   else
   {
       cout<<"No";
   }
   
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int a; int b; int c;
    cin >> a >> b >> c;
    if (a == b)
        cout << c << endl;
    else if (a == c)
        cout << b << endl;
    else if (c == b)
        cout << a << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [i for i in range(n)] # parents
        self.rank = [1] * n # height of tree
        self.size = [1] * n # size[i] -> iをrootとするgroupのサイズ

    # 木の根を返す
    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # xとyの属する集合を併合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parents[x] = y
            self.size[y] += self.size[x] 
        else:
            self.parents[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # xとyが同じグループに属しているかを判定する
    def same(self, x, y):
        return self.find(x) == self.find(y)

    #--- option ---#

    # xが属する集合の大きさを返す
    def group_size(self, x):
        return self.size[self.find(x)]

    # xが属する集合の要素を返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    # すべての根をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    # 木の数を返す
    def group_count(self):
        return len(self.roots())

    # すべての要素を辞書で返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}


uf = UnionFind(n)

# unionによるグループの併合
for _ in range(m):
    a, b = map(int, input().split())
    uf.union(a - 1, b - 1)

print(max([uf.group_size(x) for x in uf.parents]))

Measured memory_bytes: 92848
#include <stdio.h>

int main()
{
    int a,b,c;
    scanf("%d %d",&a,&b);
    if(a-2*b>=0)
    {
        c=a-2*b;
        printf("%d",c);
    }
    else
    {
        c=0;
        printf("%d",c);
    }
    return 0;
}


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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];

			//各素数で何回割れるか
			var primeDivede = new Dictionary<long, long>();

			long k = 2;
			var tmp = N;
			var kMax = Math.Ceiling(Math.Sqrt(long.MaxValue));
			while (k*k <= N ) {

				if (tmp % k==0) {

					tmp = tmp / k;
					if (primeDivede.ContainsKey(k)) {
						primeDivede[k]++;
					}
					else {
						primeDivede.Add(k, 1);
					}
				}
				else {
					k++;
					if (k>kMax) {//N<long.maxなのでk<ルート(long.max)
						break;
					}
				}
			}
			if (tmp != 1) {//最後に残る素数(=Nが素数の場合など)
				if (primeDivede.ContainsKey(tmp)) {
					primeDivede[tmp]++;
				}
				else {
					primeDivede.Add(tmp, 1);
				}
			}

			long count = 0;
			foreach (var item in primeDivede) {

				count += minusCount(item.Value);
			}
			//答えの出力
			Console.WriteLine(count);

		}

		/// <summary>
		/// 1,2,3の数列を何回引けるか
		/// </summary>
		/// <param name="x"></param>
		/// <returns></returns>
		private	static long minusCount(long x) {

			var count = 0;
			long i = 1;
			while (true) {

				x = x - i;
				if (x <0) {
					return count;
				}
				count++;
				i++;
			}

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 28288
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 2500;
const int K = 19;
int n, q;
int mod = 998244353;
int a[N][N], f[N], invf[N], used[N];
vector < pair < int, int > > v;
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int c(int n, int k){
    if (k < 0) return 0;
    return f[n] * invf[k] % mod * invf[n - k] % mod;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(0LL, a + b - n);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int N, M, w[100005], fa[100005], cnt[100005], ans;
ll sum[100005];
struct edge {int u, v, w;} ed[100005];

inline bool operator < (const edge &ed1, const edge &ed2) {return ed1.w < ed2.w;}
int getf(const int &u) {return fa[u] == u ? u : fa[u] = getf(fa[u]);}

int main(){
	getint(N), getint(M);
	for(register int i = 1; i <= N; i++) getint(w[i]);
	for(register int i = 1; i <= M; i++) getint(ed[i].u), getint(ed[i].v), getint(ed[i].w);
	sort(ed + 1, ed + M + 1);
	for(register int i = 1; i <= N; i++) fa[i] = i, cnt[i] = 0, sum[i] = w[i];
	for(register int i = 1; i <= M; i++){
		const int fu = getf(ed[i].u), fv = getf(ed[i].v);
		if(fu == fv) cnt[fu]++;
		else cnt[fu] += cnt[fv] + 1, sum[fu] += sum[fv], fa[fv] = fu;
		if(sum[fu] >= ed[i].w) ans += cnt[fu], cnt[fu] = 0;
	}
	return printf("%d\n", M - ans), 0;
}

Measured memory_bytes: 3328
#include<set>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
string A, B, C;

void MAIN() {
    cin >> N;
    cin >> A >> B >> C;
    int ans = 0;
    REP (i, A.size()) {
	set<char> s;
	s.insert(A[i]);
	s.insert(B[i]);
	s.insert(C[i]);
	ans += s.size() - 1;
    }

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

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
N = int(input())
divisions = [0] * (10 ** 7 + 1)
for i in range(1, N + 1):
    for j in range(i, N + 1, i):
        divisions[j] += 1
ans = 0
for i in range(1, N + 1):
    ans += i * divisions[i]
print(ans)

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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 modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  map<int, int> mp;
  
  int a;
  rep(i, N){
    cin >> a;
    mp[a]++;
  }

  ll ans = 0;
  for(auto itr = mp.begin(); itr != mp.end(); itr++){

    int num = itr->first;
    int cnt = itr->second;

    if(cnt >= num){
      ans += cnt - num;
    }else{
      ans += cnt;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define db double
#define ll long long
#define reg register
#define pb(x) push_back(x)
#define fup(i,x,y) for(reg int i=x;i<=y;++i)
#define fdw(i,x,y) for(reg int i=x;i>=y;--i)
using namespace std;
const int N=1e6+10;
ll ans,n;
inline int read()
{
	int x=0,ff=1;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*ff;
}
int main()
{
	//freopen("1.in","r",stdin);
	n=read();
	for(int i=1;i<=n;++i)
	{
		if(i%3!=0&&i%5!=0) ans+=(ll)i;
	}
	printf("%lld",ans);
	return 0;
}



Measured memory_bytes: 3764
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

int main(){   
    int n,k;
    cin>>n>>k;
    vector<int> p(n);
    rep(i,0,n-1) cin>>p[i];
    vector<double> kitaiti(n);
    rep(i,0,n-1) kitaiti[i] = (1.0 + (double)p[i]) / 2.0;
    vector<double> s(n+1,0);
    rep(i,0,n-1) s[i+1] = kitaiti[i]+s[i];
    double ans = 0.0;
    rep(i,0,n-k){
        double tmp = s[i+k] - s[i];
        if(ans<tmp) ans = tmp;
    }
    printf("%.14f\n",ans);
    return 0;
}

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

#define whatis(x) cerr << #x << ": " << x << endl;

const int N = 3e3+5;

double dp[N];
int n;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // dp[i] - the probability of i head so far
    cin >> n;
    dp[0] = 1;
    for (int i = 1; i <= n; i++) {
        double p;
        cin >> p;
        for (int j = i; j >= 0; j--) {
            dp[j+1] += dp[j] * p;
            dp[j] = ((double)1 - p) * dp[j];
        }
    }
    double ans = 0;
    for (int i = n; i >= 0; i--) {
        if (i < n-i) break;
        ans += dp[i];
    }
    cout << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,L;
cin>>N>>L;
string a[N];
for(int i=0;i<N;i++){
    cin>>a[i];
}
sort(a,a+N);
for(int i=0;i<N;i++){
    cout<<a[i];
}
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int N, L[100], i, j, t, sum=0;
		scanf("%d\n",&N);
		for(i=0; i<N; i++)scanf("%d",&L[i]);
		
		for (i=0; i<N; ++i){
    	for (j=i+1; j<N; ++j){
    	  if (L[i] > L[j]){
        t =  L[i];
        L[i] = L[j];
        L[j] = t;
      	}
    	}
  	}
		for(i=0; i<N-1; i++)
		sum+=L[i];
		if(L[N-1]>=sum)	printf("No\n");
		else printf("Yes\n");
	}

Measured memory_bytes: 128
from operator import itemgetter as get
N,*L = map(int,open(0).read().split())
L1 = L[:N*2]
L2 = L[N*2:]
R = sorted([(x,y) for x,y in zip(*[iter(L1)]*2)], key = get(1), reverse = 1)
B = sorted([(x,y) for x,y in zip(*[iter(L2)]*2)])
cnt = 0
for bx, by in B:
	for rx, ry in R:
		if rx < bx and ry < by:
			R.remove((rx,ry))
			cnt += 1
			break
print(cnt)

Measured memory_bytes: 3064