akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define db double
#define lowbit(p) (p&(-p))
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define A first
#define B second
using namespace std;
void read(int &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void read(ll &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void Min(int &x,int y){
	if (x>y)x=y;
}
void Max(int &x,int y){
	if (x<y)x=y;
}
void Min(ll &x,ll y){
	if (x>y)x=y;
}
void Max(ll &x,ll y){
	if (x<y)x=y;
}
/*
中位数的中位数.
同样考虑二分答案?


*/
#define M 200005
int a[M],sum[M],n,L,R;
struct Reimu{
#define ls (p<<1)
#define rs (p<<1|1)
	int f[M<<3];
	void build(int l,int r,int p){
		f[p]=0;
		if (l==r){
			return;
		}
		int mid=(l+r)>>1;
		build(l,mid,ls);
		build(mid+1,r,rs);
	}
	void upd(int l,int r,int x,int p){
		f[p]++;
		if (l==r){
			return ;
		}
		int mid=(l+r)>>1;
		if (x<=mid)upd(l,mid,x,ls);
		else upd(mid+1,r,x,rs);
	}
	int qu(int l,int r,int x,int y,int p){
		if (l==x&&r==y)return f[p];
		int mid=(l+r)>>1;
		if (y<=mid)return qu(l,mid,x,y,ls);
		if (x>mid) return qu(mid+1,r,x,y,rs);
		return qu(l,mid,x,mid,ls)+qu(mid+1,r,mid+1,y,rs);
	}
}T;
ll chk(int x){
//	printf("------%d-------\n",x);
	ll res=0;
	int i;
	T.build(L,R,1);
	T.upd(L,R,0,1);
	for (i=1;i<=n;i++){
		sum[i]=sum[i-1];
		if (a[i]<=x)sum[i]++;
		else sum[i]--;
		res+=T.qu(L,R,L,sum[i]-1,1);
//		printf("%d ",T.qu(L,R,L,sum[i]-1,1));
		T.upd(L,R,sum[i],1);
	}
//	printf("\n");
//	printf("res=%lld\n",res);
	return res;
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
//	freopen("1.in","r",stdin);
	read(n);
	int i,l,r,mid,res;
	L=-n-5;
	R=n+5;
	for (i=1;i<=n;i++){
		read(a[i]);
	}
	l=1; r=1e9; res=0;
//	printf("%lld\n",(ll)n*(n+1)/2/2+1);
	for (;l<=r;){
		mid=(l+r)>>1;
//		printf("%d %lld\n",mid,chk(mid));
		if (chk(mid)>=((ll)n*(n+1)/2/2+1)){
			r=mid-1;
			res=mid;
		}				
		else {
			l=mid+1;
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 5120
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        mut ab: [(usize, usize); m],
    }

    let mut v = vec![0; n+1];

    for (a, b) in ab {
        v[b] = std::cmp::max(a, v[b]);
    }

    let mut index = 1;
    let mut ans = 0;
    for (i, e) in v.into_iter().enumerate() {
        if e >= index {
            ans += 1;
            index = i;
        }
    }

    println!("{}", ans);
}


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

#define get_variable_name(x) #x
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, begin, end) for(int (i) = (begin); (i) < (end); (i)++)

#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())
#define REVERSE(x) reverse( (x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define PW(x) (1LL<<(x))

using namespace std;
using ll = int64_t;
using P = pair<int, int>;

template<class T,class U>
ostream& operator<<(ostream &os, const pair<T, U> &p) {
    os << get_variable_name(p) << " = (" << p.first <<", " << p.second << ")";
    return os;
}

template<class T>
ostream& operator <<(ostream& os, const vector<T> &v){
    cout << get_variable_name(v) << " = [";
    for(auto i : v) 
        os << " " << i;
    os << " ]";
    return os;
}


const int INF = 1e8;

int main() {
    ios::sync_with_stdio(false);
    string s[3];
    rep(i, 0, 3) cin >> s[i];
    int cur = 0;
    while(true) {
        if(s[cur].size() == 0) {
            cout << (char)(cur+'A') << endl;
            break;
        }
        int p = (s[cur][0] - 'a');
        s[cur].erase(0, 1);
        cur = p;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); 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; }


int main() {
    ll n, a;
    cin >> n;
    priority_queue<ll, vector<ll>, greater<ll> > pq;
    rep1(i, n){
        cin >> a;
        pq.push(a);
    }
    ll x, y;
    while (pq.size()>1){
        x = pq.top(); pq.pop();
        y = pq.top(); pq.pop();
        pq.push(x);
        if (y%x!=0) pq.push(y%x);
    }
    ll ans = x;
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 4320
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int mo = 1000000007;
using namespace std;
void upd(ll &x, ll y) { x = (x + y) % mo; }
int n, m; ll f[302][302][302];
int main() {
	scanf("%d%d", &n, &m);
	f[0][1][1] = 1;
	rep(i, 0, m - 1) rep(j, 1, i + 1) {
		rep(k, 1, j - 1) if (f[i][j][k]){
			upd(f[i + 1][j][j], f[i][j][k] * k % mo);
			upd(f[i + 1][j][k], f[i][j][k] * (j - k) % mo);
			upd(f[i + 1][j + 1][k], f[i][j][k] * (n - j) % mo);
		}
		upd(f[i + 1][j][j], f[i][j][j] * j % mo);
		upd(f[i + 1][j + 1][j], f[i][j][j] * (n - j) % mo);
	}
	printf("%lld\n", f[m][n][n]);
	return 0;
}

Measured memory_bytes: 108288
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    auto used = make_v(4, 1000, false);
    used[0][0] = true;
    REP(i, 0, n) {
        int a = s[i] - '0';
        for (int j = 2; j >= 0; j--) {
            REP (k, 0, 1000) {
                if (used[j][k]) {
                    int t = (k * 10 + a) % 1000;
                    used[j + 1][t] = true;
                }
            }
        }
    }
    int cnt = 1;
    REP(i, 0, 1000) {
        cnt += used[3][i];
    }
    cout << cnt - 1 << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c, k, sum = 0;
    cin >> a >> b >> c >> k;
    ll takeA = min(a, k), rem;
    sum += takeA;
    rem = k - takeA;
    if (rem)
    {
        ll takeB = min(rem, b);
        rem = rem - takeB;
        if (rem)
        {
            ll takeC = min(rem, c);
            sum -= takeC;
        }
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
        long sum = 0;
		for(long i=1; i<Math.sqrt(n); i++){
          if((n % ((n-i)/i)) == (n / ((n-i)/i))) sum += (n-i)/i; 
        }
		System.out.println(sum);
	}
}

Measured memory_bytes: 23636
#include <stdio.h>
#include <iostream>
using namespace std;

const int M=55;
int d[M];

int main()
{
	int n; scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&d[i]);
	int ans=0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			ans+=d[i]*d[j];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int f(int x) {
	if (x % 2 == 0) return x / 2;
	else return 3 * x + 1;
}
int main() {
	int n; cin >> n;
	set<int> st;
	int x = n;
	while (st.count(x) == 0) {
		st.insert(x);
		x = f(x);
	}
	cout << st.size() + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int n, m, c = 0;
  cin >> n >> m;
  vector<int> h(n);
  rep(i, 0, n) cin >> h[i];
  vector<vector<int>> ab(n);
  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    ab[a-1].push_back(b-1);
    ab[b-1].push_back(a-1);
  }
  rep(i, 0, n) {
    int f = 0;
    int sizes = ab[i].size();
    rep(j, 0, sizes) {
      if(h[i] <= h[ab[i][j]]) {
        //cout << "h[i]" << h[i] << "\n";
        //cout << "h[ab[i][j]]" << h[ab[i][j]] << "\n";
        f = 1;
        break;
      }
    }
    if(f == 0) {
      c++;
      //cout << "i" << i << "\n";
    }
  }
  cout << c;
}

Measured memory_bytes: 8804
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

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

int merge(vector<int> &a, int left, int mid, int right)
{
  int n1 = mid - left;
  int n2 = right - mid;
  vector<int> l(n1 + 1), r(n2 + 1);
  for (int i = 0; i < n1; ++i)
    l[i] = a[left + i];
  for (int i = 0; i < n2; ++i)
    r[i] = a[mid + i];
  l[n1] = INF, r[n2] = INF;
  int i = 0, j = 0;
  int cnt = 0;
  for (int k = left; k < right; ++k)
  {
    cnt++;
    if (l[i] <= r[j])
    {
      a[k] = l[i];
      i++;
    }
    else
    {
      a[k] = r[j];
      j++;
    }
  }
  return cnt;
}

int mergeSort(vector<int> &a, int left, int right)
{
  int cnt = 0;
  if (left + 1 < right)
  {
    int mid = (left + right) / 2;
    cnt += mergeSort(a, left, mid);
    cnt += mergeSort(a, mid, right);
    cnt += merge(a, left, mid, right);
  }
  return cnt;
}

int main()
{
  int n;
  cin >> n;
  vector<int> s(n);
  for (auto &e : s)
    cin >> e;
  int cnt = mergeSort(s, 0, s.size());
  for (int i = 0; i < n; ++i)
    cout << s[i] << " \n"[i == n - 1];
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 6732
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int N, M, Q;
  scanf("%d %d %d", &N, &M, &Q);
  int line[501][501] = {0}; // line都市L][都市R]:列車(線路)が通っているか
  int L, R;
  int p[100001], q[100001];
  rep(i, 0, M) {
    scanf("%d %d", &L, &R);
    line[L][R]++;
  }
  rep(i, 0, Q) scanf("%d %d", &p[i], &q[i]);

  // rep(i, 1, N+1) {
  //   rep(j, 1, N+1) {
  //     printf("%d ", line[i][j]);
  //   }
  //   printf("\n");
  // }
  // printf("\n");
  int train[502][502] = {0}; // train[都市L][都市R]:完全に含まれる列車の本数
  for (int s = N; s > 0; s--) {
    int sum = 0;
    for (int g = s; g <= N; g++) {
      sum += line[s][g];
      train[s][g] += sum;
      train[s][g] += train[s + 1][g];
    }
  }
  // rep(i, 1, N+1) {
  //   rep(j, 1, N+1) {
  //     printf("%d ", train[i][j]);
  //   }
  //   printf("\n");
  // }
  // printf("\n");

  rep(i, 0, Q) {
    printf("%d\n", train[p[i]][q[i]]);
  }
  return 0;
}


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

using namespace std;

int main(){
    long long int N,sum=0;
    cin >> N;
    vector<long long int> A(N),ans(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        sum += A[i];
    }

    ans[0] = sum;

    for(int i=1;i<N;i+=2){
        ans[0] -= 2*A[i];
    }

    for(int i=1;i<N;i++){
        ans[i] = 2*A[i-1]-ans[i-1];
    }

    cout << ans[0];

    for(int i=1;i<N;i++){
        cout << " " << ans[i];
    }

    cout << endl;
}

Measured memory_bytes: 2944
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<math.h>
#include<queue>
#include<functional>
using namespace std;
#define int long long
#define mod 1000000007

int a[200001];//階乗
int b[100001];//フェルマー
int p(int c, int d) {//cのd乗
	int e = c, f = 1;
	while (d > 1) {
		if (d & 1)f = e*f%mod;
		e = e*e%mod;
		d >>= 1;
	}
	return e*f%mod;
}
int K(int x, int y) {//x*y進む方法
	if (x == 0 || y == 0)return 1;
	return a[x + y] * b[x] % mod*b[y] % mod;
}
signed main() {
	a[1] = 1;
	for (int i = 2; i < 200001; i++) {
		a[i] = a[i - 1] * i%mod;
	}
	b[1] = 1;
	for (int i = 2; i < 100001; i++) {
		b[i] = b[i - 1] * p(i, mod - 2) % mod;
	}
	int h, w, x, y;
	cin >> h >> w >> x >> y;
	int ans = 0;
	for (int i = y; i < w; i++) {
		ans = (ans + K(h - x - 1, i)*K(x - 1, w - i - 1)) % mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
const int inf = 1 << 30;
const int INF = INT_MAX;

int memo[110][5][5][5];
const int MOD = 1000000007;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, d[4];
  cin >> n;
  memo[0][0][0][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (d[0] = 0; d[0] < 5; ++d[0]) {
      for (d[1] = 0; d[1] < 5; ++d[1]) {
        for (d[2] = 0; d[2] < 5; ++d[2]) {
          for (d[3] = 1; d[3] < 5; ++d[3]) {
            bool flag = true;
            for (int j = 0; j < 4; ++j) {
              if (j > 0) {
                swap(d[j], d[j - 1]);
              }
              if ((d[0] == 1 && d[1] == 3 && d[2] == 2) ||
                  (d[1] == 1 && d[2] == 3 && d[3] == 2)) {
                flag = false;
              }
              if (j > 0) {
                swap(d[j], d[j - 1]);
              }
            }
            if (flag) {
              memo[i + 1][d[1]][d[2]][d[3]] += memo[i][d[0]][d[1]][d[2]];
              memo[i + 1][d[1]][d[2]][d[3]] %= MOD;
            }
          }
        }
      }
    }
  }
  int ans = 0;
  for (d[0] = 1; d[0] < 5; ++d[0]) {
    for (d[1] = 1; d[1] < 5; ++d[1]) {
      for (d[2] = 1; d[2] < 5; ++d[2]) {
        ans += memo[n][d[0]][d[1]][d[2]];
        ans %= MOD;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a;
  int b;
  cin >> a >> b;
  int mx = (a <= b)? a:a-1;
  cout << mx << endl;
  return 0;
}


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

class dice{
    private:
        int order[6];
    public:
        void roll_N(){
            int tmp;
            tmp = order[0];
            order[0] = order[1];
            order[1] = order[5];
            order[5] = order[4];
            order[4] = tmp;
        }
        void roll_S(){
            int tmp;
            tmp = order[0];
            order[0] = order[4];
            order[4] = order[5];
            order[5] = order[1];
            order[1] = tmp;
        }
        void roll_W(){
            int tmp;
            tmp = order[0];
            order[0] = order[2];
            order[2] = order[5];
            order[5] = order[3];
            order[3] = tmp;
        }
        void roll_E(){
            int tmp;
            tmp = order[0];
            order[0] = order[3];
            order[3] = order[5];
            order[5] = order[2];
            order[2] = tmp;
        }
        void setOrder(int i, int ord){order[i] = ord;}
        int getOrder(int i){return order[i];}
        
        bool inSameDice(int inputed[]){
            dice tmp;
            for(int i=0;i<6;i++){
                tmp.setOrder(i,inputed[i]);
            }
            bool ch = false;
            for(int i=0;i<6;i++){
                if(i<4){
                    tmp.roll_N();
                }else if(i==4){
                    tmp.roll_W();
                    tmp.roll_N();
                }else{
                    tmp.roll_N();
                    tmp.roll_N();
                }
                for(int j=0;j<4;j++){
                    tmp.roll_W();
                    for( int k=0;k<6;k++){
                        if(order[k]!=tmp.getOrder(k)) break;
                        if(k==5) ch=true;
                    }
                    if(ch) break;
                }
                if(ch) break;
            }
            return ch;
        }
};


int main(void){

    int d1[6],d2[6];
    cin >> d1[0] >> d1[1] >> d1[2] >> d1[3] >> d1[4] >> d1[5];
    cin >> d2[0] >> d2[1] >> d2[2] >> d2[3] >> d2[4] >> d2[5];
    dice A,B;
    
    for( int i=0;i<6;i++){
        A.setOrder(i,d1[i]);
    }

    string out;
    if(A.inSameDice(d2)){
        out="Yes";
    }else{
        out="No";
    }
    cout << out << endl;
}



Measured memory_bytes: 3216
#include <iostream>
#include <string>
#include <vector>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main()
{
	string s;
	while(cin >> s)
	{
		if(s == "-") break;

		int m;
		cin >> m;
		rep(i,m)
		{
			int n;
			cin >> n;
			vector<char> c;
			REP(i,n,s.size())
			{
				c.push_back(s[i]);
			}

			rep(i,n)
			{
				c.push_back(s[i]);
			}

			rep(i,s.size())
			{
				s[i] = c[i];
			}
		}

		cout << s << endl;
	}
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s;
    cin >> s;
    reverse(all(s));
    map<int, LL> mp;
    int t = 0;
    int d = 1;
    for(int i = 0; i < s.size(); ++i) {
        t += (s[i] - '0') * d;
        t %= 2019;
        mp[t]++;
        d *= 10;
        d %= 2019;

    }

    LL res = 0;
    res += mp[0] * (mp[0] + 1) / 2;
    /*
    int l = 1, r = 2018;
    while(l <= r) {
        res += mp[l] * mp[r];
        ++l; --r;

    }*/
    for(int i = 1; i <= 2018; ++i) {
        res += mp[i] * (mp[i] - 1) / 2;

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


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

using namespace std;

int main(){
  int N;
  cin >> N;
  int T, A;
  cin >> T >> A;
  vector<int> H(N);
  for(int i = 0; i < N; i++) cin >> H[i];
  double mind = 1000.0;
  int idx = 0;
  for(int i = 0; i < N; i++){
    double d = 0.0;
    d = abs((double)A - (T - 0.006 * H[i]));
    if(mind >= d){
      idx = i;
      mind = d;
    }
  }
cout << idx + 1;  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#define REP0(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REP1(i,n) for((i)=1;(i)<=(long long)(n);(i)++)
#define ll long long
using namespace std;

ll i,j,k;
const ll MOD = 1000000000 + 7;

int main(){
    ll n,m;
    char a;
    cin>>a;
    
    
    if(a>='A' && a<='Z'){
        cout<<'A'<<'\n';
    }
    else{
        cout<<'a'<<'\n';
    }
    
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)
using namespace std;
using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
const int MAXN = 5 + 3000;
const int MOD = 7 + 1000000000;
int dp[MAXN][MAXN];

int query(int row, int i, int j) {
    if(i > j) return 0;
    assert(i >= 0 && j >= 0 && i < MAXN && j < MAXN);
    int ans = dp[row][j] - (i == 0 ? 0 : dp[row][i - 1]);
    if(ans < 0) ans += MOD;
    return ans;
}

void add(int& a, const int& b) {
    a += b;
    if(a >= MOD) a -= MOD;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    s = "ab" + s;

    /// dp[i][j] = numero de permutaciones de size i(i.e, cumple las primeras i - 1 restricciones)
    /// cuyo ultimo elemento es j[0...i-1]
    for(int j = 0; j < n; ++j) {
        dp[1][j] = 1;
    }

    for(int i = 2; i <= n; ++i) {
        for(int j = 0; j < n; ++j) {
            int& ans = dp[i][j];
            if(s[i] == '<') {
                ans = query(i - 1, 0, j - 1);
            } else if(s[i] == '>') {
                ans = query(i - 1, j, n - 1);
            } else assert(false);
            if(j >= i) ans = 0;
            if(j > 0) add(ans, dp[i][j - 1]);
        }
    }
    cout << dp[n][n - 1] << '\n';
    return 0;
}


Measured memory_bytes: 35456
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
vector<int> T[10005]; 
int N;
ll c[10005], score[10005];
bool searched[10005];
queue<int> que;

int main() {
  INCANT;
  cin >> N;
  int u,v;
  rep(i, N-1) {
    cin >> u >> v;
    u--;v--;
    T[u].push_back(v);
    T[v].push_back(u);
  }
  ll sum=0ll;
  rep(i, N) {
    cin >> c[i];
    sum+=c[i];
  }
  sort(c, c+N, greater<ll>());
  rep(i, N) {
    if (T[i].size()==1) {
      searched[i] = true;
      que.push(i);
      break;
    }
  }
  int now=0;
  while(!que.empty()) {
    int k = que.front();
    que.pop();
    score[k] = c[now];
    now++;
    for (auto p: T[k]) {
      if (!searched[p]) {
        searched[p] = true;
        que.push(p);
      }
    }
  }
  cout << sum-c[0] << endl;
  rep(i, N) cout << score[i] << ' ';
  cout << endl;
  return 0;
}

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

int main(){
	LL x, y, z;
	cin >> x >> y >> z;
	LL n = x + y + z;
	LL a[n], b[n], c[n];
	LL ans = 0;
	for(LL i = 0; i < n; i++){
		cin >> a[i] >> b[i] >> c[i];
		ans += a[i];
		b[i] -= a[i];
		c[i] -= a[i];
	}
	pair<LL,LL > t[n];
	for(LL i = 0; i < n; i++){
		t[i] = make_pair(b[i]-c[i],i);
	}
	sort(t, t+n);
	reverse(t, t+n);
	LL besty[n+1];
	multiset<LL> ys;
	LL cur = 0;
	for(LL i = 0; i < y; i++){
		ys.insert(b[t[i].second]);
		cur += b[t[i].second];
	}
	for(LL i = y; i <= n; i++){
		if(i > y){
			cur += b[t[i-1].second];
			ys.insert(b[t[i-1].second]);
			cur -= *ys.begin();
			ys.erase(ys.begin());
		}
		besty[i] = cur;
	}

	reverse(t, t+n);
	LL bestz[n+1];
	multiset<LL> zs;
	cur = 0;
	for(LL i = 0; i < z; i++){
		zs.insert(c[t[i].second]);
		cur += c[t[i].second];
	}
	for(LL i = z; i <= n; i++){
		if(i > z){
			cur += c[t[i-1].second];
			zs.insert(c[t[i-1].second]);
			cur -= *zs.begin();
			zs.erase(zs.begin());
		}
		bestz[i] = cur;
	}

	LL final = -1e18;
	for(LL i = y; i + z <= n; i++){
		final = max(final, besty[i] + bestz[n-i]);
	}
	cout << final + ans << endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<ld> vld;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()

const int mod = 1e9 + 7;

int main()
{
	fastIO;
	int s; cin >> s;
	vll dp(s + 1,0);

	dp[0] = 1; dp[1] = dp[2] = 0;
	for(int sum = 3; sum <= s; sum++)
		for(int coin = 3; coin <= sum; coin++)
			dp[sum] += dp[sum - coin],
			dp[sum] %= mod;

	cout << dp[s] << endl;

	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
queue<long long> m;
void yaku(long long n){
    if(n!=1) m.push(n);
    for(long long i=2; i*i<=n; i++){
        if(n%i==0){
            m.push(i);
            if(i*i!=n) m.push(n/i);
        }
    }
    return;
}
int main() {
    long long n;
    cin>>n;
    yaku(n);
    long long ans =0;
    while(!m.empty()){
        long long tmp = m.front();
        long long nn=n;
        while(nn%tmp ==0){
            nn/=tmp;
        }
        if(nn%tmp ==1) ans++;
        m.pop();
    }
    yaku(n-1);
    while(!m.empty()){
        ans++;
        m.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=c-a;
	int y=d-b;
	for(int i=0;i<x;i++)
	{
		cout<<'R';
	 } 
	 for(int i=0;i<y;i++)
	 {
	 	cout<<'U';
	 }
	 for(int i=0;i<x;i++)
	 {
	 	cout<<'L';
	 }
	 for(int i=0;i<=y;i++)
	 {
	 	cout<<'D';
	 }
	 for(int i=0;i<=x;i++)
	{
		cout<<'R';
	 } 
	 for(int i=0;i<=y;i++)
	 {
	 	cout<<'U';
	 }
	 cout<<"LU";
	 for(int i=0;i<=x;i++)
	 {
	 	cout<<'L';
	 }
	 for(int i=0;i<=y;i++)
	 {
	 	cout<<'D';
	 }
	 cout<<'R';
	 
}



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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    cout << pow(n, 3) << endl;
}

Measured memory_bytes: 4108
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD_CONST = 1000000007;

struct UnionFind {

	vector<int> p;

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

	int root(int x) {
		if (p[x] == x) {
			return x;
		}
		p[x] = root(p[x]);
		return p[x];
	}

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) {
			return;
		}

		p[rx] = ry;
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

};

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		p[i]--;
	}

	UnionFind uf(n);
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;

		uf.unite(x, y);
	}

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (uf.same(p[i], i)) {
			cnt++;
		}
	}
	cout << cnt << endl;
}  



Measured memory_bytes: 1024
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s1 = in.next();
        String s2 = in.next();
        String s3 = in.next();
        System.out.println("A" + s2.charAt(0) + "C");
    }
}


Measured memory_bytes: 27000
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pii              pair <int,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define EPS              10E-10
#define ff               first
#define ss               second
#define sqr(x)           (x)*(x)
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define SZ(a)            (int)a.size()
#define sf(a)            scanf("%d",&a)
#define sfl(a)           scanf("%lld",&a)
#define sff(a,b)         scanf("%d %d",&a,&b)
#define sffl(a,b)        scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
#define stlloop(v)       for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define REP(i,a,b)       for(int i=a;i<b;i++)
#define RREP(i,a,b)      for(int i=a;i>=b;i--)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
#define PRINT_CASE       printf("Case %d: ",z)
#define LINE_PRINT_CASE  printf("Case %d:\n",z)
#define CASE_PRINT       cout<<"Case "<<z<<": "
#define all(a)           a.begin(),a.end()
#define intlim           2147483648
#define infinity         (1<<28)
#define ull              unsigned long long
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))

using namespace std;

//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/

int main()
{

//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);

    int n,a;
    cin>>n>>a;
    cout<<sqr(n)-a<<endl;

    return 0;
}


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

int main(){
  int tate, yoko;
  cin >> tate >> yoko;
  int mini = 1000000000;
  for(int i = (tate / 3) - 10;i <= (tate / 3) + 10;i++){
    for(int j = (yoko / 2) - 10;j <= (yoko / 2) + 10;j++){
      mini = min(mini,(max(i * yoko,max((tate - i) * j,(tate - i) * (yoko - j))) - min(i * yoko,min((tate - i) * j,(tate - i) * (yoko - j)))));
    }
  }
  
  for(int i = (yoko / 3) - 10;i <= (yoko / 3) + 10;i++){
    for(int j = (tate / 2) - 10;j <= (tate / 2) + 10;j++){
      mini = min(mini,(max(i * tate,max((yoko - i) * j,(yoko - i) * (tate - j))) - min(i * tate,min((yoko - i) * j,(yoko - i) * (tate - j)))));
    }
  }
  for(int i = (tate / 3) - 10;i <= (tate / 3) + 10;i++){
    for(int j = (tate / 3) - 10;j <= (tate / 3) + 10;j++){
      mini = min(mini,max(i * yoko,max(j * yoko,(tate - i - j) * yoko)) - min(i * yoko,min(j * yoko,(tate - i - j) * yoko)));
    }
  }
  for(int i = (yoko / 3) - 10;i <= (yoko / 3) + 10;i++){
    for(int j = (yoko / 3) - 10;j <= (yoko / 3) + 10;j++){
      mini = min(mini,max(i * tate,max(j * tate,(yoko - i - j) * tate)) - min(i * tate,min(j * tate,(yoko - i - j) * tate)));
    }
  }
  cout << mini;
}

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

using namespace std;

int main()
{
    long long k;
    cin >> k;
    long long a = 49 + k / 50;
    int m = (int) (k % 50);
    cout << 50 << endl;
    for (int i = 0; i < 50; i++)
    {
        if (i != 0)
            cout << " ";
        if (i < m)
            cout << a + 50 - (m - 1);
        else
            cout << a - m;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define rep(i, j, k) for (auto i = j; i < k; i++)
#define rrep(i, j, k) for (auto i = j; i > k; i--)
using namespace std;

void solve(int &n) {
  string s[50];
  rep(i, 0, n) cin >> s[i];
  string tmp[50];
  rep(i, 0, n) {
    tmp[i] = s[i][0];
    rep(j, 1, (int)s[i].size()) {
      if (s[i][j - 1] == 'a' || s[i][j - 1] == 'i' || s[i][j - 1] == 'u' || s[i][j - 1] == 'e' || s[i][j - 1] == 'o') {
        tmp[i] += s[i][j];
      }
    }
  }
  rep(k, 1, 51) {
    bool ok = true;
    rep(i, 0, n) {
      rep(j, i + 1, n) {
        if (tmp[i].substr(0, k) == tmp[j].substr(0, k)) ok = false;
      }
    }
    if (ok) {
      cout << k << endl;
      return;
    }
  }
  cout << -1 << endl;
}

int main() {
  int n;
  while (cin >> n, n) solve(n);
}



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

int main() {
  vector<int> V(32);
  int K;
  V = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
  cin >> K;
  cout << V.at(K-1) << endl;
}

Measured memory_bytes: 256
bingo = []
for i in range(3):
    bingo.append(input().split())
N = int(input())

for i in range(N):
    inp=input()
    for j in range(3):
        for h in range(3):
            if bingo[j][h]==inp:
                bingo[j][h]=0

Ans = "No"
for i in range(3):
    if sum([int(x) for x in bingo[i]])==0:
        Ans ="Yes"

for i in range(3):
    if sum([int(row[i]) for row in bingo])==0:
        Ans="Yes"

if int(bingo[0][0])+int(bingo[1][1])+int(bingo[2][2])==0:
    Ans="Yes"
    
if int(bingo[2][0])+int(bingo[1][1])+int(bingo[0][2])==0:
    Ans="Yes"
print(Ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#B
n = int(input())
a,d = map(int,input().split())
A = []

m = int(input())
x = [0] * m
y = [0] * m
z = [0] * m
NumOfTerms = []

for i in range(m):
    x[i],y[i],z[i] = map(int,input().split())
    NumOfTerms.append(y[i])
    NumOfTerms.append(z[i])

num = set(NumOfTerms)

for i in num:
    A.append([i, a+d*(i-1)])

for i in range(len(x)):
    if x[i] == 0:
        for j in range(len(A)):
            if A[j][0] == y[i]:
                yj = j
            if A[j][0] == z[i]:
                zj = j

        tmp = A[yj][1]
        A[yj][1] = A[zj][1]
        A[zj][1] = tmp

    else:
        for j in range(len(A)):
            if A[j][0] == y[i]:
                yj = j
            if A[j][0] == z[i]:
                zj = j
        A[yj][1] = A[zj][1]

k = int(input())

for j in range(len(num)):
    if A[j][0] == k:
        print(A[j][1])
        exit()

print(a+d*(k-1))

Measured memory_bytes: 7752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1001001001;

int main() {
    int n;
    string s;
    cin >> n;
    map<string, int> mp;
    for(int i = 0; i < n; i++){
        cin >> s;
        if(mp.find(s) == mp.end()){
            mp[s] = 1;

        }else{
            int tmpn = mp[s];
            mp[s] = tmpn + 1;
        }
    }
    int maxnum = 0;
    for(auto p : mp) maxnum = max(maxnum, p.second);
    for(auto p : mp){
        if(p.second != maxnum) continue;
        cout << p.first << endl;
    }
    return 0;
}

Measured memory_bytes: 25216
W,H,x,y,r = map(int,input().split())
max_width = x + r
min_width = x - r
max_height = y + r
min_height = y - r

answer = "Yes"
if max_width > W:
  answer = "No"
elif min_width < 0:
  answer = "No"
elif max_height > H:
  answer = "No"
elif min_height < 0:
  answer = "No"

print(answer)


Measured memory_bytes: 5596
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Reflection.Metadata;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics.X86;
using System.Text;
using System.Threading;

namespace AtCoder
{
	public class Program
	{
		static void Main()
		{
			var a = new int[3, 3];
			for (int i = 0; i < 3; i++) {
				var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				for (int j = 0; j < 3; j++) {
					a[i, j] = temp[j];
				}
			}

			int n = int.Parse(Console.ReadLine());
			var done = new bool[3, 3];
			for (int k = 0; k < n; k++) {
				int t = int.Parse(Console.ReadLine());

				for (int i = 0; i < 3; i++) {
					for (int j = 0; j < 3; j++) {
						if (a[i, j] == t) {
							done[i, j] = true;
						}
					}
				}
			}

			bool ok = false;
			for (int i = 0; i < 3; i++) {
				bool yoko = true;
				for (int j = 0; j < 3; j++) {
					if (done[i, j] == false) {
						yoko = false;
						break;
					}
				}

				bool tate = true;
				for (int j = 0; j < 3; j++) {
					if (done[j, i] == false) {
						tate = false;
						break;
					}
				}

				if (yoko || tate) {
					ok = true;
					break;
				}
			}

			if ((done[0, 0] && done[1, 1] && done[2, 2])
				|| (done[2, 0] && done[1, 1] && done[0, 2])) {
				ok = true;
			}

			Console.WriteLine(ok ? "Yes" : "No"); 
		}
	}
}


Measured memory_bytes: 28156
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
ll c(ll a, ll b){
    return a / b + !!(a % b);
}
int main(){
    ll N, K;
    cin >> N >> K;
    ll po = 0;
    for(ll i = 0; i < N; i++){
        ll a;
        cin >> a;
        if(a == 1) po = i;
    }
    ll a = po, b = N - po - 1;
    ll ans = N;
    for(ll i = 0; i < K; i++){
        ans = min(c(max<ll>(a - i, 0), K - 1) + c(max<ll>(0, b - (K - i - 1)), K - 1) + 1, ans);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
    int h,w;
    cin >> h >> w;
    string s[50];
    for(int i = 0; i < w; i++) cin >> s[i];
    const int dx[4] = {0, 0, 1, -1};
    const int dy[4] = {1, -1, 0, 0};
    bool ok = true;
    for(int i = 0; i < w; i++){
        for(int j = 0; j < h; j++){
            if(s[i][j] != '#')continue;
            bool ok2 = false;
            for(int k = 0; k < 4; k++){
            const int ni = i + dx[k];
            const int nj = j + dy[k];

            if(ni < 0 or ni >= w) continue;
            if(nj < 0 or nj >= h) continue;
            if(s[ni][nj] == '#') ok2 = true; continue; 
            }
            if(ok2)continue;
            ok = false;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

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

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);

	constexpr int MAX_H = 20;

	for(int r, n; cin >> r >> n && r;) {
		unordered_map<int, int> max_height;

		rep(i, n) {
			int xl, xr, h;
			cin >> xl >> xr >> h;
			REP(x, xl, xr) {
				chmax(max_height[x], h);
			}
		}

		double ans = MAX_H;
		REP(i, -r, r) {
			const int h = max_height[i] + r;
			const int x = (i < 0 ? i + 1 : i);
			const double y = sqrt(r * r - x * x);
			chmin(ans, h - y);
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1280
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "ctime"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> N >> H >> W;
	for (int i = 0; i < N; i++) {
		cin >> L >> R;
		if (L >= H && R >= W)K++;
	}
	cout << K << endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    b:isize,
    c:isize,
    }
    println!("{}",if (a-b).abs()<(a-c).abs() {"A"}else{"B"})
}

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000
 
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;
 
int n,m,ans; string str;
 
int solve(){
    double n; cin>>n;
    double a=n/3;
    a=a*a*a;
    cout<<fixed<<setprecision(10)<<a;
    return 0;
}
 
signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
X, Y = input().split()

HEX_dic = {
    "A":10,
    "B":11,
    "C":12,
    "D":13,
    "E":14,
    "F":15
}

if HEX_dic[X] == HEX_dic[Y]:
    print("=")
elif HEX_dic[X] < HEX_dic[Y]:
    print("<")
else:
    print(">")

Measured memory_bytes: 3060
while True:
	n,m = map(int,input().split())
	if n+m == 0: break
	road = [list(map(int, input().split())) for _ in range(n) ]
	road = sorted(road, key=lambda x:-x[1])
	d = 0
	for a,b in road:
		if a <= m:
				m -= a
		else:
			d += (a - m) * b
			m = 0
	print(d) 



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

#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;

const int INF = 1001001001;

int main() {
  int n, m, l;
  cin >> n >> m >> l;
  vector<vector<int>> dist(n, vector<int>(n,INF));
  for(int i = 0; i < n; i++) {
    dist[i][i] = 0;
  }
  for(int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    dist[a][b] = dist[b][a] = c;
  }
  for(int k = 0; k < n; k++) {
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
        chmin(dist[i][j], dist[i][k]+dist[k][j]);
      }
    }
  }
  vector<vector<int>> dist2(n, vector<int>(n,INF));
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      if (dist[i][j] <= l) dist2[i][j] = 1;
    }
  }
  for(int k = 0; k < n; k++) {
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
        chmin(dist2[i][j], dist2[i][k]+dist2[k][j]);
      }
    }
  }
  int q;
  cin >> q;
  for(int qi = 0; qi < q; qi++) {
    int s, t;
    cin >> s >> t;
    --s; --t;
    int ans = dist2[s][t]-1;
    if (dist2[s][t] == INF) ans = -1;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;

#define INF 1e9

struct Range{
  long long point, num, l, r;
};
bool operator< (const Range& a, const Range& b){
  return a.point < b.point;
}

int main(int argc, char* argv[]){
  int n;
  cin >> n;
  priority_queue<int, vector<int>, greater<int>> a;
  set<Range> ranges = {{-1, -1, 0, -2}, {n, (long long)INF, n-1, n+1}};
  vector<int> point(n);
  for(int i = 0 ; i < n; i++){
    int t;
    cin >> t;
    a.emplace(t);
    point[t] = i;
  }
  long long ans = 0;
  for(int i = 0; i < n; i++){
    long long now = a.top();
    a.pop();
    auto next = ranges.upper_bound({point[now], 0, 0, 0});
    long long l = prev(next, 1)->point + 1;
    long long r = next->point - 1;
    ranges.insert((Range){point[now], now, l, r});
  }
  for(auto now:ranges){
    if(now.num == -1 || now.num == INF) continue;
    ans += now.num * (now.point - now.l + 1) * (now.r - now.point + 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 17396
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define inf INT_MAX/3
#define debug(x) cout<<#x<<":"<<x<<endl;
#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define pi 2*acos(0.0)
#define in scanf
#define out printf

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

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

int n;
int a[1000 + 2];

int main(){
	cin >> n;
	REP(i,n) {in("%d", &a[i]);}

	REP(j,n) {if (j) out(" "); out("%d", a[j]);}
	out("\n");

	FOR(i, 1, n){
		int obj = a[i];
		int j = i-1;
		while(j >= 0 && a[j] > obj){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = obj;

		// output
		REP(j,n) {if (j) out(" "); out("%d", a[j]);}
		out("\n");
	}



	return 0;
}

Measured memory_bytes: 3180
sa=input()
sb=input()
sc=input()
n=len(sa)+len(sb)+len(sc)
cnta=0
cntb=0
cntc=0
ban="a"
for i in range(n+1):
    if ban=="a":
        cnta+=1
        if cnta>len(sa):
            print("A")
            exit()
        else:
            ban=sa[cnta-1]
    elif ban=="b":
        cntb+=1
        if cntb>len(sb):
            print("B")
            exit()
        else:
            ban=sb[cntb-1]
    elif ban=="c":
        cntc+=1
        if cntc>len(sc):
            print("C")
            exit()
        else:
            ban=sc[cntc-1]

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int N,K; cin >> N >> K;
    vei a(N); rep(i,N) cin >> a[i];

    if( ( N - 1 ) % ( K - 1 ) == 0) cout << ( N - 1 ) / ( K - 1 ) << endl;
    else cout << ( N + K - 2 ) / ( K - 1 ) << endl;
    return 0;
}



Measured memory_bytes: 640