akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Control.Applicative
import Data.List
import Data.Maybe
import Data.Bits
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
import Data.Vector.Unboxed ((!))

modulus :: Int
modulus = 10^9 + 7

query :: Int -> V.Vector Int -> V.Vector Int -> Int -> Maybe Int
query d numq cplt g = loop d Nothing g
  where
    loop _ _ g' | g' <= 0 = Just 0
    loop 0 Nothing _ = Nothing
    loop 0 (Just k) g' = if k * (numq ! (k-1)) - k >= g'
                         then Just $ (g'+k-1) `div` k
                         else Nothing
    loop i v g' = min <$> ans1 <*> ans2 <|> ans1 <|> ans2
      where
        ans1 = loop (i-1) (v <|> Just i) g'
        ans2 = ((numq ! (i-1)) +) <$>
               loop (i-1) v (g' - (numq ! (i-1)) * i - (cplt ! (i-1)))
                         

main :: IO ()
main = do
  [d,g_] <- map read . words <$> getLine
  (numq_,cplt_) <- unzip
    <$> replicateM d ((\[x,y] -> (read x, read y)) . words <$> getLine)
  let numq = V.fromList numq_
      cplt = V.fromList $ map (`div` 100) cplt_
      g = g_ `div` 100
  putStrLn $ show $ fromJust $ query d numq cplt g 

Measured memory_bytes: 636
attrs = $stdin.read.split("\n")

num = attrs[0]

x_cors = attrs[1].split(' ').map(&:to_i)

min = x_cors.map { |num| num * num }.inject(:+)
pre_min = min + 1
p = 1

while pre_min > min do
  pre_min = min
  min = x_cors.map { |num| num * num }.inject(:+) - 2 * p * x_cors.inject(:+) + x_cors.length * p * p

  # puts "p: #{p}, min: #{min}, pre_min: #{pre_min}"
  p += 1
end

puts pre_min


Measured memory_bytes: 1788
import heapq

X, Y, A, B, C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = list(map(int, input().split()))

Red = p[:X]
Green = q[:Y]

h = sorted(Red + Green)
heapq.heapify(h)
for i in r:
    heapq.heappushpop(h, i)
print(sum(h))

Measured memory_bytes: 23456
#include<bits/stdc++.h>
#define ll long long
#define INF 1000000ll
using namespace std;
signed main(){
  ll h,w;
  cin >> h >> w;
  vector<string> a(h);
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }

  vector<bool> row(h, false);
  vector<bool> col(w, false);
  for (int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(a[i][j] == '#') {
        row[i] = true;
        col[j] = true;
      }
    }
  }
  
  for(int i = 0; i < h; i++) {
    if (row[i]) {
      for (int j = 0; j < w; j++) {
        if(col[j]) {
          cout << a[i][j];
        }
      }
      cout << "\n";
    }
  }
}

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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int a,b,q;
    cin >> a >> b >> q;
    vector<ll> s(a),t(b);
    for (int i = 0;i < a;++i) cin >> s[i];
    for (int i = 0;i < b;++i) cin >> t[i];
    for (int i = 0;i < q;++i) {
        ll x,n = INT64_MAX,m = INT64_MAX;
        cin >> x;
        int c = lower_bound(s.begin(),s.end(),x)-s.begin();
        if (c != a) {
            int d = lower_bound(t.begin(),t.end(),s[c])-t.begin();
            if (d != 0) {
                d--;
                if (t[d] > x) n = s[c]-x;
                else n = -t[d]+s[c]+min(x-t[d],s[c]-x);
                d++;
            }
            if (d != b) n = min(n,t[d]-x);
        }
        if (c != 0) {
            c--;
            int d = lower_bound(t.begin(),t.end(),s[c])-t.begin();
            if (d != b) {
                if (t[d] < x) m = x-s[c];
                else m = t[d]-s[c]+min(t[d]-x,x-s[c]);
            }
            if (d != 0) {
                d--;
                m = min(m,x-t[d]); 
            }
        }
        cout << min(n,m) << endl;
    }
    return 0;
}


Measured memory_bytes: 2944
al="abcdefghijklmnopqrstuvwxyz"
D1={}
D2={}
for i in range(26):
    D1[al[i]]=0
    D2[al[i]]=0

#print(D)

s=input()
t=input()

n=0
for i in range(len(s)):
    if (D1[s[i]]!=0 and D1[s[i]]!=t[i]) or (D2[t[i]]!=0 and D2[t[i]]!=s[i]) :
        n=1
        #print(i)
    else:
        D1[s[i]]=t[i]
        D2[t[i]]=s[i]

