akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

    string ans;
    for (int i = 0; i < N; i++) {
        ans += S.at(i);
        ans += T.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3468
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int N;
int p[51];

int main(int argc, char *argv[]) {
	int sr;
	int i;
	int d1, d2;

	sr=scanf("%d", &N);

	for (i=1; i<=N; i++) {
		sr=scanf("%d", &p[i]);
	}

	d1 = -1; d2 = -2;
	for (i=1; i<=N; i++) {
		if (i!=p[i]) {
			if(d1<0) {
				d1 = i;
				continue;
			} else {
				if (d2<0) {
					d2 = i;
					continue;
				} else {
					printf("NO\n"); fflush(stdout);
					return 0;
				}
			}
		}
	}
	printf("YES\n"); fflush(stdout);

	return 0;

}


Measured memory_bytes: 128
#include<iostream>

using i64 = int_fast64_t;

constexpr i64 MOD = 1e9+7;

i64 mpow(i64 m,i64 n){
    i64 e = 1;
    while(n){
        if(n&1)e*=m;
        m*=m;
        n>>=1;
        m%=MOD;
        e%=MOD;
    }
    return e;
}

int main(){
    i64 m,n;
    std::cin>>m>>n;
    std::cout<<mpow(m,n)<<std::endl;
}


Measured memory_bytes: 3104
#include <iostream>
using namespace std;
int main(void)
{
int D;
cin >> D;
switch(D){
case 22:
cout << "Christmas Eve Eve Eve" << "\n";
break;
case 23:
cout << "Christmas Eve Eve" << "\n";
break;
case 24:
cout << "Christmas Eve" << "\n";
break;
case 25:
cout << "Christmas" << "\n";
break;
}
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

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

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin>>N;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    sort(all(A));
    print(A);
    int cnt = 1;
    rep(i,N-1){
        if(A[i]!=A[i+1])cnt++;
    }
    int m = N - cnt;
    if(m %2 == 0){
        cout<<cnt<<endl;
    }else{
        cout<<cnt - 1 <<endl;
    }
}

Measured memory_bytes: 1024
N,K=map(int,input().split())
XYC=[list(input().split()) for i in range(N)]

MAP=[[0 for i in range(K*2+1)] for j in range(K*2+1)]
mod=K*2
for x,y,c in XYC:
    x=int(x)
    y=int(y)
    if c=="W":
        x+=K

    MAP[x%mod+1][y%mod+1]+=1
    MAP[(x+K)%mod+1][(y+K)%mod+1]+=1




for i in range(K*2+1):
    for j in range(1,K*2+1):
        MAP[i][j]=MAP[i][j-1]+MAP[i][j]

for i in range(K*2+1):
    for j in range(1,K*2+1):
        MAP[j][i]=MAP[j-1][i]+MAP[j][i]

ANS=0
for i in range(K):
    for j in range(K):

        if ANS<MAP[i+K][j+K]-MAP[i][j+K]-MAP[i+K][j]+MAP[i][j]:
            ANS=MAP[i+K][j+K]-MAP[i][j+K]-MAP[i+K][j]+MAP[i][j]
        if ANS<N-(MAP[i+K][j+K]-MAP[i][j+K]-MAP[i+K][j]+MAP[i][j]):
            ANS=N-(MAP[i+K][j+K]-MAP[i][j+K]-MAP[i+K][j]+MAP[i][j])
print(ANS)


Measured memory_bytes: 110040
// Nurbakyt Madibek
// Look at my code! IT'S AWESOME

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <bitset>
#include <unordered_set>

using namespace std;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) (int)((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;
typedef pair < ll, ll > pl;
typedef vector < pi > vi;
typedef vector < pi > vl;

const int inf = (int)1e9 + 123;
const ll infl = (ll)1e18 + 123;
const double eps = 1e-6;

const int MAX_N = (int)1e5 + 5;
const int mod = (int)1e9 + 7;

int x, y, z;
int n;
int a[MAX_N], b[MAX_N], c[MAX_N];
int p[MAX_N];

bool cmp(int x, int y) {
    return a[x] - b[x] > a[y] - b[y];
}

ll pref[MAX_N], suff[MAX_N];

multiset < ll > q;

ll findBest() {
    ll now = 0;
    for (int i = 1; i <= n; i++) {
        q.insert(a[p[i]]);
        now += a[p[i]];
        if (sz(q) > x) {
            now -= *q.begin();
            q.erase(q.begin());
        }
        pref[i] = now;
    }
    q.clear();
    now = 0;
    for (int i = n; i > 0; i--) {
        q.insert(b[p[i]]);
        now += b[p[i]];
        if (sz(q) > y) {
            now -= *q.begin();
            q.erase(q.begin());
        }
        suff[i] = now;
    }
    ll maxi = -infl;
    for (int i = x; n - i >= y; i++) {
        maxi = max(maxi, pref[i] + suff[i + 1]);
    }
    return maxi;
}

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    cin >> x >> y >> z;
    n = x + y + z;
    ll all = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i] >> c[i];
        a[i] -= c[i], b[i] -= c[i];
        all += c[i];
        p[i] = i;
    }
    sort(p + 1, p + n + 1, &cmp);
    cout << all + findBest() << endl;
    return 0;
}


