akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

Measured memory_bytes: 3632
from collections import deque

N, M = map(int, input().split())
k = deque()
s = deque()
for _ in range(M):
    inp = list(map(int, input().split()))
    k.append(inp[0])
    s.append(inp[1:])
p = list(map(int, input().split()))

ans = 0
for i in range(1<<N):
  all_on = True
  for m_i in range(M):
    swon = 0
    for s_i in s[m_i]:
      if i>>(s_i-1)&1:
        swon += 1
    
    if swon%2 != p[m_i]: #電球がOFFだったら
      all_on = False
      break
  
  if all_on: ans += 1

print(ans)


Measured memory_bytes: 74432
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  ll x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  vl p(a),q(b),r(c);
  rep(i,a)cin>>p[i];
  rep(i,b)cin>>q[i];
  rep(i,c)cin>>r[i];
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  sort(q.begin(),q.end());
  reverse(q.begin(),q.end());
  sort(r.begin(),r.end());
  reverse(r.begin(),r.end());
  ll ans=0;
  ll counta=x-1;
  ll countb=y-1;
  ll countc=0;
  rep(i,x)ans+=p[i];
  rep(i,y)ans+=q[i];
  bool finisha=false;
  bool finishb=false;
  rep(i,c){
    if(countc==c)break;
    if((p[counta]<=q[countb]||finishb)&&!(finisha)){
      if(p[counta]<r[countc]){
        ans+=r[countc]-p[counta];
        countc++;
        counta--;
        if(counta==-1){
          finisha=true;
        }
      }
      else break;
    }
    if((q[countb]<p[counta]||finisha)&&!(finishb)){
      if(q[countb]<r[countc]){
        ans+=r[countc]-q[countb];
        countc++;
        countb--;
        if(countb==-1){
          finishb=true;
        }
      }
      else break;
    }
  }
  cout<<ans<<endl;
}
      
  

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
string s;
cin>>s;
sort(s.begin(),s.end());
if(s[0]!='a'){
  printf("a\n");
  return 0;
}
char ans=s[0]+1;
for(ll i=1;i<s.size();i++){
if(s[i]-s[i-1]>1){
ans = s[i-1]+1;
break;
}
if(s[i]=='z'){
  printf("None\n");
  return 0;
}
if(i==s.size()-1){
  ans = s[i]+1;
}
}
printf("%c\n",ans);


}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define vel vector<long long>
#define veb vector<bool>
#define vvel vector<vel>
#define int long long
#define pin pair<int,int>
#define ppin pair<int,pin>
#define mkp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define maxel(vec, j) *max_element(vec.begin(), vec.begin()+j)

using namespace std;
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
signed main() {
    int pr = 1000;
    pr *= pr * pr; pr += 7;
    int N, K;
    string S;
    cin >> N;
    cin >> S;
    cin >> K;
    char s = S[K-1];
    rep(i, N){
        if(S[i] == s){
            cout<<s;
        }else{
            cout<<'*';
        }
    }
    return 0;
}


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

int main(){
  int W, H, N;
  cin >> W >> H >> N;
  int w[4] = {0,W,0,H}; // left, right, down, up

  int x,y,a;
  for (int i=0;i<N;i++){
    cin >> x >> y >> a;
    if (a<3) w[a-1] = (a==1)? max(x, w[a-1]) : min(x, w[a-1]);
    else w[a-1] = (a==3)? max(y, w[a-1]) : min(y, w[a-1]);
  }
  
  cout << max(0,w[1]-w[0])*max(0,w[3]-w[2]) << endl;


}

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=998244353;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
int h,w;
bool s[100][100];
int dp[100][100];

