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

int main() {
  unordered_map<string, int> mp;
  int n,ans = 0;
  cin >> n;
  for(int i = 0;i < n;i++){
    string s;
    cin >> s;
    auto itr = mp.find(s);
    if( itr != mp.end() ) {
      mp[s] = mp[s]+1;
    } 
    else {
      mp[s] = 1;
    }
  }
  int m;
  cin >> m;
  for(int i = 0;i < m;i++){
    string s;
    cin >> s;
    auto itr = mp.find(s);
    if( itr != mp.end() ) {
      mp[s] = mp[s]-1;
    } 
    else {
      mp[s] = -1;
    }
  }
  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    if(itr->second > ans) ans = itr->second;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import kotlin.math.min

fun main() {
  val input = readLine()!!.split(" ").map { it.toInt() }
  val a = input[0]
  val b = input[1]
  val c = input[2]
  var k = input[3]

  val t = k - (a + b)
  val result = if (t > 0) a - t else min(a, k)
  print(result)
}

Measured memory_bytes: 36356
#include <cstdio>

inline int query(int x, int y) {
	printf("? %d %d\n", x, y);
	fflush(stdout);
	static char opt[4];
	scanf("%s", opt);
	return opt[0] == 'Y';
}

const int N = 4011;
int Ans[N], st[N], tp;
int n, a, b;

int main() {
	scanf("%d%d",&a,&b), n = a + b;
	if(a <= b) return puts("Impossible"), 0;
	for(int i=0;i<n;++i) {
		if(tp and !query(st[tp], i)) --tp;
		else st[++tp] = i;
	}
	
	for(int i=0;i<n;++i)
		Ans[i] = query(st[tp], i);
	
	printf("! ");
	for(int i=0;i<n;++i)
		printf("%d", Ans[i]);
	putchar(10);
	return 0;
}

Measured memory_bytes: 692
// input に入力データが全部入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split(" ");

    // 文字列から10進数に変換するときはparseIntを使います
    var a = parseInt(input[0], 10);
    var b = parseInt(input[1], 10);

    // 出力
    if(a * b % 2 == 0){
      console.log("Even")
    } else {
      console.log("Odd")
    }
}

// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
	var input = document.getElementById("input").value;
	Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }
  vector<char> res;
  function<bool(int, int, int, int)> dfs = [&](int a, int b, int c, int i) {
    if (i == N) return true;
    if (S[i] == "AB") {
      if (a > 0 && dfs(a - 1, b + 1, c, i + 1)) {
        res.emplace_back('B');
        return true;
      }
      if (b > 0 && dfs(a + 1, b - 1, c, i + 1)) {
        res.emplace_back('A');
        return true;
      }
    }
    if (S[i] == "BC") {
      if (b > 0 && dfs(a, b - 1, c + 1, i + 1)) {
        res.emplace_back('C');
        return true;
      }
      if (c > 0 && dfs(a, b + 1, c - 1, i + 1)) {
        res.emplace_back('B');
        return true;
      }
    }
    if (S[i] == "AC") {
      if (a > 0 && dfs(a - 1, b, c + 1, i + 1)) {
        res.emplace_back('C');
        return true;
      }
      if (c > 0 && dfs(a + 1, b, c - 1, i + 1)) {
        res.emplace_back('A');
        return true;
      }
    }
    return false;
  };
  dfs(A, B, C, 0);
  if (res.empty()) {
    cout << "No" << '\n';
  } else {
    cout << "Yes" << '\n';
    reverse(res.begin(), res.end());
    for (char r : res) {
      cout << r << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 25452
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define mi          map<int,int>
    #define mii         map<pi,int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	 const int N =1e5;
    
     int mod= 1e9+7;
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};  
     
     
     	int po(int a, int b) {
		a %= mod;
		int res = 1;
		while (b > 0) {
			if (b & 1)
				res = (res * a) % mod;
			a =(a*a) % mod;
			b >>= 1;
		}
		 return res;	
	   } 
	   
	 int cal(int n,int r) {
		   int sm1=1,sm2=1;
		   if(r > n-r) r=n-r;
		   for(int i=1;i<=r;i++) {
			     int nax=(n-i+1);
			     sm1=(sm1*nax)%mod;			    
			     sm2=sm2*i%mod;			    
			   }
			   //~ cout<<sum<<endl;
			   return sm1*(po(sm2,mod-2))%mod;	    
		 }
 
     void solve(){
        int n,a,b;
        cin>>n>>a>>b;
        
        //~ n=min(n,(int)2e5);
        //~ cout<<n<<endl;
        int ans=po(2,n)-1;
         //~ cout<<yo<<endl;
        
        //~ rep(i,1,n+1) {
			  //~ if(i==a || i==b) continue;
			  //~ else {
				    //~ ans+=cal(n,i);
				    //~ ans%=mod;				    
				  //~ }
			//~ }
        ans=(ans-cal(n,a)-cal(n,b)+2*mod)%mod;
        //~ cout<<ans<<endl;
        ans=(ans+mod)%mod;
        
        cout<<ans<<endl;        
         
	 }
	
      int32_t main() {
	    cool;
	    int t=1;
        //cin>>t;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    int a = stdin.nextInt();
    int b = stdin.nextInt();
    int c = stdin.nextInt();
    int cnt = 0;

    for (int i = a; i <= b; i++) {
      if (c % i == 0) {
        cnt++;
      }
    }
    System.out.println(cnt);
  }

}