if n==1 :
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> ch(h + 1);
    vector<int> cw(w + 1);
    set<P> s;
    rep(i, m)
    {
        int x, y;
        cin >> x >> y;
        ch[x]++;
        cw[y]++;
        s.insert(P(x, y));
    }
    int mch = 0, mcw = 0;
    rep(i, h + 1)
    {
        mch = max(mch, ch[i]);
    }
    rep(i, w + 1)
    {
        mcw = max(mcw, cw[i]);
    }
    vector<int> sh;
    vector<int> sw;
    rep(i, h + 1)
    {
        if (ch[i] == mch)
        {
            sh.push_back(i);
        }
    }
    rep(i, w + 1)
    {
        if (cw[i] == mcw)
        {
            sw.push_back(i);
        }
    }
    for (auto i : sh)
    {
        for (auto j : sw)
        {
            if (s.find(P(i, j)) == s.end())
            {
                cout << mch + mcw << endl;
                return 0;
            }
        }
    }
    cout << mch + mcw - 1 << endl;
}

Measured memory_bytes: 23732
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int INF=1e10;


int main() {
	int	h,w;
	P	st,gl;
	cin >> h >> w >> st.first >> st.second >> gl.first >> gl.second;
	st.first--;st.second--;gl.first--;gl.second--;
	vector<string> s(h);
	rep(i,h) cin >> s[i];
	vector<vector<int>> dist(h,vector<int>(w,INF));
	deque<P> q;
	dist[st.first][st.second] = 0;
	q.emplace_back(st.first,st.second);
	while(!q.empty()){
		int	i = q.front().first;
		int	j = q.front().second;
		int	d = dist[i][j];
		q.pop_front();
		if (dist[i][j] != d) continue;
		rep(k,4){
			int	mi = dy[k] + i; int mj = dx[k] + j;
			if (mi < 0 || mi >= h || mj < 0 || mj >= w) continue;
			if (s[mi][mj] == '#') continue;
			if (dist[mi][mj] <= d) continue;
			dist[mi][mj] = d;
			q.emplace_front(mi,mj);
		}
		for (int ei = -2; ei <= 2; ei++){
			for (int ej = -2; ej <= 2; ej++){
				int mi = i + ei;int mj = j + ej;
				if (mi < 0 || mi >= h || mj <0 || mj >= w) continue;
				if (s[mi][mj] == '#') continue;
				if (dist[mi][mj] <= d) continue;
				dist[mi][mj] = d + 1;
				q.emplace_back(mi,mj);
			}
		}
	}
	int	ans = dist[gl.first][gl.second];
	if (ans == INF) ans = -1;
	cout << ans <<endl;
}

Measured memory_bytes: 10172
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int w[40];
int tanka[5]={5,7,5,7,7};
vector<int> ans;

