akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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


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

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

  int sx = 0;
  int sy = 0;
  int gx = W-1;
  int gy = H-1;

  int dist[H][W];
  int iW = 0;
  for(int i=0; i < H; i++){
    for(int j = 0; j < W; j++){
      dist[i][j] = -1;
      if(field[i][j] == '.'){
        iW+=1;
      }
    }
  }

  queue<pair<int, int>> que;
  que.push(make_pair(sx, sy));
  dist[sy][sx] = 0;

  bool gF = false;

  while(!que.empty() && !gF){
    pair<int, int> cp = que.front();
    int cx = cp.first;
    int cy = cp.second;
    que.pop();

    for(int i = 0; i < 4; i++){
      int nx = cx + dx[i];
      int ny = cy + dy[i];

      if(dist[ny][nx] != -1) continue;
      if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
      if(field[ny][nx] =='#')continue;
      if(nx == gx && ny == gy) gF = true;
      dist[ny][nx] = dist[cy][cx] + 1;
      que.push(make_pair(nx,ny));
    }
  }

  int answer;
  if(dist[gy][gx] == -1){
    answer = -1;
  } else {
    int necessaryWhite = dist[gy][gx] + 1;
    answer = iW - necessaryWhite;
  }
  cout << answer << endl;

  return 0;
}



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

using ll = long long;

#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++)
#define pb push_back
#define mp make_pair
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// these functions return the position of result of Binary Search.
#define LB(s, t, x) (int) (lower_bound(s, t, x) - s)
#define UB(s, t, x) (int) (upper_bound(s, t, x) - s)

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dx8[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[] = { 0, 0, -1, 1, -1, 1, -1, 1 };

template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

template <class T>
bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T>
bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

inline tuple<ll, ll> rotate45(tuple<ll, ll> p) { ll x = get<0>(p), y = get<1>(p); return tuple<ll, ll>(x + y, x - y); }
inline bool rangeCheck2D(int nx, int ny, int Width, int Height) { return nx >= 0 and nx < Width and ny >= 0 and ny < Height; }

void out_sequence(vector<ll> &out) { REP(i, out.size()) { cout << out[i]; if (i == out.size() - 1) cout << endl; else cout << " "; } }

int main(void)
{
	cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);

	ll N; cin >> N;
	vector<ll> a1(N), a2(N);
	vector<pair<ll, int>> pi(N);
	REP(i, N) {
		ll p; cin >> p;
		pi[i] = mp(p, i);
	}
 
	sort(all(pi));
 
	REP(i, N) {
		ll r = i + 1;
		a1[i] = 30000 * r;
		a2[i] = 30000 * (N - r) + pi[i].second + 1;
	}
 
	out_sequence(a1);
	out_sequence(a2);

	return 0;
}


Measured memory_bytes: 1280
from sys import stdin

N = int(stdin.readline().rstrip())
T = stdin.readline().rstrip().split()
M = int(stdin.readline().rstrip())
P = [stdin.readline().rstrip().split() for _ in range(M)]

T_num = [int(n) for n in T]
P_num = [list(map(int, P_in)) for P_in in P]

for i in range(len(P_num)):
    list_tmp = T_num[:]
    index = P_num[i][0] - 1
    val = P_num[i][1]
    list_tmp[index] = val
    print(sum(list_tmp))


Measured memory_bytes: 3064
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define   ull unsigned long long 
const int MAX=1e6+9;
const int mod=1e9+7;
using namespace std;
int cnt[MAX];

int main(){
	ll a,b,c;
	int n;
	int arr[10];
	int k;
	for(int i=1;i<=5;i++)
		cin>>arr[i];
	cin>>k;
	for(int i=1;i<=5;i++){
		for(int j=i+1;j<=5;j++){
			if(abs(arr[i]-arr[j])>k){
				cout<<":(";
				return 0;
			}
		}
	}
	cout<<"Yay!";

}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

class DisjointSet{
    public:
        vector<int> rank, p;
        // コンストラクタ
        DisjointSet(){}
        DisjointSet(int size){
            rank.resize(size,0);    // vectorのサイズを変更して、デフォルト値として0を代入している
            p.resize(size, 0);
            rep(i,size) makeSet(i);
        }