Measured memory_bytes: 17348
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  string S;
  cin >> S;
  string s1 = S.substr(0, N), s2 = S.substr(N);
  dump(s1, s2);
  int ans = 0;

  map<pair<string, string>, int> m;

  rep(bits, 0, (1 << N)) {
    string t1, t2;
    rep(i, 0, N) {
      if ((bits >> i) & 1) {
        t1.push_back(s1[i]);
      } else {
        t2.push_back(s1[i]);
      }
    }
    reverse(all(t2));
    m[make_pair(t1, t2)]++;
  }
  rep(bits, 0, (1 << N)) {
    string t1, t2;
    rep(i, 0, N) {
      if ((bits >> i) & 1) {
        t1.push_back(s2[i]);
      } else {
        t2.push_back(s2[i]);
      }
    }
    reverse(all(t2));
    ans += m[make_pair(t2, t1)];
  }

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


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

int main() {
  long int k,x;
  cin >> k >> x;
  if(x <= k*500 ){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  

}


Measured memory_bytes: 3544
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
using namespace std;

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


int main() {
	int n, m;
	cin >> n >> m;
	int X[m];
	rep(i, m) cin >> X[i];
	sort(X, X+m);

	int D[m-1];
	for(int i=0; i<m-1; i++) D[i] = X[i+1] - X[i];
	sort(D, D+m-1);

	int sum = 0;
	for (int i=0; i<m-n; i++) sum += D[i];
	cout << sum << endl;
}

Measured memory_bytes: 1024
using System;


namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            
            const double PRINCI = 100000;
            while (true)
            {
                var numstr = Console.ReadLine();
                int num = 0;
                try
                {
                    num = int.Parse(numstr);
                }
                catch (Exception)
                {
                    return;
                }

                var sum = PRINCI;
                for (int i = 0; i < num; i++)
                {
                    sum *= 1.05;
                    sum /= 1000;
                    sum = Math.Ceiling(sum);
                    sum *= 1000;
                }

                Console.WriteLine(sum);
            }

        }
    }
}

