akhauriyash/Code-Regression huggingface dataset:
class UnionFind:

    def __init__(self, size):
        self.table = [i for i in range(size)]

    def find(self, x):
        return self.table[x]

    def union(self, x, y):
        x1 = self.find(x)
        y1 = self.find(y)
        if x1 == y1: return False
        # 併合
        for i in range(len(self.table)):
            if self.table[i] == y1:
                self.table[i] = x1
        return True


def solve():
    [N, M] = [int(x) for x in input().split()]

    edges = []
    g = [[False] * N for _ in range(N)]
    for i in range(M):
        a, b = [int(x) for x in input().split()]
        edges.append((a-1, b-1))
        g[a-1][b-1] = g[b-1][a-1] = True

    ans = 0
    for i in range(len(edges)):
        uf = UnionFind(N)

        for j in range(len(edges)):
            e = edges[j]
            if i == j:
                # print("Remove {} -> {}".format(*e))
                continue
            uf.union(*e)

        n = len(set(uf.table))
        ans += n != 1

        # print(uf.table)
        # print(len(set(uf.table)))
        # print(any(uf.table))
    return ans


def main():
    print(solve())


if __name__ == '__main__':
    main()




Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;
#define MOD 1000000007

// 繰り返し二乗法
long long bipow(long long n, int m) {
    if (m == 0) return 1;
    if (m % 2 == 0) {
        n = (n * n) % MOD;
        return bipow(n, m / 2) % MOD;
    } else
        return (n * bipow(n, m - 1)) % MOD;
}

// fact_num[i] = i! % MOD
// fact_denpow[i] = (i**(MOD-2)) % MOD
// fact_den[i] = fact_denpow[i]! % MOD
// nCm = fact_num[n] * fact_den[m] * fact_den[n-m]
// で計算できる（MODを適切に取る）
// O(NlogN)
void set_table(int N, vector<long long> &fact_num, vector<long long> &fact_den){
    fact_num.resize(N, 0);
    fact_den.resize(N, 0);
    vector<long long> fact_denpow(N, 0);

    fact_num[0] = 1;
    for(int i=1; i<N; i++) fact_num[i] = (fact_num[i-1] * i) % MOD;

    for(int i=0; i<N; i++) fact_denpow[i] = bipow(i, MOD-2);
    fact_den[0] = 1;
    for(int i=1; i<N; i++) fact_den[i] = (fact_den[i-1] * fact_denpow[i]) % MOD;
}

// mCn
long long comb(const vector<long long> &fact_num, const vector<long long> &fact_den, int m, int n){
    if(m < n) return 0;
    return ((fact_num[m] * fact_den[n]) % MOD * fact_den[m-n]) % MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> cnt(n+1), aa(n+1);
    for(int i=0; i<n+1; i++){
        cin >> aa[i];
        cnt[aa[i]]++;
    }

    int num;
    for(int i=1; i<=n; i++){
        if(cnt[i] == 2){
            num = i;
            break;
        }
    }

    int a = -1, b = -1;
    for(int i=0; i<n+1; i++){
        if(a == -1 && aa[i] == num) a = i;
        if(a != -1 && aa[i] == num) b = n-i;
    }

    vector<long long> fact_num, fact_den;
    set_table(n+10, fact_num, fact_den);

    for(int k=1; k<=n+1; k++){
        long long tmp1 = comb(fact_num, fact_den, n+1, k);
        long long tmp2 = comb(fact_num, fact_den, a+b, k-1);
        cout << (tmp1 - tmp2 + MOD) % MOD << endl;
    }

    return 0;
}

Measured memory_bytes: 3568
#include <cstdio>

int b[13];

int main()
{
	int n;
	int l=0,r=0,i=0;
	int flag=true;
	scanf("%d",&n);
	++n;
	while (--n)
	{
		for (i=0;i<10;++i)
		{		
			scanf("%d",b+i);
			if (b[i]<l&&b[i]<r)
			{
				printf("NO\n");
				flag=false;
				break;
			}
			else if (b[i]>l&&b[i]<r)
			{
				l=b[i];
			}
			else if (b[i]<l&&b[i]>r)
			{
				r=b[i];
			}
			else if (b[i]>l&&b[i]>r)
			{
				if(b[i]-r>b[i]-l)
				{
					l=b[i];
				}
				else
				{
					r=b[i];
				}
			}
			else
			{
				printf("NO\n");
				flag=false;
				break;
			}
// 			printf("%d~ l,r=%d,%d\n",i,l,r);
		}
		if (flag)
		{
			printf("YES\n");
		}
		else
		{
			++i;
			while (i<10)//跳&#35835;！！
			{
				scanf("%d",b+i);
				++i;
			}
		}
		flag=true;
		l=r=0;
	}
	return 0;
	

}

Measured memory_bytes: 1008
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
 
