akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
// #include <bits/stdc++.h>

using namespace std;
typedef long long li;

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

    li n;
    cin >> n;

    multiset<li> last_points;
    for (int i = 0; i < n; ++i) {
        li x;
        cin >> x;
        auto p = last_points.lower_bound(x);
        if (p == last_points.begin()) {
            last_points.insert(x);
        } else {
            p--;
            last_points.erase(p);
            last_points.insert(x);
        }
    }

    cout << last_points.size() << endl;
    return 0;
}


Measured memory_bytes: 4992
from collections import deque

n, m = map(int, input().split())

friendsetlist = [set([]) for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1

    friendsetlist[a].add(b)
    friendsetlist[b].add(a)

dq = deque([])

checked = [0 for _ in range(n)]

ans = 0

for i in range(n):
    if checked[i] == 0:
        dq.append(i)
        checked[i] = 1
        tmpans = 1
        while len(dq) != 0:
            now = dq.popleft()
            for nxt in friendsetlist[now]:
                if checked[nxt] == 0:
                    tmpans += 1
                    dq.append(nxt)
                    checked[nxt] = 1
        if ans < tmpans:
            ans = tmpans

print(ans)



Measured memory_bytes: 72724
#include <iostream>
#include <map>
using namespace std;
#define N 200001
#define DD 1000000007
int a[N];
int f = 1;
map<int,int> m;
int main()
{
	int n,tot = 1;
	cin >> n;
	for(int i = 1;i <= n;i ++)
		cin >> a[i];
	for(int i = 2;i <= n;i ++)
	{
		if(a[i] != a[i - 1])
			a[++tot] = a[i];
	}
	for(int i = 1;i <= tot;i ++)
	{
		f = (f + m[a[i]]) % DD;
		m[a[i]] = f;
	}
	cout << f << endl;
	return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	template<typename T> inline int ts(T *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		return a;
	}
}
using ae86::ty;
using ae86::ts;

const int _ = 5007;

int n,sa[_],sb[_],na,nb;
vector<int> va,vb;

int main()
{
	n=ty(),ts(sa+1),ts(sb+1);

	for(int i=1;i<=n;i++)sa[i]-=48,sb[i]-=48;
	for(int i=1;i<n;i++)
	{
		if(sa[i]!=sa[i+1])va.emplace_back(i);
		if(sb[i]!=sb[i+1])vb.emplace_back(i);
	}
	na=va.size(),nb=vb.size();

	if(!na || !nb)
	{
		int cnt=0;
		for(int i=1;i<=n;i++)cnt+=sa[i]!=sb[i];
		printf("%d\n",cnt);
		
		return 0;
	}

	int ans=1e9,dlt=sa[va[0]]!=sb[vb[0]];
	for(int i=-(na+((na&1)^dlt));i<=nb+((nb&1)^dlt);i+=2)
	{
		int sum=0;
		for(int j=min(0,-i),k=j+i;j<max(na,nb-i);j++,k++)
		{
			int xa=0,xb=0;
			if(j>=0 && j<na)xa=va[j];
			else if(j>=na)xa=n;
			if(k>=0 && k<nb)xb=vb[k];
			else if(k>=nb)xb=n;
			sum+=abs(xa-xb);
		}
		ans=min(ans,sum);
	}

	printf("%d\n",ans);
	
	return 0;
}


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

#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

const double PI = 3.14;


int main()
{
	uint64_t a, b, c, d;
	cin >> a >> b >> c >> d;

	double tmp = double(a)*double(b) / 2;

	printf("%lf %d\n", tmp, c+c == a && d+d == b);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
ll n;

bool cek(ll n){
		string a=to_string(n);
		if(a.length()&1){
			return true;
		}
		return false;
	}

int main(){
	IOS
	cin >> n;
	ll ans=0;
	for(ll i=1;i<=n;i++){
		if(cek(i)){
			ans++;
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3756
#include<stdio.h>
int main(void)
{
	int x,y,z,a;
	scanf("%d %d %d %d",&x,&y,&z,&a);
	a=x;
	x=y;
	y=a;
	a=x;
	x=z;
	z=a;
	printf("%d %d %d\n",x,y,z);
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int a,b;

int main(void){
	scanf("%d%d",&a,&b);
	printf("%d\n",(a+b)%24);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e5; int n;
const lli inf = 1e18;
struct Problem
{
  lli l, r;
  void read() { scanf("%lld %lld", &l, &r); }
};
Problem problems[maxN];

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    lli maxL = -inf, minR = inf;
    for (int i = 0; i < n; i ++)
    {
      problems[i].read();
      maxL = max(maxL, problems[i].l);
      minR = min(minR, problems[i].r);
    }

    lli ans = 0;
    // maxL and minR will have to either be in the same contest or not

    // if they're in the same contest:
    for (int i = 0; i < n; i ++)
      ans = max(ans, max(0LL, minR - maxL + 1) + problems[i].r - problems[i].l + 1);

    // if they're not in the same contest:
    vector<pair<lli, lli>> t;
      // If a problem is in maxL group: max(0, problems[i].r - maxL + 1), let's call this a
      // If a problems is in minR group: max(0, minR - problems[i] + 1), let's call this b
      // sort the pairs (a, b) ascending by a and descending by b, let's call the vector of pairs t
      // now find the index i in which maximizes: min(t[0 : i].b) + min(t[i + 1 : n - 1].a)
    for (int i = 0; i < n; i ++)
      t.push_back({max(0LL, problems[i].r - maxL + 1), -max(0LL, minR - problems[i].l + 1)});
    sort(t.begin(), t.end());

    lli curr = -t[0].second;
    for (int i = 1; i < n; i ++)
    {
      ans = max(ans, curr + t[i].first);
      curr = min(curr, -t[i].second);
    }
    printf("%lld\n", ans);
  }

  return 0;
}

Measured memory_bytes: 3956
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstring>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erase(unique(all(v)),v.end());
#define pvec(v) rep(i,v.size()){ cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sizeof(m))

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
#define mod 1e9 + 7;
ll dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};


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

	ll a = 0, b = 0, c = 0, d, e, ans = 0,j=0, n, ret = M, m, y = 0;
	
	string s,t1;
	while (cin >> s) {
		a = s.size();
		repr(i, s.size()) {
			if (s[i] == 'B' && i != s.size() - 1) {
				//cout << a << " " << b << endl;
				REP(j, i + 1, a) {
					if (s[j] == 'W') {
						//cout << j << endl;
						b++;
					}
				}
				a = i;
				ans += b;
			}
			
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 720
#include<stdio.h>
int main(void)
{
  int x,n,a,b,count;
  for( ; ; )
    {count=0;
  scanf("%d%d",&n,&x);
  if(n==0 && x==0){break;}
  for(a=1;a<=(x/3) && a<=n;a++)
    {
      for(b=a+1;(x-a-b)>b && b<=n;b++)
	{	if((x-a-b)<=n){count++;}}
    }
  printf("%d\n",count);
    }
  return 0;
}

Measured memory_bytes: 600
#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)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    int n;
    cin >> n;
    vi v(n);
    REP(i, n) cin >> v[i];
    bool f = false;
    REP(i, n) {
        if(v[i] % 2 == 0) {
            if(!(v[i] % 3 == 0 || v[i] % 5 == 0)) f = true;
        }
    }
    if(f) cout << "DENIED" << endl;
    else cout << "APPROVED" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    print('YES' if len(set(A)) == N else 'NO')


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;

ll gcd(ll c, ll d){
	return d ? gcd(d, c % d) : c;
}

ll lcm(ll c, ll d){
	return c / gcd(c, d) * d;
}

ll f(ll x, ll c, ll d){
	ll cnt = x;
	cnt -= x / c;
	cnt -= x / d;
	cnt += x / lcm(c, d);

	return cnt;
}

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

	ll a_cnt = 0;
	ll b_cnt = 0;

	a_cnt = f(a-1, c, d);
	b_cnt = f(b, c, d);

	cout << b_cnt - a_cnt << endl;
}

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

int main() {
  ll n;
  cin >> n;
  // A*B + C == n
  // A*B < N

  ll ans = 0;
  for(ll a=1; a<n; a++) {
    ans += (n-1)/a;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, ans = 0;
  std::cin >> N;
  std::vector<int> a(N), b(N), c(N-1);
  for(int i=0;i<N;i++) std::cin >> a[i];
  for(int i=0;i<N;i++) {
    std::cin >> b[i];
    ans += b[i];
  }
  for(int i=0;i<N-1;i++) std::cin >> c[i];
  for(int i=0;i<N-1;i++){
    if(a[i]+1==a[i+1]) ans += c[a[i]-1];
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math/rand"
)

func main() {
	var D int
	fmt.Scan(&D)
	cs := make([]int, 26)
	for i := 0; i < 26; i++ {
		fmt.Scan(&cs[i])
	}

	ss := make([][26]int, D)
	for i := 0; i < D; i++ {
		for j := 0; j < 26; j++ {
			fmt.Scan(&ss[i][j])
		}
	}

	ts := make([]int, D)
	for d := 0; d < D; d++ {
		sat := int(-1e9)
		t := 0
		for i := 0; i < 26; i++ {
			ts[d] = i + 1
			s := solve(d+1, ts, cs, ss)
			if sat <= s {
				sat = s
				t = ts[d]
			}
		}
		ts[d] = t
	}

	for i := 0; i < 70000; i++ {
		d := rand.Intn(365)
		q := rand.Intn(25) + 1
		sat1 := solve(D, ts, cs, ss)

		t := ts[d]
		ts[d] = q
		sat2 := solve(D, ts, cs, ss)
		if sat1 < sat2 {
			continue
		}

		ts[d] = t
	}

	for i := 0; i < len(ts); i++ {
		fmt.Println(ts[i])
	}
}

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

func solve(D int, ts []int, cs []int, ss [][26]int) int {
	last := [26]int{}
	sat := 0
	for d := 0; d < D; d++ {
		j := ts[d] - 1
		last[j] = d + 1
		for i := 0; i < 26; i++ {
			sat -= (d + 1 - last[i]) * cs[i]
		}
		sat += ss[d][j]
	}

	return sat
}


Measured memory_bytes: 2556
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

string S;

int main(){
    cin>>S;
    reverse(S.begin(),S.end());
    out(S);
}



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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int a, b;
    cin >> a >> b;
    if(a == 2 || b == 2){cout << "No";}
    else cout << "Yes";
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m,x,y;
    int a[100005];

    cin>>n>>m;
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }
    vector<int> v[n+1];
    while(m--){
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    for(int i=1; i<=n; i++){
        sort(v[i].begin(),v[i].end());
    }
    int cnt=0;
    for(int i=1; i<=n; i++){
        bool flag = true;
        if(v[i].size()==0){
            cnt++;
            continue;
        }
        for(int j=0; j<v[i].size(); j++){
            if(v[i][j] == v[i][j+1]){
                if(a[v[i][j]]>=a[i])flag=false;
                j++;
            }
            else{
                if(a[v[i][j]] >= a[i])flag=false;
            }
        }
        if(flag)cnt++;
    }

    cout<<cnt<<"\n";

    return 0;
}

Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INF 1000000000000 //10^12

int main(){
    ll n,k;
    cin >>n>>k;
    vector<ll> a(n,0);
    vector<ll> s;
    vector<ll> visit(n+1,-1);
    
  
    REP(i,n) cin >> a[i];
    ll v=1;
    while(visit[v]==-1){
        visit[v]=s.size();
        s.push_back(v);
        v=a[v-1];
    }
    ll l,r;
    l=visit[v];
    r=s.size()-l;

    if(k<l) cout <<s[k]<<endl;
    else
    {
        k-=l;
        k%=r;
        cout << s[k+l] << endl;
    }
    
}

Measured memory_bytes: 8500
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

ll modval(ll num){ return (num%MODV+MODV)%MODV; }

int main(){
    Init();
    ll n, k, ans = 1, zcnt = 0; cin >> n >> k;
    vector<ll> a(n), pos, neg, zero;
    rep(i, n){
        cin >> a[i];
        if(a[i] >= 0) pos.push_back(a[i]);
        else if(a[i] < 0) neg.push_back(a[i]);
        if(a[i] == 0) zcnt++;
    }

    ll pcnt = pos.size()-zcnt;
    ll ncnt = neg.size();

    // nとkが同じなら全部掛け合わせるしか無い
    if(n == k) rep(i, n) ans = (ans*a[i])%MODV;
    // k個抜き出すと絶対0を含んでしまう場合
    else if(pcnt+ncnt < k) ans = 0;
    // kが1なら最大値を抜き出すだけ
    else if(k == 1){
        sort(all(a), greater<ll>());
        ans = a[0];
    }
    // kが奇数で、正の値が1つも無い場合は負の値（or 0）となる
    else if(k%2 == 1 && pcnt == 0){
        sort(all(a), greater<ll>());
        rep(i, k) ans = (ans*a[i])%MODV;
    }
    // それ以外は絶対正にできる
    else{
        sort(all(pos), greater<ll>());
        sort(all(neg));
        ll ppos = 0, npos = 0;
        // 奇数だったら正の数の最大値を1個かけておく
        if(k%2 == 1){
            ans *= pos[ppos];
            ppos++;
            k--;
        }
        vector<ll> mulpair;
        if(pos.size()-ppos>=2) for(ppos; ppos<pos.size()-1; ppos += 2) mulpair.push_back(pos[ppos]*pos[ppos+1]);
        if(neg.size()>=2) for(npos; npos<neg.size()-1; npos += 2) mulpair.push_back(neg[npos]*neg[npos+1]);
        sort(all(mulpair), greater<ll>());
        k /= 2;
        rep(i, k){
            ans = ans*(mulpair[i]%MODV)%MODV;
        }
    }
    cout << modval(ans) << endl;
}

Measured memory_bytes: 8104
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll N, K;
ll num[100001];
map<ll, ll> powN;

long long modpow(long long x, long long n, long long MOD){
    long long ret = 1;
    while(n > 0){
        if(n & 1) ret = (ret * x) % MOD;
        x = (x * x) % MOD;
        n = (n >> 1);
    }
    return ret;
}


signed main(){
    cin >> N >> K;
    ll ans = 0;
    for(ll i = K; i >= 1; i--){
        num[i] = modpow(K / i, N, MOD);
        for(ll j = 2; i * j <= K; j++) num[i] = (num[i] + MOD - num[i * j]) % MOD;
        ans = (ans + i * num[i] % MOD) % MOD;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 4356
let x = stdin.ReadLine() |> int

x % 100 
|> fun x -> x/5 , x%5
|> fun (a,b) -> 
    if b <> 0 then a+1
    else a
|> (*) 100
|> function
| a when x >= a -> 1
| _ -> 0
|> stdout.WriteLine

Measured memory_bytes: 11220
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

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

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

int main() {
	int n;
	cin >> n;
	vector<int> p;
	int cnt = n;
	int min = n + 1;
	REP(i, n) {
		int tmp;
		cin >> tmp;
		if (min > tmp) {
			min = tmp;
		}
		else cnt--;
	}
	cout << cnt;
}

Measured memory_bytes: 256
#b
n,d=map(int, input().split())
bc = [list(map(int, input().split())) for _ in range(n)]
import math
ans = 0
dist = 0
for p in bc:
    dist = math.sqrt((0-p[0])**2 +  (0-p[1])**2)
    if dist <= d:
        ans += 1
print(ans)

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

using namespace std;

#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define mem(a) memset(a,0,sizeof(a))
#define sqr(x) ((x)*(x))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;

const int mn=1e5+5;

int n;
unordered_map<int,int> h;

void init(){
	int cnt=0;
	for(int i=1;i<=1000;i++){
		h[i*(i+1)/2]=++cnt;
	}
}

vector<int> v[mn];

int main() {
	//cin.sync_with_stdio(0);
#ifdef LOCAL
	freopen("../1.txt", "r", stdin);
	clock_t cc=clock();
#endif
	scanf("%d",&n);
	init();
	if (h[n]==0){
		puts("No");
		return 0;
	}
	else{
		puts("Yes");
		int u=h[n];
		int cnt=1;
		printf("%d\n",u+1);
		for(int i=1;i<=u+1;i++){
			printf("%d ",u);
			for(int j=1;j<i;j++){
				v[i].pb(v[j][i-2]);
			}
			for(int j=sz(v[i]);j<u;j++){
				v[i].pb(cnt++);
			}
			for(int j=0;j<sz(v[i])-1;j++){
				printf("%d ",v[i][j]);
			}
			printf("%d\n",v[i].back());
		}
	}
#ifdef LOCAL
	cout<<"time:"<<(double)(clock()-cc)/CLOCKS_PER_SEC;
#endif
	return 0;
}

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

#define Rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PrintLn(X) cout << X << endl
int main(void)
{
	int x, a, b;
	cin >> x >> a >> b;
	if(b <= a){
		PrintLn("delicious");
	}else if(b <= a + x){
		PrintLn("safe");
	}else{
		PrintLn("dangerous");
	}
	return 0;
}


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

using namespace std;

double p[2999];
int n;
double dp[3000][3000];

int dfs(int k){
  for(int i = 0; i <= n; i++){
    if(i == 0){
      dp[k][0] = dp[k-1][0] * (1 - p[k-1]);
    }
    else{
      dp[k][i] = dp[k-1][i] * (1 - p[k-1]) + dp[k-1][i-1] * p[k-1];
    }
  }
  if(k < n) return dfs(k+1);
  else return 0;
}

int main(){
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }
  for(int i = 0; i < 3000; i++){
    for(int j = 0; j < 3000; j++){
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;
  dfs(1);
  double ans = 0;
  for(int i = (n+1)/2 ; i <= n ; i++ ){
    ans += dp[n][i];
  }
  cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 70656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{

	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
		
		String strS = br.readLine();
		String strP = br.readLine();
		
		StringBuffer sb = new StringBuffer(strS);
		
		sb.append(strS);
		
		System.out.println( (sb.indexOf(strP) == -1 ? "No" : "Yes") );
	}
}

Measured memory_bytes: 24404
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

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

    vector<string> v, v2;
    v.emplace_back(s);
    int ok = 1;
    while(ok){
        ok = 0;
        for (auto &&t : v) {
            if(t == "ABC"){
                puts("Yes");
                return 0;
            }
            int k = 0;
            for(char C = 'A'; C <= 'C'; ++C){
                string p;
                for (int i = 0; i < t.size(); ++i) {
                    if(i+2 < t.size() && t[i] == 'A' && t[i+1] == 'B' && t[i+2] == 'C') {
                        p += C; i += 2;
                        k = 1;
                    }
                    else p += t[i];
                }
                string q;
                for (char i : p) {
                    if(i == C) q += "ABC";
                    else q += i;
                }
                if(t == q) v2.emplace_back(p);
            }
            ok |= k;
        }
        v.clear();
        v2.swap(v);

    }
    puts("No");
    return 0;
}


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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template<typename T>
struct Segtree{
    int n;
    T op;
    vector<T> elm;
    function<T(T, T)> f;

    Segtree(int n, T init, function<T(T, T)> f, T op = T()) :
        n(n),
        op(op),
        elm(2 * n, init),
        f(f)
    {
        for(int i = n - 1; i >= 1; --i)
            elm[i] = f(elm[2 * i], elm[2 * i + 1]);
    }

    Segtree(int n, vector<T> init, function<T(T, T)> f, T op = T()) :
        n(n),
        op(op),
        elm(2 * n),
        f(f)
    {
        for(int i = 0; i < n; ++i)
            elm[i + n] = init[i];
        for(int i = n - 1; i >= 1; --i)
            elm[i] = f(elm[2 * i], elm[2 * i + 1]);
    }

    void set(int x, T val){
        x += n;
        elm[x] = val;
        while(x >>= 1)
            elm[x] = f(elm[2 * x], elm[2 * x + 1]);
    }

    void update(int x, T val){
        x += n;
        elm[x] = f(val, elm[x]);
        while(x >>= 1)
            elm[x] = f(elm[2 * x], elm[2 * x + 1]);
    }

    T get(int x, int y) const{
        T l = op, r = op;
        for(x += n, y += n - 1; x <= y; x >>= 1, y >>= 1){
            if(x & 1)
                l = f(l, elm[x++]);
            if(!(y & 1))
                r = f(elm[y--], r);
        }
        return f(l, r);
    }
};


signed main(){
    int n;
    cin >> n;
    vector<i64> a(n);
    for(auto& x : a)
        cin >> x;
    Segtree<i64> seg(n, a, [](auto x, auto y){return x + y;}, 0L);
    i64 ans = INF;
    for(int i = 1; i < n; ++i){
        i64 a = seg.get(0, i);
        i64 b = seg.get(i, n);
        ans = min(ans, abs(a - b));
    }
    cout << ans << endl;
}


Measured memory_bytes: 6528
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<set>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<bitset>
#include<deque>
#define Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 5050
#define maxm 100010
#define mod 1000000007
#define inf 1000000007
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>pii;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int K,Q;
int d[maxn];
int main()
{
    K=read();Q=read();
    for(int i=0;i<K;i++)  d[i]=read();
    while(Q--)
    {
        int n=read(),x=read(),m=read();x%=m;
        ll sum=0,cnt=0;
        for(int i=0;i<K;i++)  sum+=(d[i]%m),cnt+=(d[i]%m==0);
        ll add=1ll*((n-1)/K)*sum;cnt=cnt*((n-1)/K);
        for(int i=0;i<=n-2-((n-1)/K)*K;i++)  add+=(d[i]%m),cnt+=(d[i]%m==0);
        cout<<(n-1-(add+x)/m+x/m)-cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vi C(N);
  rep(i,0,N) cin>>C[i];
  sort(ALL(C));
  vi A(N-1),B(N-1);
  int j=0;
  rep(i,1,N-1){
    if(C[i]>0) break;
    A[j]=C[N-1];
    B[j++]=C[i];
    C[N-1]-=C[i];
  }
  rep(i,1,N-1){
    if(C[i]>0){
      A[j]=C[0];
      B[j++]=C[i];
      C[0]-=C[i];
    }
  }
  A[N-2]=C[N-1];
  B[N-2]=C[0];
  cout<<C[N-1]-C[0]<<endl;
  rep(i,0,N-1) cout<<A[i]<<" "<<B[i]<<endl;
  }


Measured memory_bytes: 4224
#include<stdio.h>
int main(){
  int n,i,a[2000000],minv,j,maxv=0;
  scanf("%d",&n);
  for (i = 0; i < n; i++){
    scanf("%d",&a[i]);  
}
  
  
  minv = a[0];
  maxv = a[1]-minv;
  for(j = 1;j <= n-1; j++){
  if(maxv >a[j]-minv)
    maxv = maxv;
  else if(maxv <a[j]-minv)
    maxv =a[j]-minv;
  if(minv<a[j])
    minv =minv;
  else if(minv >a[j])
    minv = a[j];

  }
   
     
 printf("%d\n",maxv);
     
 
 return 0;
}

Measured memory_bytes: 3320
#include<stdio.h>
int main (void)
{
	int a, b, c, d, e;
	scanf("%d %d %d", &a, &b, &c);
	if(a==5 && b==5 && c==7){
		printf("YES\n");
	}
	if(a==5 && b==7 && c==5){
		printf("YES\n");
	}
	if(a==7 && b==5 && c==5){
		printf("YES\n");
	}
	if(a==7 && b==7 && c==7){
		printf("NO\n");
	}
	if(a==5 && b==7 && c==7){
		printf("NO\n");
	}
	if(a==7 && b==7 && c==5){
		printf("NO\n");
	}
	if(a==5 && b==5 && c==5){
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TOPSIC
{
    class Program
    {
        static void Main(string[] args)
        {//入力値をスペース区切りで配列に格納
            string[] inputStr = Console.ReadLine().Split(' ');

            int N = int.Parse(inputStr[0]);
            int R = int.Parse(inputStr[1]);

            if (N >= 10)
            {
                Console.WriteLine(R);
            }
            else
            {
                Console.WriteLine(R + 100 * (10 - N));
            }


        }
    }
}

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

long long solve(vector<long long> X, long long L){
  long long N = X.size();
  vector<long long> C(N+1,0);
  for(int i = 1; i <= N; ++i) C[i] = C[i-1] + X[i-1];

  long long ans = max(L-X[0], X[N-1]);
  
  for(long long i = 1; i < N; ++i){
    long long j = N-i, m = min(i, j);
    long long l = L*m - (C[i+m] - C[i]) + C[i-1] - C[i-1-min(j,i-1)];
    ans = max(ans, 2*l + X[i-1]);
    //cerr << 2*l + X[i-1] << endl;
    //ans = max({ans, 2*l - X[i-1], 2*l - L + X[i]});
  }
  return ans;
}

int main(){
  long long N, L;
  cin >> L >> N;
  vector<long long> X(N);
  for(int i = 0; i < N; ++i) cin >> X[i];
  long long ans = solve(X,L);
  for(int i = 0; i < N; ++i) X[i] = L - X[i];
  reverse(X.begin(), X.end());
  ans = max(ans, solve(X,L));
  cout << ans << endl;
}


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

int main(){
  int n; cin>>n;
  vector<pair<int,int>> xy(n);
  for(int i=0; i<n; ++i)cin>>xy[i].first>>xy[i].second;

  double length=0.0;
  for(int i=0; i<n-1; ++i){
    for(int j=i+1; j<n; ++j){
      length+=sqrt(pow(abs(xy[i].first-xy[j].first),2)+pow(abs(xy[i].second-xy[j].second),2));
    }
  }

  int nn=1; for(int i=1; i<=n-1; ++i)nn*=i;

  cout<<setprecision(15)<<1.0*2*nn*length/(nn*n)<<endl;
}

Measured memory_bytes: 256
a = [list(map(int, input().split())) for i in range(3)]

n = int(input())

k = [int(input()) for p in range(n)]
for s in range(3):
    if a[s][0] in k and a[s][1] in k and a[s][2] in k:
        print("Yes")
        exit()

for t in range(3):
    if a[0][t] in k and a[1][t] in k and a[2][t] in k:
        print("Yes")
        exit()

if a[0][0] in k and a[1][1] in k and a[2][2] in k:
    print("Yes")
    exit()

if a[0][2] in k and a[1][1] in k and a[2][0] in k:
    print("Yes")
    exit()

print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>
#include <cmath>
using namespace std;
 
int main(){
  double x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  printf("%f\n",sqrt((y1-y2)*(y1-y2)+(x1-x2)*(x1-x2)));
}



Measured memory_bytes: 3212
N,S1,S2 = open(0).read().split()
N = int(N)
m = 1000000007
if N == 1:
    print(3)
else:
    if S1[0] == S1[1]:
        ans = 6
        count = 2
        state = 'h'
    else:
        ans = 3
        count = 1
        state = 'v'
    while count < N - 1:
        if S1[count] == S1[count+1]:
            if state == 'h':
                ans = (ans*3) % m
            else:
                ans = (ans*2) % m
                state = 'h'
            count += 2
        else:
            if state == 'h':
                state = 'v'
            else:
                ans = (ans*2) % m
            count += 1
    if count == N - 1:
        if state == 'v':
            ans = (ans*2) % m
    print(ans)

Measured memory_bytes: 9140
#include <stdio.h>
#include <string.h>

int main(void)
{
  char s[100001];
  int n;
  int i;
  scanf("%s", s);
  n = strlen(s);
  for ( i=0; i<n; i+=2 ) {
    putchar(s[i]);
  }
  putchar('\n');
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  long a[100000],x,cnt=0;
  scanf("%d %ld",&n,&x);
  scanf("%ld",&a[0]);
  if(a[0]>x){
    cnt+=a[0]-x;
    a[0]=x;
  }
  for(int i=1;i<n;i++){
    scanf("%ld",&a[i]);
    if(a[i]+a[i-1]>x){
      cnt+=a[i]+a[i-1]-x;
      a[i]-=a[i]+a[i-1]-x;
    }
  }
  printf("%ld\n",cnt);
}

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

int a[200005],b[200005];
vector<int> ans;

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",a+i);
	for(int i=n;i>=1;--i) {
		int cnt=0;
		for(int j=2;j<=n/i;++j) cnt+=b[j*i];
		b[i]=(cnt-a[i]+2)%2;
	}
	for(int i=1;i<=n;++i) if(b[i]==1) ans.push_back(i);
	printf("%d\n",int(ans.size()));
	for(int i=0;i<ans.size();++i) printf("%d ",ans[i]);
}

Measured memory_bytes: 3064
import sys
#input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
mod = 10**9+7
H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]
dp = [[0]*W for _ in range(H)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            continue
        if i<H-1:
            dp[i+1][j] += dp[i][j]
            dp[i+1][j]%=mod
        if j<W-1:
            dp[i][j+1] += dp[i][j]
            dp[i][j+1]%=mod
print(dp[-1][-1])







Measured memory_bytes: 51472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps=1e-6;
	ll gcd( ll a, ll b )
	{
		if(b==0)
		{
		     return a;
		}
		else
		{
		     return gcd( b, a%b );
		}
	}
	ll lcm (ll a, ll b)
	{
		return (a*b)/gcd(a,b);
	}

int main() {

    
    int n;
    cn n;
    ll aum=0;
    for (int i = 1; i <=n; ++i)
    {
    	for(int j=1; j<=n ; j++){
    	    for(int k=1; k<=n ; k++){
    	        
    	     aum+=gcd(i,gcd(j,k));   
    	    
    	    }
    	}
    }

    ct aum,nl;




    return 0;
}


Measured memory_bytes: 3620
N=int(input())
chars="Xabcdefghijklmnopqrstuvwxyz"
res=""
n_rem=N
while True:
  x=n_rem%26
  if x==0:
    x=26
  res+=chars[x]
  n_rem-=x
  if n_rem==0:
    break
  n_rem//=26
print(res[::-1])

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

signed main(void)
{
	int d;
	cin >> d;
	d = 25 - d;
	cout << "Christmas";
	rep(i, d)
	{
		cout << " Eve";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    map<vector<int>, ll> mp;
    for(int i=0;i<n;++i) {
        string s;
        vector<int> v(26, 0);
        cin >> s;
        for(int j=0;j<10;++j) {
            ++v[s[j]-'a'];
        }
        ++mp[v];
    }

    ll ans = 0;
    for(auto itr=mp.begin();itr!=mp.end();++itr) {
        ans += (itr->second) * ((itr->second)-1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 19072
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <numeric>    // accumulate
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll a, b, c, d, m = INT64_MIN;
  cin >> a >> b >> c >> d;
  m = max(m, a * c);
  m = max(m, a * d);
  m = max(m, b * c);
  m = max(m, b * d);
  if ((a <= 0 && 0 <= b) || (c <= 0 && 0 <= d)) {
    m = max(m, (ll)0);
  }
  cout << m << endl;
}


Measured memory_bytes: 3192
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main{
	
	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve() {
		FastScanner sc=new FastScanner();
		String S=sc.next();
		String T=sc.next();
		if (S.equals(T.substring(0, S.length()))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
    	return (int)nextLong();
    }
}

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

int main()
{
    //string S = string(100000LL, '>');
    string S;
    cin >> S;
    vector<int> v;
    int renzoku = 1;
    ll ans = 0;
    
    if (S[0] == '>'){
        v.push_back(1);
    }
    for (int i = 1; i < S.size(); i++){
        if (S[i] == S[i - 1]){
            renzoku++;
        } else {
            v.push_back(renzoku);
            renzoku = 1;
        }
    }
    v.push_back(renzoku);
    if (S[S.size() - 1] == '<'){
        v.push_back(1);
    }
    assert (v.size()%2 == 0);
    for (int i = 0; i < v.size(); i += 2){
        ll u = max(v[i], v[i + 1]);
        ll l = min(v[i], v[i + 1]);
        ans +=  u * (u + 1)/2 + l * (l - 1)/2;
    }

    //for (int i = 0; i < v.size(); i++){
    //    cout << i << "," << v[i] << endl;
    //}
    cout << ans << endl;
    return 0;    
}


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

int main() {
  int n;
  string S;
  cin>>n>>S;
  int A[n][n];
  rep(l,0,n){
    A[l][l] = n-l;
    int i = l+1, j = 0;
    while (i < n) {
      while (i+j < n && S[j+l] == S[i+j]) ++j; // 右向きにjを伸ばしていく
      A[l][i] = j;
      if (j == 0) { ++i; continue;}
      int k = 1;
      while (i+k < n && k+A[l][k+l] < j) A[l][i+k] = A[l][k+l], ++k; // i~j間にkを走らせる
      i += k; j -= k;
    }
  }
  int ans=0;
  rep(i,0,n){
    rep(j,i+1,n){
      ans=max(ans,min(A[i][j],j-i));
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 97664
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            while (sc.hasNext()) {
                String[] strs = sc.nextLine().split(" ");
                int a = Integer.parseInt(strs[0]);
                int b = Integer.parseInt(strs[1]);
                int k = Integer.parseInt(strs[2]);
                String r = "";
                int aup = (a+k < b)? a+k - 1 : b;
                int bdw = (b - k + 1 > aup)?b - k + 1 : aup + 1;
                for(int i=a; i<=aup; i++){
                    r += i+"\n";
                }
                for(int i=bdw; i<=b; i++){
                    r += i+"\n";
                }
                System.out.print(r);
            }
        }
    }
}

Measured memory_bytes: 22612
using static System.Console;

public static class Program
{
    public static void Main()
    {
        var N = int.Parse(ReadLine());
        var fArray = new int[N];
        for (int n = 1; n <= N; ++n) {
            //xの探索
            for (int x = 1; n >= x * x; ++x)
            {
                int yMax = n - x * x;
                for (int y = 1; yMax >= (y * y + x * y); ++y)
                {
                    int precaluLated = yMax - y * y - x * y;
                    for (int z = 1; ; ++z)
                    {
                        int right = z * z + x * z + y * z;
                        if (precaluLated <= right) 
                        {
                            if (precaluLated == right) ++fArray[n - 1];
                            else break;
                        }
                    }
                }
            }
        }
        for (int i = 0; i < N; ++i)
            WriteLine(fArray[i]);
    }
}

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

int main() {
    int N, M;
    cin >> N >> M;
    
    vector<int> H(N);
    vector<bool> V(N);
    rep(i,N) {
        cin >> H[i];
        V[i] = true;
    }
    
    rep(i,M) {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        if (H[A] == H[B]) {
            V[B] = false;
            V[A] = false;
        } else if (H[A] > H[B]) {
            V[B] = false;
        } else {
            V[A] = false;
        }
    }
    int sum = 0;
    rep(i,N) {
        if (V[i]) sum++;
    }
    /*
    rep(i,N) {
        cout << V[i] << " ";
    }
    cout << endl;
    */
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3792
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.conv;
import std.typecons;

void main() {
	alias Point = Tuple!(int, "x", int, "y");
	auto ip = readAs!(int[]), W = ip[0], H = ip[1], N = ip[2];
	// 下はダメコード
	/*auto b = new bool[][](H, W);
	b[][] = true;
	b.writeln;
	foreach(_; 0..N) {
		auto ip2 = readAs!(int[]), x = ip2[0], y = ip2[1], a = ip2[2];
		switch(a) {
			case 1:
				b[][0..x] = false;
				break;
			case 2:
				b[][x+1..$] = false;
				break;
			case 3:
				b[0..y][] = false;
				break;
			case 4:
				b[y+1..$][] = false;
				break;
			default: break;
		}
	}
	b.reduce!(a => a.count!true).sum.writeln;*/
	auto p_s = Point(0, 0), p_g = Point(W, H);
	foreach(_; 0..N) {
		auto ip2 = readAs!(int[]), x = ip2[0], y = ip2[1], a = ip2[2];
		switch(a) {
			case 1:
				p_s.x = max(p_s.x, x);
				break;
			case 2:
				p_g.x = min(p_g.x, x);
				break;
			case 3:
				p_s.y = max(p_s.y, y);
				break;
			case 4:
				p_g.y = min(p_g.y, y);
				break;
			default: break;
		}
	}
	//"(%d, %d), (%d, %d)".writefln(p_s.x, p_s.y, p_g.x, p_g.y);
	//max((p_g.x - p_s.x) * (p_g.y - p_s.y), 0).writeln;
	auto width = max(p_g.x - p_s.x, 0);
	auto height = max(p_g.y - p_s.y, 0);
	(width * height).writeln;
}

// ===================================

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (isBasicType!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

int ri() {
	return readAs!int;
}

string rs() {
	return readln.chomp;
}

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

typedef long long ll;

int MOD=1000000007;


int main(){
    ll N,ans=0;
    string S;
    cin >> N >> S;
    for(ll i=0; i<N-1; i++){
        if(S[i]!=S[i+1]) ans++;
    }
    cout << ans+1 << endl;
}



Measured memory_bytes: 512
import Control.Monad
import Data.List
import Data.Map (Map,(!))
import qualified Data.Map as M
import qualified Data.Set as S

type Sushi = (Int,Integer)
type EatMap = Map Int [Integer]

main = do
  [n,k] <- map read.words <$> getLine :: IO [Int]
  sushi <- replicateM n $ (\[a,b]->(a,fromIntegral b)).(map read.words) <$> getLine :: IO [Sushi]
  print $ solve n k $ sortBy (\(_,a) (_,b) -> compare b a) sushi

solve :: Int -> Int -> [Sushi] -> Integer
solve n k sushi = maximum $ go change eatMap howTake x ds S.empty
  where
  (eat,remain) = splitAt k sushi
  change = filter (\(t,_) -> M.notMember t eatMap') remain
  eatMap = M.filter (not.null.tail) eatMap'
  eatMap' = M.filter (not.null) eatMap''
  ds = sum $ map snd eat
  (eatMap'',howTake,x) = foldl f (zeroMap,[],0) eat
  zeroMap = M.fromDistinctAscList $ zip [1..n] $ repeat []
  f :: (EatMap, [Int],Integer) -> Sushi -> (EatMap, [Int],Integer)
  f (map,hows,x) (t,d)
    | null (map!t) = (M.adjust (d:) t map, hows, x+1)
    | otherwise  = (M.adjust (d:) t map, t:hows, x)
  go :: [Sushi] -> EatMap -> [Int] -> Integer -> Integer -> S.Set Int -> [Integer]
  go [] _ _ x ds _ = [score ds x]
  go _ _ [] x ds _ = [score ds x]
  go ((t,d):rs) eatMap (h:hs) x ds set
    | S.notMember t set = score ds x : go rs (M.adjust (d:) t $ M.adjust tail h eatMap) hs (x+1) (ds-head(eatMap!h)+d) (S.insert t set)
    | otherwise = go rs eatMap (h:hs) x ds set
  score :: Integer -> Integer -> Integer
  score ds x = ds + x*x

Measured memory_bytes: 117884
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long w = in.nextLong();
        long h = in.nextLong();
        long x = in.nextLong();
        long y = in.nextLong();
        double s = w /2.0 * h;
        int hasMany = (x*2==w && y*2==h) ? 1 : 0;
        System.out.print(s);
        System.out.print(" ");
        System.out.print(hasMany);
    }
}


Measured memory_bytes: 23764