Measured memory_bytes: 5576
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    class Program
    {
        
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);
            List<int> L = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();

            L.Sort();
            L.Reverse();

            int max_length = 0;

            for(int i = 0; i < K; i++)
            {
                max_length += L[i];
            }

            Console.WriteLine(max_length);

        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
      ios::sync_with_stdio(false);
  cin.tie(0);
  ll k,l;
  string s;
  char s1[110];
  //string s1;
  string s2="...";
  cin>>k>>s;
  l=s.length();
  if(l<=k)
  cout<<s<<endl;
  else
  {
      s.copy(s1,k,0);
      s1[k]='.';
      s1[k+1]='.';
      s1[k+2]='.';
      //s1.append(s2.begin(),s2.end());
      s1[k+3]='\0';
      cout<<s1<<endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;
const ll BIG = 1000000007;

struct pea {
	ll b;
	ll c;
};

bool cmp(pea x, pea y) {
	return x.c < y.c;
}

int main() {

	int N, M;
	cin >> N >> M;

	ll a[200000];
	pea s[200000];

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

	sort(a, a + N);

	for (int j = 0; j < M; j++) {
		cin >> s[j].b >> s[j].c;
	}

	sort(s, s + M, cmp);

	int j = M - 1;

	for (int i = 0; i < N; i++) {
		if (s[j].c > a[i]) { a[i] = s[j].c; }
		else { break; }

		s[j].b--;
		if (s[j].b == 0) { j--; }
		if (j < 0) { break; }

	}

	ll ans = 0;

	for (int i = 0; i < N; i++) {
		ans += a[i];
	}

	cout << ans;

	system("PAUSE");
}

Measured memory_bytes: 4728
import Control.Monad
import Data.List

import           Data.Attoparsec.ByteString.Char8
import qualified Data.ByteString.Char8       as B
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM

main :: IO ()
main = do
  n <- readLn
  sps <- replicateM n $ (\[s, p] -> (s, read p)) . words <$> getLine
  mapM_ print $ solve sps

solve :: [(String, Int)] -> [Int]
solve = map fst . sortBy f . zip [1..]
  where
    f (_, (s1, p1)) (_, (s2, p2)) = case compare s1 s2 of
      GT -> GT
      LT -> LT
      EQ -> compare p2 p1

Measured memory_bytes: 1020
import numpy as np
def main():
	
	buf = input().split()
	n = int(buf[0])
	k = int(buf[1])
	l = np.zeros(n)
	for i in range(n):
		l[i] = int(input())
	
	l = np.sort(l)
	min = -1
	for i in range(n-k+1):
		bufmin = l[i+k-1] - l[i]
		if (min == -1):
			min = bufmin
		elif (bufmin < min):
			min = bufmin
		
	print(int(min))
		
main()

Measured memory_bytes: 13944
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<string> vstring;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, (llint)b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

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

Measured memory_bytes: 892
use itertools::Itertools as _;
use proconio::input;

fn main() {
    input! {
        a: u32,
        b: u32,
        c: u32,
        k: usize,
    }

    let mut ans = false;
    for actions in vec![0..=2; k].into_iter().multi_cartesian_product() {
        let (mut a, mut b, mut c) = (a, b, c);
        for action in actions {
            match action {
                0 => a *= 2,
                1 => b *= 2,
                2 => c *= 2,
                _ => unreachable!(),
            }
        }
        ans |= a < b && b < c;
    }

    println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 2188
/*
 * main.cpp
 *
 *  Created on: 2020/04/12
 *      Author: SkAaO
 */

#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

int main(){
	int N;
	cin >> N;
	int X;
	float range_n, range_p;
	bool is_X = false;

	range_n = N / 1.08;
	range_p = (N + 1) / 1.08;

	for(int i = range_n; i < range_p; i++){
		if((int)(i * 1.08) == N){
			X = i;
			is_X = true;
			break;
		}
	}

	if(is_X){
		cout << X << endl;
	}else{
		cout << ":(" << endl;
	}

	return 0;

}




Measured memory_bytes: 256
p = []

for i in range(5):
    p.append(int(input()))

far = int(input())
res = True

for x in range(len(p)):
    for xx in range(x+1, len(p)):
        if p[xx] - p[x] > far:
            res = False

if res:
    print('Yay!')
else:
    print(':(')

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

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

long long MOD = 1000000000 + 7;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int x = 100 * a + 10 * b + c;
  if(x % 4 == 0){
    cout << "YES" << endl;
  } else { 
    cout << "NO" << endl;
  }
}







Measured memory_bytes: 256
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}
import java.lang.{Character => char}

object Main extends App {
  val Array(n,k) = in.readLine.split(" ").map(_.toInt)
  val s = in.readLine.map(char.getNumericValue)

  val table = mu.ArrayBuffer.empty[Int]
  s./:(-1)( (b, i) => {
    val v = if(i == 1) 1 else -1
    if(i != b) table.append(v)
    else table(table.size-1) += v
    i
  })

  val sums = table.scanLeft(0)((acc,i) => acc + i.abs)
  0 +=: table

  def rec(acc:Int, cnt:Int, left:Int, right:Int, now:Int):Int = {
    if(right == table.size) acc max (sums(right-1) - sums(left))
    else {
      val leftCnt = if(table(left) < 0) 1 else 0
      if(cnt-leftCnt == k && now == 1)
        rec(acc max (sums(right) - sums(left)), cnt-leftCnt, left+1, right, now)
      else
        rec(acc, cnt+(now^1), left, right+1, now^1)
    }
  }

  val ans = rec(0,0,0,1,s.head)
  println(ans)
}