signed main(){
	cin>>h>>w;
	rep(i,h){
		rep(j,w){
			char c;
			cin>>c;
			if(c=='.')s[i][j]=true;
			else s[i][j]=false;
		}
	}
	rep(i,h){
		rep(j,w){
			dp[i][j]=INF;
		}
	}
	dp[h-1][w-1]=0;
	for(int i=h-1;i>=0;i--){
		for(int j=w-1;j>=0;j--){
			if(i==h-1&&j==w-1)continue;
			if(i!=h-1){
				if(s[i][j]==true&&s[i+1][j]==false)chmin(dp[i][j],dp[i+1][j]+1);
				else chmin(dp[i][j],dp[i+1][j]);
			}
			if(j!=w-1){
				if(s[i][j]==true&&s[i][j+1]==false)chmin(dp[i][j],dp[i][j+1]+1);
				else chmin(dp[i][j],dp[i][j+1]);
			}
		}
	}
	if(s[0][0]==false)cout<<dp[0][0]+1<<endl;
	else cout<<dp[0][0]<<endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
template <typename T> T max(T, T);
int gcd(int a, int b);

int mo1[4] = {-1, 0, 0, 1};
int mo2[4] = {0, -1, 1, 0};
int h, w;
vector<string> s;
queue<pair<int, int>> q;

void del() {
    while (q.size()) {
        int y = q.front().first;
        int x = q.front().second;
        q.pop();
        s[y][x] = '.';

        rep(i, 4) {
            int ny = y + mo1[i];
            int nx = x + mo2[i];
            if (0 <= ny && ny < h && 0 <= nx && nx < w) {
                if (s[ny][nx] == '#') {
                    q.push(make_pair(ny, nx));
                    s[ny][nx] = '.';
                }
            }
        }
    }
}

int main() {
    // source
    cin >> h >> w;
    string temp;
    rep(i, h) {
        cin >> temp;
        s.push_back(temp);
    }

    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '#') {
                bool flag = true;
                rep(l, 4) {
                    int y = i + mo1[l];
                    int x = j + mo2[l];

                    if (0 <= y && y < h && 0 <= x && x < w) {
                        if (s[y][x] == '#') {
                            flag = false;
                            q.push(make_pair(y, x));
                        }
                    }
                }
                if (flag) {
                    cout << "No" << endl;
                    return 0;
                } else {
                    del();
                }
            }
        }
    }

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

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T max(T a, T b) {

    if (a > b) {
        return a;
    } else {
        return b;
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == 'o') ++counter;
    if (s[1] == 'o') ++counter;
    if (s[2] == 'o') ++counter;
    cout << counter * 100 + 700 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}

int main() {
    ll K, X;
    cin >> K >> X;
    ll l = -1000000;
    ll l2 = X - K + 1;
    if(l<l2)
        l = l2;
    ll r = 1000000;
    ll r2 = X + K - 1;
    if(r>r2)
        r = r2;
    for(int i = l; i < r;++i){
        cout << i << " ";
    }
    cout << r << endl;
}


Measured memory_bytes: 888
S = input()
N = int(input())
T = [S*i + "#" for i in range(1,5)]
F = [0]*4
for i in range(len(T)) :
    t = T[i]
    acc = 0
    c = 1
    for j in range(1,len(t)) :
        if t[j] == t[j-1] :
            c += 1
        else :
            acc += c//2
            c = 1
    F[i] = acc

if N <= 4 :
    ans = F[N-1]
elif N % 2 == 1 :
    d = F[2] - F[0]
    ans = F[2] + d * ((N-3)//2)
else :
    d = F[3] - F[1]
    ans = F[3] + d * ((N-4)//2)

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
main(){
  int n;cin>>n;
  int a[101010][3],dp[101010][3];
  for(int i=0;i<n;i++) cin>>a[i][0]>>a[i][1]>>a[i][2];
  for(int j=0;j<3;j++) dp[0][j]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      dp[i+1][j]=a[i][j]+max(dp[i][(j+1)%3],dp[i][(j+2)%3]);
    }
  }
  int ans=0;
  for(int i=0;i<3;i++) ans=max(ans,dp[n][i]);
  cout<<ans<<endl;
}


Measured memory_bytes: 2688
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():
    INF = 999999999999999999999999
    MOD = 10**9+7

    n = int(input())
    n = n%1000
    if n==0:
        print(0)
    else:
        print(1000-n)

main()

Measured memory_bytes: 67608
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int a[101][101], b[101][101];
	long long c[101][101], s;
	int i, j, k;
	int n, m, l;

	scanf("%d %d %d", &n, &m, &l);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
		    scanf("%d", &a[i][j]);
		}
	}
	for (i = 0; i < m; i++) {
		for (j = 0; j < l; j++) {
		    scanf("%d", &b[i][j]);
		}
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			s = 0;
			for (k = 0; k < m; k++) {
				s += a[i][k] * b[k][j];
			}
			c[i][j] = s;
		}
	}

	for (i = 0; i < n; i++) {
		printf("%lld", c[i][0]);
		for (j = 1; j < l; j++) {
		    printf(" %lld", c[i][j]);
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,n) for(int i=a;i<n;++i)
typedef vector<int> vi;
typedef long long ll;
const int mod=1e9+7;
 
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

void solve(){
	ll a,b,k;
	cin>>a>>b>>k;
	cout<<max(a-k,0ll)<<' '<<max(b-max(0ll,k-a),0ll);
 
}
 
 
int main(){
	Blue;
	int test=1;
	//cin>>test;
	while(test--)
		solve();
	return 0;
}

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

using namespace std;

int main()
{
    int r, c;
    cin >> r >> c;
    vector<vector<int>> s(r + 1, vector<int>(c + 1, 0));

    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            cin >> s[i][j];
            s[i][c] += s[i][j];
            s[r][j] += s[i][j];
        }
    }

    for (int i = 0; i < c; i++)
    {
        s[r][c] += s[r][i];
    }

    for (int i = 0; i <= r; i++)
    {
        cout << s[i][0];
        for (int j = 1; j <= c; j++)
        {
            cout << " " << s[i][j];
        }
        cout << endl;
    }

    return 0;
}


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

