akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class D
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToList();
            A.Insert(0, 0);
            var dp = new long[N + 1];
            dp[1] = 1000;
            for (var i = 2; i <= N; i++)
            {
                dp[i] = dp[i - 1];
                for (var j = 1; j <= i - 1; j++)
                {
                    var stock = dp[j] / A[j];
                    var sum = dp[j] + (A[i] - A[j]) * stock;
                    dp[i] = Math.Max(dp[i], sum);
                }
            }
            var answer = dp[N];
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 28084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
    ll X;
    cin>>X;
    ll Cou=0;
    ll Now=100;
    while(Now<X){
        Cou++;
        Now+=Now/100;
    }
    cout<<Cou<<endl;
}

Measured memory_bytes: 3636
import fractions


def lcm(a, b):
    return (a * b) // fractions.gcd(a, b)


a, b, c, d = map(int, input().split())

a -= 1  # a 以上
x = lcm(c, d)
A = a - (a // c + a // d - a // x)
B = b - (b // c + b // d - b // x)

print(B - A)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    double sum = 0;
    for(int x : a) {
        sum += 1.0 / (double)x;
    }
    cout << setprecision(12) << fixed << 1.0 / sum << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 typedef long long ll;
 
int main() {
string s;
cin>>s;
ll lo = s.size()-1;
ll ans = 0;
ll w = 0;
for(int i = 0; i<lo+1;i++){
if(s[i]=='W'){
ans+=i-w;
w++;
}
}
cout<<ans<<endl;
}

Measured memory_bytes: 640
n = int(input())
s = input() 

alpha2num = lambda c: ord(c) - ord('A') + 1
num2alpha = lambda c: chr(c+64)

x = ''
i = 0

for c in s:
	a = alpha2num(c)
	b = a + n
	if (b > 26):
		b = b - 26
	x = x + num2alpha(b)
	i += 1

print(x)

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

int main() {
 int N = 0;
 cin >> N;

 int d[N];
 int total = 0;

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

 for (int i = 0; i < N-1; i++) {
	for (int j = i+1; j < N; j++) {
		if (i != j) {
			total += d[i] * d[j];
		}
 	}
 }
		
 cout << total << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<int> A(N * N, 0);
    vector<pair<int, int>> X(N);
    rep(i, N) cin >> X[i].first, X[i].first--, X[i].second = i + 1, A[X[i].first] = i + 1;
    sort(all(X));
    int cur = 0;
    rep(i, N){
        int num = X[i].second - 1;
        while(num > 0){
            if(cur >= X[i].first){
                output("No");
                return 0;
            }
            if(A[cur] == 0){
                A[cur] = X[i].second;
                num--;
            }
            cur++;
        }
    }
    
    reverse(all(X));
    cur = N * N - 1;
    rep(i, N){
        int num = N - X[i].second;
        while(num > 0){
            if(cur <= X[i].first){
                output("No");
                return 0;
            }
            if(A[cur] == 0){
                A[cur] = X[i].second;
                num--;
            }
            cur--;
        }
    }
    
    output("Yes");
    voutput(A);
    
    
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <cmath>


int x[110];
int y[110];

int main(void){
    int k,s;
    std::cin >> k >> s;

    int counter = 0;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            if(s - (i + j) <= k && s- (i + j) >= 0){
                counter++;
            }
        }
    }

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


Measured memory_bytes: 256
/*
dp[i]表示从i点出发能到达的最长路

*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 3;
const int inf = 0x3f3f3f3f;
int n, m, ecnt = 0;
int deg[MAXN], fir[MAXN];
int dp[MAXN];
struct EDGE
{
    int v, nxt;
} edge[MAXN];
void addedge(int u, int v)
{
    deg[v]++;
    edge[ecnt].v = v;
    edge[ecnt].nxt = fir[u];
    fir[u] = ecnt++;
}
vector<int> s;
void topo()
{
    queue<int> q;
    while (!q.empty())
        q.pop();
    for (int i = 1; i <= n; i++)
        if (!deg[i])
            q.push(i);
    while (!q.empty())
    {
        int u = q.front();
        q.pop();
        s.push_back(u);
        for (int i = fir[u]; i != -1; i = edge[i].nxt)
        {
            int v = edge[i].v;
            deg[v]--;
            if (!deg[v])
                q.push(v);
        }
    }
}
int main()
{
    scanf("%d%d", &n, &m);
    memset(fir, -1, sizeof(fir));
    s.clear();
    for (int i = 1; i <= m; i++)
    {
        int u, v;
        scanf("%d%d", &u, &v);
        addedge(u, v);
    }
    topo();
    for (int i = s.size()-1; i>=0; i--)//倒着做dp
    {
        int u = s[i];
        for (int j = fir[u]; j != -1; j = edge[j].nxt)
        {
            int v = edge[j].v;
            dp[u] = max(dp[u], dp[v] + 1);
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        ans = max(ans, dp[i]);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2884
N,M = map(int,input().split())
problems =[]

for i in range(0,M):
    a = list(map(int,input().split()))
    problems.append(a)

problems.sort(key=lambda x:x[1])

x = 0
ans = 0

for j in range(0,len(problems)):
    if problems[j][0] <= x:
        continue
    else:
        x = problems[j][1] - 1
        ans += 1

print(ans)



Measured memory_bytes: 29072
#include <stdio.h>

void trace(int A[],int N){
  int i;
  for (i=0;i<N;i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}

void insertionSort(int A[],int N){
  int j,i,v;

  for(i=1;i<N;i++){
    v = A[i];
    j = i-1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    trace(A,N);
  }
}

int main(){
  int N,i,j;
  int A[100];

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

  trace(A,N);
  insertionSort(A,N);

  return 0;
}
    



Measured memory_bytes: 2040
n = int(input())
a = input()
b = input()
c = input()
ans = 0
for i in range(n):
    
    if a[i] == b[i] == c[i]:
        ans += 0
    elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        ans += 1
    else:
        ans += 2
print(ans)


Measured memory_bytes: 3060
n=int(input())
inf=float("inf")
table=[[inf]*n for i in range(n)]
for i in range(n):
  s=input()
  for j in range(n):
    if s[j]=="1":
      table[i][j]=1
    
def warshall_floyd(d):
  for k in range(n):
    for i in range(n):
      for j in range(n):
        if d[i][k]!=inf and d[k][j]!=inf:
          d[i][j]=min(d[i][j],d[i][k]+d[k][j])
          if d[i][j]<float("inf") and d[i][j]%2!=(d[i][k]+d[k][j])%2:
            return False
  return d

d=warshall_floyd(table)

if not d:
  print(-1)
else:
  ans=0
  for i in range(n):
    for j in range(i+1,n):
      ans=max(ans,d[i][j]+1)
  
  print(ans)

Measured memory_bytes: 118620
//
//  main.cpp
//  ITP1_7-A
//
//  Created by Saicj on 2015/07/14.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
#include <stdio.h>
using namespace std;

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

    //m???f???r
    int m,f,r;
    
    while (true) {
        
        cin >> m >> f >> r;
        
        if (m == -1 && f == -1 && r == -1){
            break;
        }
        
        if (m == -1 || f == -1){
            printf("F");
             printf("\n");
            continue;
        }
        
        if (m + f >= 80) {
            printf("A");
        }else if(m + f < 80 && m + f >= 65) {
            printf("B");
            
        }else if (m + f < 65 && m + f >= 50) {
            printf("C");
        }else if (m + f < 50 && m + f >= 30) {
            
            if(r >= 50){
                printf("C");
            }else{
                printf("D");
            }
        }else if (m + f < 30 ){
            printf("F");
        }
        
        printf("\n");
    }
    

    
    return 0;
}

Measured memory_bytes: 1112
import itertools

N=int(input())
P=[int(i) for i in input().split()]
Q=[int(i) for i in input().split()]

# print(P,Q)
perm = list(itertools.permutations(range(1,N+1)))
# print(perm)
a=perm.index(tuple(P))+1
# print(perm.index(tuple(P)))
b=perm.index(tuple(Q))+1
print(abs(a-b))


Measured memory_bytes: 8052
import math
from math import ceil
from math import factorial
from collections import Counter
from operator import itemgetter

def gcd(a,b):
	if(b==0):
		return a
	return gcd(b,a%b)
import bisect
ii = lambda: int(input())
iia = lambda: list(map(int,input().split()))
isa = lambda: list(input().split())

a,b = iia()

print(int((a*b)/gcd(a,b)))

Measured memory_bytes: 3444
s = gets.strip.split('')
t = gets.strip.split('')

min = 9999
0.upto(s.size-t.size) do |i|
  part = s[i...i+t.size]
  count = 0
  part.zip(t) do |a,b|
    if a != b
      count += 1
    end
  end
  min = count if count < min
end

puts min



Measured memory_bytes: 14360
#include <iostream>

using namespace std;

int N;
int C[200006];

int previ[200006];
int last[200006];

long long int MOD = 1000000007;

long long int dp[200006];

int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> C[i];
	}


	for (int i = 1; i <= N; i++) {

		previ[i] = last[C[i]];

		last[C[i]] = i;
	}


	/*for (int i = 1; i <= N; i++) {
		cout << "previ[" << i << "]= " << previ[i] << endl;
	}*/

	dp[0] = 1;

	for (int i = 1; i <= N; i++) {
		dp[i] = dp[i - 1];

		if ((previ[i] >= 1) && (previ[i]<i-1)) {
			dp[i] += dp[previ[i]];
		}
		dp[i] %= MOD;
	}

	/*for (int i = 1; i <= N; i++) {
		cout << "dp[" << i << "]= " << dp[i] << endl;
	}*/


	cout << dp[N] << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 4096
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll a, b;
  cin >> a >> b;
  cout << a*b << " " << (a+b)*2 << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 A,B;
i64 Q;

vector<i64> s,t;
const i64 INF = 1e15;

int main() {
  cin >> A >> B >> Q;
  s.resize(A + 2);
  t.resize(B + 2);
  s[0] = -INF;
  t[0] = -INF;
  rep(i,1,A) cin >> s[i];
  rep(i,1,B) cin >> t[i];
  s[A + 1] = INF;
  t[B + 1] = INF;
  vector<i64> ans;
  rep(i,0,Q - 1) {
    i64 x;
    cin >> x;
    i64 ai = lower_bound(all(s), x) - begin(s);
    i64 bi = lower_bound(all(t), x) - begin(t);
    ans.push_back( min({
        x - min(s[ai - 1], t[bi - 1]),
        max(s[ai], t[bi]) - x,
        2 * (x - t[bi - 1]) + s[ai] - x,
        2 * (s[ai] - x) + x - t[bi - 1],
        2 * (x - s[ai - 1]) + t[bi] - x,
        2 * (t[bi] - x) + x - s[ai - 1],
        }) );
  }

  for(auto const& x: ans) {
    cout << x << endl;
  }
}


Measured memory_bytes: 3828
#include<cstdio>
#include<cstdlib>
using namespace std;
const int maxn=1010;
const int maxv=5010;
const int INF=1e9;
void chkmin(int &x,int y){
	x=x<y?x:y;
}
void chkmax(int &x,int y){
	x=x>y?x:y;
}
int f[maxn];
int beg[maxn],nex[maxn<<1],tto[maxn<<1],e;
void putin(int s,int t){
	tto[++e]=t;
	nex[e]=beg[s];
	beg[s]=e;
}
int a[maxn],dp[maxn];
int b[maxv],c[maxv];
void dfs(int u){
	for(int i=beg[u];i;i=nex[i])
		dfs(tto[i]);
	for(int i=1;i<=a[u];i++)
		b[i]=INF;
	b[0]=0;
	for(int i=beg[u];i;i=nex[i]){
		for(int j=a[u];j>=0;j--){
			c[j]=INF;
			if(j>=dp[tto[i]])
				chkmin(c[j],b[j-dp[tto[i]]]+a[tto[i]]);
			if(j>=a[tto[i]])
				chkmin(c[j],b[j-a[tto[i]]]+dp[tto[i]]);
		}
		for(int j=0;j<=a[u];j++)
			b[j]=c[j];
	}
	dp[u]=INF;
	for(int i=0;i<=a[u];i++)
		chkmin(dp[u],b[i]);
	if(dp[u]==INF){
		printf("IMPOSSIBLE\n");
		exit(0);
	}
}
int main(){
//	freopen("E.in","r",stdin);
//	freopen("E.out","w",stdout);
	int n;
	scanf("%d",&n);
	for(int i=2;i<=n;i++){
		scanf("%d",&f[i]);
		putin(f[i],i);
	}
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	dfs(1);
	printf("POSSIBLE\n");
	return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left
N, M = [int(x) for x in input().split()]
PY_list = [[int(x)-1 for x in input().split()] for _ in range(M)]
lst = [[] for _ in range(N)] 
for P, Y in PY_list:
    lst[P].append(Y)
for l in lst:
    l.sort()
for p, y in PY_list:
    print('{:06}{:06}'.format(p+1, bisect_left(lst[p], y)+1))


Measured memory_bytes: 77656
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#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(){
    int n,cnt=1;
    cin >> n;
    map<int,int> m;
    m[n]++;
    while(1){
        if(n%2==0)
            n/=2;
        else
            n=3*n+1;
        m[n]++;
        cnt++;
        if(m[n]==2){
            cout << cnt << endl;
            break;
        }

    }

    return 0;
}

Measured memory_bytes: 256
function main(input) {
  input = input.split('\n');
  let AC = 0;
  let WA = 0;
  let TLE = 0;
  let RE = 0;
  for (let i = 1;i <= input[0];i++) {
    switch (input[i]) {
      case 'AC':
        AC++;
        break;
      case 'WA':
        WA++;
        break;
      case 'TLE':
        TLE++;
        break;
      case 'RE':
        RE++;
        break;
     }
  }
  console.log('AC x ' + AC);
  console.log('WA x ' + WA);
  console.log('TLE x ' + TLE);
  console.log('RE x ' + RE);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 37272
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  int n; cin >> n;
  vector<int> h(n);
  int hm = 0, cnt=0;
  rep(i,n){
    cin>>h[i];
    if(h[i]>=hm){cnt++;}
    hm = max(hm,h[i]);
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#include <ctype.h>
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, char> pic;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

ll bit[200010];
int max_n = 200000;
int pm = 0;
void add(int x) {

	while (max_n >= x)
	{
		bit[x]++;
		x += x & -x;
	}
}
void sub(int x) {
	while (max_n >= x)
	{
		bit[x]--;
		x += x & -x;
	}
}
int merge(int *a, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> L(n1 + 1);
	vector<int> R(n2 + 1);
	for (size_t i = 0; i < n1; i++)
	{
		L[i] = a[left + i];
	}
	for (size_t i = 0; i < n2; i++)
	{
		R[i] = a[mid + i];
	}

	L[n1] = INF;
	R[n2] = INF;
	int i = 0;
	int j = 0;
	for (size_t k = left; k < right; k++)
	{
		if (L[i] <= R[j]) {
			a[k] = L[i];
			i++;

		}
		else {
			a[k] = R[j];
			j++;
		}
	}
	return i + j;
}
ll mergeSort(int *a, int left, int right) {
	int res = 0;
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		res = mergeSort(a, left, mid);
		res += mergeSort(a, mid, right);
		res += merge(a, left, mid, right);
	}
	return res;
}

void solv() {
	
	int n;
	cin >> n;

	int a[500050];
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int res = mergeSort(a, 0, n);
	for (size_t i = 0; i < n; i++)
	{
		if (i > 0) cout << " ";
		cout << a[i];
	}
	cout << endl  << res << endl;
}
int main() {
	//	COMinit();
	solv();
	return 0;
}



Measured memory_bytes: 6860
n,k=map(int,input().split())
l=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
for i in range(1,n):
    s=min(k,i)+1
    ans=dp[i-1]+abs(l[i]-l[i-1])
    for j in range(2,s):
        ans=min(ans,dp[i-j]+abs(l[i]-l[i-j]))
    dp[i]=ans
print(dp[n-1])

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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long  ll;
#define endl '\n'


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


const int MOD = 1000000007;

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


long long n;
void Input() {

    cin >> n;
}

void Solve() {

    long long ans = LLONG_MAX;
    long long lim = sqrt(n);
    for(int i = 1; i <= lim + 1; i++ ) {

        if(n % i == 0) {

            ans = min(ans, i + (n / i));
        }
    }

    cout << ans - 2 << endl;
}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();
  return 0;

}



Measured memory_bytes: 256
n, x, y = map(int, input().split())
x -= 1
y -= 1
ans = [0] * n

for s in range(n):
    for t in range(s, n):
        u = min((t-s), abs(x-s) + 1 + abs(y-t), abs(x-t) + 1 + abs(y-s))
        ans[u] += 1

for _ in ans[1:]:
    print(_)

Measured memory_bytes: 3444
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
using namespace std;
typedef pair<long long,long long>p;
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
vector<long long> divisor(long long n) {
	vector< long long> ret;
	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return (ret);
}
long long mod = 1e9 + 7;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout <<fixed<< setprecision(16);
	int n, k;
	cin >> n >> k;
	vector<int>num;
	num.push_back(k);
	int siz = 0;
	while (num[siz] != 1) {
		num.push_back(num[siz] / 2 + (num[siz] % 2));
		siz += 1;
	}
	siz += 1;
	double ans = 0;
	int now = n+1;
	double ruijou[100005];
	ruijou[0] = 1;
	for (int i = 1; i <= 10000; i++) {
		ruijou[i] = ruijou[i - 1] / 2;
	}
	for (int i = 0; i < siz; i++) {
		if (now > num[i]) { 
			ans += ruijou[i]*(now - num[i])*(double)1 / n; 
		now = num[i];
		}
	}
	cout << ans;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){  
  ll n; cin >> n;
  vector<ll> v(n); cin >> v;
  reverse(v.begin(),v.end());
  ll l = 2, u = 2;
  for(ll e:v){
    l = (l+e-1)/e*e;
    u = u/e*e+e-1;
    if(l > u)break;
  }
  if(l > u)cout << -1 << endl;
  else cout << l << ' ' << u << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int, int> P;

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


int main() {
	string s;
	int N;
	cin >> N;
	cin >> s;
	int l = s.length();
	int c = 0;
	string str = s;
	REP(i, l) {
		if (s[i] == '(') {
			c++;
		}
		if (s[i] == ')') {
			c--;
		}
		if (c == -1) {
			str = '(' + str;
			c++;
		}
	}
	REP(i, c) {
		str = str + ')';
	}
	cout << str << endl;
}


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

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

const double PI = acos(-1);
#define MOD 1000000007  ///1e9+7

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '

#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///******************************** C o d e ********************************///



main()
{
    ll a,b;
    cin>>a>>b;
    cout<<a*b el;
    
}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int X = cin.nextint;
        int A = cin.nextint;
        int B = cin.nextint;
        WriteLine((X - A) % B);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11220
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int n, x, y;
int ans[2345];
signed main() {
	cin >> n >> x >> y;
	for1(i, n)for1(j, n) {
		if (i >= j)continue;
		ans[min(j - i, abs(i - x) + 1 + abs(j - y))]++;
	}
	for1(i, n - 1)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 Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            string[]s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);int b = int.Parse(s[1]);

            if(a==1){
                a += 13;
            }
            if(b==1){
                b += 13;
            }
            string ans = "";
            if(a>b){
                ans = "Alice";
            }else if(a<b){
                ans = "Bob";
            }else{
                ans = "Draw";
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <stdlib.h>
#define LEN (1e5+5)

int main()
{
  char ch; int c0 = 0, c1 = 0;
  while( (ch = fgetc(stdin)) != EOF ) {
    if(ch == '0') 		{ c0 += 1; }
    else if(ch == '1') 	{ c1 += 1; }
  }
  //printf("c0: %d c1: %d\n", c0, c1);
  printf("%d\n", 2 * ( (c0 < c1) ? c0 : c1 ) );
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

string v;
int n;
vector <int> rightswaps;
long long fact[200001];
long long invfact[200001];

long long fe(long long b, long long e) {
	long long a = 1;
	while (e != 0) {
		if (e % 2) {
			a *= b;
			a %= MOD;
		} 
		b *= b;
		b %= MOD;
		e >>= 1;
	}
	return a;
}

long long nPk(int n, int k) {
	if (n < k)
		return 0;
	return fact[n] * invfact[n - k] % MOD;
}

int main() {
	cin >> n >> v;
	fact[0] = 1;
	invfact[0] = 1;
	for (int i = 1; i <= 200000; i++) {
		fact[i] = i * fact[i - 1] % MOD;
		invfact[i] = fe(fact[i], MOD - 2);
	}
	bool flipped = false;
	for (int i = 2 * n - 1; i >= 0; i--) {
		if (v[i] == 'W' && flipped) {
			rightswaps.push_back(i);
		} else if (v[i] == 'B' && !flipped) {
			rightswaps.push_back(i);
		}
		flipped = !flipped;
	}
	/*for (int i = 0; i < rightswaps.size(); i++)
		cout << rightswaps[i] << ' ';
	cout << endl;*/
	if (rightswaps.size() != n || rightswaps.back() == 0)
		cout << 0 << '\n';
	else {
		sort(rightswaps.begin(), rightswaps.end());
		long long ans = 1;
		long long cnt = 0;
		for (int i = n - 1; i >= 1; i--) {
			cnt++;
			ans *= nPk(cnt, rightswaps[i] - rightswaps[i - 1] - 1);
			ans %= MOD;	
			cnt -= (rightswaps[i] - rightswaps[i - 1] - 1);
		}
		ans *= nPk(cnt + 1, rightswaps[0]);
		ans %= MOD;
		ans *= fact[n];
		ans %= MOD;
		cout << ans << '\n';
	}
}

Measured memory_bytes: 4732
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define for0(i,n) for (int i=0; i<n; i++)
#define forr(i,n) for (int i=n-1; i>=0; i--)
#define fori(i,a,b) for (int i=a; i<=b; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define vec(x) vector< x >
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define sqr(x) 1LL*(x)*(x)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define read(x) int x; scanf("%d",&x);
#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define debug
#endif

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

ll mat[505][505];

int main()
{
    #ifdef DEBUG
    freopen("C.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    ll H,W,h,w;
    cin >> H >> W >> h >> w;
    for0(i,H) {
        for0(j,W) {
            mat[i][j] = 1;
        }
    }

    ll max_neg = 1000000000;
    ll max_pos = max_neg - h*w + 1;
    for (int i=0; i<H; i+=h) {
        for (int j=0; j<W; j+=w) {
            mat[i][j] = max_pos;
        }
    }
    for (int i=h-1; i<H; i+=h) {
        for (int j=w-1; j<W; j+=w) {
            mat[i][j] = -max_neg;
        }
    }

    ll sum = 0;
    for0(i,H) {
        for0(j,W) {
            sum += (ll)mat[i][j];
        }
    }
    if (sum > 0) {
        cout<<"Yes"<<endl;
        for0(i,H) {
            for0(j,W){
                printf("%lld ",mat[i][j]);
            }
            printf("\n");
        }
    }
    else {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 4864
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define rsz resize()
#define lb lower_bound
#define ub upper_bound
#define br cout << endl

typedef long long ll;
typedef long double f80;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); } 
int bit(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bit(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }

template<typename T>
void leftShift(vector<T> &v, ll k) { k %= sz(v); if(k < 0) k += sz(v); rotate(v.begin(), v.begin() + k, v.end()); }
template<typename T>
void rightSift(vector<T> &v, ll k) { leftShift(v, sz(v) - k); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

inline int nxt() {
	int x;
	cin >> x;
	return x;
}

inline int nxtll() {
	ll x;
	cin >> x;
	return x;
}

void pr() {}
void sc() {}

template <typename Head, typename... Tail>
void pr(Head H, Tail... T) { cout << H << " "; pr(T...); }

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#ifndef LOCAL
string to_string(__int128 x) {
	string s = "";
	bool neg = 0;
	if(x < 0) { s += "-"; neg = 1; }
	if(!x) s += '0';
	while(x) {
		int rem = x % 10;
		s += to_string(rem);
		x /= 10;
	}
	reverse(s.begin() + neg, s.end());
	return s;
}
#endif

const int mod = 1e9 + 7; // 998244353;

int pwr(int a,int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
*/

const int N = 2005;
pii a[N];
ll dp[N][N];

void solve() {
	int n = nxt();
	fr(i, 1, n) {
		a[i].fi = nxt();
		a[i].se = i;
	}
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	dp[0][0] = 0;
	fr(i, 0, n - 1) {
		fr(j, 0, i) {
			int idx = a[i + 1].se;
			int i1 = j + 1;
			int i2 = n - (i - j);
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + abs(idx - i1) * 1LL * a[i + 1].fi);
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + abs(idx - i2) * 1LL * a[i + 1].fi);
		}
	}
	ll ans = 0;
	fr(i, 0, n) {
		ans = max(ans, dp[n][i]);
	}
	cout << ans;
}

signed main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	// cin >> t;
	t = 1;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  
  for(int i=0; i < n; i ++){
    cin >> a.at(i);
  }
  
  int score=0;
  
  for(int i = 0; i < n; i++){
    int b;
    cin >> b;
    score += b;
  }
  
  map<int, int> bonus;
  
  for(int i=0; i < n-1; i ++){
    int c;
    cin >> c;
    bonus[i+1] = c;
  }
  
  for(int i=0; i < n-1; i ++){
    if(a.at(i)+1 == a.at(i+1)){
      score += bonus.at(a.at(i));
    }
  }
  
  cout << score << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll n;
    cin >>n;
    
    ll r = 0;
    ll d = -1;
    vll a(n), b(n), c(n);
    rep(i, n) cin >>a[i];
    rep(i, n) cin >>b[i];
    rep(i, n) cin >>c[i];

    rep(i, n) {
        if (d == a[i]-1) r += c[a[i]-2];
        r += b[a[i]-1];
        d = a[i];
    }
    
    mes(r);
    
    
    
    
    

}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	int n, k;
	cin >> n >> k;
	map<int, int> mp;
	rep (i, k) {
		int d;
		cin >> d;
		rep (j, d) {
			int a;
			cin >> a;
			mp[a]++;
		}
	}

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (mp[i] == 0) ans++;
	}

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

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <bitset>
#include <cmath>
#include <map>
#include <deque>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=1;i<=n;i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int INF = 1e9;

int n;
int lds(vector<int> a){
    int n=a.size();
    deque<int> d;
    rep(i,n){
        int p=lower_bound(d.begin(), d.end(), a[i])-d.begin();
        if(p==0) d.push_front(a[i]);
        else d[p-1]=a[i];
    }
    return d.size();
}
int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    cout <<  lds(a);
}





Measured memory_bytes: 1408
using System;
delegate bool fanction(long x);
class MyData
{
    long n;
    long a, b;
    long[] h;
    public MyData(long _n, long _a, long _b, long[] _h) { n = _n; h = new long[n]; a = _a - _b; b = _b; for (int i = 0; i < n; i++) h[i] = _h[i]; }
    public bool check(long t)
    {
        long a_t = t;
	    for(int i=0;i<n;i++){
		    if (h[i] - (b*t) > 0) {
                long temp = (h[i] - b * t) / a;
			    if (((h[i] - b*t) % a) > 0) temp++;
			    a_t -= temp;
			    if (a_t < 0) return false;
		    }
	    }return true;
    }
}
class MyMain
{
    static void Main()
    {
        string[] s = System.Console.ReadLine().Trim().Split(' ');
        long n = long.Parse(s[0]), a = long.Parse(s[1]), b = long.Parse(s[2]);
        long[] ld = new long[n];
        for (int i = 0; i < n; i++) ld[i] = int.Parse(System.Console.ReadLine().Trim());
        
        long res = 0;
        binarySearch(0, 1000000000, new MyData(n, a, b, ld).check, ref res);
        System.Console.WriteLine(res);
        System.Console.ReadLine();
    }
    static void binarySearch(long l, long r,fanction f,ref long res)
    {
        if (l > r) return;
        long mid = (l + r) / 2;
        if(f(mid)){res = mid;binarySearch(l, mid - 1, f, ref res);}
        else binarySearch(mid + 1, r,f,ref res);
    }
}

Measured memory_bytes: 17312
#include<stdio.h>

int main(){
    int m,f,r;
    while (1)
    {
        scanf("%d",&m);
        scanf("%d",&f);
        scanf("%d",&r);
        if(m ==  -1 && f == -1 && r == -1)break;

        if(f == -1 || m == -1)printf("F\n");
       else if((m + f)>=80)printf("A\n");
       else if((m+f)>=65 && (m+f)<80)printf("B\n");
       else if((m+f)>=50 && (m+f)<65 || r >= 50)printf("C\n");
       else if((m+f)>=30 && (m+f)<50)printf("D\n");
       else if((m+f)<30)printf("F\n");
       

    }
    
    return 0 ;
}


Measured memory_bytes: 2032
#include "bits/stdc++.h"
using namespace std;

//47
typedef long long ll;

int main() {
	int n;
	cin >> n;
	//vector<string> v(n);
	map<string,int> m;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		sort(s.begin(),s.end());
		m[s]++;
	}
	//sort(v.begin(),v.end());
	//int ans = 0;
	//map<string,int> m;
	//for (int i = 0; i < n; ++i) {
		//m[v[i]]++;
	//}
	ll ans = 0;
	for (auto it = m.begin(); it != m.end(); ++it) {
		if (it->second > 1) {
			ans += 1LL * ((it->second *1LL * (it->second - 1)) / 2);
		}
	}
	cout << ans;
}


Measured memory_bytes: 11404
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

#define FAST_IO                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);

using namespace std;

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

const int MOD = 1000000007;


void add_self(int& a, int b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}

void sub_self(int& a, int b) {
	a -= b;
	if (a < 0) {
		a += MOD;
	}
}


int main() {

	// fast input/output
	FAST_IO;

	int n, W;
	cin >> n >> W;
	vector<ll> dp(W + 1); // 0....W
	// dp[i] means the maximum total value of items with total weight exactly i
	for (int item = 0; item < n; ++item) {
		int weight, value;
		cin >> weight >> value;
		for (int used = W - weight; used >= 0; --used)
			dp[used + weight] = max(dp[used + weight], ll(dp[used] + value));
	}
	ll ans = 0;
	for (int i = 0 ; i <= W; ++i) {
		ans = max(ans, dp[i]);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>

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

using namespace std;

typedef long long ll;

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

int main() {
	int a, b, ans;
	cin >> a >> b;
	if (a == 0) {
		if (b != 100) { ans = b; }
		else { ans = 101; }
	}
	else if (a == 1) {
		if (b != 100) { ans = 100 * b; }
		else { ans = 10100; }
	}
	else {
		if (b != 100) { ans = 10000 * b; }
		else { ans = 1010000; }
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict

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

bars = defaultdict(int)
for a in A:
    bars[a] += 1

sides = list(bars.keys())
sides.sort(reverse=True)
ans = 0
rect = []
for side in sides:
    if bars[side] >= 4:
        if rect == []:
            ans = side * side
        else:
            ans = rect[0] * side
        break
    elif bars[side] >= 2:
        rect.append(side)
        if len(rect) == 2:
            ans = rect[0] * rect[1]
            break
print(ans)


Measured memory_bytes: 18600
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, R = MAP()
if N < 10:
    print(100 * (10 - N) + R)
else:
    print(R)

Measured memory_bytes: 5148
#include<iostream>
#include<cmath>
using namespace std;
struct point{
    int x;
    int y;
    int h;
};
int main(){
    int N;
    cin>>N;
    point *points=new point[N];
    for(int i=0;i<N;i++){
        cin>>points[i].x>>points[i].y>>points[i].h;
    }
    int H;
    int m,n;
    for(int i=0;i<=100;i++){
        int find=1;
        for(int j=0;j<=100;j++){
            find=1;
            for(int k=0;k<N;k++){
                if(!points[k].h)
                    continue;
                H=abs(i-points[k].x)+abs(j-points[k].y)+points[k].h;//找到第一个h非0点
            }
            for(int l=0;l<N;l++){
                if(points[l].h!=max(H-abs(i-points[l].x)-abs(j-points[l].y),0)){
                    find=0;
                    break;
                }
            }
            if(find){
                cout<<i<<" "<<j<<" "<<H;
                break;
            }
        }
        if(find)
            break;
    }
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x,y,max;
    max = 0;
    cin >> x >> y;
    int a = x%y;
    int b = y%x;
    if ( x>y ) {
        for (int i=a;i>0;i--) {
            if ( (a%i==0) && (y%i==0) && (max<i) ) {
                    max = i;
            }
        }
        cout << max << endl;
    }
    if ( y>x ) {
        for (int j=b;j>0;j--) {
            if ( (b%j==0) && (x%j==0) && (max<j) ) {
                    max = j;
            }
        }
        cout << max << endl;
    }
    if ( x==y ) {
        cout << x << endl;
    }
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main(){
    double limit;
    long m,i,n,j,flag=1,sum=0;
    cin>>n>>m;
    vector<int> a(n);
    for(i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    limit=double(sum)/4/m;
    for(i=0;i<m;i++){
        if(a[i]<limit){
            flag=0;
        }
    
    }
    if(flag)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
    
}

Measured memory_bytes: 256