Measured memory_bytes: 7808
#include <cstdio>

int main(int argc, char const* argv[])
{
	int n;
	scanf("%d", &n);
	int tenant[120];
	for(int i = 0; i < 120; i++){
			tenant[i] = 0;
	}
	for(int i = 0; i < n; i++){
			int b, f, r, v;
			scanf("%d %d %d %d", &b, &f, &r, &v);
			tenant[30*(b-1) + 10*(f-1) + r-1] += v;
	}
	printf(" ");
	for(int i = 0; i < 120; i++){
			printf("%d", tenant[i]);
			if((i+1) % 10 == 0)printf("\n");
			if((i+1) % 30 == 0 && i+1 != 120)printf("####################\n ");
			else if(i+1 != 120)printf(" ");
	}
	return 0;
}



Measured memory_bytes: 2736
#include <iostream>
using namespace std;
int n;
int main()
{ cin>>n;
  if(n<=111)
     cout<<"111";
  else if(n<=222)
     cout<<"222";
  else if(n<=333)
     cout<<"333";
  else if(n<=444)
     cout<<"444";
  else if(n<=555)
     cout<<"555";
  else if(n<=666)
     cout<<"666";
  else if(n<=777)
     cout<<"777";
  else if(n<=888)
     cout<<"888";
  else if(n<=999)
     cout<<"999";
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int ans;
  if(a<=b) ans = a*c;
  else ans = b*c+(a-b)*d;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] iArray = new int[n];
		int result = 0;
		for (int i = 0; i < n; i++) {
			int m = sc.nextInt();
			iArray[i] = m;
			x = x - m;
			result++;
		}
		if (x > 0) {
			Arrays.sort(iArray);
			int min = iArray[0];
			int cnt = x / min;
			result = result + cnt;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 21716
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

x =[a,b,c,d,e]

x.sort()
if x[4] - x[0] <= k:
    print("Yay!")
else:
    print(":(")


Measured memory_bytes: 3060
/*
    And I know I may end up failing too
*/




#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int>pii;
typedef unsigned long long ull;

#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7
#define pb           push_back
#define pf           push_front
#define pi           acos(-1)
#define all(x)       x.begin(),x.end()
#define fast         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define INF          0x3f3f3f3f

struct hash_pair
{
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1> {}(p.first);auto hash2 = hash<T2> {}(p.second);return hash1 ^ hash2;
    }
};

ll t;
ll mod=100000007;
ll BigMod(ll base,ll pow,ll mod)
{
    if(pow==0||base==1)return 1;
    else if(pow==1)return base;
    else if(pow%2)return BigMod(base,pow-1,mod)*base%mod;
    else {ll x=(BigMod(base,pow/2,mod)%mod);x=(x*x)%mod;return x;}
}

ll dp[10005];



int main()
{
    fast;
    ll a,b,c,d,e,f,g,i,j;
    ll n,m,k;
    cin>>n;
    g=__gcd(n,360LL);
    a=n*360;
    a/=g;
    cout<<a/n<<endl;
    return 0;
}


Measured memory_bytes: 3636
/**
*    author:  Dooloper
*    created: 05.07.2020 21:16:43
**/

#include <bits/stdc++.h>

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  ll ans = a[0];
  n-=2;
  int t = 1;
  while(n){
    if(n <= 1){
      ans += a[t];
      break;
    }
    n -= 2;
    ans += a[t] * 2;
    t++;
  }
  cout << ans << endl;
  return 0;
}

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

long long fn(long long m, long long n)
{
	if(n == 0)
	{
		return 1;
	}
	else if(n % 2 == 0)
	{
		return fn((m * m) % 1000000007, n / 2);
	}
	else
	{
		return (m * fn(m, n - 1)) % 1000000007;
	}
}

int main()
{
	long long M, N;
	cin >> M >> N;		
	cout << fn(M, N) << endl;

    return 0;
}



Measured memory_bytes: 3104
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

void solve(int, vector<int> const &vals) {
  std::priority_queue<double, std::vector<double>, std::greater<double> > que;
  for (auto &&v : vals) { que.push(v); }
  while (que.size() > 1) {
    auto const a = que.top(); que.pop();
    auto const b = que.top(); que.pop();
    que.push((a + b) / 2);
  }
  cout << que.top() << "\n";
}

