akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cmath>
#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
//#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	string S;
	bool a = false;
	cin >> S;
	for (int i = 0; i < 3;i++) {
		if (S[i] != S[i + 1]) {
			a = true;
		}
	}
	if (a) {
		if (S[0] == S[1] && S[2] == S[3]) {
			cout << "Yes" << endl;
		}
		else if (S[0] == S[2] && S[1] == S[3]) {
			cout << "Yes" << endl;
		}
		else if (S[0] == S[3] && S[2] == S[1]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
	
}


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

using namespace std;

using ll = long long;

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

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i; j <= n; j++) {
            int cnt = n - (j - i);
            if (cnt > K) continue;

            vector<ll> hoge;
            ll sum = 0;
            for (int k = 0; k < i; k++) {
                hoge.push_back(v[k]);
                sum += v[k];
            }

            for (int k = j; k < n; k++) {
                hoge.push_back(v[k]);
                sum += v[k];
            }

            sort(hoge.begin(), hoge.end());
            int rest = K - cnt;
            for (int k = 0; k < min(rest, cnt); k++) {
                if (hoge[k] >= 0) continue;
                sum -= hoge[k];
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define mp make_pair
#define pb push_back
#define pf push_front
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >p;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll x,a;
  	cin>>x>>a;
  	if(x<a)
      cout<<0;
  	else
      cout<<10;
    return 0;
}


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

typedef long long int ll;
typedef string str;

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,j;
	cin >> n;
	ll b[n+2][3],a[n+2][3];
	cin >> b[0][0] >> b[0][1] >> b[0][2];
	for(i=1;i<n;i++)
	{
		cin >> a[i][0] >> a[i][1] >> a[i][2];
		b[i][0]=a[i][0]+max(b[i-1][1],b[i-1][2]);
		b[i][1]=a[i][1]+max(b[i-1][0],b[i-1][2]);
		b[i][2]=a[i][2]+max(b[i-1][1],b[i-1][0]);
	}
	cout << max(b[n-1][0],max(b[n-1][1],b[n-1][2])) << "\n";
	return 0;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h> 
//compiling code: g++ test.cpp(file) -o script(output) -std=c++11(version) -O2(make it 2x faster)
using namespace std;
int N, H[100005];

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

    string ans = "Yes";
    H[0] = H[0] - 1;
    for (int i=1; i<N; i++){
        if (H[i] == H[i-1]){
            ans = "Yes";
        } else if(H[i] > H[i-1]){
            H[i] = H[i] - 1;
            ans = "Yes";
        } else{
            ans = "No";
            break;
        }
    }

    if (N == 1){
        cout << "Yes" << "\n";
    } else{
         cout << ans << "\n";
    }

}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    long long N, M;

    cin >> N >> M;

    if (N == 1 && M == 1) cout << 1;
    else if (N == 1) cout << M - 2;
    else if (M == 1) cout << N - 2;
    else cout << (N * M) - ((N + M) << 1) + 4;
    return 0;
}


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

using namespace std;

int W, H, N;
double x[210];
double y[210];

typedef pair<double, int> P;
const double INF = 1e16;

int main(){
    while(cin >> W >> H >> N && W > 0) {
        REP(i, 2*N) cin >> x[i] >> y[i];

        x[2*N] = W, y[2*N] = 0;
        x[2*N+1] = W, y[2*N+1] = H;
        N++;

        vector<double> segs = {0.0, 1.0 * H};
        for(int i = 0; i < 2*N; i++) {
            for(int j = i + 1; j < 2*N; j++) {
                double dx = x[j] - x[i];
                double dy = y[j] - y[i];
                if(dx == 0) continue;
                double h = y[i] - x[i] / dx * dy;
                if(h < 0) continue;
                if(h > H) continue;
                segs.push_back(h);
            }
        }
        for(int i = 0; i < 2*N; i++) {
            if(x[i] == 0) segs.push_back(y[i]);
        }

        sort(segs.begin(), segs.end());
        segs.erase(unique(segs.begin(), segs.end()), segs.end());

        double answer = 0;

        for(int t = 0; t + 1 < segs.size(); t++) {
            double h1 = segs[t], h2 = segs[t+1];
            double h = (h1 + h2) / 2;
            vector<P> v;
            REP(i, 2*N) {
                double dx = x[i] - 0;
                double dy = y[i] - h;
                if(dx == 0) {
                    if(dy <= 0) v.push_back(P(-INF, i));
                    else        v.push_back(P(+INF, i));
                } else {
                    double p = h + W / dx * dy;
                    v.push_back(P(p, i));
                }
            }

            sort(v.begin(), v.end());
            double lb = v[N-1].first;
            if(lb < 0) lb = 0;
            if(lb > H) lb = H;
            double ub = v[N].first;
            if(ub < 0) ub = 0;
            if(ub > H) ub = H;
            answer += (h2 - h1) * (ub - lb) / H / H;
        }

        printf("%.12f\n", answer);
    }
    return 0;
}

