akhauriyash/Code-Regression huggingface dataset:
lis = []
H, W, K = tuple(int(x) for x in input().strip().split())
for _ in range(H):
    lis.append(tuple(1 if x == '#' else 0 for x in input().strip()))
lis = tuple(lis)

selectH = [False for _ in range(H)]
selectW = [False for _ in range(W)]
cnt = 0

def judge(h, w):
    ret = 0
    for i in range(H):
        if (h >> i) & 1:
            for j in range(W):
                if (w >> j) & 1:
                    ret += lis[i][j]
    return ret
            
if __name__ == '__main__':
    cnt = 0
    for h in range(1 << H):
        for w in range(1 << W):
            if judge(h, w) == K:
                cnt += 1
    print(cnt)

Measured memory_bytes: 9236
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}



int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ans = 0;
	rep(i, n)
	{
		if((i+1) % 2 == 1 && a[i] % 2 == 1)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
import math

N = int(input())
mod = 10**9+7

def get_primes(n):
    ps = [0, 0] + [i for i in range(2, n+1)]
    for i in range(2, n+1):
        if ps[i] == 0:
            continue
        for j in range(i * i, n+1, i):
            ps[j] = 0
    return [p for p in ps if p]


prime = get_primes(N)

ans = 1
for p in prime:
    tmp = 0
    for i in range(1, int(math.log(N, p))+1):
        tmp += N // (p**i)

    ans = (ans * (tmp + 1)) % mod

print(ans)





Measured memory_bytes: 3064
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x);
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int x[300 * 300 + 1] = {};
int y[300 * 300 + 1] = {};

ll answer[300 * 300 + 1] = {};

int main(void)
{
	int h, w, d, q;
	cin >> h >> w >> d;

	FOR(i, h) {
		FOR(j, w) {
			int a;
			cin >> a;
			x[a] = j;
			y[a] = i;
		}
	}

	FOR(i, h*w) {
		if (i + d > h * w)break;
		answer[i + d] += abs(x[i + d] - x[i]) + abs(y[i + d] - y[i]) + answer[i];
	}

	cin >> q;

	FOR(i, q) {
		int l, r;
		cin >> l >> r;
		cout << answer[r] - answer[l] << endl;
	}

	return 0;
}



Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#define N 30010
#define ll long long
using namespace std;

struct info {
	int w, s, v;
	friend bool operator<(info a, info b) {
		return a.w + a.s < b.w + b.s;
	}
} A[N];
int n;
ll f[N * 10];

inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-')f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}
#define cmax(a,b) (a<b)?a=b:1
int main() {
	n = read();
	for (int i = 1; i <= n; ++i)A[i].w = read(), A[i].s = read(), A[i].v = read();
	sort(A + 1, A + n + 1);
	for (int i = 1; i <= n; ++i)for (int j = A[i].s; j >= 0; --j)cmax(f[j + A[i].w], f[j] + A[i].v);
	ll Ans = 0;
	for (int i = 0; i <= 30000; ++i)Ans = max(Ans, f[i]);
	printf("%lld\n", Ans);
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define clear(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
	int n;
	while (cin >> n, n)
	{
		int s[1024];
		rep (i, n)
			cin >> s[i];
		sort(s, s + n);
		cout << accumulate(s + 1, s + (n - 1), 0) / (n - 2) << endl;
	}
}

Measured memory_bytes: 0
// floyd2.cpp : アプリケーションのエントリ ポイントを定義します。
//

// floyd.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <string>
using namespace std;

int main()
{
    int A, B, C,i = 1 ,sum = 0;

    cin >> A >> B >> C;

    while (B*A > sum)
    {
        sum = A * i;
        i++;
        if (sum % B == C)
        {
            break;
        }
    }
    A = sum;
    if (A % B == C)
    {
        cout << "YES";
    }
    else {
        cout << "NO";
    }


    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    char s;
    std::cin >> a >> b;
    
    s = 'x';
    if(a + b == 15) s = '+';
    if(a * b == 15) s = '*';
    
    std::cout << s << std::endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int N = 110;

int n, i, j, g, x;
long long w[N], v[N], a[100010], s;

int main() {
    cin >> n >> g;
    for (i = 1; i <= n; ++i) {
        cin >> w[i] >> v[i];
    }
    for (i = 1; i <= n; ++i) {
        for (j = g - w[i]; j >= 0; --j) {
            x = j + w[i];
            if (a[x] < a[j] + v[i]) {
                a[x] = a[j] + v[i];
                s = (s > a[x] ? s : a[x]);
            }
        }
    }
    cout << s << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#define FLAG -1
using namespace std;
typedef pair<int,int> P;
int main(){
      int h,w,dh[] = {1,1,1,0,-1,-1,-1,0}, dw[] = {1,0,-1,-1,-1,0,1,1},ctn,i,j;
      int solve = -2 ;
      cin >> h >> w;
      queue<P> que,tmp;
      char d[h][w];
      for(i=0;i<h;i++){
            for(j=0;j<w;j++)
            {
                  cin >> d[i][j];
                  if('1'<=d[i][j]&&'9'>=d[i][j])
                        que.push(make_pair(i,j));
            }
      }

      que.push(make_pair(FLAG,FLAG));
      for(;;){
            solve++;
            map<P,bool> m;
            for(;;){
                  //cout << que.size()<<endl;
                  P p = que.front();
                  que.pop();
                  if(p.first==FLAG)
                  {//cout <<" break "<<endl<<endl;
                  break;
                  }
                  ctn = 0;
                  for(i = 0;i < 8;i++){
                        if(d[p.first+dh[i]][p.second+dw[i]]=='.')ctn++;
                  }

                  if(ctn >= d[p.first][p.second]-'0'){
                        tmp.push(p);
                        for(j=0;j<8;j++)
                        if(m.count(make_pair(p.first+dh[j],p.second+dw[j]))==0&&d[p.first][p.second]!='.'){
                        que.push(make_pair(p.first+dh[j],p.second+dw[j]));
                        m[make_pair(p.first+dh[j],p.second+dw[j])]=true;
                        }
                  }
            }
            if(tmp.empty())break;
            while(!tmp.empty())
            {
                  d[tmp.front().first][tmp.front().second]='.';
                  tmp.pop();
            }
            /*for(i =0 ;i<h;i++)
            {
                  for(j=0;j<w;j++)cout << d[i][j];
                  cout <<endl;
            }
            */

            que.push(make_pair(FLAG,FLAG));

      }
      cout << solve << endl;
}

Measured memory_bytes: 10232
# -*- coding: utf-8 -*-
"""
C - Exam and Wizard
https://atcoder.jp/contests/keyence2019/tasks/keyence2019_c

"""
import sys


def solve(N, A, B):
    total_A = sum(A)
    total_B = sum(B)
    if total_A < total_B:
        return -1
    r = total_A - total_B
    margins = sorted([a-b for a, b in zip(A, B) if a-b >= 0], reverse=True)
    ans = 0
    while margins and margins[-1] <= r:
        r -= margins.pop()
        ans += 1
    return N-ans


def main(args):
    N = int(input())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    ans = solve(N, A, B)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 20084
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  int N, X, Y; cin >> N >> X >> Y;
  set<int> ST;
  RNG(K, 1, N) {
    int cnt = 0;
    RNG(i, 1, N+1) {
      int distX = abs(X-i),
          distY = abs(Y-i),
          rgt = i + K,
          lft2 = Y-(K-distX-1),
          rgt2 = Y+(K-distX-1),
          lft3 = X-(K-distY-1),
          rgt3 = X+(K-distY-1);

      if (rgt <= N && distX+abs(rgt-Y)+1 >= K && distY+abs(rgt-X)+1 >= K) ST.insert(rgt);
      if (rgt2 > i && rgt2 > 0 && rgt2 <= N && abs(rgt2-i) >= K && K > distX) ST.insert(rgt2);
      if (lft2 > i && lft2 > 0 && lft2 <= N && abs(lft2-i) >= K && K > distX) ST.insert(lft2);
      if (rgt3 > i && rgt3 > 0 && rgt3 <= N && abs(rgt3-i) >= K && K > distY) ST.insert(rgt3);
      if (lft3 > i && lft3 > 0 && lft3 <= N && abs(lft3-i) >= K && K > distY) ST.insert(lft3);
      // for (const auto& v: ST) cout << "i: " << i << " v: " << v << endl;
      cnt += ST.size();
      ST.clear();
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from math import log, ceil
r = 26
ab = "abcdefghijklmnopqrstuvwxyz"
input = raw_input
n = int(input())

def answer(n):
    m = int(ceil(log(n*(r-1) + r, r))) - 1

    #cur = r ** (m-1)
    out = ""

    sub = (r ** m - r) // (r-1)
    n = n - sub - 1
    for i in range(m):
        i = n % r
        out = ab[i] + out
        n //= r
        #i = n // cur
        #out = out + ab[i-1]
        #n -= i * cur
        #cur //= r
    return out

#for n in range(1, 676 + 26 + 2):
if True:
    out = answer(n)
    #print(n, out)
    print(out)

Measured memory_bytes: 64448
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int P = 1000000007;

void exGcd(int a, int b, int& x, int& y) {
  if (!b) {
    x = 1;
    y = 0;
    return;
  }
  exGcd(b, a % b, y, x);
  y -= a / b * x;
}

int inv(int a) {
  int x, y;
  exGcd(a, P, x, y);
  if (x < 0)
    x += P;
  return x;
}

int mpow(int x, int k) {
  int ret = 1;
  while (k) {
    if (k & 1)
      ret = ret * (ll)x % P;
    x = x * (ll)x % P;
    k >>= 1;
  }
  return ret;
}

struct Simple {
  int n;
  vector<int> fac, ifac, inv;

  void build(int n) {
    this->n = n;
    fac.resize(n + 1);
    ifac.resize(n + 1);
    inv.resize(n + 1);
    fac[0] = 1;
    for (int x = 1; x <= n; ++x)
      fac[x] = fac[x - 1] * (ll)x % P;
    inv[1] = 1;
    for (int x = 2; x <= n; ++x)
      inv[x] = -(P / x) * (ll)inv[P % x] % P + P;
    ifac[0] = 1;
    for (int x = 1; x <= n; ++x)
      ifac[x] = ifac[x - 1] * (ll)inv[x] % P;
  }

  Simple() {
    build(1);
  }

  void check(int k) {
    int nn = n;
    if (k > nn) {
      while (k > nn)
        nn <<= 1;
      build(nn);
    }
  }

  int gfac(int k) {
    check(k);
    return fac[k];
  }

  int gifac(int k) {
    check(k);
    return ifac[k];
  }

  int ginv(int k) {
    check(k);
    return inv[k];
  }

  int binom(int n, int m) {
    if (m < 0 || m > n)
      return 0;
    return gfac(n) * (ll)gifac(m) % P * gifac(n - m) % P;
  }
} simp;


int main() {

  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  simp.check(n + m);
  int ans = 0;
  for (int s = 1; s <= k; ++s)
    ans = (ans + simp.fac[s] * (ll)simp.fac[n + m - s] % P * (simp.binom(n + m, s) + simp.binom(n + m - 1, s - 1) * (ll)(n + m) % P + simp.binom(n + m - 2, s - 2) * (ll)n % P * m % P)) % P;
  ans = ans * (ll)simp.ifac[n + m - k] % P;
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 393472
//By Zank100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define din(t) long long t;cin>>t;
#define in(t) cin>>t;
ll mul(ll a, ll b)
{
    return(((a%mod)*(b%mod))%mod);
}
ll modexp(ll b, ll e){
	ll res = 1;
	for(; e; b = b * b % mod, e >>= 1) if(e & 1) res = res * b % mod;
	return res;
}
ll modinv(ll a){
    ll x=mod-2;
	return modexp(a,x);
}
ll power(ll x, ll y)
{
    ll temp;
    if(y == 0)return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)return temp*temp;
    else{
        if(y > 0)return x * temp * temp;
        else return (temp * temp) / x;
    }
}
ll cc(ll x,ll y){
    if(x-y>0)return 1;
    else if(x-y<0)return -1;
    else return 0;
}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	din(h1)din(m1)din(h2)din(m2)din(k)
	ll total=(h2*60 + m2)-(h1*60 + m1);
	ll ans=total - k;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int zs,ctw,n,q,nt,nv,nfx=1,nzl,xyz,fzt[N],fw1[N],fw2[N];
void mchange()
{
	int kbl=fzt[ctw+1]-fzt[ctw];
	if(nfx==1)
	{
		fw1[ctw+1]=max(0,fw1[ctw]-kbl);
		fw2[ctw+1]=max(0,fw2[ctw]-kbl);
		nzl-=kbl; 
	}
	else
	{
		fw1[ctw+1]=min(zs,fw1[ctw]+kbl);
		fw2[ctw+1]=min(zs,fw2[ctw]+kbl);
		nzl+=kbl;
	}
	nfx=nfx*(-1); 
}
int main()
{
	//freopen("c4.in","r",stdin);
	//freopen("test.out","w",stdout);
	int i,j;
	scanf("%d",&zs);
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%d",&fzt[i]);
	}
	scanf("%d",&q);
	fw2[0]=zs; 
	for(i=1;i<=q;++i)
	{
		scanf("%d%d",&nt,&nv);
		while(ctw<n&&fzt[ctw+1]<nt) 
		{
		   mchange();
		   ctw++;
	    }
	    if(nv+nzl>=fw1[ctw]&&nv+nzl<=fw2[ctw])	xyz=nv+nzl;
	    if(nv+nzl<fw1[ctw]) xyz=fw1[ctw];
	    if(nv+nzl>fw2[ctw]) xyz=fw2[ctw];
	    int kbl=nt-fzt[ctw];
	    if(nfx==1) xyz=max(0,xyz-kbl);
	    else xyz=min(zs,xyz+kbl);
	    printf("%d\n",xyz);
	}
	return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 1000000007
#define eps 1e-8
int n,m,a[410],b[410];
ll f[410][410],g[410][410];

ll qpow(ll x,int y)
{
	ll ans=1;
	while (y)
	{
		if (y&1) ans=ans*x%maxd;
		x=x*x%maxd;y>>=1;
	}
	return ans;
}

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
	n=read();m=read();
	rep(i,1,n) a[i]=read();
	rep(i,1,n) b[i]=read();
	rep(i,1,n)
		rep(j,0,m)
			rep(k,a[i],b[i])
				g[i][j]=(g[i][j]+qpow(k,j))%maxd;
	f[0][0]=1;
	rep(i,1,n)
	{
		rep(j,0,m)
		{
			rep(k,0,j)
			{
				f[i][j]=(f[i][j]+f[i-1][k]*g[i][j-k])%maxd;
			}
		}
	}
	printf("%lld",f[n][m]);
	return 0;
}
				


Measured memory_bytes: 2816
#include<stdio.h>

int main()
{
  int c1, c2, c3, m4=4;
  while(scanf("%d %d %d", &c1, &c2, &c3) != EOF)
    {
      if(c1 <= m4) m4++;
      if(c2 <= m4) m4++;
      if(c3 <= m4) m4++;
      if(c1 + c2 + m4 <= 20) printf("YES\n");
      else printf("NO\n");
      m4 = 4;
    }
  return 0;
}

Measured memory_bytes: 580
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

road = [a1, b1, a2, b2, a3, b3]

cnt1 = road.count(1)
cnt2 = road.count(2)
cnt3 = road.count(3)
cnt4 = road.count(4)

if cnt1 >= 3 or cnt2 >= 3 or cnt3 >= 3 or cnt4 >= 3:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3064
/*
Sharif Hasan - CSE, PUST
Dec 29, 2019 12: 00 PM 
*/
#include<bits/stdc++.h>
#define br cout<<"\n"

/*STL definations*/
#define pb push_back

#define FOR(i,n) for(i=0;i<n;i++)
#define FROM(a,i,n) for(i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

/*Main function*/
int main()
{
bool mark[1000001]={0};
int i,j;
mark[0]=mark[1]=1;
for(i=2;i<=sqrt(1000000);i++){
    if(!mark[i]){
        for(j=2*i;j<=1000000;j+=i){
            mark[j]=1;
        }
    }
}
int n;
cin>>n;
FROM(n,i,1000000){
    if(!mark[i]){
        cout<<i;br;
        break;
    }
}
return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
vector<char> C = {'0','1','2','3','4','5','6','7','8'};

int main()
{
  cout << fixed << setprecision(10);
  int H,W;
  cin >> H >> W;
  vector<vector<char>> S(H,vector<char>(W));
  int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
  rep(i,H)
  {
    rep(j,W)
    {
      cin >> S[i][j];
    }
  }
  rep(i,H)
  {
    rep(j,W)
    {
      if(S[i][j]=='#') continue;
      int b = 0;
      rep(k,8)
      {
        if(i+dx[k]<0||i+dx[k]>H-1) continue;
        if(j+dy[k]<0||j+dy[k]>W-1) continue;
        if(S[i+dx[k]][j+dy[k]]=='#') b ++;
      }
      S[i][j] = C[b];
    }
  }
  rep(i,H)
  {
    rep(j,W)
    {
      cout << S[i][j];
      if(j==W-1) cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3616
import sys
lines=[]
for line in sys.stdin:
    line= line.rstrip()
    lines.append(line)

for i in range(len(lines)//2):
    N,R=map(int,lines[2*i].split())
    ops=list(map(int,lines[2*i+1].split()))
    cards=[i for i in range(N)]
    for c in ops:
        deck_a=cards[N//2:N]
        deck_b=cards[0:N//2]
        deck_c=cards[0:0]
        while len(deck_a)>0 or len(deck_b)>0:
            d=deck_a[0:c]
            deck_a=deck_a[c:]
            deck_c+=d

            d=deck_b[0:c]
            deck_b=deck_b[c:]
            deck_c+=d
        cards=deck_c
    print(cards[-1])

Measured memory_bytes: 7656
N,M=map(int,input().split())
A=[[1,0] for i in range(N)]
A[0][1]=1

for i in range(M):
  a,b=map(int,input().split())
  if A[a-1][1]==1:
    A[b-1][1]=1
  A[a-1][0]-=1
  A[b-1][0]+=1
  if A[a-1][0]==0:
    A[a-1][1]=0
    
ans=0
for j in range(N):
  if A[j][1]==1:
    ans+=1
print(ans)

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

/* #include<cstdio>*/
int main(){
	int x, y;
	while (true){
	cin >> x >> y;
	if (x == 0 && y == 0) break;
	if (x <= y) cout << x << " " << y << endl;
	if (x > y) cout << y << " " << x << endl;


	}
	return 0; 
}



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

int main(){
    ll N,K; cin >> N >> K;
    vector<ll> x(N);
    rep(i,N) cin >> x[i];

    int idx = N;
    rep(i,N)if(x[i]>=0){
        idx = i;
        break;
    }

    ll ans = LINF;
    for(int i=0;i<=K;i++){
        // left [l,idx) = i
        int l = idx - i;
        // right [idx,r) = K - i
        int r = idx + K - i;
        if(l < 0) continue;
        if(r > N) continue;

        if(i==0){
            ll sum = abs(x[r-1]);
            ans = min(ans,sum);
            continue;
        }else if(i==K){
            ll sum = abs(x[l]);
            ans = min(ans,sum);
            continue;
        }

        ll sum1 = 2*abs(x[l]) + abs(x[r-1]);
        ll sum2 = abs(x[l]) + 2*abs(x[r-1]);
        ans = min({ans,sum1,sum2});
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
//ios::sync_with_stdio(false);
//<< setprecision(5)
const int mod=1e9+7;
const int big=1e8+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int n,k,a=1;cin>>n>>k;
	while(n--){
		a=min(a*2,a+k);
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
typedef long long ll;
struct mint {
  ll x;
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
int main() {
  int N;
  cin >> N;
  bool a[N][N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> a[i][j];
    }
  }
  vector<vector<mint>> dp(N+1,vector<mint>(1 << N));
  dp[0][0] = 1;
  for (int i = 0, m = 1 << N; i < N; i++) {
    for (int j = 0; j < m; j++) {
      if (__builtin_popcount(j) == i) {
        for (int k = 0; k < N; k++) {
          if (a[i][k] && !(j & 1 << k)) {
            dp[i+1][j | 1 << k] += dp[i][j];
          }
        }
      }
    }
  }
  cout << dp[N].back().x;
}

Measured memory_bytes: 380168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 40 + 5;

int n, g[maxn][maxn];
ll dp[maxn][maxn][maxn];
char s[maxn];

ll dfs(int l, int r, int m) {
	if(~ dp[l][r][m]) return dp[l][r][m];
	if(l == r) return dp[l][r][m] = 1;
	if(l == m || r == m) return dp[l][r][m] = 0;
	ll res = 0;
	for(int i = l;i < m;i ++) {
		for(int j = m + 1;j <= r;j ++) {
			if(!g[i][j]) continue;
      for(int p = i;p < m;p ++) {
				for(int q = m + 1;q <= j;q ++) {
					ll t1 = dfs(l,p,i);
					ll t2 = dfs(q,r,j);
					ll t3 = dfs(p + 1,q - 1,m);
					ll now = t1 * t2 * t3;
					res += now;
				}
			}
		}
	}
	return dp[l][r][m] = res;
}

int main() {
	scanf("%d", &n);
	memset(dp,-1,sizeof(dp));
	for(int i = 1;i <= n + n;i ++) {
		scanf("%s", s + 1);
		for(int j = 1;j <= n + n;j ++) g[i][j] = s[j] - '0';
	}
	ll Ans = 0;
	for(int i = 2;i <= n + n;i ++) {
		if(!g[1][i]) continue;
		ll now = dfs(2,n + n,i);
		Ans += now;
	}
	printf("%lld\n", Ans);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int check =0;
  for(int i = 0; i < N && check == 0; i ++){
    int a;
    cin >> a;
    if (!(a%2==1 ||(a%2==0 && (a%3==0 || a%5==0)))){
      check ++ ;
  }

}
    if (check){
    cout<<"DENIED"<<endl;
  }
        else{
          cout<<"APPROVED"<<endl;
        }
}


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

using namespace std;

constexpr size_t MAX_N = 100009;
int N;
long long H[MAX_N][3];
long long memo[MAX_N][3];

long long cost(int i, int choice) {
  if (i == N) return 0;
  assert(i < N);

  if (memo[i][choice] != -1) return memo[i][choice];

  if (choice == 0) return memo[i][0] = H[i][0] + max(cost(i+1, 1), cost(i+1, 2));
  if (choice == 1) return memo[i][1] = H[i][1] + max(cost(i+1, 0), cost(i+1, 2));
  if (choice == 2) return memo[i][2] = H[i][2] + max(cost(i+1, 0), cost(i+1, 1));

  assert(false);

}

int main() {

  cin >> N;
  
  for (int i=0; i<N; i++) {
    memo[i][0] = memo[i][1] = memo[i][2] = -1;
  }

  for (int i=0; i<N; i++) {
    cin >> H[i][0] >> H[i][1] >> H[i][2];
  }

  cout << max(cost(0, 0), max(cost(0, 1), cost(0, 2))) << endl;
  
  return 0;
}


Measured memory_bytes: 12928
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;


int main(){
    ll n,k; cin>>n>>k;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<bool>b(n,false);
    b[0]=true;
    ll m=0;
    ll unroop=0;
    for(ll i=0;;i++){
        if(b[a[m]-1]==true){
            m=a[m]-1;
            unroop++;
            break;
        }
        else {
            b[a[m]-1]=true;
            m=a[m]-1;
            unroop++;
        }
    }
    ll ans=0;
    if(unroop>=k){
        rep(i,k){
            ans=a[ans]-1;
        }
        cout<<ans+1<<endl;
        return 0;
    }
    ll mm=m;
    ll cnt=0;
    vector<bool>bb(n,false);
    bb[mm]=true;
    while(1){
       if(bb[a[mm]-1]==true){
           cnt++;
            break;
        }
        else {
            bb[a[mm]-1]=true;
            mm=a[mm]-1;
            cnt++;
        }
    }

    ans=m;
    cnt=(k-unroop)%cnt;
    rep(i,cnt){
        ans=a[ans]-1;
    }
    cout<<ans+1<<endl;
}








Measured memory_bytes: 4844
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        ++$this->pointer;

        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int) $this->next();
    }

    public function nextDouble()
    {
        return (float) $this->next();
    }
}

$sc = new Scanner();
$n = $sc->nextInt();
$array = [];
$max_height = 0;
$is_possible = true;

for($i=0;$i<$n;$i++){
    $array[] = $sc->nextInt();
    if($array[$i] > $max_height){
        $max_height = $array[$i];
    } else {
        if(($max_height - $array[$i]) > 1) {
            $is_possible = false;
        }
    }
}

if($is_possible){
    $answer = 'Yes';
} else {
    $answer = 'No';
} 

echo $answer.PHP_EOL;


Measured memory_bytes: 28096
# coding: utf-8

from functools import reduce

def solve(X, Ls):
  return len(list(filter(
    lambda x: x <= X, reduce(lambda x, y: x + [x[-1] + y], Ls, [0]))))


if __name__ == '__main__':
  _, X = map(int, input().split())
  print(solve(X, map(int, input().split())))

Measured memory_bytes: 9504
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int a, b;
    cin >> a >> b;
    int maxv = max(a + b, max(a - b, a * b));
    cout << maxv << endl;
}

Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let s = sc
        .read::<String>()
        .chars()
        .map(|c| c as usize - 'a' as usize)
        .collect::<Vec<_>>();
    let n = s.len();
    let mut group = vec![0; n];
    let mut cur = 0;
    let mut set = 0;
    for i in (0..n).rev() {
        set |= 1 << s[i];
        group[i] = cur;
        if set == (1 << 26) - 1 {
            set = 0;
            cur += 1;
        }
    }

    let mut pos = vec![vec![]; 26];
    for i in 0..n {
        pos[s[i]].push(i);
    }

    let mut ans = vec![];
    let mut lower = 0;
    loop {
        for i in 0..26 {
            let next = pos[i]
                .binary_search_by_key(&(lower * 2), |&pos| pos * 2 + 1)
                .err()
                .unwrap();
            if next == pos[i].len() {
                // end
                ans.push(i);
                for ans in ans.into_iter() {
                    let c = (ans as u8 + 'a' as u8) as char;
                    sc.write(c);
                }
                sc.write("\n");
                return;
            } else if group[pos[i][next]] == cur - 1 {
                lower = pos[i][next] + 1;
                cur -= 1;
                ans.push(i);
                break;
            }
        }
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    long long a,n,ans=0;
    cin>>n;
    map <long long,long long> b;
    f(i,0,n){
        cin>>a;
        b[a]++;
        if(b[a]%2==0){
            ans--;
        }
        else{
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9868
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
const int mod=1000000007;
inline int ad(int x){return x>=mod?x-mod:x;}
inline int dec(int x){return x<0?x+mod:x;}
inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}return ans;
}
int fac[1010],inv[1010];
inline int C(int n,int m){return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;}
int f[25][1010];
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	fac[0]=1;
	for(int i=1;i<=1000;i++)fac[i]=1LL*fac[i-1]*i%mod;inv[1000]=power(fac[1000],mod-2);
	for(int i=1000;i>=1;i--)inv[i-1]=1LL*inv[i]*i%mod;
	int n=read(),m=read();
	f[0][0]=1;
	for(int i=1;i<=m;i++)
	{
		int uf=read();
		for(int j=0;j<=n;j++)
		{
			for(int k=0;k<=min(uf,n-j);k++)f[i][j+k]=ad(f[i][j+k]+1LL*f[i-1][j]*C(n-j,k)%mod*C(n-k,uf-k)%mod);
		}
	}
	pr2(f[m][n]);
	return 0;
}

Measured memory_bytes: 256
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


int main(){
  int a, b;
  cin >> a >> b;
  int kakaku(int, int);
  cout << kakaku(a,b);
}

int kakaku(int a, int b){
  rep2(i, 1, 10001){
    if(floor(i*0.08) == a && floor(i*0.1) == b){
      return i;
    }
  }
  return -1;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

struct UnionFind {
  vector<int> d;
  UnionFind(int n) : d(n, -1) {}
  int root(int x) {
    if(d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int size(int x) { return -d[root(x)]; }
};

int main() {
  int n, m;
  cin >> n >> m;
  vi p(n);
  rep(i, n) {
    int a;
    cin >> a;
    a--;
    p[i] = a;
  }
  UnionFind uf(n);
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    uf.unite(x, y);
  }
  int ans = 0;
  rep(i, n) if(uf.same(i, p[i])) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

char abc[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int main() {
    ll n, ans = 0;
    string s;
    cin >> n >> s;
    map<char, bool> x, y;
    for(int i = 0; i < n; i++){
        rep(j, n){
            if(j <= i)x[s[j]] = true;
            else y[s[j]] = true;
        }
        ll now = 0;
        rep(j, 26){
            if(x[abc[j]] && y[abc[j]])now++;
        }
        ans = max(ans, now);
        x.clear();
        y.clear();
    }
    cout << ans << endl;
}   


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n;
int t[105];
int m;
int p[105],x[105];
int sum;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t[i];
        sum+=t[i];
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>p[i]>>x[i];
        cout<<sum-t[p[i]-1]+x[i]<<endl;
    }
    
    
}


Measured memory_bytes: 3576
#include<iostream>
#include<fstream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(false),cin.tie(nullptr)
int main()
{
        int n,k;
        cin>>n>>k;
        int a[n];
        for(int i=0;i<n;i++)
        {
                cin>>a[i];
        }
        sort(a,a+n);
        int sum=0;
        for(int i=0;i<k;i++)
        {
                sum+=a[i];
        }
        cout<<sum<<endl;
}


Measured memory_bytes: 3636
p = 10 ** 9 + 7
N = 2000
R = 2000

fact = [1, 1] 
factinv = [1, 1]  
inv = [0, 1]

for i in range(2, N + 1):
  fact.append((fact[-1] * i) % p)
  
for i in range(2, R + 1):
  inv.append((-inv[p % i] * (p // i)) % p)
  factinv.append((factinv[-1] * inv[-1]) % p)

def comb(n, k):
  return fact[n-2*k] * factinv[n-3*k] * factinv[k] % p

S=int(input())
K=S//3
total=0
for k in range(1,K+1):
  total+=comb(S-3,k-1)
print(total%p)

Measured memory_bytes: 65668
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>

using namespace std;

int main(){
   int a,b;
   cin>>a>>b;
   int ans[6];
   int result = 0;
   for (int i = a; i <= b; i ++){
        ans[4] = i %10;
        ans[3] = (i%100)/10;
        ans[2] = (i%1000)/100;
        ans[1] = (i%10000)/1000;
        ans[0] = (i%100000)/10000;
        if (ans[0]==ans[4]&&ans[1]==ans[3]){
            result ++;
        }
    }
    cout<<result<<endl;
}


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

int main(){
    long int A,B,C,D; cin>>A>>B>>C>>D;
    A = A-1;
    long int ac=A/C,ad=A/D,bc=B/C,bd=B/D;
    long int big=D, small=C , amari = 100;
    while( amari > 0){
        amari = big % small;
        big = small;
        small = amari;
    }
    //cout << big<< endl;
    long int mincom = D*C/big;
    long int am = A/mincom, bm = B/mincom;
    //cout << mincom << endl;
    //cout<<(B - A) << endl;
    //cout<< (bc+bd-bm) <<endl;
    //cout<< (ac+ad-am) << endl;
    cout << (B-A) - ((bc+bd-bm) - (ac+ad-am) ) << endl;
    //ユークリッドの互除法を利用してC,Dの最大公約数を求める
    /*
    long int quo = D%C;
    long int pro = D/C;
    cout<<pro<<endl;
    cout<<quo<<endl;
    long int big = C;
    while(quo > 0){
        quo = big%pro;
        pro = big/pro;
        big = pro;
        cout<<pro<<endl;
        cout<<quo<<endl;
        cout<<big<<endl;
    }
    cout<<pro<<endl;
    //素数同士の場合,最大公約数proは１
    long int V=(C*D)/pro;
    long int AovV = A/V, BovV = B/V;
    long int AovC = A/C,AovD=A/D, BovC=B/C, BovD=B/D;
    long int diff = (BovC+BovD-BovV) - (AovC+AovD-AovV);
    cout << B -A << endl;
    cout << diff << endl;
    cout << (BovC+BovD-BovV) << endl;
    cout << (AovC+AovD-AovV) << endl;
    cout << endl;
    cout << B - A - diff<< endl;
    */
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

//#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE 	;
#define dumpV(v);
#define STOP 	;
#endif
#define mp make_pair

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


const int MAX_N = 1e5+10;
vi es[MAX_N];
bool used[MAX_N];

int main(){
	int n, m;
	cin >> n >> m;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		es[a].pb(b);
		es[b].pb(a);
	}
	deque<int> d;
	d.push_front(0);
	d.push_back(*es[0].begin());
	rep(i, 2) used[d[i]] = true;
	LINE;
	while(1) {
		dump(mp(d.front(), d.back()));
		bool update = false;
		for(auto& to : es[d.front()]) {
			if(!used[to]) {
				update = true;
				d.push_front(to);
				used[to] = true;
				break;
			}
		}
		for(auto& to : es[d.back()]) {
			if(!used[to]) {
				update = true;
				d.push_back(to);
				used[to] = true;
				break;
			}
		}
		if(!update) break;
	}
	cout << d.size() << endl;
	rep(i, d.size()) {
		cout << d[i]+1;
		if(i + 1 != d.size()) cout <<" ";
		else cout << endl;
	}

	return 0;
}

Measured memory_bytes: 6784
count=0
def merge(A,left,mid,right):
    global count
    L=A[left:mid]+[10**9+1]
    R=A[mid:right]+[10**9+1] 
    i=0
    j=0
    for k in range(left,right):
        count+=1
        if L[i]<=R[j]:
            A[k]=L[i]
            i+=1
        else:
            A[k]=R[j]
            j+=1
       
def mergeSort(A,left,right):
    if left+1<right:
        mid=(left+right)//2
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)

n=int(input())
S=[int(i) for i in input().split()]
mergeSort(S,0,n)
print(*S)
print(count)


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

struct node{
    node(ll _val = 0,node *_pre = NULL,node *_nx = NULL):value(_val),pre(_pre),nx(_nx){}
    ll value;
    node *pre,*nx;
};

struct link{
    node *head = new node();
    node *tail = head;
    void add(ll val)
    {
        node *p = new node(val,tail);
        tail->nx = p;
        tail = p;
    }
    node *del(node *p)
    {
        node * tmp = p->pre;
        if (p == tail)
        {
            tail = p->pre;
            tail->nx = NULL;
            delete p;
        }
        else
        {
            node *pre = p->pre,*nx = p->nx;
            pre->nx = nx;
            nx->pre = pre;
            delete p;
        }
        return tmp;
    }
    void write()
    {
        node *j = head;
        while (j->nx != NULL)
        {
            j = j->nx;
            cout<<j->value<<' ';
        }
        cout<<'\n';
    }
}L;

const int N = 1e3+10;
ll n,k,a[N],sum[N],tot,num[50];
int main()
{
    int st;
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
    sum[i]=sum[i-1]+a[i];
    ll maxn = 0;
    for(int i=1;i<=n;i++)
        for(int j=i;j<=n;j++)
        {
            L.add(sum[j]-sum[i-1]);
            maxn = max(maxn,sum[j]-sum[i-1]);
            num[(int)(log(sum[j]-sum[i-1]) / log(2))]++;
            tot++;
        }
    st = log(maxn) / log(2);
    int cnt = 0,i;
    for (i = st;i>=0;i--)
    {
        cnt += num[i];
        if (cnt > k) break;
    }
    node* j = L.head;
    ll ans = (1LL<<40) - 1;
    while (j->nx != NULL)
    {
        j = j->nx;
        if ((j->value) < (1LL<<i))
        {
            j = L.del(j);
        }
    }
    for (i--;i>=0 && cnt > k;i--)
    {
        j = L.head;
        int tmp = 0;
        while (j->nx != NULL)
        {
            j = j->nx;
            if (((j->value) & (1LL<<i)) == 0) tmp++;
        }
        j = L.head;
        if (cnt - tmp >= k)
        {
            while (j->nx != NULL)
            {
                j = j->nx;
                if (((j->value) & (1LL<<i)) == 0) j = L.del(j);
            }
            cnt -= tmp;
        }
        else
        {
            int cnt1 = 0;
            while (j->nx != NULL)
            {
                j = j->nx;
                if (((j->value) & (1LL<<i)) == 1)
                {
                    cnt1++;
                    ans &= j->value;
                    j = L.del(j);
                }
            }
            cnt -= cnt1;
            k -= cnt1;
        }
        // L.write();
    }
    j = L.head;
    while (j->nx != NULL)
    {
        j = j->nx;
        ans &= j->value;
    }
    cout<<ans;
}


Measured memory_bytes: 15872