int main() {
  cout << fixed << setprecision(10);

  int N; cin >> N;
  vector<int> vals;
  REP(i, N) {
    int V; cin >> V;
    vals.push_back(V);
  }
  solve(N, vals);
  return 0;
}


Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long int ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
vector<ll> a; vector<vector<ll>> dp;
ll rec(int l, int r) {
    if (l == r)return 0;
    if (dp[l][r] != -1)return dp[l][r];
    ll ret = 1e18;
    for (int i = l; i < r; i++) {
        chmin(ret, rec(l, i)+rec(i+1, r)+a[r] -a[l-1]);
    }return dp[l][r] = ret;
}
int main(void) {
    int n; cin >> n; a.resize(n+1,0); dp.resize(n+1, vector<ll>(n+1, -1));
    rep(i, n) cin >> a[i+1];
    rep(i, n) a[i + 1] += a[i];
    cout << rec(1, n) << endl;
}

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

maxNum = 0
maxcount = 0
tugi = 0
ls = [0]*n
for i in range(n):
    o = int(input())
    maxNum = max(maxNum,o)
    ls[i] = o
for i in range(n):
    if ls[i] == maxNum:
        maxcount+=1
    else:
        tugi = max(tugi,ls[i])
if maxcount > 1:
    for i in range(n):
        print(maxNum)
else:
    for i in range(n):
        if ls[i] == maxNum:
            print(tugi)
        else:
            print(maxNum)


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

int main()
{
    int h,w;
    cin>>h>>w;
  	long long  dx[4]= {0, 1, 0, -1};
  	long long  dy[4]= {1, 0, -1, 0};

    pair<int,int>c,d;
    cin>>c.first>>c.second;
    cin>>d.first>>d.second;
    c.first--;
    c.second--;
    d.first--;
    d.second--;
    vector<string>a(h);
    vector<vector<long long > > b(h);
    for(int i=0;i<h;i++)cin>>a[i]; 
  
    for(int i=0;i<h;i++)
    {  
        b[i].resize(w);
      	for(int j=0;j<w;j++)b[i][j]=1000000000;
    }

    queue<pair<int,int> >q1,q2;
    q1.push(make_pair(c.first,c.second));
    b[c.first][c.second] = 0;
    while(!q1.empty() || !q2.empty())
    {
        if(!q1.empty())
        {
            auto u=q1.front();
            q1.pop();
            q2.push(make_pair(u.first,u.second));
          	for(int i=0;i<4;i++)
            {
              int nx= u.first + dx[i];
              int ny= u.second + dy[i];
              if (ny<0 || ny>=w || nx<0 || nx>=h || a[nx][ny] == '#') continue;
              if(b[nx][ny] > b[u.first][u.second] && a[nx][ny] == '.')
              {
                    b[nx][ny]=b[u.first][u.second];
                    q1.push(make_pair(nx,ny));
              }
            }
        }
        else 
        {
            auto v= q2.front();
            q2.pop();
            for(int i=-2;i<=2;i++ )
            {
                for(int j=-2;j<=2;j++)
                {
                  	int nx = v.first + i;
                  	int ny = v.second + j;
                  	if (ny<0 || ny>=w || nx<0 || nx>=h || a[nx][ny] == '#')  continue;
                    if(b[nx][ny] > (b[v.first][v.second]+1) && a[nx][ny] == '.')
                    {
                        b[nx][ny]=b[v.first][v.second]+1;
                        q1.push(make_pair(nx,ny));
                    }
                }
            }
        }

    }
    if(b[d.first][d.second] == 1000000000)cout<<-1<<endl;
    else cout<<b[d.first][d.second]<<endl;
	return 0;
}


Measured memory_bytes: 13380
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>

