akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
using ll = long long;

using namespace std;
int main(){
	string S;
	ll allsum= 0;
	cin >> S;
	int len = S.size();
	for (int tmp = 0; tmp < (1 << len - 1); tmp++) {	//演算子が入りうるすべての場所をbitで表現
		bitset<9>bit(tmp);	//取りうる最大のbit数　<>内は定数不可
		string cutstr = S;
		rep(i, len-1) {
			if (bit.test(i)) {	//iの位置のビットが立っていれば
				/*文字列を後ろから切り取り、削除*/
				allsum += stoll(cutstr.substr(len - 1 - i));
				cutstr.erase(len - 1 - i);
			}
		}
		allsum += stoll(cutstr);
	}
	cout << allsum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;
int N,M,L;
int map[110][110];
int edge[1100][1100];

struct Node
{
	int hou;
	int ti;
}node[1200];
int cx[1100];
int cy[1100];
bool vis[1100];
void  floyed()
{
	for(int k=0;k<N;k++)
		for(int i=0;i<N;i++)
			for(int j=0;j<N;j++)
				{
				if(i!=j&&j!=k&&i!=k)
					{
					map[i][j]=min(map[i][k]+map[k][j],map[i][j]);
					}
				}
}
int path(int u)
{
	int v;
	for(v=0;v<L;v++)
		{
		if(edge[u][v]&&!vis[v])
			{
			vis[v]=1;
			if(cy[v]==-1||path(cy[v]))
				{
				cx[u]=v;
				cy[v]=u;
				return 1;
				}	
			}
		}	
return 0;
}

int main()
{
	while(scanf("%d%d%d",&N,&M,&L)!=EOF)
		{
		if(N==0&&M==0&&L==0)
			break;
		for(int i=0;i<N;i++)
			for(int j=0;j<N;j++)
				{	
					if(i==j)
						map[i][j]=0;
					else
						map[i][j]=0x7fffff;
				}
		for(int i=0;i<M;i++)
			{
			int a,b,c;
			scanf("%d%d%d",&a,&b,&c);
			map[a][b]=c;
			map[b][a]=c;
			}
		floyed();
		for(int i=0;i<L;i++)
			{
			int a,b;
			scanf("%d%d",&a,&b);
			node[i].hou=a;
			node[i].ti=b;
			}
		memset(edge,0,sizeof(edge));
		for(int i=0;i<L;i++)
			{
			for(int j=0;j<L;j++)
				{
					if(i!=j&&node[i].ti-node[j].ti>=map[node[i].hou][node[j].hou])
						{
							edge[j][i]=1;
						}
				}
			}
		memset(cx,0xfffff,sizeof(cx));
		memset(cy,0xfffff,sizeof(cy));
		int ans=0;
		for(int i=0;i<L;i++)
			{
			if(cx[i]==-1)
				{
				memset(vis,0,sizeof(vis));
				ans+=path(i);
				}	
			}
		printf("%d\n",L-ans);
		}
    return 0;
}

Measured memory_bytes: 6004
# 753数の列挙
# DFS
def make_753number(n):
    s = str(n)
    if '7' in s and '5' in s and '3' in s:
        n753.add(n)
    if n <= 10**9:
        make_753number(10 * n + 7)
        make_753number(10 * n + 5)
        make_753number(10 * n + 3)


n753 = set()
make_753number(0)
N = int(input())
print(len([1 for n in n753 if n <= N]))


Measured memory_bytes: 49624
N=int(input())
G=[[] for i in range(N)]
a=[]
b=[]

for i in range(N-1):
    ai,bi=map(int,input().split())
    a.append(ai-1)
    b.append(bi-1)
    G[ai-1].append(bi-1)
    G[bi-1].append(ai-1)

k=[0]*N

from collections import deque

q=deque([0])
visited=[0]*N
ans={}
p=[-1]*N

kmx=0
while q:
    x=q.popleft()
    visited[x]=1
    cnt=1
    for i in G[x]:
        if visited[i]!=0:continue
        if p[x]==cnt:
            cnt+=1
        ans[(x,i)]=cnt
        ans[(i,x)]=cnt

        p[i] = cnt
        cnt += 1
        kmx=max(kmx,cnt-1)
        q.append(i)

print(kmx)
for i in range(N-1):
    print(ans[(a[i],b[i])])




Measured memory_bytes: 61508
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    N, X, T = map(int, input().split())
    print(ceil(N / X) * T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 65240
N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
total = 0
B = [0]*N
for n in range(N):
  count = 0
  for m in range(N):
    if A[m]<A[n]:
      count += 1
  B[n] = count
for n in range(N):
  for m in range(n,N):
    if A[m]<A[n]:
      total+=1
total *= K
K = K*(K-1)//2
for b in B:
  total += b*K
  total %= 1000000007
print(total)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N, i;
  string S;
  cin >> N;
  map<string, long long> NumR;
  
  for(i=0;i<N;i++){
    cin >> S;
    NumR[S]++;
  }
  
  cout << "AC x " << NumR["AC"] << endl;
  cout << "WA x " << NumR["WA"] << endl;
  cout << "TLE x " << NumR["TLE"] << endl;
  cout << "RE x " << NumR["RE"] << endl;
  return 0;
}

Measured memory_bytes: 3632
n = int(input())
h = list(map(int, input().split()))
count = 0
max_list = []
for i in range(len(h)-1):
    if h[i] >= h[i+1]:
        count += 1
        if i == len(h)-2:
            max_list.append(count)
    else:
        max_list.append(count)
        count = 0
if n == 1:
    print(0)
else:        
    print(max(max_list))

Measured memory_bytes: 15020
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxx = 2000001;
const int maxnum = 10010;
int A[maxx], B[maxx];
int C[maxnum];

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

    //初始化C数组
    for (int i = 0; i < maxnum; i++)
        C[i] = 0;

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i + 1]);
        //计数到C数组
        C[A[i + 1]]++;
    }

    // 累加和
    for (int i = 1; i < maxnum; i++)
        C[i] += C[i - 1];

    for (int j = 1; j <= n; j++) {
        // 根据C[A[j]]确定A[j]存贮的下标，保存到B数组
        B[C[A[j]]] = A[j];
        // 存储下标往前移动
        C[A[j]] --;
    }
    for (int i = 1; i <= n; i++)
        printf("%d%c", B[i], i == n ? '\n' : ' ');

    return 0;
}


