akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = [list(map(int, input().split())) for i in range(2)]
tmp_sum = 0
maxx = 0

for i in range(N):
    tmp_sum += A[0][i]
    tmp = tmp_sum + sum(A[1][i:])
    
    maxx = max(maxx, tmp)

print(maxx)

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

int main() {
  int h, w;
  cin >> h >> w;
  
  int i, j;
  vector<vector<char>> x(h + 2, vector<char>(w + 2, '.'));
  for(i = 1; i <= h; i++){
    for(j = 1; j <= w; j++){
      cin >> x.at(i).at(j);
    }
  }
  
  for(i = 1; i <= h; i++){
    for(j = 1; j <= w; j++){
      if(x.at(i).at(j) == '.'){
        int k, l, count = 0;
        for(k = -1; k <= 1; k++){
          for(l = -1; l <= 1; l++){
            if(x.at(i + k).at(j + l) == '#') count++;
          }
        }
        x.at(i).at(j) = count + 48;
        count = 0;
      }
    }
  }
  
  for(i = 1; i <= h; i++){
    for(j = 1; j <= w; j++){
      cout << x.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define testing 1
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9
#define oo (ll)1e18
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string lts(ll x) {stringstream s; s << x; return s.str(); }
ll stl(string x) {stringstream s(x); ll temp; s >> temp; return temp; }
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN
#if !testing
	#define cerr if(0)cout
#endif

int32_t main() {
	IAMSPEED
	// set testing to 0 when submitting to judge
	int a,b; cin >> a >> b;
	string s1=lts(a), s2=lts(b);
	FOR(i,2,a) {
		s2.pb(s2[0]);
	}
	FOR(i,2,b) {
		s1.pb(s1[0]);
	}
	if (s1<s2) cout << s1;
	else cout << s2;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	//ll n, k;
	//cin >> n >> k;
	//vector<ll> a(n);
	//rep(i, n)
	//{
	//	cin >> a[i];
	//}
	//
	//ll ok = 1000000001;
	//ll ng = 0;

	//while (abs(ok - ng) > 1)
	//{
	//	ll mid = (ok + ng) / 2;
	//	if (isOK(mid,k,a))
	//	{
	//		ok = mid;
	//	}
	//	else
	//	{
	//		ng = mid;
	//	}
	//}

	//cout << ok << endl;
	
	ll n, m;
	cin >> n >> m;
	vector<ll> k(m);
	vector<vector<ll>> s(m, vector<ll>());
	vector<ll> p(m);

	rep(i, m)
	{
		cin >> k[i];
		rep(j, k[i])
		{
			ll tmp;
			cin >> tmp;
			s[i].push_back(tmp);
		}
	}
	rep(i, m)
		cin >> p[i];

	ll ans = 0;

	ll bits = (1 << n) - 1;
	//全部0の場合も調べたいのなら条件を変更するか、別途その分だけプログラムを書く
	while (bits + 1)
	{
		bool ok = true;
		ll tmp = bits;
		for (int i = 0; i < m; i++)
		{
			ll sum = 0;
			for (int j = 0; j < s[i].size(); j++)
			{
				if ((tmp >> (s[i][j] - 1)) & 1)
				{
					sum++;
				}
			}
			if (sum % 2 != p[i])
				ok = false;
		}

		if (ok)
			ans++;

		bits--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1000000007;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,X; int M; cin >> N >> X >> M;
    vector<int> check(M,-1);
    vector<int> A;
    for (int i=0;check[X]<0;X=X*X%M,++i){
        A.emplace_back(X);
        check[X]=i;
    }

    if (N<A.size()){
        ll ans=0;
        for (int i=0;i<N;++i) ans+=A[i];
        cout << ans << '\n'; return 0;
    }
    int s=check[X];
    N-=s;
    ll ans=0;
    for (int i=0;i<s;++i) ans+=A[i];
    int c=A.size()-s;
    for (int i=0;i<N%c;++i) ans+=A[s+i];
    ll sum=0;
    for (int i=s;i<A.size();++i) sum+=A[i];
    ans+=sum*(N/c);

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

Measured memory_bytes: 4016
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) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	if n < k {
		fmt.Fprintln(writer, 0)
		return
	}
	dp := makeGrid(n-k+5, k+5)
	dp[0][0] = 1
	for i := 0; i < n-k+1; i++ {
		for j := 0; j < k+1; j++ {
			dp[i+1][j].addAs(dp[i][j])
			dp[i][j+1].addAs(dp[i][j])
		}
	}
	fmt.Fprintln(writer, dp[n-k+1][k-1])
}

func makeGrid(h, w int) [][]mint {
	index := make([][]mint, h, h)
	data := make([]mint, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

type mint int64

func (mt mint) mod() mint {
	m := mint(1e9 + 7)
	mt %= m
	if mt < 0 {
		return mt + m
	}
	return mt
}
func (mt mint) inv() mint {
	return mt.pow(mint(0).sub(2))
}
func (mt mint) pow(n mint) mint {
	p := mint(1)
	for n > 0 {
		if n%2 == 1 {
			p.mulAs(mt)
		}
		mt.mulAs(mt)
		n >>= 1
	}
	return p
}
func (mt mint) add(x mint) mint {
	return (mt + x).mod()
}
func (mt mint) sub(x mint) mint {
	return (mt - x).mod()
}
func (mt mint) mul(x mint) mint {
	return (mt * x).mod()
}
func (mt mint) div(x mint) mint {
	return mt.mul(x.inv())
}
func (mt *mint) addAs(x mint) *mint {
	*mt = mt.add(x)
	return mt
}
func (mt *mint) subAs(x mint) *mint {
	*mt = mt.sub(x)
	return mt
}
func (mt *mint) mulAs(x mint) *mint {
	*mt = mt.mul(x)
	return mt
}
func (mt *mint) divAs(x mint) *mint {
	*mt = mt.div(x)
	return mt
}



Measured memory_bytes: 2924
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    int D, G, p[10], c[10];
    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, num = 0;
        for (int i = 0; i < D; i++) {
            if (bit & (1 << i)) {
                sum += 100 * (i+1) * p[i] + c[i];
                num += p[i];
            }
        }

        for (int i = D - 1; i >= 0; i--) {
            if (bit & (1 << i)) continue;
            for (int j = 0; j < p[i]; j++) {
                if (sum >= G) break;
                sum += 100 * (i + 1);;
                num++;
            }
        }
        ans = min(ans, num);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
r, c = map(int, raw_input().split())
m = []
ans = []
for i in range(r):
    a = map(int, raw_input().split())
    m.append(a)
    sum = 0
    for j in range(c):
        print(a[j]),
        sum += a[j]
    print(sum)
total = 0
for i in range(c):
    sum = 0
    for j in range(r):
        sum += m[j][i]
    print(sum),
    total += sum
print(total)

Measured memory_bytes: 4288
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    queue<int> que;
    REP(i,9){
        que.push(i+1);
    }
    int K;
    cin >>K;
    REP(i,K){
        int a = que.front();
        if(a%10 !=0){
            que.push(a*10+a%10-1);
        }
        que.push(a*10+a%10);
        if(a%10 !=9){
            que.push(a*10+a%10+1);
        }
        if(i==K-1){
            cout<<a<<endl;
        }
        que.pop();
    }
}

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

vector<int> par(100000);
vector<int> ran(100000,1);

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

void unite(int x, int y) {
	x = root(x);y = root(y);
	if (x == y)
		return;
	if (ran[x] < ran[y])
		par[x] = y;
	else
		par[y] = x;
	if (ran[x] == ran[y])
		ran[x]++;
}

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

int main(){
  for(int i=0;i<100000;i++)
    par[i]=i;
  int n,m;
  cin >> n >> m;
  vector<int> x(m),y(m),z(m);
  for(int i=0;i<m;i++)
    cin >> x[i] >> y[i] >> z[i];
  int co=n;
  for(int i=0;i<m;i++){
    if(!check(x[i]-1,y[i]-1)){
      co--;
      unite(x[i]-1,y[i]-1);
      //cout << i << endl;
    }
  }
  cout << co << endl;
}


Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int N, A, B, C, D;
    cin >> N;
    cin >> A >> B >> C >> D;
    string str;
    cin >> str;
    bool flag=true;
    for(int i=A-1; i+1<C; i++) {
        if(str[i]=='#' && str[i+1]=='#') {
            flag=false;
            break;
        }
    }
    for(int i=B-1; i+1<D; i++) {
        if(str[i]=='#' && str[i+1]=='#') {
            flag=false;
            break;
        }
    }
    if(flag) {
        if(A<B) {
            if(C<D) {
                cout << "Yes" << endl;
            } else {
                flag=false;
                for(int i=B-2; i+2<min(D+1, (int)str.size()); i++) {
                    if(str[i]=='.' && str[i+1]=='.' && str[i+2]=='.') {
                        flag=true;
                        break;
                    }
                }
                if(flag) {
                    cout << "Yes" << endl;
                } else {
                    cout << "No" << endl;
                }
            }
        } else {
            if(C>D) {
                cout << "Yes" << endl;
            } else {
                flag=false;
                for(int i=A-2; i+2<min(C+1, (int)str.size()); i++) {
                    if(str[i]=='.' && str[i+1]=='.' && str[i+2]=='.') {
                        flag=true;
                        break;
                    }
                }
                if(flag) {
                    cout << "Yes" << endl;
                } else {
                    cout << "No" << endl;
                }
            }
        }
    } else {
        cout << "No" << endl;
    }


    return 0;
    
}

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n), vec(n);
    rep(i, n) cin >> p[i];
    rep(i, n) {
        cin >> q[i];
        vec[i] = i + 1;
    }
    int a, b, o = 0;
    do {
        o++;
        bool oka = true, okb = true;
        for (int i = 0; i < n; i++) {
            if (p[i] != vec[i]) oka = false;
            if (q[i] != vec[i]) okb = false;
        }
        if (oka) a = o;
        if (okb) b = o;
    } while (next_permutation(vec.begin(), vec.end()));
    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<limits.h>
using namespace std;

struct Interval
{
	int s, e;
	int pos;
	bool isQ;
	Interval(int s_, int e_, int pos_, bool isQ_) : s(s_), e(e_), pos(pos_), isQ(isQ_){}
};

bool cmp(Interval l, Interval r)
{
	if (l.e < r.e) return true;
	else if (l.e == r.e)
	{
		return !l.isQ && r.isQ;
	}
	else return false;
}

int N, M, Q;
vector<int> f;

void update(int x, int y) {
	for (; x <= N; x += x & -x)
		f[x] += y;
}

int query(int x) {
	int tot = 0;
	for (; x; x -= x & -x)
		tot += f[x];
	return tot;
}

int main()
{
	
	cin >> N >> M >> Q;
	f = vector<int>(N + 1, 0);
	vector<Interval> ranges;
	for (int i = 0; i < M; i++)
	{
		int s, e;
		cin >> s >> e;
		ranges.emplace_back(s, e, i, false);
	}
	for (int i = 0; i < Q; i++)
	{
		int s, e;
		cin >> s >> e;
		ranges.emplace_back(s, e, i, true);
	}
	vector<int> res(Q, 0);
	sort(ranges.begin(), ranges.end(), cmp);

	for (auto range : ranges)
	{
		if (!range.isQ) update(range.s, 1);
		else
		{
			int cnt = query(N) - query(range.s - 1);
			res[range.pos] = cnt;
		}
	}
	for (auto q : res)
	{
		cout << q << endl;
	}
	return 0;
}

Measured memory_bytes: 10352
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

void solve() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a < b) {
        cout << "No" << '\n';
        return;
    }
    if(b <= c+1) {
        cout << (b <= d ? "Yes" : "No") << '\n';
        return;
    }
    if(d < b) {
        cout << "No" << '\n';
        return;
    }
    ll s = a%b;
    ll g = d-b;
    g = gcd(g,b);
    ll r = s%g;
    ll l = r+(b-1-r)/g*g;
    cout << (l < c+1 ? "Yes" : "No") << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int t;
    cin >> t;
    rep(i,t) solve();
}

