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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  vi v(3);
  rep(i, 3) cin >> v[i];
  sort(all(v));
  int a = v[0], b = v[1], c = v[2];

  int res = 0;
  if ((c - a) % 2 == 0 && (c - b) % 2 == 0)
    res = (c - a) / 2 + (c - b) / 2;
  else if (((c - a) % 2 && (c - b) % 2 == 0) ||
           ((c - a) % 2 == 0 && (c - b) % 2))
    res = (c - a) / 2 + (c - b) / 2 + 2;
  else
    res = (c - a) / 2 + (c - b) / 2 + 1;

  cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

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 dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int h, w, d;
    cin >> h >> w >> d;

    vector<vector<int>> a(h,vector<int>(w));
    typedef pair<int, int> P;
    map<int, P> m;
    rep(i,h) rep(j,w) {
        cin >> a[i][j];
        m[a[i][j]] = P(i,j);
    }

    vector<int> sum(h*w+1);
    repf(i,1,h*w+1) {
        int pre = i-d;
        if (pre > 0) {
            int hp = abs(m[i].first-m[pre].first) + abs(m[i].second-m[pre].second);
            sum[i] = sum[pre] + hp;
        }
    }

    int q; cin >> q;
    vector<int> l(q), r(q);
    rep(i,q) cin >> l[i] >> r[i];
    rep(i,q) {
        if (l[i]-d > 0) {
            cout << sum[r[i]] - sum[l[i]] << endl;
        } else {
            cout << sum[r[i]] << endl;
        }
    }
    return 0;
}

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

using namespace std;

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

const int maxn = 1e5 + 10;
multiset <pii> mst, mst2;
ll ans, ans2;
pii p[maxn];
int n;

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> p[i].first >> p[i].second;
		mst.insert(p[i]);
		mst2.insert({p[i].second, p[i].first});
	}
	int pos = 0;
	for (int i = 0; i < n; ++i) {
		pii t;
		if (i & 1) {
			t = *mst2.begin();
			mst2.erase(mst2.begin());
			swap(t.first, t.second);
			mst.erase(mst.find(t));
		}
		else {
			t = *--mst.end();
			mst.erase(--mst.end());
			mst2.erase(mst2.find({t.second, t.first}));
		}
		if (pos < t.first) {
			ans += t.first - pos;
			pos = t.first;
		}
		if (pos > t.second) {
			ans += pos - t.second;
			pos = t.second;
		}
	}
	ans += abs(pos);
	ans2 = ans; ans = 0;
	for (int i = 0; i < n; ++i) {
		mst.insert(p[i]);
		mst2.insert({p[i].second, p[i].first});
	}
	pos = 0;
	for (int i = 0; i < n; ++i) {
		pii t;
		if (!(i & 1)) {
			t = *mst2.begin();
			mst2.erase(mst2.begin());
			swap(t.first, t.second);
			mst.erase(mst.find(t));
		}
		else {
			t = *--mst.end();
			mst.erase(--mst.end());
			mst2.erase(mst2.find({t.second, t.first}));
		}
		if (pos < t.first) {
			ans += t.first - pos;
			pos = t.first;
		}
		if (pos > t.second) {
			ans += pos - t.second;
			pos = t.second;
		}
	}
	ans += abs(pos);
	ans = max(ans, ans2);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 10368
W,H,N = map(int,input().split())
grid = []
for i in range(N):
	array = list(map(int,input().split()))
	grid.append(array)
x1 = 0
xW = W
y1 = 0
yH = H
for i in grid:
	if i[2] == 1 and x1 < i[0]:
		x1 = i[0]
	elif i[2] == 2 and xW > i[0]:
		xW = i[0]
	elif i[2] == 3 and y1 < i[1]:
		y1 = i[1]
	elif i[2] == 4 and yH > i[1]:
		yH = i[1]
print(max(0,xW-x1)*max(0,yH-y1))

Measured memory_bytes: 3064
a,b,k = map(int,input().split())
l = b - a + 1

if l >= 2*k:
    for i in  range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)



Measured memory_bytes: 3188
N, H = map(int, input().split())
A = 0
B = [0] * (N + 1)
for i in range(N):
  a, b = map(int, input().split())
  A = max(a, A)
  B[i] = b
B.sort(reverse=True)
cnt = 0
i  = 0
while H > 0:
  if B[i] > A:
    H -= B[i]
    cnt += 1
    i += 1
  else:
    k = -(-H // A)
    H -= A * k
    cnt += k
print(cnt)

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

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n;
    cin >> n;
    double ans = 0;
    for(int i = 0; i < n; i++){
        double x; string u;
        cin >> x >> u;
        if(u[0] == 'J') ans += x;
        else ans += x*380000;
    }
    cout << fixed << ans << endl;
    return 0;
}

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

int n, m;
int main() {
	int i, d;
	cin >> n >> m;
	for(i=1, d=m; d>0; i++, d-=2) printf("%d %d\n", i, i+d);
	for(i=m+2, d=m-1; d>0; i++, d-=2) printf("%d %d\n", i, i+d);
	return 0;
}

