akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string str;
    cin >> str;
    vector<pair<int, int>> over_3;

    for (int i = A - 1; i < C - 1; i++) {
        if (str[i] == '#' && str[i + 1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i = B - 1; i < D - 1; i++) {
        if (str[i] == '#' && str[i + 1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    if (C < D) {
        cout << "Yes" << endl;
        return 0;
    } else {
        if (str[D - 2] == '.' && str[D] == '.') {
            cout << "Yes" << endl;
            return 0;
        } else {
            int left, cont = 0;
            for (int i = 0; i < N; i++) {
                if (str[i] == '.' && cont == 0) {
                    left = i;
                    cont = 1;
                } else if (str[i] == '#' && cont == 1) {
                    cont = 0;
                    if (i - left >= 3) {
                        over_3.push_back({left, i - 1});
                    }
                }
            }
            if (cont == 1) {
                over_3.push_back({left, N - 1});
            }
            for (auto p : over_3) {
                if ((p.first <= B - 1 && B - 1 < p.second) ||
                    (B - 1 < p.first && p.second < D - 1) ||
                    (p.second == D - 1)) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  cin >>N;
  vector<int>vec(N);
  rep(i,N) {
cin >>vec.at(i);
  }
  int sum=0;
  rep(i,N) {
sum +=vec.at(i);
  }
  
vector<int> vect(N-1);
  repl(j,0,N-1) {
int S1=0; //at(j)まで
    rep(k,j+1) {
      S1 +=vec.at(k);
    }
int S2=sum-S1;
    vect.at(j)=abs(S2-S1);
  }
  sort(all(vect));
  cout <<vect.at(0)<< endl;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 1010, inf = maxn;
int cnt[maxn], n;
vector<int> res;
vector<int> operator + (vector<int> a, vector<int> b) {
	a.insert(a.end(), b.begin(), b.end());
	return a;
}
bool stvalid() { return *min_element(cnt, cnt+n) * 2 >= *max_element(cnt, cnt+n); }
vector<int> minimize(vector<int> a) {
	static int backup[maxn];
	copy(cnt, cnt+n, backup);
	vector<bool> vis(n);
	for (int i : a) if (vis[i])
		return vector<int>{inf};
	else vis[i] = true;
	int m = a.size();

	vector<int> b;
	for (int i = 0;i < n;++i)
		if (!vis[i]) b.pb(i), a.pb(i), --cnt[i];

	assert(a.size() == n);
	int mx = *max_element(cnt, cnt+n), mn = *min_element(cnt, cnt+n);

	if (mn * 2 >= mx) {
		copy(backup, backup+n, cnt);
		sort(b.begin(), b.end());
		return b;
	}
	if (mn < 0) {
		copy(backup, backup+n, cnt);
		return vector<int> {inf};
	}

	if (mn * 2 + 1 == mx) {
		//cerr << "in \n";
		int fstmin = inf, lstmax = -inf;
		for (int i = 0;i < n && fstmin == inf;++i)
			if (cnt[i] == mn) fstmin = i;
		for (int i = n-1;i >= 0 && lstmax == inf;++i)
			if (cnt[i] == mx) lstmax = i;
		if (fstmin < m && lstmax > fstmin) {
			copy(backup, backup+n, cnt);
			return vector<int>{inf};
		}
		//cerr << "AA";
		vector<int> c, d, e, res;
		for (int i : b) if (cnt[i] == mx)
			c.pb(i);
		else if (cnt[i] == mn)
			d.pb(i);
		else
			e.pb(i);
				
		copy(backup, backup+n, cnt);
		sort(c.begin(), c.end(), greater<>());
		sort(d.begin(), d.end(), greater<>());
		sort(e.begin(), e.end(), greater<>());

#define GB(v) (v.size()?v.back():inf)
		while (c.size()+d.size()+e.size()) {
			if (c.size()) {
				int x = c.back(), y = GB(e);
				if (x < y) {
					res.pb(x);
					c.pop_back();
				}
				else {
					res.pb(y);
					e.pop_back();
				}
			}
			else {
				int x = GB(d), y = GB(e);
				if (x < y) {
					res.pb(x);
					d.pop_back();
				}
				else {
					res.pb(y);
					e.pop_back();
				}
			}
		}
		return res;
	}
	copy(backup, backup+n, cnt);
	assert(mn * 2 < mx);
	return vector<int>{ inf };
}
void solve() {
	int sum = accumulate(cnt, cnt+n, 0);
	if (!stvalid())
		puts("-1"), exit(0);
	res = minimize(vector<int>());
	for (int i : res)
		--cnt[i];
	while (res.size() < sum) {
//	for (int i : res)
//		cout << i+1 << ' ';
//	cout << '\n';
		vector<int> ad = minimize(vector<int>());
		for (int i = 1;i < n;++i)
			ad = min(ad, minimize(vector<int>(res.end()-i, res.end())));
		assert(ad != vector<int>{inf});
		res.insert(res.end(), ad.begin(), ad.end());
		for (int i : ad) --cnt[i];
	}
}


signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for (int i = 0;i < n;++i)
		cin >> cnt[i];
	solve();
	for (int i : res)
		cout << i+1 << ' ';
	cout << '\n';
}



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

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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 main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    if (a >= k) cout << k << endl;
    else if (a + b >= k) cout << a << endl;
    else cout << a - (k - b - a) << endl;
    
    return 0;
}



Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define mp(a, b) make_pair(a, b)
#define all(vec) (vec).begin(), (vec).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;
typedef vector<vpl> vvpl;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1ll << 59;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

struct edge { ll to; ll cost; };

/*<ここから>***********************************************************/


void warshallFloyd(vvp &d) {
	rep(i, d.size()) rep(j, d.size()) rep(k, d.size()) d[j][k].second = min(d[j][k].second, d[j][i].second + d[i][k].second);
}

int main()
{
	/*
	int H, W, D;
	cin >> H >> W >> D;
	vvi A(H, vi(W));
	vp pos(H * W);
	rep(i, H) rep(j, W) {
		cin >> A[i][j];
		A[i][j]--;
		pos[A[i][j]] = mp(i, j);

	}

	int Q;
	cin >> Q;
	rep(i, Q) {
		int L, R;
		cin >> L >> R;
		L--; R--;

		int ans = 0;
		for (int j = L; j < R; j += D) {
			ans += abs(pos[j].first - pos[j + D].first) + abs(pos[j].second - pos[j + D].second);
		}
		cout << ans << endl;
	}
	*/

	int N;
	cin >> N;
	vs S(N);
	int cnt[5] = { 0 };
	rep(i, N) {
		cin >> S[i];
		if (S[i][0] == 'M') cnt[0]++;
		if (S[i][0] == 'A') cnt[1]++;
		if (S[i][0] == 'R') cnt[2]++;
		if (S[i][0] == 'C') cnt[3]++;
		if (S[i][0] == 'H') cnt[4]++;
	}

	ll ans = 0;
	rep(i, 32) {

		int c = 0;
		ll sum = 1;
		rep(j, 5) {
			if (((i >> j) & 1) == 1) {
				c++;
				sum *= cnt[j];
			}
		}

		if (c == 3) {
			ans += sum;
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    queue<P> que;

    int cnt = 0;
    rep(i, H) {
        rep(j, W) {
            char a;
            cin >> a;
            //a = '#';
            A[i][j] = (a == '.') ? 0 : 1;
            cnt += A[i][j];
            if (A[i][j]) que.push(P(i, j));
        }
    }

    int ans = 0, cnt_b = 0;
    while (!que.empty()) {
        P p = que.front();
        int x = p.second, y = p.first; 
        que.pop();
        if (y + 1 < H && A[y + 1][x] == 0) {
            cnt_b++;
            que.push(P(y + 1, x));
            A[y + 1][x] = 1;
        }
        if (y - 1 >= 0 && A[y - 1][x] == 0) {
            cnt_b++;
            que.push(P(y - 1, x));
            A[y - 1][x] = 1;
        }
        if (x + 1 < W && A[y][x + 1] == 0) {
            cnt_b++;
            que.push(P(y, x + 1));
            A[y][x + 1] = 1;
        }
        if (x - 1 >= 0 && A[y][x - 1] == 0) {
            cnt_b++;
            que.push(P(y, x - 1));
            A[y][x - 1] = 1;
        }
        cnt--;
        if (cnt == 0) {
            ans++;
            cnt = cnt_b;
            cnt_b = 0;
        }
    }

    cout << ans - 1 << endl;
    return 0;
}

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

int N,a=0,b;
int arr[1000000];
int main(){
	cin>>N;
	for(int i=1; i<=2*N; i++) {
		cin>>arr[i];
	}
	for(int i=1; i<=2*N; i=i+2) {
		a=a+arr[i+1]-arr[i]+1;
	}
	cout<<a<<endl;
}

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

int main() {
	string s,t;
	cin>>s>>t;
	if(s.size()<t.size()){
		cout << "UNRESTORABLE";
		return 0;
	}
	string ans;
	for(int i=s.size()-t.size();i>=0;i--){
		bool check=true;
		ans= s;
		for(int j=0;j<t.size();j++){
			ans[i+j]=t[j];
			if(s[i+j]=='?'){
				continue;
			}
			if(s[i+j]==t[j]){
				continue;
			}
			check=false;
			break;
		}
		if(check){
			for(int j=0;j<ans.size();j++){
				if(ans[j]=='?'){
					ans[j]='a';
				}
			}
			cout << ans;
			return 0;
		}
	}
	cout << "UNRESTORABLE";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>
#include <stdlib.h>

using namespace std;

string ex_s; //expression_string
int n;

int cal(string ex_s) //calculate expression_string
{
    int i;
    int j;
    int ans; //answer
    int cnt_p=0; //count_parentheses
    int cnt_pp=1;
    int cnt_as=0; //count_add subtract
    int cnt_md=0; //count_nultiply divide
    for(i=0;i<ex_s.size();i++)
    {
        if(ex_s[i]=='(')
        {
            for(j=i+1;j<ex_s.size();j++)
            {
                if(ex_s[j]=='(') cnt_pp+=1;
                else if(ex_s[j]==')')
                {
                    cnt_pp-=1;
                    if(cnt_pp==0)
                    {
                        cnt_pp=1;
                        break;
                    }
                }
            }
            ans=cal(ex_s.substr(i+1,j-i-1));
            ex_s=ex_s.substr(0,i)+to_string(ans)+ex_s.substr(j+1);
            i=j;
            cnt_p+=1;
        }
    }
    if(cnt_p!=0)
    {
        return cal(ex_s);
    }
    else
    {   for(i=ex_s.size()-1;i>0;i--)
        {
            if(ex_s[i]=='+')
            {
                ans=cal(ex_s.substr(0,i))+cal(ex_s.substr(i+1));
                cnt_as+=1;
                return ans;
                break;
            }
            else if(ex_s[i]=='-')
            {
                if(!isdigit(ex_s[i-1])) continue;
                ans=cal(ex_s.substr(0,i))-cal(ex_s.substr(i+1));
                cnt_as+=1;
                return ans;
                break;
            }
        }
        if(cnt_as==0)
        {
            for(i=ex_s.size()-1;i>0;i--)
            {
                if(ex_s[i]=='*')
                {
                    ans=cal(ex_s.substr(0,i))*cal(ex_s.substr(i+1));
                    cnt_md+=1;
                    return ans;
                    break;
                }
                else if(ex_s[i]=='/')
                {
                    ans=cal(ex_s.substr(0,i))/cal(ex_s.substr(i+1));
                    cnt_md+=1;
                    return ans;
                    break;
                }
            }
            if(cnt_md==0)
            {
                return atoi(ex_s.c_str());
            }
        }
    }
}

int main()
{
    cin >> n;
    while(n--)
    {
        cin >> ex_s;
        ex_s.pop_back();
        cout << cal(ex_s) << endl;
    }
	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int sum = 0;
  int maxi = 0;
  int n;
  cin >> n;
  while(n--) {
    int in;
    cin >> in;
    maxi = max(maxi, in);
    sum += in;
  }
  cout << sum - maxi / 2 << endl;
    return 0;
}


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

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	f = 0
	ma = maximum(a)
	mi = minimum(a)
	if ma-mi>1
		f = 1
	else
		ax = 0
		ix = 0
		for i in 1:n
			if a[i]==ma
				ax+=1
			else
				ix+=1
			end
		end
		if ix+ax>>1<ma
			f = 1
		elseif ix+1>ma
			f = 1
		end
		if ax==n&&ma==n-1
			f = 0
		end
	end
	println(f==0?"Yes":"No")
end
main()

Measured memory_bytes: 118284
n, a, b = (int(i) for i in input().split()) 
dif = b-a

if dif % 2 == 0:
    print(dif//2)
else:
    if a + b - 2 <= 2*n - a -b:
        print(((a + b - 1)//2))
    else:
        print(((2*n - a - b + 1)//2))

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

int main() {
    double A, B;
    cin >> A >> B;
    int answer = -1;
    for (int i = 1; i <= 2500; i++) {
        if (floor(i * 0.08) == A and floor(i * 0.1) == B) {
            answer = i;
            break;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int a, b;
	String[] line = sc.nextLine().split(" ");
	a = Integer.parseInt(line[0]);
	b = Integer.parseInt(line[1]);

	if (a < b) {
	    System.out.println("a < b");
	} else if (a > b) {
	    System.out.println("a > b");
	} else {
	    System.out.println("a == b");
	}
    }
}

Measured memory_bytes: 17120
import kotlin.comparisons.*
import java.util.*

const val MOD = 1000000007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  val s = readLine()!!
  val x = s.substring(0, 2)
  val y = s.substring(2, 4)
  val xnm = x == "00" || x > "12"
  val ynm = y == "00" || y > "12"
  val ans = when {
    xnm && ynm -> "NA"
    xnm -> "YYMM"
    ynm -> "MMYY"
    else -> "AMBIGUOUS"
  }
  println(ans)
}


Measured memory_bytes: 33552
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main()
{
    int a, b, q;
    cin >> a >> b >> q;
    auto s = set<large>{};
    s.insert(-1e18);
    s.insert(1e18);
    auto s_inv = s;
    for (int i = 0; i < a; ++i) {
        large s_i;
        cin >> s_i;
        s.insert(s_i);
        s_inv.insert(-s_i);
    }

    auto t = set<large>{};
    t.insert(-1e18);
    t.insert(1e18);
    auto t_inv = t;
    for (int i = 0; i < b; ++i) {
        large t_i;
        cin >> t_i;
        t.insert(t_i);
        t_inv.insert(-t_i);
    }

    for (int i = 0; i < q; ++i) {
        large x;
        cin >> x;

        auto s_right = *s.lower_bound(x);
        auto s_left = -*s_inv.lower_bound(-x);

        auto t_right = *t.lower_bound(x);
        auto t_left = -*t_inv.lower_bound(-x);

        s_right = s_right - x;
        s_left = x - s_left;
        t_right = t_right - x;
        t_left = x - t_left;

        auto dist = min({
            2 * s_right + t_left,
            2 * s_left + t_right,
            2 * t_right + s_left,
            2 * t_left + s_right,

            max(s_right, t_right),
            max(s_left, t_left),
        });

        cout << dist << "\n";
    }

    return 0;
}


Measured memory_bytes: 22316
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

typedef long long ll;

int n;
ll res;

int main()
{
	ll cur = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int a; scanf("%d", &a);
		ll good = 0, bad = 0;
		bool wasbad = false;
		while (a != 1) {
			good++;
			if (a % 2) wasbad = true;
			a = (a + 1) / 2;
		}
		if (wasbad) bad++, good--;
		res += max(0ll, good + bad - cur);
		ll el = cur <= good? 0: cur - good;
		cur = good + bad - min(bad, el);
	}
	cout << res << endl;
	return 0;
}

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

const int mn=1e6+7;
int vis[mn],a[mn],n,ans;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		scanf("%d",a+i);
		vis[a[i]]++;
	}
	for(int i=1;i<=n;++i) {
		if(a[i]==1&&vis[a[i]]==1) {ans++;continue;}
		int sqr=sqrt(a[i]),f=1;
		for(int j=1;j<=sqr;++j) {
			if(a[i]%j!=0) continue;
			if(vis[j]>0) f=0;
			if(j==1) {if(vis[a[i]]>1) f=0;}
			else {if(vis[a[i]/j]>0) f=0;}
		}
		ans+=f;
	}
	printf("%d",ans);
}

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

bool isOK(long long n) {
    long long sum = (1+n)*n/2;
    if(sum >= x) return true;
    else return false;
}

int binary_search(long long ng, long long ok) {
    while(abs(ok-ng) > 1) {
        long long mid = (ok+ng) / 2;
        if(isOK(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}
int main() {
    cin >> x;
    cout << binary_search(0, x) << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	nums := make([]int, n)
	for i := range nums {
		fmt.Scan(&nums[i])
	}

	cp := make([]int, n)
	copy(cp, nums)
	sort.Sort(sort.Reverse(sort.IntSlice(cp)))
	for _, v := range nums {
		ans := cp[0]
		if v == ans {
			ans = cp[1]
		}
		fmt.Println(ans)
	}
}


Measured memory_bytes: 8064
@cache = {}

def can_create?(a, m)
  key = a.join('-') + "_#{m}"
  return @cache[key] if @cache.key?(key)
  return true if m.zero?
  return false if a.empty?

  val = a.shift
  @cache[key] = can_create?(a.dup, m - val) || can_create?(a.dup, m)
end

n = gets.to_i
a = gets.split.map(&:to_i)
q = gets.to_i
m_arr = gets.split.map(&:to_i)

m_arr.each do |m|
  @cache = {}
  puts can_create?(a.dup, m) ? 'yes' : 'no'
end

Measured memory_bytes: 9832
#include <iostream>
#include <vector>

using namespace std;

int main() {
	vector<int> x(5);
	int ans;
	for (int i = 0; i < 5; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < 5; i++) {
		if (x[i] == 0) ans = i + 1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>

using namespace std;

int main(){
	char s[100010]; scanf("%s", s);
	int l = strlen(s);
	int f = 0, a, b;
	for(int i = 0; i < l; i++){
		if(i + 1 < l && s[i] == s[i + 1]){ f = 1; a = i; b = i + 1; break; }
		if(i + 2 < l && s[i] == s[i + 2]){ f = 1; a = i; b = i + 2; break; }
	}
	if(f) printf("%d %d\n", a + 1, b + 1);
	else puts("-1 -1");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    int x,y;
    string s;
    bool check(int t, vector<int> &v,int xx =0){
        DBG(t)
        if(v.size()==0 and t==0) return true;
        int sum = accumulate(v.begin(),v.end(),0);
        if(abs(t)>sum)return false;
        vector<vector<int>> dp ((int)v.size()+1,vector<int>(sum+1));
        dp[0][0]=1;
        for(int i=0; i<(int)v.size(); ++i){
            /*if(xx==1 and i ==0){
                dp[1][v[0]]=1;
                continue;
            }*/
            for(int j=0; j<=sum-v[i]; ++j){
                dp[i+1][abs(j+v[i])]|=dp[i][j];
                dp[i+1][abs(j-v[i])]|=dp[i][j];
            }
        }
        DBG(dp)
        return dp[(int)v.size()][abs(t)]>0;
    }
    void solve(){
        cin >> s >> x >> y;
        vector<vector<int >> l(2);
        s+='T';
        for(int i=0,cnt =0,j=0; i<(int)s.size(); ++i){
            if(s[i] == 'F'){
                cnt ++;
            }else{
                l[j%2].push_back(cnt);
                cnt =0;
                j++;
            }
        }
        x-=l[0][0];
        l[0].erase(l[0].begin());
        DBG(l)
        if(check(x,l[0],1) && check(y,l[1]))cout << "Yes"<<"\n";
        else cout << "No" <<"\n";
    }
};

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

    Problem p;
    p.solve();
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	int n, sum = 0, m = 0;
	cin >> n;
	for ( int i = 0 ; i < n ; i++ ){
		int tmp;
		cin >> tmp;
		m = max(m, tmp);
		sum += tmp;
	}
	sum -= m/2;
	cout << sum << "\n";

	return 0;
}


Measured memory_bytes: 256
N = int(input())
countlist = []
for i in range(0, N):
	lst = []
	for j in range(0, 26):
		lst.append(0)
	countlist.append(lst)
for i in range(0, N):
	S = input()
	for j in range(0, len(S)):
		countlist[i][ord(S[j])-97] += 1
countmin = []
for i in range(0, 26):
	min = 5000000000000000
	for j in range(0, N):
		if countlist[j][i] < min: min = countlist[j][i]
	countmin.append(min)
ans = ''
for i in range(0, 26):
	for j in range(0, countmin[i]):
		ans = ans + chr(i+97)
print(ans)

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int lli;

lli n;

lli qtd(int k)
{
	if( k == 0 ) return 1;

	lli ans = 1;

	for(int i = 1 ; i <= k ; i++)
		ans *= 26;

	return ans;
}

int main()
{
	scanf("%lld",&n);

	int sz = 1;

	while( qtd(sz) < n )
		n -= qtd( sz++ );

	for(int i = 1 ; i < sz ; i++)
	{
		for(int j = 'a' ; j <= 'z' ; j++)
		{
			if( qtd( sz - i ) >= n )
			{
				printf("%c",j);
				break;
			}

			n -= qtd( sz - i );
		}
	}

	printf("%c",'a' + n - 1);
}

Measured memory_bytes: 3824
package main

import (
	"fmt"
)

func trace(A []int, N int) {
	for i := 0; i < N; i++ {
		if i > 0 {
			fmt.Printf(" ")
		}
		fmt.Printf("%d", A[i])
	}
	fmt.Printf("\n")
}

func selectionSort(A []int, N int) {
	var exchangeCount int
	for i := 0; i < N; i++ {
		minj := i
		for j := i; j < N; j++ {
			if A[j] < A[minj] {
				minj = j
			}
		}
		if i != minj {
			A[i], A[minj] = A[minj], A[i]
			exchangeCount++
		}
	}
	trace(A, N)
	fmt.Println(exchangeCount)
}

func main() {
	var length int
	fmt.Scanf("%d", &length)

	array := make([]int, length)
	for i := 0; i < length; i++ {
		fmt.Scanf("%d", &array[i])
	}
	selectionSort(array, length)
}


Measured memory_bytes: 1120
#include<stdio.h>
int main(){

  int mon,a,b,c,d,e,f,y;

 while(1){ scanf("%d",&mon);
 y=1000-mon;
if(mon<=500&&mon>0){a=(y-500)/100;
    b=(y-500-100*a)/50;
    c=(y-500-100*a-50*b)/10;
    d=(y-500-100*a-50*b-10*c)/5;
    e=(y-500-100*a-50*b-10*c-5*d);
f=1+a+b+c+d+e;
 printf("%d\n",f);}
 else if(mon>=500){a=y/100;
    b=(y-100*a)/50;
    c=(y-100*a-50*b)/10;
    d=(y-100*a-50*b-10*c)/5;
    e=(y-100*a-50*b-10*c-5*d);
   f=a+b+c+d+e; 
 printf("%d\n",f);}
 if(mon==0){break;}}
 return 0;
}

Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		String s=sc.next();
		int kaisu=0;
		int now=1;
		int N=s.length();
		int tmp=0;
		for(int i=0; i<N; i++) {
			if(i%2==0) {
				if(s.charAt(i)-'0'==0) {
					//
				}
				else {
					tmp++;
				}
			}
			else {
				if(s.charAt(i)-'0'==0) {
					tmp++;
				}
				else {
					//
				}
			}
		}
		for(int i=0; i<N; i++) {
			if(i%2==1) {
				if(s.charAt(i)-'0'==0) {
					//
				}
				else {
					kaisu++;
				}
			}
			else {
				if(s.charAt(i)-'0'==0) {
					kaisu++;
				}
				else {
					//
				}
			}
		}
		pl(Math.min(tmp, kaisu));
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


Measured memory_bytes: 25172
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve();

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

void solve() {
  int N, A, B; cin >> N >> A >> B;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int x = i;
    int p = 0;
    while(x) {
      p += x%10;
      x/=10;
    }

    if (A <= p && p <= B) {
      ans+=i;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))

def sentinel_linear_search(lst, value):
    idx = 0
    while lst[idx] != value:
        idx += 1
        if idx == len(lst)-1:
            return 0
    return 1

cnt = 0
for i in t:
    cnt += sentinel_linear_search(s, i)
print(cnt)



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


int main(){

    int n;
    int d[100];
    cin >> n;
    for(int i = 0; i < n; i++) cin >> d[i];

    int ans = 0;

    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            ans += d[i]*d[j];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner .nextInt();
		int[][][] heya = new int[4][3][10];
		for (int i=0; i<n; i++) {
			int b = scanner .nextInt();
			int f = scanner .nextInt();
			int r = scanner .nextInt();
			int v = scanner .nextInt();
			heya[b-1][f-1][r-1] = v + heya[b-1][f-1][r-1];
		}
		for (int i=0; i<4; i++) {
			for (int j=0; j<3; j++) {
				for (int k=0; k<10; k++) {
					System.out.print(" "+heya[i][j][k]);
				}
				System.out.println();
			}
			if(i<3)
				System.out.println("####################");
		}
	}
}


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

int main() {
  string s;
  while(cin >> s) {
    vector<int> occ(255);
    for (int i = 0; i < s.size(); i++) {
      occ[s[i]]++;
    }
    bool ok = true;
    for (char i = 'a'; i <= 'z'; i++) {
      if(occ[i] & 1) ok = false;
    }
    cout << (ok ? "Yes" : "No") << endl;
  }
}


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

int main(){

	int i, j, flag = 0, sum;
	char s[1000] = {0}, p[1000] = {0}, rgst[1000] = {0};
	size_t len_s, len_p;

	scanf("%s", s);
	scanf("%s", p);

	len_s = strlen(s);
	len_p = strlen(p);

	for(i = 0; i < len_s; i++){
		s[i + len_s] = s[i];
	}

	for(i = 0; i < len_s; i++){
		for(j = 0; j < len_p; j++){
			rgst[j] = s[i + j];
		}

		if(strcmp(p, rgst) == 0){
			flag++;
		}
	}
	
	if(flag == 0){
		printf("No\n");
	} else {
		printf("Yes\n");
	}

	return 0;
}

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

using namespace std;

int solve(string str) {
    int r = 0;
    int res = 0;
    for (int i = 0; i < (int) str.length(); i++) {
        if (str[i] == 'R')
            r++;
        else 
            r = 0;
        res = max(res, r);
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string str;
    cin >> str;
    printf("%d\n", solve(str));
    return 0;
}


Measured memory_bytes: 3744
N=int(input())
S=input()
l=[]

for s in S:
    if not l:
        l.append(s)
    else:
        t=l[-1]
        if t=="(" and s==")":
            l.pop()
        else:
            l.append(s)

print("("*(l.count(")")) + S + ")"*(l.count("(")))

Measured memory_bytes: 3316
#include <stdio.h>

int main() {
  int a,b,d;
  char c;
    while(1) {
    	scanf("%d %c %d", &a, &c, &b);
    	switch(c){
    		case '+':
      		printf("%d\n", a+b);
      		break;
    		case '-':
    		  printf("%d\n", a-b);
      		break;
    		case '*':
      		printf("%d\n", a*b);
      		break;
  		  case '/':
     			printf("%d\n", a/b);
  		    break;
    		default:
    			break;
      }
    if(c == '?') break;
    }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

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

    long long w,h;
    cin >> h >> w;
    string m[h];
    long long d[w+1];
    long long last=1;
    long long temp;
    const long long mod=1000000007;

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

    for(int i=0;i<w+1;i++)
        d[i]=0;

    for(int i=h-1;i>=0;i--)
    {
        for(int j=w-1;j>=0;j--)
        {
            if(m[i][j]=='#')temp=0;
            else temp=(last+d[j])%mod;
            d[j+1]=last;
            last=temp;
        }
        d[0]=last;
        last=0;
    }

    cout << d[0] << endl;
}


Measured memory_bytes: 1280
class Tree
	def initialize(key)
		@key = key
		@left = nil
		@right = nil
	end

	def insert(k)
		if @key > k
			if !@left
				@left = Tree.new(k)
			else
				@left.insert(k)
			end

		else
			if !@right
				@right = Tree.new(k)
			else
				@right.insert(k)
			end
		end
	end

	def inorder(list)
		if @left
			list = @left.inorder(list)
		end
		list << @key
		if @right
			list = @right.inorder(list)
		end
		list
	end

	def preorder(list)
		list << @key
		if @left
			list = @left.preorder(list)
		end
		if @right
			list = @right.preorder(list)
		end
		list
	end

	def find(key,bool)
		if @key == key
			bool = "yes"
		else
			if @left && @key > key
				bool = @left.find(key,bool)
			end

			if @right && @key < key
				bool = @right.find(key,bool)
			end
		end
		bool
	end
end

n = gets.to_i
head = nil

n.times do
	num = gets.to_s.chomp!
	if num == "print"
		puts " #{head.inorder([]).join(" ")}"
		puts " #{head.preorder([]).join(" ")}"
	else
		num = num.split
		if num[0].to_s == "insert"
			if head
				head.insert(num[1].to_i)
			else
				head = Tree.new(num[1].to_i)
			end
		else
			puts head.find(num[1].to_i,"no")
		end

	end

end

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

signed main(){

  int n,l;
  cin>>n>>l;
  int sum = 0;
  for(int i=1;i<=n;++i){
    sum += l+i-1;
  }
  vector<int> apple(n+1);
  for(int i=1;i<=n;++i)apple[i] = l+i-1;
  sort(begin(apple),end(apple),[](int a,int b){return abs(a)<abs(b);});
  cout<<(sum-apple[1])<<endl;

}

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

using namespace std;
int main()
{
 int a,b,c;
 cin>>a>>b>>c;
 if(a==b&&b!=c||a!=b&&b==c||a!=b&&b!=a&&a==c)
    cout<<"Yes"<<endl;
 else cout<<"No"<<endl;


return 0;
}


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

int main() {
    int n,k;
    cin >> n>>k;
    vector<int> snk(n);
    rep(i,k){
        int d;
        cin >> d;
        vector<int> a(d);
        rep(i,d){
            cin >> a[i];
            snk[a[i]-1]=1;
        }
    }
    int cnt=0;
    rep(i,n){
        if(snk[i] !=0)continue;
        else cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}
ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}
bool isPrime(int x){
    if(x==1) return false;
    else if(x==2) return true;
    else if(x%2==0) return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0){
            return false;
        }
    }
    return true;
}


int main(){
    fast_io
    
    int n, k;
    cin>>n>>k;
    double score=0;
    for(int i=1;i<=n;i++){
        double tmp=1.0/n;
        int now=i;
        while(now<k){
            now*=2;
            tmp/=2;
        }
        score+=tmp;
    }
    cout<<fixed<<setprecision(12)<<score<<endl;
    
    return 0;
}

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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

#pragma region Debug
void debug_out() { cout << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cout << H << " ";
	debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
#pragma endregion

// コンパイル時、エイリアス「debug」を使用 --> マクロが使えるように

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	
	int n, k;
	cin >> n >> k;

	vector<double> a(n);
	rep(i,n){
		cin >> a[i];
	}

	ll ok = 1e9, ng = 0;
	while(ok - ng > 1){
		ll mid = (ok + ng) /2;
		ll cnt = 0;

		rep(i,n){
			cnt += (a[i] + mid - 1) / mid - 1;
		}
		if(cnt <= k) ok = mid;
		else ng = mid;
	}

	cout << ok << endl;
	return;
}

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

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

#define MAX 100000

int N, M;
int X[MAX];

int Xl[MAX];

int main() {
	cin >> N >> M;
	for( int i = 0; i < M; i++ ) {
		cin >> X[i];
	}

	int ans = 0;
	if( M <= N ) {
	}
	else {
		sort( X, X + M );
		for( int i = 0; i < M - 1; i++ ) {
			Xl[i] = X[i + 1] - X[i];
		}
		sort( Xl, Xl + M - 1 );
		for( int i = 0; i < M - N; i++ ) {
			ans += Xl[i];
		}
	}

	cout << ans << endl;

	return 0;
}


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

template<class T>
T lcm(T a,T b){
    return a/__gcd(a,b)*b;
}

int main(){
    string s;cin >> s;
    long ans=0;
    for(int j=s.size()-1;j>=0;j--){
        if(s[j]=='Z'){
            ans=j;
            break;
        }
    }
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){
            cout << ans-i+1;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 640
M = 998244353
n = gets.to_i
list = gets.split.map(&:to_i)

def solver(n, list)
  return 0 if list[0] != 0
  list.sort!
  ary = [0]*(list[-1] + 1)
  0.upto(n - 1){|i| ary[list[i]] += 1 }
  return 0 if ary[0] > 1
  ret = 1
  1.upto(ary.length - 1){|i|
    return 0 if ary[i] == 0
    ret *= ary[i - 1] ** ary[i]
  }
  return ret % M
end

puts solver(n, list)


Measured memory_bytes: 47332
#!/usr/bin/python3
# -*- coding: utf-8 -*-
def check(mae, keta, count, k):
    if keta == 0:
        count += 1
        if count == k:
            ans = mae
        else:
            ans = -1
        return count, ans
    if mae == 0:
        count, ans = check(0, keta - 1, count, k)
        if ans >= 0:
            ans += mae * 10 ** keta
            return count, ans
        count, ans = check(1, keta - 1, count, k)
        if ans >= 0:
            ans += mae * 10 ** keta
            return count, ans
    elif mae == 9:
        count, ans = check(8, keta - 1, count, k)
        if ans >= 0:
            ans += mae * 10 ** keta
            return count, ans
        count, ans = check(9, keta - 1, count, k)
        if ans >= 0:
            ans += mae * 10 ** keta
            return count, ans
    else:
        for i in [-1, 0, 1]:
            count, ans = check(mae + i, keta - 1, count, k)
            if ans >= 0:
                ans += mae * 10 ** keta
                return count, ans
    return count, ans

k = int(input())
if k < 10:
    print(k)
else:
    count = 9
    flag = 0
    for keta in range(2, 1000):
        for sento in range(1, 10):
            count, ans = check(sento, keta - 1, count, k)
            if ans >= 0:
                print(ans)
                flag = 1
                break
        if flag == 1:
            break





Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val s = readLine()!!
    var ans = 0
    var tmp = 0
    for (c in s) {
        when (c) {
            'A','C','G','T' -> tmp++
            else -> {
                ans = Math.max(ans, tmp)
                tmp = 0
            }
        }
    }

    Math.max(ans, tmp).let(::println)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 33716
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        mut n: usize,
        mut m: usize,
    }
    let mut ans = 0;
    if n * 2 <= m {
        ans += n;
        m -= n * 2;
        ans += m / 4;
    } else {
        ans = m / 2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys
input = sys.stdin.readline
 
def I(): return int(input())

def main():
    
    K = I()
    if K%2 == 0:
        print('-1')
        sys.exit()
    
    ans = 1
    n = 7
    for i in range(K):
        
        if n%K ==0:
            print(ans)
            break
        
        n = (10*n + 7)%K  
        ans += 1
    
    else:
        print('-1')

main()

Measured memory_bytes: 63084
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
#include <limits.h>
#include <queue>
#include <unordered_map>
#include <sstream>      // std::ostringstream
#include <bitset>
#include <iomanip>
#include <functional>
#include <set>


#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;

#define OUTPUT_DEBUG_LOG

template <typename T>
void DisplayAnswer(const T& v) {
	cout << v << endl;
}
template <typename T>
void DisplayAnswers(const vector<T>& vs) {
	for (const auto& v : vs) {
		cout << v << endl;
	}
}

template <typename T>
void DisplayAnswerOneLine(const vector<T>& vs) {
	for (const auto& v : vs) {
		cout << v << ' ';
	}
	cout << endl;
}


std::vector<std::string> split(const std::string &str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}


// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}


void DebugPrint(const vector<ll>& vec) {
	cout << "{";
	for (auto itr = vec.begin(); itr != vec.end(); ++itr) {
		cout << *itr << ",";
	}
	cout << "}" << endl;
}

// valueが2のx乗以下である計算
ll calc2x(ll value) {
	ll n = 0;
	while (value > 0) {
		value /= 2;
		++n;
	}
	return n;
}



struct Vec2 {
	double x;
	double y;

	void rotate(double rad) {
		double s = sin(rad);
		double c = cos(rad);
		double tmpX = this->x*c - this->y*s;
		double tmpY = this->x*s + this->y*c;
		this->x = tmpX;
		this->y = tmpY;
	}
};

void funcA() {

	ll N;
	cin >> N;
	DisplayAnswer(N + N * N + N * N*N);
}
int main(void) {

	funcA();
	return 0;
}


Measured memory_bytes: 3628
using System;
using System.Linq;

namespace abc042_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string[] s = new string[x[0]];
            for (int i = 0; i < x[0]; i++)
            {
                s[i] = Console.ReadLine();
            }
            Array.Sort(s);
            for (int i = 0; i < x[0]; i++)
            {
                Console.Write(s[i]);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=605;
inline ll read()
{
    ll x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,m;
double f[N];
vector<int> G[N];
double calc(int x)
{
	f[n]=0;
	for(int i=n-1;i>=1;i--){
		int siz=G[i].size();
		double k=0.0,sum=0;
		for(auto v:G[i]){
			sum+=f[v];
			k=max(k, f[v]);
		}
		if(i==x && siz>1){
			siz--; sum-=k;
		}
		f[i]=sum/(double)siz+1.0;
	}
	return f[1];
}
int main()
{
	n=read(); m=read();
	for(int i=1;i<=m;i++){
		int u=read(),v=read();
		G[u].push_back(v);
	}
	double ans=2e9;
	for(int i=0;i<n;i++) ans=min(ans, calc(i));
	printf("%.8lf\n",ans);
	return 0;
}

Measured memory_bytes: 1408
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math


def srt(s, b):
  s = sorted(s)
  if b:
    s.reverse()
  ret = ""
  for c in s:
    ret += c
  return ret

s = str(input())
t = str(input())

s = srt(s,False)
t = srt(t,True)

if s < t:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38384
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

if N == 1:
	print(0)
	exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

ans = 0
for x, n in factorization(N):
	tmp = int((2*n)**0.5)
	if tmp*(tmp+1) > 2*n:
		tmp -= 1
	ans += tmp
print(ans)

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

int main(){
	char s[11];
	int achado=0, k=0;

	scanf("%s", s);

	if(strlen(s)%2 != 0)
		printf("%s\n", "No");
	else{
		while(k<strlen(s)-1){
			if(s[k] == 'h' && s[k+1] == 'i'){
				achado++;
				k += 2;
			}else{
				printf("%s\n", "No");
				return 0;
			}
		}
	}
	if(achado != 0)
		printf("%s\n", "Yes");

	return 0;
}

Measured memory_bytes: 128
import math
a, b, h, m= map(int, input().split())
x = abs(30 * (h + m / 60) - 6 * m)
y = 360 - x
z = min(x, y)
c = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(z))
c = math.sqrt(c)
print(c)

Measured memory_bytes: 9408