akhauriyash/Code-Regression huggingface dataset:
// Problem : B - Echo
// Contest : AtCoder Beginner Contest 145
// URL : https://atcoder.jp/contests/abc145/tasks/abc145_b
// Memory Limit : 1024,000000 MB 
// Time Limit : 2000,000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cout.precision(16);
  cout << fixed;
  
  int n;
  string s;
  cin >> n >> s;
  
  if (s.size() % 2 != 0) {
    cout << "No";
    
    return 0;
  }
  
  int mid = s.size() / 2;
  
  for (int i = 0; i < (int)s.size() / 2; ++i) {
    if (s[i] != s[mid + i]) {
      cout << "No";
      
      return 0;
    }
  }
  
  cout << "Yes";
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int mn = 100000000;
	if(a + b < mn) mn = a + b;
	if(b + c < mn) mn = b + c;
	if(c + a < mn) mn = c + a;
	printf("%d\n", mn);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD   998244353
#define PI (acos(-1))
#define EPS 1e(-9);
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    int M; cin>>M;
    ll sowa=0;
    ll zenketa=0;
    ll ans=0;
    rep(i,M){
        ll d,c; cin>>d>>c;
        zenketa+=c;
        sowa+=d*c;
    }

    ans+=zenketa-1;
    ans+=(sowa-1)/9;

    cout<< ans<<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL dp[310][310][310];

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

  int N, M; cin >> N >> M;
  dp[0][1][1] = 1;
  for(int l=0;l<M;++l){
	for(int n=1;n<=N;++n){
	  for(int k=1;k<=n;++k){
		(dp[l+1][n][k] += dp[l][n][k] * (n - k)) %= MOD;
		(dp[l+1][n][n] += dp[l][n][k] * k) %= MOD;
		(dp[l+1][n+1][k] += dp[l][n][k]) %= MOD;
	  }
	}
  }

  LL ans = dp[M][N][N];
  for(LL i=1;i<N;++i)
	(ans *= i) %= MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 220160
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	int n;
	cin >> n;
	
	cout << (n/2)*((n+1)/2) << endl;
}

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

using namespace std;

int arr[200010];
long long sum[200010];

int main()
{
    int n, i;
    scanf("%d", &n);
    for(i = 1; i <= n; i++)
        scanf("%d", &arr[i]);

    for(i = 1; i <= n; i++)
        sum[i] = sum[i - 1] + arr[i];

    long long r = 1e18;
    for(i = 1; i < n; i++)
        r = min(r, abs(sum[i] - (sum[n] - sum[i])));

    printf("%lld\n", r);
    return 0;
}

Measured memory_bytes: 2560
def get_GCD(a, b)
  while ((r = a%b) != 0) do
    a = b
    b = r
  end
  b
end

def get_LCM(a, b, gcd)
  a * b / gcd
end

while s = gets do
  a, b = s.split(/\s/).map(&:to_i).sort

  gcd = get_GCD(a, b)
  lcm = get_LCM(a, b, gcd)
  puts "#{gcd} #{lcm}"
end

Measured memory_bytes: 6096
#include <iostream>
using namespace std;
int cnt[1000];
int main(){
	int x,n,p[1000];

	cin >> x >> n;
	for (int i = 0; i<n; i++){
		cin >> p[i];
		cnt[p[i]]++;
	}
	
	bool find = false;
	int curup=x,curdown=x,ans=x;
	
	while(!find){
		if(!cnt[curdown]){
			ans = curdown;
			break;
		}
		curdown--;
		if(!cnt[curup]){
			ans = curup;
			break;
		}
		curup++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3572
N = int(input())
A = list(map(int, input().split()))


def bubble_sort(A, N):
    cnt = 0
    flag = True
    while(flag):
        flag = False
        for i in range(N-1, 0, -1):
            if(A[i-1] > A[i]):
                tmp = A[i-1]
                A[i-1] = A[i]
                A[i] = tmp
                cnt += 1
                flag = True

    print(" ".join(list(map(str, A))))
    print(cnt)

bubble_sort(A, N)

Measured memory_bytes: 7788
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second
#define pb push_back

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

int N,M;
string S;

signed main(){
  cin>>N;
  vector<int> A(N);
  REP(i,0,N)cin>>A[i];
  map<int,int> B,C;
  REP(i,0,N){
    B[i+A[i]]++;
    C[i-A[i]]++;
  }
  int ans=0;
  each(b,B){
    ans+=b.se*C[b.fr];
  }
  print(ans);




}


Measured memory_bytes: 38984
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        boolean[][] deck = new boolean[4][13];

        Arrays.fill(deck[0], false);
        Arrays.fill(deck[1], false);
        Arrays.fill(deck[2], false);
        Arrays.fill(deck[3], false);

        int n = sc.nextInt();
        while (n-- > 0) {
            switch (sc.next().charAt(0)) {
            case 'S': deck[0][sc.nextInt()-1] = true; break;
            case 'H': deck[1][sc.nextInt()-1] = true; break;
            case 'C': deck[2][sc.nextInt()-1] = true; break;
            case 'D': deck[3][sc.nextInt()-1] = true; break;
            }
        }

        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 13; j++) {
                if (deck[i][j] == false) {
                    System.out.print("SHCD".charAt(i));
                    System.out.print(' ');
                    System.out.println(j+1);
                }
            }
        }
    }
}



