akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        Point a = new Point();
        Point b = new Point();
        a.x = 0;
        a.y = 0;
        b.x = 100;
        b.y = 0;
        System.out.printf("%.8f %.8f\n", a.x, a.y);
        koch(n, a, b);
        System.out.printf("%.8f %.8f\n", b.x, b.y);

    }

    static void koch(int n, Point a, Point b){
        if( n == 0 )return;
        Point s = new Point();
        Point t = new Point();
        Point u = new Point();
        double th = Math.toRadians(60);

        s.x = (2.0 * a.x + 1.0 * b.x) / 3.0; // (a.x + b.x) * ３分の２
        s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
        t.x = (1.0* a.x + 2.0*b.x) / 3.0;
        t.y = (1.0*a.y + 2.0*b.y)/3.0;
        u.x = (t.x - s.x)*Math.cos(th) - (t.y - s.y)*Math.sin(th) + s.x;
        u.y = (t.y - s.y)*Math.cos(th) + (t.x - s.x)*Math.sin(th) + s.y;

        koch(n-1,a,s);
        System.out.printf("%.8f %.8f\n", s.x, s.y);
        koch(n-1,s,u);
        System.out.printf("%.8f %.8f\n", u.x, u.y);
        koch(n-1,u,t);
        System.out.printf("%.8f %.8f\n", t.x, t.y);
        koch(n-1,t,b);
    }

    static class Point{
        private double x;
        private double y;
    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


Measured memory_bytes: 42312
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int N;

    scanf("%d", &N);

    int *ds = (int *) malloc(sizeof(int) * N);

    for(int i = 0; i < N; i ++){
        scanf("%d", ds + i);
    }
    int sum = 0;

    for(int i = 0; i < N - 1; i ++){
        for(int j = i + 1; j < N; j ++){
            sum += ds[i] * ds[j];
        }
    }
    printf("%d\n", sum);
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll H,W,M;
  cin>>H>>W>>M;
  
  ll R[H+1],C[W+1];
  RREP(i,H) R[i]=0;
  RREP(i,W) C[i]=0;
  map<pair<ll,ll>,ll> B;
  REP(i,M){
    ll a,b;
    cin>>a>>b;
    R[a]++;
    C[b]++;
    B[MP(a,b)]++;
  }
  
  ll mxr=0,mxc=0;
  RREP(i,H) chmax(mxr,R[i]);
  RREP(i,W) chmax(mxc,C[i]);
  
  vector<ll> RR,CC;
  RREP(i,H){
    if(R[i]==mxr) RR.PB(i);
  }
  RREP(i,W){
    if(C[i]==mxc) CC.PB(i);
  }
  
  ll ans=mxr+mxc-1;
  bool CAN=false;
  REP(i,(ll)RR.size()){
    REP(j,(ll)CC.size()){
      if(B[MP(RR[i],CC[j])]!=1){
        co(ans+1);
        return 0;
      }
    }
  }
  
  co(ans);
  return 0;
}

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

int N;
int A[55][55];
vector<vector<int>> G;
vector<vector<int>> V;

void init(){
  G.clear();
  V.clear();
}

void add_edge( int a, int b ){
  G[a].push_back( b );
  G[b].push_back( a );
}
int make_node( int v ){
  G.push_back( vector<int>() );
  V.push_back( vector<int>(N) );
  int nv = G.size()-1;
  add_edge( v, nv );
  for(int i=0;i<N;i++)
    V[nv][i] = V[v][i]+1;
  return nv;
}

void dfs(int s,int id, int pr,int f){
  V[id][s] = f;
  for( int to : G[id] ){
    if( to == pr ) continue;
    dfs( s, to, id, f+1 );
  }
}

void dfs(int s){
  dfs( s, s, s, 0 );
}

int check(int v,int t){
  int r = A[t][0] - V[v][0];
  if( r < 1 ) return 0;
  for(int i=1;i<t;i++)
    if( r != A[t][i] - V[v][i] ) return 0;
  return r;
}

int main(){
  while( cin >> N && N ){
    init();
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++)
        cin >> A[i][j];

    G = vector<vector<int>>(N);
    V = vector<vector<int>>(N,vector<int>(N));
    
    int pt = 0;
    for(int i=0;i<A[0][1]-1;i++)
      pt = make_node( pt );    
    add_edge( pt, 1 );
    dfs( 0 );
    dfs( 1 );
    for(int i=2;i<N;i++){
      int n = G.size();
      for(int j=N;j<n;j++){
        int r;
        if( (r = check( j, i )) ){
          int pt = j;
          for(int k=0;k<r-1;k++){
            pt = make_node( pt ); 
          }
          add_edge( pt, i );
          dfs( i );
          break;
        }
      }
    }

    vector<int> res;
    for(int i=N;i<(int)G.size();i++)
      res.push_back( G[i].size() );
    sort( res.begin(), res.end() );
    for( int i=0;i<(int)res.size();i++) {
      if( i ) cout << " ";
      cout << res[i];
    }
    cout << endl;
    
  }
}

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

