akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <queue>
#include <set>
#include <vector>
using namespace std;

template<typename T>
using vv = vector<vector<T>>;
typedef pair<int, int> pii;
#define st first
#define nd second

const int N = 1e6 + 7;
vv<bool> B;
vv<int> dist;
vv<int> left, right, top, down;
set<int> rows[N], cols[N];
int h, w, k;
int x1, y1, x2, y2;

template<typename T>
void resize(vv<T>& v, T val = 0)
{
	v.resize(h, vector<T>(w, val));
}

template<typename T>
void print(vv<T> V)
{
	for (auto& v : V)
	{
		for (T val : v)
			printf("%d ", val);
		puts("");
	}
}

int bfs()
{
	queue<pii> Q;
	Q.push({x1, y1});
		
	while (!Q.empty())
	{
		pii v = Q.front();
		Q.pop();
		int x = v.st, y = v.nd;

		//printf("%d %d\n", x, y);

		if (x == x2 && y == y2)
			return dist[x][y];
		int d = dist[x][y];
		
		int row_left = max(y - k, left[x][y] + 1);
		int row_right = min(y + k, right[x][y] - 1); 
		//printf("row: %d %d\n", row_left, row_right);
		auto it = rows[x].lower_bound(row_left);
		while (it != rows[x].end() && *it <= row_right)
		{
			int val = *it;
			dist[x][val] = d + 1;
			Q.push({x, val});
			cols[val].erase(x);
			it = rows[x].erase(it);
			if (it != rows[x].end() && *it < val)
				break;
		}

		int col_top = max(x - k, top[x][y] + 1);
		int col_down = min(x + k, down[x][y] - 1);
		//printf("col: %d %d\n", col_top, col_down);
		it = cols[y].lower_bound(col_top);
		while (it != cols[y].end() && *it <= col_down)
		{
			int val = *it;
			dist[val][y] = d + 1;
			Q.push({val, y});
			rows[val].erase(y);
			it = cols[y].erase(it);
			if (it != cols[y].end() && *it < val)
				break;
		}
	}

	return -1;
}

int main()
{
	scanf("%d %d %d", &h, &w, &k);
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	--x1; --x2; --y1; --y2;
	
	resize(B);
	resize(dist, -1);
	resize(top);
	resize(down);
	resize(left);
	resize(right);
	
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
		{
			char c;
			scanf(" %c", &c);
			if (c == '.')
				B[i][j] = true;
			else
				B[i][j] = false;
		}
	
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
			if (B[i][j])
				rows[i].insert(j);
	for (int i = 0; i < w; ++i)
		for (int j = 0; j < h; ++j)
			if (B[j][i])
				cols[i].insert(j);

	for (int i = 0; i < h; ++i)
	{
		int last = -1;
		for (int j = 0; j < w; ++j)
		{
			if (!B[i][j])
				last = j;
			left[i][j] = last;
		}
		last = w;
		for (int j = w - 1; j >= 0; --j)
		{
			if (!B[i][j])
				last = j;
			right[i][j] = last;
		}
	}

	for (int i = 0; i < w; ++i)
	{
		int last = -1;
		for (int j = 0; j < h; ++j)
		{
			if (!B[j][i])
				last = j;
			top[j][i] = last;
		}
		last = h;
		for (int j = h - 1; j >= 0; --j)
		{
			if (!B[j][i])
				last = j;
			down[j][i] = last;
		}
	}

	//print(left);

	dist[x1][y1] = 0;
	rows[x1].erase(y1);
	cols[y1].erase(x1);

	printf("%d", bfs());

	return 0;
}


Measured memory_bytes: 209532
def check(s: str) -> bool:
    ls = len(s)
    if ls % 2 != 0:
        return False
    else:
        if "".join(s[:ls//2]) == "".join(s[ls//2:]):
            return True


s = input()
l = len(s)
ans = 0
for i in reversed(range(l-1)):
    if check(s[0:i + 1]):
        ans = i+1
        break

print(ans)


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

int expo(int x, int n) {
  
  int xn = x;
  for (int i = 1; i < n; i++) {
    xn *= x;
  }  
  return xn;
  
}

int main() {
  int X;
  cin >> X;
  
  int max = 1;
  
  for (int i = 2; i < X; i++) {
    int j = 2;
    
    while (expo(i,j) <= X) {
      if (expo(i,j) > max)
        max = expo(i,j);
      j++;
    }
  }
  
  cout << max << endl;
}


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

int main() {
	int h, w, a[26] = {};
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < w; j++) {
			a[s[j] - 'a']++;
		}
	}
	int k1 = 0, k2 = 0;
	for (int i = 0; i < 26; i++) {
		if (a[i] % 2) {
			k1++;
		} else if (a[i] % 4) {
			k2++;
		}
	}
	int m = min(h, w);
	int n = max(h, w);
	if (m % 2 && n % 2) {
		cout << (k1 == 1 && k2 <= (m + n - 2) / 2 ? "Yes" : "No") << endl;
	} else if (m % 2) {
		cout << (k1 == 0 && k2 <= n / 2 ? "Yes" : "No") << endl;
	} else if (n % 2) {
		cout << (k1 == 0 && k2 <= m / 2 ? "Yes" : "No") << endl;
	} else {
		cout << (k1 == 0 && k2 == 0 ? "Yes" : "No") << endl;
	}
	return 0;
}


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

