akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

bool flag[100010];
int cnt[100010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int AC = 0;
    int P = 0;
    rep(i, M) {
        int p;
        string S;
        cin >> p >> S;
        if (flag[p] == false && S == "AC") {
            flag[p] = true;
            AC++;
        } else if (flag[p] == false && S == "WA") {
            cnt[p]++;
        }
    }
    rep(i, N) {
        if (flag[i + 1]) P += cnt[i + 1];
    } 
    cout << AC << " " << P << endl;

    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <map>

using namespace std;

bool func(int *a)
{
	int x = a[0] + a[4] + a[8];

	if (x != a[2] + a[4] + a[6])
		return false;

	if (x != a[1] + a[3] + a[8])
		return false;

	if (x != a[1] + a[5] + a[6])
		return false;

	if (x != a[0] + a[5] + a[7])
		return false;

	if (x != a[2] + a[3] + a[7])
		return false;

	return true;
}

int main(void)
{
	int a[9];

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

	if (func(a))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include<bitset>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); ++i)
#define loops(i,f,n) for(int i = (f); i < (n); ++i)
#define INF 9999999
#define in(a) cin>>a
#define out(a) cout<<a<<endl

int main()
{
	string str;
	cin >> str;
	int ans = 0;
	bool ok = false;
	loop(bit, (1 << 3))
	{
		if (ok)break;
		int ans_tmp = str[0] - '0';
		vector<char> ops;
		loop(j, 3)
		{
			if (bit&(1 << j))
			{
				ans_tmp += (str[j + 1] - '0');
				ops.push_back('+');
			}
			else
			{
				ans_tmp -= (str[j + 1] - '0');
				ops.push_back('-');
			}
		}
		if (ans_tmp == 7)
		{
			cout << str[0] << ops[0] << str[1] << ops[1] << str[2] << ops[2] << str[3] << "=7" << endl;
			ok = true;
		}
	}
}

Measured memory_bytes: 256
#E
n,W = list(map(int,input().split()))
w = [0]*(n+1)
v = [0]*(n+1)
for i in range(1,n+1):
    w[i],v[i]=list(map(int,input().split()))
V = n*max(v)

dp = [[float('inf') for i in range(V+1)] for j in range(n+1)]
#i番目(1:n)の品物までを使って価値の総和がjになるようなときの重さの最小値
dp[0][0] = 0
for i in range(1,n+1):
    for j in range(V+1): #価値
        if j-v[i]>=0:
            dp[i][j] = min(dp[i-1][j],dp[i-1][j-v[i]]+w[i])
        else:
            dp[i][j] = dp[i-1][j]
# for i in range(n+1):
#     print(dp[i])
print(max([j for j in range(V+1) if dp[n][j]<=W]))

Measured memory_bytes: 319940
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22) { cout << "bust" << endl; }
	else { cout << "win" << endl; }
	return 0;
}


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

#define pb push_back
#define ppb pop_back

using namespace std;

typedef long long ll;

ll const INF = 1e9;

int n, m, x;
ll c[12];
int a[12][12];

ll cost(int i, vector<int> curr){
	if(i==n){
		int level[12];
		memset(level, 0, sizeof level);
		for(int i=0;i<curr.size();i++){
			for(int j=0;j<m;j++){
				level[j] += a[curr[i]][j];
			}
		}
		for(int i=0;i<m;i++){
			if(level[i] < x)
				return INF;
		}
		ll cost = 0;
		for(int i=0;i<curr.size();i++){
			cost += c[curr[i]];
		}
		return cost;
	}
	else{
		curr.pb(i);
		ll ans1 = cost(i+1, curr);
		curr.ppb();
		ll ans2 = cost(i+1, curr);
		return min(ans1, ans2);
	}
}

int main(){
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>c[i];
		for(int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	vector<int> blank;
	ll costx = cost(0, blank);
	if(costx == INF)
		cout<<-1<<"\n";
	else
		cout<<costx<<"\n";
	return 0;
}

Measured memory_bytes: 3536
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    var kotlin=scan.nextLine().toLong()
    var ac= 0
    var wa = 0
    var tle = 0
    var re = 0
    for(i in 1..kotlin)
    {
        var arr = scan.nextLine()
        if(arr=="AC")
            ac++
        if(arr=="WA")
            wa++
        if(arr=="TLE")
            tle++
        if(arr=="RE")
            re++
    }
    println("AC x $ac")
    println("WA x $wa")
    println("TLE x $tle")
    println("RE x $re")
}


Measured memory_bytes: 60048
import math

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

mod = 10**9+7

