akhauriyash/Code-Regression huggingface dataset:
class BinaryTree {
  constructor(n) {
    this.nodes = [];
    for (let i = 0; i < n; i++) this.nodes[i] = {id: -1, parentId: -1, leftId: -1, rightId: -1}
  }

  get root() { return this.nodes.find(n => n.parentId === -1); }

  add(id, leftId, rightId) {
    let n = this.nodes[id];
    [n.id, n.leftId, n.rightId] = [id, leftId, rightId];
    if (leftId !== -1) this.find(leftId).parentId = id;
    if (rightId !== -1) this.find(rightId).parentId = id;
  }

  find(id) { return this.nodes[id] || {}; }

  preorder(id = this.root.id) {
    if (id === -1) return;
    let n = this.find(id);
    process.stdout.write(` ${id}`);
    this.preorder(n.leftId);
    this.preorder(n.rightId);
  }

  inorder(id = this.root.id) {
    if (id === -1) return;
    let n = this.find(id);
    this.inorder(n.leftId);
    process.stdout.write(` ${id}`);
    this.inorder(n.rightId);
  }

  postorder(id = this.root.id) {
    if (id === -1) return;
    let n = this.find(id);
    this.postorder(n.leftId);
    this.postorder(n.rightId);
    process.stdout.write(` ${id}`);
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  let tree = new BinaryTree(n);
  lines.map(l => l.split(' ').map(Number)).forEach(line => tree.add(...line));
  console.log('Preorder');
  tree.preorder();
  console.log('\nInorder');
  tree.inorder();
  console.log('\nPostorder');
  tree.postorder();
  console.log();
})();



Measured memory_bytes: 17252
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    string s[3];
    rep(i, 3) cin >> s[i];
    rep(i, 3) reverse(s[i].begin(), s[i].end());
    int turn = 0;
    while(1) {
        int x = s[turn].back() - 'a';
        s[turn].pop_back();
        turn = x;
        if(s[turn].empty()) break;
    }
    cout << (char)('A' + turn);
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Int
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

iscanl :: (Int -> a -> b -> a) -> a -> V.Vector b -> V.Vector a
iscanl !k !a !v = V.scanl' (\(!x) (!i, !v) -> k i x v) a (V.indexed v)

iscanlU
  :: (VU.Unbox a, VU.Unbox b)
  => (Int -> a -> b -> a)
  -> a
  -> VU.Vector b
  -> VU.Vector a
iscanlU !k !a !v = VU.scanl' (\(!x) (!i, !v) -> k i x v) a (VU.indexed v)

ipostscanlU
  :: (VU.Unbox a, VU.Unbox b)
  => (Int -> a -> b -> a)
  -> a
  -> VU.Vector b
  -> VU.Vector a
ipostscanlU !k !a !v = iscanlU (\(!i) (!a) (!b) -> k (i + 1) a b)
                               (k 0 a (VU.unsafeHead v))
                               (VU.unsafeTail v)

solve :: Int -> Int -> V.Vector (VU.Vector Bool) -> Int
solve !h !w !ahw = VU.last $ V.last dp
 where
  add !x !y = (x + y) `mod` (10 ^ 9 + 7)

  dp :: V.Vector (VU.Vector Int)
  dp = iscanl
    ( \(!i) (!acc) (!row) -> ipostscanlU
      (\(!j) (!prev) (!ch) -> if ch then 0 else acc VU.! j `add` prev)
      0
      row
    )
    (VU.generate w (\(!i) -> if i == 0 then 1 else 0))
    ahw

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (h, w) <-
    (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  ahw <-
    V.replicateM h
    $   VU.unfoldrN w (\bs -> Just (B.head bs == '#', B.tail bs))
    <$> B.getLine
  print $ solve h w ahw


Measured memory_bytes: 6524
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func getStirlingType2(n, k, p int) [][]int {
	table := make([][]int, n+1)
	table[1] = make([]int, k+1)
	table[1][1] = 1
	for i := 2; i <= n; i++ {
		table[i] = make([]int, k+1)
		for j := 1; j <= k; j++ {
			table[i][j] = (table[i-1][j-1] + j*table[i-1][j]) % p
		}
	}
	return table
}

func main() {
	scanner.Split(bufio.ScanWords)

	prime := 1000000000 + 7

	nBalls := nextInt()
	nBoxes := nextInt()

	if nBalls < nBoxes {
		fmt.Println(0)
	} else {
		table := getStirlingType2(nBalls, nBoxes, prime)
		fmt.Println(table[nBalls][nBoxes])
	}
}



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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;
typedef unsigned int i64;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define bye(x) return void (cout <<(x) << endl);
#define all(e) (e).begin(), (e).end()
#define pb push_back

template <typename T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}


template <typename T>
void printV(vector<T> A) {
  if (A.empty()) cerr << "EMTPY\n";
  else { 
    cerr << "[";
    for (int i = 0; i < A.size() -1 ; ++i) {
      cerr << A[i] << ", ";
    }
    if (A.size()) cerr << A.back() << "]\n";
  }
}


