akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

template <class T>
inline void eraque(std::vector<T>& vec) {
  vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
  return;
}

template <class T>
inline int lower_position(const std::vector<T>& vec, T val) {
  return static_cast<int>(std::distance(
      vec.begin(), std::lower_bound(vec.begin(), vec.end(), val)));
}

template <class T>
inline int upper_position(const std::vector<T>& vec, T val) {
  return static_cast<int>(std::distance(
      vec.begin(), std::upper_bound(vec.begin(), vec.end(), val)));
}

template <class T>
inline std::string to_binary(T n) {
  assert(n > 0);
  std::string ret = "";
  while (n) ret += (n & 1) ? '1' : '0', n >>= 1;
  std::reverse(ret.begin(), ret.end());
  return ret;
}

template <class T>
inline void println(T val) {
  std::cout << val << '\n';
}

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template <class T, class U>
std::istream& operator>>(std::istream& is, std::pair<T, U>& p) {
  return is >> p.first >> p.second;
}

template <class Tuple, std::size_t... Is>
void tuple_in(std::istream& is, Tuple& tp, std::index_sequence<Is...>) {
  ((is >> std::get<Is>(tp)), ...);
}

template <class... Args>
std::istream& operator>>(std::istream& is, std::tuple<Args...>& tp) {
  tuple_in(is, tp, std::index_sequence_for<Args...>{});
  return is;
}


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

  int n; cin >> n;
  vector<int64> l(n); cin >> l;

  int ans = 0;

  auto ok = [](int64 x, int64 y, int64 z) -> bool {
    return x + y > z && x + z > y && y + z > x;
  };

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      for (int k = j + 1; k < n; ++k) {
        if (l[i] == l[j] || l[j] == l[k] || l[i] == l[k]) continue;
        ans += ok(l[i], l[j], l[k]);
      }
    }
  }

  println(ans);

  return 0;
}


Measured memory_bytes: 3624
def main():
    N, M = map(int, input().split())
    all = list(map(int, input().split()))
    all.pop(0)
    tmp = []
    for _ in range(N - 1):
        tmp.clear()
        tmp = list(map(int, input().split()))
        tmp.pop(0)
        all = list(set(tmp) & set(all))
    print(len(all))


if __name__ == "__main__":
    main()


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

int main() {
	int x1,y1,x2,y2;
  	cin >> x1 >> y1 >> x2 >> y2;
  	
  	x2 -= x1;
  	y2 -= y1;
  	
  	int x3,y3,x4,y4;
  	x3 = x2 - y2;
  	y3 = x2 + y2;
    x4 = -y2;
  	y4 =  x2;
  
  	cout << x3 + x1 << ' ' << y3 + y1 << ' ' << x4 + x1 << ' ' << y4 + y1 << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
static const ll mod = 1000000007;
static const ll INF = 10000000000;
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */

ll d[301][301];
ll edge[301][301];

void warshall_floyd_d(int n){
    for(int k=0; k<n; k++){
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}

void warshall_floyd_edge(int n){
    for(int k=0; k<n; k++){
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                edge[i][j] = min(edge[i][j], edge[i][k]+edge[k][j]);
            }
        }
    }
}

int main(void){
    int n,m;
    ll l;
    cin >> n >> m >> l;
    ll graph[n][n];
    for(int i=0; i<n; i++){
        for(ll j=0; j<n; j++){
            graph[i][j] = -1;
        }
    }
    for(int i=0; i<m; i++){
        int a,b;
        ll c;
        cin >> a >> b >> c;
        graph[a-1][b-1] = c;
        graph[b-1][a-1] = c;
    }

    // 街同士の最短距離
    for(ll i=0; i<n; i++){
        for(ll j=0; j<n; j++){
            if(i==j) d[i][j] = 0;
            else if(graph[i][j]==-1) d[i][j] = INF;
            else d[i][j] = graph[i][j];
        }
    }
    warshall_floyd_d(n);

    // 最短路がL以下の頂点間に長さ１の辺をはる
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(d[i][j] <= l) edge[i][j] = 1;
            else edge[i][j] = INF;
        }
    }
    warshall_floyd_edge(n);

    int q;
    cin >> q;
    for(int i=0; i<q; i++){
        int s,t;
        cin >> s >> t;
        if(edge[s-1][t-1]!=INF) cout << edge[s-1][t-1]-1 << "\n";
        else cout << -1 << "\n";
    }

    return 0;
}

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

