akhauriyash/Code-Regression huggingface dataset:
package main

import (
    "fmt"
    "math"
)

var pn map[int]int

func main() {
    pn = make(map[int]int)
    var q int
    fmt.Scan(&q)

    qus := make([][]int, q)
    var min, max int
    min = 9999999
    for i := 0; i < q; i++ {
        var l, r int
        fmt.Scan(&l, &r)
        qus[i] = []int{l, r}
        if l < min {
            min = l
        }
        if r > max {
            max = r
        }
    }

    var cnt int
    pns := make([]int, (max-min)/2+2)
    pns[0] = 0
    for j := min; j <= max; j += 2 {
        if like2017(j) {
            cnt++
        }
        pns[(j-min)/2+1] = cnt
    }
    //fmt.Println(pns)

    for _, q := range qus {
        l := q[0]
        r := q[1]
        lc := pns[(l-min)/2]
        rc := pns[(r-min)/2+1]
        fmt.Println(rc - lc)
    }

}

func like2017(n int) bool {
    //fmt.Println(n)
    return isPN(n) && isPN((n+1)/2)
}

func isPN(n int) bool {
    if n == 1 {
        return false
    }
    if r, ok := pn[n]; ok {
        if r == 1 {
            return false
        } else if r == 2 {
            return true
        }
    }
    max := int(math.Sqrt(float64(n)))
    for i := 2; i <= max; i++ {
        if n%i == 0 {
            pn[n] = 1
            return false
        }
    }
    pn[n] = 2
    return true
}


Measured memory_bytes: 12676
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, x, y;
int main() {
    cin >> n >> x >> y;
    vector<vector<int>> len(n, vector<int>(n));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            len.at(i).at(j) = abs(i-j);
        }
    }

    x--; y--;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            len.at(i).at(j) = min(len.at(i).at(j), len.at(i).at(x) + len.at(y).at(j) + 1);
            len.at(i).at(j) = min(len.at(i).at(j), len.at(i).at(y) + len.at(x).at(j) + 1);
        }
    }

    vector<int> cnt(n);
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            cnt.at(len.at(i).at(j))++;
        }
    }

    for(int i = 1; i < n; ++i) {
        cout << cnt.at(i)/2 << endl;
    }
}

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

