akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

const int N=3e5+5;
const int M=3e5+1;
int n,sp,m=1;
int a[N];
int lson[N*2],rson[N*2],val[N*2];

void build(int pos,int x,int y){
	if(x==y) return;
	int mid=(x+y)>>1;
	lson[pos]=++m;
	rson[pos]=++m;
	build(lson[pos],x,mid);
	build(rson[pos],mid+1,y);
}

int query(int pos,int x,int y,int l,int r){
	if(x>=l&&y<=r) return val[pos];
	if(x>r||y<l) return 0;
	int mid=(x+y)>>1;
	return max(query(lson[pos],x,mid,l,r),query(rson[pos],mid+1,y,l,r));
}

void modify(int pos,int x,int y,int l,int v){
	if(x>=l&&y<=l){
		val[pos]=v;
		return;
	}
	if(x>l||y<l) return;
	int mid=(x+y)>>1;
	modify(lson[pos],x,mid,l,v);
	modify(rson[pos],mid+1,y,l,v);
	val[pos]=max(val[lson[pos]],val[rson[pos]]);
}

int main(){
	scanf("%d%d",&n,&sp);
	build(1,1,M);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		x++;
		int l=max(x-sp,1);
		int r=min(x+sp,M);
		int mx=query(1,1,M,l,r)+1;
		modify(1,1,M,x,mx);
	}
	printf("%d\n",val[1]);
	return 0;
}

Measured memory_bytes: 10860
#include <cstdio>
#include <algorithm>
#include <cmath>
#define maxn 500005

using namespace std;

struct node{
	long long pos, num;
}a[maxn];

long long n, s, ans = 0;

bool cmp(node x, node y){ return (x.pos < y.pos); }

