akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long  
#define all(x) x.begin(),x.end()

int const N = 3e5+1;
string s ; 

int main(){ 
     cin >> s; 
    // "keyence"
    int n = s.size();
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
           string rem = s.substr(i,j);
           string cur = "";
           for(int k=0;k<n;++k){
              if(k >= i  && k <= j)continue;
              cur += s[k];
           }
           if(cur == "keyence")return puts("YES"),0;
        }
    }
    puts("NO");
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc145/tasks/abc145_e

#include "algorithm"
#include "functional"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, T;
  cin >> N >> T;
  VPL fs(N);

  rep(i, N) {
    ll a, b;
    cin >> a >> b;
    fs[i] = {a, b};
  }

  sort(all(fs));

  ll MAX = 6000;
  // dp[i][j][k] i (>=1) 番目の料理までだけを考えた時の、注文後 j
  // 分以下となる美味しさの最大値. k は i 番目を使用したかどうか
  V<VVL> dp(N + 1, VVL(MAX + 1, VL(2)));

  repf(i, 1, N + 1) {
    PL f = fs[i - 1];
    ll time = f.first;
    ll del = f.second;

    rep(j, MAX + 1) {
      ll pm = max(dp[i - 1][j][0], dp[i - 1][j][1]);
      rep(k, 2) chmax(dp[i][j][k], pm);

      if (time <= j && j - time < T) {
        chmax(dp[i][j][1], dp[i][j - time][0] + del);
      }
    }
  }

  ll res = 0;
  rep(i, MAX + 1) rep(k, 2) { chmax(res, dp[N][i][k]); }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 995584
#include<bits/stdc++.h>
using namespace std;
int ans[107][107];
int main(){
    int n;
    scanf("%d",&n);
    int sum=0;
    if(n&1){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(j!=n-i&&j>i){
                    ans[i][j]=1;
                    sum++;
                }
            }
        }
        printf("%d\n",sum);
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(ans[i][j]==1)
                    printf("%d %d\n",i,j);
            }
        }
    }
    else{
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(j!=n+1-i&&j>i){
                    ans[i][j]=1;
                    sum++;
                }
            }
        }
        printf("%d\n",sum);
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(ans[i][j]==1)
                    printf("%d %d\n",i,j);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn solve(n: i32, pn: Vec<i32>) -> i32 {
    let mut fs: Vec<bool> = Vec::new();
    for i in 0..n {
        fs.push(pn[i as usize] == i + 1);
    }

    let mut r = 0;
    for i in 0..n {
        if fs[i as usize] {
            r += 1;

            if i != n - 1 {
                fs[(i+1) as usize] = false;
            }
        }
    }

    r
}

fn main() {
    input!{
        n: i32,
        pn: [i32; n]
    }

    println!("{:?}", solve(n, pn));
}


Measured memory_bytes: 4352
A=int(input())
B=int(input())
C=int(input())
X=int(input())
cont = 0
total = 0
a = 500
b = 100
c = 50
for i in range(0,A+1):
    for j in range(0,B+1):
        for k in range(0,C+1):
            total = a*i + b*j + c*k
            if total == X:
                cont += 1
print(cont)

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

int main() {
    int d,n;
    cin >> d >> n;
    int a=1;
    if(d==1) a=100;
    else if(d==2) a=10000;
    if(n==100){
        cout << a*(n+1) << endl;
    }
    else cout << a*n << endl;
}

Measured memory_bytes: 256
def Coins(a , b , c , x):

    count = 0

    for i in range(a+1):
        for w in range(b+1):
            for q in range(c+1):
                if 500*i + 100*w + 50*q == x:
                    count += 1

    return count

def main():
    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input())
    print(Coins(a , b , c , x))

if __name__ == '__main__':
    main()


Measured memory_bytes: 39792
#include <iostream>
#define MAX 1000000
#define min -1000000



using namespace std;

int main(){
    int K, X;
    int left, right;

    //入力
    cin >> K >> X;

    if(X-(K-1) < min){
        left = min;
    }else {
        left = X-K+1;
    }

    if(X+(K-1) > MAX){
        right = MAX;
    }else {
        right = X+K-1;
    }



    //out
    for(int i=left; i<=right;i++) {
        cout << i << " ";
    }


    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int maxCnt = sc.nextInt();
	int[] arr = new int[maxCnt*2];
	for (int i = 0; i < arr.length; i++) {
		arr[i] = sc.nextInt();
	}

	sort(arr, 0, arr.length - 1);

	int sum = 0;
	for(int i = 0; i < maxCnt * 2; i+=2) {
		sum += arr[i+1];
	} 

	System.out.println(sum);
}