Measured memory_bytes: 1392
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    long long int n, i, j, ans=0;
    scanf("%lld", &n);
    
    for(i=1; 1; i++){
        if((n-i) <= i*i) break;
        if((n-i)%i==0) ans += (n-i)/i;
    }
    printf("%lld", ans);
    
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int N;
    cin >> N;
    ll a[105];
    for(int i = 1; i <= N; i++) {
        cin >> a[i];
    }
    ll ans = 10000000000000;
    for(ll val = -100; val <= 100; val++) {
        ll now = 0;
        for(int i = 1; i <= N; i++) {
            now += (a[i] - val) * (a[i] - val);
        }
        ans = min(ans, now);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;

const ll INF = numeric_limits<ll>::max(),
         MOD = 1e9 + 7;

const int INF_i = numeric_limits<int>::max(),
          MAX = 1e6;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);

    int n, k;
    cin >> n >> k;
    vll dp(k + 1, 0);
    dp[k] = 1;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ll s = 0;
        for (int j = 0; j < a; j++) {
            s = (s + dp[j]) % MOD;
        }
        for (int j = 0; j <= k; j++) {
            if (j + a <= k) 
                s = (s + dp[j + a]) % MOD;
            ll t = dp[j];
            dp[j] = s;
            s = (MOD - t + s) % MOD;
        }
    }
    cout << dp[0] << '\n';
}

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

int get_root(int i, int wood[])
{
    if (wood[i] == -1)
    {
        return i;
    }
    return get_root(wood[i], wood);
}

int main()
{
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    int wood[n];
    int depth[n] = {0};
    rep(i, n) wood[i] = -1;

    int a, b;
    int friends[n] = {0};
    rep(i, m)
    {
        scanf("%d%d", &a, &b);
        a--;
        b--;
        friends[a]++;
        friends[b]++;
        a = get_root(a, wood);
        b = get_root(b, wood);
        if (depth[a] > depth[b])
            swap(a, b);
        if (a != b)
        {
            depth[b] = depth[b] > depth[a] + 1 ? depth[b] : depth[a] + 1;
            wood[a] = b;
        }
        // rep(i, n)
        // {
        //     printf("%d ", wood[i]);
        // }
        // printf("\n");
    }
    int group_num[n] = {0};
    rep(i, n)
    {
        int idx = get_root(i, wood);
        group_num[idx]++;
    }
    int ans[n] = {0};
    rep(i, k)
    {
        scanf("%d%d", &a, &b);
        a--;
        b--;
        if (get_root(a, wood) == get_root(b, wood))
        {
            ans[a]--;
            ans[b]--;
        }
    }
    rep(i, n)
    {
        printf("%d ", ans[i] + group_num[get_root(i, wood)] - friends[i] - 1);
    }
    printf("\n");
}

Measured memory_bytes: 2816
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int N,x,y=0;
  cin >> N;
  while(y<=N){
    x = y;
    if(x==N) break;
    while(x<N){
      x += 7;
    }
    if(x==N) break;
    y +=4;
  }
  if(x!=N){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

static const int yukati[] = {
	1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};

int main(void) {
	int K;
	if (scanf("%d", &K) != 1) return 1;
	if (K < 1 || (int)(sizeof(yukati) / sizeof(*yukati)) < K) {
		puts("f**k");
	} else {
		printf("%d\n", yukati[K - 1]);
	}
	return 0;
}


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

#define pb push_back
#define mp make_pair
#define F(i, a, n, b) for(int i=a;i<n;i+=b)
#define REVF(i, a, b, c) for(int i=a;i>=b;i-=c)
#define REP(i, n) F(i, 0, n, 1)
#define REP1(i, n) F(i, 1, n+1, 1)
#define REV(i, n) REVF(i, n, 0, 1)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define MOD 1000000007

typedef long long ll;

const ll MAX = 1e10 + 5;

string s;
map<string,int> m;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	m["SUN"] = 7; m["MON"] = 6; m["TUE"] = 5;
	m["WED"] = 4; m["THU"] = 3; m["FRI"] = 2;
	m["SAT"] = 1;
	cin>>s;
	cout<<m[s];
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	let T1 = parseInt(input[0][0], 10);
	let T2 = parseInt(input[0][1], 10);
	let A1 = parseInt(input[1][0], 10);
	let A2 = parseInt(input[1][1], 10);
	let B1 = parseInt(input[2][0], 10);
	let B2 = parseInt(input[2][1], 10);
	
	let d1 = BigInt(A1 - B1) * BigInt(T1);
	let d2 = BigInt(A2 - B2) * BigInt(T2) + d1;

	let ans = 0n;
	let tmp;
	if (d2 === 0n) ans = 'infinity';
	else if (d1 * d2 < 0n) {
		d2 = d2 * -1n;
		tmp = (d1 / d2);
		ans = (tmp * d2 === d1) ? tmp * 2n : tmp * 2n + 1n;		
	}
	else ans = 0;
	console.log(ans.toString());
}

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