/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/
const int N=1e5+5;
vector<ll> v[N];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//	cin>>t;
	while(t--){
		ll n,m;
		cin>>n>>m;
		ll a[n],b[n];
		ll i,j;
		ll mn=1e10,mx=-1e10;
		rep(i,0,n){
			cin>>a[i]>>b[i];
			v[a[i]].pb(b[i]);
			mn=min(mn,a[i]);
			mx=max(mx,a[i]);
		}
		ll dp[m+1]={};
		dp[0]=0;
		ll vis[mx+1]={};
		priority_queue<ll,vector<ll>> pq;
		rep(i,mn,m+1){
			for(auto j:v[i]){
				pq.push(j);
			}
			if(!pq.empty()){
			//	cout<<i<<" "<<pq.top()<<'\n';
			dp[i]=dp[i-1]+pq.top();
			pq.pop();
				
			}
			else
			dp[i]=dp[i-1];
		}
		cout<<dp[m]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 8832
#define _USE_MATH_DEFINES

#include <iostream>
#include <stdio.h>
#include <math.h>

struct Position { double x, y;  };

void Koch(int n, Position left, Position right) {
	if (n == 0) return;
	Position firstThird, thirdThird, secondThird;
	double th = M_PI * 60.0 / 180.0;

	firstThird.x = (2.0 * left.x + right.x) / 3.0;
	firstThird.y = (2.0 * left.y + right.y) / 3.0;
	thirdThird.x = (left.x + 2.0 * right.x) / 3.0;
	thirdThird.y = (left.y + 2.0 * right.y) / 3.0;

	secondThird.x = (thirdThird.x - firstThird.x) * cos(th) - (thirdThird.y - firstThird.y) * sin(th) + firstThird.x;
	secondThird.y = (thirdThird.x - firstThird.x) * sin(th) + (thirdThird.y - firstThird.y) * cos(th) + firstThird.y;

	Koch(n - 1, left, firstThird);
	printf("%.8f %.8f\n", firstThird.x, firstThird.y);

	Koch(n - 1, firstThird, secondThird);
	printf("%.8f %.8f\n", secondThird.x, secondThird.y);

	Koch(n - 1, secondThird, thirdThird);	
	printf("%.8f %.8f\n", thirdThird.x, thirdThird.y);

	Koch(n - 1, thirdThird, right);
}
int main() {
	Position left, right;
	int n;

	scanf("%d", &n);

	left.x = 0;
	left.y = 0;
	right.x = 100;
	right.y = 0;

	printf("%.8f %.8f\n", left.x, left.y);
	Koch(n, left, right);
	printf("%.8f %.8f\n", right.x, right.y);

	return 0;
}


Measured memory_bytes: 3232
/**
 *
 * AtCoder Beginner Contest 106 - Problema D: AtCoder Express 2 (https://beta.atcoder.jp/contests/abc106/tasks/abc106_d)
 *
 * Find the garden area excluding the roads.
 *
 * Math solution: the rectangle area is AB. One road has area A, the other one has area B. The
 * roads intersection has area 1.
 */
#include <iostream>
#include <cstring>
#include <queue>
#include <algorithm>

using namespace std;
using ii = pair<int, int>;
using query = pair<ii, int>;

#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))
#define LOGM(msg) (cerr << (msg))
#define LOGV(vec, sep) { cerr << #vec << " ="; for (const auto& v : vec) cerr << " " << v; cerr << (sep); }
#define LOGA(arr, N, sep) { cerr << #arr << " ="; for (int i = 0; i < N; ++i) cerr << " " << (arr)[i]; cerr << (sep); }
#define LOGA2(arr, N, M, sep) { cerr << #arr << " =\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cerr << (arr)[i][j] << " "; cerr << endl; } cerr << (sep); }

const int MAX { 200010 };

typedef long long ll;

#define FENWICK_TREE_MAX 1000005

ll tree[FENWICK_TREE_MAX];

inline ll least_significative_bit(ll n) { return n & (-n); }

class FenwickTree
{
public:
    FenwickTree(ll N)
        : m_N(N)
    {
        memset(tree, 0, (N + 1) * sizeof(ll));
    }

    ll RSQ(ll a, ll b)
    {
        return a == 1 ? RSQ(b) : RSQ(b) - RSQ(a - 1);
    }

    void update(ll k, ll v)
    {
        while (k <= m_N)
        {
            tree[k] += v;
            k += least_significative_bit(k);
        }
    }

private:
    ll RSQ(ll b)
    {
        ll sum = 0;

        while (b)
        {
            sum += tree[b];
            b -= least_significative_bit(b);
        }

        return sum;
    }

private:
    ll m_N;
};

#define F first
#define S second

int ans[MAX];
ii ts[MAX];
query qs[MAX];

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

ostream& operator<<(ostream& os, const query& p)
{
    os << "(" << p.first.first << ", " << p.first.second << ") [" << p.second << "]";
    return os;
}
void solve(int N, int M, int Q)
{
    sort(ts, ts + M, greater<ii>());
    sort(qs, qs + Q, greater<query>());

//LOGA(ts, M, '\n');
//LOGA(qs, Q, '\n');

    int t = 0;
    FenwickTree ft(N + 1);
    
    for (int q = 0; q < Q; ++q)
    {
        auto L = qs[q].F.F;
        auto R = qs[q].F.S;
        auto i = qs[q].S;

        while (t < M and ts[t].F >= L)
        {
            ft.update(ts[t].S, 1);
            ++t;
        } 

        ans[i] = ft.RSQ(1, R);
    }

    for (int i = 0; i < Q; ++i)
        cout << ans[i] << endl;
}

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

    int N, M, Q;
    cin >> N >> M >> Q;

    for (int i = 0; i < M; ++i)
        cin >> ts[i].F >> ts[i].S;

    for (int i = 0; i < Q; ++i)
    {
        cin >> qs[i].F.F >> qs[i].F.S; 
        qs[i].S = i;
    }

    solve(N, M, Q);

    return 0;
}


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