vector<complex<double> > fft(vector<complex<double> > a, bool inverse = false){
    int n = a.size();
    int h = 0;
    for(int i = 0; 1 << i < n; i++) h++;
    for(int i = 0; i < n; i++){
        int j = 0;
        for(int k = 0; k < h; k++) j |= (i >> k & 1) << (h - 1 - k);
        if(i < j) swap(a[i], a[j]);
    }
    for(int b = 1; b < n; b *= 2){
        for(int j = 0; j < b; j++){
            complex<double> w =
                polar(1.0, (2 * M_PI) / (2 * b) * j * (inverse ? 1 : -1));
            for(int k = 0; k < n; k += b * 2){
                complex<double> s = a[j + k];
                complex<double> t = a[j + k + b] * w;
                a[j + k] = s + t;
                a[j + k + b] = s - t;
            }
        }
    }
    if(inverse)
        for(int i = 0; i < n; i++) a[i] /= n;
    return a;
}

vector<complex<double> > fft(vector<double> a, bool inverse = false){
    vector<complex<double> > a_complex(a.size());
    for(int i = 0; i < a.size(); i++) a_complex[i] = complex<double>(a[i], 0);
    return fft(a_complex, inverse);
}

vector<double> convolve(vector<double> a, vector<double> b){
    int s = a.size() + b.size() - 1;
    int t = 1;
    while(t < s) t *= 2;
    a.resize(t);
    b.resize(t);
    vector<complex<double> > A = fft(a);
    vector<complex<double> > B = fft(b);
    for(int i = 0; i < t; i++) A[i] *= B[i];
    A = fft(A, true);
    a.resize(s);
    for(int i = 0; i < s; i++) a[i] = A[i].real();
    return a;
}

