akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <deque>
#include <utility>
#include <bitset>
#include <limits.h>
#include <time.h>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MOD = (int)1e9 + 7;

class modint {
  int v;
public:
  modint (): v(0) { }
  modint (ll v): v((v + MOD) % MOD) { }

  bool operator== (modint x) { return v == x.v; }
  bool operator!= (modint x) { return v != x.v; }

  modint operator+ (modint x) { return v + x.v; }
  modint operator- (modint x) { return v - x.v; }
  modint operator* (modint x) { return (ll)v * x.v; }

  modint& operator+= (const modint x) { return *this = (*this + x); }
  modint& operator-= (const modint x) { return *this = (*this - x); }
  modint& operator*= (const modint x) { return *this = (*this * x); }

  int operator* () { return v; }
};

#define debug(format, ...) printf(format, __VA_ARGS__);

const int N_ = 100500;
int N, A[N_];

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

  try {
    int x = *max_element(A+1, A+N+1);
    int y = *min_element(A+1, A+N+1);
    if(x - y > 1) {
      throw 0;
    }

    // 실제 distinct한 게 d개?
    for(int d = x; d <= x+1; d++) {
      bool good = true;
      int c1 = 0, c0 = 0;
      for(int i = 1; i <= N && good; i++) {
        if(d - A[i] > 1) good = false;
        if(d == A[i] + 1) {
          c1 += 1; // 얘 혼자 다른 세계에 살고 있음.
        }
        if(d == A[i]) {
          // 얘를 빼도 상관이 없음. 즉 같은 색을 가진 다른 놈 존재
          c0 += 1;

        }
      }
      if(c1 + !!c0 > d) {
        good = false;
      }
      if(c1 + c0 / 2 < d) {
        good = false;
      }
      if(good) {
        throw 1;
      }
    }

    throw 0;
  }catch(int e) {
    puts(e ? "Yes" : "No");
  }
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	ll N, A, B, ans = 0;

	cin >> N >> A >> B;

	if ((B - A) % 2 == 0) ans = (B - A) / 2;
	else {
		ll edge = min(N - B, A - 1);
		ans = edge + (B - A + 1) / 2;
	}

	cout << ans << endl;

	return 0;
}


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

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define yes cout<<"Yes"<<nl
#define no cout<<"No"<<nl
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}


int main()
{
   su;
   int n;
   cin>>n;
   ll a[n],sum=0;
   lo(i,0,n)
   {
     cin>>a[i];
   }
   sort(a,a+n);
   lo(i,0,n-1)
   {
     sum+=a[i];
   }
   if(sum>a[n-1])
    yes;
   else
    no;
   return 0;
}


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

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

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

  int n; cin >> n;
  vector<int> L(2*n);
  rep(i, 2*n) cin >> L[i];
  sort(L.begin(), L.end());

  int ans = 0;
  for(int i = 0; i < 2*n; i += 2) {
    ans += min(L[i], L[i+1]);
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))
count = 0
x = []
e = []
for i in range(len(l)-2):
    for j in range(i+1,len(l)-1):
        if l[i]!=l[j]:
            for k in range(j+1,len(l)):
                if l[i]!=l[k] and l[j]!=l[k]:
                    x.append([i+1,j+1,k+1])
                    e.append([l[i],l[j],l[k]])
count = 0           
for i in range(len(x)):
    e[i].sort()
    if e[i][0] + e[i][1] > e[i][2]:
        count +=1
print(count)

Measured memory_bytes: 42460
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPS 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
int t;
ll n, a, b, c, d;
map<ll, ll> ree;
ll calc(ll x){
    if(x == 0) return 0;
    if(x == 1) return d;
    if(ree[x] != 0) return ree[x];

    ll res = 1e18;
    if(x <= 1e18/d) res = x*d;
    
    res = min(res, d*(x%2)+a+calc(x/2));
    if(x%2) res = min(res, d*(2-x%2)+a+calc(x/2+1));

    res = min(res, d*(x%3)+b+calc(x/3));
    if(x%3) res = min(res, d*(3-x%3)+b+calc(x/3+1));

    res = min(res, d*(x%5)+c+calc(x/5));
    if(x%5) res = min(res, d*(5-x%5)+c+calc(x/5+1));

    //cout << x << " " << res << "\n";
    return ree[x] = res;
}

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

    cin >> t;
    F0R(_, t){
        cin >> n >> a >> b >> c >> d;
        ree.clear();
        cout << calc(n) << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 4380
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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 (a > b) { a = b; return 1; } return 0; }