Measured memory_bytes: 36520
def main():

    n,l = map(int,raw_input().split())
    taste = []
    flag = True
    sum_taste = 0
    for i in range(n):
        sum_taste = sum_taste + i + l
        if (i + l) < 0:
            taste.append((abs(i + l),"nag"))
        else:
            taste.append((abs(i + l),"pog"))
    sorted_taste = sorted(taste,key = lambda x:x[0])
    if sorted_taste[0][1] == "nag":
        print(sum_taste + sorted_taste[0][0])
    else:
        print(sum_taste - sorted_taste[0][0])



if __name__ == "__main__":
    main()


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

int main(void)
{
int n;


scanf("%d",&n);
char a[n][11];
for(int i=0; i<n; i++){
 scanf("%s",&a[i]);}
int c=1;

qsort(a,n,11,strcmp);

for(int i=1;i<n;i++){
    if(strcmp(a[i],a[i-1])!=0) c++;
    
  }
 
  
 
  printf("%d",c);
return 0;
}

Measured memory_bytes: 5712
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back

using namespace std;

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

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

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    vector<ll> b(a);
    sort(ALL(b));
    ll Amax=b[n-1],Asec=b[n-2];
    rep(i,n){
        if(a[i]==Amax) cout<<Asec<<endl;
        else cout<<Amax<<endl;
        
    }
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    rep(i, n)cin >> t[i];
    sort(t.begin(), t.end(), greater<int>());
    int ans = 1;
    int cnt = 0;
    int end = t[0];
    rep(i, n){
        if(end - t[i] <= k && cnt < c){
            cnt++;
        }else{
            cnt = 1;
            end = t[i];
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int m,k;
  cin >> m >> k;
  if(k <= pow(2,m)-1){
    if(m==0){
      cout << 0 << " " << 0 << endl;
      return 0;
    }
    if(m==1){
      if(k==0){
        cout << "0 0 1 1" << endl;
      }else{
        cout << -1 << endl;
      }
      return 0;
    }
    rep(i,pow(2,m)){
      if(k==i)continue;
      cout << i << " ";
    }
    cout << k << " ";
    for(int i=pow(2,m)-1; i>=0; i--){
      if(k==i)continue;
      cout << i << " ";
    }
    cout << k << endl;
  }else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
  int A, B, C, D;
  int min1, min2;
  scanf("%d%d%d%d",&A,&B,&C,&D);
  min1 = A;
  if(B < min1) min1 = B;
  min2 = C;
  if(D < min2) min2 = D;
  printf("%d\n", min1 + min2);
  return 0;
}


Measured memory_bytes: 128
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def create_bin_string(data, num):
    c_bin = "{:b}".format(data)
    switches = c_bin
    for _ in range(0, num-len(c_bin)):
        switches = "0" + switches
    return switches


def solve(N, M, data, Ps):
    lamp_sw_comb = list(map(lambda x: string_to_int(x), data))
    lamp_sw_p = string_to_int(Ps)

    count = 0
    for c in range(0, 2**N):
        switches = create_bin_string(c, N)

        are_all_light = True
        for i, lamp_sw in enumerate(lamp_sw_comb):
            on_num = 0
            for j, sw in enumerate(lamp_sw):
                if j == 0:
                    continue
                if switches[sw-1] == "1":
                    on_num += 1
            if on_num % 2 != lamp_sw_p[i]:
                are_all_light = False
                break

        if are_all_light:
            count += 1
    return count


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    [N, M] = string_to_int(input())
    data = inputs(M)
    Ps = input()
    ret = solve(N, M, data, Ps)
    print(ret)


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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const int DONE = 1;
const int YET = 0;
int fin(vector<int>a) {
	rep(i, 0, a.size()) {
		if (a[i] == YET)return i;
	}
	return -1;
}
signed main() {
	int n; cin >> n; vector<vector<int> >vec(n, vector<int>());
	rep(i, 0, n) {
		int u, k; cin >> u >> k;
		u--;
		rep(j, 0, k) {
			int v; cin >> v; v--;
			vec[u].push_back(v);
		}
	}
	vector<int>check(n, 0);
	vector<pair<int, int> >stamp(n);
	stack<int>S;
	S.push(0);
	int t = 1;
	start:
	while (!S.empty()) {
		int u = S.top();
		if (check[u] == YET) {
			stamp[u].first = t++;
			check[u] = DONE;
		}
	here:
		if (DBG) {
			cout << "t == " << t << endl;
			rep(x, 0, n) {
				cout << x + 1 << " " << stamp[x].first << " " << stamp[x].second << endl;
			}
		}
		rep(i, 0, vec[u].size()) {
			if (check[vec[u][i]] == YET) {
				S.push(vec[u][i]);
				check[vec[u][i]] = DONE;
				stamp[vec[u][i]].first = t++;
				u = vec[u][i];
				goto here;
			}
		}
		u = S.top(); S.pop();
		stamp[u].second = t++;
	}
	if (fin(check) != -1) {
		S.push(fin(check));
		goto start;
	}
	rep(i, 0, n) {
		cout << i + 1 << " " << stamp[i].first << " " << stamp[i].second << endl;;
	}

	return 0;
}

Measured memory_bytes: 3160
#include<stdio.h>

int main()
{
   int W, H, x, y, r, w, h;

   scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

   w = x+r;
   h = y+r;

   if(0<=x && x<=W){
      if(0<=y && y<=H){
         if(0<=w && w<=W){
            if(0<=h && h<=H)
               puts("Yes");
            else
               puts("No");
         }
         else
            puts("No");
      }
      else
         puts("No");
   }
   else
      puts("No");

   return 0;
}

Measured memory_bytes: 1816
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>

using namespace std;
using ull = unsigned long long;

int main() {
	int A, B, T;
	cin >> A >> B >> T;

	const int ans = T / A * B;


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



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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

// int main()
// {
//     int n;
//     ll k;
//     cin >> n >> k;
//     vector<int> a(n), check(n, 0);
//     rep(i, n) cin >> a[i];

//     vector<int> s;
//     vector<int> cycle(n + 1, -1);
//     int cnt = 0, start = 0, be;
//     s.push_back(0);
//     while (1)
//     {
//         check[a[start]]++;

//         if (check[a[start]] == 2)
//         {
//             be = a[start];
//             break;
//         }
//         s.push_back(a[start]);
//         start = a[start];
//         cnt++;
//     }

//     int s_num;
//     rep(i, cnt)
//     {
//         if (s[i] == be)
//         {
//             s_num = i;
//             break;
//         }
//     }

//     int span = cnt - s_num + 1;

//     int ans;
//     if (k < s_num)
//     {
//         ans = s[k] + 1;
//     }
//     else
//     {
//         ans = s[(k - s_num) % span + s_num] + 1;
//     }

//     cout << ans << endl;

//     return 0;
// }

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

    vector<int> s;
    vector<int> ord(n + 1, -1);
    int c = 1, l = 0;
    {
        int v = 1;
        while (ord[v] == -1)
        {
            ord[v] = s.size();
            s.push_back(v);
            v = a[v - 1];
        }
        c = s.size() - ord[v];
        l = ord[v];
    }

    // rep(i, n + 1)
    // {
    //     cout << ord[i] << ' ';
    // }
    // cout << endl;

    // rep(i, s.size())
    // {
    //     cout << s[i] << ' ';
    // }
    // cout << endl;
    if (k < l)
    {
        cout << s[k] << endl;
    }
    else
    {
        k -= l;
        k %= c;
        cout << s[l + k] << endl;
    }
    return 0;
}

Measured memory_bytes: 5860
from collections import defaultdict
from functools import lru_cache
import math


def trial_division(n):
    factor = defaultdict(int)
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            factor[num] += 1
    factor[n] += 1
    return factor


@lru_cache(maxsize=None)
def powmod(x, y, mod):
    if y == 0:
        return 1
    return (((powmod(x, y >> 1, mod) ** 2) % mod) * x ** (y & 1)) % mod


n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
numbers = defaultdict(int)
for a_i in a:
    for i, v in trial_division(a_i).items():
        numbers[i] = max(v, numbers[i])

l = 1
for i, v in numbers.items():
    l *= powmod(i, v, mod)
    l %= mod


ans = 0
for i in a:
    r = powmod(i, mod-2, mod)
    ans += l * r
    ans %= mod
print(int(ans))




Measured memory_bytes: 108124
/*Program from Luvwgyx*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define int long long
#define write(x) printf("%lld\n",x)
using namespace std;
const int maxn=1e2+10;
int a[maxn];
int read(){
    int 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;
}
signed main(){
    int n=read();double ret=0;
    for(int i=1;i<=n;i++)a[i]=read(),ret+=(1.0/a[i]);
    printf("%.7lf\n",1.0/ret);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cctype>
using namespace std;
int main(){
  vector<int> vec(30,0);
  for(int i = 0;i < 28;i++){
    int tmp;
    cin >> tmp;
    vec[tmp-1] = 1;
  }
  for(int i =0 ;i < 30;i++){
    if(vec[i] == 0)cout << i+1 << endl;
  }
  
    
  
  return 0;
}
vector<string> split(string str,string delim){
  vector<string> items;
  size_t dlm_idx;
  if(str.npos == (dlm_idx = str.find_first_of(delim))){
    items.push_back(str.substr(0,dlm_idx));
  }
  while(str.npos != (dlm_idx = str.find_first_of(delim))){
    if(str.npos == str.find_first_not_of(delim)){
      break;
    }
    items.push_back(str.substr(0,dlm_idx));
    dlm_idx++;
    str = str.erase(0,dlm_idx);
    if(str.npos == str.find_first_of(delim) && "" != str){
      items.push_back(str);
      break;
    }
  }
  return items;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
int main()
{
   ll n , a , b ;
   cin >> n >> a >> b ;
   cout << (n / (a + b) * a + (n % (a + b) >= a ? a : n % (a + b))) << endl ;
   return 0 ;
}


Measured memory_bytes: 256
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import product, combinations,permutations
from copy import deepcopy
import sys
sys.setrecursionlimit(4100000)



if __name__ == '__main__':
    A, B = map(int, input().split())
    if A<=8 and B<=8:
        print("Yay!")
    else:
        print(":(")
        

Measured memory_bytes: 10508
// https://atcoder.jp/contests/abc148/tasks/abc148_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int c, int d) { return c / gcd(c, d) * d; }

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;

    return 0;
}


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

vector<int> oneDay(vector<vector<int>> &order, vector<int> &before) {
  vector<int> erased;
  vector<int> used(order.size());

  for(auto& el : before) {
    if(used[el]) continue;
    int size1 = order[el].size();
    if(size1 == 0) {
      continue;
    }
    int opponent = order[el][size1-1] - 1;
    if(used[opponent]) {
      continue;
    }
    int size2 = order[opponent].size();
    if(size2 == 0) {
      continue;
    }
    int opponentOpponent = order[opponent][size2-1] - 1;

    if (opponentOpponent == el) {
      erased.emplace_back(el);
      erased.emplace_back(opponent);
      used[opponent] = true;
    }
  }

  return erased;
}

int main() {
  int N;
  cin >> N;
  vector<vector<int> > order(N, vector<int>(N-1));

  for(int i=0;i<N;i++) {
    for(int j=0;j<N-1;j++) {
      cin >> order[i][j];
    }
  }

  int days = 0;

  int left = N * (N-1) / 2;

  int times = 0;
  
  vector<int> before(N);
  iota(before.begin(), before.end(), 0);

  while(left > 0) {
    times++;
    bool can = true;
    vector<int> erased = oneDay(order, before);
    before.clear();
    if(erased.size() == 0) {
      can = false;
    } else {
      for(int i=0;i<erased.size();i++) {
        order[erased[i]].pop_back();
        if(order[erased[i]].size() != 0) before.emplace_back(erased[i]);
      }
    }
    left = left - (erased.size() / 2);

    if(!can || times > N*(N-1)/2) {
      days = -1;
      break;
    } else {
      days++;
    }
  }

  cout << days << endl;

  return 0;
}



Measured memory_bytes: 4224
#include <iostream>
#include <math.h>
using namespace std;

int main() {
  int x10=0;
  int x2=0;
  int k=0;
  int ans[10] = {0};

  while(cin >> x10) {
    k=0;
    int ans[10] = {0};
    for(int i=0;i<10;i++) {
      x2 = x10 % (int)(pow(2,i+1));
      if(x2 != 0){
        ans[k] = (int)pow(2,i);
        k++;
        x10 -= x2;
      }
    }
    for(int i=0;i<k-1;i++) {
      cout << ans[i] << " ";
    }
    cout << ans[k-1] << endl;
    }
  }

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

bool isPrime(int n){
	if(n <= 1){
		return false;
	}
	for(int i = 2; i*i <= n; i++){
		if(n%i == 0){
			return false;
		}
	}
	return true;
}

int main(){
	int n;
	while(cin >> n){
		if(n==0){
			break;
		}
		int cnt=0;
		for(int i=2;i<=n/2;i++){
			if(isPrime(i) && isPrime(n-i))
				cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}


Measured memory_bytes: 1160
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("parse error")
    };
}

fn main() {
    input!{
        n: usize,
        v: [String; n]
    }
    let mut set: std::collections::HashSet<String> = std::collections::HashSet::new();
    for i in v {
        set.insert(i);
    }
    println!("{}", set.len());
}


Measured memory_bytes: 22712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		Console.WriteLine(Math.Max(0, p[0] - p[1]*2));
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}

Measured memory_bytes: 11220
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>

using namespace std;

using ll = unsigned long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;

vpll arr[100010] = {};


//最大公約数
ll gcd(ll a, ll b) {
	if ( a%b == 0 )
		return b;
	return gcd(b,a%b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

ll result[100010] = {};
ll flag[100010] = {};

void solve(ll a,ll cost) {
	if (flag[a] == true)
		return;
	result[a] = cost;
	flag[a] = true;
	for (auto & vec : arr[a]) {
		solve(vec.first, vec.second + cost);
	}
}

int main() {
	ll n,a,b,c,q,k;
	cin >> n;
	for (int i = 0; i < n-1; i++) {
		cin >> a >> b >> c;
		arr[a - 1].push_back({ b - 1,c });
		arr[b - 1].push_back({ a - 1,c });
	}

	cin >> q >> k;

	solve(k-1,0);

	for (int i = 0; i < q; i++) {
		cin >> a >> b;

		cout << result[a-1] + result[b-1] << endl;


	}

}



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

int main(){
  int n;
  cin >>n;
  int sum = 0;
  rep(i,n){
    int a;
    cin >>a;
    sum += a;
  }
  if(sum%2==0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater <int>());
  if(s < t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {

	int x,n;
	cin>>x>>n;
	int p[n];
	int vis[102];
	memset(vis,0,sizeof(vis));
	for(int i=0; i<n; i++) {
		cin>>p[i];
		vis[p[i]] = 1;
	}
	//for(int i=0; i<101; i++)
	//	cout<<vis[i]<<" ";
	if(n==0)
		cout<<x;
	else {
		int a=0,b=0;
	for(int i=x; i>=0; i--) {
		if(vis[i] == 0) {
			a = i;
			break;
		}
	}

	for(int i=x+1; i<=101; i++) {
		if(vis[i] == 0) {
			b = i;
			break;
		}
	}

	if(abs(a-x) <= abs(b-x))
		cout<<a;
	else
		cout<<b;

	}
	
	return 0;
}

Measured memory_bytes: 3620
#include "algorithm"
#include "iomanip"
#include "iostream"
#include "queue"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;

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;
}

template <typename T>
void drop(const T& x) {
  cout << x << endl;
  exit(0);
}

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

  ll N, X, Y;
  cin >> N >> X >> Y;

  V<V<ll>> edge_list(N, V<ll>(0));

  rep(i, N - 1) {
    edge_list[i].emplace_back(i + 1);
    edge_list[i + 1].emplace_back(i);
  }

  edge_list[X - 1].emplace_back(Y - 1);
  edge_list[Y - 1].emplace_back(X - 1);

  V<V<ll>> dist(N, V<ll>(N, 1e10));

  rep(i, N) {
    queue<pair<ll, ll>> q;

    q.emplace(i, 0);
    dist[i][i] = 0;

    while (!q.empty()) {
      pair<ll, ll> p = q.front();
      q.pop();

      ll n = p.first;
      ll di = p.second;

      for (auto np : edge_list[n]) {
        if (chmin(dist[i][np], di + 1)) {
          q.emplace(np, di + 1);
        }
      }
    }
  }

  V<ll> dist_ct(N + 1);

  rep(j, N) rep(i, j) { ++dist_ct[dist[i][j]]; }

  rep1(i, N - 1) { cout << dist_ct[i] << "\n"; }

  return 0;
}


Measured memory_bytes: 31744
#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 1000000007
#define PI (acos(-1))
#define EPS 1e(-9);
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    int N,M;
    cin >> N>>M;

    vector<P> pa;

    rep(i,M){
        int a,b; cin>>a>>b;
        pa.emplace_back(b,a);
    }

    SORT(pa);

    ll last=0;

    ll ans=0;

    rep(i,M){
        if(pa[i].second<last) continue;
        ++ans;
        last=pa[i].first;
    }

    cout<< ans<<"\n";
    


}

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


Measured memory_bytes: 2420
#include <iostream>
#include <cmath>
#include <queue>
#include <set>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
using P = pair<double,int>;


int main(){
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  cout <<  (h2*60+m2)-(h1*60+m1)-k << endl;
  return 0;
}

Measured memory_bytes: 3592
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 10L^^9+7;
long[10^^5+50] F, RF;

long pow(long x, long n) {
    long y = 1;
    while (n) {
        if (n%2 == 1) y = (y * x) % P;
        x = x^^2 % P;
        n /= 2;
    }
    return y;
}

void init()
{
    F[0] = F[1] = 1;
    foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;

    {
        RF[$-1] = 1;
        auto x = F[$-1];
        auto k = P-2;
        while (k) {
            if (k%2 == 1) RF[$-1] = (RF[$-1] * x) % P;
            x = x^^2 % P;
            k /= 2;
        }
    }
    foreach_reverse(i, ref x; RF[0..$-1]) x = (RF[i+1] * (i+1)) % P;
}

void main()
{
    init();
    auto N = readln.chomp.to!int;
    auto S = readln.chomp.to!(char[]);

    int[] PS;
    PS.length = N*2;
    int x;
    foreach (i, c; S) {
        if (c == 'B') {
            if (x%2 == 0) {
                PS[i] = 1;
                ++x;
            } else {
                PS[i] = -1;
                --x;
            }
        } else {
            if (x%2 == 0) {
                PS[i] = -1;
                --x;
            } else {
                PS[i] = 1;
                ++x;
            }
        }
    }

    if (x != 0 || PS[0] == -1 || PS[$-1] == 1) {
        writeln(0);
        return;
    }

    int mc;
    long r = 1;
    foreach_reverse (p; PS) {
        if (p == -1) {
            ++mc;
        } else {
            r = (r * mc--) % P;
        }
    }

    writeln((r * F[N]) % P);
}

Measured memory_bytes: 5116
#include<bits/stdc++.h>
 #define ll long long int
 using namespace std;
 int main()
 {
     string s,t;
     cin>>s>>t;
     ll m=s.length(),n=t.length();
     ll dp[m+1][n+1];
     for(ll i=0;i<=m;i++)
     {
         for(ll j=0;j<=n;j++)
         {
             if(i==0||j==0)
                dp[i][j]=0;
            else
                if(s[i-1]==t[j-1])
                    dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
         }
     }
     ll i=m,j=n;
     string res="";
     while(i>=1&&j>=1)
     {
         if(s[i-1]==t[j-1])
        {
            res+=s[i-1];
            i--;
            j--;
        }
        else{
            if(dp[i-1][j]>=dp[i][j-1])
                i--;
            else
                j--;
        }
     }
     reverse(res.begin(),res.end());
     cout<<res<<endl;
     
 }

Measured memory_bytes: 70656
import java.io.*;
import java.math.BigInteger;
import java.util.*;


public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception addd) {
					addd.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception addd) {
				addd.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	
	public static FastReader sc = new FastReader();
 
	static long mod = (int) (1e9+7),MAX=(long)(1e18);
	static List<Integer>[] edges;
	public static int[][] parent;
	public static int col = 20;
	public static void main(String[] args) throws IOException{
		
		//Scanner sc = new Scanner(System.in);
	//	Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    long[] a = new long[n];
	    boolean zero = false;
	    for(int i=0;i<n;++i) {
	    	a[i] = sc.nextLong();
	    	if(a[i] == 0) zero = true; 
	    }
	    if(zero) out.print(0);
	    else {
	    	long mul = 1;
	    	boolean found = true;
	        for(int i=0;i<n && found;++i) {
	        	if(mul > (MAX)/a[i]) found = false;
	        	else mul*=a[i];
	        }
	        if(found) out.print(mul);
	        else out.print(-1);
	    }
		out.close();
	}
}

Measured memory_bytes: 49148
import fractions
a, b, c, d = map(int, input().split())
 
gcd = fractions.gcd(c,d)
lcm= int((c*d)/fractions.gcd(c,d))
a_c = int((a-1)//c)
b_c = int(b//c)
a_d = int((a-1)//d)
b_d = int(b//d)
a_cd = int((a-1)//lcm)
b_cd = int(b//lcm)
 
 
ans = b-a+1-((b_c-a_c)+(b_d-a_d)-((b_cd-a_cd)))
print(int(ans))



Measured memory_bytes: 5048
#include <stdio.h>

int main(void) {
    int a, b;
    int k;

    scanf("%d %d", &a, &b);

    if ((a + b) % 2 == 0) {
        printf("%d\n", (a + b) / 2);
    } else {
        puts("IMPOSSIBLE");
    }
    
    return 0;
}

Measured memory_bytes: 128