akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  N = readInts()[0]

  if N % 2 == 0:
    print(N // 2 - 1)
  else:
    print(N // 2)

if __name__ == "__main__":
  main()


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

int main(){
  vector<int> a(5);
  for (auto&A : a)cin >> A;
  int ans = 0;
  for (auto A: a){
    if (A%10 == 0)ans += A;
    if (A%10 != 0)ans += (A/10) *10 +10;
  }
  int true_ans = ans;
  for (auto A : a){
    if (A%10 != 0){
      true_ans = (true_ans < ans - 10 + A%10)? true_ans : ans - 10 + A%10;
    }
  }
  cout << true_ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k,d;
    cin >> n >> k; 
    map<int,int>maps;
    f(i,0,k){
        cin >> d;
        f(i,0,d){
            int x;
            cin >> x;
            maps[x]++;
        }
    }
    int ans = 0;
    f(i,1,n+1){
        if(maps[i] == 0){
            ans++;
        }
    }
    cout << ans ;

    
    return 0;
}
 

Measured memory_bytes: 3644
#include<stdio.h>
#define N 150

int main(){
  int i, j, k, l, n, v[N][N];
  scanf("%d", &n);
  for(i = 0;i < n;i++)
    for(j = 0;j < n;j++)
      v[i][j] = 0;
  for(i = 1;i < n+1;i++){
    scanf("%d%d", &v[i][0], &k);
    v[i][0] += k;
    for(j = 1;j < v[i][0]-i+1;j++){
      scanf("%d", &l);
      v[i][l]++;
    }
  }
  for(i = 1;i < n+1;i++){
    for(j = 1;j < n;j++){
      printf("%d ", v[i][j]);
    }
    printf("%d\n", v[i][j]);
  }
  return 0;
}

Measured memory_bytes: 664
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

int main(){

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

  int cnt = 0;
  for (int i = 0; i < 64; i++){
    ll now = pow(2, i);
    if (now > K){
      cnt = i; break;
    }
  }
  
  int dig[N][cnt];
  for (int i = 0; i < N; i++){
    ll num = A[i];
    for (int j = 0; j < cnt; j++){
      dig[i][j] = num % 2;
      num = num / 2;
    }
  }

  ll L = 0;
  for (int j = cnt - 1; j >= 0; j--){
    int count0 = 0, count1 = 0;
    for (int i = 0; i < N; i++){
      if (dig[i][j] == 0) count0++;
      else count1++;
    }

    if (count0 >= count1){
      ll sum = pow(2, j);
      if(L + sum <= K) L += sum;
    }
  }

  ll ans = 0;
  for (int i = 0; i < N; i++){
    ans += A[i] ^ L;
  }
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 16640
import qualified Data.Set as Set

main = do
  s' <- getContents
  let s1 = Set.fromList $ map (read :: String -> Int) $ words $ (lines s') !! 1
  let s2 = Set.fromList $ map (read :: String -> Int) $ words $ (lines s') !! 3
  print $ Set.size $ Set.intersection s2 s1

Measured memory_bytes: 38908
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int x; cin >> x;

  vector<int> a;
  REP(i, 2, 31){
    int x = i*i;
    while(x <= 1000){
      a.push_back(x);
      x *= i;
    }
  }
  a.push_back(1);
  a.push_back(1001);
  sort(all(a));

  cout << *(upper_bound(all(a), x) - 1) << endl;

  return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

set<string> st={"AKIHABARA","KIHABARA","AKIHBARA","AKIHABRA","AKIHABAR",
								"KIHBARA","KIHABRA","KIHABAR","AKIHBRA","AKIHBAR","AKIHABR",
								"KIHBRA","KIHBAR","KIHABR","AKIHBR","KIHBR"};

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

	string s;
	cin>>s;
	if(st.find(s)!=st.end()) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	static List<List<Integer>> ptnList = new ArrayList<>();

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		List<Person> personList = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			Person p = new Person();
			for(int j = 0; j < a; j++) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				p.evidenceList.add(new Evidence(x, y));
			}
			personList.add(p);
		}

		int max = 0;

		countfor: for(int count = 0; count < Math.pow(2,  n); count++) {

			String b = Integer.toBinaryString(count);
			String ptn = "";
			for(int i = 0; i < n - b.length(); i++) {
				ptn += "0";
			}
			ptn += b;

			for(int i = 0; i < personList.size(); i++) {
				if(ptn.charAt(i) == '1') {
					for(Evidence e : personList.get(i).evidenceList) {
						if(Integer.parseInt(ptn.substring(e.x - 1, e.x)) == e.y){

						}else {
							continue countfor;
						}
					}
				}
			}

			int c = 0;
			for(int i = 0; i < ptn.length(); i++) {
				if(ptn.charAt(i) == '1') {
					c++;
				}
			}
			if(c > max) {
				max = c;
			}

		}

		System.out.println(max);


		sc.close();



	}

	private static class Person {
		List<Evidence> evidenceList = new ArrayList<>();
	}

	private static class Evidence {
		int x;
		int y;

		public Evidence(int _x, int _y) {
			this.x = _x;
			this.y = _y;
		}
	}
}


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

int main(){
  string S;cin >> S;

  int res=1<<29;
  for (int start=0;start<=1;++start){
    int val=start;
    int count =0;
    for (int i=0;i<S.size();++i){
      if (S[i]-'0'!=val) ++count;

      val=1-val;
    }
    res=min(res,count);
  }
  cout << res << endl;
}


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


int main(){
  long long a,b,v,w,t;
  cin >> a >> v >>b>>w>>t;
  if(v==w){
    cout << "NO" <<endl;
    return 0;
  }
  if(v-w<0){
    cout << "NO"<<endl;
    return 0;
  }
  if(abs(a-b)<=(v-w)*t){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 3636
from itertools import combinations
n = int(input())
arr = [input() for _ in range(n)]

li = ["M", "A", "R", "C", "H"]

result = []
for s in li:
    result.append(len(set([x for x in arr if x[0] == s])))

ans = 0

for x, y, z in combinations(result, 3):
    ans += x * y * z

print(ans)

Measured memory_bytes: 22992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int n; cin >> n;
    ll a[n]; rep(i, n) cin >> a[i];
    ll x[n];
    x[0] = 0;
    rep(i, n) {
        if (i % 2 == 0) {
            x[0] += a[i];
        } else {
            x[0] -= a[i];
        }
    }
    //out(x[0]);
    rep3(i, 1, n) {
        x[i] = 2 * a[i - 1] - x[i - 1];
    }
    rep(i, n) { if (i) cout << " "; cout << x[i]; }
    cout << endl;
}



Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n, k; cin >> n >> k;

    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> s(n+1); s[0] = 0;
    rep(i,n) s[i+1] = (s[i] + a[i]) %k;

    map<int,int> mp;
    ll ans = 0;

    rep(i,n+1){
        ans += mp[s[i]];
        mp[s[i]]++;
    }

    dunk(ans);
}


Measured memory_bytes: 3968
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    const int MOD = 1e9 + 7;
    
    int n, k; 
    cin >> n >> k;
    
    vll pos;
    vll neg;
    rep(i, n) {
        ll a;
        cin >> a;
        if(a >= 0) pos.pb(a);
        else neg.pb(-a);
    }
    
    int po = pos.size();
    int ne = neg.size();
    
    if( n == k ){
        ll ans = 1;
        for(auto a : pos) ans = (ans * a) % MOD;
        for(auto a : neg) ans = (ans * a) % MOD;
        if(ne & 1) ans = (MOD - ans) % MOD;
        cout << ans << endl;
        return;
    }
    
    if( po == 0 && (k & 1) ){
        sort(all(neg));
        ll ans = 1;
        rep(i, k){
            ans = (ans * neg[i]) % MOD;
        }
        ans = (MOD - ans) % MOD;
        cout << ans << endl;
        return;
    }    
    
    sort(rall(pos));
    sort(rall(neg));

    ll ans = 1;
    int pi = 0;
    int ni = 0;
    ll tp, tn;
    
    if(k & 1){
        ans = (ans * pos[pi]) % MOD;
        k--;
        pi++;
    }

    while(k >= 2){
        if(pi + 1 < po) tp = pos[pi] * pos[pi + 1];
        else tp = -1;
        if(ni + 1 < ne) tn = neg[ni] * neg[ni + 1];
        else tn = -1;
        if(tp == -1 || tn >= tp){
            ans = (ans % MOD) * (tn % MOD) % MOD;
            ni += 2;
        }else{
            ans = (ans % MOD) * (tp % MOD) % MOD;
            pi += 2;
        }
        k -= 2;
    }
    
    // cout << ans << endl;
    // cout << k << ": " << ni << " " << pi << " " << endl;
    
    cout << ans << endl;
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 5484
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

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

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	int tc = 1; //cin >> tc;
	while (tc--)
	{
		int i, j, n, r;
		cin >> n >> r;
		cout << r + 1000 - 100*min (n, 10) << '\n';
	}

	return 0;
}



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

