akhauriyash/Code-Regression huggingface dataset:
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string S,T; cin >> S >>T;
    int N = S.size();
    cout << (S == T.substr(0,N) ? "Yes": "No") << endl;
    
}

Measured memory_bytes: 3624
n = int(input())
s=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
x=[j for j in range(n)]
from collections import deque
import copy
old_stack=deque(['a'])
x=1
while old_stack:
    s=old_stack.popleft()
    if len(s)==n:
        old_stack.appendleft(s)
        break
    for i in range(ord(max(s))-ord('a')+2):
        old_stack.append(s+chr(ord('a')+i))

for o in old_stack:    
    print(o)

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

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define F first
#define S second

typedef pair<int,int> pii;

vector<string> va,vb;
int H,W;
int dp[55][55][55][55];
int aay[]={0,1,0,-1};
int aax[]={1,0,-1,0};
int bby[]={0,1,0,-1};
int bbx[]={-1,0,1,0};
queue<pair<pii,pii>> q;
bool check(int a,int b){
	if(0<=a&&a<H&&0<=b&&b<W) return true;
	return false;
}
int dfs(int a,int b,int c,int d){
	if(dp[a][b][c][d]>=0) return dp[a][b][c][d];
	int ret=0;
	// cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
	dp[a][b][c][d]=0;
	if(va[a][b]=='%'&&vb[c][d]=='%'){
		return dp[a][b][c][d]=1;
	}
	if(va[a][b]=='%'||vb[c][d]=='%'){
		return dp[a][b][c][d]=0;
	}
	rep(i,4){
		int aa=a+aay[i];
		int bb=b+aax[i];
		int cc=c+bby[i];
		int dd=d+bbx[i];
		if(!check(aa,bb)){
			aa=a;
			bb=b;
		}
		if(!check(cc,dd)){
			cc=c;
			dd=d;
		}
		if(va[aa][bb]=='#'){
			aa=a;
			bb=b;
		}
		if(vb[cc][dd]=='#'){
			cc=c;
			dd=d;
		}
		if(dfs(aa,bb,cc,dd)==1) ret=1;
	}
	return dp[a][b][c][d]=ret;
}
int main(){
	while(cin>>W>>H){
		if(W==0&&H==0) break;
		pii L,R;
		va=vector<string>(H);
		vb=vector<string>(H);
		rep(i,H) cin>>va[i]>>vb[i];
		rep(i,H){
			rep(j,W){
				if(va[i][j]=='L'){
					va[i][j]='.';
					L=pii(i,j);
				}
				if(vb[i][j]=='R'){
					vb[i][j]='.';
					R=pii(i,j);
				}
			}
		}
		rep(i,55){
			rep(j,55){
				rep(k,55){
					rep(l,55){
						dp[i][j][k][l]=-1;
					}
				}
			}
		}
		bool f=false;
		queue<pair<pii,pii>> q;
		q.push(make_pair(L,R));
		dp[L.F][L.S][R.F][R.S]=1;
		int a,b,c,d;
		while(q.size()){
			pair<pii,pii> top=q.front();
			q.pop();
			a=top.F.F;
			b=top.F.S;
			c=top.S.F;
			d=top.S.S;
			if(va[a][b]=='%'&&vb[c][d]=='%'){
				f=true;
				continue;
			}
			if(va[a][b]=='%'||vb[c][d]=='%'){
				continue;
			}
			// cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
			rep(i,4){
				int aa=a+aay[i];
				int bb=b+aax[i];
				int cc=c+bby[i];
				int dd=d+bbx[i];
				if(!check(aa,bb)){
					aa=a;
					bb=b;
				}
				if(!check(cc,dd)){
					cc=c;
					dd=d;
				}
				if(va[aa][bb]=='#'){
					aa=a;
					bb=b;
				}
				if(vb[cc][dd]=='#'){
					cc=c;
					dd=d;
				}
				if(dp[aa][bb][cc][dd]>=0) continue;
				else{
					dp[aa][bb][cc][dd]=1;
					q.push(make_pair(pii(aa,bb),pii(cc,dd)));
				}
			}
		}
		if(f) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 37908
import functools
N = int(input())
K = int(input())

@functools.lru_cache(None)
def func(num,counter):
    remain = num%10
    quotient = num//10
    
    
    if counter == 0:
        return 1
    
    if num<10:
        if counter ==1:
            return num
        else:
            return 0

    return func(quotient,counter-1)*remain + func(quotient-1,counter-1)*(9-remain) + func(quotient,counter)

print(func(N,K))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const string YES = "Yes";
const string NO = "No";

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll count = 0;
    while(b <= a){
        b *= 2;
        count++;
    }
    while(c <= b){
        c *= 2;
        count++;
    }
    if(count <= k){
        cout << YES << endl;
    }else{
        cout << NO << endl;
    }
    return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;

int main() {

int N,T;
cin>>N>>T;
vector<int> L(N);
fx(N){
	cin>>L.at(x);
}

ll ans=T;

for(int k=N-2;k>=0;k--){
	if(L.at(k+1)>T+L.at(k)){
		ans+=T;
	}else{
		ans+=L.at(k+1)-L.at(k);
	}
}

ce(ans);

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;

const ll inf = 1LL<<60;

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

    int a,b,q; cin >> a >> b >> q;
    vector<ll> shrine(a+2), temple(b+2); 
    shrine[0] = temple[0] = -inf;
    shrine[a+1] = temple[b+1] = inf;

    for(int i=1; i<=a; ++i) cin >> shrine[i];
    for(int i=1; i<=b; ++i) cin >> temple[i];

    vector<ll> ans(q);

    for(int i=0; i<q; ++i){
        ll x; cin >> x;
        auto itr = lower_bound(shrine.begin(), shrine.end(), x);
        ll s2 = *itr;
        --itr;
        ll s1 = *itr;

        itr = lower_bound(temple.begin(), temple.end(), x);
        ll t2 = *itr;
        --itr;
        ll t1 = *itr;

        ll a1 = x - min(s1, t1);
        ll a2 = min(x-s1, t2-x) + t2-s1;
        ll a3 = min(s2-x, x-t1) + s2-t1;
        ll a4 = max(s2, t2) - x;

        ans[i] = min(min(a1, a2), min(a3, a4));
    }

    for(auto e:ans) cout << e << endl;

    return 0;
}

Measured memory_bytes: 3712
s=input()
s=s[::-1]
while len(s)>0:
    l=len(s)
    if l>=5 and s[:5]=='dream'[::-1]:
        s=s[5:]
    elif l>=7 and s[:7]=='dreamer'[::-1]:
        s=s[7:]
    elif l>=5 and s[:5]=='erase'[::-1]:
        s=s[5:]
    elif l>=6 and s[:6]=='eraser'[::-1]:
        s=s[6:]
    else:
        break
if s=='':
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int powder = Integer.parseInt(sc.next());
        int min = Integer.MAX_VALUE;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            int donuts =Integer.parseInt(sc.next());
            powder -= donuts;
            min = Math.min(min, donuts);
            cnt++;
        }
        if (powder > 0) {
            while (powder - min >= 0) {
                powder -= min;
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}

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

int main(void){
    string s;
    cin >> s;
    int n = s.length(); n--;

    // 条件1
    rep(i,(n-1)/2) {
        if (s[i] != s[n-i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    int end = (n-1)/2;

    // 条件2
    rep(i, (end-1)/2) {
        if (s[i] != s[end-i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    int start = (n+3)/2;
    // 条件3
    rep(i,(n-1)/2) {
        if (s[start+i] != s[n-i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;


    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ALDS1_1
{
    class Program
    {
        private static string Join(int[] a)
        {
            var r = "";
            for(int i = 0; i < a.Length; i++)
            {
                r += a[i].ToString();
                if(i != a.Length - 1) r += ' ';
            }
            return r;
        }

        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for(int i = 0; i < n; i++)
            {
                int v = a[i], j = i - 1;
                while (j >= 0 && a[j] > v)
                {
                    a[j + 1] = a[j--];
                    a[j + 1] = v;
                }
                Console.WriteLine(Join(a));
            }
        }
    }
}

Measured memory_bytes: 10128
#include <bits/stdc++.h>
#define intt long long
#define pb push_back
#define mk make_pair
#define ii pair<intt,intt>
#define sc second
#define fr first
using namespace std;
int main()
{
    int t=10;
    int r,d,x;
    cin>>r>>d>>x;
    while(t--)
    {
        intt last=x;
        x=r*x-d;
        cout<<x<<endl;
    }
   return 0;
}


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

int main(){
    char s[5];
    int flag = 0;
    cin >> s;
    int i;
    for (i = 0;i < 3;i++){
        if(s[i] == s[i+1])flag=1;
    }
    if(flag)
    cout << "Bad" << endl;
    else
    {
        cout << "Good" << endl;
    }
    
} 

Measured memory_bytes: 256
#include <cstdio>
int n, l, a[100005];
int main() {
	int i, j;
	scanf("%d%d", &n, &l);
	for(i=1; i<=n; i++) {
		scanf("%d", a+i);
		if(a[i] + a[i-1] >= l) break;
	}
	if(i<=n) {
		puts("Possible");
		if(i>1) i--;
		for(j=1; j<i; j++) printf("%d\n", j);
		for(j=n-1; j>=i; j--) printf("%d\n", j);
	} else {
		puts("Impossible");
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
	int X, Y;
	cin >> X >> Y;
	bool flag = false;

	for (int i = 0; i <= X; ++i) {
		if (i * 2 + (X - i) * 4 == Y) flag = true;
	}


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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
	ll N;
	cin >> N;
	vec A(N), B(N);
	REP(i, N) {
		cin >> A[i] >> B[i];
	}

	ll ans = 0;
	ll sum = 0;

	IREP(i, N) {
		ans += (B[i] - ((A[i] + sum) % B[i])) % B[i];
		sum += (B[i] - ((A[i] + sum) % B[i])) % B[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e10;
const double EPS=1e-8;

int main(){
	ll n;
	cin>>n;
	vector<ll> d;
	for(ll i1=0;i1<n;i1++){
		ll temp;
		cin>>temp;
		d.push_back(temp);
	}
	sort(d.begin(),d.end());
	ll ans=0;
	for(ll i1=0;i1<=100000;i1++){
		ll index = distance(d.begin(),lower_bound(d.begin(),d.end(),i1));
		if(index == n/2){
			ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1400
import math
while True:
    n = input()
    if (n == 0):
        break
    d = []
    EPS = 10 ** (-6)

    for i in range(n):
        a = map(float, raw_input().split(","))
        x = a[0]
        y = a[1]
        d.append([y,x])
    ans = 1
    for Y in range(0, 100):
        for X in range(0, 100):
            y1 = 1.0 * Y / 10
            x1 = 1.0 * X / 10
            sheet = 0
            for i in range(n):
                dist = (d[i][0] - y1) ** 2 + (d[i][1] - x1) ** 2
                if (dist <= 1.0):
                    sheet += 1
            ans = max(ans, sheet)
    print ans

Measured memory_bytes: 4444
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int d = input.nextInt();
        int n = input.nextInt();
        if (n == 100){
            n++;
        }
        System.out.println(rightLeadingZero(n, d * 2));
    }
    public static String rightLeadingZero (int number, int count){
        StringBuilder out = new StringBuilder(String.valueOf(number));
        for (int i = 0; i < count; i++) {
            out.append(0);
        }

        return out.toString();
    }
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			long[] arr = Console.ReadLine().Trim().Split(' ').Select(hogehoge => long.Parse(hogehoge)).ToArray<long>();

			long a = arr[0];
			long b = arr[1];

			if (a > b * 2)
			{
				Console.WriteLine(a - b * 2);
			}
			else
			{
				Console.WriteLine(0);
			}

		}

	}

}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
ll lcm(ll a,ll b)
{
	return (a/__gcd(a,b))*b;
}
bool cmp(pair<string,ll> a,pair<string,ll> b)
{
	if(a.first<b.first)
		return 1;
	else if(a.x==b.x)
	{
		return a.y<b.y;
	}
	return 0;
}
void solve()
{
	ll n;
	cin>>n;
	ll a[n+1],b[n];
	ll cnt=0;
	for(ll i=0;i<=n;i++)
	{
		cin>>a[i];
	}
	for(ll i=0;i<n;i++)
	{
		cin>>b[i];
	}
	ll x;
	for(ll i=0;i<n;i++)
	{
		x=min(a[i],b[i]);
		a[i]-=x;
		b[i]-=x;
		cnt+=x;
		x=min(a[i+1],b[i]);
		a[i+1]-=x;
		b[i]-=x;
		cnt+=x;
	}
	cout<<cnt;	
}	

int main()
{
	IOS
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}

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

int main() {
  string s;
  cin >> s;
  int n=s.size();
  for(int i=0;i<n;i+=2){
    cout << s.at(i);
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#define ll long long
using namespace std;

int main(){
    string s;
    cin >> s;
    ll check = 0;
    ll ans = 0;
    //cout << s << endl;
    for(ll i = 0; i < s.length(); i++){
        if(s[i]=='A')
            check++;
        else if(s[i]!='A' && i > 0){
            if(s[i]=='B' && s[i+1]=='C'){
                ans+=check;
                i--;
                s.erase(i,2);
            }
            else check = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define input() for(int i=0;i<n;i++)cin>>a[i];
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int n, m, ans = 0;
P p[100005];
signed main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> p[i].second >> p[i].first;
	}
	sort(p, p + m);
	int left = 0;
	rep(i, m) {
		if (left < p[i].second) {
			ans++;
			left = p[i].first - 1;
		}
	}
	cout << ans << endl;
	endre;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int sum = 0;
        char ss[] = s.toCharArray();
        char tt[] = t.toCharArray();
        for(int i = 0; i < 3; i++) {
        	if (ss[i] == tt[i])
        		sum ++;
        }
        System.out.println(sum);

	}


}


Measured memory_bytes: 21588
n, k = map(int, input().split())
import math
mod = (10**9) +7
def kai(x):
  if x == 0:
    return 1
  elif x < 0:
    return 1
  else:
    return math.factorial(x)
  
for i in range(1, k+1):
  if n - k  + 1 >= i:
    result = (kai(k-1)*kai(n-k+1))//(kai(i-1)*kai(k-i)*kai(i)*kai(n-k+1-i))
    result2 = result % mod
    print(result2)
  else:
    print(0)




Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <class T>
T inf = numeric_limits<T>::max();

vector<int> a,b,c,d;
int N,M,Q;
ll ans = 0;

void dfs(int now, int cnt, vector<int> num) {
  if (cnt == N) {
    ll temp = 0;
    for (int i = 0; i <= Q; ++i) {
      if (num[b[i]] - num[a[i]] == c[i]) temp += d[i];
    }

    if (temp > ans) ans = temp;

    return;
  }

  for (int i = now; i <= M; ++i) {
    auto n = num;
    n.push_back(i);
    dfs(i, cnt+1, n);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M >> Q;

  a.resize(Q);
  b.resize(Q);
  c.resize(Q);
  d.resize(Q);
  for (int i = 0; i < Q; ++i) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--, b[i]--;
  }
  
  dfs(1, 0, vector<int>());

  cout << ans << endl;
}


Measured memory_bytes: 3608
fun main(arr: Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val students = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }
    val checkpoints = (1..m).map { readLine()!!.split(" ").map { it.toInt() } }
    val ans = students.map { s-> getPoint(s, checkpoints) + 1 }
    ans.forEach { println(it) }
}

fun getPoint(pos:List<Int>, checkpoints:List<List<Int>>):Int {
    val diff = checkpoints.map { Math.abs(pos[0]-it[0]) + Math.abs(pos[1] - it[1]) }
    val ans = diff.indices.filter { diff[it] == diff.min()!! }.first()
    return ans
}

Measured memory_bytes: 38560
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt(); 	
      
      if(A+B >= A-B && A+B >= A*B){
     System.out.println(A+B);
      }else if(A-B >= A+B && A-B >= A*B){
	 System.out.println(A-B);
      }else{
     System.out.println(A*B);
      }
}
}

Measured memory_bytes: 22868
#include <iostream>

using namespace std;

int main(){
    int H, W;

	while(1){    
		cin >> H; cin >> W;
		if(0 == H && 0 == W) { break; }
		for(int i = 0; i < H; ++i){
		    for(int j = 0; j < W; ++j){
		        cout << "#";
		    }
		    cout << endl;
		}
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
//const ll mod = 1000000007;
int N;
ll d;
string S[300];
set<string> st[300];

set<string> f(string S) {
    set<string> ret;
    for(int i = 0; i < S.size(); i++) {
        for(char a = 'a'; a <= 'z'; a++) {
            string T = S;
            T[i] = a;
            ret.insert(T);
        }
        string T = S;
        T.erase(T.begin() + i);
        ret.insert(T);
    }
    for(int i = 0; i <= S.size(); i++) {
        for(char a = 'a'; a <= 'z'; a++) {
            string T = S;
            T.insert(T.begin() + i, a);
            ret.insert(T);
        }
    }
    for(int i = 0; i + 1 < S.size(); i++) {
        string T = S;
        swap(T[i], T[i+1]);
        ret.insert(T);
    }
    return ret;
}

void solve() {
    cin >> d;
    for(int i = 0; i < N; i++) {
        cin >> S[i];
    }
    sort(S, S+N);
    for(int i = 0; i < N; i++) {
        st[i] = f(S[i]);
    }
    vector<pair<string, string>> ans;
    for(int i = 0; i < N; i++) {
        set<string> tmp1 = st[i];
        for(int j = i + 1; j < N; j++) {
            set<string> tmp2;
            tmp2.insert(S[j]);
            set<string> tmp;
            if(d == 1) set_intersection(tmp1.begin(), tmp1.end(), tmp2.begin(), tmp2.end(), inserter(tmp, tmp.end()));
            if(d == 2) set_intersection(tmp1.begin(), tmp1.end(), st[j].begin(), st[j].end(), inserter(tmp, tmp.end()));
            if(tmp.size() >= 1) ans.push_back({S[i], S[j]});
        }
    }
    for(auto tmp : ans) {
        cout << tmp.first << "," << tmp.second << endl;
    }
    cout << ans.size() << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N) {
        if(N == 0) break;
        solve();
    }
    return 0;
}


Measured memory_bytes: 17492
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#define int long long
#define mod 1000000007
using namespace std;

int dp[3005][3005][2];//i回操作をした j個赤いボールが残っている　赤いボールがなくなったことがある
signed main() {
	int n, m; cin >> n >> m;
	dp[0][0][1] = 1;
	for (int i = 1; i <= n; i++) {
		dp[0][i][0] = 1;
	}
	for (int i = 0; i < m; i++) {
		dp[i + 1][1][1] += dp[i][0][1];
		dp[i + 1][0][1] += dp[i][0][1];
		dp[i + 1][1][1] += dp[i][1][1];
		dp[i + 1][0][1] += dp[i][1][1];
		if(n-1)dp[i + 1][2][1] += dp[i][1][1];
		if (n - 1)dp[i + 1][1][1] += dp[i][1][1];
		dp[i + 1][1][1] += dp[i][1][0];
		dp[i + 1][0][1] += dp[i][1][0];
		if (n - 1)dp[i + 1][2][0] += dp[i][1][0];
		if (n - 1)dp[i + 1][1][0] += dp[i][1][0];
		dp[i + 1][0][0] %= mod;
		dp[i + 1][0][1] %= mod;
		dp[i + 1][1][0] %= mod;
		dp[i + 1][1][1] %= mod;
		for (int j = 2; j <= n; j++) {
			for (int k = 0; k < 2; k++) {
				dp[i + 1][j - 1][k] += dp[i][j][k];
				dp[i + 1][j - 1][k] %= mod;
				dp[i + 1][j][k] += dp[i][j][k];
				if (j < n)dp[i + 1][j][k] += dp[i][j][k];
				dp[i + 1][j][k] %= mod;
				dp[i + 1][j + 1][k] += dp[i][j][k];
				dp[i + 1][j + 1][k] %= mod;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		ans = (ans + dp[m][i][1]) % mod;
	}
	cout << ans << endl;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const ll INF = TEN(18);
const int L = TEN(9);

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    V<int> xs;
    V<pair<pii, ll>> pts;

    rep(i, N) {
        int X, Y, P;
        cin >> X >> Y >> P;
        xs.pb(X);
        pts.eb(mp(X, Y), P);
    }
    sort(ALL(xs));

    V<ll> ans(N + 1, INF);

    rep(i, 1 << N) {
        V<ll> d(N);
        V<ll> xp{0};
        rep(j, N) if (i >> j & 1) { xp.pb(xs[j]); }
        V<int> vec;

        rep(j, N) {
            d[j] = abs(pts[j].fi.se);
            for (ll x : xp) {
                chmin(d[j], abs(pts[j].fi.fi - x));
            }
            if (d[j]) {
                vec.eb(j);
            }
        }

        int sz = vec.size();
        rep(j, 1 << sz) {
            ll t = 0;
            auto ds = d;
            rep(k, sz) if (j >> k & 1) {
                rep(l, sz) {
                    int id = vec[l];
                    chmin(ds[id], abs(pts[id].fi.se - pts[vec[k]].fi.se));
                }
            }
            rep(k, sz) { t += ds[vec[k]] * pts[vec[k]].se; }
            int cnt = __builtin_popcount(i) + __builtin_popcount(j);
            chmin(ans[cnt], t);
        }
    }

    rep(i, N + 1) { cout << ans[i] << endl; }

    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int N, L; cin >> N >> L;
    string arr[N];
    for(int i = 0; i < N; i++) cin >> arr[i];
    sort(arr, arr+N);
    for(int i = 0; i < N; i++) cout << arr[i];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    IOS;
    int n;
    cin>>n;
   	double a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    double dp[n+1]={0};
    dp[0]=1;
    for(int i=0;i<n;i++){
    	double temp[n+1]={0};
    	for(int j=0;j<n+1;j++) temp[j]=(double)dp[j]*(double)(1-a[i]);
    	for(int j=0;j<n;j++) temp[j+1]+=(double)dp[j]*(double)(a[i]);
    	for(int j=0;j<n+1;j++) dp[j]=temp[j];
    }
    double ans=0;
    for(int i=n/2+1;i<=n;i++){
    	ans+=dp[i];
    }
    cout<<setprecision(12)<<ans<<endl;
}

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

using namespace std;

const int MAX_N = 510;

vector<int> ending[MAX_N];

int main()
{
	int N, M, Q;
	cin >> N >> M >> Q;
	// cout << N << M << Q << endl;
	while(M--)
	{
		int l, r;
		cin >> l >> r;
		ending[l].push_back(r);
	}
	for(int i = 1; i <= N; i++)
	{
		sort(ending[i].begin(), ending[i].end());
		// cout << "I = " << i << endl;
		// for(auto &j : ending[i])
		// {
		// 	cout << j << " -> ";
		// }
		// cout << endl;
	}
	while(Q--){
		int p, q;
		cin >> p >> q;
		int ans = 0;
		for(int i  = p; i <= q; i++)
		{
			if(ending[i].size() > 0)
			{  
				// cout << "I = " << i << " : " << distance(ending[i].begin(), upper_bound(ending[i].begin(), ending[i].end(), q)) << " : " << *upper_bound(ending[i].begin(), ending[i].end(), q) << endl;
				ans += distance(ending[i].begin(), upper_bound(ending[i].begin(), ending[i].end(), q));
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<string>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<iomanip>
#define pi 3.14159265358979323846
using namespace std;

int main()
{
	int n,i;
	double x[1000],y[1000],sum=0.0,m,d1=0.0,d2=0.0,d3=0.0,d_inf=0.0,temp=0.0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x[i];
	}
	for(i=0;i<n;i++){
		cin>>y[i];
	}
	for(i=0;i<n;i++){
		d1 += abs(x[i] - y[i]);
	}
	for(i=0;i<n;i++){
		d2 += (x[i] - y[i])*(x[i] - y[i]);
	}
	d2 = sqrt(d2);
	for(i=0;i<n;i++){
		d3 += pow(abs(x[i] - y[i]),3);
	}
	d3 = pow(d3,1.0/3.0);
	for(i=0;i<n;i++){
		if(d_inf < abs(x[i]-y[i]))
			d_inf = abs(x[i]-y[i]);
	}
	cout<<setprecision(9)<<fixed<<d1<<endl;
	cout<<d2<<endl;cout<<d3<<endl;cout<<d_inf<<endl;
	
}



Measured memory_bytes: 3428
#include <iostream>

using namespace std;

//n^r
long long power(long long n, long long r){
  long long ans = 1;
  while(r > 0){
    if(r & 1)
      ans *= n;
    n *= n;
    r >>= 1;
  }
  return ans;
}


int main(){
  int N, K;
  cin >> N >> K;
  //入力終わり

  //このときはKの倍数は作れない
  if(2*N < K){
    cout << 0 << endl;
    return 0;
  }
  
  //K未満の数を考える
  int under;
  //Kが奇数なら題意を満たすa,b,cは存在しない
  if(K&1)
    under = 0;
  //Kが偶数なら，a,b,cは全てKで割った余りがK/2
  else
    //Km + K/2 < N となるmの数をカウント
    under = (N-K/2)/K + 1;

  //K以上N以下の数の中で，Kの倍数の個数を数える
  int over  = N/K;

  //組み合わせはそれぞれ3乗通りある
  cout << power(under, 3) + power(over, 3) << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char maze[15][1005];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int h,w,k,ans=0x7fffffff,cont;
    cin>>h>>w>>k;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>maze[i][j];
        }
    }
    for(int i=0;i<=(1<<h-1)-1;i++){
        vector<vector<int> >vec(h+5);
        vector<int>sum,shu;
        int loc=1,cont=0;
        vec[loc].push_back(1);

        for(int j=1,cut=i;j<h;j++,cut>>=1){//纵向划分巧克力块
            if(cut&1){
                loc++;
                vec[loc].push_back(j+1);
            }else{
                vec[loc].push_back(j+1);
            }
        }

        for(int j=0;j<=loc;j++){//初始化计数
            sum.push_back(0);
            shu.push_back(0);
        }

        /*
        for(int x=1;x<=loc;x++){
            for(int y=0;y<vec[x].size();y++){
                cout<<vec[x][y]<<" ";
            }
            cout<<endl;
        }
        cout<<"--------------------"<<endl;
        */

        bool book=false;

        for(int j=1;j<=w;j++){

            bool flag=false;

            for(int q=1;q<=loc;q++){
                shu[q]=0;
                for(int w=0;w<vec[q].size();w++){
                    if(maze[vec[q][w]][j]=='1'){
                        shu[q]++;
                        if(sum[q]+shu[q]>k) flag=true;
                    }
                }
                if(shu[q]>k){
                    book=true;
                    break;
                }
            }
            if(book) break;

            if(flag){
                cont++;
                for(int q=1;q<=loc;q++){
                    sum[q]=shu[q];
                }
            }else{
                for(int q=1;q<=loc;q++){
                    sum[q]+=shu[q];
                }
            }


        }

        if(book) continue;

        ans=min(ans,cont+loc-1);

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


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

int main() {
    int n, r;
    while(cin >> n) {
        r = 0;
        for (int i = 0; i <= 9; i++) {
            for (int j = 0; j <= 9; j++) {
                for (int k = 0; k <= 9; k++) {
                    for (int l = 0; l <= 9; l++) {
                        if (i + j + k + l == n) r++;
                    }
                }
            }
        }
        cout << r << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//LCS
	string a, b, ans = "";
	cin >> a >> b;
	int m = a.size(), n = b.size();
	vector<vector<int>> dp(m + 1, vector<int> (n + 1, 0));
	for (int i = 1; i <= m; i++)
		for (int j = 1; j <= n; j++)
			(a[i - 1] == b[j - 1]) ?  dp[i][j] = 1 + dp[i - 1][j - 1] : dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

	int i = m, j = n;
	while (i > 0 && j > 0) {
		if (dp[i][j] == dp[i - 1][j])
			i--;
		else if (dp[i][j] == dp[i][j - 1])
			j--;
		else {
			ans += a[i - 1];
			i--;
			j--;
		}
	}

	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

Measured memory_bytes: 38500
#include <iostream>
using namespace std;
int main(){
int n, A[100];
cin >> n;
for(int i = 0; i < n; i++)cin >> A[i];
for(int i = n-1; i>=0; i--){
if(i != n-1)cout<<" ";
cout<<A[i];
}
cout<<endl;
return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;
using ll = long long;


int main() {
    ll a,b,c;
    cin >> a >> b >> c;
    ll A,B,C,cnt=0;
    while(1){
        if(a%2==1||b%2==1||c%2==1)  break;
        if(cnt>=1000000){
                cnt=-1;
                break;
        }
        cnt++;
        A = a,B = b,C = c;
        a = B/2+C/2;
        b = A/2+C/2;
        c = A/2+B/2;
    }
    cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for (int i=x;i<=y;i++)
int calc(long long x)
{
	int cnt=0;
	while (x)
	{
		cnt++;
		x/=10;
	}
	return cnt;
}
int main()
{
	long long n;
	scanf("%lld",&n);
	int ans=200;
	for (int i=1;1ll*i*i<=n;i++)
	{
		if (n % i==0) 
		{
			int sum=max(calc(i),calc(n/i));
			if (sum<ans) ans=sum;
		}
	}
	printf("%d\n",ans);
}

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

const ll M=1000005,mod=998244353;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

int n,m;

int main(){
	Init();
	cin>>n>>m;
	if(n>m) swap(n,m);
	ll t=0;
	for(int i=0;i<n;i++) (t+=nCk(2*i+1,i)*nCk(n+m-2*i-2,n-i-1))%=mod;
	cout<<(m+Div(t,nCk(n+m,n)))%mod<<endl;
}

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

int a[100050];

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

    int n;
    cin>>n;
    
    for(int i=0;i<n;i++)cin>>a[i];
    
    int c=1;
    int cnt=0;
    
    for(int i=0;i<n;i++)
    {
        if(c==a[c-1])
        {
            c=1;
            break;
        }
        c=a[c-1];
        cnt++;
        if(c==1)break;
        if(c==2)break;
    }
    
    if(c==1||cnt==n)cout<<-1;
    else cout<<cnt;
    cout<<"\n";

    return 0;
}



Measured memory_bytes: 4056
#include <stdio.h>
#define SIZE 10
#define show {for(y=2; y<SIZE+2; y++){for(x=2; x<SIZE+2; x++) printf("%d",map[x][y]);printf("\n");}printf("\n");}

/* ツ青「ツ界ツづーツ右ツづ可２ツマツスツ可コツづ可２ツマツスツつクツづァツつキ */

int main(void){
	int map[SIZE+4][SIZE+4], count=0, max=0, x, y, size;
	
	for(y=2; y<SIZE+2; y++)
		for(x=2; x<SIZE+2; x++)
			map[x][y]=0;
	
	while(~scanf("%d,%d,%d",&x,&y,&size)){
		x+=2, y+=2;
		
		if(size>=1)
			map[x][y]++, map[x-1][y]++, map[x+1][y]++,
			map[x][y-1]++, map[x][y+1]++;
		if(size>=2)
			map[x-1][y-1]++, map[x+1][y-1]++,
			map[x-1][y+1]++, map[x+1][y+1]++;
		if(size==3)
			map[x-2][y]++, map[x+2][y]++,
			map[x][y-2]++, map[x][y+2]++;
	}
	
	for(y=2; y<SIZE+2; y++)
		for(x=2; x<SIZE+2; x++){
			if(map[x][y]==0) count++;
			if(map[x][y]>max) max=map[x][y];
		}
	
	printf("%d\n%d\n",count,max);

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
template<class Type> class UnionFind
{
    private:
        vector<Type> data;
        int groups;
    public:
        UnionFind(int sz)
        {
            data.assign(sz, -1);
            this->groups = sz;
        }
        bool unite(Type x, Type y)
        {
            x = find(x), y = find(y);
            if (x == y) return (false);
            if (data[x] > data[y]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
            groups--;
            return (true);
        }
        Type find(Type k) {
            if (data[k] < 0) return (k);
            return (data[k] = find(data[k]));
        }
        Type size(Type k) { return (-data[find(k)]); }
        bool same(Type x, Type y) { return find(x) == find(y); }
        int getGroups() { return this->groups; }
};
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<int> p(n);
    for(int i = 0; i < n; i++)
    {
        cin >> p[i];
        p[i]--;
    }
    UnionFind<int> uf(n);
    vector<int> x(m), y(m);
    for(int i = 0; i < m; i++)
    {
        int x, y; cin >> x >> y;
        x--, y--;
        uf.unite(p[x], p[y]);
    }
    int ans = 0;
    for(int i = 0; i < n; i++) if(uf.same(i, p[i])) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

ll a,b,k;

void input(){
    cin >> a >> b >> k;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    ll num = GCD(a, b);
    vector<ll> yakusuu;
    for(ll i=1;i<=num;++i){
        if(num%i==0) yakusuu.push_back(i);
    }
    sort(yakusuu.begin(), yakusuu.end(), greater<>());
    cout << yakusuu[k-1] << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;

namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;

        static int N;

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            while (true)
            {
                var input = cin.SplitRead();
                if (input[0] == 0 && input[1] == 0) { return; }
                int n = input[0];
                int s = input[1];
                long ans = 0;
                for(var bit = 0; bit < (1 << 10); bit++)
                {
                    List<int> use = new List<int>();
                    for(var i = 0; i < 10; i++)
                    {
                        if ((bit & (1 << i)) != 0)
                        {
                            use.Add(i);
                        }
                    }
                    if (use.Count() == n && use.Sum() == s)
                    {
                        ans++;
                    }
                }
                Console.WriteLine(ans);
            }
            //Console.Out.Flush();
        }

        
    }
    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public long Modulo(long value, long mod)
        {
            long r = value % mod;

            if (r * mod < 0)
            {
                r += mod;
            }
            return r;
        }
    }

    

}






Measured memory_bytes: 18396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,d,h,i,j,k,l,m,n,v,w,x,y,z;
	ll		ans = 0;
	string	s;
	cin >> n;

	if (n) cout << 0 << endl;
	else cout << 1 << endl;
	return 0;
}


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

int main(int argc, char* argv[]){
    unsigned long N, A, B;
    unsigned long ans;
    scanf("%lu %lu %lu", &N, &A, &B);
    ans = N / (A+B);
    ans *= A;
    // printf("%d\n", ans);

    if((N % (A+B) >= A)){
        ans += A;
    }else{
        ans += N%(A+B);
    }
    printf("%lu", ans);
}

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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int W, H, N; cin >> W >> H >> N;
    int x1 = 0, x2 = W, y1 = 0, y2 = H;
    for (int i = 0; i < N; i++) {
        int x, y, a; cin >> x >> y >> a;
        if (a == 1) x1 = max(x1, x);
        if (a == 2) x2 = min(x2, x);
        if (a == 3) y1 = max(y1, y);
        if (a == 4) y2 = min(y2, y);
    }

    int ans = 0;
    if (x1 < x2 && y1 < y2) ans = (x2 - x1) * (y2 - y1);
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>                                                  
using namespace std;                                                     
#define endl '\n'                                                        
#define pb push_back                                                     
#define all(x) x.begin(), x.end()                                        
#define rep(i, n) for (int i = 0; i < n; ++i)                            
#define reps(i, m, n) for (int i = m; i <= n; ++i)                       
typedef long long ll;                                                    
typedef vector<int> vi;                                                  
typedef vector<ll> vl;                                                   
typedef pair<int, int> pii;                                              
typedef pair<ll, ll> pll;                                                
const int INF = 0x3f3f3f3f;                                              
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;                                    
                                                                         
signed main()                                                            
{                                                                        
  cin.tie(0); ios::sync_with_stdio(false);                               
                                                                         
  int k, s; cin >> k >> s;                                               
                                                                         
  int cnt = 0;                                                           
                                                                         
  for (int x = 0; x <= k; ++x) {                                         
    for (int y = 0; y <= k; ++y) {                                       
      int z = s - x - y;                                                 
      if( z <= k && z >= 0 ) cnt++;                                      
    }                                                                    
  }                                                                      
                                                                         
  cout << cnt << endl;                                                   
                                                                         
  return 0;                                                              
}                                                                        
                                                                         

Measured memory_bytes: 256