akhauriyash/Code-Regression huggingface dataset:
n = int(input())
s = input()

r = s.count('R')
g = s.count('G')
b = s.count('B')

ans = r*g*b

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2*j - i
        if k < n:
            if s[i] == s[j]:
                continue
            if s[j] == s[k]:
                continue
            if s[k] == s[i]:
                continue
            ans -= 1
print(ans)

Measured memory_bytes: 9196
import sys
X,N = map(int,input().split())
zettai = 10000
ans = 0
if N == 0:
    print(X)
    sys.exit()
    
a = list(map(int,input().split()))



for i in range(102,-1,-1):
    b = abs(X-i)
    if i in a:
        continue
    elif b <= zettai:
        zettai = b
        ans = i

print(ans)


Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
typedef long long ll;
using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;

    while(a <= b){
        ans++;
        b -= a;
        if(ans == c) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << 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;
}
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int_least64_t n, m;
vector<double> a;
priority_queue<double> que;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        double temp;
        cin >> temp;
        a.push_back(temp);
        que.push(temp);
    }
    for (int i = 0; i < m; i++)
    {
        if (que.empty())
        {
            return cout << 0 << "\n", 0;
        }
        double temp = que.top();
        que.pop();
        temp /= 2;
        que.push(temp);
    }
    ll ans = 0;
    while (!que.empty())
    {
        ans += ll(que.top());
        que.pop();
    }
    cout << ans << "\n";
}


Measured memory_bytes: 2036
module SqIntMap = Map.Make (struct
  type t = int * int
  let compare = compare
end)

module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let () =
  let h, w, n = Scanf.scanf "%d %d %d\n" (fun h w n -> h, w, n) in
  let abs = Array.init n (fun _ -> Scanf.scanf "%d %d\n" (fun a b -> a, b)) in
  let dxdys = List.concat @@ Array.to_list @@ Array.init 3 (fun i -> Array.to_list @@ Array.init 3 (fun j -> (i - 2, j - 2))) in
  Array.fold_left (fun m (a, b) ->
    List.fold_left (fun m (dx, dy) ->
      if 1 <= a + dy && a + dy <= h - 2 && 1 <= b + dx && b + dx <= w - 2 then
        SqIntMap.add (a + dy, b + dx) (1 + try SqIntMap.find (a + dy, b + dx) m with Not_found -> 0) m
      else m) m dxdys) SqIntMap.empty abs
  |> (fun m -> SqIntMap.fold (fun _ i m -> IntMap.add i (1 + try IntMap.find i m with Not_found -> 0) m) m IntMap.empty)
  |> (fun m ->
      Array.init 10 (function
        | 0 -> (h - 2) * (w - 2) - IntMap.fold (fun _ -> ( + )) m 0
        | n -> try IntMap.find n m with Not_found -> 0))
  |> Array.iter (Printf.printf "%d\n")

Measured memory_bytes: 99960
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

string split(string s,int start,int goal){
	string t="";
	for(int i=start;i<goal;i++){
		t+=s[i];
	}
	return t;
}

int main(){
	int n;
	string s,t,v;
	cin >> n >> s;
	vector<int> pos_spl(n-1,0);
	vector<bool> chk_alp(26,0);
	
	for(int i=1;i<n;i++){
		for(int i=0;i<26;i++)chk_alp[i]=0;
		t=split(s,0,i);
		v=split(s,i,n);
		for(int j=0;j<t.size();j++){
			if(chk_alp[t[j]-'a']!=1){
				for(int k=0;k<v.size();k++){
					if(t[j]==v[k]){
						pos_spl[i-1]++;
						break;
					}
				}
			}
			chk_alp[t[j]-'a']=1;
		}
	}
	sort(pos_spl.begin(),pos_spl.end());
	cout << pos_spl.back() << endl;
	return 0;
}


Measured memory_bytes: 256
const MOD: u32 = 1000000007;

fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();

	let ans = s.trim().bytes().fold((1, 0, 0, 0), |s, ch|{
		let mut next = s;
		match ch {
			b'A' => {
				next.1 = (s.1 + s.0) % MOD;
			}
			b'B' => {
				next.2 = (s.2 + s.1) % MOD;
			}
			b'C' => {
				next.3 = (s.3 + s.2) % MOD;
			}
			_ => {
				next.0 = s.0 * 3 % MOD;
				next.1 = (3 * s.1 + s.0) % MOD;
				next.2 = (3 * s.2 + s.1) % MOD;
				next.3 = (3 * s.3 + s.2) % MOD;
			}
		}
		next
	}).3;
	println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp=boost::multiprecision;