template <class T>
struct Matrix {
  vector<vector<T>> A;
  Matrix() {}
  Matrix(size_t m, size_t n) : A(m, vector<T>(n, 0)) {}
  Matrix(size_t n) : A(n, vector<T>(n, 0)) {}
  size_t height() const { return (A.size()); }
  size_t width() const { return (A[0].size()); }
  inline const vector<T> &operator[](int k) const {
    return (A.at(k));
  }
  inline vector<T> &operator[](int k) { return (A.at(k)); }
  static Matrix E(size_t n) {
    Matrix mat(n);
    for(int i = 0; i < n; ++i) mat[i][i] = 1;
    return (mat);
  }
  Matrix &operator+=(const Matrix &B) {
    size_t m = height(), n = width();
    assert(m == B.height() && n == B.width());
    for(int i = 0; i < m; ++i)
      for(int j = 0; j < n; ++j) (*this)[i][j] += B[i][j];
    return (*this);
  }
  Matrix &operator-=(const Matrix &B) {
    size_t m = height(), n = width();
    assert(m == B.height() && n == B.width());
    for(int i = 0; i < m; ++i)
      for(int j = 0; j < n; ++j) (*this)[i][j] -= B[i][j];
    return (*this);
  }
  Matrix &operator*=(const Matrix &B) {
    size_t m = height(), n = B.width(), p = width();
    assert(p == B.height());
    vector<vector<T>> C(m, vector<T>(n, 0));
    for(int i = 0; i < m; ++i)
      for(int k = 0; k < p; ++k) {
        T tmp = (*this)[i][k];
        for(int j = 0; j < n; ++j) C[i][j] += tmp * B[k][j];
      }
    A.swap(C);
    return (*this);
  }
  Matrix &operator^=(long long k) {
    Matrix B = Matrix::E(height());
    while(k) {
      if(k & 1) B *= *this;
      *this *= *this;
      k >>= 1;
    }
    A.swap(B.A);
    return (*this);
  }

  Matrix operator+(const Matrix &B) const {
    return (Matrix(*this) += B);
  }
  Matrix operator-(const Matrix &B) const {
    return (Matrix(*this) -= B);
  }
  Matrix operator*(const Matrix &B) const {
    return (Matrix(*this) *= B);
  }
  Matrix operator^(const long long k) const {
    return (Matrix(*this) ^= k);
  }
  friend ostream &operator<<(ostream &os, Matrix &p) {
    size_t m = p.height(), n = p.width();
    for(int i = 0; i < m; i++) {
      os << "[";
      for(int j = 0; j < n; j++) {
        os << p[i][j] << (j + 1 == n ? "]\n" : ",");
      }
    }
    return (os);
  }
};

long long n, m, l;
Matrix<long long> mat, tmp;

int main() {
  cin >> n >> m >> l;
  mat = Matrix<long long>(n, m);
  tmp = Matrix<long long>(m, l);

  for(int i = 0; i < n; ++i)
    for(int j = 0; j < m; ++j) cin >> mat[i][j];
  for(int i = 0; i < m; ++i)
    for(int j = 0; j < l; ++j) cin >> tmp[i][j];
  mat *= tmp;
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < l; ++j) {
      if(j != 0) cout << " ";
      cout << mat[i][j];
    }
    cout << endl;
  }
  return 0;
}


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