Measured memory_bytes: 3744
s = input()
f = True
for i in range(0,len(s)):
    if i%2 == 0:
        if s[i] == 'R' or s[i] == 'U' or s[i] == 'D':
            continue
        else:
            f = False
            break
    else:
        if s[i] == 'L' or s[i] == 'U' or s[i] == 'D':
            continue
        else:
            f = False
            break
if f:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	long double L,e;
	std::cin >> L;

	e = L / 3;
	std::cout << std::fixed << std::setprecision(15) << e * e * e << endl;

	return 0;
}


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

ll m = 1e9+7;

int main() {
	string s; cin>>s;
	vector<ll> ABC(s.size()), AB(s.size()), A(s.size());
	ll qmarks=1;
	if (s[0]=='A' or s[0]=='?') A[0]=1;
	if (s[0]=='?') qmarks=3;

	for (ll i=1; i<s.size(); i++) {
		A[i] = A[i-1];
		AB[i] = AB[i-1];
		ABC[i] = ABC[i-1];
		if (s[i]=='A')
			A[i] = (A[i-1] + qmarks)%m;
		if (s[i]=='B')
			AB[i] = (AB[i-1] + A[i-1])%m;
		if (s[i]=='C')
			ABC[i] = (ABC[i-1] + AB[i-1])%m;
		if (s[i]=='?') {
			A[i] = ((A[i-1]*3)%m + qmarks)%m;
			AB[i] = ((AB[i-1]*3)%m + A[i-1])%m; 
			ABC[i] = ((ABC[i-1]*3)%m + AB[i-1])%m;
			qmarks = (qmarks*3)%m;
		}
	}
	
	cout << ABC.back() << endl;

	return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

signed main() {
  char a; cin >> a;
  if (islower(a)) cout << "a" << endl;
  else            cout << "A" << endl;
  return 0;
}


Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0,w=1;char ch=' ';
	while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
	if(ch=='-') w=-1,ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q*w;
}
const int N=100005,inf=0x3f3f3f3f;
int n,tot,K,rt;
int h[N],ne[N<<1],to[N<<1],a[N],is[N],L[N],R[N],kL[N],kR[N];
void add(int x,int y) {to[++tot]=y,ne[tot]=h[x],h[x]=tot;}
int dfs1(int x,int las) {
	if(a[x]!=-1) L[x]=R[x]=a[x];
	else L[x]=-inf,R[x]=inf;
	for(RI i=h[x];i;i=ne[i]) {
		if(to[i]==las) continue;
		is[to[i]]=is[x]^1;
		if(!dfs1(to[i],x)) return 0;
		L[x]=max(L[x],L[to[i]]-1),R[x]=min(R[x],R[to[i]]+1);
	}
	return L[x]<=R[x];
}
int dfs2(int x,int las) {
	for(RI i=h[x];i;i=ne[i]) {
		if(to[i]==las) continue;
		L[to[i]]=max(L[to[i]],L[x]-1),R[to[i]]=min(R[to[i]],R[x]+1);
		if(!dfs2(to[i],x)) return 0;
	}
	return L[x]<=R[x];
}
int main()
{
	int x,y;
	n=read();
	for(RI i=1;i<=n;++i) a[i]=-1;
	for(RI i=1;i<n;++i) x=read(),y=read(),add(x,y),add(y,x);
	K=read();
	for(RI i=1;i<=K;++i) x=read(),y=read(),a[x]=y,rt=x;
	is[rt]=a[rt]&1;
	if(!dfs1(rt,0)) {puts("No");return 0;}
	if(!dfs2(rt,0)) {puts("No");return 0;}
	for(RI i=1;i<=n;++i) {
		if(L[i]==R[i]&&((L[i]&1)!=is[i])) {puts("No");return 0;}
		if((L[i]&1)==is[i]) a[i]=L[i];
		else a[i]=L[i]+1;
	}
	puts("Yes");
	for(RI i=1;i<=n;++i) printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 9088
import java.util.*


data class Time(val hour: Int, val minute: Int) {
    constructor(times: List<Int>):this(times[0], times[1])
    constructor(expression: String):this(expression.split(':').map(String::toInt))
    private constructor(second: Int):this(second / 3600, (second % 3600) / 60)
    private val second: Int
        get() = hour * 3600 + minute * 60
    val wholeMinutes: Int
        get() = hour * 60 + minute
    operator fun minus(other: Time): Time = Time((second - other.second + 86400) % 86400)
}
fun main(args: Array<String>?): Unit {
    val (n, t) = readLine()!!.trim().split(' ').map(String::toInt)
    val stations = Array(n){
        val (st, sn, at, an) = readLine()!!.trim().split(' ')
        listOf(Pair(Time(st), sn), Pair(Time(at), an))
    }
    val stack = Stack<Pair<String, Int>>()
    for (i in 1 until n){
        if ((stations[i][0].first - stations[i - 1][1].first).wholeMinutes >= t) {
            stack.push(Pair(stations[i][0].second,(stations[i][0].first - stations[i - 1][1].first).wholeMinutes))
        }
    }
    println(stack.size)
    for ((name, time) in stack) {
        println("$name $time")
    }
}


Measured memory_bytes: 34048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[100005];
map<ll,int> mp[100001][3];
int chk;
int n;
int fun(int pos,int s,ll prev)
{
    if(chk==2) return 2;
    if(pos==n)
    {
        chk=2;
        return 2;
    }
    if(mp[pos][s][prev]!=0) return mp[pos][s][prev];
    int ans=1;
    if(prev<=arr[pos])
    {
        ans=max(ans,fun(pos+1,1,arr[pos]));
    }
    if(prev<=(arr[pos]-1LL))
    {
        ans=max(ans,fun(pos+1,2,arr[pos]-1LL));
    }
    return mp[pos][s][prev]=ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //int n;
    cin>>n;

        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
        }
        chk=1;
        int res=fun(0,0,0);
        if(res==1) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 35456
#include<stdio.h>
int main(){
  int n,s,a,b,c,d;
  while(scanf("%d",&n),n){
    s=0;
    while(n--){
      scanf("%d %d %d %d",&a,&b,&c,&d);
      a+=b+c;
      if     (a>160)b=9;
      else if(a>140)b=8;
      else if(a>120)b=7;
      else if(a>100)b=6;
      else if(a> 80)b=5;
      else if(a> 60)b=4;
      else          b=3;
      if     (d>25)c=9;
      else if(d>20)c=8;
      else if(d>15)c=7;
      else if(d>10)c=6;
      else if(d> 5)c=5;
      else if(d> 2)c=4;
      else         c=3;
      if(b<c)b=c;
      if(b==9)b=0;
      s+=b;
    }
    printf("%d\n",s*200);
  }
  return 0;
}

Measured memory_bytes: 600
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
ans = l[k - 1]
print(ans)

Measured memory_bytes: 9084
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vector<vector<pair<ll, ll>>> G;
vl ans;  // ans[i] : 辺iの色

void dfs(ll v, ll p, ll color) {  // いま見ている頂点v、vの親p、vとpを結ぶ辺の色color
    ll num = 1;
    rep(i, G[v].size()) {
        ll u = G[v][i].first;  // vと隣接する頂点
        ll e = G[v][i].second;  // vにつながっている辺
        if(u == p) {
            continue;
        }
        if(num == color) {
            num++;
        }
        ans[e] = num;
        num++;
        dfs(u, v, ans[e]);
    }
}

int main() {
    ll n;
    cin >> n;

    G.resize(n);
    ans.resize(n-1);

    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(make_pair(b, i));
        G[b].pb(make_pair(a, i));
    } 
    
    dfs(0, -1, -1);

    ll K = 0;
    rep(i, n) {
        chmax(K, (ll)G[i].size());
    }
    out(K);
    rep(i, n-1) {
        out(ans[i]);
    }

    re0;
}

Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
long long a[41];
int main()
{
	a[0]=2;
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	  a[i]=a[i-1]*2+2;
	printf("%lld\n",a[n]);
	return 0;
}

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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int h, w, i, j;
    cin>>h>>w;
    char s[h][w];
    int ans[h][w];
    int x[4] = {-1, 0, 0, 1};
    int y[4] = {0, -1, 1, 0};
    int dx, dy;
    int ans2 = 0;

    for(i=0; i<h; i++){
        for(j=0; j<w; j++){
            cin>>s[i][j];
            ans[i][j] = -1;
            if(s[i][j] == '.'){
                ans2++;
            }
        }
    }

    queue<pair<int, int> >q;

    q.push({0, 0});
    ans[0][0] = 0;

    while(!q.empty()){
        pair<int, int> P = q.front();
        q.pop();
        for(i=0; i<4; i++){
            dx = P.first + x[i];
            dy = P.second + y[i];
            if(dx>=0 && dx<h && dy>=0 && dy<w && ans[dx][dy] == -1 && s[dx][dy] == '.'){
                ans[dx][dy] = ans[P.first][P.second] + 1;
                q.push({dx, dy});
            }
        }
    }

    if(ans[h-1][w-1] == -1){
        cout<<"-1"<<endl;
    }
    else{
        cout<<ans2-ans[h-1][w-1]-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <queue>
#include <algorithm>
using namespace std;

#define rep(i,n)for(int i=0; i<(int)(n); i++)
#define bitrep(tmp, N)for (int tmp=0; tmp < (1<<N);tmp++)
#define all(v) v.begin(), end.bigin()

int INF = 10e9;
using P = pair<int,int>;


int main(){
  int N;
  cin >> N;
  vector<P> robots(N);
  int pos, arm;
  rep(i,N){
    cin >> pos >> arm;
    robots.at(i).first = pos+arm;
    robots.at(i).second = pos-arm;
  } 

  int count = 0, t=-INF;
  sort(robots.begin(), robots.end());
  for(int i=0; i<N; i++){
    if(t<=robots[i].second){
      count++;
      t = robots[i].first;
    }
  }
  cout << count;
}

Measured memory_bytes: 1024
// 1_5_D

#include <iostream>
using namespace std;

int main(){
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++){
    if(i%3 == 0) cout << " " << i;
    else{
      int x = i;
      while(true){
        if(!x) break;
        if(x%10 == 3){
          cout << " " << i;
          break;
        } else{
          x /= 10;
        }
      }
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

void fail(int i) {
    printf("NO\n");
    exit(0);
}

int bitRev(int x, int n) {
    int r = 0;
    for (int i = 0; i < n; ++i) {
        r <<= 1;
        r ^= (x & 1);
        x >>= 1;
    }
    return r;
}

int n, m;
int a[1 << 18];
int mn[1 << 18];
int mx[1 << 18];
int val[1 << 18];
int ans[1 << 18];
vector<pii> ord[1 << 18];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	m = (1 << n);
	for (int i = 0; i < m; ++i) {
        cin >> a[i];
        --a[i];
	}
	for (int i = 0; i < m; ++i) {
        mn[i] = 0;
        if (a[i] != -1) mn[i] = a[i];
        for (int j = 0; j < n; ++j) {
            if ((i >> j) & 1)
                mn[i] = max(mn[i], mn[i ^ (1 << j)] + 1);
        }
	}
	
	for (int i = m; i--; ) {
        mx[i] = m - 1;
        if (a[i] != -1) mx[i] = a[i];
        for (int j = 0; j < n; ++j) {
            if ((i >> j) & 1) continue;
            mx[i] = min(mx[i], mx[i ^ (1 << j)] - 1);
        }
	}
	for (int i = 0; i < m; ++i) {
        ord[mn[i]].emplace_back(mx[i], i);
	}
	set<pii> mp;
	for (int it = 0; it < m; ++it) {
        for (pii i : ord[it]) {
            mp.insert(i);
        }
        if (mp.empty()) fail(0);
        int r, j;
        tie(r, j) = *mp.begin();
        mp.erase(mp.begin());
        if (r < it) fail(1);
        val[j] = it;
	}
	printf("YES\n");
	for (int i = 0; i < m; ++i) {
        printf("%d%c", val[bitRev(i, n)] + 1, "\n "[i + 1 < m]);
	}
	return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for(int i = 0 ; i < n ; i++) cin >> h[i];
	const int inf = 1e9 + 1;
	vector<int> dp(n, inf);
	dp[0] = 0;
	for(int i = 0 ; i < n ; i++) {
		for(int j = i ; j < i + k + 1; j++) {
			if(j < n) {
				dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
			}
		}
	}
	cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 4004
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define MAX (1 << 29)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) { return s; }

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x);
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x);
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i) cin >> vec[i];
}

