akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
  int n,k;
  std::cin >> n>>k;
  string s;
  std::cin >> s;
  s[k-1]=s[k-1]-'A'+'a';
  std::cout << s << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s, t; cin >> s >> t;
	cout << (t.substr(0, s.size()) == s ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 3652
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

type Pair struct{ a, b int }

func smaller(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func fill(a []int, val int) {
	for i := 0; i < len(a); i++ {
		a[i] = val
	}
	return
}

func swap(a int, b int) (int, int) { return b, a }

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()
	ps := make([]Pair, n-1)
	al := make([][]int, n)
	for i := 0; i < n-1; i++ {
		x, y := ri()-1, ri()-1
		ps[i] = Pair{a: x, b: y}
		al[x] = append(al[x], y)
		al[y] = append(al[y], x)
	}
	c := make([]int, n)
	for i := 0; i < n; i++ {
		c[i] = ri()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(c)))
	vtx := make([]int, n)
	ci := 0
	var cur int
	q := []int{0}
	for len(q) != 0 {
		cur, q = q[0], q[1:]
		if vtx[cur] == 0 {
			vtx[cur] = c[ci]
			ci++
		}
		if ci == len(c) {
			break
		}
		for _, v := range al[cur] {
			if vtx[v] == 0 {
				q = append(q, v)
			}
		}
	}
	sum := 0
	for _, p := range ps {
		sum += smaller(vtx[p.a], vtx[p.b])
	}
	fmt.Println(sum)
	for i := 0; i < len(vtx)-1; i++ {
		fmt.Print(vtx[i])
		fmt.Print(" ")
	}
	fmt.Println(vtx[len(vtx)-1])
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

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

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  ll l=m/2;
  ll ans=min(n,l);
  if(l>n){
    ans+=(m-2*n)/4;
  }
  cout<<ans<<endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  for(int i = 0; i < N; i++){
    cin >> X.at(i);
  }
  
  int ans = 1000000;
  for(int i = 1; i <= 100; i++){
    int sum = 0;
    for(int j = 0; j < N; j++){
      sum += pow(X.at(j)-i, 2);
    }
    ans = min(ans, sum);
  }
  
  cout << ans;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin>>n;
    vector<pii> a(n);
    REP(i,n) {
        cin>>a[i].first>>a[i].second;
    }
    sort(ALL(a));
    int ans=n+a[0].first-1;
    REPF(i,1,n) {
        ans+=min(a[i].first-a[i-1].first-1,a[i-1].second-a[i].second-1);
    }
    ans+=a[n-1].second;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#define N 1000

int main(void){
  int i,num,j;
  double a[N],s;

  for(i=0;scanf("%lf",&a[i])==1;i++){}
  num=i;
  for(i=0;i<num;i++){
    s=0.0;
    for(j=0;j<10;j++){
      s+=a[i];
      if(j%2==1)
        a[i]/=3.0;
      else
        a[i]*=2.0;
    }
    printf("%0.8f\n",s);
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int count_0 = 0;
  int count_1 = 0;
  for(int i =0;i<S.size();i++){
    if(i % 2 == 0){
      if(S.at(i) != '0'){
        count_0 ++;
      }
    }else{
      if(S.at(i) != '1'){
        count_0 ++;
      }
    }
  }
  for(int i =0;i<S.size();i++){
    if(i % 2 == 0){
      if(S.at(i) != '1'){
        count_1 ++;
      }
    }else{
      if(S.at(i) != '0'){
        count_1 ++;
      }
    }
  }
    if(count_0 <= count_1){
      cout << count_0 << endl;
    }else{
      cout << count_1 << endl;
    }
  
}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
int main(void){
    char step[200];
    int num=0;
    int flag=0;

    scanf("%s",&step);

    num=strlen(step);

    for(int i=0;i<num;i++){
        if(i%2==0){
            if(step[i]=='L'){
                flag=1;
                break;
            }
        }if(i%2==1){
            if(step[i]=='R'){
                flag=1;
                break;
            }
        }
    }
    if(flag==0){
        printf("Yes");
    }
    if(flag==1){
        printf("No");
    }
    return 0;

}

Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
keta=[0 for i in range(61)]
ans=0
for i in range(n):
  b=a[i]
  cnt=0
  while(b>=1):
    if b%2==1:
      keta[cnt]+=1
    b=b//2
    cnt+=1
#print(keta)
for i in range(61):
  #print(keta[i])
  #print(keta[i]*(n-keta[i])*(2**i))
  ans+=(keta[i]*(n-keta[i])*(2**i))%(1000000007)
while(ans>1000000007):
  ans%=1000000007
print(ans)

Measured memory_bytes: 122936
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n;
	cin >> n;
	vector<int> t(n), st(n + 1), mt(n + 1), v(t);
	int sum = 0;
	REP(i, n) {
		cin >> t[i];
		sum += t[i];
	}
	REP(i, n) {
		cin >> v[i];
	}
	st[0] = 0;
	mt[0] = 0;
	REP(i, n) {
		st[i + 1] = st[i] + t[i];
		mt[i + 1] = min(mt[i], v[i] - st[i + 1]);
	}
	vector<double> temp(sum * 2 + 1);
	int cnt = 0;
	REP(i, sum * 2) {
		if (st[cnt + 1] * 2 == i) {
			cnt++;
		}
		temp[i] = min<double>(v[cnt], mt[cnt] + (double)i / 2);
	}
	temp[sum * 2] = 0;
	reverse(all(t));
	reverse(all(v));
	st[0] = 0;
	mt[0] = 0;
	REP(i, n) {
		st[i + 1] = st[i] + t[i];
		mt[i + 1] = min(mt[i], v[i] - st[i + 1]);
	}
	cnt = 0;
	REP(i, sum * 2) {
		if (st[cnt + 1] * 2 == i) {
			cnt++;
		}
		chmin(temp[sum * 2 - i], min<double>(v[cnt], mt[cnt] + (double)i / 2));
	}
	double res = 0;
	REP(i, sum * 2) {
		res += (temp[i] + temp[i + 1])*0.25;
	}
	cout << setprecision(20) << res << endl;
	return 0;
}


Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define inv(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class CRemainderMinimization2019 {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int L, R;
    cin >> L >> R;
    int ans = INF;
    vector<int> divisor;
    FOR(i, L, min(R + 1, L + 2020)) {
      divisor.emplace_back(i % 2019);
    }
    rep(i, divisor.size() - 1) {
      FOR(j, i + 1, divisor.size()) {
        ans = min(ans, divisor[i] * divisor[j] % 2019);
      }
    }
    cout << ans << endl;
  }
};


signed main() {
  CRemainderMinimization2019 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const double PI = acos(-1);

void solve(){
    //5
    int n;
    cin>>n;
    int arr[n];
    loop(n,i,0){
        int x;
        cin>>x;
        arr[x-1]=i+1;
    }
    loop(n,i,0)
        cout<<arr[i]<<' ';
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 4048
// C++ program to find angle between hour and minute hands 
#include <bits/stdc++.h> 
using namespace std; 

// Utility function to find minimum of two integers 
long double min(long double x, long double y) 
{ 
	return (x < y)? x: y; 
	
} 

long double calcAngle(double h, double m) 
{ 
	// validate the input 
	

	if (h == 12) h = 0; 
	if (m == 60) m = 0; 

	// Calculate the angles moved 
	// by hour and minute hands 
	// with reference to 12:00 
   long double hour_angle = 0.5 * (h * 60.0 + m); 
   long double minute_angle = 6.0 * m; 

	// Find the difference between two angles 
	long double angle = abs(hour_angle - minute_angle); 

	// Return the smaller angle of two possible angles 
	angle = min(360 - angle, angle); 

	return angle; 
} 

// Driver program to test above function 
const long double pi= 3.141592653589;
int main() 
{ 
	long double  a , b , h , m;
	cin>>a>>b>>h>>m;
	long double x = calcAngle(h , m);
	// cos x = a*a + b*b - c*c/2ab
	 long double z =  a*a + b*b - cos((x*pi)/((1.0)*180))*(2*a*b);
	 cout<<fixed<<setprecision(18)<<sqrt(1.0L*z)<<endl;
	return 0;
} 

// This is code is contributed by rathbhupendra 



Measured memory_bytes: 4172
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int gcd(int x, int y) {
    while(x != 0 && y != 0) {
        if(x > y)
            x = x % y;
        else
            y = y % x;
    }
    return x == 0 ? y : x;
}

int N, A[100000];
int main(int argc, char **argv) {
    cin >> N;
    for(int i = 0; i < N; ++i)
        cin >> A[i];
    
    int res = 0;
    for(int i = 0; i < N; ++i)
        res = gcd(res, A[i]);
    
    cout << res << endl;
}

Measured memory_bytes: 640
n = int(input())
def print_from_l(l):
    print(''.join(map(lambda s:chr(97+s), l)))
def g(l):
    if len(l) == n:
        print_from_l(l)
    else:
        for i in range(max(l)+2):
            g(l + [i])
g([0])

Measured memory_bytes: 4412
#include <iostream>
using namespace std;
typedef long long ll;
int n,k;
const int MAXN=2005;
struct Edge
{
	int u,v,next;
}e[MAXN*2];
int h[MAXN],cnt,size[MAXN];
void addEdge(int u,int v)
{
	e[++cnt].v=v;e[cnt].next=h[u];h[u]=cnt,e[cnt].u=u;
	e[++cnt].v=u;e[cnt].next=h[v];h[v]=cnt,e[cnt].u=v;
}
int dfs(int u,int anc,int dep)
{
	int tmp=1;
	if(dep==k/2)
		return 1;
	else
		for(int i=h[u];i;i=e[i].next)
			if(e[i].v!=anc)tmp+=dfs(e[i].v,u,dep+1);
	return tmp;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		addEdge(x,y);
		size[x]++;
		size[y]++;
	}
	int ans=0;
	if(k%2==0)
	{
		for(int i=1;i<=n;i++)
			ans=max(ans,dfs(i,0,0));
	}
	else
	{
		for(int i=1;i<=cnt;i+=2)
			ans=max(ans,dfs(e[i].u,e[i].v,0)+dfs(e[i].v,e[i].u,0));
	}
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,i,sum = 0;
    cin >> n;
    int x[n];
    for(i=0; i<n; i++){
        cin >> x[i];
        sum += x[i];
    }
    int ave = (double)sum/(double)n + 0.5;

    int total = 0;
    for(i=0; i<n; i++){
        total += (x[i]-ave)*(x[i]-ave);
    }
    
    cout << total << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e6 + 3)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}
int exp(int a, int b){
    LL res = 1;
    LL sum = a;
    for(int i=0;i<30;++i){
        if(BIT(i)&b){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
    }
    return res;
}

int main(){
    LL N;
    LL L;
    cin >> N;
    cin >> L;
    LL line[N+1];
    REPA(i, N+1){
        cin >> line[i];
    }
    int place = -1;
    REPA(i, N){
        if(line[i] + line[i+1] >= L){
            place = i;
        }
    }
    if(place == -1){
        cout << "Impossible" << endl;
    }else{
        cout << "Possible" << endl;
        for(int i=1;i<place;++i){
            cout << i << endl;
        }
        for(int i=N-1;i>place;--i){
            cout << i << endl;
        }
        cout << place << endl;
    }
    return 0;
}


Measured memory_bytes: 1536
#!/usr/bin/env python

n = int(input())
a = list(map(int, input().split()))

d = {}
cnt = 0 
for i in range(n):
    if a[i] not in d:
        d[a[i]] = 1 
    else: 
        d[a[i]] += 1

for key in d.keys():
    if d[key] != key:
        if d[key] < key:
            cnt += d[key]
        else:
            cnt += d[key]-key

print(cnt)


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> pro(n + 1, 0);
    int ac = 0, pe = 0;
    for (int i = 0; i < m; i++) {
        int p;
        string s;
        cin >> p >> s;
        if (s == "AC") {
            if (pro[p] >= 0) {
                ac++;
                pe += pro[p];
                pro[p] = -1;
            }
        } else if (pro[p] >= 0) {
            pro[p]++;
        }
    }
    cout << ac << " " << pe << endl;
    return 0;
}


Measured memory_bytes: 640
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int intans = 0;
        intans = a-b +1;

        PrintWriter out = new PrintWriter(System.out);
        out.println(intans);
        out.flush();
        scan.close();
    }
}

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

