akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  int h, w;
  cin >> h >> w;
  int f[10][10];
  rep(i,10) {
    rep(j,10) cin >> f[i][j];
  }
  rep(k,10) {
    rep(i,10) {
      rep(j,10) f[i][j] = min(f[i][j],f[i][k]+f[k][j]);
    }
  }
  int ans = 0;
  rep(i,h) {
    rep(j,w) {
      int x;
      cin >> x;
      if(x==-1) continue;
      ans += f[x][1];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <tuple>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
//ll mod = 1000000007;
//ll mod = 998244353;

vector<ll> cnt(700010);

void add(ll i, ll x) {
	i += 262143;
	cnt[i] += x;
	while (i > 0) {
		i = (i - 1) / 2;
		cnt[i] = cnt[i * 2 + 1] + cnt[i * 2 + 2];
	}
}

ll query(ll a, ll b, ll k, ll l, ll r) {
	if (r <= a || b <= l) return 0;
	if (a <= l && r <= b) return cnt[k];
	else {
		ll c1 = query(a, b, 2 * k + 1, l, (l + r) / 2);
		ll c2 = query(a, b, 2 * k + 2, (l + r) / 2, r);
		return c1 + c2;
	}
}

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<ll> s(n + 1);
	s[0] = 0;
	for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i] - k;
	map<ll, ll> mp;
	for (int i = 0; i <= n; i++) {
		s[i] += k * n;
		mp[s[i]]++;
	}
	vector<ll> t(n + 1);
	for (int i = 0; i <= n; i++) t[i] = s[i];
	sort(all(t));
	for (int i = 1; i <= n; i++) {
		if (t[i] != t[i - 1]) mp[t[i]] += mp[t[i - 1]];
	}
	ll ans = 0;
	for (int i = 0; i <= n; i++) {
		s[i] = mp[s[i]];
		ll res = query(262143, 262144 + s[i], 0, 262143, 524287);
		ans += res;
		add(s[i], 1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 22912
#include <type_traits>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <iostream>
namespace loquat {
template <int MOD>
class modulus_integer {
public:
	typedef modulus_integer<MOD> self_type;
private:
	int m_value;
	static self_type unsafe_construct(int x) noexcept {
		self_type y;
		y.m_value = x;
		return y;
	}
public:
	modulus_integer() noexcept
		: m_value(0)
	{ }
	modulus_integer(int x) noexcept
		: m_value(x % MOD)
	{
		if(m_value < 0){ m_value += MOD; }
	}
	int operator*() const noexcept { return m_value; }
	self_type& operator=(const self_type& x) noexcept {
		m_value = x.m_value;
		return *this;
	}
	self_type operator-() const noexcept {
		return unsafe_construct(m_value > 0 ? MOD - m_value : 0);
	}
	self_type operator+(const self_type& x) const noexcept {
		const int y = m_value + x.m_value;
		return unsafe_construct(y >= MOD ? y - MOD : y);
	}
	self_type operator*(const self_type& x) const noexcept {
		return unsafe_construct(
			static_cast<long long>(m_value) * x.m_value % MOD);
	}
	self_type& operator+=(const self_type& x) noexcept {
		return (*this = *this + x);
	}
};
template <int MOD>
inline std::ostream& operator<<(
	std::ostream& os, const modulus_integer<MOD>& x)
{
	os << *x;
	return os;
}
}
namespace loquat {
template <typename T, typename F = std::plus<T>>
class fenwick_tree {
public:
	using value_type = T;
private:
	std::vector<T> m_data;
	F m_func;
public:
	explicit fenwick_tree(
		size_t n,
		const value_type& x = value_type(),
		const F& f = F())
		: m_data(n + 1)
		, m_func(f)
	{
		m_data[0] = value_type();
		for(size_t i = 1; i <= n; ++i){
			m_data[i] = x;
			for(size_t j = i; (j & 1) == 0u; j >>= 1){
				m_data[i] = m_func(m_data[j], m_data[i]);
			}
		}
	}
	value_type query(size_t i) const {
		value_type s = m_data[i];
		for(i -= i & -i; i > 0; i -= i & -i){
			s = m_func(m_data[i], s);
		}
		return s;
	}
	void modify(size_t i, const value_type& x){
		const auto n = m_data.size();
		for(++i; i < n; i += i & -i){
			m_data[i] = m_func(m_data[i], x);
		}
	}
};
}
using namespace std;
using mint = loquat::modulus_integer<1000000007>;
int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	mint answer = 0;
	loquat::fenwick_tree<mint> ft(n);
	ft.modify(0, mint( 1));
	ft.modify(1, mint(-1));
	for(int i = 0; i < n; ++i){
		const auto t = ft.query(i + 1);
		if(i + 1 == n){
			answer += t * mint(n);
		}else if(i + 2 == n){
			answer += t * mint(n - 1) * mint(n);
			ft.modify(i + 1,  t);
		}else{
			const int k = n - i - 1;
			answer += t * mint(k - 2) * mint(n - 1);
			answer += t * mint(n - k + 1) * mint(n);
			ft.modify(i + 1,  t);
			ft.modify(i + 2, -t);
			ft.modify(i + 3,  t);
		}
	}
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  string s;
  cin>>s;
  int n=s.size();
  int mod=2019;
  reverse(s.begin(),s.end());
  vector<ll>sum(n+1);
  ll x=1;
  rep(i,n){
    sum[i+1]=sum[i]+((s[i]-'0')*x)%mod;
    sum[i+1]%=mod;
    x*=10;
    x%=mod;
  }
  vector<int>cnt(mod);
  ll ans=0;
  rep(i,n){
    cnt[sum[i]]++;
    ans+=cnt[sum[i+1]];
  }
  cout<<ans<<endl;
  return(0);
}




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

const int MAX_V = 18;
const int INF = 1e18;

int V,E;
int d[MAX_V][MAX_V];
int dp[1 << MAX_V][MAX_V];

int rec(int S, int v){
    if(dp[S][v] >= 0){
        return dp[S][v];
    }

    if(S == (1 << V) - 1 && v == 0){
        return dp[S][v] = 0;
    }

    int res = INF;
    for(int u = 0; u < V; u++){
        if(!(S >> u & 1)){
            res = min(res, rec(S | 1 << u, u) + d[v][u]);
        }
    }
    return dp[S][v] = res;
}

signed main() {
    cin >> V >> E;
    memset(dp,-1,sizeof(dp));

    rep(i,MAX_V) rep(j,MAX_V) d[i][j] = INF;
    for (int i = 0; i < E; i++) {
        int a,b,c;
        cin >> a >> b >> c;
        d[a][b] = c;
    }
    int ans = rec(0,0);
    if(ans == INF) ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 39960
/*Infor {{{
 ******************************************************
 * > File Name: b.cpp
 * > Author: samcompu
 * > Mail: admin@samcompu.com
 * > Created Time: 2018年07月07日 星期六 20时03分15秒
 ******************************************************
}}}*/

#include <bits/stdc++.h>

using namespace std;

/*Abbreviation {{{ */
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define ROF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define cini(a) scanf("%d", &(a))
#define cinc(a) scanf("%c", &(a))
#define cinl(a) scanf("%lld", &(a))
#define cins(a) scanf("%s", (a))
#define cind(a) scanf("%lf", &(a))
#define coui(a) printf("%d", (a))
#define couc(a) printf("%c", (a))
#define coul(a) printf("%lld", (a))
#define cous(a) printf("%s", (a))
#define coud(a) printf("%f", (a))
#define SPA printf(" ")
#define LIN printf("\n")
#define ull unsigned long long int
/*}}}*/

/*Constant {{{*/
const int MAXLEN = 1000000;
/*}}}*/

/*Class {{{*/
/*}}}*/

/*Variable {{{*/
char buff[MAXLEN + 1];
/*}}}*/

/*Declare {{{*/
/*}}}*/

/*Main {{{*/
int main() {
  cins(buff);
  int x;
  cini(x);
  for (int i = 0; i < (int)strlen(buff); i += x) couc(buff[i]);
  return 0;
}
/*}}}*/

/*Define {{{*/
/*}}}*/


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

class dice{
public:
    int face[6];

    dice(){}

    void rollN(){
        int c = face[0];
        face[0] = face[1];
        face[1] = face[5];
        face[5] = face[4];
        face[4] = c;
    }

    void rollS(){
        int c = face[0];
        face[0] = face[4];
        face[4] = face[5];
        face[5] = face[1];
        face[1] = c;
    }

    void rollW(){
        int c = face[0];
        face[0] = face[2];
        face[2] = face[5];
        face[5] = face[3];
        face[3] = c;
    }

    void rollE(){
        int c = face[0];
        face[0] = face[3];
        face[3] = face[5];
        face[5] = face[2];
        face[2] = c;
    }

    void rollZ(){
        int c = face[1];
        face[1] = face[2];
        face[2] = face[4];
        face[4] = face[3];
        face[3] = c;
    }

};

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

    dice A[n];
    rep(i, n){
        rep(j, 6){
            cin >> A[i].face[j];
        }
    }

    rep(k, n-1){
        for (int l = k+1; l < n; l++){
            rep(i, 6){
                rep(j, 4){
                    if (A[k].face[0] == A[l].face[0] && A[k].face[1] == A[l].face[1] && A[k].face[2] == A[l].face[2] && A[k].face[3] == A[l].face[3] && A[k].face[4] == A[l].face[4] && A[k].face[5] == A[l].face[5]){
                        cout << "No" << endl;
                        return 0;
                    }
                    A[l].rollZ();
                }
                if(i % 2 == 0)A[l].rollS();
                else A[l].rollE();
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3120
import collections
N,K=map(int,input().split())
#N=int(input())
A=list(map(int,input().split()))
M=10**9+7
dp=[[0]*(K+2)for i in range(N+1)]
for i in range(N+1):
    dp[i][0]=1

for i in range(1,A[0]+1):
    dp[0][i]=1
for i in range(N-1):
    for j in range(K+1):
        if j-A[i+1]<0:
            dp[i+1][j+1] = (dp[i+1][j]+dp[i][j+1])%M
        else:
            dp[i+1][j+1] = (dp[i+1][j]+dp[i][j+1]-dp[i][j-A[i+1]])%M
print(dp[N-1][K])

Measured memory_bytes: 119660
s = int(input())
n = list(input())
print()

apls = list(set(n))
count = 0

for i in range(1, s+1):
    tmp = 0
    for apl in apls:
        if n[:i].count(apl) != 0 and n[i:].count(apl) != 0:
            tmp += 1
    if count < tmp:
        count = tmp

print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);


bool cmp(const PII& a, const PII& b){
    int af = a.first, as = a.second;
    int bf = b.first, bs = b.second;

    //if(as >= 0 and bs >= 0){
    //    return af >= bf;
    //}else if(as >= 0 and bs < 0){
    //    return true;
    //}else if(as < 0 and bs >= 0){
    //    return false;
    //}else{
    //    int da = -af - (-as);
    //    int db = -bf - (-bs);
    //    return da >= db;
    //}
    //
    if(as > 0 and bs <= 0) return true;
    if(as <= 0 and bs > 0) return false;
    if(as < 0) return af - as < bf - bs;
    else return af > bf;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;
    vector<pair<int,int>> S;
    int sum = 0;
    REP(i,N){
        string s; cin >> s;
        int acc = 0;
        int tmin = 0;
        for(char c : s){
            if(c == '('){
                acc++;
            }else{
                acc--;
            }
            chmin(tmin,acc);
        }
        S.eb(tmin,acc);
        sum += acc;
    }
    if(sum != 0){
        cout << "No" << endl;
        return 0;
    }
    sort(S.begin(),S.end(),cmp);
    int now = 0;
    int tmin = 0;
    REP(i,N){
        int a,b;
        tie(a,b) = S[i];
        chmin(tmin,now+a);
        now += b;
    }
    if(tmin == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }



}

Measured memory_bytes: 11484
while True:
    Input = input().split()
    a = int(Input[0])
    op = Input[1]
    b = int(Input[2])
    
    if op == '?':
        break
    
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    else:
        print(a//b)


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

int main(){
    string homu;
    cin >> homu;
    int homuhomu = 0;
    for(auto homuhomuhomu : homu){
        homuhomu += (homuhomuhomu == '0');
    }
    cout << 2 * min((int)homu.size()-homuhomu , homuhomu) << endl;
    return 0;
}

Measured memory_bytes: 512
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};


int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    
    string s,t;
    cin >> s>>t;
    ll n = s.size(),m=t.size();
    ll ans = INF;
    for(ll i=0;i<=n-m;i++){
        //cout << i << endl;
        ll cnt=0;
        for(ll j=i,k=0;j<i+m;j++,k++){
            if(s[j]!=t[k]) cnt++;
        }
        ans =  min(ans,cnt);
    }
    pfl(ans);
    return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll a,b,c;cin>>a>>b>>c;
    if(a==b && a==c)cout<<"Yes";
    else cout<<"No";
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada ios_base::sync_with_stdio(false)
#define int long long

signed main()
{

    rootdada;
    int n, k;
    cin >> n >> k;
    int a[n], f[n];
    rep(i, 0, n)
            cin >>
        a[i];
    rep(i, 0, n)
            cin >>
        f[i];
    sort(a, a + n);
    sort(f, f + n, greater<int>());
    int start = 0, end = 1e12;
    int mid = (start - end) / 2 + end;
    while (start < end)
    {
        mid = (start + end) / 2;
        int c = 0;
        rep(i, 0, n)
            c += max(a[i] - mid / f[i], 0ll);

        if (c <= k)
            end = mid;
        else
        {
            start = mid + 1;
        }
    }
    cout << end;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef pair<int, int> P;
// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int N;
int color[MAX_N];
bool visited[MAX_N];

int main(void)
{
  cin >> N;
  vector<vector<P>> G(N + 1);
  REP(i, N - 1)
  {
    long long u, v, w;
    cin >> u >> v >> w;
    // 0-indexed
    u--, v--;
    G[u].push_back(P(v, w));
    G[v].push_back(P(u, w));
  }

  REP(i, N) visited[i] = false;

  queue<int> q;
  q.push(0);
  color[0] = 0;
  visited[0] = true;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    visited[u] = true;
    for (auto p : G[u]) {
      int v = p.first, w = p.second;
      if (visited[v]) continue;
      // 偶数なら同じ色分けに
      if (w % 2 == 0) {
        color[v] = color[u];
      }
      else {
        color[v] = 1 - color[u];
      }
      q.push(v);
    }
  }

  REP(i, N) cout << color[i] << endl;

  return 0;
}


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

using namespace std;

int main() {
	int n, x, c = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> x;
		if (x & 1) {
			c++;
		}
		if (c > 1) c-= 2;
	}
	
	if (c == 1) {
		cout << "NO";
		return 0;
	}
	cout << "YES";
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define MAX 100005
#define INF 1001001001

int n;
vector<int> par, ranks;

void init(void) {
  ranks.assign(n,0);
  par.assign(n,0);
  iota(par.begin(), par.end(), 0);
}

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

bool isSame(int x, int y) {
  return root(x) == root(y);
}

void unite(int x, int y) {
  int rx = root(x);
  int ry = root(y);
  if (rx == ry) return;

  if (ranks[rx] > ranks[ry]) {
    par[ry] = rx;
  } else {
    par[rx] = ry;
    if (ranks[rx] == ranks[ry]) ranks[ry]++;
  }
}

int main(int, char**)
{
  cin >> n;
  init();

  int q; cin >> q;
  vector<int> ans;
  rep(i,q) {
    int command, x, y;
    cin >> command >> x >> y;
    if (command == 0) {
      unite(x,y);
    } else {
      ans.push_back(isSame(x,y));
    }
  }
  for (auto a : ans) cout << a << endl;

  return 0;
}



Measured memory_bytes: 3292
package main

import (
	"bufio"
	"errors"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	for stdin.Scan() {
		in := stdin.Text()
		out, _ := do(in)
		fmt.Println(out)
	}

}

func do(in string) (string, error) {
	s := strings.Split(in, " ")
	if len(s) != 3 {
		return "", errors.New("len")
	}
	table, err := strconv.ParseUint(s[0], 10, 64)
	if err != nil {
		return "", errors.New("table")
	}
	a, err := strconv.ParseUint(s[1], 10, 64)
	if err != nil {
		return "", errors.New("a")
	}
	b, err := strconv.ParseUint(s[2], 10, 64)
	if err != nil {
		return "", errors.New("b")
	}

	if (a%2 == 0 && b%2 == 0) || (a%2 == 1 && b%2 == 1) {
		return strconv.FormatUint((b-a)/2, 10), nil
	}

	var A, B uint64
	if table-b < a {
		A = table - b
		B = table - a
	} else {
		A, B = a-1, b-1
	}

	return strconv.FormatUint((((B - A + 1) / 2) + A), 10), nil
}


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

int main() {
	int n;
	cin >> n;
	unordered_set<string> gogo;
	for (int i = 0;i<n;i++) {
		string ss ;
		cin>> ss;
		gogo.insert(ss) ;
	}
	cout << gogo.size() ;
}

Measured memory_bytes: 17680
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;




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

	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	REP(i, H) cin >> S[i];
	int res = 0;
	int dh[] = { 1,0,-1,0 };
	int dw[] = { 0,1,0,-1 };
	REP(i, H)REP(j, W) {
		if (S[i][j] == '#') continue;
		vector<vector<int>> dis(H, vector<int>(W, -1));
		dis[i][j] = 0;
		queue<P> qu;
		qu.emplace(i, j);
		while (!qu.empty()) {
			int k, l;
			tie(k, l) = qu.front();
			qu.pop();
			REP(m, 4) {
				int y = k + dh[m];
				int x = l + dw[m];
				if (y >= 0 && y < H && x >= 0 && x < W && S[y][x] == '.' && dis[y][x] < 0) {
					dis[y][x] = dis[k][l] + 1;
					res = max(res, dis[y][x]);
					qu.emplace(y, x);
				}
			}
		}
	}
	cout << res << endl;

	return 0;
}

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

using namespace std;
namespace Fast {

char buf[1 << 21], buf2[1 << 21], a[20];
char *p1 = buf, *p2 = buf;
void read() {}
inline int getc() {
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++;
}
template <typename T, typename... T2>
inline void read(T &x, T2 &... oth) {
    bool f = false;
    x = 0;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-')
            f = true;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    x = f ? -x : x;
    read(oth...);
}
} // namespace Fast

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define debug printf("(hao)")
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define clr(a, v) memset(a, v, sizeof(a))
using Fast::read;

const int M = 2e5 + 10;

/*===========================================================================*/
void solve() {
    int n, num[4] = {0};
    char a[100];
    read(n);
    for (int i = 0; i < n; i++) {
        scanf("%s", a);
        if (a[0] == 'A') {
            num[0]++;
        } else if (a[0] == 'W') {
            num[1]++;
        } else if (a[0] == 'T') {
            num[2]++;
        } else {
            num[3]++;
        }
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", num[0], num[1], num[2], num[3]);
}
/*===========================================================================*/

int main() {
    std::ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#endif
    // int T;
    // read(T);
    // while (T--)
    solve();
    return 0;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
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 main()
{
  string s ;
  cin >> s ;
  int n = s.size() ;
  string t, u ;
  string sl, sr ;
  
  REP(i,n){
    REP(j,n-i){
      t = s ;
      sl = s.substr(0,i) ;
      sr = s.substr(i+j,n-(i+j)) ;
      u = sl+sr ;
      

      if(u=="keyence"){
        cout <<"YES"<<endl ;
        return 0 ;
      }
      s = t ;
    }
  }
  
  cout <<"NO" <<endl ;
      

  return 0 ;
}





Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    string S;
  cin>>S;
  bool ans=false;
  for(int i=0;i<3;++i){
    if(S.at(i)==S.at(i+1)){
      ans=true;
    }
  }
 
  if(ans){cout<<"Bad"<<endl;}
  else{cout<<"Good"<<endl;}

    return 0;
}


Measured memory_bytes: 256
s=input()
n=len(s)
a=[]
b=""
for i in range(n):
  if s[i]=="B":
    if len(a)!=0:
      a.pop()
  else:
    a.append(s[i])
for i in range(len(a)):
  b+=a[i]
print(b)
    

Measured memory_bytes: 38256
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
ll n;
ll A,B,C;
ll L[10];
ll dfs(ll cur, ll a, ll b, ll c) {
  if(cur == n) {
    ll now = abs(a-A) + abs(b-B) + abs(c-C) - 30;
    if(min(a, min(b,c)) > 0) return now;
    else return LINF;
  }
  ll k0 = dfs(cur+1, a,b,c);
  ll k1 = dfs(cur+1, a + L[cur], b, c) + 10;
  ll k2 = dfs(cur+1, a, b+L[cur], c) + 10;
  ll k3 = dfs(cur+1, a, b, c+L[cur]) + 10;
  return min(k0, min(k2, min(k1, k3)));
}

int main(){
  cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
  cin >> n >> A >> B >> C;
  FOR(i,0,n-1) {
    cin >> L[i];
  }
  cout << dfs(0, 0, 0, 0) << endl;

  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    rep(i, s.size())
    {
        if (s[i] == '?')
            cout << 'D';
        else
        {
            cout << s[i];
        }
    }

    return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORit(it,a) for(auto it=a.begin();it!=a.end();it++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define vec vector
#define pb push_back
#define pop pop_back
#define all(x) x.begin(),x.end()
#define testcases ll t;cin>>t;while(t--)
#define mem(a,k) memset(a,k,sizeof(a))
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define rt return
#define br break
#define ct continue
#define elif else if
#define ii pair<ll,ll>
#define arrin(a,n,index) for(int i=index;i<n;i++)cin>>a[i]
#define vecin(a,n,index) for(int i=index;i<n;i++)cin>>a[i]
#define arrout(a,n,index) for(int i=index;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define vecout(a,n,index) for(int i=index;i<n;i++)cout<<a[i]<<" ";cout<<endl;
//ll mod = 1000000007;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	// START FROM HERE :)
	int d, t, s;
	cin >> d >> t >> s;

	if (s * t >= d)cout << "Yes\n";
	else cout << "No\n";

}

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

int main() {
  string s;
  cin >> s;
  int judge=0;
  int x=s.length();
  for(int i=0; i<x/2; i++){
    if(!(s.at(i)==s.at(x-i-1))){
      judge++;
    }
  }
  for(int i=0; i<x/4; i++){
    if (!(s.at(i)==s.at((x-1)/2-i-1))) {
      judge++;
    }
  }
  if (judge==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] color = new int[n];
		for(int i = 0; i < n; i++) {
			color[i] = stdIn.nextInt();
		}
		int hai = 0;
		int tya = 0;
		int midori = 0;
		int mizuiro = 0;
		int aoiro = 0;
		int kiiro = 0;
		int daidaiiro = 0;
		int akairo = 0;
		
		int maxcnt = 0;
		int mincnt = 0;
		int mosa = 0;
		for(int i = 0; i < n; i++) {
			if(color[i]>= 1 && color[i] <= 399) {
				if(hai >= 1) {
					continue;
				}
				hai++;
			}else if(color[i] >= 400 && color[i] <= 799){
				if(tya >= 1) {
					continue;
				}
				tya++;

			}else if(color[i]>= 800 && color[i] <= 1199) {
				if(midori >= 1) {
					continue;
				}
				midori++;
				
			}else if(color[i]>= 1200 && color[i] <= 1599) {
				if(mizuiro >= 1) {
					continue;
				}
				mizuiro++;
			}else if(color[i]>= 1600 && color[i] <= 1999) {
				if(aoiro >= 1) {
					continue;
				}
				aoiro++;
			}else if(color[i]>= 2000 && color[i] <= 2399) {
				if(kiiro >= 1) {
					continue;
				}
				kiiro++;
			}else if(color[i]>= 2400 && color[i] <= 2799) {
				if(daidaiiro >= 1) {
					continue;
				}
				daidaiiro++;
			}else if(color[i]>= 2800 && color[i] <= 3199) {
				if(akairo >= 1) {
					continue;
				}
				akairo++;
			}else {
				mosa++; //3200以上の猛者を捕獲
			}
		}
		
		int min = hai + tya + midori + mizuiro + aoiro + kiiro + daidaiiro + akairo;
		if(min >= 1) {
			mincnt = min;
			maxcnt = min + mosa;
		}else {
			mincnt = 1;
			maxcnt = mosa;
		}
		
		System.out.print(mincnt+" "+maxcnt);
		
		
	}

}


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

int main(void) {
  string s;
  long long K;
  cin >> s >> K;
  for (int i = 0; i < s.length(); i++) {
    int index = s[i] - 'a';
    if (index == 0) continue;
    if (26 - index <= K) {
      K -= 26 - index;
      s[i] = 'a';
    }
  }
  s[s.length() - 1] += K % 26;
  s[s.length() - 1] = (s[s.length() - 1] - 'a') % 26 + 'a';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 512
def read_valus():
    return map(int, input().split())


def read_list():
    return list(read_valus())


def read_lists(N):
    return [read_list() for n in range(N)]


def f(T, n):
    N = len(T)
    b = format(n, "015b")[::-1][:N]
    
    for n, s in enumerate(b):
        if s == "1":
            for x, y in T[n]:
                if int(b[x]) != y:
                    return False
    return True


def main():
    N = int(input())
    T = [[] for n in range(N)]
    for n in range(N):
        A = int(input())
        for _ in range(A):
            x, y = read_valus()
            x -= 1
            T[n].append((x, y))

    res = 0
    for n in range(2 ** N - 1, -1, -1):
        bit_count = bin(n).count("1")
        if res >= bit_count:
            continue

        if f(T, n):
            res = max(res, bit_count)  

    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
int H, W;
vector<string> fi;

ll solve()
{
    vector<vector<ll>> dp(H, vector<ll>(W, INF));
    if (fi[0][0] == '#')
        dp[0][0] = 1;
    else
        dp[0][0] = 0;

    repi(i, H, 0)
    {
        repi(j, W, 0)
        {
            repi(dir, 2, 0)
            {
                int ni = i + dx[dir], nj = j + dy[dir];
                if (ni >= H || nj >= W)
                    continue;
                int add = 0;
                if (fi[ni][nj] == '#' && fi[i][j] == '.')
                    add = 1;
                dp[ni][nj] = min(dp[ni][nj], dp[i][j] + add);
            }
        }
    }
    return dp[H - 1][W - 1];
}
int main()
{
    cin >> H >> W;
    fi.resize(H);
    repi(i, H, 0)
    {
        cin >> fi[i];
    }
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define ll long long
typedef pair<int, int> P;

int main(){
  string n;
  cin >> n;
  if ((n[0] == '0' && n[1] == '0') && (n[2] == '0' && n[3] == '0')) {
    cout << "NA" << endl;
    exit(0);
  }
  if ((n[0] == '0' && n[1] == '0')) {
    if (n[2] >= '2' || (n[2] >= '1' && n[3] >= '3')) {
      cout << "NA" << endl;
      exit(0);
    }else {
      cout << "YYMM" << endl;
      exit(0);
    }
  }else if ((n[2] == '0' && n[3] == '0')) {
    if (n[0] >= '2' || (n[0] >= '1' && n[1] >= '3')) {
      cout << "NA" << endl;
      exit(0);
    }else {
      cout << "MMYY" << endl;
      exit(0);
    }
  }
  if (n[0] >= '2' || (n[0] >= '1' && n[1] >= '3')) {
    if (n[2] >= '2' || (n[2] >= '1' && n[3] >= '3')) {
      cout << "NA" << endl;
    }else {
      cout << "YYMM" << endl;
    }
  }else {
    if (n[2] >= '2' || (n[2] >= '1' && n[3] >= '3')) {
      cout << "MMYY" << endl;
    }else {
      cout << "AMBIGUOUS" << endl;
    }
  }

}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return true;}return false;}

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi A(n);
  VIN(A)
  REV(A);
  Vi ans;
  REP(i,n){
    if(i%2==0) ans.pb(A[i]);
  }
  if(n==1){
    VOUT2(ans)
    return 0;
  }
  REV(A);
  REP(i,n){
    if(n%2==0) if(i%2==0) ans.pb(A[i]);
    if(n%2==1) if(i%2==1) ans.pb(A[i]);
  }
  VOUT2(ans)
}

Measured memory_bytes: 5488
#![allow(unused)]

use std::{cell, cmp, collections, convert, fmt, io, iter, ops, str};
use io::{Read, Write};

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn parse_vec<T: str::FromStr>() -> Result<Vec<T>, T::Err> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse())
        .collect()
}

fn main() {
    let n = {
        let ab = parse_vec::<i32>();
        (ab.unwrap()[0])
    };

    let result = (0..n+1).fold(n, |memo, ind| {
        let cc = calc(n, ind);

        if memo > cc {
            return cc;
        }
        memo
    });

    println!("{}", result);
}

fn calc(n: i32, ind: i32) -> i32 {
    let mut cc = 0;
    let mut tmp = ind;
    while tmp > 0 {
        cc += tmp % 6;
        tmp /= 6;
    }
    let mut tmp = n - ind;
    while tmp > 0 {
        cc += tmp % 9;
        tmp /= 9;
    }
    cc
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int a, b, c;
    cin >> a >> b >> c;
    if(b < a) swap(a, b);
    if(a <= c && c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    
    int sum = 0;
    vector<int> v (n);
    for (auto &it : v) {
        cin >> it;
        sum += it;
    }
    
    sort(v.rbegin(), v.rend());
    bool ok = v[m - 1] >= (double) sum / (4 * m);
    cout << (ok ? "Yes" : "No") << "\n";
    
    return 0;
}

// scanf("%d %d", &a, &b)
// printf("%d %d", 123, 456);

// getline(cin, s)
// while (cin >> x) {...} - read unknown data

// vector. vector[i],
// set. insert(), contains == set.find(x) != set.end(), size_t size() or count(x) 
// map. contains == count(x) ?


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

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

typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

int n,A,B,C;
vint bar(100);
int counter=0;

int dp(int k,int a,int b,int c){
    if(k==n){
        counter++;
        if(a==0 || b==0 || c==0)return 10000000;
        else return abs(a-A)+abs(b-B)+abs(c-C);
    }
    int ans=100000000;
    ans=min(ans,dp(k+1,a+bar[k],b,c)+(a>0 ? 10 : 0));
    ans=min(ans,dp(k+1,a,b+bar[k],c)+(b>0 ? 10 : 0));
    ans=min(ans,dp(k+1,a,b,c+bar[k])+(c>0 ? 10 : 0));
    ans=min(ans,dp(k+1,a,b,c));
    return ans;
}

int main(){

    cin>>n>>A>>B>>C;
    rep(i,n)cin>>bar[i];
    int ans=dp(0,0,0,0);
    cout<<ans<<endl;


    return 0;
}

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

const int M = 1e9+7;

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

    string n;
    cin >> n;
    if(n[0] == '7' || n[1] == '7' || n[2] == '7') cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 3652
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
const ll INF=1e15;
int n;
ll a,b;
ll sum;
ll X;
vector<ll> on;
ll f(ll m){
    ll cur = sum;
    for(ll i = 0; i < sz(on); ++i){
        if((m >> i) & 1) cur |= (1LL << on[i]);
    }
    return (cur >= b ? cur - b : -1);
}

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    vector<ll> arr(n);
    F0R(i,n)
        cin >> arr[i];
    a=arr[0];
    b=arr[1];
    ll xsum=0;
    FOR(i,2,n)
        xsum^=arr[i];
    ll tot=arr[0]+arr[1];
    if(tot-xsum<0) {
        cout << -1;
        return 0;
    }
    tot-=xsum;
    if((tot&(xsum<<1LL))!=0) {
        cout << -1;
        return 0;
    }
    if(tot%2) {
        cout << -1;
        return 0;
    }
    X=xsum;
    sum=(tot>>1);
    if(((tot>>1LL) ^ xsum) != (tot>>1LL) + xsum){ cout << -1; return 0; }
    for(ll i = 0; i < 60; ++i){
        if((X >> i) & 1) on.push_back(i);
    }
    // for(auto i : on) cout << i << " ";
    // cout << "\n";
    ll l = 0, r = (1LL << sz(on)) - 1, res = -1;
    if(sum == 0) l++, r--;
    while(l <= r){
        ll m = l + (r - l)/2, cur = f(m);
        if(cur != -1){
            res = cur;
            r = m - 1;
        }
        else l = m + 1;
    }
    cout << res;
    /* ll best=INF;
    if(xsum==0 && (tot>>1LL)>=arr[1]) {
        best=(tot>>1LL)-arr[1];
        cout << best;
        return 0;
    }
    ll val=0;
    for(ll i=58; ~i; i--) {
        if(((xsum>>i)&1LL)==0)
            continue;
        if(val+(1LL<<i)+(tot>>1LL)>=arr[1] && val+(1LL<<i)+(tot>>1LL)!=arr[0]+arr[1])
            best=min(best,val+(1LL<<i)+(tot>>1LL)-arr[1]);
        else
            val+=(1LL<<i);
    }
    if(best==INF) {
        cout << -1;
        return 0;
    }
    cout << best; */

    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>

int A[1000000], n;

/* 二分探索 */
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while ( left < right ) {
    mid = (left + right) / 2;
    if ( key == A[mid] ) return 1;  /* key を発見 */
    if ( key > A[mid] ) left = mid + 1;  /* 後半を探索 */
    else if ( key < A[mid] ) right = mid;  /* 前半を探索 */
  }
  return 0;
}

int main() {
  int i, q, k, sum = 0;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ )
    scanf("%d", &A[i]);

  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &k);
    if ( binarySearch( k ) ) sum++;
  }
  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 3072
