akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

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

    size_t N; cin >> N;
    vector<size_t> s(N);
    for (auto &si: s) cin >> si;

    size_t res = 0;
    size_t Q; cin >> Q;
    while (Q--) {
        size_t t; cin >> t;
        if (binary_search(s.begin(), s.end(), t)) {
            res++;
        }
    }

    cout << res << "\n";

    return 0;
}



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

struct RURM {
	using t1 = int;
	using t2 = int;
	static t1 id1() { return INT_MAX; }
	static t2 id2() { return -1; }
	static t1 op1(const t1& l, const t1& r) { return min(l, r); }
	static t1 op2(const t1& l, const t2& r) { return r != -1 ? r : l; }
	static t2 op3(const t2& l, const t2& r) { return r != -1 ? r : l; }
};

template <typename M>
class LazySegmentTree {
	using T1 = typename M::t1;
	using T2 = typename M::t2;
	const int n;
	vector<T1> data;
	vector<T2> lazy;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	void push(int node) {
		if (lazy[node] == M::id2()) return;
		if (node < n) {
			lazy[node * 2] = M::op3(lazy[node * 2], lazy[node]);
			lazy[node * 2 + 1] = M::op3(lazy[node * 2 + 1], lazy[node]);
		}
		data[node] = M::op2(data[node], lazy[node]);
		lazy[node] = M::id2();
	}
	T1 suc(int l, int r, int node, int lb, int ub, T2 val) {
		if (ub <= l || r <= lb) return M::op2(data[node], lazy[node]);
		if (l <= lb && ub <= r) return M::op2(data[node], lazy[node] = M::op3(lazy[node], val));
		push(node);
		int c = (lb + ub) / 2;
		data[node] = M::op1(suc(l, r, node * 2, lb, c, val), suc(l, r, node * 2 + 1, c, ub, val));
		return M::op2(data[node], lazy[node]);
	}
	T1 sub(int l, int r, int node, int lb, int ub) {
		if (ub <= l || r <= lb) return M::id1();
		if (l <= lb && ub <= r) return M::op2(data[node], lazy[node]);
		int c = (lb + ub) / 2;
		return M::op2(M::op1(sub(l, r, node * 2, lb, c), sub(l, r, node * 2 + 1, c, ub)), lazy[node]);
	}
public:
	LazySegmentTree(int n_) : n(size(n_)), data(n * 2, M::id1()), lazy(n * 2, M::id2()) {}
	LazySegmentTree(int n_, T1 v1, T2 v2) : n(size(n_)), data(n * 2, v1), lazy(n * 2, v2) {}
	LazySegmentTree(const vector<T1>& data_)
		: n(size(data_.size())), data(n * 2, M::id1()), lazy(n * 2, M::id2()) {
		init(data_);
	}
	void init() {
		for (int i = n - 1; i >= 1; i--) data[i] = M::op1(data[i * 2], data[i * 2 + 1]);
	}
	void init(const vector<T1>& data_) {
		for (int i = 0; i < (int)data_.size(); i++) data[i + n] = data_[i];
		init();
	}
	void update(int l, int r, T2 val) {
		suc(l, r + 1, 1, 0, n, val);
	}
	T1 find(int l, int r) {
		return sub(l, r + 1, 1, 0, n);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, com, x, y, val;
	cin >> n >> q;
	LazySegmentTree<RURM> st(n);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.find(x, y));
		}
		else {
			cin >> val;
			st.update(x, y, val);
		}
	}
	return 0;
}



Measured memory_bytes: 4896
/*~~~~~~~~~~~~~~~~~~~~~~
  Code by gkothyari 
~~~~~~~~~~~~~~~~~~~~~~~*/    
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

#define rep(i,n) 			  for(int i=0;i<(n);i++)
#define FOR(i,a,b) 			  for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) 		  for(int i=(a);i>=(b);i--)
#define DEBUG(x) 			  cout << '>' << #x << ':' << x << endl;
#define foreach(it, c)        for( typeof( (c).begin()) it = (c).begin();  it != (c).end(); ++it)
#define endl 				  "\n"
#define pb                    push_back
#define eb                    emplace_back
#define ll					  long long
#define ld					  long double
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MAX                   1e9
#define MIN                   -1e9
#define vi                    vector<int>
#define vvi                   vector<vi>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(v)                v.begin(),v.end()
#define max(x,y)              (x>y)?x:y
#define min(x,y)              (x<y)?x:y
#define mid(s,e)              (s+(e-s)/2)
#define mini                  INT_MIN
#define sqr(x) 				  ((x)*(x))
#define ones(x) 			  __builtin_popcount(x)
#define onesll(x) 			  __builtin_popcountll(x)
#define PI                    acos(-1.0)
typedef vector<pii> vpii;
const int INF = 0x3f3f3f3f, MOD = 1e9 + 7;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}