Measured memory_bytes: 18864
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<(a[2]-a[1])+(a[1]-a[0])<<endl;
}


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

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

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

    cin >> k >> s;
    int n = s.size();

    if (n <= k) cout << s << '\n';
    else cout << s.substr(0, k) << "...\n";
}


Measured memory_bytes: 3620
function main()
  RR,GG,BB,N=map(x->parse(Int,x),split(readline()))
  num=[RR,GG,BB]
  R=maximum(num)
  B=minimum(num)
  G=RR+GG+BB-R-B
  ans=0
  if R==G && G==B && N%R==0
    temp=Int(N/R)
    ans=Int(floor((temp+1)*(temp+2)/2))
  elseif R==G || G==B
    for rr=N:-R:0
      if rr%B==0
        ans+=Int(rr/B)+1
      end
    end
  else
    for rr=N:-R:0,rg=rr:-G:0
      ans+=rg%B==0
    end
  end
  println(ans)
end
main()


Measured memory_bytes: 116052
import Data.Array.IO
import Data.List
import Data.IORef
import Data.Bits
import Control.Monad

main = do
  (n:m:_) <- getLine >>= return . (map read) . words :: IO [Int]
  arr <- newArray (2,n-1) 0 :: IO (IOArray Int Int)
  ch <- newIORef False :: IO (IORef Bool)
  
  let
    g = \(a:b:_) -> do
      when (a==1) $ do
        r <- readArray arr b
        writeArray arr b (r .|. 1) 
        when (r .&. 2 /= 0) (writeIORef ch True)
      when (b==n) $ do
        r <- readArray arr a
        writeArray arr a (r .|. 2)
        when (r .&. 1 /= 0) (writeIORef ch True)

  replicateM_ m (getLine >>= g . (map read) . words)

  putStrLn =<< return . func =<< readIORef ch

  where
    func False = "IMPOSSIBLE"
    func True = "POSSIBLE"

Measured memory_bytes: 3324
def rm_s(h):
	for hai in set(h):
		if (hai in h) and (hai+1 in h) and (hai+2 in h):
			if len(h) == 3: return 1
			h1 = h[:]
			for i in range(3): h1.remove(hai+i)
			return is_hora(h1)
	else: return 0
		
def rm_k(h):
	for hai in set(h):
		if h.count(hai) >= 3:
			if len(h) == 3: return 1
			h1 = h[:]
			for i in range(3): h1.remove(hai)
			return is_hora(h1)
	else: return 0
	
def is_hora(h):
	return rm_k(h) or rm_s(h)
	
while True:
	try:
		h = map(int, raw_input())
		ans = []
		for add in range(1,10):
			if h.count(add) <= 3:
				h1 = h[:]+[add]
				for d in set(h1):
					if 2 <= h1.count(d):
						h1 = h[:]+[add]
						h1.remove(d);h1.remove(d)
						if is_hora(h1):
							ans.append(add)
							break
		print " ".join(map(str, sorted(ans))) if len(ans) > 0 else 0
	except:
		break

Measured memory_bytes: 4280
N = int(input())
S = [i for i in input()]

ABC = [chr(ord('A') + i) for i in range(26)]
for i in range(len(S)):
  if ABC.index(S[i])+1 + N <= 26:
    S[i] = ABC[ABC.index(S[i]) + N]
  else:
    S[i] = ABC[ABC.index(S[i]) + N - 26]
# print(S)
S = ''.join(S)
print(S)

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

//main
int main(){
    
    //入力部
    int n,m; cin >> n >> m;
    vector<int> k(m);
    vector<vector<int>> s(10,vector<int>(10,-1));
    rep(i,m){
        cin >> k[i];
        rep(j,k[i]){
            cin >> s[i][j];
        }
    }
    vector<int> p(m); rep(i,m) cin >> p[i];

    //変数準備

    int bitmax = (1 << n); //bitの上限
    int judge; //偶奇が合うか記録
    int tmp; //各bitの各行について、onになっているスイッチの個数
    ll ans = 0; //答え


    //bit全探索
    for(int bit = 0; bit < bitmax; bit++){
        judge = 1; //judgeリセット

        for(int i = 0; i < m; i++){ //各行について
            tmp = 0; //onのスイッチのカウントリセット

            for(int j = 0; j < k[i]; j++){ //各sについて判定
                if(bit & (1 << (s[i][j]-1) ) ) tmp++;
            }

            if(tmp % 2 != p[i]){
                judge = 0; //tmpの偶奇がp[i]とずれていたらダメ
                break; //ダメなのでループ終了
            }

        }

        if(judge) ans++; //judge = 1の時に条件成立するbitとしてカウント
    }

    cout << ans << endl;
}

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

int x[100000];

int main(){
	int n, c, k;
	scanf("%d%d%d", &n, &c, &k);
	f(i, 0, n)scanf("%d", x + i);
	sort(x, x + n);
	int i = 0, an = 0;
	while (i < n){
		i = min(i + c, (int)(upper_bound(x, x + n, x[i] + k) - x));
		++an;
	}
	printf("%d\n", an);
}


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

int g[15][15];