int main()
{
  char a, b, c;
  cin >> a >> b >> c;
  cout << a;
  cin >> a >> b >> c;
  cout << b;
  cin >> a >> b >> c;
  cout << c;
}


Measured memory_bytes: 3540
N,M,C = map(int,input().split())
res =0
B = input().split()
B = [int(i) for i in B]
for i in range(N):
  a = input().split()
  a = [int(j) for j in a]
  A = 0
  for j in range(M):
    A = A +a[j]*B[j]
  A =A+C
  if A > 0:
    res +=1
print(res)

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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

vi ans;
int N,M, tmp;

void solve(){
    for( int i = 2; i <= N; ++i){
        if(ans[i] != 0){
            ans[i] = ans[i-1] + ans[i-2];
            ans[i] %= MOD;
        } 
    }

    // rep(i, N+1)
    cout << ans[N] << endl;
}

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

    ans.resize(N+1);

    fill(ans.begin(), ans.end(), -1);

    ans[0] = 1;
    ans[1] = 1;

    rep(i,M){
        cin >> tmp;
        ans[tmp] = 0;
    }

    // rep(i, N+1)
    //     cout << ans[i] << endl;

    // cout << endl;

    solve();
}


Measured memory_bytes: 640
production = True

import sys, math, collections

def input(input_format = 0, multi = 0):

    if multi > 0: return [input(input_format) for i in range(multi)]
    else:
        next_line = sys.stdin.readline()[:-1]

        if input_format >= 10:
            use_list = False
            input_format = int(str(input_format)[-1])
        else: use_list = True

        if input_format == 0: formatted_input = [next_line]
        elif input_format == 1: formatted_input = list(map(int, next_line.split()))
        elif input_format == 2: formatted_input = list(map(float, next_line.split()))
        elif input_format == 3: formatted_input = list(next_line)
        elif input_format == 4: formatted_input = (lambda x: [x[0], list(map(int, x[1:]))])(next_line.split())
        elif input_format == 5: formatted_input = (lambda x: [x[0], list(map(float, x[1:]))])(next_line.split())
        elif input_format == 6: formatted_input = next_line.split()
        else: formatted_input = [next_line]

        return formatted_input if use_list else formatted_input[0]