int main(){
    int N;
    long M;
    cin >> N >> M;
    vector<double> a(100001, 0);
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        a[A] = a[A] + 1.0;
    }
    
    vector<double> b = a;
    
    vector<double> f = convolve(a, b);
    
    long ans = 0, i = f.size() - 1;
    while(i >= 0){
        if(f[i] > M){
            ans += i * M;
            break;
        }
        ans += i * (long)(f[i] + 0.5);
        M -= (long)(f[i] + 0.5);
        i--;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 20568
#include <bits/stdc++.h>
//debug
#define vecprint(v) rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define w1(a) cout<<(a)<<" "
#define w2(a,b) cout<<(a)<<" "<<(b)<<" "
#define w3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wl1(a) cout<<(a)<<endl
#define wl2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wl3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};


int main() {
  //input
  int x,y;
  cin >> x >> y;
  
  //process
  if(x*2 <= y && x*4 >= y && y%2 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  //output
}

Measured memory_bytes: 3624
<?php
define("MOD", 10**9+7);
fscanf(STDIN, "%d%d", $N, $M);
 
$map = factor($M);
$product = 1;
foreach($map as $prime => $count){
    $product *= nCm($count + $N - 1, $count);
    $product %= MOD;
}
printf("%d", $product);
 
//足し算
function addm($a, $b){
    return ($a + $b) % MOD;
}
//引き算
function subm($a, $b){
    return ($a + MOD - $b) % MOD;
}
//掛け算
function mulm($a, $b){
    return ($a * $b) % MOD;
}
//割り算
function divm($a, $b){
    return mulm($a, powerm($b, MOD - 2));
}
//累乗
function powerm($a, $b){
    if($b == 0)return 1;
    if($b & 1)return (powerm($a, $b>>1)**2 % MOD) * $a % MOD;
    return powerm($a, $b>>1)**2 % MOD;
}
//階乗
function factorialm($a){
    if($a == 0)return 1;
    return factorialm($a - 1) * $a % MOD;
}
//順列
function nPm($n, $m){
    if($m == 0)return 1;
    return nPm($n, $m - 1) * ($n - $m + 1) % MOD;
}
//組み合わせ
function nCm($n, $m){
    $m = min($m, $n-$m);
    return divm(nPm($n, $m), factorialm($m));
}
function factor($M){
    $rootM = $M**0.5+1;
    for($j = 2; $j <= $rootM; $j++){
        if($M%$j == 0){
            @$map[$j]++;
            $M/=$j;
            $rootM = $M**0.5+1;
            $j--;
        }
    }
    if($M>1){
        @$map[$M]++;
    }
    return $map;
}



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

struct Sweets{
	int i, p, q, r;
};

int main(){
	int n;
	Sweets s[1000];
	while(1){
		cin >> n;
		if(n == 0) break;
		for(int i = 0;i < n;i++){
			cin >> s[i].i >> s[i].p >> s[i].q >> s[i].r;
		}
		int P, Q, R, C;
		cin >> P >> Q >> R >> C;
		int sum = 0;
		for(int i = 0;i < n;i++){
			if(s[i].p <= P && s[i].q <= Q && s[i].r <= R && 
				(s[i].p * 4 + s[i].q * 9 + s[i].r * 4) <= C){
				cout << s[i].i << endl;
				sum++;
			}
		}
		if(sum == 0) cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 880
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



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

    string S;cin >> S;
    vector<int> opeCount(26,100100);
    for(int i = 0;i<26;i++){
        char now = 'a'+i;
        int count = 0;
        int countMaxi = 0;
        for(int j = 0;j<S.size();j++){
            if(S.at(j) != now) count++;
            else{
                count = 0;
            }
            countMaxi = max(count,countMaxi);
        }
        if(countMaxi != S.size()){
            opeCount.at(i) = countMaxi;
        }
    }
    int ans = 105;
    for(int V : opeCount) ans = min(ans,V);
    cout << ans << endl;
}

Measured memory_bytes: 3624
N,A,B=map(int,input().split())
X=[int(x) for x in input().split()]
X.sort(reverse=True)
ave=sum(X[:A])/A
p=X[A-1]
c=0
o=0
for i in range(N):
  if X[i]==p:
    c +=1
  elif X[i]>p:
    o +=1
    

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
 
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
 
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
 
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
 
    return result
answer=0
if not o==0:
  answer=cmb(c,A-o)
else:
  for i in range(A,min(c,B)+1):
    answer += cmb(c,i)
print(ave)
print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
const int INF = 1e18;
signed main(){
    int n;cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    sort(a.begin(),a.end());
    if(a[0] == 0){
        cout << 0 << endl;
        return 0;
    }
    int ret = 1;
    rep(i,n){
        if(ret<= INF/a[i]){
            ret = ret*a[i];
        }
        else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 4060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using ld = long double;
const ld pi = acos(-1);

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

    ld a, b, h, m;
    cin >> a >> b >> h >> m;
    ld ans = 0.0;
    ld r1 = 2.0 * pi * h / 12;
    ld r2 = 2.0 * pi * m / 60;
    r1 += m * pi / 360;
    if(a > b){
        swap(a, b);
        swap(r1, r2);
    }
    if(r1 > r2) r2 += 2.0 * pi - r1;
    else    r2 -= r1;
    if(pi / 2 <= r2 && r2 <= 3.0 * pi / 2){
        ld theta;
        if(r2 > pi) theta = r2 - pi;
        else    theta = pi - r2;
        ld x = a + b * cos(theta);
        ld y = b * sin(theta);
        ans = hypot(x, y);
    }
    else{
        ld theta;
        if(r2 > pi) theta = 2.0 * pi - r2;
        else    theta = r2;
        ld x = abs(b * cos(theta) - a);
        ld y = b * sin(theta);
        ans = hypot(x, y);
    }
    cout << fixed << setprecision(15);
    cout << ans << endl;
}

Measured memory_bytes: 4188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int l1, l2, l3, l4, n;
	cin >> n;
	l1 = n / 1000;
	l2 = n % 1000 / 100;
	l3 = n % 1000 % 100 / 10;
	l4 = n % 1000 % 100 % 10 / 1;
	
	if ( (l1 == l2 && l2 == l3) || (l2 == l3 && l3 == l4) )
	cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())

table = [[-1 for i in range(N)] for j in range(N)]

for i in range(N):
  A = int(input())
  for j in range(A):
    x, y = map(int, input().split())
    table[i][x-1] = y


result = 0
for i in range(2**N):
  state = bin(i)[2:]
  state = list('0' * (N - len(state)) + state)
  d = 1
  for i, tf in enumerate(state):
    if tf == '1':
      c = 1
      for j, a in enumerate(table[i]):
        if a == 1:
          if state[j] != '1':
            c = 0
            break
        elif a == 0:
          if state[j] != '0':
            c = 0
            break
      if c != 1:
        d = 0
        break
  if d == 1:
    result = max(result, state.count('1'))

print(result)      

Measured memory_bytes: 3064
using System;

class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);
        Console.WriteLine("{0} {1} {2}", a / b, a % b, (a / (double)b).ToString("F8"));
        Console.ReadKey();
    }
}

Measured memory_bytes: 5712
#include<stdio.h>
int main()
{
		int a,b,c,s,co,l,m,sum,i;
		scanf("%d", &a);
		scanf("%d %d", &b,&c);
		sum=0;
			m=c+a;
		while(a--){
				scanf("%d", &l);
				co=0;
				for(i=1;i<=b;i++){
						s=((i*l)+1);
						if(s>b){
								break;
						}
							co++;
				}
				sum+=co;
		}
		printf("%d\n", sum+m);
		return 0;
}

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

