akhauriyash/Code-Regression huggingface dataset:
public class Main {


  private static void solve() {
    double n = ni();
    double m = ni();
    double d = ni();
    
    double x;
    if (d == 0) {
      x = 1.0 / n;
    } else {
      x = 2.0 * (n - d) / n / n;
    }
    System.out.printf("%.12f\n", x * (m - 1));
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

int N;
int K;
vector<int> as;

int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}

int main() {
  scanf("%d%d", &N, &K);
  as.resize(N);
  for (int i=0; i<N; i++) {
    scanf("%d", &as[i]);
  }
  sort(as.begin(), as.end());
  as.erase(unique(as.begin(), as.end()), as.end());
  if (as.size() == 1) {
    if (as[0] == K) puts("POSSIBLE");
    else puts("IMPOSSIBLE");
    return 0;
  }

  int k = gcd(as[0], as[1]);
  for (int i=2; i<as.size(); i++) {
    k = gcd(k, gcd(as[i], as[0]));
    if (k == 1) {
      puts("POSSIBLE");
      return 0;
    }
  }

  if (K%k == 0 && as.back() >= K)  puts("POSSIBLE");
  else puts("IMPOSSIBLE");
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
    int i,j,H,W;

    while(cin>>H>>W&&!(H==0&&W==0)){
        for(i=0;i<H;i++){
            for(j=0;j<W;j++){
                cout<<"#";
            }
            cout<<"\n";
        }
        cout<<endl;                                    
    }
    return 0;
}



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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int, int>;
using ppa = pair<pa, int>;
#define SORT(v, n) sort(v, v + n);
#define ALL(v) v.begin(), v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v), greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)), v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (b - 1); i >= a; i--)
#define rrep(i, n) RFOR(i, 0, n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a, b) a = min(a, b)
#define maxs(a, b) a = max(a, b)

// 4近傍
int dy[]={0, 1, 0, -1};
int dx[]={1, 0, -1, 0};

// 8近傍
// int dy[]={0,0,1,-1,1,1,-1,-1};
// int dx[]={1,-1,0,0,1,-1,1,-1};

// const ll MOD = 1000000007;

ll pow_mod(ll a, ll b, ll mod) {
    ll tmp = 1;
    a %= mod;
    if (b > 0) {
        tmp = pow_mod(a, b / 2, mod);
        if (b % 2)
            tmp = (((tmp * tmp) % mod) * a) % mod;
        else
            tmp = (tmp * tmp) % mod;
    }
    return tmp;
}

void solve() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    int cnt = 0;
    rep(i,n){
        if(a[a[i]] == i) cnt++;
    }
    cout << cnt / 2 << endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int A, B, K;
  vector<int> ans;

  cin >> A >> B >> K;

  if(B-A+2 <= K){
    for(int i = A; i <= B; i++) cout << i << endl;
  }else{
    for(int i = A; i < A+K; i++) ans.push_back(i);
    for(int i = B; B-K < i; i--) ans.push_back(i);

    sort(ans.begin(), ans.end());

    for(int i = 0; i < ans.size(); i++){
      if(ans[i] == ans[i+1]) continue;
      cout << ans[i] << endl;
    }
  }

	return 0;
}


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

int main(){
  string s;
  cin >> s;
  int K;
  cin >> K;
  int N=s.size();
  set<string> sub;
  for(int i=0;i<N;i++){
    sub.insert({s[i]});
  }
  if(N>=2){
  for(int i=0;i<N-1;i++){
    sub.insert(s.substr(i,2));
  }
  }
  if(N>=3){
  for(int i=0;i<N-2;i++){
    sub.insert(s.substr(i,3));
  }
  }
  if(N>=4){
  for(int i=0;i<N-3;i++){
    sub.insert(s.substr(i,4));
  }
  }
  if(N>=5){
  for(int i=0;i<N-4;i++){
    sub.insert(s.substr(i,5));
  }
  }
  int count=1;
  for(auto x:sub){
    if(count==K){
      cout << x << endl;
      return 0;
    }
    count++;
  }
}

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

int main(){
    int a[4][3][10];
    int b,f,r,v,x;
    cin>>x;
    for(int bb=0;bb<4;bb++){
        for(int ff=0;ff<3;ff++){
            for(int rr=0;rr<10;rr++){
                a[bb][ff][rr]=0;
            }
        }
    }
    for(int i=0;i<x;i++){
        cin>>b>>f>>r>>v;
        a[b-1][f-1][r-1]+=v;
    }
    for(int bb=0;bb<4;bb++){
        for(int ff=0;ff<3;ff++){
            for(int rr=0;rr<10;rr++){
                cout<<" "<<a[bb][ff][rr];
                //if(rr!=9)cout <<" ";
            }
            cout<<'\n';
        }
        if(bb!=3)cout<<"####################"<<endl;
    }
}