def out(output_line, output_format = 0, newline = True):

    formatted_output = ""

    if output_format == 0: formatted_output = str(output_line)
    elif output_format == 1: formatted_output = " ".join(map(str, output_line))
    elif output_format == 2: formatted_output = "\n".join(map(str, output_line))

    print(formatted_output, end = "\n" if newline else "")


def log(*args):
    if not production:
        print("$$$", end = "")
        print(*args)

enum = enumerate

#
#   >>>>>>>>>>>>>>> START OF SOLUTION <<<<<<<<<<<<<<
#


def solve():

    n, m, k = input(1)
    a = input(1)
    b = input(1)


    ap = [0]
    bp = [0]

    for i in a:
        ap.append(ap[-1] + i)

    for i in b:
        bp.append(bp[-1] + i)


    log(ap, bp)

    pa = 0

    while pa < len(ap) and ap[pa] <= k:
        pa += 1

    m = pa - 1
    pb = 1

    c = k - ap[pa - 1]

    for i in range(pa - 1, -1, -1):
        while pb < len(bp) and bp[pb] <= c:
            m = max(pa - 1 + pb, m)
            pb += 1
        pa -= 1
        c += a[pa - 1]

    out(m)


        
    



    return


#for i in range(input(11)): solve()
solve()

#
#   >>>>>>>>>>>>>>>> END OF SOLUTION <<<<<<<<<<<<<<<
#