private static void sort(int[] arr, int start, int end) {
	if(start >= end) {
		return;
	}

	int originStart = start;
	int originEnd = end;

	int target = arr[start];

	while(start < end) {
		while(start < end && target > arr[end]) {
			end--;
		}
		if(start < end) {
			int temp = arr[end];
			arr[end] = arr[start];
			arr[start] = temp;
		}

		while(start < end && arr[start] >= target) {
			start++;
		}
		if(start < end) {
			int temp = arr[end];
			arr[end] = arr[start];
			arr[start] = temp;
		}
	}

	sort(arr, originStart, start - 1);
	sort(arr, end + 1, originEnd);
}

}




Measured memory_bytes: 21972
a, b, c = map(int, input().split())

if a < b :
    if b < c :
        print(a, b, c)
    elif a < c :
        print(a, c, b)
    else :
        print(c, a, b)
elif b < a :
    if a < c :
        print(b, a, c)
    elif b < c :
        print(b, c, a)
    else :
        print(c, b, a)




Measured memory_bytes: 5596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  int cnt = 0;
  if(A >= B) cout << 1 << endl;
  else {
    while(A < B) {
      B -= A;
      ++cnt;
    }
    ++cnt;
    cout << cnt << endl;
  }
  
}



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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  cout << s[0] << s.size()-2 << s.back() << endl;
  return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS

main = abc159b

abc159b = do
  s <- BS.getLine
  putStrLn $
      let l = BS.length s
       in if cond1 s l && cond2 s l && judge s
          then "Yes"
          else "No"

cond1 :: BS.ByteString -> Int -> Bool
cond1 s n = judge $ BS.take (div (n-1) 2) s

cond2 :: BS.ByteString -> Int -> Bool
cond2 s n = judge $ BS.take (div (n-1) 2) (BS.reverse s)

judge :: BS.ByteString -> Bool
judge s = s == BS.reverse s

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

  cout << abs(n-2)*abs(m-2) << endl;
  // if(n==1 && m==1){
  //   cout << 1 << endl;
  //   return 0;
  // }
  //
  // if(n==1 || m==1){
  //   cout << max(n,m)-2 << endl;
  //   return 0;
  // }
  //
  // cout << max(0L,n-2) * max(0L,m-2) << endl;

  return 0;
}


Measured memory_bytes: 256
import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
cnt = 0
info1 = []


for i in range(n):
    b_p = bisect.bisect_left(a, b[i])
    info1.append(b_p) # bがそれぞれ何種類のaを載せれるか

info2 = [info1[0]]
for l in range(1, n):
    info2.append(info2[l-1] + info1[l])

for k in range(n):
    a_p = bisect.bisect_left(b, c[k])
    if a_p != 0:
        cnt += info2[a_p - 1]  # cがそれぞれ何種類のbを載せれるか
print(cnt)


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

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

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

char c[MAXN];

void solve(){
	int n;
	scanf("%s", &c[0]);
	n = strlen(c);
	int ans = n;
	REP(i, 1, n) {
		if (c[i] != c[i - 1]) {
			ans = min(ans, max(i, n - i));
		}
	}
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    vector<ll> S(N+1, 0);
    REP(i, N) S[i+1] = S[i] + A[i];

    map<ll, ll> mp;
    ll res = 0;
    REP(i, N+1){
    	res += mp[S[i]];
    	mp[S[i]]++;
    }
    cout << res << endl;
    return 0;

}

Measured memory_bytes: 15872
def main():
    n, m = map(int, input().split())
    a = [0]*(n+1)
    for _ in range(m):
        x, y = map(int, input().split())
        a[x] += 1
        a[y] += 1
    f = True
    for i in range(n+1):
        if a[i] % 2 == 1:
            f = False
            break
    if f:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3828
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	long a, b;
	String[] input;
	while (scan.hasNext()){
	    input = scan.nextLine().split(" ");
	    a = Integer.parseInt(input[0]);
	    b = Integer.parseInt(input[1]);
	    long lcm = solveLCM(a, b);
	    long gcd = solveGCD(a, b);
	    System.out.println(gcd + " " + lcm);
	}
    }
    static long solveGCD (long a, long b) {
	long gcd = a % b;
	if (gcd == 0) {
	    return b;
	}
	return solveGCD(b, gcd);
    }

    static long solveLCM (long a, long b) {
	if (a == 0 || b == 0) {
	    return 0;
	}
	return a * b / solveGCD(a,b);
    }
}

Measured memory_bytes: 25884
#define _GLIBCXX_DEBUG
#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++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000000
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

struct edge {
  int to;
  int id;
  bool operator<(const edge &another) const{
    return id < another.id;
  };
};

vector<pair<int, vector<edge>>> graph;