main(){
  int A,B,money;
  cin >> A >> B ;
  
  if( A >= 13){
    money = B;
  }
  else if( 12 >= A && A >= 6){
    money = B/2;
  }
  else money = 0;
  cout << money << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>

using namespace std;

int main()
{
    double r,area,circ;
    cin >> r;
    area = r*r*3.141592653589;
    circ = 2*r*3.141592653589;
    cout << fixed <<setprecision(7);
    cout << area << " " << circ << endl;

    return 0;
}


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

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


#define      TEST    int t ; cin >> t ; while( t -- )

const ll big = 10e7 + 11 ;
const double PI  =3.141592653589793238463;
int  main (  ) {

    FASTIO ;

    double n ;
    cin >> n ;

    double ans = 2 * PI * n ;

    cout << ans ;

    return  0 ;
}


Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

vector<vector<int>> ans;

void rec(int l, int r, int depth){
    if(abs(l-r) <= 1) {
        return;
    }
    int m = (l+r)/2;
    rec(l, m, depth+1); rec(m, r, depth+1);

    for (int i = 0; i < m; ++i) {
        for (int j = m; j < r; ++j) {
            ans[j][i] = depth;
            ans[i][j] = depth;
        }
    }
}

int main() {
    int n;
    cin >> n;
    ans = vector<vector<int>> (n, vector<int>(n, -1));
    rec(0, n, 1);
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            if(j != i+1) printf(" ");
            printf("%d", ans[i][j]);
        }
        puts("");
    }
    return 0;
}

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

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto X = RD;
	
	writeln(X >= 30 ? "Yes" : "No");
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 2748
#include <bits/stdc++.h>
	#define endl "\n"
	#define ll long long int
	#define vi vector<ll>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<ll,ll>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y) 
	#define mem(a,val) memset(a,val,sizeof(a))
	#define pb push_back;
	#define f first
	#define s second
	
	using namespace std;
	
	signed main()
	{

	

	int n; cin>>n;
	double a,b,f=1;
	string s;
	std::vector<double> vec[n+1];
	for (int i = 1; i <= n; ++i)
	{
		/* code */
		cin>>a>>b;
		vec[i].push_back(a);
		vec[i].push_back(b);
		s+='0' + i;
		f*=i;
	}
	double ans=0;
	do{
		for (int i = 1; i < n; ++i)
		{
			/* code */
			int r = s[i] - '0';
			int t = s[i-1]-'0';
			double c = pow(vec[r][0]-vec[t][0], 2);
			double d = pow(vec[r][1]-vec[t][1], 2);
			ans += sqrt(c+d);

		}
	}while(next_permutation(s.begin(),s.end()));
	cout<<fixed<<setprecision(10)<<ans/f;
	return 0;
	}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
ll n,l,r,x;
    int b[200009],a[200009];
int main()
{
    string s,t;
    cin>>s>>t;
    n=s.length();
    int ans=0;
    for(int i=0;i<n;i++)
        if(s[i]!=t[i])
            ans++;
        cout<<ans;
}


Measured memory_bytes: 3904
import sys

# import re
# import math
# import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
# import copy
# import heapq
# import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    edge = [[] for i in range(n)]
    origin_edge = []
    edge_dic = {}
    for i in range(n - 1):
        a, b = ns()
        a -= 1
        b -= 1
        edge[a].append(b)
        edge[b].append(a)
        edge_dic[(a, b)] = -1
        origin_edge.append((a, b))

    max_root = 0
    for e in edge:
        max_root = max(max_root, len(e))

    que = queue.Queue()
    que.put((0, -1))

    while que.qsize() > 0:
        node, used_color = que.get()
        current_color = 0 if used_color != 0 else 1
        for k in edge[node]:
            ai = min(node, k)
            bi = max(node, k)

            if edge_dic[(ai, bi)] > -1:
                continue

            edge_dic[(ai, bi)] = current_color
            que.put((k, current_color))
            current_color = current_color + 1 if used_color != current_color + 1 else current_color + 2

    print(max_root)
    for a, b in origin_edge:
        print(edge_dic[(a, b)] + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 91676
import java.io.*
import java.util.*

fun solve(N: Long, H: Long, a: LongArray, b: LongArray){
    // 投げる回数 i (<= N)
    // i回投げ(大きい方からi個), 攻撃力最大の武器で残りを攻撃
    val maxAttack = a.max()!!
    val cumSum = b.sortedDescending().scanLeft(0L){ a,b -> a+b }.toList()
    var ans = floorDiv(H, maxAttack)
    for (i in 1..N){
        val throwPt = cumSum[i.toInt()-1]
        val ret  =  i + floorDiv(Math.max(0, H-throwPt), maxAttack)
        ans = Math.min(ans, ret)
    }
    println(ans)
    return
}

fun <T, R> Iterable<T>.scanLeft(initial: R, operation: (acc: R, T) -> R): Sequence<R> {
    var last = initial
    return this.asSequence().map { last = operation(last, it); last }
}

fun floorDiv(a: Long, b: Long): Long = a / b + if ( a % b == 0L ) 0L else 1L

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val H = sc.next().toLong()
    val a = LongArray(N.toInt())
    val b = LongArray(N.toInt())
    for (i in 0 until N.toInt()) {
        a[i] = sc.next().toLong()
        b[i] = sc.next().toLong()
    }
    solve(N, H, a, b)
}