Measured memory_bytes: 29548
#include <stdio.h>
#include <string.h>
#define N 2000000
#define M 20
int sum[N];
char num[M],tum[M];
int C(char x) {
  if(x=='A') return 1;
  if(x=='C') return 2;
  if(x=='G') return 3;
  return 4;
}
int search(int k, int x, int y, int t) {
  if(k==strlen(tum)) {
    if(!t) sum[x]=1;
    return sum[x];
  }
  return search(k+1,x+C(tum[k])*y,y*4,t);
}

int main() {
  int n;
  scanf("%d",&n);
  while(n--) {
    scanf("%s %s",num,tum);
    if(num[0]=='i') search(0,0,1,0);
    else {
      if(search(0,0,1,1)) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}



Measured memory_bytes: 7128
n=int(raw_input())
i = 1
print "",
while(i<=n):
    x=i
    if x%3 is 0:
        print i,
    elif x%10 is 3:
        print i,
    elif (x/10**1)%10 is 3:
        print i,
    elif (x/10**2)%10 is 3:
        print i,
    elif (x/10**3)%10 is 3:
        print i,
    elif (x/10**4)%10 is 3:
        print i,
    i = i+1

Measured memory_bytes: 4216
fun main( args : Array<String> ) {
  val bs = readLine()!!.split(" ").map { it.toInt() }
 
  bs.map { a ->
    when {
      listOf(1,3,5,7,8,10,12).contains(a) -> 0
      listOf(4,6,9,11).contains(a) -> 1
      listOf(2).contains(a) -> 2
      else -> null
    }
  }.let { 
    val (a, b) = it
    when {
      a == b -> "Yes"
      else   -> "No"
    }.let { 
      println( it )
    }
  }
}

Measured memory_bytes: 37936
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

vector<ll>path[101010];
vector<ll>node[101010];
ll flg[101010];
ll A[101010];
ll cnt = 0;

int main(){

    ll N, M;
    cin >> N >> M;
    rep(i, N)cin >> A[i];
    rep(i, M){
        ll x, y;
        cin >> x >> y;
        path[x].push_back(y);
        path[y].push_back(x);
    }
    rep(i, N){
        if(flg[i])continue;
        cnt++;
        flg[i] = cnt;
        stack<ll>S;
        S.push(i);
        while(!S.empty()){
            ll idx = S.top();
            S.pop();
            node[cnt].push_back(A[idx]);
            rep(j, path[idx].size()){
                ll to = path[idx][j];
                if(flg[to])continue;
                flg[to] = cnt;
                S.push(to);
            }
        }
    }
    if(cnt == 1){
        cout << 0 << endl;
        return 0;
    }
    ll sum = 0;
    vector<ll>v;
    rep1(i, cnt){
        sort(node[i].begin(), node[i].end());
        sum += node[i][0];
        for(ll j = 1; j < node[i].size(); j++)v.push_back(node[i][j]);
    }
    ll req = cnt - 2;
    if(v.size() < req){
        cout << "Impossible" << endl;
        return 0;
    }
    sort(v.begin(), v.end());
    rep(i, req)sum += v[i];
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 12532
N=int(input())
A=[]
for i in range(N):
  a=[int (i) for i in input().split()]
  A.append(a)
b=[]
for i in range(N):
  if A[i][0]>A[i][1]:
     b.append(A[i][1]-A[i][0]%A[i][1])
  else:
     b.append(A[i][1]-A[i][0])
b.reverse()
c=0
d=0
A.reverse()
for i in range(len(b)):
  d=b[i]-c
  c+=d%A[i][1]
print(c)

Measured memory_bytes: 25264
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 2e5+10;
inline char get() {
	static char buf[10000], *S = buf, *T = buf;
	if (S == T) {
		T = (S = buf) + fread(buf, 1, 10000, stdin);
		if (S == T) return EOF;
	}
	return *S++;
}
inline void read(int &x) {
	static char c; x = 0; int sgn = 0;
	for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
	for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
	if (sgn) x = -x;
}

ll t[N+1];
void upd(int x, ll v) {
  for (; x <= N; x += (x & -x)) t[x] = max(t[x], v);
}
ll query(int x) {
  ll ans = 0;
  for (; x; x -= (x & -x)) ans = max(ans, t[x]);
  return ans;
}

int n;
int h[N];
int a[N];
ll dp[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  read(n);
  for (int i = 0; i < n; i++) {
    read(h[i]);
  }
  for (int i = 0; i < n; i++) {
    read(a[i]);
  }
  dp[0] = a[0];
  upd(h[0], dp[0]);
  for (int i = 1; i < n; i++) {
    dp[i] = query(h[i]) + a[i];
    upd(h[i], dp[i]);
  }
  cout << *max_element(dp, dp + n) << nl;
  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<vector>
#include<climits>
#define ll long long int
using namespace std;
int main(void) {
  string s;
  char c[26]={0};
  cin>>s;
  for(auto i=s.begin(); i!=s.end(); i++) {
    if(c[(*i)-'a']==1) {
      cout<<"no"<<endl;
      return 0;
    } else c[(*i)-'a']=1;
  }
  cout<<"yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int N; cin >> N;
	vector<int> a(N);
	bool ok = true;
	int ans = mod;
	rep(i, N) {
		cin >> a[i];
		if (a[i] != a[0])ok = false;
	}
	if (ok) {
		cout << 0 << endl;
		return 0;
	}
	int minn = *min_element(a.begin(), a.end()), maxx = *max_element(a.begin(), a.end()), num;
	for (int i = minn; i <= maxx; ++i) {
		num = 0;
		for (int j = 0; j < N; ++j) {
			num += (a[j] - i)*(a[j] - i);
		}
		ans = min(ans, num);
	}
	cout << ans << endl;
	cin >> N;
}

Measured memory_bytes: 256
import sys 
sys.setrecursionlimit(1000000000)

class union_find:
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.size = [1 for i in range(N)]
        self.excluded = [0 for i in range(N)]
    
    def root(self, a):
        if self.par[a] == a:
            return a
        else:
            # 経路圧縮
            self.par[a] = self.root(self.par[a])
            return self.par[a]
    
    def same(self, a, b):
        return self.root(a) == self.root(b)
    
    def unite(self, a, b):
        if not self.same(a, b):
            self.size[self.root(b)] += self.get_union_size(a)
            self.par[self.root(a)] = self.root(b)
    
    def friend(self, a, b):
        self.unite(a, b)
        self.excluded[a] += 1
        self.excluded[b] += 1
    
    def block(self, a, b):
        if self.same(a, b):
            self.excluded[a] += 1
            self.excluded[b] += 1

    def get_union_size(self, a):
        return self.size[self.root(a)]
    
    def get_friend_sugestion_size(self, a):
        return self.get_union_size(a) - 1 - self.excluded[a]

N, M, K = map(int, input().split())
UF = union_find(N)
for i in range(M):
    A, B = map(int, input().split())
    UF.friend(A-1, B-1)
for i in range(K):
    A, B = map(int, input().split())
    UF.block(A-1, B-1)
print(*[UF.get_friend_sugestion_size(x) for x in range(N)])

Measured memory_bytes: 39216
import fractions
from functools import reduce

MOD = 10**9 + 7


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0


def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m


def main():
    N = int(input())
    AN = list(map(int, input().split()))

    AN_lcm = lcm_list(AN) % MOD

    ans = 0
    for A in AN:
        ans += AN_lcm * modinv(A, MOD)
        ans %= MOD

    print(ans)


main()


Measured memory_bytes: 68312
import sys
input = sys.stdin.readline
n = int(input())
C = [list(map(int,input().split())) for i in range(n)]

A = [0] * n
for i in range(n):
    if C[i][0] == C[i][1]:
        A[i] = 1

ans = 0
for i in range(n-2):
    if A[i]==1 and A[i+1]==1 and A[i+2]==1:
        ans = 1
if ans == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61996
#include <iostream>
using namespace std;
typedef long long ll;

const ll INF = 100000000000000000;

ll dp[302][302][302];

int main()
{
    ll n, k;
    cin >> n >> k;
    ll h[302] {0};
    for(int i = 1; i <= n; i++) cin >> h[i];
    for(int i = 0; i <= n; i++) for(int j = 0; j <= k; j++) for(int l = 0; l <= n; l++) dp[i][j][l] = INF;
    dp[0][0][0] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= i; j++){
            for(int l = 0; l <= i; l++){
                if(j > 0) dp[i][j][l] = min(dp[i][j][l], dp[i - 1][j - 1][l]);
                if(l == i){
                    if(i == j) continue;
                    for(int m = 1; m <= j + 1; m++){
                        if(h[i - m] >= h[i]) dp[i][j][l] = min(dp[i - m][j - m + 1][l - m], dp[i][j][l]);
                        else dp[i][j][l] = min(dp[i][j][l], dp[i - m][j - m + 1][l - m] + h[i] - h[i - m]);
                    }
                }
            }
        }
    }
    ll ans = INF;
    for(int j = 0; j <= k; j++){
        for(int l = 0; l <= n; l++) ans = min(ans, dp[n][j][l]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 215296
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, a: "List[int]"):
    print(max(a)-min(a))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
#define ALL(x) x.begin(), x.end()
 
typedef long long int lld;
typedef pair<int, int> pii;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;
 
	int n, m;
	cin >> n >> m;

	int cnt = 1, ans = 0;
	while (cnt < m) {
		cnt--;
		cnt += n;
		ans++;
	}

	cout << ans << '\n';
 
 
	return 0;
}

Measured memory_bytes: 256
// Think twice, Code once
// 1SAC
#include<bits/stdc++.h>
using namespace std;

/*============================ DEBUGGING =============================*/

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/*============================= DEFINES ==============================*/

#define eps 1e-9
#define mod 1000000007
#define pb emplace_back
#define mp make_pair
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define dig(n) (int)(log10(n)+1)
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define set(x,k) memset(x,k,sizeof x)
#define Sort(a) sort(a.begin(),a.end())

/*============================== TYPEDEFS ============================*/

typedef long long ll;
typedef long double ld;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<bool> vb;
typedef queue<int> qi;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;

/*============================ START FROM HERE =======================*/
bool is(str s,str t){
	int i=0,j=0;
	while(i!=SZ(s) && j!=SZ(t)){
		if(s[i]==t[j]){j++;i++;}
		else i++;
	}
	return (j==SZ(t));
}
int main(){
	FIO
	
	int n;cin>>n;
	str s;cin>>s;
	int ans=0;
	rep(i,0,1000){
		str x=tostr(i);
		if(SZ(x)<3){
			while(SZ(x)!=3)x="0"+x;
		}
		if(is(s,x))ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
class Program
{
    //static List<string> str = new List<string>();
	static void Main(string[] args)
	{
		// 入力フェーズ
				string[] input = Console.ReadLine().Split(' ');
				int N = int.Parse(input[0]);
				int Q = int.Parse(input[1]);
        string S = Console.ReadLine();
				int[] l = new int[Q];
				int[] r = new int[Q];
				for(int i=0; i<Q; i++)
				{
					input =Console.ReadLine().Split(' ');
					l[i] = int.Parse(input[0]);
					r[i] = int.Parse(input[1]);
				}

				// ?文字目からAC
				List<int> ac = new List<int>();
				//Console.WriteLine((N-1) + " len");
				for(int i=0; i<N - 1; i++)
				{
					//Console.WriteLine(S[i] + " " + S[i+1] + " " + i);
					if(S[i] == 'A' && S[i+1] == 'C')
					{
						ac.Add(i+1);
						//Console.Write((i+1)+" ");
					}
				}
				//Console.WriteLine();
				int len = ac.Count - 1;

				for(int i=0; i<Q; i++)
				{
					//各Qに答える
					if(len < 0)
					{
						Console.WriteLine("0");
						continue;
					}

					// l[i]より大きくて一番近い数字が入ってるac[?]を探す
					//Console.WriteLine(i + " l " + l[i]);
					int start = getStart(ac, l[i], 0, len);
					//Console.WriteLine(l[i] + " start " + start );

					// r[i]より小さくて一番近い数字が入ってるac[?]を探す
					//Console.WriteLine(i + " r " + r[i]);
					int end = getEnd(ac, r[i] - 1, 0, len);

					//Console.WriteLine(r[i] + " end " + end );
					Console.WriteLine((end - start + 1));
				}
    }

		static int getStart(List<int> ac, int l, int str, int end)
		{
			if(end - str <= 1)
			{
				if(ac[str] >= l) return str;
				else if(ac[end] >= l) return end;
				else return end+1;
			}

			int mid = (str + end) / 2;
			// Console.WriteLine("chukan " + l + " " + str + " " + end);//+ ((str+end)/2) + ac[(str+end)/2]);
			if(ac[mid] < l)
			{
				return getStart(ac, l, mid, end);
			}
			else
			{
				return getStart(ac, l, str, mid);
			}
		}
		static int getEnd(List<int> ac, int r, int str, int end)
		{
			if(end - str <= 1)
			{
				if(ac[end] <= r) return end;
				else if(ac[str] <= r) return str;
				else return str - 1;
			}

			int mid = (str + end) / 2;
			// Console.WriteLine("chukan2 " + ((str+end)/2) + ac[(str+end)/2]);
			if(ac[mid] > r)
			{
				return getEnd(ac, r, str, mid);
			}
			else
			{
				return getEnd(ac, r, mid, end);
			}
		}

}


Measured memory_bytes: 17348
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <math.h>
#include <sstream>
#include <iomanip>
#define REP(i,n,s) for (int i = (s);i < (int)( n ); i++)
#define REP0(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
using namespace std;

ll i,j;
const int MOD = 1000000000 + 7;
const int MOD2 = 998244353;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint=Fp<MOD2>;

int main(){
    int n,k;
    ll ans=0;
    vector<int> s;
    cin>>n>>k;
    
    
    int l[k],r[k];
    REP(i,k,0){
        cin>>l[i]>>r[i];
    }
    vector<mint> dp(n+1,0);
    REP(i,n+1,0)dp[i]=0;
    dp[1]=1;
    dp[2]=-1;

    REP(i,n+1,1){
        dp[i]+=dp[i-1];
        REP(j,k,0){
            if(i+l[j]<=n){
                dp[i+l[j]]+=dp[i];
                // cout<<"dp["<<i+l[j]<<"]:"<<dp[i+l[j]]<<"\n";
            }
            if(i+r[j]<n){
                dp[i+r[j]+1]-=dp[i];
                // cout<<"dp["<<i+r[j]+1<<":"<<dp[i+r[j]+1]<<"\n";
            }
        }
    }
   
    // REP(i,n+1,0)cout<<dp[i]<<" ";
    cout<<dp[n]<<'\n';
    return 0;
}

Measured memory_bytes: 4852
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   int n = Integer.parseInt(br.readLine());
   int TarouP = 0;//???????????????
   int HanakoP = 0;//??±????????????

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

	   String[] token = br.readLine().split(" ");
           
           //??????:0?????±???:1
	   if(  token[0].compareTo( token[1] ) > 0 ){//compareTo??§?????????????£???????????????§?????§?°???§????????§??????

	       TarouP += 3;//

	   }else if(token[0].compareTo( token[1] ) < 0 ){

		   HanakoP += 3;

	   }else{
		   TarouP++;
		   HanakoP++;
	   }


   }

   System.out.println(TarouP+" "+HanakoP);

  }
}

Measured memory_bytes: 25012
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N;
  cin >> N;
  long long K;
  cin >> K;
  long long mx = 0, g = 0;
  for (int i = 0; i < N; i++) {
    long long A;
    cin >> A;
    mx = max(mx, A);
    g = __gcd(g, A);
  }
  cout << (mx >= K && K % g == 0 ? "POSSIBLE" : "IMPOSSIBLE") << '\n';
  return 0;
}


Measured memory_bytes: 3648
N, K = map(int, input().split())
s = input() + "#"

pre, cons, comp = '#', 0, [(0, -1)]
for i in range(len(s)):
    if pre != '#' and pre != s[i]:
        if cons > 0:
            # print(cons, s[i-1])
            comp.append((cons, s[i-1]))
            cons = 1
    else:
        cons += 1

    pre = s[i]

acc = [0 for _ in range(len(comp))]
for i in range(1, len(comp)):
    acc[i] = acc[i-1] + comp[i][0]

ans = 0
for i in range(len(comp) - 1):
    lim = len(comp) - 1
    if comp[i+1][1] == '1':
        lim = min(lim, i + 2*K + 1)
    else:
        lim = min(lim, i + 2*K)
    # print("i = {}, lim = {}".format(i, lim))
    ans = max(ans, acc[lim] - acc[i])

print(ans)


Measured memory_bytes: 14328
#include <stdio.h>

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

  while (n > 0) {
    if (n % 7 == 0) {
      break;
    }
    n -= 4;
  }
  if (n >= 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


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

int main()
{
    int A,B;
    scanf("%d%d",&A,&B);
        if((A+B)%3==0)
            printf("Possible");
        if((A+B)%3!=0)
        {
            if((A%3==0)||(B%3==0))
            {

                printf("Possible");
            }
            if((A%3!=0)&&(B%3!=0))
            {
               printf("Impossible");
            }
        }

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	lint INF = 10000000000000;
	lint N;
	cin >> N;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	vector<lint>B(N,INF);
	lint Q;
	cin >> Q;
	lint b, m, e;
	rep(t, Q) {
		cin >> b >> m >> e;
		for (lint i = 0; i < e - b; i++) {
			B[b + ((i + (e - m)) % (e - b))] = A[b + i];
		}
		rep(i, N) {
			if (B[i] == INF) {
				B[i] = A[i];
			}
		}
		rep(i, N) {
			A[i] = B[i];
		}
		rep(i, N) {
			B[i] = INF;
		}
	}
	rep(i, N) {
		cout << A[i];
		if (i != N - 1) {
			cout << ' ';
		}
		else {
			cout << endl;
		}
	}
}




Measured memory_bytes: 3128
#include <stdio.h>
int main()
{
    int a, b, c, d, e, ans;
    scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
    ans = (15 - (a + b + c + d + e));
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)

using namespace std;

void solve() {
	string a, b;
	cin >> a >> b;
	
	int l1 = a.length();
	int l2 = b.length();
	
	a = '/' + a;
	b = '/' + b;
	vector <vector <int>> dp(l1 + 1, vector <int > (l2 + 1, 0));

	rep(i, 1, l1 + 1) {
		rep(j, 1, l2 + 1) {
			if(a[i] == b[j]) dp[i][j] = 1 + dp[i - 1][j - 1];
			else dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
		}
	}
	int flag = 0;
	string s = "";
	int i = l1, j = l2;
	while(i > 0 and j > 0) {
		if(a[i] == b[j]) {
			s += a[i];
			--i, --j;
		}
		else {
			if(dp[i - 1][j] > dp[i][j - 1]) 
				--i;
			else
				--j;
		}
	}
	reverse(s.begin(), s.end());
	cout << s << endl;

}

int main() {
	int t = 1;
	//cin >> t;
	while(t--)
		solve();

	return 0;
}


Measured memory_bytes: 35584
#include <stdio.h>

int main(void){

  double a1,b1;

  scanf("%lf %lf", &a1, &b1);

  if(a1 < b1){
    printf("a < b\n");
  }else if(a1 > b1){
    printf("a > b\n");
  }else{
    printf("a == b\n");
  }

  return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define DEBUG_VARIABLE(variable) cout << #variable << ":" << variable << endl

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
#define INF (1 << 9)
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

void printArray(int *array, int);
void printVector(Vector &v);
void printDimention(DVector &dv);

int cnt;
void dfs_visit(int u){
    //int v;
    color[u] = GRAY;
    //DEBUG_VARIABLE(u);
    rep(v, n){
        if(!M[u][v])    continue;
        
        if(color[v] == WHITE){
            dfs_visit(v);
        }
    }
    color[u] = BLACK;
}

bool flg;
void dfs(){
    rep(i, n)   color[i] = WHITE;
    flg = true;
    dfs_visit(0);
    //printArray(color, n);
    rep(i, n){
        if(color[i] != BLACK){
            flg = false;
            break;
        }
    }
    if(!flg) cnt++;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int m;
    cin >> n >> m;
    int a[m], b[m];
    rep(i, m){
        cin >> a[i] >> b[i];
        M[a[i] - 1][b[i] - 1] = M[b[i] - 1][a[i] - 1] = 1;
    }
    
    rep(i, m){
        M[a[i] - 1][b[i] - 1] = M[b[i] - 1][a[i] - 1] = 0;
        dfs();
        M[a[i] - 1][b[i] - 1] = M[b[i] - 1][a[i] - 1] = 1;
    }
    cout << cnt << endl;
}

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

//Vectorの表示
void printVector(Vector &v){
    rep(i, (int)v.size()){
        if(i)   cout << " ";
        cout << v[i];
    }
    cout << endl;
}

//二次元配列の表示
void printDimention(DVector &dv){
    rep(i, (int)dv.size()){
        rep(j, (int)dv[i].size()){
            if(j)   cout << " ";
            cout << dv[i][j];
        }
        cout << endl;
    }
}

//numの中に何個2がかかってるか
int factor2(int num){
    int cnt = 0;
    while(num % 2 == 0){
        num /= 2;
        cnt++;
    }
    return cnt;
}

Measured memory_bytes: 256
A, B, C, X, Y = list(map(int, input().split()))

if A+B > C * 2:
    if X > Y:
        X, Y = Y, X
        A, B = B, A
    if C * 2 < B:
        print(Y*C*2)
    else:
        print(X*C*2 + (Y-X)*B)
else:
    print(X*A + Y*B)

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

typedef long long ll;

const int MAX_N=2e5;

int N,P[MAX_N];

int inx[MAX_N+1],dp[MAX_N+1];

int main(){
	cin>>N;
	REP(i,N){
		cin>>P[i];
	}
	REP(i,N){
		inx[P[i]]=i;
	}
	int ans=1;
	dp[1]=1;
	FOR(i,2,N+1){
		if (inx[i-1]<inx[i]){
			dp[i]=dp[i-1]+1;
		}else{
			dp[i]=1;
		}
		ans=max(ans,dp[i]);
	}
	cout<<N-ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
import java.util.*;

class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 1; i < n-1; i++) {
            if (p[i] > p[i-1] && p[i] <= p[i+1]) {
                count++;
                continue;
            }
            if (p[i] <= p[i-1] && p[i] > p[i+1]) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
x = input()
valuses = ['a',	'b',	'c',	'd',	'e',	'f',	'g',	'h',	'i',	'j',	'k',	'l',	'm',	'n',	'o',	'p',	'q',	'r',	's',	't',	'u',	'v',	'w',	'x',	'y',	'z']
for i in range (25):
    if x == valuses[i]:
        print(valuses[i + 1])

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){
    int cnt=0,flag=0;
    char s[4];

    for(int i=0;i<4;i++){
        cin>>s[i];
    }

    for(int i=1;i<4;i++){
        if(s[0]!=s[i]){
            cnt++;
        }
    }

        for(int i=0;i<1;i++){
        if(s[1]!=s[i]){
            cnt++;
        }
    } 
        for(int i=2;i<4;i++){
        if(s[1]!=s[i]){
            cnt++;
        }
    }

        for(int i=0;i<2;i++){
        if(s[2]!=s[i]){
            cnt++;
        }
    }

        for(int i=3;i<4;i++){
        if(s[2]!=s[i]){
            cnt++;
        }
    }

        for(int i=0;i<3;i++){
        if(s[3]!=s[i]){
            cnt++;
        }
    }

    if(cnt==8){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

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

using namespace std;

bool is_travelable(int t_s, int x_s, int y_s, int t_g, int x_g, int y_g) {
  int time = t_g - t_s;
  int dis = abs(x_g - x_s) + abs(y_g - y_s);
  if (dis > time) return false;

  // 目的地まで届くが、タイミングがどうか
  int rest = time - dis;
  if (rest % 2 == 0)
    return true;
  else
    return false;
}

int main() {
  int N;
  cin >> N;
  int t, x, y;
  t = 0;
  x = 0;
  y = 0;

  for (int i = 0; i < N; ++i) {
    int t_i, x_i, y_i;
    cin >> t_i >> x_i >> y_i;
    if (is_travelable(t, x, y, t_i, x_i, y_i) == false) {
      cout << "No" << endl;
      return 0;
    }
    t = t_i;
    x = x_i;
    y = y_i;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	static int[] arrayA = {1,3,5,7,9,11,15,17,19,21,23,25};
	static int[] arrayB = new int[26];
	static String[][] arrayThat;
	static String[][] arrayThis;
	static char[] decode = new char[26+'a'];

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		
		for(int i = 0; i < 26 ; i++){
			arrayB[i] = i;
		}
		
		initThatandThis();
		
		for(int i = 0; i < n ;i++){
			String tmp = br.readLine();
			String[] input = tmp.split(" ");

			int[] ab = null;
			for(int j = 0; j < input.length ; j++){
				
				if(input[j].length() == 4){
					ab = checkDecodable(input[j]);
				}
				
				if(ab != null){
					break;
				}
			}
			
			//System.out.println(ab[0] + " " + ab[1]);
			
			for(int j = 0; j < 26 ; j++){
				decode[(ab[0] * j + ab[1])%26 + 'a'] = (char)('a' + j);
			}
			
			for(int j = 0; j < tmp.length(); j++){
				if(tmp.charAt(j) >= 'a' && tmp.charAt(j) <= 'z'){
					System.out.print(decode[tmp.charAt(j)]);
				}
				else {
					System.out.print(tmp.charAt(j));
				}
			}
			System.out.println();
		}
	}
	
	static int[] checkDecodable(String str){
		int[] result = new int[2];
		for(int i = 0; i < arrayA.length ; i++){
			for(int j = 0; j < arrayB.length ; j++){
				if(str.equals(arrayThat[i][j]) || str.equals(arrayThis[i][j])){
					result[0] = arrayA[i];
					result[1] = arrayB[j];
					return result;
				}
			}
		}
		
		return null;
	}
	
	static void initThatandThis(){
		arrayThat = new String[arrayA.length][arrayB.length];
		arrayThis = new String[arrayA.length][arrayB.length];
		for(int i = 0; i < arrayA.length ; i++){
			arrayThat[i] = new String[arrayB.length];
			arrayThis[i] = new String[arrayB.length];
			for(int j = 0; j < arrayB.length ; j++){
				char[] tmpThis = {'t','h','i','s'};
				char[] tmpThat = {'t','h','a','t'};
				
				for(int k = 0; k < 4; k++){
					tmpThis[k] = (char)((arrayA[i]*(tmpThis[k] - 'a') + arrayB[j])%26 + 'a');
					tmpThat[k] = (char)((arrayA[i]*(tmpThat[k] - 'a') + arrayB[j])%26 + 'a');
				}
				
				arrayThat[i][j] = new String(tmpThat);
				arrayThis[i][j] = new String(tmpThis);
				
				//System.out.println(arrayA[i] + " " + arrayB[j] + " " + arrayThat[i][j] + " " + arrayThis[i][j]);
			}
		}
	}

}

Measured memory_bytes: 25132
import sys
input = lambda: sys.stdin.readline().rstrip()

def calc():
    def mex(i):
        t = 0
        for j in X[i]:
            t |= 1 << G[j]
        t = ~t
        return (t & -t).bit_length() - 1
    M = int(input())
    X = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        X[N - min(a, b)].append(N - max(a, b))
    G = [0] * N
    for i in range(N):
        G[i] = mex(i)
    H = [0] * 1024
    a = 1
    for i in range(N)[::-1]:
        a = a * A % P
        H[G[i]] = (H[G[i]] + a) % P
    return H

P = 998244353
A = pow(10, 18, P)
N = int(input())
H1, H2, H3 = calc(), calc(), calc()
ans = 0
for i in range(1024):
    if H1[i] == 0: continue
    for j in range(1024):
        if H2[j] == 0: continue
        ans = (ans + H1[i] * H2[j] * H3[i^j]) % P

print(ans)

Measured memory_bytes: 69808