akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define EQ(a,b) (abs((a)-(b)) < EPS)
typedef complex<double> P;
const double EPS = 1e-12;

class C {
  public:
  P p; double r;
  C(){}
  C(const P _p, double _r) { p = _p; r = _r; }
};

vector<P> crosspointCC(const C &c1, const C &c2){
  vector<P> res;
  double d = abs(c1.p - c2.p);
  double rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
  double dfr = c1.r * c1.r - rc * rc;
  if(EQ(dfr, 0.0)) dfr = 0.0;
  else if(dfr < 0.0) return res;
  double rs = sqrt(dfr);

  P diff = (c2.p - c1.p) / d;
  res.push_back(c1.p + diff * P(rc, rs));
  res.push_back(c1.p + diff * P(rc, -rs));
  return res;
}

int main() {
  int N;
  while(cin >>N && N){
    vector<C> cs(N);
    REP(i, N){
      double x, y;
      scanf("%lf,%lf", &x, &y);
      cs[i] = C(P(x, y), 1.0);
    }
    int ans = 1;
    REP(i, N){
      FOR(j, i + 1, N){
        vector<P> ps = crosspointCC(cs[i], cs[j]);
        ps.push_back(cs[i].p);
        REP(k, ps.size()){
          int cnt = 0;
          REP(l, N) if(abs(ps[k] - cs[l].p) < 1.0 + EPS) ++cnt;
          ans = max(ans, cnt);
        }
      }
    }
    cout <<ans <<endl;
  }
  return 0;
}

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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

int main(){

  int X,Y,leg;

  cin >> X >> Y;

  for (int i = 0; i <= X; i++)
  {
    leg = 4 * i;
    leg += 2 * (X - i);
    if (leg == Y)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }

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


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

int main() {
    long long N, A, B;
    cin >>N>>A>>B;

    long long x = N%(A+B);
    long long ans = min(A, x);
    ans = ans + A*(N/(A+B));
    cout << ans << endl;
}

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

int64_t p=998244353;

int64_t pinv(int64_t a){
  int64_t p1=p-2;
  int64_t k=a;
  int64_t Ans=1;
  while(p1>0){
    if(p1%2==1){
      Ans*=k;
      Ans%=p;
    }
    k*=k;
    k%=p;
    p1/=2;
  }
  return Ans;
}

int main(){
  int64_t N, M, K;
  cin >> N >> M >> K;
  int64_t Ans=0;
  vector<int64_t> Pow(N);
  vector<int64_t> H(N);
  Pow.at(0)=1;
  H.at(0)=1;
  for(int i=1; i<=N-1; i++){
    Pow.at(i)=Pow.at(i-1)*(M-1);
    Pow.at(i)%=p;
    H.at(i)=H.at(i-1)*(N-i);
    H.at(i)%=p;
    H.at(i)*=pinv(i);
    H.at(i)%=p;
  } 
  for(int64_t i=0; i<=K; i++){
    Ans+=((M*Pow.at(N-1-i))%p)*H.at(i);
    Ans%=p;
  }
  cout << Ans << endl;
}

Measured memory_bytes: 6324
#include<bits/stdc++.h>
using namespace std;
const int SIZE=1400;
int H,W;
int fld[SIZE][SIZE];


int solve(int *H){
    int L[SIZE],R[SIZE];

    stack<int>S;

    for(int i=0;i<W;i++){
        while(S.size()&&H[S.top()]>=H[i])S.pop();
        if(S.empty())L[i]=i;
        else L[i]=i-S.top()-1;
        S.push(i);
    }

    S=stack<int>();

    for(int i=W-1;i>=0;i--){
        while(S.size()&&H[S.top()]>=H[i])S.pop();
        if(S.empty())R[i]=W-i-1;
        else R[i]=S.top()-i-1;
        S.push(i);
    }
    //cout<<"H :";for(int i=0;i<W;i++)cout<<H[i]<<" ";cout<<endl;
    //cout<<"L :";for(int i=0;i<W;i++)cout<<L[i]<<" ";cout<<endl;
    //cout<<"R :";for(int i=0;i<W;i++)cout<<R[i]<<" ";cout<<endl;
    int ret=0;
    for(int i=0;i<W;i++)ret=max(ret,H[i]*(L[i]+R[i]+1));
    return ret;
}

int main(){
    cin>>H>>W;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>fld[i][j];
            if(fld[i][j]==1){
                fld[i][j]=0;
            }
            else{
                fld[i][j]=(i?fld[i-1][j]:0)+1;
            }
        }
    }

    int ma=0;
    for(int i=0;i<H;i++)ma=max(ma,solve(fld[i]));

    cout<<ma<<endl;
    return 0;
}