Measured memory_bytes: 53924
/* ex3-3
   Sagzar1993  */


#include <stdio.h>

int main(void) {
    //表す整数と基数を定義
    int num, numBase;

    //入力を受け取る
    scanf("%d %d", &num, &numBase);

    int i = 0;

    while(num >= 1){
        num = num / numBase;
        i++;
    }

    printf("%d\n", i);
    
    return 0;
}


Measured memory_bytes: 128
t = input().split()
n, k = int(t[0]), int(t[1])
ans = 1.0
for i in range(1, min(n + 1, k)):
    ki, cp = i, 1.0 / n * 0.5
    while ki < k:
        ki *= 2
        ans -= cp
        cp *= 0.5
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main(){
	char m[9][9],s[9][9];
	int i,j,k=0;
	for(j=0;j<8;j++){
		scanf("%s",m[j]);
		strcpy(s[j],m[j]);
	}
	for(k=90;k<360;k+=90){
		printf("%d\n",k);
		for(i=0;i<8;i++){
			for(j=0;j<8;j++){
				s[j][7-i]=m[i][j];
			}
		}
		for(j=0;j<8;j++){
			printf("%s\n",s[j]);
			strcpy(m[j],s[j]);
		}
	}
    return 0;
}

Measured memory_bytes: 2684
# coding: utf-8

# https://atcoder.jp/contests/abc081/tasks/arc086_a
# 14:07-14:14 done


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A = sorted(A)

    cnt = {}
    for a in A:
        if a in cnt:
            cnt[a] += 1
        else:
            cnt[a] = 1
    
    num_cnts = [[k, v] for k, v in cnt.items()]

    # if len(num_cnts) <= K:
    #     return 0

    num_cnts = sorted(num_cnts, key=lambda x: x[1], reverse=True)
    ans = sum([cnt for num, cnt in num_cnts[K:]])

    return ans


print(main())


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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c;
    for(int i = 1; i < 3; i++)
        {
        if(a >= b)
        {
            d = a;
            a = b;
            b = d;
        }
    
        if(b >= c)
        {
            d = b;
            b = c;
            c = d;
        }
    
        if(a >= c)
        {
            d = a;
            a = c;
            c = d;
        }
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}

Measured memory_bytes: 3092
n=int(input())

int_sqrt=lambda x:int(x**0.5)+1
def prime_factor(x):
  d={}
  for i in p:
    while x%i<1:
      x//=i
      d[i]=d.get(i,0)+1
    if x<2: break
  if x>1: d[x]=1
  return d

p=range(2,int_sqrt(n))
d=prime_factor(n)
a=0
for i in d.values():
  t=c=0
  while t+c<i: c+=1; t+=c
  a+=c
print(a)

Measured memory_bytes: 9436
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

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