int main() {
    ll S, C;
    cin >> S >> C;

    ll ans = 0;
    C -= S * 2;

    if(C<0){
        C += S * 2;
        ans = C / 2;
    }
    else{
        ans = S + C / 4;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
ans = [[] for i in range(h)]
inc = True
r = 0
for i in range(n):
    while(a[i] > 0):
        if(inc):
            if(r <= h - 1):
                ans[r].append(i + 1)
                r += 1
            else:
                r = h - 1
                ans[r].append(i + 1)
                r -= 1
                inc = False
        else:
            if(r >= 0):
                ans[r].append(i + 1)
                r -= 1
            else:
                r = 0
                ans[r].append(i + 1)
                r += 1
                inc = True
        a[i] -= 1
for x in ans:
    for i in x:
        print(i, end = " ")
    print()

Measured memory_bytes: 3828
label = input().split()
rot = input()
 
dice = {
        "top":1,
        "front":2,
        "right":3,
        "left":4,
        "back":5,
        "bottom":6
        }
 
for r in rot:
    if r == 'E':
        dice["top"], dice["left"], dice["bottom"], dice["right"] = \
        dice["left"], dice["bottom"], dice["right"], dice["top"]
    elif r == 'N':
        dice["top"], dice["front"], dice["bottom"], dice["back"] = \
        dice["front"], dice["bottom"], dice["back"], dice["top"]
    elif r == 'S':
        dice["top"], dice["back"], dice["bottom"], dice["front"] = \
        dice["back"], dice["bottom"], dice["front"], dice["top"]
    elif r == 'W':
        dice["top"], dice["right"], dice["bottom"], dice["left"] = \
        dice["right"], dice["bottom"], dice["left"], dice["top"]
print(label[dice["top"]-1])

Measured memory_bytes: 7492
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)


N,M = map(int,input().split())
P = [0]+list(map(int,input().split()))

uf = UnionFind(N+1)
for _ in range(M):
  x,y = map(int,input().split())
  uf.union(x,y)

ans = 0

for i in range(1,N+1):
  if uf.same(i,P[i]):
    ans += 1

print(ans)

Measured memory_bytes: 20388
let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  for i = 1 to n-1 do a.(i) <- a.(i) + a.(i-1) done;

  let psum l r =
    if l >= r then 0
    else if l = 0 then a.(r-1) else a.(r-1) - a.(l-1)
  in
  let adj l r m =
    if psum l m - psum m r <= psum (m-1) r - psum l (m-1) then m else m-1
  in
  let rec upd l r m =
    if r <= m then adj l r m
    else
      if psum l m >= psum m r then adj l r m
      else upd l r (m+1)
  in

  let rec loop i v m1 m2 =
    if i > n-2 then v
    else
      let m1' = upd 0 i m1 in
      let m2' = upd i n m2 in

      let p, q, r, s = psum 0 m1', psum m1' i, psum i m2', psum m2' n in
      let v' = List.(fold_left max p [p;q;r;s] - fold_left min p [p;q;r;s]) in

      loop (i+1) (min v v') m1' m2'
  in
  loop 2 a.(n-1) 1 3 |> Printf.printf "%d\n"


Measured memory_bytes: 6528
# encoding: utf-8
N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]

ans = None
for cx in range(101):
    for cy in range(101):
        H_tmp = -1
        # print("#", cx, cy)
        for xi, yi, hi in sorted(xyh, key=lambda x: -x[2]):
            # print("##", (xi, yi, hi), H_tmp)
            dx = (xi - cx) if xi >= cx else (cx - xi)
            dy = (yi - cy) if yi >= cy else (cy - yi)
            if H_tmp == -1: H_tmp = hi + dx + dy
            elif hi == 0:
                if dx + dy < H_tmp: break
                else: continue
            elif H_tmp == hi + dx + dy: H_tmp = hi + dx + dy
            else: break
        else:
            ans = (cx, cy, H_tmp)
        if ans != None: break
    if ans != None: break

print(ans[0], ans[1], ans[2])

Measured memory_bytes: 3064
//package  com.company;

import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
       int tc=sc.nextInt();
       int ac=0,wa=0,tle=0,re=0;
       sc.nextLine();
       while(tc>0){
           String s=sc.nextLine();
           if(s.equals("AC"))ac+=1;
           else if(s.equals("WA"))wa+=1;
           else if (s.equals("TLE"))tle+=1;
           else re+=1;
           tc--;
       }
        System.out.println("AC x "+ac);
        System.out.println("WA x "+wa);
        System.out.println("TLE x "+tle);
        System.out.println("RE x "+re);
    }
}