int main()
{
	cout<<fixed<<setprecision(15);
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base:: sync_with_stdio(false); cin.tie(0);
	    
	ll a,b,i,temp,t;
	cin>>a>>b;
	temp = max(a,b);
	t=min(a,b);
	for(i=t;i<=temp;i++){
		if(abs(a-i)==abs(b-i)){
			cout<<i<<endl;
			break;
		}
	}
	if(i==temp+1){
		cout<<"IMPOSSIBLE"<<endl;
	}

	return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

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

    int n, sum = 0;
    cin >> n;
    for(int i = 1; i <= n; ++i) sum += i;
    cout << sum << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll k;
  cin >> k;

  ll n = 50;
  vll a(n, n - 1 + k / n);

  for (ll i = 0; i < k % n; i++) {
    a[i] += n;
    for (ll j = 0; j < n; j++) {
      if (i != j) a[j]--;
    }
  }

  cout << n << endl;
  for (ll i = 0; i < n - 1; i++) cout << a[i] << " ";
  cout << a[n - 1] << endl;
}

Measured memory_bytes: 256
from itertools import zip_longest

s = input()
n = len(s)-1

total = 0
li = [0] * 2**n

for i in range(2**n):
  op = [""] * n
  for j in range(n):
    if (i >> j) & 1:
      op[j] = "+"
  li[i] = op
  
for i in li:
  siki = ""
  for j, k in zip_longest(i, s, fillvalue=""):
    siki += k+j
  total += eval(siki)
  
print(total)

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int i=0; i<n; i++)
#define FOR1(i, n) for(int i=1; i<=n; i++)
#define FORI(i, n) for(int i=n-1; i>=0; i--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, x); }
template<class T, class U> void init(vector<T> &v, U x, size_t n, size_t m...) { v=vector<T>(n); for(auto& a : v) init(a, x, m);}