const int N=100005;
stack<int> q;
vector<int> g[N];
int d[N], f[N];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i=1, x, y; i<=m; i++) {
		scanf("%d%d", &x, &y);
		g[y].push_back(x);
		d[x]++;
	}
	for (int i=1; i<=n; i++) if (d[i]==0) q.push(i);
	
	int ans = 0;
	while (!q.empty()) {
		int x=q.top(); q.pop();
	//	printf("x:  %d\n", x);
		for (int i=0; i<g[x].size(); i++) {
			int y=g[x][i];
			d[y]--;
			f[y]=max(f[y], f[x]+1);
			if (d[y]==0) q.push(y);
		}
		ans=max(f[x], ans);
	}
//	for (int i=1; i<=n; i++) printf("%d ", f[i]);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
#include <stdio.h>
#include <math.h>
#include <limits>

using namespace std;

int main(void) {
    int n;
    scanf("%d", &n);
    vector<int> a(n, 0);
    for(int i = 0; i < n; ++i) scanf("%d", &a[i]);

    int minv = a[0];
    int maxv = numeric_limits<int>().min();
    for(int i = 1; i < n; ++i) {
        maxv = max(maxv, a[i] - minv);
        minv = min(minv, a[i]);
    }
    cout << maxv << endl;
}



Measured memory_bytes: 3600
/+ dub.sdl:
    name "A"
    dependency "dcomp" version=">=0.0.2"