for n in range(1,N+1):
    a=1
    b=1
    c=1
    d=1
    e=1
    f=1
    z=1
    while n % 2 == 0:
        z=0
        n /= 2

    while n % 3 ==0:
        n /= 3
        a +=1
        
    while n % 5 ==0:
        n /= 5
        b +=1
        
    while n % 7 ==0:
        n /= 7
        c +=1
        
    while n % 11 ==0:
        n /= 11
        d +=1
        
    while n % 13 ==0:
        n /= 13
        e +=1
        
    if n > 1:
        f=2
        
    if z*a*b*c*d*e*f == 8:
        ret +=1

    # print ("{0} {1} {2} {3} {4}\n".format(n, z, a, b, c))
print (ret)

Measured memory_bytes: 3064
N=int(input())
ans=0
if N//(10**1)>=1:
  ans+=9
else:
  ans+=N
  print(ans)
  exit()
if N//(10**3)>=1:
  ans+=900
else:
  if N>=100:
    ans+=N-99
    print(ans)
    exit()
  else:
    print(ans)
    exit()
if N//(10**5)==1:
  ans+=90000
  print(ans)
else:
  if N>=10000:
    ans+=N-9999
    print(ans)
  else:
    print(ans)

Measured memory_bytes: 3064
from collections import defaultdict
import heapq


n, k = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(n)]

sushi.sort(key=lambda x: x[1])
kinds = defaultdict(int)
eaten = []
ans = 0
for i in range(k):
    neta, point = sushi.pop()
    kinds[neta] += 1
    ans += point
    heapq.heappush(eaten, [point, neta])

num_of_kinds = len(kinds.keys())
ans += num_of_kinds ** 2
candidate = ans

for i in range(k):
    point, neta = heapq.heappop(eaten)
    if kinds[neta] == 1:
        continue
    kinds[neta] -= 1

    while sushi:
        new_neta, new_point = sushi.pop()
        if kinds[new_neta] >= 1:
            continue
        else:
            break
    else:
        break
    kinds[new_neta] += 1
    num_of_kinds += 1
    delta = new_point - point + (2*num_of_kinds - 1)
    candidate += delta
    ans = max(ans, candidate)

print(ans)

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
#define exit(a, b) return cout << a, b;

#define PB push_back
#define MP make_pair

#define sd(n) scanf("%d", &n)
#define pdn(n) printf("%lld\n", n);
#define pds(n) printf("%lld ", n);
#define endl '\n'

#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define all(v) v.begin(), v.end() 

using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

#define int long long
#define float long double 
#define ll long long

const int inf = (int) 1e16;
const int upper = (int) 4e5 + 15;
const int M = (ll) 1e9 + 7;
const int mod = (ll) 998244353;
const double eps =  1e-8;

bool win[100001];
vi a;

