akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N,a,b;cin>>N;
  vector<lvector> G(N);
  vector<P> pv(N-1);
  rep(i,N-1) {
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b),G[b].emplace_back(a);
    pv[i]=P{a,b};
  }
  ll K=0;
  map<P,ll> mp;
  lvector cs(N,0),used(N,0); used[0]=1;
  queue<ll> q; q.emplace(0);
  while(q.size()) {
    ll v=q.front(); q.pop();
    if(K<G[v].size()) K=G[v].size();
    ll color=1;
    for(ll u:G[v]) {
      if(used[u]) continue;
      if(color==cs[v]) color++;
      cs[u]=color; mp[P{u,v}]=color; mp[P{v,u}]=color; color++;
      used[u]=1;
      q.emplace(u);
    }
  }
  print(K);
  for(P p:pv) print(mp[p]);
  return 0;
}

Measured memory_bytes: 22144
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>

using namespace std;

int main() {

	int D, N;
	cin >> N >> D;

	vector<int> vNum(D, 0);
	vector<vector<int>> vNumList(N, vNum);

	for (int i = 0; i < vNumList.size(); i++)
	{
		for (int j = 0; j < vNumList[i].size(); j++)
		{
			cin >> vNumList[i][j];
		}
	}

	int result = 0;
	for (int i = 0; i < vNumList.size(); i++)
	{
		for (int j = 0; j < vNumList.size(); j++)
		{
			if (i == j)
			{
				continue;
			}
			long double dis = 0;
			for (int k = 0; k < D; k++)
			{
				dis += pow(abs(vNumList[i][k] - vNumList[j][k]), 2);
			}
			dis = sqrtl(dis);
			if (floorl(dis) == ceill(dis))
			{
				++result;
			}
		}
	}


	cout << result/2 << 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 < (int)(n); i++)

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

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

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

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for(int i=1; i<N; i++){
        for(int j=1; j<=K; j++){
            if(i-j<0)break;
            chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    // 答え
    cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 1792
fun main() = abc167e()

@OptIn(ExperimentalStdlibApi::class)
fun abc167e() {
    val (n, m, k) = readLine()!!.split(' ').map { it.toInt() }

    val biCoef = BiCoef(n)
    var answer = Mint()

    for (x in 0..k) {
        answer += Mint(m.toLong()) * modPow(m - 1L, n - x - 1L) * biCoef.nCr(n - 1, x)
    }

    println(answer)
}

private const val MOD = 998244353L

private fun modPow(n: Long, p: Long): Long {
    var x = n
    var y = p
    var result = 1L
    x %= MOD
    while (y > 0) {
        if (y % 2 == 1L)
            result = (result * x) % MOD
        y = y shr 1
        x = (x * x) % MOD
    }
    return result
}


@Suppress("unused")
private class BiCoef(max: Int) {
    private val fact = LongArray(max + 1)
    private val fInv = LongArray(max + 1)
    private val inv = LongArray(max + 1)

    init {
        fact[0] = 1
        fact[1] = 1
        fInv[0] = 1
        fInv[1] = 1
        inv[1] = 1
        for (i in 2..max) {
            fact[i] = fact[i - 1] * i % MOD
            inv[i] = MOD - inv[(MOD % i).toInt()] * (MOD / i) % MOD
            fInv[i] = fInv[i - 1] * inv[i] % MOD
        }
    }

    fun fact(n: Int): Long = if (n < 0) 0 else fact[n]
    fun inv(n: Int): Long = if (n < 0) 0 else inv[n]
    fun fInv(n: Int): Long = if (n < 0) 0 else fInv[n]
    fun comb(n: Int, k: Int): Long = nCr(n, k)
    fun nCr(n: Int, k: Int): Long = if (n < k || n < 0 || k < 0) 0 else fact[n] * (fInv[k] * fInv[n - k] % MOD) % MOD
    fun perm(n: Int, k: Int): Long = nPr(n, k)
    fun nPr(n: Int, k: Int): Long = if (n < k || n < 0 || k < 0) 0 else fact[n] * fInv[n - k] % MOD % MOD
}

private fun mintOf(other: Long = 0L) = Mint(other)

private class Mint(value: Long = 0L) {
    constructor(other: Mint) : this(other.value)

    private val value = if (value < 0) (value % MOD) + MOD else value % MOD
    operator fun unaryPlus() = this
    operator fun unaryMinus() = Mint(MOD - this.value)
    operator fun inc() = this.plus(1)
    operator fun dec() = this.minus(1)
    operator fun plus(other: Long) = Mint(this.value + other)
    operator fun plus(other: Mint) = this.plus(other.value)
    operator fun minus(other: Long) = Mint(this.value - other)
    operator fun minus(other: Mint) = this.plus(-other)
    operator fun times(other: Long) = Mint(this.value * other)
    operator fun times(other: Mint) = this.times(other.value)
    operator fun div(other: Long) = this.times(modPow(other, MOD - 2))
    operator fun div(other: Mint) = this.div(other.value)
    fun mod(mod: Long) = Mint(this.value % mod)
    fun modPow(other: Long) = Mint(modPow(this.value, other))
    override fun toString() = this.value.toString()
    override fun hashCode() = value.hashCode()
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false
        other as Mint
        return value == other.value
    }
}


Measured memory_bytes: 56324
require 'prime'

n = gets.to_i
mem = {}
ans = 0
if Prime.prime?(n)
  ans = 1
else
  loop do
    last = n
    Prime.each do |pr|
      mem[pr] ||= 1
      z = pr**mem[pr]
      if n % z == 0
        n /= z
        mem[pr] += 1
        ans += 1
        break
      end
      break if n < pr
    end
    if Prime.prime?(n)
      ans += 1 unless mem[n]
      break
    end
    break if last == n
  end
end
puts ans

Measured memory_bytes: 40788
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = r*r*pi;
        double cir = 2*pi*r;
        System.out.printf("%f %f",area,cir);
    }
}