int main(){
  int N, M;
  cin >> N >> M;
  graph.resize(N);
  rep(i, N){
    vector<edge> vt(0);
    graph.at(i) = make_pair(i, vt);
  }
  vector<int> a(M);
  vector<int> b(M);
  rep(i, M){
    cin >> a.at(i) >> b.at(i);
    a.at(i)--;
    b.at(i)--;
    graph.at(a.at(i)).second.push_back({b.at(i), i});
    graph.at(b.at(i)).second.push_back({a.at(i), i});
  }
  int ans = 0;
  bool cnc = false;
  sort(all(graph));
  do {
    if(graph.at(0).first != 0){
      continue;
    }
    rep(i, N-1){
      rep(j, sz(graph.at(i).second)){
        if(graph.at(i).second.at(j).to == graph.at(i+1).first){
          cnc = true;
        }
      }
      if(!cnc){
        break;
      }
      if(i == N-2){
        ans++;
      }
      cnc = false;
    }
  } while (next_permutation(all(graph)));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


struct StronglyConnectedComponents{
    vector<int> used,cmp,vs;
    vector<vector<int>> v,rv;
    StronglyConnectedComponents(int n):used(n),cmp(n,-1),v(n),rv(n){}

    void add_edge(int x,int y){
        v[x].push_back(y);
        rv[y].push_back(x);
    }
    void dfs(int x){
       used[x]=true;
       for(auto to:v[x])if(!used[to])dfs(to);
       vs.push_back(x);
    }

    void rdfs(int x,int k){
       cmp[x]=k;
       for(auto to:rv[x])if(cmp[to]==-1)rdfs(to,k);
    }

    void build(vector<vector<int>> &g){
       rep(i,used.size())if(!used[i])dfs(i);
       reverse(vs.begin(),vs.end());
       int k=0;
       for(auto x:vs)if(cmp[x]==-1)rdfs(x,k++);
       g.resize(k);
       rep(i,v.size()){
           for(auto& to:v[i]){
               int x=cmp[i],y=cmp[to];
               if(x!=y)g[x].push_back(y);
           }
       }
    }
};
int main(){
    int n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    StronglyConnectedComponents scc(2*n);
    rep(i,m){
        int x,y;
        cin>>x>>y;
        --x;--y;
        if(s[x]==s[y]){
            scc.add_edge(x,y+n);
            scc.add_edge(y,x+n);
        }
        else {
            scc.add_edge(x+n,y);
            scc.add_edge(y+n,x);
        }
    }
    vector<vector<int>> ret;
    scc.build(ret);
    cout<<(ret.size()==2*n?"No":"Yes")<<endl;
    return 0;
}

Measured memory_bytes: 55924
import java.util.Scanner;

public class Main {
//http://agc010.contest.atcoder.jp/tasks/agc010_a
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if(A == 1 && B != 1){
			System.out.println("Alice");
		}
		else if(B == 1 && A != 1){
			System.out.println("Bob");
		}
		else{
			if(A > B){
				System.out.println("Alice");
			}
			else if(B > A){
				System.out.println("Bob");
			}
			else{
				System.out.println("Draw");
			}
		}
	}
}

Measured memory_bytes: 25172
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int N;
int x_1[210], y_1[210];
int x_2[210], y_2[210];
int main(){
  fill(x_1, x_1+210, -1);
  fill(y_1, y_1+210, -1);
  fill(x_2, x_2+210, -1);
  fill(y_2, y_2+210, -1);

  int a[200], b[200], c[200], d[200];
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> a[i] >> b[i];
    x_1[a[i]] = i; y_1[b[i]] = i;
  }
  for(int i = 0; i < N; i++){
    cin >> c[i] >> d[i];
    x_2[c[i]] = i; y_2[d[i]] = i;
  }

  int count = 0;
  for(int i = 2*N-1; i >= 0; i--){
    if(x_1[i] == -1) continue;
    int j_min = -1;
    int mi = 1000;
    for(int j = i+1; j < 2*N; j++){
      if(x_2[j] == -1) continue;
      if(b[x_1[i]] < d[x_2[j]]){
        if (d[x_2[j]] < mi){
          mi = d[x_2[j]];
          j_min = j;
        }
      }
    }
    if(j_min != -1){
      x_2[j_min] = -1;
      count++;
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			a[i] = sc.nextInt();
		}
		int[] ans = new int[n + 1];
		int count = 0;
		for (int i = n; i > 0; i--) {
			int sum = 0;
			for (int j = 1; i * j <= n; j++) {
				sum += ans[i * j];
			}
			if (sum % 2 != a[i]) {
				ans[i] = 1;
				count++;
			}
		}
		System.out.println(count);
		for (int i = 1; i <= n; i++) {
			if (ans[i] == 1) {
				System.out.println(i);
			}
		}
	}
}

Measured memory_bytes: 81300
N = int(input()) #1行目のNを取得する
s = [int(input()) for i in range(N)] #複数行の数値の入力を取得
num = len(s)
s1 = sorted(s,reverse=True)[:2]
for i in range(num):
    if s1[0] == s[i]:
        print(s1[1])
    else:
        print(s1[0])

Measured memory_bytes: 13316
# frozen_string_literal: true