signed main () {
	start_routine();
	speed();
	#ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);	
	// freopen("output.txt", "w", stdout);
	// freopen("errlog.txt", "w", stderr);
	#endif

	win[0] = false;
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i += 1) {
		int lo; cin >> lo; 
		a.push_back(lo);
	}
	for (int i = 1; i <= k; i += 1) {
		bool found = false;
		for (auto j: a) {
			if (i - j >= 0) {
				if (win[i - j] == false) found = true;
			} 
		}
		if (found) win[i] = true;
		else win[i] = false;
	}

	if (win[k]) cout << "First";
	else cout << "Second";
 	end_routine();	
}

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

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    int count=0, value;
    for(int i=0; i<N; i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(),vec.end());
    value = vec.at(0);
    count++;
    for(int x: vec){
        if(x != value){
            count++;
            value = x;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<atcoder/scc>

using namespace std;
using namespace atcoder;

int main(){

  int n,m;
  cin>>n>>m;
  scc_graph scc(n);
  for(int i=0;i<m;++i){
    int u,v;
    cin>>u>>v;
    scc.add_edge(u,v);
  }
  
  auto res = scc.scc();
  cout<<size(res)<<endl;
  for(auto& vec:res){
    cout<<size(vec);
    for(auto& v:vec)cout<<" "<<v;
    cout<<'\n';
  }

}

Measured memory_bytes: 40104
import math

n, k = map(int, input().split())

m = [2**i for i in range(18)]

sum = 0

for i in range(1, n+1):
    if i<k :
        x = math.ceil((math.log2(k/i)))
        #print(i,x)
        sum += 0.5**x
    else :
        sum +=1

print(sum/n)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const ll Inf = 1ll << 60;
ll n;
ll a[maxx];
ll ans = Inf;

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	bool flg = 0;
	ll sum = 0, res = 0;
	for(int i = 1; i <= n; i++) { 
		sum += a[i];
		if(!flg) { 
			if(sum <= 0) { 
				res += 1 - sum; 
				sum = 1;
			}
		}
		else { 
			if(sum >= 0) { 
				res += sum + 1; 
				sum = -1;
			}
		}
		flg ^= 1; 
	}
	ans = min(ans, res);
	sum = res = 0;
	flg = 0;
	for(int i = 1; i <= n; i++) { 
		sum += a[i];
		if(!flg) { 
			if(sum >= 0) { 
				res += sum + 1;
				sum = -1;
			}
		}
		else { 
			if(sum <= 0) { 
				res += 1 - sum;
				sum = 1;
			}
		}
		flg ^= 1;
	}
	ans = min(ans, res);
	cout << ans << endl;
}

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

int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    int c = 0;
    for (int i = min(A, B); i >= 1; i--)
    {
        if (A % i == 0 && B % i == 0)
        {
            c++;
        }
        if (c == K)
        {
            cout << i << endl;
            return 0;
        }
    }
}


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

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  int result;
  if (N % X == 0) {
    result = N / X;
    result *= T;
  }
  else {
    result = N / X + 1;
    result *= T;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3616
import * as fs from "fs";

class MaxHeap<T> {
	private items: Array<T>;
	constructor(items: Array<T>) {
		this.items = items;
		for(let ix: number = this.items.length; ix >= 0; ix--) {
			this.bubbleDown(ix);
		}
	}
	push(item: T): void {
		let i: number = this.items.length;
		this.items.push(item);
		this.bubbleUp(i);
	}
	pop(): T {
		let toReturn: T = this.items[0];
		let poppedElement: T = this.items.pop();
		if (this.items.length > 0) {
			this.items[0] = poppedElement;
			this.bubbleDown(0);
		}
		return toReturn;
	}
	peek(): T {
		return this.items[0];
	}
	size(): number {
		return this.items.length;
	}
	private bubbleUp(ix: number): void {
		if (ix != 0) {
			let p: number = Math.floor((ix-1)/2);
			if (this.items[ix] > this.items[p]) {
				[this.items[ix], this.items[p]] = [this.items[p], this.items[ix]];
				this.bubbleUp(p);
			}
		}
	}
	private bubbleDown(ix: number): void {
		let min_index = ix;
		for(let i = 1; i < 3; i++) {
			if (2*ix+i < this.items.length && this.items[min_index] < this.items[2*ix+i]) {
				min_index = 2*ix+i;
			}
		}
		if (min_index != ix) {
			[this.items[min_index], this.items[ix]] = [this.items[ix], this.items[min_index]]
			this.bubbleDown(min_index);
		}
	}
}

let [line1, line2] = fs.readFileSync("/dev/stdin", "utf8").split("\n");
let [N, M] = line1.split(" ").map(Number);
let A = line2.split(" ").map(Number);

let maxHeap: MaxHeap<number> = new MaxHeap(A);

while (M > 0) {
	maxHeap.push(Math.floor(maxHeap.pop()/2));
	M -= 1;
}

let total = 0;
while (maxHeap.size() > 0) {
	total += maxHeap.pop();
}

console.log(total);


Measured memory_bytes: 47032
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

int main() {
  ll n,m,count=0;
  cin >> n >> m;
  ll a[m]={0};
  r(i,m)cin >> a[i];
  r(i,m)count+=a[i];
  
  if(n<count)cout<<-1<<endl;
  else cout<<n-count<<endl;
}

Measured memory_bytes: 3668
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  vector<int64_t> histogram(N + 1, 0);
  vector<int64_t> A(N);
  vector<int64_t> result(N, 0);
  for (int64_t i = 0; i < N; ++i) {
    cin >> A[i];
    ++histogram[A[i]];
  }
  int64_t P = 0;
  for (int64_t i = 0; i <= N; ++i) {
    if (histogram[i] >= 2) {
      P += histogram[i] * (histogram[i] - 1) / 2;
    }
  }
  for (int64_t i = 0; i < N; ++i) {
    const int32_t a = A[i];
    if (histogram[a] == 1) {
      cout << P << endl;
    } else if (histogram[a] == 2) {
      cout << P - (histogram[a] * (histogram[a] - 1) / 2) << endl;
    } else {
      cout << P - (histogram[a] * (histogram[a] - 1) / 2) + (histogram[a] - 1) * (histogram[a] - 2) / 2 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define re register
using namespace std;

inline int read(){
	re int ans = 0;re bool f = 1;re char ch = getchar();
	while(ch<'0'||ch>'9'){if (ch=='-')f = 0;ch = getchar();}
	while(ch>='0'&&ch<='9'){
		ans = (ans<<3)+(ans<<1)+(ch^48);
		ch = getchar();
	}
	return f?ans:~(ans-1);
}

signed main(void){
	double r = read();r*=2;
	double pai = 3.14159265358;
	printf("%lf\n",pai*r);
  	return 0;
}

Measured memory_bytes: 3720
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
struct node{
	int ans;
	char str[20];
} a[220000];
bool cmp1(node x,node y) {
	if (strcmp(x.str,y.str)<0) return true; else return false;
}
bool cmp2(node x,node y) {
	if (x.ans>y.ans||(x.ans==y.ans&&strcmp(x.str,y.str)<0)) return true; else return false;
}
int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%s",a[i].str);
	sort(a+1,a+1+n,cmp1);
	node tmp=a[1];
	int l=1,ans=1;
	for (int i=2;i<=n;++i) 
		if (strcmp(a[i].str,tmp.str)!=0) {
			for (int j=l;j<i;++j) a[j].ans=ans;
			ans=1;l=i;tmp=a[i];
		} else ++ans;
	for (int j=l;j<=n;++j) a[j].ans=ans;
	sort(a+1,a+n+1,cmp2);
	tmp=a[1];
	int x=2;
	printf("%s\n",a[1].str);
	while (a[x].ans==a[1].ans) {
		if (strcmp(a[x].str,tmp.str)!=0) {
			printf("%s\n",a[x].str);
			tmp=a[x];
		}
		++x;
	}
	return 0;
} 

Measured memory_bytes: 6528
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const int INF = 2e9;
int N, T;
int A[100005];
int MIN[100005], MAX[100005];

int main() {
  INCANT;
  cin >> N >> T;
  rep(i, N) cin >> A[i];
  
  MIN[0]=A[0];
  rep(i, N) {
    if (i==0) continue;
    MIN[i]=min(A[i], MIN[i-1]);
  }
  MAX[N-1]=A[N-1];
  for (int i=N-2; i>=0; i--) MAX[i] = max(MAX[i+1], A[i]);
  int diff=0;
  rep(i, N) diff = max(MAX[i]-MIN[i], diff);
  int cnt=0;
  rep(i, N) if (MAX[i]-A[i]==diff) cnt++;

  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 1408
a,b = map(int,input().split())
c = []
d = []
e = 0
for i in range(a):
     c.append(i+b)
     d.append(abs(i+b))
     e += i+b
d = sorted(d)
if c[-1] < 0:
     print(e+d[0])
else:
     print(e-d[0])

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll INF = LLONG_MAX / 2;
int N, M;
ll A[5010], B[5010][210];
stack<pair<ll, int>> st[5010];

int main(){
    cin >> N >> M;
    
    rep(i, N - 1) {
        scanf("%lld", &A[i + 1]);
        A[i + 1] += A[i];
    }
    rep(i, N)rep(j, M)scanf("%lld", &B[i][j]);
    rep(i, M)st[i].push(mp(INF, N));

    vll dif(N + 1), sum(N + 1);

    ll ans = 0;
    for(int l = N - 1; l >= 0; --l) {
        fill(all(dif), 0ll);
        rep(i, M) {
            ll x = B[l][i];
            while(x >= st[i].top().first) {
                int lb, ub;
                ll y;
                tie(y, lb) = st[i].top();
                st[i].pop();
                ub = st[i].top().second;
                dif[lb] -= y;
                dif[ub] += y;
            }
            int r = st[i].top().second;
            dif[l] += x;
            dif[r] -= x;
            st[i].push(mp(x, l));
        }
        FOR(i, l, N)dif[i + 1] += dif[i];
        FOR(r, l, N) {
            sum[r] += dif[r];
            smax(ans, sum[r] - A[r] + A[l]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 11904
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	ll N;
	ll a[200200];
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	ll all = 0;
	for(int i = 0; i < N; i++){
		all = all ^ a[i];
	}
	for(int i = 0; i < N; i++){
		cout << (all ^ a[i]) << " ";
	}
			cout << endl;
	return 0;
}


Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
int N;
int A_min;
int A[100000];
int sol_min() {
    for(int i=0;i<N;i++){
        int hoge=A[i] % A_min;
        if(hoge !=0 && hoge < A_min){
            A_min=hoge;
            sol_min();
            return 0;
        }
    }
    return 0;
}
int main(void) {
    cin>>N;
    for(int i=0;i<N;i++) {
        cin >> A[i];
        // cout << A[i] << endl;
    }
    sort(A, A+N);
    A_min=A[0];
    sol_min(); 
    cout << A_min;
    return 0;
}

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

int main(){
    int N;
    std::cin >> N;
    std::vector< int > A(N);
    std::vector< int > B(N);
    std::map< int, int > Amp;
    std::map< int, int > Bmp;
    for(int i=0; i<N; i++){
        std::cin >> A[i];
        
        auto itra = Amp.find(A[i]);
        if(itra != Amp.end()){
            Amp[A[i]]++;
        }else{
            Amp[A[i]] = 1;
        }
    }
    for(int i=0; i<N; i++){
        std::cin >> B[i];
        auto itrb = Bmp.find(B[i]);
        if(itrb != Bmp.end()){
            Bmp[B[i]]++;
        }else{
            Bmp[B[i]] = 1;
        }
    }
    
    for(auto itra=Amp.begin(); itra != Amp.end(); itra++){
        auto itrb = Bmp.find(itra->first);
        if(itrb != Bmp.end()){
            if(itra->second + itrb->second > N){
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }
    
    int cnt = 0;
    int Aindex = 0;
    int Bindex = 0;
    while(cnt <= N){
        if(A[Aindex] != B[Aindex]){
            cnt++;
            Aindex++;
            if(Aindex == N){ Aindex = 0; }
        }else{
            while(A[Aindex] == B[Bindex]){
                Bindex++;
                if(Bindex == N){ Bindex = 0; }
            }
            std::swap(B[Aindex], B[Bindex]);
            cnt = 0;
            Aindex++;
            if(Aindex == N){ Aindex = 0; }
            Bindex++;
            if(Bindex == N){ Bindex = 0; }
        }
    }
    
    std::cout << "Yes" << std::endl;
    for(int i=0; i<N-1; i++){
        std::cout << B[i] << " ";
    }
    std::cout << B[N-1] << std::endl;
    
    return 0;
    
}


Measured memory_bytes: 23348
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstring>

using namespace std;


string s(double d){
	if(d<=48)return "light fly";
	if(d<=51)return "fly";
	if(d<=54)return "bantam";
	if(d<=57)return "feather";
	if(d<=60)return "light";
	if(d<=64)return "light welter";
	if(d<=69)return "welter";
	if(d<=75)return "light middle";
	if(d<=81)return "middle";
	if(d<=91)return "light heavy";
	return "heavy";
}

int main(){
	double d;
	while(cin>>d){
		cout<<s(d)<<endl;
	}
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll r=0;
    ll l=1000000000;
    while (l-r>1)
    {
        ll mid=(r+l)/2;
        ll co=0;
        rep(i, n) {
            co+=(a[i]-1)/mid;
        }
        if (co>k) {
            r=mid;
        }
        else {
            l=mid;
        }
    }
    cout << l << endl;
}

Measured memory_bytes: 4848
N = int(input())
H = list(map(int, input().split()))
max_move_cnt = 0
tmp_move_cnt = 0

for i in range(N-1):
    if H[i] >= H[i+1]:
        tmp_move_cnt += 1
    else:
        tmp_move_cnt = 0

    max_move_cnt = tmp_move_cnt if tmp_move_cnt >= max_move_cnt else max_move_cnt

print(max_move_cnt)

        


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

void solve() 
{
    int a,b;cin>>a>>b;
    cout<<(a*b%2?"Odd":"Even")<<endl;
}

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

Measured memory_bytes: 256
n = map(int, raw_input().split())
m = [0, 0, 0]


count = 0
while True:
    for i in range(3):
        if n[i]%2 == 1:
            print count
            exit()
    if n[0] == n[1] and n[1] == n[2]:
        print -1
        exit()
    for i in range(3):
        m[i]=(n[(i+1)%3]/2)+(n[(i+2)%3]/2)
    for i in range(3):
        n[i] = m[i]
    count += 1


Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

class UnionFind{
public:
    //親の番号を格納する．親だった場合は-(その集合のサイズ)
    vector<int> Parent;
    //作るときはParentの値をすべて-1にする
    //こうするとすべてバラバラになる
    UnionFind(int N){
        Parent = vector<int>(N,-1);
    }
    //Aがどのグループに所属しているか
    int root(int A){
        if(Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    //自分のいるグループの頂点数を調べる
    int size(int A){
        return -Parent[root(A)];//親を取って行きたい
    }

    //AとBをくっつける
    bool connect(int A,int B){
        //AとBを直接つなぐのではなく，root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if(A==B){
            //すでにくっついているからくっつけない
            return false;
        }

        //大きい方(A)に小さい方(B)をくっつけたい
        //大小が逆だったらひっくり返しちゃう
        if(size(A) < size(B)) swap(A,B);

        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        return true;
    }
};

int main(){
    int N,M;cin>>N>>M;
    vector<int> A(M);
    vector<int> B(M);
    for(int i = 0; i < M; i++)
    {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
    vector<long long> ans(M);
    ans[M-1] = (long long) N * (N-1) / 2;
    UnionFind Uni(N);
    for(int i = M-1; i >= 1; i--)
    {
        //繋がっていなかったのが繋がった時
        if(Uni.root(A[i]) != Uni.root(B[i])){
                ans[i-1] = ans[i] - (long long)Uni.size(A[i]) * Uni.size(B[i]);
                Uni.connect(A[i],B[i]);
        }
        else ans[i-1] = ans[i];
    }
    for(int i = 0; i < M; i++)
    {
        cout<<ans[i]<<endl;
    } 
}




Measured memory_bytes: 3328
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))


n,r = miinps()

if n >= 10:
  print(r)
else:
  print(r + (100*(10-n)))

Measured memory_bytes: 3060
import java.util.*;

class Main {
	Scanner sc;
	
	void calc() {
		sc = new Scanner(System.in);
		String s = sc.next();
		if (s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5))
			System.out.println("Yes");
		else
			System.out.println("No");
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 35532
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, a, b, x;

            var word = Console.ReadLine().Split(' ');
            n = int.Parse(word[0]);
            a = int.Parse(word[1]);
            b = int.Parse(word[2]);

            if (a * n <= b)
                x = a * n;
            else 
                x = b;
            Console.WriteLine(x);
            Console.ReadKey();
        }
    }
}

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	long long int a, b;
	cin >> a >> b;
	long long int c = lcm(a, b);
	long long int sum = 0;
	long long int k = c;
	for (int i = 2; i <= sqrt(k); i++) {
		if (c % i == 0) {
			sum++;
			while (c % i == 0) {
				c = c / i;
			}
		}
	}
	if (c != 1) {
		sum = sum + 1;
	}
	cout << sum+1;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;


constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    void CCout(long long x, const char* end = "\n") { std::cerr << x << end; }
    template <typename T> void CCout(const T& x, const char* end = "\n") { std::cerr << x << end; }
    template <typename T> void CCout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cerr << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
        template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
    };

    inp inp1; // input one

    void dfs(ll val, vector<ll>* res) {
        res->emplace_back(val);
        if (val >= 4e9) return;

        int d = val % 10;

        for (int i = -1; i <= 1; ++i) {
            if (d + i >= 0 && d + i <= 9) {
                ll tmp = val * 10 + d + i;
                dfs(tmp, res);
            }
        }
    }
}

int main() {

    int k = inp1;

    vector<ll> ans;
    Rep(i, 1, 10) {
        dfs(i, &ans);
    }

    sort(allof(ans));
    Cout(ans[k - 1]);

    return 0;
}


Measured memory_bytes: 6256
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const [n, s] = stdin.split('\n')

const uniq = arr => {
  return arr.filter((e, i, self) => self.indexOf(e) === i)
}

const getSameVals = (arr, target) => {
  return arr.filter(e => target.indexOf(e) > -1)
}

const getCount = (ar1, ar2) => {
  const filtered1 = getSameVals(ar1, ar2)
  const filtered2 = getSameVals(ar2, ar1)

  return uniq([...filtered1, ...filtered2]).length
}

const ans = _ => {
  const strArr = s.split('')

  let count = 0
  for (let i = 1; i < n; i++) {
    const firstHalf = strArr.slice(0, i)
    const lastHalf = strArr.slice(i)

    let tmpCount = getCount(firstHalf, lastHalf)

    count = Math.max(tmpCount, count)
  }

  console.log(count)
}

ans()


Measured memory_bytes: 11596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i=(ll)(0); i<(ll)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007


int main() {
    ll n;
    cin >> n;
    map<ll, ll> mp;
    vector<ll> vec;
    rep(i, n){
        ll num;
        cin >> num;
        vec.push_back(num);
        mp[num]++;
    }
    ll sum;
    for(ll i=(ll)(1); i<=n; i++){
        sum += mp[i]*(mp[i]-(ll)(1))/(ll)(2);
    }
    rep(i, n){
      	ll before = (ll)(mp[vec[i]])*((ll)(mp[vec[i]])-(ll)(1))/(ll)(2);
      	ll after = ((ll)(mp[vec[i]])-(ll)(1))*((ll)(mp[vec[i]])-(ll)(2))/(ll)(2);
    	ll res = sum-before+after;
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 17520
from sys import exit

S = input()
odd = set(['L','U','D'])
even = set(['R','U','D'])

for i in range(len(S)):
    if i%2 == 0:
        if S[i] not in even:
            print("No")
            exit(0)
    else:
        if S[i] not in odd:
            print("No")
            exit(0)

print("Yes")

Measured memory_bytes: 60924
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <map>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int n;
string s;
bool isOk(int len) {
  map<string, int> memo;
  for(int i = 0; i+len <= n; ++i) {
    string cur = s.substr(i, len);
    if(memo.count(cur)) {
      if(memo[cur] + len <= i) {
        return true;
      }
    } else {
      memo[cur] = i;
    }
  }
  return false;
}

int main(void) {
  cin >> n >> s;
  int left = 0;
  int right = n/2+1;
  while(left + 1 < right) {
    int mid = (left + right) / 2;
    if(isOk(mid)) {
      left = mid;
    } else {
      right = mid;
    }
  }
  cout << left << endl;
  return 0;
}


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

int main() {
    string o,e;
    cin >> o >> e;
    string ret = "";

    for (int i = 0; i < e.length(); i++) {
       ret += o[i]; 
       ret += e[i]; 
    }
    if (o.length() > e.length()) {
        ret += o[o.length() -1];
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a)  (a).begin(),(a).end()
int main(){
  int A, B;
  cin >> A >> B;
  int num = 1;
  int counter = 0;
  while(num < B){
    num += A - 1;
    counter++;
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

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

	int n;

	cin >> n;

	float count = 0;
	float average = 0;

	vector<float> x(n);
	vector<float> y(n);

	for(int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}

	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			count++;
			average += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
		}
	}




	cout << fixed << average / count * (n - 1);
}


Measured memory_bytes: 256
from collections import deque

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
ab_set = []
for i in ab:
    ab_set.append([min(i), max(i)])
ab_set = list(map(tuple, ab_set))
ab_set = list(set(ab_set))
graph = [deque([]) for _ in range(n + 1)]

for i in ab_set:
    graph[i[0]].append(i[1])
    graph[i[1]].append(i[0])

arrive_time = [-1] * (n + 1)  # 到着時刻

def dfs(v):
    time = 1
    stack = [v]
    arrive_time[v] = time
    while stack:
        v = stack[-1]
        if graph[v]:
            w = graph[v].popleft()
            if arrive_time[w] < 0:
                time += 1
                arrive_time[w] = time
                stack.append(w)
        else:
            stack.pop()
    return arrive_time


for i in range(n):
    if arrive_time[i + 1] < 0:
        ans = dfs(i + 1)

print(max(ans))


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

int main()
{
  vector<int> points(6);
  for(int i = 0; i < 6; ++i)
  {
    cin >> points.at(i);
  }
  
  vector<int> counts(4);
  for(int i = 0; i < 4; ++i)
  {
    counts.at(i) = count(points.begin(), points.end(), i + 1);
  }
  
  if(count(counts.begin(), counts.end(), 3) > 0 || count(counts.begin(), counts.end(), 0) > 0)
  {
    cout << "NO" << endl;
    return 0;
  }
  else
  {
    cout << "YES" << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 99999999999999999

struct Info{
	ll num,words_num;
};

ll total[18],table_3[18],table_5[18],table_15[18];

ll getNUM(ll value){ //value == ??°???

	ll digit = 0;

	//?????°????±???????<10^digit<= value <= 10^(digit+1)??¨?????????????????????>
	while(pow(10,digit+1) < value){
		digit++;
	}

	ll tmp = 0;
	//printf("digit:%lld\n",digit);

	for(int i = 0; i < digit; i++){
		tmp += total[i];
	}

	ll left_num = pow(10,digit);

	//left_num???value?????§??????????????????3????????°???5????????°???15????????°?????°????±???????
	ll num_3 = value/3-left_num/3;
	ll num_5 = value/5-left_num/5;
	if(left_num%5 == 0){
		num_5++;
	}
	ll num_15 = value/15-left_num/15;

	return tmp+4*(num_3+num_5-2*num_15)+8*num_15+(digit+1)*(value+1-left_num-(num_3+num_5-num_15));
}

//2?????¢?´¢????????????number??????????????§?????¨?????¨?????????????????§?????°???????????´????????¢??°
Info calc(ll number){ //number:?????????

	Info ret;
	ret.num = 0;
	ret.words_num = 0;

	ll left,right,m,tmp;
	left = 1,right = NUM,m = (left+right)/2; //??°??????????????¢?´¢

	while(left <= right){
		if((tmp = getNUM(m)) <= number){
			ret.num = m;
			ret.words_num = tmp;
			left = m+1;
		}else{
			right = m-1;
		}
		m = (left+right)/2;
	}
	return ret;
}


int main(){


	ll left,right,num_3,num_5,num_15;

	//1???
	table_3[0] = 3;
	table_5[0] = 1;
	table_15[0] = 0;
	total[0] = 21;

	for(ll i = 1; i <= 17; i++){ //10???i??????10???(i+1)???-1
		left = pow(10,i);
		right = pow(10,i+1)-1;

		num_3 = right/3;
		num_5 = right/5;
		num_15 = right/15;

		for(int k = 0; k <= i-1; k++){
			num_3 -= table_3[k];
			num_5 -= table_5[k];
			num_15 -= table_15[k];
		}
		table_3[i] = num_3;
		table_5[i] = num_5;
		table_15[i] = num_15;

		total[i] = 4*(num_3+num_5-2*num_15)+8*num_15+(i+1)*((right+1-left)-(num_3+num_5-num_15));
	}

	ll number;
	scanf("%lld",&number);

	Info next = calc(number-1); //number-1???????????§????????????????????§?????°?????¨?????????????????°????±???????

	if(number == 1000000000000000000){
		next.words_num -= 4;
	}

	//printf("next.num:%lld next.words_num:%lld\n",next.num,next.words_num);

	string ans;

	for(ll i = 1; i <= 20; i++){
		if((next.num+i)%15 == 0){
			ans.append("FizzBuzz");
		}else if((next.num+i)%3 == 0){
			ans.append("Fizz");
		}else if((next.num+i)%5 == 0){
			ans.append("Buzz");
		}else{
			ans.append(to_string(next.num+i));
		}
	}

	ll index;
	for(index = 1;next.words_num+index < number ;index++);

	for(ll i = 0; i < 20; i++){
		printf("%c",ans[index-1+i]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 3508
import java.util.*;
public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    //number of musics
    int mNum = sc.nextInt();
    //music list
    String [] mList = new String[mNum];
    //time list
    int [] tList = new int[mNum];
    
    for (int i = 0; i < mNum; i++){
      mList[i] = sc.next();
      tList[i] = sc.nextInt();
    }
    
    //start to sleep
    String music = sc.next();
    
    //sleeping time
    int sTime = 0;
    
    //awake or sleep
    boolean sleep = false;
    
    for (int i = 0; i < mNum; i++){
      if(sleep){
        sTime += tList[i];
      }else if(mList[i].equals(music)){
        sleep = true;
      }
    }
    
    System.out.println(sTime);
    
  }
}

Measured memory_bytes: 22484
#include <iostream>
using namespace std;
int main () {
    long long int n, a[5], ans=0, mini=1000000000000001, k;
    cin>>n;
    for (long long int i=0; i<5; i++) cin>>a[i];
    for (long long int i=0; i<5; i++) {
        if (a[i]<mini) mini=a[i], k=i;
    }
    if (n%mini==0) ans=n/mini;
    else ans=n/mini+1;
    ans+=4;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 20000001
#define VMAX 10000

int main(){
  unsigned short *a, *b;

  int c[VMAX + 1];
  int n,i, j;
  scanf("%d",&n);

  a=malloc(sizeof(short)*n+1);
  b=malloc(sizeof(short)*n+1);

  for(i=0;i<=VMAX;i++) c[i]=0;

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

  for(i=1 ; i<= VMAX ; i++){
    c[i]=c[i]+c[i-1];
  }

  for(j=1;j<=n;j++){
    b[c[a[j]]]= a[j];
    c[a[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i> 1) printf(" ");
    printf("%d",b[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 9564
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a1=LIST()
    a2=LIST()
    a3=LIST()
    a=[]
    a.append(a1)
    a.append(a2)
    a.append(a3)
    n=INT()
    num=[]
    for i in range(n):
        num.append(INT())
    for i in num:
        for k in a:
            if i in k:
                temp=k.index(i)
                k[temp]=0
    flg=0
    for i in a:
        if i==[0,0,0]:
            flg=1
    for i in range(3):
        if a[0][i]==0 and a[1][i]==0 and a[2][i]==0:
            flg=1
    if a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
        flg=1
    if a[2][0]==0 and a[1][1]==0 and a[0][2]==0:
        flg=1
    if flg==1:
        print('Yes')
    else:
        print('No')
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
import numpy as np


def main():
    n = int(input())
    h = np.fromstring(input(), dtype='int', sep=' ')
    h = np.append(h, [0] * 2)

    dp = np.full(n + 1, 10 ** 9, dtype='int')
    dp[0] = 0

    for i in range(n - 1):
        dp[i + 1:i + 3] = np.minimum(
            dp[i + 1:i + 3],
            dp[i] + np.abs(h[i] - h[i + 1:i + 3])
        )
    print(dp[n - 1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 21524
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    ll d = N / 11;
    ans += d * 2;
    N %= 11LL;
    if (0 < N && N <= 6) ans += 1;
    else if (6 < N) ans += 2;
    cout << ans << '\n';
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main(){
long long h;
long long count=0;
cin>>h;
while(1){
    if(h/2>0){
        h=h/2;
        count++;
    }
    else{
        break;
    }

}
long long ans=0;
for(int i=0;i<=count;i++){
    ans+=pow(2,i);
}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
for _ in range(n):
    x, y, b, p = map(int, input().split())
    if b >= 5 and p >= 2:
        print((x*b + y*p)*4//5)
    else:
        normal = x*b + y*p
        discounted = ( x*max(5, b) + y*max(2, p) )*4//5
        if normal < discounted:
            print(normal)
        else:
            print(discounted)


Measured memory_bytes: 5600
#include <stdio.h>

const int max = 100;

int main(void){
	char a[max], b[max], c[max]; 
	int a_index=0, b_index=0, c_index=0;
	char ch = 'a';
	int i;

	scanf("%s", a);
	scanf("%s", b);
	scanf("%s", c);

	for(i = 0; i < max*3; i++){
		switch(ch){
			case 'a':
			ch = a[a_index];
			a_index++;
			if(ch == 0) {
				printf("%c\n", 'A');
				return 0;
			}
			break;
			case 'b':
			ch = b[b_index];
			b_index++;
			if(ch == 0) {
				printf("%c\n", 'B');
				return 0;
			}
			break;
			case 'c':
			ch = c[c_index];
			c_index++;
			if(ch == 0) {
				printf("%c\n", 'C');
				return 0;
			}
			break;
		}
	}

	return -1;
}

Measured memory_bytes: 128
num_snukes, num_kinds_snack = list(map(int, input().split()))

snack_maps = []

for _ in range(num_kinds_snack):
    num_snukes_has_snack_i = int(input())
    has_snack_list = list(map(int, input().split()))

    snack_maps.append(has_snack_list)

snukes_has_snacks = [False] * num_snukes

for has_snack_list in snack_maps:
    for i in has_snack_list:
        snukes_has_snacks[i - 1] = True

num_victims = len([snuke for snuke in snukes_has_snacks if not snuke])

print(num_victims)


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  string s;
  cin >> s;
  string ans = "";
  rep(i, s.length()) {
    char t = s[i];
    if (t == '0') {
      ans += "0";
    }
    if (t == '1') {
      ans += "1";
    }
    if (t == 'B') {
      if (ans != "") {
        ans = ans.substr(0, ans.length() - 1);
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
#include <vector>
typedef long long ll;

using namespace std;

int main(){
    ll s;
    cin >> s;
    vector<ll> num;
    while (s > 0){
	num.push_back(s%10);
	s /= 10;
    }
    reverse(num.begin(), num.end());

    vector<bool> add(num.size(), false);
    ll res = 0;
    for (int i = 0; i < pow(2, add.size()-1); i++){
	for (int j = 0; j < add.size(); j++) add[j] = false;
	int x = i;
	int j = 0;
	while (x > 0){
	    if (x%2 == 1) add[j] = true;
	    j++;
	    x /= 2;
	}

	ll y = 0;
	for (int j = 0; j < add.size(); j++){
	    if (!add[j]){
		y = y*10+num[j];
	    } else {
		res += y*10+num[j];
		y = 0;
	    }
	}
	res += y;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
////////////////////////  : |)  W H I T E C L O U D : |)   ////////////////////////
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    ll n,x,t,q,rem,mult;
    cin>>n>>x>>t;
    if(n<=x)mult=1;
    else
    {
        mult=n/x;
        if(n%x!=0)mult++;
    }
    cout<<t*mult<<endl;



    return 0;
}







Measured memory_bytes: 3648
// #include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <emmintrin.h>

using namespace std;

typedef long long ll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define DEBUG(x) cout<<#x<<": "<<x<<endl

#define CHMAX(a,b) a=max((a),(b))

int n,m;
unsigned int a[5000] __attribute__((aligned(16)));
unsigned int b[5000*256] __attribute__((aligned(16)));
unsigned int mx[256] __attribute__((aligned(16)));

unsigned long long tmp[2] __attribute__((aligned(16)));

static inline __m128i __attribute__((always_inline))
po_mm_max_epi32(__m128i a, __m128i b){
  __asm__("pmaxsd %1, %0" : "+x" (a) : "xm" (b));
  return a;
}

void f1(int x){
  // REP(i,m)CHMAX(mx[i],b[256*x+i]);
  for(int i=0;i<m;i+=4){
    __m128i xx = _mm_load_si128((__m128i*)(mx+i));
    __m128i yy = _mm_load_si128((__m128i*)(b+256*x+i));
    xx = po_mm_max_epi32(xx,yy);
    _mm_store_si128((__m128i*)(mx+i), xx);
  }
}
ll f2(){
  // ll ret = 0;
  // REP(i,m)ret += mx[i];
  // return ret;
  __m128i x = _mm_setzero_si128();
  __m128i y = _mm_setzero_si128();
  const __m128i zero = _mm_setzero_si128();

  for(int i=0;i<m;i+=4){
    __m128i xx = _mm_load_si128((__m128i*)(mx+i));
    __m128i yy = _mm_unpackhi_epi32(xx,zero);
            xx = _mm_unpacklo_epi32(xx,zero);
    x = _mm_add_epi64(x,xx);
    y = _mm_add_epi64(y,yy);
  }
  x = _mm_add_epi64(x,y);
  _mm_store_si128((__m128i*)tmp, x);
  return tmp[0] + tmp[1];
}

int main(){
  scanf("%d%d",&n,&m);
  REP(i,n-1)scanf("%u",a+i);
  REP(i,n)REP(j,m)scanf("%u",&b[256*i+j]);
  // REP(i,n-1)a[i]=1;
  // REP(i,n)REP(j,m)b[256*i+j]=1;

  ll ans = 0;
  REP(l,n){
    ll lensum = 0;
    REP(j,m)mx[j]=0;
    f1(l);
    CHMAX(ans,f2()-lensum);
    FOR(r,l+1,n){
      lensum += a[r-1];
      f1(r);
      CHMAX(ans,f2()-lensum);
    }
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 5248
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
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()
L = LI()
# L = np.array(_L)
#C = np.zeros(N + 1)

# def test(a,b,c):
#     if a<b+c and b<c+a and c<a+b:
#         return True
#     return False

# count = 0
# for pair in itertools.combinations(L, 3):
#     # print(pair)
#     if test(*pair):
#         count += 1
# print(count)

# for i in range(N):
#     for j in range(i+1,N):

from numba import njit
 
@njit
def f(A):
  count = 0
  for i in range(N):
    for j in range(i + 1, N):
      for k in range(j + 1, N):
        count += (A[k] < A[i] + A[j])
  return count
 
A = np.array(L)
A.sort()
print(f(A))        


Measured memory_bytes: 116264