akhauriyash/Code-Regression huggingface dataset:
// to Utils -> L46
// to Rlyeh -> L77
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <map>
#include <numeric>
using namespace std;
#define class struct
#define bogo_sort sort
#define bozo_sort stable_sort
#define elif else if
#define echo cout <<
#define read cin >>
#define fin << '\n'
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define alles(obj) obj.begin(), obj.end()
#define bash push_back
#define makePair make_pair
// type-define
#define String string
#define Stack stack
#define Queue queue
#define pQueue priority_queue
#define Vector vector
#define Pair pair
#define Map map
typedef long long llong;
typedef bool boolean;
typedef Pair<int,int> Pii;
typedef Vector<int> Vi;
// utils
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int INF = 1 << 29;

class Utils {

    static llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) {
                ans = ( ans * x ) % mod;
            }
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }

    static llong power ( llong x, llong n ) {
        return power( x, n, 1000000007 );
    }

    static llong gcd ( llong x, llong y ) {
        return x % y ? gcd( y, x % y ) : y;
    }

    static llong lcm ( llong x, llong y ) {
        return ( x / gcd(x, y) * y );
    }

    static boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
};

namespace Rlyeh {

    String fun ( int n ) {

        String str = to_string(n);
        while ( str.length() != 6 ) {
            str = "0" + str;
        }

        return str;
    }

    int n, m;
    Vector< Pair < Pii, int > > vec;
    Vector< Pair < int, String > > ans;

    signed call_of_Cthulhu( signed datum ) {

        read n >> m;

        for ( int i = 0; i < m; i++ ) {
            int p, w;
            read p >> w;
            vec.bash( makePair ( makePair ( p, w ), i ) );
        }

        sort( alles ( vec ) );

        int prev = -1;
        int cou = 1;

        for ( int i = 0; i < m; i++ ) {
            int p = vec[i].first.first;
            if ( prev != p ) {
                prev = p;
                cou = 1;
            }
            ans.bash ( makePair ( vec[i].second, fun ( p ) + fun ( cou++ ) ) );
        }

        sort ( alles ( ans ) );
        for ( int i = 0; i < m; i++ ) {
            echo ans[i].second fin;
        }

        return 0;
    }
}

signed main(){cin.tie(0); ios::sync_with_stdio(false); Rlyeh::call_of_Cthulhu(114514); return 0;}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> V(N);
  vector<int> C(N);
  int ad = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> V.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> C.at(i);
  }
  for (int i = 0; i < N; i++) {
    if (V.at(i) > C.at(i))
      ad += V.at(i) - C.at(i);
  }
    
  cout << ad << endl;
}

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

int main(){
  int a,b,k,m,l;
  cin >> a >> b >> k;
  m = min(a,b);
  for(int i=0;i < k;m--){
    if(a%m==0 && b%m==0){
      i++;
      l=m;
    }
  }
  cout << l << endl;
}

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

using namespace std;

typedef long long ll;

int main() {
	ll M;
	ll s = 0;
	ll s2 = 0;
	cin >> M;
	for (int i = 0; i < M; i++) {
		ll d, c;
		cin >> d >> c;
		s += d * c;
		s2 += c;
	}
	cout << (s - 1) / 9 + s2 - 1 << endl;
	return 0;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = SS()

    ans = N.count('2')
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10044
nums = [0] * 51
ps = [0] * 51


def calc(l, x):
    global nums, ps

    if l == 0:
        if x == 0:
            return 0
        else:
            return 1

    if x == 1:
        return 0
    elif x <= 1 + nums[l - 1]:
        return calc(l - 1, x - 1)
    elif x == 2 + nums[l - 1]:
        return ps[l - 1] + 1
    elif x <= 2 + 2 * nums[l - 1]:
        return ps[l - 1] + 1 + calc(l - 1, x - 2 - nums[l - 1])
    else:
        return ps[l]


def main():
    global nums, ps
    nums[0] = 1
    ps[0] = 1
    for i in range(len(nums)):
        if i == 0:
            continue
        nums[i] = 2 * nums[i - 1] + 3
        ps[i] = 2 * ps[i - 1] + 1

    n, x = map(int, input().split())
    print(calc(n, x))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
// --------------
// Tejas Pandey  |
// 16 - 11 - 19  |
// ABC #145      |
// --------------

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

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

double dist(pair<int,int> p,pair<int,int> q){
	int x = p.first - q.first;
	int y = p.second - q.second;
	x = x*x;
	y = y*y;
	return sqrt(x + y);
}

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		int n;
		cin >> n;
		vector<pair<int,int>> cor(n);
		vector<int> perm(n);
		ll fac = 1;
		for(int i = 0;i < n;i++){
			cin >> cor[i].first >> cor[i].second, perm[i] = i;
			fac = (fac * (i + 1));
		}
		double sum = 0;
		do{
			for(int i = 1;i < n;i++){
				sum += dist(cor[perm[i - 1]],cor[perm[i]]);
			}
		}while(next_permutation(perm.begin(),perm.end()));
		sum /= (fac * 1.0);
		cout << fixed << setprecision(10) << sum << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

using namespace std;

const long long INF = 1LL << 60;

//各桁の和を出力
long long Sum(long long n) {
  long long m = 0;
  while (n) {
    m += n % 10;
    n /= 10;
  }
  return m;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void Comuse() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

#define comuse Comuse()
// nCk(comuseを使え)
long long combi(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// pCk(comuseを使え)
long long perm(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] % MOD) % MOD;
}

//最小公倍数(aとbの)
long long lcm(long long a, long long b) {
  long long n;
  n = a / __gcd(a, b) * b;
  return n;
}

// auto A = div(n)
vector<long long> div(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

//(aのn乗をmodで割ったあまり)
long long modpow(long long a, long long n, long long mod) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans = ans * a % mod;
    }

    a = a * a % mod;

    n >>= 1;
  }

  return ans;
}

