akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

const int INF = 1 << 30;

const int dy[4] = { -1, 0, +1, 0 };
const int dx[4] = { 0, -1, 0, +1 };

int shortest(const vector<string> &S, int sy, int sx, int gy, int gx)
{
	const int H = S.size();
	const int W = S[0].size();
	vector<vector<bool>> visited(H, vector<bool>(W, false));
	queue<int> waiting;

	auto visit = [&](int y, int x) {
		if (y < 0 || H <= y || x < 0 || W <= x) {
			return;
		}
		if (S[y][x] == '#') {
			return;
		}
		if (!visited[y][x]) {
			visited[y][x] = true;
			waiting.push(y);
			waiting.push(x);
		}
	};

	visit(sy, sx);
	for (int d = 0; !waiting.empty(); ++d) {
		queue<int> q = move(waiting);
		while (!q.empty()) {
			int y = q.front(); q.pop();
			int x = q.front(); q.pop();
			if (y == gy && x == gx) {
				return d;
			}
			for (int k = 0; k < 4; ++k) {
				visit(y + dy[k], x + dx[k]);
			}
		}
	}
	return INF;
}

int main()
{
	int H, W;
	cin >> H >> W;

	vector<string> S(H);
	for (auto &x : S) {
		cin >> x;
	}

	int ans = 0;
	for (int sy = 0; sy < H; ++sy) {
		for (int sx = 0; sx < W; ++sx) {
			for (int gy = 0; gy < H; ++gy) {
				for (int gx = 0; gx < W; ++gx) {
					if (S[sy][sx] == '#' || S[gy][gx] == '#') {
						continue;
					}
					ans = max(ans, shortest(S, sy, sx, gy, gx));
				}
			}
		}
	}
	cout << ans << endl;
}


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


int main() {
  int N,K,Q;
  cin>>N>>K>>Q;
  
  vector<int> vec(N+1,Q);
  
  for(int i=0;i<Q;i++){
    int a;
    cin>>a;
    vec.at(a)-=1;
  }
  for(int i=1;i<=N;i++){
    if(vec.at(i)<K) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  
}

Measured memory_bytes: 1024
N, A = map(int, input().split())
X = list(map(int, input().split()))
for i in range(N):
    X[i] -= A
D = {0: 1}
for i in range(N):
    F = [[j, D[j]] for j in D]
    for j in F:
        if j[0] + X[i] in D:
            D[j[0] + X[i]] += j[1]
        else:
            D[j[0] + X[i]] = j[1]
print(D[0]-1)

Measured memory_bytes: 67888
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  vector<string> days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string today;
  cin >> today;

  int pos = 0;
  while (today != days[pos]) pos ++;

  int ans = 1;
  while (days[(pos + ans) % days.size()] != "SUN") ans ++;
  printf("%d\n", ans);

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

const int MAX_N = 200000;

ll fact[MAX_N+100];
ll frev[MAX_N+100];

ll rev(ll a, ll p){
    if(p == 0) return 1;
    ll tmp = rev(a, p/2);
    tmp = tmp * tmp % MOD;
    if(p % 2 == 1) tmp = tmp * a % MOD;
    return tmp;
}


void calc_fact(){
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }
}


ll comb(int n, int k){
    if(n < 0 || k < 0 || n < k) return 0;
    if(n == 0 || k == 0) return 1;
    return fact[n] * frev[k] % MOD * frev[n-k] % MOD;
}

//return x**n % mod
ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll mycomb(ll n, ll x){
    ll ret = 1;
    //REP(i,x){
    while(x > 0){
        ret *= n;
        ret %= MOD;

        ret *= mod_pow(x, MOD-2, MOD);
        ret %= MOD;

        n--;
        x--;
    }
    return ret;
}