int main(){
	while(1){
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			string t;
			cin>>t;
			w[i]=t.size();
		}
		for(int i=0;i<n-4;i++){
			int nn=i;
			int nc=0;
			int tn=0;
			while(tn<5){
				if(nc+w[nn]>tanka[tn]){
					//cout<<1<<endl;
					break;
				}else if(nc+w[nn]<tanka[tn]){
					//cout<<nc<<endl;
					nc+=w[nn];
					nn++;
				}else{
					//cout<<3<<endl;	
					tn++;
					nn++;
					nc=0;
				}
			}
			if(tn==5){
				ans.push_back(i+1);
				break;
			}
		}
	}
	REP(i,(int)ans.size()){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3108
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

vector<pll> enum_divisors(long long N) {
    vector<pll> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            // 重複しないならば i の相方である N/i も push
            if (N / i != i)
                res.push_back({i, N / i});
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main() {
    ll N;
    cin >> N;
    vector<pll> en = enum_divisors(N);
    ll ans = 0;
    rep(i, en.size()) {
        if (en[i].first < en[i].second - 1)
            ans += (en[i].second - 1);
    }

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

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

#define ll long long
#define mem(Arr,x) memset(Arr,x,sizeof(Arr))

const int maxN=100010;
const int maxM=maxN*2;
const int inf=2147483647;

int n,m;
int edgecnt=-1,Head[maxN],Next[maxM],V[maxM],W[maxM];
int Col[maxN];
bool getring;
ll edge,node;
bool vis[maxN];
ll Aper[3];

void Add_Edge(int u,int v,int w);
void dfs(int u,int col);

int main()
{
	ios::sync_with_stdio(false);mem(Head,-1);
	cin>>n>>m;
	for (int i=1;i<=m;i++){
		int u,v;cin>>u>>v;Add_Edge(u,v,1);Add_Edge(v,u,2);
	}
	mem(Col,-1);
	ll Ans=0;
	for (int i=1;i<=n;i++)
		if (Col[i]==-1)
		{
			getring=0;edge=0;node=0;Aper[0]=Aper[1]=Aper[2]=0;
			dfs(i,0);
			//cout<<getring<<" "<<edge<<" "<<node<<" "<<Aper[0]<<" "<<Aper[1]<<" "<<Aper[2]<<endl;
			if (getring) Ans+=(ll)node*node;
			else if ((Aper[0]==0)||(Aper[1]==0)||(Aper[2]==0)) Ans+=edge;
			else Ans+=(ll)Aper[0]*Aper[1]+(ll)Aper[1]*Aper[2]+(ll)Aper[2]*Aper[0];
		}
	cout<<Ans<<endl;
	return 0;
}

void Add_Edge(int u,int v,int w)
{
	edgecnt++;Next[edgecnt]=Head[u];Head[u]=edgecnt;V[edgecnt]=v;W[edgecnt]=w;
	return;
}

void dfs(int u,int col)
{
	if (Col[u]!=-1)
	{
		if (Col[u]!=col) getring=1;
		return;
	}
	
	Col[u]=col;Aper[col]++;node++;
	for (int i=Head[u];i!=-1;i=Next[i])
	{
		if (vis[i>>1]==0) vis[i>>1]=1,edge++;
		dfs(V[i],(col+W[i])%3);
	}
	return;
}


Measured memory_bytes: 6656
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, a, N);
    ll x = 1;
    ll ans = -1;
    REP1(i, N)
    {
        x = a[x - 1];
        if (x == 2)
        {
            ans = i;
            break;
        }
    }
    OUT(ans);
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {


    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        while (true) {
            int H = scanner.nextInt();
            int W = scanner.nextInt();
            if ( H == 0){
                break;
            }
            for (int i= 0; i < H; i++){
                for (int j=0; j<W; j++){
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


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

int n;
vector<int> G[100001];
int parent[100001];
int col[100001];

void dfs(int v,int p){
	parent[v]=p;
	for(int i=0;i<G[v].size();i++){
		if(G[v][i]!=p){
			dfs(G[v][i],v);
		}
	}
}

bool check(bool flag){
	queue<int> q1;
	queue<int> q2;
	for(int i=0;i<n;i++){
		if(col[i]==0){
			for(int j=0;j<G[i].size();j++){
				if(col[G[i][j]]==-1){
					q1.push(G[i][j]);
					col[G[i][j]]=2;
				}
			}
		}
		if(col[i]==1){
			for(int j=0;j<G[i].size();j++){
				if(col[G[i][j]]==-1){
					q2.push(G[i][j]);
					col[G[i][j]]=2;
				}
			}
		}
	}
	while(1){
		if(flag){
			if(q1.size()==0)return false;
			int v=q1.front();
			q1.pop();
			for(int j=0;j<G[v].size();j++){
				if(col[G[v][j]]==-1){
					q1.push(G[v][j]);
					col[G[v][j]]=0;
				}
			}
			flag=false;
		}else{
			if(q2.size()==0)return true;
			int v=q2.front();
			q2.pop();
			for(int j=0;j<G[v].size();j++){
				if(col[G[v][j]]==-1){
					q2.push(G[v][j]);
					col[G[v][j]]=1;
				}
			}
			flag=true;
		}
	}
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	memset(parent,-1,sizeof(parent));
	dfs(0,-1);
	vector<int> vs;
	int now=n-1;
	while(now!=0){
		vs.push_back(now);
		now=parent[now];
	}
	int r=(int)vs.size()-1,l=1;
	bool flag=true;
	memset(col,-1,sizeof(col));
	col[0]=0;
	col[n-1]=1;
	while(l<=r){
		if(flag){
			col[vs[r]]=0;
			r--;
			flag=false;
		}else{
			col[vs[l]]=1;
			l++;
			flag=true;
		}
	}
	printf("%s\n",check(flag)?"Fennec":"Snuke");
	return 0;
}

Measured memory_bytes: 11640
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>

using namespace std;

#define REP(i,n) for(int (i)=(0);(i)<(n);++i)
#define ll long long

int main(){
    int s[5];
    string buf,ans;
    cin >> buf;
    
    REP(i,4)s[i]=buf[i]-48;


    if((s[0]*10+s[1])<13 && (s[0]*10+s[1])>0){
        if((s[2]*10+s[3])<13 && (s[2]*10+s[3])>0)
            ans = "AMBIGUOUS";
        else 
            ans = "MMYY";
    }
    else if((s[2]*10+s[3])<13 && (s[2]*10+s[3])>0)
        ans = "YYMM";
        else ans = "NA";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
cards_list = [input() for i in range(3)]

end = True
turn = 0

def impl(cards): 
    if cards == "":
      return False
    if cards[0] == "a":
        next = 0
    elif cards[0] == "b":
        next = 1
    else:
        next = 2
        
    if len(cards) != 1:
        return cards[1:], next
    else:
        return "", next

while end:
    if cards_list[turn] == "":
        end = impl(cards_list[turn])
    else:
        cards_list[turn], turn = impl(cards_list[turn])

if turn == 0:
    print("A")
elif turn == 1:
    print("B")
else:
    print("C")


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

int main(){
  string s;
  cin>>s;
  
  int count0=0,count1=0;
  int cou0=0,cou1=0;
  int anscount=0,maxcount=0;
  for(int i=0;i<s.size();i+=2){
    if(s.at(i)=='0'){
      count0++;
    }
    else{
      count1++;
    }
  }
  for(int i=1;i<s.size();i+=2){
    if(s.at(i)=='0'){
      cou0++;
    }
    else{
      cou1++;
    }
  }
  maxcount=max((count0+cou1),(count1+cou0));
  anscount=s.size()-maxcount;
  cout<<anscount<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) a.begin(),a.end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define debug(x) cout<<#x<<": "<<x<<endl
#define INF 1e9
typedef long long ll;

int main(void){
    int n,h;
    cin>>n>>h;
    vector<pair<ll,ll>> p(n);
    ll amax=0;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        if(amax<a){
            amax=a;
        }
        p[i] = {b,a};
    }
    sort(all(p));
    reverse(all(p));

    ll cnt=0;
    rep(i,n){
        if(p[i].first < amax)break;
        h -= p[i].first;
        cnt++;
        if(h<=0)break;
    }
    if(h>0){
        cnt += h/amax;
        if(h%amax)cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n+1,0);
  ll sum;
  REP(x,1,110){
    REP(y,1,110){
      REP(z,1,110){
        sum = x*x + y*y + z*z + x*y + y*z + z*x;
        if(sum <= n){
          vec[sum]++;
        }
      }
    }
  }
  rep(i,n){
    cout << vec[i+1] << endl;
  }
}


Measured memory_bytes: 3700
ans = 999
s = input()
abc = 'abcdefghijklmnopqrstuvwxyz'
for i in range(26):
    ls = [list(s)]
    j = 0
    while True:
        if ls[j] == list(abc[i]*(len(s)-j)):
            break
        ls.append([])
        for k in range(len(ls[j])-1):
            if ls[j][k] == abc[i] or ls[j][k+1] == abc[i]:
                ls[j+1].append(abc[i])
            else:
                ls[j+1].append(ls[j][k])
        j += 1
        
        
    ans = min(ans, len(ls)-1) 
        
print(ans)

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int X, N;
    cin >> X >> N;
    vector<int> P(N, 0);
    rep(i, N) cin >> P[i];
    sort(all(P));
    dump(P);

    int min_d = 1e9;
    int min_x = 0;
    for (int x = 200; - 100 < x; x--) {
        bool ok = true;
        for (int i = 0; i < P.size(); i++) {
            if (P[i] == x) {
                ok = false;
                break;
            }
        }
        if (!ok) continue;

        int dist = abs(X - x);
        if (dist <= min_d) {
            min_d = dist;
            min_x = x;
        }
    }
    cout << min_x << endl;
    return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		// 3?????????????????°??\???
		while (true) {
			String input_line = input.readLine();
			String[] All_test_score = input_line.split(" ");
			// ??????????????????
			int interm_test_m = Integer.parseInt(All_test_score[0]);
			// ??????????????????
			int end_test_f = Integer.parseInt(All_test_score[1]);
			// ???????????????
			int return_test_r = Integer.parseInt(All_test_score[2]);
			// ???????????????????????????????¨?
			if (interm_test_m == -1 && end_test_f == -1 && return_test_r == -1) {
				break;
			}
			int total_m_f = interm_test_m + end_test_f;

			if (end_test_f==-1 || interm_test_m==-1||total_m_f<30 ) {
				System.out.println("F");
			} else if (total_m_f >= 80) {
				System.out.println("A");
			} else if (total_m_f >= 65 && total_m_f < 80) {
				System.out.println("B");
			} else if (total_m_f >= 50 && total_m_f < 65 || return_test_r >= 50) {
				System.out.println("C");
			} else  {
				System.out.println("D");
			}
		}

	}
}

Measured memory_bytes: 24516
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 3200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
// const ll mod = 998244353ll;
const ll mod = 1000000007ll;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}


ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}

bool multicase = false;

ll n,m,num,a,b,c,d,e,h,q;
ll w, k, ans;
ll x[500005], y[500005];
ll dp[15][500005];
string s;
ll query = 0;

ll calc(ll l, ll r){
    ll res = c3(r + l + 2, r + 1);
    res += mod - 1;
    res %= mod;
    return res;
}

void solve(){
    c3_init();
    ll r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    ll ans = 0;
    ll a = calc(r2, c2);
    ans = calc(r2, c2) - calc(r1 - 1, c2) - calc(r2, c1 - 1) + calc(r1 - 1, c1 - 1);

    ans += mod * 10; 
    ans %= mod;
    p(ans);
    return;
}


int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if(multicase){
        cin >> q;
    }else{
        q = 1; 
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}
















Measured memory_bytes: 51200
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

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

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


int main() {
  int i;
  cin >> i;
  int j = i;
  while(true){
    if(j % 111 == 0) break;
    j++;
  }
  cout << j << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            int temp = Integer.parseInt(sc.next());
            a[i] = temp;
        }
        int ans = getGcd(a[0], a[1]);
        for (int i = 2; i < n; i++) {
            ans = getGcd(a[i], ans);
        }
        System.out.println(ans);
    }

    private static int getGcd(int x, int y) {
        return y == 0 ? x : getGcd(y, x % y);
    }
}