        // 入力値xのみの集合を作成する
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }
        // ２つの入力要素が同じ集合か否かを判別する
        bool same(int x, int y){
            return findSet(x) == findSet(y);
        }
        // 2つの集合を結合する
        void unite(int x, int y){
            link(findSet(x), findSet(y));
        }

        void link(int x, int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x] == rank[y]) rank[y]++;
            }
        }

        int findSet(int x){
            if(x != p[x]){
                // 経路圧縮をしている
                p[x] = findSet(p[x]);
            }
            // 親要素と自分の要素が一致したときに親を返す
            return p[x];
        }
};


class Edge {
    public:
        int source, target, cost;
        // コンストラクタ
        Edge(int source=0, int target=0, int cost=0):
        source(source), target(target), cost(cost) {}
        bool operator < (const Edge &e) const {
            return cost < e.cost;
        }
};

int kruskal(int N, vector<Edge> edges){
    int totalCost = 0;
    sort(edges.begin(), edges.end());

    DisjointSet dset = DisjointSet(N+1);

    rep(i,N) dset.makeSet(i);

    int source, target;
    rep(i,edges.size()){
        Edge e = edges[i];
        if(!dset.same(e.source, e.target)){
            //MST.push_back(e);
            totalCost += e.cost;
            dset.unite(e.source, e.target);
        }
    }
    return totalCost;
}

int main()
{
    int N, M, cost;
    int source, target;

    cin >> N >> M;

    vector<Edge> edges;
    rep(i,M){
        cin >> source >> target >> cost;
        edges.push_back(Edge(source, target, cost));
    }
    cout << kruskal(N, edges) << endl;

    return 0;
}


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

int main(){
	int h, n;
  	cin>>h>>n;
  	int a[n];
  	for(int i=0;i<n;i++){
    	cin>>a[i];
    }
  
  	for(int i=0;i<n;i++){
    	h-=a[i];
    }
  	if(h<=0){
    	cout<<"Yes"<<endl;
    }else {
    	cout<<"No"<<endl;
    }
  	return 0;
}

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

int main() {
	int r, g, b;
	int rgb = 0;
	
	cin >> r >> g >> b;

	rgb = r * 100 + g * 10 + b;

	if (rgb % 4)cout << "NO";
	else cout << "YES";

}

Measured memory_bytes: 384
n = int(input())
ls, rs = [], []

def check(sl):
    h = 0
    for t in sl:
        b = h + t[0]
        if b < 0:
            return False
        h += t[1]
    return True

total = 0
for i in range(n):
    b, h = 0, 0
    S = input()
    for s in S:
        if s == '(':
            h += 1
        else:
            h -= 1
        b = min(b, h)
    if h > 0:
        ls.append((b, h))
    else:
        rs.append((b - h, -h))
    total += h
ls.sort(key=lambda x: x[0], reverse=True)
rs.sort(key=lambda x: x[0], reverse=True)
print('Yes' if check(ls) and check(rs) and total == 0 else 'No')

Measured memory_bytes: 84024
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val (a, b) = readLine()!!.split(" ")

    val s = buildString {
        a.toCharArray().zip(b.toCharArray()).map {
            append("${it.first}${it.second}")
            it
        }
    }
    println(s)
}

Measured memory_bytes: 37872
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) cout << "YES\n";
	else cout << "NO\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

vector<int> P(100),I(100);
int h;
int poiu;
void res(int l,int r)
{
	if(l>=r)return;
	int c = P[h++];
	int m = -1;
	for(int i =0;i<r;i++)
	{
		if(I[i]==c)
		{
			m = i;
			break;
		}
	}
	//cout<<m<<endl;
	//if(m==-1)return;
	res(l,m);
	res(m+1,r);
	if(poiu++)cout<<' ';
	cout<<c;

}

int main()
{
	int n;
	cin >> n;
	
	for(int i =0;i<n;i++)cin >> P[i];
	for(int i =0;i<n;i++)cin >> I[i];
	res(0,n);cout<<endl;


	return 0;
}


Measured memory_bytes: 3112
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <iomanip>
#define INF 2147483647

using namespace std;



int main()
{
	double s[1005], ave, a;
	int n;

	while (1) {
		cin >> n;
		if (n == 0) break;
		ave = 0;
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			ave += s[i];
		}
		ave /= n;
		a = 0;
		for (int i = 0; i < n; i++) {
			a += pow((s[i] - ave), 2);
		}
		a /= n;
		cout << fixed << setprecision(8) << sqrt(a) << endl;
	}

	return (0);
}