int main() {
  int N;
  cin >> N;
  int l = 0, r = N, c;
  vector<int> gender(N + 1);
  string s;
  cout << 0 << endl;
  cin >> s;
  if (s == "Female") gender[0] = gender[N] = 1;
  while (s != "Vacant") {
    c = (l + r) / 2;
    cout << c << endl;
    cin >> s;
    if (s == "Female") gender[c] = 1;
    if ((c - l) % 2 == 0 ^ (gender[l] ^ gender[c] == 0)) {
      r = c;
    } else {
      l = c;
    }
  }
  return 0;
}

Measured memory_bytes: 1236
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int[] a = new int[N];
		a[0] = sc.nextInt();
		int min = a[0];
		int max = a[0];
		int cnt = 1;
		for(int i=1; i<N; i++){
			a[i] = sc.nextInt();
			if(a[i]<=min){
				min = a[i];
			}
			if(a[i]>=max){
				max = a[i];
			}
			if(a[i]==a[0]){
				cnt++;
			}
		}

		int maxCnt;
		int minCnt;
		if(max-min>1){
			System.out.print("No");
		}else if(max-min==1){
			if(a[0]==max){
				maxCnt = cnt;
				minCnt = N - cnt;
			}else{
				maxCnt = N - cnt;
				minCnt = cnt;
			}
			if(max >= minCnt + 1 && max <= minCnt + maxCnt / 2){
				System.out.print("Yes");
			}else{
				System.out.print("No");
			}
		}else if(max==min){
			if(N==max+1 || N>=max*2){
				System.out.print("Yes");
			}else{
				System.out.print("No");
			}
		}

	}

}


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