def lcm(x, y):
  return (x // math.gcd(x, y)) * y

LCM = A[0]
for i in range(N-1):
  LCM = lcm(LCM, A[i+1])

LCM %= mod

ans = 0
for a in A:
  ans += LCM * pow(a, mod-2, mod) % mod
  ans %= mod

print(ans)

Measured memory_bytes: 74492
turn = gets.to_i

tarou_point, hanako_point = 0, 0

turn.times do
  tarou_str, hanako_str = gets.chomp.split

  if tarou_str > hanako_str
    tarou_point += 3
  elsif tarou_str < hanako_str
    hanako_point += 3
  else
    tarou_point += 1
    hanako_point += 1
  end
end

puts "#{tarou_point} #{hanako_point}"

Measured memory_bytes: 8720
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const T = readToken();
      
      auto ans = T.dup;
      foreach_reverse (ref c; ans) {
        if (c == '?') {
          c = 'D';
        }
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


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

using ll = long long;

using namespace std;

using P = pair<long, int>;
#define fi first
#define se second

#define MAX 100010

int main() {
    int n;
    cin >> n;
    long a[MAX], ma=0;
    vector<int> cans;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        ma = max(ma, a[i]);
        cans.push_back(i);
    }
    a[n] = 0;
    cans.push_back(n);
    sort(cans.begin(), cans.end(), [&](int l, int r) {
        if (a[l] != a[r]) return a[l] > a[r];
        else return l < r;
    });
    int begin=0, end=0, front=cans[0];
    long ans[n];
    fill(ans, ans+n, 0);
    //for (auto ca:cans) cerr << ca << ' ' << a[ca] << '\n';
    for ( ; begin<n; begin=end) {
        end = partition_point(cans.begin(), cans.end(), [&](int x) {
            return a[x] >= a[cans[begin]];
        }) - cans.begin();
        front = min(front, cans[begin]);
        //cerr << begin << ' ' << end << ' ' << front << '\n';
        ans[front] += end * (a[cans[begin]] - a[cans[end]]);
    }
    for (auto ansi:ans) cout << ansi << '\n';
    return 0;
}

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

long double dp[3000][3000];

int main()
{
    int n;
    cin >> n;
    
    dp[0][0] = 1;
    for (int i = 0; i != n; ++i)
    {
        long double p;
        cin >> p;
        
        dp[i + 1][0] = dp[i][0] * (1 - p);
        for (int j = 1; j <= i + 1; ++j)
            dp[i + 1][j] = p * dp[i][j - 1] + (1 - p) * dp[i][j];
    }
    
    long double ans = 0;
    for (int i = n - n / 2; i <= n; ++i)
        ans += dp[n][i];
    
    cout << setprecision(20) << ans;
    return 0;
}

Measured memory_bytes: 139008
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const long long inf = 1LL << 60;
struct edge {
	int to; long long cost;
};
struct state {
	int pos; long long cost;
};
bool operator<(const state& s1, const state& s2) {
	return s1.cost > s2.cost;
}
int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<edge> > G(N);
	for (int i = 0; i < M; ++i) {
		int L, R, C;
		cin >> L >> R >> C; --L, --R;
		G[L].push_back(edge{ R, C });
	}
	for (int i = 1; i < N; ++i) {
		G[i].push_back(edge{ i - 1, 0 });
	}
	vector<long long> dist(N, inf);
	dist[0] = 0;
	priority_queue<state> que;
	que.push(state{ 0, 0 });
	vector<bool> vis(N);
	while (!que.empty()) {
		int pos = que.top().pos; que.pop();
		if (vis[pos]) continue;
		vis[pos] = true;
		for (edge e : G[pos]) {
			if (dist[e.to] > dist[pos] + e.cost) {
				dist[e.to] = dist[pos] + e.cost;
				que.push(state{ e.to, dist[e.to] });
			}
		}
	}
	cout << (dist[N - 1] == inf ? -1 : dist[N - 1]) << endl;
	return 0;
}

Measured memory_bytes: 9340
A,B,C,D = gets.split.map &:to_i


def g(x,y)
  x / y
end

def f(x,c,d)
  x - (g(x,c) + g(x,d) - g(x,c*d/c.gcd(d)))
end


p f(B,C,D) - f(A-1,C,D)