Measured memory_bytes: 51112
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)){
			while(scanner.hasNext()){
				int result = digitNumber(scanner.nextInt(), scanner.nextInt());
				System.out.println(result);
			}
		}
	}
	
	public static int digitNumber(int a, int b){
		return (""+(a+b)).length();
	}
}

Measured memory_bytes: 26144
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,maxs,mins;
  cin >> N;
  vector<int> X(N);
  for(int i=0;i<N;i++){
    cin >> X.at(i);
  }
  sort(X.begin(),X.end());
  mins=X.at(0);
  maxs=X.at(N-1);
  int A,B;
  for(int i=mins;i<=maxs;i++){
    B=0;
    for(int j=0;j<N;j++){
      B+=pow(X.at(j)-i,2);
    }
    if(i==mins)A=B;
    else{
      A=min(A,B);
    }
  }
  cout << A << endl;
      
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % 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(){
    cin.tie(0);
   	ios::sync_with_stdio(false);

    int N;
    cin >> N;
    cout << N /3 << endl;

    
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
    int A,B,K,tmp;
    scanf("%d%d%d",&A,&B,&K);
    for(int i=A;i<=A+K-1;i++)
        if(i>=A&&i<=B)
            printf("%d\n",tmp=i);
    for(int i=max(tmp+1,B-K+1);i<=B;i++)
        printf("%d\n",i);
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

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

  string num;
  int sum_val;
  int count = 0;
  for(int i = 1; i <= N; ++i){
    num = to_string(i);
    sum_val = 0;
    for(int j = 0; j < num.length(); ++j){
      sum_val += ctoi(num[j]);
    }
    if((sum_val >= A) && (sum_val <= B)){
      count += i;
    }

  }
  cout << count << endl;
  return 0;
}


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

using namespace std;

const int INF = 1e9;

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

	int N;
	cin >> N;
	string S;
	cin >> S;
	vector<int>vW(N + 1, 0), vE(N + 1, 0);
	for (int i = 0; i < N; i++)
	{
		vW[i + 1] += vW[i];
		if (S[i] == 'W') {
			vW[i + 1]++;
		}
		vE[i + 1] += vE[i];
		if (S[i] == 'E') {
			vE[i + 1]++;
		}
	}
		int ans = INF;
		for (int i = 0; i < N; i++)
		{
			int now = vW[i] + (vE[N] - vE[i + 1]);
			if (ans > now) {
				ans = now;
			}
		}
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2964
import static java.lang.Math.atan2;
import static java.lang.Math.sqrt;
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}
	
	Scanner sc = new Scanner(System.in);
	void run() {
	
		P[] ps = new P[1024];
		ps[0] = new P(1, 0);
		
		P rot = new P(0, -1);
		for (int i = 1; i < ps.length; i++) {
			P p = ps[i-1];
			P v = p.normal().mul(-1).mul(rot);
			ps[i] = p.add(v);
		}
		for (;;) {
			int n = sc.nextInt();
			if (n == -1) break;
			System.out.printf("%.2f\n%.2f\n", ps[n-1].x, ps[n-1].y);
		}
	}
	
	static class P implements Comparable<P> {
		double x, y;
		public P(double x, double y) {
			this.x = x;
			this.y = y;
		}
		public int compareTo(P o) {
			return x != o.x ? Double.compare(x, o.x) : Double.compare(y, o.y);
		}
		public String toString() {
			return "(" + x + "," + y + ")";
		}
		public double abs() {return sqrt(x * x + y * y); }
		public double abs2() {return (x * x + y * y); }
		public double arg() { return atan2(y, x); } // (-pi 〜 pi)
		public double dist(P o) {return this.sub(o).abs(); }
		public P mul(double k) {return new P(x * k, y * k);}
		public P div(double k) {return new P(x / k, y / k);}
		public P add(P o) {return new P(x + o.x, y + o.y);}
		public P sub(P o) {return new P(x - o.x, y - o.y);}
		public P mul(P o) {return new P(x * o.x - y * o.y,  x * o.y + y * o.x); }
		public P div(P o) {return new P(x * o.x + y * o.y, -x * o.y + y * o.x).div(o.abs2()); }
		public double dot(P o) {return x * o.x + y * o.y;} // a b sin(t)
		public double det(P o) {return x * o.y - y * o.x;} // a b cos(t)
		public P normal() { return this.div(this.abs()); }
		public P rot90() { return new P(-y, x); }
		public static P polar(double d, double rad) {return new P(d * Math.cos(rad), d * Math.sin(rad));}
	}

}

