akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

vector<int> Zalgo(const string &S) {
    int N = (int)S.size();
    vector<int> res(N);
    res[0] = N;
    int i = 1, j = 0;
    while (i < N) {
        while (i+j < N && S[j] == S[i+j]) ++j;
        res[i] = j;
        if (j == 0) {++i; continue;}
        int k = 1;
        while (i+k < N && k+res[k] < j) res[i+k] = res[k], ++k;
        i += k, j -= k;
    }
    return res;
}

int main() {
    int N;string S;
    cin >> N >> S;
    int res = 0;
    rep(i,N){
        auto lcp = Zalgo(S.substr(i));
        rep(j,N-i)res = max(res,min(lcp[j], (int)j));
    }
    cout << res << endl;
}

Measured memory_bytes: 256
N = int(input())

max_f_0 = -10**10
min_f_0 = 10**10
max_f_1 = -10**10
min_f_1 = 10**10

for _ in range(N):
    x, y = map(int, input().split(" "))
    f_0 = x - y
    f_1 = x + y
    
    if max_f_0 < f_0:
        max_f_0 = f_0
    if min_f_0 > f_0:
        min_f_0 = f_0
    if max_f_1 < f_1:
        max_f_1 = f_1
    if min_f_1 > f_1:
        min_f_1 = f_1
        
print(max((max_f_0-min_f_0), (max_f_1-min_f_1)))
    
 

Measured memory_bytes: 9148
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

class Combination {
private:
	vector< vector<int> > comb;
public:
	Combination(int size) {
		comb = vector< vector<int> >(size + 1, vector<int>(size + 1, 0));
		comb[0][0] = 1;
		for (int i = 1; i <= size; i++) {
			comb[i][0] = 1;
			for (int j = 1; j <= i; j++) {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
	int get(int n, int r) {
		return comb[n][r];
	}
};

signed main() {
	Combination cmb(52);

	int N, A, B;
	cin >> N >> A >> B;

	vector<int> v(N);
	rep(i, N) cin >> v[i];

	map<int, int> cnt;
	rep(i, N) cnt[v[i]]++;

	sort(all(v));
	reverse(all(v));

	int sum = 0;
	map<int, int> m;
	rep(i, A) {
		m[v[i]]++;
		sum += v[i];
	}

	int ret = 0;
	if (m.size() == 1) {
		int num = m.begin()->first;
		REP(i, A, B) {
			if (cnt[num] < i) break;
			ret += cmb.get(cnt[num], i);
		}
	} else {
		ret = 1;
		for (auto &pr : m) {
			int num = pr.first;
			int tmp = pr.second;
			ret *= cmb.get(cnt[num], tmp);
		}
	}

	printf("%.10f\n", (double)sum / A);
	cout << ret << endl;
}


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

#define INF (1l<<55)

int N;
long long A[2010];
long long memo[2010][2010];

int l(int i) {
  return i == 0 ? N-1 : i-1;
}
int r(int i) {
  return (i+1) % N;
}
long long max(long long a, long long b) {
  return a >= b ? a : b;
}

long long f(int s, int t) {
  if (memo[s][t] >= 0) return memo[s][t];

  long long ret = 0;
  if (s == t) {
    if (A[l(s)] > A[r(s)]) ret = max(ret, A[s] + f(l(s), s));
    else                   ret = max(ret, A[s] + f(s, r(s)));
    return memo[s][t] = ret;
  }
  for (int d=0; d<2; d++) {
    int ns, nt;
    long long v;
    if (d == 0) ns = l(s), nt = t, v = A[l(s)];
    else        ns = s, nt = r(t), v = A[r(t)];
    if (ns == nt)    return memo[s][t] = 0;
    if (l(ns) == nt) return memo[s][t] = v;

    if (A[l(ns)] >= A[r(nt)]) ns = l(ns);
    else                      nt = r(nt);
    ret = max(ret, v + f(ns, nt));
  }

  return memo[s][t] = ret;
}

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

  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      memo[i][j] = -INF;
    }
  }

