akhauriyash/Code-Regression huggingface dataset:
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

if max(a) < 0:
    a.sort()
    ans = 1
    if k % 2 == 0:
        for e in a[:k]:
            ans *= e
            ans %= mod
    else:
        for e in a[-k:]:
            ans *= e
            ans %= mod

    print(ans)

elif k == n:
    ans = 1
    for e in a:
        ans *= e
        ans %= mod

    print(ans)

else:
    neg = []
    pos = []
    for e in a:
        if e < 0:
            neg.append(e)
        else:
            pos.append(e)

    neg.sort()
    pos.sort(reverse=True)

    ans = 1
    if k % 2:
        ans *= pos.pop(0)
        k -= 1

    nums = [e1 * e2 for e1, e2 in zip(neg[::2], neg[1::2])]
    nums += [e1 * e2 for e1, e2 in zip(pos[::2], pos[1::2])]

    nums.sort(reverse=True)
    for e in nums[:k//2]:
        ans *= e
        ans %= mod

    print(ans)


Measured memory_bytes: 33352
#include<iostream>
#include<bits/stdc++.h>
#include <stdio.h>
#include<unordered_map>
#define Amr_Abdelazim ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define vll vector<ll>
#define vvll vector<vector<ll> >
#define vpll vector<pair<ll,ll> >
#define P complex<ld>
#define X real()
#define Y imag()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define rep(i,n)   for(int i=0;i<n;i++)
#define repp(i,s,n)   for(int i=s;i<=n;i++)
#define print(v) {for(auto i:v)cout<<i<<" ";cout<<"\n";}
#define mkp make_pair
#define clr(ar,v) memset(ar,v,sizeof(ar));
#define TC ll amr_abdelazim;cin>>amr_abdelazim;while(amr_abdelazim--)
#define popcnt(x) __builtin_popcount(x)
#define EPS 1e-9
#define INF 1000000000000000009
#define heeer cout<<"heeeeeeeeer\n";
using namespace std;
//freopen("output.txt", "w", stdout);
//freopen("input.txt", "r", stdin);
const int mod = 1000000007;
const double pi = acos(-1);
class cmp{
public:
	bool operator() (ll &A, ll &B){
		return A > B;
	}
};
bool by_sec(const pll &a, const pll &b){
	if ((abs(a.first) == abs(b.first)))
		return (abs(a.second) < abs(b.second));
	return (abs(a.first) < abs(b.first));
}
bool byth(const tuple<ll, ll, ld>& a, const tuple<ll, ll, ld>& b){
	return (get<2>(a) < get<2>(b));
}
ld dist(P a, P b){
	return (ld)abs(a - b);
}
ll fact[1000009], inv[1000009];
ll fp(ll a, ll b){
	if (b == 0)
		return 1;
	ll ans = fp(a, b / 2);
	ans = (ans * ans)%mod;
	if (b % 2 != 0)
		ans = (ans * (a%mod))%mod;
	return ans;
}
void FacInv(ll n){
	fact[0] = inv[0] = 1;
	for (ll i = 1; i <= n; i++)
	{
		fact[i] = ((i%mod) * fact[i - 1] % mod) % mod;
		inv[i] = fp(fact[i], mod - 2);
	}
}
ll ncr(ll n, ll r){
	return (((fact[n] * inv[r]) % mod) * inv[n - r]) % mod;
}
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a%b);
}
ll max(ll a, ll b){
	if (a >= b)return a;
	else return b;
}
ll min(ll a, ll b){
	if (a <= b)return a;
	else return b;
}
const int N = 2 * 1000000 + 9;
ll a[500][500];
int main()
{
	Amr_Abdelazim

		ll x, y;
	cin >> x >> y;
	ll n;
	cin >> n;
	vll v(n);
	rep(i, n)cin >> v[i];
	ll d = 0;
	bool bb = 1;
	rep(i, x){
		if (bb){
			rep(j, y){
				while (d < n&&v[d] == 0)d++;
				if (d >= n)goto addd;
				a[i][j] = d + 1;
				v[d]--;
			}
		}
		else{
			for (int j = y - 1; j >= 0; j--){
				while (d < n&&v[d] == 0)d++;
				if (d >= n)goto addd;
				a[i][j] = d + 1;
				v[d]--;
			}
		}
		bb = !bb;
	}
addd:
	rep(i, x)rep(j, y)if (a[i][j] == -1)a[i][j] = a[i][j - 1];	
	rep(i, x)rep(j, y)if (a[j][i] == -1)a[j][i] = a[j][i - 1];
	rep(i, x){
		rep(j, y)cout << a[i][j] << " ";
		cout << "\n";
	}
		
	
	return 0;
}


Measured memory_bytes: 4052
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
	while(getline(cin,s)){
		int n=s.size();
		for(int k=0;k<26;k++){
			for(int i=0;i<n;i++)if('a'<=s[i]&&s[i]<='z')s[i]='z'<(s[i]+1)?'a':(s[i]+1);
			if(s.find("the")!=string::npos||s.find("this")!=string::npos||s.find("that")!=string::npos)break;
		}
		cout<<s<<endl;
	}
    return 0;
}