int main() {
    int n;
    cin >> n;
    rep(i,n) {
        rep(j,n) {
            g[i][j] = -1;
        }
    }
    rep(i,n) {
        int a;
        cin >> a;
        int x,y;
        rep(j,a) {
            cin >> x >> y;
            g[i][x-1] = y;
        }
    }

    int ans = 0;
    rep(i,1<<n) {
        vector<int> d(n);
        int count = 0;
        rep(j,n) {
            if (i>>j&1) {
                d[j] = 1;
                count++;
            }
        }
        bool t = true;
        rep(j,n) {
            if (d[j]) {
                rep(k,n) {
                    if (g[j][k] == -1) {
                        continue;
                    }
                    if (g[j][k] != d[k]) {
                        t = false;
                    }
                }
            }
        }
        if (t) {
            ans = max(ans, count);
        }

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3524
A = list()

A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))

A.append(A1)
A.append(A2)
A.append(A3)

N = int(input())

b = list()
for i in range(N):
    b.append(int(input()))

for x in range(N):
    for y in range(3):
        for z in range(3):
            if b[x] == A[y][z]:
                A[y][z] = 101


for i in range(3):
    counter = 0
    counter3 = 0
    for j in range(3):
        if A[i][j] == 101:
            counter += 1
        if A[j][i] == 101:
            counter3 += 1
        if counter == 3 or counter3 == 3:
            break
    if counter == 3 or counter3 == 3:
        break
if counter == 3 or counter3 == 3:
    print('Yes')

else:
    counter1 = 0
    for i in range(3):
        if A[i][i] == 101:
            counter1 += 1
    if counter1 == 3:
        print('Yes')
    else:
        counter2 = 0
        for i in range(3):
            if A[i][2-i] == 101:
                counter2 += 1
        if counter2 == 3:
            print('Yes')
        else:
            print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
#define setzero(x) memset(x,0,sizeof(x))
  
using namespace std;
 
const int inf = 2e9+500;
const int N = 1e3+10;
const int bits = 20;
const ld pi = 3.14159265358979323846;
const ll mod = 1e9;
const ll p = 29;


int main(){

    FASTIO;
    PRECISION; 
    
    ld r;
    cin>>r;

    cout<<2.0*pi*r<<"\n";
    

}

Measured memory_bytes: 3792
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;

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

    std::vector<std::string> s(N);
    for (int i = 0; i < N; i++) {
        std::cin >> s[i];
    }

    int M;
    std::cin >> M;

    std::vector<std::string> t(M);
    for (int i = 0; i < M; i++) {
        std::cin >> t[i];
    }

    std::map<std::string, int> m;
    for (int i = 0; i < N; i++) {
        m[s[i]]++;
    }
    for (int i = 0; i < M; i++) {
        m[t[i]]--;
    }

    int max = -1000;
    for (std::map<std::string, int>::iterator it = m.begin(), end = m.end(); it != end; it++) {
        if (max < it->second) {
            max = it->second;
        }
    }

    if (max < 0) {
        max = 0;
    }
    std::cout << max << std::endl;
    return 0;
}

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

int n;

int replace19(int n) {
    int x = 0;
    while (n > 0) {
        int d = n % 10;
        if (d == 1)
            d = 9;
        else if (d == 9)
            d = 1;
        x = x * 10 + d;
        n /= 10;
    }

    while (x > 0) {
        n = n * 10 + x % 10;
        x /= 10;
    }

    return n;
}

int main() {
    ios::sync_with_stdio(0);

    cin >> n;
    cout << replace19(n) << "\n";

    return 0;
}

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

const int MOD = (int)1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    VS a(h);
    REP(i, h) cin >> a[i];
    
    VVL dp(h, VL(w, 0));
    dp[0][0] = 1;
    REP(i, h)REP(j, w) {
        if(i == 0 and j == 0) continue;
        int path_cnt = 0;
        if(i - 1 >= 0 and a[i - 1][j] == '.') 
            path_cnt = (path_cnt + dp[i - 1][j]) % MOD;
        if(j - 1 >= 0 and a[i][j - 1] == '.')
            path_cnt = (path_cnt + dp[i][j - 1]) % MOD;
        dp[i][j] = path_cnt;
    }

    cout << dp[h - 1][w - 1] << ln;
    return 0;
}


Measured memory_bytes: 9216
from bisect import bisect_right
n, m = map(int, input().split())
p = []
y = []
d = {i + 1: [] for i in range(n)}
for i in range(m):
    p_, y_ = map(int, input().split())
    p.append(p_)
    y.append(y_)
    d[p_].append(y_)
for i in d.keys():
    d[i] = sorted(d[i])
for i in range(m):
    print('{:06d}{:06d}'.format(p[i], bisect_right(d[p[i]], y[i])))


Measured memory_bytes: 33512
# coding: utf-8
# Your code here!

a,b,c = map(int,input().split())

S = list(range(a,b+1))
Y = list()
#print(S,c,Y)

for i in range(1,c+1):
    if c%i == 0:
        #print(i)
        Y.append(i)
        #print(Y)
A = set(S)&set(Y)
print(len(A))


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   int n;
   ll k;
   cin>>n>>k;
   int a[200000];
   rep(i, n) cin>>a[i], a[i]--;

   map<int, int> reached;
   int c=0;
   vector<int> li;
   rep(i, n+1){
      li.push_back(c);
      reached.insert(make_pair(c, i));
      c=a[c];
      if(reached.find(c)!=reached.end()) break;
   }
   int s=reached.at(c);
   int l=li.size()-s;
   int ansi=(k<=s)?k:(s+(k-s)%l);
   int ans=li[ansi];

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