Measured memory_bytes: 28392
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
vector<int> attack[300000];
int visited[300000];
int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << "First" << endl;
		return 0;
	}
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		attack[a].push_back(b);
		attack[b].push_back(a);
	}
	int next_itr = 0;
	queue<int> next;
	next.push(1);
	visited[1] = 1;
	while (next.empty() == false) {
		next_itr = next.front();
		next.pop();
		REP(i, attack[next_itr].size()) {
			if (visited[attack[next_itr][i]] == 0) {
				visited[attack[next_itr][i]] = visited[next_itr] + 1;
				next.push(attack[next_itr][i]);
			}
		}
	}
	REP(i, n + 1) {
		visited[i] = 0;
	}
	visited[next_itr] = 1;
	next.push(next_itr);
	while (next.empty() == false) {
		next_itr = next.front();
		next.pop();
		REP(i, attack[next_itr].size()) {
			if (visited[attack[next_itr][i]] == 0) {
				visited[attack[next_itr][i]] = visited[next_itr] + 1;
				next.push(attack[next_itr][i]);
			}
		}
	}
	int maximum = 0;
	REP(i, n + 1) {
		maximum = max(maximum, visited[i]);
	}
	maximum -= 2;
	if (maximum % 3 == 0) {
		cout << "Second" << endl;
	}
	else cout << "First" << endl;
	return 0;
}

Measured memory_bytes: 15988
#pragma region
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define dump(x) cerr << #x << " = " << x << endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);
int dig(int n){return (int)(log10(n) + 1);}
int abc(char x){return (int)(x)-(int)('a');} // 0~25
char abc(int x){return (char)(x+(int)('a'));} 
int ABC(char x){return (int)(x)-(int)('A');}
char ABC(int x){return (char)(x+(int)('A'));}
void solve();
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}
#pragma endregion