Measured memory_bytes: 1176
#include<stdio.h>
int main()
{
    int a,b,c,x,y,z;
    scanf("%d%d%d",&a,&b,&c);
    x=a+b;
    y=a+c;
    z=b+c;
    if(x<=y&&x<=z)
    {
        printf("%d",x);
    }
    else if(y<=x&&y<=z)
    {
        printf("%d",y);
    }
    else
    {
        printf("%d",z);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	int a[5],k;
	bool is = true;
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
	for (int i = 0; i < 4; i++)
	{
		for (int j = i + 1; j < 5; j++)
		{
			if (a[j] - a[i] > k)
			{
				is = false;
			}
		}
	}
	if (is)
	{
		cout << "Yay!";
	}
	else
	{
		cout << ":(";
	}
	return 0;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long n, m;
    scan(n, m);
    auto b = new bool[](n);
    long L = 1;
    long R = n;
    foreach (_; 0 .. m)
    {
        long l, r;
        scan(l, r);
        L = max(l, L);
        R = min(r, R);
    }
    max(R - L + 1, 0).writeln();
}


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

namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {
            bool[] a=new bool[31];
            for (int i = 0; i < 31; i++) a[i] = false;

            for(int i = 0; i < 28; i++) a[int.Parse(Console.ReadLine())]=true;

            for(int i = 1; i < 31; i++)
            {
                if (!a[i]) Console.WriteLine(i);
            }
        }
    }
}

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

int main() {
  int N, X, fn = 0;
  cin >> N;
  X = N;
  
  for (int i = 0; i < 9; i++) {
    
    if (N == 0) 
      break;
    
    fn += N % 10;
    N = N / 10;
  }
  
  if (X % fn == 0)
    cout << "Yes";
  else
    cout << "No";
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

#define MAX_NUM (1000000007)
#define PI 3.14159265358979323846

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T>& A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first > b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

i64 modinv(i64 a, i64 m) {
  i64 b = m, u = 1, v = 0;
  while (b) {
    i64 t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

i64 My_Comb(u64 n, u64 k, i64 m) {
  if (n < k) return 0;
  if (k == 0 || n == k) return 1;
  u64 res = 1;
  k = (n / 2 < k) ? n - k : k;
  for (u64 i = 1; i <= k; ++i)
    res = (((res * (n + 1 - i)) % m) * modinv(i, m)) % m;
  return res;
}

i64 My_Pow(u64 a, u64 n, i64 m) {
  u64 tmp = n, calc = 1;
  while (tmp > 0) {
    if (tmp % 2) {
      tmp--;
      calc *= a;
      calc %= m;
    } else {
      a *= a;
      a %= m;
      tmp /= 2;
    }
  }
  return calc;
}

class UnionFind {
 public:
  vector<u64> Par;
  vector<u64> sz;

  UnionFind(u64 n);
  u64 root(u64 x);
  bool same(u64 x, u64 y);
  void unite(u64 x, u64 y);
  u64 size(u64 x);
};

UnionFind::UnionFind(u64 n) {
  Par.resize(n);
  sz.assign(n, 1);
  for (u64 i = 0; i < n; ++i) Par[i] = i;
}

u64 UnionFind::root(u64 x) {
  if (Par[x] == x) {
    return x;
  } else {
    return Par[x] = root(Par[x]);
  }
}

bool UnionFind::same(u64 x, u64 y) { return root(x) == root(y); }

u64 UnionFind::size(u64 x) { return sz[root(x)]; }

void UnionFind::unite(u64 x, u64 y) {
  x = root(x);
  y = root(y);
  if (x == y) return;
  if (sz[x] < sz[y]) swap(x, y);
  sz[x] += sz[y];
  Par[y] = x;
}

template <typename T>
i64 BinSearch(vector<T>& V, i64 comp) {
  i64 l = 0, r = V.size() - 1;
  if (V[l] > V[r]) swap(l, r);
  if (V[l] >= comp) return l;
  if (V[r] <= comp) return r;
  while (abs(r - l) > 1) {
    i64 index = (l + r) / 2;
    if (V[index] == comp)
      return index;
    else if (V[index] > comp)
      r = index;
    else
      l = index;
  }
  if (abs(V[l] - comp) < abs(V[r] - comp))
    return l;
  else
    return r;
}

int main() {
  cout << setprecision(18);

  for (u32 i = 0; i < 5; ++i) {
    u32 x;
    cin >> x;
    if (x == 0) {
      cout << i + 1 << endl;
      return 0;
        }
  }

  return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  
  map<int ,int> mp;
  
  for (int i=1; i<=m; i++) mp[i]=0;
  for (int i=0; i<n; i++) {
    int ki;
    cin >> ki;
    
    for (int j=0; j<ki; j++){
      int tmp;
      cin >> tmp;
      mp[tmp]++;
    }
  }
  int ans = 0;
  for (int i=1; i<=m; i++) if (mp[i] == n) ans++;
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a>b)
        cout<<"a > b"<<endl;
        else if(a<b)
            cout <<"a < b"<<endl;
        else
           cout << "a == b"<<endl; 
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k;
  string s;
  
  cin >> k >> s;
  if(k >= s.length()){
    cout << s << endl;
  } else {
    for (int i=0; i < k; i++){
      cout << s[i];
    }
    cout << "..." << endl;

  }
  
}


Measured memory_bytes: 3620
#include<iostream>

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    if(a>b){
        cout<<'a'<<" > "<<'b'<<endl;
    }
    else if(a<b){
        cout<<'a'<<" < "<<'b'<<endl;
    }
    else{
         cout<<'a'<<" == "<<'b'<<endl;
    
    }
    
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <cstring> 
#include <algorithm>
#include <vector>
using namespace std;

int n;
vector<int> a;
vector<int> b;

long long k;
long long t;

int main() {
    cin >> n >> k;
    for(int i=0;i<n;++i) {
      cin >> t;
      a.push_back(t-1);
    }
  
   b.resize(n);
  	
  	long long j=0;
    for(long long i=0;i<k;++i) {
      if ( b[j]!=0 ) {
        long long n = i-b[j];
        i = (( (long long)((k-i) / n) * n) + i) - 1;
        for(int i=0;i<b.size();++i) {b[i]=0;}
        continue;
      }
    
      b[j] = i;
      j=a[j];
      
    }
  
  	cout << (j+1);

}

Measured memory_bytes: 4816
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

D,T,S = I()
if D <= T*S:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 10100
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Stack<Integer> stack = new Stack<Integer>();
		Scanner k = new Scanner(System.in);
		
		String[] equation = k.nextLine().split(" ");
		
		for(int x = 0; x < equation.length; x++) {
			if (equation[x].equals("+") ||equation[x].equals("-") ||equation[x].equals("*")) {
				int f = stack.pop();
				int g = stack.pop();
				if (equation[x].equals("+")) {
					stack.push(f+g);
				}
				else if (equation[x].equals("-")) {
					stack.push(g-f);
				}
				else if (equation[x].equals("*")) {
					stack.push(f*g);
				}
			}
			else {
				int y = Integer.parseInt(equation[x]);
				stack.push(y);
			}
		}
		
		System.out.println(stack.pop());
		
		
	}
}



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