Measured memory_bytes: 3068
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int):
    f = True
    for i in range(1,10):
        if(N%i == 0 and N//i <= 9):
            f = True
            break
        else:
            f = False

    if f:
        print(YES)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
const long long MOD=1000000007LL;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    long long ans=1;
    //Nが奇数⇒0が一個と偶数が2個ずつ出てくればOK、その時2^(N/2)が答え
    //Nが偶数⇒奇数が2個ずつ出てくればOK、その時2^(N/2)が答え
    rep(i,N){
        cin>>A.at(i);
    }
    rep(i,N/2){
        ans=(ans*2)%MOD;
    }
    sort(all(A));
    if(N%2==0){
        rep(i,N){
            if(i%2==0){
                if(A.at(i)!=i+1){
                    cout << 0 << endl;
                    return 0;
                }
            }else{
                if(A.at(i)!=i){
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
    }else{
        rep(i,N){
            if(i%2==0){
                if(A.at(i)!=i){
                    cout << 0 << endl;
                    return 0;
                }
            }else{
                if(A.at(i)!=i+1){
                    cout << 0 << endl;
                    return 0;
                }
            }
        }        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
//A Odds of Oddness
#include<bits/stdc++.h>
using namespace std;

int main()
{
  int n;
  double k;
  cin>>n;
  if(n%2==0)
  {
    k=n/2;
  }
  else
  {
    k=n/2+1;
  }
  cout<<k/n<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

void solve(long long N, std::vector<long long> C, std::vector<long long> S, std::vector<long long> F){
    for(ll i=0; i< N-1; i++){
        ll curtime=0;
        for(ll j=i; j< N-1; j++) {//* start from j and arrive at j+1
            //* start
            curtime = max((curtime+F[j]-1)/F[j] * F[j], S[j]);
            //* arrive at j+1
            curtime += C[j];
        }
        cout << curtime << endl;
    }
    cout << 0 << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> C(N-1);
    std::vector<long long> S(N-1);
    std::vector<long long> F(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&C[i]);
        scanf("%lld",&S[i]);
        scanf("%lld",&F[i]);
    }
    solve(N, std::move(C), std::move(S), std::move(F));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    int main(){
      int H,N;cin>>H>>N;
      vector<int> a(N);
      for(int i=0;i<N;i++)cin>>a[i];
      sort(a.begin(),a.end());
      for(int i=0;i<N;i++){
          
          H-=a[i];
          
      }
      if(H>0)cout<<"No"<<endl;
      else cout<<"Yes"<<endl;
    }
        






Measured memory_bytes: 640
#include <bits/stdc++.h>
#define maxi 300005
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define ll long long
#define si(n) scanf("%d",&n)
#define sll(n) scanf("%lld",&n)
#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif
#define gc getchar
#define REP(i,j,n)               for( i=j;i<n;i++)
#define PER(i,j,n)               for( i=n-1;i>=j;i--)
ll mpow(ll a, ll n,ll mod){
	ll ret=1;ll b=a;
	while(n) {
		if(n&1)
			ret=(ret*b)%mod;
		b=(b*b)%mod;
		n>>=1;
	}
	return (ll)ret;
}
inline void read(int &x){
	x=0;
	register char c=gc();
	for(;c<'0' || c>'9';c=gc());
	for(;c>='0' && c<='9';c=gc())
		x=(x<<3)+(x<<1)+(c-'0');
}
inline void write(int x){
	register char buffor[35];
	register int i=0;
	do{
		buffor[i++]=(x%10)+'0';
		x/=10;
	} while(x);
	i--;
	while(i>=0) putchar(buffor[i--]);
	putchar('\n');
}
inline int in() { int x; read(x); return x; }
void solve();
int dbg=1;
using namespace std;
int main(){
	int t=1;
	//read(t);
	for(int i=0;i<t;i++){
		//printf("Case #%d:\n",i);
		solve();
	}
	return 0;
}
void solve() {
	string s;
	ll i,j,k,n;
	cin>>s;
	n=s.size();
	REP(i,0,n)
		if(i%2==0&&s[i]=='L'){
			cout<<"No\n";
			return;
		}
		else if(i%2==1&&s[i]=='R'){
			cout<<"No\n";
			return;
		}
	cout<<"Yes\n";
}



Measured memory_bytes: 256
#include<iostream>
#include<queue>

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

const int MAX_N = 50;
int arr[MAX_N];

int main(void) {
        int N;  cin >> N;
        int max_abs = -1;
        int max_idx = -1;
        bool pos = true;

        queue<P> resq;

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

                if (abs(arr[i]) > max_abs) {
                        max_abs = abs(arr[i]);
                        max_idx = i;
                        pos = arr[i]>0;
                }
        }

        for (int i = 0; i < N; i ++) {
                if ((arr[i]>0) != pos) {
                        resq.emplace(max_idx, i);
                        arr[i] += max_abs;
                }
        }

        if (pos) {
                for (int i = 1; i < N; i ++) {
                        resq.emplace(i-1, i);
                }
        }
        else {
                for (int i = N-1; i >= 1; i --) {
                        resq.emplace(i, i-1);
                }
        }

        cout << resq.size() << '\n';
        while (!resq.empty()) {
                P p = resq.front();
                resq.pop();

                cout << (p.first+1) << ' '<< (p.second+1) << '\n';
        }

        return 0;

}


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

alias C = Tuple!(int, "i", int, "p", int, "y");
alias N = Tuple!(int , "i", int, "p", int, "c");

void main()
{
    auto M = readln.split.to!(int[])[1];
    C[] cs;
    foreach (i; 0..M) {
        auto py = readln.split.to!(int[]);
        cs ~= C(i, py[0], py[1]);
    }
    sort!"a.p < b.p"(cs);
    N[] ns;
    foreach (ccs; cs.chunkBy!"a.p") {
        auto pcs = ccs[1].array;
        sort!"a.y < b.y"(pcs);
        foreach (i, c; pcs) {
            ns ~= N(c.i, c.p, i.to!int + 1);
        }
    }
    sort!"a.i < b.i"(ns);
    foreach (n; ns) {
        writefln("%06d%06d", n.p, n.c);
    }
}

Measured memory_bytes: 9596
N,M = map(int,input().split())
s = []
c = []
for i in range(M):
    s1,c1=[int(i) for i in input().split()]
    s.append(s1)
    c.append(c1)

ans = [10 for i in range(N)]
x = ''

for j in range(M):
  if ans[s[j]-1] == 10:
     ans[s[j]-1] = c[j]
  elif ans[s[j]-1] != 10 and  ans[s[j]-1] != c[j]:
    print('-1')
    exit()
  
for k in range(N):
  if k == 0 and ans[k] == 10 and N != 1:
    ans[k] = 1
  elif k == 0 and ans[k] == 10 and N == 1:
    ans[k] = 0
  elif ans[k] == 10:
     ans[k] = 0
if N == 1:
  print(ans[0])
  exit()
else:
  if ans[0] == 0 :
    print('-1')
  else :
    for l in range(N):
      x += str(ans[l])
    print(x)



Measured memory_bytes: 3064
import java.util.*;
import java.util.Collections;

class Main{
    public static void main(String[] arg){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int ans = 0;
    List<Integer> list = new ArrayList<>();
    for(int i = 0; i < A; i++){
      list.add(sc.nextInt());
    }
    Collections.sort(list,Collections.reverseOrder());
    for(int j = 0; j < B; j++){
      ans =  ans + list.get(j);
    }
    System.out.println(ans);
  }
}


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

#define unsigned int long long
#define p(a, b) pair<a,b>

using namespace std;

//ifstream cin("Input.txt");
//ofstream cout("Output.txt");`

int main() {
    int n;
    cin >> n;
    for(int i = 0; i < 100;i ++){
        for(int j = 0; j < 100; j++){
            if((4*i + 7*j) == n){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    string a;
    cin>>a;
    if(a.back()=='s'){
        cout<<a<<"es\n";
    }
    else cout<<a<<"s\n";
}

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

    int t=1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
package main

import (
    "bufio"
    "fmt"
    "os"
)

func bicnt(x int) int {
  cnt := 0
  for x > 0 && x % 2 == 0 {
    cnt++
    x /= 2
  }
  return cnt
}

func main() {
    r := bufio.NewReader(os.Stdin)
    w := bufio.NewWriter(os.Stdout)
    defer w.Flush()

    var n int
    fmt.Fscan(r, &n)
    ans := 0
    for i := 0; i < n; i++ {
      var a int
      fmt.Fscan(r, &a)
      ans += bicnt(a)
    }
    fmt.Fprintln(w, ans)
}


Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main(void){
    long long N,i,ans;
    cin>>N;
    ans=0;
    for(i=1;i*i<N+1;i++){
        if(N%i==0&&N/i-1>i){
            ans+=N/i-1;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import Data.List

main = do
    n <- readLn :: IO Int
    as_inp <- map read . words <$> getLine :: IO [Int]
    let as = sort as_inp
    print $ head $ attack as


attack :: [Int] -> [Int]
attack [a] = [a]
attack (a:as) = attack $ sort (a : (filter (/=0) $ map (\x -> x `mod` a) as))

Measured memory_bytes: 48508
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<iostream> 
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define ll long long
#define ull unsigned long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define mod 10007
#define inf 0x3f3f3f3f
#define eps 1e-18
#define maxn 100010
inline ll read(){ll tmp=0; char c=getchar(),f=1; for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1; for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0'; return tmp*f;}
inline ll power(ll a,ll b){ll ans=1; for(;b;b>>=1){if(b&1)ans=ans*a%mod; a=a*a%mod;} return ans;}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void swap(int &a,int &b){int tmp=a; a=b; b=tmp;}
using namespace std;
int a[maxn],cnt[2][maxn];
int n;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read(),++cnt[i&1][a[i]];
	cnt[0][0]=cnt[1][0]=-1;
	int mx01=0,mx02=0,mx11=0,mx12=0;
	for(int i=1;i<=100000;i++)
		if(cnt[0][i]>=cnt[0][mx01])mx02=mx01,mx01=i;
		else if(cnt[0][i]>=cnt[0][mx02])mx02=i;
	for(int i=1;i<=100000;i++)
		if(cnt[1][i]>=cnt[1][mx11])mx12=mx11,mx11=i;
		else if(cnt[1][i]>=cnt[1][mx12])mx12=i;
	if(mx01==mx11)printf("%d\n",n-max(cnt[0][mx01]+cnt[1][mx12],cnt[0][mx02]+cnt[1][mx11]));
	else printf("%d\n",n-cnt[0][mx01]-cnt[1][mx11]);
//	printf("%d %d %d %d\n",mx01,mx02,mx11,mx12);
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();
		while(true){
			String data[] = reader.readLine().split(" ");
			int a= Integer.parseInt(data[0]);
			int b= Integer.parseInt(data[1]);
			
			if(a==0 && b==0)
				break;
			
			for(int y=0; y<a; y++){
				for(int x=0; x<b; x++){
					builder.append("#");
				}
				builder.append("\n");
			}
			builder.append("\n");
		
		}
		System.out.print(builder);
	}
}

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

int ans=0xffffff,cnt;

int main() {
    char S[222];
    cin>>S;
    int len=strlen(S);
    for(int i=len-2;i;i-=2) {
        if(strncmp(S,S+i/2,i/2)==0) {
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	for(size_t i = 0; i < N; i++)
	{
		long double xa , ya , ra , xb , yb , rb;
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		long double l2 = ( xa - xb )*( xa - xb ) + ( ya - yb )*( ya - yb );
		if(( ra + rb )*( ra + rb ) < l2)
		{
			cout << 0 << endl;
		} else
		{
			if(l2 < ( ra - rb )*( ra - rb ) && rb < ra)
			{
				cout << 2 << endl;
			} else if(l2 < ( rb - ra )*( rb - ra ) && ra < rb)
			{
				cout << -2 << endl;
			} else
			{
				cout << 1 << endl;
			}
		}
	}
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    vector<i64> A(N);
    REP(i, N) cin >> A[i];

    vector<i64> C(N + 1, 0);
    i64 prev = 0;
    REP(i, N) {
        C[i + 1] = C[i] + abs(A[i] - prev);
        prev = A[i];
    }
    vector<i64> CR(N + 1, 0);
    prev = 0;
    REP(i, N) {
        CR[i + 1] = CR[i] + abs(A[N - 1 - i] - prev);
        prev = A[N - 1 - i];
    }

    REP(i, N) {
        i64 s = C[i] + CR[N - (i + 1)];
        if (i == 0) s += abs(A[1]);
        if (i == N - 1) s += abs(A[N - 2]);
        if (0 < i && i < N - 1) {
            s += abs(A[i - 1] - A[i + 1]);
        }
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int main(){
	// sengen
	string s;
	cin >> s;
	// nyuryoku
	int ans = 0;
	if(s == "RRR"){
		ans = 3;
	}else if(s == "RRS" || s == "SRR"){
		ans = 2;
	}
	if(ans == 0){
		for(int i=0;i<3;i++){
			if(s[i] == 'R'){
				ans = 1;
				break;
			}
		}
	}
	// keisan
	cout << ans << endl;

	// syutsuryoku
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;
const lli mod = 1'000'000'007;

lli pw(lli n) {
    if (n == 0) return 1;
    if (n == 1) return 2;
    if (n % 2) {
        return (2 * pw(n - 1)) % mod;
    } else {
        lli t = pw(n / 2);
        return (t * t) % mod;
    }
}

int main() {
    lli N;
    cin >> N;
    vector<int> A(N, 0);
    REP (i, 0, N) {
        int t;
        cin >> t;
        A[t]++;
    }
    lli ans = pw(N / 2);
    bool ok = true;
    if (N % 2) A[0]++;
    for (int i = !(N % 2); i < N; i += 2) {
        if (A[i] != 2)  ok = false;
    }
    cout << ok * ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cmath> 
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <numeric> 
#include <iomanip>
#include <map> 
#include <stack>
#include <sstream>
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int MAX = 1e6;
long long max(long long a, long long b) { if (a > b)return a; else return b; }
long long min(long long a, long long b) { if (a < b)return a; else return b; }
const int MAXN = 1000000 + 30;
int a[MAXN];


  		     	/*ll n, k;
		std::cin >> k >> n;
		std::vector <int> v(n);
		for (ll i = 0; i < n; i++)
		{
				std::cin >> v[i];
		}
		std::sort(v.begin(), v.end());*/

int main()
{
	
		ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
		string  s;
		std::cin >> s;
		int qanak = 0;
		if (s[0] == 'R' && s[1] == 'S'&& s[2] == 'R')
		{
			cout << 1 << endl;
			return 0;
		}
		if (s[0] == 'R' && s[1] == 'R'&& s[2] == 'R')
		{
			cout << 3 << endl;
			return 0;
		}
		for (ll i = 0; i < s.size(); i++)
		{
			if (s[i] == 'R')
			{
				qanak++;
			}
		}
		cout << qanak << endl;
		
		


		
 return 0;

}




	

  



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



int main()
{
    long int n;
    scanf("%ld",&n);
    long int a[n],sum=0;
    for(int i=0;i<n;i++)
    {
        scanf("%ld",&a[i]);
        sum+=a[i];
    }
    sum-=n;
    printf("%ld\n",sum);
    return 0;

}

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

#define GET_MACRO(a, b, c, d, NAME, ...) NAME
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REP2(i, a) REP3(i, 0, a)
#define REP3(i, a, b) REP4(i, a, b, 1)
#define REP4(i, a, b, s) for (int i = (a); i < (int)(b); i += (s))
#define REPR(...) GET_MACRO(__VA_ARGS__, REPR4, REPR3, REPR2)(__VA_ARGS__)
#define REPR2(i, a) REPR3(i, 0, a)
#define REPR3(i, a, b) REPR4(i, a, b, 1)
#define REPR4(i, a, b, s) for (int i = (b)-1; i >= (int)(a); i -= (s))
#define ALL(c) (c).begin(), (c).end()
#define DUMP(x) (std::cerr << #x << ':' << ' ' << x << '\n')
#define TMPL_T template <typename T>
#define TMPL_TU template <typename T, typename U>
#define mut auto
#define let const auto

using Int = long long;
// clang-format off
namespace extio {
std::string delimiter=" ",pdelimiter=" ";
std::string bracket_b="",bracket_e="";
void chdelim(const std::string&s){delimiter=s;}
void chpdelim(const std::string&s){pdelimiter=s;}
void chbracket(const std::string&b,const std::string&e){bracket_b=b,bracket_e=e;}
TMPL_T  void pcont(std::ostream&os,const T&x){int c=0;for(const auto&a:x){if(c++)os<<delimiter;os<<a;}}
TMPL_TU void ppair(std::ostream&os,const std::pair<T,U>&p){os<<bracket_b<<p.first<<pdelimiter<<p.second<<bracket_e;}
}
namespace std {
TMPL_T ostream& operator<<(ostream&os,const vector<T>&x){extio::pcont(os,x);return os;}
TMPL_T ostream& operator<<(ostream&os,const set<T>&x){extio::pcont(os,x);return os;}
TMPL_T ostream& operator<<(ostream&os,const multiset<T>&x){extio::pcont(os,x);return os;}
TMPL_T ostream& operator<<(ostream&os,const deque<T>&x){extio::pcont(os,x);return os;}
TMPL_TU ostream& operator<<(ostream&os,const map<T,U>&x){extio::pcont(os,x);return os;}
TMPL_TU ostream& operator<<(ostream&os,const pair<T,U>&x){extio::ppair(os,x);return os;}
}
TMPL_TU inline bool chmax(T&x,U a){return x<a&&(x=a,1);}
TMPL_TU inline bool chmin(T&x,U a){return a<x&&(x=a,1);}

inline int in(){int x;std::cin>>x;return x;}

struct Initializer_ {
  Initializer_(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(0);
    std::cout << std::setprecision(10);
    std::cerr << std::setprecision(10);
  }
} precalc;
// clang-format on
// }}}

using namespace std;

signed main() {
  REP(i, 1, 10) {
    REP(j, 1, 10) { printf("%dx%d=%d\n", i, j, i * j); }
  }
  return 0;
}

Measured memory_bytes: 3132
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE =0;
static const int GRAY =1;
static const int BLACK=2;

int n;
vector<pair<int ,int> > adj[MAX];

void dijkstra(){
    priority_queue<pair<int,int> > PQ;
    int color[MAX],i,j;
    int d[MAX];
    for(i=0;i<n;i++){
        d[i]=INFTY;
        color[i]=WHITE;
        }
    d[0]=0;
        PQ.push(make_pair(0,0));
        color[0]=GRAY;
    while(!PQ.empty()){
        pair<int,int> f=PQ.top(); PQ.pop();
        int u=f.second;
        color[u]=BLACK;
        
        if(d[u]<f.first * (-1)) continue;
        
        for(j=0;j<adj[u].size();j++){
            int v=adj[u][j].first;
            if(color[v]==BLACK) continue;
            if(d[v]>d[u]+adj[u][j].second){
                d[v]=d[u]+adj[u][j].second;
                PQ.push(make_pair(d[v]*(-1),v));
                color[v]=GRAY;
            }
        }
    }
    
    for(i=0;i<n;i++){
        cout << i << " " << (d[i]==INFTY ?-1:d[i]) << endl;
    }
}

int main(){
    int k,u,v,c,i,j;
    
    cin>>n;
    for(i=0;i<n;i++){
        cin>>u>>k;
        for(j=0;j<k;j++){
            cin>>v>>c;
        adj[u].push_back(make_pair(v,c));
        }
    }
    dijkstra();
    
    return 0;
}



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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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


const ll MRINF = 5000000000000000;
int main() {


    string S;
    cin >> S;
    cout << S.substr(0, 3) << endl;


}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
int main(){
		int W, H, x, y, r, xr, yr;
		std::cin >> W >> H >> x >> y >> r;
		if (0 <= x - r && W >= x + r && 0 <= y - r && H >= y + r) {
			std::cout << "Yes" << std::endl;
		}
		else {
			std::cout << "No" << std::endl;
		}
		return 0;
}

Measured memory_bytes: 3076
N = int(input())
S = input()
S1 = S
Comb = 0
for i in range(0, 10):
    for j in range(0, 10):
        for k in range(0, 10):
            S = S1
            a, b, c = map(str, [i, j, k])
            if S.find(a) != -1:
                S = S[S.find(a)+1::]
                if S.find(b) != -1:
                    S = S[S.find(b)+1::]
                    if S.find(c) != -1:
                        Comb += 1
print(Comb)

Measured memory_bytes: 9176
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n , x, t=0;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
	    cin >> x;
	    if(x!=i)
	        t++;
	}
	if(t <= 2)
	    cout << "YES\n";
	else
	    cout << "NO\n";
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int n;
vi in;
pii f(int L,int R){
	ll sum=in[R]-in[L];
	int l=L,r=R;
	while(r-l>1){
		int h=(l+r)/2;
		if(sum<2*(in[h]-in[L]))r=h;
		else l=h;
	}
	ll mi=inf,it=-1;
	if(l!=L&&mi>abs(sum-2*(in[l]-in[L]))){
		mi=abs(sum-2*(in[l]-in[L]));
		it=l;
	}
	if(l+1!=R&&mi>abs(sum-2*(in[l+1]-in[L]))){
		it=l+1;
	}
	ll a=in[it]-in[L],b=sum-a;
	return {min(a,b),max(a,b)};
}
int main(){
	cin>>n;
	in=vi(n+1);
	rep(i,n)cin>>in[i+1];
	rep(i,n)in[i+1]+=in[i];
	ll out=inf;
	loop(i,2,n-1){
		pii a=f(0,i),b=f(i,n);
		out=min(out,max(a.second,b.second)-min(a.first,b.first));
	}
	cout<<out<<endl;
}








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

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

  int C = 0;
  string res = "No";

  if((A * B * 1)%2 == 1){
    res = "Yes";
  } else if((A * B * 2)%2 == 1){
    res = "Yes";
  } else if((A * B * 3)%2 == 1){
    res = "Yes";
  }

  cout << res << endl;

}


Measured memory_bytes: 256
# encoding: utf-8
a = []
STDIN.each_line {|line|
  a << line.to_i
}

@c = 0
# puts  a[0]
# puts  a[1]
# puts  a[2]
# puts  a[3]
1.step do |i|
  for num in 0..a[0] do
    for num1 in 0..a[1] do
      for num2 in 0..a[2] do
        if ( (num * 500) + (num1 * 100) + (num2 * 50) ) == a[3] then @c = @c + 1 end
      end
    end
  end
  break
end

puts @c

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

int main(){
    int x;
    cin >> x;
    int sum = 0;
    for(int i = 0; i < 1000000000; i++){
        sum += (i + 1);
        if(sum >= x)
        {
            cout << i + 1 << endl;
            return 0;
        }
    }
}

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

int main(void){
    int a,b,k;
    cin >> a >> b >> k;
    int i = min(a,b);
    while(true){
        if (a%i == 0 && b%i == 0) {
            k--;
        }
        if (k == 0) {
            cout << i << endl;
            break;
        }
        i--;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 2000009
#define ll long long
#define ld long double
#define ff first
#define ss second
#define inf 1000000005
#define mod 1000000007
using namespace std;
ll n, a[22][22];
int main() {
    cin>>n;
    vector<ll> dp((1<<n));
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            cin>>a[i][j];
        }
    }
    dp[0] = 1;
    for(int mask = 0; mask < (1 << n); mask++) {
        int i = __builtin_popcount(mask);
        for(int j=0;j<n;j++) {
            if(!(mask & (1 << j)) && a[i][j]) {
                int nxtmask = mask | (1 << j);
                dp[nxtmask] += dp[mask];
                dp[nxtmask] %= mod;
            }
        }
    }
    cout<<dp[(1<<n) - 1];
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 998244353;

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

  int k;
  cin >> k;
  string s;
  cin >> s;
  if(s.length() <= k){
    cout << s << endl;
  }else{
    string ret = s.substr(0,k);
    cout << ret + "..." << endl;
  }
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }

    ll sum = 0;
    for (auto x : arr) sum += x;
    ll mid1 = sum / n, mid2 = mid1 + 1;
    
    ll ans = 0;
    for (int i = 0; i < n; i++) ans = ans + (arr[i] - mid1) * (arr[i] - mid1);
    ll temp = 0;
    for (int i = 0; i < n; i++) temp = temp + (arr[i] - mid2) * (arr[i] - mid2);

    cout << min(ans, temp) << endl;
}

Measured memory_bytes: 3604
// Length of largest subarray with 0 Sum
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	int x, n, r;
	int a[105] = {0};
	cin >> x >> n;
	int minm = 105, ans = -1;
	for(int i=0;i<n;i++)
	{
		cin >> r;
		a[r] = 1;
	}
	if(n==0)
	{
		cout << x << endl;
		return 0;
	}
	for(int i=0;i<=101;i++)
	{
		if(a[i]==0)
		{
			if(abs(x-i)<minm)
			{
				minm = abs(x-i);
				ans = i;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
X, Y = map(int,input().split())
MOD = 10 ** 9 + 7


def calc_comb(n, k, mod):
    '''
        n が大きい場合に使う
    '''
    a = 1
    b = 1
    for i in range(1,k+1):
        a *= i
        a %= mod
        b *= n
        n -= 1
        b %= mod
    return b * pow(a, mod-2, mod) % mod

if (X+Y) % 3 != 0:
    print(0)
else:
    total_move = (X+Y) // 3
    # 右に2つ動くことを選択しなければいけない回数
    right_move =  min(X,Y) - total_move
    if right_move >= 0:
        print(calc_comb(total_move, right_move, MOD))
    else:
        print(0)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
	int a,b;
	cin>>a>>b;
	cout<<(a==b?"Yes":"No");
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

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

typedef pair<double, int> pdi;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-12;

double x[1002], y[1002], r[1002];
double d[1002];
int n;

int main() {
	REP(i, 2) {
		scanf("%lf %lf", x + i, y + i);
		r[i] = 0;
	}
	
	cin >> n;
	FOR(i, 2, n + 2) scanf("%lf %lf %lf", x + i, y + i, r + i);
	
	fill(d, d + n + 2, 1e11);
	
	priority_queue<pdi, vector<pdi>, greater<pdi> > pq;
	pq.push(pdi(0, 0));
	d[0] = 0;
	
	while (!pq.empty()) {
		pdi now = pq.top(); pq.pop();
		
		double cost = now.first;
		int pos = now.second;
		
		if (d[pos] != cost) continue;
		
		REP(i, n + 2) {
			if (i == pos) continue;
			double nextcost = cost + max<double>(0, hypot(x[pos] - x[i], y[pos] - y[i]) - (r[pos] + r[i]));
			
			if (d[i] <= nextcost + EPS) continue;
			pq.push(pdi(nextcost, i));
			d[i] = nextcost;
		}
	}
	
	printf("%.15lf\n", d[1]);
	
	return 0;
}

Measured memory_bytes: 6256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n,m,a[N],cnt[N];
int main() {
	scanf("%d%d",&n,&m);
	REP(i,1,n) cnt[i]=1;
	a[1]=1;
	while (m--) {
		int u, v;
		scanf("%d%d",&u,&v);
		++cnt[v],--cnt[u];
		if (!a[u]) continue;
		a[v] = 1;
		if (!cnt[u]) a[u] = 0;
	}
	printf("%d\n", accumulate(a+1,a+1+n,0));
}









Measured memory_bytes: 4736
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int N = 1e5 + 10;

int passS[ N ], passN[ N ];
vector< int > lang[ N ], speak[ N ];
int n, m;

int cnt = 0;

void dfsN( int u );

void dfsS( int u ) {
	if ( passS[ u ] ) return;
	passS[u] = 1;
	for ( int val : speak[u] ) {
		dfsN( val );
	}
}
void dfsN( int u ) {
	if ( passN[ u ] ) return;
	passN[u] = 1;
	for ( int val : lang[u] ) {
		dfsS( val );
	}
	++cnt;
}
int main( void ) {

	cin.sync_with_stdio( false );

	cin >> n >> m;
	for ( int i = 1 ; i <= n ; ++i ) {
		int k;
		cin >> k;

		lang[ i ].resize( k );
		for ( int j = 0 ; j < k ; ++j ) {
			cin >> lang[i][j];
			speak[ lang[i][j] ].emplace_back( i );
		}
	}

	dfsN( 1 );

	cout << ( cnt == n ? "YES" : "NO" ) << endl;

	return 0;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
int n, m;
int used[8];
int connect[8][8];
int dfs(int now, int depth){
  if(used[now]) return 0;
  if(depth == n) return 1;
  used[now] = 1;
  int ans = 0;
  for(int i=0; i<n; i++){
    if(connect[now][i]) ans += dfs(i, depth+1);
  }
  used[now] = 0;
  return ans;
}

int main() {
  cin >> n >> m;
  int a[m], b[m];
  for(int i=0; i<m; i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  for(int i=0; i<m; i++){
    connect[a[i]][b[i]] = connect[b[i]][a[i]] = 1;
  }
  cout << dfs(0, 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


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

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

int N;
int A[11234];
int B[11234];
int C[11234];
int ctr[11234];
queue< int >q;
vector< int >E[11234];
int ans = 0;
int d[11234];
int cnt = 0;
bool flag[11234];
bool a;

int main(){
    
    fill( ctr, ctr+11234, 0 );
    fill( flag, flag+11234, true );
    
    cin>>N;
    REP( i, N-1 ){
        cin>>A[i]>>B[i];
        A[i]--;
        B[i]--;
        E[A[i]].push_back( B[i] );
        E[B[i]].push_back( A[i] );
        ctr[A[i]]++;
        ctr[B[i]]++;
    }
    REP( i, N ) cin>>C[i];
    sort( C, C+N );
    
    REP( i, N ) if( ctr[i] == 1 ) q.push( i );
    
    while( !q.empty() ){
        int idx = q.front();
        q.pop();
        flag[idx] = false;
        d[idx] = C[cnt];
        cnt++;
        int next;
        REP( j, E[idx].size() ){
            next = E[idx][j];
            if( flag[next] ) break;
        }
        ctr[next]--;
        if( ctr[next] == 1 ) q.push( next );
    }
    
    REP( i, N ){
        REP( j, E[i].size() ){
            ans += min( d[i], d[E[i][j]] );
        }
    }
    
    cout<<ans/2<<endl;
    REP(i, N ){
        if( i )cout<<" ";
        cout<<d[i];
    }
    puts("");
    
    return 0;
}



Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1LL<<60)

//verified AOJ GRL_1
#define MAX_V 100000
template <typename T>
struct edge{int to;T cost;};

template <typename T>
void dijkstra(int s, vector<T> &d, vector<edge<T>> G[MAX_V]){
    priority_queue< pii,vector<pii>,greater<pii> > que;
    rep( i,d.size() )d[i]=INF;
    d[s] = 0;
    que.push( pii(0,s) );

    while( que.size() ){
        pii p=que.top();
        que.pop();

        int v=p.second;
        if(d[v]<p.first)continue;

        rep(i,G[v].size()){
            edge<T> e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(pii(d[e.to],e.to));
            }
        }
    }
}


signed main(){
    vector<edge<int>> G[MAX_V];
    int v,e,s,t;
    cin>>v>>e>>s>>t;
    s--,t--;

    rep(i,e){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        a--,b--,c--;
        G[a].pb(edge<int>{b,d});
        G[a].pb(edge<int>{c,d});
        G[b].pb(edge<int>{a,d});
        G[b].pb(edge<int>{c,d});
        G[c].pb(edge<int>{a,d});
        G[c].pb(edge<int>{b,d});
    }

    vector<int> d(MAX_V);
    dijkstra(s,d,G);

    cout<<d[t]<<endl;
}



Measured memory_bytes: 23824