Measured memory_bytes: 1296
N, M = map(int, input().split())
L = list(list(map(int,input().split())) for i in range(M))
l = 1
r = N
for i in range(M):
    l = max(l,L[i][0])
    r = min(r,L[i][1])
print(max(r-l+1,0))


Measured memory_bytes: 27332
#include <cstdio>

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b){
	if(!b) return a;
	return gcd(b, a % b);
}

int main(){
	ll a, b; scanf("%lld%lld", &a, &b);
	printf("%lld\n", 3LL * gcd(a, b) * (a / gcd(a, b) - 1LL));
	return 0;
}

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

#define MAX_SEG (1<<17)

int remain_hp[100010];
int healing_all[2 * MAX_SEG];
int healing_part[2 * MAX_SEG];
int n;

void init(int n_) {
    n = 1;
    while (n < n_) n *= 2;
}

// ??????[a,b)??????x?????????
void add_to_healingseg(int a, int b, int x, int k, int l, int r) {
    if (r <= a || b <= l) return;
    if (a <= l && r <= b) {
        healing_all[k] += x; // ??????[l,r)??????x?????????
        return;
    }
    healing_part[k] += (min(b,r) - max(a,l)) * x;
    add_to_healingseg(a, b, x, 2*k + 1, l, (l + r)/2);
    add_to_healingseg(a, b, x, 2*k + 2, (l + r)/2, r);
    
}

int sum(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return (r - l) * healing_all[k] + healing_part[k];
    int res = 0;
    res += (min(b,r) - max(a,l)) * healing_all[k];
    res += sum(a, b, 2*k + 1, l, (l + r)/2);
    res += sum(a, b, 2*k + 2, (l + r)/2, r);
    return res;
}

int fetch_remainhp(int k) {
    int a = remain_hp[k];
    int b = sum(k, k + 1, 0, 0, MAX_SEG);
    return a + b;
}

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

    init(N-1);

    priority_queue<pair<int, int> > q;
    long long ans = 0;
    int curr_h = H;
    int last_heal = -1;
    for (int i=0; i<N-1; i++) {
        int d,h; cin >> d >> h;
        remain_hp[i] = curr_h;
        q.push(make_pair(h, i));

        //printf("[i:%d,d:%d,h:%d] curr_h:%d\n", i, d, h, curr_h);

        while (d >= curr_h) {
            int ch  = q.top().first;
            int idx = q.top().second;
            int rhp = fetch_remainhp(idx);
            if (ch + rhp > H) {
                q.pop();
                q.push(make_pair(H - rhp, idx));
                continue;
            }
            // ?????????????????????????±???????????????????
            if (last_heal > idx) {
                q.pop();
                continue;
            }
            // ?????§?????§????????§???????????????????????????????????????1???
            int heal_cnt = max(1, min(d - curr_h, H - fetch_remainhp(idx)) / ch);
            int heal_amount = min(heal_cnt * ch, H - fetch_remainhp(idx));
            ans += (long long)heal_cnt;
            add_to_healingseg(idx, i+1, heal_amount, 0, 0, MAX_SEG);
            curr_h = fetch_remainhp(i);
            last_heal = idx;
            //printf(" - used heal(i:%d, h:%d) -> curr_h:%d, heal_cnt:%d, heal_amount:%d, ans:%lld\n", idx, ch, curr_h, heal_cnt, heal_amount, ans);
            q.pop();
            q.push(make_pair(min(ch, H - fetch_remainhp(idx)), idx));
        }
        curr_h -= d;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4808
#pragma GCC optimize("O3") 
#define TASK ""
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
#define __USE_MINGW_ANSI_STDIO 0
#include<bits/stdc++.h>                               
using namespace std;

#define PI acos(-1)
#define pb push_back
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(c) (c).begin(), (c).end()
#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair <int, int> pii;
typedef vector <vi> vvi;
typedef vector <pii> vpii;
typedef vector<string> vs;

const int MAXN = 1e5 + 9;
const int MOD = (int)(1e9 + 7);
const int INF = 100500;

int n, m, q;
vvi gg;
int col[MAXN];
int used[MAXN];

void input() {
	cin >> n >> m;
	gg.resize(n);
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		gg[a].pb(b);
		gg[b].pb(a);
	}
}