int main()
{
  const string Type[] = {"A", "B", "NA"};

  int n;
  while (cin >> n) {
    for (int i = 0; i < n; ++i) {
      string snake;
      cin >> snake;

      int ans = 2;
      int length = static_cast<int>(snake.size());
      if (snake[0] == '>' && snake[length-1] == '~') {
	if (length >= 5 && snake[1] == '\'' && snake.find_first_of("#") != string::npos) {
	  int sharp = snake.find_first_of("#");
	  bool valid = true;
	  for (int j = 2; j < sharp && valid; ++j) {
	    if (snake[j] != '=')
	      valid = false;
	  }
	  for (int j = sharp+1; j < length-1 && valid; ++j) {
	    if (snake[j] != '=')
	      valid = false;
	  }

	  if (valid && sharp-2 == length-2-sharp)
	    ans = 0;
	} else if (length >= 6 && snake[1] == '^' && snake[length-2] == '~') {
	  bool valid = true;
	  for (int j = 2; j < length-2 && valid; j += 2) {
	    if (snake[j] != 'Q' || snake[j+1] != '=')
	      valid = false;
	  }

	  if (valid)
	    ans = 1;
	}
      }
      cout << Type[ans] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define what_is(x) cerr << #x << " is " << x << endl;
int main()
{
    fastIO;
    int x,y;
    cin>>x>>y;
    if ((y/4==x && y%4==0) || ( y%2==0 && y/2==x))
        cout<<"Yes\n";
    else if (y%2!=0 && y%4!=0)
        cout<<"No\n";
    else if (y/2>x && y/2-x<=x )
      cout<<"Yes\n";
    else
        cout<<"No\n";




}


Measured memory_bytes: 3636
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    n = int(input())
    p_list = list(map(int, input().split()))
    count = 0
    for i in range(0,n-2):
        if ((p_list[i] < p_list[i+1] < p_list[i+2]) or (p_list[i+2] < p_list[i+1] < p_list[i])):
            count += 1
    print(count)

if __name__ == "__main__":
    main()

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

int a[3010];
long dp[3010][3010];

int main(){
	int n;
	scanf("%d", &n);
	for(int i=0; i < n; i++)
		scanf("%d", &a[i]);
	for(int i=n-1; i >= 0; i--) {
		for(int j=i; j < n; j++) {
			if(i == j) {
				dp[i][j] = a[i];
			}else{
				dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]);
			}
		}
	}
	printf("%ld\n", dp[0][n-1]);
}


Measured memory_bytes: 70016
#include <iostream>

using u64 = unsigned long long;

u64 f_0(u64 x){
  switch(x % 4){
    case 0: return 0;
    case 1: return x - 1;
    case 2: return 1;
    case 3: return x;
  }
}

int main(){
  u64 A, B;
  std::cin >> A >> B;
  std::cout << (f_0(A) ^ f_0(B + 1)) << std::endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> ii;

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

    map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        int num;
        scanf("%d", &num);
        cnt[num]++;
    }

    int val[cnt.size() + 1], pre[cnt.size() + 1];
    val[0] = pre[0] = 0;
    int idx = 1;
    for (auto i : cnt)
        val[idx] = i.first, pre[idx] = pre[idx - 1] + i.second, idx++;

    ll ans = 1LL * n * (n - 1) * (n - 2) / 6;

    for (int i = 1; i < (int)cnt.size() + 1; i++) {
        for (int j = i; j < (int)cnt.size() + 1; j++) {
            if (i == j && cnt[val[i]] == 1) {
                continue;
            }

            int target = val[i] + val[j];
            int lb = lower_bound(val + 1, val + idx, target) - val;
            // printf("%d %d %d\n", i, j, idx);
            if (i == j)
                ans -= 1LL * cnt[val[i]] * (cnt[val[i]] - 1) / 2 *
                       (pre[idx - 1] - pre[lb - 1]);
            else
                ans -= 1LL * cnt[val[i]] * cnt[val[j]] * (pre[idx - 1] - pre[lb - 1]);
        }
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <math.h>
#include <string> 
#include <bits/stdc++.h>
using namespace std;

int main(){
    double r;
    cin >> r;
    cout << r*2*3.141592 << endl;
    return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define all int i=0; i<n; i++
#define pb push_back;
typedef long long int ll;

#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define mod 1000000007
int main(){
	FAST_IO;
	int n,x;
	cin>>n;
	int arr[n];
	for(int i=1; i<=n; i++){
		cin>>x;
		arr[x-1]=i;
	}
	for(int i=0; i<n; i++)cout<<arr[i]<<" ";
}



Measured memory_bytes: 1280
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int n,mp[505][505];
void solve(int l,int r,int c){
	if(l==r)return;int mid=(l+r)>>1;
	fp(i,l,mid)fp(j,mid+1,r)mp[i][j]=c;
	solve(l,mid,c+1),solve(mid+1,r,c+1);
}
int main(){
	scanf("%d",&n);
	solve(1,n,1);
	fp(i,1,n)fp(j,i+1,n)printf("%d%c",mp[i][j]," \n"[j==n]);
	return 0;
}

Measured memory_bytes: 1536
// A: Travelling Budget
"use strict";

const DEBUG_MODE = false;
const rawInput = DEBUG_MODE
  ? "600\n300\n220\n420"
  : require("fs")
      .readFileSync("/dev/stdin", "utf8")
      .trim();

const process = inputRaw => {
  const inputs = inputRaw.split("\n").map(input => parseInt(input));

  console.log(
    Math.min.apply(Math, inputs.slice(0, 2)) +
      Math.min.apply(Math, inputs.slice(2, 4))
  );
};

process(rawInput);


Measured memory_bytes: 7372
#include <iostream>
using namespace std;
void remove(string & s)
{
	string tmp = "";
	for(int i = 0; i <(int)s.size()-1; i++)
		tmp += s[i];
	s = tmp;
}
int main()
{
	string s, tmp = "";
	cin >> s;
	for(int i = 0; i < s.size(); i++)
	    if( s[i] != 'B' )
	    	tmp += s[i];
		else
			remove(tmp);
	cout << tmp;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0
template <class T>
void dumplist(T list)
{
    for (auto item : list) {
        cout << item << " ";
    }
    cout << endl;
}

void solve()
{
    ll A,B;
    cin >> A >> B;
    ll ans = 0;
    if (A >= 13) {
        ans = B;
    } else if (A >= 6) {
        ans = B / 2;
    }

    cout << ans << endl;
}

int main()
{
    do {
        solve();
    } while (DEBUG);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r, D, x;
  scanf("%d %d %d", &r, &D, &x);
  
  int S = x;
  for(int i = 0; i < 10; i++){
    S = r*S -D;
    cout << S << endl;
  }
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vvchar vector<vector<char>>
#define vchar vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    string s; cin >> s;
    int r=0,w=0;
    rep(i,n)
    if(s[i]=='R') r++;
    else w++;
    string t;
    rep(i,r)t.pb('R');
    rep(i,w)t.pb('W');
    int res=0;
    rep(i,n){
        if(s[i]!=t[i]) res++;
    }
    cout<<res/2<<endl;
}

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

int main()
{
   long int n;
   cin>>n;
  long int a[n],b[n]={0};

   for(long int i=1;i<n;i++){
    cin>>a[i];
    b[a[i]-1]++;
   }
   for(long int i=0;i<n;i++){
   cout<<b[i]<<endl;
   }
}



Measured memory_bytes: 6720
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー
#include <stack>
#include <bitset>

#define rep(i,m,n) for(int i=(m);i<=(n);i++)
#define mer(i,m,n) for(int i=(m);i>=(n);--i)

#define MOD 1000000007
//#define MOD 998244353
//#define MAX 

using namespace std;

using ll = long long int;
using ld = long double;
using std::swap;

vector<int> v;
vector<long long int> vll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<char> vc;
vector<string> vs;




int main() {
	int N,D,ans=0;
	cin >> N >> D;
	rep(i, 1, N) {
		double dist,X,Y;
		cin >> X >> Y;
		dist = pow(pow(X, 2) + pow(Y, 2),0.5);
		if (dist <= D)++ans;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 4356
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

//Ｏ(√n)
//素因数分解(map<int,int>を引数とする)
map<int, int> prime_factor(int n, map<int, int> res){
	for (int i = 2; i * i <= n; i++){
		if (n % i == 0){
			while (n % i == 0){
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n]++;
	return res;
}

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

	map<int, int> m;
	int N;
	cin >> N;
	int ans = 1;

	for (int i = 2; i <= N; i++) {
		m = prime_factor(i, m);
	}

	for(auto a:m){
		ans *= a.second + 1;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  for(int i=0;i<s.length();i++){
  	if(s[i]!=t[i]){
  		cout<<"No"<<endl;
  		return 0;

  	}
  }
  if(t.length()-1 == s.length())  cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3624
use std::io::{BufRead, BufWriter, Write};

const P: usize = 1000000007;

fn main() {
    let stdin = std::io::stdin();
    let stdout = std::io::stdout();
    solve(&mut stdin.lock(), &mut BufWriter::new(stdout.lock()));
}

fn solve<R: BufRead, W: Write>(stdin: &mut R, stdout: &mut BufWriter<W>) {
    let n = stdin.gets().parse::<usize>().unwrap();
    let s = stdin.gets().into_bytes();

    let mut opencount = 0;
    let mut prev = b'W';
    let mut pat = 1;
    for i in 0..2 * n {
        if s[i] == prev {
            if opencount == 0 {
                writeln!(stdout, "0").unwrap();
                return;
            }
            pat = pat * opencount % P;
            opencount -= 1;
            prev = if s[i] == b'B' { b'W' } else { b'B' };
        } else {
            opencount += 1;
            prev = s[i];
        }
    }
    if opencount != 0 {
        writeln!(stdout, "0").unwrap();
        return;
    }
    let mut ans = pat;
    for i in 0..n {
        ans = ans * (i + 1) % P;
    }
    writeln!(stdout, "{}", ans).unwrap();
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main()
{
  	int N, A, B, ans = 0;
  	cin >> N >> A >> B;
  	for(int i = 1; i <= N; i++){
      	int c = 0, j = i;
      	for(; j >= 1; ){
			c += j % 10;
          	j /= 10;
        }
      	if(A <= c && c <= B){
			ans += i;
        }
    }
  	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

typedef long long int ll;

int main() {
	ll x, k, d;
	scanf("%lld%lld%lld", &x, &k, &d);
	if (x == 0) {
		if (k & 1) printf("%lld\n", d);
		else printf("0\n");
	}
	else {
		if (x < 0) x = -x;
		if (k & 1) x -= d;
		if (x < 0) x = -x;
		k >>= 1;
		d <<= 1;
		if (x / d + 1 > k) printf("%lld\n", x - k * d);
		else if (x % d == 0) printf("0\n");
		else printf("%lld\n", min(x % d, d - x % d));
	}
}


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

int main() {
  int N;
  cin >> N;
  string s, t;
  while (cin >> s >> t) {
    if (s == t) {
      cout << 0 << endl;
      continue;
    }
    int n = s.size();
    int rs = s.rfind('1');
    int rt = t.rfind('1');
    int l = n - 1;
    rep(i, n) {
      if (s[i] != t[i]) {
        l = i;
        break;
      }
    }
    // cout << l << " " << rs << " " << rt << endl;
    int ans;
    if (rt < l) {
      ans = rs - rt;
    } else if (rs < l) {
      ans = rt - rs;
    } else {
      ans = abs(rs - l) + abs(rt - l);
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int main(){
  string O,E;
  cin>>O>>E;
  string ans;
  for(int i=0;i<O.size()-1;i++){
    ans+=O.at(i);
    ans+=E.at(i);
  }
  if(O.size()-E.size()==0){
    ans+=O.at(O.size()-1);
    ans+=E.at(E.size()-1);
  }
  else{
    ans+=O.at(O.size()-1);
  }
  cout<<ans<<endl;
}

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

int main()
{
	int n;
	cin>>n;
	
	long long arr[n];
	
	for(int i=0;i<n;i++)
		cin>>arr[i];
		
	if(n==2)
	{
		cout<<arr[0]<<endl;
		return 0;
	}
	
	sort(arr,arr+n,greater<long long> ());
	
	long long sum=arr[0];
	int i=1;
	int rem=n-2;
	
	while(rem)
	{
		if(rem>=2)
		{
			sum+=2*arr[i];
			i++;
			rem-=2;
		}
		else
		{
			sum+=arr[i];
			i++;
			rem--;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 5144
#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 = 2e5 + 5;

int n;
int a[N], b[N], ans[N], tree[4 * N];
vector<int> dp[N], g[N];

int join(int x, int y) {
    return max(x, y);
}

void update(int node, int l, int r, int pos, int val) {
    int m = (l + r) >> 1;

    if (l == r and pos == m) {
        tree[node] = val;
        return ;
    } else if (pos <= m) {
        update(node << 1, l, m, pos, val);
    } else if (pos > m) {
        update((node << 1) + 1, m + 1, r, pos, val);
    }

    tree[node] = join(tree[node << 1], tree[(node << 1) + 1]);
}

int query(int node, int l, int r, int x, int y) {
    if (l > r or l > y or r < x) return 0;
  
    if (l >= x and r <= y) return tree[node];
  
    int m = (l + r) >> 1;
    int q1 = query(node << 1, l, m, x, y);
    int q2 = query((node << 1) + 1, m + 1, r, x, y);
    return join(q1, q2);
}

void dfs(int x, int p) {
    int res = 1 + query(1, 1, n, 1, a[x] - 1);
    dp[a[x]].push_back(res);
    
    update(1, 1, n, a[x], res);
    ans[x] = query(1, 1, n, 1, n);
    
    for (int y: g[x]) {
        if (y != p) {
            dfs(y, x);
        }
    }
    
    dp[a[x]].pop_back();
    update(1, 1, n, a[x], dp[a[x]].back());
}

int32_t main(int32_t argc, char** argv) {
    ios::sync_with_stdio(false); cin.tie(nullptr);

    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        b[i] = a[i];
        dp[i].pb(0);
    }

    sort(b + 1, b + n + 1);

    for (int i = 1; i <= n; i++) {
        a[i] = lower_bound(b + 1, b + n + 1, a[i]) - b;
        assert(1 <= a[i] and a[i] <= n);
    }

    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }

    dfs(1, 0);

    for (int i = 1; i <= n; i++) {
        cout << ans[i] << "\n";
    }
}

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

// bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
//     return arg1.first > arg2.first;
// }

int main(void) {
    int n;
    cin >> n;

    vector<int> v(n);
    vector<int> c(n);

    for(int i=0;i<n;i++) {
        cin >> v.at(i);
    }
    for(int i=0;i<n;i++) {
        cin >> c.at(i);
    }

    int ans=0;
    for(int i=0;i<n;i++) {
        ans += max(0, v.at(i) - c.at(i));
    }

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


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//


int main() {

    int N, M; cin >> N >> M;
    vector<pair<ll,ll>> p(N);
    rep(i,N) cin >> p[i].first >> p[i].second;
    Sort(p);
    int m = 1;
    int num = 0;
    ll ans = 0;
    while (m <= M) {
        if (p[num].second == 0) {
            ++num;
        }
        else {
            ans += p[num].first;
            --p[num].second;
            ++m;
        }
    }
    out(ans);

    return 0;
}






Measured memory_bytes: 1792
#include<iostream>


using namespace std;



long long n,a,b;

int main()
{
	cin >> n >> a >> b;
	
	if((n == 1 && (b - a) > 0) || (b - a) < 0) 
	{
	cout << 0 << endl;
	return 0;
	}
	cout << (n - 2) * (b - a) + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int k = sc.nextInt();
        int[][] a = new int[k+1][k+1];
        long ans = 0L;
        for (int i = 1; i <= k; i++) {
            for (int j = 1; j <= k; j++) {
                int x = a[i][j];
                if(x == 0) {
                    x = gcd(i,j);
                    a[i][j] = x; a[j][i] = x;
                }
                for (int l = 1; l <= k; l++) {
                    int y = a[x][l];
                    if(y == 0){
                        y = gcd(x, l);
                        a[x][l] = y; a[l][x] = y;
                    }
                    ans += y;
                }
            }
        }
        System.out.println(ans);
        sc.close();

    }

    public static int gcd(int a, int b) {
        if (a < b)
            return gcd(b, a);
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }

}


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

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

int main() {
	int n,k;
  vector<int> p, d;
	cin >> n;
  rep(i,n) {
    cin >> k;
    p.push_back(k);
    d.push_back(k);
  }
  sort(d.begin(), d.end());
  int cnt = 0;
  rep(i,n) {
    if (p.at(i) != d.at(i)) cnt++;
  }
  if (cnt <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define fin(x) cout << x << endl;

using namespace std;
using ll = long long;

int main(void) {
  int n, r;
  cin >> n >> r;
  if (n >= 10) {
    fin(r);
  } else {
    cout << r + 100 * (10 - n) << endl;
  }
	return 0;
}



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

int main() {
  
  int D, T, S;
  cin >> D >> T >> S;
  
  if (T*S >= D) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;    
  }

return 0;
}  

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
long long  a,b,ta,tb;
	
	while(cin>>a>>b){
	ta=a;tb=b;
	if(a<b)swap(a,b);
	while(1){
		long long  tmp=b;
		b=a%b;
		a=tmp;
		//cout<<a<<b<<endl;
		if(b==0)break;
	}
	cout<<a<<" "<<ta*tb/a<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Map
    {
        private readonly long[] values;

        public Map(long[] values)
        {
            this.values = values;
            Array.Sort(values);
        }

        public long[] Search(long value)
        {
            int a = 0;
            int b = values.Length - 1;
            if (value < values[a]) { return new[] { 0, values[a] }; }
            if (value > values[b]) { return new[] { values[b], long.MaxValue }; }
            while (b - a >= 2)
            {
                int m = (a + b) / 2;
                if (values[m] < value) { a = m; } else { b = m; }
            }
            return new[] { values[a], values[b] };
        }
    }

    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static IEnumerable<long> Solve(int A, int B, int Q, long[] S, long[] T, long[] X)
        {
            const long INF = long.MaxValue >> 2;
            var ans = new long[Q];
            var shrines = new Map(S);
            var temples = new Map(T);
            for (int q = 0; q < Q; ++q)
            {
                long x = X[q];
                var s = shrines.Search(x);
                var t = temples.Search(x);
                long min = long.MaxValue;
                long s0 = (s[0] > 0) ? x - s[0] : INF;
                long t0 = (t[0] > 0) ? x - t[0] : INF;
                long s1 = (s[1] < INF) ? s[1] - x : INF;
                long t1 = (t[1] < INF) ? t[1] - x : INF;
                min = Math.Min(Math.Max(s0, t0), min);
                min = Math.Min(Math.Max(s1, t1), min);
                min = Math.Min(Math.Min(s0, t1) * 2 + Math.Max(s0, t1), min);
                min = Math.Min(Math.Min(s1, t0) * 2 + Math.Max(s1, t0), min);
                ans[q] = min;
            }
            return ans;
        }
        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int A = V[0], B = V[1], Q = V[2];
            long[] S = new long[A];
            for (int a = 0; a < A; ++a) { S[a] = ReadLong(); }
            long[] T = new long[B];
            for (int b = 0; b < B; ++b) { T[b] = ReadLong(); }
            long[] X = new long[Q];
            for (int q = 0; q < Q; ++q) { X[q] = ReadLong(); }
            foreach (long ans in Solve(A, B, Q, S, T, X))
            {
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 19524
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>

using namespace std;

int main()
{
    string str;
    cin >> str;

    if(str[0] == str[1] && str[1] == str[2]){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    return 0;
}

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

int main(){
  int sx,sy,tx,ty,i;
  cin>>sx>>sy>>tx>>ty;
  string s="";
  for(i=0;i<abs(tx-sx);i++){
    s+='R';
  }
  for(i=0;i<abs(ty-sy);i++){
    s+='U';
  }
  for(i=0;i<abs(tx-sx);i++){
    s+='L';
  }
  for(i=0;i<abs(ty-sy);i++){
    s+='D';
  }
  s+='L';
  for(i=0;i<=abs(ty-sy);i++){
    s+='U';
  }
  for(i=0;i<=abs(tx-sx);i++){
    s+='R';
  }
  s+='D';
  s+='R';
  for(i=0;i<=abs(ty-sy);i++){
    s+='D';
  }
  for(i=0;i<=abs(tx-sx);i++){
    s+='L';
  }
  s+='U';
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



signed main() {
    ll n; 
    cin >> n;
    map <ll, ll> mp;
    ll a;
    ll r = 0;
    
    rep(i, n) {
        cin >> a;
        mp[a] ++;
    }
    
    for (auto i: mp) {
        r += (i.second % 2);
    }
    mes(r);
    
}


Measured memory_bytes: 9648
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol(const vector<int>& v1, 
               const vector<int>& v2){ 
 return v1[0] < v2[0]; } 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }

void solve()
{
	ll n;
	cin>>n;
	vll a(n),fr(10000000,0),done(10000000,0);
	for(ll i=0;i<n;i++)
		cin>>a[i],fr[a[i]]++;
	for(ll i=0;i<10000000;i++)
	{
		
		if(fr[i]>0 && done[i]==0)
		{
			for(ll j=i*2;j<=10000000;j+=i)
				done[j]=1;
			if(fr[i]>=2)
				done[i]=1;
		}
	}
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		if(done[a[i]]==0)
		{
			ans++;
		}
	}
	cout<<ans;
	return;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 161080
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;

int main() {
  int N,M,xs,ys,ycurrent,xcurrent,ynext,xnext,max1=0,max2=0;
  queue<pair<int,int>> q;
  pair<int,int> p;
  cin >>N>>M;
  vector<vector<char>> A(N,vector<char>(M));
  vector<vector<int>> B(N,vector<int>(M));
  for(int i=0; i<N; i++){
   for(int j=0; j<M;j++){
     cin>>A[i][j];
   }
  }
 for(int i=0; i<N; i++){
   for(int j=0; j<M;j++){
      if(A[i][j]=='.'){ys=i;xs=j;
   for(int i=0; i<N; i++){
   	for(int j=0; j<M;j++){B[i][j]=INF;
      }
    }
    B[ys][xs]=0;
    vector<int> dx={-1,0,1,0},dy={0,-1,0,1}; 
    p = make_pair(ys,xs);
    q.push(p);
  
   while(!q.empty()) {
    ycurrent=q.front().first; xcurrent=q.front().second; q.pop();
     for(int i=0; i<4; i++){
       ynext=ycurrent+dy[i]; xnext=xcurrent+dx[i];
       if(0<=ynext && ynext<N && 0<=xnext && xnext<M 
       && B[ynext][xnext]==INF && A[ynext][xnext]=='.'){
         B[ynext][xnext]=B[ycurrent][xcurrent]+1;
         p = make_pair(ynext,xnext);
         q.push(p);
         }
   	  }
   }  
   for(int i=0; i<N; i++){
     for(int j=0; j<M;j++){
       if(B[i][j]!=INF&&B[i][j]>max1){
       max1=B[i][j];
          }
        }
 	  }
    }
  }
}
 cout<<max1<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int a, b;
  
  cin >> a >> b;
  
  int cnt;
  if (b==1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i=0; i<20; i++) {
    cnt = a + (a-1)*i;
    
    if (cnt >= b) {
      cout << i+1 << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
map<pair<int, int>, int> edge_idx;

long long calc_path(int prev, int now, int goal, long long current_path, vector<vector<int>> & adj){
  if(now == goal){
    return current_path;
  }
  for(auto next: adj[now]){
    if(next == prev){
      continue;
    }
    long long path = calc_path(
                               now,
                               next,
                               goal,
                               current_path | (1LL << (edge_idx[make_pair(now, next)])),
                               adj
                               );
    if(path != -1){
      return path;
    }
  }
  return -1;
}


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

  vector<vector<int>> adj(N);
  for(int i = 0; i < N - 1; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
    edge_idx[make_pair(a, b)] = i;
    edge_idx[make_pair(b, a)] = i;
  }

  int M;
  cin >> M;

  vector<long long> path(M);
  for(int i = 0; i < M; i++){
    int u, v;
    cin >> u >> v;
    u--; v--;
    path[i] = calc_path(-1, u, v, 0, adj);
    //cout << path[i] << endl;
  }

  long long ans = 0;
  for(long long bit = 1; bit < (1LL << M); bit++){
    long long or_path = 0;
    int bit_sig = -1;
    for(int i = 0; i < M; i++){
      if((bit >> i) & 1){
        or_path |= path[i];
        bit_sig *= -1;
      }
    }
    int white_cnt = 0;
    for(int i = 0; i < N; i++){
      if((or_path >> i) & 1){
        white_cnt++;
      }
    }
    //cout << "bit: " << bit <<", bit_sig: " << bit_sig << ", or_path: " << or_path << ", white_cnt: " << white_cnt << endl;
    long long pattern = (1LL << (N - 1 - white_cnt));
    ans += bit_sig * pattern;
  }
  cout << (1LL << (N - 1)) - ans << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n,r;
    cin>>n>>r;
    lli ans=0;
    while(n>0)
    {
        n=n/r;
        ans++;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int len = s.length();
    vector<int> arr(3, 0);
    for(char c : s) {
        if(c == 'a')
            arr[0]++;
        else if(c == 'b')
            arr[1]++;
        else
            arr[2]++;
    }
    sort(arr.begin(), arr.end());
    if(arr[2] - arr[0] <= 1 && arr[1] - arr[0] <= 1) {
        cout << "YES";
    } else {
        cout << "NO";
    }
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

void print() { cout << endl; }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << ((sizeof...(tail)!=0)?" ":""); print(forward<Tail>(tail)...); }
template <class T> void print(vector<T> &vec) { for (auto& a : vec) { cout << a << ((&a!=&vec.back())?" ":""); } cout << endl; }
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec); } }

struct UnionFind {
	vector<int> data;

	UnionFind(int sz) {
		data.assign(sz, -1);
	}

	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return;
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
	}

	int find(int k) {
		if(data[k] < 0) return(k);
		return data[k] = find(data[k]);
	}

	bool same(int x, int y)	{
		return find(x) == find(y);
	}

	int size(int k)	{
		return -data[find(k)];
	}
};

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

    int n, m, k; cin >> n >> m >> k;
    vector<vector<int>> G(n);
    UnionFind uf(n);
    rep(i, m) {
        int x, y; cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
        uf.unite(x, y);
    }
    vector<vector<int>> B(n);
    rep(i, k) {
        int x, y; cin >> x >> y;
        x--; y--;
        B[x].push_back(y);
        B[y].push_back(x);
    }

    rep(i, n) {
        int sz = uf.size(i) - G[i].size() - 1;
        for(const int& b: B[i]) {
            if (uf.same(i, b)) sz--;
        }
        cout << sz;
        if (i<n-1) cout << " ";
        else cout << endl;
    }
}

Measured memory_bytes: 12280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var h = ReadInts();
            var c = 0;
            var an = 0;
            var list = new List<string>();
            for (int i = 0; i < n; i++)
            {
                if (c <= h[i])
                {
                    an++;
                    c = h[i];
                }
            }
            WriteLine(an);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var aArray = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var acum = new long[N];
            var revAcum = new long[N];
            acum[0] = aArray[0];
            revAcum[N - 1] = aArray[N - 1];

            for (var i = 1; i < N; i++)
            {
                acum[i] = acum[i - 1] + aArray[i];
                revAcum[N - i - 1] = revAcum[N - i] + aArray[N - i - 1];
            }

            var min = long.MaxValue;
            for (var i = 0; i < N - 1; i++)
            {
                min = Math.Min(Math.Abs(acum[i] - revAcum[i + 1]), min);
            }
            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 36548
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

int main(){
  int n;
  cin >> n;
  vl a(n+1);
  rep(i,n) cin >> a[i+1];
  vvl dp(n+1, vl(n+1));
  vl sum(n+1);
  rep(i,n) sum[i+1] = sum[i] + a[i+1];
  for(int r=2; r<=n; r++){
    for(int l=r-2; l>=0; l--){
      dp[l][r] = dp[l][r-1] + dp[r-1][r] + sum[r] - sum[l];
      for(int k=r-1; k>=0; k--){
        if(l == k) break;
        dp[l][r] = min(dp[l][r], dp[l][k] + dp[k][r] + sum[r] - sum[l]);
      }
    }
  }
  cout << dp[0][n] << endl;
}


Measured memory_bytes: 4868
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int K, T;
    cin >> K >> T;
    VI a(T);
    REP(i, T) cin >> a[i];
    bool f = true;
    if (T == 1) {
        cout << a[0] - 1 << endl;
        return 0;
    }
    SORT(a);
    REP(i, K) {
        if (a.size() <= 1) break;
        if (f) a.back()--;
        else a.front()--;
        while (a.size() > 0 && a.front() == 0) {
            a.erase(a.begin());
            SORT(a);
        }
        //if (a.size() > 0 && a.back() == 0) a.erase(a.end() - 1);
        f = !f;
    }
    //FORE(el, a) cerr << el << " ";
    if (a.size() >= 1) cout << accumulate(ALL(a), 0) - 1 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
int main(){
	ll a[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	ll n;
	cin>>n;
	cout<<a[n];
}


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

main()
{
int h,w;
while(1){
	scanf("%d %d",&h,&w);
	if((h|w)==0)break;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
}
}


Measured memory_bytes: 2112
import itertools
ini = int(input().split(" ")[0])
try:
    negaset = [int(x) for x in input().split(" ")]
except :
    print (ini)
    exit()
okset = sorted([str(i) for i in range (10) if i not in negaset]) 
#print(ini,okset)

for p in [int("".join(j)) for j in itertools.chain.from_iterable (itertools.product(okset,repeat = i)  for i in range (len(str(ini)),len(str(ini))+2) )]:
    if p >= ini:
        print(p)
        break

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

int32_t main(){
	int H, W, h, w; cin>>H>>W>>h>>w;
	vector<vector<int>> a(H, vector<int>(W, 0));
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < W; j++){
			a[i][j] = 1;
		}
	}
	for(int col = 0; col < w; col++){
		for(int row = 0; row < H; row++){
			a[row][col] = 1;
		}
	}
	int ans = 0;
	for(auto row: a){
		for(int x: row){
			if(x == 0){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256