# induce sort (internal routine)
def sa_is_induce(s, ls, sum_l, sum_s, lms)
  n = s.size
  sa = [-1]*n

  buf = *sum_s # deep copy
  lms.each{ |lms|
    if lms != n then
      sa[buf[s[lms]]] = lms
      buf[s[lms]] += 1
    end
  }

  buf = *sum_l # deep copy
  sa[buf[s[-1]]] = n-1
  buf[s[-1]] += 1
  sa.each{ |v|
    if v>=1 && !ls[v-1] then
      sa[buf[s[v-1]]] = v-1
      buf[s[v-1]] += 1
    end
  }

  buf = *sum_l # deep copy
  sa.reverse_each{ |v|
    if v>=1 && ls[v-1] then
      buf[s[v-1]+1] -= 1
      sa[buf[s[v-1]+1]] = v-1
    end
  }

  return sa
end

# SA-IS (internal routine)
def sa_is(s, upper)
  n = s.size

  return [] if n == 0
  return [0] if n == 1

  ls = [false]*n
  (n-2).downto(0){ |i|
    ls[i] = s[i]==s[i+1] ? ls[i+1] : s[i]<s[i+1]
  }

  sum_l = [0]*(upper+1)
  sum_s = [0]*(upper+1)
  n.times{ |i|
    if ls[i] then
      sum_l[s[i]+1] += 1
    else
      sum_s[s[i]] += 1
    end
  }
  0.upto(upper){ |i|
    sum_s[i] += sum_l[i]
    sum_l[i+1] += sum_s[i] if i<upper
  }

  lms = (1 ... n).select{ |i| !ls[i-1] && ls[i] }
  m=lms.size
  lms_map = [-1]*(n+1)
  lms.each_with_index{ |lms, id| lms_map[lms] = id }

  sa = sa_is_induce(s, ls, sum_l, sum_s, lms)

  return sa if m == 0

  sorted_lms = sa.select{ |sa| lms_map[sa] != -1 }
  rec_s = [0]*m
  rec_upper = 0
  rec_s[lms_map[sorted_lms[0]]] = 0
  1.upto(m-1){ |i|
    l, r = sorted_lms[i-1, 2]
    end_l = lms[lms_map[l]+1]||n
    end_r = lms[lms_map[r]+1]||n
    same = true
    if end_l-l != end_r-r then
      same = false
    else
      while l < end_l do
        break if s[l] != s[r]
        l+=1
        r+=1
      end
      same = false if l==n || s[l]!=s[r]
    end
    rec_upper += 1 if not same
    rec_s[lms_map[sorted_lms[i]]] = rec_upper
  }

  sa_is(rec_s, rec_upper).each_with_index{ |rec_sa, id|
    sorted_lms[id] = lms[rec_sa]
  }

  return sa_is_induce(s, ls, sum_l, sum_s, sorted_lms)
end

# suffix array for array of integers
def suffix_array(s, upper = nil)
  if not upper then
    # compression
    n = s.size
    idx = (0 ... n).sort_by{ |i| s[i] }
    t = [0]*n
    upper = 0
    t[idx[0]] = 0
    1.upto(n-1){ |i|
      upper += 1 if s[idx[i-1]] != s[idx[i]]
      t[idx[i]] = upper
    }
    s = t
  end
  return sa_is(s, upper)
end

# suffix array for string
def suffix_array(s)
  return sa_is(s.bytes, 255)
end

# lcp array for array of integers
def lcp(s, sa)
  n = s.size
  rnk = [0]*n
  sa.each_with_index{ |sa, id|
    rnk[sa] = id
  }
  
  lcp = [0]*(n-1)
  h = 0
  n.times{ |i|
    h -= 1 if h > 0
    next if rnk[i] == 0
    j = sa[rnk[i]-1]
    h += 1 while j+h<n && i+h<n && s[j+h]==s[i+h]
    lcp[rnk[i]-1] = h
  }
  return lcp
end

# lcp array for string
def lcp_array(s, sa)
  return lcp(s.bytes, sa)
end

s = gets.chomp
lcp = lcp_array(s, suffix_array(s))
ans = s.size*(s.size+1)/2
lcp.each{ |lcp|
  ans -= lcp
}
puts ans


Measured memory_bytes: 67448
//gcc -std=gnu11 -O2 -o a.out Main.c -lm

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//#define	dbgPrint	printf
#define	dbgPrint	