void solve();

const int MAX_N = 131072;
// segment tree
int NN;
int seg[MAX_N * 2 - 1];
void seguse() {
  for (int i = 0; i < 2 * NN - 1; i++) {
    seg[i] = INT_MAX;
  }
}

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

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

int X;

void solve() {
  cin >> X;
  int Num = X;
  if(X == 2){
    cout << 2 <<endl;
    return;
  }
  while(true){
    for(int i = 2; i < Num; i++){
      if(Num % i == 0){
        break;
      }
      if(i + 1 == Num){
        cout << Num <<endl;
        return;
      }
    }
    Num++;
  }
}


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

typedef long long ll;
const int N = 55;

int n, m;
char c[N][N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			cin >> c[i][j];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if(c[i][j] == '#' && c[i - 1][j] != '#' && c[i + 1][j] != '#' && c[i][j - 1] != '#' && c[i][j + 1] != '#') {
				cout << "No";
				return 0;
			}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
t,x,y = N.times.map{gets.split.map(&:to_i)}.transpose
nowx = 0
nowy = 0
nowt = 0
N.times do |i|
  d = (x[i]-nowx).abs + (y[i]-nowy).abs
  nowt = t[i] - nowt
  if (nowt.odd? && d.even?) || (nowt.even? && d.odd?) || nowt < d
    puts "No"
    exit
  end
  nowx = x[i]
  nowy = y[i]
  nowt = t[i]
end
puts "Yes"


Measured memory_bytes: 23296
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0) break;

			String[] op = new String[n];
			String[] from = new String[n];
			String[] to = new String[n];

			for(int i=0;i<n;i++){
				op[i] = sc.next();
				from[i] = sc.next().replaceAll("\\?",".");
				to[i] = sc.next().replaceAll("\\?",".");
			}

			ArrayList<String> fromList = new ArrayList<String>();
			ArrayList<String> toList = new ArrayList<String>();
			ArrayList<String> mesList = new ArrayList<String>();

			for(int i=0;i<m;i++){
				String f = sc.next();
				String t = sc.next();
				String mes = sc.next();

				for(int j=n-1;j>=0;j--){
					if(f.matches(from[j]) && t.matches(to[j])){
						if(op[j].equals("permit")){
							fromList.add(f);
							toList.add(t);
							mesList.add(mes);
						}
						break;
					}
				}
			}

			int size = fromList.size();
			System.out.println(size);
			for(int i=0;i<size;i++){
				System.out.println(fromList.get(i) + " " + toList.get(i) + " " + mesList.get(i));
			}
		}
	}
}

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

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int n,w;
  cin>>n>>w;
  int val[n],wt[n];
  for (int i = 0; i < n; ++i)
  {
  	cin>>wt[i]>>val[i];
  }

  long long int dp[n+1][w+1];

  for (int i = 0; i <= n; ++i)
  {
  	for(int j=0;j<=w;++j)
  	{
  		if(i==0 || j==0)
  			dp[i][j]=0;
  		else if(wt[i-1]<=j)
  			dp[i][j] = max(val[i-1]+dp[i-1][j-wt[i-1]], dp[i-1][j]);
  		else
  			dp[i][j] = dp[i-1][j];
  	}
  }

  cout<<dp[n][w];
  return 0;
}

