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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

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

	int N; cin >> N;

	vector<pii> rpoints (N);
	F0R(i, N) {
		int a, b; cin >> a >> b;
		rpoints[i] = {a, b};
	}

	vector<pii> bpoints (N);
	F0R(i, N) {
		int a, b; cin >> a >> b;
		bpoints[i] = {a, b};
	}

	sort(rpoints.begin(), rpoints.end());
	sort(bpoints.begin(), bpoints.end());

	set<int> ycoords; 

	int total = 0;

	int cur = 0;
	for (pii point : bpoints) {
		while (cur < N && rpoints[cur].first < point.first) ycoords.insert(rpoints[cur++].second);

		auto it = lower_bound(ycoords.begin(), ycoords.end(), point.second);
		if (it != ycoords.begin()) {
			it--; ++total;
			ycoords.erase(it);
		}
	}
	print(total);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<iostream>
#include<algorithm>
#define m(a,b) memset(a,b,sizeof(a));
using namespace std;
typedef long long LL;
typedef pair<int,int>PII;
const LL inf = 1 << 30;
map<int,int>mp;
const int maxn = 1e4;
int n,k = 0;
int num[maxn+5];
bool sushu(int x){
	for(int i = 2;i*i<=x;i++)
		if(x%i == 0) return false;
	return true;
}
int main(){
	for(int i = 2;i<=55556;i++){
		if(sushu(i)){
			num[++k] = i;
			mp[i] = 1;
		}
	}
	cin >> n;
	for(int i = 2;;i++){
		if(num[i]%10 == 3){
			if(n==1){
				cout << num[i] << endl;
				break;
			}
			else{
				cout << num[i] << " ";
			}
			n--;
		}
	}
	return 0;
}

Measured memory_bytes: 512
#pragma once
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int N,M;
  int L,R;
  int ans=0;
  cin >> N>>M;
  vector<int> list(N);
  rep(i, M) {
    cin >> L >>R;
    if (list[L - 2] == 0) {
      rep(i, L-1) {
        list[i]=1;
      }
    }
    if (list[R] == 0) {
      for (int i = R; i < N; i++) {
        list[i] = 1;
      }
    }
    dout << "====listの内容====\n";
    for (int i = 0; i < N; i++) dout << list[i] << endl;
    dout << "====ここまで====\n";
  }
  rep(i, N) { 
    if (list[i] == 0) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> vec;
vec.at(i)
vector<vector<int>> vec(10, vector<int>(10));
sort(all(vec));
sort(all(vec), greater<int>());
    //配列の内容表示
dout << "====vecの内容====\n";
for (int i = 0; i < N; i++) dout << vec[i] << endl;
dout << "====ここまで====\n";
*/

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

double L;

int main(){
    cin>>L;
    
    double e=L/3;
    double ans=e*e*e;

    cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var x uint64
  var ans uint64 = 0

  fmt.Scanln(&x)

  if x % 11 > 6 {
    ans += 1
  }

  if x % 11 != 0 {
    ans += 1
  }

  ans += x / 11 * 2

  fmt.Println(ans)
}

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

#ifdef TESTING
  #include "dump.hpp"
#else
  #define DUMP(...)
  #define DEBUG(...)
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}