void bfs(int v, int color, int depth) {
	queue < pii > qq;
	qq.push({ v, depth });
	while(!qq.empty()) {
		pii u = qq.front();
		qq.pop();
		if(!col[u.fi]) col[u.fi] = color;
		if(used[u.fi] >= u.se) continue;
		used[u.fi] = u.se;
		if(u.se == 0) continue;
		for(auto to : gg[u.fi]) {        
			qq.push({ to, u.se - 1 });
		}
	}		
}

struct query {
	int v, d, c;
};

void solve() {
	cin >> q;
	vector < query > oo;
	for(int i = 0; i < q; i++) {
		query q;
		cin >> q.v >> q.d >> q.c;
		q.v--;
		oo.pb(q);
	}
	reverse(all(oo));
	for(int i = 0; i < q; i++) {
		bfs(oo[i].v, oo[i].c, oo[i].d);
	}
	for(int i = 0; i < n; i++) cout << col[i] << endl;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef LOCAL
	freopen("xxx.in", "r", stdin);
	freopen("xxx.out", "w", stdout);
#else
	//freopen(TASK".in", "r", stdin);
	//freopen(TASKa".out", "w", stdout);
#endif	
	input();
	solve();
	return 0;
}

Measured memory_bytes: 9328
#include <stdio.h>
#include <string.h>
int main() {
	int n, m, ans, max = 0;
	char blue[100][11];
	char red[100][11];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", blue[i]);
	}
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		scanf("%s", red[i]);
	}
	for (int i = 0; i < n; i++) {
		ans = 0;
		for (int j = 0; j < n; j++) {
			if (strcmp(blue[i], blue[j]) == 0) {
				ans++;
			}
		}
		for (int j = 0; j < m; j++) {
			if (strcmp(blue[i], red[j]) == 0) {
				ans--;
			}
		}
		if (max < ans) max = ans;
	}
	for (int i = 0; i < m; i++) {
		ans = 0;
		for (int j = 0; j < n; j++) {
			if (strcmp(red[i], blue[j]) == 0) {
				ans++;
			}
		}
		for (int j = 0; j < m; j++) {
			if (strcmp(red[i], red[j]) == 0) {
				ans--;
			}
		}
		if (max < ans) max = ans;
	}
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
using vs = vector<string> ;
#define all(v) v.begin(),v.end()
const int MAX_V = 210;
const int INF = 1e5;
 
int V;
vll G[MAX_V];
int match[MAX_V];
bool used[MAX_V];
 
void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}
 