using namespace std;
typedef int _int;
typedef long long ll;
#define int mp::cpp_int
ll mod = 1000000007;
void COME_LET_THE_GAMES_BEGIN(){cout << setprecision(20);}
void vin(vector<ll>*a,int N){for (; N; N--){ll x;cin >> x;(*a).push_back(x);}}
void vin(vector<tuple<ll, ll, ll>>*a,int N){for(;N;N--){tuple<ll, ll, ll>x;cin>>get<0>(x)>>get<1>(x)>>get<2>(x);(*a).push_back(x);}}
void output(bool f){if(f){puts("Yes");}else{puts("No");}}
void output(ll a){printf("%lld\n", a);}
ll N, C, K;
vector<ll> T;
void input() {
    cin >> N >> C >> K;
    vin(&T, N);
}
ll solve() {
    sort(T.begin(), T.end());
    ll a = 0, t = 0;
    ll res = 0;
    for (ll i = 0; i < N; i++) {
        if (t < T[i]) {
            a = 0;
        }
        if (a == 0) {
            a = C-1;
            res++;
            t = T[i]+K;
        }
        else {
            a--;
        }
    }
    return res;
}
_int main () {
    COME_LET_THE_GAMES_BEGIN();
    input();
    output(solve());
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
	ll n;cin>>n;
	ll res = 0;
	repp(i,1,n+1,2){
		ll cnt = 0;
		rep(j,1,i+1)
			if(i % j == 0)
				cnt++;
		if(cnt == 8)
			res++;
	}
	cout << res << ednl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n;
  int i=0;
  int a;
  int min=1000000;
  int max=-1000000;
  long long int sum=0;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(min>a) min=a;
    if(max<a) max=a;
    sum=sum+a;
  }

  printf("%d %d %lld\n", min, max, sum);
  return 0;
}

Measured memory_bytes: 600
n,q=list(map(int,input().split()))
GR=[[] for _ in range(n)]
for i in range(n-1):
  a,b=list(map(int,input().split()))
  GR[a-1].append(b)
  GR[b-1].append(a)
 
ans=[0 for _ in range(n)]
for i in range(q):
  p,x=list(map(int,input().split()))
  ans[p-1] += x
  
gr=[1]
parent=[0 for _ in range(n)]
while gr:
  po=gr.pop()
  for no in GR[po-1]:
    if no == parent[po-1]:
      continue
    gr.append(no)
    parent[no-1]=po
    ans[no-1] += ans[po-1]
      
print(' '.join(map(str,ans)))

Measured memory_bytes: 74852
#include <stdio.h>

int main(void)
{
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if((a + b) % 2 == 0){
		printf("%d", (a + b) / 2);
	}
	else{
		printf("IMPOSSIBLE");
	}
	
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int a = sc.nextInt();
		int count = 0;
		while(h > 0) {
			h -= a;
			count++;
		}
		System.out.println(count);
		sc.close();
	}
}

Measured memory_bytes: 23892
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int L;
  cin>>L;
  int r=0,tmp=1;
  while(2*tmp<=L){
    tmp*=2;r++;
  }
  vector<tuple<int,int,int>> ans;
  REP(i,r){
    ans.emplace_back(i+1,i+2,1<<i);
    ans.emplace_back(i+1,i+2,0);
  }

  for(int i=r;i>=1;i--){
    if(L-(1<<(i-1))>=(1<<r)){
      ans.emplace_back(i,r+1,L-(1<<(i-1)));
      L-=(1<<(i-1));
    }
  }

  cout<<r+1<<' '<<ans.size()<<endl;
  for(auto e:ans){
    cout<<get<0>(e)<<' '<<get<1>(e)<<' '<<get<2>(e)<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll d,t,s;
    while(cin>>d>>t>>s){
        bool ok = (d<=t*s);
        cout<<(ok ? "Yes\n" : "No\n");
    }
    return 0;
}

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

int main(){
    int n;
    string s1, s2;
    int a = 0, b = 0;
    cin >> n;
    
    for ( int i = 0; i < n; i++ ){
        cin >> s1 >> s2;
        if ( s1 > s2) a+=3;
        else if ( s1 < s2 ) b+=3;
        else {
            a++; b++;
        }
    }
    
    cout << a << " " << b << endl;
    
    return 0;
}


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