class UnionFind:
    def __init__(self, n):
        self.data = [0] * N
        for i in range(N):
            self.data[i] = i
            
    def get_root(self, x):
        r = self.data[x]
        if r == x:
            return r
        p = self.get_root(r)
        self.data[x] = p
        
        return p
    
    def unite(self, x, y):
        rx = self.get_root(x)
        ry = self.get_root(y)
        
        if rx != ry:
            self.data[rx] = ry

    def same(self, x, y):
        return self.get_root(x) == self.get_root(y)

N, K, L = map(int, input().split())
LA = [[int(v) - 1 for v in input().split()] for _ in range(K)]
LB = [[int(v) - 1 for v in input().split()] for _ in range(L)]

u1 = UnionFind(N)
for x, y in LA:
    u1.unite(x, y)
    
u2 = UnionFind(N)
for x, y in LB:
    u2.unite(x, y)

result = {}
for i in range(N):
    a = u1.get_root(i)
    b = u2.get_root(i)
    
    if result.get((a, b)) == None:
        result[(a, b)] = 0
    result[(a, b)] += 1
    
for i in range(N):
    a = u1.get_root(i)
    b = u2.get_root(i)
    
    print(result[(a, b)], end = "")
    if i != N - 1:
        print(" ", end = "")
    else:
        print()


Measured memory_bytes: 80572
S = input()[::-1]

words = ("dream"[::-1], "dreamer"[::-1], "erase"[::-1], "eraser"[::-1])

index = 0

while True:
    flag = False
    for word in words:
        if S[index:index + len(word)] == word:
            index += len(word)
            flag = True

    if index == len(S):
        print("YES")
        exit()

    if flag is False:
        break

print("NO")






Measured memory_bytes: 40432
#include <iostream>
#include <vector>

using namespace std;

int main()
{
   int h, w;    cin >> h >> w;
   vector<string> s(h);
   for (int i = 0; i < h; i++) cin >> s[i];

    //8方向を移動するための配列
   const int dx[8] = {1, 0, -1, 0, 1, -1, 1, -1};
   const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
    
    //ここから判定
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if (s[i][j] == '#') continue;


            //周囲八方向を調べる
            int num = 0;
            for (int d = 0; d < 8; d++){
                const int ni = i + dy[d];
                const int nj = j + dx[d];

                if (ni < 0 || h <= ni) continue;    //はみ出したら(h)
                if (nj < 0 || w <= nj) continue;    //はみ出したら(w)
                if (s[ni][nj] == '#') num++;    //爆弾があったら
            }

            s[i][j] = char(num + '0');
        }
    }
    for (int i = 0; i < h; i++) cout << s[i] << endl;
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;


int main()
{
	FAST;
	int n;
	cin >> n;
	int arr[100005];

	for(int i=1 ; i<=n ; i++)
		cin >> arr[i];


	int count = 0;
	int current = 1;
	while(count < n)
	{
		current = arr[current];
		if(current == 2)
		{
			cout << count+1;
			return 0;
		} 
		count++;
	}
	cout << "-1";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <iterator> // inserter . setのintersection するとき．
// #include <regex> //正規表現
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int64_t A, B; cin >> A >> B;

// 全ての素数同士は互いに素
// 素数をすべて選ぶ．

// 約数の集合
set<int64_t> divA, divB;
int64_t a = A, b = B;
for(int64_t i = 2; i * i <= A; ++i){
    while (a % i == 0) {
        divA.insert(i);
        a /= i;
    }
}
if (a != 1) divA.insert(a);

for(int64_t i = 2; i * i <= B; ++i){
    while (b % i == 0) {
        divB.insert(i);
        b /= i;
    }
}
if (b != 1) divB.insert(b);

int cnt = 1;
for (int64_t i : divA){
    if (divB.count(i)) ++cnt;
}

cout << cnt << "\n";


}