int main(){
  string str;
  cin >> str;
  
  vector<int> counts(4);
  
  for(int i = 1; i< 4;i++){
    bool ret = true;
    for(int j =  0 ; j <i; j++){
      if(str.at(j) == str.at(i)){
        counts.at(j) ++;
        break;
      }
    }
  }
  
  int kindcount = 0; 
  for(int i = 0; i < 4; i++){
  	if(counts.at(i) == 1) kindcount ++;
  }
  
  if(kindcount == 2){cout << "Yes" <<endl; }
  else {cout << "No" <<endl; }
  
    
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX

using namespace std;

using ll = long long;

#define mp make_pair

const int p = 1000000007;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/

/*const int N = 1000000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/


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

    int n;
    cin>>n;
    vector<vector<int>> a(n, vector<int>(26));
    string s;
    for (int i = 0; i<n; i++)
    {
        cin>>s;
        for (auto it: s) a[i][it-'a']++;
    }
    for (int i = 0; i<26; i++)
    {
        int res = a[0][i];
        for (int j = 1; j<n; j++) res = min(res, a[j][i]);
        for (int j = 0; j<res; j++) cout<<char('a'+i);
    }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=100005;
const int inf=10000*10000*4;
int solve(vector< pair<int,int> >&a,vector< pair<int,int> >&b,int k){
  int res=inf;
  for(int i=0;i<a.size();i++){
    if(a[i].first>=k)res=min(res,a[i].second);
    int p=lower_bound(b.begin(),b.end(),make_pair(k-a[i].first,0))-b.begin();
    if(p<b.size())res=min(res,a[i].second+b[p].second+min(a[i].second,b[p].second));
  }
  return res;
}
int a[maxn];
vector< pair<int,int> >b,c;
int main(){
  //freopen("aa.in","r",stdin);
  int n,kk;
  scanf("%d%d",&n,&kk);
  for(int i=1;i<=n;i++){
    scanf("%d",a+i);
  }
  b.push_back(make_pair(0,0));
  c.push_back(make_pair(0,0));
  for(int i=1;i<=n+1;i++)if(i==n+1||a[i]>=0){
    for(int j=i;j<=n;j++){
      b.push_back(make_pair(j-i+1,a[j]));
    }
    for(int j=i-1;j;j--){
      c.push_back(make_pair(i-j,-a[j]));
    }
    break;
  }
  int ans=min(solve(b,c,kk),solve(c,b,kk));
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 2040
// https://atcoder.jp/contests/abc047/tasks/abc047_b
// B - すぬけ君の塗り絵 2 イージー

#include <stdio.h>

// 標準入力から改行かスペースまで読み取り、数字として返す
int get_num() {
    // 10文字+区切り文字までしか受け付けられない
    char s[11];
    int i, n;
    // scanf()の直後は改行が入力に残っているので、
    // 最初の改行は読み飛ばす
    do {
        s[0] = getchar();
    } while (s[0] == '\0' || s[0] == '\n');
    for (i = 1; i < sizeof(s); i++) {
        s[i] = getchar();
        if (s[i] == ' ' || s[i] == '\n') {
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}

int main(int argc, const char * argv[]) {
    int w, h, n, i, j, k;
    int x, y, a, count;
    int c[100][100] = {0};
    w = get_num();
    h = get_num();
    n = get_num();

    for (i = 0; i < n; i++) {
        x = get_num();
        y = get_num();
        a = get_num();

        switch (a) {
            case 1:
                for (j = 0; j < h; j++) {
                    for (k = 0; k < x; k++) {
                        c[k][j] = 1;
                    }
                }
                break;
            case 2:
                for (j = 0; j < h; j++) {
                    for (k = x; k < w; k++) {
                        c[k][j] = 1;
                    }
                }
                break;
            case 3:
                for (j = 0; j < y; j++) {
                    for (k = 0; k < w; k++) {
                        c[k][j] = 1;
                    }
                }
                break;
            case 4:
                for (j = y; j < h; j++) {
                    for (k = 0; k < w; k++) {
                        c[k][j] = 1;
                    }
                }

            default:
                break;
        }
    }
    
    count = 0;
    
    for (j = 0; j < h; j++) {
        for (k = 0; k < w; k++) {
            if (c[k][j] == 0) {
                count ++;
            }
        }
    }
    
    printf("%d\n", count);
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h> 

int main(void) 
{ 
   int x, y, r, tmp; 
   scanf("%d %d",&x,&y); 

   if(x<y){
   tmp = x; 
   x = y ;
   y = tmp;
   }
    r=x%y;
   
   while(r!=0){ 
   x = y; 
   y = r; 
   r = x % y; 
   }

   printf("%d\n",y);
   
   return 0 ;
}

Measured memory_bytes: 2728
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break

    cnt = 0
    for i in range(1, n-1):
        for j in range(i+1, n):
            if j+1 <= x-i-j <= n:
                cnt += 1

    print(cnt)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep2(i,a,n) for (int i = a; i < n; i++)
using namespace std;
int N, M;
int K[11];
int S[11][11];
int P[11];
int main() {
    cin >> N >> M;
    rep(i, M) {
        cin >> K[i];
        rep(k, K[i]) {
            int nu;
            cin >> nu;
            S[i][k] = nu -1;
        }
        sort(S[i], S[i] + K[i]);
    }
    int ans = 0;
    rep(i, M) {
        cin >> P[i];
    }
    for(int bit = 0; bit < (1<<N); bit++) {
        int mana[11];
        memset(mana, 0, sizeof(mana));


        for(int i = 0; i < N; i++) {
            if(bit & (1<<i)) {
                rep(m, M) {
                    if(binary_search(S[m], S[m] + K[m], i)) {
                        mana[m] += 1;
                    }
                }
            }

        }
        bool flag = true;
        rep(i, M) {
            if(mana[i] % 2 != P[i]) flag = false;
        }
        if(flag) ans++;
    }
    cout << ans << endl;
    return 0;
}


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


int main(){
	double a;
	while(cin >> a){
		double i = 1;
		while(1){
			double h =((a*a)/19.6);
			double y = (5*i-5);
			if(y >= h)break;
			i++;
		}
		cout << i<<endl;

	}
		return 0;

}

Measured memory_bytes: 3176
H, W, M = map(int, input().split())
Hs = [0] * H
Ws = [0] * W
boms = set()

for _ in range(M):
  h, w = map(lambda x: int(x) - 1, input().split())
  boms.add((h, w))
  Hs[h] += 1
  Ws[w] += 1
  
Hmax = max(Hs)
Wmax = max(Ws)
HMaxIndexs = set(i for i, h in enumerate(Hs) if h == Hmax)
WMaxIndexs = set(i for i, w in enumerate(Ws) if w == Wmax)

crossCount = len(HMaxIndexs) * len(WMaxIndexs)
crossBomCount = len(list(filter(lambda x: x[0] in HMaxIndexs and x[1] in WMaxIndexs, boms)))
print(Hmax + Wmax - 1) if crossCount == crossBomCount else print(Hmax + Wmax)



Measured memory_bytes: 173480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  string s;
  cin >> s;
  for(ll i=0;i<s.size();i++) {
    if(s[i]=='?') s[i]='D';
  }
  cout << s << endl;
}

Measured memory_bytes: 3684
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

ll N;
vector<string> S;

bool check(){
    rep(i,N)rep(j,N){
        if(S[i][j] != S[j][i]) return false;
    }

    return true;
}


bool tate(){
    string str = S[0];
    S.erase(S.begin()+0);
    S.pb(str);
    return check();
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    cin >> N;
    rep(i,N){
        string inp;
        cin >> inp;
        S.pb(inp);
    }
    ll ans  = 0 ;
    rep(i,N){
        if(tate()) ans ++;
    }
    
    
    cout << ans*N << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.buffer.readline

n = int(input())
a = list(map(int,input().split()))

a.sort(reverse = True)

ans = a[0]

r = n-2
i = 1
while r > 1:
    ans += 2*a[i]
    i += 1
    r -= 2
if r == 0:
    print(ans)
else:
    print(ans + a[i])



Measured memory_bytes: 29172
import sys
s = input()
i = 1 
s1 = ''
while i <= len(s):
  s1 += s[-i]
  i += 1
s2 = s1
while s2 != '':
  if s2[0:5] == 'maerd':
    s2 = s2[5:]
  elif s2[0:7] == 'remaerd':
    s2 = s2[7:]
  elif s2[0:5] == 'esare':
    s2 = s2[5:]
  elif s2[0:6] == 'resare':
    s2 = s2[6:]
  else:
    print('NO')
    sys.exit()
print('YES')

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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<vector<char>> Map(H, vector<char>(W));
  vector<bool> Row_remain(H), Col_remain(W);
  
  // input
  for(int i=0; i<H; i++) {
    string str;
    cin >> str;
    for(int j=0; j<W; j++){
   	  Map.at(i).at(j)= str.at(j);
    }
  }

  // walk-through
  //// 残る行を調べる
  for(int i=0; i<H; i++) {
    for(int j=0; j<W; j++){
   	  if( Map.at(i).at(j)=='#' ){
      	Row_remain.at(i)= true;
        break;
      }
    }
  }
  //// 残る列を調べる
  for(int j=0; j<W; j++){
    for(int i=0; i<H; i++) {
   	  if( Map.at(i).at(j)=='#' ){
      	Col_remain.at(j)= true;
        break;
      }
    }
  }
  
  // output
  for(int i=0; i<H; i++) {
    if( Row_remain.at(i) ){
      for(int j=0; j<W; j++){
   	    if( Col_remain.at(j) ){
      	  cout << Map.at(i).at(j);
        }
   	  }
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <unistd.h>

static const unsigned char TABLE_BITS_COUNT[] = {
  0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6
};

static const unsigned char TABLE_TRAILING_ZEROS[] = { 0, 1, 6, 2, 7, 5, 4, 3 };

static unsigned int
fold_bitflag_func(
  unsigned int  acc,
  unsigned int  x,
  unsigned char *ary,
           int  col)
{
  unsigned char i = TABLE_TRAILING_ZEROS[((x * 0x1d) >> 5) & 0x07];
  return acc + TABLE_BITS_COUNT[ary[i] & col];
}

static unsigned int
fold_bitflag(
  unsigned int  n,
  unsigned int  init,
  unsigned int  (*func)(unsigned int, unsigned int, unsigned char *, int),
  unsigned char *data0,
           int  data1)
{
  unsigned int flg;

  while (1) {
    flg = n & ((~n) + 1);
    if (flg == 0) {
      break;
    }
    init = func(init, flg, data0, data1);
    n ^= flg;
  }

  return init;
}

static void
abc173_c(void)
{
  unsigned int h, w, k;
  unsigned char ary[6];

  scanf("%d %d %d\n", &h, &w, &k);

  for (int i = 0; i < h; i++) {
    unsigned char buf[8];
    scanf("%s\n", buf);

    unsigned char c = 0;
    for (int j = 0; j < w; j++) {
      if (buf[j] == '#') {
        c |= (1 << j);
      }
    }
    ary[i] = c;
  }

  unsigned int ans = 0;
  for (int row = 0; row < 1 << h; row++) {
    for (int col = 0; col < 1 << w; col++) {
      unsigned int cnt = fold_bitflag(row, 0, fold_bitflag_func, ary, col);
      if (cnt == k) {
        ans += 1;
      }
    }
  }
  printf("%d\n", ans);
}

int
main(void)
{
  abc173_c();
  return 0;
}


Measured memory_bytes: 1684
#include <iostream>

using namespace std;

int main() {
    int A, B, T;
    cin >> A, cin >> B, cin >> T;
    int biscuit = 0;
    for (int i = A; i <= T; i+= A) {
        biscuit += B;
    }
    cout << biscuit << endl;
    return 0;
}


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

ll n,m;

int main(){
	cin>>n>>m;
	vl dp(m+1);
	for(int i=0;i<n;i++){
		ll w,v;
		cin>>w>>v;
		vl DP(m+1);
		for(int j=0;j<=m;j++){
			if(j+w<=m) DP[j+w]=dp[j]+v;
			DP[j]=max(DP[j],dp[j]);
		}
		dp=DP;
	}
	ll res=0;
	for(int i=0;i<=m;i++) res=max(res,dp[i]);
	cout<<res<<endl;
}

Measured memory_bytes: 1804
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    bool inc = false, dec = false, flag = true;
    int ans = 1;
    for (int i = 0; i < n-1; i++) {
        if (flag && a[i] < a[i+1]) inc = true, flag = false;
        else if (flag && a[i] > a[i+1]) dec = true, flag = false;
        else if (flag) continue;
        if (inc && a[i] > a[i+1]) {
            ans++;
            inc = false, flag = true;
        } else if (dec && a[i] < a[i+1]) {
            ans++;
            dec = false, flag = true;
        }
    }
    cout << ans << endl;
}

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

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

  // 白：0, 黒：1
  vector<vector<int>> board(h, vector<int> (w, 0));

  rep(i, n) {
    int x, y, a;
    cin >> x >> y >> a;
    
    if (a == 1) {
      rep(j, h) {
        for (int k = 0; k < x; k++) board[j][k] = 1;
      }
    } else if (a == 2) {
      rep(j, h) {
        for (int k = x; k < w; k++) board[j][k] = 1;
      }
    } else if (a == 3) {
      for (int j = 0; j < y; j++) {
        rep(k, w) board[j][k] = 1;
      }
    } else {
      for (int j = y; j < h; j++) {
        rep(k, w) board[j][k] = 1;
      }
    }
  }

  int ans = 0;
  rep(i, h) {
    rep(j, w) {
      if (board[i][j] == 0) 
        ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
    	int n;
    	cin>>n;
    	long long dp[3][n+1];dp[0][0]=dp[1][0]=dp[2][0]=0;
    	for(int i=1;i<=n;i++)
    	{
    	    cin>>dp[0][i]>>dp[1][i]>>dp[2][i];
    	    dp[0][i]+=max(dp[1][i-1],dp[2][i-1]);
    	    dp[1][i]+=max(dp[0][i-1],dp[2][i-1]);
    	    dp[2][i]+=max(dp[1][i-1],dp[0][i-1]);
    	}
    	cout<<max(dp[0][n],max(dp[1][n],dp[2][n]))<<endl;
    	return 0;
    }

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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P &a, const P &b) { return a.real() * b.imag() - a.imag() * b.real(); }
ld dot(const P &a, const P &b) { return a.real() * b.real() + a.imag() * b.imag(); }

using C = pair<ld, P>;
#define rad first
#define pnt second

C smallest_enclosing_disc(vector<P> ps) {
    auto c3 = [](const P &a, const P &b, const P &c) {
        ld A = norm(b - c);
        ld B = norm(c - a);
        ld C = norm(a - b);
        ld S = abs(cross(b - a, c - a));
        P p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) / (4 * S * S);
        ld r = abs(p - a);
        return make_pair(r, p);
    };

    auto c2 = [](const P &a, const P &b) {
        P c = (a + b) / (ld)2;
        ld r = abs(a - c);
        return make_pair(r, c);
    };

    auto in_circle = [](const P &a, const C &c) {
        return norm(a - c.pnt) <= c.rad * c.rad + eps;
    };

    int n = ps.size();
    random_shuffle(ps.begin(), ps.end());
    C c = c2(ps[0], ps[1]);
    for(int i = 2; i < n; ++i) {
        if(!in_circle(ps[i], c)) {
            c = c2(ps[0], ps[i]);
            for(int j = 1; j < i; ++j) {
                if(!in_circle(ps[j], c)) {
                    c = c2(ps[j], ps[i]);
                    for(int k = 0; k < j; ++k) {
                        if(!in_circle(ps[k], c)) {
                            c = c3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

int main() {
    int n;
    cin >> n;
    vector<P> ps(n);
    for(int i = 0; i < n; ++i) {
        ld x, y;
        cin >> x >> y;
        ps[i] = P(x, y);
    }
    printf("%.12f\n",(double)smallest_enclosing_disc(ps).rad);
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
l1=[1]*n
l2=[1]+[0]*(n-1)

for x,y in l:
  x-=1
  y-=1

  l1[y]+=1
  if l2[y]==0 and l2[x]==1:
    l2[y]=1

  l1[x]-=1
  if l1[x]==0:
    l2[x]=0

print(l2.count(1))

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

int main() {
	string s;
	cin >> s;
	int k;
	cin >> k;
	for (int i = 0; i < s.size(); i++) {
		int tmp = ('z' - s[i] + 1) % 26;
		if (k >= tmp) {
			k -= tmp;
			s[i] = 'a';
		}
	}
	k %= 26;
	s.back() += k;
	cout << s;
}

Measured memory_bytes: 512
#!/usr/local/gnu/bin/bash
read a
read b
if((${#a}!=${#b}))
then
    ((${#a}>${#b})) && echo GREATER || echo LESS
    exit
fi
aa=(`echo $a | fold -1`)
ba=(`echo $b | fold -1`)
for i in `seq 0 $((${#a}-1))`
do
    if((aa[i]!=ba[i]))
    then
        ((aa[i]>ba[i])) && echo GREATER || echo LESS
        exit
    fi
done
echo EQUAL

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n + 1];
	for(int i = 0; i < n; i++)
	{
		cin>>a[i];
	}
	
	int dp[n + 1];
	
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for(int i = 2; i < n; i++)
	{
		dp[i] = min(abs(a[i] - a[i - 1]) + dp[i - 1], abs(a[i] - a[i - 2]) + dp[i - 2] );
	}
	/*for(int i = 0; i < n; i++)
	{
		cout<<dp[i]<<" ";
	}*/
	//cout<<endl;
	cout<<dp[n - 1]<<endl;
	
	return 0;
}

