akhauriyash/Code-Regression huggingface dataset:
d,g = map(int,input().split())
p,c = [],[]
ans = float('inf')
for i in range(d):
    x,y = map(int,input().split())
    p.append(x)
    c.append(y)
for i in range((1<<d)):
    tmp,cnt = 0,0
    for j in range(d):
        if i&(1<<j):
            tmp = tmp + 100*(j+1)*p[j]+c[j]
            cnt += p[j]
    if tmp>=g:
        if cnt<ans: ans=cnt
    else:
        for j in range(d-1,-1,-1):
            if i&(1<<j): continue
            for k in range(p[j]):
                if tmp>=g: break
                tmp = tmp + 100*(j+1)
                cnt+=1
        if cnt<ans: ans = cnt
print(ans)

Measured memory_bytes: 9160
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
void cmx(lint&x,lint y){if(x<y)x=y;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint inf=numr<lint>::max();
    lint n;std::cin>>n;
    std::vector<lint>a(n+4);
    for(lint i=2;i<n+2;i++){
        std::cin>>a.at(i);
    }
    n+=4;
    std::vector<std::array<lint,3>>dp(n,std::array<lint,3>{-inf,-inf,-inf});
    dp.at(0).at(0)=0;
    for(lint i=0;i<n;i++){
        for(lint j=0;j<3;j++){
            if(dp.at(i).at(j)==-inf)continue;
            for(lint k=0;j+k<3&&i+2+k<n;k++){
                cmx(dp.at(i+2+k).at(j+k),dp.at(i).at(j)+a.at(i+2+k));
            }
        }
    }
    std::cout<<dp.at(n-1).at(1+n%2)<<'\n';
}


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

int main() {
    char x, y;
    cin >> x >> y;
    if(x < y){
        cout << "<" << endl;
    }else if(x > y){
        cout << ">" << endl;
    }else{
        cout << "=" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())

list_0=[]

for i in range(N):
  W = str(input())
  if W in list_0:
    print('No')
    exit()
  else:
    list_0.append(W)

for _ in range(N-1):
  if list_0[_][len(list_0[_])-1]==list_0[_+1][0]:
    pass
  else:
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 9132
H,W=map(int,input().split())
N=int(input())
a=list(map(int,input().split()))
answers=[[0 for _ in range(W)] for _ in range(H)]
h=0
w=0
number=1
for a_ in a:
    for _ in range(a_):
        answers[h][w] = number
        if w>=0:
            w+=1
        else:
            w-=1
        if w==W:
            h+=1
            w=-1
        elif w==-W-1:
            h+=1
            w=0
    number+=1
for answer in answers:
    print(*answer)


Measured memory_bytes: 74516
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int tp[100010];
int main(void){
	int n,i,j,k;
	int p[20];
	p[1]=1;
	p[2]=6;
	p[3]=9;
	p[4]=36;
	p[5]=81;
	p[6]=216;
	p[7]=729;
	p[8]=36*36;			// 1296,6^4
	p[9]=81*81;			// 6561,9^4
	p[10]=36*216;		// 7776,6^5
	p[11]=216*216;		// 46656,6^6
	p[12]=81*729;		// 59049,9^5
	p[13]=216*216*6;	// 
	p[14]=729*729;		// 
	cin>>n;
	for(i=0;i<=100005;i++){
		tp[i]=99999;
	}
	tp[0]=0;
	for(i=1;i<=13;i++){
		for(j=0;j+p[i]<=n;j++){
			tp[j+p[i]]=min(tp[j+p[i]],tp[j]+1);
		}
	}
	printf("%d\n",tp[n]);

	return 0;
}


Measured memory_bytes: 640
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())
inline void Fail(){
	printf("No");
	exit(0);
}
string t="YAKI";
string s;
int main(){
	cin>>s;
	if(s.size()<=3)Fail();
	rep(i,4)if(s[i]!=t[i])Fail();
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;
const ll INF = 0x3f3f3f3f3f3f3f3f;
#define DEBUG(x) cout << (x) << '\n'
#define fi first
#define se second

int n, a[MAXN];
void run(){
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    priority_queue< pair<int, int> > q;
    q.push(make_pair(a[n-1], a[n-1]));
    ll ans = 0;
    for(int i = n - 2; ~i; i--){
        int x = a[i];
        auto p = q.top(); q.pop();
        ans += p.fi;
        if(x >= p.fi) q.push(make_pair(p.fi, x));
        else q.push(make_pair(x, p.fi));
        if(x >= p.se) q.push(make_pair(p.se, x));
        else q.push(make_pair(x, p.se));
    }
    cout << ans;
}
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
    ios::sync_with_stdio(false);

    run(); return 0;
}