int main() {
    int n;
    cin >> n;
    
    int a = 0;
    int min = 1000001;
    int max = -1000001;
    long long int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a <= min) min = a;
        if (a >= max) max = a;
        sum += a;
    }
    printf("%d %d %ld\n", min, max, sum);
}


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

#define LL long long int
#define LD long double
#define inp_s ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define mod 1000000007

int main(){
      int n, k;
      cin >> n;
      for(int i=0 ; i<=200 ; i++){
            for(int j=0 ; j<=200 ; j++){
                  if(4*i + 7*j == n){
                        cout << "Yes\n";
                        return 0;
                  }
                  
            }
      }
      cout << "No\n";
      return 0;
}

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

int main()
{
    int a,b,n,ans;
    while(cin >> a >> b >> n){
       ans = 0;
       a %= b;
       for(int i = 0; i < n; ++i){
           a *= 10;
           ans += a / b;
           a %= b;
       }
       cout << ans << endl;
    }

}

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

int main(){
  string N;
  cin >> N;
  if(N[0] == '9'){
    cout << "Yes" << endl;
  }
  else if(N[1] == '9'){
cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3528
#include <stdio.h>

int main(void)
{
	int a[200] = {0};
	int b[200] = {0};
	int sum[200] = {0};
	int dn[200] = {0};
	int i = 0;
	int j = 0;
	
    while (scanf("%d %d", &a[i], &b[i]) != EOF){
		sum[i] = a[i] + b[i];
    	i++;
	}
	
	for (j = 0; j < i; j++){
		while (sum[j] != 0){
			sum[j] /= 10;
			dn[j]++;
		}
	}
	
	for (j = 0; j < i; j++){
		printf("%d\n", dn[j]);
	}
    return (0);
}

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

int main() {
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    vector<int> ld = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    cout << (D1 == ld[M1] ? true : false) << endl;

    return 0;
}

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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }


void seethis(vector<ll>vect)
{
    for(ll x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

int main()
{
	FASTIO;
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
	    ll n;
	    cin>>n;
	    set<string>se;
	    while(n--)
        {
            string s;
            cin>>s;
            se.insert(s);
        }
        cout<<se.size()<<"\n";
	}
	return 0;
}













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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int r, c, k;
    cin >> r >> c >> k;
    vector<vi> rc(r, vi(c, -1));
    rep(i, k) {
        int ri, ci, v;
        cin >> ri >> ci >> v;
        --ri; --ci;
        rc[ri][ci] = v;
    }
    vector<vll> dp(4, vll(c+1, 0));
    rep(i, r) rep1(j, c) {
        ll up = 0;
        rep(i2, 4) up = max(up, dp[i2][j]);
        rep(t, 4) {
            if (rc[i][j-1] == -1) {
                dp[t][j] = max({dp[t][j], up, dp[t][j-1]});
            }
            else {
                if (t+1 <= 3) dp[t+1][j] = max({dp[t+1][j], up+rc[i][j-1], dp[t][j-1]+rc[i][j-1]});
                dp[t][j] = max({dp[t][j], up, dp[t][j-1]});
            }
        }
    }
    cout << dp[3][c] << endl;
    return 0;
}


Measured memory_bytes: 38616
#include<stdio.h>
int main()
{
  int N;
  int p[25]={};
  scanf("%d",&N);
  int i;
  int count=0;
  
  for(i=0;i<N;i++)
    scanf("%d",&p[i]);
  
  for(i=0;i<N-2;i++)
  {
    if(p[i]<=p[i+1]&&p[i+1]<=p[i+2])
      count++;
    else if(p[i]>=p[i+1]&&p[i+1]>=p[i+2])
      count++;
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 128
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,a,b = inpl()
p = pow(2,n,mod)
x = y = 1
for i in range(a):
    x *= n-i
    x %= mod
for i in range(a):
    x *= pow(a-i,mod-2,mod)
    x %= mod

for i in range(b):
    y *= n-i
    y %= mod
for i in range(b):
    y *= pow(b-i,mod-2,mod)
    y %= mod
# print(x,y)
print((p-x-y-1)%mod)

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<ll>>;
#define MAX 1000000007

int main()
{
    int k;
    cin >> k;
    string s="ACL";
    rep(i,k)cout << s;
    cout << endl;
}

Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include<map>
#define int long long int

using namespace std;

signed main(){

    int a[3], i, j, tmp = 0;   
    
    for(i = 0; i < 3; i++){
        cin >> a[i];
    }

    for(i = 0; i < 2; i++){
        for(j = i + 1; j < 3; j++){
            
            if(a[i] < a[j]){
                tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
    }

    if(a[0] == a[1] + a[2]){
        cout << "Yes\n";
        return 0;
    }else{
        cout << "No\n";
        return 0;
    }

}


Measured memory_bytes: 256
N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])

Measured memory_bytes: 53884
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader() {
			br =  new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while(st==null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
					
				}
				catch(IOException e) {
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
	}
	public static void main(String[] args) {
		FastReader ob = new FastReader();
		String s = ob.next();
		int arr[] = new int[2];
		for(int i=0;i<s.length();i++) {
			arr[s.charAt(i)-'A']++;
		}
		if(arr[0]==3 || arr[1]==3) {
			System.out.println("No");
			return;
		}
		System.out.println("Yes");
		
	}

}


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

class Main {
	static int[][] resultList = new int[10][10];
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//標準入力から値の読み込み
		String str = in.readLine();
		//入力さた行数分インクを落とす
		while (str != null) {
			if("".equals(str)) break;
			String[] strList =str.split(",");
			int row = Integer.parseInt(strList[0]);
			int colum = Integer.parseInt(strList[1]);
			int size =  Integer.parseInt(strList[2]);
			str = in.readLine();
			switch(size){
			case  1:
				smallDrop(row,colum);
				break;
			case  2:
				middleDrop(row,colum);
				break;
			case  3:
				largeDrop(row,colum);
				break;
			}
		}

		//結果の出力
		reult(resultList);
	}
	//インク小
	static void smallDrop(int row,int colum){
		resultList[row][colum] =+ 1;
		if(colum < 9) resultList[row][colum + 1]++;
		if(row < 9) resultList[row + 1][colum]++;
		if(colum > 0) resultList[row][colum - 1]++;
		if(row > 0)resultList[row -1][colum]++;
	}

	//インク中
	static void middleDrop(int row,int colum){
		smallDrop(row,colum);
		if(row < 9 && colum < 9) resultList[row + 1][colum + 1]++;
		if(row < 9 && colum > 0) resultList[row + 1][colum - 1]++;
		if(row > 0 && colum > 0) resultList[row - 1][colum - 1]++;
		if(row > 0 && colum < 9) resultList[row - 1][colum + 1]++;
	}

	//インク大
	static void largeDrop(int row,int colum){
		middleDrop(row,colum);
		if(colum < 8) resultList[row][colum + 2]++;
		if(row < 8) resultList[row + 2][colum]++;
		if(colum > 1) resultList[row][colum - 2]++;
		if(row > 1)resultList[row -2][colum]++;
	}

	//結果出力用
	//色のついていない部分のマス目の個数第１行目に、
	//１番濃いマス目の濃さを第２行目に出力
	static void reult(int[][] resultList){
		//色のついていない部分のマス目
		int  cleanSquares = 0;
		//１番濃いマス目の濃さ
		int depth = 0;

		//色のついていない部分のマス目と１番濃いマス目の濃さを調べる
		for(int i =0 ; resultList.length > i ;  i++){
			for(int j = 0 ; resultList[i].length > j ; j++){
				if(depth < resultList[i][j]) depth = resultList[i][j];
				else if(resultList[i][j] == 0) cleanSquares++;
			}
		}

		//結果を出力
		System.out.println(cleanSquares);
		System.out.println(depth);
	}

}

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

// 桁数を返す
int cnt_digits(ll X){
    int cnt=0;
    while(X>0){
        X/=10;
        cnt++;
    }
    return cnt;
}

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<pair<int,int>,int>> v(m);

    rep(i,m){
        int p,y;
        cin>>p>>y;
        v[i]={{p,y},i};
    }

    sort(all(v));
    vector<string> ans(m,"");

    int num=1;
    int c=6-cnt_digits(v[0].first.first);
    rep(i,c) ans[v[0].second]+='0';
    ans[v[0].second]+=to_string(v[0].first.first);
    c=6-cnt_digits(num);
    rep(i,c) ans[v[0].second]+='0';
    ans[v[0].second]+=to_string(num);

    //cout<<ans[v[0].second]<<endl;
    
    for(int i=1;i<m;i++){
        if(v[i].first.first!=v[i-1].first.first) num=1;
        else num++;

        c=6-cnt_digits(v[i].first.first);
        rep(j,c) ans[v[i].second]+='0';
        ans[v[i].second]+=to_string(v[i].first.first);
        c=6-cnt_digits(num);
        rep(j,c) ans[v[i].second]+='0';
        ans[v[i].second]+=to_string(num);
    }

    rep(i,m) cout<<ans[i]<<endl;
}


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

int main()
{
	int q;
	scanf("%d", &q);
	for (int i = 0; i < q; i++)
	{
		long long a, b;
		scanf("%lld%lld", &a, &b);
		if (a > b)
			std::swap(a, b);
		long long count{2 * a - 2};
		if (a + 1 < b)
		{
			// a, b - 1、これには対になるものがない
			// これ以降は[a + 1, b - 2]で探せばよい
			count++;
			// (left, right]で
			long long left{a + 1}, right{b - 1};
			while (left + 1 < right)
			{
				long long mid{(left + right) / 2};
				if (mid * mid < a * b)
					left = mid;
				else
					right = mid;
			}
			if (left * left < a * b)
			{
				long long tmp_max{2 * std::min(left - a - 1, b - 2 - left) + 1};
				if (left * (left + 1) <= a * b - 1)
				{
					tmp_max = std::max(tmp_max, 2 * std::min(left - a, b - 1 - left));
				}
				count += tmp_max;
			}
		}
		printf("%lld\n", count);
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = 0;
    for (int i=0;i<n;i++) {
      a+=sc.nextInt()-1;
    }
    System.out.println(a);
  }
}


Measured memory_bytes: 27184
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;


template <class T> T gcd(T a, T b){
    if(b>a) T tmp = a, a=b, b=tmp;
    if(b==0) return a;
    else return gcd(b,a%b);
}

template <class T> T gcd_n(const vector<T> &V){
    T tmp=V[0];
    for( auto v : V) tmp = gcd(tmp, v);
    return tmp;
}

template <class T> T lcm(T a, T b){
    if(a==0 || b==0) return 0;
    else 
    {
        T g=gcd(a,b);
        return g*(a/g)*(b/g);
    }
}
template <class T> T lcm_n(const vector<T> &V){
    T gcd_ = gcd_n(V);
    T tmp = V[0];
    for(auto v : V) tmp = lcm(tmp, v);
    return tmp;
}

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> X(n, 0);
    REP(i, n) cin >> X[i];

    vector<int> dist(n, 0);
    REP(i, n) dist[i]=abs(X[i]-x);
    cout << gcd_n(dist)<< endl;
    return 0;
}

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

