akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <stdio.h>
#include <math.h>

#define K 10000
typedef long long ll;

using namespace std;
int N;
vector<int> A;
vector<int> B;
vector<int> C;

void counting_sort(){
    for (int i = 0; i <= K; i++){
        C.push_back(0);
    }
    for (int j = 0; j < A.size(); j++){
        C[A[j]] = C[A[j]] + 1;
    }
    for (int i = 0; i <= K; i++){
        if (C[i] > 0){
            while (C[i] > 0){
                B.push_back(i);
                C[i] = C[i] - 1;
            }
        }
    }
}

//提出時には消す
#include <fstream>

int main()
{
    //提出時には消す
    // std::ifstream in("/home/ubuntu/procon/input.txt");
    // cin.rdbuf(in.rdbuf());

    cin.tie(0);

    int n;
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> n;
        A.push_back(n);
    }

    counting_sort();
    
    for (int i = 0; i < B.size(); i++)
    {   
        if (i < B.size() - 1){
            cout << B[i] << " ";
        }else{
            cout << B[i] << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 22904
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, A, K, t;

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A >> K;
		while (A%K) {
			A -= ((A%K - 1) / (A / K + 1) + 1)*(A / K + 1);
		}
		t ^= A / K;
	}
	if (t) {
		puts("Takahashi");
	}
	else {
		puts("Aoki");
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <functional>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define sz(a) int((a).size())
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const int N = (int)2e5+77;
const ll mod = (ll)1e9+7;

ll a[4],n,ans;

int main() {
    forn(i, 4) cin >> a[i];
    cin >> n;
    n = n * 4;
    ford(i, 3, 0) {
        ll k = 1 << i;
        ll mn = 1e10;
        forn(j, i + 1) {
            mn = min(mn, k * a[j]);
            k /= 2;
        }
        k = 1 << i;
        ll x = (n / k);
        ans += x * mn;
        n -= x * k;
        if (n <= 0) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
divs = Array.new(0)
for i in 1..([n, 10**6].min)
  if n % i == 0
    divs.push(i)
  end
end

min = 10**13
divs.each{|d| min = [min, d+(n/d)].min}
puts min-2

Measured memory_bytes: 1788
h, w, k = map(int, input().split())
c = []
for i in range(h):
  c.append(input())
t = 2**(h+w)
ans = 0
for i in range(t):
  tc = c[:]
  b = format(i, 'b').zfill(h+w)
  for j in range(len(b)):
    if b[j] == "1":
      if j < h:
        tc[j] = "?"*w
      else:
        for l in range(h):
          tc[l] = tc[l][:(j-h)] + "?" + tc[l][(j-h+1):]
  cn = 0
  for j in range(h):
    cn += tc[j].count("#")
  if cn == k:
    ans += 1
print(ans)

Measured memory_bytes: 9156
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

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

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

  int count = 0;
  int s = 0;
  while(s < n){
    int t = s;
    while(t < n && a[s] == a[t]){
      ++t;
    }
    count += (t - s) / 2;
    s = t;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int x = scanner.nextInt();
        final int a = scanner.nextInt();
        if (x < a) {
            System.out.println(0);
        }else {
            System.out.println(10);
        }
    }
}


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

int main() {
    long long int i, n, c, cal=0;
    long long int x[110000]={0}, v[110000]={0};
    long long int sum_r[110000]={0}, sum_l[110000]={0};
    long long int counter_l[110000]={0}, counter_r[110000]={0};
    
    cin >> n >> c;
    
    for(i=1; cin >> x[i] >> v[i]; i++);
    
    for(i=1; i<=n; i++) {
        sum_r[i] = sum_r[i-1] + v[i];
        sum_l[i] = sum_l[i-1] + v[n-i+1];
    }
    for(i=1; i<=n; i++) {
        sum_r[i] -= x[i];
        sum_l[i] -= c-x[n-i+1];
    }
    
    for(i=1; i<=n; i++) {
        counter_l[i] = max(counter_l[i-1], sum_l[i]);
        counter_r[i] = max(counter_r[i-1], sum_r[i]);
    }
    
    for(i=1; i<=n; i++) {
        cal = max(cal, max(sum_r[i], sum_r[i]-x[i]+counter_l[n-i]));
        cal = max(cal, max(sum_l[i], sum_l[i]-(c-x[n-i+1])+counter_r[n-i]));
    }
    
    cout << cal << endl;
}


Measured memory_bytes: 5376
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    string s,t; cin >> s >> t;
    int ans = 0;
    rep(i,s.size()){
        if(s[i] != t[i]){
            ans++;
        }
    }
    dunk(ans);
    return 0;
}

Measured memory_bytes: 3928
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<LL,LL>PL;
const LL INF=1e18;
const LL MOD=1e9+7;
LL N,i,j;
LL cnt,ans;
LL C[200010],D[200010];
vector<LL>V[200010],Q[200010];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>N;
    for(i=0;i<N;i++)
    {
        cin>>C[i];
        if(i==0||C[i]!=C[i-1])
            V[C[i]-1].push_back(i);
    }
    for(i=0;i<200000;i++)
    {
        for(j=1;j<V[i].size();j++)
        {
            Q[V[i][j-1]].push_back(cnt);
            Q[V[i][j]].push_back(cnt++);
        }
    }
    ans=1;
    for(i=0;i<N;i++)
    {
        for(j=0;j<Q[i].size();j++)
            ans=(ans+D[Q[i][j]])%MOD;
        for(j=0;j<Q[i].size();j++)
            D[Q[i][j]]=ans;
    }
    cout<<ans<<endl;
    return 0;
}


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

#define   ll     long long int

int ara[111];
vector<int> v;

int main( )
{
    int n, i, j, k, s = 0;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> ara[i];
        s += ara[i];
        if (ara[i] % 10) v.push_back(ara[i]);
    }
    if (s % 10 == 0) {
        sort(v.begin(), v.end());
        int ss = s;
        for (i = 0; s % 10 == 0 && i < (int) v.size(); i++) {
            s -= v[i];
        }
        if (s % 10 == 0) {
            s = 0;
        }
        cout << s << '\n';
    }
    else {
        cout << s << '\n';
    }
    return 0;
}