Measured memory_bytes: 26220
import java.util.*;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		String inS = stdin.next();
		int min = inS.length();
		for (int i = 0; i < (inS.length() - 1); i++) {
			if (inS.charAt(i) != inS.charAt(i + 1)) {
				min = Math.min(min, Math.max((i + 1), (inS.length() - i - 1)));
			}
		}

		System.out.println(min);
	}

}


Measured memory_bytes: 24904
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll n;
    cin >> n;
    ll total = 0;
    vector<ll> a(100000);
    rep(i, n)
    {
        ll tempA;
        cin >> tempA;
        total += tempA;
        ++a[tempA];
    }
    ll q;
    cin >> q;
    vector<ll> b(q);
    vector<ll> c(q);
    rep(i, q)
    {
        cin >> b[i] >> c[i];
    }
    rep(i, q)
    {
        total -= a[b[i]] * b[i];
        total += a[b[i]] * c[i];
        a[c[i]] += a[b[i]];
        a[b[i]] = 0;
        cout << total << endl;
    }
}

Measured memory_bytes: 5148
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < p.length; i++) {
            p[i] = sc.nextInt();
        }
        int counter = 0;
        for (int i = 0; i < p.length - 2; i++) {
            int min = p[i];
            int max = p[i];
            for (int j = i; j < i + 3; j++) {
                min = Math.min(min, p[j]);
                max = Math.max(max, p[j]);
            }
            if (p[i + 1] != min && p[i + 1] != max) {
                counter++;
            }
        }
        System.out.println(counter);
        sc.close();
    }
}

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

#define endl '\n'
#define f1 first
#define s2 second
#define pb push_back
#define mp make_pair
#define ll long long
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const int N=405;

ll dizi[N],n,dp[N][N],pre[N];

ll dpf(int l,int r){
	//cout<<l<<" "<<r<<" "<<endl;
	if(dp[l][r]!=-1)return dp[l][r];
	if(l==r)return 0;
	ll ans=LLONG_MAX;
	for(int i=l;i<r;i++){
		ans=min(ans,dpf(l,i)+dpf(i+1,r));
	}
	if(ans>=LLONG_MAX)return 0;
	return dp[l][r]=ans+pre[r]-pre[l-1];
}

int main(){
	//fri("in.txt");
	//fro("out.txt");
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>dizi[i];
		pre[i]=pre[i-1]+dizi[i];
	}
	memset(dp,-1,sizeof(dp));
	cout<<dpf(1,n);
return 0;
}

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