struct node{
    int ch[26];
    bool isend;
    node(){
        memset(ch, 0, 26*sizeof(int));
        isend = 0;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int T = 1;
//    cin >> T;
    vector<node> nodes(1e6+7);
    vector<vector<int>> where;
    int pos = 0;
    FOR1(tt, T){
        int n;
        cin >> n;
        vector<string> ss(n);
        where.resize(n+1);
        FOR(i, n) {
            cin >> ss[i];
            reverse(ss[i].begin(), ss[i].end());

            int now = 0;
            FOR(j, ss[i].length()){
                int pc = ss[i][j] - 'a';
                if (nodes[now].ch[pc] == 0)
                    nodes[now].ch[pc] = ++pos;
                now = nodes[now].ch[pc];
                where[i].push_back(now);
            }
            nodes[now].isend = 1;
        }

        ll sol = 0;
        FOR(i, n){
            set<int> S;
            FORI(j, ss[i].length()){
                int pos = where[i][j];
                for(int pc : S) {
                    int chi = nodes[pos].ch[pc];
                    if ((chi > 0 && nodes[chi].isend)) {
//                        cout << i << " " << j << " " << (char)(pc+'a') << endl;
                        sol++;
                    }
                }
                S.insert(ss[i][j]-'a');
            }
            pos = 0;
            for(int pc : S) {
                int chi = nodes[pos].ch[pc];
                if ((chi > 0 && nodes[chi].isend)) {
//                    cout << i << " " << j << " " << (char)(pc+'a') << endl;
                    sol++;
                }
            }
        }
        cout << sol-n << endl;
    }




    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}



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

int mem[21][11][156];
int n, k, s;

int dfs(int sum,int set_number,int pre_select_number){
  int ret = 0, i;
  if(mem[pre_select_number][set_number][sum] != -1){
    return mem[pre_select_number][set_number][sum];
  }
  if(set_number == k){
    if(sum == s){
      return 1;
    }else{
      return 0;
    }
  }
  for(i = pre_select_number + 1;i <= n;i++){
    ret += dfs(sum + i,set_number + 1,i);
  }
  return mem[pre_select_number][set_number][sum] = ret;
}


int main(void){
  while(1){
    scanf("%d%d%d",&n,&k,&s);
    if(n == 0 && k == 0 && s == 0){
      break;
    }
    memset(mem,-1,sizeof(mem));
    printf("%d\n",dfs(0,0,0));
  }
  return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

ll A[MAXN];
ll B[MAXN];
int ord[MAXN];
ll dp[MAXN][35];

bool cmp(int i,int j)
{
    if(((A[i]-1)*B[j])==((A[j]-1)*B[i]))return B[i]<B[j];
    return (A[i]-1)*B[j]>(A[j]-1)*B[i];
}

int main()
{
    ll n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

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

    cin>>n>>k;

    ++k;

    for(int i=1;i<=n;i++){
        cin>>A[i]>>B[i];
        ++A[i];
        ++B[i];
        ord[i] = i;
    }

    sort(ord+1,ord+n+1,cmp);

    dp[0][0] = 1;

    for(int i=1;i<=30;i++)
        dp[0][i] = k+2;

    for(int i=1;i<=n;i++){
        cur = ord[i];
        if(A[cur]==1){
            idx = i;
            break;
        }
        dp[i][0] = 1;
        for(int j=1;j<=30;j++){
            dp[i][j] = A[cur]*dp[i-1][j-1]+B[cur];
            dp[i][j] = min(dp[i][j],k+2);
            dp[i][j] = min(dp[i][j],dp[i-1][j]);
        }
    }

    int res = 0;

    ll vv = 0;

    if(idx==-1){
        for(int i=0;i<=30;i++){
            if(dp[n][i]<=k)res = i;
        }
    }
    else {
        for(int j=0;j<=30;j++){
            vv = dp[idx-1][j];
            if(vv<=k){
                res = max(res,j);
            }
            else break;

            for(int i=idx;i<=n;i++){
                cur = ord[i];
                vv+=B[cur];
                if(vv<=k){
                    res = max(res,j+i-idx+1);
                }
                else break;
            }
        }
    }

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 58880
#include <bits/stdc++.h>
#define ll long long int
#define fio ios_base::sync_with_stdio(0);cin.tie(0)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define slld(t) scanf("%lld",&t)
#define plld(t) printf("%lld\n",t)
#define sc(t) scanf("%c",&t)
#define pb(x) push_back(x)
#define ii pair<int,int>
#define vi vector<int>
#define vvi vector<vi >
#define vii vector<ii >
#define vvii vector<vii >
#define clr(x) memset(x,0,sizeof(x))
#define rep(i,begin,end) for(__typeof(end) i=begin-(begin>end);i!=end-(begin>end);i+=1-2*(begin>end))
#define M_PI 3.14159265358979323846
#define MOD 1000000007
#define MAX 100005
#define EPS 1e-12
using namespace std;

int main()
{
	int curr=0, maxx=0;
	string s;
	int n;
	cin>>n>>s;

	for(auto it:s)
	{
		if(it=='I') curr++;
		else curr--;
		maxx = max(maxx, curr);
	}
	pd(maxx);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  map<int, int> M;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    M[A]++;
  }
  int ans = 0;
  for (auto m : M) {
    if (m.second % 2 == 1) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

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

  int n;cin >> n;
  int res=0;
  while(n>3){
    res++;
    if(n%3==0) n/=3;
    else n=n/3+1;
  }
   
  cout << res+1 << endl;
}

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

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

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX_V 1000

signed main(){
	int n;
	ll W;
	cin >> n >> W;
	ll w[n];
	int v[n];
	REP(i,n){
		cin >> w[i] >> v[i];
	}
	vector<vector<ll>> dp(n + 1, vector<ll>(MAX_V * (n + 1) + 1, LINF));
	dp[0][0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= MAX_V * n; j++){
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			if(j - v[i] < 0) continue;
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
		}
	}
	int ans = 0;
	for(int i = MAX_V * n; i >= 0; i--){
		if(dp[n][i] <= W){
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
        int N;
        string S;
        cin >> N;
        cin >> S;
        string word("ABC");
        int count = 0;
        string::size_type pos = S.find(word);
        while (pos != string::npos) {
                count++;
                pos = S.find("ABC", pos+word.length());
        }
        cout << count << endl;








}


Measured memory_bytes: 256
//g++  7.4.0

#include <bits/stdc++.h>
using namespace std;

long long  knapSack(long long W, long long  wt[], long long val[], long long n)
{
    long long i, w;
    long long K[n + 1][W + 1];

    // Build table K[][] in bottom up manner
    for (i = 0; i <= n; i++)
    {
        for (w = 0; w <= W; w++)
        {
            if (i == 0 || w == 0)
                K[i][w] = 0;
            else if (wt[i - 1] <= w)
                K[i][w] = max(
                    val[i - 1] + K[i - 1][w - wt[i - 1]],
                    K[i - 1][w]);
            else
                K[i][w] = K[i - 1][w];
        }
    }

    return K[n][W];
}


int main()
{
    long long n, w;
    cin >> n >> w;
    long long a[n][2];
    for(int i=0;i<n;i++)
        for(int j=0;j<2;j++)
            cin >> a[i][j];
    
   long long wt[n], val[n];
   
   for(int i=0;i<n;i++)
   {
       wt[i] = a[i][0];
       val[i] = a[i][1];
   }
    
    cout << knapSack(w, wt, val, n);     
}

Measured memory_bytes: 82408
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;

int H,W,D;
struct Numbers{
    int x;
    int y;
};
Numbers numberpos[90001];
int cost[301][301]={};

void numberinput(void){
    cin>>H>>W>>D;
    int memo;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            scanf("%d",&memo);
            numberpos[memo].x=i;
            numberpos[memo].y=j;
        }
    }
}



void solve(void){
    int rui[90001]={};
    for(int i=D+1;i<=H*W;i++){
        Numbers &prevnumpos=numberpos[i-D];
        Numbers &currnumpos=numberpos[i];
        int addcost=0;
        if(prevnumpos.x>currnumpos.x){
            addcost+=prevnumpos.x-currnumpos.x;
        }else{
            addcost+=currnumpos.x-prevnumpos.x;
        }
        if(prevnumpos.y>currnumpos.y){
            addcost+=prevnumpos.y-currnumpos.y;
        }else{
            addcost+=currnumpos.y-prevnumpos.y;
        }
        rui[i]=rui[i-D]+addcost;
    }
    int Q;
    int l,r;
    cin>>Q;

    for(int i=0;i<Q;i++){
        scanf("%d%d",&l,&r);
        printf("%d\n",rui[r]-rui[l]);
    }

}

int main(void){
    numberinput();
    solve();
	
    return 0;
}


Measured memory_bytes: 2176
data=[list(input().split()) for _ in range(9)]
n=0
while n<9:
    s=data[n][0]
    t=int(data[n][1])
    u=int(data[n][2])
    v=t+u
    w=t*200+u*300
    print(f"{s} {v} {w}")
    n+=1


Measured memory_bytes: 5608
#include <iostream>
int main()
{
    int n,m;
    std::cin >> n >> m;
    int path[51]={0};
    for(int i=0;i<m;i++)
    {
        int a,b;
        std::cin>>a>>b;
        path[a]++;
        path[b]++;
    }
    
    for(int i=1;i<=n;i++)
    {
        std::cout<<path[i]<<std::endl;
    } 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <iomainp>
*/
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

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

using namespace std;

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

  int N;
  cin >> N;
  vector<int> x(N+1), y(N+1);
  REP(i, N){
    cin >> x[i];
    cin >> y[i];
  }
  x[N] = x[0];
  y[N] = y[0];
  double long tmp = 0;
  REP(i, N){
    REP(j, N){
 
      if (i == j){;}
      else{
      int x_diff = x[i] - x[j];
      ll x_val = x_diff * x_diff;
      int y_diff = y[i] - y[j];
      ll y_val = y_diff * y_diff;
      long double val = sqrt(x_val + y_val);
    tmp += val;
  }}}

  long double ans = tmp/N ;
  cout << fixed << setprecision(10) << ans << "\n";

  return 0;
}



Measured memory_bytes: 256
def main():
    n = int(input())
    a = [list(map(lambda x : int(x)-1, input().split())) for _ in range(n)]
    for i in range(n):
        a[i].reverse()
    # print(a)
    s = set()

    def check(i, s):
        if len(a[i]) == 0:
            return
        j = a[i][-1]
        if len(a[j]) == 0:
            return
        if a[j][-1] == i:
            if i < j:
                s.add((i, j))
            else:
                s.add((j, i))
    
    for i in range(n):
        check(i, s)
    day = 0
    while s:
        day += 1
        prevS = set()
        s, prevS = prevS, s
        for p in prevS:
            i = p[0]
            j = p[1]
            a[i].pop()
            a[j].pop()
        for p in prevS:
            i = p[0]
            j = p[1]
            check(i, s)
            check(j, s)
    
    for i in range(n):
        if len(a[i]):
            print(-1)
            return
    print(day)
    return

main()


Measured memory_bytes: 35060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    ll n;
    cin >> n;
    int ans = INF;
    for(ll i = 1; i * i <= n; ++i){
        if(n % i != 0)  continue;
        string s = to_string(i), t = to_string(n / i);
        chmin(ans, (int)max(s.length(), t.length()));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int A,B,M;cin>>A>>B>>M;
    vector<int> a(A),b(B);
    rep(i,A) cin>>a[i];
    rep(i,B) cin>>b[i];
    int ans=(*min_element(ALL(a)))+(*min_element(ALL(b)));
    rep(i,M){
        int x,y,c;cin>>x>>y>>c;x--,y--;
        chmin(ans,a[x]+b[y]-c);
    }
    cout<<ans<<endl;
    return 0;
}

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

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

int MOD = 1e9 + 7;
ll INF = 1e18;

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

int main(){
    double a, b; cin>>a>>b;
    cout << fixed << setprecision(10) << acos(-1)*4/3*b*b*b << endl;
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define MOD ((long long) (1000*1000*1000 + 7))
#define inf (int) 2e15
#define exit(a, b) return cout << a, b;
#define eps (double)1e-8
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end()
#define ll long long 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

const int MODULO = MOD;
int n;
bool vis[3][1001][4];
int dp[3][1001][4];
bool blocked[3][1001];

int rec (int row, int col, int type) {
	if (vis[row][col][type]) return dp[row][col][type];
	vis[row][col][type] = true;
	if (blocked[row][col]) {
		dp[row][col][type] = 0;
		return 0;
	}
	if (type == 0) {
		if (row >= 1) {
			if (col >= n - 1 && row != 2) {
				dp[row][col][type] = 0;
				return 0;
			}
			dp[row][col][type] += rec(row - 1, col, 2);
			dp[row][col][type] %= MODULO;
		}
	} 
	if (type == 1) {
		if (row <= 1) {
			if (col >= n - 1) {
				dp[row][col][type] = 0;
				return 0;
			}
			dp[row][col][type] += rec(row + 1, col, 3);
			dp[row][col][type] %= MODULO;
		}
	}
	if (type == 2) {
		if (col == 0 && row == 0) {
			dp[row][col][type] = 1;
			return dp[row][col][type];
		}
		if (col >= 1 && row < 2) {
			dp[row][col][type] += rec(row, col - 1, 0);
			dp[row][col][type] %= MODULO;
			dp[row][col][type] += rec(row, col - 1, 1);
			dp[row][col][type] %= MODULO;
		}
	}
	if (type == 3) {
		if (col >= 1 && row >= 1) {
			dp[row][col][type] += rec(row, col - 1, 0);
			dp[row][col][type] %= MODULO;
			dp[row][col][type] += rec(row, col - 1, 1);
			dp[row][col][type] %= MODULO;
		}
		else {
			dp[row][col][type] = 0;
			return dp[row][col][type];
		}
	}
}
signed main () {
	start_routine;
	
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#endif 

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

	int c = b - a;	
	int s = 0;
	for (int i = 1; i <= c; i += 1)
		s += i;

	cout << s - b;
	end_routine;
}


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

template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }

typedef vector<vector<int>> graph;

constexpr int MAX_N = 900;

enum {ESCAPE, LOOP, CATCH};
enum {Q, A, NUM};

const string message[3] = {
	"Queen can escape.",
	"Queen can not escape and Army can not catch Queen.",
	"Army can catch Queen.",
};

int dp[MAX_N][MAX_N][NUM];

inline int get_index(int x, int y, int w) {
	return x + y * w;
}

inline void add_edge(int a, int b, graph &G) {
	G[a].emplace_back(b);
	G[b].emplace_back(a);
}

inline string solve(int q, int a, const vector<int> &g, const graph &G) {
	const int n = G.size();
	for(int v = 0; v < n; ++v) {
		for(int u = 0; u < n; ++u) {
			dp[v][u][Q] = dp[v][u][A] = LOOP;
		}
	}

	for(int v = 0; v < n; ++v) {
		dp[v][v][Q] = dp[v][v][A] = CATCH;
	}

	for(const auto &e : g) {
		for(int v = 0; v < n; ++v) {
			if(e != v) dp[e][v][Q] = ESCAPE;
		}
	}

	while(true) {
		bool update = false;

		for(int v = 0; v < n; ++v) {
			for(int u = 0; u < n; ++u) {
				if(v == u) continue;

				// queen turn
				if(dp[v][u][Q] != ESCAPE) {
					const int prev = dp[v][u][Q];
					dp[v][u][Q] = CATCH;
					for(const auto &to : G[v]) {
						chmin(dp[v][u][Q], dp[to][u][A]);
					}
					if(dp[v][u][Q] != prev) update = true;
				}

				// army turn
				{
					const int prev = dp[v][u][A];
					dp[v][u][A] = ESCAPE;
					for(const auto &to : G[u]) {
						chmax(dp[v][u][A], dp[v][to][Q]);
					}
					if(dp[v][u][A] != prev) update = true;
				}
			}
		}

		if(!update) break;
	}

	return message[dp[q][a][Q]];
}

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

	for(int w, h; cin >> w >> h && w;) {
		vector<string> field(h);
		for(auto &e : field) cin >> e;

		const int n = w * h;
		int q, a;
		vector<int> g;

		graph G(n);

		for(int i = 0; i < h; ++i) {
			for(int j = 0; j < w; ++j) {
				if(field[i][j] == '#') continue;

				const int v = get_index(j, i, w);

				switch(field[i][j]) {
				case 'Q': q = v; break;
				case 'A': a = v; break;
				case 'E': g.emplace_back(v); break;
				}

				add_edge(v, v, G);

				if(i < h - 1) {
					if(field[i + 1][j] != '#') {
						add_edge(v, get_index(j, i + 1, w), G);
					}
				}

				if(j < w - 1) {
					if(field[i][j + 1] != '#') {
						add_edge(v, get_index(j + 1, i, w), G);
					}
				}
			}
		}

		cout << solve(q, a, g, G) << endl;
	}

	return EXIT_SUCCESS;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N; cin >> N;
  int a[2][111];
  rep(k, 2) rep(i, N) cin >> a[k][i];

  queue<tuple<int, int, int>> q;
  q.emplace(0, 0, 0);
  int max = 0;
  while(!q.empty()) {
    int ans, y, x; tie(ans, y, x) = q.front(); q.pop();
    ans += a[y][x];
    if (y == 1 && x == N - 1) {
      max = std::max(ans, max);
      continue;
    }
    if (y == 0) {
      q.emplace(ans, 1, x);
    }
    if (x < N - 1) {
      q.emplace(ans, y, x + 1);
    }
  }

  cout << max << endl;
  
  return 0;
}

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

using namespace std;

struct UnionFind {
private:
	vector<int> uf;
	size_t sz;

public:
	UnionFind(size_t Size) {
		uf.assign(Size, -1);
		sz = Size;
	}