Measured memory_bytes: 256
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    N,Z,W=MI()
    a=LI()
    inf=10**10
    
    #xがi枚目,yがj枚目を持っているとき
    dp=[[0]*(N+1) for _ in range(N+1)]
    
    #dpのj列目の,j行目より先の最大値を持っておく
    Mj=[0]*(N+1)
    
    #dpのi行目の,i列めより先の最小値を持っておく
    mi=[inf]*(N+1)
    
    #初期化
    dp[-1][0]=abs(a[-1]-W)
    Mj[0]=abs(a[-1]-W)
    for i in range(1,N):
        dp[i][-1]=abs(a[-1]-a[i-1])
        dp[-1][i]=abs(a[-1]-a[i-1])
        Mj[i]=abs(a[-1]-a[i-1])
        mi[i]=abs(a[-1]-a[i-1])
        
    for i in range(N-1,0,-1):
        for j in range(N-1,-1,-1):
            if i==j:
                continue
            if i>j:
                dp[i][j]=mi[i]
                Mj[j]=max(Mj[j],dp[i][j])
            else:
                dp[i][j]=Mj[j]
                mi[i]=min(mi[i],dp[i][j])
        
    print(Mj[0])
        

main()


Measured memory_bytes: 74332
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll N;
	cin >> N;
	ll num = 0;
	for(ll i = 1; i <= N; i++) {
		if(to_string(i).size() % 2 == 1) {
			num++;
		}
	}
	cout << num << endl;
}