using namespace std;

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

  int N,K; cin>>N>>K;
  string S; cin>>S;

  struct RL {
    char c;
    int l;
  };
  char pc = S[0];
  int l = 1;
  vector<RL> rls;
  for (int i = 1; i < S.size(); i++) {
    if (S[i] == pc) {
      l++;
    } else {
      rls.push_back({pc, l});
      l = 1;
    }
    pc = S[i];
  }
  rls.push_back({pc, l});
  while (K--) {
    if (rls.size() >= 3) {
      rls[rls.size()-3].l += rls[rls.size()-2].l + rls[rls.size()-1].l;
      rls.resize(rls.size()-2);
    } else if (rls.size() == 2) {
      rls.front().l += rls.back().l;
      rls.resize(1);
    } else { // 1
      break;
    }
  }
  int ans = 0;
  for (auto rl : rls) {
    ans += rl.l-1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1480
def main():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')
    T = input().rstrip('\n')

    ns = len(S)
    nt = len(T)

    mod1 = 1000000007
    mod2 = 1000000009
    mod3 = 998244353
    b1 = 1007
    b2 = 2009
    b3 = 2999
    H1 = 0
    H2 = 0
    H3 = 0
    for i, t in enumerate(T):
        t = ord(t)
        H1 = ((H1 * b1)%mod1 + t)%mod1
        H2 = ((H2 * b2)%mod2 + t)%mod2
        H3 = ((H3 * b3)%mod3 + t)%mod3
    h1 = 0
    h2 = 0
    h3 = 0
    for i in range(nt):
        s = ord(S[i%ns])
        h1 = ((h1 * b1) % mod1 + s) % mod1
        h2 = ((h2 * b2) % mod2 + s) % mod2
        h3 = ((h3 * b3) % mod3 + s) % mod3

    idx = []
    if h1 == H1 and h2 == H2 and h3 == H3:
        idx.append(0)
    b1_nt = pow(b1, nt, mod1)
    b2_nt = pow(b2, nt, mod2)
    b3_nt = pow(b3, nt, mod3)
    for i in range(1, ns):
        s = ord(S[(i+nt-1)%ns])
        s_prev = ord(S[i-1])
        h1 = ((h1 * b1) % mod1 - (b1_nt * s_prev)%mod1 + s) % mod1
        h2 = ((h2 * b2) % mod2 - (b2_nt * s_prev)%mod2 + s) % mod2
        h3 = ((h3 * b3) % mod3 - (b3_nt * s_prev) % mod3 + s) % mod3
        if h1 == H1 and h2 == H2 and h3 == H3:
            idx.append(i%ns)
    if len(idx) == 0:
        print(0)
        exit()
    ans = 1
    dic = {}
    for i in range(len(idx)):
        if (idx[i] - nt)%ns in dic:
            tmp = dic[(idx[i]-nt)%ns] + 1
            dic[idx[i]] = tmp
            ans = max(ans, tmp)
        else:
            dic[idx[i]] = 1
    for i in range(len(idx)):
        if (idx[i] - nt)%ns in dic:
            tmp = dic[(idx[i]-nt)%ns] + 1
            dic[idx[i]] = tmp
            ans = max(ans, tmp)
        else:
            dic[idx[i]] = 1
    ans_ = ans
    for i in range(len(idx)):
        if (idx[i] - nt)%ns in dic:
            tmp = dic[(idx[i]-nt)%ns] + 1
            dic[idx[i]] = tmp
            ans = max(ans, tmp)
        else:
            dic[idx[i]] = 1
    if ans == ans_:
        print(ans)
    else:
        print(-1)


if __name__ == '__main__':
    main()


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

int main() {
	int h,w,k;
	cin >> h >> w >> k;
	vector< string > m(h);
	for (int i=0; i<h; i++) {
		cin >> m[i];
	}
	int ans = 0;
	for (int mr = 0; mr < (1<<h); mr++) {
		for (int mc = 0; mc < (1<<w); mc++) {
			int b = 0;
			for (int i=0; i<h; i++) {
				for (int j=0; j<w; j++) {
					if (((mr>>i)&1) && ((mc>>j)&1) && m[i][j] == '#') b++;
				}
			}
			if (b == k) ans++;
		}
	}
	cout << ans << '\n';
	
	
	
	return 0;
}


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

string S;
int main(){
    cin >> S;
    int k = S.size();
    int cnt = 0;
    for(int i=0;i<k;i++) if(S[i]=='o') cnt++;
    if(cnt+(15-k)<8) cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#define N 4
#define N2 16
#define LIMIT 100
using namespace std;
static const char c[4] = {'r','u', 'l', 'd'};
static const int x[4] = {0,-1, 0, 1};
static const int y[4] = {1,0, -1, 0};
int limit, MDT[N2][N2], path[LIMIT];
struct Puzzle
{
  int f[N2], space, MD;
};
Puzzle state;
int getMD(Puzzle p)
{
  int sum = 0;
  for(int i=0; i<N2; i++)
  {
    if(p.f[i] == N2) continue;
    sum += MDT[i][p.f[i] - 1];
  }
  return sum;
}

bool dfs(int depth, int previous)
{
  if(state.MD == 0) return true;
  if(depth + state.MD > limit) return false;
  Puzzle temp;
  int sx, sy, tx, ty;
  sx = state.space/N; sy = state.space%N;
  for(int r=0; r<4; r++)
  {
    tx = sx + x[r]; ty = sy + y[r];
    if(ty < 0 || tx < 0 || tx >=N || ty >= N) continue;
    if(max(previous, r) - min(previous, r) == 2) continue;
    temp = state;
    state.MD -= MDT[tx*N + ty][state.f[tx*N + ty]-1];
    state.MD += MDT[state.space][state.f[tx*N + ty] -1];
    swap(state.f[state.space], state.f[tx*N + ty]);
    state.space = tx*N + ty;
    if(dfs(depth+1, r))           //tai
    {
      path[depth] = r; return true;// xiu le
    }
    state = temp;
  }
  return false;
}
string iterative_deepening(Puzzle &p)
{
  p.MD = getMD(p);
  for(limit = p.MD; limit<=LIMIT; limit++)
  {
    state = p;
    if(dfs(0, -100))
    {
      string ans = "";
      for(int i=0; i<limit; i++)
      {
        ans += c[path[i]];
      }
      return ans;
    }
  }
  return "unsolvable";
}
int main()
{
  Puzzle in;
  for(int i=0; i<N2; i++)
  {
    scanf("%d", &in.f[i]);
    if(in.f[i] == 0)
    {
      in.f[i] = N2; in.space = i;
    }
  }
  for(int i=0; i<N2; i++)
  {
    for(int j=0; j<N2; j++)
      MDT[i][j] = abs(i/N - j/N) + abs(i%N - j%N);
  }
  string ans = iterative_deepening(in);
  cout << ans.size() << endl;

  return 0;
}



Measured memory_bytes: 3268
/**
 * 
 */
import java.util.*;
/**
 * @author akira
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		for(int i = 0;i < n;i++){
			scan.nextLine();
			scan.nextLine();
			String[] mp = new String[8];
			for(int j = 0;j < mp.length;j++){
				mp[j] = scan.nextLine();
			}
			rec(mp,scan.nextInt() - 1,scan.nextInt() - 1);
			System.out.println("Data " + (i + 1) + ":");
			for(int j = 0;j < 8;j++){
				System.out.println("" + mp[j]);
			}
		}
	}

	public static void rec(String[] mp, int x, int y) {
		final int[] dy = { -1, -2, -3, 0, 0, 0, 1, 2, 3, 0, 0, 0 }, dx = { 0,
				0, 0, 1, 2, 3, 0, 0, 0, -1, -2, -3 };
		mp[y] = mp[y].substring(0, x) + "0"
				+ mp[y].substring(x + 1, mp[y].length());
		for (int i = 0; i < dy.length; i++) {
			if (0 <= y + dy[i] && y + dy[i] < 8 && 0 <= x + dx[i]
					&& x + dx[i] < 8 && mp[y + dy[i]].charAt(x + dx[i]) == '1') {
				rec(mp, x + dx[i], y + dy[i]);

			}
		}
	}

}

Measured memory_bytes: 17392
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;
int main(void){
    ll N, X, T;
    
    cin >> N >> X >> T;
    
    ll ans;
    
    if(N % X == 0){
        ans = (N / X) * T;
    }else{
        ans = ((N / X) + 1) * T;
    }
    
    cout << ans << endl;
    
    return 0;
    
}


Measured memory_bytes: 3604
N, X, Y = gets.chomp.split(" ").map(&:to_i)

ans = Array.new(N - 1, 0) #距離
1.step(N) do |i|
    (i + 1).step(N) do |j|
        a = j - i
        b = (X - i).abs + 1 + (Y - j).abs
        d = a < b ? a : b
        ans[d - 1] += 1 if d > 0
    end
end
puts ans


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

template <typename T>
class BIT{
  vector<T> array;
  int n;
public:
  BIT(int num){
    n = num;
    array.resize(n + 1);
  }
  T sum(int i){
    T s = 0;
    while(i > 0){
      s += array[i];
      i -= i & -i;
    }
    return s;
  }
  T sum(int i, int j){
    return sum(j)-sum(i-1);
  }
  void add(int i, T x){
    while(i <= n){
      array[i] += x;
      i += i & -i;
    }
  }
};

int c[500010];
TU que[500010];

int main(){
  int n,q;
  cin>>n>>q;
  BIT<int>bit(n);
  for(int i=1; i<=n; ++i)cin>>c[i];
  rep(i,q){
    int l,r;
    cin>>l>>r;
    que[i]=TU(r,l,i);
  }
  sort(que,que+q);
  rep(i,q)swap(get<0>(que[i]),get<1>(que[i]));
  vector<int>x(n+1,-1),ans(q);
  int now=0;
  rep(i,q){
    for(int j=now+1; j<=get<1>(que[i]); ++j){
      if(x[c[j]]!=-1){
        bit.add(x[c[j]],-1);
      }
      x[c[j]]=j;
      bit.add(x[c[j]],1);
    }
    ans[get<2>(que[i])]=bit.sum(get<0>(que[i]),get<1>(que[i]));
    now=get<1>(que[i]);
  }
  rep(i,q)cout<<ans[i]<<endl;
}

Measured memory_bytes: 17396
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, P);
    IN(string, S);
    ll ans = 0;
    if (P == 2 or P == 5)
    {
        ans = 0;
        REP(i, N)
        {
            ans += ((S[i] - '0') % P == 0) * (i + 1);
        }
    }
    else
    {
        vi mod(P);
        ll k = 1;
        ll s = 0;
        ++mod[0];
        for (ll i = N - 1; i >= 0; --i)
        {
            s = (s + (S[i] - '0') * k) % P;
            ++mod[s];
            k = (k * 10) % P;
        }
        REP(i, P)
        {
            ans += mod[i] * (mod[i] - 1) / 2;
        }
    }
    OUT(ans);
}


Measured memory_bytes: 640
#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 h,w;
  cin >> h >> w;
  vector<vector<int>> c(10,vector<int>(10));
  vector<vector<int>> a(h,vector<int>(w));
  rep(i,10){rep(j,10){ cin>>c[i][j]; }}
  rep(i,h){rep(j,w){ cin>>a[i][j]; }}

  rep(k,10){rep(i,10){rep(j,10){
    if(c[i][j]>c[i][k]+c[k][j]){c[i][j]=c[i][k]+c[k][j];}
  }}}
  ll ans=0;
  rep(i,h){rep(j,w){
    if(a[i][j]==1 || a[i][j]==-1){ continue; }
    ans += c[a[i][j]][1];
  }}

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


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

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

    for(int i=1; i<4; i++){
        if(S[i]==S[i-1]){
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    cout<<"Good"<<endl;
}


Measured memory_bytes: 3612
n = int(input())
a = list(map(int, input().split()))
left = 0
right = 0
for i in range(n):
  left += a[i]
  left %= (10**9+7)
for j in range(n):
  right += a[j]
  right %= (10**9+7)
c = (left*right)%(10**9+7)
l = [(k**2)%(10**9+7) for k in a]
print(((c+(10**9+7)-sum(l)%(10**9+7))*pow(2, 10**9+5, 10**9+7))%(10**9+7))

Measured memory_bytes: 31448
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
#define mp make_pair
pair<int,int> xy[100001];
struct node{int x,y,id;}nod[100001];
inline bool cmp_x(node x,node y){return x.x<y.x;}
inline bool cmp_y(node x,node y){return x.y<y.y;}
bool cmp_e(pair<int,int> x,pair<int,int> y){
	int x1=x.X,y1=x.Y,x2=y.X,y2=y.Y;
	int a=min(abs(xy[x1].X-xy[y1].X),abs(xy[x1].Y-xy[y1].Y)),
	b=min(abs(xy[x2].X-xy[y2].X),abs(xy[x2].Y-xy[y2].Y));
	return a<b;
}
vector<pair<int,int> > edg;
int fat[100001];
int ance(int x){return fat[x]==x?x:fat[x]=ance(fat[x]);}
void merge(int x,int y){fat[ance(x)]=ance(y);}
int main(){
	int n,i,cnt=0,sum=0;scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d%d",&xy[i].X,&xy[i].Y),nod[i]=(node){xy[i].X,xy[i].Y,i};
	sort(nod+1,nod+n+1,cmp_x);for(i=1;i<n;i++)edg.pb(mp(nod[i].id,nod[i+1].id));
	sort(nod+1,nod+n+1,cmp_y);for(i=1;i<n;i++)edg.pb(mp(nod[i].id,nod[i+1].id));
	sort(edg.begin(),edg.end(),cmp_e);
	for(i=1;i<=n;i++)fat[i]=i;
	for(i=0;;i++){
		if(cnt==n-1)return !printf("%d\n",sum);
		int x=edg[i].X,y=edg[i].Y;
		if(ance(x)==ance(y))continue;
//		cout<<x<<" "<<y<<"\n";
		cnt++;merge(x,y);
		sum+=min(abs(xy[x].X-xy[y].X),abs(xy[x].Y-xy[y].Y));
	}
}
/*1
3
1 5
3 9
7 8
*/
/*2
6
8 3
4 9
12 19
18 1
13 5
7 6
*/

Measured memory_bytes: 4340
#include <stdio.h>
#include <bits/stdc++.h>
#define ll long long
using namespace std;


ll a, b, c, firstDivisble, lastDivisible ;

ll solution(ll int A,ll int B,ll int K) {
/*
  ll  int cnt=0;
    if( A%K==0 or B%K==0)
        cnt++;
    if(A>=K)
        cnt+= (B - A)/K;
    else
        cnt+=B/K;

    return cnt;
    */
    ll int div, div1;
    div= A%K == 0 ? A : A + (K - A%K);
         div1 = B%K == 0 ? B : B - B%K; //B/K behaves this way by default.
        return (div1 - div)/K + 1;
}
void init(){
	scanf("%lld", &a);
	scanf("%lld", &b);
	scanf("%lld", &c);
	if(a > b){
		printf("0\n");
	}
	printf("%lld\n", solution(a, b, c));
}

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

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N, M;
	cin >> N >> M;
	string ans;
	if (N == M) {
		ans = "Yes";
	}
	else {
		ans = "No";
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N, K, sum = 1, Ans = 1;
	scanf("%d%d", &N, &K);
	while(1)
	{
		sum = sum + (sum - 1) / K + 1;//強度チェック 
		if (sum > N)//個数をすぎたら
		{
			printf("%d\n", Ans);
			return 0;
		}
		Ans++;//ループするたびに段数が増える
	}
}




Measured memory_bytes: 2100
def m():
    N = int(input())
    A = [0] + list(map(int, input().split()))
    X = [0] * (N+1)
    for i in range(N, 0,-1):
        p = 0
        for j in range(i, N+1, i):
            if X[j]: p +=1
        if p % 2 != A[i]:
            X[i] = 1
    M = X.count(1)
    print(M)
    for i in range(1, N+1):
        if X[i] == 0:
            continue
        print(i, end=' ')
    return

m()

Measured memory_bytes: 98588
#include "bits/stdc++.h"

#define INF 99999999
#define FER 0.0000000001

using namespace std;

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

struct Edge
{
	int s, t, w;
	Edge(int s,int t,int w):s(s),t(t),w(w){}
	Edge() :Edge(-1, -1, -1) {}
	bool operator<(const Edge& e)const
	{
		return w != e.w ? w < e.w : (s != e.s ? s < e.s : t < e.t);
	}
};


struct P
{
	double x, y;
	P(double x, double y) :x(x), y(y) {}
	P() :P(0, 0) {}
	P operator+(const P& v)const
	{
		return P(x + v.x, y + v.y);
	}
	P operator-(const P& v)const
	{
		return P(x - v.x, y - v.y);
	}
	P operator*(const double v)const
	{
		return P(x*v, y*v);
	}
	bool operator==(const P& v)const
	{
		return abs(x - v.x) <= 0.0000000000001&&abs(y - v.y) <= 0.00000000000001;
	}
	bool operator!=(const P& v)const
	{
		return abs(x - v.x) > 0.0000000000001 || abs(y - v.y) > 0.00000000000001;
	}

	double dot(const P& v)const
	{
		return x*v.x + y*v.y;
	}
	double cross(const P& v)const
	{
		return x*v.y - y*v.x;
	}
	double length()const
	{
		return sqrt(x*x + y*y);
	}
	double length2()const
	{
		return (x*x + y*y);
	}

	bool operator<(const P& v)const
	{
		return x<v.x || (x == v.x) && y < v.y;
	}
	bool operator>(const P& v)const
	{
		return x>v.x || (x == v.x) && y > v.y;
	}
};

struct Rectangle
{
	int h;
	int p;
	Rectangle(int h,int p):h(h),p(p){}
};

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

	ll N, K, L, R;
	cin >> N >> K >> L >> R;

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

	vector<vector<ll>> va(N + 1), vb(N + 1);
	va[0].push_back(0);
	vb[0].push_back(0);

	for (int i = 0; i < (N / 2); i++)
	{
		for (int k = K - 1; k >= 0; k--)
		{
			for (int j = 0; j != va[k].size(); j++)
			{
				va[k + 1].push_back(va[k][j] + a[i]);
			}
		}
	}

	for (int i = (N / 2); i < N; i++)
	{
		for (int k = K - 1; k >= 0; k--)
		{
			for (int j = 0; j != vb[k].size(); j++)
			{
				vb[k + 1].push_back(vb[k][j] + a[i]);
			}
		}
	}

	ll ans = 0;
	for (int k = 0; k <= K; k++)
	{
		sort(va[k].begin(), va[k].end());
		sort(vb[K - k].begin(), vb[K - k].end());
		for (int j = 0; j != va[k].size(); j++)
		{
			ans += (upper_bound(vb[K - k].begin(), vb[K - k].end(), R - va[k][j]) - lower_bound(vb[K - k].begin(), vb[K - k].end(), L - va[k][j]));
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 23572
# ref https://atcoder.jp/contests/abc153/submissions/9758833
# ref http://drken1215.hatenablog.com/entry/2020/01/26/225000

# coding: utf-8
H, N = map(int, input().split())
A = [0]
B = [0]

for i in range(N):
    a, b = (list(map(int, input().split())))
    A.append(a)
    B.append(b)

dp = [[float('inf') for i in range(H+1)] for j in range(N+1)]

for i in range(N+1):
    dp[i][0] = 0

for i in range(1, N+1):
    for j in range(1, H+1):
        dp[i][j] = min(dp[i-1][j],
                       dp[i-1][max(j-A[i], 0)] + B[i],
                       dp[i][max(j-A[i], 0)] + B[i])
        #print(dp[i-1][j],dp[i-1][max(j-AB[i][0],0)] + AB[i][1],dp[i][max(j-AB[i][0],0)] + AB[i][1])


print(dp[N][H])


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

int main() {
    string S; cin >> S;
    int K; cin >> K;
    int N = S.length();
    vector<string> ans;
    string tmp;
    for (int i = 0; i < N; i++) {
        tmp = S[i];
        ans.push_back(tmp);
        for (int j = i+1; j < N; j++) {
            if (j-i >= K) break;
            tmp += S[j];
            ans.push_back(tmp);
        }
    }
    sort(ans.begin(), ans.end());
    int now = 0, cnt = 0;
    if (K == 1) {
        cout << ans[0] << endl;
        return 0;
    }
    while (cnt < K) {
      if (now+1 >= ans.size()) break;
        if (ans[now] != ans[now+1]) {
            cnt++;
            if (cnt == K) break;
        }
        now++;
    }
    cout << ans[now] << endl;
}


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

const int mx = 1000005;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> cnt(mx);
    for (int x : a) {
      if (cnt[x] != 0) {
        cnt[x] = 2;
        continue;
      }
      for (int i = x; i <= mx; i += x) {
        cnt[i]++;
      }
    }
    int ans = 0;
    for (int x : a) {
      if (cnt[x] == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7960
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        int n;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        int i = 1;
        while(i <= n){
            int x = i;
            if ( x % 3 == 0 ){
                System.out.print(" " + i);
                i++;
                continue;
            }
            while(x != 0){
                if ( x % 10 == 3 ){
                    System.out.print(" " + i);
                    break;
                }
                x /= 10;
            }
            i++;
        }
        System.out.println();
}

}

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

int main() {
  int a;
  cin >> a;
  int b = a / 100;
  int c = (a - (b * 100)) / 10;
  int d = (a - (b * 100) - (c * 10)) / 1;
  cout << (b + c + d) << endl;
}


Measured memory_bytes: 256
(t=[1e9]*9<<m=0
d=(0..9).map{t=t.rotate -1}
$_.to_i.times{a,b,c=gets.split.map &:to_i;m=[a,b,m].max;d[a][b]=d[b][a]=c}
r=0..m
r.map{|k|r.map{|i|r.map{|j|d[i][j]>(t=d[i][k]+d[k][j])&&d[i][j]=t}}}
puts r.map{|i|s=0;r.map{|j|s+=d[i][j]};[i,s]}.min_by{|i,s|[s,i]}*" ")while gets>?1

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

int main() {
    int N;
    cin >> N;
    int x=0;
    int a=0;
    int ans;
for(int i=0; true; ++i){
a=pow(2,i);
x=i;
if (a > N) break;
}
ans=pow(2,x-1);
    cout << ans << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll n,m,k;

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	cout<<b+min(c,a+b+1)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<(int)y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=998244353;
const int siz=2e5;
const int inf=1e9;
int main(){
	string s; int K; cin>>s>>K;
	s += "0"; K = min(K, 300);
	vector<int> v(1, 0);
	int cnt = 0;
	rep(i,0,s.size()){
		if(s[i] == '0') v.push_back(cnt);
		else cnt++;
	}for(int i = v.size()-1; i > 0; i--) v[i] -= v[i-1];
	long dp[v.size()][301][301] = {}; dp[0][0][0] = 1;
	int sum = 0;
	rep(i,1,v.size()){
		sum += v[i];
		rep(j,0,K+1){
			rep(k,0,v[i])rep(l,sum,cnt+1) (dp[i][j][l] += dp[i-1][j][l-k]) %= mod;
			rep(k,v[i],cnt-sum+v[i]+1)rep(l,max(k,sum),cnt+1) (dp[i][j][l] += dp[i-1][j-k+v[i]][l-k]) %= mod;
		}
	}
	long ans = 0;
	rep(j,0,K+1) (ans += dp[v.size()-1][j][cnt]) %= mod;
	cout<<ans<<endl;
}

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

int main(){
  while(true){
    int mt,n;
    cin>>mt;
    if(mt==0){
      break;
    }
    cin>>n;
    int st,et,total=0;
    for(int i=0;i<n;i++){
      cin>>st>>et;
      total=total+et-st;
    }
    if(total>=mt){
      cout<<"OK"<<endl;
    }else if(total<mt){
      cout<<mt-total<<endl;
    }
  }
  
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

bool is_lower(char &c){
  if('a' <= c && c <= 'z'){
    return true;
  }
  return false;
}

bool is_upper(char &c){
  if('A' <= c && c <= 'Z'){
    return true;
  }
  return false;
}

void to_lower(char &c){
  c += 'a' - 'A';
}

void to_upper(char &c){
  c += 'A' - 'a';
}

int main(){
  string str;
  getline(cin,str);
  for(auto c : str){
    if(is_lower(c)){
      to_upper(c);
    }else if(is_upper(c)){
      to_lower(c);
    }
    printf("%c",c);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 3168
{-# LANGUAGE CPP #-}
module Main where

import qualified Data.Vector.Unboxed as V 
import qualified Data.Map.Strict as M
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.Char
import qualified Data.List as L

dump :: (Show a) => a -> IO()
#if __GLASGOW_HASKELL__ >= 800
dump x = print x
#else
dump _ = pure ()
#endif

-- "101010" -> [1,0,1,0,1,0]
readToList :: String -> [Int]
readToList [] = []
readToList (x:xs) = read [x] : readToList xs

 
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getInt :: IO Int
getInt = readInt <$> BS.getLine

-- "10 10 10" -> [10, 10, 10]
getlist :: IO [Int]
getlist = (fmap (read . BS.unpack) . BS.words) <$> BS.getLine

-- "10 10 10" -> [10, 10, 10]
getIntVec :: Int -> IO (V.Vector Int)
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readmat :: Int -> IO [[Int]]
readmat rows = replicateM rows getlist

newtype UF a = UF (M.Map a a) deriving (Show) -- Map node parent

makeuf :: Int -> UF Int
makeuf n = let m = M.fromList $ zip [0..n] [0..n]
                in UF m

union :: (Eq a, Ord a) => a -> a -> UF a -> UF a
union l r uf@(UF m) = let lp = find l uf
                          rp = find r uf
                      in if lp == rp
                         then uf
                         else if size l uf < size r uf
                              then UF $ M.update (const $ Just rp) lp m
                              else UF $ M.update (const $ Just lp) rp m

find :: (Eq a, Ord a) => a -> UF a -> a
find x uf@(UF m) = let px = m M.! x
                in if px == x
                   then px
                   else find px uf -- TODO 貼り直し

size :: (Eq a, Ord a) => a -> UF a -> Int
size x (UF m) = M.size $ M.filter (\par -> par==x) m

genbit :: Int -> [[Int]]
genbit 0 = []
genbit 1 = [[0],[1]]
genbit len = do
  x <- [0,1]
  map (x:) $ genbit (len-1)

base :: Int
base = 10 ^ 9 + 7

forn :: (Num a, Enum a, Monad m) => a -> (a -> m b) -> m [b]
forn x = forM [0..(x-1)]

count :: (Eq a) => a -> [a] -> Int
count y = length . filter (== y)

main :: IO()
main = do
  a <- getInt
  b <- getInt
  print $ 6-a-b


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define rep(i,j,k) for(int i=j;i<k;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1LL;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

main(){
    fastio;
    string a,b;
    cin >> a >> b;
    int na = a.size(),nb = b.size();
    int tab[na+1][nb+1];
    for(int i=0;i<=na;i++)
        tab[i][0]=0;
    for(int i=0;i<=nb;i++)
        tab[0][i]=0;
    for(int i=1;i<=na;i++){
        for(int j=1;j<=nb;j++){
            if(a[i-1]==b[j-1]){
                tab[i][j]=tab[i-1][j-1]+1;
            }
            else tab[i][j]=max(tab[i-1][j],tab[i][j-1]);
        }
    } // fim do calculo do tamanho
    string resp = "";
    int at = tab[na][nb];
    int i = na,j=nb;
    while(at){ // construindo a string resposta
        while(tab[i][j]==tab[i][j-1]){
            j--;
        }
        while(tab[i][j]==tab[i-1][j]){
            i--;
        }
        resp+=a[i-1];
        i--;
        j--;
        at = tab[i][j];
    }
    reverse(resp.begin(),resp.end()); // string da lcs
    cout << resp << endl;
    
}

Measured memory_bytes: 70656
import sys
N = int(input())
a = [-1]*N**2
x = list(map(lambda x:int(x)-1, input().split()))
x = list(zip(x, list(range(1, N+1))))
x.sort()
now = 0
for v, i in x:
    if a[v]>=0:
        print('No')
        sys.exit()
    a[v] = i
    cnt = 0
    while cnt < i-1:
        if now==v:
            print('No')
            sys.exit()
        if a[now]<0:
            a[now] = i
            cnt+=1
        now+=1
now = N*N-1
for v, i in reversed(x):
    cnt = 0
    while cnt<N-i:
        if now<=v:
            print('No')
            sys.exit()
        if a[now]<0:
            a[now] = i
            cnt+=1
        now-=1
if all(v >= 0 for v in a):
    print('Yes')
    print(*a)
else:
    print('No')

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

using namespace std;

#define endl '\n'

int main(){

  ios_base :: sync_with_stdio(false);
  cin.tie(NULL);
  
 int n,k;

 cin >> n >> k;
 int cnt[n+1] = {0};

 for(int i=0;i<k;i++){
   int d;
   cin >> d;
   while(d--){
     int a;
     cin >> a;
     cnt[a]++;
   }
 }

 int ans = 0;

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

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

Measured memory_bytes: 3648
/******************************************
* AUTHOR : SHUBHAM KUMAR *
* NICK : { "CODECHEF" : "SCHELEON",
		   "CODEFORCES" : "SCH3130N" } * 	
* INSTITUTION : BIT MESRA *
******************************************/

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define sd(x) scanf("%lld",&x)
#define ll long long int
#define large 100005
#define MOD 1000000007
#define dd double
#define pb push_back
#define mk make_pair
#define rep0(i,b) for(int i=0;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define pll pair<ll, ll>
#define ld long double
#define vll vector<ll>
#define vpll vector<pll>
#define sortv(v) sort(v.begin(),v.end())  

ll ModE(ll x, unsigned ll y, ll p = MOD) 
{ 
    ll res = 1;
    x = x % p;    
    while (y > 0) 
    {   if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
}

using namespace std;

ll dp[large];

ll solve(ll h[], ll i, ll prev){
	if(i<0)
		return MOD;
	if(i==0)
		return 0;
	if(dp[i]!=MOD)
		return dp[i];
	if(i>=2)
		dp[i] = min(abs(h[i-1]-h[i])+solve(h, i-1, i), abs(h[i-2]-h[i])+solve(h, i-2, i));
	else
		dp[i] = abs(h[i-1]-h[i])+solve(h, i-1, i);
	return dp[i];
		// return dp[i];
}

int main() {
	//#ifndef _DEBUG
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    //freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    //freopen("output.txt", "w", stdout);
	#endif

	fastio
	//ios_base& scientific (ios_base& str);

	//ll T; cin>>T; while(T--){}

	ll n;
	cin>>n;
	ll h[n];
	rep0(i,n){
		cin>>h[i];
		dp[i]=MOD;
	}
	cout<<solve(h, n-1, n-1);
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define endl '\n';
typedef long long ll;
typedef long double ld;
using namespace std;

const int N = 1e5 + 10;
int d[N];
int n;

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &d[i]);
  }
  sort(d, d + n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0 || (d[i - 1] != d[i])) {
      if (i == n - i) {
        cnt += d[i] - d[i - 1];
      }
    }
  }
  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 0x3f3f3f3f
#define MOD 998244353
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
int n;
pii d[MN];
ll cnt[MN];

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

    cin >> n;
    FOR(i, 1, n){
        cin >> d[i].f;
        d[i].s = i;
        if(d[i].f == 0 && i != 1){
            cout << "0\n";
            return 0;
        }
    }
    if(d[1].f != 0){
        cout << "0\n";
        return 0;
    }
    sort(d+1, d+n+1);
    ll ans = 1;
    FOR(i, 1, n){
        if(d[i].f-1>=0){
            ans = ans*(cnt[d[i].f-1]);
            ans %= MOD;
        }
        ++cnt[d[i].f];
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

#define MAX 10000
#define NIL -1

typedef struct { int parent, left, right;} Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u,int d) {
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL)
    h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

// 接点 u の兄弟を返す
int getSibling(int u) {
  if( T[u].parent == NIL ) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL )
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL )
    return T[T[u].parent].right;
  return NIL;
}

void print(int u) {
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg = 0;
  if(T[u].left  != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  
  if(T[u].parent == NIL) {
    printf("root\n");
  } else if(T[u].left == NIL && T[u].right == NIL) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main(void) {
  int v, l, r, root = 0;
  scanf("%d",&n);
  for(int i=0;i<n;i++) T[i].parent = NIL;
  for(int i=0;i<n;i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].left  = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }
  
  for(int i=0; i<n; i++)
  if(T[i].parent == NIL) root = i;
  
  setDepth(root,0);
  setHeight(root);
  
  for(int i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 2048
# coding: utf-8
# Your code here!
N=int(input())

l=[]
for _ in range(N):
    x,y=map(int,input().split())
    l.append([x,y])

i=0
ans=0
for i in range(N):
    for j in range(N):
        if i==j:
            pass
        else:
            ans+=((l[i][0]-l[j][0])**2+(l[i][1]-l[j][1])**2)**0.5


print(ans/(N**2-N)*(N-1))


Measured memory_bytes: 3064