+/

import std.algorithm, std.range, std.stdio, std.math, std.conv, core.bitop;

// import dcomp.scanner;
// import dcomp.algorithm;

int n;
struct Edge {
    int to;
    long dist;
}
Edge[][] g;
long md;

long[2][] dfs(int p) {
    if (g[p].empty) {
        return [[0L, 0L]];
    }
    Edge le = g[p][0], re = g[p][1];
    auto lt = dfs(le.to);
    auto rt = dfs(re.to);
    if (lt.length > rt.length) {
        swap(le, re);
        swap(lt, rt);
    }
    long ld = le.dist, rd = re.dist;
    long[2][] ans;
    foreach (co; lt) {
        //co[1] + ld + rd + rco[0] <= md
        int idx = binSearch!((i){return co[1]+ld+rd+rt[i][0] > md;})(-1L, rt.length).to!int-1;
        if (idx == -1) continue;
        ans ~= [co[0]+ld, rt[idx][1]+rd];
        ans ~= [rt[idx][1]+rd, co[0]+ld];
    }
    sort(ans);
    if (ans.empty) return ans;
    long ma = 10L^^15;
    int co = 0;
    foreach (e; ans) {
        if (ma <= e[1]) continue;
        ma = min(ma, e[1]);
        ans[co] = e;
        co++;
    }
    return ans[0..co];
}

//md以下にできるか？
bool solve(long _md) {
    md = _md;
    return !dfs(0).empty;
}

int main() {
    auto sc = new Scanner();
    int n;
    sc.read(n);
    g = new Edge[][](n);
    foreach (i; 1..n) {
        int a; long b;
        sc.read(a, b); a--;
        g[a] ~= Edge(i, b);
    }

    writeln(binSearch!solve(-1L, 10L^^12));
    return 0;
}
/* IMPORT /Users/yosupo/Program/dcomp/source/dcomp/scanner.d */
// module dcomp.scanner;

class Scanner {
    import std.stdio : File, readln, stdin;
    import std.conv : to;
    import std.range : front, popFront, array, ElementType;
    import std.array : split;
    import std.traits : isSomeString, isDynamicArray;
    import std.algorithm : map;
    File f;
    this(File f = stdin) {
        this.f = f;
    }
    string[] buf;
    bool succ() {
        while (!buf.length) {
            if (f.eof) return false;
            buf = readln.split;
        }
        return true;
    }
    int read(Args...)(auto ref Args args) {
        foreach (i, ref v; args) {
            if (!succ()) return i;
            alias VT = typeof(v);
            static if (!isSomeString!VT && isDynamicArray!VT) {
                v = buf.map!(to!(ElementType!VT)).array;
                buf.length = 0;
            } else {
                v = buf.front.to!VT;
                buf.popFront();
            }
        }
        return args.length;
    }
}
/* IMPORT /Users/yosupo/Program/dcomp/source/dcomp/algorithm.d */
// module dcomp.algorithm;

//[0,0,0,...,1,1,1]で、初めて1となる場所を探す。pred(l) == 0, pred(r) == 1と仮定
T binSearch(alias pred, T)(T l, T r) {
    while (r-l > 1) {
        T md = (l+r)/2;
        if (!pred(md)) l = md;
        else r = md;
    }
    return r;
}