Measured memory_bytes: 4372
a, b, m = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))

min_sum = min(A) + min(B)

M = []
for i in range(m):
      an, bn, diff = list(map(int, input().split()))
      M.append(A[an - 1] + B[bn - 1] - diff)

diff_min = min(M)
print(min_sum if min_sum < diff_min else diff_min)

Measured memory_bytes: 18612
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
//using namespace __gnu_pbds; 

#define rep(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace(x) cout << #x << ": " << x << endl
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
#define fill(x,v) memset(x, v, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;

int main(){
  int n,k, a;
  cin >> n >> k;
  ll rpta =0 ;
  rep(i,0,n){
    cin >> a;
    if(a >= k) rpta++;
  }
  cout << rpta << endl;
} 

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

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

int main()
{
	int a,b;
	cin>>a>>b;
	if (a<=5)
	{
		cout<<0<<endl;
		return 0;
	}
	else if (a>5 && a<=12)
	{
		cout<<b/2<<endl;
		return 0;
	}
	else
	{
		cout<<b<<endl;
		return 0;
	}
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long int N,a,b,c,d,e,sum=0;
  vector<long int> input(5);
  cin >> N >>input[0] >> input[1] >> input[2] >> input[3] >> input[4];
  long int tmp=1000000000000000;
  int index=0;
  for(int i=0;i<5;i++){
    if(input[i]<tmp){
      tmp = input[i];
      index = i;
    }
  }
  std::sort(input.begin(),input.end());
  long int count = ceil(N/(double)input[0]);
  // cout << "input0 " <<input[0] << endl;
  // cout << "count: " <<count << endl;
  // cout << index << endl;
  cout << count + 4 << endl;
  return 0;
}