Measured memory_bytes: 47580
package main

import "fmt"

func main() {
	var (
		n       int
		a, b, c string
	)
	fmt.Scan(&n, &a, &b, &c)

	ans := 0
	for i := 0; i < n; i++ {
		if a[i] != b[i] && b[i] != c[i] && c[i] != a[i] {
			ans += 2
		} else if !(a[i] == b[i] && b[i] == c[i] && c[i] == a[i]) {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
def bubbuleSort(arr):
    for i in range(0, len(arr)-1):
        for j in range(len(arr)-1, i, -1):
            if arr[j] > arr[j-1]:
                temp = arr[j]
                arr[j] = arr[j-1]
                arr[j-1] = temp

N ,M = [int(x) for x in input().split(' ')]

cakes = [[0 for _ in range(N)] for _ in range(8)]

for i in range(N):
    data = [int(x) for x in input().split(' ')]
    for j in range(8):
        t = j
        for k in range(3):
            if t % 2 == 0:
                cakes[j][i] += data[k]
            else:
                cakes[j][i] -= data[k]
            t //=2

for x in cakes:
    bubbuleSort(x)

max_point = 0
for i in range(8):
    max_point = max(max_point, sum(cakes[i][:M]))

print(max_point)

Measured memory_bytes: 3316
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define MAXN 2000005
ll fac[MAXN];

ll power(ll x,ll y)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % MOD; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) 
        return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res * x) % MOD;  
  
        // y must be even now  
        y = y >> 1LL; // y = y/2  
        x = (x * x) % MOD;  
    }  
    
    return res;  
}  