int main(){
	scanf("%lld%lld", &n, &s);
	
	for (long long i = 1; i <= n; i++) scanf("%lld%lld", &a[i].pos, &a[i].num);
	sort(a + 1, a + n + 1, cmp);
	
	long long left = 1, right = n;
	
	while (left <= right){
		if (a[right].pos <= s){
			ans += (s - a[left].pos);
			break;
		}
		if (a[left].pos >= s){
			ans += (a[right].pos - s);
			break;
		}
		
		ans += (a[right].pos - a[left].pos);
		if (a[left].num >= a[right].num){
			while (left < right && a[left].num >= a[right].num) a[left].num += a[right--].num;
		}
		else{
			while (left < right && a[right].num > a[left].num) a[right].num += a[left++].num;
		}
	}
	
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 1664
from sys import stdin, stdout
# from math import sqrt, pi, acos, gcd, atan2, cos, sin, factorial, log10
# # from matplotlib import mlab
# # from matplotlib import pylab
# # from decimal import Decimal
# # from random import randint
# # import re
# PEPS = 1e-10
# INF = float('inf')
# 
# 
# def sqr(a):
#     return a * a
# 
# 
# def dist(a, b = (0, 0)):
#     return sqrt(sqr(a[0] - b[0]) + sqr(a[1] - b[1]))
# 
# 
# def s_dist(a, b = (0, 0)):
#     return (sqr(a[0] - b[0]) + sqr(a[1] - b[1]))
# 
# 
# def dist3(a, b = (0, 0, 0)):
#     return sqrt(sqr(a[0] - b[0]) + sqr(a[1] - b[1]) + sqr(a[2] - b[2]))
# 
# 
# def s_dist3(a, b = (0, 0, 0)):
#     return (sqr(a[0] - b[0]) + sqr(a[1] - b[1]) + sqr(a[2] - b[2]))
# 
# 
# def trans(p, al):
#     return (p[0] * cos(al) + p[1] * sin(al), - p[0] * sin(al) + p[1] * cos(al))
# 
# 
# def get_angle(a, b, c):
#     cos_al = (sqr(a) + sqr(b) - sqr(c)) / (2 * a * b)
#     return acos(cos_al)
# 
# 
# def write_float(ans):
#     stdout.write(str('%.13f' % ans) + '\n')
# 
# 
# def get_hight(pt1, pt2, pt3):
#     a = (pt2[0] - pt1[0], pt2[1] - pt1[1])
#     b = (pt3[0] - pt1[0], pt3[1] - pt1[1])
#     return abs(a[0] * b[1] - a[1] * b[0]) / dist(pt1, pt2)
# 
# 
# def get_square(pt1, pt2, pt3):
#     a = (pt2[0] - pt1[0], pt2[1] - pt1[1])
#     b = (pt3[0] - pt2[0], pt3[1] - pt2[1])
#     return (a[0] * b[-1] - a[1] * b[0]) / 2
# 
# 
# def sign(v):
#     if v > 0:
#         return 1
#     elif v < 0:
#         return -1
#     else:
#         return 0
# 
# 
# def inn(pt, triangle):
#     signs = set()
#     signs.add(sign(get_square(triangle[0], triangle[1], pt)))
#     signs.add(sign(get_square(triangle[1], triangle[2], pt)))
#     signs.add(sign(get_square(triangle[2], triangle[0], pt)))
#     return len(signs) == 1
# 
# 
# def inter_in(a, b):
#     return dist((a[0], a[1]), (b[0], b[1])) < a[-1] + b[-1]
# 
# 
# def inter_in3(a, b):
#     return dist3(a[:-1], b[:-1]) < a[-1] + b[-1]
# 
# 
# def shift(what, wth):
#     return (what[0] - wth[0], what[1] - wth[1])
# 

a = list(map(int, stdin.readline().split()))
stdout.write(['No', 'Yes'][a[0] == a[1] == a[2]])

Measured memory_bytes: 2940
/**
*    created: 03.07.2020 16:00:37
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    cout << 2 * b - a << endl;
    return 0;
}

Measured memory_bytes: 3520
import sys
input = sys.stdin.readline

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5+100
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
mod=10**9+7
ans=0
for i in range(N):
    ans+=A[i]*(cmb(i,K-1)-cmb(N-i-1,K-1))
    ans%=mod
print(ans)


Measured memory_bytes: 63332
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<cmath>
#define repi(i, n) for(int i = 0; i < (int) n; i++)
#define repn(n) for(int i = 0; i < (int) n; i++)
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define fast() ios::base::sync_with_stdio(false); cin.tie(NULL);
typedef long long int ll;
//typedef vector<int> vi;
//using ll = long long; //only for C++11 compiler and newer

using namespace std;

int main(){
    //fast()
    //freopen("input.txt","r",stdin);
    
    int n; cin >> n;
    int sum = 0, p1, p2, pos[n];
    repn(n){cin >> pos[i]; sum += pos[i];}
    p1 = sum / n;
    p2 = p1 + 1;
    sum = 0;
    repn(n){sum += pow(pos[i] - p1, 2);}
    p1 = sum, sum = 0;
    repn(n){sum += pow(pos[i] - p2, 2);}
    cout << min(p1, sum) << '\n';
    return 0;
}

Measured memory_bytes: 256
N = int(input())
XY_lst = []
for i in range(N):
    XY_lst.append(list(map(int,input().split())))
# print(XY_lst)

def distance(xy_lst1,xy_lst2):
    xi = xy_lst1[0]
    yi = xy_lst1[1]
    xj = xy_lst2[0]
    yj = xy_lst2[1]

    d = ((xi-xj)**2 + (yi-yj)**2)**(0.5)
    return(d)

# make distance dictionary
d_dic = {}
d_sum = 0
for i in range(N):
    i_dic = {}
    for j in range(N):
        dij = distance(XY_lst[i], XY_lst[j])
        d_sum += dij
        i_dic[str(j)] = dij
    d_dic[str(i)] = i_dic
# print(d_dic)
        

# ansewer is culculated by 1/N * sum(dij): i,j included by N
print(d_sum / N)

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

int main() {
  int A, B;

  cin >> A >> B;

  if (A == B) cout << "Draw" << endl;
  else if (A == 1) cout << "Alice" << endl;
  else if (B == 1) cout << "Bob" << endl;
  else if (A > B) cout << "Alice" << endl;
  else cout << "Bob" << endl;

  return 0;
}


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

// int main () {
    
//     ll a,b,n;
//     cin >> a >> b >> n;

//     int max;
//     for (int i = 1; i<=n; i++) {
//         ll now = a*i/b - a*(i/b);
//         if (now > max) max = now;
//     }

//     cout << max << endl; 
// }

int main () {
    ll a,b,n;
    cin >> a >> b >> n;
    ll x = min(b-1,n);
    ll ans = a*x/b - a*(x/b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define puts(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef complex<double> comp;

void solve(void){
	int x1, y1, x2, y2, Q;
	cin >> x1 >> y1 >> x2 >> y2 >> Q;

	comp o(x1, y1), p(x2-x1, y2-y1), r;

	r = polar(1.0, arg(p));

	while(Q--)
	{
		int x3, y3;
		cin >> x3 >> y3;

		comp q(x3-x1, y3-y1);

		q = conj(q / r) * r + o;

		printf("%.12lf %.12lf\n", q.real(), q.imag());
	}


}
int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3508
pi = 3.1415926

############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
a,b,c,k = invr()
ans = 0
if k > a:
    ans += a
    k -= a
    if k > b:
        k -= b
        ans += -1*(k)
        print(ans)
    else:
        print(ans)
        
else:
    print(k)
    


Measured memory_bytes: 61912
n,m = gets.split.map(&:to_i)
l = []
r = []
readlines.each do |item|
	temp = item.split.map(&:to_i)
	l << temp[0]
	r << temp[1]
end

result = r.min - l.max

puts result >= 0 ? result + 1 : 0

Measured memory_bytes: 11772
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

vector<vector<ll>> pascals_triangle(int n) {
    vector<vector<ll>> combi(n + 1, vector<ll>(n + 1));
    REP(i, n + 1) REP(j, i + 1) {
        if (j == 0 || j == i) combi[i][j] = 1LL;
        else combi[i][j] = combi[i - 1][j - 1] + combi[i - 1][j];
    }
    return combi;
}

void solve() {
    ll n, p;
    cin >> n >> p;
    auto pt = pascals_triangle(n + 1);
    ll even = 0;
    REP(i, n) {
        int a;
        cin >> a;
        if (a % 2 == 0) even++;
    }
    ll odd = n - even;
    ll o = 0;
    // printvv(pt);
    for (int i = 0; i <= odd; i += 2) o += pt[odd][i];
    ll ans = (ll)pow(2, even) * o;
    cout << (p == 0 ? ans : (ll)pow(2, n) - ans) << endl;
}


Measured memory_bytes: 4040
#!/usr/bin/env ruby
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

a = a.sort.reverse

ans = 0 + a[0]

i = 3
loop do
  break if i > a.length

  if i % 2 == 0
    ans += a[(i - 2) / 2]
  else
    ans += a[(i - 2) / 2 + 1]
  end
  i += 1
end

puts ans


Measured memory_bytes: 33344
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int n,m,k; 
deque <P> q;
int vis[100005];
int main()
{
	cin>>k;
	q.push_front(make_pair(1,1));
	while(!q.empty())
	{
		P top=q.front();
		//cout<<top.first<<" "<<top.second<<endl; 
		q.pop_front();
		if(vis[top.first]) continue;
        vis[top.first]=1;
		if(top.first==0)
		{
			cout<<top.second<<endl;
			return 0;
		}
		q.push_front(make_pair((top.first*10)%k,top.second));
		q.push_back(make_pair((top.first+1)%k,top.second+1));
	}
	return 0;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //// 文字列の入力
            //string s = Console.ReadLine();

            //// 整数の入力
            //long n = long.Parse(Console.ReadLine());

            //// 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            //// 整数配列の入力
            //var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var N = inputLongArray[0];
            var M = inputLongArray[1];

            var students = new long[N][];
            var points = new long[M][];

			for (int n = 0; n < N; n++) {
                var data = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
                var nn = new long[2];
                nn[0] = data[0];
                nn[1] = data[1];
                students[n] = nn;
			}

            for (int m = 0; m < M; m++) { 
                var data = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
                var mm = new long[2];
                mm[0] = data[0];
                mm[1] = data[1];
                points[m] = mm;
            }

            //var results = new List<string>();

			for (int n = 0; n < N; n++) {
                long answer = long.MaxValue;
                long ret = 1;
				for (int m = 0; m < M; m++) {
                    var aa = students[n][0];
                    var bb = points[m][0];
                    var cc = students[n][1];
                    var dd = points[m][1];

                    var a = Math.Abs(aa - bb) + Math.Abs(cc - dd);
					if (a < answer) {
                        answer = a;
                        ret = m + 1;
					}
                }

                Console.WriteLine(ret);
			}

            Console.Out.Flush();
        }
    }
}


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

int main() {
	int H, W; cin >> H >> W;
	int N; cin >> N;
	vector<int>colors;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		for (int j = 0; j < a; j++)colors.push_back(i+1);
	}

	vector<vector<int>>ans(H, vector<int>(W));

	int l = 0, r = W - 1, t = 0, b = H - 1;
	int dir = 0;
	int pr = 0, pc = 0;
	while (colors.size()) {
		ans[pr][pc] = colors.back();
		colors.pop_back();

		if (dir == 0 && pc == r) {
			dir = (dir + 1) % 4;
			t++;
		}
		if (dir == 1 && pr == b) {
			dir = (dir + 1) % 4;
			r--;
		}
		if (dir == 2 && pc == l) {
			dir = (dir + 1) % 4;
			b--;
		}
		if (dir == 3 && pr == t) {
			dir = (dir + 1) % 4;
			l++;
		}

		if (dir == 0) {
			pc++;
		}
		else if (dir == 1) {
			pr++;
		}
		else if (dir == 2) {
			pc--;
		}
		else {
			pr--;
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (j)cout << " ";
			cout << ans[i][j];
		}
		cout << endl;
	}
	
	return 0;
}

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

using ll =long long;

//最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}

int main()
{
ll N,K;
  cin>>N>>K;
  vector<ll> vec(N);
  for(ll i=0;i<N;i++){
    cin>>vec[i];
  }
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  ll sum=0;
  
  for(ll i=K;i<N;i++){
    sum+=vec[i];
  }
  
  cout<<sum<<endl;
    
}



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


int main()
{ string s,t;
    cin>>s>>t;
    int total = 1e5;
    int flag = 0;
    for(int i = 0;i<s.size();i++){
        int cur = 0;
        for(int j = 0;j<t.size();j++){
            if(i+j>=s.size()){
                flag = 1;
                break;
            }
            if (t[j]!=s[i+j]) cur++;
            
        }
        if(flag==1) break;
        total = min(total,cur);
    }
    cout<<total<<endl;
    
     
return 0;
   
}

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

using namespace std;

int N;
long long int A, B, X[100005];

int main(void) {

	cin >> N >> A >> B;
	long long int tmp;
	for (int i = 1; i <= N; i++) {
		cin >> tmp; X[i] = tmp;
	}

	long long int ans=0;

	for (int i = 1; i <= N-1; i++) {
		ans += min(A*(X[i + 1] - X[i]), B);
	}

	cout << ans << endl;
	//system("pause");
	return 0;
}

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

#define int long long

int32_t main() {
    string s; cin >> s;
    int a = 0, sum = 0;
    for(char x: s) {
        if(x == 'B') a++;
        else sum += a;
    }
    cout << sum << endl;
}


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

bool compare(tuple<int, int, int, string> a, tuple<int, int, int, string> b) {
  return get<2>(a) < get<2>(b);
}

int main() {
  int n, m;

  cin >> n >> m;

  vector<tuple<int, int, int, string>> c(m);

  for (int i = 0; i < m; i++) {
    int p, y;
    cin >> p >> y;
    c[i] = make_tuple(p, y, i, "kari");
  }

  sort(c.begin(), c.end());

  int pnum = get<0>(c[0]);
  char s[100];
  sprintf(s, "%06d%06d", pnum, 1);
  get<3>(c[0]) = s;

  int p = get<0>(c[0]);
  int y = 2;

  for (int i = 1; i < m; i++) {
    if (p == get<0>(c[i])) {
      sprintf(s, "%06d%06d", p, y);
      get<3>(c[i]) = s;

      y++;
    } else {
      y = 2;
      p = get<0>(c[i]);
      pnum = get<0>(c[i]);
      sprintf(s, "%06d%06d", p, 1);
      get<3>(c[i]) = s;
    }
  }

  sort(c.begin(), c.end(), compare);

  for (int i = 0; i < m; i++) {
    cout << get<3>(c[i]) << endl;
  }

  return 0;
}

Measured memory_bytes: 9344
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0093
{
    public class Program

    {
        public static void Main(string[] args)
        {
            bool NotFirst = false;
            while (true)
            {
                
                int[] items = RIntAr();
                if (items.Sum() == 0) return;

                List<int> reapYear = new List<int>();
                for (int i = items[0] ; i <= items[1] ; i++)
                {
                    if (i % 400 == 0) reapYear.Add(i);
                    else if (i % 4 == 0 && i % 100 != 0) reapYear.Add(i);
                }

                if (NotFirst) Console.WriteLine("");
                else NotFirst = true;

                if (reapYear.Count() > 0)
                {
                    foreach (var item in reapYear)
                    {
                        Console.WriteLine(item);
                    }
                }
                else
                {
                    Console.WriteLine("NA");
                }
                
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 20280
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;
bool debug = true;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  ll ans = 2 * N;
  for (ll i = 0; i < N; ++i) {
    bool ok = true;
    for (ll j = 0; i + j < N; ++j) {
      if (S.at(i + j) !=  T.at(j)) {
        ok = false;
      }
    }
    if (ok) {
      ans = min(ans, i + N);
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3544
from collections import deque
H, W = map(int, input().split())
R = [[0 for j in range(W)] for i in range(H)]
ans = 0
dx = [[-1, 0], [1, 0], [0, -1], [0, 1]]
for i in range(H):
  inp = input()
  for j in range(W):
  	if inp[j] == "#":
  	  R[i][j] = 1
for s in range(H * W):
  sh = s // W
  sw = s % W
  if R[sh][sw] == 1:
    continue
  D = [[-1 for j in range(W)] for i in range(H)]
  D[sh][sw] = 0
  d = deque([(sh, sw)])
  while len(d):
    a = d.pop()
    for k in range(4):
      hn = a[0] + dx[k][0]
      wn = a[1] + dx[k][1]
      if 0 <= hn < H and 0 <= wn < W and R[hn][wn] == 0 and D[hn][wn] == -1:
        D[hn][wn] = D[a[0]][a[1]] + 1
        ans = max(ans, D[hn][wn])
        d.appendleft((hn, wn))
print(ans)

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

int No(){
	cout << "No" << endl;
	return 0;
}

int main(){
	int N,A,B,C,D;
	string S;
	cin >> N >> A >> B >> C >> D >> S;
	A--;
	B--;
	C--;
	D--;
	
	for(int i=A;i<C;i++)if(S[i]=='#' && S[i+1]=='#')return No();
	for(int i=B;i<D;i++)if(S[i]=='#' && S[i+1]=='#')return No();
	
	if(C>D){
		bool flag=false;
		for(int i=B;i<=D;i++)if(S[i-1]=='.' && S[i]=='.' && S[i+1]=='.')flag=true;
		if(!flag)return No();
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 644
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
void solve(); int main() { solve(); return 0; }

void solve() {
  string s;
  cin >> s;
  cout << s.rfind("Z") - s.find("A") + 1 << endl;
}


Measured memory_bytes: 3724
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX_N = 100000;
long a[MAX_N], b[MAX_N];
long long x;
pair<long long, long long> p[MAX_N];
long solve(){
    long long count = 0 ;
    count += (x/11)*2;
    x %= 11;
    if(x != 0)  count += (x/7 + 1);  
    return count;
}
int main(){
    cin >> x;
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n;
    cin >> n;
    vector<ll> t(n), a(n);
    rep(i, n)cin >> t[i] >> a[i];
    ll x = 1, y = 1;
    rep(i, n) {
		ll now = max( (x + t[i] - 1) / t[i], (y + a[i] - 1) / a[i]);
		x = t[i] * now; 
        y = a[i] * now;
	}
    cout << x+y << endl;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(b==1){cout << 0 << endl;return 0;}
  int ans = 1;
  int tap = 1;
  tap = a;
  if(b<=tap){cout << 1 << endl;return 0;}
  while(true){
    ans++;
    tap += a-1;
    if(b<=tap){cout << ans << endl;return 0;}
  }
}

Measured memory_bytes: 256
import numpy as np
from itertools import permutations

n, c = map(int, input().split())
change_cost = [np.array(list(map(int, input().split()))) for i in range(c)]

iwakan = {}
for i in range(3):
    iwakan[i] = np.zeros(c)

for i in range(n):
    for j, color in enumerate(list(map(int, input().split()))):
        iwakan[(i+j)%3] += change_cost[color-1]

ans = float("inf")
for p in permutations(range(c), 3):
    cost = 0
    for i, color in enumerate(p):
        cost += iwakan[i][color]
    ans = min(ans, cost)
print(int(ans))

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

typedef long long ll;
using namespace std;

bool graph[8][8];

int dfs(int v, int N, bool visited[8]) {
  bool all_visited = true;
  for (int i = 0; i < N; i++) {
    if (visited[i] == false) {
      all_visited = false;
    }
  }

  if (all_visited) {
    return 1;
  }

  int ret = 0;

  for (int i = 0; i < N; i++) {
    if (graph[v][i] == false)
      continue;
    if (visited[i])
      continue;
    visited[i] = true;
    ret += dfs(i, N, visited);
    visited[i] = false;
  }
  return ret;
}

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

  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    graph[A - 1][B - 1] = graph[B - 1][A - 1] = true;
  }

  bool visited[8];
  for (int i = 0; i < N; i++) {
    visited[i] = false;
  }

  visited[0] = true;
  cout << dfs(0, N, visited) << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=a-1;i>=b;i--)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.14159265358979323
#define sz(a) (int)((a).size())
#define len(a) (int)(a.length())
#define FOR(i,j,k,l) for(ll i=j;i<k;i+=l)
#define CC(x) cout<<x<<endl


void Fast_IO() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("input.in","r",stdin);
   freopen("output.out","w",stdout); 
   #endif
}
int main(){
   //Fast_IO();
   ll n,k;
   cin>>n>>k;
   ll a[n];
   f(i,0,n) cin>>a[i];
   ll u=a[0],b=a[k];
   if(b>u) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   ll x=1;
   while(x+k<n){
      u=a[x];
      b=a[k+x];
      x++;
      if(b>u) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
   }
}

Measured memory_bytes: 5168
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i;
    cin >> n >> m;
    string a[n],b="";
    for(i=0;i<n;i++)
    {
        cin >> a[i];
    }
    sort(a,a+n);
    for(i=0;i<n;i++)
    {
        b+= a[i];
    }
    cout << b;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define e "\n"
#define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#define fix(n) cout << fixed << setprecision(n);
using namespace std;
int main()
{
	MaRiaMa;
	int a, b,sum=16;
	cin >> a >> b;
	int s = max(a, b) - min(a, b);
	if (s == 0)
		cout << "Yay!";
	else
	{
		sum -= (2*min(a,b));
		if ((s += s) <= sum)
			cout << "Yay!";
		else
			cout << ":(";
	}
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(998244353)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

vector<ll> G[(int)1e5+2];
bool checked[(int)1e5+2];
int color[(int)1e5+2];

bool saiki(int now, int col){
  if(checked[now]){
    return color[now] == col;
  }
  checked[now] = true;
  color[now] = col;
  rep(j, G[now].size()){
    int next = G[now][j];
    if(!saiki(next, (col+1) & 1)){
      return false;
    }
  }

  return true;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n,m;
  cin>>n>>m;
  rep(i,m){
    ll a,b;cin>>a>>b;a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  if(!saiki(0, 0)){
    cout<< n * (n-1) / 2 - m << endl;
    return 0;
  }

  ll C0 = 0, C1 = 0;
  rep(i,n){
    if(color[i] == 0){
      C0++;
    }else{
      C1++;
    }
  }
  cout<< C0 * C1 - m <<endl;

  return 0;
}

Measured memory_bytes: 7168
a=int(raw_input())
b=int(raw_input())
c=int(raw_input())
x=int(raw_input())
op=0
for i in range(a+1):
	for j in range(b+1):
		for k in range(c+1):
			if 500*i+100*j+50*k==x:
				op=op+1
				
print op

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


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


    int res = 0;
    for(int i=1; i*2<s.size(); i++) {
        string l="", r="";
        FOR(j, 0, i) {
            l += s[j];
            r += s[i+j];
        }
        if(l==r) res = 2*i;
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N;
    cin >> N;
    vector<int> A;
    int before=-1;
    rep(i,N){
        int in;
        cin >> in;
        if(before!=in) A.push_back(in);
        before=in;
    }
    int S=A.size();
    if(S<=2){
        cout << 1 << endl;
        return 0;
    }
    int ans=1;
    int up=(A[0]<A[1])?1:-1;
    for(int i=1;i<S-1;i++){
        if(A[i-1]<A[i] && A[i]>A[i+1]){
            ans++,i++;
            continue;
        }
        if(A[i-1]>A[i] && A[i]<A[i+1]) ans++,i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
N,_=gets.chomp.split(' ').map{|n| n.to_i}
T,A=gets.chomp.split(' ').map{|n| n.to_i}
H=gets.chomp.split(' ').map{|n| n.to_i}

min = 999999999999
imin = -1
for i in 0..(H.size-1)
	h = H[i]
	tmp = (A-(T-h*0.006)).abs
	if(min > tmp)
		min = tmp
		imin = i+1
	end
end
puts imin


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

using namespace std;
#define ll long long int


int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    int s = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        s+=a[i];
    }
    int x = 4*m;
    int cnt = 0;
    for(int i=0;i<n;i++){
        if(x*a[i]>=s) cnt++;
    }
    if(cnt>=m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define print(x) cout<<(x)<<'\n'
using ll=long long;
using pl=pair<ll,ll>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vs=vector<string>;

void solve() {
    ll R;
    cin >> R;
    if(R<1200) print("ABC");
    else if(R<2800) print("ARC");
    else print("AGC");
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
#include<numeric>
#include<queue>
#define int long long int
using namespace std;
int i, j, k, a, b, c, d, p[100000], n, f;
signed main() {
	cin >> a;
	for (i = 0; i < a; i++)
		cin >> p[i];
	b = 2;
	n += p[0] - 1;
	for (i = 1; i < a; i++) {
		n += (p[i] - 1) / b;
		if (p[i] == b)
			b++;
	}
	cout << n << endl;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {
	
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n=Integer.parseInt(scan.next());
		int q=Integer.parseInt(scan.next());
		String s=scan.next();
		int[] count=new int [n];
		Arrays.fill(count, 0);
		//累積和
		for (int i=1;i<n;++i) {
			if (s.charAt(i-1)=='A'&&s.charAt(i)=='C') {
					count[i]=count[i-1]+1;			
				}
			else {
				count[i]=count[i-1];
			}
		}
		
		int l,r;
		int[] ans =new int [q];
		for (int i=0;i<q;++i) {
			l=Integer.parseInt(scan.next());
			r=Integer.parseInt(scan.next());
			ans[i]=count[r-1]-count[l-1];
			
		}
		
		for (int i=0;i<q;++i) {
			System.out.println(ans[i]);
		}
		
	
}
}
//end


Measured memory_bytes: 58100
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main()
{    
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  // int takahashi_num = C/B + (C%B)*1;
  // int aoki_num = A/D + (A%D)*1;
  // if (takahashi_num > aoki_num)
  // {
  //   cout << "No" << endl;
  // }else{
  //   cout << "Yes" << endl;
  // }

  for (int i = 0; i < 200; i++)
  {
    C -= B;
    if (C <= 0)
    {
      cout << "Yes" << endl;
      return 0;
    }
    A -= D;
    if (A <= 0){
      cout << "No" << endl;
      return 0;
    }
    
  }
  
  
} 


Measured memory_bytes: 3588
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll n, k;
    cin >> n >> k;

    ll l = 0, r = INF;

    vector<ll> a(n);

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

    while (r - l > 1)
    {
        ll mid = (r + l) / 2;

        ll count = 0;

        for (ll i = 0; i < n; i++)
        {
            if (a[i] % mid == 0)
            {
                count += a[i] / mid - 1;
            }
            else
            {
                count += a[i] / mid;
            }
        }

        if (count <= k)
        {
            r = mid;
        }
        else
        {
            l = mid;
        }
    }

    cout << r << endl;
}


Measured memory_bytes: 4752
K = int(input())
total = 0

def gcd(a, b):
    if(a > b):
        a, b = b, a

    while(b > 0):
        r = a % b
        a = b
        b = r

    return a

dp = [[0 for i in range(K+1)] for j in range(K+1)]

for a in range(1, K+1):
    for b in range(1, K+1):
        if(dp[a][b] == 0):
            dp[a][b] = gcd(a, b)

        res = dp[a][b]

        for c in range(1, K+1):
            if(dp[res][c] == 0):
                dp[res][c] = gcd(res, c)

            total += dp[res][c]


print(total)

Measured memory_bytes: 9516
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <tuple>
#include <vector>

using namespace std;

class union_find {
    vector<int> p;
    vector<int> r;

public:
    union_find(int n) {
        p = vector<int>(n);
        r = vector<int>(n);

        for (int i = 0; i < n; i++) {
            p[i] = i;
            r[i] = 0;
        }
    }

    int root(int a) {
        if (p[a] != a) {
            p[a] = this->root(p[a]);
        }

        return p[a];
    }

    void unite(int a, int b) {
        int ra = this->root(a);
        int rb = this->root(b);

        if (ra == rb) {
            return;
        }

        if (r[ra] < r[rb]) {
            p[ra] = rb;
        } else {
            p[rb] = ra;

            if (r[ra] == r[rb]) {
                r[ra]++;
            }
        }
    }
};

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

    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }

    vector<tuple<int, int, int>> xy, yx;
    for (int i = 0; i < n; i++) {
        xy.push_back(make_tuple(x[i], y[i], i));
        yx.push_back(make_tuple(y[i], x[i], i));
    }

    sort(xy.begin(), xy.end());
    sort(yx.begin(), yx.end());

    priority_queue<tuple<int, int, int>,
            vector<tuple<int, int, int>>,
            greater<tuple<int, int, int>>> que;
    for (int i = 0; i < n - 1; i++) {
        que.push(make_tuple(
                min(abs(get<0>(xy[i]) - get<0>(xy[i + 1])), abs(get<1>(xy[i]) - get<1>(xy[i + 1]))),
                get<2>(xy[i]), get<2>(xy[i + 1])));
        que.push(make_tuple(
                min(abs(get<0>(yx[i]) - get<0>(yx[i + 1])), abs(get<1>(yx[i]) - get<1>(yx[i + 1]))),
                get<2>(yx[i]), get<2>(yx[i + 1])));
    }

    long long res = 0;

    union_find uf(n);
    while (!que.empty()) {
        tuple<int, int, int> q = que.top();
        que.pop();

        if (uf.root(get<1>(q)) != uf.root(get<2>(q))) {
            uf.unite(get<1>(q), get<2>(q));
            res += get<0>(q);
        }
    }

    cout << res << endl;
}


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

int main() {
  int a,b;
  string A,B,C;
  cin>>A>>B>>a>>b>>C;
  if(A==C){
    a--;
  }
  else{
    b--;
  }
  cout<<a<<" "<<b;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	int counts[] = { 0,0,0,0 };
	for (int i = 0; i < n; ++i) {
		string input;
		cin >> input;
		if (input == "AC") counts[0]++;
		if (input == "WA") counts[1]++;
		if (input == "TLE") counts[2]++;
		if (input == "RE") counts[3]++;
	}

	cout << "AC x " << counts[0] << endl;
	cout << "WA x " << counts[1] << endl;
	cout << "TLE x " << counts[2] << endl;
	cout << "RE x " << counts[3] << endl;

	return 0;
}

Measured memory_bytes: 3244
n = int(input())
a = [ int(i) for i in input().split(" ")]

dp = [ -1 for i in range(len(a))]
dp[0] = 0

for i in range(1, len(a)):
  onestep = dp[i-1] + abs(a[i-1] - a[i])
  if i - 2 < 0:
    twostep = onestep
  else:
    twostep = dp[i-2] + abs(a[i-2] - a[i])
  
  dp[i] = min(onestep, twostep)

print(dp[-1])

Measured memory_bytes: 13976
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

int main() {
	int N, K; cin >> N >> K;
	VI A(N), num(N, 0); 
	rep(i, 0, N) {
		scanf("%d", &A[i]);
		++num[A[i]];
	}
	sort(ALL(num), greater<int>());

	int cnt = 0;
	rep(i, 0, K) cnt += num[i];
	
	cout << N - cnt << "\n";
	
	return 0;
}


Measured memory_bytes: 1792
N = int(input())
XY = [list(map(int,input().split())) for _ in range(N)]

dist = 0
for x1,y1 in XY:
    for x2,y2 in XY:
        dist += ((x1-x2)**2+(y1-y2)**2)**(1/2)
print(dist/N)

Measured memory_bytes: 3060
//112B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int n=0, T=0, c=0, t=0, ans=1001;
    cin >> n >> T;
    rep(i, n){
        cin >> c >> t;
        if(t<=T){
            if(c < ans) ans = c;
        }
    }
    if(ans==1001){
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

int main(void)
{
    ll X,K,D,k;
    cin >> X >> K >> D;

    ll ans;

    X = abs(X);
    if (X/K >= D) {
        ans = X - D*K;
    }
    else {
        k = X/D;
        K -= k;
        X -= k*D;
        if (K%2 == 1) {
            X = abs (X-D);
        }
        ans = X;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'


int main() {
  int n;
  cin >> n;
  vi h(n);
  rep (i, n) cin >> h[i];

  rep (i, n) {
    if (i == 0) h[i]--;
    else {
      if (h[i - 1] == h[i]) continue;
      else {
        h[i]--;
        if (h[i] < h[i - 1]) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 640