Measured memory_bytes: 256
def prime_count(n):
	j = 0
	ans = [1] * (n + 1)
	ans[0] = ans[1] = 0
	for i in xrange(3, n + 1, 2):
		if i * 2 > n:
			break
		if ans[i] != 0:
			for j in xrange(2 * i, n + 1, i):
				ans[j] = 0
	for k in xrange(2 * 2, n + 1, 2):
		ans[k] = 0
	print sum(ans)

try:
	while True:
		n = input()
		prime_count(n)
except EOFError:
	pass

Measured memory_bytes: 12752
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int moto=sc.nextInt();
		int wa=0;
		int tmp=moto;

		while(tmp>0) {
			wa+=tmp%10;
			tmp/=10;
		}

		if(moto%wa==0) {
			System.out.println("Yes");
		}

		else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 100005;

int n, k, a[MAXN];

int main(){
	scanf("%d %d",&n,&k);
	for(int i=0; i<n; i++) scanf("%d",&a[i]);
	int ret = 1e9;
	for(int i=0; i+k-1<n; i++){
		ret = min(ret, a[i+k-1] - a[i] + min(abs(a[i]), abs(a[i+k-1])));
	}
	cout << ret << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll a, b;
  cin >> a >> b;

  for (ll n = 1; n <= 100000; n++) {
    ll val1 = n * 8 / 100;
    ll val2 = n * 10 / 100;

    if (val1 == a && val2 == b) {
      cout << n << en;
      return 0;
    }
  }
  cout << -1 << en;
  return 0;
}


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