int main(){
	ll n,c,k;cin>>n>>c>>k;
	vector<ll> t(n);
	for(int i = 0; i < n; i++) {
		cin>>t[i];
	}
	sort(ALL(t));
	ll tmp = t[0] + k;
	ll ans = 1;
	ll res = 0;
	for(int i = 1; i < n; i++) {
		if (ans < c && t[i] <= tmp){
			ans++;
		}
		else{
			res += (ans + c - 1) / c;
			tmp = t[i] + k;
			ans = 1;
		}
	}
	res += (ans + c - 1) / c;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys
input=sys.stdin.buffer.readline
from heapq import heappop,heappush
N,M,S=map(int,input().split())
graph=[[]for _ in range(N)]
for _ in range(M):
  u,v,a,b=map(int,input().split())
  graph[u-1].append((v-1,a,b))
  graph[v-1].append((u-1,a,b))
cd=[tuple(map(int,input().split())) for _ in range(N)]
INF=1e18
S=min(S,2500)
time=[[INF]*2501 for _ in range(N)]
q=[(0,0,S)]
while q:
  now_time,cur_city,cur_coin=heappop(q)
  for nxt_city,cost,dt in graph[cur_city]:
    if cur_coin>=cost and time[nxt_city][cur_coin-cost]>now_time+dt:
      time[nxt_city][cur_coin-cost]=now_time+dt
      heappush(q,(now_time+dt,nxt_city,cur_coin-cost))
  c,d=cd[cur_city]
  new_coin=min(2500,cur_coin+c)
  nxt_time=now_time+d
  if nxt_time<time[cur_city][new_coin]:
    time[cur_city][new_coin]=nxt_time
    heappush(q,(nxt_time,cur_city,new_coin))
for i in range(1,N):
  print(min(time[i]))

Measured memory_bytes: 26172
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      if (i % 2 == 0) continue;
      int count = 0;
      for (int j = 1; j <= i; j++) {
        if (i % j == 0) count++;
      }
      if (count == 8) ans++;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 35560
S = list(input())
T = list(input())
ans = 10 ** 9
nowans = 0
for i in range(len(S) - len(T) + 1):
    nowans = 0
    for j in range(len(T)):
        if S[i + j] != T[j]:
            nowans += 1
    ans = min(ans,nowans)
print(ans)

Measured memory_bytes: 64988
#include <stdio.h>

int main(){
  int w, h, x, y, r;
  scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

  if((x - r) >= 0 && (x + r) <= w && (y - r) >= 0 && (y + r) <= h){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18;
struct misaka{
    int x,y;
    int cnt;
}e;
int n,m;
int sx,sy;
int ex,ey;
char g[2000][2000];
bool st[2000][2000];
int dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
ll ans=INF;
void bfs(){
    deque<misaka> q;
    q.push_front((misaka){sx,sy,0});
    while(!q.empty()){
        auto tmp=q.front();
        q.pop_front();
        int x=tmp.x;
        int y=tmp.y;
        int cnt=tmp.cnt;
        if(x==ex and y==ey){
            ans=cnt;
            return;
        }
        if(st[x][y]) continue;
        st[x][y]=true;
        for(int i=0;i<4;++i){
            int tx=x+dx[i];
            int ty=y+dy[i];
            if(tx<1 || tx>n || ty<1 || ty>m  || g[tx][ty]=='#') continue;
            q.push_front((misaka){tx,ty,cnt});
        }
        for(int i=x-2;i<=x+2;++i){
            for(int j=y-2;j<=y+2;++j){
                if(i<1 || i>n || j<1 || j>m  || g[i][j]=='#') continue;
                q.push_back((misaka){i,j,cnt+1});
            }
        }
    }
}

int main() {
    cin>>n>>m>>sx>>sy>>ex>>ey;
    for(int i=1;i<=n;++i){
        scanf("%s",g[i]+1);
    }
    bfs();
    if(ans==INF) puts("-1");
    else printf("%d",ans);
    return 0;
}

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

#define ll long long
#define ld long double
#define ii pair<int ,int >
#define S second
#define F first
#define PI 3.1415926535897932384626
#define SPEED std::ios_base::sync_with_stdio(false);

int main(){
    SPEED
    ll n;
    cin>>n;
    cout<<n*n*3;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define int long long int
#define mod 998244353
int power(int a,int b)
{
	if(b==0)
	  return 1;
    else
    {
		int r=power(a,b/2);
		r=r%mod;
		r=r*r;
		r=r%mod;
		if(b%2==0)
		   return r;
		else
		{
			r=r*a;
			r=r%mod;
			return r;
		}
	}
}
int32_t main()
{
    int x;
    cin>>x;
    int answer=1000*(x/500);
    x%=500;
    answer+=5*(x/5);
    cout<<answer<<endl; 
}


Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
#include<limits>
#include<iomanip>
#include<set>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 100000000
#define NUM 1000000007

string s;
int stsize = 0;
ll sum = 0;
ll ans=0;
ll dfs(ll sum, ll cord, int i);

int len_s = 0;
int main() {
	cin >> s;
	stsize = s.size();
	dfs(sum,s[0]-'0',1);
	cout << ans << endl;
	return 0;
}

ll dfs(ll sum, ll cord, int i) {
	if (i == stsize) {
		ans += sum+cord;
		return 0;
	}

	dfs(sum+cord, s[i] - '0', i + 1);
	dfs(sum,cord*10+(s[i]-'0'), i + 1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "\t" << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl << "\t", dump_func(__VA_ARGS__);
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  int H, W, N; cin >> H >> W >> N;
  int ans = W - 1;
  VVI bs(H);
  REP (i, N) {
    int y, x; cin >> y >> x;
    y--;
    x--;
    bs[y].push_back(x);
  }
  REP (i, H) {
    sort(ALL(bs[i]));
  }
  int r = 0;
  REPI (i, 1, H) {
    if (bs[i].size() == 0) {
      r++;
      continue;
    }
    if (bs[i][0] <= r) {
      cout << i << endl; return 0;
    }
    if (bs[i][0] > r + 1) {
      r++;
    }
  }
  cout << H << endl;
}


Measured memory_bytes: 11264
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	
	void doIt(){
		Person [] record = new Person[24];
		for(int i=0;i<24;i++){
			record[i] = new Person(sc.nextInt(),sc.nextDouble());
		}
		Arrays.sort(record,0,7);
		System.out.println(record[0].toString() + "\n" + record[1].toString());
		Arrays.sort(record,8,15);
		System.out.println(record[8].toString() + "\n" + record[9].toString());
		Arrays.sort(record,16,23);
		System.out.println(record[16].toString() + "\n" + record[17].toString());
		Arrays.sort(record);
		System.out.println(record[0].toString() + "\n" + record[1].toString());		
	}

	public static void main(String[] args) {
		new Main().doIt();
	}
	
	class Person implements Comparable<Person>{
		int number;
		Double time;
		Person(int number , double time){
			this.number = number;
			this.time = time;
		}
		@Override
		public String toString() {
			double record = time;
			time = 99.99;
			return number + " " + record;
		}
		@Override
		public int compareTo(Person o) {
			return time.compareTo(o.time);
		}
	}
}

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

int main() {
  int N;
  cin >> N;
  double d=0.0;
  int a;
  rep(i, N) {
    cin >> a;
    d += 1.0/a;
  }
  cout << fixed << setprecision(5) << 1 / d << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   string S;
   cin >> S;
   for (int i = 0; i < S.size(); i++) {
      if (i == 3) cout << "8";
      else cout << S[i];
   }
   cout << endl;
   return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()
tsugikuenai = 0
curr = 0

for i in range(N-1):
  curr += A[i]
  if 2*curr < A[i+1]:
    tsugikuenai = i+1
    
print(N - tsugikuenai)

Measured memory_bytes: 14276
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using ll = long long;

int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b){
    return a * b / gcd(a, b);
}

int main()
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll cn,dn,cdn;
    cn = b/c - (a-1)/c;
    dn = b/d - (a-1)/d;
    cdn = b/lcm(c,d) - (a-1)/lcm(c,d);
    ll ans = b-a+1-(cn+dn-cdn);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
n,m=map(int,input().split())
citydic={}
for i in range(m):
    p,y=map(int,input().split())
    add=[i,p,y]
    temp=citydic.get(p,[])
    temp.append(add)
    citydic[p]=temp

#print(citydic)
def make_id(p):
    dif=6-len(str(p))
    res="".join(["0" for i in range(dif)])
    return res+str(p)

ansdic={}
for key, v in citydic.items():
    l=sorted(v,key=lambda x: x[2])
    #print(l)
    for x, templ in enumerate(l,1):
        #makeid
        citynum,p,y=templ
        id1=make_id(p)+make_id(x)
        ansdic[citynum]=id1

for i in range(m):
    print(ansdic[i])


Measured memory_bytes: 56912
import itertools
import math

n = int(input())
names = []

for _ in range(n):
    names.append(input())

#名前にmarchが入っている人をカウント
march = {"M":0,"A":0,"R":0,"C":0,"H":0}

for name in names:
    if name[0] in march:
        march[name[0]]+=1
march_num = 0
for count in march.values():
    if count > 0:
        march_num += 1

if march_num >= 3:
    ans = 0
    for cap_1,cap_2,cap_3 in itertools.combinations(march,3):
        cap_1_num = march[cap_1]
        cap_2_num = march[cap_2]
        cap_3_num = march[cap_3]
        ans += cap_1_num*cap_2_num*cap_3_num

else:
    ans = 0

print(ans)

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

long long g1(long long n, int p){
    if (n == 0) return 0;
    return n/p + g1(n/p, p);
}

long long g2(long long n, int p){
    if (n%2 == 1){
        return g1(n, p) - g2(n-1, p);
    }
    long long res = g1(n/2, p);
    if (p == 2) res += n/2;
    return res;
}

int main(){
    long long n;
    cin >> n;
    long long ans = min(g2(n, 2), g2(n, 5));
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 1;
    for(int k = 1; k < n; ++k) {
        if(s[k-1] != s[k]) ans++;
    }
    cout << ans << '\n';
}

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

int N,K;
string S;

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

    for(int i=0;i<N;i++){
        if(S[i]!=S[K-1])S[i]='*';
    }
    cout<<S<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int n;cin>>n;
  int t;cin>>t;
  map<int,int> b,e;
  rep(i,n){
    int l,r;cin>>l>>r;
    b[l]++;e[r]++;
  }
  int co=0;
  int m=0;
  rep(i,t){
    co+=b[i];
    co-=e[i];
    m=max(m,co);
  }
  cout<<m<<endl;
  return 0;
}


Measured memory_bytes: 12476
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   char c;
   cin >> c;

   if( (c == 'a') || (c == 'e') || (c == 'i') || (c == 'o') || (c == 'u')){
      cout << "vowel" << endl;
   }else{
      cout << "consonant" << endl;
   }


   return 0;
}

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

vector<int> G[100010];
int dp[100010];

int dfs(int k){
    if(dp[k] != -1) return dp[k];
    if(G[k].size() == 0) return dp[k] = 0;
    vector<int> d;
    for(int i = 0; i < G[k].size(); i++){
        d.push_back(dfs(G[k][i]));
    }
    sort(d.begin(), d.end(), greater<int>());
    int MAX = -1;
    for(int i = 0; i < d.size(); i++){
        MAX = max(MAX, d[i] + i + 1);
    }
    return dp[k] = MAX;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    memset(dp, -1, sizeof(dp));
    for(int i = 1; i < n; i++){
        cin >> a[i];
        a[i]--;
        G[a[i]].push_back(i);
    }
    cout << dfs(0) << endl;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define TEMP int
#define ordered_set tree<TEMP, null_type, less<TEMP>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

const int N = 100005;

ll p[N], q[N], r[N];

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());


    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    FOR(i,1,a){
        cin >> p[i];
    }
    FOR(i,1,b){
        cin >> q[i];
    }
    FOR(i,1,c){
        cin >> r[i];
    }
    sort(p+1,p+a+1);
    sort(q+1,q+b+1);
    vector<ll>v;
    ROF(i,a,a-x+1){
        v.pb(p[i]);
    }
    ROF(i,b,b-y+1){
        v.pb(q[i]);
    }
    FOR(i,1,c){
        v.pb(r[i]);
    }
    sort(all(v));
    reverse(all(v));
    ll ans = 0;
    FOR(i,0,x+y-1){
        ans += v[i];
    }
    cout << ans;
    
    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

Measured memory_bytes: 8560
n=int(input())
a=list(map(int,input().split()))
q=int(input())
nums=[0]*10**5
for i in a:
    nums[i-1]+=1
res=sum(a)
for i in range(q):
    b,c=map(int,input().split())
    res-=(b)*nums[b-1]
    res+=(c)*nums[b-1]
    nums[c-1]+=nums[b-1]
    nums[b-1]=0
    print(res)


Measured memory_bytes: 84256
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    prev =S[0]
    answer = 1
    for ss in S:
        if ss != prev:
            answer += 1
        prev = ss
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<stdio.h>
int a[10000000];
int erfen(int a[],int n, int key){
int mid;
int right=n;
int left=0;
while(left<right){
    mid=(left+right)/2;
    if(a[mid]>key)right=mid;
    else if(a[mid]<key)left=mid+1;
    if(a[mid]==key)return 1;
}
return 0;
}
int main(){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
}
int m;
scanf("%d",&m);
int sum=0;
int key;
for(int i=0;i<m;i++){
    scanf("%d",&key);
    if(erfen(a,n,key))sum++;
}
printf("%d\n",sum);
return 0;
}

Measured memory_bytes: 3000
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iomanip>

int calc(int a, std::string op, int b)
{
	int value;
	if (op == "+")
	{
		value = a + b;
	}
	else if (op == "-")
	{
		value = a - b;
	}
	else if (op == "*")
	{
		value = a * b;
	}
	else
	{
		value = a / b;
	}
	return value;
}

int main()
{
	int a, b;
	std::string op;
	std::vector<int> value;

	std::cin >> a >> op >> b;

	while (op != "?")
	{
		int answer = calc(a, op, b);
		value.push_back(answer);
		std::cin >> a >> op >> b;
	}

	for (auto item : value)
	{
		std::cout << item << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3144
open Batteries

let (ga, gb, gt) = match (List.map int_of_string (String.split_on_char ' ' (read_line()))) with
    [ga; gb; gt] -> (ga, gb, gt)
  | _ -> (0, 0, 0)

let calc = (gt / ga) * gb
                         
let answer = string_of_int calc

let () = print_endline answer

Measured memory_bytes: 3072
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

int main(){
    // input
    int N;
    string S, T;
    cin >> N >> S >> T;

    // out
    for( int i=0; i<N; i++ ){
        cout << S[i] << T[i];
    }
    cout << endl;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
const int N = 1300;
const int M = 256;

int main()
{
    char str[N];
    int ary[M] = {0};
    while (fgets(str, 1300, stdin))
    {
        for(int i = 0; i <strlen(str)-1; i++)
        {
            if(str[i] >= 'A' && str[i] <= 'Z')
            {
                ary[str[i]+32]++;
            }
            else
            {
                ary[str[i]]++;
            }
        }
    }
    for(int i = 'a'; i <= 'z'; i++)
    {
        printf("%c : %d\n", i, ary[i]);
    }
    return 0;
}





Measured memory_bytes: 2604
import heapq
n = int(input())
heap_a = list(map(int, input().split()))

# N＝５０だと、多くても４９
# > 愚直にやっても大丈夫なはず。なるべく早く実行するために、Heapqを使用する。

heapq.heapify(heap_a)

#tar = heapq.nsmallest(2, heap_a)
while True:
    tar1 = heapq.heappop(heap_a)
    tar2 = heapq.heappop(heap_a)

    heapq.heappush(heap_a, (tar1 + tar2) / 2.0)
    if (len(heap_a) == 1):
        break


print(heapq.heappop(heap_a))


Measured memory_bytes: 9092
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

ll sum(ll l, ll r) { return (l + r) * (r - l + 1) / 2; }

int main() {
  int n, k;
  cin >> n >> k;
  mint ans;
  for (int i = k; i <= n + 1; ++i) {
    ll l = sum(0, i - 1), r = sum(n - i + 1, n);
    ans += r - l + 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3552
n,m = map(int,input().split())
ans = "YES"
cnt = [0]*n
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    cnt[a] += 1
    cnt[b] += 1
for i in range(n):
    if cnt[i]%2 != 0:
        ans = "NO"
        break
print(ans)

Measured memory_bytes: 9616
#include<bits/stdc++.h>
using namespace std;
int a[105],n;
int f(int k)
{
    int ans=0;
    for(int i=0;i<n;i++)
        ans+=(k-a[i])*(k-a[i]);
    return ans;
}
int main()
{
    int sum=0;
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i],sum+=a[i];
    int k;
    if(sum>0) k=ceil(sum*1.0/n);
    else k=sum/n;
    int ans=1e9;
    ans=min(ans,f(k));
    ans=min(ans,f(k-1));
    ans=min(ans,f(k+1));
    printf("%d\n",ans);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static boolean linerSearch(int key, int n, int[] A) {
		int i = 0;
		A[n] = key;
		while (key != A[i]) {
			i++;
			if (i == n) {
				return false;
			}
		}
		return true;
	}

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int count = 0;
		int num1 = scanner.nextInt();
		int[] suretu1 = new int[num1 + 1];
		for (int i = 0; i < num1; i++) {
			suretu1[i] = scanner.nextInt();
		}
		int num2 = scanner.nextInt();
		int[] suretu2 = new int[num2];
		for (int i = 0; i < num2; i++) {
			suretu2[i] = scanner.nextInt();
		}
		for (int i = 0; i < num2; i++) {
			int key = suretu2[i];
			if (linerSearch(key, num1, suretu1)) {
				count++;
			}
		}
		System.out.println(count);
		scanner.close();
	}

}



Measured memory_bytes: 40328
// Template begins
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue> 
#include <string.h>
#include <string>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define sort0(v) sort(all(v))
#define lbb(a,b,arr,x) lower_bound(arr+a,arr+b+1,x)-arr
#define ubb(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-arr
#define freq(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-lower_bound(arr+a,arr+b+1,x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define printp(x) cout << x.ff << " " << x.ss << endl
 
const ll mod=998244353;
#define inf 9999999999999
#define MAXN   100001 
  
// stores smallest prime factor for every number 
 
 
ll inv(ll i){if(i==1) return 1;return (mod-((mod/i)*inv(mod%i))%mod)%mod;}
 
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b,b%a);}
inline void fastio(){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
// Template ends
const int MN = 2e5+7;

void solve(){
    int n; cin>>n;
    if(n==0) cout<<1<<endl;
    else if(n==1) cout<<0<<endl;
}
int main(){
    fastio();
    //write code
    int t; t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

typedef long long ll;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

    int ans = a + b;
    if(ans >= 24) ans = ans - 24;

    p(ans);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  long n;
  cin >> n;
  long x=n;
  cout << x << ":";int c=0;
  long k = 1;

  int i = 2;
  while(i*i<=n && k < n) {
    if (x % i == 0) {cout << " " << i;k*=i;x/=i;c++;}
    if (x % i != 0) {i++;}
  }
  if (k!=n) {
    cout << " " <<n/k;
  }


  cout << endl;
  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};

vector<vector<Edge>> g;
vector<int> ans;
const int MN = 15;
vector<int> searched(MN, 0);
vector<int> color(MN, -1);

int main() {
    int n,m; cin >> n >> m;
    vector<vector<int>> days(100000);
    rep(i,n){
        int a, b; cin >> a >> b;
        a--;
        days[a].push_back(b);
    }
    priority_queue<int> pq;
    int sum = 0;
    for (int i=0; i < m; i++) {
        for (int j=0; j < days[i].size(); j++) {
            pq.push(days[i][j]);
        }
        if (! pq.empty()) {
            int val = pq.top();
            pq.pop();
            sum += val;
        }
    }

    cout << sum << endl;

}


Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long int lli;
using namespace std;
lli LARGE_NUM = 1000000007;

lli len(int x) {
    if (x == 0) return 1LL;
    return 3LL + 2LL * len(x - 1);
}

lli p(int x) {
    if (x == 0) return 1LL;
    return 1LL + 2LL * p(x - 1);
}

lli g(int l, lli x) {
    if (l == 0) return 1LL;

    if (x == 1LL)
        return 0LL;
    lli length = len(l - 1);
    if (1LL < x && x <= length + 1LL)
        return g(l - 1, x - 1LL);
    if (x == length + 2LL)
        return p(l - 1) + 1LL;
    if (length + 2LL < x && x <= 2LL + 2LL * length)
        return p(l - 1) + 1LL + g(l - 1, x - (2LL + length));
    if (x == 3LL + 2 * length)
        return p(l);

    cout << "error: l = " << l << " x = " << x << endl;
    return 0;
}

signed main() {
    int N;
    lli X;
    cin >> N >> X;
    cout << g(N, X) << endl;
}


Measured memory_bytes: 256
def main():
    A, B = map(int, input().split(" "))
    L = []
    L.append(A)
    L.append(B)
    L.append(A - 1)
    L.append(B - 1)
    L.sort(reverse=True)
    print(L[0] + L[1])


if __name__ == '__main__':
    main()

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int N = 1e5 + 10;

int n, k, a[N]; 

int ans = 0;

int deg[N], dep[N];

int main()
{
	gii(n, k); --k;
	for (int i = 1; i <= n; ++i) gi(a[i]);
	if (a[1] != 1) ++ans, a[1] = 1;
	for (int i = 1; i <= n; ++i)
		++deg[a[i]];
	static int q[N]; int l = 0, r = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (!deg[i]) q[r++] = i;
	}
	while (l < r)
	{
		int u = q[l++];
		--deg[a[u]];
		if (!deg[a[u]]) q[r++] = a[u];
		if (dep[u] == k && a[u] != 1) a[u] = 1, ++ans;
		else dep[a[u]] = max(dep[a[u]], dep[u] + 1);
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 1792
def sieve(n):
    prime = [True] * (n+1)
    prime[0] = prime[1] = False
    for i in range(2, n+1):
        if prime[i]:
            for j in range(2*i, n+1, i):
                prime[j] = False
    return prime


MAX_A = 55555
is_prime = sieve(MAX_A)
N = int(input())
a = []
for i in range(MAX_A+1):
    if is_prime[i] and i % 5 == 1:
        a.append(str(i))
        if len(a) == N:
            break
print(' '.join(a))


Measured memory_bytes: 39920
#include <bits/stdc++.h>
#define N 22

using namespace std;

int imp[N][N];
int cost[N];
int an,bn,lim;
int eve[N];
int ans=0x7fffffff;

int main(){
  scanf("%d%d%d",&bn,&an,&lim);
  for(int i=1;i<=bn;i++){
    scanf("%d",cost+i);
    for(int j=1;j<=an;j++){
      scanf("%d",&imp[i][j]);
    }
  }
  for(int i=0;i<1<<bn;i++){
    for(int u=1;u<=an;u++)
      eve[u]=0;
    int nans=0;
    for(int j=1;j<=bn;j++){
      int k=1<<(j-1);
      if(k&i){
        nans+=cost[j];
        for(int u=1;u<=an;u++){
          eve[u]+=imp[j][u];
        }
      }
    }
    for(int u=1;u<=an;u++)
      if(eve[u]<lim)goto ot;
    ans=min(ans,nans);
    ot:;
  }
  if(ans==0x7fffffff)puts("-1");
  else cout<<ans<<endl;
}

Measured memory_bytes: 3652