A.sort(reverse=True)
if N%2:
    print(2*sum(A[:(N+1)//2])-A[0]-A[N//2])
else:
    print(2*sum(A[:N//2])-A[0])



Measured memory_bytes: 31528
#include<stdio.h>
#include<string.h>

int friend[502][502], ans[502];

void dfs(int x,int y){
  if(y < 0)return;
  int i;
  ans[x] = 1;
  for(i = 1;i < 501;i++){
    if(friend[x][i]){
      dfs(i, y - 1);
    }
  }
}

int main(){
  while(1){
    int n, m, res = 0, i, j;
    scanf("%d%d",&n ,&m);
    if(n == 0 && m == 0)return 0;
    memset(friend, 0, sizeof(friend));
    memset(ans, 0, sizeof(ans));
    for(i = 0;i < m;i++){
      int a, b;
      scanf("%d%d", &a, &b);
      friend[a][b] = 1;
      friend[b][a] = 1;
    }
    dfs(1, 2);
    for(i = 2;i <= n;i++){
      res += ans[i];
    }
    printf("%d\n", res);
  }
}

Measured memory_bytes: 1592
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair
#define debug_vec(x, n) cout << (#x) << ": "; for(int i = 0; i < n; i++) cout << x[i] << (i == n - 1 ? "\n" : " ");

typedef long long ll;
typedef long double ld;

void solve(){
    ll n, m, x;
    cin >> n >> m >> x;
    int a[n + 1][m + 1] = {0};
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= m; j++){
            cin >> a[i][j];
        }
    }
    int res = -1;
    for(int i = 1; i < (1 << n); i++){
        vector<int> b(m);
        int curr = 0;
        for(int j = 0; j <= n; j++){
            if((i >> j) & 1){
                for(int k = 0; k < m; k++){
                    b[k] += a[j][k + 1];
                }
                curr += a[j][0];
            }
        }
        // cout << i << "\n";
        // debug_vec(b, m);
        // cout << curr << "\n";
        int flag = 0;
        for(int j = 0; j < m; j++){
            if(b[j] < x){
                flag = 1;
                break;
            }
        }
        if(flag == 0){
            if(res == -1){
                res = curr;
            }
            else if(curr < res){
                res = curr;
            }
        }
    }
    cout << res << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
import math
N,K = map(int,input().split())
ans = 0
for i in range(1,N+1):
  if i >=K:
    ans += 1/N
  else:
    X = math.ceil(math.log2(K)-math.log2(i))
    ans += ((1/N)*((1/2)**X))
print(ans)

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String line = sc.next();
    Main abc122B = new Main();
    System.out.println(abc122B.solve(line));
  }

  public int solve(String line) {
    int ans = 0;
    int temp = 0;
    Set<Character> set = new HashSet(Arrays.asList('A', 'T', 'C', 'G'));
    for (int i = 0; i < line.length(); i++) {
      if (set.contains(line.charAt(i))) {
        temp += 1;
        if (temp > ans) {
          ans = temp;
        }
      } else {
        temp = 0;
      }
    }
    return ans;
  }
}


Measured memory_bytes: 23252
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;
constexpr long double kPI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, M;
  cin >> N >> M;
  vector<pll> XY(M);
  vll R(N, 0);
  R[0] = 1;
  vll W(N, 1);
  REP(i, 0, M) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    W[x]--;
    W[y]++;
    if (R[x]) {
      R[y] = 1;
    }
    if (W[x] == 0) {
      R[x] = 0;
    }
  }

  int ans = 0;
  REP(i, 0, N) {
    if (R[i]) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n;
  cin >> n;
  vector<P> task(n);
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    task[i] = make_pair(b,a);
  }
  int cur = 0;
  sort(all(task));
  rep(i,n) {
    cur += task[i].se;
    if(cur > task[i].fi) {
      cout << "No" << endl;
      return 0;
     }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#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++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
const int INF = 1e9;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */

/** Problem1241 : Lagrange's Four-Square Theorem **/
int main()
{
	int N;
	while (cin>>N, N) {
		int ans=0;
		
		for (int a=1; a*a<=N; a++) {
			if (N - a*a == 0) {
				ans++;
				continue;
			}
			
			for (int b=a; a*a+b*b<=N; b++) {
				if (N - a*a - b*b == 0) {
					ans++;
					continue;
				}
				
				for (int c=b; a*a+b*b+c*c<=N; c++) {
					int diff = N - a*a - b*b - c*c;
					if (diff == 0) {
						ans++;
						continue;
					}
					
					int sqdiff = (int)sqrt(diff);
					if (sqdiff*sqdiff == diff && sqdiff >= c) {
//						cerr << a << " " << b << " " << c << " " << sqdiff << endl;
						ans++;
						continue;
					}
				}
			}
		}
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        int n;
        
        n=s.length();
        
        String X;
        
        X=s.substring(n-1);
        if(X.equals("s")) {
        	 System.out.println(s+"es");
        } else {
        	 System.out.println(s+"s");
        }
        
    
       
    }
}


Measured memory_bytes: 38464
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}


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

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

  int A, B, C, D;
  cin >> A >> B >> C >> D;

  cout << max(0, min(B, D) - max(A, C)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int Case,k,n,a,b,c,d;
int l,r,mid,A,B;
int main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>Case;
	while(Case--)
	{
		cin>>a>>b>>c>>d;
		n=a+b;
		l=0,r=n+1,k=(max(a,b)-1)/(min(a,b)+1)+1;
		while(l<r)
		{
			mid=(l+r)>>1;
			A=a-mid/(k+1)*k-mid%(k+1),B=b-mid/(k+1);
			if(B<=1LL*A*k) l=mid+1;
			else r=mid;
		}
		A=a-l/(k+1)*k-l%(k+1),B=b-l/(k+1),r=l+B-A*k+1;
		for(int i=c;i<=min(d,l);i++) cout<<((i%(k+1))?"A":"B");
		for(int i=max(c,l+1);i<=d;i++) cout<<(((i-r)%(k+1))?"B":"A");
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a;
    cin >> a;
    
    // 文字列の入力
    string s;
    cin >> s;
    string s2;
    
    s2 = a >= 3200 ? s : "red";
    // 出力
    cout << s2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        
    }
    vector<int> a(v);
    sort(v.begin(),v.end());
    int l, r;
    l = v[n/2 - 1];
    r = v[n/2];
    if (l != r) {
        for (int i = 0; i < n; i++) {
            if (a[i] <= l) {
                cout << r << endl;
            }
            else if (a[i] >= r) {
                cout << l << endl;
            }
        }
    }
    else if (l == r) {
        for (int i = 0; i < n; i++) {
            cout << l << endl;
        }
    }
    return 0;
}

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

class Solve {
private:
	using Real = long double;
	using Point = std::complex<Real>;
	using pd5 = std::array<Point, 5>;
	using vd = std::vector<Real>;
	using vvd = std::vector<vd>;

	int N, M, L;
	std::vector<pd5> stars;
	vvd graph;

	void makeStars()
	{
		stars.resize(N);
		for (auto& e: stars)
		{
			int x, y, a, r;
			scanf("%d%d%d%d", &x, &y, &a, &r);
			for (int i{}; i < 5; i++)
			{
				Real angular{(a + 90 + 72 * i) / 180.0 * M_PI};
				e[i].real(x + r * std::cos(angular));
				e[i].imag(y + r * std::sin(angular));
			}
		}
	}

	void makeGraph()
	{
		graph.resize(N, vd(N));
		for (int i{}; i < N; i++)
			for (int j{1}; j < N; j++)
				graph[i][j] = graph[j][i] = calcDistance(i, j);
	}

	Real calcDistance(int a, int b)
	{
		Real min{1e9};
		for (int a_i{}; a_i < 5; a_i++)
			for (int b_i{}; b_i < 5; b_i++)
			{
				if (linesCross(a, a_i, b, b_i))
					return 0;
				Point &a1{stars[a][a_i]}, &a2{stars[a][(a_i + 2) % 5]}, &b1{stars[b][b_i]}, &b2{stars[b][(b_i + 2) % 5]};
				min = std::min(min, std::abs(a1 - b1));
				if (std::real((a1 - b1) / (b2 - b1)) > 0 && std::real((a1 - b2) / (b1 - b2)) > 0)
					min = std::min(min, std::abs(a1 - b1) * std::abs(std::sin(std::arg((a1 - b1) / (b2 - b1)))));
				if (std::real((b1 - a1) / (a2 - a1)) > 0 && std::real((b1 - a2) / (a1 - a2)) > 0)
					min = std::min(min, std::abs(b1 - a1) * std::abs(std::sin(std::arg((b1 - a1) / (a2 - a1)))));
			}
		return min;
	}

	bool linesCross(int a, int a_i, int b, int b_i)
	{
		Point &bbase{stars[b][b_i]};
		Point &bfrom{stars[b][(b_i + 2) % 5]};
		Point &abase{stars[a][a_i]};
		Point &afrom{stars[a][(a_i + 2) % 5]};
		return std::imag((abase - bbase) / (bfrom - bbase)) * std::imag((afrom - bbase) / (bfrom - bbase)) < 0
			&& std::imag((bbase - abase) / (afrom - abase)) * std::imag((bfrom - abase) / (afrom - abase)) < 0;
	}

	Real dijkstra()
	{
		using pri = std::pair<Real, int>;
		std::priority_queue<pri, std::vector<pri>, std::greater<pri>> dij;
		dij.push({0, M});
		std::vector<Real> dist(N, 1e9);
		dist[M] = 0;
		while (!dij.empty())
		{
			auto now{dij.top()};
			dij.pop();
			if (now.first > dist[now.second]) continue;
			for (int i{}; i < N; i++)
				if (now.first + graph[now.second][i] < dist[i])
				{
					dist[i] = now.first + graph[now.second][i];
					dij.push({dist[i], i});
				}
		}
		return dist[L];
	}

public:
	bool is_last_query{};
	Solve()
	{
		scanf("%d%d%d", &N, &M, &L);
		if (N == 0)
		{
			is_last_query = true;
			return;
		}
		M--; L--;
		makeStars();
		makeGraph();
		std::cout << std::setprecision(10) << std::fixed << dijkstra() << std::endl;
	}
};

int main()
{
	while (!Solve().is_last_query);

	return 0;
}


Measured memory_bytes: 3720
#![allow(dead_code)]
use std::collections::VecDeque;
use std::io::*;
struct Io<'a> {
    r: BufReader<StdinLock<'a>>,
    w: BufWriter<StdoutLock<'a>>,
    buf: VecDeque<String>,
    buf_str: String,
}
impl<'a> Io<'a> {
    fn r<T: std::fmt::Debug, S: std::str::FromStr<Err = T>>(&mut self) -> S {
        if self.buf.len() == 0 {
            self.r.read_line(&mut self.buf_str).unwrap();
            for w in self.buf_str.split_whitespace() {
                self.buf.push_back(w.to_owned());
            }
            self.buf_str.clear();
        }
        self.buf.pop_front().unwrap().parse().unwrap()
    }
    fn w<T: std::fmt::Display>(&mut self, v: T) {
        writeln!(self.w, "{}", v).unwrap();
    }
    fn iter<'b, T: std::fmt::Debug, S: std::str::FromStr<Err = T>>(
        &'b mut self,
    ) -> IoIter<'a, 'b, T, S> {
        IoIter {
            io: self,
            p: std::marker::PhantomData,
            q: std::marker::PhantomData,
        }
    }
}
struct IoIter<'a: 'b, 'b, T: std::fmt::Debug, S: std::str::FromStr<Err = T>> {
    io: &'b mut Io<'a>,
    p: std::marker::PhantomData<T>,
    q: std::marker::PhantomData<S>,
}
impl<'a, 'b, T: std::fmt::Debug, S: std::str::FromStr<Err = T>> Iterator for IoIter<'a, 'b, T, S> {
    type Item = S;
    fn next(&mut self) -> Option<S> {
        Some(self.io.r())
    }
}
fn main() {
    let stdin = stdin();
    let stdout = stdout();
    let r = BufReader::new(stdin.lock());
    let w = BufWriter::new(stdout.lock());
    let io = Io {
        r: r,
        w: w,
        buf: VecDeque::new(),
        buf_str: String::new(),
    };
    problem(io);
}

