akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

struct UnionFind {
    vector<int> data;
    int __size;
    UnionFind(int size) : data(size, -1), __size(size) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) != (y = root(y))) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x; __size--;
        }
        return x != y;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return __size; }
};

int main() {
    int n, m; cin >> n >> m;
    UnionFind uf(n * 2);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b; a--; b--;
        uf.unionSet(a, b + n);
        uf.unionSet(a + n, b);
    }
    if (uf.findSet(0, n)) {
        cout << 1LL * n * (n - 1) / 2 - m << endl;
    } else {
        int cnt = 0;
        for (int i = 0; i < n; i++) if (uf.findSet(0, i)) cnt++;
        cout << 1LL * cnt * (n - cnt) - m << endl;
    }
    return 0;
}

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

int main()
{
    long long int N;
    cin >> N;
    
    long long int ans;
    
    for(long long int i=1; i<=sqrt(N); i++){
        if(N%i == 0){
            ans = N/i;
        }
    }

    cout << ans + N/ans - 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#define MOD 998244353
int dp[200005][3][3][2]; 
char str[200005]; 
int main()
{
	// freopen("ARC094-F.in", "r", stdin); 
	scanf("%s", str);
	int n = strlen(str), cnt = 0, sum = 0; 
	for (int i = 0; i < n; i++)
		(sum += str[i] - 'a') %= 3; 
	for (int i = 1; i < n; i++)
		cnt += str[i] != str[i - 1]; 
	if (!cnt)
	{
		puts("1"); 
		return 0;
	}
	if (n <= 3)
	{
		if (n == 2)
			puts("2"); 
		else
		{
			if (cnt != n - 1)
				puts("6"); 
			else if (str[0] == str[2])
				puts("7"); 
			else
				puts("3"); 
		}
		return 0; 
	}
	dp[1][0][0][0] = dp[1][1][1][0] = dp[1][2][2][0] = 1; 
	for (int i = 1; i < n; i++)
	{
		for (int x = 0; x < 3; x++)
		{
			for (int y = 0; y < 3; y++)
			{
				for (int t = 0; t < 2; t++)
				{
					for (int z = 0; z < 3; z++)
						(dp[i + 1][z][(y + z) % 3][t | (x == z)] += dp[i][x][y][t]) %= MOD; 
				}
			}
		}
	}
	int ans = 0; 
	for (int i = 0; i < 3; i++)
		(ans += dp[n][i][sum][1]) %= MOD; 
	printf("%d\n", ans + (cnt == n - 1));
	return 0; 
}


Measured memory_bytes: 14464
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

bool scanUnsigned(char**);
bool scanInteger(char**);

bool isNumeric(char* str) {
    if (str == NULL) return false;
    bool numeric = scanInteger(&str);
    cout << *str << endl;

    if (*str == '.') {
        ++str;
        numeric = scanUnsigned(&str) || numeric;
    }
    cout << numeric << *str << endl;

    if (*str == 'e' || *str == 'E') {
        str++;
        numeric = numeric && scanUnsigned(&str);
    }
    cout << numeric << *str << endl;

    return numeric && *str == '\0';
}

bool scanUnsigned(char **str) {
    const char *before = *str;
    while (**str != '\0' && '0' <= **str && **str <= '9') {
        cout << **str << endl;
        ++(*str);
    }
    return *str > before;
}

bool scanInteger(char **str) {
    if (**str == '+' || **str == '-')
        ++(*str);
    return scanUnsigned(str);
}

int main() {
    string s;
    cin >> s;
    if (s == "Sunny") cout << "Cloudy\n";
    else if (s == "Cloudy") cout << "Rainy\n";
    else cout << "Sunny\n";


    return 0;
}


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

using namespace std;

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

	vector<int> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}

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

	cout << d[n / 2] - d[n / 2 - 1];

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define all(v)    ((v.begin()),(v.end()))
#define sz(v)     ((int)(v.size()))
#define forv(i, v) for(int i = 0; i < sz(v); ++i)
#define forn(i,n)   for(int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef vector<int>     vi;
typedef vector<double>  vd;
typedef vector< vi >    vii;
typedef vector< vd >    vdd;
typedef vector<string>  vs;


