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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template

int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

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

    int a,b;
    cin>>a>>b;
    if(a+b >= 10) cout<<"error\n";
    else cout<<a+b<<newl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <string>

using namespace std;

#define U unsigned
#define S short
#define L long
#define LL long long 
#define LLU long long unsigned

//Reading and Printing Arrays

//short int
#define rhd(arr, n) for(int aab = 0; aab < n; aab++){scanf("%hd", &arr[aab]);}
#define phd(arr, n) for(int aab = 0; aab < n; aab++){printf("%hd ", arr[aab]);}
//int
#define rd(arr, n) for(int aab = 0; aab < n; aab++){scanf("%d", &arr[aab]);}
#define pd(arr, n) for(int aab = 0; aab < n; aab++){printf("%d ", arr[aab]);}
//unsigned int
#define ru(arr, n) for(int aab = 0; aab < n; aab++){scanf("%u", &arr[aab]);}
#define pu(arr, n) for(int aab = 0; aab < n; aab++){printf("%u ", arr[aab]);}
//long int
#define rld(arr, n) for(int aab = 0; aab < n; aab++){scanf("%ld", &arr[aab]);}
#define pld(arr, n) for(int aab = 0; aab < n; aab++){printf("%ld ", arr[aab]);}
//unsigned long int
#define rlu(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lu", &arr[aab]);}
#define plu(arr, n) for(int aab = 0; aab < n; aab++){printf("%lu ", arr[aab]);}
//long long int
#define rlld(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lld", &arr[aab]);}
#define plld(arr, n) for(int aab = 0; aab < n; aab++){printf("%lld ", arr[aab]);}
//unsigned long long int
#define rllu(arr, n) for(int aab = 0; aab < n; aab++){scanf("%llu", &arr[aab]);}
#define pllu(arr, n) for(int aab = 0; aab < n; aab++){printf("%llu ", arr[aab]);}
//float
#define rf(arr, n) for(int aab = 0; aab < n; aab++){scanf("%f", &arr[aab]);}
#define pf(arr, n) for(int aab = 0; aab < n; aab++){printf("%f ", arr[aab]);}
//double
#define rlf(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lf", &arr[aab]);}
#define plf(arr, n) for(int aab = 0; aab < n; aab++){printf("%lf ", arr[aab]);}
//char
#define rc(arr, n) for(int aab = 0; aab < n; aab++){scanf("%c", &arr[aab]);}
#define pc(arr, n) for(int aab = 0; aab < n; aab++){printf("%c", arr[aab]);}
//string
#define rs(arr) scanf("%s", arr);
#define ps(arr) puts(arr);

//swap
#define swap(a, b, tip) tip tempswap = a;a = b;b = tempswap;
//freopen
#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);

/*       ▄▀▄     ▄▀▄
        ▄█░░▀▀▀▀▀░░█▄
    ▄▄  █░░░░░░░░░░░█  ▄▄
   █▄▄█ █░░▀░░┬░░▀░░█ █▄▄█       */

int min(int a, int b){	return a <= b ? a : b;}
int max(int a, int b){	return a >= b ? a : b;}
int findmin(int arr[], int n){int min = 0;for(int i = 1; i < n;min = arr[i] < arr[min] ? i : min, i++);return min;}
int findmax(int arr[], int n){int max = 0;for(int i = 1; i < n;max = arr[i] > arr[max] ? i : max, i++);return max;}
int arrsum(int arr[], int n){int sum = 0;for(int i = 0; i < n; sum += arr[i], i++);return sum;}
	