Measured memory_bytes: 17504
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
//#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  fio();
  int n, m;
  cin >> n >> m;
  vector<bool> solve(n, false);
  vi pena(n);
  rep (i, m) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (solve[p]) continue;
    if (s == "AC") {
      solve[p] = true;
    }
    else {
      pena[p]++;
    }
  }

  int ac = 0, pn = 0;
  rep (i, n) {
    if (solve[i]) {
      ac++;
      pn += pena[i];
    }
  }
  cout << ac << " " << pn << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[200000];
signed main(){
	int n, l, ans = 0, p;
	scanf("%lld%lld", &n, &l);
	rrep(i,n)scanf("%lld", &a[i]);
	rrep(i,n-1){
		if(a[i]+a[i+1] >= l){ans = 1;p = i;}
	}
	if(ans == 0){printf("Impossible\n");return 0;}
	printf("Possible\n");
	rrep(i,n-1){
		if(i == p)break;
		printf("%lld\n", i);
	}
	drep(i,n-1,1){
		if(i == p)break;
		printf("%lld\n", i);
	}
	printf("%lld\n", p);
	return 0;
}







Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <string>
#include <cstdlib> 
using namespace std;
int a[100010], b[100010];
int main() {
	int top = 0;
	char ch = getchar();
	while (!isalpha(ch)) ch = getchar();
	while (isalpha(ch)) {
		if (ch == 'b') a[++top] = 0;
		if (ch == 'd') a[++top] = 1;
		if (ch == 'p') a[++top] = 2;
		if (ch == 'q') a[++top] = 3;
		ch = getchar();
	}
	for (int i = 1; i <= top; ++i)
		b[i] = a[top - i + 1] ^ 1;
	for (int i = 1; i <= top; ++i)
		if (a[i] != b[i]) 
			puts("No"), exit(0);
	puts("Yes");
	return 0;
}


Measured memory_bytes: 1024
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
num=[0]*(3*n)
num[1]=a[0]
for i in range(1,n):
    num[2*i],num[2*i+1]=a[i],a[i]
ans=0
for i in range(n):
    ans+=num[i]
print(ans)