Measured memory_bytes: 6164
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	ll n,j,h,l=0,cnt=0,max_cnt=0;
    cin>>n;
    while(n--)
    {
        cin>>h;
        if(h<=l)
            cnt++;
        else
            cnt=0;
        l=h;
        max_cnt=max(max_cnt,cnt);
    }
    cout<<max_cnt;
}

Measured memory_bytes: 256
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-26 20:39:54
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

  int s, w; cin >> s >> w;

  if (w >= s) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }

  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  ll n,a,ans=0;
  cin>>n>>a;
  int x[50];
  ll dp[55][5100];
  //center 2550
  rep(i,n){
    cin>>x[i];
    x[i]-=a;
  }
  rep(i,55){
    dp[i][0]=0;
  }
  dp[0][x[0]+2550]=1;
  repi(i,1,n){
    dp[i][x[i]+2550]=1;
    rep(j,5000){
      dp[i][j]+=dp[i-1][j-(x[i])];
      dp[i][j]+=dp[i-1][j];
    }
   
  }
   
  rep(i,n){
    ans+=dp[i][2550];
  }
  
  cout<<dp[n-1][2550]<<endl;

  return 0;
}







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

int n;
long long arr[55],ans,step;

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++) scanf("%lld",&arr[i]);
  while(true){
    int flag = 0;
    for(int i=0;i<n;i++){
      long long tmp = arr[i]/n;
      arr[i]-=tmp*n;
      ans+=tmp;
      if(tmp>0) flag=1;
      else continue;
      for(int j=0;j<n;j++){
        if(i==j) continue;
        arr[j]+=tmp;
        step++;
      }
    }
    if(!flag) break;
  }
  printf("%lld",ans);
}

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

void solve() {
	int n, p;
	cin >> n >> p;
	int odd = 0, even = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (x % 2 == 0) even += 1;
		else odd += 1;
	}
	if (odd > 0) cout << (1ll << (odd - 1)) * (1ll << even);
	else cout << (p == 0 ? (1ll << even) : 0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int  main()
{
	int N,W;
  	cin >> N >> W;
  	long long weight[N];
  	long long value[N];
  	for(int i=0;i<N;i++)
    {
      cin >> weight[i] >> value[i];
    }
  
  	long long dp[N+1][W+1];
  	for(int i=0;i<=N;i++)
    {
    	for(int j=0;j<=W;j++)
        {
          if(i==0 || j==0)
            dp[i][j]=0;
          else if(j>=weight[i-1])
          {
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-weight[i-1]]+value[i-1]);
          }
          else
            dp[i][j]=dp[i-1][j];
        }
    }
  
  cout << dp[N][W];
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<int Mod> class ModInt {
  int v;
public:
  constexpr ModInt(const long long x = 0) noexcept : v((x % Mod + Mod) % Mod) {};
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    v += rhs.v;
    if (v >= Mod)
      v -= Mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (v < rhs.v)
      v += Mod;
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    v = int(1LL * v * rhs.v % Mod);
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1)
        *this *= rhs;
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  constexpr ModInt operator-() const noexcept { return ModInt(-v); }
  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr bool operator==(const ModInt rhs) const noexcept {
    return v == rhs.v;
  }
  constexpr bool operator!=(const ModInt rhs) const noexcept {
    return v != rhs.v;
  }
  constexpr ModInt pow(long long exp) const noexcept {
    ModInt res(1), mul(v);
    while (exp) {
      if (exp & 1)
        res *= mul;
      mul *= mul;
      exp >>= 1;
    }
    return res;
  }
  friend ostream &operator<<(ostream &os, const ModInt obj) noexcept {
    return os << obj.v;
  }
  friend istream &operator>>(istream &is, ModInt &obj) noexcept {
    long long tmp;
    is >> tmp;
    obj = ModInt<Mod>(tmp);
    return is;
  }
};
constexpr int MOD = 998244353;
using mint = ModInt<MOD>;