template <typename T>
void printVV(vector<vector<T>> A) {
  cerr << "[";
  for (auto v : A) {
    printV<T>(v);
  }
  cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

int main(int argc, char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<vector<pair<int,int>>> graph(n+1);
  for (int i = 0; i < n-1; i++) {
    int a, b; cin >> a >> b;
    graph[a].push_back({b,i});
    graph[b].push_back({b,i});
  }

  int K = 0;
  vector<int> ans(n-1);
  function<void(int,int)> Dfs = [&] (int node, int c) {
    int start = 1;
    for (auto& p: graph[node]) {
      int u = p.first;
      int idx = p.second;
      if (ans[idx] != 0) continue;
      if (start == c) start += 1;
      ans[idx] = start;
      Dfs(u,start);
      ++start;
    }
    K = max(K, start-1);
  };
  Dfs(1,0);
  cout << K << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << '\n';
  }

  return 0;
}



Measured memory_bytes: 8320
#include<bits/stdc++.h>
const long double pi=acos(-1);
using namespace std;
string s[1000];
bool cmp(string s1,string s2)
{
	return s1<s2;
}
int main()
{
	int n,l;
	cin>>n>>l;
	for(int i=0;i<n;i++)
	cin>>s[i];
	sort(s,s+n,cmp);
	string s1="";
	for(int i=0;i<n;i++)
	s1+=s[i];
	cout<<s1<<"\n";
	return 0;
}

Measured memory_bytes: 256
// 双方向リスト

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

struct Node
{
    int key;
    Node *pre, *next;
};

Node *nil;

void init();
Node* find(int x);
void deleteNode(Node *t);

void insert(int x);
void de_lete(int x);
void deleteFirst();
void deleteLast();
void dump();

int main(){
    int key,n,i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;

    scanf("%d", &n);
    init();

    for(i = 0; i < n; i++){
        scanf("%s", com);
        if(com[0] == 'i'){
            scanf("%d", &key);
            insert(key);
            np++;size++;
        }else if(com[0] == 'd'){
            if(strlen(com) > 6){
                if(com[6] == 'F'){deleteFirst();}
                else {deleteLast();}
            }else{
                scanf("%d", &key);
                de_lete(key); nd++;
            }
            size--;
        }
    }
    dump();
    return 0;
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->pre = nil;
}

Node* find(int x){
    Node *now = nil->next;
    while(now != nil && now->key != x){
        now = now->next;
    }
    return now;
}

void deleteNode(Node *t){
    if(t == nil) return;
    t->pre->next = t->next;
    t->next->pre = t->pre;
    free(t);
}

void insert(int x){
    Node *n = (Node *)malloc(sizeof(Node));
    n->key = x;
    n->next = nil->next;
    nil->next->pre = n;
    nil->next = n;
    n->pre = nil;
}

void de_lete(int x){
    deleteNode(find(x));
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){

    deleteNode(nil->pre);
}

void dump(){
    Node *n = nil->next;
    int p = 0;
    while(1){
        if(n == nil) break;
        if(p++ > 0) printf(" ");
        printf("%d", n->key);
        n = n->next;
    }
    printf("\n");
}


Measured memory_bytes: 34400
N, M = map(int, input().split())
image = []
template = []
ans = "No"

for _ in range(N):
    row = list(input())
    image.append(row)

for _ in range(M):
    row = list(input())
    template.append(row)

for h in range(0, N-(M-1)):
    for w in range(0, N-(M-1)):
        if image[h][w] == template[0][0]:
            flag = True
            for h2 in range(M):
                for w2 in range(M):
                    if image[h+h2][w+w2] != template[h2][w2]:
                        flag = False
                        break
            if flag == True:
                ans = "Yes"
                break

print(ans)


Measured memory_bytes: 3316
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
#define INF (3000)
int main(){
  int m1=INF,m2=INF;
  for(int i=0;i<3;i++){
    int a;
    scanf("%d",&a);
    m1 = min(a,m1);
  }
  for(int i=0;i<2;i++){
    int a;
    scanf("%d",&a);
    m2 = min(a,m2);
  }
  printf("%d\n",m1+m2-50);
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll K;
    cin >> K;
    ll N = 50;
    ll q = K / N;
    ll r = K % N;
    vector<ll> A(N);
    rep(i,N){
        A[i] = i;
    }
    rep(i,N){
        A[i] += q;
    }
    rep(i,r){
        A[i] += N+1;
        rep(j,N){
            A[j]--;
        }
    }
    cout << N << endl;
    PR(A,N);
    /*
    if(q!=0){
        rep(i,N){
            A[i] = N;
        }
        K -= N;
        ll qq = K/N;
        ll rr = K%N;
        rep(i,N){
            A[i] += qq;
        }
        rep(i,rr){
            A[i]++;
        }
    }else{
        rep(i,r){
            A[i] = N;
        }
    }
    cout << N << endl;
    PR(A,N);*/
}

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

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