// 境界，出力文字列 チェック



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


////////// 	Template structure for debugging

#define tr(...) trace(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void trace(const char* name, Arg1&& arg1){
cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void trace(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cout.write(names, comma-names) << " : " << arg1 << " | " ; 

trace(comma+1, args...);
}

#define print(...) pr(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void pr(const char* name, Arg1&& arg1){
cout << arg1 << endl;
}
template <typename Arg1, typename... Args>
void pr(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cout << arg1 << " "; 
pr(comma+1, args...);
}

void printV(vector<int> &arr)
{
for(int i=0;i<arr.size();i++)cout << arr[i] << " \n"[ i == arr.size()-1 ];
}

///////////////// Fenwick Tree 
// void update(int index,int num){

// 	while(index<=N){
// 		arr[index] += num;
// 		index += index & (-index);
// 		//cout << index << endl;
// 	}

// }

// int sum(int index){

// 	int s = 0;
// 	while(index){
// 		s += arr[index];
// 		index -= index & (-index);
// 	}
// 	return s;
// }

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

/////////////////// Type definitions
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<long,long> pl;
typedef pair<double,double> pd;
#define f first
#define s second
////////////////////////////////////////////////////////////////////////////

int t;
void solve(){}	

int main(){

	int n, w;
	cin >> n >> w;
	vector<pair<ll,ll>> arr(n,{0,0});

	for(int i=0; i<n; i++)
		cin >> arr[i].f >> arr[i].s;
	
	ll dp[n+1][w+1];
	memset(dp,0,sizeof dp);	
	for(int i = 1;i <= n; i++)
		for(int weight = 0;weight <= w; weight++)
			if(weight >= arr[i-1].f)dp[i][weight] = max(dp[i-1][weight - arr[i-1].f] + arr[i-1].s,dp[i-1][weight]);
			else dp[i][weight] = dp[i-1][weight];

	print(dp[n][w]);
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,m,d,t;
bool ans = true;
map<int,int> M;

signed main() {
    cin >> n;
    rep(i,n) cin >> d, M[d]++;
    cin >> m;
    rep(i,m) cin >> t, M[t]--;
    for(auto i : M) if (i.se < 0) ans = false;
    if (ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

constexpr int di[] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dj[] = {1, 1, 0, -1, -1, -1, 0, 1};

int h, w, n;

void fall(vector<string> &s){
    bool update = true;
    while(update){
        update = false;
        for(int i=0;i<h-1;i++){
            for(int j=0;j<w;j++){
                if(isalpha(s[i][j]) && s[i+1][j] == '.'){
                    swap(s[i][j], s[i+1][j]);
                    update = true;
                }
            }
        }
    }
}

bool eval(vector<string> &s){
    vector<vector<bool> > flag(h, vector<bool>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w-1;){
            int nj = j+1;
            while(nj<w && isalpha(s[i][j]) && s[i][j]==s[i][nj]) nj++;
            if(nj-j >= n){
                for(int k=j;k<nj;k++){
                    flag[i][k] = true;
                }
            }
            j = nj;
        }
    }
    for(int j=0;j<w;j++){
        for(int i=0;i<h-1;){
            int ni = i+1;
            while(ni<h && isalpha(s[i][j]) && s[i][j]==s[ni][j]) ni++;
            if(ni-i >= n){
                for(int k=i;k<ni;k++){
                    flag[k][j] = true;
                }
            }
            i = ni;
        }
    }
    bool res = false;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(flag[i][j]){
                s[i][j] = '.';
                res = true;
            }
        }
    }
    return res;
}

bool game(vector<string> s){
    bool update = true;
    while(update){
        update = false;
        fall(s);
        update = eval(s);
    }
    bool res = true;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            res &= s[i][j] == '.';
        }
    }
    return res;
}

int solve(){
    cin >> h >> w >> n;
    vector<string> s(h);
    for(int i=0;i<h;i++){
        cin >> s[i];
    }    
    bool ok = false;
    for(int i=0;i<h;i++){
        for(int j=0;j<w-1;j++){
            swap(s[i][j], s[i][j+1]);
            ok |= game(s);
            swap(s[i][j], s[i][j+1]);
        }
    }
    cout << (ok ? "YES" : "NO") << endl;
    return 0;
}

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



Measured memory_bytes: 3228
p105=100009
count = [0]*p105
n = int(input())
a = list(map(int,input().split()))
sum=0
for i in range(n):
    count[a[i]]+=1
    sum+=a[i]

q=int(input())
#b=[]*q
#c=[]*q
for i in range(q):
    b,c=map(int,input().split())
    num=count[b]
    sum-= num*b
    sum+= num*c
    count[b] = 0
    count[c]+= num

    print(sum)


Measured memory_bytes: 21776
import sys

def dfs(x,m,nex):
    if m==n:
        #print(x)
        if x%2==0:
            global ans
            ans += 1
    else:
        ai = a[nex]
        m += 1
        nex += 1
        for i in (ai,ai-1,ai+1):
            dfs(x*i,m,nex)

sys.setrecursionlimit(10**6)

n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in (a[0],a[0]-1,a[0]+1):
    dfs(i,1,1)
print(ans)

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