int main(){
  int N, L;
  cin >> N >> L;
  int pie=0;
  for(int i=0; i<N; i++){
    pie += L + i;
  }
  int ans;
  if(L<=0 && 0<L+N) ans = pie;
  else if(0<L) ans = pie - L;
  else ans = pie - (L+N-1);
  cout << ans << endl;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll x,y,a=100000,ans=0; cin>>x>>y;
    if(3>=x) ans+=a*(4-x);
    if(3>=y) ans+=a*(4-y);
    if(x==1&&y==1) ans+=a*4;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
package main

import "fmt"

func main() {
	var h, w, a, b int
	fmt.Scan(&h, &w, &a, &b)

	comInit()

	ans := 0
	for i := b; i < w; i++ {
		c := com(i+h-a-1, i) * com(a-1+w-i-1, a-1) % mod
		ans = (ans + c) % mod
	}

	fmt.Println(ans)
}

// https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#5-二項係数-ncr

const max int = 1e6
const mod int = 1e9 + 7

var fac [max]int
var finv [max]int
var inv [max]int

// テーブルを作る前処理
func comInit() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for i := 2; i < max; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

// 二項係数計算
func com(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod
}


Measured memory_bytes: 23936
//2015/7/
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

bool che[50][50][50][50];

struct Person{ int x, y; };

struct Twin{ Person T, K; int cnt; };

bool isOK(Twin t){
	if (t.T.x == t.K.x && t.T.y == t.K.y){
		return true;
	}
	return false;
}

void initCheck(Twin t){
	for (int a = 0; a < 50; a++){
		for (int b = 0; b < 50; b++){
			for (int c = 0; c < 50; c++){
				for (int d = 0; d < 50; d++){
					che[a][b][c][d] = false;
				}
			}
		}
	}
	che[t.T.x - 1][t.T.y - 1][t.K.x - 1][t.K.y - 1] = true;
}

bool Check(Twin t){
	if (che[t.T.x - 1][t.T.y - 1][t.K.x - 1][t.K.y - 1]){
		return false;
	}
	che[t.T.x - 1][t.T.y - 1][t.K.x - 1][t.K.y - 1] = true;
	return true;
}

int main(){
	int x,y,d[52][52];
	Twin tw;
	while (cin >> x >> y){
		if (x == 0 && y == 0){
			break;
		}

		cin >> tw.T.x >> tw.T.y >> tw.K.x >> tw.K.y;

		tw.cnt = 0;
		for (int i = 0; i < y + 2; i++){
			for (int j = 0; j < x + 2; j++){
				d[j][i] = 1;
			}
		}

		for (int i = 1; i <= y; i++){
			for (int j = 1; j <= x; j++){
				cin >> d[j][i];
			}
		}

		queue<Twin> que;
		que.push(tw);

		initCheck(tw);

		while (1){
			if (que.empty()){
				cout << "NA\n";
				break;
			}
			Twin T = que.front();
			que.pop();

			if (T.cnt >= 100){
				cout << "NA\n";
				break;
			}
			if (isOK(T)){
				cout << T.cnt << endl;
				break;
			}
			T.cnt += 1;
			/*for (int i = 0; i < y + 2; i++){
				for (int j = 0; j < x + 2; j++){
					if (j == T.T.x && i == T.T.y){
						cout << "T";
					}
					else if (j == T.K.x&&i == T.K.y){
						cout << "K";
					}
					else
						cout << d[j][i];
				}
				cout << endl;
			}*/

			//T??????,K??????
			Twin tmp = T;
			if (d[tmp.T.x][tmp.T.y - 1] == 0)
			{
				tmp.T.y -= 1;
			}
			if (d[tmp.K.x][tmp.K.y + 1] == 0){
				tmp.K.y += 1;
			}
			if (Check(tmp)){
				que.push(tmp);
			}

			//T??????,K??????
			tmp = T;
			if (d[tmp.T.x][tmp.T.y + 1] == 0)
			{
				tmp.T.y += 1;
			}
			if (d[tmp.K.x][tmp.K.y - 1] == 0){
				tmp.K.y -= 1;
			}
			if (Check(tmp)){
				que.push(tmp);
			}

			//T??±???,K?\????
			tmp = T;
			if (d[tmp.T.x + 1][tmp.T.y] == 0)
			{
				tmp.T.x += 1;
			}
			if (d[tmp.K.x - 1][tmp.K.y] == 0){
				tmp.K.x -= 1;
			}
			if (Check(tmp)){
				que.push(tmp);
			}

			//T?\????,K??±???
			tmp = T;
			if (d[tmp.T.x - 1][tmp.T.y] == 0)
			{
				tmp.T.x -= 1;
			}
			if (d[tmp.K.x + 1][tmp.K.y] == 0){
				tmp.K.x += 1;
			}
			if (Check(tmp)){
				que.push(tmp);
			}

		}
	}
	return 0;
}


Measured memory_bytes: 7640
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }

const int MOD = 1000000007;

int H, W;
vector<string> S;