ans = 0


def calc(data):
    ans = 0
    flag = [1]*n
    for i in range(len(data)):
        num = data[i]
        sum_ = sum(flag[:max(0, num-1)])
        ans += sum_*math.factorial(len(data)-i-1)
        flag[num-1] = 0
    return ans


ans = calc(p)-calc(q)

print(abs(ans))

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}
int comb(int n, int k) {
	k = min(k, n - k);
	int x = 1, y = 1;
	rep(i, k) {
		y *= i + 1;
		y %= MOD;
	}
	for (int i = n - k + 1; i <= n; i++) {
		x *= i;
		x %= MOD;
	}
	return x * modinv(y, MOD) % MOD;
}

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

	int n, m;
	cin >> n >> m;
	cout << n * (n - 1) / 2 + (m - 1) * m / 2 << endl;
	
	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)

void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

int run(istream& in, ostream& out) {
    string S;
    in >> S;
    string ans(S.size(), 'x');
   out << ans << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
bool vis[105];
int main()
{
	memset(vis, true, sizeof(vis));
	int x, n;
	cin >> x >> n;
	for (int i = 1; i <= n; i++)
	{
		int p;
		cin >> p;
		vis[p] = false;
	}
	for (int i = 0; i <= 100; i++)
	{
		if (vis[x - i])
		{
			cout << x - i << endl;
			return 0;
		}
		else if (vis[x + i])
		{
			cout << x + i << endl;
			return 0;
		}

	}
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

char c;

signed main() {
	cin >> c;
	if (0 <= c - 'a'&&c - 'a' < 26) cout << 'a' << endl;
	else cout << 'A' << endl;
}


Measured memory_bytes: 3592
x=input()
a=[0]
d={}
d[0]=0
for i in range(1,1000):
	a+=[i**5]
	a+=[-i**5]
	d[i**5]=i
	d[-i**5]=-i

a.sort()
for i in range(len(a)):
    if x+a[i] in a:
        print d[a[i]+x],d[a[i]]
        break

Measured memory_bytes: 65680
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll N;
    cin >> N;
    vector<ll> as(N);
    for (size_t i = 0; i < N; i++){
        cin >> as.at(i);
    }
    vector<ll> mod(N, 0);
    for (size_t i = 0; i < N; i++){
        while (as.at(i) % 2 == 0){
            mod.at(i)++;
            as.at(i) /= 2;
        }
    }
    ll ret{0};
    for (size_t i = 0; i < N; i++){
        ret += mod.at(i);
    }
    cout << ret;

    return 0;
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}

long long arr[51], nck[51][51];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    for(int i = 0; i < n; ++i)
        cin >> arr[i];

    sort(arr, arr + n, greater<long long>());

    nck[0][0] = 1;
    for(int i = 1; i < 51; ++i)
        for(int j = 0; j <= i; ++j)
            nck[i][j] = nck[i - 1][j] + (j > 0 ? nck[i - 1][j - 1] : 0);

    long double tot = 0;
    int cnt = 0;

    for(int i = 0; i < a; ++i){
        tot += arr[i];
        if(i > 0 && arr[i] != arr[i - 1])
            cnt = 0;
        ++cnt;
    }

    int iden = 0;

    for(int i = 0; i < n; ++i)
        if(arr[i] == arr[a])
            ++iden;

    cout << setprecision(7) << fixed << tot / ((long double) a) << "\n";

    // iden choose cnt

    // if all items are the same, do it for a..b

    long long prod = nck[iden][cnt];

    if(a == cnt){
        for(int i = a + 1; i <= b; ++i)
            prod += nck[iden][i];
    }

    cout << prod << "\n";

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int h,w;
vvi a;
vector<vvi> dp;

int main(){
	cin>>h>>w;
	a=vvi(h+1,vi(w+1));
	dp=vector<vvi>(h+1,vvi(h+1,vi(w)));
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++){
		char c;
		cin>>c;
		if(c=='#') a[i][j]++;
	}
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) a[i][j]+=a[i][j-1];
	for(int j=1;j<=w;j++) for(int i=1;i<=h;i++) a[i][j]+=a[i-1][j];
	for(int i=0;i<h;i++) for(int j=i+1;j<=h;j++){
		int I=w;
		for(int k=w-1;k>=0;k--){
			while(1){
				int t=a[j][I]-a[j][k]-a[i][I]+a[i][k];
				if(!t||t==(j-i)*(I-k)) break;
				I--;
			}
			dp[i][j][k]=I;
		}
	}
	int res=0;
	while(1){
		if(dp[0][h][0]==w) break;
		vector<vvi> DP(h+1,vvi(h+1,vi(w)));
		for(int i=0;i<h;i++) for(int k=0;k<w;k++){
			int I=i;
			for(int j=i+1;j<=h;j++){
				while(I<j&&min(dp[i][I][k],dp[I][j][k])<=min(dp[i][I+1][k],dp[I+1][j][k])) I++;
				int tmp=dp[i][j][k];
				DP[i][j][k]=max(min(dp[i][I][k],dp[I][j][k]),(tmp==w?w:dp[i][j][tmp]));
			}
		}
		dp=DP;res++;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 53072
from collections import deque

def dfs(snuke,fnuke):
    global n,a,b,c,d,s
    que = deque()
    que.append([snuke,fnuke])
    lq = 1
    while(lq > 0):
        tmp = que.pop()
        tmps = tmp[0]
        tmpf = tmp[1]
        lq-=1
        if tmps == c and tmpf == d:
            return True
        if tmps+1 != tmpf and s[tmps] =="." and tmps != c:
            que.append([tmps+1,tmpf])
            lq+=1
        elif tmps+2 != tmpf and s[tmps+1] =="." and tmps != c:
            que.append([tmps+2,tmpf])
            lq+=1
        elif tmpf+1 != tmps and s[tmpf] =="." and tmpf != d:
            que.append([tmps,tmpf+1])
            lq+=1
        elif tmpf+2 != tmps and s[tmpf+1] =="." and tmpf != d:
            que.append([tmps,tmpf+2])
            lq+=1
    return False

n,a,b,c,d = map(int,input().split())
s = input()
s += "###"
snuke = a
fnuke = b
if dfs(snuke,fnuke):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3892
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
    static long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if(N >= 30){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }


    }

}




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