Measured memory_bytes: 31668
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n,W;
    cin >> n >> W;

    vector<vector<ll>> dp(n+1,vector<ll>(W+1,0));
    rep(i,n){
        int w, v;
        cin >> w >> v;
        rep(j,W+1){
            if ( w <= j ) {
                dp[i+1][j] = max( dp[i][j], dp[i][j-w] + v );
            }
            else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    
    cout << dp[n][W] << endl;
}


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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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 string YES = "Yes";
const string NO = "No";

void solve(long long N, std::string s) {
  if( count(s.begin(), s.end(), 'R') > count(s.begin(), s.end(), 'B')){
    cout << YES << endl;
  }else{
    cout << NO << endl;
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::string s;
  std::cin >> s;
  solve(N, s);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  long a[n];
  long b[n];
  int i;
  vector<pair<int,int>> p(n);
  for(i=0;i<n;i++){
    cin >> a[i] >> b[i];
    p[i] = make_pair(b[i],a[i]);
  }
  sort(p.begin(),p.end());
  long curTime = 0;
  int chk = 1;
  for(i=0;i<n;i++){
    if(chk == 0)break;
    curTime += p[i].second;
    if(curTime > p[i].first) chk = 0;
  }

  if(chk == 0)cout << "No";
  else cout << "Yes";
}


Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int x, y;
int x2, y2;
int x3, y3;

string s;

int main()
{
	cin >> x >> y;
	cin >> x2 >> y2;
	
	x3 = x, y3 = y;
	
	while(x != x2) {
		if(x > x2)
			cout << "L", x--, s += 'R';
		else if(x < x2)
			cout << "R", x++, s += 'L';
	}
	while(y != y2) {
		if(y > y2)
			cout << "D", y--, s += 'U';
		else if(y < y2)
			cout << "U", y++, s += 'D';
	}
	cout << s, x = x3, y = y3, s.clear();
	if(x <= x2)
		cout << "L", s += 'R';
	else
		cout << "R", s += 'L';
	while(y != y2+1) {
		if(y > y2+1)
			cout << "D", y--, s += 'U';
		else if(y < y2+1)
			cout << "U", y++, s += 'D';
	}
	while(x != x2+1) {
		if(x > x2+1)
			cout << "L", x--, s += 'R';
		else if(x < x2+1)
			cout << "R", x++, s += 'L';
	}
	cout << "D" << s << "U";
}

Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
a=(10-(A%10))%10
b=(10-(B%10))%10
c=(10-(C%10))%10
d=(10-(D%10))%10
e=(10-(E%10))%10
M=max(a,b,c,d,e)
print(A+a+B+b+C+c+D+d+E+e-M)


Measured memory_bytes: 9156
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    float a, b, c;
    cin >> a >> b >> c;

    float s = (a + b + c) / 2;
    cout << sqrt(s*(s-a)*(s-b)*(s-c)) << endl;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> A >> B >> C >> D;
    int cnt = 0;
    while (A > 0 && C > 0) {
        if (cnt % 2 == 0) {
            C -= B;
        } else {
            A -= D;
        }
        cnt++;
    }
    if (A > 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
n = int(input())
table = "MARCH"
arr = [0] * len(table)

for i in range(n):
    A = input()
    for j in range(len(table)):
        if A[0] == table[j]:
            arr[j]+=1

res = 0
for i in range(len(table)):
    for j in range(i+1,len(table)):
        for k in range(j+1,len(table)):
            res+=arr[i]*arr[j]*arr[k]

print(res)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void)
{
	int n;
	int min,max;
	int check;

	int i;

	while(1){
		cin >> n;
		if (n==0) break;

		min=n;
		
		while(1){

			check=0;
			for(i=2;i*i<=min;i++){
				if(min%i==0){
					check=1;
					break;
				}
			}
			if(check==0) break;
			else min--;

		}
		max=n;
		while(1){

			check=0;
			for(i=2;i*i<=max;i++){
				if(max%i==0){
					check=1;
					break;
				}
			}
			if(check==0) break;
			else max++;
		}

		cout << max-min << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
'use strict'

function Main(input) {
    let s = '';
    for (let i = 1; i <= input.length; i++) {
        if (i % 2 === 1) {
            s += input[i - 1];
        }
    }
    console.log(s);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
    int n;
    cin >> n;

    int candy[2][n];
    cin >> candy[0][0];
    for(int i = 1; i < n; i++){
        cin >> candy[0][i];
        candy[0][i] += candy[0][i-1];
    }

    cin >> candy[1][0];
    candy[1][0] += candy[0][0];
    for(int i = 1; i < n; i++){
        cin >> candy[1][i];
        candy[1][i] += max(candy[1][i-1], candy[0][i]);
    }

    cout << candy[1][n-1] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <typeinfo>
#include <list>
#include <queue>
#include <stack>
#include <limits.h>
#include <set>
#include <map>
#include <cstring>

using namespace std;




long long Solve(vector<long long> Capacity, long long N) {
    long long res = N / Capacity[0] + (N % Capacity[0] ? 1 : 0), min_num = Capacity[0];
    for (int i = 1; i < 5; i++) {
        if (Capacity[i] >= min_num) {
            res++;
        }
        else {
            res = i + N / Capacity[i] + (N % Capacity[i] ? 1 : 0);
            min_num = Capacity[i];
        }
    }
    return res;
}


int main() {
    ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    vector<long long> Capacity(5);
    for (int i = 0; i < 5; i++) {
        cin >> Capacity[i];
    }
    cout << Solve(Capacity, N);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
      
        if(A == B){
          System.out.println("Draw");
        }else if((A == 1 || A > B) && B != 1){
          System.out.println("Alice");
        }else{
          System.out.println("Bob");
        }
	}

}



Measured memory_bytes: 35788
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var Si = Sarray();
            var Ti = Sarray();
            var dp = new long[N + 1, M + 1];
            for (var i = 0; i <= N; ++i)
                dp[i,0] = 1;
            for (var i = 0; i <= M; ++i)
                dp[0, i] = 1;
            for (var i = 1; i <= N; ++i)
                for (var j = 1; j <= M; ++j)
                {
                    dp[i, j] = (dp[i - 1, j] + dp[i, j - 1] - dp[i - 1, j - 1] + Mod) % Mod;
                    if (Si[i - 1] == Ti[j - 1])
                        dp[i, j] = (dp[i, j] + dp[i - 1, j - 1]) % Mod;
                }
            WriteLine(dp[N, M]);
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int mod = 1e9+7;

int main()
{
    int64_t a;
    string b;

    cin >> a >> b;
    a = a * ((b[0]-'0') * 100 + (b[2]-'0') * 10 + (b[3]-'0'));
    a /= 100; 
    cout << a << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
typedef long long ll;
using namespace std;

int n;
double x[8],y[8];
double sum;

void calc(int depth,bool b[8],double len,int prev){
  if(depth==n){
    sum+=len;
    return;
  }
  else{
    for(int i=0;i<n;i++){
      if(b[i]){
        continue;
      }
      else{
        b[i]=1;
        double d=sqrt((x[prev]-x[i])*(x[prev]-x[i])+(y[prev]-y[i])*(y[prev]-y[i]));
        calc(depth+1,b,len+d,i);
        b[i]=0;
      }
    }
    return;
  }
}

int main(void){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
  }

  bool s[8]={};
  for(int i=0;i<n;i++){
    s[i]=1;
    calc(1,s,0,i);
    s[i]=0;
  }

  double m=1;
  for(int i=1;i<=n;i++){
    m*=i;
  }
  //cout<<sum/m<<endl;
  printf("%.10f\n",sum/m);

  return 0;
}


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

typedef struct {
  char name[10];
  int  time;
}task;

int main(void){

    int n,q;
    int time=0,k=0,end;
    scanf("%d %d",&n,&q);
    task a[1000000];

    for(int i=0;i<n;i++){
      scanf("%s %d",&a[i].name,&a[i].time);
    }
    end=n-1;

    for(int i=0;k<n;i++){
      if(a[i].time>q){
        a[i].time-=q;
        time+=q;
        a[++end]=a[i];
      }
      else{
        time+=a[i].time;
        printf("%s %d\n",a[i].name,time);
        k++;
      }

    }



    return 0;




}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second


int n, m, s, mod = 100000;

int main() {
	while (true) {
		cin >> n >> m >> s;
		if (n==0 && m==0 && s==0)break;
		vector<vector<int>>dp(n*n + 1, vector<int>(s+1));
		dp[0][0] = 1;
		for (int i = 1;i <= m;i++) {
			for (int j = n * n - 1;j >= 0;j--) {
				for (int k = 0;k <= s - i;k++) {
					dp[j + 1][k + i] += dp[j][k];
					dp[j + 1][k + i] %= mod;
				}
			}
		}
		cout << dp[n*n][s] << endl;
	}
	return 0;
}


Measured memory_bytes: 3320
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;
const int N=1e5+5;
int dp[N];

int32_t main(){
    IOS;
    int n,k;
    cin>>n>>k;
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        int pre[k+1]={0};
        for(int i=0;i<=k;i++){
            pre[i]=(pre[i]+dp[i])%M;
            if(i+x+1<=k){
                pre[i+x+1]=(pre[i+x+1]-dp[i]+M)%M;
            }
        }
        for(int i=0;i<=k;i++){
            dp[i]=(pre[i])%M;
            if(i+1<=k) pre[i+1]=(pre[i]+pre[i+1])%M;
        }
        //for(int i=0;i<=k;i++){cout<<dp[i]<<" ";}
        //cout<<endl;
    }
    cout<<dp[k];
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[200010];
ll dd[200010];

int main() {
	ll n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	s += "X";
	ll index = 0;
	ll c = 1;
	rep(i,0,s.sz-1){
		if(s[i]!=s[i+1]){
			d[index+1] = s[i]-'0';
			dd[index+1] = c;
			c = 1;
			index++;
		}
		else{
			c++;
		}
	}
	rep(i,1,200010){
		dd[i] += dd[i-1];
	}
	ll mx = 0;
	rep(i,1,index+1){
		if(d[i]==0){
			ll k1 = 2*k;
			mx = max(mx,dd[i+k1-1]-dd[i-1]);	
		}
		else{
			ll k1 = 2*k+1;
			mx = max(mx,dd[i+k1-1]-dd[i-1]);
		}
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n;
    cin >> n;
    vector<vector<int>> dp(3, vector<int>(n+1, 0));
    for(int i = 1; i <= 2; i++) {
        for(int j = 1; j <= n; j++) {
            cin >> dp[i][j];
            dp[i][j] += max(dp[i-1][j], dp[i][j-1]);
        }
    }
    cout << dp[2][n] << endl;
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define abs(x) ((x>0)? (x) : (-(x)))
int main()
{
	int n,w,i,j,sum=0;
	int sum1,sum2,ans=1000000;
	int wlst[110];
	int wsumlst[110]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&w);
		sum+=w;
		wlst[i]=w;
		if(i==0)wsumlst[i]=wlst[i];
		else wsumlst[i]=wsumlst[i-1]+wlst[i];
	}
	for(j=0;j<n;j++)
	{
		sum1=wsumlst[j];
		sum2=sum-sum1;
		if((abs(sum1-sum2))<ans)ans=(abs(sum1-sum2));
		//printf("%d %d %d\n",sum1,sum2,(abs(sum1-sum2)));
	}
	printf("%d",ans);
}


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

typedef long long int ll;

// 桁数を返します
int len(ll n) { return log10(n) + 1; }

// ====================================================================

int main() {
  ll n, ans;
  cin >> n;
  for (int i = 1; i <= sqrt(n); i++)
    if (n % i == 0) ans = n / i;
  cout << len(ans) << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstdlib>

bool compare(int* a, int* b, int length){
  for(int i = 0; i < length; i++){
    if(a[i] != b[i])
      return false;
  }
  return true;
}

int main() {
  // int myints[] = {1,2,3};

  int n;
  std::cin >> n;

  int a[n];
  int per[n];
  int b[n];
  int rank1 = 0;
  int rank2 = 0;
  int rankCounter = 1;


  for(int i = 0; i < n; i++){
    int x;
    std::cin >> x;
    a[i] = x;
    per[i] = x;
  }

  for(int i = 0; i < n; i++){
    std::cin >> b[i];
  }



  std::sort (per,per+n);
  do {
    rankCounter++;
    if(compare(per, a, n)){
      rank1 = rankCounter;
    }
    if(compare(per, b, n)){
      rank2 = rankCounter;
    }
    if(rank1 != 0 && rank2 != 0){
      break;
    }
  } while(std::next_permutation(per, per+n));

  // std::cout << "The 3! possible permutations with 3 elements:\n";
  // do {
  //   std::cout << myints[0] << ' ' << myints[1] << ' ' << myints[2] << '\n';
  // } while ( std::next_permutation(myints,myints+3) );

  // std::cout << "After loop: " << myints[0] << ' ' << myints[1] << ' ' << myints[2] << '\n';
  std::cout << abs(rank1-rank2) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    cout << (a+b+c > 21?"bust":"win") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

// 最小全域木（kruskal）
template< typename T >
struct edge {
  int from, to;
  T cost;

  edge(int to, T cost) : from(-1), to(to), cost(cost) {}

  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};


template< typename T >
struct MinimumSpanningTree {
  T cost;
  Edges< T > edges;
};

template< typename T >
MinimumSpanningTree< T > kruskal(Edges< T > &edges, int V) {
  sort(begin(edges), end(edges), [](const edge< T > &a, const edge< T > &b) {
    return a.cost < b.cost;
  });
  UnionFind tree(V);
  T total = T();
  Edges< T > es;
  for(auto &e : edges) {
    if(tree.unite(e.from, e.to)) {
      es.emplace_back(e);
      total += e.cost;
    }
  }
  return {total, es};
}

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

    ll n;
    while(cin >> n) {
        if(n == 0) return 0;

        Edges<double> es;
        vector<double> x(n), y(n), z(n), r(n);
        rep(i, n) cin >> x[i] >> y[i] >> z[i] >> r[i];

        vector<vector<double>> dist(n, vector<double>(n));
        rep(i, n) rep(j, n) {
            if(i == j) dist[i][j] = 0.0;
            double d = sqrt(pow(x[i]-x[j], 2) + pow(y[i]-y[j], 2) + pow(z[i]-z[j], 2));
            dist[i][j] = max(0.0, d - r[i] - r[j]);
            es.emplace_back(i, j, dist[i][j]);
        }
        double ans = kruskal(es, n).cost;
        cout << fixed;
        cout << setprecision(3) << ans << endl;
    }
}



Measured memory_bytes: 3520
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		int[] b = new int[3];
		int[] count = new int[4];

		for(int i=0; i<3; i++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			count[a[i]-1]++;
			count[b[i]-1]++;
		}
		for(int i=0; i<4; i++){
			if(count[i]>2){
				System.out.println("NO");
				return;
			}
		}

		System.out.println("YES");
    }
}


Measured memory_bytes: 35824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7, N = 1e5+5;
vector<int> adj[N];
int color[N];
bool dfs(int u, int c){
    color[u] = c;
    bool ans = false;
    for(int v : adj[u]){
        if(color[v] == c)
            return true;
        if(color[v] == 0)
            ans |= dfs(v,c^3);
    }
    return ans;
}
int main(){
    ll n,m;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int a,b;
        scanf("%d %d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    if(dfs(1,1)){
        cout << n*(n-1)/2 - m << '\n';
        return 0;
    }
    else{
        ll cnt[3] = {};
        for(int c : color)
            cnt[c]++;
        cout << cnt[1]*cnt[2]-m << '\n';
    }
}


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

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i=0; i<n; i++){
        cin >> d.at(i);
    }
    sort(d.begin(),d.end());
    if(d.at((n/2)-1) != d.at((n/2))){
        cout << d.at((n/2)) - d.at((n/2)-1) << endl;
    }
    else{
        cout << 0 <<  endl;
    }
}




Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,e) for(int (i)=s;(i)<(e);++i)
#define mrep(i,s,e) for(int (i)=s;(i)>(e);--i)
typedef long long ll;
const ll INF=1e18,MOD=1e9+7;
const int iINF=1e9;
int main(){
    int n;
    cin>>n;
    vector<int>p(n);
    for(int i=0;i<n;i++)cin>>p[i];
    int ans=0;
    for(int i=0;i<n-2;i++){
        if(max(p[i],max(p[i+2],p[i+1]))!=p[i+1]&&min(p[i],min(p[i+1],p[i+2]))!=p[i+1])ans++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#ifndef CLASS_MODINT
#define CLASS_MODINT

#include <cstdint>

template <std::uint32_t mod>
class modint {
private:
	std::uint32_t n;
public:
	modint() : n(0) {};
	modint(std::int64_t n_) : n((n_ >= 0 ? n_ : mod - (-n_) % mod) % mod) {};
	static constexpr std::uint32_t get_mod() { return mod; }
	std::uint32_t get() const { return n; }
	bool operator==(const modint& m) const { return n == m.n; }
	bool operator!=(const modint& m) const { return n != m.n; }
	modint& operator+=(const modint& m) { n += m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator-=(const modint& m) { n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator*=(const modint& m) { n = std::uint64_t(n) * m.n % mod; return *this; }
	modint operator+(const modint& m) const { return modint(*this) += m; }
	modint operator-(const modint& m) const { return modint(*this) -= m; }
	modint operator*(const modint& m) const { return modint(*this) *= m; }
	modint inv() const { return (*this).pow(mod - 2); }
	modint pow(std::uint64_t b) const {
		modint ans = 1, m = modint(*this);
		while (b) {
			if (b & 1) ans *= m;
			m *= m;
			b >>= 1;
		}
		return ans;
	}
};

#endif // CLASS_MODINT

#include <vector>
#include <iostream>
using namespace std;
using mint = modint<1000000007>;
int main() {
	long long N; int K;
	cin >> N >> K;
	vector<long long> vp = { 0 }, vq;
	for (int i = 1; 1LL * i * i <= N; ++i) {
		vp.push_back(i);
		vq.push_back(N / i);
	}
	if (vp.back() == vq.back()) vq.pop_back();
	while (!vq.empty()) vp.push_back(vq.back()), vq.pop_back();
	int S = vp.size() - 1;
	vector<mint> dp(S);
	for (int i = 0; i < S; ++i) {
		dp[i] = vp[i + 1] - vp[i];
	}
	for (int i = 1; i < K; ++i) {
		vector<mint> ndp(S);
		int ptr = 0;
		mint sum = 0;
		for (int j = S - 1; j >= 0; --j) {
			while (ptr != S && vp[ptr + 1] * vp[j + 1] <= N) {
				sum += dp[ptr++];
			}
			ndp[j] = sum * (vp[j + 1] - vp[j]);
		}
		dp = ndp;
	}
	mint ans = 0;
	for (int i = 0; i < S; ++i) ans += dp[i];
	cout << ans.get() << endl;
	return 0;
}

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

using namespace std;

int main(){
    const double PI = 3.14159265359;
    double r;
    cin >> r;
    cout << fixed;
    cout << setprecision(6) << PI * r * r << " " << 2 * PI * r << endl;
    return 0;
}


Measured memory_bytes: 3276
/** Which of the favors of your Lord will you deny ? **/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class TIn>using indexed_set = tree<TIn, null_type, less<TIn>,rb_tree_tag, tree_order_statistics_node_update>;

/**

PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 2e5+7;
const LL LINF = 1e17;

template <class T>
string to_str(T x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}

int main()
{
    optimizeIO();

    string s,t;

    cin>>s>>t;

    int ans = 0;

    for(int i=0;i<s.size();i++)
        if(s[i]!=t[i]) ans++;

    cout<<ans<<endl;

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




Measured memory_bytes: 3796