const int MAXN = 51;
typedef long long LL;
LL A[MAXN]; int n;
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n; LL tc = 0;
	for (int i = 1; i <= n; ++i) std::cin >> A[i];
	while (true) {
		int at = std::max_element(A + 1, A + 1 + n) - A;
		if (A[at] < n) break;
		LL t = A[at] / n; tc += t;
		for (int i = 1; i <= n; ++i) if (i != at) A[i] += t;
		A[at] %= n;
	}
	std::cout << tc << std::endl;
	return 0;
}


Measured memory_bytes: 256
wa, num = map(int, input().split())
kame = (num / 2) - wa
turu = wa - kame

if (kame >= 0 and turu >= 0) and (wa == kame + turu) and (num == 2 * turu + 4 * kame) and (
        kame.is_integer() and turu.is_integer()):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9192
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

const double INF = 1e12;
const double GR = (sqrt(5) - 1.0) / 2.0; // GR == 0.618
// Func = double(*)(double);
template<class Func> double argmax(Func f, double lo = -INF, double hi = INF, const int LOOP = 60) {
    double x = hi - GR * (hi - lo), y = lo + GR * (hi - lo);
    double vx = f(x), vy = f(y);
    for (int i=0; i<LOOP; i++) {
	if (vx < vy) { lo = x; x = y; vx = vy; y = lo + GR * (hi - lo); vy = f(y); }
	else { hi = y; y = x; vy = vx; x = hi - GR * (hi - lo); vx = f(x); }
    }
    return (x+y)/2.0;
}