int main() {
  int N, C100, C10, C1;
  cin >> N;
  C100 = N / 100;
  C10 = N % 100 / 10;
  C1 = N % 100 % 10;
  cout << C100 + C10 + C1 << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

MOD = 1000000007
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def main():    
    n = int(stdin.readline().rstrip())
    ans = ""
    while n > 0:
        n -= 1
        kazu = n%26
        ans = alpha[kazu] + ans
        n = n//26
    print(ans)
    
main()

Measured memory_bytes: 9968
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll a[100005],d[100005];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll N,K;
    cin>>N>>K;
    ll i,j;
    for(i=0;i<N;i++)
    {  cin>>a[i]; }
    d[0]=0; d[1]=abs(a[1]-a[0]);
    for(i=2;i<N;i++)
    {
        d[i]=9999999999;
        for(j=i-1;j>=max(i-K,0ll);j--)
        { d[i]=min(d[i],d[j]+abs(a[j]-a[i])); }
    }
    cout<<d[N-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
s = int(input())

def check_target(s):
    s = str(s)
    prev = s[0]
    for i in range(len(s)):
        if s[0] != s[i]:
            return False
    return True

ans = 0
for i in range(s, 1000):
    if check_target(i):
        ans = i
        break

print(ans)


Measured memory_bytes: 2940
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      for(int i = 0;i < n;i++)a[i]=sc.nextInt();
      Arrays.sort(a);
      long x = 1;
      List<Integer> list = new ArrayList<Integer>();
      for(int i = n-1;i > 0;i--){
      	if(a[i]==a[i-1]&&list.size()<=1){
          x *= (long)a[i];
          list.add(a[i]);
          i--;
        }
        if(list.size()==2)break;
      }
      if(list.size()<=1)System.out.println(0);
      else System.out.println(x);
    }
}


Measured memory_bytes: 50956
N, K, *XY = map(int, open(0).read().split())

X, Y = zip(*sorted(zip(*[iter(XY)] * 2)))

ans = 1e20
for k in range(K, N + 1):
    for i in range(N - k + 1):
        dx = X[i + k - 1] - X[i]
        YY = sorted(Y[i:i + k])
        ans = min(ans, min(dx * (YY[j + K - 1] - YY[j]) for j in range(k - K + 1)))

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <list>
#include <cmath>
#include <iomanip>

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

    std::vector<double> xn;
    std::vector<double> yn;

    for (int i = 0; i < n; ++i) {
         double x;
         std::cin >> x;
         xn.push_back(x);
    }

    for (int i = 0; i < n; ++i) {
         double y;
         std::cin >> y;
         yn.push_back(y);
    }

    double chebyshev_distance = 0.0;
    double manhattan_distance = 0.0;
    double euclidean_distance = 0.0;
    double p2 = 0.0;

    for (int i = 0; i < n; ++i) {
        double manhattan = std::abs(xn[i] - yn[i]);
        manhattan_distance += manhattan;
        euclidean_distance += manhattan*manhattan;
        p2 += manhattan*manhattan*manhattan;

        if(chebyshev_distance < manhattan) chebyshev_distance = manhattan;
    }

    std::cout << std::setprecision(10) << manhattan_distance << std::endl;
    std::cout << std::setprecision(10) << std::sqrt(euclidean_distance) << std::endl;
    std::cout << std::setprecision(10) << std::pow(p2,1.0/3.0) << std::endl;
    std::cout << std::setprecision(10) << chebyshev_distance << std::endl;

    return 0;
}


Measured memory_bytes: 3432
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main() {
    int n; cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    int cnt = 0;
    for (int i=0;i<n-1;++i) {
        if (p[i] != i + 1) cnt++;
    }

    YES(cnt <= 2);
}

Measured memory_bytes: 256
n, a = map(int, input().split())
x = list(map(int, input().split()))
#dp[i][j][k] := i枚目までカードを選び、合計がjになり、k枚カードを選んだ選び方の総数
#合計のマックスは、xの総和で考える、高々2500なので間に合う
dp = [[[0 for i in range(n+1)] for j in range(sum(x)+1)] for k in range(n+1)]
dp[0][0][0] = 1
for i in range(1,n+1):
    for j in range(sum(x) + 1):
        for k in range(n+1):
            if j + x[i-1] < sum(x) + 1 and k < n:
                dp[i][j + x[i-1]][k+1] += dp[i-1][j][k]
            dp[i][j][k] += dp[i-1][j][k]
ans = 0
for j in range(sum(x)+1):
    for k in range(1,n+1):
        if j == a * k:
            ans += dp[-1][j][k]

print(ans)

Measured memory_bytes: 115292
N = int(input())
A = [input() for _ in range(N)]

print('AC x {}'.format(len([x for x in A if x == 'AC'])))
print('WA x {}'.format(len([x for x in A if x == 'WA'])))
print('TLE x {}'.format(len([x for x in A if x == 'TLE'])))
print('RE x {}'.format(len([x for x in A if x == 'RE'])))

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