Measured memory_bytes: 8868
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <deque>
#include <queue>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define pi acos(-1)

const int maxn = 1000000 + 5;

int main()
{
    int a, b;

    cin >> a >> b;

    int c;

    c = max(a + b, max(a - b, a * b));

    cout << c << endl;

    return 0;
}


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

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    string s;
    void input() {
        cin >> s;
    }

    bool check(int x, int y) {
        if (s.size() < y) return false;
        int n = y - x;
        map<char, int> count;
        for (int j = x; j < y; j++) {
            count[s[j]]++;
        }
        for (auto it = count.begin(); it != count.end(); it++) {
            if (it->second > double(n) / 2) return true;
        }
        return false;
    }

    void solve() {
        for (int i = 0; i < s.size(); i++) {
            if (check(i, i + 2)) {
                cout << i + 1 << " " << i + 2 << endl;
                return;
            }
            if (check(i, i + 3)) {
                cout << i + 1 << " " << i + 3 << endl;
                return;
            }
        }
        cout << "-1 -1" << endl;
    }
}

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



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int lg10(ll x){
  int ret = 0;
  while(x){
    ret++;
    x/=10;
  }
  return ret;
}

ll tens[20];

ll calc(ll d){
  int ld = lg10(d);
  ll ans = 0;
  FOR(l,ld,2*ld+1){
    ll sum = 0;
    ll add = l%2==0 ? 1 : 10;
    REP(i,l/2){
      int mx = -25, mn = 25;
      ll tt = tens[l-1-i] - tens[i];
      FOR(x,-9,10){
        ll nsum = sum + tt * x;
        if(nsum <= d){
          CHMAX(mx,x);
        }else{
          CHMIN(mn,x);
        }
      }
      int cand = -25;
      if(cand == -25 && mx!=-25){
        ll nsum = sum + tt * mx;
        if(nsum % tens[i+1] == d % tens[i+1]){
          cand = mx;
        }
      }
      if(cand == -25 && mn!=25){
        ll nsum = sum + tt * mn;
        if(nsum % tens[i+1] == d % tens[i+1]){
          cand = mn;
        }
      }
      if(cand != -25){
        ll nsum = sum + tt * cand;
        sum = nsum;
        if(i==0){
          if(cand<0){
            add *= 10+cand;
          }else{
            add *= 9-cand;
          }
        }else{
          add *= 10-abs(cand);
        }
      }else{
        add = 0;
      }
      if(add == 0){
        break;
      }
    }
    if(sum == d){
      ans += add;
    }
  }
  return ans;
}

int main(){
  // prepare tens
  tens[0] = 1;
  FOR(i,1,20)tens[i] = tens[i-1]*10ll;

  ll d;
  scanf("%lld",&d);
  printf("%lld\n",calc(d));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
using namespace std;
int main( void )
{
	double x = 0.0, y = 0.0, angle = 0.0;

	int walk, rotate;
	char split;
	string input;
	while ( cin >> input && input != "0,0" )
	{
		istringstream is( input );
		is >> walk >> split >> rotate;

		double radian = angle * M_PI / 180.0;
		x += walk * sin( radian );
		y += walk * cos( radian );
		angle += rotate;
	}

	cout << (int)x << endl;
	cout << (int)y << endl;

	return 0;
}

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

#define ll long long

char s[1011][1011],c;
int n,m,cnt=0;
ll vis[1011][1011],mod=(ll)(1e9+7);

int main() {
    scanf("%d%d ",&n,&m);
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++)
            scanf("%c",&s[i][j]);
        scanf("%c",&c);
    }
    int j=1;
    while(s[1][j]=='.'&&j<=m)
    {
        vis[1][j++]=1;
    }
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i][j]=='#')
                vis[i][j]=0;
            else
                vis[i][j]=(vis[i-1][j]+vis[i][j-1])%mod;
        }
    }
    printf("%lld\n",vis[n][m]);
    //cout<<cnt<<endl;
    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  int ans = a * x + b * y;
  int tmp = ans;

  rep(i, max(x, y)) {
    if (i < x) tmp -= a;
    if (i < y) tmp -= b;
    tmp += 2 * c;
    ans = min(ans, tmp);
  }

  cout << ans << endl;
}


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

int main(){
    string a,b,ans="";
    cin>>a>>b;
    if(a.size()==b.size()){
    for(int i=0;i<a.size();i++){
        ans +=a.at(i);
        ans +=b.at(i);
    }
    }else{
        for(int i=0;i<a.size()-1;i++){
            ans +=a.at(i);
            ans +=b.at(i);
        }
        ans += a.at(a.size()-1);
    }
    cout<<ans<<endl;
}

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