int P[6], Q[6];
double F(double a) {
    double ret = 0;
    REP (i, 6) {
	ret += max(P[i]*a, Q[i]*(1.0-a)) / 100;
    }
    return -ret;
}

void MAIN() {
    REP (i, 6) scanf("%d", P+i);
    REP (i, 6) scanf("%d", Q+i);
    double a = argmax(F, 0, 1.0);
    printf("%.12f\n", -F(a));
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
from sys import stdin
import fractions


n,x = [int(x) for x in stdin.readline().rstrip().split()]

li = list(map(int,stdin.readline().rstrip().split()))
lin = []
for i in range(len(li)):
    lin.append(abs(li[i]-x))
poi = lin[0]
for i in range(len(lin)-1):
    poi = fractions.gcd(poi,lin[i+1])

print(poi)

Measured memory_bytes: 16276
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, n) for(long long (i) = (a); (i) < (n); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define GET(v) cin >> (v)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

int main()
{
    int n;
    GET(n);
    
    switch(n) {
        case 22: SHOW("Christmas Eve Eve Eve"); break;
        case 23: SHOW("Christmas Eve Eve"); break;
        case 24: SHOW("Christmas Eve"); break;
        case 25: SHOW("Christmas"); break;
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int n;
    cin>>n;
    REP(i,n){
        int tmp;
        cin>>tmp;
        if(tmp%2==0){
            if(tmp%3!=0&&tmp%5!=0){
                cout<<"DENIED";
                return 0;
            }
        }
    }
    cout<<"APPROVED";
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    int half = N / 2;
    std::cout<<std::fixed<<std::setprecision(10);
    cout << (long double)(N - half)/N << endl; // "3.14"
    return 0;
}

Measured memory_bytes: 256
import sys

a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

card = [
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0]
]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if(b[i] == a[j][k]):
                card[j][k] = 1

if card[0].count(1) == 3:
    print("Yes")
    sys.exit()

if card[1].count(1) == 3:
    print("Yes")
    sys.exit()

if card[2].count(1) == 3:
    print("Yes")
    sys.exit()

if card[0][0] == 1 and card[1][0] == 1 and card[2][0] == 1:
    print("Yes")
    sys.exit()

if card[0][1] == 1 and card[1][1] == 1 and card[2][1] == 1:
    print("Yes")
    sys.exit()

if card[0][2] == 1 and card[1][2] == 1 and card[2][2] == 1:
    print("Yes")
    sys.exit()

if card[0][0] == 1 and card[1][1] == 1 and card[2][2] == 1:
    print("Yes")
    sys.exit()

if card[0][2] == 1 and card[1][1] == 1 and card[2][0] == 1:
    print("Yes")
    sys.exit()

print("No")


Measured memory_bytes: 62240
import static java.lang.System.*;
import java.util.*;
 
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		TreeSet<Integer> set = new TreeSet<>();
		for (int i=a; i<=Math.min(b,a+k-1); i++) set.add(i);
		for (int i=b; i>=Math.max(a,b-k+1); i--) set.add(i);
		set.forEach(out::println);
	}
}

