akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
vector<int>V(N);
vector<int>P(N);
for(int i=0;i<N;i++){
    cin>>V[i];
}
for(int i=0;i<N;i++){
    cin>>P[i];
}

int sum=0;
for(int i=0;i<N;i++){
    if(V[i]-P[i]>0){
        sum+=V[i]-P[i];
    }
}
cout<<sum<<endl;
}

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

int main() {
  long long n, t;
  cin >> n >> t;
  vector<long long> v(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
  }
  long long ans = t;
  for (int i = 2; i <= n; i++) {
    ans += t;
    ans -= max(v[i - 1] + t - v[i], 0LL);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
n=int(input())
a=list(sorted(map(int,input().split())))
def valid():
    cur=(n+1)&1
    for i in range(n):
        if n&1==0 and i&1==0 and i>0:
            cur+=2
        if n&1==1 and i&1==1:
            cur+=2
        if a[i] != cur: return False
    return True
print(2**(n//2)%(10**9+7) if valid() else 0)

Measured memory_bytes: 52588
#include <iostream>
#include <cstdio>
#include <algorithm>
int main()
{
int a[3],max,min;
scanf("%d",&a[0]);
max=min=a[0];
scanf("%d",&a[1]);
if(a[1]>max)
max=a[1];
else
min=a[1];
scanf("%d",&a[2]);
if(a[2]>max)
max=a[2];
else if(a[2]<min)
min=a[2];
printf("%d",max-min);
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main(){
  int M[N][N];
  int i,j,n,u,k,v;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++) M[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++) {
      printf("%d",M[i][j]);
      if(j!=n-1) printf(" ");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2132
// agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long int ll;
int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
     
       
  int a,b;
  cin>>a>>b;
  if(b==1){ cout<<0; return 0; }
  if(a>=b){ cout<<1; return 0; }
  int cnt=0;
  int ans=1;
  ll fck;
  while(true){
      fck=ans*a;
      fck-=cnt;
      if(fck>=b) {cout<<ans; return 0; }
      ans++;
      cnt++;
  }
   
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

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

int main(){
    ll n; cin >> n;
    ll t[n]; rep(i,0,n) cin >> t[i];

    ll res = t[0];
    rep(i,1,n){
        res = t[i] / gcd(res,t[i]) * res;
      	//cout << res << endl;
    }
    cout << res << ednl;
}

Measured memory_bytes: 256
N, X =map(int,input().split())
a = list(map(int,input().split()))
x = 0
count = 0
for i in range(len(a)+1):
    count += 1
    if not i == len(a):
        x += a[i]
    else:
        break
    if x > X:
        break
print(count)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
using namespace std;
int cnt(int x) {
  int ret = 0;
  while (x > 0) {
    ++ret;
    x /= 10;
  }
  return ret;
}
int main() {
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; ++i) {
    if (cnt(i) % 2 == 1) {
      ++ans;
    }
  }
  cout << ans << "\n";
}



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

long long gcd(long long a,long long b){
  if(max(a,b)%min(a,b) == 0) return min(a,b);
  else return gcd(min(a,b),max(a,b)%min(a,b));
}

int main() {
  int n;long long x,ans;
  cin >> n >> x;
  vector<long long>dx(n);
  for(int i = 0;i < n;i++){
    long long xx;
    cin >> xx;
    dx.at(i) = abs(x-xx);
  }
  if(n == 1){
    cout << dx.at(0) << endl;
    return 0;
  }
  ans = gcd(dx.at(0),dx.at(1));
  if(n == 2){
    cout << ans << endl;
    return 0;
  }
  for(int i = 2;i < n;i++){
    ans = gcd(ans,dx.at(i));
  }
  cout << ans << endl;
}


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

class cD
{
public:
	void N()
	{
		int nTemp = 0;
		nTemp = nD[1];
		nD[1] = nD[2];
		nD[2] = nD[6];
		nD[6] = nD[5];
		nD[5] = nTemp;
	}

	void S()
	{
		int nTemp = 0;
		nTemp = nD[1];
		nD[1] = nD[5];
		nD[5] = nD[6];
		nD[6] = nD[2];
		nD[2] = nTemp;
	}

	void W()
	{
		int nTemp = 0;
		nTemp = nD[1];
		nD[1] = nD[3];
		nD[3] = nD[6];
		nD[6] = nD[4];
		nD[4] = nTemp;
	}

	void E()
	{
		int nTemp = 0;
		nTemp = nD[1];
		nD[1] = nD[4];
		nD[4] = nD[6];
		nD[6] = nD[3];
		nD[3] = nTemp;
	}

	int nD[7] = { 0 };
};
int main()
{
	cD D;
	for (int i = 1; i <= 6; i++)
	{
		cin >> D.nD[i];
	}

	string strInput;
	cin >> strInput;
	for (char e : strInput)
	{
		switch (e)
		{
		case 'E':
			D.E();
			break;
		case 'N':
			D.N();
			break;
		case 'W':
			D.W();
			break;
		case 'S':
			D.S();
			break;
		}
	}
	cout << D.nD[1] << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
using pii = std::pair<int, int>;
using vi = std::vector<int>;
using vd = std::vector<double>;
using vc = std::vector<char>;
using vb = std::vector<bool>;
using vs = std::vector<std::string>;
using vpii = std::vector<pii>;
using vvi = std::vector<vi>;
using vvb = std::vector<vb>;
using vvpii = std::vector<vpii>;
template<typename A> using fn = std::function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
using namespace std;

template<typename MonoidTrait> class SegTree {
  using Monoid = MonoidTrait;
  using T = typename Monoid::value_type;

  Monoid m;
  std::vector<T> data;
  int size = 1;

public:
  SegTree(const int &n = 0) {
    m = Monoid();
    while (size < n) size *= 2;
    data.assign(size * 2, m.id());
  }

  template<typename InputIterator> SegTree(InputIterator first, InputIterator last) {
    m = Monoid();
    int n = std::distance(first, last);
    while (size < n) size *= 2;
    data.resize(size * 2, m.id());
    std::copy(first, last, data.begin() + size);
    for (int i = size - 1; i >= 1; --i) data[i] = m(data[i * 2], data[i * 2 + 1]);
  }

  T fold(int l, int r) const {
    T acc = m.id();
    for (l += size, r += size; l < r; l >>= 1, r >>= 1) {
      if (l & 1) acc = m(acc, data[l++]);
      if (r & 1) acc = m(acc, data[--r]);
    }
    return acc;
  }

  void update(int i, const T &x) {
    data[i += size] = x;
    while (i /= 2) data[i] = m(data[i * 2], data[i * 2 + 1]);
  }

  const T &operator[](int i) const { return data[i + size]; }
};

template<typename T, T upperInf = std::numeric_limits<T>::max()> struct minMonoid {
  using value_type = T;
  constexpr T id() const { return upperInf; }
  T operator()(const T &a, const T &b) const { return std::min(a, b); }
};

main {
  using RMQ = SegTree<minMonoid<int, 2147483647>>;
  int n, q;
  cin >> n >> q;
  RMQ t(n);
  while (q--) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com) {
      cout << t.fold(x, y + 1) << endl;
    } else {
      t.update(x, y);
    }
  }
}

Measured memory_bytes: 4956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef double dl;
#define mp make_pair
#define pb emplace_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define dst distance
#define INF 1000000000
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define MAXN 1010
ll MOD = 1e9+7;

ll memo[MAXN][MAXN];
ll N,a,b,c,d;
ll F[MAXN];
ll Finv[MAXN];
ll I[MAXN];

ll exp(ll a, ll p){
	if (p==0)return 1;
	ll t = exp(a,p/2);
	t = t*t%MOD;
	if(p%2)t=t*a%MOD;
	return t;
}

ll inv(ll x){
	return exp(x,1e9+5);
}

ll C(ll T, ll a){
	assert(a <= T);
	return ((F[T]*Finv[a])%MOD)*Finv[T-a]%MOD;
}

ll ask(ll left, ll A){
	if (memo[left][A] != -1)return memo[left][A];
	if (left == 0)return memo[left][A] = 1;
	if (A == b+1)return memo[left][A] = 0;
	if (left < A)return memo[left][A] = 0;

	ll ans = 0;
	ll mult = 1;
	ll nl = left;

	for (int e=1;e<c;++e){
		if (nl < A)break;
		mult = (((mult * C(nl,A))%MOD) * I[e])%MOD;
		nl -= A;
	}

	for (int e=c;e<=d;++e){
		if (nl<A)break;
		mult = (((mult * C(nl,A))%MOD) * I[e])%MOD;
		nl -= A;
		// cout<<"Mult "<<left<<' '<<A<<' '<<mult<<'\n';
		ans = (ans + ask(nl, A+1)*mult) %MOD;
	}

	ans = (ans+ask(left,A+1))%MOD;
	// cout<<"Ask "<<left<<' '<<A<<' '<<ans<<'\n';
	return memo[left][A] = ans;
}

int main(){
	cin>>N>>a>>b>>c>>d;
	F[0] = 1;
	for (int i=1;i<=N;++i)F[i] = (F[i-1]*i)%MOD;
	for (int i=0;i<=N;++i)Finv[i] = (inv(F[i]))%MOD;
	for (int i=0;i<=N;++i)I[i] = inv(i);
	memset(memo,-1,sizeof(memo));
	cout<<ask(N,a);
}

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

int main () {
    int N,ans=999;
    cin >> N;
    vector<int> W(N);
    for(int i=0;i<N;i++){
        cin >> W[i];
    }
    for(int j=1;j<N;j++){
        int m=0,n=0;
        for(int k=0;k<j;k++) m+=W[k];
        for(int k=j;k<N;k++) n+=W[k];
        ans=min(ans,abs(m-n));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=805,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int n,m,k;
char d[MAXn][MAXn];
int dx[] = {1,0,0,-1};
int dy[] = {0,1,-1,0};
int dis[MAXn][MAXn];
bool chk(int x,int y){
    if (d[x][y] == '#') return true;
    return x < 0 || x >= n || y < 0 || y >= m;
}
int main(){
    IOS();
    cin >> n >> m >> k;
    ii st = ii(0,0);
    REP (i,n) REP (j,m) {
        dis[i][j] = INF;
        cin >> d[i][j];
        if (d[i][j] == 'S') {
            st = ii(i,j);
            dis[i][j] = 0;
        }
    }
    queue<ii> q;
    q.emplace(st);
    while (SZ(q)) {
        ii cur = q.front();
        q.pop();
        REP (i,4) {
            int tx = cur.X + dx[i], ty = cur.Y + dy[i];
            if (chk(tx,ty)) continue;
            if (dis[tx][ty] > dis[cur.X][cur.Y] + 1) {
                dis[tx][ty] = dis[cur.X][cur.Y] + 1;
                if (dis[tx][ty] < k) {
                    q.emplace(tx,ty);
                }
            }
        }
    }
    int ans = INF;
    REP (i,n) REP (j,m) {
        if (dis[i][j] <= k) {
            int cur = min({i,j,n-i-1,m-j-1});
            cur = (cur+k-1)/k;
            ans = min(ans,cur);
        }
    }
    cout << ans+1 << endl;
}


Measured memory_bytes: 6796
#include <stdio.h>

int main(void) {
	int L;
	char S[128] = "";
	char danger_left[128], danger_right[128];
	int chance_left[128], chance_right[128];
	int i;
	int answer = 0;
	if (scanf("%d%127s", &L, S + 1) != 2) return 1;
	for (i = 0; i <= L + 1; i++) {
		danger_left[i] = danger_right[i] = (S[i] == 'B');
		chance_left[i] = chance_right[i] = (S[i] == 'W');
	}
	for (i = 1; i <= L; i++) {
		if (danger_left[i - 1] && S[i] == 'W') danger_left[i] = 1;
 		if (S[i] != 'W' && chance_left[i - 1] > 0) {
			chance_left[i] = S[i] == 'B' ? chance_left[i - 1] + 1 : 0;
		}
	}
	for (i = L - 1; i >= 1; i--) {
		if (danger_right[i + 1] && S[i] == 'W') danger_right[i] = 1;
		if (S[i] != 'W' && chance_right[i + 1] > 0) {
			chance_right[i] = S[i] == 'B' ? chance_right[i + 1] + 1 : 0;
		}
	}
	for (i = 1; i <= L; i++) {
		if (S[i] == '.' && (!danger_left[i - 1] || !danger_right[i + 1])) {
			int candidate = 0;
			if (chance_left[i - 1] > 0) candidate += chance_left[i - 1] - 1;
			if (chance_right[i + 1] > 0) candidate += chance_right[i + 1] - 1;
			if (candidate > answer) answer = candidate;
		}
	}
	printf("%d\n", answer);
	return 0;
}



Measured memory_bytes: 2144
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

int main() {
	string N;
	cin >> N;
	int sum = 0;
	Rep(i, N.size()) {
		sum += N[i] - '0';
	}
	cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3724
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string
#include <vector> // vector
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <cstdint> // int64_t, int_fast64_t

#define all(v) v.begin(),v.end()

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"

typedef std::int_fast64_t ll; // at least int64 > 9*10^18
typedef std::uint_fast64_t ull; // at least uint64

ll comb(ll a,ll b) {
  long double result = 1;
  rep(i,b) {result*=(a-i);result/=i+1;}
  return (ll)result;
}

int main() {
  ll n,a,b;
  std::cin >> n >> a >> b;
  std::vector<ll> values(n);
  rep(i,n) std::cin >> values[i];
  std::sort(all(values),std::greater<ll>());
  long double val_sum = 0;
  rep(i,a) val_sum+=values[i];
  ll min_v = values[a-1];
  if(min_v==values[0]) {
    ll count = 0;
    for(count=0;count<n&&values[count]==values[0];count++) ;
    ll combinations = 0;
    for(ll i=a;i<=std::min(b,count);i++) {
      combinations += comb(count,i);
    }

    std::cout << std::setprecision(10) << val_sum/((long double) a) << ENDL;
    std::cout << std::setprecision(18) << combinations << ENDL;
    return 0;
  }
  ll count = 0;
  rep(i,n) if(values[i]==min_v) count++;
  ll first_i;
  rep(i,n) if(values[i]==min_v) {
    first_i = i;
    break;
  }
  ll combinations = comb(count,a-first_i);
  std::cout << std::setprecision(10) << val_sum/((long double) a) << ENDL;
  std::cout << std::setprecision(18) << combinations << ENDL;
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let d_list: Vec<u32> = (0..n).map(|_| read()).collect();
    let len = d_list.len();

    let mut ans = 0;

    for i in 0..len {
        for j in 0..i{
            if i == j {
                continue;
            }
            ans += d_list[i] * d_list[j];
        }
    }

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


Measured memory_bytes: 4352
import java.util.Scanner;

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

        char[] split = s.toCharArray();
        int digit = s.length();
        long total = 0;
        for (int i = 0; i < Math.pow(2, digit - 1); i++) {
            StringBuilder sb = new StringBuilder();
            for (int j = 0; j < digit; j++) {
                sb.append(split[j]);
                if ((1 & i >> j) == 1) {
                    sb.append("+");
                }
            }
            for (String num : sb.toString().split("\\+")) {
                total += Long.parseLong(num);
            }
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 23508
#include<iostream>
using namespace std;
 
int main(){
	int a;
	
	cin>>a;
	
	if(a<1200){
		cout<<"ABC"<<endl;
	}
	else if(a<2800){
		cout<<"ARC"<<endl;
	}
	else{
		cout<<"AGC"<<endl;
	}
}

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

using namespace std;
const int N = 3e5+100;
long long a[N],s[N];
int main(){
  int n;
  cin>>n;
  long long sum=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    sum+=a[i];
    s[i]=s[i-1]+a[i];
  }
  long long minn=(1e18);
  for(int i=1;i<=n;i++){
    //cout<<i<<' '<<abs(s[i]-(sum-s[i]))<<endl;
    minn=min(minn,abs(s[i]-(sum-s[i])));
  }
  cout<<minn<<endl;
  return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }





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.at(i);
	bool ok = true;
	rep(i,h){
		rep(j,w){
			if(s[i][j] == '#'){
				bool flg = true;
				rep(k,4){
					int y = i + dy[k], x = j + dx[k];
					if(inside(y,x,h,w) && s[y][x] == '#') flg = false;
				}
				if(flg) ok = false;
			}
		}
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  vector<string> s;
  int res1 = 0, res2 = 0, res3 = 0, res4 = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    if (tmp == "AC") res1++;
    if (tmp == "WA") res2++;
    if (tmp == "TLE") res3++;
    if (tmp == "RE") res4++;
  }

  cout << "AC x " << res1 << endl;
  cout << "WA x " << res2 << endl;
  cout << "TLE x " << res3 << endl;
  cout << "RE x " << res4 << endl;
  return 0;
}

Measured memory_bytes: 3628
fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}
 
fn main() {
    let s = getline();
    let n: i32 = s.trim().parse().unwrap();
    let x = 800 * n;
    let y = 200 * (n / 15);
    let ans = x - y;
 
    println!("{}", ans);
}

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

int main(){
    float N,K;
    int ans = 0;
    cin >> N >> K;
    vector<int> x(N);
    for(int i = 0;i<N;i++) cin >> x[i];
    float th = K/2;
    for(int i=0;i<N;i++){
        if(x[i]<th) ans+= x[i];
        else ans+=abs(K-x[i]);
    }
    cout << ans*2 << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#define ll long long 
using namespace std;
int a[3];
int main()
{
	for (int i = 0; i < 3; i++)
	cin >> a[i];
	sort(a, a + 3);
	int ans = a[2] * 10 + a[1] + a[0];
	cout << ans;
	return 0;
}

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

int main(void){
    int n; cin >> n;
    vector<ll>p(n),idx(n);
    for(int i=0;i<n;i++){
        cin >> p[i];p[i]--;
        idx[p[i]]=i;
    } 



    set<ll>s;
    s.insert(-1);s.insert(n);
    ll ans = 0;
    for(int i=n-1;0<=i;i--){
        vector<ll> l(2,-1),r(2,n);

        ll index = idx[i];
        s.insert(index);

        // for(auto iter = s.begin();iter!=s.end();iter++){
        //     cout << *iter << '#';
        // }cout << endl;

        // auto itr = s.end();
        // itr--;
        // cout << *itr << endl;

        auto iter = s.find(index);
        if(iter != s.begin()) l[0] = *--iter;
        if(iter != s.begin()) l[1] = *--iter;
        iter = s.find(index);iter++;
        if(iter != s.end()) r[0] = *iter++;
        if(iter != s.end()) r[1] = *iter++;
        // cout << l[1] << ' ' << l[0] << ' '<< index << ' ' << r[0] << ' ' << r[1] << endl;
        ans += (i+1) * ((index - l[0]) * (r[1] - r[0]) + (l[0] - l[1]) * (r[0] - index));
        // cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  double x,h,result;
  while(1){
    cin >> x >> h;
    if(x+h==0)break;
    result = sqrt((x*x)/4 + h*h)*2*x + x*x;
    printf("%.10f\n",result);
  }
  return 0;
}

Measured memory_bytes: 1236
#include<iostream>
using namespace std;
int main()
{
string s;
cin>>s;
for(int i=0;i<5;++i){
cout<<s[i];
}
cout<<" ";
for(int i=6;i<13;++i){
	cout<<s[i];
}
cout<<" ";
for(int i=14;i<19;++i){

cout<<s[i];

}

}


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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	char s[100005]; scanf("%s", s);
	int n = 0;
	for(int i = 0; s[i]; i++) {
		n++;
	}
	int res[n]{0};
	for(int i = 0; i < n - 1; i++) { 
		if(s[i] == 'R' && s[i + 1] == 'L') {
			int left = i - 1; int right = i + 2; res[i]++; res[i + 1]++;
			bool ok = true;
			while(left >= 0 && s[left] == 'R') {
				left--;
				if(ok) {
					res[i + 1]++; ok = false;
				} else {
					res[i]++; ok = true;
				}
			}
			ok = true;
			while(right < n && s[right] == 'L') {
				right++;
				if(ok) {
					res[i]++; ok = false;
				} else {
					res[i + 1]++; ok = true;
				}
			}
		}	
	}
	for(auto a : res)
		printf("%d ", a);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,inp;
	while(cin>>n,n){
		int ge[7]={0};
		rep(i,n){
			cin>>inp;
			if(inp<10)ge[0]++;
			else if(inp<20)ge[1]++;
			else if(inp<30)ge[2]++;
			else if(inp<40)ge[3]++;
			else if(inp<50)ge[4]++;
			else if(inp<60)ge[5]++;
			else ge[6]++;
		}
		rep(i,7)cout<<ge[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int lx,ly,rx,ry,n,x,y,a,p;
    lx=0,ly=0;
    cin>>rx>>ry>>n;
    while(n--)
    {
        cin>>x>>y>>a;
        if(a==1)
            lx=max(x,lx);
        else if(a==2)
            rx=min(x,rx);
        else if(a==3)
            ly=max(y,ly);
        else if(a==4)
            ry=min(y,ry);
    }
    int area=(rx-lx)*(ry-ly);
   /* if(area>=0)
        cout<<area<<endl;
    else
        cout<<0<<endl;*/
    cout<<(max(0, rx - lx) * max(0, ry - ly))<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    sb = s[:len(s)//2]
    sa = s[len(s)//2 + 1:]
    for i in range(len(s)):
        if s[i] != s[-i-1]:
            print("No")
            exit()
    for i in range(len(sb)):
        if sb[i] != sb[-i-1] or sa[i] != sa[-i-1]:
            print("No")
            exit()
    print("Yes")


if __name__ == '__main__':
    solve()


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

signed main(){
	int a,b,ans = 0;
	cin >> a >> b;
	for(int i = a;i <= b;i++){
		bool flag = true;
		string s = to_string(i);
		for(int j = 0;j < s.length();j++){
			if(s[j] != s[s.length() - j - 1]) flag = false;
		}
		ans += flag;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// N
		int N = sc.nextInt();
		// M
		int M = sc.nextInt();
		// X
		int X = sc.nextInt();
		
		int[] a = new int[M];
		for (int i = 0; i < M; i++) {
			a[i] = sc.nextInt();
		}
		
		int ryouhinn1 =0;
		for (int i = X+1; i < N; i++) {
			for (int j = 0; j < a.length; j++) {
				if (i == a[j]) {
					ryouhinn1++;
				}
			}
		}
		int ryouhinn2 =0;
		for (int i = X-1; i >=0; i--) {
			for (int j = 0; j < a.length; j++) {
				if (i == a[j]) {
					ryouhinn2++;
				}
			}
		}
		
		
		if (ryouhinn1 > ryouhinn2 ) {
			System.out.println(ryouhinn2);
		} else {
			System.out.println(ryouhinn1);
		}
		
//1		// 出力
//		
//		for (int i = 0; i < b; i++) {
//			if (a + i == x) {
//				System.out.println("YES");
//				return;
//			}
//		}
//		System.out.println("NO");
		
		
	}
}



Measured memory_bytes: 21716
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n] = put n
putList (n:ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n] = putStr n
putStrList (n:ns) = do
  putStr n
  putStr " "
  putStrList ns

main = do
  s <- getLine
  let m = 'o' `count` s
   in put $ 700 + m * 100


Measured memory_bytes: 380
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8)cout << "pon" << endl;
    else if(n%10 == 3)cout << "bon" << endl;
    else cout << "hon" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

const int bits = 42;

int main() {
  int N, K;
  while (cin >> N >> K) {
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    vector<ll> cands(N);
    for (int i = 0; i < N; i++) {
      ll x = 0;
      for (int j = i; j < N; j++) {
        x += a[j];
        cands.push_back(x);
      }
    }
    ll res = 0;
    for (int b = bits - 1; b >= 0; b--) {
      int cnt = 0;
      vector<ll> hits;
      for (ll x : cands) {
        if ((x >> b) & 1) {
          hits.push_back(x);
        }
      }
      if (hits.size() >= K) {
        res |= (1ll << b);
        cands = hits;
      }
    }
    cout << res << endl;
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    string s; cin >> s;

    vector<ll> t;

    ll r = 0;
    ll l = 0;

    for (ll i = 0; i < s.size(); ++i) {
        if (s[i] == '<') {
            if (l < 0) {
                t.push_back(l);
                l = 0;
            }
            ++r;
        } else {
            if (r > 0) {
                t.push_back(r);
                r = 0;
            }
            --l;
        }
    }

    if (l < 0) {
        t.push_back(l);
    }

    if (r > 0) {
        t.push_back(r);
    }

    ll ans = 0;

    if (t.size() == 1) {
        ans += abs(t[0]) * (abs(t[0]) + 1) / 2;
        cout << ans << endl;
        return 0;
    }

    for (ll i = 0; i < t.size(); ++i) {
        if (i == 0 && t[i] < 0) {
            ans += abs(t[i]) * (abs(t[i]) + 1) / 2;
            continue;
        }

        if (i == t.size()-1 && t[i] > 0) {
            ans += t[i] * (t[i] + 1) / 2;
            continue;
        }

        if (i == t.size()-1 && t[i] < 0) {
            continue;
        }

        if (t[i] > 0 && t[i+1] < 0) {
            ll ma = max(abs(t[i]), abs(t[i+1]));
            ll mi = min(abs(t[i]), abs(t[i+1]));

            ans += ma * (ma + 1) / 2;
            ans += mi * (mi - 1) / 2;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3068
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)

int
main(int argc, char *argv[])
{
  int n, h[100010];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &h[i]);

  int k = 0, x, ans = 0;
  while (k < n) {
    x = 0;
    while (k < n - 1 && h[k] >= h[k + 1]) {
      x++;
      k++;
    }
    k++;
    ans = Max(ans, x);
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 640
import java.util.*;
class Main
{
  public static void main(String [ ]args)
  {
    Scanner sc = new Scanner(System.in);
    int A= sc.nextInt();
    int B =sc.nextInt();
    int sum=1;
    int count=0;
    
    while(sum<B)
    {
      count++;
      sum+=(A-1);
    }
    System.out.println(count);
  }
  
}

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

int main() {
	int n,k;
	cin >> n >> k;
	vector<int>h(n);
	for (int i = 0; i < n; i++)cin >> h.at(i);
	vector<int>dp(n);
	dp.at(0) = 0;
	for (int i = 1; i <= n - 1; i++) {
		if (i < k) {
			int res = 1000000000;
			for (int j = 1; j <= i; j++) {
				res = min(res, dp.at(i - j) + abs(h.at(i) - h.at(i - j)));
			}
			dp.at(i) = res;
		}
		else {
			int res = 1000000000;
			for (int j = 1; j <= k; j++) {
				res = min(res, dp.at(i - j) + abs(h.at(i) - h.at(i - j)));
			}
			dp.at(i) = res;
		}
	}
	cout << dp.at(n - 1) << endl;
}

Measured memory_bytes: 1024
N = int(input())
A = [int(x) for x in input().split()]
x = [None]*N
x[0] = sum([A[i]*((-1)**i) for i in range(N)])//2
for i in range(1, N):
    x[i] = (A[i-1] - x[i-1])

ans = [2*x[i] for i in range(N)]
print(' '.join(map(str, ans)))


Measured memory_bytes: 23096
#include <stdio.h>

int main(){
    int i,n,maxp,minp,a,b,c,d,e,sum;

    while(1){
	scanf("%d",&n);

	if(n == 0) break;

	maxp = 0; 
	minp = 10000000;
	for(i=0; i<n; i++){
	    scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	    sum = a + b + c + d + e;
	    if(sum > maxp) maxp = sum;
	    if(sum < minp) minp = sum;
	}
	printf("%d %d\n",maxp,minp);
    }
    return 0;
}

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

int main()
{
  int h,w;
  cin >> h >> w;
  char m[h+2][w+2];
  int i, j;
  rep(i, w+2){
    m[0][i] = 0;
  }
  for(int i =1; i <h+1; i++){
    m[i][0] = 0;
    for(int j = 1; j < w+1; j++){
      cin >> m[i][j];
    }
    m[i][w+1] = 0;
  }
  rep(i, w+2){
    m[h+1][i] = 0;
  }
  
  int n;
  for(int i = 1; i < h+1; i++){
    for(int j = 1; j < w+1; j++){
      n = 0; //number
  if(m[i-1][j-1] == '#') n++;
      if(m[i-1][j] == '#') n++;
      if(m[i-1][j+1] == '#') n++;
      if(m[i][j-1] == '#') n++;
      if(m[i][j+1] == '#') n++;
      if(m[i+1][j-1] == '#') n++;
      if(m[i+1][j] == '#') n++;
      if(m[i+1][j+1] == '#') n++;
      
      if(m[i][j] == '#') cout << '#';
      else cout << n;
    }
    cout << endl;
  }
  return 0;
}
  
  /*
  int i = 0; int j = 0;
  int n = 0; //number
  if(m[i][j+1] == '#') n++;
  if(m[i+1][j] == '#') n++;
  if(m[i+1][j+1] == '#') n++;
      
  if(m[i][j] == '#') cout << '#';
  else cout << n;
  
  for(int j = 1; j < w-1; j++){
    n = 0; //number
    if(m[i][j-1] == '#') n++;
    if(m[i][j+1] == '#') n++;
    if(m[i+1][j-1] == '#') n++;
    if(m[i+1][j] == '#') n++;
    if(m[i+1][j+1] == '#') n++;
    
    if(m[i][j] == '#') cout << '#';
    else cout << n;
  }
  
  j = w-1;
  n = 0; //number
  if(m[i][j-1] == '#') n++;
  if(m[i+1][j] == '#') n++;
  if(m[i+1][j-1] == '#') n++;
  
  if(m[i][j] == '#') cout << '#';
  else cout << n;
  cout << endl;
  
  for(int i = 1; i < h-1; i++){
    j = 0;
    n = 0; //number
    if(m[i-1][j] == '#') n++;
    if(m[i-1][j+1] == '#') n++;
    if(m[i][j+1] == '#') n++;
    if(m[i+1][j] == '#') n++;
    if(m[i+1][j+1] == '#') n++;
    
    if(m[i][j] == '#') cout << '#';
    else cout << n;
    
    for(int j = 1; j < w-1; j++){
      n = 0; //number
  if(m[i-1][j-1] == '#') n++;
      if(m[i-1][j] == '#') n++;
      if(m[i-1][j+1] == '#') n++;
      if(m[i][j-1] == '#') n++;
      if(m[i][j+1] == '#') n++;
      if(m[i+1][j-1] == '#') n++;
      if(m[i+1][j] == '#') n++;
      if(m[i+1][j+1] == '#') n++;
      
      if(m[i][j] == '#') cout << '#';
      else cout << n;
    }
    j = w-1;
    n = 0; //number
    if(m[i-1][j-1] == '#') n++;
    if(m[i-1][j] == '#') n++;
    if(m[i][j-1] == '#') n++;
    if(m[i+1][j-1] == '#') n++;
    if(m[i+1][j] == '#') n++;
    
    if(m[i][j] == '#') cout << '#';
    else cout << n;
    cout << endl;
  }
  
  i = h-1; j = 0;
  n = 0; //number
  if(m[i-1][j] == '#') n++;
  if(m[i-1][j+1] == '#') n++;
  if(m[i][j+1] == '#') n++;
      
  if(m[i][j] == '#') cout << '#';
  else cout << n;
  
  for(int j = 1; j < w-1; j++){
    n = 0; //number
    if(m[i][j-1] == '#') n++;
    if(m[i][j+1] == '#') n++;
    if(m[i-1][j-1] == '#') n++;
    if(m[i-1][j] == '#') n++;
    if(m[i-1][j+1] == '#') n++;
    
    if(m[i][j] == '#') cout << '#';
    else cout << n;
  }
  
  j = w-1;
  n = 0; //number
  if(m[i][j-1] == '#') n++;
  if(m[i-1][j] == '#') n++;
  if(m[i-1][j-1] == '#') n++;
  
  if(m[i][j] == '#') cout << '#';
  else cout << n;
  cout << endl;
  
  return 0;
}
*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793)
#define mod 1000000007


int main() {
	llint n, m;
	cin >> n >> m;
	llint ans = 0;
	if(m-2 >= 0&&n-2 >= 0)ans += (m-2)*(n-2);
	else if (m == 1)ans += n - 2;
	else if (n == 1)ans += m - 2;
	if (n == 1 && m == 1)ans = 1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		PriorityQueue<Integer> x = new PriorityQueue<Integer>();
		for(int i = 0; i < m; i++) {
			x.add(sc.nextInt());
		}
		
		boolean ifFirst = true;
		int tmp = 0;
		PriorityQueue<Integer> d = new PriorityQueue<Integer>(Collections.reverseOrder());
		while(!x.isEmpty()) {
			int a = x.poll();
			if(ifFirst) {
				ifFirst = false;
				tmp = a;
			}else {
				d.add(a - tmp);
				tmp = a;
			}
		}
		
		for(int i = 0; i < n - 1; i++) {
			d.poll();
		}
		int ans = 0;
		while(!d.isEmpty()) {
			ans += d.poll();
		}
		
		System.out.println(ans);
	}
}

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


int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (a > 0 && c > 0) {
        c -= b;
        a -= d;
    }
    if (c <= 0) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;
}

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

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

  int sq;

  if (b < 10) sq = 10 * a + b;
  else if (b < 100) sq = 100 * a + b;
  else sq = 1000 * a + b;

  bool ans = false;

  for (int i = 1; i <= 400; i++) {
    if (sq == i * i) {
      ans = true;
      break;
    }
  }

  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,n) for(ll i=a;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
  ll num[100001];
  rep(i,0,100001)num[i]=0;
  ll n;
  cin>>n;
  ll a[n];
  ll sum=0;
  rep(i,0,n){
    cin>>a[i];
    num[a[i]]++;
    sum+=a[i];
  }
  ll q;
  cin>>q;
  ll b[q],c[q];
  rep(i,0,q)cin>>b[i]>>c[i];
  rep(i,0,q){
    sum+=(c[i]-b[i])*num[b[i]];
    cout<<sum<<endl;
    num[c[i]]+=num[b[i]];
    num[b[i]]=0;
  }
  return 0;
}

Measured memory_bytes: 6696
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  string S;
  cin >> S;
  if((S[0] == S[1] && S[1] == S[2]) || (S[1] == S[2] && S[2] == S[3])){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;

}


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

int main () {

    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int ans = 0;
    for (int r = 0; r <= N/R; r++) {
        for (int g = 0; g <= N/G; g++) {

            int blue_balls = N - r * R - g * G;

            if (blue_balls >= 0 && blue_balls % B == 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main(void){
  char s[16], t[16];
  scanf("%s%s", s, t);
  int sn = strlen(s);
  int tn = strlen(t);
  // printf("s: %s, len(%d)\nt: %s, len(%d)\n", s, sn, t, tn);
  if(memcmp(s, t, sn)  == 0){
    if(tn == sn+1){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define int long long
#define fori(j,n) for(int i=j;i<n;i++)
#define forb(n,j) for(int i=n-1;i>=0;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define PI 3.141592653589793
#define M 1000000007
using namespace std;
int fast(int a,int b)
{
    int ans=1;
    a=a%M;
    if(a==0)
        return 0;
    while(b>0)
    {
        if(b&1)
        {
            ans=(ans*a)%M;
        }
        b>>=1;
        a=(a*a)%M;
    }
}
int h[100010];
int n;
int dp[100010];
int fun(int i)
{
    if(i==n)
        return 0;
    if(i>n)
        return INT_MAX;
    if(dp[i]!=-1)
        return dp[i];
    int left=abs(h[i]-h[i+1])+fun(i+1);
    int right=abs(h[i]-h[i+2])+fun(i+2);
    dp[i]=min(left,right);
    return min(left,right);
}
int32_t main()
{
    IOS;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    fori(1,n+1)
        cin>>h[i];
    cout<<fun(1);
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
using namespace std;
#define MAX 2000000

int H, A[MAX + 1];

void maxHeapify(int i){
  int l, r, largest;

  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;

  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i){
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int main(){
  int i;

  cin >> H;

  for(i = 1 ; i <= H ; i++){
    cin >> A[i];
  }
  for(i = H / 2 ; i >= 1 ; i--){
    maxHeapify(i);
  }
  for(i = 1 ; i <= H ; i++){
    cout << " " << A[i];;
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 5036
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    int x;
    cin>>x;
    int ans=0;
    if(x==1){
        cout<<1<<endl;
        return 0;
    }
    for(int i=2;i<=x;i++){
        for(int j=2;j*j<=i;j++){
            for(int k=2;pow(j,k)<=i;k++){
                if(pow(j,k)==i)ans=i;
            }
        }
    }
    cout<<ans<<endl;
}

   


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
#include<iomanip>
#include<vector>

using namespace std;
typedef long long ll; 


ll ans,mx,sum,mn=1e18,flag;
ll east;
ll a,b;
int main(){
	ll n;
	cin>>n;
	string s;
	cin>>s;
	
	for(ll i=0; i<n; i++){
		if(s[i]=='E') east++;
	}
	ll a1=0,b1=0;
	for(ll i=0; i<n; i++){
		if(s[i]=='W') a++;
		else b++;
		if(s[i]=='W'){
			a1=a-1;
			ll finaleast=east-b;		
			mn = min(mn,a1+finaleast);
		} else {
			ll finaleast=east-b;
			mn = min(mn,a+finaleast);
		}
	}
	if(east==n) cout<<0;
	
	else 	cout<<mn<<endl;
	
}


Measured memory_bytes: 900
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
using namespace std;
typedef unsigned long long ll;
const int maxn=1e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;

int main()
{
    char s[1007],t[1007];
    scanf("%s %s",s,t);
    int len_s=strlen(s);
    int len_t=strlen(t);
    int ans=inf;
    for(int i=0;i<len_s-len_t+1;i++)
    {
        int tmp=0;
        for(int j=0;j<len_t;j++)
        {
            if(s[i+j]!=t[j]) tmp++;
        }
        ans=min(tmp,ans);
    }
    printf("%d\n",ans);
    return 0;
}


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

int main(){
	int n;
	string s;
	cin >> n >> s;
	
	bool res = true;
	if(n%2 == 1) res = false;
	else{
		rep(i, n/2){
		if(s.at(i) != s.at(n/2+i)) res = false;
	}
	}

	if(res) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256