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

int main(){
  int n; cin >> n;
  int a;
  vector<map<int,bool>> vec(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    for (int j = 0; j < a; j++)
    {
      
      int x; cin >> x;
      bool y; cin >> y;
      vec.at(i)[x] = y;
      
    }
    
  }
  /*
  //input確認out
  for (auto &&i : vec)
  {
    cout << "opinion" << endl;
    for (auto &&j : i)
    {
      cout << "Number " << j.first << " is ";
      if (j.second) cout << "honest" << endl;
      else cout << "unreliable" << endl;
    }
    
  }
  */

  int ans = 0;


  for (int bit = 0; bit < (1 << n); bit++)
  {
    bool flag = true;
    int tmp = 0;
    //cout << "######roop: " << bit << endl;
    for (int i = 0; i < n; i++)
    {
      if (bit & (1 << i)) //iが正直（という設定）かどうかのbool値
      {
        tmp++;
        for (auto &&e : vec.at(i))//正直者の証言がランダムに取り出される。
        {
          int key = e.first;
          bool value = e.second;
          //cout << i << " says " << key << " is " << (value ? "honest" : "unreliable") << " but actually, " << (bit & (1 << key - 1) ? "honest" : "unreliable") << endl;
          if (bool(bit & (1 << key - 1)) != value) 
          {
            //cout << "flag down" << endl;
            flag =false; //設定情報(bit)がmap[key] = value と一致しなければ矛盾フラグをさげる。
            break;
          }
        }
        
      }
      
    }
    if(flag)ans = max(ans, tmp);
    //cout << "answer is " << ans << " now." << endl;
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
def MAIN():
    n = int(input())
    ans = [[i, 0, 0] for i in range((n + 1))]
    G = [[] for _ in range((n + 1))]
    for _ in range(n):
        u, k, *v = map(int, input().split())
        G[u] = v
    cnt = 1
    def dfs(u):
        nonlocal ans
        if ans[u][1] != 0:
            return
        nonlocal cnt
        ans[u][1] = cnt
        cnt += 1
        for v in G[u]:
            dfs(v)
        ans[u][2] = cnt
        cnt += 1
    for i in range(1, n + 1):
        if ans[i][1] == 0:
            dfs(i)
    for i in range(1, n + 1):
        print(*ans[i])
MAIN()



Measured memory_bytes: 5720
#include<stdio.h>
int main(void){
    int a,b,c,d,x;
    d=0;
    scanf("%d %d %d",&a,&b,&c);
    for(x=a;x<=b;x++){

        if(c%x==0){
            d=d+1;
        }
    }
    printf("%d\n",d);
    return 0;
}

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

#define rep(X, N) for (ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(), (V).end()
#define endl "\n"

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;

int main(){

    string s;
    cin >> s;
    int size = s.size();

    if(s[size - 1] == 's'){
        cout << s << "es" << endl;
    }else{
        cout << s << "s" << endl;
    }

    return 0;
}


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

int main(){
	
	
	int n,k;
	cin>>n>>k;
	int ar[k];
	map<int,int> m1;
	for(int i=0;i<k;i++){
		cin>>ar[i];
		m1[ar[i]]++;
	}
	for(int i=0;i<=100;i++){
		int l = n-i;
		int r = n+i;
		if(!m1[l]){
			cout<<l<<"\n";
			break;
		}else if(!m1[r]){
			cout<<r<<"\n";
			break;
		}
	}						
	return 0;
}

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

int main() {
    int N, X;
    cin >> N >> X;
    int L[100];
    for (int i=0; i<N; i++) {
        cin >> L[i];
    }
    int x = 0;
    int num = 1;
    for (int i=0; i<N; i++) {
        x += L[i];
        if (x > X) {
            cout << num << endl;
            return 0;
        }
        num += 1;
    }
    cout << num << endl;
    return 0;
}

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

int main(){
  long long n,ans=0;
  cin >> n;
  long long a[n],b[n]={};
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=n;i>=1;i--){
    long long cnt=0;
    for(int j=2;j*i<=n;j++){
      if(b[j*i-1]==1){
        cnt++;
      }
    }
    if(cnt%2!=a[i-1]){
      b[i-1]=1;
      ans++;
    }
  }
  cout << ans << endl;
  for(int i=0;i<n;i++){
    if(b[i]==1){
      cout << i+1 << " ";
    }
  }
  if(ans>0){
    cout << "\n";
  }
  return 0;
}

Measured memory_bytes: 3968
// B - Good Distance
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>

int main(void){
    int n, d;
    int x[11][11];
    scanf("%d%d", &n, &d);
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){ scanf("%d", &x[i][j]); }
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            int norm = 0;
            for(int k=0; k<d; k++){
                int diff = abs(x[i][k] - x[j][k]);
                norm += diff * diff;
            }
        
            bool flag = false;
            for(int k=0; k<=norm; k++){
                if(k * k == norm) flag = true; 
            }
            if(flag) ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

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

bool comp(pair<int,pair<int,int>> p,pair<int,pair<int,int>> q){
    return p.first < q.first;
}

int main(){
    int H,W;
    cin >> H >> W;
    int s_y,s_x;
    int g_y,g_x;
    cin >> s_y >> s_x;
    cin >> g_y >> g_x;
    s_y--;s_x--;
    g_y--;g_x--;
    vector<string> S(H);
    rep(i,H) cin >> S[i];
    vector<vector<ll>> seen(H,vector<ll>(W,INF));
    priority_queue<pair<int,pair<int,int>>> pq;
    pq.push(make_pair(0,make_pair(s_y,s_x)));
    while(!pq.empty()){
        auto now = pq.top();
        pq.pop();
        int num = -now.first;
        int now_y = now.second.first;
        int now_x = now.second.second;
        if(seen[now_y][now_x]<=num) continue;
        seen[now_y][now_x]=num;
        for(int k=0;k<4;k++){
            if(now_y+dy[k]<0||now_y+dy[k]>=H||now_x+dx[k]<0||now_x+dx[k]>=W) continue;
            if(S[now_y+dy[k]][now_x+dx[k]]!='#'&&seen[now_y+dy[k]][now_x+dx[k]]>num){
                //cout << now_y << "," << now_x << ":" << num <<" move1" << endl;
                pq.push(make_pair(-num,make_pair(now_y+dy[k],now_x+dx[k])));
            }
        }
        for(int i=-2;i<=2;i++){
            for(int j=-2;j<=2;j++){
                if(abs(i)+abs(j)<2)continue;
                if(now_y+i<0||now_y+i>=H||now_x+j<0||now_x+j>=W) continue;
                if(S[now_y+i][now_x+j]!='#'&&seen[now_y+i][now_x+j]>num){
                    pq.push(make_pair(-(num+1),make_pair(now_y+i,now_x+j)));
                }
            }
        }
    }
    if(seen[g_y][g_x]==INF) seen[g_y][g_x]=-1;
    cout << seen[g_y][g_x] << endl;
    return 0;
}

Measured memory_bytes: 13832
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())
    X = list(iim())

    av = sum(X) / N
    av = int((2*av+1) // 2)
    ans = 0
    for x in X:
        ans += (x - av)**2
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3060
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let s = read_vec::<String>();
    let ans : String = s.iter().map(|s1|  s1.chars().nth(0).unwrap().to_uppercase().nth(0).unwrap()).collect::<String>();
    println!("{}",ans )
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 1007;





int main(){
	while(1){
		ll n;cin>>n;
		if(n==0)break;
		vector<ll> a;
		a.resize(n);
		FOR(i,0,n)cin>>a[i];
		ll sa=INF;
		FOR(i,0,n){
			FOR(j,0,n){
				if(i==j)continue;
				if(abs(a[i]-a[j])<sa){
					sa = abs(a[i]-a[j]);
				}
			}
		}
		cout<<sa<<endl;
	}
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 998244353
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define M 100010


int main(){
    IOS;
 	
 	
	char c;cin>>c;
	ll x= c-'a';
	if(x>=0 and x<26)cout<<'a';
	else cout<<'A';
	
    
     
    return 0;
}


Measured memory_bytes: 3584
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
ar=(1..n).to_a
sum= sum ar.select{|i|i%3!=0&&i%5!=0}
puts sum

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

#include <bits/stdc++.h>
#define rep(i,a,n) for(ll i = a;i < n;i++)
typedef long long ll;
using namespace std;


const ll MOD = 1e9+7;
 
template <ll MOD>
struct modint{
    ll x;
    modint() : x(0) {}
    modint(ll a): x((a % MOD + MOD) % MOD) {}
    
    
 
    bool operator!() const{return !x;}
 
    bool operator<(const modint &a) const{
        modint res(*this);
        return res.x < a.x;
    }
    
    bool operator>(const modint &a) const{
        modint res(*this);
        return res.x > a.x;
    }
 
    modint &operator+=(const modint &a){
        if((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
 
    modint &operator-=(const modint &a){
        if((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
 
    modint &operator*=(const modint &a){
        (x *= a.x) %= MOD;
        return *this;
    }
 
    modint &operator/=(const modint &a){
        *this *= a.inv();
        return *this;
    }
 
    modint &operator%=(const modint &a){
        x %= a.x;
        return *this;
    }
 
    modint operator-() const{ return modint(-x); }
 
    modint operator+(const modint &a) const{ return modint(*this) += a; }
    modint operator-(const modint &a) const{ return modint(*this) -= a; }
    modint operator*(const modint &a) const{ return modint(*this) *= a; }
    modint operator/(const modint &a) const{ return modint(*this) /= a; }
    modint operator%(const modint &a) const{ return modint(*this) %= a; }
    bool operator==(const modint &a) const{ return x == a.x; }
    bool operator!=(const modint &a) const{ return x != a.x; }
 
 
    modint pow(ll n) const{
        modint res(1), a(x);
        while(n > 0){
            if(n & 1) res *= a;
            a *= a;
            n /= 2;
        }
        return res;
    }
 
    modint inv() const{
        return this->pow(MOD-2);
    }
 
    friend ostream &operator<<(ostream &os, const modint &m){
        return os << m.x;
    }
 
    friend istream &operator>>(istream &is, modint &m){
        ll t;
        is >> t;
        m = modint<MOD>(t);
        return (is);
    }
    
    static ll get_mod(){ return MOD; }
};
using mint = modint<MOD>;

int main(){ 
    ll n;
    cin >> n;
    ll a[n] = {};

    rep(i,0,n) cin >> a[i];

    ll kabu = 0,memo = 1000;
    rep(i,0,n-1){
        kabu += memo / a[i];
        memo %= a[i];

        if(a[i] > a[i+1]){
            memo += kabu * a[i];
            kabu = 0;
        }
    }
    memo += kabu * a[n-1];

    cout << max(1000LL,memo) << endl;
}


Measured memory_bytes: 3608
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        Arrays.sort(arr);

        int totalCount = 0;
        int target = arr[0];
        int count = 1;
        for (int i = 1; i < n; i++) {
            int before = arr[i - 1];
            int current = arr[i];
            if (before == current) {
                count++;
            } else {
//                debug(count, target);
                totalCount += count - target >= 0 ? count - target : count;
                target = current;
                count = 1;
            }
        }
//        debug(count, target);

        totalCount += count - target >= 0 ? count - target : count;
        System.out.println(totalCount);
    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

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

    b -= a;
    bool ok = false;
    for(long long int i=0;i<n;++i){
        if((n-1-i)*c-i*d <= b && b <= (n-1-i)*d-i*c || i*c-(n-1-i)*d <= b && b <= i*d-(n-1-i)*c){
            ok = true;
            break;
        }
    }

    cout << (ok ? "YES" : "NO") << endl;

    return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	double n, m, d;
	cin >> n >> m >> d;
	if(d == 0) cout << setprecision(20) << (m - 1) / n << endl;
	else cout << setprecision(20) << 2 * (n - d) / n / n * (m - 1) << endl;
	return 0;	
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var a,b,c,k int
  fmt.Scanf("%d %d %d %d", &a, &b ,&c, &k)

  // K枚のカードを選択し、取りうる最大値を算出する
  if a >= k {
    // aとkを比較し、aがkよりも多い場合は全てAのカードで最大値を算出
    fmt.Println(k)
  } else if b >= k-a {
    // aよりもkの方が大きい場合はbとk-aを比較し、bがk-aよりも多い場合は全てA・Bのカードで
    // 最大値を算出
    fmt.Println(a)
  } else {
    // bよりもk-aの方が大きい場合はk-a-bの値分、Cのカードを使用する
    fmt.Println(a-(k-a-b))
  }
}


Measured memory_bytes: 1820
loop do
  a, op, b = gets.split
  a = a.to_i
  b = b.to_i
  if op == "?"
    break
  end
  if op == "+"
    n = a + b
  elsif op == "-"
    n = a - b
  elsif op == "*"
    n = a * b
  elsif op == "/"
    n = a / b
  end
  puts n
end


Measured memory_bytes: 6872
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <set>
#include <queue>

using namespace std;

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

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

	vector<string> fieldB(m);
	for (int i = 0; i < m; ++i) {
		cin >> fieldB[i];
	}

	for (int i = 0; i < n - m + 1; ++i) {
		for (int j = 0; j < n - m + 1; ++j) {
			bool flag = true;
			for (int c = 0; c < m; ++c) {
				if (!flag) break;
				for (int k = 0; k < m; ++k) {
					if (fieldA[i + c][j + k] != fieldB[c][k]) {
						flag = false;
						break;
					}
				}
			}
			if (flag) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}

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

typedef long long ll;
const int N = 540;
const ll INF = 0x3f3f3f3f3f3f3f3fll;

int n;
ll L[N][N], R[N][N], f[N][N];

inline void down(ll &x, const ll y) {x > y ? x = y : 0;}

inline void sum2D(ll (*a)[N]) {
	int i, j;
	for (i = 1; i <= n; ++i) for (j = 1; j <= n; ++j) a[i][j] += a[i][j - 1];
	for (i = 1; i <= n; ++i) for (j = 1; j <= n; ++j) a[i][j] += a[i - 1][j];
}

inline ll sum(ll (*a)[N], int r1, int r2, int c1, int c2) {return a[r2][c2] - a[r2][c1] - a[r1][c2] + a[r1][c1];} // (r1, r2] X (c1, c2]

int main() {
	int i, j, k;
	scanf("%d", &n);
	for (i = 1; i <= n; ++i) {
		for (j = 1; j < i; ++j) scanf("%lld", L[i] + j);
		for (; ++j <= n; ) scanf("%lld", R[i] + j);
	}
	sum2D(L), sum2D(R), memset(f, 63, sizeof f);
	for (i = 1; i < n; ++i) f[i][0] = R[i][i];
	for (i = 1; i < n; ++i)
		for (j = 0; j < i; ++j) if (f[i][j] < INF)
			for (k = i + 1; k <= n; ++k)
				down(f[k][i], f[i][j] + sum(R, i, k, i, k) + sum(L, k, n, j, i));
	printf("%lld\n", *std::min_element(f[n], f[n] + n));
	return 0;
}

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

using namespace std;
using ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define YES(f) if((f)){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(f) if((f)){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))

#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

vector<int> x(3), l;
int N;

void init()
{
	cin >> N;
	rep(i, 3) cin >> x[i];
	l.RS(N);
	rep(i, N) cin >> l[i];
}

int calc(int y)
{
	vector<int> t(3, 0);
	int res = -30;
	rep(i, N) {
		if (y % 4 != 3) {
			t[y % 4] += l[i];
			res += 10;
		}
		y /= 4;
	}
	rep(i, 3) {
		if (t[i] == 0) {
			return INT_MAX;
		}
		res += abs(t[i] - x[i]);
	}
	return res;
}

void solve()
{
	int res = INT_MAX;
	int y = 1;
	rep(i, N) y *= 4;
	rep(i, y) {
		chmin(res, calc(i));
	}
	cout << res << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  set<int>ans;
  int a,b,k;
  cin>>a>>b>>k;
  k = min(k,b - a);
  REP(i,a,a+k)ans.insert(i);
  mREP(i,b,b-k)ans.insert(i);
  for(auto j : ans)cout << j << endl;
  if(a==b)cout<<a<<endl;
  return 0;
} 

Measured memory_bytes: 256
from sys import stdin
import numpy as np
N,M,C=[int(x) for x in stdin.readline().rstrip().split()]
B=[int(x) for x in stdin.readline().rstrip().split()]
data=[]
for i in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()])

ans=0
for j in data:
    tmp=np.array(j)*np.array(B)
    if np.sum(tmp)+C > 0:
        ans+=1
print(ans)

Measured memory_bytes: 12420
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let a: Vec<u32> = read_vec();
    if a[0] + a[1] + a[2] >= 22 {
        println!("bust");
    } else {
        println!("win");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];

    int ans=0;
    for(int i=0;i<N;){
        int j=i+1,k=i+1;
        while(j<N and (a[j-1]==a[j] or a[j-1]<a[j])) j++;
        while(k<N and (a[k-1]==a[k] or a[k-1]>a[k])) k++;
        ans++;
        i=max(j,k);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
/// Zhupengfei 2018
/// Hereby declare: this program is in public domain.

/// Solution for problem: abc103D

#include <bits/stdc++.h>

#ifdef LOCAL
#pragma GCC poison printf // To avoid fastio problems
#pragma GCC poison scanf
#endif

#define left left1erlerqwer
#define right right1rw0e9r

using namespace std;

pair<int, int> rq[100001]={};
vector<int> rsons[100001]={};
vector<int> lsons[100001]={};
int right[100001], left[100001]={};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
    int N, M;
    cin>>N>>M;
    int a, b;
    fill(right+1, right+N+1, 1e9);
    for(int i=1;i<=M;i++) {
        cin>>a>>b;
        right[a]=min(right[a], b);
    }
    int R=-1e9;
    int count=0;
    for(int i=1;i<=N;i++) {
        if(right[i]!=1e9) {
            if(i>=R) {
                count++;
                R=right[i];
            } else {
                R=min(R, right[i]);
            }
        }
    }
    cout<<count<<endl;
	return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;

using namespace std;

int main() {

	int h, w;
	cin >> h >> w;

	char a[h][w];
	queue<pair<int, int>> q;

	int wC = 0;
	int ans = 0;

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

	rep (i, h) {
		rep (j, w) {
			cin >> a[i][j];

			if (a[i][j] == '#')
				q.push(make_pair(i, j));
			else 
				wC++;
		}
	}

	while (wC > 0) {

		int size = q.size() + 1 - 1;
	/*	cout << size << endl;
		cout << q.size() << endl;*/

		queue<pair<int, int>> nextQ;

		while (!q.empty()) {
					

			pair<int, int> pos = q.front(); q.pop();
			int x = pos.first;
			int y = pos.second;

			rep(i, 4) {
				int mx = x + dx[i];
				int my = y + dy[i];

				if (mx < 0 || mx >= h || my < 0 || my >= w)
					continue;
					

				//cout << "x = " << x << "  y = " << y << "  mx = " << mx << "  my = " << my << endl;
			

				if (a[mx][my] == '.') {
					nextQ.push(make_pair(mx, my));
					a[mx][my] = '#';
					wC--;
				}
			}
		}
		q.swap(nextQ);
		ans++;
/*
					cout << endl;
		rep (i, h) {
			rep (j, w) {
				cout << a[i][j];
			}
			cout << endl;
		}
		cout << endl;*/
	}

	cout << ans << endl;
}
/*

.Q#QQ#
Q.QQ.Q
#QQ#Q.
QQ.Q..
Q#Q.Q.
.Q.Q#Q*/

Measured memory_bytes: 9360
n=int(input())
w=[input() for i in range(n)]
flag=True
for s in w:
    if w.count(s) > 1:
        flag = False
for i in range(1,n):
    if w[i][0] != w[i-1][-1]:
        flag = False
print("Yes" if flag else "No")

Measured memory_bytes: 3060
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

S = input()
if S[0] == S[1] or S[1]==S[2] or S[2]==S[3]:
    print('Bad')
else:
    print('Good')


Measured memory_bytes: 3956
#include <stdio.h>

int main(int argc, char** argv){
	int x,y,tmp;

	// Input
	scanf("%d%d",&x,&y);

	// Solve & Output
	for(;;){
		if ( x < y ){
			tmp = y;
			y = x;
			x = tmp;
		}

		if( x % y == 0 ){
			printf("%d\n",y);
			break;
		} else {
			tmp = x % y;
			x = y;
			y = tmp;
		}
	}

	return 0;
}

Measured memory_bytes: 592
#include <iostream>
using namespace std;
 
int N;
int A[210];        
int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];
 
    int res = 0;
 
   
    while (true) {
        bool exist_odd = false; 
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;  
        }
 
        if (exist_odd) break;  
 
        
        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res; 
    }
 
    cout << res << endl;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

a=[]
for i in range(len(h) - 1):
  a.append(h[i] - h[i+1])

cnt=0
temp=0
for i in range(len(a)):
  if a[i] >= 0:
    temp+=1
  else:
    cnt = max(temp, cnt)
    temp=0
cnt = max(temp, cnt)
print(cnt)

Measured memory_bytes: 14252
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <cassert>
#define rep(i,n) for (ll i = 0; i < (ll)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<int, pi> pip;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int h, w;
char s[100][100];
int dist[100][100];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    rep(i,h) rep(j,w) {
        cin >> s[i][j];
        dist[i][j] = inf;
    }
    dist[0][0] = 0;
    priority_queue<pip, vector<pip>, greater<pip>> que;
    que.push(pip(0, pi(0,0)));
    while (!que.empty()) {
        pip p = que.top(); que.pop();
        int x = p.second.first, y = p.second.second;
        if (p.first > dist[x][y]) continue;
        if (x != h-1) {
            if (dist[x+1][y] > dist[x][y]+(s[x][y] != s[x+1][y])) {
                dist[x+1][y] = dist[x][y]+(s[x][y] != s[x+1][y]);
                que.push(pip(dist[x+1][y], pi(x+1,y)));
            }
        }
        if (y != w-1) {
            if (dist[x][y+1] > dist[x][y]+(s[x][y] != s[x][y+1])) {
                dist[x][y+1] = dist[x][y]+(s[x][y] != s[x][y+1]);
                que.push(pip(dist[x][y+1], pi(x,y+1)));
            }
        }
    }
    if (dist[h-1][w-1]%2) {
        cout << (dist[h-1][w-1]+1)/2 << endl;
    } else {
        if (s[0][0] == '.') cout << dist[h-1][w-1]/2 << endl;
        else cout << dist[h-1][w-1]/2 + 1 << endl;
    }
}

Measured memory_bytes: 384
#include <cstdio>

int main() {
	int n;
	int a[100000];
	int edge[100000];

	int sum = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
	}

	int tmp = 0;
	for(int i = 0; i < n; i++) {
		tmp += i % 2 ? -a[i] : a[i];
	}
	edge[0] = tmp / 2;

	for(int j = 1; j < n; j++) {
		edge[j] = a[j - 1] - edge[j - 1];
	}

	for(int i = 0; i < n - 1; i++) {
		printf("%d ", edge[i] * 2);
	}
	printf("%d\n", edge[n - 1] * 2);

	return 0;
}

Measured memory_bytes: 2048
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 100002;

int n, A[CMax], ats, pr, pb;
string S;

int main() {
    cin >> S;
    if (S.length() == 1) {
        cout << 0 << endl;
        return 0;
    }
    pr = 0, pb = S.length() - 1;
    while (pr < pb) {
        if (S[pr] != S[pb] && (S[pr] != 'x' && S[pb] != 'x')) {
            cout << -1 << endl;
            return 0;
        } else if (S[pr] == S[pb]) {
            pr++; pb--;
        } else if (S[pr] == 'x') {
            ats++;
            pr++;
        } else if (S[pb] == 'x') {
            ats++;
            pb--;
        }
    }

    printf("%d\n", ats);
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,K;cin >> N >> K;
  map<char,int> mp;
  cin >> mp['s'] >> mp['p'] >> mp['r'];
  mp['n'] = 0;
  string t;cin >> t;
  reverse(all(t));
  int ans = 0;
  rep(i,N){
    ans += mp[t[i]];
    if(i+K < N && t[i] == t[i+K]){
      t[i+K] = 'n';
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#define N 21
using namespace std;

int main(){
  int n,m,x,y,rx,ry,l,cnt,d[N][N];
  char c;
  while(1){
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++) d[i][j]=0;
    cin>>n;
    if(!n) break;
    for(int i=0;i<n;i++) cin>>x>>y,d[N-y-1][x]=1;
    cin>>m;
    rx=ry=10;
    cnt=0;
    while(m--){
      cin>>c>>l;
      while(l--){
	if(c=='N') ry--;
	if(c=='E') rx++;
	if(c=='S') ry++;
	if(c=='W') rx--;
	if(d[ry][rx]) d[ry][rx]=0,cnt++;
      }
    }
    if(cnt==n) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
N,M,Q = map(int,input().split())
data = [0]*Q
for i in range(Q): data[i] = list(map(int,input().split()))

a = []
def gen_a(n,ai,cur):
    if n==0:
        for k in range(1,M+1):
            if k==10:
                k = "a"
                gen_a(1,10,str(k))
            else:
                gen_a(1,k,str(k))
    elif n==N:
        ar = list(cur)
        if ar[-1] == "a": ar[-1] = "10"
        a.append(ar)
    else:
        for k in range(ai,M+1):
            if k == 10:
                k = "a"
                gen_a(n+1,10,cur+str(k))
            else: 
                gen_a(n+1,k,cur+str(k))

gen_a(0,1,0)

ans = 0
for a_item in a:
    cnt = 0
    for d_item in data:
        nb = int(a_item[d_item[1]-1]) if a_item[d_item[1]-1] != "a" else 10
        na = int(a_item[d_item[0]-1]) if a_item[d_item[0]-1] != "a" else 10
        if nb - na == d_item[2]:
            cnt += d_item[3]
    if ans < cnt:
        ans = cnt

print(ans)

Measured memory_bytes: 118864
using System;

public class Hello{
    public static void Main(){
         string[] str = Console.ReadLine().Split(' ');
        int a =int.Parse(str[0]);
        int b =int.Parse(str[1]);
        if(a<b){
            Console.WriteLine("a < b");
        }
        else if (a>b){
            Console.WriteLine("a > b");
        }
        else if (a==b){
            Console.WriteLine("a == b");
        }
    }
}



Measured memory_bytes: 15960
stdin.ReadLine().Split(' ') |> Array.map int |> function
| [|n; y|] ->
    [for man in 0..(min n (y / 10000)) do
        for gosen in 0..(min (n - man) (y / 5000)) do
            yield man, gosen, n - man - gosen]
    |> Seq.tryFind (fun (a, b, c) -> (a + b + c = n) && (a * 10000 + b * 5000 + c * 1000 = y))
    |> function
    | Some(a, b, c) -> printfn "%d %d %d" a b c
    | None -> printfn "-1 -1 -1"
| _ -> ()


Measured memory_bytes: 144476
#include<iostream>
#include<queue>
#include<utility>
using namespace std;
typedef pair<int,int> P;

int n,l,a[100100];

inline bool drop(int i){
  if(i==0)return a[i]>a[i+1];
  if(i==n-1)return a[i]>a[i-1];
  return a[i]>a[i-1] && a[i]>a[i+1];
}

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

  priority_queue< P,vector<P>,greater<P> > q;

  for(int i=0;i<n;i++){
    if(drop(i))q.push(make_pair(l-a[i],i));
  }

  int ans = 0;
  while(q.size()){
    int t = q.top().first, i = q.top().second;
    q.pop();

    ans = max(ans,t);
    a[i] = 0;

    if(i!=0 && drop(i-1))q.push(make_pair(l-a[i-1]+t,i-1));
    if(i!=n-1 && drop(i+1))q.push(make_pair(l-a[i+1]+t,i+1));
  }
  cout << ans << endl;
}

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


int main()
{
  string n;

  cin >> n;
  if ( n[0] == n[1] && n[1] == n[2] ) cout << "Yes" << endl;
  else if ( n[1] == n[2] && n[2] == n[3] ) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
 
int main()
{
  char a[10],b[10],c[10];
  scanf("%s%s%s",&a,&b,&c);
  printf("%c%c%c",a[0]+('A'-'a'),b[0]+('A'-'a'),c[0]+('A'-'a'));
    
}

Measured memory_bytes: 128
#include <cstdio>

int gcd(int a, int b) {return b ? gcd(b , a % b) : a;}

int main()
{
    int k; 
    scanf("%d", &k);
    int ans = 0;
    for(int i = 1; i <= k; i++)
    for(int j = 1; j <= k; j++)
    for(int l = 1; l <= k; l++)
        ans += gcd(gcd(i, j), l);
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 1728
#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(){
	double N;
	cin>>N;
	vector<int>A(N);
	rep(i,N){
		cin>>A.at(i);
	}
	double ans=0;
	rep(i,N){
		ans+=1.0/A.at(i);
	}
	cout<<fixed<<setprecision(6)<<1.0/ans<<endl;
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
N = gets.chomp.to_i
h = {}
[*1..9].each do |i|
  [*1..9].each do |j|
    h[[i,j]] = 0
  end
end
[*1..N].each do |num|
  i = num.to_s[0].to_i
  j = num.to_s[-1].to_i
  h[[i,j]] += 1 if j !=0
end
nas = 0
[*1..9].each do |i|
  [*1..9].each do |j|
    nas += h[[i,j]] * h[[j,i]]
  end
end
puts nas


Measured memory_bytes: 4988
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int main(){
	int i,K;
	string s,b;
	cin>>s;
	cin>>K;
	if(s.substr(0,1)!="1"){
		cout<<s.substr(0,1)<<endl;
		return 0;
	}
	for(i=1;i<=K-1;i++){
		if(s.substr(i,1)!="1"){
			b=s.substr(i,1);
			cout<<b<<endl;
			return 0;
		}
	}
	printf("1");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <numeric>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>

double inf = 1e12;

double f(double t, std::vector<std::tuple<intmax_t, intmax_t, char>> const& xyd) {
  double xmax = -inf;
  double xmin = inf;
  double ymax = -inf;
  double ymin = inf;

  for (auto const& p: xyd) {
    intmax_t xi, yi;
    char d;
    std::tie(xi, yi, d) = p;
    double x = xi;
    double y = yi;

    if (d == 'R') {
      x += t;
    } else if (d == 'L') {
      x -= t;
    } else if (d == 'U') {
      y += t;
    } else if (d == 'D') {
      y -= t;
    }

    xmax = std::max(xmax, x);
    xmin = std::min(xmin, x);
    ymax = std::max(ymax, y);
    ymin = std::min(ymin, y);
  }

  return (xmax-xmin) * (ymax-ymin);
}

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<std::tuple<intmax_t, intmax_t, char>> xyd;
  xyd.reserve(N);
  for (size_t i = 0; i < N; ++i) {
    intmax_t x, y;
    char d;
    scanf("%jd %jd %c", &x, &y, &d);
    xyd.emplace_back(x, y, d);
  }

  double lb = 0;
  double ub = 1e9;
  for (int i = 0; i < 200; ++i) {
    double midl = (lb+lb+ub) / 3;
    double midu = (lb+ub+ub) / 3;
    if (f(midl, xyd) > f(midu, xyd)) {
      lb = midl;
    } else {
      ub = midu;
    }
  }

  printf("%.12f\n", std::min(f(lb, xyd), f(ub, xyd)));
}


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

int main() {
  
  int Hone, Mone, Htwo, Mtwo, K;
  
  cin >> Hone >> Mone >> Htwo >> Mtwo >> K;
  
  
  cout << Htwo * 60 + Mtwo - Hone * 60 - Mone - K << endl;
  
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    char b;
    cin >> b;
    if(b == 'A') cout << 'T' << endl;
    else if(b == 'T') cout << 'A' << endl;
    else if(b == 'C') cout << 'G' << endl;
    else cout << 'C' << endl;
}


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

int gcd(int a,int b,int c){
    int m = min(a,min(b,c));
    for(int i=m;i>=1;i--){
        //cout << i << endl;
        //cout << a%i << b%i << c%i << endl;
        if(a % i == 0 && b % i == 0 && c % i == 0) return i;
    }
}

int main(){
    int k;
    cin >> k;
    int sum = 0;
    gcd(4,4,3);
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                //cout << a <<"," << b << "," << c << "," <<gcd(a,b,c) << endl;
                sum += gcd(a,b,c);
            }
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int imos[200001];
vector<int> x[100000];
int l[100000];
int main() {
	int n, m; cin >> n >> m;
	rep(i, n) {
		int a; cin >> a; a--;
		l[i] = a;
		if (i > 0) {
			x[a].push_back(i);
		}
	}
	rep(i, n - 1) {
		if (l[i] > l[i + 1]) {
			imos[l[i] + 1]++; imos[l[i + 1] + m]--;
		}
		else {
			imos[l[i] + 1]++; imos[l[i + 1]]--;
		}
	}
	rep1(i, 2 * m) {
		imos[i] += imos[i - 1];
	}
	Rep(i, m, 2 * m) {
		imos[i - m] += imos[i];
	}
	ll out = 0;
	rep1(i, n - 1) {
		out += min(l[i] + 1, (l[i] - l[i - 1] + m) % m);
	}
	ll mi = out;
	rep(i, m - 1) {
		int len = x[i].size();
		rep(j, len) {
			int v = x[i][j];
			out += (l[v] - l[v - 1] + m) % m - 1;
		}
		out -= imos[i];
		mi = min(mi, out);
	}
	cout << mi << endl;
	return 0;
}

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

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

using namespace std;

const int IINF = INT_MAX;

struct Edge{
  int to,cost;
  Edge(int to=IINF,int cost=IINF):to(to),cost(cost){}
};

map<string,int> mp;
int day1[1100],N,par[1100],mp_idx;
vector<Edge> G[1100];
bool used[1100];

inline int getIndex(string s){
  if( mp.find(s) == mp.end() ) return mp[s] = mp_idx++;
  return mp[s];
}

inline void init(){
  mp_idx = 0;
  mp.clear();
  rep(i,N) G[i].clear(), par[i] = i;
}

int find(int x){
  if( par[x] == x ) return par[x];
  return par[x] = find(par[x]);
}

inline void unit(int x,int y){
  x = find(x), y = find(y);
  if( x != y ) par[x] = par[y];
}

void dfs(int cur,int &cost){
  if( used[cur] ) return;
  used[cur] = true;
  rep(i,(int)G[cur].size()){
    int to = G[cur][i].to;
    if( !used[to] && par[cur] == par[to] ){
      cost += G[cur][i].cost;
      dfs(to,cost);
    }
  }
}

inline void compute(){
  set<int> S;
  rep(i,N) S.insert(find(i));
  int cnt = S.size();
  int mincost[N];
  rep(i,N) mincost[i] = IINF;
  rep(i,N){
    int idx = par[i];
    int cost = day1[i];
    rep(j,N) used[j] = false;
    dfs(i,cost);
    rep(j,N) if( !used[j] && par[j] == par[i] ) cost += day1[j];
    mincost[idx] = min(mincost[idx],cost);
  }
  int ans = 0;
  for( int i : S ) ans += mincost[i];
  cout << ans << endl;
}

int main(){
  while( cin >> N, N ){

    init();
    rep(i,N){
      string a,b;
      int c,d;
      cin >> a >> c >> b >> d;
      int ia = getIndex(a);
      day1[ia] = c;
      int ib = getIndex(b);
      if( ia == ib ) continue;
      G[ib].push_back(Edge(ia,d));
      unit(ia,ib);
    }

    compute();

  }
  return 0;
}

Measured memory_bytes: 1468
#include <bits/stdc++.h>
#define N 5005
#define INF 10000000000000LL
using namespace std;
int n,A,B,p[N],pos[N],cnt[N][N];
long long f[N][N];
int main(){
    scanf("%d%d%d",&n,&A,&B);
    for(int i=1;i<=n;++i){
        scanf("%d",&p[i]);
        pos[p[i]]=i;
    }
    for(int i=n;i;--i)
        for(int j=1;j<=n;++j)
            if(pos[j]>=i)cnt[i][j]=cnt[i+1][j]+(j<=p[i]);
    for(int j=n;j;--j)
        for(int i=n;i;--i)
            if(!cnt[i][j])f[i][j]=f[i][j+1];
            else{
                f[i][j]=min(f[i][j+1]+B,f[pos[j]+1][j+1]+1LL*A*(cnt[i][j]-1));
                //printf("cnt=%d f[%d][%d]=",cnt[i][j]-1,i,j),cout<<f[i][j]<<endl;
            }
    cout<<f[1][1]<<endl;
}


Measured memory_bytes: 293632
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define N 10000

class Stack{
private:
	int num[N];
	int head;
public:
	Stack(){
		head=0;
	}

	void push(int x){
		head++;
		num[head]  =x;
	}

	void pop(void){
		head--;
	}

	int top(void){
		return num[head];
	}
};

int main(){
	Stack stack;
	string str;
	int x,y;

	while(cin >> str){

		if(str == "+"){
			x= stack.top();
			stack.pop();
			y=stack.top();
			stack.pop();
			stack.push(x+y);
		}
		else if(str == "-"){
			x = stack.top();
			stack.pop();
			y=stack.top();
			stack.pop();
			stack.push(y-x);
		}
		else if(str == "*"){
			x=stack.top();
			stack.pop();
			y=stack.top();
			stack.pop();
			stack.push(x*y);
		}
		else{
			x = atoi(str.c_str());
			stack.push(x);
		}
	}

	cout << stack.top() << endl;
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main(){
int x, y, z, m;
cin >> x >>y >> z;
if (x<y) {m=x; x=y; y=m;};
if (y<z) {m=y; y=z; z=m;};
if (x<y) {m=x; x=y; y=m;};
	cout<<z<<" "<<y<<" "<<x<<endl;
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

vector<ll> findDivisor(ll n) {
	vector<ll> divisor;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			divisor.push_back(i);
			if (i * i != n) divisor.push_back(n / i);
		}
	}
	sort(ALL(divisor));
	return divisor;
}

// a と b の最大公約数を求める
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// a と b の最小公倍数を求める
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main() {
	ll A, B;
	cin >> A >> B;
	
	vector<ll> v = findDivisor(A);
	set<ll> ss;
	for (ll u : v) ss.insert(u);
	
	v = findDivisor(B);
	vector<ll> kyu;
	for (ll u : v) if (ss.find(u) != ss.end()) kyu.push_back(u);
	
	int ans = 0;
	ll l = 1;
	
	for (ll u : kyu) {
		if (gcd(l, u) > 1) continue;
		ans++;
		l = lcm(l, u);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  vector<vector<int>> A(a,vector<int>(b));
  for(int i = 0;i<a;i++){
    int c;
    cin >> c;
    for(int j = 0;j<c;j++){
      cin >> A.at(i).at(j);
    }
  }
  vector<int> C(b);
  for(int s = 0;s<b;s++){
    for(int i = 0;i<a;i++){
      for(int j = 0;j<A.at(i).size();j++){
        if(A.at(i).at(j) == s+1)
        C.at(s)++;
      }
    }
  }
  int ans = 0;
  for(int i = 0;i<b;i++){
    if(C.at(i) == a)
      ans++;
  }
  cout << ans << endl;
}

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

long long a, b, ans;

long long func(long long x){
	if(x <= 0) return 0;
	if(x == 1) return 1;
	if(x == 2) return 3;
	if(x == 3) return 0;
	long long res = 0;
	long long t = 1;
	while((t<<1) <= x) t <<= 1;
	if((x - t + 1) % 2 == 1) res += t;
	res += func(x-t);
//	cout << x << " " << res << "\n";
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> a >> b;
	ans = func(a-1) ^ func(b);
	cout << ans << "\n";
}

Measured memory_bytes: 256