int main() {
    cin >> H >> W;
    S.resize(H);
    rep(i, H) cin >> S[i];

    vector<vector<int>> L(H);
    vector<vector<int>> R(H);
    vector<vector<int>> U(H);
    vector<vector<int>> D(H);

    rep(i, H) {
        L[i].resize(W);
        R[i].resize(W);
        U[i].resize(W);
        D[i].resize(W);
    }

    rep(j, H) {
        rep(i, W) {
            L[j][i] = 0;
            R[j][i] = 0;
            U[j][i] = 0;
            D[j][i] = 0;
        }
    }

    for (int j = 0; j < H; j++) {
        for (int i = 0; i < W; i++) {
            if (S[j][i] == '#') {
                L[j][i] = 0;
            }
            else {
                if (i == 0) {
                    L[j][i] = 1;
                }
                else {
                    L[j][i] = L[j][i-1] + 1;
                }
            }
        }

        for (int i = W-1; i >= 0; i--) {
            if (S[j][i] == '#') {
                R[j][i] = 0;
            }
            else {
                if (i == W-1) {
                    R[j][i] = 1;
                }
                else {
                    R[j][i] = R[j][i+1] + 1;
                }
            }
        }
    }

    for (int i = 0; i < W; i++) {
        for (int j = 0; j < H; j++) {
            if (S[j][i] == '#') {
                U[j][i] = 0;
            }
            else {
                if (j == 0) {
                    U[j][i] = 1;
                }
                else {
                    U[j][i] = U[j-1][i] + 1;
                }
            }
        }

        for (int j = H-1; j >= 0; j--) {
            if (S[j][i] == '#') {
                D[j][i] = 0;
            }
            else {
                if (j == H-1) {
                    D[j][i] = 1;
                }
                else {
                    D[j][i] = D[j+1][i] + 1;
                }
            }
        }
    }

    int res = 0;
    rep(j, H) {
        rep(i, W) {
            if (S[j][i] == '.') {
                res = max(res, L[j][i] + U[j][i] + R[j][i] + D[j][i] - 3);
            }
        }
    }

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


Measured memory_bytes: 67200
#include <stdio.h>
#include<stdlib.h>

void maxHeapify(int*,int);
int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
     return 2*i+1;
     }
int H;
int main(){
int A[500000];

  int i,j,k;
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  for(i=H/2;i>=1;i--){
    maxHeapify(A,i);
  }
for(i=1;i<H;i++){
    printf(" %d",A[i]);
  }
 printf(" %d\n",A[H]);
 return 0;
}

void maxHeapify(int *A,int i){
  int largest,l,arr,r;
    l=left(i);
  r=right(i);
  if(l<=H && A[l]>A[i]){
    largest=l;
  }
  else
    largest=i;
  if(r<=H && A[r]>A[largest])
    largest=r;

  if(largest!=i){
    arr=A[i];
    A[i]=A[largest];
    A[largest]=arr;
    maxHeapify(A,largest);
  }
}

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

int main(){
    int n;
    cin >> n;
    vector<vector<int> > G(n, vector<int>(n, 0));

    for (int y = 0; y < n; y++) {
        int num, k;
        cin >> num >> k;
        for (int i = 0; i < k; i++) {
            int x;
            cin >> x;
            x--;
            G[x][y] = 1;
        }
    }

    for (int y = 0; y < n; y++) {
        cout << G[0][y];
        for (int x = 1; x < n; x++) {
            cout << " " << G[x][y];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3144
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
inline int read()
{
	int sum=0,p=1;char ch=getchar();
	while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
	if(ch=='-')p=-1,ch=getchar();
	while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
	return sum*p;
}

ll p[19];

int a[20];
inline double calc()
{
	int s=0;ll x=0,ten=1;
	REP(i,0,15)s+=a[i],x+=ten*a[i],ten*=10;
	return (double)x/s;
}


inline void out()
{
	int x=17;
	while(!a[x])x--;
	DREP(i,x,0)printf("%d",a[i]);puts("");
}

int main()
{
#ifndef ONLINE_JUDGE
#endif
	int k=read();
	a[0]=1;p[0]=1;
	REP(i,1,17)p[i]=p[i-1]*10;
	while(k--)
	{
		double y=calc();
		int x=0;
		REP(i,0,17)if(p[i]>=y){x=i;break;}
		REP(i,0,x-1)a[i]=9;
		while(calc()>=(double)p[x]+1e-10 && a[x]<=9)
			a[x]++;
		out();
		if(a[x]<9)a[x]++;
		else {
			a[x+1]++,a[x]=0;
			if(a[x+1]==10)a[x+1]=0,a[x+2]++;
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i, sz(v)) { if (i) os << " "; os << v[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a - mod; }

void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
      solve();
    }
}


string s, t;

bool check(int x) {
    cin >> t;
    if (t[0] == 'V') exit(0);

    if (x % 2 == 0 && t[0] != s[0]) return 0; // debuged, 'F' to s[0]
    if (x % 2 && t[0] == s[0]) return 0;

    return 1;
}

template<typename T>
void binary_search(T ok, T ng) {
    while (abs(ng - ok) > 1) {
        T mid = (ng + ok) / 2;
        cout << mid << endl;
        (check(mid) ? ok : ng) = mid;
    }
}

void solve() {
  int n;
  cin >> n;
  if (n <= 20) {
    rep(i, n) {
      cout << i << endl;
      string s;
      cin >> s;
      if (s[0] == 'V') return;
    }
  }

  cout << 0 << endl;
  cin >> s;
  if (s[0] == 'V') return;

  binary_search(0, n);
}


Measured memory_bytes: 852
#include<stdio.h>

int main(){
    int n,b,f,r,v,i,j,k;
    int data[4][3][10];

    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                data[i][j][k]=0;
            }
        }
    }

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        data[b-1][f-1][r-1]+=v;
    }

    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",data[i][j][k]);
            }if(j!=2)printf("\n");
        }if(i!=3)printf("\n####################\n");
    }