#include<stdio.h>

int main(){

  int n, m[100], i, j, tmp, c = 0, min;

  scanf("%d",&n);

  for( i = 0; i < n; i++)
    scanf("%d",&m[i]);

  for( i = 0; i < n; i++){
    min = i;
    for(j = i; j < n; j++){
      if(m[j] < m[min]){
	min = j;
      }
    }
    if( i != min){
      tmp = m[i];
      m[i] = m[min];
      m[min] = tmp;
      c++;
    }
}

  for( i = 0; i < n; i++){
    printf("%d",m[i]);
    if(i < n - 1)
      printf(" ");
  }
  printf("\n%d\n",c);

  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main() {
    double i_place, N, K;
    cin >> N >> K;
    vector<double> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
        if(A[i] == 1) i_place = i;
    }

    double before_count = i_place;
    double after_count = N - 1 - i_place;
    int X, Y;
    cout << 1 + ceil((N-K)/(K-1)) << endl;
}

Measured memory_bytes: 4068
#include <iostream>
#include <utility>
#include <string>
#include<algorithm>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=1;i<=n;i++)
char c[114][514];
signed main() {
	int h, w;
	int cnt = 0;
	cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> c[i][j];
		}
	}
	rep(i, h) {
		rep(j, w) {
			if (c[i][j] == '#'&&c[i][j - 1] != '#' && c[i - 1][j] != '#' && c[i][j + 1] != '#' && c[i + 1][j] != '#')cnt++;
		}
	}
	if (cnt == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int n;
Int happy[110000][3];
Int dp[110000][3];
// 0: umi
// 1: yama
// 2: HW

int main(){
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> happy[i][0] >> happy[i][1] >> happy[i][2];
    }

    for(int i = 1;i <= n;i++){
        for(int place = 0;place < 3;place++){
            for(int placeY = 0; placeY < 3;placeY++){
                if(place == placeY)continue;
                dp[i][place] = max(dp[i][place],
                                   dp[i-1][placeY] + happy[i][place]);
            }
        }
    }
    
    Int ans = 0;
    for(int place = 0;place < 3;place++){
        ans = max(ans, dp[n][place]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5120
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S=INT()
MAX=10**9

x1, y1 = 0, 0
x2, y2 = MAX, 1
x3 = MAX-S%MAX if S%MAX!=0 else 0
y3 = ceil(S, MAX)

print(x1,y1,x2,y2,x3,y3)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class AtCodeeeeeeeeeeeeeeeeeeeer
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            Console.WriteLine(
                s[0] +""+ s.Substring(1, s.Length - 2).Length + s[s.Length - 1]
                );
        }

    }
}


Measured memory_bytes: 11092