Measured memory_bytes: 1788
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  ll a;
  set<ll> mm;

  cin >> a;

  for(int i=0;;i++){
    mm.insert(a);

    if(a % 2 == 0) a /= 2;
    else a = a * 3 + 1;

    if(mm.find(a) != mm.end()){
      printf("%d\n", i+2);
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fori(i,a,n) for(i=a;i<=n;i++)
#define ford(i,n,a) for(i=n;i>=a;i--)
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
ll n,r;
int main()
{
	cin>>n>>r;
	if (n<10) cout<<r+100*(10-n)<<endl;
	else cout<<r<<endl;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
  char a,b,c;

  a = getchar();
  b = getchar();
  c = getchar();

  if(a=='H'&&c=='H'||a=='D'&&c=='D')
    printf("H\n");
  else
    printf("D\n");

  return 0;
}


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

int main() {
  ll N;
  cin >> N;
  int res = 11;
  rep2(i, 1, sqrt(N) + 1) if(N % i == 0) {
    ll x = i, y = N / i;
    int fx = 0, fy = 0;
    while(x > 0) {
      x /= 10;
      fx++;
    }
    while(y > 0) {
      y /= 10;
      fy++;
    }
    res = min(res, max(fx, fy));
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

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

string s;
int c1,c2;

int main()
{
	cin>>s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='A') c1++;
        else c2++;
    }
    if(c1==s.length()||c2==s.length()) puts("No");
    else puts("Yes");
	return 0;
}

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

using namespace std;


int main() {
    int n;
    cin>>n;
    int num[100002]={0};
    for (int i = 0; i < n; ++i) {
        int in;
        cin>>in;
        num[in]++;
        num[in+1]++;
        num[in+2]++;
    }
    int maxn = 0;
    for (int j : num) {
        maxn= max(maxn, j);
    }
    cout<<maxn<<endl;
    return 0;
}

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

#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

vector<int> es[8];

int rep(int i, vector<bool> used) {

    int result = 0;

    used[i] = true;
    bool is_final = true;
    REP(j, es[i].size()) {
        if (!used[es[i][j]]) {
            is_final = false;
            result += rep(es[i][j], used);
        }
    }

    if (is_final) {
        REP(j, used.size()) if(!used[j]) return 0;
        return 1;
    } else {
        return result;
    }
}

int main() {

    int N, M; cin >> N >> M;
    REP(i, M) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        es[y].push_back(x);
        es[x].push_back(y);
    }

    vector<bool> used(N); REP(i, N) used[i] = false;

    cout << rep(0, used) << endl;

    return 0;
}


Measured memory_bytes: 764
n,m = map(int,input().split())
L = [list(map(int,input().split())) for _ in range(n)]
L = sorted(L, key=lambda x: x[0])
limit = m
ans = 0
for i in range(n):
  if limit <= 0: break
  ans += min(limit, L[i][1]) * L[i][0]
  limit -= L[i][1]
print(ans)

Measured memory_bytes: 29128
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        while (true)
        {
            // Input H, W
            string[] str = Console.ReadLine().Split(' ');
            int H = int.Parse(str[0]);
            int W = int.Parse(str[1]);

            if (H == 0 && W == 0)
            {
                break;
            }

            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    Console.Write('#');
                }
                Console.WriteLine(string.Empty);
            }
            Console.WriteLine(string.Empty);
        }
    }
}

Measured memory_bytes: 8996
using System;