Measured memory_bytes: 27860
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

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

  cout << min(b/a, c) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>

//マップの最大値
#define MAP_MAX		100

//マップの文字列
char wh_map[MAP_MAX][MAP_MAX + 1];



//----- 再帰関数 -----//
void f_saiki(int , int , int , int , char);

//----- 答えを返す関数 -----//
int f_ans(int , int);

//----- 初期化関数 -----//
void f_syokika(int);




//*****----- main -----*****//

int main(void)
{
	//縦のマップと横のマップ
	int tate = 0 , yoko = 0;
	//答えを格納する変数
	int ans = 0;
	
	//縦と横を入力
	while (1)
	{
		scanf("%d%d" , &tate , &yoko);
		if (tate == 0 && yoko == 0)
		{
			return 0;
		}

		//マップを入力
		f_syokika(tate);

		//関数で処理
		ans = f_ans(tate , yoko);
		printf("%d\n" , ans);
	}
}



//*****----- 再帰関数 -----*****//

void f_saiki(int x , int y , int tate , int yoko , char tansakumozi)
{
	//まず現在座標をNULLとする
	wh_map[y][x] = NULL;

	//4方向を実現する配列
	int h_tate[4] = {1 , -1 , 0 , 0};
	int h_yoko[4] = {0 , 0 , 1 , -1};

	for (int i = 0; i < 4; i++)
	{
		//次座標
		int nextx = x + h_yoko[i];
		int nexty = y + h_tate[i];

		//４方向の座標で、行ける且つ文字が同じところを探す
		if (nexty >= 0 && nexty < tate && nextx >= 0 && nextx < yoko)
		{
			//同じ文字が続く
			if (wh_map[nexty][nextx] == tansakumozi)
			{
				f_saiki(nextx , nexty , tate , yoko , tansakumozi);
			}
		}
	}
}