int main()
{
	fast;
	ll x;
	cin >> x;
	ll ans = 0;
	ans += (x / 500) * 1000;
	x %= 500;
	ans += (x / 5) * 5;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
s = input().split()
N = int(s[0])
P = int(s[1])
s = input().split()
a = [int(i) for i in s]

import itertools
import math
import scipy.misc as scm

#あまりはあまりの和なので、各袋の2で割ったあまりを求める
b = [i % 2 for i in a]   #0 or 1の配列になる
zeros = b.count(0)
ones = b.count(1)

if P == 0 : 
    ## P == 0 の時は何も選ばないが１通りあるのでそれを加える
    #0になる組み合わせの数  zerosC0 + zerosC1 zerosC2 + ... zerosCzeros = 2^zeros
    #2になる組み合わせの数 onesC2 * 2^zeros
    #4になる組み合わせの数 onesC4 * 2^zeros
    lim = math.floor(ones / 2)
    cnt = 0
    for i in range(lim + 1) : 
        onesCx = scm.comb(ones , 2 * i , 1) * 2**zeros
        cnt += onesCx

else : 
    ## P == 1の時
    #1になる組み合わせは onesC1 * 2^zeros
    #3になる組み合わせは onesC3 * 2^zeros
    lim = math.floor(ones / 2)
    cnt = 0
    for i in range(lim + 1) : 
        onesCx = scm.comb(ones , 2 * i + 1 , 1) * 2**zeros
        cnt += onesCx

print(cnt)

Measured memory_bytes: 24996
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=20;
int a[N],n;
int dfs(int L,int R,int lt,int rt){
	if (L>R)return 0;
	if (L==R)return (lt+rt)*a[L];
	int ans=1e18;
	for (int i=L;i<=R;i++)
		ans=min(ans,dfs(L,i-1,lt,lt+rt)+dfs(i+1,R,lt+rt,rt)+a[i]*(lt+rt));
	return ans;
}
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;i++)scanf("%lld",&a[i]);
	printf("%lld\n",dfs(2,n-1,1,1)+a[1]+a[n]);
} 

Measured memory_bytes: 384
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <limits>
#include <vector>
#include<functional>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define print_double(val,a) cout << fixed << setprecision(a) << val << endl;
ll mod = 1e9 + 7;
int par[100010];
int rank1[100010];