bool dfs(int v){
  used[v]=true;
  rep(i,G[v].size()){
    int u = G[v][i], w = match[u];
    if(w<0 || !used[w] && dfs(w)){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}
 
int bipartite_matching(){
  int res = 0;
  memset(match, -1, sizeof(match));
  rep(v,V){
    if(match[v]<0){
      memset(used, 0, sizeof(used));
      if(dfs(v)) res++;
    }
  }
  return res;
}
 
int main(){
  cin>>V;
  vector<pair<int,int>> red,blue;
  rep(i,V){
    int a,b;cin>>a>>b;red.push_back(make_pair(a,b));
  }
  rep(i,V){
    int c,d;cin>>c>>d;blue.push_back(make_pair(c,d));
  }
  rep(i,V){
    rep(j,V){
      pair<int,int> r,b;
      r = red[i],b=blue[j];
      if(r.first<b.first && r.second<b.second) add_edge(i,j+V);
    }
  }
  //cout << "グラフ" << endl;
  //rep(i,V)rep(j,G[i].size()) cout<< i << " " << G[i][j]<<endl;
  cout << bipartite_matching() << endl;
}

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

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

	vector<int> v(n), w(n);
	for(int i = 0; i < n; i++) cin >> v[i] >> w[i];

	int dp[100001] = {0};
	for(int i = 0; i < n; i++){
		for(int j = W; j >= 0; j--){
			if(j - w[i] < 0) continue;
			dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
		}
	}
	cout << dp[W] << endl;
}

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

int main() {
    long long A,B,C,D; cin >> A >> B >> C >> D;
    long long a,b,c,d,e,f;
    a = (A-1)/C; b = B/C; c = (A-1)/D; d = B/D;
    long long tmp,r,M=C,N=D,s; long long x = C*D; 

    if(M<N){
        tmp = M;
        M = N;
        N = tmp;
    }
    
    r = M % N;
    while(r != 0){
        M = N;
        N = r;
        r = M % N;
    }
    s = x/N;

    e = (A-1)/s; f = B/s;

    
    cout << B-A+1-((b-a)+(d-c)-(f-e)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int  main()
{
	int arr [6],i,x=-99;
	for (i=0;i<5;i++){
		scanf("%d",&arr[i]);
		if(arr[i] == 0)
			 x = i+1 ;
	}
	printf("%d",x);
	return 0;
}

Measured memory_bytes: 2152
#include<iostream>
using namespace std;
int main(){
	int n,x,i,j,k,a=0,count=0;
	for(;;){
	cin>>n>>x;
	if(n==0 && x==0){
	break;
	}
	for(j=1;j<=n;j++){
		for(i=1;i<=n;i++){
			for(k=1;k<=n;k++){
				if(j+i+k==x&&k<i&&i<j){
					count++;
					
				}
			}
		}
		
	}
	cout<<count<<endl;
	count=0;
	}
return 0;
}

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

#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	multiset<int> mult;
	mult.insert(a[0]);
	for(int i=1;i<n;i++)
	{
		auto it = mult.lower_bound(a[i]);
		if(it!=mult.begin())
		{
			it--;
			mult.erase(it);
		}
		mult.insert(a[i]); 
	}
	cout<<mult.size();
	return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

ll dp[1001][1001];

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

    int n, m; cin >> n >> m;
    vector<ll> x(n), y(n), z(n);
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i];

    ll ans = -linf;
    for (int bits = 0; bits < (1 << 3); bits++) {
        dp[0][0] = 0;
        for (int i = 1; i <= m; i++) dp[0][i] = -linf;
        for (int i = 0; i < n; i++) {
                ll X = x[i]; if (bits & (1 << 0)) X *= -1;
                ll Y = y[i]; if (bits & (1 << 1)) Y *= -1;
                ll Z = z[i]; if (bits & (1 << 2)) Z *= -1;
            for (int j = 1; j <= m; j++) {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - 1] + X + Y + Z);
            }
        }
        ans = max(ans, dp[n][m]);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int r,D;
	cin>>r>>D;
	
	int x[11];
	
	cin>>x[0];
	
	for(int i=0;i<11;i++){
		x[i+1]=r*x[i]-D;
	}
	
	for(int i=0;i<10;i++){
		cout<<x[i+1]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque
n = int(input())
an = list(map(int, input().split()))
b = deque([])
if n % 2 == 0:
    for i in range(0, n, 2):
        b.append(an[i])
        b.appendleft(an[i+1])
else:
    b.append(an[0])
    for i in range(1, n, 2):
        b.append(an[i])
        b.appendleft(an[i+1])
print(*b)


Measured memory_bytes: 25412
list1 = []
cnt = 0
for i in range(4):
    list1.append(int(input()))
for i in range(list1[0]+1):
    for j in range(list1[1]+1):
        for k in range(list1[2]+1):
            if list1[3] == 500*i + 100*j + 50*k:
                cnt += 1
print(cnt)

Measured memory_bytes: 3064
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (x<y) {
			System.out.println(0);
		}else {
			System.out.println(10);
		}
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl

template<typename T>
T gcd(T x, T y){
    if ((x==1)||(y==1)) return 1;
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}

int main() {
    IN(int, n);
    set<string> a;
    REP(i, n){
        IN(string, s);
        a.insert(s);
    }
    COUT(a.size());
}


Measured memory_bytes: 19260
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DEBUG_OUTPUT_ENABLED 1
	#define DBG(X) dout << #X << "=" << (X) << '\n';
	#define SAY(X) dout << (X) << '\n';
#else
	#define DEBUG_OUTPUT_ENABLED 0
	#define DBG(X) 42;
	#define SAY(X) 42;
#endif

#define dout   debug::instance

using namespace std;

template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
namespace debug {
	struct DebugStream {
		private:
			bool is_first;
		public:
			DebugStream(bool _is_first): is_first(_is_first) {}
			template<typename T> DebugStream operator<<(const T& value) const {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				cout << value;
				return DebugStream(false);
			};

			template<typename T> DebugStream printArray(T* l, T* r) {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				while(l != r) {
					cout << (*l);
					++l;
					if(l == r) {
						cout << '\n';
					} else {
						cout << ' ';
					}
				}
				return DebugStream(false);
			}
	};
	DebugStream instance(true);
};

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }
const int MAXN = (int)2e5 + 7;
int answ[MAXN], n, x;
void solve() {
	cin >> n >> x;
	n = 2 * n - 1;
	--x;
	if(x == 0 || x == n - 1) {
		cout << "No\n";
		return;
	}
	memset(answ, NIL, sizeof(answ));
	set<int> setik;
	for(int i = 0; i < n; ++i) setik.insert(i);
	int mid = (n - 1) / 2;
	for(int i = -1; i <= 1; ++i) {
		answ[mid + i] = x + i;
		setik.erase(x + i);
	}
	for(int i = 0; i < n; ++i) {
		if(answ[i] != NIL) continue;
		auto iter = setik.begin();
		answ[i] = *iter;
		setik.erase(iter);
	}
	cout << "Yes\n";
	for(int i = 0; i < n; ++i) cout << answ[i] + 1 << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
   SPEED;
   int n;
   cin>>n;
   set <string> s;
   for(int i=0;i<n;i++)
   {
       string str;
       cin>>str;
       s.insert(str);
   }
   cout<<s.size();
}

Measured memory_bytes: 19232
#!/usr/bin/env python3


def compute(n):
    return sum(i for i in range(1, n + 1) if i % 3 != 0 and i % 5 != 0)


def main():
    n = int(input())
    res = compute(n)
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

const double Pi = acos(-1);

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    m += h * 60;
    double t1 = Pi * m / 360;
    double t2 = Pi * m / 30;
    double t = abs(t1 - t2);
    cout << fixed << setprecision(15) << sqrt(a * a + b * b - 2 * a * b * cos(t)) << endl;
}