using namespace std;

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

	int n, t;
	cin >> n >> t;

	int l;
	cin >> l;

	long long ans = 0;

	for (int i = 1; i < n; i++) {
		int a;
		cin >> a;
		ans += min(a - l, t);
		l = a;
	}

	cout << ans + t << endl;

	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
// #include<unordered_map>
#include<set>
// #include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y, idx;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

template<typename T>
T minT(T a, T b) {
	if (a < b) return a;
	else return b;
}

template<typename T>
T maxT(T a, T b) {
	if (a > b) return a;
	else return b;
}

template<typename T>
T absT(T a) {
	if (a < 0) a *= -1;
	return a;
}

template<typename T>
T powT(T a, T x) {
	T res = 1;
	while (x > 0) {
		if (x & 1) res = res*a;
		a = a*a;
		x >>= 1;
	}
	return res;
}

ll StoLL(string str) {
	ll ret = 0, ini = 0;
	if (str[0] == '-') ini = 1;
	repi(i, ini, str.length()) {
		ret *= 10;
		ret += (ll)(str[i] - '0');
	}
	if (ini) ret *= -1;
	return ret;
}

///////////////////////////////////////////////////////////////////////////////////////

int main() {
	ll n, k, a;
	cin >> n >> k;
	repi(i, 0, n) cin >> a;
	ll ans = MAX_10p18;

	repi(i, 1, k + 1) {
		ll tn, tans;
		tn = n - i, tans = 1;
		if (tn > 0) {
			tans += tn / (k - 1);
			if (tn % (k - 1) != 0) tans++;
		}
		ans = min(ans, tans);
	}
	wrln(ans);
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> B(N-1);

    for(int i = 0; i < N - 1; i++){
        cin >> B[i];
    }
    int ans = B[0] + B[N-2];
    for(int i = 1; i < N - 1; i++){
        ans = ans + min(B[i-1], B[i]);
    } 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int p[n];
    for (int i = 0;i<n;i++){
        cin>>p[i];
    }
    int ans =0;
    sort(p,p+n);
    for (int i = 0;i<n-1;i++){
        ans+=p[i];
    }
    ans+=p[n-1]/2;
    cout<<ans;

    
}


Measured memory_bytes: 3572
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,W;
    cin >> H >> W;
    string s[55];
    rep(i,0,H) cin >> s[i];
    bool ok = true;
    rep(i,0,H){
        rep(j,0,W){
            if(s[i][j] == '#'){
                ll cnt = 0;
                if(i > 0){
                    if(s[i-1][j] == '#') cnt++;
                }
                if(i+1 < H){
                    if(s[i+1][j] == '#') cnt++;
                }
                if(j > 0){
                    if(s[i][j-1] == '#') cnt++;
                }
                if(j+1 < W){
                    if(s[i][j+1] == '#') cnt++;
                }
                if(cnt == 0) ok = false;
            }
        }
    }
    if(ok){
        print("Yes");
    }else{
        print("No");
    }
    

}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i, N, tele, walk;
  long long int walk_sum = 0, tele_sum = 0;//初期値
  double walk_max;
  int x[100000];//街の座標のリスト

  scanf("%d %d %d\n", &N, &walk, &tele);
  walk_max = (double)tele/walk;

  for(i = 0; i < N ; i++){
    scanf("%d", &x[i]);
  }



  for(i = 0; i < N-1; i++){
    if( x[i+1] - x[i] > walk_max){//テレポート優先
      tele_sum += tele;
    }else{//歩行優先
      walk_sum += ( x[i+1] - x[i] ) * walk;
    }
  }

  printf("%lld\n", tele_sum + walk_sum);

  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cctype>
#include <cstring>
using namespace std;

int main(void) {

  int count , i , x;

  string  w , T;

  count = 0;

  cin >> w;

  while(1) {

    cin >> T;

    if(T == "END_OF_TEXT") break;

    x = T.size();

    for(i = 0; i < x; i++) {

      if(isupper(T[i])) {

	T[i] = tolower(T[i]);

      }

    }

    if(T == w) {

      count++;

    }

  }

  cout << count << "\n";

}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 524290;
const int mod = 1e9 + 7;

int f[2][MAXN], n, m, k, a[25][25], cur;