int main(int argc, char** argv) {
	unordered_set<string> us;
	int N;
	cin >> N;
	string s;
	int num = 0;
	for (int i = 0; i < N; i++) {
		cin >> s;
		if (us.find(s) == us.end()) {
			num++;
			us.insert(s);
		}
	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 17648
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
const int inf = 1e9+5;
int op(int a,int b){
  return max(a,b);
}
int e(){
  return -inf;
}
int val;
bool f(int x){
  return x < val;
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,q;
  cin >> n >> q;
  vector<int> a(n+1,-inf);
  for(int i = 1; i <= n; ++i) cin >> a[i];
  segtree<int,op,e> seg(a);
  while(q--){
    int t,l,r,pos;
    cin >> t;
    if(t == 1){
      cin >> pos >> val;
      seg.set(pos,val);
    }
    else if(t == 2){
      cin >> l >> r;
      cout << seg.prod(l,r+1) << '\n';
    }
    else{
      cin >> pos >> val;
      int ans = seg.max_right<f>(pos);
      cout << ans << '\n';
    }
  }
  return 0;
}

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

int main() {
  string S;
  cin>>S;
  
  if((S[0]==S[1]) && (S[1]==S[2])||(S[1]==S[2]) &&(S[1]==S[3])){
    cout<<"Yes";
    
  }
  
  else cout<<"No";
  
}

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

int main() {
    int n; cin >> n;
    vector<double> p(n, 0);

    for (int i = 0; i < n; i += 1)
        cin >> p[i];
    
    vector<vector<double>> dp(2, vector<double> (n + 1, 0));
    
    dp[1][0] = 1.0;

    for (int i = 0; i < n; i += 1) {
        int now = (i % 2);
        int then = 1 - now;

        for (int j = 0; j <= n; j += 1) {
            dp[now][j] = (1 - p[i]) * dp[then][j];
            if (j > 0)
                dp[now][j] += p[i] * dp[then][j - 1];
        }
    }
    
    double ans = 0;

    for (int i = 0; i <= n; i += 1)
        if (i > n - i)
            ans += dp[(n - 1) % 2][i];
    
    cout.precision(15);
    cout << ans << "\n"; 
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;
int isSubstring(string s1, string s2) 
{ 
    int M = s1.length(); 
    int N = s2.length(); 
    for (int i = 0; i <= N - M; i++) { 
        int j; 
        for (j = 0; j < M; j++) 
            if (s2[i + j] != s1[j]) 
                break; 
        if (j == M) 
            return i; 
    } 
    return -1; 
} 
int main()
{
    rkc;
    /*string s,t;
    cin>>s>>t;
    if(s.length()==t.length())
    {
        int c=0;
        sort(s.begin(),s.end());
        sort(t.begin(),t.end());
        fl(i,0,s.length())if(s[i]==t[i])c++;
        if(c==t.length())cout<<"array";
        else cout<<"need tree";
    }
    else
    {
        int res=isSubstring(s,t),res1=isSubstring(t,s);
        if(res!=-1||res1!=-1)
        cout<<"automaton";
        else
        {
                sort(s.begin(),s.end());
                sort(t.begin(),t.end());
                if(isSubstring(s,t)||isSubstring(t,s))cout<<"both";
                else cout<<"need tree";
        }
    }*/
    /*string s,t="",w="";
    cin>>s;
    t+=s[0]+s[1];
    w+=s[2]+s[3];
    cout<<t<<" "<<w;
    /*if((t=="01"||t=="02"||t=="03"||t=="04"||t=="05"||t=="06"||t=="07"||t=="08"||t=="09"||t=="10"||t=="11"||t=="12")&&(w=="01"||w=="02"||w=="03"||w=="04"||w=="05"||w=="06"||w=="07"||w=="08"||w=="09"||w=="10"||w=="11"||w=="12"))
    cout<<"AMBIGUOUS";
    if((t=="01"||t=="02"||t=="03"||t=="04"||t=="05"||t=="06"||t=="07"||t=="08"||t=="09"||t=="10"||t=="11"||t=="12")&&(w!="01"||w!="02"||w!="03"||w!="04"||w!="05"||w!="06"||w!="07"||w!="08"||w!="09"||w!="10"||w!="11"||w!="12"))
    cout<<"MMYY";
    if((t!="01"||t!="02"||t!="03"||t!="04"||t!="05"||t!="06"||t!="07"||t!="08"||t!="09"||t!="10"||t!="11"||t!="12")&&(w=="01"||w=="02"||w=="03"||w=="04"||w=="05"||w=="06"||w=="07"||w=="08"||w=="09"||w=="10"||w=="11"||w=="12"))
    cout<<"YYMM";
    if(t=="00"||w=="00")
    cout<<"NA";
    if(t>=97&&t<=109&&w>=97&&w<=109)
    cout<<"AMBIGUOUS";*/
    ll n;
    cin>>n;
    ll q=n%100;
    ll w=n/100;
    if((q>=1&&q<=12&&w>=1&&w<=12))cout<<"AMBIGUOUS";
    else if((q==0||q>12)&&(w>=1&&w<=12))cout<<"MMYY";
    else if((q>=1&&q<=12)&&(w>12||w==0))cout<<"YYMM";
    else cout<<"NA";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  
  if (c == 'a'){
    cout << "vowel" << endl;
  }
  
  else if (c == 'e'){
    cout << "vowel" << endl;
  }
  
  else if (c == 'i'){
    cout << "vowel" << endl;
  }
  
  else if (c == 'o'){
    cout << "vowel" << endl;
  }
  
  else if (c == 'u'){
    cout << "vowel" << endl;
  }
  
  else {
    cout << "consonant" << endl;
  }
}
    

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c;
  d=a*100+b*10+c;
  if(d%4==0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input! {n:usize};
    println!("ABC{:3}", n);
}


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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
cout.tie(0);
long long int h, w,ans;
cin >> h >> w;
if (h % 2 == 0){
ans = h/2 * w;
}else{
if (w % 2 == 0){
ans = h * w/2;
}else{
ans = h * w/2 + 1;
}
}
if (w == 1 || h == 1){
ans = 1;
}
cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int N,a[100005],b[100005],color[100005],K=0;
vector<long long int> vec[100005];
queue<long long int > task;
map<pair<long long int,long long int>, long long int>coloring;
int main() {
	cout << fixed << setprecision(18);
	cin>>N;
	for(int i=0;i<N-1;i++){
		color[i]=INF;
		cin>>a[i]>>b[i];
		a[i]--;
		b[i]--;
		if(a[i]>b[i]){swap(a[i],b[i]);}
		vec[a[i]].push_back(b[i]);
		vec[b[i]].push_back(a[i]);
	}
	color[N-1]=INF;
	color[0]=0;
	task.push(0);
	while(!task.empty()){
		long long int now =task.front();
		task.pop();
		long long int nextcolor=1;
		for(int i=0;i<vec[now].size();i++){
			
			if(color[vec[now][i]]==INF){
				//cout<<now<<" "<<vec[now][i];
				if(nextcolor==color[now]){nextcolor++;}
				color[vec[now][i]]=nextcolor;
				coloring[{min(now,vec[now][i]),max(now,vec[now][i])}]=nextcolor;
				K=max(nextcolor,K);
				task.push(vec[now][i]);
				nextcolor++;
			}
		}
		//cout<<now<<endl;
	}
	cout<<K<<endl;
	for(int i=0;i<N-1;i++){
		//cout<<"Debug "<<color[i]<<endl;
		cout<<coloring[{a[i],b[i]}]<<endl;
	}
	
} 

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

using ll = long long;
template <class T> using p = pair<T, T>;
template <class T> using vt = vector<T>;

#define rep(i, n)   for (int i = 0; i < (n); i++)
#define sz(x)       (int)(x).size()
#define eb          emplace_back
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

  int h, w, ch, cw, dh, dw;
  cin >> h >> w >> ch >> cw >> dh >> dw;

  vt <vt<bool> > v(h);
  rep (i, h) {
    v[i].resize(w);
    rep (j, w) {
      char c;
      cin >> c;
      v[i][j] = (c == '.');
    }
  }

  set <p <int> > s;
  s.insert(p <int> (ch - 1, cw - 1));
  deque <p<int> > d;
  d.pb(p<int> (ch - 1, cw - 1));
  int cnt = 0;
  while (!d.empty() && !s.count(p <int> (dh - 1, dw - 1))) {
    deque <p<int> > newd = d;
    while (!newd.empty()) {
      int n = sz(newd);
      while (n--) {
        p <int> t = newd.front();
        newd.pop_front();
        if (t.fi - 1 >= 0 && v[t.fi - 1][t.se] && !s.count(p <int> (t.fi - 1, t.se))) {
          newd.pb(p <int> (t.fi - 1, t.se));
          s.insert(p <int> (t.fi - 1, t.se));
          d.pb(p <int> (t.fi - 1, t.se));
        }
        if (t.fi + 1 < h && v[t.fi + 1][t.se] && !s.count(p <int> (t.fi + 1, t.se))) {
          newd.pb(p <int> (t.fi + 1, t.se));
          s.insert(p <int> (t.fi + 1, t.se));
          d.pb(p <int> (t.fi + 1, t.se));
        }
        if (t.se - 1 >= 0 && v[t.fi][t.se - 1] && !s.count(p <int> (t.fi, t.se - 1))) {
          newd.pb(p <int> (t.fi, t.se - 1));
          s.insert(p <int> (t.fi, t.se - 1));
          d.pb(p <int> (t.fi, t.se - 1));
        }
        if (t.se + 1 < w && v[t.fi][t.se + 1] && !s.count(p <int> (t.fi, t.se + 1))) {
          newd.pb(p <int> (t.fi, t.se + 1));
          s.insert(p <int> (t.fi, t.se + 1));
          d.pb(p <int> (t.fi, t.se + 1));
        }
      }
    }

    if (s.count(p <int>(dh - 1, dw - 1))) break;
    cnt++;

    //cout << "cnt = " << cnt << endl;
    int n = sz(d);
    while (n--) {
      p <int> t = d.front();
      d.pop_front();
      t.fi -= 2;
      t.se -= 2;
      rep (i, 5) {
        int idxi = t.fi + i;
        if (idxi > h - 1 || idxi < 0) continue;
        rep (j, 5) {
          int idxj = t.se + j;
          if (idxj > w - 1 || idxj < 0) continue;
          if (v[idxi][idxj] && !s.count(p <int> (idxi, idxj))) {
            s.insert(p <int> (idxi, idxj));
            d.pb(p <int> (idxi, idxj));
          }
        }
      }
    }
  }
  if (!s.count(p <int> (dh - 1, dw - 1))) cout << -1 << endl;
  else cout << cnt << endl;

  return 0;
}

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

int main() {
  ll N, K; cin >> N >> K;
  ll x[N];
  for (ll i = 0; i < N; i++) {
    cin >> x[i];
  }
  
  ll res[N-K+1];
  for (ll i = 0; i < N-K+1; i++) {
    if (x[K-1+i] <= 0) {
      res[i] = -x[i];
    }
    else if (x[i] >= 0) {
      res[i] = x[K-1+i];
    }
    else {
      ll L = x[K-1+i]-x[i];
      ll l = x[K-1+i];
      res[i] = min(L+l, 2*L-l);
    }
  }
  ll ans = 1e9;
  for (ll i = 0; i < N-K+1; i++) {
    ans = min(ans, res[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<vector>
#include<climits>
#define ll long long int
using namespace std;
bool cmp(int n, pair<int, int> const& p) {
  return p.second < n;
}

int main(void) {
  int n, h;
  ll sum=0;
  int ans=0;
  cin>>n>>h;
  vector<pair<int, int>> v(n);
  vector<int> bb(n);
  for(int i=0; i<n; i++) {
    int a, b;
    cin>>a>>b;
    v[i]={a, b};
    bb[i]=b;
  }
  sort(v.begin(), v.end());
  sort(bb.begin(), bb.end(), greater<int>());
  for(int i=0; i<n; i++) {
    if(v[n-1].first<=bb[i]) {
      h-=bb[i];
      ans++;
    }
    if(h<=0) {
      cout<<ans<<endl;
      return 0;
    }
  }
  ans+=h/v[n-1].first;
  if((h%v[n-1].first)!=0) {
    ans+=1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    rep(i, N) cin >> v[i] >> w[i];
    
    vector<vector<int>> dp(N + 1, vector<int>(W + 1, -1));
    dp[0][0] = 0;
    REP(i, N + 1) rep(j, W + 1) {
        dp[i][j] = dp[i - 1][j];
        if (j >= w[i - 1]) {
            dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
            dp[i][j] = max(dp[i][j], dp[i][j - w[i - 1]] + v[i - 1]);
        }
    }
    int ans = 0;
    rep(i, W + 1) ans = max(ans, dp[N][i]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 6828
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

def main():
	n = II()
	v = LI()
	v.sort()
	ans = v[0]
	for i in range(1,n):
		ans = (ans+v[i])/2
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
 
const int N = 1e5;
 
ll arr[2*N+5];
ll cnt[2*N+5];
 
int main(){
 
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n; cin >>n;
    for(int i = 0; i<n; i++){
        cin >>arr[i]; cnt[arr[i]]++;
    }
 
    ll aux = 0;
    for(int i = 1; i<=n; i++){
        aux += (cnt[i]*(cnt[i]-1))/2;
    }
 
    ll ans;
    for(int i = 0; i<n; i++){
        ans = aux - ((cnt[arr[i]]*(cnt[arr[i]]-1))/2) +  (((cnt[arr[i]]-1)*(cnt[arr[i]]-2))/2);
        cout <<ans <<endl;
    }
 
    return 0;
}

Measured memory_bytes: 4736
Alp =["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"]*2
N = int(input())
S = list(input())
for i in range(len(S)):
	Anum = Alp.index(S[i])
	S[i] = Alp[Anum+N]
print("".join(S))

Measured memory_bytes: 3064
# import sys
# input = sys.stdin.readline

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

n = int(input())
# ans = []
# for u in range(1, n+1):
#     cnt = 0
#     for i in range(1, int(n/(u**2))+2):
#         for j in range(1,int(u/(i**2))+2):
#             for k in range(1,int(u/(j**2))+2):
#                 if i**2+j**2+k**2+i*j+j*k+k*i == u:
#                     if i == j == k:
#                         cnt += 1
#                     elif i != j and j != k and k != j:
#                         cnt += 6
#                     else:
#                         cnt += 3
#
#     ans.append(cnt)
# print(ans)
ans = [0] * (n+1)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            cal = i**2+j**2+k**2+i*j+j*k+k*i
            if cal <= n:
                ans[cal] += 1
for i in range(1, n+1):
    print(ans[i])





Measured memory_bytes: 69516
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr))
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
int32_t main(){
    
    ios_base::sync_with_stdio(cin.tie(NULL));
    cout.tie(NULL);
    
    int tc = 1;
    // cin>>tc;
    while(tc -- ){
        
        int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int k;
        cin>>k;
        cout<<a[k-1]<<endl;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int uchiha=1e3+5;
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
int y=max(a,c);
int z=min(b,d);
int r=z-y;
cout<<max(0,r);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll mod = 1e9+7;
bool isPrime2(ll a)
{
    if(a<2) return false;
    if(a==2) return true;
    if(a%2==0) return false;
    for(ll i=3;i<=sqrt(a);i+=2){
        if(a%i==0){
            return false;
        }
    }
    return true;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        ll n; cin >> n;
        for(ll i=n;;i++){
            if(isPrime2(i)){
                cout << i << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 256
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, W = iim()
    S = [list(iim()) for i in range(N)]

    dp = [0] * (W + 1)

    def f1(s):
        v, w, m = s
        mm = []
        i = 1
        while i <= m:
            mm.append(i)
            m -= i
            i <<= 1

        if m:
            mm.append(m)
        return (v, w, mm)

    SS = map(f1, S)

    for v, w, m in SS:
        for k in m:
            v1, w1 = v * k, w * k
            for i in range(W, w1-1, -1):
                j = i - w1
                v2 = dp[j] + v1
                if dp[i] < v2:
                    dp[i] = v2
    print(dp[W])

if __name__ == "__main__":
    resolve()



Measured memory_bytes: 5980
#include <bits/stdc++.h>
#define R register

typedef long long ll;

const int MN = 2e5 + 5;

inline int read(){
	R int x; R bool f; R char c;
	for (f = 0; (c = getchar()) < '0' || c > '9'; f = c == '-');
	for (x = c ^ '0'; (c = getchar()) >= '0' && c <= '9'; x = (x << 1) + (x << 3) + (c ^ '0'));
	return f ? -x : x;
}

int n, a[MN];
ll ans;

inline ll getsol(int x) {
	R ll res = 0;
	for (R int i = 1; i <= n; ++i) 
		res += abs(x - a[i]);
	ans = std::min(ans, res);
	return res;
}

int main() {
	n = read();
	for (R int i = 1; i <= n; ++i) 
		ans += abs(a[i] = read() - i);
	R int l = -1e9, r = 1e9;
	for (; r - l > 5; ){
		R int md1 = l + (r - l) / 3, md2 = r - (r - l) / 3;
		if (getsol(md1) < getsol(md2)) r = md2;
		else l = md1;
	}
	for (; l <= r; ++l) getsol(l);
	
	printf("%lld\n", ans);
	return 0;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    int ans = 0;

    if (b >= c) {
        ans = b + c;
    }
    else {
        ans = 2 * b;
        c -= b;
        if (c - a <= 1) {
            ans += c;
        }
        else {
            ans += a + 1;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n,k = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
ans = 10**9
for i in 0..n-k
    ret = x[i].abs > x[i+k-1].abs ? x[i].abs : x[i+k-1].abs
    if x[i]*x[i+k-1] < 0
        ret += 2*(x[i].abs < x[i+k-1].abs ? x[i].abs : x[i+k-1].abs)
    end
    ans = ret if ans > ret
end
p ans

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

bool vf(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;
  }
}

bool bingo(vector<int> A, vector<int> B){
  if (vf(B, A[0])&&vf(B, A[1])&&vf(B, A[2])) return true;
  if (vf(B, A[3])&&vf(B, A[4])&&vf(B, A[5])) return true;
  if (vf(B, A[6])&&vf(B, A[7])&&vf(B, A[8])) return true;
  if (vf(B, A[0])&&vf(B, A[3])&&vf(B, A[6])) return true;
  if (vf(B, A[1])&&vf(B, A[4])&&vf(B, A[7])) return true;
  if (vf(B, A[2])&&vf(B, A[5])&&vf(B, A[8])) return true;
  if (vf(B, A[0])&&vf(B, A[4])&&vf(B, A[8])) return true;
  if (vf(B, A[2])&&vf(B, A[4])&&vf(B, A[6])) return true;
  return false;
}

int main() {
  vector<int> A(9);
  for(int i=0; i < 9; i++){
      cin >> A[i];
  }
  
  int N;
  cin >> N;
  vector<int> B(N);
  for(int i=0; i < N; i++){
    cin >> B[i];
  }

  if(bingo(A,B)){
    cout << "Yes" << endl;  
  } else {
    cout << "No" << endl;  
  }
}



Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
A = LI()
ans = 0
for i in range(N):
    if i%2 ==0:
        if A[i] % 2==1:
            ans += 1
print(ans)

Measured memory_bytes: 68516
object Main extends App {
	val N = scala.io.StdIn.readInt
	var A = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	var count = 0

	for(i<-0 until N-1){
		if(A(i) == i+1){
			count = count + 1;
			val temp = A(i)
			A(i) = A(i+1)
			A(i+1) = temp
		}
	}

	if(A(N-1) == N) count = count + 1;

	println(count)

}


Measured memory_bytes: 38272
#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define in(x) (read(x))
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) (x&(-x))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9+7;
const ld eps = 1e-9;
const int inf = mod;
const db PI = atan(1)*4;
template<typename T>
inline int sign(const T&a){if(a<0)return -1;if(a>0)return 1;return 0;}


template<typename T> inline void in(T &x){
    x = 0; T f = 1; char ch = getchar();
    while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
    while (isdigit(ch))  {x = x * 10 + ch - '0'; ch = getchar();}
    x *= f;
}

string s;
const int maxn = 100010;
int a[maxn];
int main(){
	cin>>s;
	REP(i,0,sz(s))a[i] = s[i]-'a';
	int k = 0;
	cin>>k;
	REP(i,0,sz(s)){
		if(a[i]==0)continue;
		if(26-a[i]<=k){
			k-=26-a[i];

			a[i] = 0;
		}
	}
	a[sz(s)-1] = (a[sz(s)-1]+k)%26;
	REP(i,0,sz(s)){
		cout<<(char)(a[i]+'a');
	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,t,n,i,xacm=0,yacm=0,tnou=0,xd;
    cin>>n;
    for(i=1;i<=n;i++)
    {
     cin>>t>>a>>b;
     tnou+=fabs(a-xacm)+fabs(b-yacm);
     xd=t-tnou;
     if(xd<0)
     {
      cout<<"No";
      return 0;
     }
     else if(xd%2==0)
        {tnou=t;xacm=a;yacm=b;}
     else
      {cout<<"No";return 0;}
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
N,M,Q=map(int,input().split())
member=list(range(N))
pos=0
m=list(map(int,input().split()))
for i in m:
    if i%2==0:
        pos+=i
        while pos>=len(member):pos-=len(member)
        del member[pos]
        if pos>len(member):pos=0
    else:
        pos-=i
        while pos<0:pos+=len(member)
        del member[pos]
        if pos>len(member):pos=0
q=list(map(int,input().split()))
for i in q:
    if i in member:
        print("1")
    else:
        print("0")


Measured memory_bytes: 29204
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N, K;
  std::cin >> N >> K;
  --K;
  std::string S;
  std::cin >> S;
  S[K] = std::tolower(S[K]);
  std::cout << S << std::endl;
  return 0;
}

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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;

int main(){
	int n;
	cin>>n;
	map<string,int>m;
	char last;
	bool ok=1;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		if(m[s]){
			ok=0;
		}
		if(i){
			if(last!=s[0])ok=0;
		}	
		last=s[sz(s)-1];
		m[s]++;
	}
	cout<<(ok?"Yes":"No");
}

Measured memory_bytes: 3640