int main() {
  long long n, x, m;
  cin >> n >> x >> m;

  vector<long long> sm(100005, 0);
  vector<long long> cnt(100005, 0);

  sm[1] = x;
  cnt[x] = 1;
  long long first_sum = 0, first_len = 0;
  long long loop_sum = 0, loop_len = 0, loop_num = 0;
  long long last_sum = 0, last_len = 0;

  long long a = x;
  int i = 2;
  for ( ; i <= n; i++ ) {
    a = a * a % m;
    if ( cnt[a] != 0 ) {
      loop_len = i - cnt[a];
      first_len = i-1 - loop_len;
      first_sum = sm[first_len];
      loop_sum = sm[i-1] - first_sum;
      loop_num = (n - first_len) / loop_len;
      last_len = (n - first_len) % loop_len;
      last_sum = sm[first_len+last_len] - sm[first_len];
      break;
    }
    sm[i] = a + sm[i-1];
    cnt[a] = i;
  }

  long long ans = ( loop_num != 0 ) ? first_sum + (loop_sum*loop_num) + last_sum : sm[n];
  cout << ans << endl;
  return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i = 0; i < n; i++)  cin >> h[i];
  vector<int> dp(n, INT_MAX);
  dp[0] = 0;
  dp[1] = abs (h[1] - h[0]);

  for(int i = 2; i < n; i++){
    for(int j = 1; j <= k; j++){
        if(i - j >= 0){
            dp[i] = min (dp[i], abs (h[i] - h[i - j]) + dp[i - j]);
        }
    }
  }

  cout << dp[n - 1] << endl;
  return 0;
}


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

int main()
{
   string str,ans;
   cin>>str;
   if(str[str.length()-1]=='s'){
       ans=str+"es";
   }else{
       ans=str+"s";
   }
    cout<<ans;
    return 0;
}


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

struct point {
    int id, x, y;
    point() : id(-1), x(0), y(0) {}
    point(int id, int x, int y) : id(id), x(x), y(y) {}
    point(int id, pair<int,int> xy) : id(id), x(xy.first), y(xy.second) {}
    bool operator < (const point &p) const {
        return id < p.id;
    }
};
class kdtree {
private:
    struct node {
        int p;
        int location;
        int l,r;
        node():l(NIL),r(NIL) {}
    };

    static bool lessX(const point &a, const point &b) { return a.x < b.x; }
    static bool lessY(const point &a, const point &b) { return a.y < b.y; }
    static const int NIL=-1;

    int root;
    int np;
    int N;
    vector<node> T;
    vector<point> &P;

    int make_kd_tree(int l, int r, int depth) {
        if (!(l < r)) return -1;
        int mid = (l + r) / 2;
        int t = np++;

        if (depth) sort(begin(P) + l, begin(P) + r, lessY);
        else       sort(begin(P) + l, begin(P) + r, lessX);

        T[t].location = mid;
        T[t].l = make_kd_tree(l, mid, !depth);
        T[t].r = make_kd_tree(mid+1, r, !depth);

        return t;
    }
    void find(int v, int sx, int sy, int tx, int ty, int depth, vector<point> &ans) {
        int x = P[T[v].location].x;
        int y = P[T[v].location].y;

        if (sx <= x && x <= tx && sy <= y && y <= ty) {
            ans.push_back(P[T[v].location]);
        }

        if (depth) {
            if(T[v].l != NIL && sy <= y) find(T[v].l, sx, sy, tx, ty, !depth, ans);
            if(T[v].r != NIL && y <= ty) find(T[v].r, sx, sy, tx, ty, !depth, ans);
        } else {
            if(T[v].l != NIL && sx <= x) find(T[v].l, sx, sy, tx, ty, !depth, ans);
            if(T[v].r != NIL && x <= tx) find(T[v].r, sx, sy, tx, ty, !depth, ans);
        }
    }

public:
    kdtree(vector<point> &p) : P(p) {
        np = 0;
        N = p.size();
        T.resize(N);
        root = make_kd_tree(0, N, 0);
    }
    void query(int sx,int sy,int tx,int ty, vector<point> &p) {
        find(root, sx, sy, tx, ty, 0, p);
    }
};