const int MAX = 2000100;
long long fac[MAX], finv[MAX], inv[MAX];
void init_comb() {
  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;
  }
}
long long comb(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  init_comb();
  int n, m, k;
  cin >> n >> m >> k;
  vector<mint> fact(n+1);
  fact[1] = m;
  for (int i = 2; i <= n; i++)
    fact[i] = fact[i-1]*(m-1);
  mint ans = 0;
  rep(i, k+1)
    ans += fact[n-i]*comb(n-i-1+i, i);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 50964
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int dan = 0;
  bool hasnext;
  int base = 0;
  int nextbase = 0;
  int nextat = 0;
  
  cin >> N;
  vector<int> mochi(N);
  vector<bool> picked(N);
  
  for(int i = 0; i < N; i++){
    cin >> mochi.at(i);
    if(base < mochi.at(i))
      base = mochi.at(i);
  }
  while(dan < N){
    hasnext = false;
    for(int i = 0; i < N; i++){
    	if(!picked.at(i) && base > mochi.at(i) && nextbase < mochi.at(i)){
          hasnext = true;
    	  nextbase = mochi.at(i);
     	  nextat = i;
   		}
    }
    if(hasnext){
	    base = mochi.at(nextat);
    	picked.at(nextat) = true;
      nextbase = 0;
    	dan++;
    }
    else break;
  }
  
  cout << dan + 1 << endl;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

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

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

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

    var(i64, a, b);
    print(a / __gcd(a, b) * b);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int mod=998244353;
int main(){
    ll n;cin>>n;
    ll ans=0;
    vector<vector<pll> >a(n+1);
    rep(i,n){
        ll b;cin>>b;
        rep(j,b){
            ll c,d;cin>>c>>d;
            a[i+1].pb(mp(c,d));
        }
    }
    rep(i,1<<n){
        bool f=1;
        ll cnt=0;
        rep(j,n){
            bool t=((1<<j)&i);
            if(t)cnt++;
            for(auto e:a[j+1]){
                ll k=e.first;
                if(t){
                    if(e.second){
                        if((1<<(k-1))&i);
                        else f=0;
                    }else{
                        if((1<<(k-1))&i)f=0;
                    }
                }
            }
        }
        if(f)ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}

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

int main(void)
{
    int a, b, result;
    cin >> a >> b;

    if (a > b) {
        result = a + a - 1;
    } else if (a < b) {
        result = b + b - 1;
    } else {
        result = a + b;
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
    int n;
    while(cin >> n){
    int cnt = 0;
    for(int i = 0; i <= 9; i++){
	  for(int j = 0; j <= 9; j++){
		for(int k = 0; k <= 9; k++){
		  for(int l = 0; l <= 9; l++){
			  cnt += (i + j + k + l == n);  
			}
		  }  
	   }	
	}
  cout << cnt << endl;
  }
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3128
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def main():
    N, K, Q = LI()
    points = [0] * N
    A = []
    for _ in range(Q):
        a = I()
        points[a-1] += 1
    for i in range(N):
        if K + points[i] - Q > 0:
            print("Yes")
        else:
            print("No")

main()



Measured memory_bytes: 7100
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1000000007, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}
 

 
signed main(){
	int N;
	cin >> N;
	vector<int> a(N); for(auto& e:a)cin >> e;
	REP(i,N){
		FOR(j,i,N){
			swap(a[i],a[j]);
			int flg = 1;
			REP(k,N-1)if(a[k]>a[k+1])flg = 0;
			if(flg){
				cout<<"YES"<<endl;
				return 0;
			}
			swap(a[i],a[j]);
		}
	}
	cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
#include <limits>
using namespace std;
typedef long long ll;

float inf = std::numeric_limits<float>::infinity();

/* 二次元配列の宣言
  vector<vector<int>> tb;
  tb.resize(H);
  for (size_t i = 0; i < H; i++) {
    tb[i].resize(W);
  }
*/
/*
  A.resize(N);
  for (int i = 0; i < N; i++) {scanf("%d",&A[i]);}
*/

int main(void) {
  string a,x,b;
  cin >> a >> x >> b;

  cout << a[0] << x[0] << b[0] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cis(s);
    cis(t);
    cii(a);
    cii(b);
    cis(u);
    if(s==u){
        a--;
    }else{
        b--;
    }
    co(to_string(a) + " " + to_string(b));
    return 0;
}

Measured memory_bytes: 256
def max_heapify(A, i):
    left_id = 2 * i
    right_id = left_id + 1

    largest_id = i
    if left_id <= len(A) and A[left_id - 1] > A[largest_id - 1]:
        largest_id = left_id
    if right_id <= len(A) and A[right_id - 1] > A[largest_id - 1]:
        largest_id = right_id
    
    if i != largest_id:
        A[i - 1], A[largest_id - 1] = A[largest_id - 1], A[i - 1]
        max_heapify(A, largest_id)


import sys

heap_size = int(input())
A = list(map(int, sys.stdin.readline().split()))
for i in range(heap_size // 2, 0, -1):
    max_heapify(A, i)
print('', *A)


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

namespace _167.B
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var i = Console.ReadLine()
                .Split()
                .Select(int.Parse)
                .ToList();
            var (a, b, c, k) = (i[0], i[1], i[2], i[3]);
            k -= a;
            if (k <= 0) Console.WriteLine(k + a);
            else
            {
                k -= b;
                if (k <= 0) Console.WriteLine(a);
                else
                {
                    Console.WriteLine(a - k);
                }
            }
        }
    }
}

Measured memory_bytes: 18876
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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


int main(void) {
	string s;
	int n, k;

	cin >> n >> k;
	cin >> s;

	s[k - 1] = s[k - 1] - 'A' + 'a';

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,r; cin >> n >> r;
    if(n >= 10) OUT(r);
    else OUT(r+100*(10-n));

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

long long int solve(string s)
{
	for(int i=0;i<s.length();i++)
	{
		int min=i;
		for(int j=i;j<s.length();j++)
		{
			if(s[min]-'0'>s[j]-'0')
			{
				min=j;
			}
		}
		char tmp=s[i];
		s[i]=s[min];
		s[min]=tmp;
	}
	long long int min,max;
	min=max=0;
	for(int i=0;i<s.length();i++)
	{
		max+=(long long int)pow(10.0,i)*(s[i]-'0');
		min+=(long long int)pow(10.0,i)*(s[s.length()-i-1]-'0');
	}
	return max-min;
}

int main(void)
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		cout<<solve(s)<<endl;;
	}
	return 0;
}

Measured memory_bytes: 1252
n, s = int(input()), input()

ans = ["" for i in range(n)]


def solve():
    for i in range(n-2):
        if s[i] == "o" and ans[i] == "S" or s[i] == "x" and ans[i] == "W":
            ans[i+1] = ans[i-1]
        elif ans[i-1] == "S":
            ans[i+1] = "W"
        else:
            ans[i+1] = "S"

    for i in range(n):
        if s[i-1] == "o" and ans[i-1] == "S" and ans[i-2] == ans[i]:
            continue
        if s[i-1] == "x" and ans[i-1] == "S" and ans[i-2] != ans[i]:
            continue
        if s[i-1] == "o" and ans[i-1] == "W" and ans[i-2] != ans[i]:
            continue
        if s[i-1] == "x" and ans[i-1] == "W" and ans[i-2] == ans[i]:
            continue

        return False

    return True


def main():
    ans[0] = ans[-1] = "S"
    if solve():
        print("".join(ans))
        exit()

    ans[0], ans[-1] = "S", "W"
    if solve():
        print("".join(ans))
        exit()

    ans[0], ans[-1] = "W", "S"
    if solve():
        print("".join(ans))
        exit()

    ans[0] = ans[-1] = "W"
    if solve():
        print("".join(ans))
        exit()

    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

class BIT{
public:
  int n,bit[1111111];
  BIT(){fill(bit,bit+1111111,0);}
  void add(int i,int x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  int sum(int i){
    int s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
};

void Main() {
  BIT t=BIT();
  t.n=1000010;
  int n;
  R n;
  while(n--) {
    int x;
    R x;
    x++;
    if(t.sum(1)) pr("No");
    else if(x>1000000) {
      pr("Yes");
      t.add(1000001,1);
    } else if(t.sum(x)==x-1&&t.sum(1000001)>x-1) pr("No");
    else {
      pr("Yes");
      while(t.sum(x)-t.sum(x-1)) t.add(x--,-1);
      t.add(x,1);
    }
  }
}

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


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  REP(i,N) {
    cin >> P[i];
    --P[i];
  }

  vector<int> pos(N);
  REP(i,N) pos[P[i]] = i;

  UnionFind uf(N);
  REP(i, N - 1) if(pos[i] < pos[i + 1]) uf.unionSet(i, i + 1);

  int ret = N;
  REP(i,N) ret = min(ret, N - uf.size(i));
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 2560
#include <stdio.h>
 
int main()
{
  int i, j, k, n;
  int a[3][3], b[10];
  for(i = 0; i < 3; i++){
    for(j = 0; j < 3; j++){
      scanf("%d", &a[i][j]);
    }
  }
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &b[i]);
    for(j = 0; j < 3; j++){
      for(k = 0; k < 3; k++){
        if(b[i] == a[j][k]){
          a[j][k] = 0;
          goto OUT;
        }
      }
    }
    OUT:
    ;
  }
  for(i = 0; i < 3; i++){
    if(a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0){
      printf("Yes\n");
      return 0;
    }
    if(a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0){
      printf("Yes\n");
      return 0;
    }
  }
  if((a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) || (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0)){
    printf("Yes\n");
      return 0;
  }
  printf("No\n");
  
  return 0;
}

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

using namespace std;

#define int long long 
#define INF 21000000000

bool cmp(int a,int b){
		return a >= b;
}

signed main(){
		int n,m;
		cin >> n >> m;
		priority_queue<int> a;
		int sum = 0;
		for(int i=0;i<n;i++){
				int tmp;
				cin >> tmp;
				a.push(tmp);
				sum += tmp;
		}
		for(int i=0;i<m;i++){
				int tmp = a.top();
				sum -= tmp - tmp/2;
				a.pop();
				a.push(tmp/2);
		}
		cout << sum << endl;
}



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

long long int mod = 1000000007;

vector<long long int> c(100010);
long long int fib(long long int n)
{
    if (n == 0)
        return 0;
    if (n == 1)
        return 1;
    if (c[n - 2] == -1)
        c[n - 2] = fib(n - 2);
    if (c[n - 1] == -1)
        c[n - 1] = fib(n - 1);
    return (c[n - 2] + c[n - 1]) % mod;
}

int main()
{
    long long int n, m, ans = 1;
    vector<long long int> a;
    cin >> n >> m;
    c[0] = 0;
    c[1] = 1;
    for (long long int i = 2; i < 100010; i++)
    {
        c[i] = (c[i - 1] + c[i - 2]) % mod;
    }
    a.resize(m + 2);
    a[0] = -1;
    a[m + 1] = n + 1;
    for (long long int i = 1; i < m + 1; i++)
    {
        cin >> a[i];
    }
    for (long long int i = 0; i <= m; i++)
    {
        long long int diff = a[i + 1] - a[i] - 1;
        ans = (ans * fib(diff)) % mod;
        // cout << diff << " " << fib(diff) << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
S = list(input() for i in range(N))
march = "MARCH"
A = [0]*5
for i in S:
    if i[0] in march:
        A[march.index(i[0])]+=1
ans = 0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans += A[i]*A[j]*A[k]
print(ans)

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

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define debug(x) cerr << (#x) << "is "<< x << "\n"

using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

int32_t main(){
	ios::sync_with_stdio(NULL);
	cin.tie(NULL);
	string s;
	cin >> s;
	int n=s.length();
	int ans=0;
	f(i,0,n){
		if(s[i]=='o') ans++;
	}
	ans=ans+(15-(int)s.length());
	if(ans>=8) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
MOD = 10**9+7
dp = [[0]*1100 for _ in range(1100)]
H, W = input_nums()
a = []
for i in range(H):
    a.append(input())

dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if i+1 < H and a[i+1][j] == '.':
            dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD
        if j+1 < W and a[i][j+1] == '.':
            dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % MOD
print(dp[H-1][W-1])

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

#define int long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pi acos(-1.0)

void solve();
int32_t main()
{
    IOS;
    string s;
    cin >> s;
    vector<int>v;
    int cnt = 0;
    for(int i=0;i<s.size();i++){
        if(s[i] == 'S'){
            if(cnt != 0){
                v.push_back(cnt);
                cnt = 0;
            }
        }
        else{
            cnt++;
        }
    }
    if(cnt != 0){
        v.push_back(cnt);
    }
    sort(v.rbegin(),v.rend());
    cnt = 0;
    //cnt = v[0];
    if(v.size()==0)
        cnt = 0;
    else
        cnt = v[0];
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
//x.substr(start, length);
/*
// Create a vector containing n 
//vectors of size m.  
    vector<vector<int> > vec( n , vector<int> (m, 0));  
*/
struct type{
    int k, i, j;
};
//to check if a no is prime or not?
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; 
}

// minimum subaaray sum of size k-sliding window approach
int findSubarray(int arr[], int n, int k)
{
	int window_sum = 0;
	int min_window = INT_MAX;
	int last = 0;
	for (int i = 0; i < n; i++)
	{
		window_sum += arr[i];
		if (i + 1 >= k)
		{
			if (min_window > window_sum)
			{
				min_window = window_sum;
				last = i;
			}
			window_sum -= arr[i + 1 - k];
		}
	}
	int sum=0;
	for(int i=last-k+1;i<=last;i++)
	{
	    sum+=arr[i];
	}
	return sum;
}
signed main() 
{
    fastio;
    //cout << fixed << setprecision(0);
    int n,k,s;
    cin>>n>>k>>s;
    if(s==1000000000)
    {
        f(i,k)cout<<s<<" ";
        f(i,n-k)cout<<1<<" ";
    }
    else
    {
        f(i,k)cout<<s<<" ";
        f(i,n-k)cout<<1000000000<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int a,b,n;
	cin>>a>>b>>n;
	if(a>=2*b){
		cout << ((n+499)/500)*b << endl;
	}else{
		cout << min(((n+999)/1000)*a,(n/1000)*a+((n-(n/1000)*1000 + 499)/500)*b) << endl;
	}

	return 0;
}


Measured memory_bytes: 3108
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
ll solve(){
    ll res = 0;
    ll H,W; cin >> H >> W;
    vector<vector<ll>> M(H+2,vector<ll>(W+2,LINF));
    vector<pll> Section(H*W);
    for(int i = 1; i <= H;i++){
        for(int j = 1; j <= W;j++){
            ll x; cin >> x; x--;
            M[i][j] = x;
            Section[x] = {i,j};
        }
    }
    
    vector<vector<ll>> flag(H+2,vector<ll>(W+2,-1));
    int id = 0;
    int d[4] = {1,0,-1,0};
    for(int i = 0; i < H*W;i++){
        ll x,y; tie(x,y) = Section[i];
        
        vector<ll> F;
        for(int k = 0; k < 4;k++){
            ll nx = x + d[k];
            ll ny = y + d[k^1];
            if(M[nx][ny] < M[x][y]){
                if(flag[nx][ny] == INF){
                    F.push_back(INF); F.push_back(INF+1);
                }else{
                    F.push_back(flag[nx][ny]);
                }
            }
        }
        sort(F.begin(),F.end());
        F.erase(unique(F.begin(),F.end()),F.end());
        if(F.empty()){
            flag[x][y] = id++;
        }else if(F.size() == 1){
            flag[x][y] = F[0];
        }else{
            flag[x][y] = INF;
            res++;
        }

    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 34236
void main() {
	import std.random;
	auto D = ri;
	auto rnd = Random(42);
	iota(D).map!(_ => uniform(1, 27, rnd)).each!writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

long rl() {
	return readAs!long;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 2860
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())

    num = [0] * k
    for i in range(1, n + 1):
        num[i % k] += 1
        
    if k % 2 != 0:
        print(pow(num[0], 3))
    else:
        print(pow(num[0], 3) + pow(num[k // 2], 3))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10164
N,K=map(int,input().split())
A=list(map(int,input().split()))

left=[0]*N
right=[0]*N
for i in range(N):
    if 0<i:
        for l in range(0,i):
            if A[l]<A[i]:
                left[i]+=1
    if i<N-1:
        for r in range(i+1,N):
            if A[r]<A[i]:
                right[i]+=1
        
ans=0
mod=10**9+7
for i in range(N):
    ans=(ans+(K*right[i]%mod+K*(K-1)//2*(left[i]+right[i])%mod)%mod)%mod

print(ans)
    

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

int main() 
{
    int n;
    cin >> n;
    set<int> s;
    for (int i=0; i<n; i++)
    {
        int d;
        cin >> d;
        s.insert(d);
    }
    cout << s.size();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int a, b;
	char c;
	while (scanf("%d %c %d", &a,&c, &b),c!='?') {
		if (c == '*')
			printf("%d\n", a*b);
		else if (c == '/')
			printf("%d\n", a / b);
		else if (c == '+')
			printf("%d\n", a + b);
		else if (c == '-')
			printf("%d\n", a - b);
	}
	return 0;
}

Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
int64_t gcd(int64_t x,int64_t y){
if(x==0 || y==0)
  return max(x,y);
  else{
   if(x<y)
     return gcd(x,y%x);
    else if(y<x)
      return gcd(y,x%y);
    else
      return x;
  
  }

}
int main(){
int64_t N,M;
  cin>>N>>M;
  string s,t;
  cin>>s>>t;
  int64_t g=gcd(N,M);
  bool x=true;
  for(int i=0;i<g;i++){
  if(s.at(i*(N/g))!=t.at(i*(M/g))){
     x=false; break;
  }
    
  }if(x)
    cout<<(N/g)*M<<endl;
  else
    cout<<-1<<endl;
  
   return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}
    
void run(){
    int n;
    cin>>n;
    vi x(n);
    rep(i,n)cin>>x[i];
    int ans=inf;
    REP(i,1,100){
        int s=0;
        rep(j,n)s+=(x[j]-i)*(x[j]-i);
        ans=min(ans,s);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int n; cin >> n;
  vi w(n);
  ll SUM = 0;
  rep(i,n) {
    cin>>w[i];
    SUM+=w[i];
  }
  ll ans = INF;
  ll sum = 0;
  rep(i,n) {
    sum += w[i];
    ans = min(ans, abs(sum-(SUM-sum)));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    A, V = map(int, rl().split())
    B, W = map(int, rl().split())
    T = int(rl())
    
    if V <= W:
        print('NO')
        return
    d = abs(A - B)
    if d / (V - W) <= T:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9184
A, B = map(int, input().split())


# 0 から n まで並べたときの右から d ビット目の1の数
def count1(n, d):
    mod = n % (2 ** (d + 1))
    n >>= d + 1
    n <<= d
    return n + max(mod - 2 ** d + 1, 0)


def main():
    # (B の2進各桁の1の数) - ((A-1) の2進各桁の1の数)
    bitcounts = []
    n = B
    d = 0
    while n > 0:
        bitcounts.append(count1(B, d))
        d += 1
        n >>= 1

    n = A - 1
    d = 0
    while n > 0:
        bitcounts[d] -= count1(A - 1, d)
        d += 1
        n >>= 1

    # xor して10進にする。奇数なら1、偶数なら0
    r = 0
    ans = 0
    for bc in bitcounts:
        if bc % 2 == 1:
            ans += 2 ** r
        r += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    string T;
    cin >> T;
    int result = 0;
    int res = 0;
    for (int i = 0;i<=S.size()-T.size();i++){
        for (int j = i; j < T.size()+i;j++){
            if(S[j]==T[j-i]){
                result++;
            }
            if(result>res){
                res = result;
            }
            
        }result = 0;
    }
    cout <<T.size()-res;
    return 0;
}

Measured memory_bytes: 3592