Measured memory_bytes: 3600
//ABC125 A - 
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    vector<int> vt(n,0);
    vector<int> ct(n,0);
    for (auto& v:vt){
        cin>>v;
    }
    for (auto& c:ct){
        cin>>c;
    }
    int ans=0;
    for (int i= 0;i<n;++i){
        if(vt[i]-ct[i] > 0){
            ans += (vt[i]-ct[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

//問題文より、入力されるデータの最大個数
#define MAXCOUNT 100

//ソートの結果と交換回数を出力する関数
void print(int array[], int size, int count);

int main(void)
{
	//i、jは繰り返し変数、countはループの回数を、tempは挿入するデータを格納
	int i, j, count, temp;
	//sizeは配列の要素数を、arrayは入力される数値を格納
	int size;
	int array[MAXCOUNT];

	//データの個数を入力
	scanf("%d", &size);

	//データを入力
	for(i = 0; i < size; i++){
		scanf("%d", &array[i]);
	}

	count = 0;
	//配列の終端の一つ前まで走査
	for(i = 0; i < (size - 1); i++){
		//大きい値から確定していく
		for(j = 0; j < (size - 1 - i); j++){
			//昇順に並び替える
			if(array[j + 1] < array[j]){
				temp = array[j + 1];
				array[j + 1] = array[j];
				array[j] = temp;

				//交換回数を加算する
				count++;
			}
		}
	}

	//結果を出力
	print(array, size, count);

	return 0;
}

void print(int array[], int size, int count)
{
	int i;

	//配列の中身を1行で表示し、最後に改行する
	for(i = 0; i < (size - 1); i++){
		printf("%d ", array[i]);
	}

	printf("%d\n", array[i]);
	//交換回数を表示
	printf("%d\n", count);
}


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

using P = pair<int,int>;
using P3 = pair<P, int>;
using ll = long long int;
constexpr int INF = 1<<28;

struct edge{
    int to, cap, rev;
};

vector<vector<edge> > G;
vector<bool> used;

void add_edge(int from, int to, int cap){
    G[from].emplace_back((edge){to, cap, int(G[to].size())});
    G[to].emplace_back((edge){from, 0, int(G[from].size())-1});
}

// 増加路の探索
int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    for(auto &e : G[v]){
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    used.resize(G.size());
    int flow = 0;
    while(1){
        fill(used.begin(), used.end(), false);
        int f = dfs(s, t, INF);
        if(f==0) break;
        flow += f;
    }
    return flow;
}

int main() {
    int N, M, L;
    int dist[101][101];
    P query[1001];
    G.resize(2005);
    while(cin >> N >> M >> L, N){
        for(int i=0;i<N;i++) fill(dist[i], dist[i]+N, INF);
        for(int i=0;i<M;i++){
            int u, v, d;
            cin >> u >> v >> d;
            dist[u][v] = d;
            dist[v][u] = d;
        }
        for(int i=0;i<N;i++){
            dist[i][i] = 0;
        }
        for(int k=0;k<N;k++){
            for(int i=0;i<N;i++){
                for(int j=0;j<N;j++){
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
        for(int i=0;i<L;i++){
            int p, t;
            cin >> p >> t;
            query[i] = P(t, p);
        }
        sort(query, query+L);
        
        int S = L*2, T = L*2+1;
        for(int i=0;i<L*2+2;i++){
            G[i].clear();
        }
        for(int i=0;i<L;i++){
            add_edge(S, i, 1);
            add_edge(i+L, T, 1);
        }
        for(int i=0;i<L;i++){
            for(int j=i+1;j<L;j++){
                int u = query[i].second, v = query[j].second;
                if(dist[u][v] <= query[j].first-query[i].first){
                    add_edge(i, j+L, 1);
                }
            }
        }
        cout << L - max_flow(S, T) << endl;
    }
    return 0;
}



Measured memory_bytes: 23392
n = int(input())
ba_cnt = 0
b_top_cnt = 0
a_end_cnt = 0

ab = 0
for _ in range(n):
    s = input()
    ab += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        ba_cnt += 1
    elif s[0] == 'B':
        b_top_cnt += 1
    elif s[-1] == 'A':
        a_end_cnt += 1

ans = ab
if ba_cnt == 0:
    ans += min(a_end_cnt, b_top_cnt)
else:
    ans += (ba_cnt-1)
    if a_end_cnt >0:
        a_end_cnt -= 1
        ans += 1
    if b_top_cnt > 0:
        b_top_cnt -= 1
        ans += 1
    ans += min(a_end_cnt,b_top_cnt)

print(ans)



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

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

const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;

int ar[55];

int main() {
#ifdef Mr_Emrul
	freopen("inputf.in", "r", stdin);
#endif /// Mr_Emrul

	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++) {
		cin >> ar[i];
	}
	ll ans = 0;
	for(int i = 1; i <= n; i++) {
		if(i > k) {
			break;
		}
		multiset <int> st;
		for(int j = 1; j <= i; j++) {
			st.insert(ar[j]);
		}
		multiset <int> cur;
		cur = st;
		ll tot = 0;
		int rem = k - i;
		while(cur.size() && rem) {
			ll x = *cur.begin();
			if(x < 0) {
				cur.erase(cur.find(x));
			}
			else {
				break;
			}
			rem--;
		}
		for(int x : cur) {
			tot += x;
		//	cout << x << endl;
		}
		//cout << "==\n";
		ans = max(ans, tot);
		for(int j = n; j > i && (i + n - j  + 1) <= k; j--) {
			st.insert(ar[j]);
			multiset <int> cur;
			cur = st;
			ll tot = 0;
			int rem = k - (i + n - j  + 1);
			while(cur.size() && rem) {
				ll x = *cur.begin();
				if(x < 0) {
					cur.erase(cur.find(x));
				}
				else {
					break;
				}
				rem--;
			}
			for(int x : cur) {
				tot += x;
			//	cout << x << endl;
			}
			//cout << "==\n";
			ans = max(ans, tot);
		}
	}
	reverse(ar + 1, ar + n + 1);
	for(int i = 1; i <= n; i++) {
		if(i > k) {
			break;
		}
		multiset <int> st;
		for(int j = 1; j <= i; j++) {
			st.insert(ar[j]);
		}
		multiset <int> cur;
		cur = st;
		ll tot = 0;
		int rem = k - i;
		while(cur.size() && rem) {
			ll x = *cur.begin();
			if(x < 0) {
				cur.erase(cur.find(x));
			}
			else {
				break;
			}
			rem--;
		}
		for(int x : cur) {
			tot += x;
		//	cout << x << endl;
		}
		//cout << "==\n";
		ans = max(ans, tot);
		for(int j = n; j > i && (i + n - j  + 1) <= k; j--) {
			st.insert(ar[j]);
			multiset <int> cur;
			cur = st;
			ll tot = 0;
			int rem = k - (i + n - j  + 1);
			while(cur.size() && rem) {
				ll x = *cur.begin();
				if(x < 0) {
					cur.erase(cur.find(x));
				}
				else {
					break;
				}
				rem--;
			}
			for(int x : cur) {
				tot += x;
				//cout << x << endl;
			}
			//cout << "==\n";
			ans = max(ans, tot);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
	int N;
	cin >> N;
	vector<P> val;
	vector<ll> xs;
	for (int i = 0, x; i < N * 2; i++) {
		cin >> x;
		val.emplace_back(x, i / 2);
		xs.push_back(x);
	}
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	for (int i = 0; i < N * 2; i++) {
		val[i].first = lower_bound(xs.begin(), xs.end(), val[i].first) - xs.begin();
	}
	sort(val.begin(), val.end());
	vector<int> cnt(N);
	int li = 0, ri = N * 2 - 1;
	while (!cnt[val[li].second]) cnt[val[li++].second]++;
	fill(cnt.begin(), cnt.end(), 0);
	while (!cnt[val[ri].second]) cnt[val[ri--].second]++;
	fill(cnt.begin(), cnt.end(), 0);
	ll res = 1000000000000000000ll;
	int var = 0, l = 0, r = 0;
	while (r <= N * 2) {
		if (var == N) {
			res = min(res, xs[val[r - 1].first] - xs[val[l].first]);
			cnt[val[l].second]--;
			if (cnt[val[l].second] == 0) var--;
			l++;
		}
		else {
			if (r < N * 2) {
				cnt[val[r].second]++;
				if (cnt[val[r].second] == 1) var++;
			}
			r++;
		}
	}
	cout << min((xs.back() - xs.front()) * res, (xs.back() - xs[val[li].first]) * (xs[val[ri].first] - xs.front())) << endl;
	return 0;
}


Measured memory_bytes: 10720
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void inline swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void inline swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

priority_queue<int> que;
int n, m;

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

	REP(i, n)
	{
		int a;
		cin >> a;
		que.push(a);
	}

	while (m)
	{
		int a = que.top();
		que.pop();

		a /= 2;
		--m;
		que.push(a);
		
	}

	ll ans = 0;
	while (!que.empty())
	{
		ans += (ll)que.top();
		que.pop();
	}

	cout << ans << endl;

}


Measured memory_bytes: 892
n=int(input())

a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]

s=0
ss=0
sss=0

for i in range(n):
  s=s+a[i]
  a[i]=s
  
  ss=ss+b[n-i-1]
  b[n-i-1]=ss

for i in range(n):
    sss=max(a[i]+b[i],sss)

print(sss)


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int>l(n);
  for(int i=0; i<n; i++)cin >> l[i];
  sort(l.rbegin(), l.rend());
  cout << accumulate(l.begin(), l.begin()+k, 0);
  return 0;
}


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

class Dice{
public:
  int value[6];
  void roll(char _order) {
    switch(_order) {
    case 'N':
      swap(value[4], value[0]);
      swap(value[0], value[1]);
      swap(value[1], value[5]);
      break;
    case 'E':
      swap(value[2], value[0]);
      swap(value[0], value[3]);
      swap(value[3], value[5]);
      break;
    case 'S':
      swap(value[1], value[0]);
      swap(value[0], value[4]);
      swap(value[4], value[5]);
      break;
    case 'W':
      swap(value[0], value[2]);
      swap(value[2], value[5]);
      swap(value[5], value[3]);
      break;
    }
  }
  void rotate(void) {
    this->roll('N');
    this->roll('E');
    this->roll('S');
  }
  bool operator==(const Dice other) {
    bool res = true;
    for (int knock=1;knock<=30;knock++) {
      res = true;
      for (int i=0;i<6;i++)
        if (other.value[i] != this->value[i])
          res = false;
      if (res)
        break;
      else {
        if (knock % 5 == 0) {
          if (knock / 5 <= 3) {
            this->roll('N');
          } else if (knock / 5 == 4) {
            this->roll('E');
          } else {
            this->roll('E');
            this->roll('E');
          }
        } else {
          this->rotate();
        }
      }
    }
    return res;
  }
};

int main() {
  int n;
  Dice dice[100];
  cin >> n;
  for (int i=0;i<n;i++)
    for (int j=0;j<6;j++)
      cin >> dice[i].value[j];

  bool res = true;
  for (int i=0;i<n;i++)
    for (int j=i+1;j<n;j++)
      if (dice[i] == dice[j])
        res = false;

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



Measured memory_bytes: 3108
import numpy as np

N = int(input())
A = list(map(int, input().split()))

A=np.array(A)

global res

res=[0]*N

def test(A):
    if A.shape[0]==1:
        if A[0]==1:
            res[0]=1
            return 1
        else:
            return 0
    else:
        B=np.arange(len(A))+1
        C=max((A==B)*B)
        if C==0:
            return 0
        else:
            res[len(A)-1]=C
            return test(np.delete(A,C-1,0))

if test(A)==1:
  for i in range(N):
    print(res[i])
else:
  print(-1)

Measured memory_bytes: 18864
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) {
    int n;
    cin>>n;
    cin.ignore();
    for (int k = 0; k < n; ++k) {
        int grid[8][8];
        int x, y;
        for (int i = 0; i < 8; ++i) {
            string str;
            cin>>str;
            for (int j = 0; j < 8; ++j) {
                grid[i][j] = str[j] - '0';
            }
        }
        cin>>x;
        cin>>y;
        cin.ignore();

        int dx[12] = {1, 2, 3, 0, 0, 0, -1, -2, -3, 0, 0, 0};
        int dy[12] = {0, 0, 0, 1, 2, 3, 0, 0, 0, -1, -2, -3};
        vector<pair<int, int> > p;
        p.push_back(make_pair(x-1, y-1));
        while (!p.empty()) {
            auto pos = p.back();
            grid[pos.second][pos.first] = 0;
            p.pop_back();
            for (int i = 0; i < 12; ++i) {
                int nx = pos.first + dx[i];
                int ny = pos.second + dy[i];
                if (0 <= nx && nx < 8 && 0 <= ny && ny < 8) {
                    if (grid[ny][nx] == 1) p.push_back(make_pair(nx, ny));
                }
            }
        }

        printf("Data %d:\n", k+1);
        for (int i = 0; i < 8; ++i) {
            for (int j = 0; j < 8; ++j) {
                cout<<grid[i][j];   
            }
            cout<<endl;
        } 
    }
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<string>
#include<queue>

using namespace std;

int main() {
  string com;
  int key;
  priority_queue<int> PQ;

  while (1) {
    cin >> com;
    if (com == "end") {
      break;
    } else if (com == "insert") {
      cin >> key;
      PQ.push(key);
    } else {
      cout << PQ.top() << endl;
      PQ.pop();
    }
  }

  return 0;
}


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

namespace procon
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] letter = new string[s.Length];

            for(int i =0;i<s.Length;i++)
            {
                letter[i] = s.Substring(i, 1);
            }

            var query = s
                .GroupBy(x => x)
                .Select(c => new { item = c.Key, count = c.Count() })
                .Where(a => a.count > 1)
                .Select(a => a);

            string result = "no";
            if (query == null || !query.Any())
            {
                result = "yes";
            }
                Console.WriteLine(result);
            
        }
    }
}

Measured memory_bytes: 13408
use std::vec::Vec;
use std::ascii::AsciiExt;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (n, k): (usize, usize) = {
      let v = read_vec();
      (v[0], v[1])
    };
    let s: Vec<char> = read::<String>().chars().collect();
    let mut res: String = String::new();
    for i in 0..n {
      if i == k-1 {
        res.push(s[i].to_ascii_lowercase());
      }
      else {
        res.push(s[i]);
      }
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main()
{
    ll n,m;
    cin >> n >> m;
    ll sum = 0;
    for(int i = 0;i < m;i++)
    {
        ll a;
        cin >> a;
        sum += a;
    }
    cout << max(n - sum,(ll)-1) << "\n";

    return 0;
}

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


int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    int ans = 0;
    for (int i = 1; i < n; i++) {
        ans += a[i] - a[i - 1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,A,B = MI()
    X=LI()
    now = X[0]
    ans = 0
    for x in X:
        ans += min((x-now)*A, B)
        now = x
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 14764
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll n, k;
    cin >> n >> k;

    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    vector<ll> sum(n + 1, 0);

    rep(i, n){
        sum[i + 1] = sum[i] + a[i];
    }

    vector<ll> sums;
    for(int i = 0; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            sums.push_back(sum[j] - sum[i]);
            //cout << j << " " << i << " " <<sum[j] - sum[i] << endl;
        }
    }

    sort(all(sums), greater<ll>());
    ll ans = 0;
    vector<ll> vec = sums;
    for(ll i = 60; i >= 0; i--){
        ll cnt = 0;
        vector<ll> nvec;
        for(ll j = 0; j < vec.size(); j++){
            if(vec[j] & (1LL << i)){
                cnt++;
                nvec.push_back(vec[j]);
            }
        }

        if(cnt >= k){
            ans |= (1LL << i);
            vec = nvec;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 10096
w,a,b=map(int,input().split())
aa=a+w
bb=b+w
if b>=a:
  d=b-aa
  if d<=0:
    print(0)
  else:
    print(d)
else:
  d=a-bb
  if d<=0:
    print(0)
  else:
    print(d)

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

using namespace std;

const unsigned long long MOD = 1000000007LL;

long long dp[101][4][4][4];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n; cin >> n;

    dp[0][3][3][3] = 1;

    for(int i = 1; i <= n; ++i){
        for(int c1 = 0; c1 < 4; ++c1){
            for(int c2 = 0; c2 < 4; ++c2){
                for(int c3 = 0; c3 < 4; ++c3){
                    for(int c4 = 0; c4 < 4; ++c4){
                        if(c1 == 0 && c2 == 2 && c4 == 1)
                            continue;
                        else if(c1 == 0 && c3 == 2 && c4 == 1)
                            continue;
                        else if(c2 == 2 && c3 == 0 && c4 == 1)
                            continue;
                        else if(c2 == 0 && c3 == 1 && c4 == 2)
                            continue;
                        else if(c2 == 0 && c3 == 2 && c4 == 1)
                            continue;
                        dp[i][c2][c3][c4] = (dp[i][c2][c3][c4] + dp[i - 1][c1][c2][c3]) % MOD;
                    }
                }
            }
        }
    }

    long long tot = 0;

    for(int c1 = 0; c1 < 4; ++c1)
        for(int c2 = 0; c2 < 4; ++c2)
            for(int c3 = 0; c3 < 4; ++c3)
                tot = (tot + dp[n][c1][c2][c3]) % MOD;

    cout << tot << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
signed main(){
  string s[100000];
  ll a,b;
  cin>>a>>b;
  for(ll i=0;i<a;i++){
    cin>>s[i];
  }
  for(ll i=-1;i<a+1;i++){
    for(ll j=-1;j<b+1;j++){
	if( i == -1 || i == a ){
      cout<<"#";
    }else if( j == -1 || j == b ){
      cout<<"#";
    }else{
      cout<<s[i][j];
    }
    }
    cout<<"\n";
  }
  return(0);
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef pair<int, int> P;

int f(int i, int j, int x, int y) {
  int cnd1 = j - i;
  int cnd2 = abs(i - x) + abs(j - y) + 1;
  return min(cnd1, cnd2);
}

int main(void) {
  int n, x, y;
  std::cin >> n >> x >> y;
  map<int, int> mp;
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      int dis = f(i, j, x, y);
      mp[dis]++;
    }
  }
  for (int k = 1; k <= n - 1; ++k) {
    std::cout << mp[k] << std::endl;
  }
  return 0;
}


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

constexpr int si = 1001 * 1234;
int n, m, ar[si], cnt[si];
int64_t s1[si], sus[si];

void add_region(int a, int b_inc, int val){
   if (a > b_inc) return;
   s1[a] += val; s1[b_inc +1] -= val;
}
void add_region2(int a, int b_inc, int val, int one=1){
   if (a > b_inc) return;
   cnt[a] +=one; cnt[b_inc +1] -= one;
   add_region(a, b_inc, val*one);
}
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   while (cin >> n >> m)
   {
      for (int i = 1; i <= n; i++) cin >> ar[i];

      memset(cnt, 0, sizeof cnt);memset(s1, 0, sizeof s1); memset(sus, 0, sizeof sus);
      
      for (int i = 1; i < n; i++)
      {
         if (ar[i] < ar[i+1]) {
            add_region(1, ar[i], ar[i + 1] - ar[i]);
            add_region(ar[i+1] + 1, m, ar[i + 1] - ar[i]);
            //good ar[i]+1 .. ar[i+1]
            add_region2(ar[i]+1, ar[i+1], ar[i + 1] + 1);
         }else {
            add_region(ar[i+1] + 1, ar[i], m -ar[i] + ar[i + 1]);
            //good ar[i]+1 ..m, 1 .. ar[i+1]
            add_region2(ar[i] + 1, m, m+ar[i+1]+1);
            add_region2(1, ar[i + 1], 1 +ar[i+1], +1);
         }
      }
      for (int i = 1; i <= m; i++) s1[i+1] += s1[i], cnt[i+1] += cnt[i];

      for (int i = 1; i <= m; i++) sus[i] = s1[i] - cnt[i]* static_cast<int64_t>(i);

      auto ans = sus[1];
      for (int i = 2; i <= m; i++) ans = min(ans, sus[i]);
      cout << ans << "\n";
      //break;
   }
   return 0;
}

Measured memory_bytes: 24832
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+100;
int a[MAXN];
int main()
{
    int N,K;
    scanf("%d%d",&N,&K);
    for(int i=0;i<N;i++)    scanf("%d",a+i);
    sort(a,a+N);
    int g=a[0];
    for(int i=1;i<N;i++)    g=__gcd(g,a[i]);
    int n=N-1;
    bool flag=false;
    while(n>=0&&a[n]>=K)
    {
        if((a[n]-K)%g==0)
        {
            flag=true;
            break;
        }
        n--;
    }
    if(flag)    printf("POSSIBLE");
    else printf("IMPOSSIBLE");
    //printf("\n");
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
void print(ll x){
	if(x<0)putchar('-'),x=-x;
	int y=x%10+'0';
	if(x>=10)print(x/10);
	putchar(y);
}
int n;
double ans,a[3005],dp[3005][3005];
int main(){
	n=read();
	for(int i=0;i<3005;i++)
		dp[0][i]=1;
	for(int i=1;i<=n;i++)
		scanf("%lf",&a[i]);
	for(int i=1;i<=n;i++)
		for(int j=0;j<i;j++){
			dp[i][j+1]+=dp[i-1][j]*(1-a[i]);
			dp[i][j]+=dp[i-1][j]*a[i];
		}
	for(int i=0;i<=n/2;i++)
		ans+=dp[n][i];
	printf("%.10lf",ans);
	return 0;
}

Measured memory_bytes: 69120
x, k = map(int, input().split())
result = x%k
if x < k :
    if x < (k - x) :
        print(x)
    else :
        print(k - x)
else :
    if result == 0 :
        print(0)
    elif k > result :
        print(abs(k - result))
    else :
        print(result)

Measured memory_bytes: 3060
from collections import defaultdict
N, X, M = map(int, input().split())
A = [X]
visited = set()
visited.add(X)

idx = defaultdict()
idx[X] = 0

iii = -1

for i in range(1, M):
    tmp = (A[-1]**2) % M
    if tmp not in visited:
        A.append(tmp)
        visited.add(tmp)
        idx[tmp] = i
    else:
        iii = idx[tmp]

# print(A)
# print(len(A))
# print(iii)

ans = 0

ans += sum(A[:iii])
N -= iii

l = len(A) - iii

ans += (N // l) * sum(A[iii:])
N -= N // l * l

ans += sum(A[iii:iii + N])

print(ans)
exit()


Measured memory_bytes: 85616
import java.util.*;

public class Main {
  public static void main(final String[] args) {
    final Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    long X = sc.nextLong();
    sc.close();

    long ans = 0;
    if (A == 0) {
      ans = B / X + 1;
    } else {
      ans = B / X - (A - 1) / X;
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#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() {
    vector<vector<int>> a(3, vector<int>(3));
    rep(i, 3)rep(j, 3) {
        cin >> a[i][j];
    }
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, n) cin >> b[i];
    vector<vector<bool>> appear(3, vector<bool>(3));
    rep(i, 3)rep(j, 3) {
        appear[i][j] = false;
        rep(k, n) {
            if (a[i][j] == b[k]) appear[i][j] = true;
        }
    }
    string ans = "No";
    rep(i, 3) {
        if (appear[i][0] && appear[i][1] && appear[i][2]) ans = "Yes";
    }
    rep(i, 3) {
        if (appear[0][i] && appear[1][i] && appear[2][i]) ans = "Yes";
    }
    if(appear[0][0] and appear[1][1] and appear[2][2]) ans = "Yes";
    if(appear[0][2] and appear[1][1] and appear[2][0]) ans = "Yes";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
n = int(input())
l = []
for i in range(1, n // 2 + 1):
  a = str(i)
  b = str(n - i)
  k = 0
  for j in range(len(a)):
    k += int(a[j])
  for j in range(len(b)):
    k += int(b[j])
  l.append(k)
print(min(l))

Measured memory_bytes: 3480
n , m = map(int,input().split())
#{num:[ac,WA]}
P = {}
AC = 0
WA = 0
for i in range(m):
    num ,jud = map(str,input().split())
    if num in P:
        if P[num][0] == 0:
            if jud == "AC":
                P[num][0] = 1
            else:
                P[num][1] += 1
    else:
        if jud == "AC":
            P[num] = [1,0]
        else:
            P[num] = [0,1]

for j in P.values():
    if j[0] == 1:
        AC += 1
        WA += j[1]
    
print("{} {}".format(AC,WA))

Measured memory_bytes: 25252
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;

int dp[11][2001];

int main(){
	int N, K;
	cin >> N >> K;
	vector<int> book[11];
	rep(i, N){
		int c, g;
		cin >> c >> g;
		book[g].push_back(c);
	}
	rep(i, 11) sort(book[i].rbegin(), book[i].rend());

	rep(i, 11){
		FOR(j, 1, book[i].size()){
			book[i][j] += book[i][j-1] + j*2;
		}
	}

	FOR(i, 1, 11){
		rep(j, K+1) dp[i][j] = dp[i-1][j];
		FOR(j, 1, book[i].size()+1){
			for(int k = 0; k+j <= K; k++){
				dp[i][k+j] = max(dp[i][k+j], dp[i-1][k]+book[i][j-1]);
			}
		}
	}
	cout << dp[10][K] << endl;

    return 0;
}

Measured memory_bytes: 1316