Measured memory_bytes: 130880
#include <stdio.h>
const int N=1e3+10;
int max(int a,int b){return a>b?a:b;}
int main(){
    int d,g,p[N],c[N],dp[N][2],tot=0;
    bool f=false;
    scanf("%d%d",&d,&g);
    g/=100;
    for(int i=1;i<=d;i++){
        scanf("%d%d",&p[i],&c[i]);
        c[i]/=100;
        tot+=p[i];
    }
    for(int i=0;i<=tot;i++)dp[i][true]=dp[i][false]=0;
    for(int i=1;i<=d;i++){
        for(int j=0;j<p[i];j++)for(int k=j;k<=tot;k++)dp[k][f]=max(dp[k][f],dp[k-j][!f]+i*j);
        for(int j=p[i];j<=tot;j++)dp[j][f]=max(dp[j][f],dp[j-p[i]][!f]+i*p[i]+c[i]);
        f=!f;
    }
    for(int i=0;i<=tot;i++){
        if(dp[i][!f]>=g){
            printf("%d\n",i);
            return 0;
        }
    }
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <deque>
#include <vector>

auto main() -> int {
  int A, B, K;
  std::cin >> A >> B >> K;

  int ans;
  int f = 0;

  int t = std::min(A, B);
  while (f != K) {
    if (A % t == 0 && B % t == 0) {
      f++;
      ans = t;
    }
    t--;
  }

  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

vector<P> path[100005];
bool used[100005];
int dis[100005];

bool check(int p,int d){
	if(used[p]){
		if(dis[p]==d)return true;
		return false;
	}
	used[p]=true;
	dis[p]=d;
	
	for(int i=0;i<path[p].size();i++){
		if(!check(path[p][i].first,d+path[p][i].second))return false;
	}
	return true;
}


int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	bool s;
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>a>>b>>c;
		a--,b--;
		path[a].push_back(make_pair(b,c));
		path[b].push_back(make_pair(a,-c));
	}
	for(i=0;i<n;i++){
		if(used[i])continue;
		s=check(i,0);
		if(!s)break;
	}
	print_Yes_No(s);
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

ll N,M;

P ok(ll mid,vector<ll> &a,vector<ll> &s) {
  ll cnt = 0, sum = 0;
  ll l = N - 1;
  bool end = false;
  rep(i,N) {
    while(1) {
      if(a[i] + a[l] >= mid) {
	if(l==0) {
	  cnt += N * (N - i);
	  sum += (N - i) * s[N];
	  sum += N * (s[N] - s[i]); 
	  end = true;
	  break;
	}
	l--;
      } else {
	cnt += N - l - 1;
	sum += s[N] - s[l+1];
	sum += a[i] * (N - l - 1);
	break;
      }
    }
    if(end) break;
  }
  return P(cnt,sum);
}

int main() {
  cin>>N>>M;
  vector<ll> a(N);
  rep(i,N) cin>>a[i];
  sort(a.begin(),a.end());
  vector<ll> s(N+1,0);
  rep(i,N) s[i+1] = s[i] + a[i];
  ll l = 0, r = 200010, mid;
  while(r-l>1) {
    mid = (l+r)/2;
    if(ok(mid,a,s).first >= M) l = mid;
    else r = mid;
  }
  P pir = ok(r,a,s);
  ll ans = (M - pir.first) * l + pir.second;
  // cout<<pir.first<<" "<<pir.second<<endl;
  cout<<ans<<endl;
}

Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	//stack<int> q,w;
	//freopen("in.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    string s;
    cin>>s;
    ll temp,t,a;
    //a=s.length();
    for(int i=0;i<s.length();i++)
    {
    	if(s[i]=='A')
    	{
    		temp=i+1;
    		break;
    	}
    }
     for(int i=0;i<s.length();i++)
    {
    	if(s[i]=='Z')
    	{
    		a=i+1;
    		
    	}
    }
   
    cout<<a-temp+1<<endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int MOD = 1000000007;

vector<pair<ll,ll>> factorization(ll a){
    vector<pair<ll, ll>> factorize;
    for(int i = 2; i * i <= a; i++){
        if (a % i != 0) continue;
        ll cnt = 0;
        while(a % i == 0){
            a /= i;
            cnt++;
        }
        factorize.push_back({i, cnt});
    }
    if (a != 1) factorize.push_back({a, 1});
    return factorize;
}



int main(void){
    int N; cin >> N;
    map<string, int> mp;
    
    for(int i = 0; i < N; i++){
        string s; cin >> s;
        if (mp[s] == 0) mp[s]++;
    }
    
    int cnt = 0;
    for(auto p: mp){
        cnt += p.second;
    }
    cout << cnt << endl;
}


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

const int INF = 1e9;

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

    vector<vector<int>> list(n);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        list[a].push_back(b);
        list[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        for (int nv : list[v])
        {
            if (dist[nv] != INF)
            {
                continue;
            }
            dist[nv] = dist[v] + 1;
            pre[nv] = v;
            q.push(nv);
        }
    }

    cout << "Yes" << endl;
    for (int i = 1; i < n; i++)
    {
        cout << pre[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10644
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>


#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

const ll INF = 1e10;
int main(){
    int n, m;
    cin >> n;
    VEC(ll, d, n);
    cin >> m;
    VEC(ll, t, m);
    sort(ALL(d));
    sort(ALL(t));



    int now = 0;
    vector<bool> seen(m, false);
    rep(i, m){
        if(t[i] == d[now]){
            now++;
            seen[i] = true;
        }

        else {
            while(now < n){
                now++;
                if(t[i] == d[now]){
                    now++;
                    break;
                }
            }
            if(now >= n)break;
            seen[i] = true;
        }
        if(now >= n)break;
    }
    bool all_seen = true;
    rep(i, m)if(!seen[i])all_seen = false;

    cout << (all_seen ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3456
#include <string>
#include <iostream>
using namespace std;
int n, power[14];
void solve(int x, int v, string S) {
	if (v == n) { printf("%s\n", S.c_str()); return; }
	if (x == 14) return;
	solve(x + 1, v - power[x], '-' + S);
	solve(x + 1, v, '0' + S);
	solve(x + 1, v + power[x], '+' + S);
}
int main() {
	power[0] = 1;
	for (int i = 1; i < 14; i++) power[i] = power[i - 1] * 3;
	scanf("%d", &n); solve(0, 0, "");
	return 0;
}

Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    int cnt = 0;
    for(int i=1; i<n-1; i++){
        if((p[i-1]<p[i] && p[i]<p[i+1])||(p[i-1]>p[i] && p[i]>p[i+1]))
        cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

struct str {
	int x, y, d;
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int h, w, sx, sy, gx, gy;
	cin >> h >> w >> sx >> sy >> gx >> gy;
	sx--; sy--; gx--; gy--;
	vector<vector<char>> a(h, vector<char>(w));
	rep(i, h) rep(j, w) cin >> a[i][j];
	deque<str> que;
	vector<vector<int>> dis(h, vector<int>(w, inf));
	que.push_back({ sx, sy,0 });
	dis[sx][sy] = 0;
	int dx[] = { 1,0,-1,0 };
	int dy[] = { 0,1,0,-1 };
	while (!que.empty()) {
		str p = que.front(); que.pop_front();
		rep(i, 4) {
			int nx = p.x + dx[i];
			int ny = p.y + dy[i];
			if (0 <= nx && nx < h && 0 <= ny && ny < w && a[nx][ny] == '.') {
				if (dis[nx][ny] > p.d) {
					dis[nx][ny] = p.d;
					que.push_front({ nx,ny,p.d });
				}
			}
		}
		for (int i = -2; i <= 2; i++) {
			for (int j = -2; j <= 2; j++) {
				int nx = p.x + i;
				int ny = p.y + j;
				if (0 <= nx && nx < h && 0 <= ny && ny < w && a[nx][ny] == '.') {
					if (dis[nx][ny] == inf) {
						dis[nx][ny] = p.d + 1;
						que.push_back({ nx,ny,p.d + 1 });
					}
				}
			}
		}
	}
	cout << (dis[gx][gy] == inf ? -1 : dis[gx][gy]) << '\n';
}

Measured memory_bytes: 8756
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<int>v;
    for(int i=1;i<n;i++){
        if(a[i]>a[i-1]){
            continue;
        }else{
            v.push_back(i-1);
        }
    }
    if(v.size()==0){
        cout<<"YES";
        return 0;
    }
    if(v.size()==2){
        int x=v[0];
        int y=v[1]+1;
        swap(a[x],a[y]);
        if(is_sorted(a,a+n)){
            cout<<"YES";
        }else{
            cout<<"NO";
        }
    }else{
        cout<<"NO";
    }
    return 0;
    
}



Measured memory_bytes: 256
N = int(input())

total = 0
for i in range(N):
  tmp = i+1
  if tmp%3 == 0 and tmp%5 == 0:
    continue
  elif tmp%3 == 0 and tmp%5 != 0:
    continue
  elif tmp%3 != 0 and tmp%5 == 0:
    continue
  else:
    total += tmp
print(total)
    

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

#define int long long
#define double long double

double EPS = (1e-8);

struct Point {
  double x, y;
};

struct Circle {
  Point p;
  double r;
  int id;
};

bool intersect(Circle a, Circle b) {
  double x1 = a.p.x, y1 = a.p.y;
  double x2 = b.p.x, y2 = b.p.y;  
  double d = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);

  if ( d - (a.r+b.r)*(a.r+b.r) >= -EPS ) return false;  
  else return true;
}

vector<Circle> C[4];
vector<Circle> circles;
int N;
unordered_map<int, int> dp;

int dfs(int bit) {
  //cout << bit << endl;
  if ( bit == (1<<N)-1 ) return 0;
  if ( dp[bit] ) return dp[bit];

  int ret = 0;
  int n;
  for ( int i = 0; i < 4; i++ ) {
    n = C[i].size();
    for ( int a = 0; a < n; a++ ) {
      Circle c1 = C[i][a];
      int i1 = c1.id;
      //if ( bit == 9 && i1 == 1 ) cout << 'a' << endl;
      if ( bit & (1<<i1) ) continue;
      bool flag = true;	
      for ( int j = 0; j < i1; j++ ) {
	if ( !(bit & (1<<j)) && intersect(circles[j], c1) ) {
	  flag = false;
	  break;
	}
      }
      //if ( bit == 9 && i1 == 1 ) cout << 'a' << endl;
      if ( !flag ) continue;
      //if ( bit == 9 && i1 == 1 ) cout << 'a' << endl;
      for ( int b = a+1; b < n; b++ ) {
	Circle c2 = C[i][b];
	int i2 = c2.id;
	//if ( i1 == 1 && i2 == 2 ) cout << 'a' << endl;
	if ( bit & (1<<i2) ) continue;       	
	for ( int j = 0; j < i2; j++ ) {
	  if ( !(bit & (1<<j)) && intersect(circles[j], c2) ) {	    
	    flag = false;
	    break;
	  }
	}
	if ( flag ) {
	  ret = max(ret, dfs(bit|(((1<<i1)+(1<<i2))))+2);	  
	} else {
	  flag = true;
	}
      }
    }
  }
  
  return dp[bit] = ret;  
}

signed main() {
  while ( cin >> N, N ) {
    for ( int i = 0; i < 4; i++ ) C[i].clear();
    circles.clear();
    dp.clear();    
    
    for ( int i = 0; i < N; i++ ) {
      Circle in;
      double x, y, r;
      int c;      
      cin >> x >> y >> r >> c;
      c--;
      in.p = Point{x, y};      
      in.r = r;
      in.id = i;      
      C[c].push_back(in);
      circles.push_back(in);      
    }
    
    cout << dfs(0) << endl;    
  }
  
  return 0;
}



Measured memory_bytes: 43968
#include <bits/stdc++.h>
using namespace std;
constexpr size_t N = 200000;
int main(void){
    long n;
    cin >> n;
    static long v[N];
    for(long i=0; i<n; i++){
        long t;
        cin >> t;
        v[i] = t-(i+1);
    }
    sort(v, v+n);
    long ans = 0;
    for(long i=0; i<n; i++){
        ans += labs(v[i]-v[n/2]);
    }
    cout << ans << endl;
    return 0;
}


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


def main():
    N = int(input())
    P = list(map(int, input().split()))
    print(' '.join(map(str, P)))
    insertionSort(N, P)


def insertionSort(N, P):
    for i in range(1, N):
        v = P[i]
        j = i - 1
        while j >= 0 and P[j] > v:
            P[j + 1] = P[j]
            j -= 1
        P[j + 1] = v

        print(' '.join(map(str, P)))


if __name__ == '__main__':
    main()



Measured memory_bytes: 5608
#include<iostream>
#include<queue>
using namespace std;
int N,M;
int A[1<<17],B[1<<17],C[1<<17],D[1<<17];
main()
{
	cin>>N>>M;
	for(int i=0;i<N;i++)cin>>A[i]>>B[i];
	for(int i=0;i<M;i++)cin>>C[i]>>D[i];
	int L=N-1,R=M-1;
	priority_queue<int>P;
	while(0<=L||0<=R)
	{
		int X=0<=L?A[L]:-1;
		int Y=0<=R?C[R]:-1;
		if(X>=Y)
		{
			P.push(-B[L]);
			L--;
		}
		else
		{
			int d=D[R];
			while(P.size()>=d)P.pop();
			R--;
		}
	}
	long ans=0;
	while(!P.empty())ans-=P.top(),P.pop();
	cout<<ans<<endl;
}



Measured memory_bytes: 4752
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int N, A, B;

int each_sum (int num){
    int sum = 0;
    while (num > 0){
        sum += num % 10;
        num /= 10;
    }
    return sum;
}

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

    int total = 0;
    for (int i = 1; i <= N; i ++){
        int num = each_sum(i);
        if (A <= num && num <= B){
            total += i;
        }
    }
    cout << total << endl;
    return 0;
}

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

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    ll ans = 0;
    if(a >= k){
        ans = k;
    }else{
        ans = a;
        k -= a;
        if(b < k){
            k -= b;
            ans -= k;
        }
    }

    cout << ans << endl;
}

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

int main(void){
    int a[3000], b[3000];
    for(int i = 0; i < 3000; i++){
        cin >> a[i] >> b[i];
        if((a[i] == 0) && (b[i] == 0)) break;
        if(a[i] > b[i]) cout << b[i] << " " << a[i] << endl;
        else cout << a[i] << " " << b[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3012
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] nums=new int[n];
        for(int i=0;i<n;i++){
            nums[i]=sc.nextInt();
        }
        int ans=0;
        int tmp=0;
        for(int i=0;i<n-1;i++){
            if(nums[i]>=nums[i+1]){
                tmp++;
            }else{
                tmp=0;
            }
            ans=Math.max(ans,tmp);
        }
        System.out.println(ans);
        
    }


}


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

using namespace std;

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

  sort(a.begin(), a.end(), greater<int>());

  int alice = 0, bob = 0;
  for (int i = 0; i < N; ++i) {
    if (i % 2 == 0) alice += a[i];
    else bob += a[i];
  }

  cout << alice - bob;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
	static int n;
	static final int INF = 999999999;
	public static void main(String[] args) throws IOException{
		Scanner s = new Scanner(System.in);
		
		while(true){
			n = s.nextInt();
			if(n==0) break;
			
			int field[][] = new int[10][10];
			for(int i = 0; i < 10; i++){
				for(int j = 0; j < 10; j++){
					if(i!=j)
						field[i][j] = INF;
				}
			}
			int maxid = 0;
			for(int i = 0; i < n; i++){
				int x = s.nextInt();
				int y = s.nextInt();
				int c = s.nextInt();
				field[x][y] = field[y][x] = c;
				maxid = Math.max(maxid, Math.max(x, y));
			}
			
			
			for(int i = 0; i <= maxid; i++)
				for(int j = 0; j <= maxid; j++)
					for(int k = 0; k <= maxid; k++)
						field[j][k] = Math.min(field[j][k], field[j][i]+field[i][k]);
			
			int min = INF;
			int minid = 0;
			for(int i = 0; i <= maxid; i++){
				int temp = 0;
				for(int j = 0; j <= maxid; j++){
					temp += field[i][j];
				}
				if(min > temp){
					min = temp;
					minid = i;
				}
			}
			System.out.println(minid+" "+min);
		}
	}
}

Measured memory_bytes: 19704
using System;

namespace A___Shiritori
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = input[0];
            var b = input[1];
            var c = input[2];
            if (a[a.Length - 1] == b[0] && b[b.Length - 1] == c[0])
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define MAXX 100005
 
#define PI   3.14159265358979323846264338327950

#define PB push_back 
#define F first
#define S second
 
#define ll 	 long long int

#define mod  1000000007




int main()
{
	FAST;
	ll a, b;
	cin >> a >> b;
	if(b >= a){
		cout << "unsafe";
		return 0;
	}
	cout << "safe";
	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main()
{
 int s;
 int m;
 int h;
 scanf("%d",&s);
 m=s/60;
 s=s%60;
 h=m/60;
 m=m%60;
 printf("%d:%d:%d\n",h,m,s);
 return 0;
}

  

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

typedef int INT_;

#define int long long

const int MAX = 1e5 + 10;

INT_ main()
{	
	int n; cin>>n;
	string ss; cin>>ss;
	int s=0;
	int t=0;
	for(int i=0;i<n;i++){
		if(ss[i]=='(') t++;
		else{
			if(t>0) t--;
			else s++;
		}
	}

	for(int i=0;i<s;i++) cout<<'(';
	cout<<ss;
	while(t--) cout<<')'; 
}	

Measured memory_bytes: 256
a,b,c,d,e,f = map(int,input().split())

a *= 100
b *= 100
ma = (f+a-1)//a
mb = (f+b-1)//b
mc = (f+c-1)//c
md = (f+d-1)//d
ans1 = ans2 = ans3 = 0
for i in range(ma+1):
    for j in range(mb+1):
        for k in range(mc+1):
            for m in range(md+1):
                s = a*i+b*j+c*k+d*m
                if  s> f:
                    break
                if (a*i+b*j)*e >= 100*(c*k+d*m):
                    if ans3 == 0:
                        ans2 = s
                        ans3 = c*k+d*m
                    else:
                        if  ans3*s < ans2*(c*k+d*m):
                            ans2 = s
                            ans3 = c*k+d*m
print(ans2,ans3)


Measured memory_bytes: 3064