int main() {
    int n;
    cin >> n;
    vector<point> p(n);
    for (int i = 0; i < n; i++) {
        p[i].id = i;
        scanf("%d %d", &p[i].x, &p[i].y);
    }
    kdtree tree(p);
    int q;
    cin >> q;
    while (q--) {
        int sx, tx, sy, ty;
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);

        vector<point> ans;
        tree.query(sx, sy, tx, ty, ans);

        sort(begin(ans), end(ans));
        for (int i = 0; i < (int)ans.size(); i++) {
            printf("%d\n", ans[i].id);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 16012
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n,s,t = sc.next
  
  val composed = (s.zipWithIndex.map{case (e, index) => (e, index * 2)} ++ t.zipWithIndex.map{case (e, index) => (e, index * 2 + 1)}).sortBy(_._2)  
  
  println(composed.map{case (e, _) => e}.mkString)
}

Measured memory_bytes: 25420
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0;
    map<int,int>mp;
    cin>>n;
    for(int i=1;i<=min(n,9);i++){
        int fs,ls;
        fs=ls=i;
        mp[fs*10+ls]++;
    }
    for(int i=10;i<=n;i++){
        int tp=i;
        int fs,ls;
        ls=i%10;
        while(tp>0)
        {
            fs=tp%10;
            tp/=10;
        }
        mp[fs*10+ls]++;
    }
    for(auto x:mp)
    {
        int xx=x.first;
        int ls=xx%10;
        int fs=xx/10;
        ans+=mp[ls*10+fs]*x.second;
    }
    cout<<ans;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int n;
string s[3];

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

  cin>>n;
  rep(i,3)cin>>s[i];

  int res=0;
  rep(i,n){
    set<char> st;
    rep(j,3)st.insert(s[j][i]);
    res+=(int)st.size()-1;
  }
  cout<<res<<endl;
  return 0;
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int n;

int main() {

	FAST;

	cin >> n;
	int even = n / 2;
	int odd = n - even;
	cout << setprecision(9) << fixed << 1.0 * odd / n << '\n';
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 100010;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
    int h, w, k; cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    vector<vector<int>> berry_counter(h, vector<int>(w, 0));
    int counter = 1;
    rep(i, h){
        rep(j, w){
            if(s[i][j] == '#'){
                berry_counter[i][j] = counter;
                counter++;
            }
        }
    }
    rep(i, h){
        rep(j, w){
            if(j < w - 1 and berry_counter[i][j] != 0){
                if(berry_counter[i][j + 1] == 0){
                    berry_counter[i][j + 1] = berry_counter[i][j];
                }
            }
        }
    }
    rep(i, h){
        for(int j = w - 1; j >= 0; j--){
            if(j > 0 and berry_counter[i][j] != 0){
                if(berry_counter[i][j - 1] == 0){
                    berry_counter[i][j - 1] = berry_counter[i][j];
                }
            }
        }
    }
    rep(j, w){
        rep(i, h){
            if(i < h - 1 and berry_counter[i][j] != 0){
                if(berry_counter[i + 1][j] == 0){
                    berry_counter[i + 1][j] = berry_counter[i][j];
                }
            }
        }
    }
    rep(j, w){
        for(int i = h - 1; i >= 0; i--){
            if(i > 0 and berry_counter[i][j] != 0){
                if(berry_counter[i - 1][j] == 0){
                    berry_counter[i - 1][j] = berry_counter[i][j];
                }
            }
        }
    }
    rep(i, h){
        rep(j, w){
            cout << berry_counter[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#C

k, n = map(int, input().split())

a = list(map(int, input().split()))

d = []
#d[]は各家の距離
for i in range(n-1):
    d.append(a[i+1] - a[i])

d.append(k - a[n-1] + a[0])

print(k - max(d))

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

using namespace std;

#define INF 1e9

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

    int n;
    cin>>n;

    vector<int> p(n);

    for(int i=0;i<n;i++)cin>>p[i];

    vector<int> a(n+1);

    for(int i=0;i<n;i++){
        a[p[i]]=i;
    }

    int ans=n,len=1;

    for(int i=1;i<n;i++){
        if(a[i]<a[i+1])len++;
        else{
            ans=min(ans,n-len);
            len=1;
        }
    }

    cout<<min(ans,n-len)<<endl;

}

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

long long int dp[102][100005];
long long int cost[1000000],weight[1000000];
long long int n,capacity;

long long int knapsack(long long int i,long long int w){

  long long int p=0,q=0;

  //memset(dp,-1,sizeof(dp));
  if(i==n+1)
    return 0;

  if(dp[i][w]!=-1)
    return dp[i][w];


  else{
    if(w+weight[i]<=capacity){
            p=cost[i]+knapsack(i+1,w+weight[i]);

    }

    q=knapsack(i+1,w);

    dp[i][w]=max(p,q);

    return dp[i][w];
  }
}
int main() {
    ios_base::sync_with_stdio(false);

    long long int a,b,c,d,i,j,k,g,W,t;

        cin>>n>>capacity;

        for(i=1;i<=n;i++)
        {
            cin>>weight[i]>>cost[i];
        }

       memset(dp,-1,sizeof(dp));
        cout<<knapsack(1,0)<<"\n";

    return 0;
}


Measured memory_bytes: 83328
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#include<string.h>
int main()
{
    ll a,b,c,d,i,test;
    char ar[10000];
    char ar1[10000];
    cin>>ar>>ar1;
    cout<<ar1<<ar<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>


int main() {

	int N;
	int Y;

	std::cin >> N >> Y;

	int max = N * 10000;
	int ref = 0;
	for (int i = 0; i <= N; i++) {
		for (int o = 0; o <= i; o++) {
			ref = max - (i * 5000) - (o * 4000);
			if (Y == ref) {
				std::cout << N - i <<" " << i - o << " " << o;
				return 0;
			}
		}
	}

	std::cout << "-1 -1 -1";
	//while (true) {}

	return 0;
}

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

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  long n,k;
  cin >> n >> k;
  if(n%k==0){
	cout << "0" << endl;
  }
  else{
	cout << "1" << endl;
  }
  return 0;
}


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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map
#define mtv(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)

vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out( 
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cout << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    stringstream ss; ss << H;
    cout << args[idx] << "- " << ss.str() << ", ";
    debug_out(args, idx + 1, LINE_NUM, T...);
}


void doit(){
    ll n,i,j,x,y;
    cin >> n >> x >> y;
    vector<ll>dist(n);
    rep(i,1,n+1){
        rep(j,i+1,n+1){
                ll in = j-i;
                in = min({in,1+abs(i-x)+abs(j-y)});
                dist[in]++;
        }
    }
    rep(i,1,n)cout << dist[i] << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    map<int,int> MA, MB;
    vector<int> A(N), B(N);
    rep(i,N) {
        cin >> A[i];
        MA[A[i]]++;
    }
    rep(i,N) {
        cin >> B[i];
        MB[B[i]]++;
    }
    for (auto [k,v] : MA) {
        if (MB.count(k) > 0) {
            if (N - MB[k] < v) {
                cout << "No" << endl;
                return 0;
            } 
        }
    }

    for (auto [k,v] : MB) {
        if (MA.count(k) > 0) {
            if (N - MA[k] < v) {
                cout << "No" << endl;
                return 0;
            } 
        }
    }

    int j = 0, prev = -1;
    rep(i,N) {
        if (A[i] != prev) j = 0;
        if (A[i] == B[i]) {
            for (; j < N; j++) if (A[i] != A[j] && B[j] != A[i]) break;
            swap(B[i], B[j]);
        }
        prev = A[i];
    }

    cout << "Yes" << endl;
    rep(i,N) {
        if (i) cout << " ";
        cout << B[i];
    }
    cout << endl;
}


Measured memory_bytes: 23540
fun main(arg: Array<String>) {
    val (N, X) = listOfInt()
    val A = listOfLong()
    val M = Array<Array<Long>>(N) { Array<Long>(N) { 0 }}
    for (k in 0 until N) {
        for (n in 0 until N) {
            if (k == 0) M[k][n] = A[n]
            else M[k][n] = Math.min(M[k-1][n], A[(N + n - k) % N])
        }
    }
//repeat(N) { System.err.println(M[it].joinToString()) }
    var ans = Long.MAX_VALUE
    val x = X.toLong()
    for (k in 0 until N) {
        var min = (x * k) + M[k].sum()
        if (min < ans) ans = min
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }
fun listOfLong() = listOfString().map { it.toLong() }


Measured memory_bytes: 209956
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

struct Sieve {
    int n;
    vector<int> f, primes;
    
    Sieve(int n=1) : n(n), f(n+1) {
        f[0] = f[1] = -1;
        for (long long i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (long long j = i*i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }

    bool isPrime(int x) { return f[x] == x;}

    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }

    vector<pair<int, int>> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) return {};
        vector<pair<int, int>> res(1, pair<int, int>(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    Sieve sieve(n);
    map<int, int> mp;
    for (int i = 1; i <= n; ++i) {
        auto f = sieve.factor(i);
        for (auto p : f) {
            mp[p.fi] += p.se;
        }
    }
    vi cnt(100, 0);
    for (auto p : mp) {
        cnt[p.se]++;
    }
    int over2 = 0;
    int over4 = 0;
    int over14 = 0;
    int over24 = 0;
    int over74 = 0;
    rep(i, 100) {
        if (i >= 2) over2 += cnt[i];
        if (i >= 4) over4 += cnt[i];
        if (i >= 14) over14 += cnt[i];
        if (i >= 24) over24 += cnt[i];
        if (i >= 74) over74 += cnt[i];
    }
    int ans = over24 * (over2 - 1) + over14 * (over4 - 1) + (over2 - 2) * over4 * (over4 - 1) / 2 + over74;
    cout << ans << endl;
}

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

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

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

const int max_n = 200111, inf = 1000111222;
const ll mod = 1000000007;

int n, m;
string s;

ll dp[max_n];
ll pr[max_n];
ll dp2[max_n];

ll solve_allr() {
    ll ans = 1;
    dp[1] = 1;
    dp[2] = 0;
    ll sum = dp[1];
    for (int i = 3; i < max_n; ++i) {
        dp[i] = sum;
        sum += dp[i - 1];
        sum %= mod;
    }
    for (int len = 1; len < n; ++len) {
        ans += dp[n - len] * (len + 1);
        ans %= mod;
    }
    return ans;
}

ll solve(int L) {
    int L1 = L / 2;
    pr[1] = 1;
    dp2[1] = 1;
    for (int i = 2; i < max_n; ++i) {
        dp2[i] = (pr[i - 1] - pr[max(1, i - L1 - 1) - 1] + 2 * mod) % mod;
        pr[i] = pr[i - 1] + dp2[i];
        pr[i] %= mod;
    }
    dp[1] = 1;
    for (int i = 3; i < max_n; i += 2) {
        dp[i] = dp2[i / 2 + 1];
    }
    ll ans = 0;
    for (int len = 1; len <= min(L, n - 1); len += 2) {
        ans += dp[n - len] * (len + 1);
        ans %= mod;
    }
    return ans;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> n >> m;
    cin >> s;
    if (s[0] == 'B') {
        for (int i = 0; i < s.size(); ++i) {
            s[i] = (s[i] == 'B' ? 'R' : 'B');
        }
    }
    bool allr = 1;
    for (char c : s) {
        if (c == 'B') {
            allr = 0;
            break;
        }
    }
    if (allr) {
        cout << solve_allr() << endl;
        return 0;
    }
    if (n % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    while (s.back() == 'R') {
        s.pop_back();
    }
    int L = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'B') {
            break;
        } else {
            ++L;
        }
    }
    if (L % 2 == 0) {
        ++L;
    }
    int len = 0;
    for (int i = L; i < s.size(); ++i) {
        if (s[i] == s[i - 1]) {
            ++len;
        } else {
            if (s[i] == 'B' && len % 2 == 1) {
                L = min(L, len);
            }
            len = 1;
        }
    }
    cout << solve(L) << endl;
    return 0;
}

// think 2:06


Measured memory_bytes: 5252