Measured memory_bytes: 3700
#include <stdio.h>
int main(){
  int X,Y,Z;
    scanf("%d %d %d",&X,&Y,&Z);
   if(2*X==Y+Z){
    printf("No\n");
   }else if(X==Y||X==Z||Y==Z){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1644
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	int a;
	cin>>a;
	cout<<3*a*a<<endl;
	return 0;
}

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

int n, m;

unsigned dp[1010][1010];
int main() {
    while(1) {
        std::cin >> n >> m;

        if(n * m == 0) {
            return 0;
        }

        std::vector<int> A(n), B(n);

        for(int i = 0; i < n; ++i) {
            std::cin >> A[i];
        }
        for(int i = 0; i < n; ++i) {
            std::cin >> B[i];

            A[i] = (B[i] - A[i] + m) % m;
        }
        memset(dp, -1, sizeof(dp));

        for(int i = 0; i < n; ++i) {
            dp[0][i] = A[0] + i * m;
        }
        for(int i = 1; i < n; ++i) {
            for(int j = 0; j < n; ++j) {
                dp[i][j] = std::min(std::max(0, A[i] - A[i - 1]) + dp[i - 1][j], dp[i][j]);

                if(j != 0) {
                    dp[i][j] = std::min(A[i] + m - A[i - 1] + dp[i - 1][j - 1], dp[i][j]);
                }
                dp[i][j] = std::min(dp[i - 1][j + 1], dp[i][j]);
            }
        }

        int min = 1e9;
        for(int i = 0; i < n; ++i) {
            min = std::min(static_cast<int>(dp[n - 1][i]), min);
        }
        assert(min >= 0);

        std::cout << min << std::endl;
    }

}


Measured memory_bytes: 7092
#include <stdio.h>
int main(){
  int taka,aoki;
  int n,i;
  
  scanf("%d %d %d",&taka,&aoki,&n);
  
  for(i=0;i<n;i++){
    if(i%2==0){
      taka/=2;
      aoki+=taka;
    } else {
      aoki/=2;
      taka+=aoki;
    }
  }
  printf("%d %d",taka,aoki);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    ll n,m;cin>>n>>m;
    vector<bool> a(n+1,true);
    rep(i,m){
        ll tmp;cin>>tmp;
        a[tmp] = false;
    }
    vector<ll> dp(n+1);

    dp[0] = 1;
    if(a[1]) dp[1] = 1;
    for(ll i =  2;i<=n;i++){
        if(a[i-1])dp[i] += dp[i-1];
        if(a[i-2])dp[i] += dp[i-2];
        dp[i] %= MOD;
    }

    cout << dp[n] <<endl;
}




Measured memory_bytes: 1024
program main
Implicit None
	integer(8)::n,m,i,k
	integer(8),allocatable::l(:),r(:),g(:)
	
	read*,n,m
	allocate(l(m),r(m),g(n+1))
	
	g = 0
	do i = 1,m
		read*,l(i),r(i)
		g(l(i)) = g(l(i))+1
		g(r(i)+1) = g(r(i)+1)-1
	enddo
	
	do i = 2,n
		g(i) = g(i-1)+g(i)
	enddo
	
	k = 0
	do i = 1,n
		if(g(i) == m) k = k+1
	enddo
	
	print"(i0)",k
end program main

Measured memory_bytes: 2560
/**
*    author:  Dooloper
*    created: 17.09.2020 22:31:35
**/

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <functional>
#include <cassert>


using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define PI 3.14159265358979323846264338327950L
const int mod = 1e9 + 7;

int main() {
    cin.tie(0);
    int N;
    ll sum = 0;
    cin >> N;

    vector<int> A(N, 0);
    for (int i = 0; i < N; i++){
      cin >> A[i];
      sum += A[i];
      sum %= mod;
    }

    ll ans = 0;
    for (int i : A){
      sum -= i;
      if(sum < 0)
        sum += mod;
      ans += i * sum;
      ans %= mod;
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	vector<pair<ll, ll>> p(n);
	vector<ll> x(n), y(n);
	rep(i, n) {
		ll xt, yt;
		cin >> xt >> yt;
		p[i] = {xt, yt};
		x[i] = xt;
		y[i] = yt;
	}
	sort(all(x));
	sort(all(y));
	ll ans = 1LL << 62;
	for(int ix = 0; ix < n-1; ix++) {
		for(int jx = ix+1; jx < n; jx++) {
			for(int iy = 0; iy < n-1; iy++) {
				for(int jy = iy+1; jy < n; jy++) {
					int cnt = 0;
					rep(k, n) {
						ll kx = p[k].first;
						ll ky = p[k].second;
						if(kx >= x[ix] && kx <= x[jx]) {
							if(ky >= y[iy] && ky <= y[jy]) {
								cnt++;
							}
						}
					}
					if(cnt >= k) {
						ll area = (x[jx] - x[ix]) * (y[jy] - y[iy]);
						ans = min(ans, area);
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <utility>
#include <algorithm>
#define inf 10e8
typedef long long ll;

int main(void) {
  ll i, j, k, n, ans, max;
  scanf("%lld", &n);
  std::pair<ll, ll> p[n];
  ll sum[n];
  for(i = 0; i < n; ++i) scanf("%lld%lld", &p[i].first, &p[i].second);
  std::sort(p, p + n);
  sum[0] = p[0].second;
  for(i = 1; i < n; ++i) sum[i] = sum[i - 1] + p[i].second;
  ans = sum[0];
  max = p[0].first;
  for(i = 1; i < n; ++i) {
    if(max < p[i].first - sum[i - 1]) max = p[i].first - sum[i - 1];
    if(ans < sum[i] - p[i].first + max) ans = sum[i] - p[i].first + max;
  }
  printf("%lld\n", ans);
  return 0;
}


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

using namespace std;
using ll=long long;

const ll INF = 1e15;
ll dp[105][100005];
ll w[100005];
ll v[100005];
ll N, W;

int main()
{
    cin >> N >> W;
    for(int i = 1;i <= N;i++)
    {
        cin >> w[i] >> v[i];
    }
    for(int i = 0;i< 105;i++)
    {
        for(int j = 0;j < 100005;j++)
        {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(int i = 1;i <= N;i++)
    {
        for(int j = 0;j <= 100000;j++)
        {
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            if(j - v[i] >= 0)
            {
                dp[i][j] = min(dp[i-1][j-v[i]] + w[i], dp[i][j]);
            }
        }
    }
    ll ans = 0;
    for(int i = 0;i <= 100000;i++)
    {
        if(dp[N][i] <=W)
        {
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 82936
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

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

    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK" << '\n';
            return 0;
        }
    }
    cout << "NG" << '\n';

    fflush(stdout);
    return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>

#define MAX 100000

typedef struct{
  char name[11];
  int time;
} Process;

Process P[MAX];
int head,tail;

int min(int,int);
void initialize(void);
int isEmpty(void);
int isFull(void);
void enqueue(Process);
Process dequeue(void);

int main(void){
  int n,q,t_sum=0;
  Process tmp;
  int i;

  scanf(" %d %d",&n,&q);

  for(i = 0; i < n; i++){
    scanf(" %s %d",P[i].name,&P[i].time);
    enqueue(P[i]);
  }

  while(head != tail){
    tmp = dequeue();
    if(tmp.time == 0) continue;
    t_sum += min(tmp.time,q) == tmp.time ? tmp.time : q;
    tmp.time -= min(tmp.time,q) == tmp.time ? tmp.time : q;
    if(tmp.time != 0){
      enqueue(tmp);
    }
    else{
      printf("%s %d\n",tmp.name,t_sum);
    }
  }
  
  
  return 0;
}

int min(int x, int y){
  if(x <= y) return x;
  else return y;
}

void initialize(void){
  head = tail = 0;
}

int isEmpty(void){
  return head == tail;
}

int isFull(void){
  return head == (tail+1) % MAX;
}

void enqueue(Process x){
  if(isFull()){
    fprintf(stderr,"Queue is full\n");
  }
  else{
    P[tail] = x;
    if(tail + 1 == MAX) tail = 0;
    else tail++;
  }
}

Process dequeue(void){
  Process x;
  if(isEmpty()){
    fprintf(stderr,"Queue is empty\n");
    Process T={
      "error",
      0,
    };
    return T;
  }
  x = P[head];
  if(head + 1 == MAX) head = 0;
  else head++;
  return x;
}
  



Measured memory_bytes: 3256
#include <stdio.h>

int main(void){
	int i,j,H,W;

	H = 1;
	W = 1;

	while(H != 0 || W != 0){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0){
			break;
		}
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				if(i == 0 || (i+1) == H){
					printf("#");
				}
				else{
					if(j == 0 || (j+1) == W){
						printf("#");
					}
					else{
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b==10||b+c==10||a+c==10){
    if(a==7||b==7||c==7)
      cout<<"YES"<<endl;
  }
    else{
      cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "stdio.h"
#include "string.h"

int N, M;
char s[100][10], t[100][10];

int main(void){
	int max_pnt=0;

	scanf("%d", &N);

	for(int n=0; n<N; n++){
		fflush(stdin);
		scanf("%s", s[n]);
	}

	scanf("%d", &M);

	for(int m=0; m<M; m++){
		fflush(stdin);
		scanf("%s", t[m]);
	}

	for(int n=0; n<N-1; n++){
		int point = 1;

		for(int n2=n+1; n2<N; n2++){
			if(strcmp(s[n], s[n2])==0) point++;
		}

		for(int m=0; m<M; m++){
			if(strcmp(s[n], t[m])==0) point--;
		}

		if(point>max_pnt) max_pnt = point;
	}
	
	printf("%d\n", max_pnt);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include <random>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int a,b;
  scanf("%d%d",&a,&b);
  if (a == b) {
    cout<<0<<endl;
    return 0;
  }
  if (abs(a) == abs(b)) {
    cout<<1<<endl;
    return 0;
  }
  if (abs(a) < abs(b)) {
    int ans = abs(b)-abs(a);
    if (a < 0) ans++;
    if (b < 0) ans++;
    cout<<ans<<endl;
    return 0;
  } else {
    int ans = abs(a)-abs(b);
    if (a > 0) ans++;
    if (b > 0) ans++;
    cout<<ans<<endl;
    return 0;
  }
  return 0;
}































Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y,ans;
	cin >> x >> y;
	if((x>=0&&x<y)||(y<=0&&x<y)){
		ans=y-x;
	}else if((y==0&&y<x)||(x<0&&y>-1*x)||(y<0&&y>-1*x)){
		ans=1+y+x;
	}else if(y==-1*x){
		ans=1;
	}else if((y<0&&x>=0&&y<-1*x)||(x<0&&y>0&&y<-1*x)){
		ans=1-x-y;
	}else if((x<0&&y<x)||(y>0&&y<x)){
		ans=2+x-y;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn check(n: u32, k: u32, p: u32, w: Vec<u32>) -> u32 {
    let mut i: usize = 0;
    let mut j: u32 = 0;
    while j < k {
        let mut s: u32 = 0;
        while s + w[i] <= p {
            s += w[i];
            i += 1;
            if i as u32 == n {
                return n;
            }
        }
        j += 1;
    }
    return i as u32;
}

fn main() {
    let n: u32 = read();
    let k: u32 = read();
    let w: Vec<u32> = (0..n)
        .map(|_| {
            let number: u32 = read();
            number
        })
        .collect();
    let mut left: u32 = 0;
    let mut right: u32 = 100_000 * 10000;
    let mut mid: u32;
    while right - left > 1 {
        mid = (right + left) / 2;
        if check(n, k, mid, w.clone()) >= n {
            right = mid;
        } else {
            left = mid;
        }
    }
    println!("{}", right);
}



Measured memory_bytes: 5040
import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] strs = br.readLine().split(" ");
    int[] num = new int[3];
    for (int i = 0; i < 3; i++) {
      num[i] = Integer.parseInt(strs[i]);
    }
    Arrays.sort(num);
    
    System.out.println(num[0] * num[1] / 2);
  }
}

Measured memory_bytes: 21204
import math

n = int(input())
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
diff = 0

for i in range(n-1):
    diff += math.factorial(n-1-i) * (a[i] - b[i])
    for j in range(n-1-i):
        if a[i+1+j] > a[i]:
            a[i+1+j] -= 1
            
        if b[i+1+j] > b[i]:
            b[i+1+j] -= 1

print(abs(diff))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <queue>

#define ll long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){ return (a % b)? gcd(b, a%b) : b; }
template<typename T> T lcm(T a, T b){ return a * b / gcd(a, b); }

int main(void){
    string s;
    cin >> s;
    int n = s.length();
    if(s[n-1] == 's'){
        cout << s + "es" << endl;
        return 0;
    }
    cout << s + "s" << endl;
    
    
    
    return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N; cin >> N;
	int A, B; cin >> A >> B;
	int C; cin >> C;
	vector<int>ds(N);
	for (int i = 0; i < N; ++i) {
		cin >> ds[i];
	}
	sort(ds.begin(), ds.end(), greater<int>());
	ld ans = 0;
	ld cal = C;
	ans = max(ans,cal / A);
	for (int i = 0; i < N; ++i) {
		cal += ds[i];
		ans = max(ans, cal / (A + B*(i + 1)));
	}
	cout << int(ans) << endl;
	return 0;
}

Measured memory_bytes: 3068
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<map>

using namespace std;
typedef pair<int,int> P;

int p[10][10];
int cp[10][10];
int flag[10][10];
int h,w,c;

int sx[4]={0,1,0,-1};
int sy[4]={1,0,-1,0};
int col[7],res;

int bfs(int cc){
	memset(flag,0,sizeof(flag));
	queue<P> que;
	que.push(P(1,1));
	flag[1][1]=1;
	while(que.size()){
		P q=que.front();
		que.pop();
		int x=q.first,y=q.second;
		for(int i=0;i<4;i++){
			int nx=sx[i]+x,ny=sy[i]+y;
			if(flag[nx][ny]==0){
				if(cp[x][y]==cp[nx][ny]){
					flag[nx][ny]=1;
					que.push(P(nx,ny));
				}
			}
		}
	}
	int cnt=0;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(flag[j][i]==1)cp[j][i]=cc;
			cnt+=flag[j][i];
		}
	}
	return cnt;
}

void dfs(int x){
	if(x<4){
		for(int i=1;i<=6;i++){
			col[x]=i;
			dfs(x+1);
		}
	}else{
		col[4]=c;
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				cp[j][i]=p[j][i];
			}
		}
		for(int i=0;i<5;i++){
			bfs(col[i]);
		}
		res=max(res,bfs(7));
	}
}

int main(void){
	while(1){
		scanf("%d %d %d",&h,&w,&c);
		if(h+w+c==0)break;
		res=0;
		memset(p,0,sizeof(p));
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				scanf("%d",&p[j][i]);
			}
		}
		dfs(0);
		printf("%d\n",res);
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    int n;
    int k;
    int r, s, p;
    cin >> n >> k;
    cin >> r >> s >> p;
    string t; cin >> t;
    vector<char>before(n-1);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        int mod = i % k;
        if(before[mod] != t[i]){
            if(t[i] == 'r'){
//                cout << "a" << endl;
                ans += p;
            }else if(t[i] == 's'){
//                cout << "k" << endl;
                ans += r;
            }else{
//                cout << "j" << endl;
                ans += s;
            }
            before[mod] = t[i];
        }else{
            before[mod] = 'a';
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ull = unsigned long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;
using vpii = vector<pii>;

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

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    vi A(3);
    int K;
    cin >>A[0]>>A[1]>>A[2]>>K;
    SORT(A);
    cout <<(A[2]*pow(2,K)+A[0]+A[1]);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n*3];
        for (int i = 0; i < n*3; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        long ans = 0L;
        for (int i = n; i < n*3; i++) {
            if((i-n) % 2 == 0){
                ans += a[i];
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


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

int main()
{
    string a, b;
    cin >> a >> b;
    if(a==b)cout << "EQUAL";
    else if(a.size()==b.size() and a>b)cout << "GREATER";
    else if(a.size()==b.size() and a<b)cout << "LESS";
    else if(a.size()>b.size())         cout << "GREATER";
    else                                cout << "LESS";
}


Measured memory_bytes: 3612
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vll a(n, HIGHINF), b(n-1);
    REP(i, n-1) {
        ll b; cin >> b;
        chmin(a[i], b);
        chmin(a[i+1], b);
    }
    cout << accumulate(a.begin(), a.end(), 0LL) << '\n';
    return 0;
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

A,V = LI()
B,W = LI()
T = I()

if (V-W)*T >= abs(A-B):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 83040
S = "???" + input() + "???"

a = 0

ans = 0
i = 0
while i < len(S):
    s = S[i]

    if s == "A":
        a += 1
        i += 1
        while i < len(S):
            s1 = S[i]
            s2 = S[i + 1]

            if s1 == "A":
                a += 1
                i += 1
                continue
            elif s1 + s2 == "BC":
                ans += a
                i += 2
            else:
                break

        a = 0
    else:
        i += 1
        continue

print(ans)


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

int main() {
  int n;

  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  
  for (int i=0; i<n; i++){
    cin >> a.at(i);
    a.at(i)--;
  }
  for (int i=0; i<n; i++){
    cin >> b.at(i);
  }
  for (int i=0; i<n-1; i++){
    cin >> c.at(i);
  }
  
  int sum=0;
  for (int i=0; i<n; i++){
    sum += b.at(a.at(i));
    if(i==0){
    }else if (a.at(i)==a.at(i-1)+1){
      sum += c.at(a.at(i-1));
    }
  }
  cout << sum << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define N (int)1e2+5
#define M (int)1e5+5
#define f1 first
#define s2 second
#define INF 9999999
#define pb push_back
#define ll long long
#define mod (int)1e9+7
#define ull unsigned long long;
#define all(a) a.begin(),a.end()
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);

int dp[N][M],dizi[N],pre[M],n,m;

int main(){
	//fri("in.txt");
	//fro("out.txt");
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>dizi[i];
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		memset(pre,0,sizeof(pre));
		pre[0]=dp[i-1][0];
		for(int j=1;j<=m;j++){
			pre[j]=pre[j-1]+dp[i-1][j];
			pre[j]%=mod;
		}
		for(int j=0;j<=m;j++){
			dp[i][j]=pre[j];
			if(j-dizi[i]-1>=0){
				dp[i][j]-=pre[j-dizi[i]-1];
			}
			dp[i][j]+=mod;
			dp[i][j]%=mod;
		}
	}
	cout<<dp[n][m];
}

Measured memory_bytes: 40832
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

ll Conbi(int a, int b) {
	if (b > a)
		return 0;
	b = min(b, a - b);
	if (b == 0)
		return 1;
	ll ans = 1;
	for (int i = 1; i <= b; i++, a--) {
		ans *= a;
		ans /= i;
	}
	return ans;
}

int main(void) {
	int num, l, r, i, m = 0, s;
	ll ans = 0;
	double ave = 0.0;
	cin >> num >> l >> r;
	vector<ll> d(num);
	for (i = 0; i < num; i++)
		scanf("%lld", &d[i]);
	sort(d.begin(), d.end(), greater<ll>());
	for (i = 0; i < l; i++) {
		ave += (double)d[i];
		if (d[i] == d[l - 1])
			m++;
	}
	for (s = m; i < num; i++) {
		if (d[i] == d[l - 1])
			s++;
	}
	if (d[0] != d[l - 1])
		r = l;
	for (i = 0; i <= r - l; i++)
		ans += Conbi(s, m + i);
	ave /= (double)l;
	printf("%.9lf\n%lld\n", ave, ans);
	return 0;
}

Measured memory_bytes: 256
def findProductSum(A, n): 
      
    # calculating array sum (a1 + a2 ... + an) 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum += A[i]
  
    # calcualting square of array sum 
    # (a1 + a2 + ... + an)^2 
    array_sum_square = (array_sum * array_sum )
  
    # calcualting a1^2 + a2^2 + ... + an^2 
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += (A[i] * A[i]) 
  
    # required sum is (array_sum_square - 
    # individual_square_sum) / 2 
    return (array_sum_square - individual_square_sum) // 2 
n = int(input())
a = [int(x) for x in input().split()]
MOD = 10**9 +7

print(int(findProductSum(a,n))%MOD)

# print(s%MOD)

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string S;cin>>S;
    ll s = 0,t = 0;
    ll res = 0;
    rep(i,S.size()){
        if(S[i] == 'S')s++;
        else{
            if(s > 0){
                res++;
                s--;
            }
        }
    }
    cout << S.size() - 2*res << endl;
}


Measured memory_bytes: 720
#include <iostream>
#include <cstdio>

const int MAX_N = 50;

int main() {
  int a, p;

  scanf("%d %d", &a, &p);
  //printf("%d %d ", a, p);
  int lack = a * 3 + p;
  int pie = lack / 2;
  printf("%d\n", pie);

  return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
from bisect import bisect_left as bl
def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    ans = N
    tmp = 0
    B = list(accumulate(A))
    for i,b in enumerate(B):
        k = bl(A,b*2)
        if k == N:continue
        if A[k-1] == A[i] and A[k] > 2*b:
            tmp = i+1
    ans -= tmp
    
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 14524
s = input()

for i in range(8):
	if i % 2 == 0:
		ope1 = "+"
	else:
		ope1 = "-"
	i //= 2
	if i % 2 == 0:
		ope2 = "+"
	else:
		ope2 = "-"
	i //= 2
	if i % 2 == 0:
		ope3 = "+"
	else:
		ope3 = "-"
	
	ans = s[0]+ope1+s[1]+ope2+s[2]+ope3+s[3]

	if eval(ans) == 7:
		print(ans+"=7")
		break


Measured memory_bytes: 3060
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let s: Vec<u8> = read::<String>().into_bytes();
    let n = s.len();

    if (n % 2 == 0) ^ (s[0] != s[n-1]) {
        println!("First");
    } else {
        println!("Second");
    }
}

Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(500000)

class UF:
    #経路圧縮のみのunion find木
    def __init__(self,n):
        self.n = n
        self.parents = [-1] * (n+1) #1-indexedにするために１個足している
        self.rnks = [0] * (n+1)

    def find(self,n):
        if self.parents[n] < 0:
            return n
        else:
            self.parents[n] = self.find(self.parents[n])
            return self.parents[n]

    def union(self,a,b):
        a_par = self.find(a)
        b_par = self.find(b)

        if a_par == b_par:
            return
        if self.rnks[a_par] > self.rnks[b_par]:
            a_par,b_par = b_par,a_par
        if self.rnks[a_par] == self.rnks[b_par]:
            self.rnks[a_par] += 1
        self.parents[a_par] += self.parents[b_par]
        self.parents[b_par] = a_par

    def length(self,n):
        par = self.find(n)
        return abs(self.parents[par])

    def is_same(self,a,b):
        return self.find(a) == self.find(b)



def main():
    n,m,k = map(int,input().split())
    uf = UF(n)
    block_lst = [0 for _ in range(n+1)]
    friend_lst = [0 for _ in range(n+1)]
    #友達リスト部分
    for i in range(m):
        a,b = map(int,input().split())
        friend_lst[a] += 1
        friend_lst[b] += 1
        uf.union(a,b)
    #print(friend_lst)

    #ブロックリスト部分
    for i in range(k):
        c,d = map(int,input().split())
        if uf.is_same(c,d):#c,dが同じ友達候補グループにない限り、解答には影響しない！
            block_lst[c] += 1
            block_lst[d] += 1
    #print(block_lst)
    #メイン処理
    answer = []

    for i in range(1,n+1):
        f_o_f = uf.length(i)
        answer.append(f_o_f - friend_lst[i] - block_lst[i] - 1)


    print(" ".join(map(str,answer)))






if __name__ == '__main__':
    main()


Measured memory_bytes: 54312
#include <bits/stdc++.h> 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vll>;
using vb = vector<bool>;
 
const int INF = 2e9+5;
const ll LLINF = (1LL << 60) + 5;
 
/*
  filippos
  Contest : AtCoder DP contest
  Task : N - Slimes
*/
 
int main(){
  cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);

  int n; cin >> n;
  vll v(n);
  for(auto &i : v)
    cin >> i;

  // very similar to cms problem, somme or similar

  // "interval dp"

  // first of all, let's compute prefix sums
  partial_sum(v.begin(), v.end(), v.begin());
  
  function<ll(int,int)> sum = [&](int l, int r){
    return v[r] - (l ? v[l-1] : 0);
  };

  vvl memo(n, vll(n, -1));
  // returns  minimal cost to compute this
  function<ll(int, int)> dp = [&](int i, int j){
    // base case
    if(i >= j) return 0LL;
    ll &ans = memo[i][j];
    if(ans != -1) return ans;

    ans = LLINF;
    for(int x = i; x < j; x++){
      ans = min(ans, dp(i, x) + dp(x+1, j));
    }
    ans += sum(i, j);
    return ans;
  };

  cout << dp(0, n-1);

  return cout << endl, 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;

typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;

typedef vector<lint> vl;
typedef pair<lint,lint> pll;


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, m, x;
    cin>>n>>m>>x;
    vi c(n);
    vector<vi> p(n, vi(m));
    for (int i=0; i<n; ++i){
        cin>>c[i];
        for (int &v : p[i]) cin>>v;
    }

    int mincost = INT_MAX;
    vi cur(m, 0);
    int curc = 0;

    auto isOK = [&](){
        for (int v : cur){
            if (v<x) return false;
        }
        return true;
    };

    function<void(int)> dfs = [&](int bi){
        if (isOK()){
            mincost = min(mincost, curc);
            return;
        }

        for (int b = bi; b<n; ++b){
            curc += c[b];
            //if (curc > mincost) continue;
            for (int i=0; i<m; ++i){
                cur[i] += p[b][i];
            }
            dfs(b+1);
            curc -= c[b];
            for (int i=0; i<m; ++i){
                cur[i] -= p[b][i];
            }
        }
    };

    dfs(0);
    if (mincost == INT_MAX) cout<<-1;
    else cout<<mincost;

}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
long long n;
long long work(long long x){
	if(x==1) return 1;
	return 1+work(x/2)*2;
} 
int main() {
	scanf("%lld",&n);
	printf("%lld",work(n));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef map<ll,ll> umap;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    ll n,a,b,c;
    string si[100005];
    vector<char> v;
    cin >> n >> a >> b >> c;
    rep(i,1,n){
    	cin >> si[i];
    }
    rep(i,1,n){
    	if(a<0||b<0||c<0){
    		cout << "No" << endl;
    		return 0;
    	}
    	if(si[i]=="AB"){
    		if(a==0&&b==0){
    			cout << "No" << endl;
    			return 0;
    		}
    		if(a==1&&b==1){
    			if(i<n&&si[i+1]=="BC"){
    				v.pb('B');
    				a--; b++;
    			} else {
    				v.pb('A');
    				a++; b--;
    			}
    		} else if(a>=b){
    			v.pb('B');
    			a--; b++;
    		} else {
    			v.pb('A');
    			a++; b--;
    		}
    	}
    	
    	if(si[i]=="BC"){
    		if(b==0&&c==0){
    			cout << "No" << endl;
    			return 0;
    		}
    		if(b==1&&c==1){
    			if(i<n&&si[i+1]=="AC"){
    				v.pb('C');
    				b--; c++;
    			} else {
    				v.pb('B');
    				b++; c--;
    			}
    		} else if(b>=c){
    			v.pb('C');
    			b--; c++;
    		} else {
    			v.pb('B');
    			b++; c--;
    		}
    	}
    	
    	if(si[i]=="AC"){
    		if(c==0&&a==0){
    			cout << "No" << endl;
    			return 0;
    		}
    		if(c==1&&a==1){
    			if(i<n&&si[i+1]=="AB"){
    				v.pb('A');
    				c--; a++;
    			} else {
    				v.pb('C');
    				c++; a--;
    			}
    		} else if(c>=a){
    			v.pb('A');
    			c--; a++;
    		} else {
    			v.pb('C');
    			c++; a--;
    		}
    	}
    }
    cout << "Yes" << endl;
    rep(i,0,n-1) cout << v[i] << endl;
    return 0;
}

Measured memory_bytes: 6872
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  cout<<Svec(v)-n<<endl;
}

Measured memory_bytes: 256