	int find(int x) { return (uf[x] < 0) ? x : uf[x] = find(uf[x]); }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -uf[find(x)]; }
	int size() { return sz; }

	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) { return; }
		--sz;

		if (uf[y] < uf[x]) { swap(x, y); }
		uf[x] += uf[y];
		uf[y] = x;
	}
};

int main() {
	int N, M;
	cin >> N >> M;
	UnionFind uf(N);
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		uf.unite(a, b);
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		ans = max(ans, uf.size(i));
	}
	cout << ans << "\n";

	return 0;
}


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

typedef long long ll;

int N, K;
ll mod = 1000000007;
vector<int> V;
ll dp[2][200010];
ll tmp[2][200010];

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


    for(int i = 1; i * i <= N; i++)
    {
        V.push_back(i);
        V.push_back(N / i);
    }

    sort(V.begin(), V.end());
    V.erase(unique(V.begin(), V.end()), V.end());

    dp[1][0] = 1;
    for(int i = 0; i < 200010; i++)tmp[1][i] = 1;
    for(int i = 0; i < K; i++)
    {
        for(int j = 0; j < V.size(); j++)
        {
            dp[i % 2][j] = tmp[1 - i % 2][(int)(V.size()) - 1 - j] *
                           (V[j] - (j - 1 >= 0 ? V[j - 1] : 0)) % mod;
            if(j == 0)tmp[i % 2][j] = dp[i % 2][j];
            else tmp[i % 2][j] = (tmp[i % 2][j - 1] + dp[i % 2][j]) % mod;
        }
    }

    cout << tmp[1 - K % 2][(int)(V.size()) - 1] << endl;

    return 0;
}