Measured memory_bytes: 13888
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    vector<vector<int>> c(3,vector<int>(3,0));
    rep(i,3)rep(j,3) cin>>c[i][j];
    if(c[0][2]-c[0][1]==c[1][2]-c[1][1] &&
       c[1][2]-c[1][1]==c[2][2]-c[2][1] &&
       c[0][1]-c[0][0]==c[1][1]-c[1][0] &&
       c[0][1]-c[0][0]==c[2][1]-c[2][0])
       cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) (v.begin(),v.end())
#define ff first
#define ss second
const ll maxn=1e6+10;
const ll mod=1e9+7;
 
 
 
 
int main() {
  	fast;
  	ll n,w;
  	cin>>n>>w;
  	ll we[n],co[n];
  	for(ll i=0;i<n;i++){
  		cin>>we[i]>>co[i];
	  }
  		
	vector<ll> dp(maxn+3,INT_MAX);
	//dp[j] = min(dp[j] (j>=co[i]) ? we[i]+dp[j-co[i]] : INT_MAX) //dp[val] represents min weight we can get at value val.
	dp[0]=0;
	for(ll i=0;i<n;++i){
		for(ll j=maxn;j>=0;--j){
			dp[j]=min(dp[j],(j>=co[i]) ? dp[j-co[i]]+we[i] : INT_MAX);
		}
	}
	ll ans=0;

	for(ll i= 0; i<=maxn ;++i){
		
		if(dp[i]<=w)
			ans=i;
	}
  	cout<<ans;
  	
}

Measured memory_bytes: 8064
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
N = ir()
A = lr()
bit = [0 for _ in range(60)]
for a in A:
    for i in range(a.bit_length()):
        if (a >> i) & 1:
            bit[i] += 1

answer = 0
for i, x in enumerate(bit):
    answer += x * (N-x) * 2 ** i

print(answer%MOD)
# 22

Measured memory_bytes: 124568
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int sv[100005];

	for(int i=0;i<100005;i++)
		sv[i]=0;
	sv[0]=1;
	sv[1]=1;
	for(int i=2;i<sqrt(100005);i++)
	{
		if(sv[i]==0){
		for(int j=2*i;j<100005;j+=i)
			sv[j]=1;}
	}
	int like[100005];
	for(int i=0;i<100005;i++)
	{
		if(sv[i]==0 && sv[(i+1)/2]==0)
			like[i]=1;
		else
			like[i]=0;
	}
	for(int i=0;i<100005;i++)
		like[i]+= like[i-1];
	int q;
	cin>>q;
	while(q-->0)
	{
		int l,r;
		cin>>l>>r;
		cout<<like[r]-like[l-1]<<"\n";
	}
}

Measured memory_bytes: 4384
N = int(input())
A = tuple(map(int, input().split()))

state = [0] * (N + 1)
for i in range(N, 0, -1):
    if N < i + i:
        state[i] = A[i-1]
    else:
        state[i] = A[i-1]
        j = i + i
        while j <= N:
            state[i] ^= state[j]
            j += i
ans = [str(i) for i, x in enumerate(state) if x == 1]
print(len(ans))
if ans:
    print(" ".join(ans))

Measured memory_bytes: 22312
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        m: usize,
        h: [i64; n],
        ab: [(Usize1, Usize1); m],
    }
    let mut tree = vec![vec![]; n];
    for (a, b) in ab {
        tree[a].push(b);
        tree[b].push(a);
    }
    let mut res = 0;
    for i in 0..n {
        if tree[i].iter().map(|&v| h[v]).max().unwrap_or(0) < h[i] {
            res += 1;
        }
    }

    println!("{}", res);
}


Measured memory_bytes: 12188
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;

int main() {
	string before, after;
	cin >> before;
	for (long long i = 0; i < before.size(); i++) {
		if (i % 2 == 0) {
			after.push_back(before[i]);
		}
	}
	cout << after;
	return 0;
}

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

string west2ja(int y) {
  if (y <= 1911) {
    return 'M' + to_string(y - 1867);
  } else if (y <= 1925) {
    return 'T' + to_string(y - 1911);
  } else if (y <= 1988) {
    return 'S' + to_string(y - 1925);
  } else {
    return 'H' + to_string(y - 1988);
  }
}

int main() {
  int e, y;
  cin >> e >> y;
  string result;
  switch (e) {
  case 0:
    result = west2ja(y);
    break;
  case 1:
    result = to_string(y + 1867);
    break;
  case 2:
    result = to_string(y + 1911);
    break;
  case 3:
    result = to_string(y + 1925);
    break;
  case 4:
    result = to_string(y + 1988);
    break;
  }
  cout << result << endl;
}


Measured memory_bytes: 3284
#include <stdio.h>
#include <stdlib.h>

int main(){
	int N;
	int i,j;
	int k;
	int *is_prime;
	int *soinsu;
	long int ans = 1;

	scanf("%d", &N);

	is_prime = (int*)malloc(sizeof(int) * (N+1));
	soinsu = (int*)malloc(sizeof(int) * (N+1));

	is_prime[0] = is_prime[1] = 0;
	for(i=2; i < N+1; i++){
		is_prime[i] = 1;
	}
	for(i=0; i<=N; i++){
		soinsu[i] = 0;
	}

	// Find prime numbers
	for(i=2; i*i <= N; i++){
		for(j=2; i*j <= N; j++){
			is_prime[i*j] = 0;
		}
	}

	// i=1,2,3,4,...,Nの素因数を求めていく。
	for(i=2; i<=N; i++){
		k = i;
		for(j=2; j<=N; j++){
			if(is_prime[j] == 1){
				while(k % j == 0){
					k /= j;
					soinsu[j]++;
				}	
			}
		}
	}
	
	for(i=2; i <= N; i++){
		if(soinsu[i] != 0){
			ans *= soinsu[i] + 1;			
			ans %= (int)(1e9+7);
		}
	}	
	printf("%ld\n", ans);
	return 0;
}




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