inline void Inc(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Lowbit(int x) { return x & -x; }

inline int Trans(int x, int y, int z)
{
	if (x >> y & 1)
		return !z ? -1 : x;
	return !z ? x : ((x >> y) - Lowbit(x >> y) + 1) << y | (x & (1 << y) - 1);
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read() - 1, m = Read(), k = Read();
	mset(a, -1);
	for (int i = 1, x, y; i <= k; i ++)
		x = Read(), y = Read() - 1, a[x][y] = Read();
	f[0][0] = cur = 1;
	for (int i = 1; i <= m; i ++)
		for (int j = 0; j < n; j ++, cur ^= 1)
		{
			mset(f[cur], 0);
			for (int k = 0; k < (1 << n); k ++)
				if (f[cur ^ 1][k])
				{
					if (a[i][j] != 1 && ~Trans(k, j, 0))
						Inc(f[cur][Trans(k, j, 0)], f[cur ^ 1][k]);
					if (a[i][j] != 0 && ~Trans(k, j, 1))
						Inc(f[cur][Trans(k, j, 1)], f[cur ^ 1][k]);
				}
		}
	int ans = 0;
	for (int i = 0; i < (1 << n); i ++)
		Inc(ans, f[cur ^ 1][i]);
	return printf("%d\n", ans), 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
lint N, A, B, C, INF = 1e9;
vector<lint> l(N);

lint dfs(lint num, lint a, lint b, lint c){
	if(num == N){
		if(min({a, b, c}) > 0) return abs(a - A) + abs(b - B) + abs(c - C) - 30;
		else return INF;
	} 
	lint w = dfs(num + 1, a, b, c);
	lint x = dfs(num + 1, a + l[num], b, c) + 10;
	lint y = dfs(num + 1, a, b + l[num], c) + 10;
	lint z = dfs(num + 1, a, b, c + l[num]) + 10;
	return min({x, y, z, w});
}

signed main(){
  cin >> N >> A >> B >> C;
	l.resize(N);
	for(lint i = 0; i < N; i++) cin >> l[i];
	cout << dfs(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
using ll = long long;

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  sort(a.rbegin(),a.rend());
  ll ans = a[0];
  for(ll i=2;i<n;i++){
    ans += a[i/2];
  }
  cout << ans << endl;
}

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

int main()
{
    int n,m,a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b)
    {
        cout << 0 << endl;
        return 0;
    }
    else if((b/a)>=c)
    {
        cout << c << endl;
        return 0;
    }
    else if((b/a)<c)
    {
        cout << b/a << endl;
    }

}


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

#include <cmath>
#include <map>
#include <cstdlib>

using namespace std;

int main(int argc, char *argv[]){

  int A, B;
  cin >> A >> B;
  int ret = 0;
  if(A > B){
    ret += A--;
  }else{
    ret += B--;
  }
  if(A > B){
    ret += A--;
  }else{
    ret += B--;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d,n,i,j,k=1,t[8][3]={0,0,0,1,1,1,0,0,1,0,1,0,1,0,0,1,1,0,1,0,1,0,1,1};
    cin>>n;
    a=n/1000;
    n=n-1000*a;
    b=n/100;
    n=n-100*b;
    c=n/10;
    n=n-10*c;
    d=n;
    for(i=0;i<8;++i)
    {
        n=a;
        for(j=0;j<3;++j)
        {
            if(j==0)
            {
                if(t[i][j]==1)n+=b;
                else n-=b;
            }
             if(j==1)
            {
                if(t[i][j]==1)n+=c;
                else n-=c;
            }
             if(j==2)
            {
                if(t[i][j]==1)n+=d;
                else n-=d;
            }
            if(n==7)
            {
                cout<<a;
                if(t[i][0]==1)cout<<"+";
                else cout<<"-";
                cout <<b;
                if(t[i][1]==1)cout<<"+";
                else cout<<"-";
                cout<<c;
                if(t[i][2]==1)cout<<"+";
                else cout<<"-";
                cout<<d<<"="<<n<<endl;
                k=0;
                break;
            }
        }
        if(k==0)break;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

namespace NyaGadget
{	// DFSライブラリ

	struct DFSedge
	{
		ll vertex;	// 頂点
		DFSedge(ll v) { vertex = v; }
	};

	template <class TE = DFSedge> struct DFS
	{
		using Graph = vector<vector<TE>>;
		Graph graph;

		DFS(ll size) { graph.resize(size); }
		vector<TE>& operator [](int n) { return graph[n]; }

		/**
		@brief 辺を追加する関数
		@note
		 頂点v1とv2を結ぶ辺を追加する。
		**/
		void CreateEdge(ll v1, ll v2)
		{	// 後戻りも出来るようにv1→v2とv2→v1の両方の辺を追加する
			graph[v1].push_back(DFSedge(v2));
			graph[v2].push_back(DFSedge(v1));
		}
	};

}

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define ceil(a, b) ceil((ld) a / (ld) b);                         // div ceiling
#define each(e, collection) for(auto& e: collection)              // for each
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

using namespace NyaGadget;

/**
@brief 深さ優先探索
@param v 頂点
@param r 根
@param g 処理するグラフ
@param memo 前処理したメモ(加算するべきカウンタの値)
@param ans 出力する答えを格納する配列
@note
 DFSで全てのノードを処理する。
**/
void Solve(ll r, ll v, DFS<>& dfs, vector<ll>& memo, vector<ll>& ans)
{
	if (r != -1)
		ans[v] = ans[r] + memo[v];

	each(e, dfs[v])
	{	// 後戻りしないようにする
		if (e.vertex == r)
			continue;

		Solve(v, e.vertex, dfs, memo, ans);
	}
}

int main(void)
{
	ll n, q; cin >> n >> q;

	ll u, v;
	DFS<> dfs(n);
	rep(i, 0, n - 1)
	{
		cin >> u >> v;
		--u; --v;
		dfs.CreateEdge(u, v);
	}

	vector<ll> p(q), x(q);
	rep(i, 0, q)
	{
		cin >> p[i] >> x[i];
		p[i]--;
	}

	// 頂点xで加算するべきカウンタの値をメモしておく。
	vector<ll> memo(n);
	rep(i, 0, q)
		memo[p[i]] += x[i];

	vector<ll> ans(n);
	ans[0] = memo[0];
	Solve(-1, 0, dfs, memo, ans);

	each (e, ans)
		cout << e << " ";

	return 0;
}


Measured memory_bytes: 35200
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    A = [list(map(int, input().split())) for i in range(2)]

    Candy = [[0 for _ in range(n)] for _ in range(2)]
    Candy[0][0] = A[0][0]
    Candy[1][0] = A[0][0] + A[1][0]

    for i in range(1, n):
        Candy[0][i] = Candy[0][i-1] + A[0][i]
    for j in range(1, n):
        Candy[1][j] = max(Candy[1][j-1], Candy[0][j]) + A[1][j]

    print(Candy[1][n-1])
    #print(Candy)

resolve()

Measured memory_bytes: 38256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>


using namespace std;
int main(){
  vector<int> p;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    p.push_back(x);
  }
  for(int x=0;x<n;x++){
    if(n-2*x>0){
      cout<<p.at(n-2*x-1);
    }
    else{
      cout<<p.at(-(n-2*x));
    }
    if(x!=n-1)
      cout<<" ";
  }

}

Measured memory_bytes: 3060
from itertools import chain
import numpy as np

H,W,K = map(int,input().split())

def gen_row_pattern(i):
  # i番目以降だけ(inclusive)を使う
  if i>W:
    return [[]]
  # 下に流す
  result = [[(i,i)] + x for x in gen_row_pattern(i+1)]
  # 入れ替え
  if i <= W-1:
    result += [[(i,i+1)] + x for x in gen_row_pattern(i+2)]
  return result

patterns = gen_row_pattern(1)

import numpy as np
A = np.zeros((W+1,W+1),dtype=np.int64)
for x,y in chain(*patterns):
  A[x,y] += 1
  if x != y:
    A[y,x] += 1

# 最初は1番に居る
v = np.zeros(W+1,dtype=np.int64)
v[1] = 1

MOD = 10**9 + 7

for _ in range(H):
  v = np.mod(np.dot(A,v),MOD)

answer = v[K]
print(answer)

Measured memory_bytes: 18264
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	x := getNextInt64(scanner)
	k := getNextInt64(scanner)
	d := getNextInt64(scanner)
	if x < 0 {
		c := -x / d
		if k < c {
			fmt.Fprintln(writer, abs(x+k*d))
			return
		}
		if (k-c)%2 == 0 {
			fmt.Fprintln(writer, abs(x%d))
			return
		}
		fmt.Fprintln(writer, abs(x%d+d))
		return
	}
	c := x / d
	if k < c {
		fmt.Fprintln(writer, abs(x-k*d))
		return
	}
	if (k-c)%2 == 0 {
		fmt.Fprintln(writer, x%d)
		return
	}
	fmt.Fprintln(writer, abs(x%d-d))
}
func abs(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1816
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

PII ba[200005];

int main() {
	int n;
	scanf("%d", &n);
	REP(i, n)scanf("%d%d", &ba[i].second, &ba[i].first);
	sort(ba, ba + n, greater<PII>());
	int f = ba[0].first;
	REP(i, n) {
		f = min(f, ba[i].first);
		f -= ba[i].second;
	}
	if (f < 0)printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1792
open Batteries
open BatPrintf

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> String.split_on_char ' '
  |> List.map cnv


let rec zip xs ys =
  match xs, ys with
  | [], _ -> []
  | _, [] -> []
  | x::xs, y::ys ->
    (x, y) :: zip xs ys

let s = scan "%s" identity

let () =
  let n = String.length s in
  let open Bigarray in
  let arr = Array2.create Int C_layout (n+1) 2  in
  Array2.set arr 0 1 1;
  String.iteri (fun i c  ->
      let n = Char.code c - Char.code '0' in
      let x = Array2.get arr i 0 in
      let y = Array2.get arr i 1 in
      Array2.set arr (i+1) 0 @@ List.min [x + n; y + (10-n)] ;
      Array2.set arr (i+1) 1 @@ List.min [x + n + 1; y + 10 - n - 1] ;
    ) s;
  printf "%d\n" @@ List.min [Array2.get arr n 0; 1 + Array2.get arr n 1]


Measured memory_bytes: 24448
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

	public void Proc()
	{
        int inputCount = int.Parse(Reader.ReadLine());

        int[][][] Ryo = new int[4][][];
        for (int i = 0; i < Ryo.Length; i++) {
            Ryo[i] = new int[3][];
            for (int j = 0; j < Ryo[i].Length; j++) {
                Ryo[i][j] = new int[10];
            }
        }
        for (int i = 0; i < inputCount; i++) {
            int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            Ryo[inpt[0]-1][inpt[1]-1][inpt[2]-1] += inpt[3];
        }

        string delimiter = string.Empty.PadLeft(20, '#');
        System.Text.StringBuilder ans = new System.Text.StringBuilder();
        for (int i = 0; i < Ryo.Length; i++) {
            if(i> 0) {
				ans.AppendLine(delimiter);

			}
			for (int j = 0; j < Ryo[i].Length; j++) {
                ans.AppendLine(" " + string.Join(" ", Ryo[i][j].Select(a=>"" + a).ToArray()));
            }
        }
        Console.Write(ans.ToString());
    
    }




    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"


3
1 1 3 8
3 2 2 7
4 3 8 1



";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 9720
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,j,sum1=0,cnt=0,ar[100000];
    float flag,sum=0,m;
    vector<long long int>vec;
    list<long long int>mylist;
    vector<long long int>::iterator it1;
    list<long long int>::iterator it2;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>ar[i];
        sum=sum+ar[i];
    }
    //cout<<sum<<endl;
    flag=sum *(1/(4*m));
    //cout<<flag<<endl;
    for(i=0;i<n;i++)
    {

        if(ar[i]>=flag)
           cnt++;
    }
    if(cnt>=m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}



Measured memory_bytes: 256
N = int(input())
S = input()
len_S = len(S)
count = 0

if len_S % 2 == 1:
    print('No')

else:
    for i in range(len_S//2):
        if S[i] == S[i+(len_S//2)]:
            count += 1
        else:
            print('No')
            break

    if count == len_S//2:
        print('Yes')    

Measured memory_bytes: 3060
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use libm::*;
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
use superslice::*;

pub 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")
}

//abc099-C
#[fastout]
fn main() {
    let n: i64 = read();

    let mut ansv = vec![10000000; (n + 1) as usize];

    {
        let mut num = 1;
        while num as i64 <= n {
            // eprintln!("{} = 1", num);
            ansv[num] = 1;
            num *= 6;
        }
    }

    {
        let mut num = 1;
        while num as i64 <= n {
            // eprintln!("{} = 1", num);
            ansv[num] = 1;
            num *= 9;
        }
    }

    for i in 2..(n + 1) {
        if ansv[i as usize] == 1 {
            // eprintln!("ansv[{}] = {}", i, 1);
            continue;
        }

        let a1 = ansv[(i - 1) as usize];
        let mut a6 = 1000000;
        {
            let mut sub = 6;
            while i - sub >= 1 {
                let mid = ansv[(i - sub) as usize];
                a6 = min(mid, a6);
                sub *= 6;
            }
        }

        let mut a9 = 1000000;
        {
            let mut sub = 9;
            while (i - sub >= 1) {
                let mid = ansv[(i - sub) as usize];
                a9 = min(a9, mid);
                sub *= 9;
            }
        }

        let new_min = min(min(a1, a6), a9) + 1;
        // eprintln!("ansv[{}] = {}", i, new_min);
        ansv[i as usize] = new_min;
    }

    println!("{}", ansv[n as usize]);
}

fn go(mid: usize, d: usize, use_num: usize, num753_cand: &mut Vec<usize>, n: usize) {}


Measured memory_bytes: 2284
#import re
import sys
input = sys.stdin.readline
#import heapq
#import bisect
#from collections import deque
#import math

def main():
    B = [[]*3 for i in range(3)]
    for i in range(3):
        B[i] = list(map(int, input().split()))
    
    C = [[0]*3 for i in range(3)]
    n = int(input())
    for i in range(n):
        check = int(input())
        for i in range(3):
            for j in range(3):
                if B[i][j] == check:
                    C[i][j] = 1
    ans = "No"
    for i in range(3):
        if (C[i][0] == 1 and C[i][1] == 1 and C[i][2] == 1):
            ans = "Yes"
            break
        if (C[0][i] == 1 and C[1][i] == 1 and C[2][i] == 1):
            ans = "Yes"
            break
        if (C[0][0] == 1 and C[1][1] == 1 and C[2][2] == 1):
            ans = "Yes"
            break
        if (C[2][0] == 1 and C[1][1] == 1 and C[0][2] == 1):
            ans = "Yes"
            break
    
    print("Yes") if ans == "Yes" else print("No")
            
            


    
if __name__ == '__main__':
    main()


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll a,b;
  cin >> a >> b;

  ll ans = a - b*2;
  if(ans > 0)
    cout << ans << endl;
  else
    cout << 0 << endl;
  
  
}


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

int main() {
	long long int n;
	cin>>n;
	long long int arr[n];
	for(int i=0;i<n;i++)
	{
	    cin>>arr[i];
	}
	sort(arr,arr+n);
	for(int i=0;i<n-1;i++)
	{
	    if(arr[i]==arr[i+1])
	    {
	    cout<<"NO";
	    return 0;
	    }
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

int main()
{
	int n, d;
	std::cin >> n >> d;
	d = 2 * d + 1;
	int result = 0;

	for (int i = 0; i < 1000; i++) {
		if (n <= d * i) {
			result = i;
			break;
		}
	}

	std::cout << result;
    return 0;
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;
vector<P> edge[100001];
vector<bool> isUsed(100001, false);
vector<bool> ans(100001);

int dfs(int v) {
    isUsed[v] = true;
    
    REP(i, edge[v].size()) {
        if(!isUsed[edge[v][i].first]) {
            if(edge[v][i].second % 2 == 1) ans[edge[v][i].first] = !ans[v];
            else ans[edge[v][i].first] = ans[v];                
            dfs(edge[v][i].first);
        }
    }

    return 0;
}

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

    REP(i, n-1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        edge[u].push_back(make_pair(v, w));
        edge[v].push_back(make_pair(u, w));
    }

    ans[0] = 1;
    dfs(0);

    REP(i, n) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 9472
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int count = 0;
        for (int i = 1; i <= N; i++) {
            String str = String.valueOf(i);
            if (str.length() % 2 == 1) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 29524
#include<bits/stdc++.h>
using namespace std;
#define MAX 11

int main(){
    int D,G,p[MAX],c[MAX];
    cin >> D >> G;
    for(int i=0;i<D;i++) cin >> p[i] >> c[i];

    int ans = 1e9;
    for(int bit=0;bit<(1<<D);bit++){
        int sum = 0,cnt = 0,rest_max = -1;
        for(int i=0;i<D;i++){
            if(bit & (1<<i)){
                sum += 100*(i+1)*p[i]+c[i];
                cnt += p[i];
            }
            else{
                rest_max = i;
            }
        }
        if(sum < G){
            int s1 = 100*(rest_max+1);
            int need = (G-sum+s1-1)/s1;
            if(need >= p[rest_max]) continue;
            cnt += need;
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}


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

typedef long long LL;

const int N=100000;

int n,m;
struct seg{
  int l,r,v;
}a[N+9];
vector<int>vl[N+9],vr[N+9];

void into(){
  scanf("%d%d",&n,&m);
  for (int i=1;i<=m;++i){
	scanf("%d%d%d",&a[i].l,&a[i].r,&a[i].v);
	vl[a[i].l].push_back(i);
	vr[a[i].r].push_back(i);
  }
}

multiset<LL>s;
LL dp[N+9];

void Get_dp(){
  for (int i=1;i<=n;++i){
	if (i>1&&s.empty()) {dp[n]=-1;return;}
	dp[i]=i==1?0:*s.begin();
	for (int vs=vr[i].size(),j=0;j<vs;++j) s.erase(s.find(dp[a[vr[i][j]].l]+a[vr[i][j]].v));
	for (int vs=vl[i].size(),j=0;j<vs;++j) s.insert(dp[a[vl[i][j]].l]+a[vl[i][j]].v);
  }
}

void work(){
  Get_dp();
}

void outo(){
  printf("%lld\n",dp[n]);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 16400
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main(){
    int N,D;cin>>N>>D;
    vector<vector<int>> X(N);
    REP(i, N){
        REP(j, D){
            int x;cin>>x;
            X[i].push_back(x);
        }
    }

    int ans = 0;
    REP(i, N){
        FOR(j, i+1, N){
            int dis = 0;
            REP(k, D){
                dis += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
            }
            
            FOR(k, 1, 150){
                if(dis == k*k){
                    ans++;
                    break;
                }
            }
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define double long double
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
typedef pair<P,P> PP;
double eps=1e-8;
int mod=1e9+7;
int inf=1LL<<55;

priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end(), l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower
  return R-L;
}

signed main(){
  int a,b;
  cin>>a>>b;
  cout<<((a==b)?"Yes":"No")<<endl;
  return 0;
}


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

const int k = 10000;

void countingsort(int A[], int B[], int n){
    int C[k+1];
    for(int i=0; i<k+1; i++){
        C[i] = 0;
    }

    for(int i=0; i<n; i++){
        C[A[i]]++;
    }
    for(int i=1; i<k+1; i++){C[i] += C[i-1];}
    for(int i=n-1; i>=0; i--){
        B[C[A[i]] - 1] = A[i];
        C[A[i]]--;
    }
}

int main(){
    int n, i;
    scanf("%d", &n);
    int A[n], B[n];
    for(i=0; i<n; i++){
        scanf("%d", &A[i]);
    }
    countingsort(A, B, n);

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

    return 0;
}


Measured memory_bytes: 18872
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;


int main()
{
    int n,l; cin >> n >> l;
    int tmp = INF;
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += (l+i);
    }
    int eat = sum;
    int ans;
    for(int i = 0; i < n; i++){
        eat -= (l+i);
        if(tmp > abs(sum-eat)){
            tmp = abs(sum-eat);
            ans =eat;
        }
        eat += (l+i);
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
//97-122
int main(void){
    char s[1000000];
    int ch[27];
    int sl=0;
    scanf("%s",s);
    sl=strlen(s);
    for(int i=0;i<sl;i++){
        ch[(int)s[i]-97]+=1;
    }
    for(int i=0;i<26;i++){
        if(ch[i]==0){
            printf("%c\n",i+97);
            return 0;
        }
    }
    printf("None\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <string>
using namespace std;
using lli=long long int;
using ld=long double;
lli INF=1e18;
#define endl '\n'



int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	int i,j,stones;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	

	int dp[k+1];
	//True if the first player wins if there are i stone remaining
	for(i=0;i<=k;i++)
		dp[i]=0;

	for(stones=0;stones<=k;stones++)
	{
		for(j=0;j<n;j++)
		{
			if(stones>=a[j] && !dp[stones-a[j]])
				dp[stones]=1;
		}
	}

	if(dp[k]==1)
		cout<<"First";
	else
		cout<<"Second";

	return 0;

}

Measured memory_bytes: 640
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength

#素因数分解
def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
    a.append(n)
  return a

#重複を検出
def has_duplicates(seq):
  return len(seq) != len(set(seq))



#X = str(input()).split()
#a = [int(x) for x in input().split()]


N = int(input())
A = [int(x) for x in input().split()]

if(has_duplicates(A) == True):
  ans = "NO"
else:
  ans = "YES"


print(ans)



Measured memory_bytes: 101108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0111
{
    public class Program
    {
        public static void Main(string[] args)
        {
            while (true)
            {
                string line = Console.ReadLine();
                if (line == null) return;

                string bit = "";
                foreach (var item in line) bit += Convert.ToString(Array.IndexOf(toBit, item), 2).PadLeft(5,'0');

                string res = "";
                int pos = 0;
                int len = 1;
                while (pos + len <= bit.Length)
                {
                    if (toChar.ContainsKey(bit.Substring(pos, len)))
                    {
                        res += toChar[bit.Substring(pos, len)];
                        pos += len; len = 1;
                    }
                    else len++;
                }
                Console.WriteLine(res);
            }
        }

        static readonly Dictionary<string, char> toChar = new Dictionary<string, char>()
        {
            {"101",' '},
            {"000000",'\''},
            {"000011",','},
            {"10010001",'-'},
            {"010001",'.'},
            {"000001",'?'},
            {"100101",'A'},
            {"10011010",'B'},
            {"0101",'C'},
            {"0001",'D'},
            {"110",'E'},
            {"01001",'F'},
            {"10011011",'G'},
            {"010000",'H'},
            {"0111",'I'},
            {"10011000",'J'},
            {"0110",'K'},
            {"00100",'L'},
            {"10011001",'M'},
            {"10011110",'N'},
            {"00101",'O'},
            {"111",'P'},
            {"10011111",'Q'},
            {"1000",'R'},
            {"00110",'S'},
            {"00111",'T'},
            {"10011100",'U'},
            {"10011101",'V'},
            {"000010",'W'},
            {"10010010",'X'},
            {"10010011",'Y'},
            {"10010000",'Z'}
        };

        static readonly char[] toBit = new char[]
        {
            'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','.',',','-','\'','?'
        };


        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 24116