Measured memory_bytes: 46332
def solve():
    N, K = map(int, input().split())

    res = 0
    for b in range(K+1, N+1):
        res += b-K
        res += (N//b - 1) * (b-K)
        res += (N%b)-K+1 if N%b >= K else 0
    if K == 0:
        res -= N
    print(res)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

std::vector<size_t> make_vector(size_t n, size_t x) {
  return std::vector<size_t>(n, x);
}

template <class Tp>
std::vector<Tp> make_vector(size_t n, const Tp& x) {
  return std::vector<Tp>(n, x);
}

template <class... Ts>
auto make_vector(size_t n, size_t m, const Ts&... x) {
  return std::vector<decltype(make_vector(m, x...))>(n, make_vector(m, x...));
}

int main() {
  size_t N;
  scanf("%zu", &N);

  auto p = make_vector(N, N, 0);
  for (auto& pi: p)
    for (auto& pij: pi) scanf("%d", &pij);

  auto q = make_vector(N+1, N+1, 0);
  for (size_t i = 0; i < N; ++i)
    for (size_t j = 0; j < N; ++j)
      q[i+1][j+1] = q[i+1][j] + p[i][j];

  for (size_t i = 0; i < N; ++i)
    for (size_t j = 1; j <= N; ++j)
      q[i+1][j] += q[i][j];

  auto sum = [&](size_t u, size_t b, size_t l, size_t r) {
    int res = q[b][r];
    res -= q[b][l];
    res -= q[u][r];
    res += q[u][l];
    return res;
  };

  int res = 0;
  for (size_t i = 0; i < N; ++i)
    for (size_t j = i+1; j < N; ++j) {
      int frame = sum(i, j+1, 0, N);
      frame -= sum(i+1, j, 1, N-1);

      std::vector<int> left(N);
      for (size_t k = 1; k < N; ++k) {
        left[k] = left[k-1];
        left[k] -= sum(i, j+1, k-1, k);
        left[k] += sum(i+1, j, k, k+1);
      }

      std::vector<int> right(N);
      for (size_t k = N-1; k--;) {
        right[k] = right[k+1];
        right[k] -= sum(i, j+1, k+1, k+2);
        right[k] += sum(i+1, j, k, k+1);
      }

      for (size_t k = N-1; k--;)
        right[k] = std::max(right[k], right[k+1]);

      int cur = frame;
      for (size_t k = 0; k+1 < N; ++k)
        cur = std::max(cur, frame+(left[k]+right[k+1]));

      for (size_t k = 0; k < N; ++k)
        cur = std::max(cur, sum(i, j+1, k, k+1));

      res = std::max(res, cur);
    }

  for (size_t i = 0; i < N; ++i)
    for (size_t j = 0; j < N; ++j)
      for (size_t k = j+1; k <= N; ++k)
        res = std::max(res, sum(i, i+1, j, k));

  printf("%d\n", res);
}



Measured memory_bytes: 3220
implicit none
integer :: n,q
integer :: l,r,i,k
integer, allocatable :: c(:)
character(100000) :: s
read *,n,q
read *,s

allocate(c(0:N-1))
c(:) = 0
k = 0
i = 1
do while (i<N)
   if (s(i:i+1) == 'AC') then
      k = k + 1
      c(i) = k
      c(i+1) = k
      i = i + 2
   else if (s(i+1:i+1) /= 'A') then
      c(i) = k
      c(i+1) = k
      i = i + 2
   else
      c(i) = k
      i = i + 1
   endif
enddo

do i = 1, q
   read *,l,r
   write(6,'(i0)') c(r-1)-c(l-1)
enddo
end

Measured memory_bytes: 1572
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        x: isize,
        n: isize,
        p: [isize; n]
    }
    for i in 0..=100 {
        let a = x + i;
        let b = x - i;
        if !p.contains(&b) {
            println!("{}", b);
            return;
        }
        if !p.contains(&a) {
            println!("{}", a);
            return;
        }
    }
}


Measured memory_bytes: 2144
#include <stdio.h>
 