int main() {
    int N, K;

    cin >> N >> K;

    int min = 10000000;

    // ４ビットの全組み合わせループ
    for (int tmp = 0; tmp < (1 << N); tmp++) {

        int D = 1;

        //ビット表現(0000)
        bitset<10> s(tmp);

        for (int i = 0; i < N; i++) {

            if (s.test(i)) {
                D = D * 2;
            }else{
                D = D + K;
            }
        }

        if (min > D){
            min = D;
        }
    }
    cout << min << endl;    

    return 0;

}





Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int j = -1;
  int cur = 0;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    while (j < n - 1 && cur + a[j + 1] == (cur ^ a[j + 1])) {
      cur += a[++j];
    }
    ans += j + 1 - i;
    cur -= a[i];
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1024
function Main(input) {
	var existA = input.indexOf("A");
	var existB = input.indexOf("B");

	if(existA >= 0 && existB >= 0) {
		console.log("Yes");
	} else {
		console.log("No");
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include<time.h>
#include<cmath>
#include<vector>
using namespace std;

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

	vector<string> input(h);
	
	for (int i = 0; i < h; i++) {
		cin >> input[i];
	}

	for(int i = 0; i < h; i++){
		cout << input[i]<<endl<<input[i]<<endl;
	}


	cout << endl;


}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<sstream>
using namespace std;

class Amidakuji{

public:
	int W;
	vector<int> array;//????´?1???????????????
	Amidakuji(int w);
	void Swap(int x,int y);
	void call();
};

//????????????????????????????????????
Amidakuji::Amidakuji(int w){

	for (int i = 0; i < w; i++){
		array.push_back(i+1);//[0,1,2,3,4]={1,2,3,4,5}
	}
	
	W = w;

}

void Amidakuji::Swap(int x,int y){

	//???????????£????????????array[]???????????????
	//int?????§???????????£????????§char???int?????????????????????-48;
	
	int q;
	q = array[x - 1];
	array[x-1] = array[y-1];
	array[y-1] = q;
	

}

void Amidakuji::call(){

	for (int i = 0; i<W; i++){
		cout << array[i] << endl;
	}

}

int stoi(string str){
	int ret;
	stringstream ss;
	ss << str;
	ss >> ret;
	return ret;
}

int main(){


	int w, n,loc,a,b,length;
	string text,str_a,str_b,str_v;
	

	while (cin >> w>>n){
		cin.ignore();
		//??????????????????????????§???????????????
		Amidakuji Amidakuji(w);
		for (int i = 0; i < n; i++){
			getline(cin, text);

			length=(int)text.length();
			//????????¶?????§??????10,2??????????????¨??????{1,0,,,2}??????????????¢????????£?????????????????§??????????????????????????????????????????

			//?????????????????????????????????????????????????????§?????????????????£?????????????????\????????????????????£???
			loc=text.find(",", 0);
			str_a = text[0];
			for (int j = 1; j < loc; j++){
				str_v = text[j];
				str_a = str_a + str_v;

			}
			str_b = text[loc + 1];
			for (int j = loc + 2; j < length; j++){
				str_v = text[j];
				str_b = str_b + str_v;
			}

			
			a = stoi(str_a);
			b = stoi(str_b);


			if (a != 0 && b != 0){
				//???????????????????????????swap???????????????
				Amidakuji.Swap(a, b);
				a = b = 0;
			}
		}
	
		//????????????
		Amidakuji.call();
	}

	return 0;
}

Measured memory_bytes: 1252
import itertools
S = input()
L = len(S)

ans = 0
for i,j in itertools.combinations(range(L+1),2):
  ss = S[i:j]
  ok = True
  for s in list(ss):
    if not(s == 'A' or s == 'C' or s == 'G' or s == 'T'):
      ok = False
      break
      
  if ok:
    ans = max(ans,j-i)
    
print(ans)
                                 



Measured memory_bytes: 3060
import math
import string


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

a, b = map(int, input().split())
l = [None]*5
cnt = 0
for i in range(1, 10):
    l[0] = str(i)

    for j in range(0, 10):
        l[1] = str(j)

        for k in range(0, 10):
            l[2] = str(k)
            l[3] = str(j)
            l[4] = str(i)
            s = ''.join(l)
            # print(int(s))
            if int(s) >= a and int(s) <= b:
                cnt += 1
print(cnt)


Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=100005;
int n;
int a[N];
set <int> e[N];
int del[N];
queue <int> Q;
void Get_color(){
	static char s[N];
	cin>>(s+1);
	For(i,1,n)
		a[i]=s[i]=='W';
}
int check(){
	For(i,1,n)
		if (a[i])
			return 0;
	return 1;
}
int milen=0;
int dfs(int x,int pre){
	int mi=a[x]?-2:0;
	for (auto y : e[x])
		if (y!=pre){
			int tmp=dfs(y,x);
			milen=min(milen,mi+tmp);
			mi=min(mi,tmp+(a[x]?-2:0));
		}
	milen=min(milen,mi);
	return mi;
}
int main(){
	n=read();
	For(i,1,n-1){
		int x=read(),y=read();
		e[x].insert(y),e[y].insert(x);
	}
	Get_color();
	if (check())
		return puts("0"),0;
	For(i,1,n)
		if (e[i].size()==1)
			Q.push(i);
	int ans=n;
	while (!Q.empty()){
		int x=Q.front();
		Q.pop();
		if (a[x])
			continue;
		del[x]=1;
		ans--;
		int y=*e[x].begin();
		e[x].erase(y),e[y].erase(x);
		if (e[y].size()==1)
			Q.push(y);
	}
	ans*=2;
	ans-=2;
	int rt=0;
	For(i,1,n)
		if (!del[i]){
			rt=i;
			break;
		}
	For(i,1,n)
		a[i]^=e[i].size()&1;
	For(i,1,n)
		ans+=a[i];
	dfs(rt,0);
	cout<<max(ans+milen,1)<<endl;
	return 0;
}

Measured memory_bytes: 21760
#include <iostream>
#include <algorithm>
#include <cmath>

#define REP(i, n) for(int i = 0; i < n; i++)
#define INF 2e9

using namespace std;
typedef long long ll;

ll dp[4096], dp_next[4096];
int nums[12];

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

	loop = pow(2, N);
	REP(i, pow(2, N)) dp[i] = dp_next[i] = INF;
	REP(i, N) nums[i] = pow(2, i);

	REP(i, M) {
		ll a;
		int b, c, n, t = 0;
		cin >> a >> b;
		REP(j, b) {
			cin >> c;
			t += nums[c - 1];
		}
		
		dp[t] = min(dp[t], a);
		REP(j, loop) {
			n = j | t;
			dp_next[n] = min(dp[n], min(dp_next[n], dp[j] + a));
		}

		REP(j, loop) dp[j] = dp_next[j];
	}

	if (dp[loop - 1] == INF) cout << -1 << endl;
	else cout << dp[loop - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a=0,b=0,o=0,ab=0;
	int now;
	char var[5];
	while(~scanf("%d,%s",&now,var)){
		if(var[1]=='B')ab++;
		else if(var[0]=='A')a++;
		else if(var[0]=='B')b++;
		else if(var[0]=='O')o++;
	}
	printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;
 
/* 
    TITLE:
*/
 
//=================================================
int N;
//=================================================
void input()
{
cin>>N;
}
 
//=================================================
void solve()
{
int ans = 0;
for (int i = 0; N ; ++i){
  int m = N % 10;
  if (m == 1){
    m = 9;
  }
  else if (m == 9){
    m = 1;
  }
  ans += pow(10,i) * m;
  N /= 10;
}
  cout<<ans<<endl;
}
//=================================================
signed main()
{
    input();
    solve();
    return 0;
}

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

using namespace std;

const int N = 1e5 + 6;
bool prime[N];

void sieve() {
    memset(prime , 1 , sizeof prime);
    prime[0] = prime[1] = 0;
    for (int i = 2 ;i * i < N ;i++)
        if (prime[i])
            for (int j = i * i ;j < N ;j += i)
                prime[j] = 0;
}

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

    for (int i = n ; ;i++) {
        if (prime[i]) {
            cout << i;
            return 0;
        }
    }
}

Measured memory_bytes: 384
<?php
  
$n = trim(fgets(STDIN));

$s = [];
$d = [];
for($i=0; $i<$n; $i++){
  
  $s[$i] = str_split(trim(fgets(STDIN)));
  
  $sv = array_count_values($s[$i]);
  $dv = array_count_values($d);
  
  $dd = [];
  if($i==0) {
    $d = $s[$i];
  } else {
    $d = array_values(array_unique(array_intersect($s[$i],$d)));
    
    for($j=0; $j<count($d); $j++){
      $dj = $d[$j];
      $m = min($sv[$dj], $dv[$dj]);
      for($k=0; $k<$m; $k++){
        array_push($dd,$dj);
      }
    }
    
    $d = $dd;
  }
}

sort($d);
for($i=0; $i<count($d); $i++){
  echo $d[$i];
}

?>

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

int main() {
  int N;
  std::cin >> N;
  std::vector<int> v(N - 1);
  for (int i = 0; i < N - 1; i++) {
    std::cin >> v[i];
  }
  int ans = v[0] + v[N - 2];
  for (int i = 1; i < N - 1; i++) ans += std::min(v[i - 1], v[i]);
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int sum = 3;
		if(a == b) sum-=1;
		if(a == c) sum-=1;
		if(b == c) sum-=1;
		if(sum == 0)sum = 1;
		System.out.println(sum);
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
    using namespace std;
  #define int long long int
    #define endl "\n"
    #define MOD 1000000007
    #define mod 1000000007
    #define M 1000000007
    
    #define pb push_back
    #define take(a,b,c) for(int b=0;b<c;b++) cin>>a[b]
  //  #define mp make_pair
  #define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
  #define mx 400005
  #define fiint(a,b) memset(a,b,sizeof(a))  
  #define bitcount __builtin_popcount
  #define fori(i,a,b) for(int i=a;i<b;i++)
  #define ford(i,a,b) for(int i=a;i>=b;i--)
  #define debug(x) cout<<x<<endl;
  #define cases(t) int t; cin>>t; while(t--)
  #define inf1 INT_MAX
  #define all(a) a.begin(),a.end()
  #define vec vector<int>
  #define pii pair<int,int>
  #define plii pair<int,int>
  #define pint pair<int,int>
  #define ff first
  #define ss second
  #define lb lower_bound
  #define ub upper_bound
  #define bs binary_search
  #define sz(x) (int)x.size()
#define PI                    3.14159265359

bool prime[10000001];

void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}

signed  main() 
{ 
	int n;cin>>n;
	vec v[n];
	fori(i,0,n)
	{
		int a,b,c;cin>>a>>b>>c;
		v[i].pb(a);v[i].pb(b);v[i].pb(c);
	}
	int  dp[n][3];
	fori(i,0,n)
		fori(j,0,3)
			dp[i][j]=0;
	dp[0][0]=v[0][0];
	dp[0][1]=v[0][1];
	dp[0][2]=v[0][2];
	fori(i,1,n)
		fori(j,0,3)
				fori(k,0,3)
					if(j!=k)
						dp[i][j]=max(dp[i][j],dp[i-1][k] + v[i][j]);
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;				
			

	
		
	
}




 


Measured memory_bytes: 9600
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

from collections import defaultdict
dic = defaultdict(int)
for a in As:
    dic[a] += 1
    dic[a-1] += 1
    dic[a+1] += 1

print(max(dic.values()))

Measured memory_bytes: 93420
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	int n,m,a,b,c,l;
	cin >> n >> m;
	vector<pair<int,int> > v[n];
	int cost[m];
	while(cin >> a >> b >> c,a+b+c){
		v[a-1].push_back(make_pair(b-1,c));
	}
	cin >> l;
	while(l--){
		for(int i=0;i<m;i++){
			cin >> cost[i];
		}
		for(int i=0;i<n;i++){
			int sum=0;
			for(int j=0;j<v[i].size();j++){
				sum+=cost[v[i][j].first]*v[i][j].second;
			}
			cout << (i?" ":"") << sum;
		}
		cout << endl;
	}
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

int main()
{   /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); /**/
    int n, k;
    cin >> n >> k;
    int a = 1;
    for (int i = 0; i < n; i++)
    {
        if (2 * a <= a + k)
            a *= 2;
        else
            a += k;
    }
    cout << a;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vvl = vector<vector<ll>>;
using vl  = vector<ll>;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define DBG(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
const ll MOD = 1000000007;
const double PI = acos(-1);  
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp

ll a,b,x;
ll ans;
//string s;
ll f(ll n,ll x){
	if(n>=0){
		return (n/x+1);
	}
	return 0;
}

signed main(){
	acc_io;
	ans=0;
	cin>>a>>b>>x;
	ans=f(b,x)-f(a-1,x);
	cout<<ans<<endl;
	return 0;
}


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

#define llong long long 
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define rand __rand
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());  // or mt19937_64
template<class T = int> T rand(T range = numeric_limits<T>::max()) { return (T)(rng() % range); }

#define CONCAT_(x, y) x##y/*{{{*/
#define CONCAT(x, y) CONCAT_(x, y)
#ifdef LOCAL_DEBUG   
int __db_level = 0;
bool __db_same_line = false;
#define clog cerr << string(!__db_same_line ? __db_level * 2 : 0, ' ')
struct debug_block {
    function<void()> fn;
    void print_name() { __db_same_line = true; fn(); clog << endl; __db_same_line = false;  }
    debug_block(function<void()> fn_): fn(fn_) { clog << "{ "; print_name(); ++__db_level; }
    ~debug_block() { --__db_level; clog << "} "; print_name(); }
};
#define DB(args...) debug_block CONCAT(dbbl, __LINE__)([=]{ clog << args; })
#define deb(...)  if (1) { (clog << "[" #__VA_ARGS__ "] = [" << __VA_ARGS__) << "]"; if (!__db_same_line) clog << endl; }
#else
#define clog if (0) cerr
#define DB(...)
#define deb(...)
#endif
template<class T>
ostream& operator,(ostream& out, const T& thing) { return out << ", " << thing; }
template<class U, class V>
ostream& operator<<(ostream& out, const pair<U, V>& p) { return (out << "(" << p.first, p.second) << ")"; }
template<class A, class B>
ostream& operator<<(ostream& out, const tuple<A, B>& t) { return (out << "(" << get<0>(t), get<1>(t)) << ")"; }
template<class A, class B, class C>
ostream& operator<<(ostream& out, const tuple<A, B, C>& t) { return (out << "(" << get<0>(t), get<1>(t), get<2>(t)) << ")"; }
template<class T> ostream& operator<<(ostream& out, const vector<T>& container) { 
    out << "{";
    if (len(container)) out << container[0];
    rep1(i, len(container) - 1) out, container[i];
    return out << "}";
}
template<class x> vector<typename x::value_type> $v(const x& a) { return vector<typename x::value_type>(a.begin(), a.end()); }
#define ptrtype(x) typename iterator_traits<x>::value_type
template<class u> vector<ptrtype(u)> $v(u a, u b) { return vector<ptrtype(u)>(a, b); }/*}}}*/
// ACTUAL SOLUTION BELOW ////////////////////////////////////////////////////////////

int cal_kyu(int x) {
    if (x < 600) return 8;
    if (x < 800) return 7;
    if (x < 1000) return 6;
    if (x < 1200) return 5;
    if (x < 1400) return 4;
    if (x < 1600) return 3;
    if (x < 1800) return 2;
    return 1;
}

int main(void) {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int x; cin >> x;
    cout << cal_kyu(x);
    

    return 0;
}

// Remember:
// - Multitest? REFRESHING the data!!!
// - Constrains for each set of data may differs. Should NOT USE the same max constant (maxn)
//   for all of them.
// vim: foldmethod=marker


Measured memory_bytes: 3696
import collections
def main():
    n = int(input())
    v = list(map(int,input().split()))

    if len(set(v)) == 1:
        print(n//2)
    elif len(set(v)) == 2:
        cnt1 = 0
        cnt2 = 0
        tmp1 = list(set(v))
        tmp2 = [tmp1[1], tmp1[0]]
        # even = v[::2]
        # odd = v[1::2]
        #
        for i, a in enumerate(v):
            if i % 2 == 0:
                if a == tmp1[0]:
                    cnt1 += 1
                if a == tmp2[0]:
                    cnt2 += 1
            else :
                if a == tmp1[1]:
                    cnt1 += 1
                if a == tmp2[1]:
                    cnt2 += 1
        print(n-max(cnt1,cnt2))
    else:
        even = v[::2]
        odd = v[1::2]
        count_e = collections.Counter(even)
        count_o = collections.Counter(odd)
        ce = count_e.most_common()
        co = count_o.most_common()
        if ce[0][0] != co[0][0]:
            print(n-ce[0][1] - co[0][1])
        else:
            if len(ce) == 1:
                print(n-co[1][1])
            elif len(co) == 1:
                print(n-ce[1][1])
            else:
                print(min(n-ce[0][1]-co[1][1], n-ce[1][1]-co[0][1]))




if __name__ == '__main__':
    main()


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

int main() {
  int n, k; cin >> n >> k;
  
  double prob = 0.0;
  
  for(int i = 1; i <= n; i++){
    int point = i;
    double p = 1.0;
    
    while(point < k){
      point *= 2;
      p *= 0.5;
    }
    prob += p;
    
  }
  
  prob /= n;
  
  cout << setprecision(20) << prob << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <complex>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cassert>
using namespace std;

#define EPS 1e-8
typedef complex<double> P;

bool isequal(const P& a, const P& b)
{
	return a.real()+EPS > b.real() && a.real() < b.real()+EPS &&
		   a.imag()+EPS > b.imag() && a.imag() < b.imag()+EPS;
}

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS; // non-parallel
}

bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}

P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}