Measured memory_bytes: 4268
#include <stdio.h>
int main(void){
	char s[101];
	int a;
	scanf("%d%s",&a,s);
	int i,len=0,c=0;
	for(i=0;s[i]!='\0';i++) len++;
	if(len%2==1) c=1;
	else for(i=len/2;i<len;i++) if(s[i]!=s[i-len/2]) c=1;
	printf(c==0?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p,left,right;
};
struct Node t[MAX];
int n;

void preParse(int u){
  if(u == NIL) return;
  printf(" %d",u);
  preParse(t[u].left);
  preParse(t[u].right);
}
void inParse(int u){
  if(u == NIL) return;
  inParse(t[u].left);
  printf(" %d",u);
  inParse(t[u].right);
}
void postParse(int u){
  if(u == NIL) return;
  postParse(t[u].left);
  postParse(t[u].right);
  printf(" %d",u);
}
int main(){
  int i,v,l,r,root;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    t[i].p=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    t[v].left=l;
    t[v].right=r;
    if(l!=NIL)t[l].p=v;
    if(r!=NIL)t[r].p=v;
  }
  for(i=0;i<n;i++){
    if(t[i].p==NIL)root=i;
  }
  printf("Preorder\n");
  preParse(root);
  printf("\n"); 
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");
return 0;
}

Measured memory_bytes: 616
#include <stdio.h>


int main(void)
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if (a <= b && b <= c) printf("%d %d %d\n", a, b, c);
	if (a <= c && c < b) printf("%d %d %d\n", a, c, b);
	if (b < c && c <= a) printf("%d %d %d\n", b, c, a);
	if (b < a && a <= c) printf("%d %d %d\n", b, a, c);
	if (c < a && a <= b) printf("%d %d %d\n", c, a, b);
	if (c <= b && b < a) printf("%d %d %d\n", c, b, a);

	return 0;
}

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll n;
cin >> n;
ll a[n];
for (ll i = 0; i < n; i++) cin >> a[i];
ll sum[n];
for (ll i = 0; i < n; i++) sum[i] = a[i] + i;
map<ll, ll> mp;
for (ll i = 0; i < n; i++) mp[sum[i] * (-1)]++;
ll ans = 0;
for (ll i = 0; i < n;i++){
    ans += mp[a[i] - i];
}
cout << ans << endl;
}