public class Hello{
    public static void Main(string[] args){
        // 自分の得意な言語で
        // Let's チャレンジ！！

        var line = System.Console.ReadLine();
        string[] value =line.Split(' ');
      
      if(Int32.Parse(value[0]) < Int32.Parse(value[1])){
        System.Console.WriteLine(0);
      }else{
        System.Console.WriteLine(10);
      }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <fstream>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdint>
#include <iomanip>
#include <tuple>
#include <random>

using namespace std;

int get_digits(unsigned int a) {
    int cur = a;
    int retval = 0;
    while(cur != 0) {
        retval += cur % 10;
        cur = cur / 10;
    }
    return retval;
}

int main(void) {
    int n;
    cin >> n;
    int ret = 0x7fffffff;
    for(int i = 1;i <= (n/2)+1;i++) {
        ret = std::min(ret,get_digits(i) + get_digits(n-i));
    }
    cout << ret << endl;
}


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

int main(void)
{
    int n;
    cin >> n;
    int v[n], c[n], res;

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

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

    res = 0;
    for (int i=0; i<n; i++) {
        if (v[i] > c[i]) {
            res += v[i] - c[i];
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) x.begin() , x.end()
#define ll long long 
#define pb push_back
#define mp make_pair

using namespace std;

long long lcm(long long a , long long b){
    return (a * b) / __gcd(a ,b);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n , m , a , b;
    cin>>n>>m>>a>>b;
    long long dif = m - n + 1;
    long long diva = m/a  - ((n - 1) / a);
    long long divb = m/b - ((n - 1) / b);
    long long divl = m/lcm(a,b) - ((n - 1)/ lcm(a, b));
    //cout<<diva<<" "<<divb<<" "<<divl<<" L "<<lcm(n , m)<<endl;
    cout<<(dif - diva - divb + divl)<<endl;


}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;


int main(){
    long a,b,c,d;
    long p,q,r,s;

    cin >> a >> b >> c >> d;

    p = a*c;
    q = a*d;
    r = b*c;
    s = b*d;

    cout << max(max(p,q),max(r,s)) << endl;
}

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

int dp[20][20];
int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		int gx, gy, p; scanf("%d%d%d", &gx, &gy, &p);
		vector<pair<P, P>>v;
		rep(j, p) {
			int x1, y1, x2, y2; scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
			if (P(x1, y1) > P(x2, y2)) {
				swap(x1, x2); swap(y1, y2);
			}
			v.push_back({ {x1,y1},{x2,y2} });
		}
		sort(v.begin(), v.end());
		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1;
		for (int j = 0; j <= gx; j++) {
			for (int k = 0; k <= gy; k++) {
				if (!binary_search(v.begin(), v.end(), make_pair(P(j, k), P(j, k + 1))))
					dp[j][k + 1] += dp[j][k];
				if (!binary_search(v.begin(), v.end(), make_pair(P(j, k), P(j + 1, k))))
					dp[j + 1][k] += dp[j][k];
			}
		}
		if (dp[gx][gy])printf("%d\n", dp[gx][gy]);
		else puts("Miserable Hokusai!");
	}
}

Measured memory_bytes: 3216
#include <iostream>

using namespace std;

int main()
{
    int c1,c2,sum,v1,v2,v3;

    cin >>c1 >> c2;

   if(c1>0 && c2>0)
   {
    v1=c1%3;
    v2=c2%3;
    sum=c1+c2;
    v3=sum%3;
   }
    if(v1==0 || v2==0 || v3==0)
    {
        cout << "Possible" << endl;
    }
    else{cout << "Impossible" << endl;}


    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#define int int64_t
using namespace std;
main() {
    int X,Y,Z,K; cin>>X>>Y>>Z>>K;
    vector<int> A(X); for(auto& x:A) cin>>x;
    vector<int> B(Y); for(auto& x:B) cin>>x;
    vector<int> C(Z); for(auto& x:C) cin>>x;
    for(auto xs : vector<vector<int>*>({&A,&B,&C})) {
        sort(xs->begin(), xs->end());
        reverse(xs->begin(), xs->end());
    }
    set<vector<int>> s;
    priority_queue<pair<int, vector<int>>> q;
    q.push({A[0]+B[0]+C[0], {0,0,0}});
    s.insert({0,0,0});
    for(int k=1; k<=K; ++k) {
        if(q.empty()) {
            printf("empty\n"); exit(0);
        }
        auto pair= q.top(); q.pop();
        int iA= pair.second[0];
        int iB= pair.second[1];
        int iC= pair.second[2];
        cout<< pair.first <<endl;
        if(iA<A.size()-1) {
            if(s.find({iA+1,iB,iC}) == s.end()) {
                q.push({A[iA+1]+B[iB]+C[iC], {iA+1,iB,iC}});
                s.insert({iA+1,iB,iC});
            }
        }
        if(iB<B.size()-1) {
            if(s.find({iA,iB+1,iC}) == s.end()) {
                q.push({A[iA]+B[iB+1]+C[iC], {iA,iB+1,iC}});
                s.insert({iA,iB+1,iC});
            }
        }
        if(iC<C.size()-1) {
            if(s.find({iA,iB,iC+1}) == s.end()) {
                q.push({A[iA]+B[iB]+C[iC+1], {iA,iB,iC+1}});
                s.insert({iA,iB,iC+1});
            }
        }
    }
}

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

int main() {
  int n, a = 0, b = 1;
  cin >> n;
  vector<int> vec(n, 0);
  vector<int> vec2(n, 0);
  for(int i = 0; i < n; i++) {
    cin >> vec.at(i);
    vec2.at(i) = vec.at(i);
  }

   
  for(int i = n-1; i >= 0; i--){
    b = n / (i + 1); 
    
    for(int j = 1; j < b; j++){
      vec2.at(i) -= vec2.at((j + 1) * ( i + 1) - 1);
    }
    
    vec2.at(i) = vec2.at(i) % 2;
    if(vec2.at(i) == -1) vec2.at(i) = 1;
    a += vec2.at(i);
  }
  
    cout << a << endl;
  for(int i = 0; i < n; i++){
    if(a == 0) break;
    else if(vec2.at(i) == 1){
      if(i == n - 1) cout << i + 1<< endl;
    else{
      cout << i + 1 << " ";
    }
    }
  }
  

}

Measured memory_bytes: 2432
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	gcd := GCD(nextInt(), nextInt())
	fmt.Println(1 + len(Factorize(gcd)))
}

func Factorize(n int) [][]int {
	res := [][]int{}
	for i := 2; i*i <= n; i++ {
		if n%i != 0 {
			continue
		}
		cnt := 0
		for n%i == 0 {
			n /= i
			cnt++
		}
		res = append(res, []int{i, cnt})
	}
	if n != 1 {
		res = append(res, []int{n, 1})
	}
	return res
}

func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}


Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;


lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli W, H, x, y;
	cin >> W >> H >> x >> y;

	cout << (W * H) / 2.0 << " " << (W == 2 * x && H == 2 * y ? 1 : 0) << endl;



	return 0;
}