int main() {
    double x, y;
    int a,b,c,d,e,f;
    while(scanf("%d %d %d %d %d %d",&a ,&b ,&c ,&d ,&e ,&f )!=EOF) {
        x = (double)(e*c-b*f) / (double)(a*e-b*d);
        y = (double)(a*f-c*d) / (double)(a*e-b*d);
        if (x == -0.000000) x = 0.000000;
        if (y == -0.000000) y = 0.000000;
        printf("%.3f %.3f\n", x , y);
    }
    return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int main(){
int64_t D,N;
  cin>>D>>N;
  if(N<=99)
    cout<<pow(100,D)*N<<endl;
  else{
    int64_t ans=101*pow(100,D);
    cout<<ans<<endl;}
   return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            return ReadLong() < 1200 ? "ABC" : "ARC";
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27200
#include <stdio.h>
int main()
{
    int N;
    scanf("%d",&N);
    if((N%10==2)||(N%10==4)||(N%10==5)||(N%10==7)||(N%10==9))
    {
        printf("hon\n");
    }
    else if((N%10==0)||(N%10==1)||(N%10==6)||(N%10==8))
    {
        printf("pon\n");
    }
    else if(N%10==3)
    {
        printf("bon\n");
    }
}

Measured memory_bytes: 1612
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string str; cin >> str;
	bool n = false, s = false, e = false, w = false;
	rep(i, 0, str.size()) {
		if (str[i] == 'N')n = true;
		if (str[i] == 'S')s = true;
		if (str[i] == 'E')e = true;
		if (str[i] == 'W')w = true;
	}
	if ((n == s) && (e == w))puts("Yes");
	else puts("No");

	return 0;
}


Measured memory_bytes: 256
require 'prime'
c = 0
gets.to_i.times do |j|
  f = []
  next if (j + 1).even?
  (j+1).prime_division.each do |i|
    f.push(i[1])
  end
  c += 1 if f.map{|i| i + 1}.inject(:*) == 8
end
p c



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

int main(){
  string S,T;
  cin >> S >> T;
  int ans=0;
  if(S[0]==T[0])ans++;
  if(S[1]==T[1])ans++;
  if(S[2]==T[2])ans++;
  cout << ans << endl;
}


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

using namespace std;

int main(){
	int n; cin >> n;
	vector<string> words;
	for(int i = 0; i < n; ++i){
		string word; cin >> word;
		words.push_back(word);
	}
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			if(i == j) continue;
			if(words[i] == words[j]){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	for(int i = 0; i < n - 1; ++i){
		if(words[i][words[i].size()-1] != words[i+1][0]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
n=int(input())
fans=0
if(n<105):
    print(0)
else:
    for i in range(105,n+1,2):
        count=0
        for j in range(1,i+1):
            if(i%j==0):
                count+=1
        if(count==8):
            fans+=1
    print(fans)

Measured memory_bytes: 3060
f = list(map(int, input().split()))
s = list(map(int, input().split()))
yes = 0

for _ in range(4):
    s[0],s[2],s[5],s[3] = s[2],s[5],s[3],s[0]
    for _ in range(4):
        s[1],s[2],s[4],s[3] = s[2],s[4],s[3],s[1]
        if f == s:
            yes = 1

for _ in range(4):
    s[0],s[1],s[5],s[4] = s[1],s[5],s[4],s[0]
    for _ in range(4):
        s[1],s[2],s[4],s[3] = s[2],s[4],s[3],s[1]
        if f == s:
            yes = 1

if yes == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5612
#include<vector>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int c[26] = {0};
	int t,t1;
	for(t=0;t<n;t++)
	{
		getchar();
		for(t1=0;t1<m;t1++)
		{
			char cc;
			scanf("%c",&cc);
			c[cc-'a'] ++;
		}
	}
	int s4=0,s2=0,s1=0;
	for(t=0;t<26;t++)
	{
		s4 += c[t]/4;
		c[t] %= 4;
		s2 += c[t]/2;
		c[t] %= 2;
		s1 += c[t];
	}
	if(n%2==1 && m%2==1)
	{
		if(s1>1 || s2>n/2+m/2)
			printf("No\n");
		else
			printf("Yes\n");
	}
	else if(n%2 == 1)
	{
		if(s1>0 || s2>m/2)
			printf("No\n");
		else
			printf("Yes\n");
	}
	else if(m%2 == 1)
	{
		if(s1>0 || s2>n/2)
			printf("No\n");
		else
			printf("Yes\n");
	}
	else
	{
		if(s1>0 || s2>0)
			printf("No\n");
		else
			printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
str_n = str(n)

if n < 10:
    print(n)
    sys.exit(0)

ans = 0
while True:
    if n // 10 == 0:
        break
    ans += 9
    n //= 10

# 最上位から1桁下が全て9の場合、繰り下がりが不要
if set(str_n[1:]) == {'9'}:
    ans += n
else:
    ans += (n - 1)

print(ans)


Measured memory_bytes: 61864
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

char alphabet[] = {
    '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'
};

void chmax(int prev_max, int new_max){
    if (new_max > prev_max){
        prev_max = new_max;
    }
    return;
}

void chmin(int prev_min, int new_min){
    if (new_min > prev_min){
        prev_min = new_min;
    }
    return;
}

// 二分探索
// llrep(i,N){
//     b = B[i];
//     auto cntA = lower_bound(A.begin(), A.end(), b);//イテレータなのでそのままllに変換とかはできない
//     auto cntC = upper_bound(C.begin(), C.end(), b);
//     ll cntA_ll = distance(A.begin(), cntA);
//     ll cntC_ll = C.size() - distance(C.begin(), cntC);
//     cnt += (cntA_ll * cntC_ll);
// }


int main(){
    string S;
    cin >> S;
    int l=0;
    rep(i,S.length()){
        if (S[i]=='x') l ++;
    }
    if (l <= 7) cout << "YES" << endl;
    else cout << "NO" << endl; 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(void) {
  int H, W;
  std::cin >> H >> W;
  int tmp[W];
  char a[H][W];
  int flag = 0;
  int Hminace = 0;
  int Wminace = 0;
  int Huse[H];
  int Wuse[W];
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      std::cin >> a[i][j];
    }
  }

  for (int i = 0; i < H; ++i) {
    flag = 0;
    for (int j = 0; j < W; ++j) {
      if (a[i][j] != '.') {
        flag = 1;
      }
    }
    if (flag == 1) {
      Huse[i] = 1;
    }
    else {
      Huse[i] = 0;
    }
  }


  for (int j = 0; j < W; ++j) {
    flag = 0;
    for (int i = 0; i < H; ++i) {
      if (a[i][j] != '.') {
        flag = 1;
      }
    }
    if (flag == 1) {
      Wuse[j] = 1;
    }
    else {
      Wuse[j] = 0;
    }
  }


  for (int i = 0; i < H; ++i) {
    if (Huse[i] == 1) {
      flag = 0;
      for (int j = 0; j < W; ++j) {
        if (Wuse[j] == 1) {
          std::cout << a[i][j];
          flag = 1;
        }
      }
      if (flag == 1) {
        std::cout << std::endl;
      }
    }
  }
  return 0;
}


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

typedef long long ll;
typedef std::vector< int > VI;

const double EPS = 1e-10;
const double PI  = acos(-1);
const ll     INF = 1 << 30;

int main(int argc, char* argv[])
{
  int n;
  std::string s;
  std::cin >> n >> s;

  int ans = 0;

  for (int i = 1; i < n; i++) {
    std::string s1 = s.substr(0, i);
    std::string s2 = s.substr(i);
    std::sort(s1.begin(), s1.end());
    s1.erase(std::unique(s1.begin(), s1.end()), s1.end());
    std::sort(s2.begin(), s2.end());
    s2.erase(std::unique(s2.begin(), s2.end()), s2.end());

    int cnt = 0;
    std::string::iterator it1 = s1.begin();
    std::string::iterator it2 = s2.begin();
    while(it1 != s1.end() && it2 != s2.end()) {
      if (*it1 == *it2) {
	cnt++;
	it1++;
	it2++;
      } else {
	if (*it1 > *it2) {it2++;} else {it1++;}
      }
    }
    //std::cout << s1 << " " << s2 << " " << cnt << std::endl;
    ans = std::max(ans, cnt);
  }

  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		long c=0;
		for(long i=1;i<n;i++) {
			c+=i;
		}
		System.out.println(c);

	}

}

Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
using namespace std;
typedef pair<int,int> Pt;
typedef pair<int,Pt> P;
#define fr first
#define sc second
#define INF (1 << 26)
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
Pt st;
char mas[105][105];
int w,h,d[]={0,1,0,-1};
bool used[105][105];
int bfs(){
  priority_queue< P , vector<P> , greater<P> > que;
  fill_n(used[0],105*105,false);
  que.push(P(0,st));
  used[st.fr][st.sc] = true;
  while(!que.empty()){
    P p = que.top(); que.pop();
    rep(i,4){
      int nx = p.sc.fr + d[i] , ny = p.sc.sc + d[3-i] , pt = p.fr;
      if(nx < 0 || ny < 0 || nx >= h || ny >= w) return pt;
      if(used[nx][ny]) continue;
      if(mas[p.sc.fr][p.sc.sc] == '.' && mas[nx][ny] == '#') pt++;
      que.push(P(pt,Pt(nx,ny)));
      used[nx][ny] = true;
    }
  }
}
int main(){
  while(cin >> w >> h , w){
    rep(i,h) rep(j,w){
      cin >> mas[i][j];
      if(mas[i][j] == '&') st = Pt(i,j) , mas[i][j] = '.';
    }
    cout << bfs() << endl;
  }
}

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

int totalDigits(int N) {
  if(N == 0) {
    return 0;
  }
  int first = N % 10;
  return first + totalDigits((N - N % 10) / 10);
}
int main() {
  int N;
  cin >> N;
  int total = totalDigits(N);
  if(N % total == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N,M,Q;
int a[51],b[51],c[51],d[51];
int ans;
int A[13];

void dfs(int id,int p)
{
    if(id==N+1)
    {
        int sum=0;
        for(int i=0;i<Q;i++)
        {
            if(A[b[i]]-A[a[i]]==c[i])
                sum+=d[i];
        }
        ans=max(ans,sum);
        return;
    }
    else
    {
        for(int i=p;i<=M;i++)
        {
            A[id]=i;
            dfs(id+1,i);
        }
    }
}
int main()
{
    cin>>N>>M>>Q;
    for(int i=0;i<Q;i++)
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    dfs(1,1);
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b;
	scanf("%d%d", &a, &b);
	if(a <= 0 && 0 <= b) printf("Zero\n");
	else if(a <= 0){
		if((min(0, b)-a+1)%2 == 1) printf("Negative\n");
		else printf("Positive\n");
	}
	else printf("Positive\n");
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <iostream>
#include <unordered_set>
#include <map>

using namespace std;

int main() {
    vector<int> degrees(4, 0);
    for (int i = 1; i <= 3; i++) {
        int a, b;
        cin >> a >> b;
        degrees[a - 1]++;
        degrees[b - 1]++;
    }
    int one = 0, two = 0;
    for (int i = 0; i < 4; i++) {
        if (degrees[i] == 1) one++;
        if (degrees[i] == 2) two++;
    }
    if (one == 2 && two == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  long n ; // max n = 200000
  scanf("%ld",&n) ;

  long a[200000] ;
  long i ;

  for( i = 0 ; i < n ; i++){
    scanf("%ld",&a[i]) ;
  }

  long cnt, p ;
  cnt = 0 ;
  long j = 0 ;
  int t ; // true or false
  for( p = 1 ; p <= n ; p++ ){
    t = 0 ;
    for( i = j ; i < n ; i++ ){
      if( a[i] == p ){
        t = 1 ;
        cnt++ ;
        j = i+1 ;
        break ;
      }
    }
    if( t == 0 ){
      if( p == 1 ){
        cnt = n+1 ;
        break ;
      }else{
        break ;
      }
    }
  }

  printf("%ld\n", n-cnt) ;

  return 0 ;
}


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

sys.setrecursionlimit(10 ** 6)

def debug(s):
    if True:
        print(s)

def get_sieve_of_eratosthenes(n):
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while False:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

def filterTrue(a):
    return a

def solve(N: int, A: "List[int]"):
    A = sorted(A)
    table = [False for i in range(A[-1]+1)]
    alreadyDid = set()
    for a in A:
        table[a] = True
    for a in A:
        if a in alreadyDid:
            table[a] = False
            continue
        alreadyDid.add(a)
        i = a*2
        while i < len(table):
            table[i] = False
            i += a
    print(len(list(filter(filterTrue,table))))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 167056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int N;
    cin >> N;
    int a[100010];
    for(int i = 0;i < 100010;i++) {
        a[i] = 0;
    }
    for(int i = 0;i < N;i++) {
        int A;
        cin >> A;
        a[A - 1]++;
        a[A]++;
        a[A + 1]++;
    }
    int ret = 0;
    for(int i = 0;i < 100010;i++) {
        ret = max(ret,a[i]);
    }
    cout << ret << endl;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.inp","r",stdin);
    long long int n,h[100000],s[100000],i;
    cin >> n;
    for ( i = 1; i <= n; i++)
    {
        cin >> h[i];
    }
    s[1] = 0;
    s[2] = abs(h[2] - h[1]);
    for (i = 3; i <= n; i++)
    {
        s[i] = min((s[i-1] + abs(h[i-1] - h[i])), (s[i-2] + abs(h[i-2] - h[i])));
    }
    cout << s[n] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<bitset>
#include<deque>
#include<iterator>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include <cmath>
#include<vector>
using namespace std;
#define pb push_back
#define pf push_front
#define M 1000000007
#define ll long long int
int main()
 {
 	 
     ll n;
     cin>>n;
     double ans;
    ans=2*3.14159265358979323846*n;
    printf("%.20lf",ans);
     return 0;
 }

Measured memory_bytes: 3764
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define rep(i, n) for(int i = 0;i < n;i++)
#define repb(i, n) for(int i = n;i >= 0;i--)
#define reps(i, m, n) for(int i = m;i < n;i++)
#define repsb(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;


int main(){
	int m,mi,mx,n;
	while(1){
		cin>>m>>mi>>mx;
		if(m==0&&mi==0&&mx==0)	break;
		int p[10000],d=0;
		reps(i,1,m+1){
			cin>>p[i];
		}
		n=0;
		reps(i,mi,mx+1){
			if(d<=p[i]-p[i+1]){
				d=p[i]-p[i+1];
				n=i;
			}
		}
		cout<<n<<endl;
	}

	return 0;
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
  vector<string> s(n);
  int i;
  rep(i,n)cin>>s[i];
  sort(all(s));
  string now=s[0];
  int ans=1;
  for(i=1;i<n;i++)
  {
    if(now!=s[i])
    {
      now=s[i];
      ans++;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 9548
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>
#include <iomanip>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	string s;
	cin >> s;
	
	int cnt1 = ((int)s.size() - 1) * 9;
	
	if( (int)(s.front() - '0') > 1 ) {
		cnt1 += (int)(s.front() - '0') - 1;
	}
	
	int cnt2 = 0;
	ll tmp = stoll(s);
	
	while( tmp ) {
		cnt2 += (tmp % 10);
		tmp /= 10;
	}
	
	cout << max(cnt1, cnt2) << endl;
	
	return 0;
}


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

int main() {
    ll N, K;
    cin >> N >> K;
    map<ll, ll> mp;
    for (int i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        mp[a] += b;
    }

    ll cnt = 0;
    for (auto p : mp) {
        if (cnt + p.second >= K) {
            cout << p.first << endl;
            return 0;
        }
        cnt += p.second;
    }
}


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

int main() {
  int64_t n;
  std::cin >> n;

  int64_t ans = 1, i = 1;
  while (i * i <= n) {
    ans = i * i;
    i++;
  }

  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int B = 18;
int mark[B];
int numbers[1 << B];
int n, a, b;
 
void solve(int st, int en, int set_bit, int rest, int mask){
    //cout << st << " , " << en << " setando " << set_bit << endl;
    for(int i = st ; i <= en ; i++){
        numbers[i] |= set_bit;
    }    
    
    if(rest <= 1){
        return;
    }
    
    int find = -1, se = -1;
    
    for(int j = 0 ; j < n ; j++){
        if(!mark[j]){
            if(find == -1 && (numbers[st] & (1 << j)) != (numbers[en] & (1 << j)))
                find = j;
            else
                se = j;
        }
    }
    
    assert(find != -1 && se != -1);
    mask ^= (1 << find);
    
    mark[find] = true;
    
    int mid = (st + en) >> 1;
    
    numbers[mid] |= (numbers[st] & mask) ^ (1 << se);
    numbers[mid + 1] |= (numbers[st] & mask) ^ (1 << se);
    
    solve(st, mid, numbers[st] & (1 << find), rest - 1, mask);
    solve(mid + 1, en, numbers[en] & (1 << find), rest - 1, mask);
    
    mark[find] = false;
}

int main() {
    cin >> n >> a >> b;
    
    numbers[0] = a;
    numbers[(1 << n) - 1] = b;
    
    if(n == 1){
        cout << "YES" << endl;
        cout << a << " " << b << endl;
        return 0;
    }
    
    if(__builtin_popcount(a ^ b) & 1){
        for(int i = 0 ; i < n ; i++){
            if((a & (1 << i)) != (b & (1 << i))){
                int mask = (1 << n) - 1;
                mask ^= (1 << i);
                
                int ss = (i + 1) % n;
                
                mark[i] = true;
                int mid = ((1 << n) - 1) >> 1;
                
                numbers[mid] = numbers[mid + 1] = (numbers[0] & mask) ^ (1 << ss);
                
                solve(0, mid, (a & (1 << i)), n - 1, mask);
                solve(mid + 1, (1 << n) - 1, (b & (1 << i)), n - 1, mask);
                break;
            }
        }
        
        cout << "YES" << endl;
        
        for(int i = 0 ; i < (1 << n) ; i++){
            cout << numbers[i] << ' ';
        }
        
        cout << endl;
    }else{
        cout << "NO" << endl;
    }
    
	return 0;
}

Measured memory_bytes: 1536
import numpy as np
W, H, N = map(int, input().split())
P = [tuple(map(int, input().split())) for _ in range(N)]
rect = np.ones([W, H])
for p in P:
    if p[2] == 1:
        rect[:p[0]] = 0
    elif p[2] == 2:
        rect[p[0]:] = 0
    elif p[2] == 3:
        rect[:, :p[1]] = 0
    elif p[2] == 4:
        rect[:, p[1]:] = 0
print(int(np.sum(rect)))

Measured memory_bytes: 20800
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, M; 
  cin >> N >> M;

  vector<int> dp(1<<N, INF);
  dp[0] = 0;
  REP(i, M){
    int cost, b;
    cin >> cost >> b;

    int bit = 0;
    REP(j, b) {
      int c;
      cin >> c; c--;
      bit |= (1<<c);
    }

    REP(j, (1<<N)){
      chmin(dp[j|bit], dp[j]+cost);
    }
  }

  int ans = dp[(1<<N)-1];
  if(ans == INF) ans = -1;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  s+="XXX";
  int ctr=0;
  for(int i=0;i<n;i++){
    if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C'){
      ctr++;
    }
  }
  cout<<ctr;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <cmath>
#include <cstdio>
using namespace std;

#define PI 4*atan(1);

int main(){
  int a, b, asum = 0, bsum = 0;
  for(int i = 0; i < 4; i++){
    cin >> a;
    asum += a;
  }
  for(int i = 0; i < 4; i++){
    cin >> b;
    bsum += b;
  }
  if(asum >= bsum)cout << asum << endl;
  if(asum < bsum)cout << bsum << endl;
}

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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007
void printbit(int u){if(u==0)cout<<0;else{int s=0,k=0;for(;0<u;u>>=1,k++)s=(s<<1)|(u&1);for(;0<k--;s>>=1)cout<<(s&1);}}

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}

int width,height;
int m,n;

ll data[100010];

int main(){
    int i,j,k;
    int x,y,a,b;
    
    cin >> n >> m;
    
    ll result = 0;
    
    for (i=0;i<n;i++){
        scanf("%lld",data+i);
    }
    
    for (i=0;i<n-1;i++){
        a = data[i]+data[i+1];
        if (a <= m) continue;
        b = a - m; // gap
        result+=b;
        if (data[i]<=m){
            data[i+1]-=b;
        }else{
            data[i]-=b-data[i+1];
            data[i+1]=0;
        }
    }
    
    cout << result << endl;
    
    

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
   int n,m,x;
   cin>>n>>m>>x;
   int s1=0,sn=0;
    int a[m];
    rep(i,0,m) {
        cin>>a[i];
        if (a[i]<x) s1++;
        else sn++;
    }
    cout<<min(s1,sn);
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, n, m) for(int i = n; i < (int)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll MOD = 1000000007;

void dfs(string s, ll num, ll N) {
    if (s.length() == N) {
        PRINT(s);
        return;
    }
    REP(i, num+1) {
        char c = 'a' + i;
        string tmp = s + c;
        if (i == num) dfs(tmp, num+1, N);
        else dfs(tmp, num, N);
    }
    return;
}

int main()
{
    ll N;
    cin >> N;
    dfs("a", 1, N);
    return 0;
}


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

using namespace std;
const ll N=100010;

int main()
{
    ll n;
    cin>>n;
    unordered_map<string,ll> m;
    ll ans=0;
    for(ll i=0;i<n;++i)
    {
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        ans+=m[s];
        m[s]+=1;
    }
    cout<<ans<<endl;

    return (0);
}


Measured memory_bytes: 10660
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    string s; cin >> s;
    ll ans = 0;
    int n = s.size();
    for(int bit = 0; bit < (1 << n-1); bit++){
        string t = ""; int cnt = 0;
        for(int i = 0; i < n; i++){
            t += s[cnt++];
            if(i < n-1 && bit & (1 << (n-2-i))){
                t += '+';
            }
        }
        ll k = 0;
        for(int i = 0; i < t.size(); i++){
            if(i == t.size()-1){
                k = k*10+(t[i]-'0');
                ans += k;
                k = 0;
            }
            else{
                if(t[i] != '+'){
                    k = k*10+(t[i]-'0');
                }
                else{
                    ans += k;
                    k = 0;
                }
            }
        }
    }
    cout << ans << endl;
    system("pause");
}

Measured memory_bytes: 504