int main()
{
	int x1,y1,x2,y2;
	while(scanf("%d%d%d%d", &x1,&y1,&x2,&y2), (x1||y1||x2||y2))
	{
		vector<L> Lines;
		vector<P> xp;
		Lines.push_back(L(P(x1,y1),P(x2,y2)));
		for(int i=0; i<2; i++)
		{
			scanf("%d%d%d%d", &x1,&y1,&x2,&y2);
			Lines.push_back(L(P(x1,y1),P(x2,y2)));
		}
		
		bool g=true;
		for(int i=0; i<3; i++)
		for(int j=i+1; j<3; j++)
		{
			if(!intersectLL(Lines[i], Lines[j])) g=false;
			if(!intersectSS(Lines[i], Lines[j])) g=false;
			
			if(g)
			{
				xp.push_back(crosspoint(Lines[i], Lines[j]));
			}
		}
		
		for(int i=0; i<xp.size(); i++)
		for(int j=i+1; j<xp.size(); j++)
		{
			if(isequal(xp[i], xp[j])) g=false;
		}
		
		if(!g)
		{
			puts("kyo");
			continue;
		}
		
		double area=0.5*abs(((xp[1].real()-xp[0].real())*(xp[2].imag()-xp[0].imag())-(xp[2].real()-xp[0].real())*(xp[1].imag()-xp[0].imag())));
		if(area < 100000) puts("syo-kichi");
		else if(area < 1000000) puts("kichi");
		else if(area < 1900000) puts("chu-kichi");
		else	puts("dai-kichi");
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define N 5010
#define mod 1000000007
using namespace std;
ll jc[N],inv[N];
ll K(ll x,int y=mod-2){
	ll t=1; for (;y;y>>=1,x=x*x%mod) if (y&1) t=t*x%mod; return t;
}
ll C(int x,int y){
	return jc[x]* inv[y]%mod *inv[x-y]%mod;
}
void U(ll &x,int y){
	if ((x+=y)>=mod) x-=mod;
}

int a[N],tot,cnt; ll f[N],g[N];
ll doit(int cc=cnt){
	memset(f,0,sizeof f); f[0]=1; tot=0;
	for (int i=1;i<=cc;++i){
		memset(g,0,sizeof g);
		for (int j=0;j<=a[i];++j)
			for (int k=tot;~k;--k)
				U(g[k+j],f[k]*C(a[i],j)%mod*C(a[i],j)%mod*jc[j]%mod);
		tot+=a[i];
		memcpy(f,g,sizeof g);
	}
	for (int i=tot;~i;--i) f[i]=f[i]*jc[tot-i]%mod;
	for (int i=tot;~i;--i){
		for (int j=i-1;~j;--j)
			U(f[j],mod-f[i]*C(i,j)%mod);
	}
	return f[0];
}

int n,x,y,sz[N]; vector<int>G[N];
void dfs(int x,int fff){
	int mx=0; sz[x]=1;
	for (auto y:G[x]) if (y-fff){
		dfs(y,x); sz[x]+=sz[y];
		mx=max(mx,sz[y]);
	}
	mx=max(mx,n-sz[x]);
	if (mx*2==n) exit(0*printf("%lld",jc[mx]*jc[mx]%mod));
	if (mx*2>n) return;
	for (auto y:G[x]) if (y-fff) a[++cnt]=sz[y];
	if (x-1) a[++cnt]=n-sz[x]; a[++cnt]=1;
	exit(0*printf("%lld",(doit()+doit(cnt-1))%mod));
}

int main(){
	jc[0]=1; for (int i=1;i<N;++i) jc[i]=jc[i-1]*i%mod;
	inv[N-1]=K(jc[N-1]); for (int i=N;i--;) inv[i-1]=inv[i]*i%mod;
	cin>>n;
	for (int i=n;--i;) cin>>x>>y, G[x].push_back(y), G[y].push_back(x);
	dfs(1,0);
}

Measured memory_bytes: 1024
n = int(input())

li_h = list(map(int, input().split()))

count = 0

for h in sorted(range(1, 101), reverse=True):
    now = 0
    for h_2 in li_h:
        if h_2 >= h and now < h:
            count += 1
        now = h_2

print(count)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue

#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>


#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORd(i,a,b) for(int i=(a);i>=(b);i--)
#define FORl(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORN(i,n) for(int i=(0);i<(n);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
//..............................!!!!!!Get ready to fight!!!!!!............................



int main()
{
    fast
    string s,t;
  	cin>>s>>t;
      string st;
    for(int i=0;i<t.length()-1;i++)
    {
      st.push_back(t[i]);
    }
    if(st==s)
      cout<<"Yes\n";
    else
      cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3644
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int x;
    cin>>x;
    if(x >= 30)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 3640