void pre()
{
    fac[0] = 1;
    for(ll i=1;i<MAXN;++i)
        fac[i] = (fac[i - 1] * i) % MOD;
}

ll inv(ll X)
{
    return(power(X,MOD - 2));
}

ll ncr(ll N,ll R)
{
    if(N < 0 || R < 0 || N < R)
        return(0);
    
    ll up = fac[N];
    ll down = (fac[R] * fac[N - R]) % MOD;
    up = (up * inv(down)) % MOD;
    return(up);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    pre();
    
    ll K; cin>>K;
    string s; cin>>s;
    ll M = s.length();
    ll N = K + M;
    ll ans = 0;
    
    for(ll i=1;i<=N;++i) //ending at i
    {
        ll c = ncr(i - 1,M - 1);
        ll l_spaces = max(0LL,i - M);
        ll r_spaces = max(0LL,N - i);
        
        c = (c * power(25LL,l_spaces)) % MOD;
        c = (c * power(26LL,r_spaces)) % MOD;
        
        ans = (ans + c) % MOD;
    }
    
    cout<<ans<<endl;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n,m;
    char c;
    cin >> n >> c >> m;
    if(c == '+')cout << n+m << endl;
    else cout << n-m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include<time.h>
using namespace std;


int main(void)
{
	int a, b;
	scanf("%d", &a);
	scanf("%d", &b);
	if (1 <= a&&a < 10 && 1 <= b&&b < 10)
	{
		printf("%d", a*b);
	}
	else
		printf("-1");


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<set>
#include <algorithm>
#define ll long long 
#include <string.h>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	ll int i,c=0;
	for(i=0;i<s.size();i++)
	{
		if (s[i]!=t[i])
		c++;
		
	}
	cout<<c<<endl;
}
    
	
		

	
			

		


 







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

int main()
{
    ll N;
    cin >> N;
    ll res=N;

    for(ll a=1;a*a<=N;a++){
        if(N%a==0)res=min(res,a+N/a-2);
    }
    cout<<res;
    return 0;
}

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

int main(){
    string s;
    cin >> s;

    string res = "";

    for(int i = 0; i < s.length(); i++){
        if(s[i] == '0')                             res += "0";
        else if(s[i] == '1')                        res += "1";
        else if(s[i] == 'B' && res.length() != 0)   res = res.substr(0, res.length()-1); 
    }

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

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var k int
	fmt.Scan(&k)
	n := 50
	base := make([]int, n)
	for i := 0; i < n; i++ {
		base[i] = 49
	}
	m := k % n
	h := k / n
	for i := 0; i < n; i++ {
		base[i] += h
		if i < m {
			base[i] += n - m
		} else {
			base[i] -= m
		}
	}
	fmt.Println(n)
	for i := 0; i < n; i++ {
		fmt.Printf("%d ", base[i])
	}
	fmt.Println()
}


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

int main(){
    int n, q, t;
    string name;
    cin >> n >> q;
    queue <pair<string, int> > Q;
    for (int i = 0; i < n; i++){
        cin >> name >> t;
        Q.push(make_pair(name, t));
    }
    pair <string, int> u;
    int a, sum = 0;
    while (!Q.empty()){
        u = Q.front();
        Q.pop();
        a = min(q, u.second);
        u.second -= a;
        sum += a;
        if (u.second > 0){
            Q.push(u);
        }else{
            cout << u.first << " " << sum << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6324
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int L = 60;

int cnt[L][L];

int in(int a, int b) {
	int res = 0;
	while (a % b == 0) {
		res++;
		a /= b;
	}
	return res;
}

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

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		int any = -1;
		for (int j = 0; j < (int)s.size(); j++) {
			if (s[j] == '.') any = j;
		}
		if (any == -1) {
			s.push_back('.');
			any = (int)s.size() - 1;
		}
		while ((int)s.size() - (any + 1) < 9) {
			s.push_back('0');
		}
		int X = 0;
		for (auto t : s) {
			if (t == '.') {
				continue;
			} else {
				X *= 10;
				X += (t - '0');
			}
		}
		cnt[in(X, 2)][in(X, 5)]++;
	}
	int ans = 0;
	for (int f2 = 0; f2 < L; f2++) {
		for (int s2 = 0; s2 < L; s2++) {
			for (int f5 = 0; f5 < L; f5++) {
				for (int s5 = 0; s5 < L; s5++) {
					if (make_pair(f2, f5) > make_pair(s2, s5)) continue;
					if (f2 + s2 < 18 || f5 + s5 < 18) continue;
					if (f2 == s2 && f5 == s5) {
						ans += cnt[f2][f5] * (cnt[f2][f5] - 1) / 2;
					} else {
						ans += cnt[f2][f5] * cnt[s2][s5];
					}
				}
			}
		}
	}
	cout << ans << '\n';
}

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

const int M = 1e9 + 7;

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

    vector<string> a(h);

    for(int i = 0; i < h; i++)
    {
        cin >> a[i];
    }

    vector<vector<int>> dp(h, vector<int>(w));

    for(int i = 0; i < h; i++)
    {
        if(a[i][0] != '#')
        {
            dp[i][0] = 1;
        }
        else
        {
            break;
        }     
    }

    for(int i = 0; i < w; i++)
    {
        if(a[0][i] != '#')
        {
            dp[0][i] = 1;
        }
        else
        {
            break;
        }       
    }

    for(int i = 1; i < h; i++)
    {
        for(int j = 1; j < w; j++)
        {
            if(a[i][j] != '#')
            {
                dp[i][j] = ((dp[i - 1][j] % M) + (dp[i][j - 1] % M)) % M;
            }      
        }
    }

    // for(int i = 0; i < h; i++)
    // {
    //     for(int j = 0; j < w; j++)
    //     {
    //         cout << dp[i][j] << " ";
    //     }

    //     cout << "\n";
    // }

    cout << dp[h - 1][w - 1];

    return 0;
}

Measured memory_bytes: 9460
// In The Name OF Allah
// Mehrkish Makuei
// Islamic Republic Of Iran

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define Mehrkish ios::sync_with_stdio(false),		cin.tie(0),		cout.tie(0)
#define pb push_back

const int maxx = 2e5 + 19;
int n, m, a[maxx], c[maxx], b[maxx], ans, jvb, sum, z, l, x, y, k, minn = 99999999;
string s[119], t, w;
bool flag = true;
vector <ll> v;

void Input(){
	cin >> x >> y;
}

void Solve(){
	if ( x <= y )
		swap( x, y );
	ans += x;
	x--;
	ans += max( x, y );
	cout << ans << endl;
}


int main(){
	Mehrkish;
	Input(),	Solve();
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int a= gi();
	    int b= gi();
	    int c= gi();

        //System.out.print((a+b)%24);
        if (b-a==c-b) {
        	System.out.print("YES");
        }else{
        	System.out.print("NO");
        }

	   
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 35588
import java.util.*;
import java.lang.*;

public class Main {

    public static void main(String[] args) {
        Scanner text = new Scanner(System.in);
        String W = text.next().toUpperCase();
        int cnt = 0;
        boolean flag = false;
        String end = "END_OF_TEXT";

        while(true) {
            String[] N = text.next().split(" ");
        
            for(String tex : N){
                if(tex.equals(end)) {
                    flag = true;
                    break;
                } else if(tex.toUpperCase().equals(W)) {
                    cnt++;
                }
            }
            if(flag) {
                break;
            }
        }

        System.out.println(cnt);
    }
}


Measured memory_bytes: 26020
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        long A = scanner.nextLong();
        long B = scanner.nextLong();
        if ((A+B) % 2 == 0) {
            System.out.println((A+B)/2);
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }
}

Measured memory_bytes: 21972
import java.util.*;
import java.lang.*;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int check = 0;

        for(int i = 0; i < S.length(); i += 2){
            if(S.charAt(i) == 'L'){
                check = 1;
            }
        }
        for(int i = 1; i < S.length(); i += 2){
            if(S.charAt(i) == 'R'){
                check = 1;
            }
        }

        if(check == 0){
            System.out.println("Yes");
        } else {
            System.out.println("No");

        }



    }
}






Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var n = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        n = n.OrderBy(x => x).ToArray();
        var sum = 0;
        var k1 = n[2] - n[1];
        n[0]++;
        n[1]++;
        var sa = n[1] - n[0];
        var m = sa / 2;
        var d = sa % 2;
        if (d == 1)
        {
            sum += 2;
        }
        sum += k1 + m;
        Console.WriteLine(sum);
    }
}

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