int main(void)
{
	unsigned long a, b, x;
	unsigned long min, max;
	int ret;
	
	ret = scanf("%ld %ld %ld", &a, &b, &x);
	
	min = (a + x - 1) / x;
	max = b / x;
	
	printf("%ld\n", max-min+1);
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#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++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n;
	cin >> n;
	int h1;
	cin >> h1;

	int ans = 0, cnt = 0;
	rep(_, n - 1) {
		int h2;
		cin >> h2;
		if (h1 >= h2)
			cnt++;
		else
			cnt = 0;
		chmax(ans, cnt);
		h1 = h2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
N,M,V,P = map(int,input().split())
A = list(map(int,input().split()))
#%%
As = sorted(A)
border = As[-P]
upbound = N-P
lowbound = N-P
while As[upbound] == border:
    upbound += 1
    if upbound > N-1:break
while As[lowbound] == border:
    lowbound -= 1
    if lowbound < 0:break

upbound -= 1
lowbound += 1
    
def isOK(mid):
    if mid>= lowbound: return True
    if mid==N-1: return True
    if (border-As[mid])>M:
        return False
    
    S = sum(As[mid+1:upbound+1])-As[mid]*(upbound-mid)
    U = M*(N-V)
    if S>U:
        return False
    else:
        return True

def bsearch():
    ng = -1
    ok = N
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if isOK(mid):
            ok = mid
        else :
            ng = mid
    return ok


key = bsearch()

print(N-key)

Measured memory_bytes: 14480
#include <atcoder/all>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long


string s;

int main(){
    cin>>s;
    auto sa = atcoder::suffix_array(s);
    auto la = atcoder::lcp_array(s,sa);
    LL ret = 0;
    REP(i,s.size())ret+=(i+1);
    REP(i,la.size())ret-=la[i];
    cout<<ret<<endl;
}

Measured memory_bytes: 15672
s = input()
a = [0]*(len(s)+1)

for i in range(len(s)):
  if s[i] == '<':
    a[i+1] = max(a[i+1],a[i]+1)

for i in range(len(s)-1,-1,-1):
  if s[i] == '>':
    a[i] = max(a[i],a[i+1]+1)
print (sum(a))

Measured memory_bytes: 23452
N[101];main(i,j,n,S){
	for(;scanf("%d%d",&n,&S),n;printf("%d\n",n)){
		for(memset(N,0,404),i=0;i<n;i++)scanf("%d",&j),N[j]++;
		for(n=0,i=101;i>0;i--)if(N[i]){
				if(i*2>S)n+=N[i]*(N[i]-1)/2;
				for(j=i-1;j>0&&i+j>S;j--)n+=N[i]*N[j];
		}
	}
	return 0;
}

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

const int MAXN = 2e5 + 5;

int n, k;
int a[MAXN];

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


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

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

using namespace std;
using lint=long long;

lint solve(vector<pair<int,int>> a){
	sort(a.begin(),a.end());

	lint ans=0;
	priority_queue<int,vector<int>,greater<>> Q;
	for(auto [k,d]:a){
		Q.emplace(d);
		ans+=d;
		while(Q.size()>k) ans-=Q.top(), Q.pop();
	}
	return ans;
}

int main(){
	int q; scanf("%d",&q);
	rep(_,q){
		int n; scanf("%d",&n);
		lint sum=0;
		vector<pair<int,int>> L,R;
		rep(i,n){
			int k,l,r; scanf("%d%d%d",&k,&l,&r);
			if     (l>r) L.emplace_back( k ,l-r), sum+=r;
			else if(r>l) R.emplace_back(n-k,r-l), sum+=l;
			else         sum+=l;
		}
		printf("%lld\n",sum+solve(L)+solve(R));
	}

	return 0;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  int minx=1001,maxx=-1;
  for(int i=0;i<N;++i){
    int A;
    cin >> A;
    if(minx >A) minx = A;
    if(maxx <A) maxx = A;
  }
  cout << maxx-minx << endl;
  return 0;
}

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

int compare_string(const void *a, const void *b) {
  return strcmp(( char * )a , ( char * )b );
}

int main(void){
  int i,j;
  char ii[200000][11];
  int len,flg;
  int cnt,maxcnt;
  scanf("%d",&len);
  for(i=0;i<len;i++){
    scanf("%s\n",ii[i]);
  }

  qsort(ii,  len,sizeof(ii[0]), compare_string);
  
  maxcnt = 1;	
  cnt = 1;
  for(i=1;i<len;i++){
    if (strcmp(ii[i-1],ii[i]) == 0){
      cnt++;	
      if(maxcnt < cnt){
        maxcnt = cnt;
      }
    }
    else{
      cnt=1;
    }
  }

  cnt = 1;
  for(i=0;i<len;i++){
    if (strcmp(ii[i-1],ii[i]) == 0){
      cnt++;	
    }
    else{
      cnt=1;
    }
      if(maxcnt <= cnt){
        printf("%s\n",ii[i]);
      }
  }
  return 0;
}

Measured memory_bytes: 4476
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
using namespace std;

const int MAX = 100000;

int GCD(int a, int b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return GCD(b, a % b);
}

int main() {
	int N, X;
	int x[MAX];

	cin >> N >> X;

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

	int ans = abs(x[0] - X);
	
	for (int i = 1; i < N; i++) {
		ans = GCD(ans, abs(x[i] - X));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	map<string,vi> m;
	string s;
	int a;
	while(cin>>s>>a){
		m[s].pb(a);
	}
	for(map<string,vi>::iterator it=m.begin();it!=m.end();it++){
		o(it->fi);
		vi v = it->se;
		sort(all(v));
		rep(i,0,v.size()){
			cout<<v[i];
			if(i!=v.size()-1) cout<<" ";
		}
		cout<<endl;
	}
}

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

int main(){
    int n=200010;
    vector<bool> v(n);
    vector<int> p;
    for(int i=2;i<n;++i) v[i]=true;
    v[0]=v[1]=false;
    for(int i=2;i*i<n;++i) if(v[i]) for(int j=i*i;j<n;j+=i) v[j]=false;
    for(int i=2;i<n;++i) if(v[i]) p.emplace_back(i);
    int x;
    cin>>x;
    cout<<*lower_bound(p.begin(),p.end(),x)<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int N;
  cin>>N;
  unordered_map<string, int> u;
  u["AC"] = 0;
  u["WA"] = 0;
  u["TLE"] = 0;
  u["RE"] = 0;
  
  for(int i = 0; i < N; i++)
  {
  	string str = " ";
    cin>>str;
    
    u[str]++;
  }
  
  /*
  for(auto i : u)
  {
  	cout<<i.first<<" x "<<i.second<<endl;
  }
  */
  
  cout<<"AC"<<" x "<<u["AC"]<<endl;
  cout<<"WA"<<" x "<<u["WA"]<<endl;
  cout<<"TLE"<<" x "<<u["TLE"]<<endl;
  cout<<"RE"<<" x "<<u["RE"]<<endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<string>
#include<assert.h>
#include<sstream>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
typedef long long ll;
typedef pair<int, int> pii;
const ll LINF = 1e18 + 7;
const int N = 1e3 + 7;
const int INF = 1e9 + 7;
const int MOD = 21092013;
const double EPS = 1e-8;
//-------------head-------------
char S[N];
int main() {
	scanf(" %s", S);
	int L = strlen(S);
	int w = 0, e = 0, s = 0, n = 0;
	rep(i, 0, L)
		if (S[i] == 'W') {
			w = 1;
		} else if (S[i] == 'E') {
			e = 1;
		} else if (S[i] == 'N') {
			n = 1;
		} else {
			s = 1;
		}
	if (((e ^ w) == 0 && (n ^ s) == 0)) {
		puts("Yes");
	} else {
		puts("No");
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<long long,long long> pint;
typedef long long ll;
const int inf   = 1<<29;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

ll n,k,mi,point,a[100001],sz;
vector<ll> v[100001];
bool used[100001];
void dfs(ll m){
  sz++;
  used[m]=true;
  rep(i,v[m].size()){
    if(!used[v[m][i]])dfs(v[m][i]);
    }
  if(a[m]<mi){
    mi=a[m];
    point=m;
    }
  }

  
int main(){
  cin>>n>>k;
  pint p[n];
  ll l,r;
  rep(i,n){
    cin>>a[i];
    p[i]=pint(a[i],i);
    used[i]=false;
    }
  rep(i,k){
    cin>>l>>r;
    v[l].push_back(r);
    v[r].push_back(l);
    }
  int cnt=0,num=0;
  bool minp[n];
  rep(i,n)minp[i]=false;
  rep(i,n){
    if(!used[i]){
      mi=longinf;sz=0;
      dfs(i);
      num++;
      minp[point]=true;
      }
    }
  if(num==1){
    cout<<0<<endl;
    return 0;
    }
  sort(p,p+n);
  ll ans=0;
  rep(i,n){
    if(minp[p[i].second])
      ans+=p[i].first;
    else{
      if(num>2){
        ans+=p[i].first;
        num--;}
      }
    }
  if(num>2)cout<<"Impossible"<<endl;
  else cout<<ans<<endl;
  return 0;  
  }


Measured memory_bytes: 8832
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-11
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007
const int N = 500031;

int n;
vector<pair<int,int> > g[N];
int tests,k;

int used[N];

int timer,tout[N],tin[N];

int up[N][20];

long long dep[N];

void dfs(int v,int p=1)
{
	used[v]=1;
	++timer;
	tin[v]=timer;
	up[v][0]=p;
	for (int i=1;i<20;i++)
	{
		up[v][i]=up[up[v][i-1]][i-1];
	}

	for (int i=0;i<g[v].size();i++)
	{
		int to=g[v][i].first;
		if (used[to])
			continue;
		long long new_cost=g[v][i].second+dep[v];
		dep[to]=new_cost;
		dfs(to,v);
	}
	++timer;
	tout[v]=timer;
}

bool upper(int a,int b)
{
	return tin[a]<=tin[b]&&tout[a]>=tout[b];
}

long long lca(long long a,long long b)
{
	if (upper(a,b))
		return a;
	if (upper(b,a))
		return b;
	for (int i=19;i>=0;--i)
	{
		if (!upper(up[a][i],b))
			a=up[a][i];
	}
	return up[a][0];
}

long long solve(int a,int b)
{
	long long Q=lca(a,b);
	return dep[a]+dep[b]-2*dep[Q];
}

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin>>n;
	for (int i=1;i<n;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		g[a].push_back(make_pair(b,c));
		g[b].push_back(make_pair(a,c));
	}

	dfs(1);

	cin>>tests>>k;
	for (;tests;--tests){
		int a,b;
		cin>>a>>b;
		long long res=solve(a,k)+solve(b,k);
		cout<<res<<endl;
	}

	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 39424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int N; cin >> N;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if(N == i * j) Yes
        }
    }
    No


}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
        int k=sc.nextInt();
		int[] arr=new int[n];
		for(int i=0;i<n;i++){
			arr[i]=sc.nextInt();
		}
		int []dp=new int[n];
		dp[0]=0;
		for(int i=1;i<n;i++){
			dp[i]=Integer.MAX_VALUE;
		}
		for(int i=0;i<n;i++){
			for(int j=i+1;j<=i+k;j++){
				if(j<n){
					dp[j]=Math.min(dp[j], dp[i]+Math.abs(arr[j]-arr[i]));
				}
			}
		}
		System.out.println(dp[n-1]);
	}
}

Measured memory_bytes: 59376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxN = 2e3 + 55;
const int BIG = 2e9 + 55;

int n, x, y;
vector<int> g[maxN];

void bfs(int s, int D[maxN]) {
    queue<int> que;
    que.push(s);

    fill_n(D + 1, n, BIG);
    D[s] = 0;

    while(!que.empty()) {
        int u = que.front();
        que.pop();

        for(auto &v : g[u]) {
            if(D[v] > D[u] + 1) {
                D[v] = D[u] + 1;
                que.push(v);
            }
        }
    }
}

int dist[maxN][maxN];

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

    cin >> n >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);

    for(int i = 1; i + 1 <= n; i++) {
        g[i].push_back(i + 1);
        g[i + 1].push_back(i);
    }

    for(int i = 1; i <= n; i++) {
        bfs(i, dist[i]);
    }

    vector<int> ans(n + 1);

    for(int i = 1; i <= n; i++) {
        for(int j = i + 1; j <= n; j++) {
            ans[dist[i][j]]++;
        }
    }

    for(int i = 1; i <= n - 1; i++) {
        cout << ans[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 16768
#include<stdio.h>

int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		double x1,x2,x3,x4,y1,y2,y3,y4;
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		if(x1==x2&&x3==x4)printf("YES\n");
		else{
			if((y1-y2)/(x1-x2)==(y3-y4)/(x3-x4))printf("YES\n");
			else printf("NO\n");
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
using namespace  std;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
int binarySearch(vector<int> &A, int x){
    int N = A.size();
    int l=0, r=N;
    while(l<r){
        int m = (l+r)/2;
        if(A[m]==x) return m;
        else if(A[m]>x) r = m; 
        else l = m+1; 
    }
    return -1;
}
signed main(){
    int N; cin>>N;
    vector<int> S(N);
    REP(i, N) cin>>S[i];
    sort(S.begin(), S.end());
    int Q; cin>>Q;
    int res = 0;
    REP(i, Q){
        int x; cin>>x;
        if(binarySearch(S, x)!=-1) res++; 
    } 
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3172
use proconio::input;

fn main() {
    input! {
        n: usize, m: usize, c: i64,
        b: [i64; m],
        a: [[i64; m]; n],
    }

    let mut ret = 0;
    for i in 0..n {
        let ai = &a[i];
        let total = (0..m).map(|j| ai[j] * b[j]).sum::<i64>() + c;
        if total > 0 {
            ret += 1;
        }
    }
    println!("{}", ret);
}


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

bool rep(int i, int *t, int *x, int *y);
int main()
{
    int N;
    cin >> N;
    int t[N+1],x[N+1],y[N+1];
    t[0] = 0; x[0] = 0; y[0] = 0;
    for (int i = 1; i <= N; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }
    for (int i = 0; i < N; i++) {
        if (!rep(i,t,x,y)) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}
//t_i番目からt_(i+1)番目の座標に到達できるか
bool rep(int i, int *t, int *x, int *y){
    int deltaT = t[i+1] - t[i];
    deltaT -= abs(y[i]-y[i+1]);
    if (deltaT >= abs(x[i]-x[i+1])){
        if (deltaT%2 == 0) {
            return (x[i]%2 == x[i+1]%2);
        } else {
            return (x[i]%2 != x[i+1]%2);
        }
    }
    return false;
} 

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

using namespace std;

int main()
{
    set<string> items;
    string in;
    int n;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> in;
        items.insert(in);
    }
    cout << items.size() << endl;
    return 0;
}


Measured memory_bytes: 19260
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [u64; n],
    }
    let mut s = vec![0; n + 1];
    for i in 0..n {
        s[i + 1] = s[i] + a[i];
    }
    let mut b = vec![];
    for i in 0..n {
        for j in i + 1..=n {
            b.push(s[j] - s[i]);
        }
    }

    let mut res = 0u64;
    for i in (0..40).rev() {
        let c = b.iter().filter(|&b| *b >> i & 1 == 1).count();
        if c >= k {
            b.retain(|&b| b >> i & 1 == 1);
            res |= 1 << i;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 6080
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.map!(to!int).array; }

void calc(string s) {
    int a = s[0] - '0';
    int b = s[1] - '0';
    int c = s[2] - '0';
    int d = s[3] - '0';

    int reduce(int lhs, int rhs, int op) {
        return op == 0 ? lhs + rhs : lhs - rhs;
    }
    string op(int op) { // <--- 戻り値を char から string に変えました
        return op == 0 ? "+" : "-";
    }

    for (int i = 0; i < 2; i++) {
        int x = reduce(a, b, i);
        for (int j = 0; j < 2; j++) {
            int y = reduce(x, c, j);
            for (int k = 0; k < 2; k++) {
                int z = reduce(y, d, k);
                if (z == 7) {
                    // writeln(a, op(i), b, op(j), c, op(k), d, "=7");
                    writefln("%s%s%s%s%s%s%s=7", a, op(i), b, op(j), c, op(k), d);
                    return;
                }
            }
        }
    }
}

void main() {
    auto s = readln.chomp;
    calc(s);
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		FS r = new FS();
		int N = r.nextInt();
		int L = r.nextInt();
		String[] S = new String[N];
		for(int i=0; i<N; i++) {
			S[i] = r.next();
		}
		Arrays.sort(S);
		for(int i=0; i<N; i++) {
			System.out.print(S[i]);
		}
		System.out.println();
	}

	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}

		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 8656
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;


// a,bの最小公倍数
ll lcm(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll gcd(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}
// MOD
ll modadd(ll a, ll b){return (a%MOD+b%MOD+MOD)%MOD;}
ll modmul(ll a, ll b){return a%MOD*b%MOD%MOD;}
ll modexp(ll a, ll n){if(n==0)return 1; if(n%2==0){ll e=modexp(a,n/2); return modmul(e,e);} return modexp(a,n-1)*a%MOD;}
ll modinv(ll n){return modexp(n%MOD,MOD-2);}
ll modfact(ll n){ll res=1; for (int i=1; i <= n; ++i){res *= i; res %= MOD;} return res;}
ll modncr(ll n, ll r){ll numer=1;ll denom=1;for(int i=1;i<=r;++i){numer=modmul(numer,n-r+i);denom=modmul(denom,i);}return modmul(numer, modinv(denom));}


int main(){

    string s, t;
    cin >> s >> t;

    vsort(s);
    sort(t.begin(), t.end(), greater<char>());

    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    





}



//              g++ -std=c++1z


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=100005;
inline LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
LL n,c,x[N],v[N],pf[N],sf[N],sv[N],f[2][N],g[2][N];
LL cal1()
{
	LL ret1=0;
	for(int i=1;i<=n;i++){
		f[0][i]=pf[i]-v[i];
		g[0][i]=pf[i]-2*v[i];
		ret1=max(ret1,f[0][i]);
	}
	return ret1;
}
LL cal2()
{
	LL ret2=0;
	for(int i=n;i>=1;i--){
		f[1][i]=sf[i]-sv[i];
		g[1][i]=sf[i]-2*sv[i];
		ret2=max(ret2,f[1][i]);
	}
	return ret2;
}
int main()
{
	n=read();c=read();
	for(int i=1;i<=n;i++) v[i]=read(),x[i]=read();
	for(int i=1;i<=n;i++) pf[i]=pf[i-1]+x[i];
	for(int i=n;i>=1;i--){
		sv[i]=c-v[i];
		sf[i]=sf[i+1]+x[i];
	}
	LL ans=0;
	ans=max(ans,cal1());
	ans=max(ans,cal2());
	//cout << ans <<endl;
	LL lf=0,rf=0,lg=0,rg=0;
	for(int i=1;i<=n;i++){
		f[0][i]=max(f[0][i],f[0][i-1]);
		g[0][i]=max(g[0][i],g[0][i-1]);
	}
	for(int i=n;i>=1;i--){
		f[1][i]=max(f[1][i],f[1][i+1]);
		g[1][i]=max(g[1][i],g[1][i+1]);
	}
	for(int i=1;i<=n;i++){
		ans=max(ans,f[0][i]+g[1][i+1]);
//		lf=max(lf,f[0][i]);
//		lg=max(lg,g[0][i]);
	}
	for(int i=n;i>=1;i--){
		ans=max(ans,f[1][i]+g[0][i-1]);
//		rf=max(rf,f[1][i]);
//		rg=max(rg,g[1][i]);
	}
//	ans=max(ans,lf+rg);
//	ans=max(ans,lg+rf);
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 7296