int main(){
	
	char arr[7];

	scanf("%s", arr);

	if(arr[2] == arr[3] && arr[4] == arr[5]){
		puts("Yes");
	}	
	else{
		puts("No");
	}
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;

ll a[MAXn],b[MAXn];
multiset<ll> ms;
map<ll,ll> mp;
int main(){
    IOS();
    ll n,m;
    cin >> n >> m;
    for (ll i=1;i<=n;++i) {
        cin >> a[i] >> b[i];
        a[i]--;
    }
    
    for (int i=0;i<m;++i) {
        mp[i] = i;
        ms.insert(0);
    }
    for (int i=1;i<=n;++i) {
        ll l = -1;
        for (auto j=mp.lower_bound(a[i]);j != mp.end() && j->first <= b[i];mp.erase(j++)) {
            ll f = j->first;
            l = max(l,mp[f]);
            ms.erase(ms.find(f - mp[f]));
        }
        if (l != -1 && b[i] < m) {
            mp[b[i]] = l;
            ms.insert(b[i] - l);
        }
        if (SZ(ms)) cout << *ms.begin() + i << endl;
        else cout << -1 << endl;
    }
}


Measured memory_bytes: 28592
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int>P;
#define X second
#define Y first
#define pb push_back
#define LL long long

int main(){
	int AN,BN,R;
	while(cin>>AN>>BN>>R,AN){
		LL ans=0;
		vector<P>V;
		for(int i=0;i<AN;i++){
			int x,y;
			cin>>x>>y;
			V.pb(P(y,x));
		}
		V.pb(P(114514,114514));
		V.pb(P(810893,810893));
		sort(V.begin(),V.end());
		
		for(int i=0;i<BN;i++){
			int x,y;
			cin>>x>>y;
			
			vector<P>::iterator it=lower_bound(V.begin(),V.end(),P(y-4*R,x-4*R));
			for(;(*it).Y<=y+4*R;){
				
				if(((*it).X-x)*((*it).X-x)+((*it).Y-y)*((*it).Y-y)<=16*R*R){
					ans++;
				}
				
				if(x+4*R<(*it).X){
					it=lower_bound(V.begin(),V.end(),P((*it).Y+1,x-4*R));
				}
				else{
					it++;
				}
			}
			
		}
		
		cout<<ans<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 2636
#include <stdio.h>
#include <stdlib.h>
#define SENTINEL 1000000001

int g_num_swap = 0;

void merge(int *a, int left, int mid, int right) {
	int n1, n2, *L, *R, i, j, k;

	n1 = mid - left;
	n2 = right - mid;
	L = malloc(sizeof(int)*n1 + 1);
	R = malloc(sizeof(int)*n2 + 1);
	for (i = 0; i < n1; i++) {
		L[i] = a[left + i];
	}
	for (i = 0; i < n2; i++) {
		R[i] = a[mid + i];
	}
	L[n1] = R[n2] = SENTINEL;

	i = j = 0;
	for (k = left; k < right; k++) {
		if (L[i] <= R[j]) {
			a[k] = L[i++];
		} else {
			a[k] = R[j++];
		}
		g_num_swap++;
	}
	free(L);
	free(R);
}

void merge_sort(int *a, int left, int right) {
	int mid;

	if (left+1 < right) {
		mid = (left + right) / 2;
		merge_sort(a, left, mid);
		merge_sort(a, mid, right);
		merge(a, left, mid, right);
	}
}

int main(void) {
	int *s, n, i;
	const char *fmt = "%d";

	scanf("%d", &n);
	s = malloc(sizeof(int)*n);
	for (i = 0; i < n; i++) {
		scanf("%d", s+i);
	}
	merge_sort(s, 0, n);

	for (i = 0; i < n; i++) {
		printf(fmt, s[i]);
		fmt = " %d";
	}
	printf("\n%d\n", g_num_swap);
	free(s);
	return 0;
}

Measured memory_bytes: 4484
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll a[3];
    ll b=0;
    rep(i,0,2){
        cin>>a[i];
        b=b+a[i];
    }
    if(b>=22){
        cout<<"bust"<<endl;
    }else{
        cout<<"win"<<endl;
    }
    
    return 0;
}




Measured memory_bytes: 256
if __name__ == "__main__":
    num_nodes = int(input())
    P = list(map(lambda x: float(x), input().split()))
    Q = list(map(lambda x: float(x), input().split()))

    Depth = [[0] * (num_nodes + 1) for i in range(num_nodes + 1)]
    Exp = [[0.0] * (num_nodes + 1) for i in range(num_nodes + 1)]
    Cum_prob = [0.0] * (2 * num_nodes + 2)

    for i in range(2 * num_nodes + 1):
        Cum_prob[i + 1] = Cum_prob[i] + (P[i // 2] if i % 2 else Q[i // 2])

    for i in range(num_nodes + 1):
        Exp[i][i] = Q[i]
        Depth[i][i] = i

    for l in range(1, num_nodes + 1):
        for i in range(num_nodes + 1 - l):
            j = i + l
            d0 = Depth[i][j - 1]
            d1 = Depth[i + 1][j]
            d2 = -1
            cost = 1e30
            for k in range(d0, min(d1 + 1, j)):
                v = Exp[i][k] + Exp[k + 1][j]
                if v < cost:
                    d2 = k
                    cost = v
            Depth[i][j] = d2
            Exp[i][j] = cost + Cum_prob[2 * j + 1] - Cum_prob[2 * i]

    print(f"{Exp[0][num_nodes]:.5f}")



Measured memory_bytes: 14464
const str = require('fs').readFileSync('/dev/stdin', 'utf8')
const [W, H, x, y, r] = str.split(/\s/).map(s => parseInt(s, 10))
const inRange = (v, width, max) => (v - width) >= 0 && (v + width) <= max
const res = inRange(x, r, W) && inRange(y, r, H)
console.log(res ? 'Yes' : 'No')


Measured memory_bytes: 15176
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 unsigned long long a;
  long double b;
  cin>>a>>b;
  //
 cout<<(ll)(a*b)<<endl;
}



Measured memory_bytes: 3732
#include <iostream>
using namespace std;
int main(void){
    int H, W;
    while(1){
    cin >> H >> W;
    if(H==0&&W==0){
        break;
    }else{
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout<< "#";
        }
        cout<<endl;
    }
    cout<<endl;
   }
 }
 
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <iostream>

using namespace std;


int main(){
	int n, a, b, ta, tb;

	while (1){
		cin >> n;
		if (n == 0)break;
		ta = tb = 0;

		for (int i = 0; i < n; i++){
			cin >> a >> b;
			if (a == b){
				ta += a;
				tb += b;
			}
			else{
				a>b ? ta += a + b : tb += a + b;
			}
		}

		cout << ta << " " << tb << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
while True:
    n,x=input().split()
    n,x=[int(n),int(x)]
    if n==0 and x==0:
        break
    count=0
    for i in range(1,n-1):
        for j in range(i+1,n):
            for k in range(j+1,n+1):
                sum=i+j+k
                if sum==x:
                    count=count+1
    print(count)


Measured memory_bytes: 5596
#include<cstdio>
using namespace std;
int main(void)
{
	int a[101],i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=n-1;i>=0;i--){
		printf("%d",a[i]);
		if(i!=0){
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}

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

typedef long long  LL;
int n,nxt[200010],k;
LL l,r,ans[26];
char s[200010];

void calc(LL m)
{
	if (m<=n)
		{
			for (int i=1; i<=m; i++)  ans[s[i]-'a']++;
			return;
		}
	LL a0=1,b0=0,c0=0,a1=1,b1=1,c1=1,a2,b2,c2;
	while (a1*k+b1*(n-k)<=m)
		{
			a2=a1+a0,b2=b1+b0,c2=c0;
			a0=a1,b0=b1,c0=c1,a1=a2,b1=b2,c1=c2;
		}
	for (int i=1; i<=k; i++)  ans[s[i]-'a']+=a0;
	for (int i=k+1; i<=n; i++)  ans[s[i]-'a']+=b0;
	calc(m-a0*k-b0*(n-k));
}

void work()
{
	scanf("%s\n%lld %lld",s+1,&l,&r),n=strlen(s+1)/2,l--;
	nxt[1]=0;
	for (int i=2,j=0; i<=n; i++)
		{
			while ((j)&&(s[i]!=s[j+1]))  j=nxt[j];
			if (s[i]==s[j+1])  nxt[i]=++j;  else  nxt[i]=j;
		}
	k=n-nxt[n];
	calc(l);
	for (int i=0; i<26; i++)  ans[i]*=-1;
	calc(r);
	for (int i=0; i<26; i++)  printf("%lld ",ans[i]);
}

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


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

int main() {
    long long N;
    cin >> N;
    long long mx = 10000000000;
    long long mi = 10000000000;

    for(int i = 1; i <= N / i; i++) {
        if(N % i == 0) {
            mx = N / i;
            mi = min( mi , mx);
        }
    }
    cout << to_string(mi).size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
//cout << fixed << setprecision();
//priority_queue<ll, vector<ll>, greater<ll>> q;

class BIT
{
private:
	vl bit;
	ll n;
public:
	BIT(ll k){
		n=k;
		bit.resize(n+10,0);
	}
	void add(ll ind,ll a){
		for(ll i=ind; i<=n ; i+=i&-i){
			bit[i]+=a;
		}
	}
	ll get_sum(ll a){
		ll ret=0;
		for(ll i=a; i>0; i-=(i&-i)){
			ret+=bit[i];
		}
		return ret;
	}
	ll get_sum(ll l,ll r){
		ll ret1=get_sum(l-1);
		ll ret2=get_sum(r);
		return ret2-ret1;
	}
};

signed main(){
	ll n; cin>>n;
	BIT bit(n);
	ll q; cin>>q;
	while(q--){
		ll ty; cin>>ty;
		if(ty==0){
			ll ind,a;
			cin>>ind>>a;
			bit.add(ind,a);
		}
		else{
			ll l,r; cin>>l>>r;
			cout<<bit.get_sum(l,r)<<endl;
		}
	}
	
	
	return 0;
}


Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) {
            S[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int[] T = new int[q];
        for (int i = 0; i < q; i++) {
            T[i] = sc.nextInt();
        }
        int count = 0;
        Arrays.sort(S);
        Arrays.sort(T);
        int idx = 0;
        for (int i = 0; i < q; i++) {
            for (int j = idx; j < n; j++) {
                if (T[i] == S[j]) {
                    idx = j;
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 39684
import java.util.Scanner;

public class Main {

    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);

        String s = scanner.next();


        if (s.charAt(0) != s.charAt(s.length() - 1)) {
            if (s.length() % 2 != 0) {
                System.out.println("First");
            } else {
                System.out.println("Second");
            }
        } else {
            if (s.length() % 2 == 0) {
                System.out.println("First");
            } else {
                System.out.println("Second");
            }
        }

    }
}


Measured memory_bytes: 24916
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
    ll n,m;cin>>n>>m;
    ll ans=min(n,m/2);
    m-=ans*2;
    ans+=m/4;
    cout<<ans<<endl;
    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


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

using namespace std;

int main()
{
    long A,B,K,A1,B1,min,max;
    int ans=0;
    cin >> A >> B;
    min = A > B ? B : A;
    max = A > B ? A : B;
    for(long i = min; i < max; i++)
    {
        A1 = (A - i > 0) ? A - i : i - A;
        B1 = (B - i > 0) ? B - i : i - B;

        if(A1 == B1)
        {
            ans = 1;
            K = i;
            break;
        }
    }

    if (ans > 0){
        cout << K << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import queue
INF = 10000000

#初期化
G = []
kabe = []
H, W = map(int, input().split())

#入力
for i in range(10):
    G.append(list(map(int, input().split())))

for i in range(H):
    kabe.append(list(map(int, input().split())))

lenList = [INF for i in range(10)]

q = queue.PriorityQueue()

def dijkstra():
    global G
    global q
    global lenList
    
    x = q.get()
    #行ったことあるものは捨てる。
    if lenList[x[1]] != INF:
        return
    
    #間違いなく最短なので更新
    lenList[x[1]] = x[0]

    #行ったことないところをプッシュ
    for i in range(10):
        if lenList[i] == INF:
            q.put([x[0] + G[i][x[1]], i])

#初期値を入力して発火
q.put([0, 1])# [距離,現在地]
while not(q.empty()):
    dijkstra()

sum = 0

for i in range(H):
    for j in range(W):
        if kabe[i][j] != -1:
            sum += lenList[kabe[i][j]]

print(sum)

Measured memory_bytes: 4720
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			int m=in.nextInt();
			int field[]=new int[n];
			Arrays.fill(field, -1);
			if((n|m)==0)
				return;
			for(int i=0;i<m;i++)
			{
				String dir=in.next();
				if(dir.equals("s"))
				{
					int id=in.nextInt();
					int w=in.nextInt();
					boolean judge=false;
					for(int j=0;j<n;j++)
					{
						for(int k=j;k<j+w;k++)
						{
							if(k<n&&field[k]==-1)
								judge=true;
							else
							{
								judge=false;
								break;
							}
						}
						if(judge)
						{
							for(int k=j;k<j+w;k++)
								field[k]=id;
							System.out.println(j);
							break;
						}
					}
					if(!judge)
						System.out.println("impossible");
				}
				else
				{
					int away=in.nextInt();
					for(int j=0;j<n;j++)
						if(field[j]==away)
							field[j]=-1;
				}
			}
			System.out.println("END");
		}
	}

	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 20732
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

const int MAX_N = 60;
pair<int, int> XY[MAX_N];
int N;

int edge_count(int dx, int dy) {
    int res = 0;
    for(int i = 0; i < N; ++i) for(int j = i+1; j < N; ++j) 
        if(XY[j].first - XY[i].first == dx && XY[j].second - XY[i].second == dy) ++res;
    return res;
}

int main()
{
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) scanf("%d %d", &XY[i].first, &XY[i].second);
    sort(XY, XY+N);

    int ans = N;
    for(int i = 0; i < N; ++i) for(int j = i+1; j < N; ++j) 
        ans = min(ans, N - edge_count(XY[j].first - XY[i].first, XY[j].second - XY[i].second));
    
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
const gInput = require("fs").readFileSync("/dev/stdin", "utf8")
main(gInput.split(' ').map( s => parseInt(s)))

function main(input){
    var a = input[0]
    var b = input[1]
    var area = a * b
    var length = 2*a+2*b
    console.log(area + ' ' + length)
}


Measured memory_bytes: 15156
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

int a,b;

int main() {
	cin>>a>>b;
	cout<<(a>b?a-1:a)<<endl;

	return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bool ok = false;
  int n = s.size();
  for (int l = 0; l < n; l++) {
    for (int r = 0; r <= n - l; r++) {
      if (s.substr(0, l) + s.substr(l + r, n) == "keyence")
        ok = true;
    }
  }
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let mut stk = Vec::new();
    for b in s.chars().map(|c| c == '1') {
        if !stk.is_empty() && stk.last().unwrap() ^ b {
            stk.pop();
        } else {
            stk.push(b);
        }
    }

    println!("{}", s.len() - stk.len());
}


Measured memory_bytes: 2240
x, y = map(int, input().split())
count = abs(abs(x)-abs(y))

if x * y < 0:
    count += 1
elif x * y == 0 and x > y:
    count += 1
elif x * y > 0:
    if x < 0 and abs(x) < abs(y):
        count += 2
    elif x > 0 and abs(x) > abs(y):
        count += 2

print(count)

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

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

void solve(long long N){
    set<int> se;
    REP(i,1,10){
        REP(j,1,10){
            se.insert(i*j);
        }
    }
    if(se.count(N)) cout<<YES<<endl;
    else cout<<NO<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;


int main() {
	
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	int ans = 100000000;

	for (int i = 0; i < 3; i++) {
		int sub = 0;
		for (int j = 0; j < 3;j++) {
			if (i == j)continue;
			sub += abs(a[j] - a[i]);
		}
		ans = min(ans, sub);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
const int Maxn = 2e5 + 5;
int ct[Maxn];

int main(){
    string ss;
    int cnt;
    cin >> ss;
    memset(ct, 0, sizeof(ct));
    for (int i = 0; i < ss.size(); i++) {
        cnt = ss[i] - 'a' + 1;
        ct[cnt]++;
    }
    for (int i = 1; i <= 26; i++){
        if(ct[i] == 0){
            printf("%c\n", 'a' + i - 1);
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,k;
  cin>>h>>w>>k;
  string c[h];
  int ans=0;
  for(int i=0;i<h;i++)
    cin>>c[i];
  for(int i=0;i<((1<<h)-1);i++)
    for(int j=0;j<((1<<w)-1);j++){
      int blackn=0;
      for(int p=0;p<h;p++)
        for(int l=0;l<w;l++)
          if(((i>>p)&1)==0&&((j>>l)&1)==0&&c[p][l]=='#') blackn++;
      if(blackn==k)
        ans++;
    }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main(){
    string s;
    int big=0,cc=0;
    cin>>s;
    if(s[0]=='A'){
        for(int i=2;i<s.size()-1;i++){
            if(!('a'<=s[i]&&'z'>=s[i])){
                big++;
                if(s[i]=='C')cc++;
            }
        }
        if(!('A'<=s.back()&&s.back()<='Z')&&!('A'<=s[1]&&s[1]<='Z')){
            if(big==1&&cc==1){
                cout<<"AC\n";
                return 0;
            }
        }
    }
    cout<<"WA\n";
}

Measured memory_bytes: 256
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

var sc = newScanner()

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

func main() {
	n := scanInt()
	answer := findMax(n)
	fmt.Println(answer)
}

func debug(a ...interface{}) {
	//fmt.Println(a...)
}

func findMax(n int) int {
	factors := primeFactorize(n)
	if len(factors) == 0 && n != 1 {
		return 1
	}
	debug(factors)
	cnt := 0
	for i := 0; i < len(factors); i++ {
		f := factors[i]
		cnt += counti(f.i)
	}
	return cnt
}

func primeFactorize(n int) []factor {
	factors := []factor{}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			ex := 0
			for n%i == 0 {
				ex++
				n /= i
			}
			factors = append(factors, factor{i, ex})
		}
	}
	if n != 1 {
		factors = append(factors, factor{n, 1})
	}
	return factors
}

type factor struct {
	n int
	i int
}

func counti(n int) int {
	sum := 0
	for i := 1; i <= n; i++ {
		sum += i
		if sum > n {
			debug(n, sum)
			return i - 1
		}
		if sum == n {
			return i
		}
	}
	debug(sum, n)
	return -1
}


Measured memory_bytes: 1764
import math
N,K = list(map(int,input().split(" ")))
nums = (K) * [0]
for i in range(1,N+1):
    nums[i%K] += 1
ans = 0
for a in range(K):
    b = (K-a) % K 
    c = (K-a) % K
    if (2 * K - 2 * a) % K != 0:
        continue
    # print("a,b,c = ",a,b,c)
    # print("nums:",nums)
    ans += nums[a] * nums[b] * nums[c]

print(ans)

Measured memory_bytes: 4596
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[] str = Console.ReadLine().Split();
		int[]A = new int[N];
		var dic = new Dictionary<int,int>();
		bool flag1 = true;
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str[i]);
			if(flag1){
			var list = PrimeFactors(A[i]);
			foreach(var j in list){
				if(dic.ContainsKey(j)){
					dic[j]++;
					if(dic[j]>=2){
						flag1 = false;
						break;
					}
				} else {
					dic[j] = 1;
				}
			}
            }
		}
		bool flag = true;
		foreach(var i in dic.Keys){
			if(dic[i]>=2){
				flag = false;
			}
		}
		if(flag){
			Console.WriteLine("pairwise coprime");
		} else {
			int d = A[0];
			for(var i=1;i<N;i++){
				d = Gcd(d,A[i]);
			}
			if(d==1){
				Console.WriteLine("setwise coprime");
			} else {
				Console.WriteLine("not coprime");
			}
		}
	}
	public static int Gcd(int a, int b) {
		if (a < b)
			return Gcd(b, a);
		while (b != 0) {
			var r = a % b;
			a = b;
			b = r;
		}
		return a;
	}
	public static HashSet<int> PrimeFactors(int n){
		int i = 2;
		int tmp = n;
		var list = new HashSet<int>();
		while(i*i<=n){
			if(tmp%i==0){
				tmp /= i;
				list.Add(i);
			} else {
				i++;
			}
		}
		if(tmp != 1){
			list.Add(tmp);
		}
		return list;
	}
}

Measured memory_bytes: 92676
S = input()

from collections import deque

q = deque()
if len(S) > 5: #4文字以下ならそもそもバツ→入れない
  q.append((len(S), S))
#ここに、次にチェックする文字列を入れていく
#今回はque(fi-fo)として使うので、popleftを使う

flag = False
while(q):
  nowlen, nows = q.popleft()
  nows5 = nows[0:5]
  nowsfrom5 = nows[5:]
  if nows5 == 'dream':
    if nowlen == 5:
      flag = True
      break
    else:
      if nowlen>=10: q.append((nowlen-5, nowsfrom5))
    if nows[0:7] == 'dreamer':
      if nowlen == 7:
        flag = True
        break
      else:
        if nowlen>=12: q.append((nowlen-7, nows[7:]))
  elif nows5 == 'erase':
    if nowlen == 5:
        flag = True
        break
    else:
      if nowlen>=10: q.append((nowlen-5, nowsfrom5))
    if nows[0:6] == 'eraser':
      if nowlen == 6:
        flag = True
        break
      else: 
        if nowlen>=11: q.append((nowlen-6, nows[6:]))

print('YES' if flag else 'NO')


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

struct Segment {
	int from, to, value;
};

bool processQuery(vector<Segment> &v, int plen, int len, int alph) {
	if (len > plen) {
		v.push_back({plen + 1, len, 1});
		return true;
	}
	while (!v.empty()) {
		int from = v.back().from, to = v.back().to, value = v.back().value;
		v.pop_back();
		if (from > len || value == alph) {
			continue;
		}
		to = min(to, len);
		if (from < to) {
			v.push_back({from, to - 1, value});
		}
		v.push_back({to, to, value + 1});
		if (to < len) {
			v.push_back({to + 1, len, 1});
		}
		return true;
	}
	return false;
}

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &x: a) {
		cin >> x;
	}

	int l = 1, r = n - 1, ans = n;
	while (l <= r) {
		int mid = (l + r) >> 1;
		vector<Segment> v;
		v.push_back({1, a[0], 1});
		bool can = true;
		for (int i = 1; i < n; i++) {
			if (!processQuery(v, a[i - 1], a[i], mid)) {
				can = false;
				break;
			}
		}
		if (!can) {
			l = mid + 1;
		} else {
			ans = mid;
			r = mid - 1;
		}
	}
	cout << ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	solve();
}


Measured memory_bytes: 6512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

#define add push_back
#define inf 2147000000

#define rep(i,n) for(int i=0;i<n;i++)
#define out(a) cout<<a<<endl;

using namespace std;

int main(void){
	int w,h;
	int y1[30],y2[30],t[31];
	string str;
	scanf("%d%d",&w,&h);
	rep(i,h){
		cin>>str;
		int m;
		rep(j,4)if(str[j]==','){m=j;break;}
		
		switch(m){
			case 1:
				y1[i]=str[0]-48;
				break;
			case 2:
				y1[i]= (str[0]-48)*10;
				y1[i]+=str[1]-48;
				break;
		}
		if(str[m+2]!='\0'){
			y2[i] = (str[m+1]-48) * 10;
			y2[i] += str[m+2]-48;
		}else{
			
			y2[i] = str[m+1]-48;
		}
	}
	rep(i,31)t[i]=i;
	
	rep(i,h){
		swap(t[y1[i]],t[y2[i]]);
	}
	
	rep(i,w)out(t[i+1]);
}

Measured memory_bytes: 0
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int N; cin >> N;
    int XOR = 0;
    vector<int> v[40];
    rep(i,0,N) {
        int p; cin >> p;
        XOR ^= p;
        int LSB = p & (-p);
        int put = 0;
        while(LSB != 1) put++, LSB >>= 1;
        v[put].push_back(p);
    }

    int cnt = 0;
    repr(i,35,0) {
        if(XOR >> i & 1) {
            if(v[i].size() == 0) {
                cout << -1 << endl;
                return 0;
            }
            else {
                int p = v[i][0];
                XOR = XOR ^ p ^ (p-1);
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1408
S = input()
for i in range(16):
    c0 = 'A' * (i&1)
    c1 = 'A' * ((i>>1)&1)
    c2 = 'A' * ((i>>2)&1)
    c3 = 'A' * ((i>>3)&1)
    s = c0 + 'KIH' + c1 + 'B' + c2 + 'R' + c3
    if S == s:
        print('YES')
        break
else:
    print('NO')


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1,0,1,0 }; const int dy[] = { 0,1,0,-1 };

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> rooms(H);
	int sy, sx;
	REP(i, H) {
		cin >> rooms[i];
		auto idx = rooms[i].find("S");
		if (idx != string::npos) {
			sy = i;
			sx = idx;
		}
	}
	
	queue<pair<int,pii>> Q;
	Q.push({ 0,{sy,sx} });
	set<pii> S;
	S.insert({ sy, sx });
	while (!Q.empty()) {
		pair<int, pii> q;
		q = Q.front(); Q.pop();
		if (q.first == K)
			break;
		REP(i, 4) {
			int ny = q.second.first + dy[i];
			int nx = q.second.second + dx[i];
			if (WRAP(ny, nx, H, W)) {
				if (rooms[ny][nx] != '#'&&S.find({ny,nx}) == S.end()) {
					S.insert({ ny,nx });
					Q.push({ q.first+1,{ny,nx} });
				}
			}
		}
	}
	int ans = 1e9;
	for (auto x : S) {
		ans = min(ans, (min(min(abs(x.first-0),abs(x.first-H+1)), min(abs(x.second - 0), abs(x.second - W + 1)))+(K-1))/K+1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 30976
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





const int N = 7 ; 
char g[N+1][N+1];
void solve(){
	int h , w , K ;
	cin >> h >> w >> K; 
	rep(i,0,h) rep(j,0,w) cin >> g[i][j];
	int H = 1<<h; 
	int W = 1<<w;
	int ans = 0 ;
	for(int i = 0 ; i < H  ; i++){
		for(int j = 0 ; j < W ; j++){
			int b = 0 ;
			for(int k = 0 ; k < h ; k++){
				for(int l = 0 ; l < w ; l++){
					if(((i>>k)&1) == 0 and  ((j>>l)&1) == 0 and g[k][l] == '#') b++;
				}
			}
			if(b==K) ans++;
		}
	}
	cout << ans << endl;
}


signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
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; }
ll rec(ll n){
    ll ans = 0;
    n /= 2;
    while(n/5 != 0){
        ans += n/5;
        n /= 5;
    }
    return ans;
}
int main(){
    cout << fixed << setprecision(10);
    ll n;
    cin >> n;
    if(n%2 == 0)cout << rec(n) << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s;cin>>s;
	if(s[0]>s[1])swap(s[0],s[1]);
	if(s=="abc"||s=="acb"||s=="bca")cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

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

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

  int n;
  string s, t;

  cin >> n >> s >> t;
  for (int i = 0; i < n; i++)
    cout << s[i] << t[i];
  cout << endl;
}

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

using namespace std;

vector<string> split(const string &str, char delim = ' ') {
  stringstream ss(str);
  vector<string> res;
  for (string tmp; getline(ss, tmp, delim);) res.push_back(tmp);
  return res;
}

template<typename T = long long> inline T toInteger(const string&);

template<> inline int toInteger<int>(const string& s) {
  return stoi(s);
}

template<> inline long toInteger<long>(const string& s) {
  return stol(s);
}

template<> inline long long toInteger<long long>(const string& s) {
  return stoll(s);
}

template<typename T = long long> inline T toInteger(const string& s, int n) {
  T res = 0;
  for (char c : s) {
    if (isdigit(c)) res = res * n + c - '0';
    else if (isalpha(c)) res = res * n + tolower(c) - 'a' + 10;
  }
  return s[0] == '-' ? -res : res;
}

int main() {
  string line;
  while (cin >> line) {
    auto d = split(line, ',');
    vector<int> l(10), v(2), s(10);
    for (int i = 0; i < 10; ++i) l[i] = toInteger<int>(d[i]);
    for (int i = 0; i < 2; ++i) v[i] = toInteger<int>(d[i + 10]);
    partial_sum(l.begin(), l.end(), s.begin());
    for (int i = 0; i < 10; ++i) {
      if (s[i] * v[1] >= (s.back() - s[i]) * v[0]) {
        cout << i + 1 << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3176
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, C;
  cin >> n >> C;
  int d[50][50] = {};
  rep(i, C) rep(j, C) cin >> d[i][j];
  int c[500][500] = {};
  int t[3][30] = {};
  rep(i, n) rep(j, n) {
    int x;
    cin >> x;
    t[(i + j) % 3][x - 1]++;
  }
  int ans = INF;
  rep(i, C) {
    rep(j, C) {
      if (i != j) {
        rep(k, C) {
          if (i != k && j != k) {
            int tmp = 0;
            rep(l, C) tmp += d[l][i] * t[0][l];
            rep(l, C) tmp += d[l][j] * t[1][l];
            rep(l, C) tmp += d[l][k] * t[2][l];
            cmin(ans, tmp);
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 768
N = int(input())
A = map(int, input().split())

counter = N - 1
current = 1

for a in A:
    # print(f"a={a} counter={counter}, current={current}")
    if a == current:
        current += 1
    else:
        counter -= 1
    if counter < 0:
        print(-1)
        break
else:
    print(N - counter -1)


Measured memory_bytes: 17980
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int sum=0;
  for(int i=1;i<N+1;i++){
    int count=0;
    for(int j=1;j<N+1;j++){
      if(i%2==1&&i%j==0){
        count++;
      }
      else{
      }
    }
    if(count==8){
      sum++;
    }
    else{
    }
  }
  cout<<sum<<endl;
}

      


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

/* 配列使用 */
int main(){
  int N;
  cin >> N;

  vector<int> mochi(N + 1, -1);
  int size;
  int j;
  int cnt = 0;
  for(int i = 0; i < N; i++){
    cin >> size;
    // 挿入する位置:j 
    j = cnt;
    while(j > 0 && size > mochi[j - 1]){
      j--;
    }
    // 等しい値でなければ
    if(j == 0 || size != mochi[j - 1]){
      int i;
      // 後ろから挿入位置まで１つ後ろに移動
      for(i = cnt; i >= j; i--){
        mochi[i] = mochi[i - 1];
      }
      // 挿入位置に挿入
      mochi[j] = size;
      cnt++;
    }
    /*
    for(int i = 0; i < cnt; i++)
      cout << mochi[i] << ",";
    cout << endl;
    */
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256