//*****----- 答えを返す関数 -----*****//

int f_ans(int tate , int yoko)
{
	//答えを返す変数
	int ans = 0;

	for (int i = 0; i < tate; i++)
	{
		for (int j = 0; j < yoko; j++)
		{
			//まだ探索していない
			if (wh_map[i][j] != NULL)
			{
				ans++;
				//再帰関数で同じ文字を消す
				f_saiki(j , i , tate , yoko , wh_map[i][j]);
			}
		}
	}

	return ans;
}




//*****----- 初期化関数 -----*****//

void f_syokika(int tate)
{
	for (int i = 0; i < tate; i++)
	{
		scanf("%s" , wh_map[i]);
	}
}

Measured memory_bytes: 2128
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (int)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


int extend_gcd(int a, int b, int& x, int& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    int x1, y1;
    int d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

int rowNum[]={-1,0,0,1};
int colNum[]={0,-1,1,0};

int main()
{
	fastio
	int n;
	cin>>n;

	string s;
	cin>>s;

	int idx=0,cntr=0,cntw=0,ans,cntr2=0,cntw2=0;

	for(int i=n-1;i>=0;i--)
	{
		if(s[i]=='R')
		{
			idx=i;
			break;
		}
	}

	for(int i=0;i<idx;i++)
	{
		if(s[i]=='W')
			cntw++;
	}

	idx=n-1;

	for(int i=0;i<n;i++)
	{
		if(s[i]=='W')
		{
			idx=i;
			break;
		}
	}

	for(int i=n-1;i>idx;i--)
	{
		if(s[i]=='R')
			cntr++;
	}

	ans = min(cntr,cntw);
	string temp = s;

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

	for(int i=0;i<n;i++)
	{
		if(s[i]=='W' && temp[i]=='R')
		{
			cntr2++;
		}
	}

	ans = min(cntr2,ans);
	cout<<ans<<endl;
}

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

int main() {
	int j;
	int memo = 0;
	int memo2 = 0;
	int n;
	int a[114514];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < n - 1; i++) {
		if (a[i] != a[i + 1]) {
			memo2++;
			j = i;
			while (1) {
				if (a[j] == a[i]) j++;
				else break;
			}
			if ((j - i) % 2 == 1) memo++;
		}
	}
	if (memo % 2 == 0)cout << memo2 + 1 << endl;
	if (memo % 2 == 1)cout << memo2 << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		int x = s.nextInt();
	    // int x2 = s.nextInt();
		System.out.println(x * x * x);
	}
	public static void main(String[] args) {
		
		new Main().run();
	}
}

Measured memory_bytes: 25904
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#define pi acos(-1)
using namespace std;
int main()
{
    int n;int a=0,b=0;
    cin>>n;
    while (n--) {
    string str1, str2;
    cin >> str1 >> str2;
        if ( str1 == str2 ){a++;b++;}
    else if ( str1 < str2 )b+=3;
    else if ( str1 > str2 )a+=3;
    }
    cout <<a<<" "<<b<< endl;
    return 0;
}



Measured memory_bytes: 3208