Measured memory_bytes: 256
S=input()
N=len(S)
a=S[0:(N-1)//2-1]
A=S[(N-1)//2-1:0:-1]
b=S[(N+3)//2-1:N-1]
B=S[N:(N+3)//2-1:-1]
if(a==A) and (b==B) and (a==B):
    print("Yes")
else:
     print("No")

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
	char s[9];
	int i, ans = 0;
	scanf("%s", s);
	for (i = 0; i < 6; i++) {
		if (s[i] == '1')ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;

int main(){
string a;cin>>a;
int cnt=0;for (char c:a) cnt+=c=='o';
write(700+cnt*100);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;

int main()
{
    int n;
    ll x[10];
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&x[i]);
    }
    sort(x+1,x+1+n);
    ll ans=0;
    for(int i=1;i<n;i++)ans+=x[i];
    ans+=x[n]/2;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define PI acos(-1)
#define BMW_GTR ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef long long ll;
using namespace std;

//ll const n = 50005;

int main()
{
    BMW_GTR;

    string S;
    cin >> S;

    if(S[0] == 'R' && S[1] == 'R' && S[2] == 'R')
    {
        cout << 3;
        return 0;
    }

    else if((S[0] == 'R' && S[1] == 'R' && S[2] != 'R'))
    {
        cout << 2;
        return 0;
    }

    else if((S[1] == 'R' && S[2] == 'R' && S[0] != 'R'))
    {
        cout << 2;
        return 0;
    }

    else if(S[0] == 'R' || S[1] == 'R' || S[2] == 'R')
    {
        cout << 1;
        return 0;
    }
    else if(S[0] == 'S' || S[1] == 'S' || S[2] == 'S')
    {
        cout << 0;
    }

    return 0;
}


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

template<typename T>
T get_value(std::istream& is);

int main() {
  cin.sync_with_stdio(false);
  cin.tie(nullptr);

  vector<int> v(get_value<size_t>(cin));
  for (auto& e: v)
    cin >> e;

  sort(v.begin(), v.end());
  cout << unique(v.begin(), v.end()) - v.begin() << '\n';
  return 0;
}

template<typename T>
inline T get_value(std::istream& is)
{
  T v;
  is >> v;
  return v;
}


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

using namespace std;

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

const double PI = acos(-1);



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    string s;
    cin >> n >> s;
    for (int i = 0; i < s.size(); i++) {
        int x = s[i] - 'A';
        x = (x + n) % 26;
        s[i] = 'A' + x;
    }
    cout << s;
}

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

N = int(input())
pairs = [tuple(map(int, input().split())) for _ in range(N)]
As, Bs = zip(*pairs)

if N % 2 == 0:
    sA = sorted(As)
    medA2 = sA[N//2-1] + sA[N//2]
    sB = sorted(Bs)
    medB2 = sB[N//2-1] + sB[N//2]
    print(medB2 - medA2 + 1)
else:
    sA = sorted(As)
    medA = sA[N//2]
    sB = sorted(Bs)
    medB = sB[N//2]
    print(medB - medA + 1)  



Measured memory_bytes: 51556
#include<bits/stdc++.h>
using namespace std;
string s,s1,s2;
int t,n,m,tmp,p,pp;
int cnt[10001];
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n; m=0; p=10147;
    while (n--){
    	  cin>>t;
    	  cnt[t]++;
    	  if (t>m) m=t;
    	  if (t<p) p=t;
	}
	cout<<p;
	cnt[p]--;
	for (int i=p; i<=m; i++)
	    while (cnt[i]--)
	          cout<<' '<<i;
    cout<<'\n';
	return 0;
} 


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


int main(int argc, const char * argv[]) {
    int x, y;
    cin >> x >> y;
    if(x == 2 || y == 2){
        cout << "No" << endl;
    }else if(x == 4){
        if(y == 6 || y == 9 || y == 11){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else if(x == 6){
        if(y == 9 || y == 11){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else if(x == 9 && y == 11){
        cout << "Yes" << endl;
    }else if(x == 11){
      cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<functional>
#include <algorithm>
#include  <iostream>
#include   <ctype.h>
#include   <cstring>
#include   <fstream>
#include    <cstdio>
#include    <vector>
#include    <string>
#include     <cmath>
#include     <deque>
#include     <stack>
#include     <queue>
#include      <list>
#include       <set>
#include       <map>
#define INF 0X7FFFFFFF
#define PI acos(-1.0)
typedef long long ll;
using namespace std;
const int N = 1e6;
inline int getint()
{
	int w = 0, q = 0;
	char c = getchar();
	while ((c<'0' || c>'9') && c != '-') c = getchar();
	if (c == '-') q = 1, c = getchar();
	while (c >= '0'&&c <= '9') w = w * 10 + c - '0', c = getchar();
	return q ? -w : w;
}
int a[200];
int main() {
	int n = getint();
	int maxn = -11111111, minn = 11111111;
	for (int i = 0; i < n; i++) {
		a[i] = getint();
		maxn = max(a[i], maxn);
		minn = min(a[i], minn);
	}
	ll ans = INF;
	for (int i = minn; i <= maxn; i++) {
		ll t = 0;
		for (int j = 0; j < n; j++) {
			t += (a[j] - i)*(a[j] - i);
		}
		ans = min(ans, t);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>
#include <cstring>
#include <cmath>
using namespace std;
const int maxn = 55;

int n;
struct node {
  int x, y;
  node(int a, int b) {x = a, y = b;}
  node() {}
} p[100];
bool vis[maxn];
map<pair<int, int>, bool> m;

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &p[i].x, &p[i].y);
  }

  int ans = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      int x = p[i].x - p[j].x, y = p[i].y - p[j].y, cnt = 0;
      if (m[make_pair(x, y)] == true) continue;
      m[make_pair(x, y)] = true;
      memset(vis, false, sizeof vis);

      for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
          if (i == j) {
              continue;
          }
          if ((p[i].x - p[j].x) == x && (p[i].y - p[j].y) == y) {
            cnt++;
          } else if (-(p[i].x - p[j].x) == x && -(p[i].y - p[j].y) == y) {
            cnt++;
          }
        }
      }
      //printf("cnt %d\n", cnt);
      ans = max(ans, cnt/2);
    }
  }
  printf("%d\n", n - ans);

  return 0;
}

/*
4
1 1
2 2
15 12
65 47
*/


Measured memory_bytes: 384
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int W1 = 0;
    int H1 = 0;
    int W2 = sc.nextInt();
    int H2 = sc.nextInt();
    int N = sc.nextInt();
    for(int i=0;i<N;i++){
      int x = sc.nextInt();
      int y = sc.nextInt();
      int a = sc.nextInt();
      if(a==1){
        if(W1<x)W1 = x;
      }else if(a==2){
        if(W2>x)W2 = x;
      }else if(a==3){
        if(H1<y)H1 = y;
      }else{
        if(H2>y)H2 = y;
      }
    }
    int ans = (W2-W1)*(H2-H1);
    if((W2-W1)<0 || (H2-H1)<0){
      ans = 0;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 36032
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
 
typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;
 
constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
 
int main() {
    f64 T,X; cin>>T>>X;
    cout<<T/X<<endl;
}



Measured memory_bytes: 384
n, m = gets.to_s.split.map{|t|t.to_i}
pys  = Array.new(m){|i| gets.to_s.split.map{|t|t.to_i}.push(i) }

pys.sort_by!{|prefecture, y, _| [prefecture, y] }

used = Array.new(n+1){ false }

ans = []
id = -1
pys.each do |prefecture, y, i|
  
  if !used[prefecture]
    id = 0
    used[prefecture] = true
  end
  
  id += 1
  
  ans << [i, prefecture.to_s.rjust(6, '0') + id.to_s.rjust(6, '0')]
end
  
ans.sort_by!{|i, _| i }

ans.each do |_, str|
  puts str
end

Measured memory_bytes: 31192
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    ll n, m;
    cin >> n >> m;
    if (n == 1 || m == 1) {
        int k = n^m^1;
        if (k == 1) puts("1");
        else cout << k - 2 << endl;
    } else {
        cout << (n-2) * (m-2) << endl;
    }
}


Measured memory_bytes: 3632
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    string s, t;
    cin >> s >> t;
    int ns = s.size();
    int nt = t.size();

    map<char, vector<int>> pos_s;
    for(int i=0;i<s.size();i++){
        pos_s[s[i]].push_back(i);
    }
    int nowpos = 0;
    ll rep = 0;
    for(auto c: t){
        if(!pos_s.count(c)){
            cout << -1 << endl;
            return 0;
        }
        auto pos = lower_bound(pos_s[c].begin(), pos_s[c].end(), nowpos);
        // 繰り返し追加
        if(pos == pos_s[c].end()){
            rep++;
            nowpos = 0;
            pos = lower_bound(pos_s[c].begin(), pos_s[c].end(), nowpos);
        }
        nowpos = *pos + 1;
    }

    ll ans = rep * s.size() + nowpos;

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

Measured memory_bytes: 1216
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(int[] a) {
    int x = 0;
    for (int i = 0; i < a.length; i++) {
        if (i % 2 == 0) x += a[i];
        else x -= a[i];
    }
    auto b = [x/2];
    for (int i = 1; i < a.length; i++) {
        b ~= a[i-1] - b[$-1];
    }
    auto ans = b.map!(e => text(e * 2)).join(" ");
    writeln(ans);
}

void main() {
    int n; scan(n);
    auto a = readints;
    calc(a);
}


Measured memory_bytes: 6344
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,mx=0;
    cin>>n;
    int graph[n][3];
    for(int i=0;i<n;i++)
       for(int j=0;j<3;j++)
           cin>>graph[i][j];
           
    for(int i=n-2;i>=0;i--)
    {
        for(int j=0;j<3;j++)
        {
            mx=0;
             if(j==0)
               mx=max(graph[i+1][j+1],graph[i+1][j+2]);
               else if(j==1)
                  mx=max(graph[i+1][j+1],graph[i+1][j-1]);
                  else
                     mx=max(graph[i+1][j-1],graph[i+1][j-2]);
            graph[i][j]=graph[i][j]+mx;
        }
    }
    
    mx=0;
    
    for(int i=0;i<n;i++)
       mx=max(mx,graph[0][i]);
     
    cout<<mx<<"\n";
    
    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
constexpr int INF = 0x3f3f3f3f;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, 0, n) cin >> a[i];

  int l = 0, r = INF;
  while (r - l > 1) {
    int x = (r + l) >> 1;

    bool ok = [&] {
      int res = 0;
      rep(i, 0, n) { res += (a[i] - 1) / x; }
      return res <= k;
    }();
    (ok ? r : l) = x;
  }
  cout << r;
  return 0;
}


Measured memory_bytes: 4036
//Bismillahir Rahmanir Raheem
//In the name of Allah , Most Gracious , Most Merciful

/*

  * * * * * * *   * * * * * * *   *           *   * * *   * * * * * *
              *   *           *   *           *     *     *           *
              *   *           *   *           *     *     *             *
              *   *           *   *           *     *     *             *
              *   * * * * * * *   * * * * * * *     *     *             *
  *           *   *           *   *           *     *     *             *
  *           *   *           *   *           *     *     *             *
  *           *   *           *   *           *     *     *           *
  * * * * * * *   *           *   *           *   * * *   * * * * * *

*/

#include<bits/stdc++.h>
using namespace std;

#define BOOST ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define DEBUG freopen("input.txt","r",stdin)


int main()
{
    BOOST;
    //DEBUG;
    double r,c;
    cin>>r;
    c = 2 * 3.14159 * r;
    cout<<c<<endl;
    return 0;
}





Measured memory_bytes: 3792
<?php
    fscanf(STDIN, "%d", $n);
    $total = 0;
    for ($i = 0; $i < $n; $i++ ) {
        fscanf(STDIN, "%d %d", $a, $b);
        $total += $b - $a + 1;
    }
    echo $total . "\n";
?>


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

struct uf_tree
{
    vector<int> par, rank;
    uf_tree(int n) : par(n), rank(n)
    {
        for (int i = 0; i < n; i++)
        {
            par[i] = i;
            rank[i] = 1;
        }
    }

    int find(int x)
    {
        if (x == par[x])
            return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);

        if (x == y)
            return;

        if (rank[x] < rank[y])
            swap(x, y);
        par[y] = x;
        rank[x] += rank[y];
    }

    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    int size(int x)
    {
        return rank[find(x)];
    }
};

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    uf_tree uf(n);

    int deg[n] = {};
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        deg[a]++, deg[b]++;

        uf.unite(a, b);
    }

    vector<int> v[n];

    rep(i, k)
    {
        int c, d;
        cin >> c >> d;
        --c, --d;
        v[c].push_back(d);
        v[d].push_back(c);
    }

    rep(i, n)
    {
        int ans = uf.size(i) - 1 - deg[i];
        for (auto u : v[i])
        {
            if (uf.same(i, u))
                ans--;
        }
        if (i)
            cout << " ";
        cout << ans;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, M, X, Y;
int x[110], y[110];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M >> X >> Y;
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> y[i];
  }
  for (int i = X+1; i <= Y; i++) {
    int war = 0;
    for (int j = 0; j < N; j++) {
      war |= x[j] >= i;
    }
    for (int j = 0; j < M; j++) {
      war |= y[j] < i;
    }
    if (war) continue;
    cout << "No War" << endl;
    return 0;
  } 
  cout << "War" << endl; 

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
//Ford-Fulkerson O(FE)
#include<algorithm>
#include<utility>
#include<vector>
#include<limits>
template<typename T>
struct MF{
	struct edge{
		int to,rev;
		T cap;
	};
	vector<vector<edge> >G;
	vector<int>used;
	MF(int n_=0):G(n_),used(n_,0){}
	void add_edge(int from,int to,T cap)
	{
		G[from].push_back({to,(int)G[to].size(),cap});
		G[to].push_back({from,(int)G[from].size()-1,0});
	}
	T dfs(int u,int t,T f,int dfstime)
	{
		if(u==t)return f;
		used[u]=dfstime;
		for(edge&e:G[u])
		{
			if(used[e.to]<dfstime&&e.cap>0)
			{
				T d=dfs(e.to,t,min(f,e.cap),dfstime);
				if(d>0)
				{
					e.cap-=d;
					G[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	T max_flow(int s,int t)
	{
		T ret=0;
		for(int dfstime=1;;dfstime++)
		{
			T f=dfs(s,t,numeric_limits<T>::max(),dfstime);
			if(f>0)ret+=f;
			else break;
		}
		return ret;
	}
};
int H,W;
main()
{
	cin>>H>>W;
	MF<int>mf(H*W*2+H+W);
	int S,T;
	for(int i=0;i<H;i++)
	{
		string s;
		cin>>s;
		for(int j=0;j<W;j++)if(s[j]!='.')
		{
			int id=i*W+j;
			if(s[j]=='S')S=id*2+1;
			if(s[j]=='T')T=id*2;
			mf.add_edge(id*2,id*2+1,1);
			mf.add_edge(2*H*W+i,id*2,1e9);
			mf.add_edge(2*H*W+H+j,id*2,1e9);
			mf.add_edge(id*2+1,2*H*W+i,1e9);
			mf.add_edge(id*2+1,2*H*W+H+j,1e9);
		}
	}
	int ans=mf.max_flow(S,T);
	cout<<(ans<1e9?ans:-1)<<endl;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};


mint c[4005][4005]; // パスカルの三角形
void init() {
    c[0][0] = 1;
    for (int i=0;i<=4000;++i) {
        for (int j=0;j<=i;j++) {
            c[i+1][j] += c[i][j];
            c[i+1][j+1] += c[i][j];
        }
    }
}

mint comb(int n, int k) {
    return c[n][k];
}

mint f2(int n, int k) {
    return comb(n+k-1, k-1);
}

mint f(int n, int k) {
    if (n < k) return 0;
    if (n == 0 && k == 0) return 1;
    if (k < 1) return 0;
    return f2(n-k, k);
}


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

    for (int i=1;i<=K;++i) {
        mint blue = f(K, i);
        mint red = 0;
        {
            red += f(N-K, i-1);
            red += f(N-K, i);
            red += f(N-K, i);
            red += f(N-K, i+1);
        }
        mint ans = blue * red;
        cout << ans.x << endl;
    }
}

Measured memory_bytes: 125568
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long n,m,ans,a[1000],i,j;
	 cin>>n>>m;
	    for (i=1;i<=n;i++)cin>>a[i];
	    for (i=1;i<n;i++)
	      for(j=i+1;j<=n;j++)
	        if(a[i]<a[j])swap(a[i],a[j]);
	         ans=0;
	           for(long i=1;i<=m;i++)ans+=a[i];
	            cout<<ans;
	        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s,t;
	cin>>s>>t;
	ll a,b;
	cin>>a>>b;
	string now;
	cin>>now;
	if(now==s){
		a--;
	}
	else{
		b--;
	}
	cout << a<<" "<<b;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
#define LL long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
using namespace std;

const int MOD=1e9+7;
const int INF=0x7ffffff;
const int magic=348;
const double eps=1e-9;

//ith step,j red
LL dp[3048][3048][2];
int n,m;

inline LL mod(LL x)
{
	while (x>=MOD) x-=MOD;
	while (x<0) x+=MOD;
	return x;
}

int main ()
{
	//freopen ("data.in","r",stdin);
	//freopen ("data2.out","w",stdout);
	int i,j,k;
	scanf("%d%d",&n,&m);
	dp[0][0][0]=1;
	for (i=1;i<=n;i++)
		dp[0][i][1]=1;
	LL ans=0;
	for (i=1;i<=m;i++)
		for (j=0;j<=n;j++)
		{
			if (j==0)
			{
				dp[i][j][0]=mod(dp[i-1][1][0]+dp[i-1][1][1]+dp[i-1][0][0]);
				if (i==m) ans=mod(ans+dp[i][j][0]);
				continue;
			}
			if (j==1)
			{
				dp[i][j][0]=mod((j+1<=n?dp[i-1][j+1][0]:0)+(j==n?dp[i-1][j][0]:2*dp[i-1][j][0])+dp[i-1][j-1][0]+dp[i-1][j][1]);
				if (i==m) ans=mod(ans+dp[i][j][0]);
				dp[i][j][1]=mod((j+1<=n?dp[i-1][j+1][1]:0)+(j==n?0:dp[i-1][j][1]));
				continue;
			}
			dp[i][j][0]=mod((j+1<=n?dp[i-1][j+1][0]:0)+(j==n?dp[i-1][j][0]:2*dp[i-1][j][0])+dp[i-1][j-1][0]);
			dp[i][j][1]=mod((j+1<=n?dp[i-1][j+1][1]:0)+(j==n?dp[i-1][j][1]:2*dp[i-1][j][1])+dp[i-1][j-1][1]);
			if (i==m) ans=mod(ans+dp[i][j][0]);
		}
	/*for (i=0;i<=m;i++)
	{
		for (j=0;j<=n;j++)
			cout<<dp[i][j][0]<<' ';
		cout<<endl;
	}
	cout<<endl;
	for (i=0;i<=m;i++)
	{
		for (j=0;j<=n;j++)
			cout<<dp[i][j][1]<<' ';
		cout<<endl;
	}*/
	printf("%I64d\n",ans);
	return 0;
}

Measured memory_bytes: 143616