akhauriyash/Code-Regression huggingface dataset:
n = int(input())
ls_xu = [list(input().split()) for i in range(n)]

ans = 0
for i in range(n):
    if ls_xu[i][1] == "BTC":
        ls_xu[i][0] = float(ls_xu[i][0]) * 380000
    else:
        ls_xu[i][0] = float(ls_xu[i][0])
    ans += ls_xu[i][0]
print(ans)

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

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

int main()
{
	int N;
	while(cin>>N, N)
	{
		char S,T,B;
		cin>>S>>T>>B;
		int s=S-'A';
		int t=T-'A';
		int b=B-'A';

		double p[16][3][3]={0};
		p[0][s/3][s%3] = 1;

		for(int i=1; i<=N; i++)
		{
			for(int y=0; y<3; y++)
			for(int x=0; x<3; x++)
			for(int d=0; d<4; d++)
			{
				int nx=x+dx[d];
				int ny=y+dy[d];

				if(nx<0 || 3<=nx || ny<0 || 3<=ny)
				{ nx=x; ny=y; }

				if(nx==b%3 && ny==b/3)
				{ nx=x; ny=y; }

				p[i][ny][nx]+=p[i-1][y][x]/4;
			}
		}

		cout << p[N][t/3][t%3] << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
#define INF 10000000
using namespace std;

typedef pair<int,int> P;
typedef pair<int,P> P2;

int m,n,k,d,num;

int stoi(string s){
  stringstream ss;
  ss << s;
  int a;
  ss >> a;
  return a;
}

int trans(string s){
  if(s=="H")return m+n;
  if(s=="D")return m+n+1;
  if(s[0]=='C'){
    s.erase(s.begin());
    return stoi(s)-1;
  }
  s.erase(s.begin());
  return stoi(s)+m-1;
}

int main(){
  while(cin >> m >> n >> k >> d && (m||n||k||d)){
    int cal[6],dijk[200][100];
    vector<P> dis[200];

    for(int i=0;i<m;i++)cal[i] = 0;

    num = m+n+2;
    for(int i=0;i<num;i++)
      for(int j=0;j<(1<<m);j++)dijk[i][j] = INF;

    for(int i=0;i<m;i++)cin >> cal[i];

    for(int i=0;i<d;i++){
      string a,b;
      int tmp;

      cin >> a >> b >> tmp;
      dis[trans(a)].push_back(P(trans(b),tmp));
      dis[trans(b)].push_back(P(trans(a),tmp));
    }

    priority_queue<P2 ,vector<P2> ,greater<P2> > q;
    dijk[m+n][0] = 0;
    q.push(P2(0,P(m+n,0)));

    while(q.size()){
      P2 p = q.top();q.pop();
      int dist = p.first, pos = p.second.first, cake = p.second.second;

      for(int i=0;i<(int)dis[pos].size();i++){
	int to = dis[pos][i].first, cost = dis[pos][i].second;
	int visit = cake;
	if(to<m){
	  if( (visit>>to) & 1)continue;
	  else visit += 1<<to;
	} 
	if(dijk[to][visit] > dist + cost){
	  dijk[to][visit] = dist + cost;
	  q.push(P2(dist+cost,P(to,visit)));
	}
      }
    }

    int ans = INF;
    for(int i=0;i<(1<<m);i++){
      int diet = 0;
      for(int j=0;j<m;j++)
	if( (i>>j) & 1)diet += cal[j];
      ans = min(ans,k*dijk[num-1][i] - diet);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1048
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"

const ll MOD = 1000000007;
const int INF = 1e9 + 1e8;
const int N = 2e5 + 5;

vector<int> v[N];
bool vis[N];
int val[N];
int res[N];
vector<int> lis(N, INF);

void dfs(int s){
    vis[s] = 1;

    auto it = UB(all(lis), val[s]);
    auto idx = it - lis.begin();
    auto temp = lis[idx];
    if(lis[idx - 1] < val[s]) lis[idx] = val[s];
    res[s] = LB(all(lis), INF) - lis.begin() - 1;

    for(auto i : v[s]) if(!vis[i]) dfs(i);

    lis[idx] = temp;
}
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    int n;
    cin >> n;
    repp(i, 1, n) cin >> val[i];
    in_edges(n - 1);

    lis[0] = -INF;
    dfs(1);
    repp(i, 1, n) cout << res[i] << endl;
}

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

Measured memory_bytes: 25256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから
void solve(){
  int n;
  cin>>n;
  cout<<(n+1)/2;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [-i for i in a]
heapq.heapify(a)

for i in range(m):
    p = heapq.heappop(a)*(-1)
    p //= 2
    heapq.heappush(a, -p)

print(-sum(a))

Measured memory_bytes: 20448
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n, cnt = 0; cin >> n;
  vector<ll> v(n);
  ll ans = 1;
  rep(i, n) cin >> v[i];
  sort(All(v), greater<ll>());
  for(int i = 0; i < n-1; i++){
    if(v[i] == v[i+1] && cnt != 2){
      i++;
      cnt++;
      ans *= v[i];
    }
  }
  if(cnt == 2) cout << ans << endl;
  else cout << "0" << endl;
  system("pause");
}


Measured memory_bytes: 1272
#include <stdio.h>

int main()
{
	int n,senro[10],i;
	
	for(i=0;i<10;i++)
		senro[i]=0;
	
	while(scanf("%d",&n)!=EOF)
	{
		if(n==0){
			for(i=9;i>=0;i--){
				if(senro[i]!=0){
					printf("%d\n",senro[i]);
					senro[i]=0;
					break;
				}
			}
		}else{
			for(i=0;i<10;i++){
				if(senro[i]==0){
					senro[i]=n;
					break;
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
from collections import*
class UNION_FIND(object):
    def __init__(self,n):
        #親の番号を格納する。親だった場合は-(その集合のサイズ)
        #作るときはParentの値を全て-1にする
        #こうすると全てバラバラになる
        self.parent=[-1 for i in range(n)]
        
    def root(self,x):
        #Aがどのグループに属しているか調べる
        if self.parent[x]<0:
            return x
        else:
            self.parent[x]=self.root(self.parent[x])  #親を再帰で探知 再帰は最後に上のifにひっかかる
            return self.parent[x]
 
    def size(self,x):
        #自分のいるグループの頂点数を調べる
        return -self.parent[self.root(x)]   #親をとってきたい
        
    def union(self,x,y):
        #AとBをくっ付ける
        #AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        #print(self.parent)
        x=self.root(x)
        y=self.root(y)
        #print(x,y)
        if x==y:   #すでにくっついてるからくっ付けない
            return False
            
        #大きい方(A)に小さいほう(B)をくっ付けたい
        #大小が逆だったらひっくり返しちゃう。
        if self.size(x)<self.size(y):
            x,y=y,x
        self.parent[x]+=self.parent[y]  #Aのサイズを更新する
        self.parent[y]=x   #Bの親をAに変更する
        return True


n,k,l=map(int,input().split())
u1=UNION_FIND(n)
u2=UNION_FIND(n)
d=defaultdict(int)

for i in range(k):
    a,b=map(int,input().split())
    u1.union(a-1,b-1)
for i in range(l):
    a,b=map(int,input().split())
    u2.union(a-1,b-1)

for i in range(n):
    d[(u1.root(i),u2.root(i))]+=1
print(*[d[(u1.root(i),u2.root(i))]for i in range(n)])

Measured memory_bytes: 41476
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	ll n;
	cin >> n;
	if (n % 2 == 1) {
		cout << 0 << '\n';
		return 0;
	}
	ll answer = 0;
	for (ll num = 5; num <= n; num *= 5) {
		ll x = n / num;
		answer += x / 2;		
	}
	cout << answer << '\n';
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>T operator()(T&& lhs, T&& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>T operator()(T&& lhs, T&& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();
}

bool next(std::array<int, 10>& ar, int M)
{
	if (M == 1)
	{
		return false;
	}
	for (auto i : boost::irange(10) | adaptor::reversed)
	{
		if (ar[i] != M)
		{
			++ar[i];
			for (auto j : boost::irange(i + 1, 10))
			{
				ar[j] = ar[i];
			}
			break;
		}
	}
	return ar[0] == 1;
}

void Main()
{
	std::array<int, 10> A = { 1,1,1,1,1,1,1,1,1,1 };
	int N, M, Q;
	std::cin >> N >> M >> Q;
	std::vector<std::tuple<int, int, int, int>> query;
	for (auto _ : boost::irange(Q))
	{
		int a, b, c, d;
		std::cin >> a >> b >> c >> d;
		query.emplace_back(a - 1, b - 1, c, d);
	}
	auto max = lib::min_v<int>;
	do
	{
		auto value = 0;
		for (auto [a, b, c, d] : query)
		{
			if (A[b] - A[a] == c)
			{
				value += d;
			}
		}
		max = std::max(max, value);
	} while (next(A, M));
	std::cout << max << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

using namespace std;

typedef long long ll;

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

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

	int x, y;
	cin >> x >> y;

	for(int a = 0; a <= x; a++){
		if(2 * a + 4 * (x - a) == y){
			cout << "Yes" << endl;
			exit(0);
		}
	}

	cout << "No" << endl;
}


Measured memory_bytes: 3632
import 'dart:io';

import 'dart:math' as math;

void main(List<String> arguments) {
  final abhm =
      stdin.readLineSync().split(' ').map((raw) => int.parse(raw)).toList();
  final a = abhm[0];
  final b = abhm[1];
  final h = abhm[2];
  final m = abhm[3];
  final hTheta = (60 * h + m) / 720 * 2 * math.pi;
  final mTheta = m / 60 * 2 * math.pi;
  final aX = a * math.cos(hTheta);
  final ay = a * math.sin(hTheta);
  final bX = b * math.cos(mTheta);
  final by = b * math.sin(mTheta);
  final dx = aX - bX;
  final dy = ay - by;

  print(math.sqrt(math.pow(dx, 2) + math.pow(dy, 2)));
}


Measured memory_bytes: 13172
#include <cstdio>
#include <cstring>
long long ans, n, m;

int main(){
	scanf("%lld%lld", &n, &m);
	if (n != 1 && m != 1){
		ans = m * n - (2 * m + 2 * n - 4);
	} else {
		if (n == 1 && m == 1) ans = 1;
		else ans = m * n - 2;
	}
	printf("%lld", ans);
	
	return 0;
} 

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int N;
	scanf("%d", &N);
	if (N==1)
	{
		printf("Hello World");
		return 0;
	}
	else
	{
		int a, b;
		scanf("%d %d", &a, &b);
		printf("%d", a + b);
		return 0;
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    cout << fixed << setprecision(10) << a/b << endl;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
use std::collections::BTreeMap;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize = read_as_vec()[0];

    let mut balls: Vec<(i64, i64)> = Vec::new();
    for _ in 0..n{
        let line = read_as_vec();
        balls.push((line[0], line[1]));
    }

    if balls.len() == 1{
        println!("1");
        return;
    }
    
    let mut btree = BTreeMap::new();
    for i in 0..n{
        for j in (i+1)..n{
            //println!("i = {}, j = {}", i, j);
            let mut p: i64 = balls[i].0 - balls[j].0;
            let mut q: i64 = balls[i].1 - balls[j].1;
            if p < 0{
                p = -p;
                q = -q;
            }else if p == 0 && q < 0{
                q = -q;
            }
            
            let current = btree.entry((p, q)).or_insert(0);
            *current += 1;
        }
    }

    
    println!("{}", n - btree.iter().map(|(_, value)| value).max().unwrap());
}


Measured memory_bytes: 4352
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int m;
    cin >> m;
    vi b(m);
    rep(i, m) cin >> b[i];

    bool x = true;
    rep(i, m) {
        if(!binary_search(all(a), b[i])) x = false;
    }

    cout << x << endl;
}


Measured memory_bytes: 4284
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll H,W;
    cin >>H>>W;
    vector<vector<ll>>A(H,vector<ll>(W));

    rep(i,H){
        rep(j,W){
            cin>>A[i][j];
        }
    }
    vector<tuple<ll,ll,ll,ll>>ans;
    rep(i,H){
        rep(j,W){
            if(A[i][j]%2==1){
                if(j != W-1){
                    A[i][j]--;
                    A[i][j+1]++;
                    ans.pb(make_tuple(i,j,i,j+1));

                }
                
            }
        }
        
    }

    rep(i,H){
        if(A[i][W-1]%2==1){
            if(i!=H-1){
                A[i][W-1]--;
                A[i+1][W-1]++;
                ans.pb(make_tuple(i,W-1,i+1,W-1));
            }
        }
    }

    cout << ans.size() << endl;

    rep(i,ans.size()){
        cout<<get<0>(ans[i])+1<<" "<<get<1>(ans[i])+1<<" "<<get<2>(ans[i])+1<<" "<<get<3>(ans[i])+1<<endl;
    }


    return 0;
    

}

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

#define M 1000002
#define NIL (-1)
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){
  long long key;
  int a1,a2,h3;
  int i=0;
 
  key = getKey(str);
  a1 = h1(key);
  a2 = h2(key);
  while(1){
    h3 =(a1 +i*a2)%M;
    if(strcmp(str,H[h3])==0) return 1;
    if((i==M) || (H[h3][0] == '\0')) return 0;
    i++;
  }
}

void insert(char str[]){
  long long key;
  int a1,a2,h3;
  int i=0;
  
  key = getKey(str);
  a1=h1(key);
  a2=h2(key);
  
  while(1){
    h3 =(a1 +i*a2)%M;
    if(H[h3][0] == '\0') break;
    i++;
  }
  strcpy(H[h3],str);
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 14280
k = int(input())
ai = reversed([int(x) for x in input().split()])
b = 2; t = 2
f = False
for a in ai:
    b = (((b-1)//a)+1)*a
    t = ((t//a)+1)*a-1
    if b > t:
        f = True
        break
if f:
    print(-1)
else:
    print(b,t)


Measured memory_bytes: 14252
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<algorithm>
#include<vector>

#define maxn 2000005
#define INF 0x3f3f3f3f3f3f3f3fll

using namespace std;

inline int getint()
{
	int num=0,flag=1;char c;
	while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
	while(c>='0'&&c<='9')num=num*10+c-48,c=getchar();
	return num*flag;
}

int n,K,X,Y;
int Q,lst;
long long val[maxn<<2][3],lazy[maxn<<2];

inline void add(int x,long long num)
{for(int i=0;i<3;i++)val[x][i]+=num;lazy[x]+=num;}
inline void pushdown(int i)
{add(i<<1,lazy[i]),add(i<<1|1,lazy[i]),lazy[i]=0;}
inline void pushup(int x)
{for(int i=0;i<3;i++)val[x][i]=min(val[x<<1][i],val[x<<1|1][i]);}

inline void update(int i,int l,int r,int x,long long num)
{
	if(l==r){val[i][0]=num,val[i][1]=num+l,val[i][2]=num-l;return;}
	pushdown(i);
	int mid=(l+r)>>1;
	if(x<=mid)update(i<<1,l,mid,x,num);
	else update(i<<1|1,mid+1,r,x,num);
	pushup(i);
}

inline long long query(int i,int l,int r,int ql,int qr,int tag)
{
	if(qr<l||r<ql)return INF;
	if(ql<=l&&r<=qr)return val[i][tag];
	pushdown(i);
	int mid=(l+r)>>1;
	return min(query(i<<1,l,mid,ql,qr,tag),query(i<<1|1,mid+1,r,ql,qr,tag));
}

int main()
{
	n=getint(),K=getint()-1,X=getint(),Y=getint();
	Q=getint();
	memset(val,0x3f,sizeof val);
	update(1,1,n,X,abs(Y-Q));
	update(1,1,n,Y,abs(X-Q));
	while(K--)
	{
		lst=Q;Q=getint();
		long long t0=query(1,1,n,lst,lst,0)+abs(Q-lst);
		long long t1=query(1,1,n,Q,n,1)-Q;
		long long t2=query(1,1,n,1,Q,2)+Q;
		long long ans=min(t0,min(t1,t2));
		add(1,abs(Q-lst));
		update(1,1,n,lst,ans);
	}
	printf("%lld\n",val[1][0]);
}

Measured memory_bytes: 194816
#include<bits/stdc++.h>
using namespace std;
int main(int,char**){
    int i,j,d,c[26],*s,*r;
    cin>>d;
    s = new int[26*d];
    r = new int[d];
    for(i=0;i<26;i++){
        cin>>c[i];
    }
    for(i=0;i<d;i++){
        for(j=0;j<26;j++){
            cin>>s[i*26+j];
        }
    }
    vector<int> v;
    for(i=0;i<26;i++){
        if(i==0){
            v.push_back(c[i]);
        }
        else{
            v.push_back(v.back()+c[i]);
        }
    }
    random_device rd;
    mt19937_64 mt(rd());
    int l[26];
    for(i=0;i<d;i++){
        int select = mt()%(v.back()+1);
        for(j=0;j<26;j++){
            if(v[j]>select){
                r[i] = j;
                break;
            }
        }
        int mostsat,mostsatidx;
        for(j=0;j<26;j++){
            if(s[i*26+j]>mostsat){
                mostsat=s[i*26+j];
                mostsatidx=j;
            }
        }
        if(c[mostsatidx]*(i-l[mostsatidx]+1)<mostsat){
            r[i]=mostsatidx;
        }
        l[i]=i+1;
    }
    for(i=0;i<d;i++){
        cout<<r[i]+1<<endl;
    }
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int MAX = 101010;
vi is_prime(MAX,1);
is_prime[0] = 0; is_prime[1] = 0;
for(int i = 2; i < MAX; ++i) {
if(!is_prime[i]) continue;
for(int j = i*2; j < MAX; j += i) is_prime[j] = 0;
}

int X;
cin >> X;
for(int i = X; i <= MAX; i++) {
    if(is_prime[i] == 1) {
        cout << i << endl;
        return 0;
    }
} 

return 0;
}

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

using namespace std;

int main(){
	int n; cin >> n;
	vector <string> v(n);
	for (int i = 0; i < n; i++){
		cin >> v[i];
	}
	bool rr = false;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			if (v[i][j] == '#')
				rr = true;
		}
	}
	if(!rr){
		cout << "-1" << endl;
 		return 0;
	}
	
	
	int r = n * 2;
	for (int i = 0; i < n; i++){
		int c = 0;
		bool hst = false;
		for (int j = 0; j < n; j++){
				if (v[j][i] == '#'){
				hst = true;
			}
			if (v[i][j] == '.'){
				c++;
			}
		}
		if (!hst){
			c++;
		}
		for (int j = 0; j < n; j++){
			bool hd = false;
			for (int z = 0; z < n; z++){
				if (v[z][j] == '.')
					hd = true;
			}
			if (hd)
				c++;
		}
		
		r = min(r, c);
		
	}
	
	cout << r << endl;
	
	return 0;
}

Measured memory_bytes: 512
/// {{{
#include "bits/stdc++.h"
#define   ALL(x)  x.begin(), x.end()
#define   iostreamBooster()  do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
using namespace std;
typedef long long i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

struct UnionFind {
  vector<int> u;
  explicit UnionFind(int n) : u(n+5, -1) {};
  int root(int i) { return u[i] < 0 ? i : u[i] = root(u[i]); }
  void unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return;
    u[x] += u[y];
    u[y] = x;
  }
};

int N, K, L;

signed main()
{
  iostreamBooster();

  cin >> N >> K >> L;

  UnionFind road(N);
  UnionFind rail(N);

  for (int i = 0; i < K; ++i) {
    int x, y; cin >> x >> y;
    road.unite(x, y);
  }

  for (int i = 0; i < L; ++i) {
    int x, y; cin >> x >> y;
    rail.unite(x, y);
  }

  unordered_map<int, int> cnt[200010];
  for (int i = 1; i <= N; ++i) {
    cnt[rail.root(i)][road.root(i)] += 1;
  }

  for (int i = 1; i <= N; ++i) {
    cout << cnt[rail.root(i)][road.root(i)] << '\n';
  }


  return 0;
}



Measured memory_bytes: 24576
#include <iostream>
#include <stdlib.h>

using namespace std;

int dir[9][2] = {
	{-1, -1},
	{0, -1},
	{1, -1},
	{-1, 0},
	{0, 0},
	{1, 0},
	{-1, 1},
	{0, 1},
	{1, 1}
};

int main(int argc, char **argv)
{
	int **array, **array2, *array3, n;
	
	cin >> n;
	for(int t = 0; t < n; t++){
		if(t > 0){
			cout << endl;
		}
		array = (int **)calloc(9, sizeof(int));
		array2 = (int **)calloc(9, sizeof(int));
		for(int i = 0; i < 9; i++){
			array[i] = (int *)calloc(9, sizeof(int));
			array2[i] = (int *)calloc(9, sizeof(int));
		}
		
		for(int i = 0; i < 9; i++){
			array3 = (int *)calloc(10, sizeof(int));
			for(int j = 0; j < 9; j++){
				cin >> array[i][j];
				array3[array[i][j]]++;
			}
			
			for(int k = 1; k <= 9; k++){
				if(array3[k] > 1){
					for(int j = 0; j < 9; j++){
						if(k == array[i][j]){
							array2[i][j] = 1;
						}
					}
				}
			}
			
			free(array3);
		}
		
		for(int i = 0; i < 9; i++){
			array3 = (int *)calloc(10, sizeof(int));
			for(int j = 0; j < 9; j++){
				array3[array[j][i]]++;
			}
			
			for(int k = 1; k <= 9; k++){
				if(array3[k] > 1){
					for(int j = 0; j < 9; j++){
						if(k == array[j][i]){
							array2[j][i] = 1;
						}
					}
				}
			}
			free(array3);
		}
		
		for(int i = 1; i < 9; i+=3){
			for(int j = 1; j < 9; j+=3){
				array3 = (int *)calloc(10, sizeof(int));
				for(int k = 0; k < 9; k++){
					array3[array[i+dir[k][0]][j+dir[k][1]]]++;
				}
				
				for(int k = 1; k <= 9; k++){
					if(array3[k] > 1){
						for(int l = 0; l < 9; l++){
							if(k == array[i+dir[l][0]][j+dir[l][1]]){
								array2[i+dir[l][0]][j+dir[l][1]] = 1;
							}
						}
					}
				}
				
				free(array3);
			}
		}
		
		for(int i = 0; i < 9; i++){
			for(int j = 0; j < 9; j++){
				if(array2[i][j] == 0){
					cout << " " << array[i][j];
				} else {
					cout << "*" << array[i][j];
				}
			}
			cout << endl;
		}
		
		for(int i = 0; i < 9; i++){
			free(array[i]);
			free(array2[i]);
		}
		free(array);
		free(array2);
	}
	
	return 0;
}

Measured memory_bytes: 0
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            n, a, b, c, x = map(int, raw_input().split())
            if n == 0 and a == 0 and b == 0 and c == 0 and x == 0:
                break
            y = map(int, raw_input().split())
            count = 0
            flg = False
            for i in range(len(y)):
                while x != y[i]:
                    x = (a * x + b) % c
                    count += 1
                    if count > 10000:
                        flg = True
                        break
                if flg:
                    print -1
                    break
                if i != len(y) - 1:
                    x = (a * x + b) % c
                    count += 1
            else:
                print count


        
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Measured memory_bytes: 4668
n = int(input())
time = 0
here = [0,0]
for i in range(n):
    t,x,y = map(int,input().split())
    if t - time < abs(x-here[0])+abs(y-here[1]):
        print("No")
        exit()
    if (t-time) % 2 != (abs(x-here[0])+abs(y-here[1]))%2:
        print("No")
        exit()
    time = t
    here = [x,y]
print("Yes")


Measured memory_bytes: 3064
N, M = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(map(int, input().split())) for _ in range(M)]
bc.sort(key=lambda x: x[1], reverse=True)
rest = N
for b, c in bc:
  a += [c] * min(rest, b)
  rest -= min(rest, b)
a.sort(reverse=True)
print(sum(a[:N]))

Measured memory_bytes: 23652
#include <iostream>
#include <algorithm>

using namespace std;

int Euclid(int a, int b)
{
	if(b == 0)
	{
		return(a);
	}
	else
	{
		Euclid(b, a % b);
	}
}

void solve()
{
	int a, b;
	while(cin >> a >> b)
	{
		if(a < b)
		{
			swap(a, b);
		}
		cout << Euclid(a, b) << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using p32 = pair<i32, i32>;

vector<vector<i32>> g;
vector<i32> visited, dp;

i32 dfs(i32 n = 0) {
    if (visited[n] == 2) return dp[n];
    visited[n] = 1;
    for (auto& e : g[n]) {
        if (visited[e] == 1) return -1;

        i32 tmp = dfs(e);
        if (tmp == -1) return -1;
        dp[n] = max(tmp + 1, dp[n]);
    }
    visited[n] = 2;
    return dp[n];
}

i32 id(i32 a, i32 b) {
    return a < b ? id(b, a) : a * (a-1) / 2 + b + 1;
}

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

    g.resize(n * (n-1) / 2 + 1);
    for (i32 i = 0; i < n; i++) {
        i32 a = 0;
        for (i32 j = 0; j < n-1; j++) {
            i32 b;
            cin >> b, b = id(i, b-1);
            g[a].push_back(b);
            a = b;
        }
    }

    visited.resize(n * (n-1) / 2 + 1);
    dp.resize(n * (n-1) / 2 + 1);
    cout << dfs() << endl;
}


Measured memory_bytes: 35456
n, m = map(int, input().split())

a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]
for i in range(n):
    for j in range(n):
        if a[i][j] == b[0][0] and i + m - 1 < n and j + m - 1 < n:
            flag = 1
            for y in range(m):
                for x in range(m):
                    if a[i + y][j + x] != b[y][x]:
                        flag = 0
                        break
                
            if flag == 1:
                print("Yes")
                exit()

print("No")


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
using namespace std;
#define MAX 100000
int main()
{
	int a;
	int b[100000];
	int count = 0;
	stack<int> s;
	stack<int> t;
	int x;
	cin >> a;
	
	for (int j = 0; j < a; j++)
	{
		cin >> b[j];

	}
	sort(b, b + a);
	
	for (int j = 0; j < a; j++)
	{
		s.push(b[j]);

	}

	/*
	for (int j = 0; j < a; j++)
	{
		cout << s.top();
		s.pop();

	}
	*/
	

	for (int j = 0; j < a; j++)
	{
		t.push(s.top());
		count++;
		//cout << t.top();
		s.pop();
		if (j < a - 1 && t.top() == s.top())
		{
			t.pop();
			s.pop();
			count--;
			j++;
		}
		

	}



	cout << count;
	
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        int[] a = new int[n];
        boolean[] bools = new boolean[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt()-1;
        }
        ArrayList<Integer> li = new ArrayList<Integer>();
        int now = 0;
        while(k > 0){
            if(!bools[now]){
                li.add(now);
                bools[now] = true;
                k--;
                now = a[now];
            }else{
                int prev = li.indexOf(now);
                long pp = li.size()-prev;
                long per = k % pp;
                int ppp = (int)per;
                prev += ppp;
                System.out.println(li.get(prev)+1);
                return;
            }
        }
        System.out.println(now+1);
    }
}


class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 47984
<?php

function strHacking($s) {
	$string_len = strlen($s);
	$return_str ='';
	for ($i=0; $i < $string_len; $i++) {

		if ($s[$i] == '1' || $s[$i] == '0') {
			$return_str .= $s[$i];
		}
		if ($s[$i] == 'B') {
			
			$return_str = substr($return_str, 0,strlen($return_str)-1);
		}

	}
	return $return_str;
}
fscanf(STDIN, "%s", $s);
echo strHacking($s) . "\n";
?>

Measured memory_bytes: 3700
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
	while(true)
	{
		int x[15000],n,m,y[15000],b,c,d,p[15000],minx;
		scanf("%d", &n);
		if(n==0){
			break;
		}
		for(int i=0;i<n;i++){
			scanf("%d", &y[i]);
			p[i] = x[i] = y[i];
		}
		c=0;
		d=0;
		m=n;
		d=m;
		minx=100000;
		for(int i=0;i<n;i++){
			for(int j=1;j<=3;j++){
				if(i>=1 && (y[i-1]!=j && y[i+1]!=j)){
					goto loopend;
				}
				p[i] = x[i] = j;
				//combo
				b=1;
				d=n;
				while(true){
					c=0;
					for(int k=0;k<m;k++){
						if(p[k]==p[k+1]){
							b++;
						}
						else{
							if(b >= 4){
								//erase
								for(int l = k + 1; l < m; l++)
								{
									p[l-b] = p[l];
								}
								d -= b;
								c++;
								for(int l=d;l<m;l++){
									p[l]=0;
								}
							}
							b=1;
						}	
						m=d;
					}

					if(c==0){
						break;
					}
					else{
						c=0;
					}
				}
				minx=min(minx,m);
				x[i]=y[i];
				for(int k=0;k<n;k++){
					p[k]=y[k];
				}
				loopend:;
			}
		}
		printf("%d\n", minx);
	}
	return 0;
}

Measured memory_bytes: 2712
#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define printmx(matrix) Loop(i, matrix.size()) { Loop(j, matrix[i].size()) { cout << matrix[i][j] << " "; } cout << endl; }
#define rndf(d) (ll)((double)(d) + (d >= 0 ? 0.5 : -0.5))
#define floorsqrt(x) ((ll)sqrt((double)x) + ((ll)sqrt((double)x) * (ll)sqrt((double)x) <= (ll)(x) ? 0 : -1))
#define ceilsqrt(x) ((ll)sqrt((double)x) + ((ll)x <= (ll)sqrt((double)x) * (ll)sqrt((double)x) ? 0 : 1))
#define rnddiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) * 2 >= (ll)(b) ? 1 : 0))
#define ceildiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) == 0 ? 0 : 1))
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)

/*******************************************************/

int main() {
	int n; cin >> n;
	vll a(n); Loop(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	ll m = a.back();
	auto k = lower_bound(a.begin(), a.end() - 1, m / 2);
	if (k == a.begin()) {
		cout << m << " " << *k << endl;
	}
	else {
		auto j = k;
		j--;
		if (abs(m - *k * 2) < abs(m - *j * 2)) cout << m << " " << *k << endl;
		else cout << m << " " << *j << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
// 🐋💭 Next Prime
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

func main() {
    let ab = readInts()
    let (a, b) = (ab[0], ab[1])
    let gcdValue = gcd(a, b)
    print(gcdValue * (a / gcdValue) * (b / gcdValue))
}
main()



Measured memory_bytes: 13504
import java.util.Scanner;

public class Main {
	void main() {
		Scanner sc = new Scanner(System.in);
				while(true) {
					String str = sc.nextLine();
					if(str.equals("0")) break;
					int l = str.length();
					int sum = 0;
					for(int i=0;i<l;i++) {
						char c = str.charAt(i);
						sum += c - '0';
					}
					System.out.println(sum);
				}
			}
			public static void main(String[] args) {
		new Main().main();
	}
}



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

int main(){
	std::string st;
	std::cin >> st;
	
	while(!(st.empty())){
		std::cout << st.back();
		st.erase(st.begin() + st.size() -1);
	}
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 1176
aI, aO, aT, aJ, aL, aS, aZ = map(int, input().split())

if aI * aJ * aL == 0:
    K = (aI // 2 + aJ // 2 + aL // 2) * 2 + aO
else:
    K1 = ((aI - 1) // 2 + (aJ - 1) // 2 + (aL - 1) // 2) * 2 + aO + 3
    K2 = (aI // 2 + aJ // 2 + aL // 2) * 2 + aO
    K = max([K1, K2])

print(K)

Measured memory_bytes: 3064
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	while (true) {
		int n;
		scanf("%d", &n);
		if (n == 0) return 0;
		vector<int> input;
		REP(i, n) {
			int a;
			scanf("%d", &a);
			input.push_back(a);
		}
		int ok[300][300] = {};
		vector<pair<int, int>> next;
		for (int i = 1; i < n; ++i) {
			if (abs(input[i] - input[i - 1]) <= 1) {
				ok[i - 1][i] = 1;
				next.push_back(make_pair(i - 1, i));
			}
		}
		for (int i = 0; i < next.size(); ++i) {
			int left = next[i].first;
			int right = next[i].second;
			if (left != 0 && right != n - 1) {
				//ok to expand
				if (abs(input[left - 1] - input[right + 1]) <= 1) {
					//ok
					if (ok[left - 1][right + 1] == 0) {
						ok[left - 1][right + 1] = 1;
						next.push_back(make_pair(left - 1, right + 1));
					}
				}
			}
			for (int i = 0; i < left; ++i) {
				if (ok[i][left - 1] == 1 && ok[i][right] == 0) {
					ok[i][right] = 1;
					next.push_back(make_pair(i, right));
				}
			}
			for (int i = right + 2; i < n; ++i) {
				if (ok[left][i] == 0 && ok[right+1][i] == 1) {
					ok[left][i] = 1;
					next.push_back(make_pair(left, i));
				}
			}
		}
		int dp[500] = {};
		for (int i = 0; i < n; ++i) {
			dp[i + 1] = max(dp[i], dp[i + 1]);
			for (int q = i + 1; q < n; ++q) {
				if (ok[i][q] == 1) {
					dp[q + 1] = max(dp[q + 1], dp[i] + (q - i + 1));
				}
			}
		}
		cout << dp[n] << endl;
	}
}



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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<pair<string,ll> > svp;

#define spc        ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define PI         2*acos(0.0)
#define lb         lower_bound
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define btpc       __builtin_popcountll
#define sp(x)      cout<<fixed<<setprecision(x)

const   long long  cs=2e5+5;
const   long long  inf=1e18;
const   long long  mod=1e9+7;
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;   vector<long long> v,v1;

    string s,s1;
    cin>>s;
    n=s.length();
    for(i=0;i<n;i++)
    {
        if(s[i]!='B') v.pb((s[i]-'0'));
        else {
            if(v.size()>0) v.pp();
        }
    }
    for(i=0;i<v.size();i++)
    {
        cout<<v[i];
    }
    cout<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    /*freopen ("input.txt","r",stdin);
    freopen ("output.txt","w",stdout);*/

    // ll tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3628
w, h, n = input().split()
lx ,ly ,hx ,hy = 0, 0, int(w), int(h)
for i in range(int(n)):
    S = list(map(int, input().split()))
    if S[2]==1 and lx<S[0]:
        lx = S[0]
    elif S[2]==2 and hx>S[0]:
        hx = S[0]
    elif S[2]==3 and ly<S[1]:
        ly = S[1]
    elif S[2]==4 and hy>S[1]:
        hy = S[1]
ans = int(hx-lx)*int(hy-ly) 
if hx-lx<=0 or hy-ly<=0:
    print(0)
else: print(ans)



Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define de(x) cout<<#x<<" = "<<x<<endl
using namespace std;
typedef long long ll;
int a,b,c,d,e,f;
double gl=0;
double g=0;
int main()
{
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    int water=0,suger=0;
    int watter=0;
    ll ro=0;
    int ans1=0,ans2=0;

    for(int i=0;i<=35;i++)
    {
        water=i*a;
        for(int j=0;j<=35;j++)
        {
            water=water+j*b;
            watter=water*100;
            for(int k=0;k<=1500;k++)
            {
                ro=water*e;
               // suger=k*c;
                for(int z=0;z<=1500;z++)
                {
                    suger=k*c+d*z;
                    if(suger>3000) break;
                   // if(suger==934) {de(11);return 0;}
                    if(suger+watter!=0&&suger<=ro&&suger+watter<=f)
                    {
                        g=1.0*suger/watter;
                        //de(g);
                        if(gl<=g)
                        {
                          //  de(111);
                        gl=g;
                        ans1=watter+suger;ans2=suger;
                        }
                    }

                }
            }
        }

    }
    cout<<ans1<<" "<<ans2<<endl;
}


Measured memory_bytes: 384
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 10;
const int M = 20;
const int mod = 1e9 + 7;

int dp[N][M];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    s = '.' + s;
    dp[0][0] = 1;
    for (int i = 1; i < s.size(); i ++){
        if (s[i] != '?'){
            for (int j = 0; j < 13; j ++)
                dp[i][(10 * j + s[i] - '0') % 13] = (dp[i][(10 * j + s[i] - '0') % 13] + dp[i - 1][j]) % mod;
        }
        else{
            for (int k = 0; k < 10; k ++){
                s[i] = (char)(k + '0');
                for (int j = 0; j < 13; j ++)
                    dp[i][(10 * j + s[i] - '0') % 13] = (dp[i][(10 * j + s[i] - '0') % 13] + dp[i - 1][j]) % mod;
            }
        }
    }
    cout << dp[s.size() - 1][5];
    return 0;
}


Measured memory_bytes: 8172
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K,H,W, mi1,mi2,sum;
LL ans,a;
LL no;
string s,t;

int main() {
	cin >> s;
	cin >> t;
	ans = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i])ans++;
	}
	cout << ans << endl;

	return 0;
}



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

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vector <int> > vvi;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);


typedef pair<int,bool> P;

int main(){
    //    cin.tie(0);
    //    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<ll,int> M;
    vll A(N);
    REP(i,N)cin >> A[i];
    so(A);rev(A);
    int ans = 0;
    cerr << "S" << endl;
    REP(i,N){
        bool b = false;
        cerr << M[A[i]] << endl;
        if(M[A[i]] >= 1){
            M[A[i]]--;
            ans++;
            b = true;
        }
        if(b)continue;
        ll n = 1;
        while(n <= A[i]){
            n *= 2;
        }
        M[n-A[i]]++;
        cerr << n - A[i] << ":" << M[n-A[i]] << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 26752