int main()
{
	int64_t n, m, d;
	cin >> n >> m >> d;
	if (d == 0)
	{
		cout << fixed << setprecision(20) << (1.0 * (m - 1) * (n - d) / (n * n)) << endl;
		return 0;
	}
	cout << fixed << setprecision(20) << (2.0 * (m - 1) * (n - d) / (n * n)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, a[300010], q, l, r;


int32_t main(){
INIT
int x; cin>>x;
if(x>=30){cout<<"Yes";}
else{cout<<"No";}



return 0;
}





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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 1000000007;

ll gcd(ll a, ll b){
  if (a%b == 0)return(b);
  else return(gcd(b, a%b));
}

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

  int n;
  cin >> n;
  vi a(n+1);
  rep(i,n+1)cin >> a[i];

  vll mx(n+1,-1);
  rep(i,n+1){
    if(i == 0)mx[i] = 1;
    else mx[i] = (mx[i-1] - a[i-1])*2;
    if(mx[i] > 1e18 || mx[i] < 0)break;
  }

  ll ret = 0;
  ll cur = 0;

  for(int i = n;i >= 0;i--){
    if(mx[i] == -1){
      cur += a[i];
    }else{
      if(mx[i] >= cur + a[i]){
        cur += a[i];
      }else{
        if(mx[i] >= (cur+1)/2 + a[i]){
          cur = mx[i];
        }
        else{
          ret = -1;
          break;
        }
      }
    }

    ret += cur;
  }

  cout << ret << endl;
}

Measured memory_bytes: 4520
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

void solve()
{

}

int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
ll n;
cin>>n;
string ans;
while(1)
{
	if(n==0)break;
	n--;
	ans+='a'+n%26;
	n/=26;
}
reverse(all(ans));
ol(ans);
return 0;
}



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