fn problem(mut io: Io) {
    let n: usize = io.r();
    let k: usize = io.r();

    let a = n % k;
    let b = k - a;
    io.w(std::cmp::min(a, b));
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	
		//BufferedReader br=new BufferedReader(new FileReader("sample.txt"));
		
		Dice dice1 =new Dice(br.readLine());
		Dice dice2=new Dice(br.readLine());
		System.out.println(dice1.equals(dice2)?"Yes":"No");
	
		
		
	}
	}
class Dice{

String top,front,right,left,back,bot;

	Dice(String str){
		String[] s=str.split(" ");
		top=s[0];
		front=s[1];
		right=s[2];
		left=s[3];
		back=s[4];
		bot=s[5];
	}
	boolean equals(Dice d){
		for(int i=0;i<6;i++){
			if(front.equals(d.front))break;
			if(i==3)roll('E');
			roll('N');
		}
		for(int i=0;i<3;i++){
			if(top.equals(d.top))break;
			roll('W');
		}
		return left.equals(d.left)&&right.equals(d.right);
	}
		
	void roll(char c){
		String top,bot,back,front,left,right;
		
		top=this.top;bot=this.bot;
		front=this.front;
		back=this.back;
		left=this.left;
		right=this.right;
		
		switch(c){
		case 'N':
			top=this.front;
			bot=this.back;
			front=this.bot;
			back=this.top;
			break;
		
		case 'S':
			top=this.back;
			bot=this.front;
			front=this.top;
			back=this.bot;
			break;
		case 'W':
			top=this.right;
			bot=this.left;
			right=this.bot;
			left=this.top;break;
		
		case 'E':
			top=this.left;
			bot=this.right;
			right=this.top;
			left=this.bot;
			break;
		}
		this.top=top;
		this.front=front;
		this.right=right;
		this.left=left;
		this.back=back;
		this.bot=bot;
		
	}
	String getd1(){return this.top;}
}

Measured memory_bytes: 17096
/*
                        Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
        {   if(n % 2 ==1)
            result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
    return result % M;
}      
bool isPrime(int n)
    {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
    }
int inv(int a,int m)
{   return power(a,m-2);
}
int lcm(int a,int b)
{   return a*b/(gcd(a,b));
}
signed main()
{   jaldi
    int n;
    cin>>n;
    int a[n],i;
    for(i=0;i<n;i++)
    cin>>a[i];
    int ans=0;
    for(i=0;i<n;i++)
    {   for(int j=i+1;j<n;j++)
        ans+=a[i]*a[j];
    }
    cout<<ans;
}

Measured memory_bytes: 256