int main()
{
  long long int n,m;
  cin >>  n >> m;

  if(n * 2 >= m){
    cout << m/2 <<endl;
  }else{
    cout << n + (m - 2 * n)/4 << endl;
  }

  return 0;
}


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

const long long INF = 1LL << 60;

long N;
long long h[100010];
long long dp[100010];

int main() {

  cin >> N;
  for (int i = 0; i < N; ++i) cin >> h[i];
  for (int i = 0; i < N; ++i) dp[i] = INF;

  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);

  for (int i = 2; i < N; ++i) {
    long a = dp[i - 1] + abs(h[i] - h[i - 1]);
    long b = dp[i - 2] + abs(h[i] - h[i - 2]);

    if (a < dp[i]) {
      dp[i] = a;
    }

    if (b < dp[i]) {
      dp[i] = b;
    }
  }

  cout << dp[N - 1] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define len(x) ((int)(x).size())

using namespace std;

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

  int N;
  cin >> N;

  int a = 1;

  while (N > 1000 * a) ++a;

  cout << 1000 * a - N << endl;

  return 0;
}


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

int main()
{
    int X;
    cin >> X;
    int a = sqrt(X);
    while (1)
    {
        if ((X == 2) || (X == 3))
        {
            cout << X << endl;
            return 0;
        }
        for (int i = 2; i <= sqrt(X); i++)
        {
            if (X % i == 0)
            {
                break;
            }
            else if (i == a)
            {
                cout << X << endl;
                return 0;
            }
        }
        X++;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
   	#endif
    string a,b;
    cin>>a>>b;
    int n=stoi(a+b);
    long double k=sqrt(n);
    cout<<((k-floor(k)==0)?"Yes":"No");
   	return 0;
}

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

const int MAX_N = 110000;
int dp[MAX_N];

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

    for (int i=0;i<MAX_N;++i) dp[i] = N;
    dp[0] = 0;
    
    for (int n=1;n<=N;++n){
        for (int pow6=1;pow6<=n;pow6*=6) dp[n] = min(dp[n], dp[n-pow6]+1);
        for (int pow9=1;pow9<=n;pow9*=9) dp[n] = min(dp[n], dp[n-pow9]+1);
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 640
//https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_9_A
//p235.cpp

#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main(){
	int H, i, A[MAX+1]; //1-オリジンのため +1する

	cin >> H;
	for( i = 1; i <= H; i++) cin >> A[i];

	for( i = 1; i <= H; i++){
		cout << "node " << i << ": key = " << A[i] << ", ";
		if ( parent(i) >= 1 ) cout << "parent key = " << A[parent(i)] << ", ";
		if ( left(i) <= H ) cout << "left key = " << A[left(i)] << ", ";
		if ( right(i) <= H ) cout << "right key = " << A[right(i)] << ", ";
		cout << endl;
	}
	return 0;
}




Measured memory_bytes: 3104
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef long long ll;  //ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<ll, ll> > PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

// g++ -std=c++11 prac.cpp 
int main(){
    ll x,y=0,z,n,m=0,k,h,w,sum=0,ans=0,Max=0,count=0,Min=1e9+1;
    string s,t,u;
    bool ok=true;
    cin >> n;
    PS p(n);
    map<pair<ll,ll>, ll> mp; 
    rep(i,n){
        cin >> x >> y;
        p[i] = make_pair(x,y);
    }
    sort(RALL(p));
    rep(i,n-1){
        for(int j=i+1;j<n;j++){
            x = p[i].first - p[j].first;
            y = p[i].second - p[j].second;
            if(mp.empty()){
                mp.insert(make_pair(make_pair(x,y),1));
            }
            else if(mp.find(make_pair(x,y)) == mp.end()){
                mp.insert(make_pair(make_pair(x,y),1));
            }
            else{
                mp.find(make_pair(x,y))->second++;
            }
        }
    }

    for(auto i = mp.begin(); i != mp.end();i++) {
        chmax(Max,i->second);
    }
    
    cout << n-Max << endl;
    return 0;
}


Measured memory_bytes: 384
import math
from collections import deque
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

n = readInt()

ans=1

while ans*2<=n:
	ans*=2

print(ans)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  string S[50];
  const int dx[8] = {1, 0, 1, -1, 0, -1, 1, -1};
  const int dy[8] = {0, 1, 1, 0, -1, -1, -1, 1};
  
  for(int i = 0; i < H; i++) cin >> S[i];
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(S[i][j] == '#') continue;
      
      int num = 0;
      for(int k=0; k<8; k++){
        int x = i + dx[k];
        int y = j + dy[k];
        if(x < 0 || x >= H) continue;
        if(y < 0 || y >= W) continue;
        if(S[x][y] == '#') num++;
      }
      
      S[i][j] = char(num + '0');
    }
  }
  for(int i=0; i<H; i++) cout << S[i] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