using namespace std;

char s[205];

bool check(const int& b, const int& e) {
  if ((e - b) % 2 == 1)
    return false;
  int mid = (e - b) / 2;
  for (int i = 0; i < mid; ++i)
    if (s[b + i] != s[b + mid + i])
      return false;
  return true;
}

int main()
{
  scanf("%s", s);
  int n = strlen(s);
  for (int i = n - 1; i >= 1; --i)
    for (int j = 0; j <= n - i; ++j)
      if (check(j, j + i)) {
        printf("%d\n", i);
        return 0;
      }
  return 0;
}

Measured memory_bytes: 256
#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」を使用 --> マクロが使えるように

std::vector<bool> IsPrime;
vi D;

void sieve(size_t max){
	if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
    IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
  } 
	IsPrime[0] = false; // 0は素数ではない
  IsPrime[1] = false; // 1は素数ではない

	if(max+1 > D.size()){
		D.resize(max+1, 0);
	}
	rep(i,D.size()){
		D[i] = i;
	}

  for(size_t i=2; i*i<=max; ++i){ // 0からsqrt(max)まで調べる
    if(IsPrime[i]){ // iが素数ならば
			D[i] = i;
      for(size_t j=2; i*j<=max; ++j){ // (max以下の)iの倍数は
        IsPrime[i*j] = false; // 素数ではない
				if(D[i*j] == i*j) D[i*j] = i;
			}
		}
	}
}