int main(){
  INT(n); INT(c);
  vector<set<pair<int, int>>> vs(c + 1);
  REP(n){
    INT(si); INT(ti); INT(ci);
    vs[ci].insert(MP(si, ti));
  }
  REP(i, 1, c + 1){
    set<pair<int, int>> s0 = vs[i], s;
    if (s0.empty()){continue;}
    auto it = s0.begin();
    int l = (*it).first, r = (*it).second;
    REP(SZ(s0)){
      it++;
      if (it == s0.end() || r != (*it).first){
        s.insert(MP(l, r));
        l = (*it).first; r = (*it).second;
      } else {
        r = (*it).second;
      }
    }
    vs[i] = s;
  }
  vector<int> vi(200002, 0);
  for(auto s: vs){
    for(auto e: s){
      vi[e.first * 2]++;
      vi[e.second * 2 + 1]--;
    }
  }
  int ans = 0, tmp = 0;
  for(auto e: vi){
    tmp += e;
    ans = max(ans, tmp);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> P;
double toRad(double agl) {return agl*M_PI/180.0;}
P rotate(P a, double r) {
  return P(a.real()*cos(r)-a.imag()*sin(r),a.real()*sin(r)+a.imag()*cos(r));
}
int n;
void dfs(P l, P r,int k) {
  if(k==n) {
    printf("%.10f %.10f\n",l.real(),l.imag());
    return;
  }
  P s=l+(r-l)*0.333333333333333,t=l+(r-l)*0.666666666666666;
  P u=s+rotate(t-s,toRad(60));
  dfs(l,s,k+1);
  dfs(s,u,k+1);
  dfs(u,t,k+1);
  dfs(t,r,k+1);
}
int main() {
  cin >> n;
  dfs(0,100,0);
  printf("%.10f %.10f\n",100.0,0.0);
  return 0;
}


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

using namespace std;

char s[100015];
int dp[100015];
char t[4][10] = {"dream","dreamer","erase","eraser"};

int main(){
    scanf("%s",s+1);
    int n = strlen(s+1);
    dp[0] = 1;
    for(int i = 0; i<n; i++){
        if(!dp[i])
            continue;
        for(int j = 0; j<4; j++){
            int len = strlen(t[j]);
            if(!strncmp(s+1+i,t[j],len))
                dp[i+len] = 1;
        }
    }
    if(dp[n])
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

Measured memory_bytes: 768
/**
*    author:  Dooloper
*    created: 01.06.2020 22:44:40
**/

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


using namespace std;
typedef unsigned long long ull;
#define ll long long

int main() {
    cin.tie(0);
    ll A;cin>>A;
    double B;cin>>B;
    ll ib = B*100 + 0.5;//誤差があった時に余分に切り捨てられないように

    cout<<(ll)A*ib/100<<endl;
}

Measured memory_bytes: 3628
/*IT'S A VERY LONG ROAD BUT IT WILL BE WORTH IT*/
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
signed main()
{
    fast;
    int n;
    cin>>n;
    string s[n+1];
    int t[n+1];
    map<string,int> mp;
    for(int i = 1;i<=n;i++)
    {
        cin>>s[i];
        cin>>t[i];
        mp[s[i]] = i;
    }
    string ss;
    cin>>ss;
    int ans =0;
    int idx = mp[ss]+1;
    for(int i = idx;i<=n;i++)
        ans+=t[i];
    cout<<ans;
}

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

using namespace std;

int main(void)
{
  int a,b,x;

  cin>>a>>b>>x;

  for(int i=0;i<b;i++)
  {
    if(a==x)
    {
      cout<<"YES"<<endl;
      break;
    }
    else if(a<x)
    {
      a++;
    }
    else if(a>x)
    {
      cout<<"NO"<<endl;
      break;
    }
    
  }
      if(a<x)
    {
      cout<<"NO"<<endl;
    }
  
}


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

int main() {
	int n, m;
	int in[10010][2];
	bool a[10010];
	bool b[10010];

	while(cin >> n >> m, n | m) {
		for(int i = 0; i < 10010; i++) {
			a[i] = false;
			b[i] = false;
		}

		for(int i = 0; i < m; i++) {
			cin >> in[i][0] >> in[i][1];
		}

		for(int i = 0; i < m; i++) {
			if(in[i][0] == 1) {
				a[in[i][1]] = true;
			}
			else if(in[i][1] == 1) {
				a[in[i][0]] = true;
			}
		}

		for(int i = 0; i <= n; i++) {
			if(a[i]) {
				b[i] = true;
				for(int j = 0; j < m; j++) {
					if(in[j][0] == i) {
						b[in[j][1]] = true;
					}
					else if(in[j][1] == i) {
						b[in[j][0]] = true;
					}
				}
			}
		}

		int ans = 0;
		for(int i = 2; i <= n; i++) {
			if(b[i]) {
				ans++;
			}
		}

		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1256
#include <iostream>

using namespace std;

int main(void){
    int n, y;
    cin >> n >> y;
    int tmp = 0;
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            tmp = y - (10000 * i + 5000 * j);
            if (i + j + tmp / 1000 == n && tmp >= 0 && tmp / 1000 <= 2000) {
                cout << i << ' ' << j << ' ' << tmp / 1000 << ' ' << endl;
                return 0;
            } 
        }
        
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

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


using namespace std;
int n;


void dfs(string s, char mx) {
    if (s.size() == n) {
        cout << s << endl;
    }
    else {
        for (char c='a'; c<=mx+1; c++) {
            dfs(s+c, max(mx, c));
        }
    }
}


int main () {
    cin >> n;
    dfs("", 'a'-1);
    return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main() {
    int k, s;
    int x, y, z, cnt = 0;
    
    scanf("%d%d", &k, &s);
    for(x = 0; x <= k; x++){
        for(y = x; y <= k; y++){
            for(z = y; z <= k; z++){
                if(x+y+z == s){
                    if(x == y && y == z){
                        cnt++;
                    }else if(x == y || y == z || z == x){
                        cnt += 3;
                    }else{
                        cnt += 6;
                    }
                }
            }
        }
    }
    printf("%d\n", cnt);
    return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;

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

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

    int ans = 0;

    for (int i = 0; i < n; ++i) {
        int k = i + 1;

        for (int j = i+1; j < n; ++j) {
            while (k < n && l[k] < l[i] + l[j]) {
                ++k;
            }

            ans += k - (j+1);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/*input
11 16
11 17
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }

template<typename T>
void print(vector<T> vec, string name = "") {
	cout << name;
	for (auto u : vec)
		cout << u << ' ';
	cout << '\n';
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;

	printf((m1 == m2) ? "0" : "1");
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/


Measured memory_bytes: 256
import math
n = int(input())
A = list(map(int,input().split()))
count = 0
for i in A:
    count +=i
ave = count/n
f,i = math.modf(ave)
answer = 0
if f >=0.5:
    a = i + 1
    for i in A:
        answer += (i-a)**2
else:
    a = i
    for i in A:
        answer +=(i-a)**2
print(int(answer))

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

std::vector<int > edge[100004];
std::vector<int > c(100004);
std::vector<int > ans(100004);
std::vector<bool> visited;
std::priority_queue<int > queue;
std::queue<int > q;


int main(){
  int N;
  scanf("%d", &N);
  int a, b;
  visited=std::vector<bool>(100004, false);
  for (int i=0; i<N-1; i++){
    scanf("%d", &a);
    scanf("%d", &b);
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  long long sum=0;
  for (int i=0; i<N; i++){
    scanf("%d", &c[i]);
    sum+=c[i];
    queue.push(c[i]);
  }
  int highest=queue.top();
  queue.pop();
  std::cout << sum-highest << std::endl;
  ans[0]=highest;
  visited[0]=true;
  q.push(0);
  while(q.size()>0){
    int src=q.front();
    q.pop();
    for (int i=0; i<edge[src].size();i++){
      int tgt=edge[src][i];
      if (visited[tgt]) continue;
      visited[tgt]=true;
      int highest=queue.top();
      queue.pop();
      ans[tgt]=highest;
      q.push(tgt);
    }
  }
  for (int i=0; i<N; i++){
    printf("%d%c",ans[i],(i==N-1)?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 3968
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int N = sc.nextInt();
		if(N % 100 == 0) {
			N += 1;
		}
 
		System.out.println(N * (int)Math.pow(100, D));
	}
}

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

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

int main() {
    int n, a, b;
    int count = 0;
    cin >> n >> a >> b;
    for (int i = 1; i <= n; i++) {
        int sum = sum_digits(i);
        if (a <= sum && sum <= b) count += i;
    }
    cout << count << endl;
}


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

int main(){
	string S,T;
	int  count;
	
	cin >> S >> T;
	
	for(size_t i = 0; i < 3; i++)
	{
		if(S.at(i) == T.at(i))
		{
			count++;
		}
	}
	
	cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long


struct st{
	int val,freq;
};

bool comp(st a1,st a2){
	return a1.freq>a2.freq;
}

int main() {
  int n;
  sfi(n)

  int arr[n+5];

  f(i,0,n)
  sfi(arr[i])

  int no=0,ne=0;

  st mp1[100005],mp2[100005];


  f(i,0,100005){
  	mp1[i].freq=0,mp2[i].freq=0;
  	mp1[i].val=i,mp2[i].val=i;
  }

  f(i,0,n){
  	if(i%2==0){
  		no++;
  		mp1[arr[i]].freq++;
  	}
  	else{
  		ne++;
  		mp2[arr[i]].freq++;
  	}
  }

 	sort(mp1,mp1+100004,comp);
 	sort(mp2,mp2+100004,comp);

 //	cout<<mp1[0].freq<<" "<<no<<endl;

 	if(mp1[0].val!=mp2[0].val){
 		cout<<ne-mp1[0].freq+no-mp2[0].freq;
 	}

 	else{
 		cout<<min(ne-mp1[1].freq+no-mp2[0].freq,ne-mp2[1].freq+no-mp1[0].freq);
 	}


    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



long long N, K;

long long solve() {
    long long res = 0;
    for (long long b = K+1; b <= N; ++b) {
        long long tmp = min(b-1, b-K);
        long long A = N - (b-1);
        long long B = N-K;
        long long add = (A/b) * (b - K);
        if (B/b == A/b + 1) add += (B%b) + 1;
        tmp += add;
        res += tmp;
    }
    return res;
}

int main() {
    while (cin >> N >> K) {
        cout << solve() << endl;
    }
}








Measured memory_bytes: 256
from collections import deque


def slide_min(L: int, li: list):
	deq = deque()
	ret = []
	for i, x in enumerate(li):
		while deq and deq[-1][1] > x:
			deq.pop()
		deq.append((i, x))
		if deq[0][0] + L == i:
			deq.popleft()
		ret.append(deq[0][1])
	return ret[L - 1:]


def slide_max(L: int, li: list):
	deq = deque()
	ret = []
	for i, x in enumerate(li):
		while deq and deq[-1][1] < x:
			deq.pop()
		deq.append((i, x))
		if deq[0][0] + L == i:
			deq.popleft()
		ret.append(deq[0][1])
	return ret[L - 1:]


n, k, *a = map(int, open(0).read().split())
m, M = slide_min(k - 1, a), slide_max(k - 1, a)
ans = 1
for i in range(n - k):
	if not (a[i] < m[i + 1] and M[i + 1] < a[i + k]):
		ans += 1
cnt = 1
subt = 0
for x, y in zip(a, a[1:]):
	if x < y:
		cnt += 1
	else:
		cnt = 1
	if cnt == k:
		subt += 1
if subt:
	ans -= subt - 1

print(ans)


Measured memory_bytes: 35636
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
    multimap<string, int> m;
    int q; cin >> q;
    while (q--) {
        int com; cin >> com;
        if (com == 0) {
            string key; int x;
            cin >> key >> x;
            m.emplace(key, x);
        } else if (com == 1) {
            string key; cin >> key;
            auto p = m.equal_range(key);
            for (auto it = p.first; it != p.second; it++) {
                cout << it->second << endl;
            }
        } else if (com == 2) {
            string key; cin >> key;
            m.erase(key);
        } else if (com == 3) {
            string l, r; cin >> l >> r;
            auto it = m.lower_bound(l);
            while (it != m.end() && it->first <= r) {
                cout << it->first << " " << it->second << endl;
                ++it;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 24872
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < (int)n;i++)
#define repb(i, n) for(int i = (int)n;i >= 0;i--)
#define reps(i, m, n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i, m, n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[]) {
  int n,s=0,t;
  cin>>n;
  t=n;
  while (t>0) {
    s+=t%10;
    t/=10;
  }
  if(n%s==0)  cout << "Yes" << '\n';
  else  cout << "No" << '\n';
 return 0;
}


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

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

 vector<int> vec(N);
 for(int i=0; i<N; i++) cin >> vec.at(i);

 sort(vec.begin(), vec.end());
 reverse(vec.begin(), vec.end());

 int sum=0;

 for(int i=0; i<K; i++) sum+=vec.at(i);

 cout << sum << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

	if (N % 1000 != 0)
	{
		cout << 1000 - N % 1000 << endl;
	}
	else
	{
		cout << 0 << endl;
	}

	return 0;
}

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

int main(){
    int A=0,B=0,X=0;
    cin>>A>>B>>X;
    if(X-A>B || X-A<0){
        cout<<"NO"<<endl;
    }else{
        cout<<"YES"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
 double tmp = (double)n / 1.08;
      int tmp2 = (int)tmp;
if ((int)((double)tmp2 * 1.08) == n) {
  System.out.println(tmp2);
} else if ((int)((double)(tmp2 + 1) * 1.08) == n) {
  System.out.println(tmp2 + 1);
} else {
  System.out.println(":(");
}
    }
}

Measured memory_bytes: 23252
N,A,B,C=map(int,input().split())
X=[0,A,B,C]
L=[int(input()) for i in range(N)]
d=4**N
ans=float('inf')

for i in range(d):
  F=[0 for i in range(4)]
  cnt=[0 for i in range(4)]
  for j in range(N):
    F[i%4]+=L[j]
    cnt[i%4]+=1
    i //= 4
  p=True
  for k in range(1,4):
    if F[k]==0:
      p=False
      break
  tmp=0
  if p:
    for k in range(1,4):
      tmp+=cnt[k]*10+abs(X[k]-F[k])-10
    ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  ll n; cin >> n;
  vector<ll> v(n);
  map<ll, ll> m;
  rep(i, n){
    cin >> v[i];
    m[v[i]]++;
  }
  ll sum = 0;
  for(auto itr = m.begin(); itr != m.end(); itr++){
    if(itr->second >= 2){
      ll t = itr->second*(itr->second-1);
      t /= 2;
      sum += t;
    }
  }
  for(int i = 0; i < n; i++){
    if(m[v[i]] >= 2){
      cout << sum - (m[v[i]]-1) << endl;
    }
    else{
      cout << sum << endl;
    }
  }
  system("pause");
}

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> last(20);
  int j = 0;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    for (int b = 0; b < 20; b++) {
      if ((x >> b) & 1) {
        j = max(j, last[b]);
        last[b] = i + 1;
      }
    }
    ans += i + 1 - j;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(8);
  string s,ans="AKIHABARA";
  cin >> s;
  if(s.size()<=4) {cNO;return 0;}
  if(s[0]!='A') s = 'A'+s;
  if(s[4]!='A') s.insert(4,"A");
  if(s[6]!='A') s.insert(6,"A");
  if(s[s.size()-1]!='A') s += 'A';

  if(s==ans) cYES;
  else cNO;
  return 0;
}


Measured memory_bytes: 256
c_1 = list(map(int, input().split()))
c_2 = list(map(int, input().split()))
c_3 = list(map(int, input().split()))
c = c_1 + c_2 + c_3
if sum(c) == 3 * (c_1[0] + c_2[1] + c_3[2]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
n = int(input())
A = list(map(int,input().split()))
q = int(input())
M = list(map(int, input().split()))

d = {}

def solve(i, m):
    if m == 0:
        return True
    if i >= n:
        return False
    if (i, m) in d:
        return d[i, m]
    res = solve(i + 1,  m) or solve(i + 1, m - A[i])
    d[i,m] = res
    return res

for m in M:
    if solve(0, m):
        print('yes')
    else:
        print('no')



Measured memory_bytes: 9316
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)


int main() {
    int n;
    cin >> n;
    cout << 1110 - n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);
#define int long long
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin>>n>>m;
	vector<int> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a.begin(),a.end());
	vector<pair<int,int>>b(m);
	for(int i=0;i<m;i++)cin>>b[i].second>>b[i].first;
	sort(b.begin(),b.end(),greater<pair<int,int>>());
	int curr = 0;
	for(int i=0;i<m&&curr<n;i++)
	{
		while(b[i].second&&curr<n)
		{
			if(a[curr]>b[i].first){curr=n;break;}
			else a[curr]=b[i].first;
			++curr,--b[i].second;
		}
	}
	int res = 0;
	for(int val : a)
		res+=val;
	cout<<res<<endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);

int main(){
  int N;
  cin >> N;
  vector<int> c(100001,0);

  REP(i,N){
    int a;
    cin >> a;
    c[a]++;
  }

  int ans = c[0]+c[1]+c[2];
  int tmp = ans;
  FOR(i,1,100001-3){
    tmp-=c[i-1];
    tmp+=c[i+2];
    ans=max(ans,tmp);
  }
  cout << ans << endl;

}



Measured memory_bytes: 640
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>
using namespace std;
int n,k,ans;
bool arr[100000];
int main() {
	IOS
	cin>>n>>k;
	ans=n;
	for(int i=1;i<=k;i++){
		int t;
		cin>>t;
		while(t--){
			int w;
			cin>>w;
			arr[w]=1;
		}
	}
	for(int i=1;i<=n;i++)
		if(arr[i])
			ans--;
	cout<<ans<<endl;

}

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

int main() {
  double N;
  int K;
  cin >> N >> K;
  vector<double> sums(N), exp_vs(N);
  double sum = 0;
  for (int i = 0; i < N; ++i) {
    double pi;
    cin >> pi;
    double exp_v = ((pi * (pi + 1)) / 2) / pi;
    exp_vs.at(i) = exp_v;
    sum += exp_v;
    if (i == K - 1) {
      sums.at(i) = sum;
    } if (i >= K) {
      sums.at(i) = sums.at(i - 1) + exp_v - exp_vs.at(i - K);
    }
  }
  int max_i = max_element(sums.begin(), sums.end()) - sums.begin();
  double result = 0;
  for (int i = 0; i < K; ++i) {
    int ind = max_i - i;
    double n = exp_vs.at(ind);
    result += n;
  }
  cout << setprecision(10) << result << endl;
}

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


int main()
{
	int N;
	cin >> N;
	bool able = false;
	for (int cakes = 0; cakes <= N / 4; cakes++)
	{
		for (int dounuts = 0; dounuts <= N / 7; dounuts++)
		{
			if (cakes * 4 + dounuts * 7 == N)
				able = true;
		}

		if (able)
			break;
	}

	if (able)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define y0 yy
#define y1 Yy
#define yn YY
#include <assert.h>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

string s;

int main(){
    ios::sync_with_stdio(false);
    cin>>s;
    int pos=0;
    while(pos<s.size()){
        if(s.substr(pos,7)=="dreamer" && s.substr(pos+5,5)!="erase")pos+=7;
        else if(s.substr(pos,6)=="eraser")pos+=6;
        else if(s.substr(pos,5)=="dream")pos+=5;
        else if(s.substr(pos,5)=="erase")pos+=5;
        else{
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


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

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

    if(S=="ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}

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

int main() {
	ll n, k;
	cin>>n>>k;
	vector<ll> v(n);
	for(ll i=0;i<n;i++){
		cin>>v[i];
	}
	ll tmp=0;
	for(int i=0;i<=k-1;i++) tmp+=v[i];
	for(int i=k;i<n;i++){
		ll tmp1=tmp-v[i-k]+v[i];
		if(tmp1>tmp) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		tmp=tmp1;
	}
}

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

double x[10], y[10];
double ans = 0.0;

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

	for (int i = 0; i < N; ++i) cin >> x[i] >> y[i];

	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			double dx, dy;
			dx = x[i] - x[j];
			dy = y[i] - y[j];
			ans += pow((dx * dx + dy * dy), 0.5) * 2 / N;
		}
	}

	cout << setprecision(15) << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main()
{
    string N,ans;
    
    cin >> N;
    
   
    if((N[0]==N[1]&&N[1]==N[2])||(N[1]==N[2]&&N[2]==N[3])) ans ="Yes";
    
   
    
    else ans = "No";

    cout << ans << endl;
    
    return 0;
}

    

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int d = sc.nextInt();
		int scope = d * 2 + 1;
		int num = (n + scope - 1) / scope;

		System.out.println(num);

		sc.close();
	}

}


Measured memory_bytes: 23380
// 2011/07/21 Tazoe

#include <iostream>
using namespace std;

void trn(int n)
{
	if(n==0)
		return;

	int a = n%10;
	if(a<0)
		a = 10+a;

	n = n-a;
	n = n/(-10);
	trn(n);

	cout << a;
}

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		trn(n);
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int main(){
	int n;
	while(cin>>n,n){
		vp in;
		rep(i,n){
			int a,b;
			cin>>a>>b;
			in.pb(pii(a,b));
		}
		int s=n;
		cin>>n;
		s+=n;
		rep(i,n){
			int a,b;
			cin>>a>>b;
			in.pb(pii(a,b));
		}
		sort(all(in));
		vi dp(s);
		dp[0]=1;
		loop(i,1,s){
			rep(j,i)
				if(in[j].first<in[i].first&&
					in[j].second<in[i].second)
					dp[i]=max(dp[i],dp[j]+1);
		}
		int out=0;
		rep(i,s)out=max(out,dp[i]);
		cout<<out<<endl;
	}
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> p;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9



int main() {
	int t[5];
	for (int i = 1; i <= 4; i++) t[i] = 0;
	for (int i = 0; i < 3; i++) {
		int a, b;
		cin >> a >> b;
		t[a]++;
		t[b]++;
	}
	int count1 = 0;
	int count2 = 0;
	for (int i = 1; i <= 4; i++) {
		if (t[i] == 1) count1++;
		else if (t[i] == 2) count2++;
	}
	if (count1 == 2 && count2 == 2) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>> 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define mp make_pair
#define pll pair <lli,lli>
#define vll vector <lli>
#define pq2 priority_queue<pair<lli,lli>>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld long double 
const long double pi = 3.1415926535898;
#define dec greater<lli>()
const lli mod=1000000007;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i*i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=i*i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
int main()
{
    fio;
    lli n;
    cin>>n;
    lli t=n/1000;
    t*=1000;
    if (n%1000!=0)
    t+=1000;
    cout<<t-n;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  string S;
  cin >> S;
  int l = 0, r = S.size() - 1;
  int ans = 0;
  while (l < r) {
    if (S[l] != S[r]) {
      if (S[l] == 'x') {
        l++;
        ans++;
      } else if (S[r] == 'x') {
        r--;
        ans++;
      } else {
        cout << -1 << endl;
        return 0;
      }
    } else {
      l++;
      r--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int x,a,b;cin>>x>>a>>b;
    if(b<=a){
        cout<<"delicious"<<endl;
    }else if(b-a<=x){
        cout<<"safe"<<endl;
    }else{
        cout<<"dangerous"<<endl;
    }
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int R;
    cin >> R;
    printf("%lf\n",  2.0 * M_PI * R);
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    vector<int> SX(N);
    rep(i, N) {
        cin >> X[i];
        SX[i] = X[i];
    }

    sort(all(SX));
    int can1, can2;
    can1 = SX[N / 2 - 1], can2 = SX[N / 2];

    rep(i, N) {
        if (X[i] <= can1)
            cout << can2 << endl;
        else if (X[i] >= can2)
            cout << can1 << endl;
    }
}

Measured memory_bytes: 3712
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N;
  cin >> N;
  int T, A;
  cin >> T >> A;
  T--, A--;

  vvi G(N);
  rep(i, 0, N - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].pb(b);
    G[b].pb(a);
  }

  vector<int> depth(N);
  vector<int> parent(N);
  vector<int> mx(N);
  auto dfs = [&](auto fun, int v, int p, int d) -> int {
    depth[v] = d;
    parent[v] = p;
    mx[v] = 0;
    for (int w : G[v]) {
      if (w == p) continue;
      chmax(mx[v], fun(fun, w, v, d + 1) + 1);
    }
    return mx[v];
  };
  dfs(dfs, A, -1, 0);

  {
    int k = (depth[T] - 1) / 2;
    rep(i, 0, k) T = parent[T];
  }
  int ans = 0;
  ans = depth[T] + mx[T] - 1;
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 12672
#include<stdio.h>
#include<algorithm>
#define inf -2139062144
using namespace std;
int a[100005];
int gcd(int a, int b)
{
	return b ? gcd(b, a%b) : a;
}
int main()
{
	int n,k,i,j;
	scanf("%d%d",&n,&k);
	int ma = inf;
	for(i=1;i<=n;i++)
    {
		scanf("%d",&a[i]);
		ma = max(ma,a[i]);
	}
	int re = a[1];
	for(i=1;i<=n;i++)
	{
		re = gcd(re,a[i]);
	}
	if(ma >= k && k%re == 0)
	{
		printf("POSSIBLE\n");
	}
	else
	{
		printf("IMPOSSIBLE\n");
	}
	return 0;
}


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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007
#define tc             ll tc;scanf("%lld",&tc);while(tc--)

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:
/*bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}*/


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

/*ll lcm(ll x, ll y)
{

    ll ret=__gcd(x,y);
    return (x*y)/ret;
}*/

/*ll dx[]= {0,0,1,-1};
ll dy[]= {1,-1,0,0};*/

int main()
{
    ll n;
    cin >> n;
    vector< string > vs;
    map< string, ll > m;
    for(ll i=0;i<n;i++)
    {

        string ss;
        cin >> ss;
        if(m[ss]==0) vs.pb(ss);
        m[ss]++;
    }
    ll ms=0;
    vector< string > v;
    for(ll i=0;i<vs.size();i++)
    {

        ms= max(ms,m[vs[i]]);
    }
    for(ll i=0;i<vs.size();i++)
    {

        if(m[vs[i]]==ms) v.pb(vs[i]);
    }
    sort(all(v));

    for(ll i=0;i<v.size();i++) cout << v[i] << endl;
}


Measured memory_bytes: 37556
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <cstdio>

using namespace std;

typedef long double ld;

struct Point {
    ld x, y;
    Point(ld x=0, ld y=0) : x(x), y(y) {}
    bool operator==(const Point &o) const {
        return x == o.x && y == o.y;
    }
    Point operator+(const Point &o) const {
        return Point(x + o.x, y + o.y);
    }
    Point operator/(int n) const {
        return Point(x/n, y/n);
    }
    Point operator+=(const Point &o) {
        x += o.x;
        y += o.y;
        return Point(x, y);
    }
    Point operator/=(int n) {
        x /= n;
        y /= n;
        return Point(x, y);
    }
    string to_s() {
        char buf[1024];
        sprintf(buf, "%7llf %7llf", x, y);
        return string(buf);
    }
};

int main() {
    int n; cin >> n;
    if (n % 2 == 1) {
        cout << "NA" << endl;
        return 0;
    }
    vector<Point> vs(n);
    Point g(0, 0); // 重心
    for (int i = 0; i < n; i++) {
        ld x, y;
        cin >> x >> y;
        vs[i] = Point(x, y);
        g += vs[i];
    }
    g /= n;

    for (int i = 0; i < n/2; i++) {
        if (not(vs[i] + vs[i+n/2] == g + g)) {
            cout << "NA" << endl;
            return 0;
        }
    }
    cout << g.to_s() << endl;
    return 0;
}

Measured memory_bytes: 1300