#define S(X) ((X)*(X))

double dsq(double x,double y,double z,double xx,double yy,double zz){
  return S(xx-x)+S(yy-y)+S(zz-z);
}

int main(){
  for(int n;cin>>n,n;){
    double x[30],y[30],z[30];
    for(int i=0;i<n;i++){
      cin>>x[i]>>y[i]>>z[i];
    }
    double cx=0,cy=0,cz=0;
    double f;
    for(double d=10;d>1e-9;d/=10){
      for(int i=0;i<1000;i++){
	int dx=0;
	for(int j=0;j<n;j++){
	  if(dsq(cx,cy,cz,x[dx],y[dx],z[dx])<dsq(cx,cy,cz,x[j],y[j],z[j])){
	    dx=j;
	  }
	}
	double bx,by,bz;
	bx=x[dx]-cx;
	by=y[dx]-cy;
	bz=z[dx]-cz;
	f=sqrt(S(bx)+S(by)+S(bz));
	cx+=bx*d/f;
	cy+=by*d/f;
	cz+=bz*d/f;
      }
    }
    cout.precision(5);
    cout<<fixed<<f<<endl;
  }
  return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

int main() {
  string n1, n2;
  cin >> n1 >> n2;
  
  if(n1.length() < n2.length()) {
    cout << "LESS" << endl;
    return 0;
  } else if(n1.length() > n2.length()) {
    cout << "GREATER" << endl;
    return 0;
  } else {
    for(int i = 0; i < n1.length(); i++)
      if((n1[i] - '0') > (n2[i] - '0')) {
        cout << "GREATER" << endl;
        return 0;
      } else if((n1[i] - '0') < (n2[i] - '0')) {
        cout << "LESS" << endl;
        return 0;
      }
  }
  
  cout << "EQUAL" << endl;

  return 0;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amin(T& a,T2 b){ if(a > b) a = b;}

	vector<vector<ll>> mkcmb(const int MX){
		vector<vector<ll>> cmb(MX+2, vector<ll>(MX+2));
		rep(i,MX+1)  cmb[i][0] = 1;
		rep2(i,1,MX+1) rep2(j,1,i+1)
			cmb[i][j] = (cmb[i-1][j] + cmb[i-1][j-1]);
		return cmb;
	}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, a, b;
	cin >>n >>a >>b;
	VL v(n), sm(n+1);
	rep(i, n) cin >>v[i];
	sort(v.rbegin(), v.rend());
	rep(i, n) sm[i+1] = sm[i] + v[i];
	
	auto ncr = mkcmb(55);
	
	ll ans = 0;
	rep2(i, a, b+1){
		int cnt=0, ndc=0;
		if(v[i-1] < v[a-1]) break;
		if(sm[a]*i != sm[i]*a) break;
		rep(j, n) if(v[a-1]==v[j]){
			cnt++;
			if(j < i) ndc++;
		}
		//dbg(i,cnt, ndc);
		ans += ncr[cnt][ndc];
	}
	
	printf("%.14f\n%lld\n", (double)sm[a] /a,  ans);
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
 
typedef long long ll;
#define INF 1e9


int main(){
  string s;
  int K;
  cin >> s >> K;

  //vector<string> sub;
  set<string> sub;
  REP(i, s.length()){
    //cout << "i: " <<  i << endl;
    FOR(j, 1, s.length()-i+1){
      if(j > K){
        break;
      }
      //cout << "j: " << j << " " << s.substr(i,j)<< endl;
      //sub.push_back(s.substr(i, j));
      sub.insert(s.substr(i, j));
    }
  }
  //sort(sub.begin(), sub.end());

  int cnt = 1;
  set<string>::iterator i = sub.begin();
  while(i != sub.end()){
    if(cnt == K){
      cout << *i << endl;
      break;
    }
    cnt++;
    ++i;
  }
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define MOD 1000000007
#define CAP 100000001
#define inf 1000000000000000000LL
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define sz(v) v.size()
#define all(v)    v.begin(),v.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int ll
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}

ll n,x;

bool cmp(pair<ll,pii > a, pair<ll,pii > b){
	ll a1=a.s.s*x+a.f*(a.s.f-a.s.s);
	ll b1=b.s.s*x+b.f*(b.s.f-b.s.s);
	return a1>b1;
}

signed main() {
	fast;
	
	cin>>n>>x;
	std::vector<pair<ll,pii > > v(n);


	ll sc1=0;
	for(int i=0;i<n;i++) cin>>v[i].f>>v[i].s.f>>v[i].s.s, sc1+=v[i].f*v[i].s.f;
	sort(all(v),cmp);

	ll l=0,r=inf+1, mid, ans=inf+1;
	while(l<=r){
		mid=(l+r)/2;
		
		ll lef=mid;
		ll scc=sc1;
		ll i=0;
		for(i=0;i<n&&lef>=x&&scc>0;i++){
			scc-=v[i].s.s*x+v[i].f*(v[i].s.f-v[i].s.s);
			lef-=x;
		}

		if(i<n&&lef>0){
			ll mx=0;

			for(int j=0;j<i;j++){
				ll pr = max(v[j].s.s*(lef-v[j].f)+v[j].s.f*v[j].f, v[j].s.f*lef) + (v[i].s.s*x+v[i].f*(v[i].s.f-v[i].s.s)) - (v[j].s.s*x+v[j].f*(v[j].s.f-v[j].s.s));
				mx=max(mx,pr);
			}

			for(;i<n;i++){
				ll pr = max(v[i].s.s*(lef-v[i].f)+v[i].s.f*v[i].f, v[i].s.f*lef);
				mx=max(mx,pr);
			}

			scc-=mx;
		}
		//cout<<"#"<<l<<" "<<r<<" "<<mid<<" -- "<<scc<<" "<<lef<<" "<<i<<endl;
		
		if(scc<=0){
			r=mid-1;
			ans=min(ans,mid);
		}
		else l=mid+1;
	}

	assert(ans!=inf+1);
	cout<<ans;

	
} 

Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()
    print(800 * N - 200 * (N //15))


main()

Measured memory_bytes: 3064