  long long ans = 0;
  for (int i=0; i<N; i++) ans = max(ans, f(i, i));
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 34584
#include <bits/stdc++.h>
using namespace std;
int N,L;
int main(){
    
    cin >> N >> L;
    string A[105];
    for(int i=0;i<N;i++)
    {
       cin >> A[i]; 
    }
    sort(&A[0],&A[N]);
    for(int i=0;i<N;i++)
    {
        cout << A[i];
    }
}

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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans;
  if (a > b) {
    ans = 0;
  } else if (n == 1) {
    if (a != b) {
      ans = 0;
    } else {
      ans = 1;
    }
  } else {
    ans = (b - a) * (n - 2) + 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define mems(x)     memset(x,0,sizeof(x))
#define all(a)      a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*---------------------------------------------------------------------------------------------------*/

void solve()
{
  int h,w,tgt,ans=0;
  cin >> h>>w >> tgt;
  int mat[h][w],cnt=0;
  f(i,h)
  {
      string s;
      cin >> s;
      f(j,w)
      {
          mat[i][j]=(s[j]=='#')?1:0;
          cnt+=(mat[i][j]==1)?1:0;
      }
  }
f(k,1<<h)
    {
    vector<int> r;
        f(l,h)
        {
            if((1<<l)&k)
            {
                r.pb(l);
            } 
        }
        f(m,(1<<w))
        {
            vector<int> c;
            f(l,w)
            {
                if((1<<l)&m)
                {
                    c.pb(l);
                }
            }
    int mt[h][w];
    mems(mt);
    int x=cnt;
            f(i,sz(r))
            {
                f(j,w)
                {
                    mt[r[i]][j]=1;
                    if(mat[r[i]][j]==1)
                    {
                        x--;
                    }
                }
            }
            f(i,sz(c))
            {
                f(j,h)
                {
                    if(mt[j][c[i]])
                    continue;
                    if(mat[j][c[i]]==1)
                    x--;
                }
            }
            if(x==tgt)
            ans++;
        }

    }
  cout << ans << '\n';
  return;
} 

signed main()
{
  FAST
  int T=1;
//   cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


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


int main()
{
    string str;
    int i,sum=0;
    cin>>str;
    int len = str.size();

    for(i=0;i<len;i++)
    {
        if(str[i]=='+')
            sum++;
        else
            sum--;
    }
    
    cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 256
/* C */

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

#define MOD 2019

int main(){
	long long int l, r;
	cin >> l >> r;
	long long int mini = 2019;

	if(l / MOD == r / MOD){
		l = l % MOD, r = r%MOD;
		for (long long int i = l; i < r; ++i)
		{
			for (long long int j = i + 1; j <= r ; ++j)
			{
				mini = min(((i % MOD) * (j % MOD)) % MOD, mini); 
			}
		}
	}else{
		mini = 0;
	}

	cout << mini << endl;
}

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

#define INF 1001001001
#define MAX 1e18

const int mod = 998244353;

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n), tox(n), toy(n);
  rep(i,n) {
    cin >> x[i] >> y[i]; --x[i], --y[i];
    tox[y[i]] = x[i];
    toy[x[i]] = y[i];
  }
  stack<int> ybkup;
  dsu d(n);
  rep(i,n) {
    int ymin = toy[i];
    while (!ybkup.empty()&&toy[i]>ybkup.top()) {
      int y = ybkup.top(); ybkup.pop();
      d.merge(i,tox[y]);
      ymin = min(ymin,y);
    }
    ybkup.push(ymin);
  }
  rep(i,n) cout << d.size(x[i]) << endl;

  return 0;
}


Measured memory_bytes: 7188
import sys
input = sys.stdin.readline

h, w, K = [int(x) for x in input().split()]
s = [input().rstrip() for _ in range(h)]

ans = h + w - 2
for i in range(2 ** (h - 1)):
    new_s = []
    cnt = 0
    i_bin = bin(i)[2:].zfill(h - 1)
    add = []
    for j in range(h - 1):
        if i_bin[j] == "1":
            cnt += 1
            add.append(s[j])
            new_s.append(add)
            add = []
        else:
            add.append(s[j])
        if j == h - 2:
            add.append(s[-1])
            new_s.append(add)
    if h == 1:
        new_s = [s]
    total = [0] * len(new_s) # ブロックごとに、切った後~進んだ分の増えたホワイトチョコの個数を管理
    for k in range(w):
        tmp_list = [0]*len(new_s) # ブロックごとに、1つ進めて増えるホワイトチョコを管理
        flag = 0
        for l in range(len(new_s)):
            tmp = sum([int(new_s[l][x][k]) for x in range(len(new_s[l]))])
            if tmp > K:
                flag = 1
                break
            tmp_list[l] = tmp
            total[l] += tmp
        if flag:
            break
        for m in total: # 1つでもKを越えていたら直前で切る
            if m > K:
                cnt += 1
                total = tmp_list
                break
    if not flag:
        ans = min(ans, cnt)
print(ans)






Measured memory_bytes: 47576
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    x = [0]*n

    for i in range(0, n, 2):
        x[0] += a[i]

    for i in range(1, n, 2):
        x[0] -= a[i]

    for i in range(n-1, 0, -1):
        x[i] = a[i]*2-x[(i+1) % n]

    print(*x)


if __name__ == "__main__":
    main()


Measured memory_bytes: 63984
#include<bits/stdc++.h>
using namespace std;
#define M 1e9 + 5
#define C 998244353
#define pi 3.14159265359
#define loop(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define rloop(i,a,b) for(ll i = ll(a); i >= ll(b); --i)
#define sloop(i,a) for (std::set<ll>::iterator i = a.begin(); i != a.end(); ++i)
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;

void solve(){
    ll n,a,b,m,ans=0,x=M,llim,ulim;
    cin >> n;
    cout << 2*pi*n << "\n";
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    loop(f,0,t){    
        solve();
    }   
}

Measured memory_bytes: 3740
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}

vector<string> vs;
vector<string> mask1;
vector<string> mask2;
int main(){
  int h,w; cin >> h >> w;
  rep(i,h){
    string in; cin >> in;
    vs.pb(in);
  }
  mask1 = vs;
  mask2 = vs;
  rep(i,h){
    mask1[i][0] = '#';
    mask2[i][w-1] = '#';
    rep(j,w){
      if(j == 0 || j == w-1) continue;
      if(i%2 == 0)
        mask1[i][j] = '#';
      else
        mask2[i][j] = '#';
    }
  }
  for(auto i:mask1)
    cout << i << endl;
  cout << endl;
  for(auto i:mask2)
    cout << i <<endl;
  return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef unsigned long long ll;

int main(){
    // read in integers
    string s;
    cin >> s;

    string ans = "";

    REP(i, s.size()){
        if (s[i] == 'B') {
            if (ans.size() != 0)ans.pop_back();
        }
        else ans += s[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

vector<int> eT;
vector<ll> uF;
ll ans = 0;

void es( int n ){
	for( int i = 0; i < n; ++i ){
		eT.push_back(i);
		uF.push_back(1ll);
	}
}

int wurzel( int x ){
	if( eT.at(x) == x ){
		return x;
	} else {
		return eT.at(x) = wurzel( eT.at(x) );
	}
}

void verbinden( int x, int y ){
	x = wurzel(x);
	y = wurzel(y);
	if( x == y ) return;
	eT.at(x) = y;
	ll nx = uF[x];
	ll ny = uF[y];
	ll n = uF[y] = nx + ny;
	// cout << "n: " << n << ", nx: " << nx << ", ny:" << ny << endl;
	ans += n*(n-1)/2 - nx*(nx-1)/2 - ny*(ny-1)/2;
	// cout << "ans: " << ans << endl;
}

bool gleich( int x, int y ){
	return wurzel(x) == wurzel(y);
}

int main(){
	int n, m;
	cin >> n >> m;
	es(n);
	ll bq = (ll)n*(n-1)/2;
	vector<pair<int, int>> vp;
	for( int i = 0; i < m; ++i ){
		int a, b;
		cin >> a >> b;
		--a; --b;
		vp.emplace_back(a, b);
	}
	vector<ll> ansbox;
	ansbox.push_back(bq);
	for( int i = m-1; i > 0; --i ){
		int a = vp.at(i).first;
		int b = vp.at(i).second;
		verbinden(a, b);
		ansbox.push_back(bq - ans);
	}
	reverse( ansbox.begin(), ansbox.end() );
	for( int i = 0; i < m; ++i ){
		cout << ansbox.at(i) << endl;
	}
	return 0;
}

Measured memory_bytes: 4208
n,m = map(int, input().split())
p = list(map(int, input().split()))

l = [[] for j in range(n)]

for i in range(m):
    x,y = map(int, input().split())
    l[x-1].append(y-1)
    l[y-1].append(x-1)

connect = []
a = []
v = [0 for i in range(n)]

for i in range(n):
    if v[i] == 0:
        connect.append([i])
        a.append([p[i]-1])
        v[i]=1
        stack =[i]
        while stack:
            q = stack.pop()
            for j in range(len(l[q])):
                if v[l[q][j]]==0:
                    connect[-1].append(l[q][j])
                    a[-1].append(p[l[q][j]]-1)
                    stack.append(l[q][j])
                    v[l[q][j]]=1

ans = 0

for i in range(len(connect)):
    ans += len(set(a[i]) & set(connect[i]))

print(ans)


Measured memory_bytes: 50020
S = input()
T = input()
s = len(S)
t = len(T)

ans = 1000

for i in range(s-t+1):
  cnt = 0
  for j in range(t):
    if S[i+j] != T[j]:
      cnt += 1
  ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 9072
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

const int DEFAULT = 0;

struct SegmentTree {
    int n;
    vector<int> heap;
    
    SegmentTree(int n): n(n) {
        heap.assign(4 * n, DEFAULT);
    }
    void update(int id, int l, int r, int q, int v) {
        if (q < l || q > r) {
            return;
        }
        if (l == r) {
            heap[id] += v;
        }
        else {
            int m = l + (r - l)/2;
            update(2 * id, l, m, q, v);
            update(2 * id + 1, m + 1, r, q, v);
            pushup(id);
        }
    }
    
    int query (int id, int l, int r, int ql, int qr) {
        if (qr < l || ql > r) {
            return DEFAULT;
        }
        if (ql <= l && r <= qr) {
            return heap[id];
        }
        else {
            int m = l + (r - l)/2;
            return query(2 * id, l, m, ql, qr) + query(2 * id + 1, m + 1, r, ql, qr);
        }
    }
     
    void pushup(int id) {
        heap[id] = heap[2 * id] + heap[2 * id + 1]; 
    }  
};

int main() {
    int n, q;
    cin >> n >> q;
    SegmentTree sg = SegmentTree(n);
    
    for (int i = 0; i < q; i++) {
        int cmd;
        cin >> cmd;
        if (cmd == 0) {
            int pos, v;
            cin >> pos >> v;
            sg.update(1, 1, n, pos, v);
//            for (int i = 0; i < 4 * n; i++) {
//                cout << i << ":" << sg.heap[i] << endl; 
//            }
        }
        else {
            int ql, qr;
            cin >> ql >> qr;
            cout << sg.query(1, 1, n, ql, qr) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4424
N,X,Y=map(int,input().split())

L=[0]*(N)
for i in range(1,N):
  for j in range(i+1,N+1):
    l=min(j-i,abs(X-i)+1+abs(j-Y))
    L[l]+=1

for i in range(1,N):
  print(L[i])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m;
  cin >> n >> m;
  vector<vl> g(n);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vl root(n, -1);
  queue<ll> q;
  q.push(0);
  root[0] = 0;
  while(!q.empty()) {
    ll i = q.front();
    q.pop();
    for(auto v : g[i]) {
      if(root[v] != -1) continue;
      root[v] = i;
      q.push(v);
    }
  }
  cout << "Yes" << '\n';
  rep2(i, 1, n) cout << root[i] + 1 << '\n';
}

Measured memory_bytes: 13028
#include <bits/stdc++.h>
using namespace std;
const int N = 2003;
const long long M = 1000000007;

int n, k;

long long C[N][N];
void pre()
{
    for (int i = 0; i < N; ++i)
    {
        C[i][0] = 1;
        for (int j = 1; j <= i; ++j)
            C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % M;
    }
}

int main()
{
    pre();
    cin >> n >> k;
    for (int i = 1; i <= k; ++i)
    {
        cout << (C[k - 1][i - 1] * C[n - k + 1][i]) % M << endl;
    }
    return 0;
}


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

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

#define pb push_back
#define in ,
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

struct Star {
  ll x, y, d;
};

ll minX[400000 * 2 - 1], maxX[400000 * 2 - 1],
minY[400000 * 2 - 1], maxY[400000 * 2 - 1];
ll n, nn = 1;

void update(ll k, ll a, ll c[]) {
  k += nn - 1;
  c[k] = a;

  while(k > 0) {
    k = (k - 1) / 2;
    c[k] = min(c[k * 2 + 1], c[k * 2 + 2]);
  }
}

ll query(ll a, ll b, ll k, ll l, ll r, ll c[]) {
  if(r <= a || b <= l) return INT_MAX;
  if(a <= l && r <= b) return c[k];

  ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2, c);
  ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r, c);

  return min(vl, vr);
}

bool asc(Star &l, Star &r) {
  return l.d < r.d;
}

int main() {
  ll d, ans = 0;
  cin >> n >> d;
  vector<Star> v(n);

  while(nn < n) nn *= 2;

  rep(i, 0, nn * 2 - 1) {
    minX[i] = INT_MAX;
    minY[i] = INT_MAX;
    maxX[i] = INT_MAX;
    minX[i] = INT_MAX;
  }

  rep(i, 0, n) cin >> v[i].x >> v[i].y >> v[i].d;

  sort(v.begin(), v.end(), asc);

  rep(i, 0, n) {
    update(i, v[i].x * -1, maxX);
    update(i, v[i].x, minX);
    update(i, v[i].y * -1, maxY);
    update(i, v[i].y, minY);
  }

  // rep(i, 0, n) cout << v[i].x << " " << v[i].y << " " << v[i].d << endl;;

  // rep(i, 0, nn * 2 - 1) cout << minX[i] << endl;
  ll ld = v[0].d, lp = 0;
  rep(i, 1, n) {
    if(v[i].d - ld > d) {
      rep(j, lp, i + 1) {
        if(v[i].d - v[j].d <= d) {
          lp = j;
          ld = v[lp].d;
          break;
        }
      }
    }
    ll hx = query(lp, i + 1, 0, 0, nn, maxX) * -1;
    ll lx = query(lp, i + 1, 0, 0, nn, minX);
    ll hy = query(lp, i + 1, 0, 0, nn, maxY) * -1;
    ll ly = query(lp, i + 1, 0, 0, nn, minY);
    if(lp != i) ans = max(ans, ((hx - lx) * (ll)(hy - ly)));
    // cout << lp << " " << i << endl;
    // cout << hx << " " << lx << " " << hy << " " << ly << endl;
    // cout << ans << endl;
  }

  cout << ans << endl;
}

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

typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

ll H, N, A[1000], B[1000], DP[10001];

int main() {
	cin >> H >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}
	for (int i = 1; i <= H; i++) {
		DP[i] = 0xE869120E869120;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < H; j++) {
			DP[min(j + A[i], H)] = min(DP[min(j + A[i], H)], DP[j] + B[i]);
		}
	}
	cout << DP[H] << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

void i_sort(int* a, int n , int g , int* count ){
	int j,v;
	for(int i=g ; i<n ;++i){
		v=a[i];
		j=i-g;
		while(j>=0 && a[j]>v){
			a[j+g]=a[j];
			j=j-g;
			a[j+g]=v;
			(*count)++;
		}
	}
}

void s_sort(int* a , int n ,  int* cnt){
	*cnt=0;
	vector<int> g;
	int m=0,tmp=1;
	for(;;){
		g.push_back(tmp);
		tmp=tmp*4+1;
		m++;
		if(tmp>=n) break;
	}
	cout << m << endl;
	reverse(g.begin(), g.end());
	for(int i=0;i<m;++i){
		i_sort(a , n , g[i] , cnt);
		cout << g[i];
		if(i!=m) cout << " ";
	}
	cout << endl;
}

int main(){
	int n,count;
	cin >> n;
	int* a = new int [n];
	for(int i=0;i<n ; ++i){
		cin >> a[i];
	}
	s_sort(a,n,&count);
	cout << count << endl;
	for(int i=0;i<n ; ++i){
		cout << a[i] << endl;
	}
	delete [] a;
	return 0; 
}

Measured memory_bytes: 4888
#include <iostream>

using namespace std;

int main() {

	int a, b, out;
    string op;

	while (!cin.eof()) {

		cin >> a >> op >> b;

        if (op == "?") {
            break;
        } else if (op == "+") {
            out = a + b;
        } else if (op == "-") {
            out = a - b;
        } else if (op == "*") {
            out = a * b;
        } else if (op == "/") {
            out = a / b;
        }
		cout << out << "\n";
	}

	return 0;
}



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

int main() {
    int N , K;
    cin>> N ;

    K = N;

    int sum=0;

    while(N>0){
        sum += N%10;
        N /= 10;
    }

    if(K%sum==0) cout << "Yes" << endl;

    else cout << "No" << endl;

}

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

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

#define fst first
#define snd second
#define pb push_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;
const int maxn = 100 + 10;

template<typename T> T read() {
	T n(0), f(1);
	char ch = getchar();
	for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
	for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

char st[maxn];
int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif

    scanf("%s", st);

    int ans = INT_MAX;

    REP(c, 0, 26) {
        int len = 0, res = 0;
        REP(i, 0, strlen(st)) {
            if(st[i] == c + 'a') {
                len = 0;
                chkmin(ans, max(res, iend-1-i));
            }else chkmax(res, ++len);
        }
    }
    printf("%d\n", ans);

    return 0;
}


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

int abs(int x){
  if(x<0){
    x=-x;
  }
  return x;
}

int main(){
  int N;
  cin>>N;
  vector<int> A(N+2,0);
  for(int i=1;i<=N;i++){
    cin>>A.at(i);
  }
  vector<int> cost(N+1),skip(N+1);
  int sum=0;
  for(int i=0;i<=N;i++){
    cost.at(i)=abs(A.at(i+1)-A.at(i));
    sum+=cost.at(i);
  }
  for(int i=1;i<=N;i++){
    skip.at(i)=abs(A.at(i+1)-A.at(i-1));
  }
  for(int i=1;i<=N;i++){
    cout<<sum-cost.at(i-1)-cost.at(i)+skip.at(i)<<endl;
  }
}


Measured memory_bytes: 2432
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <string>
using namespace std;

int main() {
	long N;
	cin >> N;
	size_t ans = SIZE_MAX;
	for (long i = 1; i * i <= N; ++i) {
		if (N % i == 0) ans = min(max(to_string(i).size(), to_string(N / i).size()), ans);
	}
	cout << ans;
}

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

using namespace std;

int main() {
	map<string, int> cnt;

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		cnt[s]++;
	}

	cout << "AC x " << cnt["AC"] << endl;
	cout << "WA x " << cnt["WA"] << endl;
	cout << "TLE x " << cnt["TLE"] << endl;
	cout << "RE x " << cnt["RE"] << endl;

	return 0;
}

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


int main() {
	
	int h,n;
	cin >> h >> n;
	int dmg=0;
	for(int i=0; i<n; i++){
		int a; 
		cin >> a;
		dmg += a;
	}
	
	cout << (dmg>=h ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
	Scanner scan = new Scanner(System.in);
	int n = scan.nextInt();
	int reg = scan.nextInt();
	Queue<String> method = new LinkedList<String>();
	Queue<Integer> time = new LinkedList<Integer>();
	int i;
	int time0=0;
	for(i=0 ; i<n ; i++){
	    method.add(scan.next());
	    time.add(scan.nextInt());
	}

	while(method.size()>0){
	    if(time.peek() - reg>0){
		method.add(method.poll());
		time.add(time.poll() - reg);
		time0+=reg;
	    }

	    
	    else{
		time0+=time.poll();
		System.out.println(method.poll() + " " +time0);
	    }
	}
    }
}
		
	    



Measured memory_bytes: 73296
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = input()
    t = input()
    ans = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            ans += 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 68600
#include<stdio.h>

int main(void){
	int a[3];
	
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	
	if(a[0]<=a[1] && a[0]<=a[2]){
		printf("%d ",a[0]);
		if(a[1]<=a[2])printf("%d %d\n",a[1],a[2]);
		else printf("%d %d\n",a[2],a[1]);
	}else if(a[1]<=a[0] && a[1]<=a[2]){
		printf("%d ",a[1]);
		if(a[0]<=a[2])printf("%d %d\n",a[0],a[2]);
		else printf("%d %d\n",a[2],a[0]);
	}else{
		printf("%d ",a[2]);
		if(a[0]<=a[1])printf("%d %d\n",a[0],a[1]);
		else printf("%d %d\n",a[1],a[0]);
	}
	return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
int d[54];

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

  cin >> N;
  rep(i, N) cin >> d[i];
  int sum = 0;
  rep(i, N) {
    for (int j=i+1; j< N; j++) {
      sum += d[i] * d[j];
    }
  }

  cout << sum << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
	int n,sum[2]={};
	cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;i++)cin>>v[i];
	sort(v.begin(),v.end(),greater<int>());
	for(int i=0;i<n;i++)
	{
		if(i%2)sum[0]+=v[i];
		else sum[1]+=v[i];
	}
	cout<<sum[1]-sum[0]<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
        public static void main(String[] args){
                Scanner scanner=new Scanner(System.in);
                int x=scanner.nextInt();
                if(Math.abs(x-scanner.nextInt())<Math.abs(x-scanner.nextInt())){
                        System.out.println("A");
                }else{
                        System.out.println("B");
                }
        }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int N;
   	string S;
   	cin >> N >> S;

   	if(N%2==0)
   		{
   		for(int i = 0; i < N/2;++i)
		{
			if(S[i]!=S[N/2+i])
			{
			 cout << "No" ;
			 return 0;
			}	
   		}

   		cout << "Yes"; 
   	}
   	else
      	cout << "No" ;


    return 0;
}

Measured memory_bytes: 256
;; E - Flatten

(defun main ()
  (let* ((n (read))
         (a (loop repeat n collect (read))))
    (princ (solve a))))

(defparameter *modulus* (+ (expt 10 9) 7))

(defun solve (a)
  (let ((lcm (mod-lcm a)))
    (reduce #'mod+ (mapcar #'(lambda (x) (mod/ lcm x)) a))))

(defun mod-lcm (xs)
  "The least common multiple (mod *modulus*) of the elements of xs."
  (loop with lcm = (make-hash-table)
        for x in xs
        for f = (factorize x)
     do (loop for k being each hash-key of f
           do (setf (gethash k lcm)
                    (max (or (gethash k lcm) 0) (gethash k f))))
        finally (return (value lcm))))

(defun factorize (x)
  "Return a hash-table whose key is a factor of x and whose value is
   the key's exponent."
  (let ((vec (make-hash-table)))
    (loop for d from 2 while (<= (* d d) x)
       do (loop while (zerop (mod x d))
             do (if (gethash d vec)
                    (incf (gethash d vec))
                    (setf (gethash d vec) 1))
                (setf x (floor x d))))
    (when (> x 1)
          (if (gethash x vec)
              (incf (gethash x vec))
              (setf (gethash x vec) 1)))
    vec))

(defun value (f)
  "The inverse of the factorize function."
  (or (loop for k being each hash-key of f
            for e = (expt k (gethash k f))
            for p = e then (mod* p e)
            finally (return p))
      1))


;; modulo addition/product/division

(defun mod+ (&rest rest)
  (mod (apply #'+ rest) *modulus*))

(defun mod* (&rest rest)
  (mod (apply #'* rest) *modulus*))

(defun mod/ (num denom)
  (mod* num (mod-inverse denom)))

(defun bit-sequence (v)
  "(bit-sequence 13) => (1 1 0 1)"
  (nreverse
    (loop for x = v then (ash x -1) while (plusp x) collect (logand x 1))))

(let ((modulus-2-bits (bit-sequence (- *modulus* 2))))
  ; Mが素数のとき，a^(M-2) ≡ a^(-1) mod M (フェルマーの小定理より)
  (defun mod-inverse (a)
    (loop for b in modulus-2-bits
          for e = a then (mod* e e (if (zerop b) 1 a))
          finally (return e))))

(main)


Measured memory_bytes: 49636
#include <bits/stdc++.h>
#define ll long long
#define f(i, a, b) for(ll i = a; i <= b; ++i)
#define ff(i, a, b) for(ll i = a; i < b; ++i)
#define F(i, a, b) for(ll i = a; i >= b; --i)
#define FF(i, a, b) for(ll i = a; i > b; --i)
#define x first
#define y second
#define X real()
#define Y imag()
using namespace std;
typedef complex<ll> P;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;

const ll N = 25;
ll n, c, sum = 0, a[N], b[N];

signed main(){
//	freopen("PERFECT1.inp","r",stdin);
//	freopen("PERFECT1.out","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	f(i,1,n) cin >> a[i];
	f(i,1,n){
		cin >> c;
		sum += c;
	}
	ff(i,1,n) cin >> b[i];
	ff(i,1,n) if(a[i]+1 == a[i+1]) sum += b[a[i]];
	cout << sum;
}



Measured memory_bytes: 256
from collections import defaultdict
n=int(input())
o=[]
for i in range(n):
    x,y=map(int,input().split())
    o.append([x,y])
o.sort()
p2=[]
q2=[]
c=[]
if n==1:
    print(1)
else:
    for i in range(n):
        for j in range(i+1,n):
            p2=o[j][0]-o[i][0]
            q2=o[j][1]-o[i][1]
            c.append(str(p2)+" "+str(q2))
    r=defaultdict(int)
    for f in c:
        r[f]+=1
    p=list(r.values())
    q=max(p)
    print(n-q)


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

vector<pair<long long, long long>> divisor_pair(long long n) {
	vector<pair<long long, long long>> v;
	for (long long i = 1; i * i <= n; ++i) {
		if (n % i == 0) v.emplace_back(i, n/i);
	}
	return v;
}

vector<long long> divisor(long long n) {
	vector<pair<long long, long long>> div_pair = divisor_pair(n);
	vector<long long> v(div_pair.size()*2);
	if (div_pair.back().first == div_pair.back().second) v.pop_back();
	for (int i = 0, j = v.size()-1; i < div_pair.size(); i++, j--) {
		v[i] = div_pair[i].first;
		v[j] = div_pair[i].second;
	}
	return v;
}

int main() {
	int n, m;
	cin >> n >> m;
	auto v = divisor(m);
	int ans;
	for (int x : v) {
		if (x >= n) {
			ans = m / x;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
A,B,C,D,E,F = map(int, input().split())

L = []
for a in range(31):
    for b in range(31):
        k = A*a+B*b
        if 0 < 100*k <= F:
            L.append(k)

L.sort()


su = 0
for i, l in enumerate(L):
    limit = min(F-100*l, E*l)
    wd = 100*l
    if i == 0:
        w = wd
    for c in range(3000):
        if C*c >limit:
            break
        d = (limit - C*c) // D
        p = C*c+D*d
        if p*w > wd*su:
            w = wd
            su = p
print(w+su, su)

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

int main(){
  int N;
  int i,j;
  int k = 0;
  int b;

  vector<vector<int>> bingo(3,vector<int> (3));

  for(i=0;i<3;++i){
    for(j=0;j<3;++j){
      cin >> bingo.at(i).at(j);
    }
  }

  cin >> N;
  for(i=0;i<N;++i){
    cin >> b;
    for(j=0;j<3;++j){
      for(k=0;k<3;++k){
        if(bingo.at(j).at(k) == b)
        bingo.at(j).at(k) = -1;
    }
  }
}

  if(bingo.at(0).at(0) == bingo.at(0).at(1) && bingo.at(0).at(0) == bingo.at(0).at(2)){
    cout << "Yes" << endl;
  }else if(bingo.at(1).at(0) == bingo.at(1).at(1) && bingo.at(1).at(0) == bingo.at(1).at(2)){
      cout << "Yes" << endl;
}else if(bingo.at(2).at(0) == bingo.at(2).at(1) && bingo.at(2).at(0) == bingo.at(2).at(2)){
  cout << "Yes" << endl;
}else if(bingo.at(0).at(0) == bingo.at(1).at(0) && bingo.at(0).at(0) == bingo.at(2).at(0)){
  cout << "Yes" << endl;
}else if(bingo.at(0).at(1) == bingo.at(1).at(1) && bingo.at(0).at(1) == bingo.at(2).at(1)){
    cout << "Yes" << endl;
}else if(bingo.at(0).at(2) == bingo.at(1).at(2) && bingo.at(0).at(2) == bingo.at(2).at(2)){
  cout << "Yes" << endl;
}else if(bingo.at(0).at(0) == bingo.at(1).at(1) && bingo.at(0).at(0) == bingo.at(2).at(2)){
  cout << "Yes" << endl;
}else if(bingo.at(0).at(2) == bingo.at(1).at(1) && bingo.at(0).at(2) == bingo.at(2).at(0)){
  cout << "Yes" << endl;
}else{
  cout << "No" << endl;
}
}

Measured memory_bytes: 256
import collections

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

T_count = collections.Counter(T)
# print(T_count)

point = T_count["r"]*P + T_count["s"]*R + T_count["p"]*S

for idx, t in enumerate(T):
    # print(idx + K - 1)
    if idx + K >= N:
        break
    if t == T[idx+K]:
        if t == "r":
            point -= P
        elif t == "s":
            point -= R
        elif t == "p":
            point -= S
        T[idx+K] = "x"
print(point)

Measured memory_bytes: 49492
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>

using namespace std;

int main(){

	map<string,char> table;
	map<char,string> table2;

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

	// \

	for(int i = 0; i < 26; i++){
		string ms;
		for(int j = 0; j < 5; j++){
			if((i>>j)&1){
				ms+='1';
			}
			else
				ms+='0';
		}
		reverse(ms.begin(),ms.end());
		table2['A'+i]=ms;
	}
	table2[' ']="11010";
	table2['.']="11011";
	table2[',']="11100";
	table2['-']="11101";
	table2[(char)39]="11110";
	table2['?']="11111";


	string str;
	while(getline(cin,str)){
		// ¶ð»
		string nstr;
		for(int i = 0; i < str.size(); i++){
			nstr+=(table2[str[i]]);
		}
		//¡
		string dstr;
		for(int i = 0; i < nstr.size(); i++){
			for(map<string,char>::iterator it = table.begin(); it !=table.end(); it++){
				string s=it->first;
				if(i+s.size()-1<nstr.size()){
					string ss=nstr.substr(i,s.size());
					if(it->first==ss){
						dstr+=it->second;
						i+=s.size()-1;
						break;
					}
				}
			}
		}
		cout<<dstr<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define int long long
//int mod=1e9+7;
int mod=998244353;

const int MAX = 510000;
const int MOD = 998244353;

int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main(){
  COMinit();
  int n,a,b,k;
  cin>>n>>a>>b>>k;
  int ans=0;
  for(int i=0;i<=n;i++){
    int x=k-i*a;
    if(x%b==0)(ans+=comb(n,i)*comb(n,x/b))%=mod;
  }
  cout<<ans%mod<<endl;
}


Measured memory_bytes: 12160
#include<iostream>
#include<cstdlib>

using namespace std;

int main(){

  int i=0,tmp=0;
  int c[100]={0};
  char s[100];
  while(cin>>s){
    if(s[0]=='+'){
      tmp=c[i-2]+c[i-1];
      c[i-2]=c[i-2]+c[i-1];
      c[i-1]=0;
      if(i!=1){
	i--;
      }
    }
    else if(s[0]=='-'){
      tmp=c[i-2]-c[i-1];
      c[i-2]=c[i-2]-c[i-1];
      c[i-1]=0;
      if(i!=1){
	i--;
      }
    }else if(s[0]=='*'){
      tmp=c[i-2]*c[i-1];
      c[i-2]=c[i-2]*c[i-1];
      c[i-1]=0;
      if(i!=1){
	i--;
      }
    }
    else{
      c[i]=atoi(s);
      i++;
    }
  }    
  cout<<tmp<<"\n";
  return 0;
}



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

int main(){
  int n, k;
  cin >> n >> k;
  std::vector<int> p(n);
  rep(i, n){
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  int ans = 0;
  rep(i, k){
    ans += p.at(i);
  }
  std::cout << ans << '\n';
  return 0;
}

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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main() {
    ll n, m;
    while(cin >> n >> m) {
        if(n == 0 && m == 0) break;
        vl a(n);
        rep(i, n) cin >> a[i];
        ll ans = 0LL;
        rep(i, n) {
            ans += min(a[i], m / n);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
def funct(num):
    capitals = [chr(x) for x in range(ord('a'), ord('z')+1)]
    result = []
    while num > 0:
        result.append(capitals[(num-1)%26])
        num = (num-1) // 26
    result.reverse()
    return ''.join(result)

print(funct(int(input())))    

Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
using namespace std;

int main () {
    int n,r; cin >> n >> r;
    if (n >= 10) {
        cout << r << endl;
        return 0;
    }
    cout << r + 100 * (10 - n) << endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * ALDS1_3_A.cpp
 *
 *  Created on: Apr 25, 2018
 *      Author: 13743
 */

#include<cstdio>
#include<cstdlib>

using namespace std;

int st[100];
int top = -1;

void push(int x) {
	++top;
	st[top] = x;
}

int pop() {
	--top;
	return st[top+1];
}

int main() {
	char s[100];
	while(scanf("%s", s) != EOF) {
		int a = pop();
		int b = pop();
		if(s[0] == '+') {
			push(a+b);
		}
		else if(s[0] == '-') {
			push(b-a);
		}
		else if(s[0] == '*') {
			push(a*b);
		}
		else {
			push(b);
			push(a);
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
}





Measured memory_bytes: 2716
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    vvi edge(n);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edge[b].push_back(a);
        edge[a].push_back(b);
    }
    vi c(n);
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        sum += c[i];
    }
    sort(c.begin(), c.end(), greater<int>());
    vi ret(n, -1);
    deque<int> que;
    int cidx = 0;
    que.push_back(0);
    ret[0] = c[cidx++];
    while (que.size() != 0) {
        int p = que.front();
        que.pop_front();
        for (auto &ch : edge[p]) {
            if (ret[ch] != -1)
                continue;
            ret[ch] = c[cidx++];
            que.push_back(ch);
        }
    }
    cout << sum - c[0] << "\n";
    for (int i = 0; i < n; ++i) {
        cout << ret[i];
        if (i == n - 1)
            cout << endl;
        else
            cout << " ";
    }
    return 0;
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d) ? "Yes" : "No") << endl;
}


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

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    int count = 0;
    for (int i = 0; i < N - 2; i++){
        if(S.substr(i, 3) == "ABC"){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
// c++14 (gcc 5.3.0) : 
#include <bits/stdc++.h>

int main()
{
	char x;
	char y;
	int numX;
	int numY;
	
	scanf("%c", &x); getchar();
	scanf("%c", &y); getchar();
	
	switch(x)
	{
		case 'A' : numX = 10; break;
		case 'B' : numX = 11; break;
		case 'C' : numX = 12; break;
		case 'D' : numX = 13; break;
		case 'E' : numX = 14; break;
		case 'F' : numX = 15; break;
	}
	
	switch(y)
	{
		case 'A' : numY = 10; break;
		case 'B' : numY = 11; break;
		case 'C' : numY = 12; break;
		case 'D' : numY = 13; break;
		case 'E' : numY = 14; break;
		case 'F' : numY = 15; break;
	}
	
	if (numX < numY)
	{
		printf("<\n");
		//printf("%d < %d\n", numX, numY);
	}
	else
	if (numX > numY)
	{
		printf(">\n");
		//printf("%d > %d\n", numX, numY);
	}
	else
	if (numX == numY)
	{
		printf("=\n");
		//printf("%d = %d\n", numX, numY);
	}
	
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (auto &x: a) cin >> x;
  for (auto &x: b) cin >> x;

  vector<vector<vector<short> > > dp(n+1, vector<vector<short> > (1 << n, vector<short>(50+1, 10000)));
  dp[0][0][0] = 0;
  vector<vector<int> > mask(n+1);
  for (int i = 0; i < (1 << n); i++) mask[__builtin_popcount(i)].push_back(i);

  for (int k1 = 0; k1 < n; k1++) {
    for (int k2 = 0; k2 < n; k2++) {
      int t;
      if ((k1 & 1) == (k2 & 1)) t = a[k2];
      else t = b[k2];
      int m = (1 << k2);
      for (auto &i: mask[k1]) {
        if (i & m) continue;
        for (int j = 0; j <= t; j++) {
          dp[k1+1][i|m][t] = min(dp[k1+1][i|m][t], (short)(dp[k1][i][j] + __builtin_popcount(m-1) - __builtin_popcount((int)i & (m-1))));
        }
      }
    }
  }

  int best = 10000;
  for (int i = 0; i <= 50; i++) {
    if (dp[n][(1<<n)-1][i] < best) best = dp[n][(1<<n)-1][i];
  }

  if (best == 10000) best = -1;
  cout << best << endl;

/*
  for (auto &x: dp) {
    for (auto &y: x) {
      for (auto &z: y) {
        cerr << z << " ";
      }
      cerr << endl;
    }
    cerr << endl;
  }
*/

  return 0;
}


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

#define ll long long int

using namespace std;

int main() {
    string s;
    string t;

    cin >> s >> t;
    ll n = s.size();
    ll res = 0;
    for (ll i = 0; i < n; ++i) {
        if (s[i] != t[i]) ++res;
    }
    cout << res << endl;
}


Measured memory_bytes: 3920