Measured memory_bytes: 5628
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc013.contest.atcoder.jp/tasks/agc013_b>
問題文============================================================
 N 頂点 M 辺の、連結な単純無向グラフが与えられます。
 頂点には 1 から N までの番号がついており、辺には 1 から M までの番号がついています。
 辺 i は、頂点 Ai と頂点 Bi を結んでいます。 次の条件を満たすパスを 1 つ見つけて、出力してください。
 
 2 個以上の頂点を通る
 同じ頂点を 2 度以上通らない
 パスの少なくとも一方の端点と直接辺で結ばれている頂点は、必ずパスに含まれる
 
 ただし、この問題の制約の下で、このようなパスが必ず存在することが証明できます。
 また、あり得る答えのうちどれを出力しても構いません。
 
=================================================================

解説=============================================================

================================================================
*/

void solve(){
    ll N,M; cin >> N >> M;
    vector<ll> A(M),B(M);
    for(int i = 0; i < M;i++){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }
    vector<vector<ll>> G(N);
    for(int i = 0; i < M;i++){
        G[A[i]].push_back(B[i]); G[B[i]].push_back(A[i]);
    }
    vector<int> used(N,0);
    ll l = 0, r = G[0][0];
    used[l] = used[r] = 1;
    deque<ll> deq; deq.push_front(l); deq.push_back(r);
    while(true){
        bool f = true;
        for(auto v:G[l]){
            if(used[v]) continue;
            f = false; used[v] = 1;
            deq.push_front(v); l = v; break;
        }
        if(!f)continue;
        for(auto v:G[r]){
            if(used[v])continue;
            f = false; used[v] = 1;
            deq.push_back(v); r = v; break;
        }
        if(f) break;
    }
    vector<ll> ans(deq.begin(),deq.end());
    cout << ans.size() << endl;
    for(int i = 0; i < (int)ans.size();i++){
        cout << ans[i]+1 << " \n"[i == ans.size()-1];
    }
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    solve();
	return 0;
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define pb push_back
#define Int int64_t
using namespace std;
const int MAXN=7;
int main()
{
   char board[MAXN][MAXN];
   Int n,m,K;
   cin>>n>>m>>K;
   for(int i=0;i<n;++i){
       for(int j=0;j<m;++j){
            cin>>board[i][j];
       }
   }
   Int ans=0;
   for(int mask=0;mask<(1<<(n+m));++mask){
       Int count=0;
       for(int i=0;i<n;++i){
           for(int j=0;j<m;++j){
               if(mask&((1<<j)|(1<<(m+i)))||board[i][j]!='#') continue;
               ++count;
           }
       }
       ans+=(count==K);
   }
   cout<<ans<<"\n";
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 2e5 + 10;
int N, M;
int L[MAX], R[MAX], D[MAX];
LL x[MAX];
bool exist_r[MAX];
VI x_idx[MAX];
bool used[MAX];

int main(void) {
    scanf("%d%d", &N, &M);
    REP(i, M) {
        scanf("%d%d%d", L + i, R + i, D + i);
        L[i]--;
        R[i]--;
        exist_r[R[i]] = true;
        x_idx[L[i]].EB(i);
    }
    memset(x, -1, sizeof(x));
    queue<int> q;
    REP(i, N) {
        if (!exist_r[i]) {
            x[i] = 0;
            q.emplace(i);
        }
    }
    bool ok = true;
    while (!q.empty()) {
        const int e = q.front();
        q.pop();
        FORE(i, x_idx[e]) {
            used[i] = true;
            if (x[R[i]] == -1) {
                x[R[i]] = x[L[i]] + D[i];
                q.emplace(R[i]);
            }
            if (x[R[i]] != x[L[i]] + D[i]) {
                ok = false;
            }
        }
    }
    REP(i, M) {
        if (!used[i]) {
            if (x[L[i]] == -1 && x[R[i]] == -1) {
                x[L[i]] = 0;
                x[R[i]] = x[L[i]] + D[i];
            } else if (x[L[i]] == -1) {
                x[L[i]] = x[R[i]] - D[i];
            } else if (x[R[i]] == -1) {
                x[R[i]] = x[L[i]] + D[i];
            }
            if (x[R[i]] != x[L[i]] + D[i]) {
                ok = false;
            }
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 12160
#include<stdio.h>
#define MAX 100000
#define MIN -1

struct Node{
  int parent, left, right;
};

struct Node T[MAX];
int D[MAX], H[MAX];

int Depth(int);
int Sibling(int);
void print(int);


int main(){
  int i,n, x,y,z,a,b;
  
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    T[i].parent=MIN;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d%d%d",&x,&y,&z);
    T[x].left=y;
    T[x].right=z;
    if (y!=MIN) T[y].parent=x;
    if (z!=MIN) T[z].parent=x;
  }

  for ( i = 0; i < n; i++ ){
    D[i]=Depth(i);
    H[i]=0;
  }

  for ( i = 0; i < n; i++ ){
    if ( T[i].left==MIN&&T[i].right==MIN) { 
      H[i]=0;
       a = T[i].parent;
       b = 1;
      while(1){
	if (a==MIN) break;
	if ( H[a] < b ) H[a]=b;
	b++;
	a = T[a].parent;
      }
    }
  }

  for ( i = 0; i < n; i++ ){
    print(i);
  }
  return 0;
}

int Depth(int u){
  int d=0;
  while(T[u].parent!=MIN){
    u=T[u].parent;
    d++;
  }
  return d;
}

int Sibling(int u){
  if ( T[u].parent==MIN) return MIN;
  if ( T[T[u].parent].left!=u&&T[T[u].parent].left!=MIN) return T[T[u].parent].left;
  if ( T[T[u].parent].right!=u&&T[T[u].parent].right!=MIN) return T[T[u].parent].right;
  return MIN;
}

void print(int u){
  int count=0;
  printf("node %d: ", u);

  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", Sibling(u));
  if ( T[u].left!=MIN) {
    count++;
  }
  if ( T[u].right!=MIN){
    count++;
  }
  printf("degree = %d, ", count);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if ( T[u].parent==MIN){
    printf("root\n");
  } else if ( T[u].left==MIN&&T[u].right==MIN){
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}




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

int main(){
    int x;
    cin >> x;
    int m = 0; 
    rep(i,32){
        for(int j = 2;j <= 10;j++){
            if(x >= pow(i,j)){
                int s = pow(i,j);
                m = max(m,s);
            }
            else break;
        }
    }
    cout << m << endl;
}

Measured memory_bytes: 640
/*
 * じょえチャンネル
 * 高評価・チャンネル登録よろしくおねがいします！
 * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
 */
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)
template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

string a,b,c;
bool ab[20005],ac[20005],bc[20005];
signed main() {
	cin>>a>>b>>c;
	rep(i,a.size()+b.size()+1){
		rep(j,b.size()){
			int k=-b.size()+i+j;
			if(0<=k&&k<a.size()&&b[j]!='?'&&a[k]!='?'&&b[j]!=a[k]){
				ab[i]=true;
			}
		}
	}
	rep(i,a.size()+c.size()+1){
		rep(j,c.size()){
			int k=-c.size()+i+j;
			if(0<=k&&k<a.size()&&c[j]!='?'&&a[k]!='?'&&c[j]!=a[k]){
				ac[i]=true;
			}
		}
	}
	rep(i,b.size()+c.size()+1){
		rep(j,c.size()){
			int k=-c.size()+i+j;
			if(0<=k&&k<b.size()&&c[j]!='?'&&b[k]!='?'&&c[j]!=b[k]){
				bc[i]=true;
			}
		}
	}
	int ans=inf;
	int aindex=b.size()+c.size();
	rep(i,a.size()+b.size()+c.size()*2+1){
		for(int j=max(0ll,min(aindex,j)-(int)c.size());j<=min((int)b.size()*2+(int)a.size()+(int)c.size()+1,max(j+(int)b.size(),aindex+(int)a.size()));j++){
			int dab=max(0ll,i-aindex+(int)b.size());
			int lab=max(aindex,i)-i,rab=min(aindex+(int)a.size(),i+(int)b.size())-i;
			if(ab[dab]){
				continue;
			}
			int dac=max(0ll,j-aindex+(int)c.size());
			lab=max(aindex,j)-j,rab=min(aindex+(int)a.size(),j+(int)c.size())-j;
			if(ac[dac]){
				continue;
			}
			dac=max(0ll,j-i+(int)c.size());
			lab=max(i,j)-j,rab=min(i+(int)b.size(),j+(int)c.size())-j;
			if(bc[dac]){
				continue;
			}
			chmin(ans,max({i+(int)b.size(),j+(int)c.size(),aindex+(int)a.size()})-min({i,j,aindex}));
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


const int NM = 100000;
ll A[NM];

ll MOD = 1000000007;


void solve() {
    string S;
    cin >> S;

    if (S == "AAA" || S == "BBB") {
        cout << "No";
   }
    else {
        cout << "Yes";
    }
}



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







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int K=N/2;
  double S=N/2;
  if(N%2==0){
    cout<<fixed<<setprecision(10)<<0.5<<endl;
  }
  else{
    cout<<fixed<<setprecision(10)<<double((S+1)/N)<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)




using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll Nmax=1e9;
const ll INF=1e9;

// B貪欲法で決定する．
int main(){
  clock_t start = clock();
  int d;
  cin>>d;
  vector<int> c(26);
  vector<vector<int>> s(d,vector<int>(26));
  vector<int> last(26),last0(26);
  vector<int>c_inv(26); // iを選んだ際の1日での下がり幅
  

  ll c_tot=0;
  rep(i,26){
    cin>> c[i];
    c_tot+=c[i];
    last[i]=-1;
    last0[i]=-1;
  }
  rep(i,26){
    c_inv[i]=c_tot-c[i];
  }

  rep(i,d){//i日目
    rep(j,26){
      cin>>s[i][j];
    }
  }
  // ここまで入力．

  //貪欲法により，初期値t[i]を決める．
  vector<int> t(d);
  int maxloss, iml; // maxlossとその日付
  random_device rnd;
  maxloss=INF;
  rep(i,d){//i日目
   int maxs=-INF;
   int jm=0;

   rep(j,26){
     cin>>s[i][j];
     ll casej=s[i][j];
     rep(k,26){
       if(j!=k){
         casej-=c[k]*(i-last[k]);
       }
     }

     if(casej>maxs){
       maxs=casej;
       jm=j;
     }
   }

   if(maxs<maxloss){
     maxloss=maxs;
     iml=i;
   }
   
   last[jm]=i;
   t[i]=jm;
  }

int cicle=0;
int Ncicle=10000;
  ll sum;
  bool judge=true;
 while(judge){
   cicle++;
   t[iml]=rnd()%26;
   //cout<<t[iml]<<":";
   
   maxloss=INF;
   sum=0;

   rep(i,d){//i日目
     ll casei;
     last[t[i]]=i;
     casei= s[i][t[i]];
     rep(j,26){
       casei-=c[j]*(i-last[j]);
     }
     
     sum+= casei;
     
     if(casei<maxloss){
       maxloss=casei;
       iml=i;
     }
  }  
   clock_t end = clock();
   double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;

   if(time>1700){
       judge=false;
   }

 }//while
  
  
  rep(i,d){
    cout<<t[i]+1<<endl;
  
   }
 // cout<<sum; //消すこと














}


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

int main()
{
    long long H, N, inf = 1e9;
    cin >> H >> N;
    vector<long long> A(N);
    vector<long long> B(N);
    vector<long long> dp(H + 1, inf);

    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i) >> B.at(i);
    }

    dp.at(0) = 0;

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (i + 1 - A.at(j) <= 0)
            {
                dp.at(i + 1) = min(dp.at(i + 1), dp.at(0) + B.at(j));
            }

            else
            {
                dp.at(i + 1) = min(dp.at(i + 1), dp.at(i + 1 - A.at(j)) + B.at(j));
            }
        }
    }

    /*
    for (int i = 0; i <= H; i++)
    {
        cout << dp.at(i) << " ";
    }
    */

    cout << dp.at(H) << endl;
}


Measured memory_bytes: 384
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
a=lnii()
b=lnii()

plus=[]
minus=0
ans=0
for i in range(n):
  if a[i]<b[i]:
    minus+=b[i]-a[i]
    ans+=1
  else:
    plus.append(a[i]-b[i])

if minus==0:
  print(0)
  exit()

plus.sort(reverse=True)
for i in range(len(plus)):
  minus-=plus[i]
  ans+=1
  if minus<=0:
    print(ans)
    exit()

print(-1)

Measured memory_bytes: 24256
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
    char s[100005];
    scanf("%s", s);
    int q;
    scanf("%d", &q);
    bool dic = true;
    deque<char> ans;
    int len = strlen(s);
    for (int i = 0; i < len; i++) {
        ans.push_back(s[i]);
    }
    while (q--) {
        int t;
        scanf("%d", &t);
        if (t == 1) {
            // reverse
            dic = !dic;
        } else {
            int f;
            char c[2];
            scanf("%d%s", &f, c);
            if ((dic && f == 2) || (!dic && f == 1)) {
                ans.push_back(c[0]);
            } else {
                ans.push_front(c[0]);
            }
        }
    }
    if (dic) {
        for (auto c : ans) {
            printf("%c", c);
        }
    } else {
        for (auto c = ans.rbegin(); c != ans.rend(); c++) {
            printf("%c", *c);
        }
    }
    printf("\n");
}


Measured memory_bytes: 896
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

void solve() {
  int n;
  ll d;
  vector<ll> amt;
  cin >> n >> d;
  for(int i = 0; i < n; i++) {
    ll t;
    cin >> t;
    amt.push_back(t);
  }
  for(int i = 1; i < n; i++) {
    if(amt[i-1] + amt[i] >= d) {
      cout << "Possible\n";
      for(int x = 1; x < i; x++) cout << x << "\n";
      for(int x = n-1; x > i; x--) cout << x << "\n";
      cout << i << "\n";
      return;
    }
  }
  cout << "Impossible\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


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

int main() {
  int H,A;
  int att = 0;
  cin >> H >> A;
  
  if( H % A == 0){
    att = H/A;
  }else{
    att = H / A + 1;
  }
  cout << att << endl;
}

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

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

Measured memory_bytes: 3620