Measured memory_bytes: 79104
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
//#include <algorithm>


int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    char str[100][16]={0};
    long i, j;
    for(i=0; i<n; i++) {
        scanf("%s", str[i]);
        if(i>0) {
            if (str[i-1][strlen(str[i-1])-1] != str[i][0] ) {
                printf("No\n");
                return 0;
            }
        }
        for(j=0; j<i-1; j++) {
            if ( strcmp( str[j], str[i] ) == 0 ) {
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");

    return 0;
}





Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

vector<pair<ll,ll>> v[mx];
vector<bool> used(mx,false);
vector<ll> dfs_d(mx,0);
vector<ll> l(mx),r(mx),d(mx);

void dfs(int x){
  for(auto to:v[x]){
    if(used[to.F]){ continue; }
    used[to.F] = true;
    dfs_d[to.F] = dfs_d[x] + to.S;
    dfs(to.F);
  }
}

int main(){  
  int n,m;
  cin >> n >> m;
  rep(i,m){
    cin >> l[i] >> r[i] >> d[i]; l[i]--; r[i]--;
    v[l[i]].emplace_back(pair<ll,ll>(r[i],d[i]));
    v[r[i]].emplace_back(pair<ll,ll>(l[i],-d[i]));
  }
  rep(i,n){ if(!used[i]){ used[i]=true; dfs(i); } }
  bool flag=true;
  rep(i,m){ if(d[i]!=dfs_d[r[i]]-dfs_d[l[i]]){flag=false; break;} }
  
  cout << (flag?"Yes":"No") << endl;
  return 0;
}

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

int main()
{
	int n, a[3];
	cin >> n;
	while (cin >> a[0] >> a[1] >> a[2])
	{
		sort(a, a + 3);
		if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2])
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2960
import java.util.Arrays;
import java.util.Scanner;
		public class Main{
		    static Scanner sc = new Scanner(System.in);
		    static int[] array;
		    public static void main(String[] args){
		        read();
		        solve();
		    }

		    static void read(){
		        array = new int[10];
		        for(int i = 0; i < 10; i++){
		            array[i] = sc.nextInt();
		        }
		    }

		    static void solve(){
		        Arrays.sort(array);
		        System.out.println(array[9]);
		        System.out.println(array[8]);
		        System.out.println(array[7]);
		    }

		
	    }


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	a *= 100, b *= 100;

	vb canS(f+1), canW(f+1);
	canS[0] = canW[0] = true;
	FOR(i,1,f+1) {
		if (i >= a && canW[i-a]) canW[i] = true;
		if (i >= b && canW[i-b]) canW[i] = true;
		if (i >= c && canS[i-c]) canS[i] = true;
		if (i >= d && canS[i-d]) canS[i] = true;
	}
	
	pll res = {0,1};
	FOR(s,0,f+1) if (canS[s]) FOR(w,1,f+1) if (canW[w]) {
		if (s+w > f) continue;
		if (100*s > e*w) continue;
		pll cur = {s,s+w};

		if (cur.xx * res.yy >= res.xx * cur.yy) res = cur;
	}
	cout << res.yy << " " << res.xx << endl;
}



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

if 599 >=x:
    print('8')
elif 799>=x:
    print('7')
elif 999 >=x:
    print('6')
elif 1199 >=x:
    print('5')
elif 1399 >=x:
    print('4')
elif 1599 >=x:
    print('3')
elif 1799 >=x:
    print('2')
elif 1999 >=x:
    print('1')

Measured memory_bytes: 9180
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

a, b = inintm()

for i in range(10001):
    if i*0.08//1 == a and i*0.1//1 == b:
        print(i)
        exit()

print(-1)


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

int main() {
	// your code goes here
	int w, h, x, y, r;
	cin >> w >> h>> x >> y >> r;
	string isIn;
	if(0<= x -r && w >= x +r && 0 <= y -r && h >= y +r) isIn = "Yes";
	else isIn = "No";
	
	cout << isIn << endl;
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
const double PI = acos(-1);

int main(){
  int r;
  cin >> r;
  double s = r * r * PI;
  cout << s / PI << endl;
  return 0;
} 

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

int main()
{
    int n;
    cin >> n;
    int p[100005];
    bool last = false;
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> p[i];
        if(!last && p[i] == i + 1){
            ans++;
            last = true;
            continue;
        }
        last = false;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
const int MAX_N = 600005;
bool isPrime[MAX_N];
void eratos() {
  for (int i = 0; i < MAX_N; i++) isPrime[i] = true;
  isPrime[0] = isPrime[1] = false;
  for (int i = 0; i < MAX_N; i++) {
    if (isPrime[i]) {
      for (int j = i + i; j < MAX_N; j += i) {
        isPrime[j] = false;
      }
    }
  }
}

signed main() {
  int n;
  cin >> n;
  eratos();
  int cnt = 0, idx = 0;
  while (cnt < n) {
    if (isPrime[idx] && idx % 5 == 1) {
      cout << idx << ' ';
      cnt++;
    }
    idx++;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 768
#!/usr/bin/perl

$line = 0;
while (<>) {
    chomp;
    if ($line == 0) {
        chomp;
        $n = $_;
    } else {
        @l = split /\s/, $_;
    }
    $line++;
}

$i = 0;
foreach (sort {$a <=> $b} @l) {
    if ($i % 2 == 0) {
        $total += $_;
    }
    $i++;
}

print "$total\n";


Measured memory_bytes: 512
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
     int inputA = sc.nextInt();
     int inputB = sc.nextInt();
     int delta = inputB - inputA;
     int length = 0;
     for (int i = 1; i < delta; i++) {
       length += i;
     }
     int snow = length - inputA;
     System.out.println(snow);
  }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int a, b, c;
	cin >> a >> b >> c;
	cout << a * b / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
  $a=trim(fgets(STDIN));
$b=explode(" ",$a);
$c=trim(fgets(STDIN));
$d=explode(" ",$c);
sort($d);
$total=0;
for($i=0;$i<$b[1];$i++){
  $total+=$d[$i];
}
echo $total;
?>

Measured memory_bytes: 16324
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;

class Program
{
    static Node[] Path;
    static long[,] Step;
    static long[] ans;
    static void Main(string[] args)
    {
        //入力を受け取る
        var N = long.Parse(Console.ReadLine());
        
        Path = new Node[N+1];
       // Step = new long[N+1,N+1];
        for(long i = 0; i< N ;i++){
          Path[i+1] = new Node();
        }
        
        for(long i = 1; i< N ;i++){
           var ABC = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
           var A = ABC[0];
           var B = ABC[1];
           var C = ABC[2];
           Path[A].adj.Add(B,C);
           Path[B].adj.Add(A,C);
           //Step[A,B] = C;
           //Step[B,A] = C;
        }
        
        var QK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var Q = QK[0];
        var K = QK[1];
        ans = new long[N+1];
        for(long i = 0;i <= N ;i++){
          ans[i] = -1;
        }
        //幅優先探索でKからの最短経路を求める
        WFS(K);
        //XからKとYからKのそれぞれの最短経路を足し合わせたものを答えにする
        for(long i = 0; i < Q ;i++){
          var XY = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
          var X = XY[0];
          var Y = XY[1];
          Console.WriteLine(ans[X]+ans[Y]);
        }
        
    }
    static void WFS(long num)
    {
        var queue = new MyQueue();
        queue.Enque(num);
        ans[num] = 0;
        while (!(queue.isEmpty()))
        {
            var top = queue.Deque();
                foreach(KeyValuePair<long,long> item in Path[top].adj) {
                    //探索済みか
                    if (ans[item.Key] == -1)
                    {
                        ans[item.Key] = ans[top] + item.Value;
                        queue.Enque(item.Key);
                    }
                }
        }
    }
}

class MyQueue
{
    public long[] datas = new long[100000];
    public long enpoint = -1;
    public long depoint = -1;
    public void Enque(long data)
    {
        this.enpoint++;
        datas[this.enpoint] = data;
    }
    public long Deque()
    {
        this.depoint++;
        return datas[this.depoint];
    }
 
    public bool isEmpty()
    {
        return (this.depoint == this.enpoint);
    }
}

class Node{
  public Dictionary<long,long> adj;
  public Node(){
    this.adj = new Dictionary<long,long>();
  }
}

Measured memory_bytes: 54956
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

ll dp[110][(1 << 17) + 10];

int main() {
    while (1) {
        int N;
        cin >> N;
        if (N == 0) {
            break;
        }
        ll bits[N];
        ll sati[N];
        fill(bits, bits + N, 0);
        for (int i = 0; i < N; i++) {
            int m;
            cin >> m >> sati[i];
            for (int j = 0; j < m; j++) {
                int st, ed;
                cin >> st >> ed;
                for (int k = st - 6; k < ed - 6; k++) {
                    bits[i] += (1 << k);
                }
            }
        }
        for (int i = 0; i < 110; i++) {
            fill(dp[i], dp[i] + (1 << 17) + 10, -1);
        }
        dp[0][0] = 0;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < (1 << 16); j++) {
                if (dp[i][j] != -1) {
                    dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
                    if ((j & bits[i]) == 0) {
                        dp[i + 1][j + bits[i]] = max(dp[i + 1][j + bits[i]],
                                                         dp[i][j] + sati[i]);
                    }
                }
            }
        }
        ll ans = 0;
        for (int i = 0; i < (1 << 16); i++) {
            if (dp[N][i] > ans) {
                ans = dp[N][i];
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 115740
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 10000000000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define endl '\n'

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

ll n , a[101010], dp[101010], sum[101010], x, pre, mn=-inf, t;
bool pm[101010];
char ch;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


    //cin >> t;

//while(t--){

    cin >> n >> x;
    dp[0]=x;

    n--;

    rep(i, 0, n-1){
        cin >> ch >> x;

        pm[i]=ch!='+';

        sum[i+1]=x;
        a[i]=x;

    }

    rep(i,0,n-1){
        sum[i+1]+=sum[i];
    }

    pre=-1;

    rep(i,0,n-1){

        if(pm[i] && pre!=-1){
            chmax(mn,dp[pre]-(sum[i]-sum[pre])-sum[i]);
        }
        if(!pm[i]){
            dp[i+1]=max(dp[i],mn+sum[i])+a[i];
        }
        else{
            dp[i+1]=max(dp[i]-a[i],mn+sum[i]+a[i]);
            pre=i;
        }
    }
    cout<<dp[n]<<endl;

//}


return 0;
}
///....


Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<double, llint> P;
typedef pair<llint, P> E;

struct edge{
	llint to; double cost;
	edge(llint a, double b){
		to = a, cost = b;
	}
};

int n, S, T;
double x[1005], y[1005], r[1005];
vector<edge> G[1005];
double dist[1005];

void dijkstra()
{
	for(int i = 1; i <= T; i++) dist[i] = inf;
	dist[S] = 0;
	
	priority_queue< P, vector<P>, greater<P> > Q;
	Q.push( make_pair(0, S) );
	
	int v; double d;
	while(Q.size()){
		d = Q.top().first;
		v = Q.top().second;
		Q.pop();
		if(dist[v] < d) continue;
		for(int i = 0; i < G[v].size(); i++){
			if(dist[G[v][i].to] > d + G[v][i].cost){
				dist[G[v][i].to] = d + G[v][i].cost;
				Q.push( make_pair(dist[G[v][i].to], G[v][i].to) );
			}
		}
	}
}

int main(void)
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	
	double sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	
	cin >> n;
	S = n+1, T = n+2;
	x[S] = sx, y[S] = sy, x[T] = tx, y[T] = ty;
	for(int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> r[i];
	
	for(int i = 1; i <= T; i++){
		for(int j = 1; j <= T; j++){
			if(i==j) continue;
			double d = (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]);
			d = sqrt(d);
			G[i].push_back(edge(j, max(0.0, d-(r[i]+r[j]))));
		}
	}
	dijkstra();
	
	printf("%.11f\n", dist[T]);

	return 0;
}

Measured memory_bytes: 22512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
    int n,k;
    cin>>n>>k;
    set<int> s;
    while(k--){
        int d;
        cin>>d;
        while(d--){
            int x;
            cin>>x;
            s.insert(x);
        }
    }
    cout<<n-s.size();
}


Measured memory_bytes: 3528
#include <iostream>
#include <cmath>

int main()
{
    while(1) {
        int n = 0;
        std::cin >> n;

        if (n == 0) {
            break;
        }
        int a[1000];
        double r = 0;
        double s = 0;
        double sn = 0;
        for(int i = 0; i < n; i++) {
            std::cin >> a[i];
        }

        double sum = 0;
        double ave = 0;

        for (int i = 0; i < n; i++) {
            sum += a[i];
        }

        ave = sum / n;

        for (int i = 0; i < n; i++) {
            sn += (a[i] - ave) * (a[i] - ave);
        }

        s = sn / n;
        r = sqrt(s);


        std::printf("%lf\n", r);



    }


    return 0;

}

Measured memory_bytes: 3108
a = []
for i in range(5):
  a.append(int(input()))
k = int(input())

flag = True
for i in range(5):
  if not flag:
    break
  for j in range(i+1, 5):
    if a[j] - a[i] > k:
      flag = False
      break

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


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

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

int main() {
#ifdef cute
	freopen("in", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
  cin >> n;

  vector<vector<int>> a(n);
  vector<pair<int, int>> ps;
  for(int i = 1; i < n; i++) {
    int u, v;
		cin >> u >> v;
		--u; --v;
    a[u].push_back(v);
    a[v].push_back(u);
    ps.push_back({u, v});
  }
 
  int k = 0;
  map<pair<int, int>, int> colo;
  vector<int> cs(n, 0);
 
  vector<int> used(n, 0);
  queue<int> q;

  used[0] = 1;
  q.push(0);
  while(!q.empty()) {
    int v = q.front();
		q.pop();
    if(k < a[v].size()) k = a[v].size();

    int cur=1;
    for(int u: a[v]) {
      if(used[u]) continue;
      if(cur == cs[v]) ++cur;
      cs[u] = colo[{u,v}] = colo[{v, u}] = cur++;
      used[u] = 1;
      q.push(u);
    }
  }
 
  cout << k << '\n';
  for(auto p: ps) cout << colo[p] << '\n';


#ifdef cute
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif
}

/* stuff you should look for
	* array bounds
	* special cases (n=1?), set tle
	* do sth instead of nothing and stay organized
	* check for variables with close names

g++ .cpp -o .exe -O2 -std=c++11 -D cute
*/



Measured memory_bytes: 20088
#include <bits/stdc++.h>
#define MAX 100005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);
#define fi(a,b,c) for(int i=a;i<b;i=i+c)
#define fj(a,b,c) for(int j=a;j<b;j+=c)
using namespace std;
 
ll gcd(ll n1,ll n2) {
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent) {
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
ll max(ll a,ll b,ll c) {
	return max(a,max(b,c));
}
int max(int a,int b,int c) {
	return max(a,max(b,c));
}

int main()
{
	int n, k;
	sd(n);sd(k);
	int l[k], r[k];
	fi(0,k,1){
		sd(l[i]);sd(r[i]);
		l[i]--;
		r[i]--;
	}
	ll dp[n]={0}, pre[n+1]={0};
	ll mod=998244353;
	dp[0]=1;
	pre[1]=1;
	for(int i=1;i<n;i++){
		for(int j=0;j<k;j++){
			//cout<<i<<" "<<r[j]<<" "<<l[j]<<endl;
			if(i-r[j]>0) {
				dp[i]=(dp[i]+pre[i-l[j]]-pre[i-r[j]-1]+mod)%mod;
			}else if(i-l[j]>-1){
				dp[i]=(dp[i]+pre[i-l[j]]-pre[0]+mod)%mod;
			}
		}
		//cout<<dp[i]<<endl;
		pre[i+1]=(dp[i]+pre[i])%mod;
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 6796
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
  vector<string> v;
  int count = 0, num = 0, minTime = 10;
  for(int i=0; i<5; i++){
    string tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  for(int i=0; i<5; i++){
    int len = v[i].size();
    
    if(v[i][len-1]-'0' < minTime && v[i][len-1]!='0')minTime=v[i][len-1]-'0';
    if(v[i][len-1]-'0'>0){
      v[i][len-1] = '0';
      count++;
    }
    num += atoi(v[i].c_str());
  }
  num += count * 10;
  if(minTime<10)num += minTime-10;
  cout << num << endl;
  
  return 0;
}

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

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

    bool isApproved = true;

    for (int i = 0; i < n; ++i)
    {
        int inputNum;
        cin >> inputNum;

        if (isApproved && inputNum % 2 == 0)
        {
            if (inputNum % 3 != 0 && inputNum % 5 != 0)
            {
                isApproved = false;
            }
        }
    }

    if (isApproved)
    {
        cout << "APPROVED" << endl;
    }
    else
    {
        cout << "DENIED" << endl;
    }
}

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

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int N = sc.nextInt();
		boolean[] flag = new boolean[9];
		int color = 0;
		int over3200 = 0;
		for(int i=0; i<N; i++) {
			int a = sc.nextInt();
			for(int j=1; j<=8; j++) {
				if(a < 400*j && a >= 400*(j-1) && !flag[j]) {
					color++;
					flag[j] = true;
				}
			}
			if(a >= 3200) {
				over3200++;
			}
		}
		
		if(color != 0) {
			System.out.print(color);
		} else {
			System.out.print(1);
		}
		
		System.out.print(" ");
		
		System.out.println(color+over3200);
		
	}

	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}



Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;

ll r, d, x[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> r >> d >> x[0];
    FOR(i,1,10) {
        x[i] = x[i-1] * r - d;
        cout << x[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    k = 1
    hold = 0
    for i in range(n):
        if a[i] == k:
            hold += 1
            k += 1
    if hold == 0:
        print(-1)
    else:
        print(n-hold)
resolve()

Measured memory_bytes: 77516
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	string T;
	scan(T);
	int N=T.size();
	rep(i,N){
		if(T[i]=='?') T[i]='D';
	}
	prin(T);
	return 0;
}


Measured memory_bytes: 3752
import sys
readline = sys.stdin.readline
write = sys.stdout.write

D = [
    (2, 1, 5, 0, 4, 3), # 'L'
    (1, 5, 2, 3, 0, 4), # 'U'
    (3, 1, 0, 5, 4, 2), # 'R'
    (4, 0, 2, 3, 5, 1), # 'D'
]
def rotate_dice(L, k):
    return [L[e] for e in D[k]]

dd = ((-1, 0), (0, -1), (1, 0), (0, 1))

def solve():
    D = "LBRF"

    N = int(readline())
    if N == 0:
        return False

    PS = []
    memo = [-1]*(1 << N)
    def dfs(state, us):
        res = 0
        if memo[state] != -1:
            return memo[state]
        for i in range(N):
            if state & (1 << i):
                continue
            vs = set(us)
            r = 0
            for x, y, e in PS[i]:
                k = (x, y)
                if k in vs:
                    continue
                vs.add(k)
                r += e
            res = max(res, dfs(state | (1 << i), vs) + r)
        memo[state] = res
        return res

    for i in range(N):
        x, y = map(int, readline().split()); y = -y
        l, r, f, b, d, u = map(int, readline().split())
        L = [u, f, r, l, b, d]
        s = readline().strip()
        P = [(x, y, d)]
        for e in map(D.index, s):
            dx, dy = dd[e]
            L = rotate_dice(L, e)
            x += dx; y += dy
            P.append((x, y, L[-1]))
        P.reverse()
        PS.append(P)
    write("%d\n" % dfs(0, set()))
    return True
while solve():
    ...


Measured memory_bytes: 12724
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int,int> pii;
typedef priority_queue<int,vector<int>,greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 1010;
vector<int>tree[N];
int v[N],dp[5*N],f[N],n;
void dfs(int x){
    for(auto vv:tree[x])
        dfs(vv);
    memset(dp,0x3f,sizeof(dp));
    dp[0]=0;
    for(auto vv:tree[x]){
        for(int i=v[x];i>=0;i--)
        {
            int tmp=0x3f3f3f3f;
            if(i>=v[vv])tmp=min(tmp,dp[i-v[vv]]+f[vv]);
            if(i>=f[vv])tmp=min(tmp,dp[i-f[vv]]+v[vv]);
            dp[i]=tmp;//此处不能取min，因为每一个子树都要算贡献。
        }
    }
    for(int i=v[x];i>=0;i--)f[x]=min(f[x],dp[i]);
}
int main()
{
    memset(f,0x3f, sizeof(f));
    scanf("%d",&n);
    for(int i=2;i<=n;i++){
        int x;scanf("%d",&x);
        tree[x].push_back(i);
    }
    for(int i=1;i<=n;i++){
        scanf("%d",&v[i]);
    }
    dfs(1);
    if (f[1]<0x3f3f3f3f) {
        printf("POSSIBLE\n");
    } else {
        printf("IMPOSSIBLE\n");
    }
    return 0;
}

Measured memory_bytes: 384
import math
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
	x[i], y[i] = map(int, input().split())

ans = 0
for i in range(N-1):
	for j in range(i, N):
		ans += math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)
ans /= (N/2)
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC084A
{
    class Program
    {
        static void Main(string[] args)
        {
            int M = int.Parse(Console.ReadLine());

            Console.WriteLine(24 - M + 24);

            Console.ReadKey();
        }
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<pair<int,int> > vp(N);
  for(int i=0;i<N;i++){
    int v;
    cin >> v;
    vp.at(i).first=v;
  }
  for(int i=0;i<N;i++){
    int c;
    cin >> c;
    vp.at(i).second=c;
  }
  int X=0;
  int Y=0;
  for(int i=0;i<N;i++){
    if(vp.at(i).first>vp.at(i).second){
      X+=vp.at(i).first;
      Y+=vp.at(i).second;
    }
  }
  cout << X-Y << endl;
}


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

using namespace std;

int main() {

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

int x[3] {A, B, C};

sort(x, x + 3);

if (x[0] == 5 && x[1] == 5 && x[2] == 7) {
cout << "YES" << endl;
}

else cout << "NO" << endl;

}


Measured memory_bytes: 256
#include<stdio.h>

 void kansu(int A[],int N)
{
int i;
for(i=0;i<N;i++){

if(i>0){
printf(" ");
}
printf("%d",A[i]);
}
printf("\n");
}
void insertionSort(int A[],int N)
{
int i,j,v;    
for(i= 1; i<N;i++){ 
    v = A[i];
     j = i - 1;
    while (j >= 0 && A[j] > v){
       A[j+1] = A[j];
       j--;
}
     A[j+1] = v;
kansu(A,N);

}
}
int main()
{
    int N,i,j;
    int A[100];

    scanf("%d",&N);
for(i=0;i<N;i++){
scanf("%d",&A[i]);
}

 
 
   kansu(A,N);
    insertionSort(A,N);
        return 0;
}

Measured memory_bytes: 1764
// inputに入力データ全体が入る

function Main(input) {

	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(input[0]);
	var c = parseInt(input[2]);
	if(input[1] === "+")
		console.log("%d",a+c)
	if(input[1] === "-")
		console.log("%d",a-c)
}

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

Measured memory_bytes: 11468
#include<stdio.h>
 
int main() 
{ 
    int x,y; 
    for(int i=1;i>0;i++)
    {
        scanf("%i %i",&x,&y);
        if(x==0 && y==0) 
        {
            break; 
        }
        if(x>y) 
        {
            printf("%i %i\n",y,x);
        } 
        else
        {   
            printf("%i %i\n",x,y);
        } 
    }
    return 0; 
}


Measured memory_bytes: 2040
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;
int main(void)
{
   int n;
   string s;

   cin >> n;
   cin >> s;

   int x = 0;

   int max = x;
   for (int i = 0; i < n; i++) {
       if (s[i] == 'I') {
           x++;
       }
       else {
           x--;
       }

       if (max < x) {
           max = x;
       }
   }

   cout << max << endl;

   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main()
{
	map<char, int> m;
	string s;
	cin >> s;
	rep(i,s.size()){
		m[s[i]]++;
	}
	for (auto x:m){
		if(x.second % 2 != 0){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;

  vector<pair<int, int>> p(M);
  for (int i = 0; i < M; i++) {
    int a;
    int b;
    cin >> a >> b;
    p.at(i) = make_pair(a, b);
  }

  int maxv = -1;
  int minv = 1001001;
  for (int i = 0; i < M; i++) {
    int a;
    int b;
    tie(a, b) = p.at(i);
    maxv = max(a, maxv);
    minv = min(b, minv);
  }

  cout << max(minv - maxv + 1, 0) << endl;
}


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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP				make_pair
#define X				first.first
#define Y				first.second

typedef pair<string, int> P;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

char road[200050];
int N, A, B, C, D;

signed main() {
	cin >> N >> A >> B >> C >> D;
	REPONE( i, N ) {
		cin >> road[i];
	}

	REPONE( i, N - 1 ) {
		if( A <= i && i <= C && road[i] == '#' && road[i + 1] == '#' ) {
			cout << "No" << endl;
			return 0;
		}
		if( B <= i && i <= D && road[i] == '#' && road[i + 1] == '#' ) {
			cout << "No" << endl;
			return 0;
		}
	}


	if( road[B + 1] == '#' && D < C ) {
		FOR( i, B, D ) {
			if( road[i] == '.' && road[i + 1] == '.' && road[i + 2] == '.' ) {
				cout << "Yes" << endl;
				return 0;
			}
		}
		cout << "No" << endl;
		return 0;
	}

	if( road[B - 1] == '#' && road[B + 2] == '#' && D < C ) {
		FOR( i, B + 3, D ) {
			if( road[i] == '.' && road[i + 1] == '.' && road[i + 2] == '.' ) {
				cout << "Yes" << endl;
				return 0;
			}
		}
		cout << "No" << endl;
		return 0;
	}
	

	cout << "Yes" << endl;

}

Measured memory_bytes: 384
#include<stdio.h>

int main() {
	int x, y;
	scanf("%d%d", &x, &y);
	if (y % 2 == 0 && 4 * x - y >= 0 && y - 2 * x >= 0) {
		printf("Yes");
	}
	else printf("No");

	return 0;
}

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

typedef long long ll;
const ll MOD = 1e9+7;
const int N = 2e5+5;

int n,a[N],q;
vector<int>v[N];

void dfs(int s,int p,int add){
    a[s]+=add;
    for(auto e:v[s]){
        if(e!=p){
            dfs(e,s,a[s]);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>q;
    for(int i=1;i<=n-1;i++){
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    while(q--){
        int x,y;
        cin>>x>>y;
        a[x]+=y;
    }

    dfs(1,0,0);
    for(int i=1;i<=n;i++)cout<<a[i]<<" ";
    return 0;
}


Measured memory_bytes: 23552