akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
using namespace std;

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

using ll = long long;

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

    const int MAXN = 310;
    int A[MAXN][MAXN];
    bool deleted[MAXN][MAXN];

    REP (i, N) {
        REP (j, N) {
            cin >> A[i][j];
        }
    }

    REP (k, N) {
        REP (i, N) {
            REP (j, N) {
                if (A[i][j] > A[i][k] + A[k][j]) {
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }

    memset(deleted, false, sizeof(deleted));

    ll sum = 0;
    REP (i, N) {
        FOR (j, 0, i) {
            sum += A[i][j];
            REP (k, N) {
                if (k != i and k != j and A[i][j] == A[i][k] + A[k][j]) {
                    sum -= A[i][j];
                    break;
                }
            }
        }
    }
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 640
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# library
# -------------------------------------------------------------
class Combination:
    def __init__(self, n, mod):
        self.mod = mod
        self.fact = [1]*n
        self.finv = [1]*n
        self.inv  = [1]*n
        for i in range(2,n):
            self.fact[i] = (self.fact[i-1]*i) % self.mod
            self.inv[i]  = self.mod - self.inv[self.mod%i] * (self.mod//i)%self.mod
            self.finv[i] = self.finv[i-1] * self.inv[i] % self.mod
 
    def nCr(self, n, r):
        if n<r:
            return 0
        else:
            return self.fact[n] * (self.finv[r] * self.finv[n-r] % self.mod) % self.mod

mod = 10**9+7
Combination = Combination(200010, mod)

# -------------------------------------------------------------
# main
# -------------------------------------------------------------

N,M,K = map(int,input().split())

ans = 0
for d in range(1,N):
    t = d * Combination.nCr(N*M-2, K-2)
    t %= mod
    t *= (N-d)*M*M
    t %= mod
    ans += t
    ans %= mod
for d in range(1,M):
    t = d * Combination.nCr(N*M-2, K-2)
    t %= mod
    t *= (M-d)*N*N
    t %= mod
    ans += t
    ans %= mod

print(ans)

Measured memory_bytes: 26740
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)

from collections import deque


def resolve():
    S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    Q = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    # N, D = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    # h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))

    reverse = False

    s_list = deque(S)

    for _ in range(Q):
        q = input().strip()
        if q == '1':
            reverse = not reverse
        else:
            t, f, c = q.split(' ')
            if (f == '1' and not reverse) or (f == '2' and reverse):
                s_list.appendleft(c)
            else:
                s_list.append(c)

    if reverse:
        print(''.join(list(s_list)[::-1]))
    else:
        print(''.join(list(s_list)))


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """a
4
2 1 p
1
2 2 c
1"""
        output = """cpa"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """a
6
2 2 a
2 1 b
1
2 2 c
1
1"""
        output = """aabc"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """y
1
2 1 x"""
        output = """xy"""
        self.assertIO(input, output)


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

using namespace std;

int main(){
    int n, a, b, ans = 0;
    cin >> n >> a >> b;
    int c1 = 0, c2 = 0, c3 = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(x <= a) c1++;
        else if(x > a && x <= b) c2++;
        else c3++;
    }
    cout << min({c1, c2, c3}) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>

int main() {
  int N,i,M;
  cin>>N;
  int A[N]={0};
  int B[N]={0};
  int C[N]={0};
  long a=0,b=0,x=0;
  long Aall=0,Ball=0;
  long delta;
  for(i=0;i<N;i++){
   cin>>A[i]>>B[i];
    C[i]=A[i]+B[i];
    Aall=Aall+A[i];
    Ball=Ball+B[i];
  }
  delta=Aall;
  sort(C, C+N);
  
  for(i=0;i<N;i++){
    if(i%2==1){
    delta=delta-C[N-1-i];
    }
  
  }
 
  cout<<delta<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define TRAV(i, a) for(auto & i : (a))
#define SZ(x) ((int)(x).size())
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int, int> PII;
typedef std::vector<int> VI;

int main(){
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);
	std::string s;
	std::cin >> s;
	int k;
	std::cin >> k;
	int n = SZ(s);
	VI xd;
	int cnt = 0;
	char last = '$';
	TRAV(c, s){
		if(c == last) cnt++;
		else{
			if(cnt > 0) xd.push_back(cnt);
			cnt = 1;
			last = c;
		}
	}
	xd.push_back(cnt);
	if(SZ(xd) == 1){
		ll ile = 1ll*k*n;
		std::cout << ile/2 << "\n";
		return 0;
	}
	if(s[0] == s.back()){
		int one = 0;
		ll all = 0;
		all += xd[0]/2;
		all += xd.back()/2;
		REP(i, 1, SZ(xd)-1) one += xd[i]/2;
		all += 1ll*one*k;
		all += 1ll*(xd[0]+xd.back())/2*(k-1);
		std::cout << all << "\n";
	}else{
		int one = 0;
		TRAV(i, xd) one += i/2;
		std::cout << 1ll*one*k << "\n";
	}


	return 0;
}

Measured memory_bytes: 256
h, w, z = map(int ,input().split())
s = []
for i in range(h):
    s.append(list(input()))
ans = int(1e9+7)
if h == 1:
    ans = 0
    cnt = 0
    for i in range(w):
        if s[0][i] == '1':
            cnt += 1
        if cnt > z:
            ans += 1
            cnt -= z
    print(ans)
    exit()

for i2 in range(2**(h-1)):
    d = [True] * (h-1)
    for j2 in range(h-1):
        if (i2 >> j2) & 1:
            d[j2] = False
    d.append(False)


    val = 0
    for i in range(len(d)-1):
        if d[i] == False:
            val += 1
    #print(val,d)
    l = []
    lis = []
    for i in range(h):
        l.append(i)
        if d[i] == False:
            lis.append(l)
            l = []

    flg2 = True#横がiのときにcnt2の要素がkを超えるとFalse
    flg = True#cntの要素がkを超えるとFalse
    cnt = [0] * len(lis)#全体での1の個数
    for i in range(w):
        cnt2 = [0] * len(lis)#iでの1の個数
        for j in range(len(lis)):
            for k in lis[j]:
                if s[k][i] == '1':#高さがkで横がiの時、
                    cnt[j] += 1#lis[j]を1たす
                    cnt2[j] += 1
            if cnt[j] > z:
                flg = False
            if cnt2[j] > z:
                flg2 = False
        if flg == False:
            for j in range(len(cnt)):
                cnt[j] = cnt2[j]
            flg = True
            val += 1
        #print(cnt,cnt2)
        #print(i,val)
    if flg2 == True:
        ans = min(ans,val)
    #print(val,d,lis,flg)
print(ans)


Measured memory_bytes: 49244
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int m, n;
		List<Integer> member = new ArrayList<Integer>();
		while ((m = in.nextInt()) != 0 && (n = in.nextInt()) != 0) {
			member.clear();
			for (int i = 1; i <= m; i++) {
				member.add(i);
			}
			int imo = -1;
			while (member.size() > 1) {
				imo = (imo + n) % member.size();
				member.remove(imo);
				imo = imo - 1;
			}
			System.out.println(member.get(0));
		}
		in.close();
	}

}

Measured memory_bytes: 17236
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    int n;
    vector<LL> x;
    vector<LL> x_copy;
    LL tmp_x;
    LL ans;
    vector<LL> x_center(2);
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_x;
        x.push_back(tmp_x);
    }
    x_copy = x;
    sort(x_copy.begin(), x_copy.end());
    for(int i=0; i<x_copy.size(); i++){
    }
    for(int i=0; i<2; i++){
        x_center[i] = x_copy[x_copy.size()/2-1+i];
    }
    for(int i=0; i<n; i++){
        if(x[i]<=x_center[0]){
            ans=x_center[1];
        }else{
            ans=x_center[0];
        }
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 5488
#include <iostream>
#include <vector>
#include <cmath>

int main() {
  int N;
  std::cin >> N;
  std::vector<long long> A(N+1, 0);
  for (int i=0; i<N+1; ++i) std::cin >> A.at(i);
  std::vector<long long> B(N+1, 0);
  for (int i=0; i<N; ++i) std::cin >> B.at(i);
  
  long long answer = 0, carry = 0;
  for (int i=0; i<N+1; ++i) {
    answer += std::min(A.at(i), carry);
    A.at(i) = A.at(i) >= carry ? A.at(i) - carry : 0;
    answer += std::min(A.at(i), B.at(i));
    carry = B.at(i) >= A.at(i) ? B.at(i) - A.at(i) : 0;
  }
  std::cout << answer << "\n";
}

Measured memory_bytes: 1792
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i32,
        s: chars,
        k: usize,
    }
    let char = s[k-1];
    for c in s {
        if c == char {
            print!("{}", c);
        } else {
            print!("*");
        }
    }
    println!("");
}


Measured memory_bytes: 4352
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt();
		int A[]=new int[26];
		int z=0,y=0;
		while(z<n){
			String a=stdIn.next();
			int G[]=new int[26];
			while(y<a.length()){
				char b=a.charAt(y);
				G[b-'a']++;
				y++;
			}y=0;
			while(y<26) {
				if(z==0||A[y]>G[y])
					A[y]=G[y];
				G[y]=0;
				y++;
			}y=0;
			z++;
		}z=0;
		while(z<26) {
			while(y<A[z]) {
				System.out.print((char)(z+97));
				y++;
			}y=0;
			z++;
		}
		System.out.println();
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>  
using namespace std; 
int main(){  
	int n;
	cin>>n;
	if(n%1000==0)cout<<0;
	else{
		for(int i=1;i<=1000;i++){
			if((n+i)%1000==0){
				cout<<i;
				break;
			}
		}
	} 
    return 0;  
} 

Measured memory_bytes: 3588
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    long long N;
    cin>>N;
    map<string, int> ma;
    REP(i,N){
        string s;
        cin>>s;
        ma[s]++;
    }
    cout<<ma.size()<<endl;
    return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;

  vector<int> a(N-1);

  rep(i, N-1){
    cin >> a[i];
    a[i]--;
  }

  vector<int> cnt(N);

  for(int i = N-2; i >= 0; i--){

    cnt[a[i]]++;

  }

  rep(i, N){
    cout << cnt[i] << endl;
  }





  return 0;
}


Measured memory_bytes: 4780
#undef NDEBUG
#include <bits/stdc++.h>

using namespace std;

using li = long long;
using ld = long double;

#define all(v) (v).begin(), (v).end()

void solve(bool);

int main() {
#ifdef YA
    auto s = clock();
    assert(freopen("input.txt", "r", stdin));
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    cout << fixed << setprecision(20);

    solve(true);

#ifdef YA1
    while (true) solve(false);
#endif

#ifdef YA
    cerr << endl << endl << (clock() - s) / (double)CLOCKS_PER_SEC << endl;
#endif

    return 0;
}

// 5 10 10 40

void solve(__attribute__((unused)) bool read) {
    int n, X;
    cin >> n >> X;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(all(a));

    if (accumulate(all(a), 0LL) < X) {
        cout << n - 1 << endl;
        return;
    }

    int maxHappy = 0;
    for (int j = 0; j < n; ++j) {
        int x = X;
        int happy = 0;
        for (int i = j; i < n; ++i) {
            if (a[i] <= x) {
                x -= a[i];
                ++happy;
            }
        }
        maxHappy = max(maxHappy, happy);
    }
    cout << maxHappy << endl;
}


Measured memory_bytes: 256
//#pragma comment(linker,"/STACK:102400000,102400000")
//#include <initializer_list>
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define slla(n) scanf("%lld", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); repp(i,1,___T)

const int dx44[5] = { 0,-1,-1,1,1 };
const int dy44[5] = { 0,-1,1,-1,1 };

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int dx82[9] = { 0,-1,-1,1,1, 2,2,-2,-2 };
const int dy82[9] = { 0,2,-2,2,-2, 1,-1,1,-1 };
const int maxn = 2e3 + 50;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;

ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void extgcd(ll a,ll b,ll& d,ll& x,ll& y){ if(!b){ d=a; x=1; y=0;} else{ extgcd(b,a%b,d,y,x); y-=x*(a/b); }}
ll inverse(ll a,ll n){ ll d,x,y;extgcd(a,n,d,x,y);return d==1?(x+n)%n:-1;}

void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes");}// exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No");}// exit(0); }
void one() { puts("-1"); exit(0); }

ll n,k,q;
ll ans;
ll val[maxn];

void cal(int t) {
	int x = val[t];
	priority_queue<int>que;
	vector<int>v;
	repp(i,1,n) {
		if(val[i]>=x) {
			que.push(-val[i]);
		} else {
			while(!que.empty()) {
				if(que.size()>=k) {
					v.push_back(-que.top());
				}
				que.pop();
			}
		}
	}
	while(!que.empty()) {
		if(que.size()>=k) {
			v.push_back(-que.top());
		}
		que.pop();
	}
	sort(v.begin(),v.end());
	if(v.size()>=q)
		ans = min(ans,1LL*(v[q-1]-x));
}

void solve() {
	scanf("%lld%lld%lld",&n,&k,&q);
	repp(i,1,n) {
		scanf("%lld",&val[i]);
	}

	ans = 2e9;
	repp(i,1,n){
		cal(i);
	}

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

int main()
{

    int t;
	//sa(t);
	t = 1;
	repp(i,1,t) {

		solve();	
	}
    // system("pause");
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()

{

  int a,b,c,d,e,f;

  cin >> a;

  cin >> b;

  c=(a+b);

  d=((c+1)/2);

  e=(c%2);

  f=(c/2);

  if (e==0)

  {

    cout << f<< endl;

  }

  else 

  {

    cout << d<< endl;

  }

  return 0;

 }

Measured memory_bytes: 3620
#include <string>
#include <cstdio>
#include <bitset>
#include <iostream>

using namespace std;

int main(){
    unsigned int innum;
    scanf("%d",&innum);
    cout << bitset<32>(innum) << endl;
    unsigned int n1 = ~innum;
    unsigned int n2 = innum<<1;
    unsigned int n3 = innum>>1;
    cout << bitset<32>(n1) <<endl;
    cout << bitset<32>(n2) <<endl;
    cout << bitset<32>(n3) <<endl;
}



Measured memory_bytes: 3268
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const int maxn = 105;
string a,b,c;
map<int,int> mp;
int ans;
int main(int argc, char const *argv[])
{
	int n;
	cin>>n>>a>>b>>c;
	for(int i = 0;i < n; ++i)
	{
		mp.clear();
		mp[a[i]]++;
		mp[b[i]]++;
		mp[c[i]]++;
		// printf("mp[%c] = %d,%d\n",a[i],mp[a[i]],3 - max(mp[c[i]],max(mp[a[i]],mp[b[i]])));
		ans += (3 - max(mp[c[i]],max(mp[a[i]],mp[b[i]])));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

class UnionFind():
	def __init__(self, n):
		self.n=n
		self.parents = [-1]*n
	def find(self, x):
		if self.parents[x] < 0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]
	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)
		if x==y:
			return
		if self.parents[x] > self.parents[y]:
			x, y = y, x
		self.parents[x] += self.parents[y]
		self.parents[y] = x
	def size(self, x):
		return -self.parents[self.find(x)]
	def same(self, x, y):
		return self.find(x) == self.find(y)

def main():
	N,M,K = MI()
	frend = [[] for _ in range(N)]
	block = [[] for _ in range(N)]
	uf = UnionFind(N)
	for _ in range(M):
		A,B = map(int1, sys.stdin.readline().split())
		uf.union(A,B)
		frend[A].append(B)
		frend[B].append(A)

	for _ in range(K):
		C,D = map(int1, sys.stdin.readline().split())
		if uf.same(C,D):
			block[C].append(D)
			block[D].append(C)

	ans_v = []
	for i in range(N):
		ans = uf.size(i)-len(frend[i])-len(block[i])-1
		ans_v.append(ans)
	printH(ans_v)

main()

Measured memory_bytes: 51728
import sys

def plot(x, y):
    global ban
    if 0 <= x < 10 and 0 <= y < 10: ban[y][x] += 1

def drop(x, y, s):
    for dx, dy in [(0, 0), (-1, 0), (1, 0), (0, -1), (0, 1)]:
        plot(x + dx, y + dy)
    if s == 1: return
    for dx, dy in [(-1, -1), (-1, 1), (1, -1), (1, 1)]:
        plot(x + dx, y + dy)
    if s == 2: return
    for dx, dy in [(-2, 0), (2, 0), (0, -2), (0, 2)]:
        plot(x + dx, y + dy)

ban = [[0 for x in range(10)] for y in range(10)]
for line in sys.stdin:
    x, y, size = map(int, line.split(','))
    drop(x, y, size)

print(sum(ban[y][x] == 0 for y in range(10) for x in range(10)))
print(max(ban[y][x] for y in range(10) for x in range(10)))

Measured memory_bytes: 6768
main(){double a,b,c,d,e,f;for(;~scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f);printf("%.3f %.3f\n",(e*c-b*f)/(a*e-b*d)+0.0,(a*f-d*c)/(a*e-b*d)+0.0));exit(0);}

Measured memory_bytes: 652
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

ll gcd(ll x, ll y) {
  while (y != 0) {
    ll r = x % y;
    x = y; y = r;
  }
  return x;
}

bool f(ll a, ll b, ll c, ll d) {
  if (b > d) return false;
  if (a < b) return false;
  ll g = gcd(b, d);
  ll r = (a - c) % g + g;
  r %= g;
  ll lim = c + r;
  if (r == 0) lim += g;
  return lim - b >= 0;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (f(a, b, c, d) ? "Yes" : "No") << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

    int AC=0;
    int TLE=0;
    int WA=0;
    int RE=0;
    int brpKali;
    scanf("%d", &brpKali);
    char inputan[brpKali][100];
    for(int i=0;i<brpKali;i++){
        scanf("%s", inputan[i]);    //AC, TLE, AC, AC, WA ,TLE

    }
    for(int j=0;j<brpKali;j++){
        if(inputan[j][0]=='A'){
            AC++;
        }
        else if(inputan[j][0]=='W'){
            WA++;
        }
        else if(inputan[j][0]=='T'){
            TLE++;
        }
        else if(inputan[j][0]=='R'){
            RE++;
        }

    }
printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", AC, WA, TLE, RE);




    return 0;
}

Measured memory_bytes: 11448
[N,K]=list(map(int, input().split()))
dlist=[]
alist=[]
for i in range(K):
    d=int(input())
    dlist.append(d)
    alist.append(list(map(int, input().split())))
nlist=[n for n in range(1,N+1)]
ans=0
for n in range(1,N+1):
    flg=True
    for als in alist:
        if n in als:
            flg=False
            break
    if flg:
        ans+=1
print(ans)


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

int main()
{
    char a, b;
    cin >> a >> b;
    bool AtCoDeer  = (a == 'H');
    bool TopCoDeer = (b == 'H');

    char ans[2] = {'D', 'H'};

    cout << ans[!(AtCoDeer ^ TopCoDeer)] << endl;


    return 0;
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++)
    {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    cout << d.at(N / 2) - d.at((N / 2) - 1) << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int n, cnt[3] = {};
double dp[301][301][301];
 
double solve(int i, int j, int k) {
    if (i == 0 && j == 0 && k == 0)
        return 0;
    if (dp[i][j][k] != -1)
        return dp[i][j][k];
 
    dp[i][j][k] = (double) n / (i + j + k);
    if (i > 0)
        dp[i][j][k] += solve(i-1, j, k) * i / (i + j + k);
    if (j > 0)
        dp[i][j][k] += solve(i+1, j-1, k) * j / (i + j + k);
    if (k > 0)
        dp[i][j][k] += solve(i, j+1, k-1) * k / (i + j + k);
 
    return dp[i][j][k];
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
 
    cin >> n;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        cnt[a-1]++;
    }
 
    for (int i=0; i<=n; i++)
        for (int j=0; j<=n; j++)
            for (int k=0; k<=n; k++)
                dp[i][j][k] = -1;
    cout << fixed << setprecision(10) << solve(cnt[0], cnt[1], cnt[2]) << "\n";
 
    return 0;
}

Measured memory_bytes: 213376
#include<iostream>
#include<algorithm>

int main(){
	int A, B, C, D, E, F;
	std::cin >> A >> B >> C >> D >> E >> F;
	int K1 = A + B + C + D - std::min({ A,B,C,D });
	int K2 = E + F - std::min({ E,F });
	std::cout << K1 + K2 << std::endl;
	return 0;
}


Measured memory_bytes: 3100
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define PREP(it,array) for(vector<P>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)

#define MP       make_pair
#define PB       push_back
#define ALL(x)   (x).begin(),(x).end()

const int INF = 1<<29;
const double EPS = 1e-9;
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef long long LL;
typedef pair<int,int> P;


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);

  double mm, mx;

  double tmp;
  while(cin>>tmp){
    mm = min(mm,tmp);
    mx = max(mx,tmp);
  }

  cout << mx - mm << endl;


  return 0;
}

Measured memory_bytes: 1280
s=str(0)+input()
t=str(0)+input()

dp=[[0]*(len(t)) for i in range(len(s))]

for i in range(1,len(s)):
    for j in range(1,len(t)):
        if s[i]==t[j]:
            dp[i][j]=dp[i-1][j-1]+1
        else:dp[i][j]=max(dp[i-1][j],dp[i][j-1])

ans=[""]*dp[i][j]
i=len(s)-1
j=len(t)-1
k=dp[i][j]-1
while i>0 and j>0:
    if s[i]==t[j]:
        ans[k]=s[i]
        k-=1
        i-=1
        j-=1
    elif dp[i][j]==dp[i-1][j]:i-=1
    elif dp[i][j]==dp[i][j-1]:j-=1

print("".join(ans))

Measured memory_bytes: 138920
#include <iostream>
#include <vector>
using namespace std;
 
int main(void) {
  
  int N, M;
  cin >> N >> M;    //スヌケ君:N, お菓子の種類：M
  
  int sum[N] = {0};
  
  for(int i=0; i<M; i++){
    int d;
    cin >> d;
    
    for(int j=0; j<d; j++){
      int x;
      cin >> x;
      sum[x-1] ++;
    }  
  }
  
  int count = 0;
  
  for (int i=0; i<N; i++) {
    if (sum[i] == 0){
      count++;
    }
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 3620
N,K = map(int,input() .split(" "))
cnt =  0

if K % 2 == 0:
    cnt2 = 0
    for i in range(1,N+1):
        if i % (K//2) == 0:
            cnt += 1
        if i % (K) == 0:
            cnt2 += 1
    cnt -= cnt2

    print((cnt**3)+(cnt2**3))

else:
    for i in range(1,N+1):
        if i % (K) == 0:
            cnt += 1

    print(cnt**3)



Measured memory_bytes: 39024
#include <iostream>

using namespace std;

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

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

const long long INF = 1LL << 60;

int N;
long long h[100010];
long long dp[100010];

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

	for (int i = 0; i < 100010; i++) dp[i] = INF;
	dp[0] = 0;

	for (int i = 1; i < N; i++) {
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	cout << dp[N - 1] << endl;

	return 0;
}


Measured memory_bytes: 5100
import math
import itertools

def get_prime(n):
    if n<=1:
      return []
    prime=[2]
    limit=int(math.sqrt(n))
    
    data=[i+1 for i in range(2,n,2)]
    while limit>data[0]:
      prime.append(data[0])
      
      data=[j for j in data if j % data[0]!=0]
      
    return prime+data

xx=get_prime(100000)

xxx=[False]*100001

for i in xx:
  xxx[i]=True

xxxx=[False]*100001

for i in xx:
  xxxx[i]=True

for i in range(1,100001):
  if xxx[i]==True:
    if xxxx[(i+1)//2]==False:
      xxx[i]=False

q=int(input())

for i in range(100001):
  if xxx[i]==True:
    xxx[i]=1
  else:
    xxx[i]=0
    
xxx=list(itertools.accumulate(xxx))
    

for i in range(q):
  l,r=map(int,input().split())
  print(xxx[r]-xxx[l-1])

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

int main() {
  // int Ans = 0;  // 回答：
  string Ans = "Yes";  // 回答：
  string S; cin >> S; // 元の文字列：３から９９文字までの奇数文字数

  // i 番目の文字は、同時に以下の３文字と同じで無ければならない。
  //  (N-1)/2 - i
  //  (N+1)/2 + i
  //  (N-1) - i

  int N = S.size(); // 文字列長
  int M = (N+2) / 4  ;  // 最終判定文字位置
//  cout << "M:" << M << endl;
  rep(i,M){
    int P1 = (N-1)/2 -1 -i;
    int P2 = (N+1)/2 +i;
    int P3 = (N-1) - i;
//      cout << i << " " << S.at(i) << " " << S.at(P1) << " " << S.at(P2) << " " << S.at(P3) << endl;
    if(S.at(i)==S.at(P1) && S.at(i)==S.at(P2) && S.at(i)==S.at(P3) ) {
    } else {
      Ans = "No";
      break;
    }
  }

  cout << Ans << endl;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  int sum=0;
  int flag=0;
  for(int i=a;i<=b;i++){
    flag=0;
    string s = to_string(i);
    for(int j=0;j<s.size();j++){
      if(s[j] != s[s.size()-1-j]){
        break;
      }
      if(j == s.size()-1){
        flag=1;
      }
    }
    if(flag==1){
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#しゃくとり法忘れてた
n=int(input())
a=list(map(int,input().split()))
ans=0
right=0
now=[0]*20#2^20なので
for i in range(n):
    left=i
    if i!=0:
        for j in range(20):
            if (a[left-1]>>j)&1:
                now[j]-=1
    else:
        for j in range(20):
            if (a[left]>>j)&1:
                now[j]+=1
    while all([now[j]<=1 for j in range(20)]):
        #print(100000000)
        right+=1
        if right==n:
            break
        for k in range(20):
            if (a[right]>>k)&1:
                now[k]+=1
    else:
        #print(right)
        for k in range(20):
            if (a[right]>>k)&1:
                now[k]-=1
    right-=1
    ans+=(right-left+1)
    #print(left,right)
print(ans)

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

int main(){
  int N;
  vector<int> bits(4);
  
  cin >> N;
  for (int i=3;i>-1;i--){
    bits.at(i)=N/pow(10,i);
    N=N-bits.at(i)*pow(10,i);
  }
  if(((bits.at(0)==bits.at(1))&&(bits.at(0)==bits.at(2))) || ((bits.at(1)==bits.at(2))&&(bits.at(1)==bits.at(3)))){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int h,w,hh,ww;
	cin>>h>>w>>hh>>ww;
	cout<<(h-hh)*(w-ww)<<endl;
	return 0;
}


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

int main() {
  int N, M, cnt;
  cin >> N >> M;
  vector<int> a(N);
  rep(i, N) cin >> a.at(i);
  int sum = 0;
  rep(i, N) sum += a.at(i);
  rep(i, N) {
    if (a.at(i) * 4 * M >= sum) cnt++;
  }
  if (cnt >= M) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

template<class T>bool chmax(T &a, const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}

template<class T>bool chmin(T &a, const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int n;cin>>n;
	VI l(n);
	rep(i,n)cin>>l.at(i);
	sort(all(l));
	reverse(all(l));
	LL ans=0;
	rep(i,n-2){
		for(int j=i+1;j<n-1;j++){
			for(int k=j+1;k<n;k++){
				if(l.at(i)<l.at(j)+l.at(k)){
					ans++;
				}else{
					break;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main(){
  int n;cin>>n;
  vector<vector<int>>a;
  vector<int>tmp;
  int num1,num2;
  cin>>num1;
  tmp.push_back(num1);
  for(int i=1;i<n;i++){
    cin>>num2;
    if(num2>num1){
      tmp.push_back(num2);
      num1=num2;
      if(i==n-1){
        a.push_back(tmp);
      }
    }
    else{
      a.push_back(tmp);
      tmp={num2};
      num1=num2;
    }
  }
  ll sisan=1000;
  for(auto aa:a){
    int size=aa.size();
    if(size>1){
    ll moti=sisan/aa.at(0);
    sisan-=aa.at(0)*moti;
    sisan+=aa.at(size-1)*moti;
    moti=0;
    }
  }
  cout <<sisan<<endl;
}

Measured memory_bytes: 3568
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;

#include "atcoder/fenwicktree"
using namespace atcoder;

signed main(){
	int N, Q;
	cin >> N >> Q;
	vector<int>a(N);
	cin >> a;
	fenwick_tree<int>seg(N);
	REP(i, N) seg.add(i, a[i]);
	while(Q--) {
		int t;
		cin >> t;
		if(t) {
			int l, r;
			cin >> l >> r;
			out(seg.sum(l, r));
		} else {
			int p, x;
			cin >> p >> x;
			seg.add(p, x);
		}
	}
}

Measured memory_bytes: 12080
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

int main(){
	int W,H;
	while(cin >> W >> H && W){
		string cmd;
		int x=0,y=0,d=0;
		while(cin >> cmd , cmd != "STOP"){
			if(cmd[0]=='F'){
				int val; cin >> val;
				rep(i,val)x += dx[d] , y += dy[d];
			}else if(cmd[0] == 'B'){
				int val; cin >> val;
				rep(i,val)x += dx[(d+2)%4] , y += dy[(d+2)%4];
			}else if(cmd[0] == 'R'){
				d = (d+1)%4;
			}else if(cmd[0] == 'L'){
				d = (d+3)%4;
			}
			if(x<0)x=0;
			if(x>=W)x = W-1;
			if(y<0)y=0;
			if(y>=H)y = H-1;
		}
		cout << x+1 << " " << y+1 << endl;
	}
}

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

int main(){
  string S; cin >> S;
  int Q; cin >> Q;
  
  string str[2]={"",""};
  int cur=0;
  for(int i=0; i<Q; i++){
    int T; cin >> T;
    if(T==1){
      cur=(cur+1)%2;
    }else{
      int F;
      string C;
      cin >> F >> C;
      str[(cur+F+1)%2]+=C;
    }
  }
  if(cur==0){
    reverse(str[0].begin(),str[0].end());
    cout << str[0] << S << str[1] << endl;
  }else{
    reverse(str[1].begin(),str[1].end());
    reverse(S.begin(),S.end());
    cout << str[1] << S << str[0] << endl;
  }
}

Measured memory_bytes: 1088
#include <iostream>

using namespace std;

int main()
{
   string s;
   int i,j=0;
   cin>>s;
   for(i=0;s[i];i++)
   {
       if(s[i]=='7')
        j++;
   }
   if(j)
    cout<<"Yes";
   else
    cout<<"No";
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int p[100010];
struct node{
	int x,y,id;
}nodes[100010];
struct edge{
	int u,v,cost;
}mst[100010];
int find(int u)
{
	if(p[u]==u)
	return p[u];
	else return p[u]=find(p[u]);
}
bool cmp1(node &a,node &b)
{
	return a.x<b.x;
}
bool cmp2(node &a,node &b)
{
	return a.y<b.y;
}
bool cmp3(edge &a,edge &b)
{
	return a.cost<b.cost;
}
int main()
{
	int n,k=0;
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		cin >> nodes[i].x >> nodes[i].y;
		nodes[i].id=i;
	}
	sort(nodes+1,nodes+1+n,cmp1);
	for(int i=1;i<=n-1;i++)
	{
		mst[k].u=nodes[i].id;
		mst[k].v=nodes[i+1].id;
		mst[k].cost=abs(nodes[i].x-nodes[i+1].x);
		k++;
	}
	sort(nodes+1,nodes+1+n,cmp2);
	for(int i=1;i<=n-1;i++)
	{
		mst[k].u=nodes[i].id;
		mst[k].v=nodes[i+1].id;
		mst[k].cost=abs(nodes[i].y-nodes[i+1].y);
		k++;
	}
	sort(mst,mst+k,cmp3);
	for(int i=0;i<=n;i++)
	{
		p[i]=i;
	}
	long long ans=0;
	for(int i=0;i<k;i++)
	{
		int a=mst[i].u,b=mst[i].v;
		a=find(a),b=find(b);
		if(a!=b)
		{
			ans+=mst[i].cost;
			p[a]=b;
		}
	}
	cout << ans;
}



Measured memory_bytes: 2944
#include<stdio.h>
#define LEN 100005
#define MAX 100005
//プロセス（構造体）
typedef struct pp {
	char name[11];
	int t;
}P;
//グローバル変数
P Q[LEN + 1];
int head, tail, n;

//キューが空かどうか
int isEmpty() {
	return head == tail;
}
//キューが満杯かどうか
int isFull() {
	return head == (tail + 1) % MAX;
}
//キューに要素を追加する
void enqueue(P x) {
	if (!(isFull())) {
		Q[tail] = x;
		if (tail + 1 == MAX) {
			tail = 0;
		}
		else {
			tail++;
		}
	}
}
//キューから要素を取り出す
P dequeue() {
	if (!(isEmpty())) {
		P x = Q[head];
		if (head + 1 == MAX) {
			head = 0;
		}
		else {
			head++;
		}
		return x;
	}
}
int main() {
	int elaps = 0;	/*経過した時間の合計*/
	int sum = 0;	/*プロセスの時間の合計*/
	int i, q;		/*プロセス数とクォンタム*/
	P u;

	/*headとtailの初期化*/
	head = tail= 0;

	/*プロセス数とクォンタムの入力*/
	scanf("%d %d", &n, &q);

	/*キューの要素の読み込み*/
	for (i = 0; i < n; i++) {
		scanf("%s", u.name);
		scanf("%d", &u.t);
		enqueue(u);
		/*プロセスの時間を合計*/
		sum += u.t;
	}

	/*elapsがsumと等しくなるまでループ*/
	while (elaps < sum) {
		/*キューから要素を取り出す*/
		u = dequeue();
		/*クォンタムで与えられた時間内に
		処理が完了するとき*/
		if (u.t <= q) {
			/*enqueue()は行わず
			そのプロセスの残り時間分
			elapsに足す*/
			elaps += u.t;
			/*プロセスと経過時間を出力*/
			printf("%s %d\n", u.name, elaps);
		}
		/*完了しないとき*/
		else {
			/*クォンタム分経過時間に足す*/
			elaps += q;
			/*プロセスの残り時間を
			クォンタム分減らす*/
			u.t -= q;
			/*キューの末尾に追加*/
			enqueue(u);
		}
	}

	return 0;
}



Measured memory_bytes: 3360
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    String t = sc.next();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < n; i++) {
      sb.append(s.charAt(i));
      sb.append(t.charAt(i));
    }
    System.out.println(sb.toString());
  }
}

Measured memory_bytes: 22612
#coding=UTF-8

mojir=input()
hyo=mojir.split(' ')

N=int(hyo[0])
K=int(hyo[1])

#短絡的にやります
ans=1
for idx in range(0,N,1):
    iro = K-1 if idx != 0 else K
    ans=ans*iro

print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    if(s == "AAA" || s == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<fstream>
#define vi vector<int>
#define vii vector<vi>
#define ll long long
#define vl vector<ll>
#define vll vector<vl>
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define per(i, a, b) for (long long i = (a); i > (b); i--)
#define pb push_back
#define sz(v) (int)v.size()
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
using namespace std;
int main(){
	CIN;
	ll n,m;
	cin >> n >> m;
	if(abs(n-m) >= 673){
		cout << 0;
		return 0;
	}
	ll mini = 10000000000;
	rep(i,n,m+1){
		rep(j,i+1,m+1){
			mini = min(mini,(i*j)%2019);
		}
	}
	cout << mini;
}

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

int main() {
    int n;
    std::cin >> n;

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

    std::cout << *std::max_element(a.begin(), a.end()) - *std::min_element(a.begin(), a.end())
              << "\n";
}

Measured memory_bytes: 3544
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
using ll  = long long;
using ull = unsigned long long;

/* BitForObj Lib */
template <class T> T ntz(T x);
template <> unsigned ntz<unsigned>(unsigned x) {  return __builtin_ffs(x); }
template <> ull ntz<ull>(ull x) {  return __builtin_ffsll(x); }
template <class T> T count_bits(T x);
template <> unsigned count_bits<unsigned>(unsigned x) {  return __builtin_popcount(x); }
template <> ull count_bits<ull>(ull x) {  return __builtin_popcountll(x); }

template <class T>
class BitForObj {
 public:
  class Iter {
   public:
    Iter(T bits) : bits_(bits), val_( bits & (-bits) ) {}
    bool operator!=(const Iter& riter) const { return bits_ != riter.bits_; }
    Iter& operator++(void) {
      bits_ = bits_ ^ val_;
      val_ = bits_ & (-bits_);
      return *this;
    }
    unsigned operator*(void) const { return ntz(val_) - 1; }

   private:
    T bits_; T val_;
  };

  BitForObj(T bits) : bits_(bits), bit_nr_(0) {
    while (bits_ >= (1 << bit_nr_)) bit_nr_++;
  }
  Iter begin() const { return Iter(bits_); }
  Iter end() const { return Iter(0); }

 private:
  const T bits_; int bit_nr_;
};
using BitForObjU = BitForObj<unsigned>;
using BitForObjULL = BitForObj<ull>;
/* /BitForObj Lib */

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

  /* */
  string s;  cin >> s;
  int len = s.length();

  ull ans_sum = 0;
  for (ull i = 0; i < (1ull << (len - 1)); ++i) {
    auto prev = 0;
    for (auto x : BitForObjU(i)) {
      ans_sum += std::atoi( s.substr(prev, (x + 1) - prev).c_str() );
      prev = x + 1;
    }
    ans_sum += std::atoll( s.substr(prev).c_str() );
  }
  std::cout << ans_sum << std::endl;
  /* */

  return EXIT_SUCCESS;
}


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

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

    double N;
    cin >> N;
    for (double i = 1; i <= N; i++) {
        int j = i * 1.08;
        if (j == N) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using pii  = pair<int,int>;
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
    int  N,M,A[100007],l;
    ll k;
    l=k=0;
    pii B[100007];
    cin >> N >> M;
    rep(i,N){
        cin>>A[i];
    }
    rep(i,M){
        cin>>B[i].first>>B[i].second;
    }
    sort(A,A+N);
    sort(B,B+M, [](const pii &a, const pii &b){return a.second<b.second;});
    [&](){
        for(int i=M-1;i>=0;i--){
            for(int j=0;j<B[i].first;j++){
                if(A[l+j]>B[i].second || l+j>=N){
                    
                    return;
                }
                else A[l+j]=B[i].second;
            }
            l+=B[i].first;
        }
    }();
    rep(i,N){
        k+=A[i];
    }
    cout << k << endl;
}

Measured memory_bytes: 1408