int main(){
    ll N, A, B;
    cin >> N >> A >> B;

    //fact[0] = frev[0] = 1;
    //for(int i = 1; i <= MAX_N; i++){
    //    fact[i] = (fact[i-1] * i) % MOD;
    //    frev[i] = rev(fact[i], MOD-2);
    //}

    ll ans = 0;
    ans = mod_pow(2, N, MOD);

    ll x = mycomb(N, A);
    ll y = mycomb(N, B);

    ans += (MOD - x);
    ans %= MOD;

    ans += (MOD - y);
    ans %= MOD;

    ans += (MOD - 1);
    ans %= MOD;

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


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

signed main(void)
{
	int n, ans;
	bool flag;
	string x;
	cin >> n;
	pair<string, int> p[n];

	rep(i, n) cin >> p[i].first >> p[i].second;
	cin >> x;
	ans = 0;
	flag = false;
	rep(i, n)
	{
		if (flag)
			ans += p[i].second;
		if (p[i].first == x)
			flag = true;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// AOJ 1277: Minimal Backgammon
// 2017.10.16 bal4u@uu

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

char tbl[102];
double dp[102][102];

int main()
{
	int n, t, l, b, i, j, k, a;
	double ans;

	while (scanf("%d%d%d%d", &n, &t, &l, &b) && n > 0) {
	    memset(tbl, 0, sizeof(tbl));
		memset(dp,0,sizeof(dp));
	    for (i = 0; i < l; i++) scanf("%d", &a), tbl[a] = 1;
		for (i = 0; i < b; i++) scanf("%d", &a), tbl[a] = 2;

		dp[0][0] = 1;
		for (i = 1; i <= t; i++) for (j = 0; j < n; j++) {
			for (k = 0; k < 6; k++) {
				if (dp[i-1][j] == 0) continue;
		        a = j + k+1;
		        if (a > n) a -= 2*(a-n);
				if      (tbl[a] == 0) dp[  i][a] += dp[i-1][j]/6;
				else if (tbl[a] == 1) dp[i+1][a] += dp[i-1][j]/6;
				else                  dp[  i][0] += dp[i-1][j]/6;
			}
		}
		for (ans = 0, i = 1; i <= t; i++) ans += dp[i][n];
		printf("%.6f\n",ans);
    }
	return 0;
}

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

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

	int H,W,h,w;
	cin>>H>>W>>h>>w;
	cout<<H*W-h*W-H*w+w*h<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define maxn 700000
#define INF 999999999
int n, a[maxn], id[maxn];

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

struct node
{
	int x, y, l, r;
	node(int _x = 0, int _y = 0, int _l = 0, int _r = 0) 
	{ x = _x, y = _y, l = _l, r = _r; }
	friend bool operator <(const node& a, const node& b)
	{ return a.x > b.x; }
}; priority_queue <node> q;

struct tree
{
	int opt, mn[maxn];
	void Build(int p, int l, int r)
	{
		if(l == r) { mn[p] = ((l & 1) ^ opt) ? a[l] : INF; return; }
		int mid = (l + r) >> 1;
		Build(p << 1, l, mid), Build(p << 1 | 1, mid + 1, r);
		mn[p] = min(mn[p << 1], mn[p << 1 | 1]);
	}
	
	int Query(int p, int l, int r, int L, int R)
	{
		if(L > r || R < l) return INF;
		if(L <= l && R >= r) return mn[p];
		int mid = (l + r) >> 1;
		return min(Query(p << 1, l, mid, L, R), Query(p << 1 | 1, mid + 1, r, L, R));
	}
}T1, T2;

void Push(int L, int R)
{
	if(L > R) return;
	int fir, sec; 
	if(L & 1) fir = T1.Query(1, 1, n, L, R - 1), sec = T2.Query(1, 1, n, id[fir] + 1, R);
	else fir = T2.Query(1, 1, n, L, R - 1), sec = T1.Query(1, 1, n, id[fir] + 1, R);
	q.push(node(fir, sec, L, R));
}

int main()
{
	n = read();
	for(int i = 1; i <= n; i ++) a[i] = read(), id[a[i]] = i;
	T1.opt = 0, T2.opt = 1; 
	T1.Build(1, 1, n); T2.Build(1, 1, n); Push(1, n);
	while(!q.empty())
	{
		node t = q.top(); q.pop();
		int L = t.l, R = t.r;
		printf("%d %d ", t.x, t.y);
		Push(L, id[t.x] - 1);
		Push(id[t.x] + 1, id[t.y] - 1);
		Push(id[t.y] + 1, R);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 12532
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n)cin>>a[i];
  vll c(n+2);
  c[0]=3;
  ll ans=1;
  rep(i,n){
    ans*=c[a[i]];
    ans%=MOD;
    c[a[i]]--;
    c[a[i]+1]++;
  }
  COUT(ans);
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cctype>
#include <climits>
#include <vector>
#include <queue>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int c, n = 0;
	bool minus = false;
	if ((c = gcu()) == '-') minus = true; else ungetc(c, stdin);
	while ((c = gcu()) >= '0' && c <= '9') n = 10 * n + (c - '0');
	//return n; }
	return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo
#undef si

#define v vector
struct graph {
	struct node {int n, w;};
	v<v<node>> nodes;

	void read(int n) {
		nodes.resize(n);
		for (auto &x: nodes) {
			in();
			for (int k = in(); k--;) {
				int c = in();
				x.push_back({c, in()});
			}
		}
	}

	v<node> dks() {
		v<node> w(nodes.size(), {0, INT_MAX});
		w[0].w = 0;
		priority_queue<node> q;
		q.push({0, 0});
		while (!q.empty()) {
			node n = q.top();
			q.pop();
			for (node &x: nodes[n.n]) {
				w[x.n].w = min(w[x.n].w, n.w + x.w);
				if (!w[n.n].n)
					q.push({x.n, w[x.n].w});
			}
			w[n.n].n = 1;
		}
		return move(w);
	}
};

bool operator < (const graph::node &a, const graph::node &b) {
	return a.w > b.w;
}

int main() {
	graph g;
	g.read(in());
	int i = 0;
	for (auto &x: g.dks())
		out(i++, ' ', x.w, '\n');
}


Measured memory_bytes: 9024
#include<stdio.h>
int main(){
  int n,a,b,i,j=0,k=0,m=0;
  scanf("%d %d %d",&n,&a,&b);
  for(i=n;i>=1;i--){
    k=i;
    for(j=0;k!=0;){
      j+=k%10;
      k/=10;
    }
    if(j>=a && j<=b){
    m+=i;
    }
  }
  printf("%d",m);
  return 0;
}

Measured memory_bytes: 1720
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, K;
  int ans = 0;
  int cnt = 0;

  cin >> N >> K;

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

  cnt = K;
  ans++;
  while(N > cnt){
   cnt += (K-1);
   ans++; 
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-

from math import sqrt

# 素数判定用関数
def is_prime2(num):
    if num < 2:
        return False
    if num == 2 or num == 3 or num == 5:
        return True
    if num % 2 == 0 or num % 3 == 0 or num % 5 == 0:
        return False
    # 疑似素数(2でも3でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    num_sqrt = sqrt(num)
    while prime <= num_sqrt:
        if num % prime == 0:
            return False
        prime += step
        step = 6 - step
    return True

# 同じ数2回素数判定やりたくないのでここに保存
prime = [is_prime2(i) for i in range(100001)]
# 2017に似た数
like2017 = [0] * 100001
for i in range(1, 100001, 2):
    if prime[i] and prime[(i+1)//2]:
        like2017[i] = 1
# 累積和
sm = [0] * 100001
for i in range(1, 100001):
    sm[i] = sm[i-1] + like2017[i]

Q = int(input())
for i in range(Q):
    l, r = map(int, input().split())
    # 累積和から各QはO(1)で出せる
    print(sm[r]-sm[l-1])


Measured memory_bytes: 9816
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;cin>>n;
    int t[100000],x[100000],y[100000];
    t[0]=0;x[0]=0;y[0]=0;
    for(int i=1;i<=n;i++){
        cin>>t[i]>>x[i]>>y[i];
    }
    for(int i=1;i<=n;i++){
        if((x[i]-x[i-1]+y[i]-y[i-1])>(t[i]-t[i-1])||(x[i]-x[i-1]+y[i]-y[i-1]-t[i]+t[i-1])%2!=0)
        {cout<<"No"<<endl;return 0;}
    }
    cout<<"Yes"<<endl;return 0;
}

Measured memory_bytes: 1536
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n;
	cin >> n;
	map<pair<int, int>, ll> mp;
	ll res = 0;

	for (int i = 1; i <= n; i++)
	{
		int ld = i % 10;
		int ci = i;
		int fd = 0;
		while (ci)
		{
			fd = ci % 10;
			ci /= 10;
		}
		mp[{ld, fd}]++;
	
	}

	for (auto p : mp)
	{
		pii cur = p.first;
		swap(cur.first, cur.second);
		res += p.second * mp[cur ];
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

const int MAX_N = 10;
int N;
int L[MAX_N];

void _main() {
  cin >> N;
  rep(i, 0, N) cin >> L[i];
  sort(L, L + N);

  int sum = 0;
  rep(i, 0, N-1) sum += L[i];

  if (L[N-1] < sum) cout << "Yes" << "\n";
  else              cout << "No"  << "\n";
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;

int main(){
	double N,K;
	cin >> N >> K;
	double sum = 0;
	double p = 1;
	for(int i = 1 ; i <= N ; i++){
		double a = i;
		p  =1;
		while(a < K){
			a *= 2;
			p *= 0.5;
		}
		sum += p / N;
	}
	
	printf("%.10f\n",sum);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    ll A1,A2,A3;
    cin >>A1>>A2>>A3;
    if(A1+A2+A3 >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
    


    return 0;
    

}

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

int main(){
    int n,m,x,ans0=0,ansn=0;cin>>n>>m>>x;
    for(int i=0;i<m;i++){
        int A;cin>>A;
        if(A<x) ans0++;
        else ansn++;
    }
    cout<<min(ans0,ansn)<<endl;
}

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

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

const int INF = 0x3f;

int main()
{
    int n, m, l;
    scanf("%d %d %d", &n, &m, &l);

    int dp[n][n];
    memset(dp, INF, sizeof(dp));
    for (int i = 0; i < m; i++) {
        int u, v, c;
        scanf("%d %d %d", &u, &v, &c);
        u--, v--;
        dp[u][v] = dp[v][u] = c;
    }

    for (int k = 0; k < n; k++)
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);

    int dp2[n][n];
    memset(dp2, INF, sizeof(dp2));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (dp[i][j] <= l)
                dp2[i][j] = 1;

    for (int k = 0; k < n; k++)
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                dp2[i][j] = min(dp2[i][j], dp2[i][k] + dp2[k][j]);

    int q;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        u--, v--;

        int ans;
        if (dp2[u][v] == 0x3f3f3f3f)
            ans = -1;
        else
            ans = dp2[u][v] - 1;
        printf("%d\n", ans);
    }

    return 0;
}


Measured memory_bytes: 1280
N,K = map(int,input().split())
S = input()
sum = 0
dis = 0
for i in range(N-1):
    if S[i]== S[i+1]:
        sum+=1
    else:
        dis+=1
l = (dis+1)//2
if (S[0]!=S[-1]) and (l<=K):
    sum-=1
print(sum+2*min(K,l))


Measured memory_bytes: 39408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,n,h) for(int i = n; i < h; ++i)
#define rep3(l,n,h) for(int l = n; l <= h; ++l)
typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;


int main(void) {
   string s;
   int count = 0;
   cin >> s;
    for(int i = 0; i < s.length()/2; i++) {
        if(s[i] != s[s.length()-1-i]) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;

int main() {
  ll N,M;
  cin>>N>>M;
  if(M/2<N){
    cout<<M/2;
  }
  else{
    M-=2*N;
    M/=4;
    cout<<N+M;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    string S;
    cin >> S;
    int cnt = 0;
    int ans = 0;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == 'R') {
            cnt++;
        }
        else {
            ans = max(ans,cnt);
            cnt = 0;
        }
    }
    cout << max(ans,cnt) << endl;
}


Measured memory_bytes: 3624
x1,y1,x2,y2 = map(int, input().split())
x3, y3 = x2 - (y2-y1), y2 + (x2-x1)
x4, y4 = x1 - (y2-y1), y1 + (x2-x1)
print(x3, y3, x4, y4)

Measured memory_bytes: 2940
function Main(input){
  var S = input.split("");
  var a = S.splice(0,2);
  var lef = a.join("");
  var rig = S.join("");
  lef = parseInt(lef,10);
  rig = parseInt(rig,10);
  
  if((0<lef&&lef<=12)&&rig>12){
    console.log('MMYY');
  }else if(lef>12&&(0<rig&&rig<=12)){
    console.log('YYMM');
  }else if((0<=lef&&lef<=12)&&(0<=rig&&rig<=12)){
    if(lef===0&&rig>0){
      console.log('YYMM');
    }else if(lef>0&&rig===0){
      console.log('MMYY');
    }else if(lef===0&&rig===0){
      console.log('NA');
    }else{
      console.log('AMBIGUOUS');
    }
  }else{
    console.log('NA');
  }



}  

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import itertools
n = int(input())
k = int(input())
result = []
for seq in list(itertools.combinations_with_replacement([2, 1], n)):
    current = 1
    for i in seq:
        if i == 1:
            current += k
        else:
            current *= 2
    result.append(current)
print(min(result))


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include<vector>

using namespace std;
int main() {
	int k,a,b;
	cin >>k>> a>>b;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int div;

  for(int i = 1; i <= 10; i++) {
    div = i * 1000 - N;
    if(div >= 0 && div < 1000) {
      cout << div << endl;
      return 0;
    }
  }
}

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

using namespace std;

#define pb push_back
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define mem(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, int> pli;

const int mn = 3005;
const int mod = 1e9 + 7;
#define P mod

int n, m;

const string ss = "snuke";

int main() {
    //cin.sync_with_stdio(0);
#ifdef trote
    freopen("../1.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#endif
    cin >> n;
    int ans = 1e9;
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        if (1ll * i * (i + 1) / 2 >= n) {
            ans = i;
            break;
        }
    }
    vector<int> v;
    for(int i=ans;i;i--){
        if (i<=n) n-=i,v.pb(i);
    }
    reverse(all(v));
    for(auto &i:v) printf("%d\n",i);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define REP(i,n) for(int i=0;i<(n);i++) 
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define disp(x) for(auto i : x) cout << i << " "; cout << endl
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
const int INF = 2e9, MOD = 1e9+7;

const int maxn = 1e5 + 5;

int n, m;
priority_queue<int> q;

int main()
{
    FIO
    
    cin >> n >> m;

    REP(i, n)
    {
        int a;
        cin >> a;
        q.push(a);
    }

    REP(i, m)
    {
        if(q.empty())
            break;
        int x = q.top();
        q.pop();
        x /= 2;
        if(x > 0)
            q.push(x);
    }

    ll ans = 0;
    while(!q.empty())
    {
        ans += q.top();
        q.pop();
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3832
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int up,down;
  down = n % 100;
  up = n / 100;
  int flag;
  if(1 <= down && down <= 12){//YYMM ok
    if(1 <= up && up <= 12) flag = 0;
    else flag = 1;
  }
  else{// YYMM x
    if(1 <= up && up <= 12) flag = 2;
    else flag = 3;
  }
  if(flag == 0) printf("AMBIGUOUS");
  else if(flag == 1) printf("YYMM");
  else if(flag == 2) printf("MMYY");
  else if(flag == 3) printf("NA");
  printf("\n");
  return 0;
}

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

#define ll long long int

using namespace std;

const ll im = 1e5;
const ll inf = 1001002003004005006ll;

template <class T> int min(T &a, const T &b) {
    if (a > b) {
        a = b;
        return 1;
    } else 
        return 0;
}

int main()
{
    ll n, w;
    cin >> n >> w;
    vector<ll> a(n, 0);
    vector<ll> v(n, 0);
    ll s = 0;
    for (ll i = 0 ; i < n ; i++) {
        cin >> a[i] >> v[i];
        s += v[i];
    }
    vector<vector<ll>> dp = vector<vector<ll>>(n + 1, vector<ll>(s + 1, inf));
    dp[0][0] = 0;
    for (ll i = 0 ; i < n ; i++) {
        for (ll j = 0 ; j < s ; j++) {
            if (dp[i][j] == inf) continue;
            min(dp[i + 1][j], dp[i][j]);
            ll new_weight = dp[i][j] + a[i];
            min(dp[i + 1][j + v[i]], new_weight);
        }
    }
    ll answer = 0;
    for (ll i = 0 ; i < s + 1 ; i++) {
        if (dp[n][i] <= w) {
            if (i > answer) {
                answer = i;
            }
        }
    }
    cout << answer;

    return 0;
}

Measured memory_bytes: 80256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if(n==1||n==2||n==3||n==5||n==6||n==9||n==10||n==13||n==17){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
  }
  

  
}

Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <limits>
#include <numeric>

using ld = long double;
using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	/* constant */
	constexpr double epsilon = std::numeric_limits<double>::epsilon();

	/* math */
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	ul inline digit(const ul &num){ return static_cast<ul>(std::log10(num+epsilon))+1; }

	/* algorithm */
	ul gcd(const ul &a,const ul &b) { return (!b) ? a : gcd(b,a%b); }
	ul lcm(const ul &a,const ul &b) { return (a/gcd(a,b))*b; } // a/gcd(a,b)*b <=> (a*b)/gcd(a,b)
	std::vector<bool> eratosthenes(const ul &n)
	{
		std::vector<bool> prime_candidate(n,true);
		prime_candidate[0] = prime_candidate[1] = false;
		for(ul i = 2;i*i < n;++i)
		{
			if(!prime_candidate[i]) continue;
			for(ul j = 2;i*j < n;++j) prime_candidate[i*j] = false;
		}
		return prime_candidate;
	}
	ll rho_method(const ll &n)
	{
		auto f = [&](const ll &xi){ return (xi*xi+1)%n; };
		ll x = 2, y = 2, d = 1;
		while(d == 1)
		{
			x = f(x);
			y = f(f(y));
			d = lamlib::gcd(lamlib::abs(x-y),n);
		}
		return d;
	}
	// 素因数分解(試し割)
	std::vector<ll> prime_factorization_trial(const ll &n)
	{
		ll num = n;
		std::vector<ll> prime;
		for(ll i = 2;i*i <= n;++i)
		{
			while((num%i) == 0)
			{
				prime.emplace_back(i);
				num /= i;
			}
		}
		if(num > 1) prime.emplace_back(num);
		return prime;
	}

	/* string */
	inline ul same_char_count(const std::string s,const char &ch){ return std::count(std::cbegin(s),std::cend(s),ch); }
}

// std::cout << std::fixed << std::setprecision(15) << std::endl;

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

	if(a >= 'A' && a <= 'Z') std::cout << "A" << std::endl;
	else std::cout << "a" << std::endl;

	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>

int main(){
	int n;
	while(std::cin >> n, n){
		std::vector<int> v;
		for(int i=0;i<n;i++){
			int j;
			std::cin >> j;
			v.push_back(j);
		}
		std::sort(v.begin(), v.end());
		int ave = 0;
		for(int i=1;i<v.size()-1;i++){
			ave += v[i];
		}
		ave /= n-2;
		std::cout << ave << std::endl;
	}
}

Measured memory_bytes: 1216
//compiledef
#include <bits/stdc++.h>
#define rep(i, n)for(i=0;i<(n);i++)
#define per(i, n) for(i=(n);i>0;i--)
#define repx(i, n, x) for(i=(x);i<(n);i++)
#define xper(i, n, x) for(i=(n);i>(x);i--)
#define pback push_back

//c++def
using namespace std;
typedef long long int ll;
const long long int MOD = 1e9+7;
const long long int MOD2 = 998244353;
int w[200][200];
int prim_mst(int n){
	int i;
	int j;
	int cost = 0;
	int d[200];
	int pi[200];
	int color[200];
	rep(i, n){
		d[i]= 2e9;
		pi[i]=-1;
		color[i] = 0;
	}
	d[0] = 0;
	while(29091101){
		int mincost = 2e9;
		rep(i, n){
			if(color[i] != 2 && d[i] < mincost){
				mincost = d[i];
				j = i;
			}
		}
		if(mincost == 2e9)break;
		color[j] = 2;
		for(int v=0; v<n;v++){
			if(color[v] != 2 && w[j][v] < d[v]){
				pi[v] = j;
				d[v] = w[j][v];
			}
		}
	}
	rep(i, n){
		if(pi[i] != -1) cost += w[i][pi[i]];
	}
	return cost;
}

int main(){
	int n;
	int i, j;
	int tmp;
	cin >> n;
	rep(i, n){
		rep(j, n){
			cin >> tmp;
			if(tmp == -1) w[i][j] = 2e9;
			else w[i][j] = tmp;
		}
	}
	cout << prim_mst(n) << endl;
}



Measured memory_bytes: 3148
#include <string>
#include <iostream>
using namespace std;
int main(void){
  int a;
  int b;
  cin >> a;
  string str;
  cin >> str;
  b = str.size();
  if(b <= a){
    cout << str << endl;
  }
  else{
    str = str.substr(0, a);
    cout << str << "..." << endl;
  }
}

Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

const li mod = 1e9 + 7;

int main() {
    li n;
    cin >> n;

    vector<li> xs(n), xps(n);
    for (int i = 0; i < n; ++i) {
        cin >> xs[i];
        xs[i]--;
        xps[xs[i]] = i;
    }

    li ans = n;

    vector<bool> vis(n);
    for (int i = 0; i < n; ++i) {
        if (vis[i]) {
            continue;
        }
        int pos = i, length = 1;
        while (true) {
            vis[pos] = true;
            if (xs[pos] < n - 1 && xps[xs[pos] + 1] > pos) {
                pos = xps[xs[pos] + 1];
                length += 1;
            } else {
                break;
            }
        }
        ans = min(ans, n - length);
    }

    cout << ans << endl;


    return 0;
}


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

ll dp[100005],n,h[100005];

void boost()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

ll solve(ll currh)
{
	if(currh==n)
		return 0;
	if(dp[currh]!=-1)
		return dp[currh];
	ll res1=1000000007,res2=1000000007;
	if(currh+1<=n)
		res1 = abs(h[currh]-h[currh+1])+solve(currh+1);
	if(currh+2<=n)
		res2 = abs(h[currh]-h[currh+2])+solve(currh+2);
	return dp[currh]=min(res1,res2);
}

int main()
{
	int i;
	boost();
	memset(dp,-1,sizeof(dp));
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>h[i];
	cout<<solve(1)<<endl;
	return 0;
}

Measured memory_bytes: 4992
/*
[abc142] E - Get Everything
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 12;
const int MAX_M = 1e3;
const int INF = 1e9;

int N, M;
int A[MAX_M], B[MAX_M];
int C[MAX_M][MAX_N];
int dp[1 << MAX_N];

ll solve() {
    int cp[MAX_M];
    for (int i = 0; i < M; i++) {
        cp[i] = 0;
        for (int j = 0; j < B[i]; j++) {
            cp[i] = cp[i] | (1 << C[i][j]);
        }
    }

    fill(dp, dp + (1 << N), INF);
    dp[0] = 0;
    for (int i = 0; i < M; i++) {
        for (int pat = 0; pat < (1 << N); pat++) {
            dp[pat | cp[i]] = min(dp[pat | cp[i]], dp[pat] + A[i]);
        }
    }

    int ans = dp[(1 << N) - 1] >= INF ? -1 : dp[(1 << N) - 1];

    return ans;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        for (int j = 0; j < B[i]; j++) {
            cin >> C[i][j];
            C[i][j]--;
        }
    }

    cout << solve() << endl;

    return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b; cin >> a >> b;
	if(a < b){
		for(int i = 0; i < b; i++){
			cout << a;
		}
	}
	else{
		for(int i = 0; i < a; i++){
			cout << b;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
def solve():
    from sys import stdin
    f_i = stdin
    
    while True:
        n = int(f_i.readline())
        if n == 0:
            break
        
        ans = int(f_i.readline())
        s = ans
        for i in range(n - 1):
            if s > 0:
                s += int(f_i.readline())
            else:
                s = int(f_i.readline())
            if s > ans:
                ans = s
        print(ans)

solve()



Measured memory_bytes: 5620
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int n, flag = 0;
  char s[110];
  scanf("%d%s", &n, s);
  if (n % 2 != 0)
    flag = 1;
  for (int i = 0; i < n / 2; i++)
  {
    if (s[i] != s[i + n / 2])
      flag = 1;
  }
  puts(flag == 0 ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
struct aa{
    int first,second;
}P; 
aa arr[N];//记录区间 
int minnore[N]; 
aa S[N];

bool cmp1(aa a, aa b){
    return a.first > b.first;
}

int main(){
    int q, L, R, mxL = 0, mnR = 1e9 + 7, RR, LL;
    int flag1 = 0, flag2 = 0, maxlen = 0;
    scanf("%d", &q);
    for(int i = 0; i < q; i ++ ){
        scanf("%d%d", &L, &R);
        arr[i].first = L;
        arr[i].second = R;
        if(L > mxL){
            mxL = L;
            RR = R;
            flag1 = i;
        }
        if(R < mnR){
            mnR = R;
            LL = L;
            flag2 = i;
        } 
        maxlen = max(maxlen, R - L + 1);
    }
    int ans1 = maxlen;
    if(mnR >= mxL)    ans1 += mnR - mxL + 1;
    if(flag1 == flag2){
        cout << ans1 << endl;
        return 0;
    }
    for(int i = 0; i < q; i ++ ){
        S[i].first = max(arr[i].second - mxL + 1, 0);
        S[i].second = max(mnR - arr[i].first + 1, 0);
    }
    sort(S, S + q, cmp1);
    minnore[q-1] = S[q - 1].second;
    for(int i = q - 2; i >= 0; i --){
        minnore[i] = min(minnore[i + 1], S[i].second);
    }
    int ans2 = 0;
    for(int i = 0; i < q; i ++ ){
        ans2 = max(ans2, S[i].first + minnore[i+1]);
    }
    cout << max(ans2,ans1) <<endl;
    return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String u = sc.next();
		sc.close();

		if (u.equals(s)) {
			System.out.println((a - 1) + " " + b);
		} else {
			System.out.println(a + " " + (b - 1));
		}
	}
}


Measured memory_bytes: 21844
#include <stdio.h>

int lost[4][13];

int main(void)
{
	int n;
	int i, j;
	int tmp_lost = 0;
	char mark;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%*c%c %d", &mark, &tmp_lost);
		tmp_lost--;
		switch (mark){
			case 'S':
				lost[0][tmp_lost] = 1;
				break;
			
			case 'H':
				lost[1][tmp_lost] = 1;
				break;
			
			case 'C':
				lost[2][tmp_lost] = 1;
				break;
			
			case 'D':
				lost[3][tmp_lost] = 1;
				break;
		}
	}
	
	for (i = 0; i < 4; i++){
		for (j = 0; j < 13; j++){
			if (lost[i][j] != 1){
				switch (i){
					case 0:
						mark = 'S';
						break;
					
					case 1:
						mark = 'H';
						break;
						
					case 2:
						mark = 'C';
						break;
					
					case 3:
						mark = 'D';
						break;
				}
				printf("%c %d\n", mark, j + 1);
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 1732
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;


int main(){
  string s, t;
  cin >> s;
  cin >> t;

  int ans = 0;
  rep(i, 3){
    if(s[i] == t[i]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/**
 *  author:   TakeruOkuyama
 *  created:  2020-04-08 10:36:09
**/
#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(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    //vector<bool> x(26, 0);
    //vector<bool> y(26, 0);
    int max = 0;
    for(int i = 0; i < N - 1; i++){
        vector<bool> x(26, false);
        vector<bool> y(26, false);
        for(int j = 0; j < N; j++){
            
            if(j <= i){
                x[int(S[j])-97] = true;
            }else{
                y[int(S[j])-97] = true;
            }
            
        }
        int count = 0;
            rep(k, 26){
                if(x[k] == true && y[k] == true){
                    count++;
                }
            }
            if(count > max){
                max = count;
            }
    }
    cout << max << endl;
return 0;}

/**
 * compile: g++ code.cpp
 * run: ./a.out
 * insert date string: ctrl + shift + i
 * 
**/ 

Measured memory_bytes: 256
/*
          ,     \    /      ,
         / \    )\__/(     / \
        /   \  (_\  /_)   /   \
   ____/_____\__\@  @/___/_____\____
  |             |\../|              |
  |              \VV/               |
  |        ------hoi-------         |
  |_________________________________|
   |    /\ /      \\       \ /\    |
   |  /   V        ))       V   \  |
   |/     `       //        '     \|
   `              V                '
*/

#include <bits/stdc++.h>

#define ld long double
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define f first
#define se second
#define Speedforce boost();
#define fop(s1, s2) freopen(s1, "r", stdin);freopen(s2, "w", stdout);

using namespace std;

void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 1e6;
const ll inf = 1e9 + 7;
const ld PI = acos(-1);

ll bin_pow(ll x, ll y){
    ll res = 1, base = x;
    while(y){
        if(y & 1){
            res *= base;
            res %= inf;
        }
        base *= base;
        base %= inf;
        y /= 2;
    }
    return res;
}

string s;

int main(){
    Speedforce
    //fop("", "")
    cin >> s;
    for(int i = 0;i < s.size();i ++){
        if((i & 1) && s[i] != 'i'){
            cout << "No";
            return 0;
        }
        if(!(i & 1) && s[i] != 'h'){
            cout << "No";
            return 0;
        }
    }
    if(s.size() & 1){
        cout << "No";
        return 0;
    }
    cout << "Yes";
}


Measured memory_bytes: 256
import re
from itertools import count
from sys import stdin


def main():
    _, t, a, *hs = get_params()
    print(solve(t, a, hs))


def get_params():
    return map(int, words(get_contents()))


def words(s):
    return re.split(r'\s', s)


def get_contents():
    return stdin.read().strip()


def solve(t, a, hs):
    def temperature(h):
        return t - 0.006 * h

    def distance(t):
        return abs(t - a)

    ts = map(temperature, hs)
    ds = map(distance, ts)
    dis = zip(ds, count(1))
    return min(dis)[1]


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <functional>
#include <climits>
#include <string>
 
using namespace std;
 
int main()
{
	int N; cin >> N;
	vector<int>a(N+1);
	for( int n = 1; n <= N; n++ )
	{
		cin >> a[n];
	}
	sort(a.begin(), a.end());
 
	int k = 0, ans = 0;
	for( int i = 1; i <= N; i++ )
	{
		if( a[i] == a[i - 1] )
		{
			k++;
			if( k > a[i] )ans++;
		}
		else
		{
			if( k < a[i - 1] )
				ans += k;
			k = 1;
		}
	}
	if( k < a[N] )
		ans += k;
 
	cout << ans << endl;
}

Measured memory_bytes: 640
using System;

namespace _0133
{
    class Program
    {
        static void Main(string[] args)
        {
            char[,] x = new char[8, 8];
            for (int i = 0; i < 8; i++)
            {
                string s = Console.ReadLine();
                for (int j = 0; j < 8; j++)
                {
                    x[i, j] = s[j];
                }
            }
            Console.WriteLine("90");
            for (int j = 0; j < 8; j++)
            {
                for (int i = 7; i >= 0; i--)
                {
                    Console.Write(x[i, j]);
                }
                Console.WriteLine();
            }
            Console.WriteLine("180");
            for (int i = 7; i >= 0; i--)
            {
                for (int j = 7; j >= 0; j--)
                {
                    Console.Write(x[i, j]);
                }
                Console.WriteLine();
            }
            Console.WriteLine("270");
            for (int j = 7; j >= 0; j--)
            {
                for (int i = 0; i < 8; i++)
                {
                    Console.Write(x[i, j]);
                }
                Console.WriteLine();
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 8580
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
//https://www.creativ.xyz/dump-cpp-652/
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
 
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

#ifdef DEBUG_
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
long long gcd(long long a,long long b)
{
    if (a%b==0) return(b);
    else return(gcd(b,a%b));
}
 long long lcm(long long a,long long b){
 long long g = gcd(a,b);
 return a / g * b; 
 }
signed main(void) { cin.tie(0); ios::sync_with_stdio(false);
    int a,b; cin>>a>>b;
    cout<<lcm(a,b)<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{

	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		//				int N = scanner.nextInt();
		//				int K = scanner.nextInt();
		String s = s = scanner.next();

		s = s.replaceFirst("7", "8");
		System.out.println(s);
	}
}


Measured memory_bytes: 21716
#include<iostream>
using namespace std;
int main() {
  int n,given[55],a[55],count=0;
  cin >> n;
  for(int i=0;i<n;i++) cin >> given[i];
  for(int i=0;i<n;i++) a[i] = i+1;
  for(int i=0;i<n;i++){
    if(given[i] == a[i]) count++;
  }
  if(count == n || count == n-2){
    cout << "YES";
  }else{
    cout << "NO";
  }
  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);
			int N = sc.nextInt();
			int A = sc.nextInt();
			int B = sc.nextInt();
      if(N*A<B){
        System.out.print(N*A);
      }
      else if(N*A>B){
             System.out.print(B);
      }
      else{
               System.out.print(B);
      }
			
		}
	}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC omodtimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
typedef complex<long double> com;
 
const ll mod = 998244353;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ld n;
	cin >> n;
	cout << setprecision(60) << n*n*n/ld(27) << endl;
}

Measured memory_bytes: 256
n,m,x,y = map(int,input().split())

xc = list(map(int,input().split()))
xc.sort()
yc = list(map(int,input().split()))
yc.sort()

if xc[-1]+1 <= yc[0] and x < xc[-1]+1 and y >= xc[-1]+1:
    print('No War')
else:
    print('War')

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>

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

using namespace std;

int ans;

void gcd(int x,int y)
{
	ans++;
	x = x % y;
	swap(x,y);

	if(y == 0)
	{
		cout << x << " " << ans << endl;
		return;
	}
	else gcd(x,y);
}

int main()
{
	int a,b;
	while(cin >> a >> b)
	{
		if(a == 0 && b == 0) break;

		ans = 0;

		if(a < b) swap(a,b);
		gcd(a,b);	
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200000 + 10;
char s[N];
int f[N][3];
int main(){
    scanf("%s",s+1);
    int n = strlen(s+1);
    f[1][1] = 1, f[1][2] = -1e9;
    for(int i=2;i<=n;i++){
        f[i][1] = f[i-1][2]+1;
        if(s[i]!=s[i-1]) f[i][1] = max(f[i][1],f[i-1][1]+1);
        f[i][2] = max(f[i][2],max(f[i-2][1],f[i-2][2])+1);
    }
    cout<<max(f[n][1],f[n][2])<<endl;
}


Measured memory_bytes: 2816
import heapq
N,M = map(int,input().split())
H=[]
for i in input().split():
    heapq.heappush(H,-int(i))
for i in range(M):
    a = heapq.heappop(H)
    heapq.heappush(H,-(-a//2))
print(-sum(H))

Measured memory_bytes: 14180