int main() {

  auto n = 0;
  auto a = 0;
  auto b = 0;
  scanf("%d %d %d", &n,&a,&b);


  // mark 1
  //const auto n = std::stoi(arguments[0]);
  //const auto a = std::stoi(arguments[1]);
  //const auto b = std::stoi(arguments[2]);
  auto max = 0;
  auto min = 0;

  if (a > b) {
    max = b;
  } else {
    max = a;
  }

  if ( (a + b) <= n ) {
    min = 0;
  } else {
    min = a + b - n;
  }

  std::cout << max << " " << min << std::endl;

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
const ll MAX_V=100001;//頂点の制約
const ll INF=1000000000000000;

struct edge{ll to,cost;};

vector<edge> G[MAX_V];//隣接リスト
ll d[MAX_V];//頂点sからの最短距離
ll N;//頂点数

void dijkstra(ll s){
    priority_queue<P,vector<P>,greater<P>> que;
    fill(d,d+N+1,INF); 
    d[s]=0;
    que.push(P(0LL,s));//P.a:最短距離 P.b:頂点の番号

    while(!que.empty()){
        P p=que.top(); que.pop();
        ll v=p.b;//頂点番号
        if(d[v]<p.a) continue;
        rep(i,G[v].sz){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main(){
    cin>>N;
    //辺の情報入力
    rep(i,N-1){
        ll from,to,cost; cin>>from>>to>>cost;
        G[from].push_back((edge){to,cost});
		G[to].push_back((edge){from,cost});
    }
	ll Q,K; cin>>Q>>K;
    dijkstra(K);

	vector<ll> ans(Q);
    rep(i,Q){
		ll x,y; cin>>x>>y;
		ans[i]=d[x]+d[y];
	}
	rep(i,Q) cout<<ans[i]<<endl;
}

Measured memory_bytes: 11120
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int get(int a){
	int res = 0;
	while(a != 0){
		res += a % 10;
		a/=10;
	}
	return res;
}

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

	int mini = 1e9;
	range(i,1,n){
		int b = n - i;
		mini = min(mini, get(i) + get(b));
	}
	cout << mini << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(int i=x;i<n;i++)
string s = "", t = "";
int dp[3002][3002],n,m;
int main()
{
    cin >> s >> t;
    n = s.size();
    m = t.size();
    loop(i, 1, n+1)
    {
        loop(j, 1, m+1)
        {
            if (s[i - 1] == t[j - 1])
            {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    if (dp[n][m] == 0) return 0;
    vector<char>ans;
    int i = n, j = m;
    while (i > 0 and j > 0)
    {
        if (s[i - 1] == t[j - 1])
        {
            ans.push_back(s[i - 1]);
            i--;
            j--;
        }
        else if (dp[i - 1][j] > dp[i][j - 1]) i--;
        else j--;
    }
    int k = ans.size() - 1;
    loop(l, 0, k + 1)
        cout << ans[k - l];
}


Measured memory_bytes: 35456
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#define INF INT_MAX
using namespace std;

string a;
int cnt;
int ans;

int main(){
	cin >> a;

	for (int i = 0; i < a.size() + 1; i++){
		
		if (a[i] == 'A' || a[i] == 'C' || a[i] == 'G' || a[i] == 'T'){
			cnt++;
		}
		else{
			if (ans < cnt){
				ans = cnt;
				cnt = 0;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;



#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define in insert
#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define int ll
const ll mod =1e9+7;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
const ll maxn = 400000+10;


int32_t main()
{

  int n,x,y;
  cin>>n>>x>>y;
  vi ans(n+1,0);
  for(int i = 1;i<=n;i++){
    for(int j = i+1;j<=n;j++){
      int dist = j-i;
      dist= min(dist,abs(i-x)+1+abs(j-y));
      ans[dist]++;
      }
    }
  for(int i = 1;i<=n-1;i++)
  {
    cout<<ans[i]<<endl;
  }








}


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int K = int.Parse(line);
            line = Console.ReadLine();
            if (line.Length > K)
            {

                Console.WriteLine(line.Substring(0,K) + "...");
            }
            else
            {
                Console.WriteLine(line);
            }

        }
    }
}


Measured memory_bytes: 27548
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define MAX 30
#define NTL -1

struct Node {int p, l, r; };
Node T[MAX];
int n;

void preorder(int r) {
    if(r == NTL) return;
    cout << " " << r;
    preorder(T[r].l);
    preorder(T[r].r);
}

void inorder(int r) {
    if(r == NTL) return;
    inorder(T[r].l);
    cout << " " << r;
    inorder(T[r].r);
}

void postorder(int r) {
    if(r == NTL) return;
    postorder(T[r].l);
    postorder(T[r].r);
    cout << " " << r;
}

int main() {
    int i, id, l, r;
    cin >> n;
    for(int i = 0; i < n; i++) {
        T[i].p = NTL;
    }
    for(int i = 0; i < n; i++) {
        cin >> id >> l >> r;
        T[id].l = l;
        T[id].r = r;
        if(l != NTL) {
            T[l].p = id;
        }
        if(r != NTL) {
            T[r].p = id;
        }
    }
    for ( i = 0; i < n; i++) {
        if(T[i].p == NTL) {r = i; break;}
    }
    cout << "Preorder" << endl;
    preorder(r);
    cout << endl;
    cout << "Inorder" << endl;
    inorder(r);
    cout << endl;
    cout << "Postorder" << endl;
    postorder(r);
    cout << endl;
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define repvin(V,N) for(int i = 0; i < N; i++) {int tmp; cin >> tmp; V.push_back(tmp);}

using namespace std;

int main(){

    ll n,k;
    cin >> n >> k;

    vector<ll> x;

    repvin(x,n);

    if(k != 1){

        ll ans = LLONG_MAX;

        rep(i,n + 1 - k){
            ans = min(ans,  x[k - 1 + i] - x[i] + min(abs(x[i]), abs(x[k - 1 + i])));
        }

        cout << ans << endl;

    }else{

        ll ans = LLONG_MAX;
        rep(i,n){
            ans = min(ans, abs(x[i]));
        }
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1400
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
c2 = 0
c4 = 0
for i in range(N):
  if a[i] % 4 == 0:
    c4 += 1
  elif a[i] % 2 == 0:
    c2 += 1
f = 1
t = N - 1
if c2 >= 2:
  t -= c2 - 1
#print(c2, c4, t)
if t // 2 + t % 2 > 0 and c4 == 0: f = 0
if c2 == N and c2 % 2 == 0:
  print("Yes")
  exit(0)
if t // 2 + t % 2 <= c4 and f:
  print("Yes")
else: print("No")


Measured memory_bytes: 58608
#include <bits/stdc++.h>
using namespace std;
int main (){
  int n,tt;
  cin>>n>>tt;
  vector <int>c(n);
  vector <int>t(n);
  int i,m=1001;
  for(i=0;i<n;i++){
    cin>>c[i]>>t[i];
    if(t[i]<=tt){
      if(m>c[i])
        m=c[i];
    }
  }
  if(m==1001)
    cout<<"TLE";
  else
  cout<<m;
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int H, W;
	while (1){
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <stdio.h>

int main()
{
	char s[100001];
	scanf("%s", s);
	
	int i;
	for (i = 0; s[i] != 0; i++);
	if (s[0] == s[i-1] && i % 2 == 0) printf("First\n");
	else if (s[0] != s[i-1] && i % 2 == 1) printf("First\n");
	else printf("Second\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1724
#include <cstdio>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;

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

int g(int po){
	if(po == 4||po == 6 || po == 9 || po == 11 ){
		return 2;
	}
	else if(po == 2){
		return 1;
	}
	else {
		return 0;
	}
}


int main(){
	int H,W;
	cin >> H>>W;



	string a[100];

	REP(j,H){
			cin >> a[j];
	}

	REP(i,W+2){
		cout << "#";
	}
	cout << endl;

	REP(j,H){
		cout << "#";
		cout << a[j];

		cout << "#" <<endl;
	}

	REP(i,W+2){
		cout << "#";
	}
	cout << endl;
	
}

Measured memory_bytes: 256
//結局全探索、たかだか2^10通りなので
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    int N;
    cin >> N;
    int F[N][10];
    ll P[N][11];
    for(int i = 0; i < N; ++i) 
        for(int j = 0; j < 10; ++j) cin >> F[i][j];
    
    for(int i = 0; i < N; ++i) 
        for(int j = 0; j < 11; ++j) cin >> P[i][j];
    
    ll res = -1e9;
    int cnt[N];
    for(int cs = 0; cs < (1<<10); ++cs) {
        fill(cnt, cnt + N, 0);
        bool flg = false;
        ll tmp = 0;
        for(int i = 0; i < 10; ++i) {
            if(cs & (1 << i)) {
                flg = true;
                for(int j = 0; j < N; ++j)
                    if(F[j][i]) ++cnt[j];
            }
        }

        for(int i = 0; i < N; ++i) tmp += P[i][cnt[i]];
        if(flg) res = max(res, tmp);
        else continue;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
def sum_C(n,k):
	nn=n
	max = 0
	min = 0
	sum=0
	for i in range(k):
		min += i
	for j in range(k):
		max += nn
		nn-=1
	sum += (max-min+1)%(pow(10,9)+7)

	#print(sum)
	
	for i in range(k,n+1,1):
		max+=n-i
		min+=i
		#print(max-min+1)
		sum+=(max-min+1)%(pow(10,9)+7)
	return sum
 
 
N,K = map(int, input().split())
 
p = sum_C(N,K)
p = p%(pow(10,9)+7)
print(p)

Measured memory_bytes: 64616
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y){
if(x==0 || y==0)
  return max(x,y);
  else{
  if(x<y)
    return gcd(x,y%x);
    else if(y<x)
      return gcd(y,x%y);
    else
      return x;
  }

}
int main(){
int N,X;
  cin>>N>>X;
  vector<int>A(N);
  for(int i=0;i<N;i++){
  int x;
    cin>>x;
    A.at(i)=abs(x-X);
  
  }
  int ans=A.at(0);
  for(int i=1;i<N;i++){
  ans=gcd(ans,A.at(i));
  
  }cout<<ans<<endl;
  
  
 return 0;
}

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

public class Main {
    static StringTokenizer st;
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws IOException {
        if (nextInt()>nextInt()) {
            System.out.println("safe");
        }
        else {
            System.out.println("unsafe");
        }
    }
    
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}




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

#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;

const int MAXN = 55;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int LOG = 18;
const double EPS = 1e-9;
const double PI = 3.1415926535;

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

ll matrix[MAXN][MAXN];
ll ans[MAXN][MAXN];

ll add(ll a, ll b) {
    if(a + b >= MOD)
        return (a + b - MOD);
    return (a + b);
}

ll mult(ll a, ll b) {
    return (a * b) % MOD;
}

void matrix_mult(ll A[][MAXN], ll B[][MAXN], int N) {
    ll temp[MAXN][MAXN];
    memset(temp, 0, sizeof(temp));
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            for(int k = 0; k < N; k++)
                temp[i][j] = add(temp[i][j], mult(A[i][k], B[k][j]));

    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            A[i][j] = temp[i][j];
}

ll solution(int N, ll y) {
    for(int i = 0; i < N; i++)
        ans[i][i] = 1;

    while(y > 0) {
        if(y & 1)
            matrix_mult(ans, matrix, N);

        y = y >> 1;
        matrix_mult(matrix, matrix, N);
    }

    ll sol = 0;
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            sol = add(sol, ans[i][j]);

    return sol;
}

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

    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            cin >> matrix[i][j];

    cout << solution(N, K) << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int k;
	int mp[10];
	int f=0;
	int cnt=0;	
	for(int i=1;i<=8;++i)mp[i]=0;
	for(int i=1;i<=n;++i){
		cin>>k;
		if(k>=1&&k<=399){
			mp[1]++;
		}
		if(k>=400&&k<=799){
			mp[2]++;
		}
		if(k>=800&&k<=1199){
			mp[3]++;
		}
		if(k>=1200&&k<=1599){
			mp[4]++;
		}
		if(k>=1600&&k<=1999){
			mp[5]++;
		}
		if(k>=2000&&k<=2399){
			mp[6]++;
		}
		if(k>=2400&&k<=2799){
			mp[7]++;
		}
		if(k>=2800&&k<=3199){
			mp[8]++;
		}
		if(k>=3200){
			f++;
		}
	}
	for(int i=1;i<=8;++i){
		if(mp[i]!=0)cnt++;
	}
	if(f==0&&cnt!=0){
		printf("%d %d\n",cnt,cnt);
	}
	else if(f!=0&&cnt==0){
		printf("%d %d\n",1,f);	
	}
	else if(f!=0&&cnt!=0){
		printf("%d %d\n",cnt,cnt+f);
	}
	
	return 0;
}

Measured memory_bytes: 256
//
// Created by 中野誠大 on 2019-02-10.
//

#include<iostream>

#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;


int main() {
    string N;
    cin >> N;
    cout << "ABC"+N<<endl;
}




Measured memory_bytes: 256
var s:string;
    i,j,k:longint;
    x,y,ans:longint;
begin
  readln(s);
  for i:=1 to length(s) do
  begin
    if(x=y)then
    begin
      x:=x+1;
      if(s[i]='p')then
      ans:=ans-1;
    end
    else
    begin
      y:=y+1;
      if(s[i]='g')then
      ans:=ans+1;
    end;
  end;
  writeln(ans);
end.

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF 1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    int x;
    int t;
    cin >> x >> t;
    if (x <= t) {
        cout << 0 << endl;
    } else {
        cout << x - t << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	static long goukei = 0;
	static long MAX = 0;
	static Scanner scan = new Scanner(System.in);
	static int N = scan.nextInt();
	static int[]A = new int[N];//N~10;
	static int M = scan.nextInt();
	static int Q = scan.nextInt();
	
	static int[]g = new int[Q];
	static int[]b = new int[Q];
	static int[]c = new int[Q];
	static int[]d = new int[Q];
	
	
	public static void main(String[]args) {
		
			
			for(int i = 0;i<Q;i++) {
				g[i] = scan.nextInt();
				b[i] = scan.nextInt();
				c[i] = scan.nextInt();
				d[i] = scan.nextInt();
			}
			
			ho(A,0);
			
		
			System.out.println(MAX);
	
		
		
	}
	
	
	private static void ho(int[]a,int N) {
		
		if(N==a.length) {
			for(int i = 0;i<N;i++) {
				//System.out.print(a[i]);
				//System.out.print(" ");
			}
			
			
			goukei = 0;
			for(int i = 0;i<Q;i++) {
				if(a[b[i]-1]-a[g[i]-1]==c[i]) {
					goukei+=(long)d[i];
				}
			}
			
			//System.out.print(goukei);
			//System.out.print(" ");
			
			
			if(MAX<goukei)MAX = goukei;
			
			//System.out.println(MAX);
			
		}else if(N==0) {
			for(int i =1;i<=M;i++){
				a[N] = i;
				ho(a,N+1);
			}
		}else{
			for(int i =a[N-1];i<=M;i++) {
				a[N]=i;
				ho(a,N+1);
			}
		}
		
	}
		

}


Measured memory_bytes: 36908
while True:
    nums = list(map(int, input().split(" ")))
    if nums[0] == nums[1] and nums[1] == 0:
        break
    else:
        if nums[0] > nums[1]:
            nums[0], nums[1] = nums[1] ,nums[0]
        print("%d %d" %(nums[0], nums[1]))
        


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b == c || a+c == b || b+c == a){
        cout << "Yes\n";
    }else cout << "No\n";
}


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

using namespace std;

int main()
{
    string S; cin >> S;
    
    vector<char> v1;
    
    vector<int> v2; int c = 1;
    
    for(int i = 1; i < S.size(); i++)
    {
        if(S[i - 1] != S[i])
        {
            v1.push_back(S[i - 1]);
            v2.push_back(c);
            
            c = 0;
        }
        
        c++;
    }
    
    v1.push_back(S[S.size() - 1]);
    v2.push_back(c);
    
    int ret = 0;
    
    for(int i = 1; i < v1.size() -1; i++)
    {
        if(v1[i - 1] == 'J' && v1[i] == 'O' && v1[i + 1] == 'I' && v2[i - 1] >= v2[i] && v2[i] <= v2[i + 1])
        {
            ret = max(ret, v2[i]);
        }
    }
    
    printf("%d\n", ret);
    
    return 0;
}

Measured memory_bytes: 9608
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;

  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long, long long>;

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

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

  char temp;
  std::cin>>temp;

  temp++;

  std::cout<<temp<<"\n";

  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
 
using namespace std;
int main()
{
 int n,w;
  cin>>n>>w;
  int a[n][2];
  for(int i=0;i<n;i++)
  cin>>a[i][0]>>a[i][1];
 long long  dp[n+1][w+1];
  
  for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=w;j++)
    {
      if(i==0 ||j==0)
       dp[i][j]=0;
      else if(j>=a[i-1][0])
       dp[i][j]=max(a[i-1][1]+dp[i-1][j-a[i-1][0]],dp[i-1][j]);
      else
        dp[i][j]=dp[i-1][j];
    }
   }
  
  
  cout<<dp[n][w];
  return 0;
  
}

Measured memory_bytes: 79104
S = input()
list = []
for i in S:
    list.append(int(i))
n = len(S)
ans =[]
Ans =[]
for i in range(n-2):
    ans.append(100*list[i]+10*list[i+1]+list[i+2])
for i in range(n-2):
     Ans.append(abs(ans[i]-753))
print(min(Ans))

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

int main(){
  string S, T;
  cin >> S >> T;
  int count = 0;
  
  if(T.size() == S.size() + 1){
    for(int i = 0; i < S.size(); i++){
      if(S.at(i) == T.at(i)){
        count++;
      }
    }
    if(count == S.size()){
      cout << "Yes" << endl;
    }
    else
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
def resolve():
    n, k = map(int, input().split())
    H = []
    for _ in range(n):
        H.append(int(input()))
    H_sort = list(sorted(H, reverse=True))
    ans = 10**9
    for i in range(n-k+1):
        ans = min(ans, H_sort[i]-H_sort[i+k-1])
    print(ans)
resolve()

Measured memory_bytes: 14376
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::*;

use std::io::*;
use std::str::FromStr;

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

fn main() {
  let n: usize = read::<usize>();

  let mut ans = 0;
  for head in 1..10 {
    for end in 1..10 {
      ans += (count(n, head, end)) * count(n, end, head);
    }
  }
  println!("{}", ans);
}

fn to_int(n: &str) -> usize {
  if n.is_empty() {
    0
  } else {
    n.parse::<usize>().unwrap()
  }
}

fn decompose(x: usize) -> (usize, usize, usize) {
  let s = x.to_string();
  let len = s.len();
  let head = to_int(&s[0..1]);
  let end = to_int(&s[(len - 1)..len]);
  let mid = to_int(&s[1..std::cmp::max(len - 1, 1)]);
  (head, mid, end)
}

fn count(x: usize, head: usize, end: usize) -> usize {
  let x_str: String = x.to_string();
  let digit: usize = x_str.len();

  let (xh, xm, xe) = decompose(x);

  let mut res = 0;

  if head == end && head <= x {
    res += 1;
  }

  let ten: usize = 10;

  for d in 2..digit {
    res += ten.pow((d - 2) as u32);
  }

  if digit >= 2 {
    if head < xh {
      res += ten.pow((digit - 2) as u32);
    } else if head == xh {
      if end <= xe {
        res += xm + 1;
      } else {
        res += xm;
      }
    }
  }

  res
}


Measured memory_bytes: 4352
use std::cmp::{max, min};

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let s: Vec<i64> = sc.vec(n);
    let mut head_sum = vec![vec![0]; n + 1];
    let mut tail_sum = vec![vec![0]; n + 1];
    for k in 1..(n + 1) {
        let mut cur = k;
        for i in 0.. {
            if cur >= n {
                break;
            }
            let next_sum = head_sum[k][i] + s[cur];
            head_sum[k].push(next_sum);

            let next_sum = tail_sum[k][i] + s[n - 1 - cur];
            tail_sum[k].push(next_sum);

            cur += k;
        }
    }

    let mut ans = 0;
    for k in 1..(n + 1) {
        for count in 1..head_sum[k].len() {
            let sum = head_sum[k][count] + tail_sum[k][count];
            let head_max = k * count;
            let a = n - 1 - head_max;
            if a <= k {
                continue;
            }
            if head_max >= a && a % k == 0 {
                continue;
            }

            ans = max(ans, sum);
        }
    }

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

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

constexpr auto M = 1000000007L;

int64_t mpow(int64_t x, int64_t y) {
    if (y == 0) {
        return 1;
    }

    if (y == 1) {
        return x;
    }

    auto t = mpow(x, y / 2);

    return t * t % M * mpow(x, y % 2) % M;
}

int main() {
    int64_t k;
    cin >> k;

    string s;
    cin >> s;

    int64_t n = s.size();

    constexpr auto B = 2000001L;

    vector fact(B, 1L), ifact(B, 1L), inv(B, 1L);
    for (auto i : irange(2L, B)) {
        fact[i] = fact[i - 1] * i % M;
        inv[i] = (M - inv[M % i] * (M / i) % M) % M;
        ifact[i] = ifact[i - 1] * inv[i] % M;
    }

    auto combi = [&](int64_t x, int64_t y) {
        return fact[x] * ifact[y] % M * ifact[x - y] % M;
    };

    int64_t ans = 0;
    for (auto i : irange(0L, k + 1)) {
        auto r = k - i;

        ans += mpow(26, i) * mpow(25, r) % M * combi(n + r - 1, r) % M;
        ans %= M;
    }

    cout << ans << endl;
}

Measured memory_bytes: 51164
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    vector<string> a(n);
    rep(i,n) cin>>a[i];
    char tmp=a[0][0];
    map<string,int> mp;
    rep(i,n){
        if(tmp!=a[i][0]||mp[a[i]]!=0){
            cout<<"No"<<endl;
            return 0;
        }
        mp[a[i]]++;
        tmp=a[i][a[i].size()-1];
    }
    cout<<"Yes"<<endl;
}

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

const double PI=3.141592653589793;
const ll MX = 1e18;


int main()
{
  double L;
  cin >> L;
  L /= 3;
  double cube = pow(L, 3.0);
  printf("%.10f\n", cube);

  return 0;
}


Measured memory_bytes: 256
from fractions import gcd
def floor(a, b):
  # return int((a - a%b)/b)
  return a//b
# def gcd(a, b):
#   while a % b != 0:
#       a, b = b, a % b
#   return a
def lcm(a, b):
  return floor((a * b), gcd(a, b))
input = list(map(int, input().split(' ')))
total_count = input[1] + 1 - input[0]
div_c = floor(input[1], input[2]) - floor(input[0] -1, input[2])
div_d = floor(input[1], input[3]) - floor(input[0] -1, input[3])
div_cd = floor(input[1], lcm(input[2], input[3])) - floor(input[0] -1, lcm(input[2], input[3]))
print(total_count - (div_c + div_d - div_cd))

Measured memory_bytes: 5076
#include <stdio.h>
#define MAX (int)1e5+1

int A[MAX];

void swap(int *a, int *b) { int tmp = *a; *a = *b; *b = tmp; }

int partition(int p, int r) {
    int i, j;
    i = p - 1;
    for (j = p; j <= r; j++) {
        if (A[j] <= A[r]) {
            i++;
            swap(&A[i], &A[j]);
        }
    }
    return i;
}

int main() {
    int i, q, n;

    scanf("%d", &n);

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

    q = partition(0, n - 1);

    for (i = 0; i < n; i++) {
        if (i == q) printf("[");
        printf("%d", A[i]);
        if (i == q) printf("]");
        printf( (i == n - 1) ? "\n" : " ");
    }

    return 0;
}

Measured memory_bytes: 2128
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long N=sc.nextInt(),x=1;
		for(int i=1;i<=N;i++){
			x=x*i%1000000007;
		}
		System.out.println(x);
	}
}

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

int main()
{
	int n, k, q;
	cin>>n>>k>>q;
	int suma[n+1];
	memset(suma, 0, sizeof(suma));
	for (int i=0; i<q; i++)
	{
		int aux;
		cin>>aux;
		suma[aux]++;
	}
	for (int i=1; i<=n; i++)
	{
		if (suma[i] + k - q>0)
		{
			cout<<"Yes\n";
		}
		else
		{
			cout<<"No\n";
		}
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define cin_pl(x,y) for(int i=0;i<x;i++){cin>>y[i];}
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int>> matrix;
typedef pair<int,int> pr;
typedef vector<pr> vpt;
typedef greater<int> gi;
 
int main()
{
    int n,k;
    cin>>n>>k;
    vi h(n);
    rep(i,n) cin>>h[i];
    int c=0;
    rep(i,n)
    {
        if(h[i]>=k)
        c++;
    }
    prians(c);
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

int N, X;
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

signed main()
{
	cin>>N>>X;
	vector<int> x(N);
	rep(i,N)cin>>x[i];
	sort(all(x));
	int ans = 0;
	rep(i, N) {
		ans = gcd(ans, abs(x[i] - X));
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 1024