Measured memory_bytes: 29316
N,M=map(int,input().split())

X=[int(i) for i in input().split()]

X.sort()
X.reverse()

Y=[0]*(M-1)
for j in range(M-1):
    Y[j]=X[j]-X[j+1]

Y.sort()
Y.reverse()

Z=0
for k in range(N-1,M-1):
    Z=Z+Y[k]
print(Z)

Measured memory_bytes: 13840
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i)
#define per(i,a,b) for(int i=(b),i##_end=(a);i>=i##_end;--i)
#define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;++i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > > 
#ifdef flukehn
#define debug(...) fprintf(stderr, __VA_ARGS__);
#else
#define debug(...)
#endif
typedef double db;
typedef long long L;
typedef long double lf;
typedef unsigned int uint;
typedef unsigned long long uL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f,mo=998244353;
template<typename T>inline void admo(int&a,const T&b){a=(a+b>=mo?a+b-mo:a+b);}
template<typename T>inline void sumo(int&a,const T&b){a=(a-b<0?a-b+mo:a-b);}
template<typename T,typename S>inline bool upmx(T&a,const S&b){return a<b?a=b,1:0;}
template<typename T,typename S>inline bool upmn(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T>inline T gcd(T a,T b){while(b)a%=b,swap(a,b);return a;}
inline int Pow(int a,int b,int p=mo){int r=1;for(;b;b>>=1,a=1ll*a*a%p)if(b&1)r=1ll*r*a%p;return r;}
const int N=2e5+11;
int n;
int a[N],b[N];
int main(){
#ifdef flukehn
	freopen("g.in","r",stdin);
#endif
	ios::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i],b[a[i]]=i;
	int now=0,ans=0;
	for(int i=1;i<=n;i++)
	{
		if(b[i]>b[i-1])
		{
			now++;
		}
		else now=1;
		ans=max(ans,now);
	}
	cout<<n-ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<vector<pii>> g(n);
    REP(i,n-1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        g[a].emplace_back(b,c);
        g[b].emplace_back(a,c);
    }
    int q, k;
    cin >> q >> k;
    k--;
    
    // ダイクストラ
    vector<bool> visit(n);
    vector<ll> d(n,0);
    // cost,頂点
    priority_queue<pll> pq;
    for (auto p:g[k]) {
        pq.emplace(p.second,p.first);
    }
    visit[k] = true;
    int vcount = 1;
    while(vcount < n) {
        vcount++;
        pll cnt = pq.top(); pq.pop();
        visit[cnt.second] = true;
        d[cnt.second] = cnt.first;
        for(auto p:g[cnt.second]) {
            if (!visit[p.first]) pq.emplace(d[cnt.second] + p.second,p.first);
        }
    }

    REP(i,q) {
        int x, y;
        cin >> x >> y;
        x--;y--;
        OUT(d[x] + d[y])
    }

    return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;

    vector<int> p(a),q(b),r(c);

    rep(i,a)cin>>p[i];
    rep(i,b)cin>>q[i];
    rep(i,c)cin>>r[i];

    sort(all(p),greater<int>());
    sort(all(q),greater<int>());
    sort(all(r),greater<int>());

    vector<int> eat;

    rep(i,x)eat.eb(p[i]);
    rep(i,y)eat.eb(q[i]);
    rep(i,c)eat.eb(r[i]);

    sort(all(eat),greater<int>());

    rep(i,x+y)ans += eat[i];


    cout<<ans<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


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

typedef long long ll;

struct Edge{
    int u,v;
    bool operator == (const Edge& t) const {
	if( min(u,v)==min(t.u,t.v) and max(u,v) == max(t.u,t.v) )
	    return true;
	return false;
    }
};

void dfs(const Edge& e, const vector<vector<int>>& g, vector<bool>& used, int x) {
    
    used[x] = true;
    for(auto& nxt : g[x]) {
	if( used[nxt] == true ) continue;
	if( Edge{x,nxt} == e ) continue;
	dfs(e,g,used,nxt);
    }
}
bool is_bridge(const Edge& e, const vector<vector<int>>& g ){

    vector<bool> used(g.size(),false);
    dfs(e,g,used,0);
    bool ans = true;
    for(auto e : used) 
	ans &= e;
    return !ans;
}




int main () {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    vector<Edge> edges;
    for(int i=0; i<m; i++) {
	int u,v;
	cin >> u >> v; u--; v--;
	g[u].push_back( v );
	g[v].push_back( u );

	edges.push_back( Edge{u,v} );
    }

    int ans = 0;
    for(auto& e : edges) {
	ans += is_bridge(e,g);
    }
    cout << ans << endl;


    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif
	vl a(4);
	rep(i, 4) cin >> a[i];
	ll n;
	cin >> n;
	ll ans = 0LL;
	reverse(all(a));
	ll tmp = 1e18;
	rep(i, 4) tmp = min(tmp, (ll)pow(2, i) * a[i]);
	ans = (n/2) * tmp;
	if(n&1) {
		tmp = 1e18;
		REP(i, 1, 4) tmp = min(tmp, (ll)pow(2, i-1) * a[i]);
		ans += tmp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import combinations
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

n,m=map(int,input().split())
uf=UnionFind(n)
e=[]
comb=list(combinations(list(range(n)),2))
for _ in range(m):
  a,b=map(int,input().split())
  e.append((a-1,b-1))
ans=0
for i in range(m):
  uf=UnionFind(n)
  for j in range(m):
    if i==j:continue
    uf.Unite(*e[j])
  if not all([uf.isSameGroup(x,y) for x,y in comb]):ans+=1
print(ans)

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    int N;
    cin>>N;
    vector<int> C(N),D(N);
    rep(i,N) cin>>C[i]>>D[i];
    int l=0;
    rep(i,N){
        if(C[i]==D[i]) l++;
        else l=0;
        if(l==3){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3628
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair



int main(){
  CIN(n,kk);
  VC2(n,x,y);

  V xx=x;
  V yy=y;
  sort(ALL(x));
  sort(ALL(y));

  ll ans=LINF*4;
  REP(i,n)
    FOR(j,i+1,n)
      REP(k,n)
        FOR(l,k+1,n){
          ll cou = 0;
          REP(m,n)
            if(x[i]<=xx[m]&&x[j]>=xx[m]&&y[k]<=yy[m]&&y[l]>=yy[m])
              ++cou;
          if(cou>=kk){
            ans=min(ans,1LL*(x[j]-x[i])*(y[l]-y[k]));
          }
        }

  COUT(ans);
          


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	vector<int>    t(n);
	inc(i, n) { cin >> s[i] >> t[i]; }
	string x;
	cin >> x;
	
	int ans = 0, c = 0;
	inc(i, n) {
		ans += c * t[i];
		if(s[i] == x) { c = 1; }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n,a,b;cin>>n>>a>>b;
    ll ans=0;
    ans+=(n/(a+b))*a;
    ans+=min(a,n%(a+b));
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n, K;
    scanf("%d%d", &n, &K);
    int ans = 0;
    while(n){
        n /= K;
        ++ans;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 1000000 /* 最大値 1,000,000 */

/* 素数判定表 */
int p[MAX + 1];
int PRIME = 1;
int NONPRIME = 0;

int main(void) {
	int a, b, n;
	int i, j;

	/* 素数判定表を生成する */
	p[0] = NONPRIME;
	p[1] = NONPRIME;
	for (i = 2; i <= MAX; i++) p[i] = PRIME; /* 初期化 */
	/* 素数の倍数を非素数と判定する (エラトステネスのふるい) */
	for (i = 2; i <= MAX; i++) {
		if (p[i] == PRIME) {
			for (j = i + i; j <= MAX; j += i) p[j] = NONPRIME;
		}
	}

	/* データセット毎の処理 */
	while (scanf("%d%d%d", &a, &b, &n) == 3 && a > 0 && b > 0 && n > 0) {
		/* n 番目の素数を探す */
		for (i = 0; i < n; a += b) {
			if (p[a] == PRIME) i++; /* a が素数ならこれが i 番目の素数である */
		}
		a -= b;
		printf("%d\n", a); /* 出力する */
	}

    return 0;
}

Measured memory_bytes: 4504
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>
#include <cassert>
using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    string s,t;
    cin >> s >> t;
    int a = 0;
    rep(i,3){
        if(s[i]==t[i]){
            a++;
        }
    }
    cout << a << endl;

    return 0;
}

Measured memory_bytes: 760