void solve() {
	int N, K;
	int ans = 0;
	int tmp = 0;
	int f = 1;
	string S;
	cin >> N >> K;
	ans = min(abs(N % K), abs(N % K - K));
	cout << ans << endl;
	//if (ans >= M) cout << "Yes" << endl;
	//else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
 
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);

    ll x; cin >> x;
    ll base = 100, ans = 0;
    while (base < x) {
        ++ans;
        base += base/100;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
using ll=long long;
#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REP1(i, n)  for(int i = 1; i < (int)n; ++i)
#define REPll1(i, n)  for(ll i = 1; i*i < (int)n; ++i)
char alphabet[26] = {'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'};

int cnt(ll n) {
    int c = 0;
    while (true) {
        if (n < 1)break;
        n = n / 10;
        c++;
    }
    return c;
}

const ll MAX1E5 = 100000;
const ll MAX1E10 = 10000000000;
const double mod = 1e9 + 7;

int main() {
    ll N = 0, K = 0, answer = 0, sum1 = 0, sum2 = 0, tmp = 0;
    ll cnt1 = 0, cnt2 = 0, a = 0, b = 0;
    cin >> N >> K;
    ll A[MAX1E5+1] = {};
    REP(i, N) {
        cin >> a >> b;
        A[a] += b;
    }
    REP1(i, MAX1E5+1) {
        
        if (K <= A[i]) {
            cout << i << endl;
            return 0;
        }
      	K -= A[i];
    }

}


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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+5, mod = 1e9+7;

void solve() {
    int n; cin >> n;
    
    if (n >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1; 
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using Edge = pair<int, int>;


vector<vector<Edge>> G;
vector<int> dist;
vector<bool> seen;
bool ans = true;

void dfs(int v){
    for(auto e : G[v]){
        int nv = e.first;
        int cost = e.second;
        if(seen[nv]){
            //矛盾
            if(dist[nv] != dist[v] + cost) ans = false;
        }else{
            dist[nv] = dist[v] + cost;
            seen[nv] = true;
            dfs(nv);
        }
    }
}

int main(){
    int n, m; cin >> n >> m;
    G.resize(n);
    dist.assign(n, 0);
    seen.assign(n, 0);
    rep(i,m) {
        int l, r, d; cin >> l >> r >> d;
        --l, --r;
        G[l].push_back(Edge(r, d));
        G[r].push_back(Edge(l, -d));
    }
    rep(i,n){
        if(!seen[i]){
            dist[i] = 0;
            seen[i] = true;
            dfs(i);
        }  
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 12032
n,m,q=map(int,input().split())
d=[[0 for _ in range(n+1)] for _ in range(n+1)]

for _ in range(m):
  l,r=map(int,input().split())
  d[l][r]+=1

for y in range(1,n+1):
  for x in range(1,n+1):
    d[y][x]+=(d[y][x-1]+d[y-1][x]-d[y-1][x-1])

for _ in range(q):
  p,q=map(int,input().split())
  print(d[q][q]-d[q][p-1]-d[p-1][q]+d[p-1][p-1])

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

int main() {
 string input; cin >> input;
 string check = "ACGT";
 
 int ans = 0;
 int tempAns = 0;
 for(int i = 0; i < input.length(); i++) {
  if(check.find(input.at(i)) != std::string::npos) {
   tempAns++;
  } else {
   tempAns = 0;
  }
   if( ans < tempAns) {
     ans = tempAns;
   }
 }
  
  cout << ans << endl;
  
  return 0;
}

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


int main(){
  int n, dx, dy;
  int px, py;
  long long int mdis, dis;
  int mpx, mpy;
  cin>> n;
  for(int i = 0;i < n;i++){
    px = py = 0;
    mdis = 0;
    do{
      cin >> dx >> dy;
      px += dx; py += dy;
      dis = pow(px,2)+pow(py,2);
      if( mdis < dis){
        mpx = px;mpy = py;
        mdis = dis;
      }else if(mdis == dis && mpx < px){
        mpx = px;mpy = py;
      }
    }while(dx||dy);
    cout << mpx << " " << mpy << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n, m;
    cin >> n >> m;

    vector<int> p(1 << n, (1 << 30) - 1);
    p[0] = 0;
    for (int j = 0; j < m; j++) {
        int a, b;
        cin >> a >> b;

        int t = 0;
        for (int i = 0; i < b; i++) {
            int c;
            cin >> c;
            c--;

            t ^= 1 << c;
        }
        if (a < p[t]) p[t] = a;
    }

    for (int i = 1; i < n; i++) {
        for (int l = 0; l < 1 << n; l++) {
            for (int k = 0; k < 1 << n; k++) {
                int t = l | k;
                if (p[l] + p[k] < p[t]) p[t] = p[l] + p[k];
            }
        }
    }

    int r = p[(1 << n) - 1];
    cout << (r == (1 << 30) - 1 ? -1 : r) << endl;

    //2^n通りの鍵しかない
    //その開け方を実現する最小コストでDP
    //1個しか開けられないのは確定 2個のやつは1個と1個に分割できるかも 3個のやつは、2個以下の2つの組み合わせを全探索 12個までやる

    return 0;
}

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

int main(){
  long long trudy = 1000000007;
  long long n;
  cin >> n;
  long long zero[61], ichi[61];
  for(int i=0; i<=60; i++){
    zero[i] = 0;
    ichi[i] = 0;
  }
  for(long long i=0; i<n; i++){
    long long num;
    cin >> num;
    for(long long j=0; j<=60; j++){
      if(num & ((long long)1 << j)) ichi[j]++;
      else zero[j]++;
    }
  }
  long long sum = 0;
  for(long long i=0; i<=60; i++){
    long long temp = zero[i] * ichi[i];
    temp %= trudy;
    temp *= (((long long)1 << i) % trudy);
    temp %= trudy;
    sum += temp;
    sum %= trudy;
  }
  cout << sum << endl;
  return 0;
}
      
      



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void) {
    int a,b,temp;
    while (1) {
        scanf("%d%d", &a,&b);
        if (a == 0 && b==0)break;
        if (a > b) {
            temp = a;
            a = b;
            b = temp;
        }
        printf("%d %d\n", a,b);
        
    }
    return 0;
}


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

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector< vector<int> > S(M);
    for(int i=0; i<M; i++) {
        int k;
        cin >> k;
        while(k--) {
            int s;
            cin >> s;
            S[i].push_back(--s);
        }
    }
    vector<int> p(M);
    for(int i=0; i<M; i++) {
        cin >> p[i];
    }

    int ans = 0;
    for(int bit=0; bit<(1<<N); bit++) {
        int lamp = 0;
        for(int i=0; i<M; i++) {
            int cnt = 0;
            for(auto e: S[i]) {
                if((bit>>e) & 1) {
                    cnt++;
                }
            }
            if(cnt%2 == p[i]%2) {
                lamp++;
            }
        }
        if(lamp == M) {
            ++ans;
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int maxn = 2e5 + 5;
 
int n;
int c[maxn];
vector<int> G[maxn];
 
int sz[maxn];
int tot;
int cnt[maxn];
typedef long long ll;
 
ll ans[maxn];
 
void dfs(int u, int fa){
    sz[u] = 1;
    int in = cnt[c[u]]; 
    for(auto v : G[u]){
        if(v == fa)
            continue;
        int front = tot - cnt[c[u]];
        dfs(v, u);
        sz[u] += sz[v];
        int back = tot - cnt[c[u]];
        ans[c[u]] -= 1LL * (back - front) * (back - front + 1) / 2;
    } 
    tot++;
    cnt[c[u]] = in + sz[u];
}
 
int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> c[i];
    }
    for(int i = 1;i < n;i++){
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1, 1);
    for(int i = 1;i <= n;i++){
        ans[i] -= 1LL * (n - cnt[i]) * (n - cnt[i] + 1) / 2;
        ans[i] += 1LL * n * (n + 1) / 2;
    }
    for(int i = 1;i <= n;i++){
        cout << ans[i] << endl;
    }
    return 0;
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  int n;
  string ans="Three";
  char x;
  cin>>n;
  r(i,n){
    cin>>x;
    if(x=='Y'){ans="Four";break;}

  }
  cout<<ans<<endl;

return 0;}


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

int main(){
  string S;
  cin>>S;
  if(S.at(2)==S.at(3)&&S.at(4)==S.at(5)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readLine()?.split(" ")?.map { it.toInt() } ?: return
    val diff = Math.abs(n - m)
    if (diff >= 2) {
        println(0)
        return
    }
    val key = (Math.pow(10.0, 9.0) + 7).toLong()
    var pN = 1L
    var pM = 1L

    for (i in n downTo 2) {
        pN = (pN * i) % key
    }
    for (i in m downTo 2) {
        pM = (pM * i) % key
    }

    val result = if (diff == 1) {
        (pN * pM) % key
    } else {
        (((pN * pM) % key) * 2) % key
    }
    println(result)
}

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

using namespace std;

int main() {
  int H1, M1, H2, M2, K;
  
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  
  int can = (H2 - H1) * 60 + M2 - M1;
  
  cout << (K <= can ? can - K : 0) << endl;
  
  return 0;
}

Measured memory_bytes: 3608
#include <cstdio>

#define MAXN 100009

int ans[MAXN+1], par[MAXN+1], impar[MAXN+1];

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

    for(int i=1; i<=m; i++){
        int x;
        scanf("%d", &x);

        if(x%2) impar[++impar[0]]=x;
        else par[++par[0]]=x;
    }

    if(impar[0]>2) printf("Impossible\n");
    else{
        int tr=0;
        if(impar[0]>0){
            if(impar[1]>1)
                ans[++ans[0]]=impar[1]-1;
            tr=1;
        }

        for(int i=1; i<=par[0]; i++){
            if(tr==0){
                ans[++ans[0]]=par[i]-1;
                tr=1;
            }else ans[++ans[0]]=par[i];
        }

        if(impar[0]>1) ans[++ans[0]]=impar[2]+1;
        else ans[++ans[0]]=1;

        if(impar[0]>0) printf("%d ", impar[1]);
        for(int i=1; i<=par[0]; i++)
            printf("%d ", par[i]);
        if(impar[0]>1) printf("%d ", impar[2]);
        printf("\n%d\n", ans[0]);
        for(int i=1; i<=ans[0]; i++)
            printf("%d ", ans[i]);
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long
				
int32_t main() {
	fast_cin();  
	int n; cin >> n;
	vector<int> a(n + 1, 0);
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	set<int> st[20];
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < 20; ++j) {
			if ((1LL << j) & a[i]) {
				st[j].insert(i);
			}
		}
		int l = 1;
		for (int j = 0; j < 20; ++j) {
			if ((int)st[j].size() >= 2) {
				auto it = st[j].rbegin();
				++it;
				l = max(l, *it + 1);
			}
		}
		ans += (i - l + 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 95616
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long int lli;
using namespace std;
lli LARGE_NUM = 1000000007;

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

    // 素数を求める
    int Z[101] = {};
    for (int i = 2; i <= N; i++) {
        if (Z[i] == 0 && i + i <= N) {
            int n = i;
            do {
                n += i;
                Z[n] = 1;
            } while (n + i <= N);
        }
    }

    int num_pri = 0;
    vector<int> pri;
    for (int i = 2; i <= N; i++) {
        if (Z[i] == 0) {
            pri.push_back(i);
            ++num_pri;
        }
    }

    // N! = P(p^index)で表す
    vector<int> index(pri.size(), 0);
    for (int i = 2; i <= N; i++) {
        int n = i;
        for (int j = 0; j < num_pri; j++) {
            while (n % pri[j] == 0) {
                index[j] += 1;
                n /= pri[j];
            }
        }
    }

    // 75個約数を持つものを探す。N=100で2が97個。
    // これは、{74}, {24, 2}, {14, 4}, {4, 4, 2} の4通りだけ
    int ans = 0;
    // {74}
    for (int i = 0; i < num_pri; i++) {
        if (index[i] >= 74) ++ans;
    }

    // {24, 2}
    for (int i = 0; i < num_pri; i++) {
        if (index[i] >= 24) {
            for (int j = 0; j < num_pri; j++) {
                if (i == j) continue;
                if (index[j] >= 2) ++ans;
            }
        }
    }

    // {14, 4}
    for (int i = 0; i < num_pri; i++) {
        if (index[i] >= 14) {
            for (int j = 0; j < num_pri; j++) {
                if (i == j) continue;
                if (index[j] >= 4) ++ans;
            }
        }
    }

    // {4, 4, 2}
    for (int i = 0; i < num_pri; i++) {
        if (index[i] >= 4) {
            for (int j = i + 1; j < num_pri; j++) {
                if (i == j) continue;
                if (index[j] >= 4) {
                    for (int k = 0; k < num_pri; k++) {
                        if (i == k || j == k) continue;
                        if (index[k] >= 2) ++ans;
                    }
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;

    double ans = 0;
    auto f = [&](int i) {
        double res = 1.0 / N;
        while (i < K) {
            res *= 0.5;
            i *= 2;
        };
        return res;
    };
    for(int i=1; i<=N; i++) {
        ans += f(i);
    }

    printf("%.15lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,n) for(ll i=1;i<=n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll A,B,N;
    cin>>A>>B>>N;
    ll ans=min(B-1,N);
    cout<<A*ans/B<<endl;
    return 0;
}


Measured memory_bytes: 3632
module f;

import std.conv, std.stdio;
import std.algorithm, std.array, std.string, std.range;

void main()
{
    auto n = readln.chomp.to!long;
    // (qk+1) k^r = n

    auto answer = (n-1).countFactors - 1;
    // r = 0:
    //   qk+1 = n <=> k | (n-1)

    foreach (f; n.factors)
    {
        if (f == 1) continue;
        auto t = n;
        while (!(t % f))
            t /= f;
        answer += ((t % f) == 1);
    }
    // otherwise:
    //  (k | n) and (k | (n/k^r-1))

    answer.writeln;
}

auto countFactors(long n)
{
    return reduce!((a, b) => a * (b + 1))(1, 
            n.primeFactors.group.map!(_ => _[1]));
}
long[] factors(long n)
{
    auto powers = n.primeFactors.chunkBy!((a, b) => a == b).map!pwrs.array;
    stderr.writeln(powers);
    return powers.reduce!((a, b) => a.cartesianProduct(b).map!(_ =>
            _[0] * _[1]).array);
}
long[] pwrs(R)(R r)
{
    long[] ret;
    ret ~= 1;
    foreach (e; r)
        ret ~= ret[$-1] * e;
    return ret;
}
auto primeFactors(long n)
{
    long[] ret;
    long p = 1;
    while (p * p < n)
    {
        p += 1;
        while (!(n % p))
        {
            ret ~= p;
            n /= p;
        }
    }
    if (n != 1)
        ret ~= n;
    stderr.writeln(ret);
    return ret;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int W, H;
int P[100010];
int Q[100010];
int main(){

    cin >> W >> H;
    for(int i = 0; i < W; i++) cin >> P[i];
    for(int i = 0; i < H; i++) cin >> Q[i];
    int col = 0;
    int row = 0;
    vector<pii> v;
    for(int i = 0; i < W; i++){
        v.push_back(pii(P[i], 0));
    }
    for(int i = 0; i < H; i++){
        v.push_back(pii(Q[i], 1));
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    for(pii p : v){
        if(p.second == 0){
            ans += (ll)(1 + H - row) * p.first;
            col++;
        }
        else{
            ans += (ll)(1 + W - col) * p.first;
            row++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int [] x = new int [p];
		int [] y = new int [p];
		int sub = 0;
		double p1 = 0;
		double p2 = 0;
		double p3 = 0;
		double pmax = 0;
		for(int i = 0; i < p; i++) {
			x[i] = sc.nextInt();
		}
		
		for(int i = 0; i < p; i++) {
			y[i] = sc.nextInt();
		}
		for(int i = 0; i < p; i++) {
			sub = Math.abs(x[i] - y[i]);

			p1 += sub;
			p2 += sub * sub;
			p3 += sub * sub * sub;
			pmax = Math.max(pmax , sub);
		}
	    p2 = Math.sqrt(p2);
        p3 = Math.cbrt(p3);
		
        System.out.println(p1);
        System.out.println(p2);
        System.out.println(p3);
        System.out.println(pmax);
	}
}



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

typedef long long ll;

vector<int> prime;
int sp[1010101], e[1010101], tau[1010101];

void sieve(int n){
	tau[1] = 1;
	for(int i=2; i<=n; i++){
		if(!sp[i]){ prime.push_back(i); e[i] = 1; tau[i] = 2; }
		for(auto j : prime){
			if(i*j > n) break;
			sp[i*j] = j;
			if(i%j == 0){
				e[i*j] = e[i] + 1;
				tau[i*j] = tau[i] / e[i*j] * (e[i*j] + 1);
				break;
			}
			e[i*j] = 1; tau[i*j] = tau[i] * tau[j];
		}
	}
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    sieve(1010100);
    ll n, ans = 0; cin >> n;
    for(int i=1; i<n; i++) ans += tau[i];
    cout << ans;
}


Measured memory_bytes: 15712
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int SUM = A;
		int ANS = 1;
		for ( ; SUM<B; ANS++) {
			SUM += A-1;
		}
		if(B==1) ANS=0;
		System.out.println(ANS);
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
void cmps(vector<int>&v,int &i){
	i=lower_bound(all(v),i)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int mod_pow(int x,int y,int m=mod){
	int res=1;
	while(y>0){
		if(y&1)res=res*x%m;
		y>>=1;x=x*x%m;
	}
	return res;
}
int perm[1000001],inv[1000001];
void init_perm(){
	perm[0]=1;
	REP(i,1000001)perm[i]=perm[i-1]*i%mod;
	inv[1000000]=mod_pow(perm[1000000],mod-2);
	for(int i=999999;i>=0;i--){
		inv[i]=inv[i+1]*(i+1)%mod;
	}
}
int nCk(int x,int y){
	if(x<y)return 0;
	return perm[x]*inv[x-y]%mod*inv[y]%mod;
}


signed main(){
	int N,H,W;
	cin>>N>>H>>W;
	cout<<(N-H+1)*(N-W+1)<<endl;
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		List<Long> list_p = new LinkedList<>();
		List<Long> list_n = new LinkedList<>();
		long ans = 0;
		for(int i=0;i<n;i++) {
			long tmp = in.nextInt();
			if(tmp>=0) {
				list_p.add(tmp);
				ans += tmp;
			}else {
				list_n.add(tmp);
				ans -= tmp;
			}
		}
		if(list_p.size()>1) list_p.sort((e1,e2)->e1==e2?0:e1>e2?-1:1);
		if(list_n.size()>1) list_n.sort((e1,e2)->e1==e2?0:e1<e2?-1:1);
		if(list_p.size()==0) ans += 2*list_n.get(list_n.size()-1);
		if(list_n.size()==0) ans -= 2*list_p.get(list_p.size()-1);
		System.out.println(ans);
		while(list_n.size()+list_p.size()>1) {
			if(list_n.size()==0 && n!=2) {
				long a = list_p.get(0);
				long b = list_p.get(list_p.size()-1);
				list_n.add(-a+b);
				list_p.remove(list_p.size()-1);
				list_p.remove(0);
				System.out.println(b + " " + a);
			}else if(list_n.size()==0 && n==2){
				long a = list_p.get(0);
				long b = list_p.get(list_p.size()-1);
				list_p.remove(list_p.size()-1);
				list_p.remove(0);
				list_p.add(a-b);
				System.out.println(a + " " + b);
			}else if(list_p.size()==0) {
				long a = list_n.get(0);
				long b = list_n.get(list_n.size()-1);
				list_p.add(-a+b);
				list_n.remove(list_n.size()-1);
				list_n.remove(0);
				System.out.println(b + " " + a);
			}else {
				long a = list_p.get(0);
				long b = list_n.get(0);
				if(list_p.size()<=list_n.size()) {
					list_p.add(a-b);
					System.out.println(a + " " + b);
				}else {
					list_n.add(-a+b);
					System.out.println(b + " " + a);
				}
				list_p.remove(0);
				list_n.remove(0);
			}
		}
		
		in.close();
 
	}
 
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<vector<T>> m) {
    repall (v, m)
        init(v);
}

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}
// -------------------------------------------------------------------

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vec food(m + 1);
    rep (i, n) {
        int k, tmp;
        cin >> k;
        rep (j, k) {
            cin >> tmp;
            food[tmp]++;
        }
    }

    int ans = 0;
    For(i, 1, m) if (food[i] == n) ans++;

    print(ans);

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {      
      Scanner sc = new Scanner(System.in);
      String S = sc.next();
      String T = sc.next();
      int check =0;
      for (int i=0; i<S.length(); i++) {
        if (S.charAt(i) == T.charAt(i)) check++;
      }
      if (check == S.length()) {
      System.out.println("Yes");
      } else {
          System.out.println("No");
      }
    }
}

Measured memory_bytes: 26932
import sys
from operator import itemgetter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())
    
    B = [(i, a) for i, a in enumerate(A)]
    B.sort(key=itemgetter(1))
    ans = [0] * N
    for i, a in B[:-1]:
        ans[i] = B[-1][1]
        
    ans[B[-1][0]] = B[-2][1]
    
    print(*ans, sep='\n')
    
    return


if __name__ == '__main__':
    main()


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

int main() {
	string s;cin>>s;
	string ans;
	for(auto x:s){
		if(x=='1'){
			ans.push_back('1');
		}
		if(x=='0'){
			ans.push_back('0');
		}
		if(x=='B'){
			if(ans.size()){
				ans.pop_back();
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char t[100][101];
  int w,h,a,i,x,y;
  while(1){
    a=scanf("%d %d",&h,&w);
    if(w==0 && h==0) break;
    for(i=0;i<h;i++) scanf("%s",t[i]);
    x=0;y=0;a=w*h+1;
    while(1){
      switch(t[y][x]){
        case '>': x+=1; break;
        case '<': x-=1; break;
        case '^': y-=1; break;
        case 'v': y+=1; break;
        case '.': a=0; break;
      }
      a--;
      if(a<=0) break;
    }
    if(a==0) printf("LOOP\n");
     else printf("%d %d\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 624
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]=='A'&&s[i+1]=='C'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

int main() {
    ll N,K;
    
    cin>>N>>K;
    vector<ll> V(N);
    
    for(ll i=0;i<N;i++)
        cin>>V[i];
        
    ll l=1,r=1e9;
    
    while(l<r){
        ll mid=(l+r)/2;
        
        ll sum=0;
        for(ll i=0;i<N;i++){
            sum+=((V[i]-1)/mid);
            
        }
        if(sum<=K)
            r=mid;
        else l=mid+1;
    }
    cout<<r<<"\n";
	return 0;
}


Measured memory_bytes: 4784
// abc059_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string A, B;
    cin >> A >> B;

    if (A.size() == B.size()){
        if (A > B){
            print("GREATER");
        } else if (A < B){
            print("LESS");
        } else {
            print("EQUAL");
        }

    } else if (A.size() > B.size()){
        print("GREATER");
    } else {
        print("LESS");
    }


    return 0;
}


Measured memory_bytes: 256
import sys
import collections
import math

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2

    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2

    if n != 1:
        a.append(n)

    a = collections.Counter(a)
    return a

def main():
    N, M = map(int, input().split())
    a = prime_factorize(M)
    mod = 10**9 + 7

    if len(a) == 0:
        print(1)
        return

    ans = 1
    fct = math.factorial
    for i_a in a:
        ans *= (fct(a[i_a]+N-1)//(fct(a[i_a])*fct(N-1))) % mod
        ans %= mod
    print(ans)
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  cout << min(A, K) - max(K - A - B, 0) << endl;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define N 0
#define INF 0x3f3f3f3f
#define LL long long
#define mz(x) ms(x,0)
#define ms(x,y) memset(x,y,sizeof(x))
#define mc(x,y) memcopy(x,y,sizeof(y))
#define MOD 1000000007

using namespace std ;

int p[100010] ;
int _rank[100010] ;
int edge[100010] ;
int sum[100010] ;
vector<int> blockship[100010] ;

void make_set (int x)
{
	p[x] = x ;
	_rank[x] = 0 ;
	sum[x] = 1 ;
}

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

int find_set (int x)
{
	if (x != p[x])
		p[x] = find_set (p[x]) ;
	
	return p[x] ;
}

int set_sum (int x)
{
	return sum[find_set(x)] ;
}

void union_set (int x, int y)
{
	link (find_set(x), find_set(y)) ;
}

int main()
{
	int n, m, k ;
	scanf ("%d%d%d", &n, &m, &k) ;
	
	for (int i=1; i<=n; i++)
		make_set (i) ;
	
	for (int i=0; i<m; i++)
	{
		int a, b ;
		scanf ("%d%d", &a, &b) ;
		
		union_set (a, b) ;
		edge[a]++ ;
		edge[b]++ ;
	}
	
	for (int i=0; i<k; i++)
	{
		int a, b ;
		scanf ("%d%d", &a, &b) ;
		
		blockship[a].push_back (b) ;
		blockship[b].push_back (a) ;
	}
	
	for (int i=1; i<=n; i++)
	{
		int ans = set_sum (i) - 1 ;
		ans -= edge[i] ;
		
		for (int b : blockship[i])
			if (find_set(b) == find_set(i))
				ans-- ;
				
		cout << ans ;
		if (i < n)
			cout << " " ;
		else
			cout << endl ;
	}

	return 0 ;
}

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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int32_t main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);

    map<char, char> M;
    M['A'] = 'T';
    M['T'] = 'A';
    M['G'] = 'C';
    M['C'] = 'G';

    char c;
    cin >> c;
    cout << M[c] << "\n";

    return 0;
}


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

int main()
{
    int n, m;
   

    cin >> n >> m;
    int a[m];
    for(int i=0; i<m; i++){
        cin >> a[i];
        n -= a[i];
    }

    if(n>=0) cout << n << endl;
    else cout << -1 << endl;

    return 0;


}

Measured memory_bytes: 3204
#include <iostream>
#include <cstdio>
using namespace std;
int main(int argc, char *argv[]){
  int a,b,c;
  cin >> a;
  cin >> b;
  cin >> c;
  if(a < b){
    if(b < c){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int a,b,c[10005],d;
d=0;
cin>>a>>b;
for(int i=1;i<=b;i++)
{
	cin>>c[i];
	d=d+c[i];
}
if(a>=d)
{
	cout<<a-d;
}
else
{
	cout<<"-1";
}
return 0;

}


Measured memory_bytes: 3636
##N Mの入力                                                                                                                                                                                                 
N,M = [int(x) for x in input().split()]
##地点の保存                                                                                                                                                                                                
x = [int(num) for num in input().split()]
##地点のソート                                                                                                                                                                                              
x = sorted(x)
##それぞれの幅の決定                                                                                                                                                                                        
dis = [x[i+1]-x[i] for i in range(M-1)]
##幅の長さのソート                                                                                                                                                                                          
dis = sorted(dis)
##答えの算出                                                                                                                                                                                                
dis_top = 0
for i in range(1,N):
    if((M-1)-i < 0):
        break;
    dis_top = dis_top + dis[(M-1)-i]
##答えの出力                                                                                                                                                                                                
ans = sum(dis) - dis_top
print(ans)

Measured memory_bytes: 13832
#include <iostream>
using namespace std;
int h, w, c, p[9][9], q[9][9];
int id = 7;

void change(int x, int y, int color){
	int first = p[x][y];
	p[x][y] = color * (-1);
	if (x < h - 1 && p[x + 1][y] == first)
		change(x + 1, y, color);
	if (x > 0 && p[x - 1][y] == first)
		change(x - 1, y, color);
	if (y < w - 1 && p[x][y + 1] == first)
		change(x, y + 1, color);
	if (y > 0 && p[x][y - 1] == first)
		change(x, y - 1, color);
}

void pabs(){
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (p[i][j] < 0)
			p[i][j] = p[i][j] * (-1);
		}
	}


}

void show(){
	cout << endl;
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			cout << p[i][j] << " ";
		}
		cout << endl;
	}
}

int main()
{

	//長方形サイズ，目標色の入力
	while (cin >> h >> w >> c, (h || w || c)){

		//初期化
		for (int i = 0; i < 9; i++){
			for (int j = 0; j < 9; j++){
				p[i][j] = 0;
			}
		}
		//色の入力
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++)
				cin >> p[i][j];
		}

		//パネルをコピーしておく
		for (int a = 0; a < h; a++){
			for (int b = 0; b < w; b++){
				q[a][b] = p[a][b];
			}
		}

		//全パターン

		int max = 0;
		int counter;
		for (int i = 1; i < 7; i++){
			for (int j = 1; j < 7; j++){
				for (int k = 1; k < 7; k++){
					for (int l = 1; l < 7; l++){
						for (int m = 1; m < 7; m++){

							//パネルを初期状態に戻す
							for (int a = 0; a < h; a++){
								for (int b = 0; b < w; b++){
									p[a][b] = q[a][b];
								}
							}
							//5回色塗り
							change(0, 0, i);
							pabs();
							change(0, 0, j);
							pabs();
							change(0, 0, k);
							pabs();
							change(0, 0, l);
							pabs();
							change(0, 0, m);
							pabs();

							//集計
							for (int i = 0; i < h; i++){
								for (int j = 0; j < w; j++){
									if (p[i][j] == c){
										change(i, j, ++id);
										pabs();
										counter = 0;
										for (int a = 0; a < h; a++){
											for (int b = 0; b < w; b++){
												if (p[a][b] == id)
													counter++;
											}
										}
										if (counter > max)
											max = counter;
									}
								}
							}

						}
					}
				}
			}
		}

		//出力
		cout << max << endl;
	}
	return 0;
}

Measured memory_bytes: 1168
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
#define debegin printf("debug\nbegin\n")
#define deend printf("debug\nend\n")
#define isfind printf("find\n")
template<class T>inline void rread(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
map<pair<pa,int>,int>vis;
int main(){
	int a,b,c;
	rread(a);rread(b);rread(c);
	if(a>b)swap(a,b);
	if(a>c)swap(a,c);
	if(b>c)swap(b,c);
	int cnt=0;
	vis[mp(mp(a,b),c)]=0;
	while(1){
		if(a>b)swap(a,b);
		if(a>c)swap(a,c);
		if(b>c)swap(b,c);
		if(a&1||b&1||c&1){
			printf("%d\n",cnt);
			return 0;
		}
		int d=b/2+c/2,e=a/2+c/2,f=a/2+b/2;
		a=d;b=e;c=f;
		cnt++;
		if(vis.count(mp(mp(a,b),c)))break;
		vis[mp(mp(a,b),c)]=cnt;
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 256