printf("\n");
return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <string>
using namespace std;
int main(){
  string str;
  getline(cin,str);

  for(int i = 0 ; i < str.size() ; i++){
    string a = "apple",p = "peach";
    int f = 1;
    if(str[i] == a[0]){
      for(int c = 0;c < 5; c++){
	if(a[c] != str[i + c])f = 0;
      }
      if(f)str.replace(i,5,"peach");
    }else if(str[i] == p[0]){
      for(int c = 0;c < 5; c++){
	if(p[c] != str[i + c])f = 0;
      }
      if(f)str.replace(i,5,"apple");
    }
}
  cout << str << endl;
}

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

using namespace std;
typedef long long ll;

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if (U == S) --A;
  else --B;
  cout << A << " " << B << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int n;
int h[maxn], nxt[maxn];
int is_zero[maxn];
int neg[maxn];
std::vector<int> edge[maxn];
inline void link(int f,int x) {
	nxt[x] = h[f], h[f] = x;
}
std::stack<int> stack;
inline void dfs(int x) {
	int neg = 0;
	for(int i = h[x];i;i = nxt[i]) {
		dfs(i);
		neg ^= 1;
	}
	if(neg ^ 1) {
		stack.push(x);
	} else {
		is_zero[x] = 1;
	}
	for(;stack.size() > 1;) {
		int x = stack.top(); stack.pop();
		int y = stack.top(); stack.pop();
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
}
inline void wwj() {
	rep(i, 1, n) h[i] = nxt[i] = 0;
	int root = -1;
	for(int i = 1, f;i <= n;++i) {
		cin >> f;
		if(f == -1) root = i;
		else link(f, i);
	}
	stack = std::stack<int>();
	dfs(root);
	if(stack.size()) {
		edge[stack.top()].emplace_back();
	}
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	wwj(), wwj();
	rep(i, 1, n) {
		if(is_zero[i] && edge[i].size()) {
			cout << "IMPOSSIBLE" << '\n';
			return 0;
		}
	}
	rep(i, 1, n) {
		if(!is_zero[i] && !neg[i]) {
			std::queue<int> q; q.push(i); neg[i] = 1;
			for(;!q.empty();) {
				int x = q.front(); q.pop();
				for(int i : edge[x]) if(!neg[i] && !is_zero[i]) {
					neg[i] = - neg[x];
					q.push(i);
				} else {
					std::cerr << neg[i] << ' ' << neg[x] << '\n';
				}
			}
		}
	}
	cout << "POSSIBLE" << '\n';
	rep(i, 1, n) {
		if(is_zero[i]) {
			cout << 0 << " \n"[i == n];
		} else {
			cout << neg[i] << " \n"[i == n];
		}
	}
}


Measured memory_bytes: 11264
#include <bits/stdc++.h> 
using namespace std;
 
typedef signed long long ll;
const int MX = 1e6 + 5;

string to_s(int n) {
	stringstream ss;
	ss << n;
	return ss.str();
}

int main() {
	vector<string> p;
	int n, num, arr[10];
	string A = "", B = "";
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> num;
		A.push_back(to_s(num)[0]);
	}
	for(int i = 0; i < n; i++) {
		cin >> num;
		B.push_back(to_s(num)[0]);
	}

	for(int i = 0; i < n; i++) {
		arr[i] = i + 1;
	}

	do {
		string C = "";
		for(int i = 0; i < n; i++) {
			C.push_back(to_s(arr[i])[0]);
		}
		p.push_back(C);
	} while (next_permutation(arr, arr + n));

	int a = lower_bound(p.begin(), p.end(), A) - p.begin();
	int b = lower_bound(p.begin(), p.end(), B) - p.begin();

	cout << abs(a - b) << endl;

    return 0;
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int dp[100005][3];

int main(){
    int n;
    cin >> n;
    
    ll ans = 1;
    rep(i, n){
        int a;
        cin >> a;
        int cnt = 0;
        rep(j, 3){
            if(dp[i+1][j]==a){
                cnt++;
            }
        }
        rep(j, 3){
            if(dp[i+1][j]==a){
                dp[i+1][j]++;
                break;
            }
        }
        rep(j, 3){
            dp[i+2][j] = dp[i+1][j];
        }
        ans *= cnt;
        ans %= MOD;
    }

    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 1408
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,m = readline() |> split |> parseMap
	a = -ones(Int,n)
	f = 0
	if m==0&&n==1
		println(0)
	else
	for i in 1:m
		s,c = readline() |> split |> parseMap
		if a[s]==-1
			a[s] = c
		elseif a[s]!=c
			f = 1
		end
	end
	if f == 1 || (n>1&&a[1]==0)
		println(-1)
	else
		if a[1]==-1
			print(1)
		else
			print(a[1])
		end
		for i in 2:n
			if a[i]==-1
				print(0)
			else
				print(a[i])
			end
		end
		println("")
	end
end
end

main()

Measured memory_bytes: 166544
n,a,b,c=map(int,input().split())
tree=[a,b,c]
ls=[int(input()) for _ in range(n)]
ans=10000
for i in range(4**n):
    group=[[] for _ in range(4)]
    for j in range(n):
        k,i=i%4,i//4
        group[k].append(ls[j])
    buf=0
    for l in range(3):
        group_len=len(group[l])
        if group_len==0:
            buf=10000
            break
        buf+=(group_len-1)*10+abs(sum(group[l])-tree[l])
    ans=min(ans,buf)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>


using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;


void MakeDFSTree(int cur, int pre, vector<bool> &used, vector<vector<pair<int, int>>>& tree, vector<vector<pair<int, int>>>& g) {
	used[cur] = true;
	for (auto nxt : g[cur]) {
		if (nxt.first == pre) continue;
		if (used[nxt.first]) continue;
		tree[cur].emplace_back(nxt);
		tree[nxt.first].emplace_back(cur, nxt.second);
		MakeDFSTree(nxt.first, cur, used, tree, g);
	}
}
int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, m; cin >> n >> m;
	vector<pair<int, int>> vp(n); for (int i = 0; i < n; i++) cin >> vp[i].first >> vp[i].second;
	sort(vp.begin(), vp.end());
	vector<int> l(m), r(m);
	for (int i = 0; i < m; i++) {
		cin >> l[i] >> r[i];
		l[i] = lower_bound(vp.begin(), vp.end(), make_pair(l[i], -inf)) - vp.begin();
		r[i] = upper_bound(vp.begin(), vp.end(), make_pair(r[i], inf)) - vp.begin();
	}
	vector<int> sub(n + 1);
	for (int i = 0; i <= n; i++) {
		if (i == 0) sub[i] = vp[i].second;
		else if (i == n) sub[i] = vp[i - 1].second;
		else sub[i] = vp[i - 1].second ^ vp[i].second;
	}

	vector<vector<pair<int, int>>> g(n + 1);
	for (int i = 0; i < m; i++) {
		g[l[i]].emplace_back(r[i], i);
		g[r[i]].emplace_back(l[i], i);
	}
	/*
	{
		vector<vector<pair<int, int>>> tree(n + 1);
		vector<bool> used(n + 1);
		for (int i = 0; i <= n; i++) {
			if (used[i]) continue;
			MakeDFSTree(0, -1, used, tree, g);
		}
		g = move(tree);
	}
	*/
	vector<bool> used(n + 1);
	vector<int> res;
	
	auto dfs = [&](auto &&f, int cur, int pre)->void {
		used[cur] = true;
		for (auto nxt : g[cur]) {
			if (nxt.first == pre) continue;
			if (used[nxt.first]) continue;
			f(f, nxt.first, cur);
			if (sub[nxt.first]) {
				sub[cur] ^= 1;
				sub[nxt.first] ^= 1;
				res.emplace_back(nxt.second);
			}
		}
	};
	
	for (int i = 0; i <= n; i++) {
		if (used[i]) continue;
		dfs(dfs, i, -1);
		if (sub[i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (int i = 0; i <= n; i++) if (sub[i]) {
		cout << -1 << endl;
		return 0;
	}
	sort(res.begin(), res.end());
	cout << res.size() << "\n";
	for (int i = 0; i < res.size(); i++) cout << res[i] + 1 << " \n"[i + 1 == res.size()];
	return 0;
}


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

N = int(input())
b = list(map(int, input().split()))
ans = []

for _ in range(N):
    for i in range(len(b)-1, -1, -1):
        if b[i]==i+1:
            ans.append(b[i])
            b = [b[j] for j in range(len(b)) if j!=i]
            break
    else:
        print(-1)
        exit()

ans.reverse()

for ans_i in ans:
    print(ans_i)

Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  float sum=0;
  ll i,n;
  cin>>n;
  ll a[n];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
    sum+=a[i];
  }
  float x=sum/n;
  //cout<<x<<endl;
  float num=floor(x);
  float num2=ceil(x);
  //cout<<num<<" "<<num2<<endl;
  ll sum1=0,sum2=0;
  for(i=0;i<n;i++)
  {
    sum1+=(a[i]-num)*(a[i]-num);
    sum2+=(a[i]-num2)*(a[i]-num2);
  }
  cout<<min(sum1,sum2);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <string.h>
using namespace std;

int main()
{
    int a[5] = {}, c, d;
    int one = 0, two = 0;
    for (int i = 0; i < 3; i++)
    {
        cin >> d >> c;
        a[d]++;
        a[c]++;
    }
    for (int i = 1; i <= 4; i++)
    {
        if (a[i] == 1)
            one++;
        else if (a[i] == 2)
            two++;
    }
    if (one == 2 && two == 2)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

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

    bool a[n] = {}, b[n] = {};

    rep(i, m)
    {
        int to, from;
        cin >> to >> from;
        to--, from--;
        if (to == 0)
            a[from] = 1;
        if (from == n - 1)
            b[to] = 1;
    }

    rep(i, n)
    {
        if (a[i] == 1 && b[i] == 1)
        {
            OP("POSSIBLE");
            return 0;
        }
    }

    OP("IMPOSSIBLE");

    return 0;
}

/*vector<int> g[200000];

int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int flag = 0;
    rep(i, g[0].size())
    {
        int v = g[0][i];
        if (find(ALL(g[v]), n - 1) != g[v].end())
            flag = 1;
    }
    flag == 1 ? OP("POSSIBLE") : OP("IMPOSSIBLE");

    return 0;
}*/


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

int main(){
  ll n, s;
  cin >> n >> s;
  ll a[n];
  rep(i,n) cin >> a[i];
  ll ans = 0;
  vector<vector<ll>> dp(n+1,vector<ll>(s+1,0));
  rep(i,n) {
    rep(j,s+1) {
      dp[i+1][j] += dp[i][j];
      if(j == 0 && a[i] <= s) {
        (dp[i+1][a[i]] += i+1) %= mod;
      } else {
        if(j-a[i] >= 0) (dp[i+1][j] += dp[i][j-a[i]]) %= mod;
      }
    }
    (ans += dp[i+1][s]) %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 70784
import java.util.Scanner;
public class Main{
    static class song{
        public  song(long a, long b){
            this.a = a;
            this.b = b;
        }
       long a;
        long b;

    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double w = sc.nextDouble();
        double h = sc.nextDouble();
        double x = sc.nextDouble();
        double y = sc.nextDouble();
        int lines = 0;
        if(h/2==y && w/2==x){
            lines=1;
        }
        double res = (w * h)/2;
        System.out.println(res+" "+lines);
        }


//        int i = 0;
//        while(true){
//            if(sc.hasNextLine()!=true){
//                sc.close();
//                break;
//            }
//            String str = sc.nextLine();
//            i++;
//            System.out.println(i+" "+str);
//        }
    }



Measured memory_bytes: 25172
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;

int main() {
	int n; 
	cin >> n;
	string ans;
	if (n < 1000) {
		ans = "ABC";
	}
	else {
		ans = "ABD";
	}
	cout << ans << endl;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as C
import Data.List
import qualified Data.IntSet as IS

main :: IO ()
main = do
    n <- readLn
    as <- U.map (`div` 400) <$> U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine
    let normal = U.filter (<8) as
    let free = n - (U.length normal)
    let rest = IS.size $ IS.fromList $ U.toList normal
    putStrLn $
        show (max 1 rest)
        ++ " "
        ++ (show $ rest+free)


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define ll long long int
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool compareInterval(pair<ll,ll> a, pair<ll,ll> b) 
{ 
    return (a.first < b.first); 
} 
int main() {
    fast();
    ll n;
    cin>>n;
    vector<pair<ll,ll>> vec;
    for(ll i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        vec.push_back(make_pair(x,i+1));
    }
    sort(vec.begin(),vec.end(),compareInterval);
    for(ll i=0;i<n;i++)
    {
        cout<<vec[i].second<<" ";
    }
    
}

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

int main(void){
    int n=0;
    int a,b,c = 0;
    std::cin>>n;
    if(0!=n){
        while(cin>>a>>b>>c){
            if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a){
                printf("YES\n");
            }
            else{
                printf("NO\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3028
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repe(i, n) for(int i = 0; i <= (n); i++)
#define fo(i, a, b) for(int i = (a); i < (b); i++)
#define foe(i, a, b) for(int i = (a); i <= (b); i++)
#define NL << endl

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;

int main() {
	int n, a, b;

	cin >> n;
	if (n == 1) {
		cout << "Hello World" NL;
	} else {
		cin >> a >> b;
		cout << a + b NL;
	}


	return 0;

}



Measured memory_bytes: 256
unittest
{
	assert( [ "5", "MASHIKE", "RUMOI", "OBIRA", "HABORO", "HOROKANAI" ].parse.expand.solve == 2 );
	assert( [ "4", "ZZ", "ZZZ", "Z", "ZZZZZZZZZZ" ].parse.expand.solve == 0 );
	assert( [ "5", "CHOKUDAI", "RNG", "MAKOTO", "AOKI", "RINGO" ].parse.expand.solve == 7 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	auto ss = new string[ n ];
	foreach( ref s; ss )
	{
		input.popFront;
		s = input.front.strip;
	}
	return tuple( ss );
}

auto solve( string[] ss )
{
	// 各頭文字ごとにカウント
	auto cs = new long[ 5 ];
	foreach( i, u; "MARCH" )
	{
		cs[ i ] = ss.count!( ( a, b ) => a[0] == b )( u );
	}
	
	// 0件の頭文字は削除
	cs = cs.filter!( ( a ) => 0 < a ).array;
	if( cs.length < 3 ) return 0;
	
	// 組み合わせを計算
	auto t = 0L;
	for( auto a = 0; a < cs.length - 2; a++ )
	{
		for( auto b = a + 1; b < cs.length - 1; b++ )
		{
			for( auto c = b + 1; c < cs.length; c++ )
			{
				t += cs[ a ] * cs[ b ] * cs[ c ];
			}
		}
	}
	
	return t;
}


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

int pipe[65005];
long long joint[65005];
long long pay[65005];

int cmpnum(const void *a, const void *b)
{
    return *(long long *)b - *(long long *)a;
}

int main(void)
{
    int n, m;
    int i, j;
    long long pipe_total_len;
    long long joint_total_len;
    long long patch_total_len;
    long long pipe_pay;
    long long patch_pay;

    while (1) {
        scanf("%d", &n);
        if (n == 0) {
            break;
        }

        memset(pipe, 0, sizeof(pipe));
        memset(joint, 0, sizeof(joint));
        memset(pay, 0, sizeof(pay));

        pipe_total_len = 0;
        for (i = 0; i < n; i++) {
            scanf("%d", &pipe[i]);
            pipe_total_len += pipe[i];
        }
        pay[0] = pipe_total_len * n;    /* パイプだけの最大の給料 */
        for (i = 0; i < n - 1; i++) {
            scanf("%lld", &joint[i]);
        }
        
        qsort(joint, n - 1, sizeof(long long), cmpnum);
        j = 1;
        joint_total_len = 0;
        m = 0;
        for (i = n - 1; i > 0; i--) {
            joint_total_len += joint[m];                            /* ジョイントの長さの合計 */
            patch_total_len = pipe_total_len + joint_total_len;     /* パイプとジョイントを繋いだ最大の長さ */
            patch_pay = patch_total_len * i;                        /* パイプとジョイントを繋いだ給料 */
            pay[j] = patch_pay;                                     /* 配列payに給料を格納 */
            j++;
            m++;
        }
        qsort(pay, n, sizeof(long long), cmpnum);
        
        printf("%lld\n", pay[0]);
    }

    return (0);
}


Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}


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

    Int a, b, max;
    cin >> a >> b;
    max = a+b > a-b ? a+b : a-b;
    max = a*b > max ? a*b : max;
    cout << max << endl;

    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const int N=1e5+5;
const int MOD=1e9+7;

int32_t main()
{
    IOS;
    int x, y;
    cin>>x>>y;
    int lcm=(x*y)/gcd(x, y);
    int ans=lcm - x;
   	if(ans!=0 && ans%y!=0)
   	{
   		cout<<ans;
   	}
   	else
   	{
   		cout<<"-1";
   	}
    return 0;
}

Measured memory_bytes: 764
x = input().split()
N = int(x[0])
M = int(x[1])

SC = [input().split() for i in range(M)]
s = [int(x[0]) for x in SC]
c = [int(x[1]) for x in SC]

T = 0
if N > 1:
    for i in range(M):
        if s[i] == 1 and c[i] == 0:
            T = -1
for i in range(M):
    for j in range(M):
        if (s[i] == s[j]) and (c[i] != c[j]):
            T = -1
if T == -1:
    print(-1)
elif N == 1 and M == 0:
    print(0)
else:
    L = [0 for i in range(N)]
    K ="No"
    for i in range(M):
        if s[i] == 1:
            K = "Yes"
    if K == "Yes":
        for i in range(N):
            for j in range(M):
                if i == s[j]-1:
                    L[i] = c[j]
    else:
        L[0] = 1
        for i in range(N):
            for j in range(M):
                if i == s[j]-1:
                    L[i] = c[j]
    s = ""
    for i in range(N):
        s = s + str(L[i])
    print(int(s))

Measured memory_bytes: 3064
void main() {
	auto ip = readAs!(int[]), N = ip[0], x = ip[1];
	auto a = readAs!(int[]).sort().array;
	ulong res;
	foreach(i, v; a[0..$-1]) if(x >= v) {
		x -= v;
		res++;
	}
	if(x == a.back) res++;
	writeln(res);
}

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

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

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 (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A = get_ints

min = 10 ** 9
A.permutation(3) do |array|
  cost = (array[1] - array[0]).abs + (array[2]-array[1]).abs
  min = cost if cost < min
end

puts min


Measured memory_bytes: 14524