vector<pair<int, int>>G[100005];
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		rank1[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) { return x; }
	return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) { return; }
	if (rank1[x] < rank1[y]) { par[x] = y; }
	else {
		par[y] = x; if (rank1[x] == rank1[y]) { rank1[x]++; }
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int>p(n);
	vector<int>x(m);
	vector<int>y(m);
	for (int i = 0; i < n; i++) {
		cin >> p[i]; p[i]--;
	}
	for (int i = 0; i < m; i++) {
		cin >> x[i] >> y[i];
	}
	init(n);
	rep(i, m) { unite(x[i] - 1, y[i] - 1); }
	/*rep(i, n) {
		G[find(i)].push_back(pair<int,int>(p[i], i));
	}*/
	int ans = 0;
	/*rep(i, n) {
		vector<int>v1, v2;
		rep(j, G[i].size()) {
			v1.push_back(G[i][j].first);
			v2.push_back(G[i][j].second);
		}
		Sort(v1);
		Sort(v2);
		rep(j, v1.size()) {
			if (binary_search(v2.begin(), v2.end(), v1[j]))ans++;
		}
	}*/
	rep(i, n) {
		if (same(i, p[i])) { ans++; }
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;

    int A[N] = {0};

    int a, b;
    for (int i = 0; i < M; i++)
    {
        cin >> a >> b;
        a--;
        b--;

        A[a]++;
        A[b]++;
    }

    for (int i = 0; i < N; i++)
    {
        cout << A[i] << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <utility>
#include <bitset>
#include <queue>
#include <stack>
#define mod 998244353
#define pb(x) push_back(x)
using namespace std;
vector<int> g[100010];
int ans,n,du[100010],pos;
int need[100010];
void dfs(int x,int pre)
{
    if(g[x].size()>2)need[x]=1;
    int cnt=g[x].size();
    for(int i=0;i<cnt;i++)
    if(g[x][i]!=pre)
    {
        dfs(g[x][i],x);
        need[x]|=need[g[x][i]];
    }
}
int main()
{
    scanf("%d",&n);
    int root;
    int flag=0;
    for(int i=1;i<=n;i++)g[i].clear();
    memset(need,0,sizeof(need));
    for(int i=1;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        x++;y++;
        g[x].push_back(y);
        g[y].push_back(x);
        du[x]++;du[y]++;
        if(du[x]>2)root=x,flag=1;
        if(du[y]>2)root=y,flag=1;
    }
    if(flag==0)
    {
        puts("1");
        return 0;
    }
    dfs(root,0);
    for(int i=1;i<=n;i++)
    if(need[i])
    {
        int num=0;
        int cnt=g[i].size();
        for(int j=0;j<cnt;j++)
            if(!need[g[i][j]])num++;
        if(num!=0)ans=ans+num-1;
    }
    if (ans<1)ans=1;
    cout<<ans<<endl;
}

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

struct data{
  int pq, p, q;
};

const int MAX_N = 50000;
bool prime[MAX_N+1];

void sieve()
{
  fill(prime, prime+MAX_N+1, true);
  prime[0] = prime[1] = false;
  for(int i = 2; i <= MAX_N; i++)
    if(prime[i])
      for(int j = i*2; j <= MAX_N; j += i)
        prime[j] = false;
}
 
int main()
{
  sieve();
  while(1){
    int m, a, b;
    cin >> m >> a >> b;
    if(m == 0 && a == 0 && b == 0) break;
    struct data ans;
    ans.pq = 0;
    for(int i = 2; i <= MAX_N; i++){
      if(prime[i]){
        for(int j = i; j <= MAX_N; j++){
          if(prime[j]){
            int y = i*j;
            if(y > m) break;
            if(y < ans.pq) continue;
            if(a*j <= b*i){
              ans.pq = y;
              ans.p = i;
              ans.q = j;
            } 
          }
        }
      }
    }
    cout << ans.p << " " << ans.q << endl;
  }
}

Measured memory_bytes: 1208
H, W = map(int, input().split())
C = [list(input()) for _ in range(H)]
dp = [[0] * W for _ in range(H)]

# x方向
for y in range(H):
    prev_x = -1
    for x in range(W):
        if C[y][x] == '#':
            for i in range(x - prev_x - 1):
                dp[y][i + prev_x + 1] = x - prev_x - 1
            prev_x = x
        if x == W - 1:
            for i in range(x - prev_x):
                dp[y][i + prev_x + 1] = x - prev_x
             

ans = 0
# y方向
for x in range(W):
    prev_y = -1
    for y in range(H):
        if C[y][x] == '#':
            for i in range(y - prev_y - 1):
                dp[i + prev_y + 1][x] += y - prev_y - 1
                ans = max(ans, dp[i + prev_y + 1][x] - 1) # 自分自身を2回カウントしているため-1
            prev_y = y
        if y == H - 1:
            for i in range(y - prev_y):
                dp[i + prev_y + 1][x] += y - prev_y
                ans = max(ans, dp[i + prev_y + 1][x] - 1) # 自分自身を2回カウントしているため-1


print(ans) 




Measured memory_bytes: 218376
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int a,b,c,d,e,f;
	set<int> w;
	set<int> s;
	cin >> a >> b >> c >> d >> e >>f;
	for(int i = 0; i <= (f/100)/a; i++) {
		for(int j = 0; j <= (f/100)/b; j++) {
			int tmp = a*i + b*j;
			if (tmp <= f && tmp != 0){
				w.insert(tmp);
			}
		}
	}

	for(int i = 0; i <= f/c; i++) {
		for(int j = 0; j <= f/d; j++) {
			int tmp = c*i + d*j;
			if (tmp <= f){
				s.insert(tmp);
			}
		}
	}
	// for(auto  itr = w.begin(); itr != w.end(); itr++) {
	// 	cout << *itr << endl;
	// }

	// for(auto  itr = s.begin(); itr != s.end(); itr++) {
	// 	cout << *itr << endl;
	// }

	float x = (float(100*e))/(float(100+e));
	int water = a*100;
	int sugar = 0;
	float max = 0.0;
	for(auto  itr = w.begin(); itr != w.end(); itr++) {
		for(auto  itr2 = s.begin(); itr2 != s.end(); itr2++) {
			float tmp = (float(100*(*itr2)))/(float((*itr)*100+(*itr2)));
			if (tmp <= x && tmp > max && *itr * 100 + (*itr2) <= f){
				water = *itr * 100;
				sugar = *itr2;
				max = tmp;
				if(tmp == x){
					break;
				}
			}
		}
	}
	cout << water + sugar << " " << sugar << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

//modを使う cur(7,77,...)がkで割り切れるとき終了させる
//cur = old*10 + 7; 
//old = k*x + old%k;
//cur = 10*(k*x) + (10*(cur%k) + 7);
//      割切成分　 　　余り成分
//つまり、毎ステップmodを取っていっても解ける（オーバーフロー防げる）
//exにk = 999983があり、そのans = 999982が最大
int main(){
    ll k;
    cin >> k;
    ll cur = 7 % k;
    rep(i, 0, k){
        if(cur == 0) {
            cout << i+1 << endl;
            return 0;
        }
        cur *= 10 % k;
        cur += 7;
        cur %= k;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

bool prime[1000002];

void seive(int s){
	for(int i=0;i<=s;i++)prime[i]=true;
	prime[0]=prime[1]=false;
	for(int i=2;i<=s;i++){
		if(prime[i]==true){
			for(int j=i*2;j<=s;j+=i)prime[j]=false;
		}
	}
}

int main(void){
	seive(1000000);
	while(1){
		int n;
		int ans=0;
		scanf("%d",&n);
		if(n==0)break;
		for(int j=3;j<=n/2;j+=2){
			if(prime[j]==true && prime[n-j]==true)ans++;
		}
		printf("%d\n",ans);
	}
    return 0;
}

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

using namespace std;

int main() {
	string s,t;
	bool flg = false;
	cin >> s >> t;
	
	for (int i = s.size() - t.size(); i >= 0; i--) {
		flg = true;
		for (int ti = 0; ti < t.size(); ti++) {
			if (s[i+ti] != '?' && s[i+ti] != t[ti]) {
				flg = false;
				break;
			}
		}
		if (flg) {
			for (int j = 0; j < s.size(); j++) {
				if (j < i || j >= i + t.size()) {
					cout << ((s[j] == '?') ? 'a' : s[j]);
				} else {
					cout << t;
					j += (t.size()-1);
				}
			}
			cout << endl;
			return 0;
		}
	}

	cout << "UNRESTORABLE" << endl;

}

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

long long int pre(long long int n)
{
  if(n<2)
    return 0;
  long long int c=1;
  for(int i=2;i<=sqrt(n);i++)
    if(n%i==0)
      {
	c+=i;
	if(i!=n/i)
	  c+=n/i;
      }
  return c;
}

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      long long int s = pre(n);
      if(n>s)
	cout<<"deficient number"<<endl;
      else if(n<s)
	cout<<"abundant number"<<endl;
      else 
	cout<<"perfect number"<<endl;
    }
  
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
#define zzz ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
int main()
{
    zzz;
    int n;
    cin>>n; vector<int> a(n); for(int i=0;i<n;++i) cin>>a[i];
    sort(a.begin(),a.end());
    double ans = (double)(a[0]);
    for(int i=1;i<n;++i)
    {
        ans = (ans+(double)(a[i]))/2.0;
    }
    cout<<ans;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = end - 1; begin <= i; i--)		// repeat reverse

#endif


class ABC128D
{
public:
	ABC128D()
	{
		cin >> n >> k;
		k++;
		v.resize(n);
		rep(i, 0, n)
			cin >> v[i];
		copy(all(v), back_inserter(vr));
		reverse(all(vr));
	}
	void Run(void)
	{
		ll best = 0;
		ll solve = 0;
		rep(li, 0, k)
		{
			rep(ri, 0, k - li)
			{
				rep(di, 0, k - li - ri)
				{
					solve = Solve(li, ri, di);
					if (best < solve)
						best = solve;

				}
			}
		}

		cout << best;

	}
private:
	ll Solve(ll lmax, ll rmax, ll dmax)
	{
		ll sum = 0;
		vector<ll> ans(n);

		lmax = (n < lmax) ? n : lmax;
		rep(i, 0, lmax)
			ans.push_back(v[i]);

		rmax = (n - lmax < rmax) ? n - lmax : rmax;
		rep(i, 0, rmax)
			ans.push_back(vr[i]);
	
		sum = accumulate(all(ans), 0);
		sort(all(ans));

		dmax = (ans.size() < dmax) ? ans.size() : dmax;
		rep(i, 0, dmax)
		{
			if (ans[i] < 0)
				sum -= ans[i];
		}

		return sum;
	}
	ll n;
	ll k;
	vector<ll> v;
	vector<ll> vr;
};


int main(void)
{
	ABC128D abc128d;
	abc128d.Run();

	return 0;
}

Measured memory_bytes: 256
#/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  // #define MAX 100001
  #define md 998244353
  #define add accumulate
  #define ll long long int
  #define ld long double
  #define ff first
  #define ss second
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  #define repa(a,n) for(int i=a;i<n;i++)
  const int MAX=1e5+5;
  const int mod=1e9+7;
  const int N=3e5+9;
  const long double eps=1e-9;
  const ld PI=acos(-1.0);
    ll dx[]={1,0,-1,0};
	ll dy[]={0,1,0,-1};
  //
  //
  int main(){
  	hs;
  	ll a,b;
  	cin>>a>>b;
  	cout<<max(a+b,max(2*a-1,2*b-1));
  	return 0;
  }

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

int main()
{
	int n;
	int v[101];
	long m[100][100];
	const long nil = 999999999;

	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> v[i] >> v[i + 1];

	for (int i = 0; i < 100; i++)
		for (int j = 0; j < 100; j++)
			if (i == j)
				m[i][j] = 0;
			else
				m[i][j] = nil;
	
	for(int i = n - 2; i > -1; i--)
		for(int j = i + 1; j < n; j++)
			for (int k = i; k < n; k++)
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + v[i] * v[k + 1] * v[j + 1]);

	cout << m[0][n - 1] << endl;

	return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> s(n, 0);
  for (int i = 1;i < n;i++) {
    int a;
    cin >> a;
    s[a - 1] += 1;
  }
  for (int x : s) {
    cout << x << endl;
  }
}

Measured memory_bytes: 4052
n = int(input())

if n == 1:
    print('a')
    exit()

def dfs(s, cmax):
    if len(s) == n:
        print(s)
    else:
        for i in range(ord(cmax)-ord('a')+2):
            c = chr(i+ord('a'))
            if ord(c) < ord(cmax):
                dfs(s+c, cmax)
            else:
                dfs(s+c, c)

dfs('a', 'a')

Measured memory_bytes: 4412
/*ex6_2
    takafumi_ueki*/
#include <stdio.h>
#include <string.h>
#define LIMIT 101
int main(void){
    int middle_length,last_char;
    char str[LIMIT];
    //文字列を受け取る
    scanf("%s",str);
    // 挟まれる文字数(文字列の文字数-2)を計算する
    middle_length = (int)strlen(str)-2;
    //最後の文字は(文字列の文字数-1)番目の文字
    last_char = str[(int)strlen(str)-1];
    //最初の文字、挟まれる文字数、最後の文字を出力する
    printf("%c%d%c\n",str[0],middle_length,last_char);
    return 0;
}

Measured memory_bytes: 128
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""

import sys


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    D = []
    S = 0
    cnt = 0
    for i in range(N):
        d = B[i] - A[i]
        if d > 0:
            S += d
            cnt += 1
        else:
            D.append(-d)
            if len(D) == N:
                print(0)
                sys.exit()
    D.sort()
    ans = 0
    for i in range(len(D)-1, -1, -1):
        ans += 1
        if D[i] < S:
            S -= D[i]
            if i == 0:
                if S > 0:
                    print(-1)
                    sys.exit()
        else:
            break
    print(ans + cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 80816
#include <bits/stdc++.h>
using namespace std;
// 素因数分解

long long divisor_num(long long a) {
  long long ans = 1;

  for (int i = 2; i <= sqrt(a); i++) {
    int cnt = 0;
    while (a % i == 0) {
      cnt++;
      a /= i;
    }
    ans *= (cnt + 1);
    if (a == 1) break;
  }
  if (a != 1) ans *= 2;

  return ans;
}

long long N;
int main() {
    cin >> N;
    long long ans = 0;
    for (int i = N-1; i > 0; i--) {
      ans += divisor_num(i);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
const int MN=200000+5,P=998244353,inv2=P+1>>1;
using namespace std;
typedef long long ll;
template<typename T>inline T&IN(T&in){
	in=0;char c=getchar();int f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))in=in*10+c-'0',c=getchar();
	return in*=f;
}
int n,K,ans;
int a[MN],dep[MN],vis[MN];
int nxt[MN],to[MN],h[MN],cnt;
void add(int u,int v){to[cnt]=v,nxt[cnt]=h[u],h[u]=cnt++;}
void dfs(int u){
	dep[u]=1;
	for(int e=h[u],v=to[e];~e;e=nxt[e],v=to[e]){
		dfs(v);
		if(!vis[v])dep[u]=max(dep[u],dep[v]+1);
	}
	if(u!=1&&dep[u]==K&&a[u]!=1)vis[u]=1,ans++;
}
int input(){
	IN(n),IN(K);memset(h,-1,sizeof h);
	for(int i=1;i<=n;++i)IN(a[i]);
	for(int i=2;i<=n;++i)add(a[i],i);
	if(a[1]!=1)ans++;
	dfs(1);
	printf("%d\n",ans);
}
int main(){
	input();
	return 0;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
    int n,a,b;
    string s;
    cin>>n>>a>>b>>s;

    int kaigai=1,kakutei=1;
    rep(i,0,n){
        if(s[i]=='a'){
            if(kakutei<=a+b){
                cout<<"Yes"<<endl;
                kakutei++;
            }else cout<<"No"<<endl;
        }
        else if(s[i]=='b'){
            if(kakutei<=a+b && kaigai<=b){
                cout<<"Yes"<<endl;
                kakutei++;
                kaigai++;
            }else cout<<"No"<<endl;
        }
        else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   string s;
   cin>>n;
   getchar();
   cin>>s;
   getchar();
   if(s.size()<=n)
   {
    cout<<s<<endl;
       return 0;
   }
   for(int i=0;i<=n;i++)
   {
       if(i<n)
       {
           cout<<s[i];
       }
   }
   if(n!=s.size() && s.size()>n)
    cout<<"..."<<endl;
    return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int bfs[60][60][60];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	queue<pair<int,pair<int,int> > >Q;
	Q.push(make_pair(a,make_pair(b,c)));
	for(int i=0;i<60;i++)for(int j=0;j<60;j++)for(int k=0;k<60;k++)
		bfs[i][j][k]=-1;
	bfs[a][b][c]=0;
	while(Q.size()){
		int A=Q.front().first;
		int B=Q.front().second.first;
		int C=Q.front().second.second;
		Q.pop();
		if(A==B&&B==C){
			printf("%d\n",bfs[A][B][C]);return 0;
		}
		if(A+2<60&&bfs[A+2][B][C]==-1){
			bfs[A+2][B][C]=bfs[A][B][C]+1;
			Q.push(make_pair(A+2,make_pair(B,C)));
		}
		if(B+2<60&&bfs[A][B+2][C]==-1){
			bfs[A][B+2][C]=bfs[A][B][C]+1;
			Q.push(make_pair(A,make_pair(B+2,C)));
		}
		if(C+2<60&&bfs[A][B][C+2]==-1){
			bfs[A][B][C+2]=bfs[A][B][C]+1;
			Q.push(make_pair(A,make_pair(B,C+2)));
		}
		if(A+1<60&&B+1<60&&bfs[A+1][B+1][C]==-1){
			bfs[A+1][B+1][C]=bfs[A][B][C]+1;
			Q.push(make_pair(A+1,make_pair(B+1,C)));
		}
		if(A+1<60&&C+1<60&&bfs[A+1][B][C+1]==-1){
			bfs[A+1][B][C+1]=bfs[A][B][C]+1;
			Q.push(make_pair(A+1,make_pair(B,C+1)));
		}
		if(C+1<60&&B+1<60&&bfs[A][B+1][C+1]==-1){
			bfs[A][B+1][C+1]=bfs[A][B][C]+1;
			Q.push(make_pair(A,make_pair(B+1,C+1)));
		}
		
	}
}


Measured memory_bytes: 1024
import numpy as np

N = int(input())
min_keta = 10 ** 6


def get_keta(var):
    ans = 0
    while True:
        var = var // 10
        ans += 1
        if var == 0:
            break
    return ans


for a in range(1, int(np.sqrt(N)) + 1):
    if N % a == 0:
        tmp_keta = get_keta(max(a, N // a))
        if tmp_keta < min_keta:
            min_keta = tmp_keta
print(min_keta)


Measured memory_bytes: 12408
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
    if (a % b == 0) {
        return(b);
    }
    else {
        return(gcd(b, a % b));
    }
}


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

int main(void) {
    int n;
    cin >> n;
    cout << ((n % 1000) ? (1000 - (n % 1000)) : 0);
}

/*

*/


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>
#include <sstream>
#include <bitset>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) { // nCr の計算
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

int main() {
	int n;
	cin >> n;
	vector<double> x(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	sort(x.begin(), x.end());
	int ans = 99999999;
	for (int i = x[0]; i <= x[x.size() - 1]; i++) {
		int damage = 0;
		for (int j = 0; j < n; j++) {
			damage += (x[j] - i) * (x[j] - i);
		}
		ans = min(damage, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3184
N, M = map(int, input().split())
ds = []
for _ in range(M):
    ds.append(tuple(map(int, input().split()))[1::])
    
P = tuple(map(int, input().split()))

# スイッチのon/offについて全探索
oks = 0
for i in range(2**N):
    switch_states = [(i>>j)&1 for j in range(N)]
    # すべての電球について
    for di, d in enumerate(ds):
        # 関連するスイッチがonの個数を数える
        switch_counts = 0
        for s in d:
            switch_counts += switch_states[s-1]
        if switch_counts%2 != P[di]:
            break
    else:
        oks += 1
print(oks)

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

int main(){
	int q;
	scanf(" %d", &q);
	for(int i=0; i<q; ++i){
		int c, a, n;
		scanf(" %d %d %d", &c, &a, &n);
		
		int ans=0;
		//greedy
		//canが組めるまで組む
		while(c>0 && a>0 && n>0){
			ans++;	
			c--;
			a--;
			n--;
		}	
	
		//ccaが組めるまで組む
		while(c>1 && a>0){
			ans++;	
			c-=2;
			a--;
		}
		
		//cccが組めるまで組む
		while(c>2){
			ans++;	
			c-=3;
		}
		
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1188
def read_input():
    h, w = map(int, input().split())
    maze = [list(input()) for _ in range(h)]
    cell = lambda x, y : x * w + y

    edges = {}
    for hi in range(h):
        for wi in range(w):
            edges[cell(hi, wi)] = []

            if maze[hi][wi] == "#":
                continue
            if 0 <= hi - 1:
                if maze[hi - 1][wi] == '.':
                    edges[cell(hi, wi)].append(cell(hi - 1, wi))
            if hi + 1 < h:
                if maze[hi + 1][wi] == '.':
                    edges[cell(hi, wi)].append(cell(hi + 1, wi))
            if 0 <= wi - 1:
                if maze[hi][wi - 1] == '.':
                    edges[cell(hi, wi)].append(cell(hi, wi - 1))
            if wi + 1 < w:
                if maze[hi][wi + 1] == '.':
                    edges[cell(hi, wi)].append(cell(hi, wi + 1))

    return h, w, edges, maze


def warshall_floyd(h, w, edges):
    v = h * w
    d = [[v + 1 for _ in range(v)] for _ in range(v)]

    for i in range(v):
        d[i][i] = 0

    for f, tlist in edges.items():
        for t in tlist:
            d[f][t] = 1

    for k in range(v):
        for i in range(v):
            for j in range(v):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d   
    

def submit():
    h, w, edges, maze = read_input()
    dist = warshall_floyd(h, w, edges)

    max_dist = 0
    v = h * w
    for i in range(v):
        for j in range(v):
            d = dist[i][j]
            if d > v:
                continue
            if d > max_dist:
                max_dist = d
    print(max_dist)


if __name__ == "__main__":
    submit()

Measured memory_bytes: 41968
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define pi 3.141592653589793238462643383279502884197
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
bool dp1[31000][10],dp2[31000][100],dp3[1000];
signed main(){
	int n;
	string st;
	cin>>n>>st;
	dp1[0][st[0]-'0'] = 1;
	for(int i=1;i<st.size();i++){
		for(int j=0;j<=9;j++){
			dp1[i][j] = dp1[i-1][j];
		}
		dp1[i][st[i]-'0'] = true;
	}
	for(int i=1;i<st.size();i++){
		for(int j=0;j<=99;j++){
			dp2[i][j] = dp2[i-1][j];
		}
		for(int j=0;j<=9;j++){
			if( dp1[i-1][j] == 1 ) dp2[i][10*j + st[i]-'0' ] = true;
		}
	}
	for(int i=2;i<st.size();i++){
		for(int j=0;j<=99;j++){
			if( dp2[i-1][j] == 1 ) dp3[10*j+st[i]-'0'] = true;
		}
	}
	int ans = 0;
	for(int i=0;i<=999;i++){
		if( dp3[i] ) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int a,b; cin>>a>>b;
	cout<<a/b<<" "s<<a%b<<" "s<<fixed<<setprecision(8)<<1.0*a/b<<"\n"s;
}


Measured memory_bytes: 3296
import java.util.*;
import java.io.*;
public class Main  {
    public static void main(String args[]) {
      FastScanner fs=new FastScanner();    
      PrintWriter out=new PrintWriter(System.out);
      
      int k=fs.nextInt();
      String str="";
      while(k-->0)
      str+="ACL";
      out.println(str);
        
        out.flush();
        out.close();
    }
	static void ruffleSort(int[] a) {
 		Random random=new Random();
		int n=a.length;
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
}
        class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		String next() {
			while (!st.hasMoreTokens())
				try {
				st=new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		String nextLine() {
		    String str="";
		    try {
		        str=br.readLine();
		    }
		    catch (IOException e) {
		        e.printStackTrace(); 
		    }
		    return str;
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		double nextDouble() {
		    return Double.parseDouble(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
	}

Measured memory_bytes: 36556
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define rrep()
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int n,m;
    int ans=0;
    cin>>n>>m;
    rep(i,0,n){
        int a,b;
        cin>>a>>b;
        m+=a;
        m-=b;
        if(m<0){
            cout<<0<<endl;
            return 0;
        }
        ans=max(ans,m);
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 3048
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int maxn = 1010;

int n, a[3][maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= 2; i++)
        for (int j = 1; j <= n; j++)
            scanf("%d", &a[i][j]);
    for (int i = 1; i <= 2; i++)
        for (int j = 1; j <= n; j++)
            a[i][j] += max(a[i-1][j], a[i][j-1]);
    printf("%d\n", a[2][n]);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}



// check
// 問題文を復唱する


int main() {
  ll r,d,x;
  cin >> r >>d >>x ;
  // string s;
  // cin >> s;
  // vector<ll> a(n,0);
  // cin >> a;
// 
  // ll ans = 0;
  vector<ll> ans(10,-1);
  ans[0] = x*r -d;
  for (int i = 1; i < 10; i++) {
      ans[i] = ans[i-1] * r -d;
  }



  for (int i = 0; i < 10; i++) {
      cout << ans[i] <<endl;
  }
  // cout << ans <<endl;

  
  // cout << (true? "Yes":"No");


}




















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


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
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;
}
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;
}
int main(){
    ll a,b,k;cin >> a >>b >>k;
    ll c=max((ll)0,a-k);
    if(c==0)b=max((ll)0,b-(k-a));
    cout << c << " " <<b <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int N;
vector<int> A, B, C;

int search(int k) {
    int p = 0;
    for (int a = N-1; a >= 1; a /= 2) {
        while (p+a < N && A[p+a] < k){
          p += a;
        }
    }
    return p;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N;
  A.resize(N);
  B.resize(N);
  C.resize(N);
  for(int i=0; i<N; ++i)
    cin >> A[i];
  for(int i=0; i<N; ++i)
    cin >> B[i];
  for(int i=0; i<N; ++i)
    cin >> C[i];
  sort(all(A));
  sort(all(B));
  sort(all(C));
  long long res = 0;
  for(int i=0; i<N; ++i){
    int p = search(B[i]);
    if(A[p] >= B[i])
      continue;
    long long pp = upper_bound(all(C), B[i]) - C.begin();
    res += (p+1)*(N-pp); 
  }
  cout << res << "\n";
  return 0;  
}



Measured memory_bytes: 1408
#pragma GCC optimize("Ofast", "unroll-loops")
#pragma GCC target("avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (__typeof(a) i = (a); i < (b); ++i)
#define iter(it, c) \
  for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1 << 31);

#define sc second
#define fs first
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T>
T smod(T a, T b) {
  return (a % b + b) % b;
}
// vim: cc=60 ts=2 sts=2 sw=2:

int main() {
  // code

  string s;
  cin >> s;
  if (s == "BBB" || s == "AAA")
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  // codend
}


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

long long n; int h1=1001,r1=1000,h2=2001,r2=2000,stp,a[105],ans[10005];
void solve(long long n){
	if (n==1 || n%2==0){
		if (n>1) solve(n-1);
		stp++;
		ans[++r1]=stp; ans[--h2]=stp;
	} else{
		solve(n/2);
		stp++; ans[++r1]=stp; ans[++r2]=stp;
	}
}
int main(){
	scanf("%lld",&n); solve(n);int i;
	printf("%d\n",r1-h1+r2-h2+2);
	for (i=h1; i<=r1; i++) printf("%d ",ans[i]);
	for (i=h2; i<=r2; i++) printf("%d ",ans[i]);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1e-6
#define ll long long
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define int long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define fi first
#define se second
#define endl "\n"
#define pii pair<int,int>
#define fi first
#define se second
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll Max(ll a,ll b){return a>=b?a:b;}
ll Min(ll a,ll b){return a<=b?a:b;}
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res,t;res=1;t=a%c;while(b){if(b&1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
using namespace std;
//head file

int main()
{
        int num;
        cin>>num;
        if(num>=30)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define scanInt(a) scanf("%d", &a)
using namespace std;

int main() {
    int a;
    scanInt(a);
    printInt(a+a*a+a*a*a);
    return 0;
}


Measured memory_bytes: 3712
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int n;
    while (cin >> n) {
        if (n == 0) break;

        string prev;
        string current;
        cin >> prev;

        int read_cnt = 2;
        int cnt = 0;

        while (read_cnt <= n) {
            cin >> current;
            if ((prev == "lu" && current == "ru") ||
                (prev == "ru" && current == "lu") ||
                (prev == "ld" && current == "rd") ||
                (prev == "rd" && current == "ld"))
                cnt++;

            prev = current;
            read_cnt++;
        }

        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>

 int main(){
	int x, y;
	int t;

	for (;;) {
		scanf("%d%d", &x, &y);
		if (x == 0 && y == 0) break;
		if (x > y) t = x, x = y, y = t;
		printf("%d %d\n", x, y);
	}

             return 0;
             }
 



Measured memory_bytes: 2036
'''A - Garden
https://atcoder.jp/contests/abc106/tasks/abc106_a

>>> main(2, 2)
1
>>> main(5, 7)
24'''


def main(a, b):
    print((a - 1) * (b - 1))


if __name__ == "__main__":
    a, b = map(int, input().split(' '))
    main(a, b)


Measured memory_bytes: 2940
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using INT=mp::cpp_int;
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
INT LCM(INT x,INT y){
  INT z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
INT modinv(INT a, INT m) {
    INT b = m, u = 1, v = 0;
    while (b) {
        INT t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main() {
  cout << fixed << setprecision(30);
  ll n;
  string s;
  cin>>n>>s;
  if(n==1)putout(0);
  else{
    ll rwcount=0,lbcount=0,ans=1e18;
    loop(i,n)if(s[i]=='.')rwcount++;
    loop(i,n){
            ans=min(ans,rwcount+lbcount);
      if(s[i]=='.')rwcount--;
      else lbcount++;
      ans=min(ans,rwcount+lbcount);
    }
    putout(ans);
  }
}

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

int N;
constexpr int MAXN = 100;
struct Node{int id, x, y, flag;};
std::vector<Node> P;

int main() {
    std::cin >> N;
    P.resize(N * 2);
    for (int i = 0; i < N; i++) {
        P[i].id = 0;
        std::cin >> P[i].x  >> P[i].y;
    }
    for (int i = N; i < 2*N; i++) {
        P[i].id = 1;
        std::cin >> P[i].x  >> P[i].y;
    }

    std::sort(P.begin(), P.end(), [](auto a, auto b){return a.x < b.x;});
    int r_count = 0;
    int b_count = 0;
    int cnt = 0;
    for (int i = 0; i < 2 * N; ++i) {
        if (P[i].id == 1) {
            //blue
            int m = -1;
            int my = -1;
            for (int j = 0; j < i; j++) {
                if ((P[j].id == 0) && (P[j].flag == 0) && (P[j].y < P[i].y)) {
                    if(my < P[j].y) {
                        m = j;
                        my = P[j].y;
                    }
                }
            }
            if (m >= 0) {
                P[m].flag = 1;
                cnt++;
            }
        }
    }
    std::cout << cnt << std::endl;
}

Measured memory_bytes: 888