akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

#define log2(x) (31 - __builtin_clz(x))

using namespace std;

int l, n;
vector<struct Info> out;

struct Info
{
    int u, v, w;

    Info() { }

    Info(int _u, int _v, int _w) : u(_u), v(_v), w(_w) { }
};

inline void Add(int u, int v, int w)
{ out.emplace_back(u + 1, v + 1, w); }

void Output()
{
    cout << n << ' ' << out.size() << endl;
    for (auto i : out)
        cout << i.u << ' ' << i.v << ' ' << i.w << endl;
}

int main()
{
    cin >> l;
    n = log2(l) + 1;
    for (int i = 0; i < n - 1; ++i)
        Add(i, i + 1, 0), Add(i, i + 1, 1 << i);
    int t = 1 << log2(l);
    l ^= t;
    while (l)
    {
        int x = log2(l);
        Add(x, n - 1, t);
        t |= 1 << x, l ^= 1 << x;
    }
    Output();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

class Frac{
	public:
		int denom,numer;
};

int main(){

	string str;
	Frac frac[25];

	while(cin>>str){
		if(str[0]=='#')break;

		int cnt=0;
		int pow=1;

		for(int i=0;i<str.size();i++){
			if(str.substr(i,4)=="west"){
				frac[cnt].numer=90;
				i+=3;
			}
			else{
				frac[cnt].numer=-90;
				i+=4;
			}
			cnt++;
			pow*=2;
		//	cout<<frac[cnt-1].numer<<"/"<<frac[cnt-1].denom<<endl;
		}
		pow/=2;
		for(int i=0;i<cnt;i++){
			frac[i].denom=pow;
			pow/=2;
		//	cout<<frac[i].numer<<"/"<<frac[i].denom<<endl;
		}

		Frac a;
		a.denom = frac[cnt-1].denom;
		a.numer = frac[cnt-1].numer;

		if(a.numer<0){
			a.numer=0;
			a.denom=1;
		}
		if(a.numer/a.denom >= 90){
			a.numer=90;
			a.denom=1;
		}

		for(int i=cnt-2;i>=0;i--){
		//	cout<<"i="<<i-1<<" "<<a.numer<<"/"<<a.denom<<endl;
		//	cout<<"frac[i]="<<frac[i].numer<<"/"<<frac[i].denom<<endl;
			if(a.denom != frac[i].denom){
				int tmpNumer = a.denom;
				a.denom *= frac[i].denom/tmpNumer;
				a.numer *= frac[i].denom/tmpNumer;
				
			}

			a.numer += frac[i].numer;

			while(1){
				if(a.denom % 2==0 && a.numer%2==0){
					a.denom /=2;
					a.numer /=2;
				}
				else break;
			}
			if(a.numer<=0){
				a.numer=0;
				a.denom=1;
			}
			if(a.numer/a.denom >= 90){
				a.numer=90;
				a.denom=1;
			}
			
		}

		cout<<a.numer;
		if(a.denom>=2){
			cout<<"/"<<a.denom;
		}
		cout<<endl;
	}

	return 0;
}

			

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    forn(i, 0, n) {
        int j = i;
        while (j < n && (s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T')) {
            j++;
        }
        ans = max(ans, j-i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3660
#include<iostream>
#include<map>

int main(){
std::string S;
std::cin >> S;

std::map<std::string, int> mp;
mp["SUN"]=7;
mp["MON"]=6;
mp["TUE"]=5;
mp["WED"]=4;
mp["THU"]=3;
mp["FRI"]=2;
mp["SAT"]=1;

std::cout<< mp[S]<< "\n";

return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static Exter;
using System.Linq;
#if DEBUG
#else
using console = System.Console;
#endif

public class App
{
    public static void Main(string[] args)
    {
        console.ReadLine();
        cout = readarr.Zip(readarr,(a,b)=>a-b).Where(s=>s>0).Sum();
    }
}
public static class Exter
{
    public static void rep(int loop,Action<int> act)
    {
        for(int i=0;i<loop;i++)
            act(i);
    }
    public static int ToInt(this string v)=>int.Parse(v);
    public static int Max(params int[] p)=>p.Max();
    public static long Max(params long[] p)=>p.Max();
    public static int Min(params int[] p)=>p.Min();
    public static long Min(params long[] p)=>p.Min();
    public static object cout
    {
        set
        {
            console.Write(value.ToString());
            console.WriteLine();
            
        }
    }
    public static int[] readarr
    {
        get 
        {
            preadarr = console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            return preadarr;
        }
    }
    public static int[] preadarr;
}

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

int main(){
    ll n,k,q;
    cin>>n>>k>>q;
    map<ll,ll> game;
    for(ll i=1;i<=q;i++) {
        ll  j;
        cin>>j;
        game[j]++;
    }
    for(ll i=1;i<=n;i++){
        if((q-game[i])<k) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, b, c;
  string s;
  cin >> n;
  vll v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  sort(v.begin(), v.end());
  ll sum = 0;
  for (int i = 0; i < n - 1; i++)
    sum += v[i];
  if (sum > v[n - 1])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import re

n = int(input())
for _ in range(n):
    dataset = input()
    stage = 1
    while (re.match('\[[0-9]+\]', dataset) is None):
        iterator = re.finditer('\[([0-9]+\]\[)+[0-9]+\]', dataset)
        for match in iterator:
            areas = list(map(int, match.group()[1:-1].split('][')))
            minimum_areas = sorted(areas)[:len(areas)//2 + 1]
            if stage == 1:
                minimum_voters = [m // 2 + 1 for m in minimum_areas]
                minimum_vote = sum(minimum_voters)
            else:
                minimum_vote = sum(minimum_areas)
            dataset = dataset.replace(match.group(), '*' + str(minimum_vote) + '*', 1)
        dataset = dataset.replace('*', '')
        # print(dataset)

        stage += 1
    print(dataset[1:-1])


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

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

  int n = floor(sqrt(N));
  long long W;
  for (int i = n; i >= 1; i--)
  {
    if (N % i == 0)
    {
      W = i;
      break;
    }
  }

  long long H = N / W;
  cout << W + H - 2 << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int N, C; cin >> N >> C;
    vector<vector<int>> d(C, vector<int>(C)), c(N, vector<int>(N));
    rep(i,C) rep(j,C) cin >> d[i][j];
    rep(i,N) rep(j,N) cin >> c[i][j], c[i][j]--;
    
    // s[i][j] : iグループを色jにするときの違和感
    vector<vector<int>> s(3, vector<int>(C));
    rep(i,N) rep(j,N) {
        int w = (i+j)%3;
        rep(k,C) {
            s[w][k] += d[c[i][j]][k];
        }
    }

    int ans = 250000010;
    rep(i,C) rep(j,C) rep(k,C) {
        if (i == j || j == k || k == i) continue;
        chmin(ans, s[0][i]+s[1][j]+s[2][k]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 99940000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll power(ll x,ll y){
    ll ret=1;
    while(y>0){
        if(y&1)
            ret=(ret*x);
        y/=2;
        x=(x*x);
    }
    return ret;
}
string rot(string s){
	string ret="";
	ll i;
	for(i=1;s[i];i++){
		ret+=s[i];
	}
	ret+=s[0];
	return ret;
}
void solve(){
	ll n,i,ans=0;
	cin>>n;
	vll vec(n);
	nfl(i,n){
		cin>>vec[i];
		ans+=vec[i]-1;
	}
	cout<<ans<<endl;
}	
int main(){
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	long double x[52];
	long double y[52];
	for(ll i=0;i<n;i++){
		cin>>x[i]>>y[i];
	}
	ll cnt=0;
	long double lx=0;
	long double rx=1002.0;
	while(cnt<=99){
		cnt++;
		long double x1=(lx*2+rx)/3;
		ll cnt2=0;
		long double ly=0;
		long double ry=1002.0;
		long double Ans1=0;
		while(cnt2<=99){
			cnt2++;
			long double y1=(ly*2+ry)/3;
			long double ans1=0;
			for(ll i=0;i<n;i++){
				long double now=(x1-x[i])*(x1-x[i])+(y1-y[i])*(y1-y[i]);
				now=sqrt(now);
				ans1=max(now,ans1);
			}
			long double y2=(ly+ry*2)/3;
			long double ans2=0;
			for(ll i=0;i<n;i++){
				long double now=(x1-x[i])*(x1-x[i])+(y2-y[i])*(y2-y[i]);
				now=sqrt(now);
				ans2=max(now,ans2);
			}
			if(ans1<ans2){
				ry=y2;
			}
			else{
				ly=y1;
			}
			if(cnt2==100){
				Ans1=min(ans1,ans2);
			}
		}
		
		long double x2=(lx+rx*2)/3;
		cnt2=0;
		ly=0;
		ry=1002;
		long double Ans2=0;
		while(cnt2<=99){
			cnt2++;
			long double y1=(ly*2+ry)/3;
			long double ans1=0;
			for(ll i=0;i<n;i++){
				long double now=(x2-x[i])*(x2-x[i])+(y1-y[i])*(y1-y[i]);
				now=sqrt(now);
				ans1=max(now,ans1);
			}
			long double y2=(ly+ry*2)/3;
			long double ans2=0;
			for(ll i=0;i<n;i++){
				long double now=(x2-x[i])*(x2-x[i])+(y2-y[i])*(y2-y[i]);
				now=sqrt(now);
				ans2=max(now,ans2);
			}
			if(ans1<ans2){
				ry=y2;
			}
			else{
				ly=y1;
			}
			if(cnt2==100){
				Ans2=min(ans1,ans2);
			}
		}
		if(Ans1<Ans2){
			rx=x2;
		}
		else{
			lx=x1;
		}
		if(cnt==100){
			long double fa=min(Ans1,Ans2);
			printf("%.10Lf",fa);
		}
	//	printf("%.10Lf\n",Ans1);
	//	printf("%.10Lf\n\n",Ans2);
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3852
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;

void print(int x, int y, int *z) {
  cout << x << " " << y << endl;
  *z = x - y;
}

int main() {
  int N;
  cin >> N;
  vector<int> ps;
  vector<int> ns;
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    if (A > 0) ps.push_back(A);
    else ns.push_back(A);
  }
  
  if ((int)ns.size() == N) {  // all negative
    sort(ns.begin(), ns.end());
    int ans = ns[N - 1];
    for (int i = 0; i < N - 1; ++i) {
      ans -= ns[i];
    }
    cout << ans << endl;
    int tmp;
    print(ns[N - 1], ns[0], &tmp);
    for (int i = 1; i < N - 1; ++i) {
      print(tmp, ns[i], &tmp);
    }
  } else if ((int)ps.size() == N) {  // all positive
    sort(ps.begin(), ps.end());
    int ans = -ps[0];
    for (int i = 1; i < N; ++i) {
      ans += ps[i];
    }
    cout << ans << endl;
    int tmp;
    print(ps[0], ps[1], &tmp);
    for (int i = 2; i < N - 1; ++i) {
      print(tmp, ps[i], &tmp);
    }
    print(ps[N - 1], tmp, &tmp);
  } else {
    int ans = 0;
    for (auto p : ps) {
      ans += p;
    }
    for (auto n : ns) {
      ans -= n;
    }
    cout << ans << endl;

    if (ps.size() == 1) {
      int tmp;
      print(ps[0], ns[0], &tmp);
      for (int i = 1; i < ns.size(); ++i) {
	print(tmp, ns[i], &tmp);
      }
    } else {
      int tmp;
      print(ns[0], ps[0], &tmp);
      for (int i = 1; i < ps.size() - 1; ++i) {
	print(tmp, ps[i], &tmp);
      }
      print(ps[ps.size() - 1], tmp, &tmp);
      for (int i = 1; i < ns.size(); ++i) {
	print(tmp, ns[i], &tmp);
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 2424
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextLineInt() []int {
	lineString := strings.Split(nextLine(), " ")
	var lineInt = make([]int, len(lineString))
	for i := range lineString {
		lineInt[i], _ = strconv.Atoi(lineString[i])
	}
	return lineInt
}

func bool2int(b bool) int {
	if b {
		return 1
	} else {
		return 0
	}
}

func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func d(a, b int) int {
	return abs(a - b)
}

func main() {
	var n int

	fmt.Scanf("%d", &n)

	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &h[i])
	}

	cost := make([]int, n)

	cost[0] = 0
	cost[1] = abs(h[1] - h[0])

	for i := 1; i < n-1; i++ {
		cost[i+1] = min(cost[i-1]+d(h[i-1], h[i+1]), cost[i]+d(h[i], h[i+1]))
	}
	fmt.Println(cost[n-1])
}


Measured memory_bytes: 5504
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll n,d;
  cin >> n >> d;
  d*=d;
  int ans = 0;
  rep(i,n){
    ll x,y;
    cin >> x >> y;
    if(x*x+y*y<=d) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define pii pair<int, int>
#define ss second
#define ff first
#define all(x) ((x).begin(), (x).end())

using namespace std;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int maxn = 3*(1e3) + 100;
const ll oo = 1e9 + 100;

int memo[3100][3100];
pii a[3100];

int knap(int v, int bag){
    if (v < 0 || bag <= 0) return 0;
    if (memo[v][bag] != -1) return memo[v][bag];
    return memo[v][bag] = max(knap(v-1, bag), knap(v-1, bag-a[v].ff) + a[v].ss);
}


int main(void){
    int n, t;
    cin >> n >> t;
    memset(memo, -1, sizeof memo);

    for (int i=0; i<n; i++){
        cin >> a[i].ff >> a[i].ss;
    }
    sort(a, a+n);
    reverse(a, a+n);
    

    cout << knap(n-1, t) << endl;
return 0;
}

Measured memory_bytes: 37888
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

const inf = 1001001001

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N, K := getInt(), getInt()
	a := make([]int, N+1)
	m := inf
	for i := 0; i < N; i++ {
		a[i] = getInt()
		m = min(m, a[i])
	}

	ans := 0
	flg := false
	for i := 0; i < N-1; {
		if i+1 < N && flg == true && a[i+1] == m {
			i++
		}
		ans++
		for k := 0; k < K; k++ {
			if i+k > N {
				break
			}
			if a[i+k] == m {
				flg = true
			}
		}
		i += (K - 1)
		// out(i)
	}
	out(ans)

}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, W;
  cin >> N >> W;
  vector<vector<ll>> item(N, vector<ll>(2));
  for (ll i = 0; i < N; ++i) {
    cin >> item.at(i).at(0) >> item.at(i).at(1);
  }
  vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
  dp.at(0).at(0) = 0;
  for (ll i = 0; i < N; ++i) {
    ll w = item.at(i).at(0), v = item.at(i).at(1);
    for (ll j = 0; j < W; ++j) {
      dp.at(i + 1).at(j) = max(dp.at(i + 1).at(j), dp.at(i).at(j));
      if (j + w <= W) {
        dp.at(i + 1).at(j + w) = max(dp.at(i + 1).at(j + w), dp.at(i).at(j) + v);
      }
    }
  }
  ll ans = 0;
  for (ll i = 0; i <= W; ++i) {
    ans = max(ans, dp.at(N).at(i));
  }
  cout << ans << "\n";
}


Measured memory_bytes: 83156
program base_2Number
    implicit none
    integer(8):: n, ia, i, sgn=1
    character(1), allocatable:: ans(:)
 
    read*, n
    if (n==0) then
        print*, 0
    end if
    allocate(ans(1))
    ia=0
    do while(abs(n) >= 1)
        ia=ia+1
        call append(ia,mod(n,2))
        n = (n-abs(mod(n,2))*sgn) / 2
        sgn=-1*sgn
    end do
 
    print*, ans(ia:1:-1)
 
    contains
    subroutine append(i, num)
        integer(8):: i, num
        character(1), allocatable:: tmp(:)
 
        if (i > size(ans)) then
            allocate(tmp(size(ans)))
            tmp(:) = ans(:)
            deallocate(ans)
            allocate(ans(size(tmp)*2))
            ans(1:size(tmp)) = tmp(:)
        end if
        ans(i) = char(abs(num)+ichar('1')-1)
    end subroutine
end program base_2Number

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}
int p[100010];int q[100010];int r[100010];
inline bool cmp(int a,int b){
	return a>b;
}

int main(){
	int x,y,a,b,c;read(x);read(y);read(a);read(b);read(c);
	rep(i,1,a)read(p[i]);
	rep(i,1,b)read(q[i]);
	rep(i,1,c)read(r[i]);
	sort(p+1,p+a+1,cmp);sort(q+1,q+b+1,cmp);sort(r+1,r+c+1,cmp);
	
	long long ans=0;
	rep(i,1,x)ans+=p[i];
	rep(i,1,y)ans+=q[i];
	rep(i,1,c){
		if(!x&&!y)break;
		if(!x){
			if(r[i]>q[y]){ans+=r[i]-q[y];y--;}
			else{break;}
			continue;
		}
		if(!y){
			if(r[i]>p[x]){ans+=r[i]-p[x];x--;}
			else{break;}
			continue;
		}
		int mi=min(p[x],q[y]);
		if(r[i]>mi){
			if(p[x]<q[y]){ans+=r[i]-p[x];x--;}
			else{ans+=r[i]-q[y];y--;}
		}else{break;}
	}
	write(ans);
	return 0;
}

Measured memory_bytes: 1408
import math
n = int(input())
a = list(map(int, input().split()))
lcm = a[0]
for i in range(1, n):
    lcm = lcm * a[i] // math.gcd(lcm, a[i])

res = 0
for i in range(n):
    res += (lcm - 1) % a[i]
print(res)

Measured memory_bytes: 9400
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
const int MOD=1e9+7;


int main(){
  ll n,c,k,ans=1;cin>>n>>c>>k;
  vll t(n);
  rep(i,0,n){
    cin>>t[i];
  }
  sort(t.begin(),t.end());
  int j=0,tmp=t[j]+k,p=0;
  rep(i,0,n){
    if(p<c&&tmp>=t[i]){
      p++;
    }
    else{
      ans++;j=i;p=1;
      tmp=t[j]+k;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()

int main()
{
  int N, Q;
  string S;
  cin >> N >> S >> Q;
  int K[Q];
  for (int i = 0; i < Q; ++i) {
    cin >> K[i];
  }
  for (int i = 0; i < Q; ++i) {
    long long k = K[i], D=0, M=0, DM=0, ans=0;
    for (int j = 0; j < k; ++j) {
      if (S[j] == 'D') {
        D++;
      }else if (S[j] == 'M') {
        M++;
        DM += D;
      }else if (S[j] == 'C') {
        ans += DM;
      }
    }
    for (int j = k; j < N; ++j) {
      //まずは取り除くことから
      if (S[j-k] == 'D') {
        D--;
        DM -= M;
      }else if (S[j-k] == 'M') {
        M--;
      }
      if (S[j] == 'D') {
        D++;
      }else if (S[j] == 'M') {
        M++;
        DM += D;
      }else if (S[j] == 'C') {
        ans += DM;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 1412
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
    long long n, p;
    cin >> n >> p;
    map<long long, int> mp;
    for (long long i = 2; i * i <= p; i++) {
        while (p % i == 0) {
            mp[i]++;
            p /= i;
        }
    }
    if (p != 1) mp[p]++;
    long long ans = 1;
    for (auto e : mp) {
        int k = e.second / n;
        for (int i = 0; i < k; i++) {
            ans *= e.first;
        }
    }
    cout << ans << endl;
}



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

int main()
{
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] != t[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll N;
    cin >> N;
    vec A(N);
    Rep (i, N) {
        cin >> A[i];
    }

    ll X = 0;
    for (ll i = 2; i < N; i++) X = (X ^ A[i]);

    ll S = A[0] + A[1];

    ll Y = (S-X) / 2;

    if (Y < 0 or S-X != 2*Y) {
        cout << -1 << "\n";
        return 0;
    }

    ll tmp = 0;

    for (ll b = 60; b >= 0; b--) {
        if (((X >> b) & 1) == 0 and ((Y >> b) & 1)) {
            tmp = tmp | (1LL<<b);
            if (tmp > A[0]) {
                cout << -1 << "\n";
                return 0;
            }
        }
    }

    for (ll b = 60; b >= 0; b--) {
        if (((X >> b) & 1) and ((Y >> b) & 1)) {
            cout << -1 << "\n";
            return 0;
        } else if (((X >> b) & 1) and ((Y >> b) & 1) == 0) {
            if ((tmp | (1LL<<b)) <= A[0]) {
                tmp = tmp | (1LL<<b);
            }
        }
    }

    if (tmp == 0) {
        cout << -1 << "\n";
    } else {
        cout << A[0] - tmp << "\n";
    }

}

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

int main(){
  int n,a;
  float hoge=0;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    hoge+=(1/(float)a);
  }
  cout << 1/hoge << '\n';
  return 0;
}


Measured memory_bytes: 256
//package pack4;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{
			String[] strA = insBR.readLine().split(" ");
			int[] intA = new int[strA.length];
			double[] dbA = new double[strA.length];
			for(int i = 0;i < strA.length ;i++){
				intA[i] = Integer.parseInt(strA[i]);
				dbA[i] = Integer.parseInt(strA[i]);
			}
			int d = intA[0] / intA[1];
			int r = intA[0] % intA[1];
			double f = dbA[0] / dbA[1];
			String strF = String.format("%1$.5f", f);
			System.out.println(d + " " + r + " " + strF);
		}catch(IOException e){
			e.printStackTrace();
		}catch(NumberFormatException e){
			e.printStackTrace();
		}
	}
}



Measured memory_bytes: 24828
<?php
$n = (int)trim(fgets(STDIN));

$base = 0;
$last_a = 0;
$first_b = 0;
$ba = 0;
for ($i=0; $i < $n; $i++) { 
	$s = trim(fgets(STDIN));
	$base += substr_count($s, 'AB');
	$b_flg = $a_flg = false;
	if ($s[0] === 'B') {
		$first_b += 1;
		$b_flg = true;
	}
	if ($s[strlen($s)-1] === 'A') {
		$last_a += 1;
		$a_flg = true;
	}
	if ($a_flg && $b_flg) {
		$ba += 1;
	}
}
if ($last_a === $first_b && $last_a === $ba) {
	$comb_cnt = max(0, $last_a - 1);
}else{
	$comb_cnt = min($last_a, $first_b);
}

echo $base + $comb_cnt;


Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> a(H,vector<char>(W));
  
  vector<bool> authRow(H,false);
  vector<bool> authCol(W,false);
  for(int CH=0; CH<H; CH++){
    for(int CW=0; CW<W; CW++){
      cin >> a.at(CH).at(CW);
      if(a.at(CH).at(CW)=='#'){
        authRow.at(CH)=true;
        authCol.at(CW)=true;
      }
    }
  }
  
  for(int CH=0; CH<H; CH++){
    if(authRow.at(CH)){
      for(int CW=0; CW<W; CW++){
        if(authCol.at(CW)) cout << a.at(CH).at(CW);
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    string s;
    cin >> s;
    if(s == "ABC"){
        cout << "ARC" << endl;
        return 0;
    }
    if(s == "ARC"){
        cout << "ABC" << endl;
        return 0;
    }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
inline int parent(int i) { return i / 2; }
inline int left(int i) { return i * 2; }
inline int right(int i) { return i * 2 + 1; }
int main() {
	int H; cin >> H;
	vi A(H + 1); rep(i, 1, H + 1) cin >> A[i];
	rep(i, 1, H + 1) {
		cout << "node " << i << ": key = " << A[i] << ", ";
		if(parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
		if(left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
		if(right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;

int D, G;
vector<int> P;
vector<int> C;



int solve(){
    int ans = 1<<30;
    for(int i=0; i<(1<<D); i++){
        
        int score = 0;
        int step = 0;
        int mx_not_1 = 0;
        for(int j=0; j<D; j++){
            
            if(i & (1<<j)){
                score += (j+1) * 100 * P[j];
                score += C[j];
                step += P[j];
            } else {
                mx_not_1 = max(mx_not_1, j);
            }
        }
        if(score >= G) ans = min(ans, step);
        for(int j=0; j<P[mx_not_1]-1; j++){
            score += (mx_not_1 + 1) * 100;
            step++;
            if(score >= G) ans = min(ans, step);
        }
    }
    return ans;
}




int main() {
    cin >> D >> G;
    P.resize(D);
    C.resize(D);
    for(int i=0; i<D; i++)
        cin >> P[i] >> C[i];
    
    cout << solve() << endl;
    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	ll k;
	cin>>s>>k;
	string ss=s+s;
	ll one=0,two=0;
	range(i,1,s.size()){
		if(s[i]==s[i-1]){
			one++;
			s[i]='A';
		}
	}
	range(i,1,ss.size()){
		if(ss[i]==ss[i-1]){
			two++;
			ss[i]='A';
		}
	}
	ll cnt=0;
	rep(i,s.size()){
		if(s[i]!=s[0])break;
		cnt++;
	}
	rep(i,s.size()){
		if(s[i]!=s[0])break;
		cnt++;
	}
	if(cnt=ss.size())cnt=s.size();
	puta(cnt%2==1?(k+1)/2*one+(k/2)*(two-one):one+(k-1)*(two-one));
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
int w,h,s,sum;
P pmax(P a,P b){
	if(a>b)return a;
	return b;
}
int u[33][33];
P dp[33][33][33][33];
P ret(P a,P b,int cnt){
	if(dp[a.first][a.second][b.first][b.second].first!=-1)
		return dp[a.first][a.second][b.first][b.second];
	P ans(1,cnt);
	int s1=0,s2=0;
	for(int i=a.first;i<b.first;i++){
		
		for(int j=a.second;j<=b.second;j++){
			s1+=u[i][j];
		}
		if(sum-s1>s||sum-(cnt-s1)>s)
			continue;
		P x=ret(a,P(i,b.second),s1),y=ret(P(i+1,a.second),b,cnt-s1);
		ans=pmax(ans,P(x.first+y.first,min(x.second,y.second)));
	}
	for(int i=a.second;i<b.second;i++){
		for(int j=a.first;j<=b.first;j++){
			s2+=u[j][i];
		}
		if(sum-s2>s||sum-(cnt-s2)>s)
			continue;
		P x=ret(a,P(b.first,i),s2),y=ret(P(a.first,i+1),b,cnt-s2);
		ans=pmax(ans,P(x.first+y.first,min(x.second,y.second)));
	}
	return dp[a.first][a.second][b.first][b.second]=ans;
}
int main(){
	while(cin>>h>>w>>s,h||w||s){
		sum=0;
		rep(i,h)rep(j,w)rep(k,h)rep(l,w)
		dp[i][j][k][l]=P(-1,0);
		rep(i,h)rep(j,w){
			cin>>u[i][j];
			sum+=u[i][j];
		}
		P ans=ret(P(0,0),P(h-1,w-1),sum);
		cout<<ans.first<<" "<<s-(sum-ans.second)<<endl;
	}
	return 0;
}

Measured memory_bytes: 9000
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int K;
    string S;
    cin >> K >> S;
    if (S.size() <= K) cout << S << '\n';
    else cout << S.substr(0, K) << "..." << '\n';
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

void solve(){

    lli ans = 0;
    priority_queue<pair<lli,lli>> q;
    priority_queue<pair<lli,lli>,vector<pair<lli,lli>>,greater<pair<lli,lli>>> qq;

    lli n;
    cin>>n;
    REP(i,0,n){
        lli k,l,r;
        cin>>k>>l>>r;
        if(l-r>0){
            q.push({k,l-r});
            ans += r;
        }
        else{
            qq.push({k,r-l});
            ans += l;
        }
    }

    lli now = 0;

    multiset<lli> s;
    lli cnt = 0;
    for(lli i=n;i>=1;i--){
        while(q.size() && q.top().first >= i){
            s.insert(q.top().second);
            q.pop();
        }
        if(s.size()==0)continue;
        ans += (*s.rbegin());
        s.erase(prev(s.end()));
    }

    s.clear();
    for(lli i=cnt+1;i<=n;i++){
        while(qq.size() && qq.top().first < i){
            s.insert(qq.top().second);
            qq.pop();
        }
        if(s.size()==0)continue;
        ans += (*s.rbegin());
        s.erase(prev(s.end()));
    }
    cout<<ans<<endl;

}


int main(){

    lli t;
    cin>>t;
    while(t--)solve();

    return 0;
}


Measured memory_bytes: 7164
# -*- coding: utf-8 -*-
N = int(input())

ans = 'No'
for n in range(10):
    if n == 0:
        continue
    if N / n < 10 and N % n == 0:
        #print('N, nxm: ', N, n, N/n)
        ans = 'Yes'
        break

print(ans)


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

int dp[45];
void solve(){
    int n;
    dp[0]=1;
    dp[1]=1;
    cin>>n;
    for(int i=2;i<=n;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    cout<<dp[n]<<endl;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#include <stdio.h>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;

//A問題

// int main(){
//   int n, x, t;
//   cin >> n >> x >> t;
//   if(n % x == 0){
//     cout << n/x*t << endl;
//   }else{
//     cout << (n/x + 1)*t << endl;
//   }
// }

//B問題

int main(){
    char a[200010];
    cin >> a;
    int len = strlen(a);
    int sum = 0;
    for(int i = 0; i < len; i++){
        sum += a[i]-'0';
    }
    if(sum % 9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3836
// AOJ 2299:   Tiles are Colorful
// 2017.12.10

#include <stdio.h>
#include <string.h>

int m, n, k;
char map[501][503];
int mv[4][2] = {{-1,0},{1,0},{0,1},{0,-1}};
int rpos[26], cpos[26];
int sr[501], sc[501];

int calc()
{
	int r, c, i, r2, c2, a, ans = 0;
	for (r = 0; r < m; r++) for (c = 0; c < n; c++) 
		if ((sr[c] + sc[r]) && map[r][c] == '.' ) {
			memset(rpos, -1, sizeof(rpos));

		    for (i = 0; i < 4; i++) {
				if (!sr[c]) { if (i < 2) continue; }
				if (!sc[r]) { if (i > 2) continue; }

				r2 = r, c2 = c;
				while (1) {
					r2 += mv[i][0], c2 += mv[i][1];
					if (r2 < 0 || r2 >= m || c2 < 0 || c2 >= n) break;
					if (map[r2][c2] == '.') continue;

	                a = map[r2][c2]-'A';
					if (rpos[a] >= 0) {
	                    map[r2][c2] = '.', sr[c2]--, sc[r2]--;
						r2 = rpos[a], c2 = cpos[a];
	                    map[r2][c2] = '.', sr[c2]--, sc[r2]--;
	                    ans += 2, k -= 2;
						if (!k) return ans;
					} else rpos[a] = r2, cpos[a] = c2;
					break;
				}
            }
        }

	return ans;
}

int main()
{
	int r, c, t, k, ans;
	char buf[10];

    fgets(buf, 10, stdin);
	sscanf(buf, "%d%d", &m, &n);
	for (k = 0, r = 0; r < m; r++) {
		fgets(map[r], 503, stdin);
		for (c = 0; c < n; c++) {
			if (map[r][c] != '.') k++, sr[c]++, sc[r]++;
		}
	}
	ans = 0;
	do t = calc(), ans += t;
	while (t && k);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2108
#include <iostream>

using namespace std;

int main()
{
    int n,tmp,ans[3];
    cin >> n;
    for(int i = 0;i<3;i++)
    {

        //cout <<"\n" <<  tmp <<"\n";
        tmp = n%10;
        if(tmp == 1)
        {
            ans[i] = 9;
        }else{
            ans[i] = 1;
        }


        n /= 10;
    }
    for(int i = 2;i>=0;i--)
    cout << ans[i];

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

ll modComb(ll n, ll k) {
    ll tmp = 1;
    for (int i = 0; i < k; i++) {
        tmp *= n - i;
        tmp %= MOD;
    }
    for (int i = 1; i <= k; i++) {
        tmp *= modInv(i);
        tmp %= MOD;
    }
    return tmp;
}

ll N, M;
vector<ll> graph[200010];
vector<bool> checked(200010, false);
ll ans;

ll bfs(ll);

int main() {
    cin >> N >> M;
    rep(i, M) {
        ll A, B;
        cin >> A >> B;
        graph[A].push_back(B);
        graph[B].push_back(A);
    }

    for (ll i = 1; i <= N; i++) {
        if (!checked[i]) {
            ans = max(ans, bfs(i));
        }
    }

    cout << ans << endl;
}

//nは最初の人間の番号
ll bfs(ll start_num) {
    ll graph_sum = 1;
    queue<ll> next_num;
    next_num.push(start_num);
    checked[start_num] = true;
    while (!next_num.empty()) {
        for (ll i = 0; i < (ll)graph[next_num.front()].size(); i++) {
            ll tmp_next_num = graph[next_num.front()][i];
            if (!checked[tmp_next_num]) {
                checked[tmp_next_num] = true;
                next_num.push(tmp_next_num);
                graph_sum++;
            }
        }
        next_num.pop();
    }
    return graph_sum;
}

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


int main(){
    int64_t A,B,M;
    cin >> A >> B >> M; //Aは冷蔵庫の数、Bは電子レンズの数、Mは割引券の数
    vector<int64_t> a(A); //Aの値段配列
    vector<int64_t> b(B); //Bの値段配列
    for(int i=0;i<A;i++){
        cin >> a.at(i);
    }
    for(int i=0;i<B;i++){
        cin >> b.at(i);
    }//入力を終了

    int64_t minprise=200000000000;

    //割引券を使った場合を全探索
    for(int i=0;i<M;i++){
        int x,y; //割引券の商品の場所　+1されてます
        int64_t c; //割引する価格
        cin >> x >> y >> c;
        int64_t prise;
        prise = a.at(x-1)+b.at(y-1)-c;
        if(prise < minprise){
            minprise = prise;
        }
    }
    int64_t simpleprise;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    simpleprise = a.at(0)+b.at(0);
    if(simpleprise < minprise){
        minprise = simpleprise;
    }
    cout << minprise;
    }
    

Measured memory_bytes: 1792
#include <iostream>
#include <string>

using namespace std;


int main()
{
	int n;
	double ans=0;
	double x;
	string u;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x >> u;
		if (u == "BTC") {
			ans += 380000 * x;
		}
		else {
			ans += x;
		}
	}
	printf("%f\n", ans);

	return 0;
}

Measured memory_bytes: 256
//XOR Circle

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    map<int,int>m{};
    int n;cin>>n;
    rep(i,0,n){int t;cin>>t;m[t]++;}
    int s = m.size();
    vector<p>a;
    for(auto i:m)a.pb(mp(i.first,i.second));
    if(s>3){cout<<"No"<<nnn;return 0;}
    if(s==3&&n%3==0){
        int t=n/3;int x=0;
        for(auto i:m){
            if(i.second!=t){cout<<"No"<<nnn;return 0;}
            x=x xor i.first;
        }
        if(x!=0)cout<<"No"<<nnn;
        else cout<<"Yes"<<nnn;
        return 0;
    }
    if(m[0]==n&&s==1){cout<<"Yes"<<nnn;return 0;}
    if(s==2&&n%3==0&&m[0]==n/3){cout<<"Yes"<<nnn;return 0;}
    cout<<"No"<<nnn;
    return 0;
}

Measured memory_bytes: 9920
#include <bits/stdc++.h>
#include <iomanip>
#define M 100000
#define MAX 1000000001
#define MIN -100000000
#define mod 998244353 
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

int main(){
	int a[5];
	for(int i=0;i<5;i++)
		cin>>a[i];
	for(int i=0;i<5;i++){
		if(a[i] == 0){
			cout<<(i+1)<<"\n";
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

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

#define MAX_N 1000
#define MAX_M 100

const long long INF = 1LL << 60;

//境界値に注意！！！

// DP テーブル
ll dp[100010];

int main (){
    ll N;
    cin >> N;
    ll res=N;
    for(ll i=0;i<=N;i++) {
        ll cc =0;
        ll t=i;
        while(t>0){
            cc+=t%6;
            t/=6;
        }
        t=N-i;
        while(t>0){
            cc+=t%9;
            t/=9;
        }
        if(res>cc)res=cc;
    }
    cout << res<< endl;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
a = [0]*N
b = [0]*N
c = [0]*M
d = [0]*M
for i in range(N):
    a[i],b[i] = map(int,input().split())
for i in range(M):
    c[i],d[i] = map(int,input().split())

for i in range(N):
    mindif = 10**9
    ans = -1
    for j in range(M):
        dif = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if (mindif > dif):
            mindif = dif
            ans = j
    print(ans+1)        




Measured memory_bytes: 3064
import sys 
sys.setrecursionlimit(100000000)
n = int(input())
graph = [[] for _ in range(n)]
color = [-1]*n
visited = [0]*n
for _ in range(n-1):
  u, v, w = map(int, input().split())
  u -= 1
  v -= 1 
  graph[u] += [[v, w]]
  graph[v] += [[u, w]]
def dfs(u, c):
  color[u] = c 
  for v, w in graph[u]:
    if color[v] != -1:
      continue
    if color[v] == -1 and w % 2 == 0:
      dfs(v, c)
    if color[v] == -1 and w % 2 != 0:
      dfs(v, abs(1-c))
  return 

dfs(0, 1)
for i in range(n):
  if color[i] == 1:
    print(1)
  else:
    print(0)




Measured memory_bytes: 85852
#include <stdio.h>

int main(void) {
	int antennas[5];
	int k;
	int i, j;
	int sadflag = 0;

	for(i = 0;i < 5;i++) {
		scanf("%d", &antennas[i]);
	}
	scanf("%d", &k);

	for(i = 0;i < 5;i++) {
		for(j = i + 1; j < 5; j++) {
			if((antennas[j] - antennas[i]) > k) {
				sadflag = 1;
				break;
			}
		}
		if(sadflag) {
			break;
		}
	}

	if(sadflag) {
		printf(":(\n");
	} else {
		printf("Yay!\n");
	}
	return 0;
}


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

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

    string month;

    month = S.substr(5, 2);

    if (month == "01" || month == "02" || month == "03" || month == "04"){
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int ans = scanner.nextInt();
		while (true) {
			char c = scanner.next().charAt(0);
			if (c == '+')
				ans += scanner.nextInt();
			else if (c == '-')
				ans -= scanner.nextInt();
			else if (c == '*')
				ans *= scanner.nextInt();
			else if (c == '/')
				ans /= scanner.nextInt();
			else {
				System.out.println(ans);
				return;
			}
		}
	}
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int64_t kaijo(int64_t n){
    if(n==1) return n;
    return (kaijo(n-1))%INF * n;
}

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,m;
    cin >> n >> m;
    int64_t res = 0;
    if(n==m){
        res = 2 * ((kaijo(n)%INF) * (kaijo(m)%INF))%INF;
    }
    if(abs(n-m)==1){
        res = ((kaijo(n)%INF) * (kaijo(m)%INF))%INF;
    }
    cout << res << endl;
}

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

using namespace std;

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

  int c = 0;
  vector<int> p(n);
  for(int i = 0; i < n; ++i) {
    cin >> p[i];
    if(p[i] != i + 1) {
      c++;
    }
  }
  if(c == 2 || c == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256