ll gcd(ll x, ll y) {
	int r = 0;
	if (x < y) swap(x, y);

	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vll A(N);
	REP(i,N)cin >> A[i];
	if (N == 2) {
		cout << max(A[0], A[1]) << endl;
		return 0;
	}
	// 0 1 2 3 <= A
	//  0 1 2  <= R,L
	ll cur = A[0];
	vll R(N - 1), L(N - 1);
	REP(i, N - 1){
		cur = gcd(cur, A[i]);
		L[i] = cur;
	}
	cur = A[N - 1];
	REPR(i, N - 1) {
		cur = gcd(cur, A[i + 1]);
		R[i] = cur;
	}
	ll ans = max(R[0],L[N-2]);
	FOR(i, 1, N-1) {
		chmax(ans, gcd(L[i-1],R[i]));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include<atcoder/all>

using namespace std;
using namespace atcoder;

int main(){
    int N,M;
    cin>>N>>M;
    string S[N+2];
    for(int i=1;i<=N;i++){
        cin>>S[i];
        S[i]="#"+S[i]+"#";
    }
    S[0]="";
    S[N+1]="";
    for(int i=0;i<M+10;i++){
        S[0]+="#";
        S[N+1]+="#";
    }

    mf_graph<int> g(N*M+2);
    int s=0;
    int t=N*M+1;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=M;j++){
            //cout<<"----"<<i<<","<<j<<endl;
            int ij=(i-1)*M+j;
            //cout<<ij<<endl;
            if(S[i][j]=='.'){
                if((i+j)%2==0){
                    //cout<<s<<","<<ij<<endl;
                    g.add_edge(s,ij,1);
                    int dx[]={0,0,1,-1};
                    int dy[]={1,-1,0,0};
                    for(int k=0;k<4;k++){
                        if(S[i+dy[k]][j+dx[k]]=='.'){
                            int ij2=(i-1+dy[k])*M+j+dx[k];
                            //cout<<ij<<","<<ij2<<endl;
                            g.add_edge(ij,ij2,1);
                        }
                    }
                }
                else {
                    //cout<<ij<<","<<t<<endl;
                    g.add_edge(ij,t,1);
                }
            }
        }
    }

    cout<<g.flow(s,t)<<endl;

    vector<mf_graph<int>::edge> ge=g.edges();
    for(int i=0;i<ge.size();i++){
        int fl=ge[i].flow;
        int to=ge[i].to;
        int fr=ge[i].from;
        int tx=(to-1)%M+1;
        int ty=(to-1)/M+1;
        int fx=(fr-1)%M+1;
        int fy=(fr-1)/M+1;

        if(fl!=0&&s!=fr&&t!=to){
            //cout<<fx<<","<<fy<<","<<tx<<","<<ty<<endl;
            if(fx+1==tx){
                S[fy][fx]='>';
                S[ty][tx]='<';
            }
            if(fx-1==tx){
                S[fy][fx]='<';
                S[ty][tx]='>';
            }
            if(fy+1==ty){
                S[fy][fx]='v';
                S[ty][tx]='^';
            }
            if(fy-1==ty){
                S[fy][fx]='^';
                S[ty][tx]='v';
            }
        }
    }
    for(int i=1;i<=N;i++){
        for(int j=1;j<=M;j++){
            cout<<S[i][j];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 5608
n, m = list(map(int, input().split()))
anq = []
for i in range(n):
  a = list(map(int, input().split()))
  k = a.pop(0)
  anq.append(a)
  
count = 1
tempand = set(anq[0])
for i in range(n-1):
  tempand = set(tempand) & set(anq[count])
  count += 1
print(len(tempand))

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

int main(void){
  int i,N,K;
  cin >> N >> K;
  vector<vector<int>> v;
  REP(i,N){
    if(i/K==0) v.push_back(vector<int>(0));
    v[i%K].push_back(i);
  }
  ll sum=0;
  REP(i,v.size()){
    ll n = (ll)v[i].size();
    if((2*(i+1))%K==0) sum+=n*n*n;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 6836
def main():
    """
    """
    N, M, Q = map(int, input().split())
    L, R = zip(*(
        map(int, input().split())
        for _ in range(M)
    ))
    p, q = zip(*(
        map(int, input().split())
        for _ in range(Q)
    ))

    # answers = f(N, M, Q, L, R, p, q)
    # experiment(N, M, Q, L, R, p, q)
    # answers = TLE(N, M, Q, L, R, p, q)
    answers = editorial(N, M, Q, L, R, p, q)
    for ans in answers:
        print(ans)


def editorial(N, M, Q, L, R, p, q):
    """
    ２次元累積和のライブラリを持っておくとよいらしい
        確かに実装ミスりそう

    """
    # LRの組合せ, N<=500より間に合う
    t1 = [[0] * (N+1) for _ in range(N+1)]
    t2 = [[0] * (N+1) for _ in range(N+1)]
    for l, r in zip(L, R):
        t1[l][r] += 1

    # Lごとの累積和
    for l in range(1, N+1):
        for r in range(1, N+1):
            t2[l][r] = t2[l][r-1] + t1[l][r]

    answers = []
    for _p, _q in zip(p, q):
        ans = 0
        for l in range(_p, _q+1):
            ans += t2[l][_q] - t2[l][_p-1]

        answers.append(ans)

    return answers


def TLE(N, M, Q, L, R, p, q):
    """
    10^5 * 10^5
    """
    answers = []
    for _p, _q in zip(p, q):
        ans = 0
        for left, right in zip(L, R):
            if _p <= left and right <= _q:
                ans += 1

        answers.append(ans)

    return answers


if __name__ == '__main__':
    main()


Measured memory_bytes: 136344
// 基本テンプレート
 
#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>
#include <bitset>
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 debug(...) fprintf(stderr, __VA_ARGS__)
#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};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int A[200010], B[200010];
signed main() {
    int N; cin >> N;

    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];

    int ans = 0;
    for(int d=0; d<29; d++) {
        vector<int> mods;
        for(int i=0; i<N; i++) {
            mods.push_back(B[i] % (1LL << (d+1)));
        }
        sort(mods.begin(), mods.end());

        for(int i=0; i<N; i++) {
            // [lb, ub] の範囲でビットが立つ
            int lb, ub;
            if(A[i] >> d & 1) {
                int mask = A[i] % (1LL << d);
                lb = (1LL << (d+1)) - mask;
                ub = lb + (1LL << d) - 1;
            }
            else {
                int mo = A[i] % (1LL << (d+1));
                lb = (1LL << d) - mo;
                ub = lb + (1LL << d) - 1;
            }

            int div = (1LL << (d+1));
            vector< pair<int, int> > segs;
            if(lb / div != ub / div) {
                segs.push_back(make_pair(lb%div, div-1));
                segs.push_back(make_pair(0, ub%div));
            }
            else {
                segs.push_back(make_pair(lb%div, ub%div));
            }

            /*
            fprintf(stderr, "bit = %s, d = %lld, lb = %lld, ub = %lld\n", bitset<28>(A[i]).to_string().c_str(), d, lb, ub);  
            for(auto x : segs) {
                fprintf(stderr, "[%lld, %lld]\n", x.first, x.second);
            }
            */

            int cnt = 0;
            for(auto x : segs) {
                int L, R; tie(L, R) = x;
                auto idx = lower_bound(mods.begin(), mods.end(), L);
                auto jdx = upper_bound(mods.begin(), mods.end(), R);
                (cnt += (jdx - idx)) %= 2;
            }
            ans ^= (cnt << d);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7028
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	long long x[n+1],y[n+1],z[n+1];
	for(int i=1;i<=n;i++){
		cin>>x[i];
	}
	for(int i=1;i<=n;i++){
		cin>>y[i];
	}
	for(int i=1;i<=n;i++){
		cin>>z[i];
	}
	sort(x+1,x+n+1);
	sort(y+1,y+n+1);
	sort(z+1,z+n+1);
	long long f[n+1];
	int j=1;
	for(int i=1;i<=n;i++){
		while(j<=n&&z[j]<=y[i]){
			j++;
		}
		f[i]=n-j+1;
	}
	long long q[n+2];
	q[n]=f[n];
	q[n+1]=0;
	for(int i=n-1;i>0;i--){
		q[i]=q[i+1]+f[i];
	}
	j=1;
	long long ans=0;
	for(int i=1;i<=n;i++){
		while(j<=n&&y[j]<=x[i]){
			j++;
		}
		ans+=q[j];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

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

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int A[100011];

void solveSingleCase(int caseNo)
{
    int N;
    cin >> N;
    READRANGE(A + 1, A + N + 1);
    int button = 1;
    FOR(i, 0, N + 2) {
        if (button == 2) {
            cout << i << endl;
            return;
        }
        button = A[button];
    }
    cout << -1 << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 640
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String args[]) {
        String s;

        Scanner sc = new Scanner(System.in);
        s = sc.nextLine();

        Scanner scn = new Scanner(s);

        Stack<Integer> stack = new Stack<Integer>();

        while (scn.hasNext()) {
            String op = scn.next();
            if (op.equals("+")) {
                int n = stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("-")) {
                int n = -1 * stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("*")) {
                int n = stack.pop() * stack.pop();
                stack.push(n);
            } else {
                stack.push(Integer.parseInt(op));
            }
        }

        System.out.println(stack.pop());
    }
}

Measured memory_bytes: 26348
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for ly in range(N):
    for lx in range(N):
        # 見ている範囲が NxN を超えている
        if ly+M-1 >= N or lx+M-1 >= N: continue

        # NxN を見ている範囲と MxM の match を探索
        match = True
        for y in range(M):
            for x in range(M):
                if A[ly+y][lx+x] != B[y][x]:
                    match = False
        if match:
            print("Yes")
            exit()

print("No")

Measured memory_bytes: 3064
from functools import reduce
def nCr(n,r,DIV):
  if r<n-r:
    r=n-r
  if r==0:
    return 1
  f=lambda x,y:x*y%DIV
  X=reduce(f,range(n-r+1,n+1))
  Y=reduce(f,range(1,r+1))
  return X*pow(Y,DIV-2,DIV)%DIV

mod = pow(10, 9) + 7
x, y = map(int, input().split())
left, right = 0, 0
a, b = max(x, y), min(x, y)

if (2*b - a) % 3 == 0:
    d, s = a - b, (2*b - a)//3
    p, q = d + s, s
    print(nCr(p+q, p, mod))
else:
    print(0)

Measured memory_bytes: 9636
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

#define MAX_V 200000+4

struct Edge{ int to,cap,rev; };
int used[MAX_V];
vector<Edge> G[MAX_V];

void addEdge(int from,int to,int cap){
    G[from].push_back((Edge){to,cap,(int)G[to].size()});
    G[to].push_back((Edge){from,0,(int)G[from].size()-1});
}
int DFS(int v,int t,int f){
    if(v==t)
        return f;
    used[v]=true;
    for(int i=0;i<(int)G[v].size();i++){
        Edge &e=G[v][i];
        if(!used[e.to] && 0<e.cap){
            int d=DFS(e.to,t,min(f,e.cap));
            if(0<d){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
int maxFlow(int s,int t){
    int flow=0;
    while(1){
        for(int i=0;i<MAX_V;i++)
            used[i]=false;
        int f=DFS(s,t,INT_MAX);
        if(f==0)
            break;
        flow+=f;
    }
    return flow;
}

const int INF = 1e8;

int main(void){
    int H,W;cin>>H>>W;
    vector<string> vs;
    REP(i,H){string s;cin>>s;vs.pb(s);}

    int d[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
    int src=2*H*W,dst=2*H*W+1;
    REP(i,H)
        REP(j,W){
            if(i==0||j==0||i==H-1||j==W-1)
                addEdge(i*W+j+H*W,dst,INF);
            if(vs[i][j]=='X'){
                addEdge(src,i*W+j,INF);
                addEdge(i*W+j,i*W+j+H*W,INF);
            }
            else
                addEdge(i*W+j,i*W+j+H*W,1);
            REP(k,4){
                int ii=i+d[k][0],jj=j+d[k][1];
                if(0<=ii&&ii<H&&0<=jj&&jj<W)
                    addEdge(i*W+j+H*W,ii*W+jj,INF);
            }
        }

    int f=maxFlow(src,dst);
    if(INF<=f)
        cout<<-1<<endl;
    else
        cout<<f<<endl;
     return 0;
}

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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
//#define int long long
//#define double long double

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

    int k;
    string s;
    cin >> k >> s;
    
    if (s.size() <= k)
        cout << s << '\n';
    else
        cout << s.substr(0, k) << "...\n";

    return 0;
}

//      *   *  *****  *   *  *   *
//     *   *  *      **  *  *   *
//    *****  *****  * * *  *   *
//   *   *      *  *  **  *   *
//  *   *  *****  *   *   ***

//      ***** ***** *   * *     ***** *   * ***** *****
//        *  *   * *   * *       *   **  *   *   *   *
//       *  *   * ***** *       *   * * *   *   *****
//   *  *  *   *   *   *       *   *  **   *   *
//  ****  *****   *   ***** ***** *   *   *   *


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int n,x,y,z;
ll dp[64][1<<18];

int main(){
    cin >> n >> x >> y >> z;
    int mask = (1<<(x+y+z))-1;
    int ng = (1<<(x+y+z-1)) | (1<<(y+z-1)) | (1<<(z-1));

    dp[0][0] = 1;

    //cout << "NG : " << static_cast<bitset<18>>(ng) << endl;
    //cout << "mask: " << static_cast<bitset<18>>(mask) << endl;

    for(int i=0;i<n;i++){
        for(int state=0;state<=mask;state++){
            for(int a=1;a<=10;a++){
                int next_state = (state << a) | (1<<(a-1));
                next_state &= mask;
                if((next_state & ng) == ng){ continue; }

                dp[i+1][next_state] += dp[i][state];
                dp[i+1][next_state] %= mod;
            }
        }
    }

    ll ans = 1;
    for(int i=0;i<n;i++) ans = (ans*10) % mod;

    for(int i=0;i<=mask;i++){
        ans -= dp[n][i];
        ans = (ans + mod) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 82176
import bisect
N = int(input())
list = list(map(int, input().split()))
list.sort()

score = 0

for i in range (N-2):
    for j in range (i+1, N-1):
        index = bisect.bisect_left(list, list[i] + list[j]) - j - 1
        score += index

print (score)


Measured memory_bytes: 3188
object Main extends App {
    for (Array(a, b, n) <- io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))) {
        var (rem, res, i) = (a, 0, n)
        while (i > 0) {
            rem = rem % b * 10
            res += rem / b
            i -= 1
        }
        println(res)
    }
}

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


int main() {
    string s;
    cin >> s;
    set<char> se;
    for(int i = 0; i < 4; i++){
        se.insert(s[i]);
    }
    if (se.size() == 2){
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int sum = 0;
    for (auto i : s)
    {
        sum += i - '0';
    }
    if (sum % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3780
#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#define fup(i,a,b) for(int i=a;i<=b;i++)
#define fdw(i,a,b) for(int i=a;i>=b;i--)
#define sync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define cl(a) memset(a,0,sizeof(a))
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
int dp[10001];
int w[1001];
int v[1001];
int main(){
	int n, m, i, j;
	scanf("%d%d",&m,&n);
    for(i = 1; i <= n; i++)
        scanf("%d %d",&w[i] , &v[i]);
    memset(dp, inf, sizeof(dp));
    dp[0] = 0;
    for(i = 1; i <= n; i++)
        for(j = 0; j <= 10000; j++){
            if(j >= w[i])
                dp[j] = min(dp[j], dp[j-w[i]]+v[i]);
        }
    int ans = dp[m];
    int k = m;
    for(i = m+1; i <= 10000; i++){
        if(ans >= dp[i]){
            ans = dp[i];
        }
    }
    printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a>>b;
  if(a==1||b==1){
    if(a==1&&b!=1) cout <<"Alice"<<endl;
    else if(a!=1&&b==1) cout <<"Bob"<<endl;
    else cout <<"Draw"<<endl;
  }
  else{
    if(a>b) cout <<"Alice"<<endl;
    else if(a<b) cout <<"Bob"<<endl;
    else cout <<"Draw"<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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;}

int n,m;
int x[100100];
int px[100100];

int main(){
	cin>>n>>m;
	REP(i,m)
		cin>>x[i];
	sort(x,x+m);
	ll ans=x[m-1]-x[0];
	
	for(int i=0;i<m-1;i++){
		px[i]=x[i+1]-x[i];
	}
	
	sort(px,px+m-1,greater<int>());
	for(int i=0;i<n-1;i++){
		ans-=px[i];
	}
	cout<<ans<<endl;
	return 0;
}
	

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int H, W, D;
    cin >> H >> W >> D;

    int Y[300 * 300 + 1];
    int X[300 * 300 + 1];
    int tmp;

    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            cin >> tmp;
            Y[tmp] = h + 1;
            X[tmp] = w + 1;
        }
    }

    int Q, L, R;
    cin >> Q;

    int C[300 * 300 + 1] = {};

    for (int q = 0; q < Q; q++) {
        cin >> L >> R;
        if (L == R)
            cout << 0 << endl;
        else {
            if (C[R] == 0) {
                int A = R % D;
                if (A == 0) A = D;
                int B;
                int cost = 0;
                while (A + D <= W * H) {
                    B = A + D;
                    cost += abs(Y[B] - Y[A]) + abs(X[B] - X[A]);
                    A = B;
                    C[A] = cost;
                }
            }
            cout << C[R] - C[L] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 2176
#include<cmath>
#include<iostream>
#include<algorithm>
#include <string>
#include <stdexcept>
using namespace std; 
int main(){
  int a,b,c,d,e;
 	cin >>a>>b;
 if(a<9&&b<9) cout <<"Yay!";
   else cout << ":(";
  	
  
}

Measured memory_bytes: 256
n=int(input())
a=[]
h=[]
for _ in range(n):
    x=int(input())
    h.append([tuple(map(int,input().split())) for _ in range(x)])
    a.append(x)
ans=0
for i in range(2**n):
    f=1
    for j in range(n):
        if (i>>j)&1:
            for k in range(a[j]):
                x,y=h[j][k]
                if (i>>(x-1))&1!=y:
                    f=0

    if f:
        c=0
        for j in range(n):
            c+=(i>>j)&1

        ans=max(ans,c)
print(ans)


Measured memory_bytes: 42604
S = input()
N = len(S)
if S[:] == S[N-1::-1] and S[0:N//2] == S[N//2-1::-1] and S[(N+3)//2-1:] == S[N-1:(N+3)//2-2:-1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    #l,r,d=map(int,input().split())
    s=input()
    ans=0
    if s=="RSS" or s=="SRS" or s=="SSR" or s=="RSR":
        ans=1
    elif s=="RRS" or s=="SRR":
        ans=2
    elif s=="RRR":
        ans=3
    print(ans)


if __name__ == "__main__":

    main()


Measured memory_bytes: 77276
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <string.h>
#include<algorithm>
#include <numeric>      // std::accumulate
#include <iomanip>      // std::setprecision


using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define v           vector <int>
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define EPS			 1e-9
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;

bool cmp(const pair<int, int>& a, const pair<int, int>& b)
{
    return (a.second < b.second);
}

int gcd(int a, int b) 
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
long long power(ll n, ll k) 
{
    if (k == 0) return 1;
    ll sq = (power(n, k / 2));
    sq = (sq * sq);
    if (k % 2 == 1)
        sq = (sq * n);
    return sq;
}
bool isPrime(int n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    if (n % 2 == 0 || n % 3 == 0) return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
string to_binary(int x) 
{
    string s;
    while (x > 0) 
    {
        s += (x % 2 ? '1' : '0');
        x /= 2;
    }
    reverse(s.begin(), s.end());
    return s;
}
const int N = 2e5 + 4;
ll x[N], y[N];
ll sector(int i, ll z) {
    if (i)return z - x[i - 1];
    else return z;
}

void solve()
{

    int n; cin >> n;

    if (n % 1000 == 0)
    {
        cout << 0 << "\n";
        return;
    }
    cout << ((((n / 1000) + 1) * 1000) - n) << "\n";
}

int main()
{
    IOS;
    solve();
    /*
    int tt; cin >> tt;
    while (tt--)
    {

    }
    */
    
}
       

Measured memory_bytes: 3196
import sys

S = list(sys.stdin.readline().rstrip())
T = list(sys.stdin.readline().rstrip())

len_s = len(S)
len_t = len(T)

for i in range(len_s - len_t, -1, -1):
    for j in range(len_t):
        if S[i+j] == T[j] or S[i+j] == "?":
            continue
        else:
            break
    else:
        for k in range(len_t):
            S[i+k] = T[k]

        print(("".join(S)).replace("?","a"))
        exit()

print("UNRESTORABLE")

Measured memory_bytes: 38384
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
	static int mod = (int)1e9+7;
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static void main(String sp[])throws IOException{
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		long arr[] = new long[n+2];
		for(int i=0;i<q;i++)
			arr[sc.nextInt()]+=1;
		
		long pre[] = new long[n+2];
		long suf[] = new long[n+2];
		for(int i=1;i<=n;i++){
			pre[i]=arr[i];
			suf[i]=arr[i];
		}
		
		for(int i=1;i<=n;i++){
			pre[i]+=pre[i-1];
		}
		for(int i=n;i>=1;i--){
			suf[i]+=suf[i+1];
		}
		
		
		for(int i=1;i<=n;i++){
			long total = (long)pre[i-1]+(long)suf[i+1];
			if(total>=k)	
				System.out.println("No");
			else System.out.println("Yes");
			
		}

	}
	
	public static class pair{
		int pos;
		int bomb;
	}
	
	
	public static int partition(int [] arr, int s, int e){
		
		int index=s;
		int pivot = arr[e];
		for(int i=s;i<=e-1;i++){
			if(arr[i]<=pivot){
				arr = swap(arr, index, i);
				index++;
			}
		}
		swap(arr,index,e);
		print(arr);
		return index;
	}
	
	public static int[] swap(int[] arr, int low, int high){
		int temp = arr[low];
		arr[low]=arr[high];
		arr[high]=temp;
		return arr;
	}
	
	
	public static long gcd(long a, long b){
		if(a==0)
			return b;
		
		return gcd(b%a,a);
	}
	
	public static void print(int[] arr){
		for(int i=0;i<arr.length;i++)
			System.out.print(arr[i]+" ");
		System.out.println();
	}
	

	public static class comp implements Comparator<pair>{
		public int compare(pair o1, pair o2){
			return o1.bomb-o2.bomb;
		}
	}
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
}

Measured memory_bytes: 61008
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int a = stdin.nextInt();
		int b = stdin.nextInt();
		int c = stdin.nextInt();
		int d = stdin.nextInt();

		int min = Math.min(a, b) + Math.min(c, d);
		System.out.println(min);
	}

}


Measured memory_bytes: 21844
import java.io.*;

class Main {
	public static void main(String[] args) {
		// BufferedReader br = new BufferedReader(new
		// InputStreamReader(System.in));
		try {
		        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str = br.readLine();
			// n:???????????°???k:?????????????????°
			int n = Integer.parseInt(str.split(" ")[0]);
			int k = Integer.parseInt(str.split(" ")[1]);
			// ?????????????´?????????????
			int[] nimotu = new int[n];
			// ??¨????????????????????????????¨?????????????
			int totalWeight = 0;
			// ??????????????????????´????????????????????±???????
			for (int i = 0; i < n; i++) {
				nimotu[i] = Integer.parseInt(br.readLine());
				totalWeight += nimotu[i];
			}
			// ???????????????????±???????
			int aver = totalWeight / k;
			int maxweight = aver;
			int tracknum;
			while(maxweight <= totalWeight){
				//if(limit == 1)break;
				int weight = 0;
				tracknum = 1;
				boolean flg = true;
				// ???????????????????¶???????????????????????????????????????????
				for(int i = 0;i < n && tracknum <= k;) {
					// ????????????????????????????????°?????????
					if(weight + nimotu[i] <= maxweight){
						weight += nimotu[i];
						i++;
					//??????????????????????????????????????????????????£?????????????????°?¬????
					} else if(weight > 0){
						if(maxweight < weight){
							maxweight = weight;
						}
						weight = 0;
						tracknum++;
					//??????????????¨????¨??????§??????????????????????????????????????°?¬????
					} else {
						flg = false;
						break;
					}
				}
				/* ???????????¶
				 * 1.tracknum = k?????¨??????????????????????????¨?????????????????¨
				 * 2.flg = true????????¨?????????????????????????????????????????¨
				*/
				if(tracknum <= k && flg){
					System.out.println(maxweight);
					break;
				}
				// ?????????????????´?????????????????????????¬????
				maxweight++;
			}
		} catch (IOException e) {
			System.out.println("error");
		}
	}
}

Measured memory_bytes: 29648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    string s;
    cin>>s;
    bool f = false;
    rep(i,0,s.size()-1){
        if(s[i]==s[i+1]) f = true;
    }
    if(f) cout<<"Bad"<<endl;
    if(!f) cout<<"Good"<<endl;
}

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

int main(){
  int n; cin >> n;
  vector<long> a(n);
  int ans = 0;
  int key = 1;
  bool flag = false;
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  for(int i = 0; i < n; i++){
    if(a.at(i) != key) ans++;
    else{
      key++;
      flag = true;
    }
  }
  if(flag)
    cout << ans;
  else
    cout << -1;
}

Measured memory_bytes: 4856
N=int(input())
S=str(input())
ans=0


for a in range (10):    
    for b in range (10):
        for c in range (10):
            x=S.find(str(a))
            if x != -1 and x<N-2:
                
                y=S.find(str(b),x+1)
                if y!= -1 and y<N-1:
                    z=S.find(str(c),y+1)
                    if z!= -1:ans=ans+1

print(ans) 

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	int n, d;
	cin >> n >> d;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		double value = sqrt((double)((x * x) + (y * y)));
		if (value <= d)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

//!

Measured memory_bytes: 3680
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
#include<functional>
using namespace std;
int n,m;
int par[200005];
int num[200005];
pair<int,int> e1[100005];
long long ans[100005];
int find(int x)
{
	if(par[x]==x)
		return x;
	else
		return par[x]=find(par[x]);
}
long long unite(int x,int y)
{
	x=find(x);
	y=find(y);
	if(x==y)
		return 0;
	long long xn=num[x],yn=num[y];
	par[y]=x;
	num[x]+=num[y];
	return xn*yn;
}
int main()
{
	cin>>n>>m;
	long long N=(long long)n*(long long)(n-1)/(long long)2;
	for(int i=0;i<n;i++)
	{
		par[i]=i;
		num[i]=(long long)1;
	}
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		e1[i]=make_pair(x,y);
	}
	ans[m]=N;
	for(int i=m-1;i>=0;i--)
	{
		int x=e1[i].first;
		int y=e1[i].second;
		ans[i]=ans[i+1]-unite(x,y);
	}
	for(int i=1;i<=m;i++)
		cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 3712
W, H, N = map(int, input().split())

border = [0,W,0,H]

for i in range(N):
  x, y, a = map(int, input().split())
  if a == 1:
    border[a-1] = max(border[a-1], x)
  elif a == 2:
    border[a-1] = min(border[a-1], x)
  elif a == 3:
    border[a-1] = max(border[a-1], y)
  elif a== 4:
    border[a-1] = min(border[a-1], y)

    
print(max(border[1] - border[0], 0) * max(border[3] - border[2], 0))

Measured memory_bytes: 38384
N = int(input())
F = [list(map(int,input().split())) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]

ans = float("-inf")

for i in range(1,1 << 10):
  res=0
  for n in range(N):
    count=0
    for j in range(10):
      if i & F[n][j] << j: count+=1
    res+=P[n][count]
  ans=max(res,ans)
print(ans)

Measured memory_bytes: 3188
import sys
#
# num = input()
#
# num1 = num[0]
# num2 = num[1]
# num3 = num[2]
# num4 = num[3]

num1, num2, num3, num4 = (int(i) for i in input().split())

num1 = str(num1)
num2 = str(num2)
num3 = str(num3)
num4 = str(num4)


strTarget = "1974"
isCheck1 = False
isCheck2 = False
isCheck3 = False
isCheck4 = False

isValidation1 = num1 in strTarget
if isValidation1 :
    strTarget = strTarget.replace(num1,"")
    isCheck1 = True

isValidation2 = num2 in strTarget
if isValidation2 :
    strTarget = strTarget.replace(num2,"")
    isCheck2 = True

isValidation3 = num3 in strTarget
if isValidation3 :
    strTarget = strTarget.replace(num3,"")
    isCheck3 = True

isValidation4 = num4 in strTarget
if isValidation4 :
    strTarget = strTarget.replace(num4,"")
    isCheck4 = True

if isCheck1 and isCheck2 and isCheck3 and isCheck4:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define all(a) begin(a), end(a)
#define sz(a) (int)(a.size())
#define deb(a) cout << #a << ": " << a << ENDL
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli> ii;
typedef vector<lli> vi;

const int MAXN = 16;
const int MAX = (1 << MAXN);
lli INF = 1e18;

lli dp[MAX];
lli calc[MAX];

lli n;

bool cmp(lli u, lli v) {
    return __builtin_popcount(u) < __builtin_popcount(v);
}

lli solve(lli mask) {
    lli &ans = dp[mask];
    if(ans != -1) return ans;
    ans = calc[mask];
    vi pos;
    fore(i, 0, 16) if(mask & (1 << i)) pos.pb(i);
    int cnt = sz(pos);
    fore(i, 1, (1 << cnt) - 1) {
        lli nwMask = 0;
        fore(j, 0, cnt) if(i & (1 << j)) nwMask |= (1 << pos[j]);
        ans = max(ans, solve(nwMask) + solve(mask ^ nwMask));
    }
    return ans;
}

int main()
{   _
    cin >> n;
    fore(i, 0, MAX) dp[i] = -1;
    vector<vector<lli>> mat(n, vector<lli>(n));
    fore(i, 0, n) fore(j, 0, n) cin >> mat[i][j];
    vector<lli> state((1 << n));
    fore(i, 0, (1 << n)) state[i] = i;
    sort(all(state), cmp);
    calc[0] = 0;
    fore(i, 1, (1 << n)) {
        fore(j, 0, n) {
            if(state[i] & (1 << j)) {
               calc[state[i]] += calc[state[i] ^ (1 << j)];
               fore(k, 0, n) {
                    if(k == j or (!(state[i] & (1 << k)))) continue;
                    calc[state[i]] += mat[j][k];
               }
               break;
            }
        }
    }
    cout << solve((1 << n) - 1) << ENDL;
    return 0;
}


Measured memory_bytes: 4788