vi a;

bool pairwise(){
	set<int> pFactor, check;
	rep(i,a.size()){
		int focus = a[i];
		pFactor.clear();
		while(focus != 1){
			pFactor.insert(D[focus]);
			// debug(focus, D[focus], "pass");
			focus /= D[focus];
		}
		for(auto itr = pFactor.begin(); itr != pFactor.end(); ++itr){
			if(check.find(*itr) != check.end()){
				return false;
			}
			else{
				check.insert(*itr);
			}
		}
	}
	return true;
}

bool setwise(){
	int temp = a[0];
	rep(i,a.size()){
		temp = gcd(temp, a[i]);
	}
	if(temp==1){
		return true;
	}
	else{
		return false;
	}
}

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

	a.resize(n,0);
	rep(i,n){
		cin >> a[i];
	}

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

	sieve(a[n-1]);

	if(pairwise()){
		cout << "pairwise coprime" << endl;
	}
	else if(setwise()){
		cout << "setwise coprime" << endl;
	}
	else{
		cout << "not coprime" << endl;
	}

}

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

Measured memory_bytes: 11392
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
	int n;
	cin >> n;
	vector<int> a(10000);
	for(int i=1; i<=100; i++){
	for(int j=1; j<=100; j++){
	for(int k=1; k<=100; k++){
		if(i*i+j*j+k*k+i*j+j*k+k*i <= 10000) a[i*i+j*j+k*k+i*j+j*k+k*i-1]++;
	}}}
	rep(i, n){
		cout << a[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  bool is=true;
  while(is){
    double a,b;
    cin>>a>>b;
    if(cin.eof()){
      is=false;
      break;
    }
    if(a<35.50&&b<71.00) cout<<"AAA"<<endl;
    else if(a<37.50&&b<77.00) cout<<"AA"<<endl;
    else if(a<40.00&&b<83.00) cout<<"A"<<endl;
    else if(a<43.00&&b<89.00) cout<<"B"<<endl;
    else if(a<50.00&&b<105.00) cout<<"C"<<endl;
    else if(a<55.00&&b<116.00) cout<<"D"<<endl;
    else if(a<70.00&&b<148.00) cout<<"E"<<endl;
    else cout<<"NA"<<endl;
  }
  return 0;
}


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

int main()
{
	int k;
	char s[101];
	scanf("%d", &k);
	scanf("%s", s);

	if (strlen(s) > k) {
		int i;
		for (i = 0; i < k; i++)
			putchar(s[i]);
		printf("...\n");
	} else {
		printf("%s\n", s);
	}
	
	return 0;
}

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

using namespace std;


int main() {



  long a,b,c,k;

  cin >> a>>b>>c>>k;

  long sum = 0;
  
  if(k>0 && a>0){
    int x = min(a,k);
    sum += x;
    k-=x;
  
  }

  if(k>0 &&b>0){

    int x = min(b,k);
    k -= x;
  }
    
  if(k>0 &&c>0){

    int x = min(c,k);
    sum -= x;
    k -= x;
  }

      
      
    
  

  
  



  cout << sum<<endl;
  
  
  return 0;
}



Measured memory_bytes: 3628