akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
vector<vector<int>> c(10, vector<int>(10));
#define INF 1e+9
#define MAX_V 100

struct edge {
	int to;
	int cost;
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int V;// 頂点の数
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V, INF);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;

		for (int i = 0; i < G[v].size(); ++i) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main()
{
	V=10;
	int h, w;
	cin >> h >> w;
	rep(i, 10) rep(j, 10) {
		cin >> c[i][j];
		edge e={j,c[i][j]};
		G[i].push_back(e);
	}
	vector<vector<int>> grid(h, vector<int>(w));
	vector<int> num(10);
	int cnt = 0;
	rep(i, h) rep(j, w)
	{
		cin >> grid[i][j];
		if (grid[i][j] != -1)
		{
			num[grid[i][j]]++;
			cnt++;
		}
	}
	if (num[1] ==cnt){
		cout<<0<<endl;
	}else{
		int ans=0;
		rep(i,10){
			if(num[i]>0){
				dijkstra(i);
				ans+=d[1]*num[i];
			}
		}
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;
int main()
{
	int a = 0;
	string s;
	cin >> s;
	cout << 700 + 100*count(s.cbegin(), s.cend(), 'o') << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  set<ll>se;
  for(int i=0;i<n;i++){
    ll a;cin>>a;
    se.insert(a);
  }
  if(se.size() == n)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 9600
using System;
public class Hello{
    public static void Main(){
        // Your code here!
        string[] nl = Console.ReadLine().Split(' ');
      	int n = int.Parse(nl[0]);
//      	int l = int.Parse(nl[1]);
      	string[] word = new string[n];
      	for(int i=0;i<n;i++){
          word[i] = Console.ReadLine();
        }
        Array.Sort(word);
        
        for(int i=0;i<n;i++){
          Console.Write("{0}",word[i]);
        }
      	Console.WriteLine("");
    }
}



Measured memory_bytes: 11360
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N; 
	cin >> N;
	vector<int> P(N);
	vector<int> pos(N+1);
	rep(i,N){
		cin >> P[i];
		pos[P[i]] = i;
	}
	vector<int> dp(N+1);
	rep(i,N){
		dp[P[i]] = 1;
		if(P[i] == 1)continue;
		if(i > pos[P[i]-1]){
			dp[P[i]] = dp[P[i]-1] + 1;
		}
	}
	int nax = 0;
	rep(i,N+1)nax = max(nax, dp[i]);
	cout << N - nax << endl;
}

//int main(){
//	int N; 
//	cin >> N;
//	vector<int> P(N);
//	vector<int> pos(N);
//	rep(i,N){
//		cin >> P[i];
//		--P[i];
//		pos[P[i]] = i;
//	}
//	int ans = 0;
//	int add_front = -1;
//	int add_back = N;
//	int lst = N/2-1;
//	int rst = N/2;   	if(N % 2 == 1)rst ++;
//	for( ; lst >= 0; lst --){
//		if(pos[lst] > pos[lst + 1]){
//			pos[lst] = add_front--;
//			++ans;
//		}
//	}
//	for( ; rst < N; ++rst){
//		if(pos[rst] < pos[rst - 1]){
//			pos[rst] = add_back ++;
//			++ans;
//		}
//	}
//	cout << ans << endl;
//}

//int main(){
//	int N; 
//	cin >> N;
//	vector<int> P(N);
//	rep(i,N)cin >> P[i];
//	set<int> fward, bward;
//	REP(i,N){
//		fward.insert(i);
//		bward.insert(i);
//	}
//	int f_ans = 0, b_ans = 0;
//	vector<int> fremain;
//	vector<int> bremain;
//	int min_forward = inf, max_backward = -inf;
//	//forward
//	{
//		rep(i,N){
//			auto itr = fward.begin();
//			if(*itr < P[i]){
//				min_forward = min(min_forward, P[i]);
//				++f_ans;
//			}else{
//				fremain.push_back(P[i]);
//			}
//			fward.erase(P[i]);
//		}
//		for(auto x:fremain){
//			if(x > min_forward) ++f_ans;
//		}
//	}
//	//backward
//	{
//		for(int i = N-1; i >= 0; --i){
//			auto itr = bward.rbegin();
//			if(*itr > P[i]){
//				max_backward = max(max_backward, P[i]);
//				++b_ans;
//			}else{
//				bremain.push_back(P[i]);
//			}
//			bward.erase(P[i]);
//		}
//		for(auto x:bremain){
//			if(x < max_backward) ++b_ans;
//		}
//	}
//	cout << min(f_ans, b_ans) << endl;
//	return 0;
//}


Measured memory_bytes: 5592
H,W = map(int,input().split())
a = [None]*H
for i in range(H):
    a[i] = list(map(int, input().split() ) )

ans=[]
for i in range(H):
    for j in range(W):
        
        if i==H-1 and j==W-1:
            continue
        if a[i][j]%2==1:
            if j!=W-1:
                ans.append((i,j,i,j+1))
                a[i][j+1]+=1
            else:
                ans.append((i,j,i+1,j))
                a[i+1][j]+=1
print(len(ans))
for aa in ans:
    print(*[aaa+1 for aaa in aa])

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

int main() {
  int N;
  int A;
  int B;	
  int d;
  cin >> N;	//駐車時間
  cin >> A;	//比例式
  cin >> B;	//一定金額
  d = N * A;
  if (d >= B) {
    cout << B << endl;
  }
  else {
    cout << d << endl;
  }
}
  

Measured memory_bytes: 256
n,a=map(int,input().split())
li=list(map(int,input().split()))

max_a=sum(li)

dp=[[ 0 for _ in range(n+1)]for _ in range(max_a+1)]
dp[max_a][n]=1

for j in range(n):
  for i in range(max_a+1):
    for k in range(n+1):
      if dp[i][k]>0:
        dp[i-li[j]][k-1]+=dp[i][k]
        
  
ans=0
for f in range(max_a+1):
  for g in range(n+1):
    if f==g*a:
      ans+=dp[f][g]
      
      
print(ans-1)

Measured memory_bytes: 75016
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        m: usize,
        dc: [(usize, usize); m],
    }
    let mut cnt = 0;
    let mut acc = 0;

    for &(d, c) in dc.iter() {
        cnt += c;
        acc += d * c;
    }
    cnt -= 1;
    cnt += (acc - 1) / 9;

    println!("{}", cnt);
}


Measured memory_bytes: 8444
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

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

using namespace std;
using ll = long long;

int main() {
    string S; cin >> S;

    if ((S[0] == S[1]) && (S[0] == S[2])) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
//#define int long long
#define D double
#define inf 123456789
#define mod 1000000007
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
#define rep(i, s, t) for(re int i = s; i <= t; ++ i)
#define drep(i, s, t) for(re int i = t; i >= s; -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define lb(x) (x)&(-(x))
#define ls k * 2
#define rs k * 2 + 1
#define maxn 100005
int n, m, a[maxn];
il bool cmp(int a, int b) {
	return a > b;
}
il int doit(int x, int y) {
	int ans = 0;
	while(a[x + 1] == y) ans ^= 1, ++ x;
	return ans;
}
int main() {
	//file(a);
	n = read();
	rep(i, 1, n) a[i] = read();
	sort(a + 1, a + n + 1, cmp);
	int nx = 0;
	while(1) {
		++ nx;
		if(a[nx] < nx) break;
	}
	-- nx;
	if(((a[nx] - nx) & 1) || doit(nx, nx)) printf("First");
	else printf("Second");
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

void solve() {
    int n; cin >> n;
    int a[200200];
    rep(i, n) {
        cin >> a[i];
    }
    int b[200200];
    int j = n - 1, i = 0;
    while(j >= 0) {
        b[i] = a[j];
        j -= 2; i ++;
    }
    j = n - 2; i = n - 1;
    while(j >= 0) {
        b[i] = a[j];
        j -= 2; i --;
    }
    rep(i, n) {
        cout << b[i] << " ";
    }
    cout << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 3712
N = int(input())
EPS = 1e-9
for i in range(N):
    x1,y1,x2,y2,x3,y3,x4,y4 = map(float,input().split())
    if x2 == x1 and x4 == x3:
        print('YES')
        continue
    elif x2 == x1 or x4 == x3:
        print('NO')
        continue
    f = (y2 - y1) / (x2 - x1)
    g = (y4 - y3) / (x4 - x3)
    if g - EPS <= f <= g + EPS:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 7604
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
int a[4];
int main(){
  //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<a[0]+a[1];
    
    return 0;
}


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

int main(){
  int a[3];
  for(int i = 0; i < 3; i++){
     std::cin >> a[i];
  }
  std::sort(a, a + 3);
  for(int i = 0; i < 3; i++){
    if(i != 0){
      std::cout << " ";
    }
     std::cout << a[i];
  }
  std::cout << std::endl;
}



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

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

    int tmp, tmp2, tmp3;
    tmp = N / 1.08;
    tmp2 = tmp*1.08;
    tmp3 = (tmp + 1)*1.08;
    if(tmp2 == N){
        cout << tmp << endl;
    }
    else if(tmp3 == N){
        cout << tmp+1 << endl;
    }
    else{
        cout << ":(" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 2050

int N;
int length[8],POW[8];
int table[8][1025],ans[1025];
char buf[8][SIZE];

int gcd(int x,int y){

	x = abs(x);
	y = abs(y);

	if(x < y){
		swap(x,y);
	}
	if(y == 0){
		return x;
	}else{
		return gcd(y,x%y);
	}
}

//最小公倍数
int lcm(int x,int y){

	return (x*y)/gcd(x,y);
}

int getNUM(char ch){

	if(ch >= '0' && ch <= '9'){

		return ch-'0';

	}else{

		return 10+(ch-'A');
	}
}


void func(){

	scanf("%d",&N);

	int tmp_len;
	int LCM = 1;

	for(int i = 0; i < N; i++){

		scanf("%s",buf[i]);

		if(LCM == BIG_NUM)continue;

		for(tmp_len = 0; buf[i][tmp_len] != '\0'; tmp_len++);

		int GCD = tmp_len/2;

		for(int k = 2; k < tmp_len; k += 2){

			if(buf[i][k] == '0' && buf[i][k+1] == '0')continue;

			GCD = gcd(GCD,k/2);
		}

		length[i] = (tmp_len/2)/GCD;

		int index = 0;

		for(int k = 0; k < tmp_len; k += 2*GCD){

			table[i][index++] = getNUM(buf[i][k])*POW[4]+getNUM(buf[i][k+1]);
		}

		LCM = lcm(LCM,length[i]);

		if(LCM > 1024){

			LCM = BIG_NUM;
		}
	}

	if(LCM == BIG_NUM){

		printf("Too complex.\n");
		return;
	}

	for(int i = 0; i < LCM; i++){

		ans[i] = 0;
	}

	for(int i = 0; i < N; i++){

		int span = LCM/length[i];

		for(int k = 0; k < length[i]; k++){

			ans[span*k] |= table[i][k];
		}
	}

	for(int i = 0; i < LCM; i++){

		int left = ans[i]/POW[4];

		if(left >= 10){

			printf("%c",'A'+(left-10));
		}else{

			printf("%c",'0'+left);
		}

		int right = ans[i]%POW[4];

		if(right >= 10){

			printf("%c",'A'+(right-10));
		}else{

			printf("%c",'0'+right);
		}
	}
	printf("\n");
}

int main(){

	POW[0] = 1;
	for(int i = 1; i <= 7; i++){

		POW[i] = POW[i-1]*2;
	}

	int num_set;
	scanf("%d",&num_set);

	for(int loop = 0; loop < num_set; loop++){

		func();
	}

	return 0;
}



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

int func(int n){
	if(n==1) return 1;
	return n*func(n-1);
}

double dist(P town1, P town2){
	double res = 0;
	res += (town1.first - town2.first) * (town1.first - town2.first);
	res += (town1.second - town2.second) * (town1.second - town2.second);
	return sqrt(res);
}

int main(){
	
	int n;
	cin >> n;
	vector<P> town;
	rep(i,n){
		int x,y;
		cin >> x >> y;
		town.push_back(make_pair(x,y));
	}
	
	double res = 0;
	int tmp = func(n-1);
	rep(i,n){
		for(int j = i+1; j < n; j++){
			res += dist(town[i], town[j]) * tmp * 2;
		}
	}
	
	res /= func(n);
	printf("%.10f", res);
	
	

	return 0;
}

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

syogen=[]
for i in range(N):
	a=int(input())
	temp=[list(map(int, input().split())) for _ in range(a)]
	syogen.append([a,temp])

ans=0

for h in range(2**N):
	flag=0
	cnt=0
	l=[0]*N
	for g in range(N):
		if h>>g &1:
			l[g]=1
	#print(l)
	for gg in range(N):
		if l[gg]==1:
			temp_=syogen[gg]
			#print(temp_)
			for n in range(temp_[0]):
				if l[temp_[1][n][0]-1]==temp_[1][n][1]:
					continue
				else:
					flag=1
					break
		if flag==1:
			break
		elif flag==0 and gg==N-1:
			#print(bin(h))
			ans=max(ans,sum(l))

print(ans)

Measured memory_bytes: 9176
def resolve():
	n = int(input())
	a = list(map(int, input().split()))
	ans = 0
	while True:
		again = True
		for i in range(n):
			if a[i] % 2:
				again = False
			a[i] = a[i] / 2
		if again:
			ans += 1
		else:
			break
	print(ans)
resolve()

Measured memory_bytes: 38512
// 解き直し.
// https://img.atcoder.jp/arc064/editorial.pdf
// テストケース(1_12.txt) などで, TLE版となったため, ロジック修正.
// AtCoder Beginner Contest 051 (D - Candidates of No Shortest Paths) で 実装した ダイクストラ法 を 一部流用.
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define a first
#define b second
double cost[1010][1010];          // 頂点(i, j) の 最小コスト を 保存.
double x[1010], y[1010], r[1010]; // バリア情報.
double b[1010][1010];             // バリア i, j の 中心を結ぶ辺のコスト.

struct edge {
    int u;    // 次の頂点.
    double d; // 距離.
    bool operator < (const edge &E) const { return d > E.d; }
};

vector<edge> G[1010];

// https://ja.wikipedia.org/wiki/ダイクストラ法
// グラフを最良優先探索する.
// ※dijkstraの動作確認用.
// @param s: 今回探索する頂点番号.
// @return: 特に無し.
void dijkstra(int s){
    
    // 1. 初期化.
    priority_queue<edge> pq;
    
    // 2. 始点設定.
    pq.push({s, 0.0});
    cost[s][s] = 0.0;
    
    // 3. キュー pq が 空になるまで, 探索.
    while(!pq.empty()){
        // 4. 探索を継続するために, 頂点を取得.
        int u = pq.top().u;    // 頂点番号.
        double d = pq.top().d; // コスト.
        pq.pop();
        
        // 5. より小さいコストが設定済みなら, Skip.
        if(cost[s][u] < d) continue;
        
        // 6. 各隣接する頂点について, コストを確認し, 最短コストを更新.
        rep(i, G[u].size()){
            int nu = G[u][i].u;
            double nd = d + G[u][i].d;
            // 最短コスト更新.
            if(cost[s][nu] > nd) cost[s][nu] = nd, pq.push({nu, nd});
        }
    }
}

int main(){
    
    // 1. 入力情報.
    double xs, ys, xt, yt;
    int N;
    scanf("%lf %lf %lf %lf %d", &xs, &ys, &xt, &yt, &N);
    rep(i, N) scanf("%lf %lf %lf", &x[i + 1], &y[i + 1], &r[i + 1]);
    x[0] = xs, y[0] = ys, x[N + 1] = xt, y[N + 1] = yt;
    
    // 2. 辺のコストを事前計算.
    rep(i, N + 1){
        repx(j, i + 1, N + 2){
            double w = max(0.0, hypot(x[i] - x[j], y[i] - y[j]) - (r[i] + r[j]));
            b[i][j] = w;
            b[j][i] = w;
        }
    }
    
    // 3. グラフ作成.
    // 頂点が, 0, 1, ... , N, N + 1 までの (N + 2)頂点あると見る.
    rep(i, N + 1){
        repx(j, i + 1, N + 2){
            G[i].pb({j, b[i][j]});
            G[j].pb({i, b[j][i]});
        }
    }
    
    // 4. ダイクストラ法.
    rep(i, 1010) rep(j, 1010) cost[i][j] = 202020202020202020.0;
    dijkstra(0);
    
    // 5. 出力.
    printf("%.10f\n", cost[0][N + 1]);
    return 0;
    
}

Measured memory_bytes: 39680
import Control.Applicative
import Control.Monad (forM_)

type Dice    = [(Int, Int)]
type Command = Char

fromList :: [Int] -> Dice
fromList [a, b, c, d, e, f] = [(a, f), (b, e), (c, d)]
fromList _ = error "Invalid dice."

rev :: (a,a) -> (a,a)
rev (x,y) = (y,x)

roll :: Dice -> Command -> Dice
roll [a, b, c] com =
    case com of
        'N' -> [b, rev a, c]
        'E' -> [rev c, b, a]
        'S' -> [rev b, a, c]
        'W' -> [c, b, rev a]
        _   -> error "Invalid command."
roll _ _ = error "Invalid command."

top :: Dice -> Int
top [(a,_),(_,_),(_,_)] = a
top _ = error "Invalid dice."

front :: Dice -> Int
front [(_,_),(b,_),(_,_)] = b
front _ = error "Invalid dice."

right ::  Dice -> Int
right [(_,_),(_,_),(c,_)] = c
right _ = error "Invalid dice."

spin :: Dice -> [Dice]
spin [a, b, c] = [ [a, b, c]
                 , [a, rev c, b]
                 , [a, rev b, rev c]
                 , [a, c, rev b]
                 ]
spin _ = error "Invalid dice."

dicePermutation :: Dice -> [Dice]
dicePermutation d = spin d ++ spin d' ++ concatMap (spin  . roll d) "NEWS"
  where d' = roll (roll d 'N') 'N'

tellRightFromTopAndFront :: Int -> Int -> Dice -> Int
tellRightFromTopAndFront x y dice = right $ head $ 
    filter (\d -> top d == x && front d == y) $ dicePermutation dice

main :: IO ()
main = do
    dice <- fromList . map read . words <$> getLine
    q <- readLn
    forM_ [1..q] $ \_ -> do
       [t, f] <- map read . words <$> getLine
       print $ tellRightFromTopAndFront t f dice

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define FOR(i, n) for(int i = 1; i<=n; i++)
#define F0R(i, n) for(int i = 0; i<n; i++)
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
const LL MOD = 1e9+7;
LL tr[2005], S, ans = 0, vl[2005];

void upd(LL g, LL k){
	k %= MOD; k += MOD; k %= MOD;
	for(; g<=S; g+=(g&-g)){
		tr[g] += k;
		tr[g] += MOD;
		tr[g] %= MOD;
	}
}

LL ge(LL g){
	LL res = 0;
	for(; g>0; g-=(g&-g)){
		res += tr[g];
		res += MOD;
		res %= MOD;
	}
	return res;
}

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

	cin >> S;
	for(int i = 3; i<=S; i++){
		upd(i, 1);
		vl[i] = 1;
	}
	ans += vl[S];
	for(int i = 2; i<=(S)/3; i++){
		for(int j = S; j>=3; j--){
			upd(j, -vl[j]);
			vl[j] = ge(j-3);
			upd(j, vl[j]);
		} ans += vl[S]; ans %= MOD;
	}

	cout << ans << endl;

	cout.flush();
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll long long
const ll MAX=1e2+10;
const ll modn=1e9+7;
using namespace std;


void solve() {
    int x;
    cin>>x;
    if(x>=30){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }


}
int main() {
    //ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3628
import bisect
N, M = map(int, input().split())
city = []
table = [0]*M
count = [0]*N
for i in range(M):
  P, Y = map(int, input().split())
  P -= 1
  city.append((i,P,Y))
city.sort(key=lambda x:x[2])
for i, P, Y in city:
  count[P] += 1
  x = str(count[P])
  P = str(P+1)
  ans = P.zfill(6)+x.zfill(6)
  table[i] = ans
for i in range(M):
  print(table[i])

Measured memory_bytes: 29804
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  int n;
  cin >> n;
  int ans = 0;
  
  rep(i,n){
    int a,b;
    cin >>a>>b;
    ans+=b-a+1;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;
map<prl,ll> mp;
map<prl,bool> used;

ll powmod(ll px, ll py, ll pmod){
	if(py == 0) return 1;
	if(py % 2 == 0) return powmod((px * px) % pmod, py / 2, pmod);
	else return (px * powmod(px, py - 1, pmod)) % pmod;
} 

//GCD
ll mygcd(ll x, ll y){
	if( y == 0 ) return x;
	return mygcd(y, x % y);
}

int main() {
    // your code goes here
    ll n,a[200005],b[200005],g,ans=1,zs=0;
    prl mm;
    cin >> n;
    rep(i,1,n){
        cin >> a[i] >> b[i];
        g = mygcd(abs(a[i]),abs(b[i]));
        if(g!=0) a[i] /= g;
        if(g!=0) b[i] /= g;
        if(a[i]<0){
            a[i] *= -1;
            b[i] *= -1;
        }
        if(a[i]==0&&b[i]!=0) b[i]=-1;
        if(b[i]==0&&a[i]!=0) a[i]=1;
    }
    rep(i,1,n){
        if(a[i]!=0||b[i]!=0){
            mp[{a[i],b[i]}]++;
        } else zs++;
    }
    used[{0,0}]=true;
    ans=1;
    rep(i,1,n){
        if(used[{a[i],b[i]}]) continue;
        if(b[i]>=0) if(used[{b[i],-a[i]}]) continue;
        if(b[i]<0) if(used[{-b[i],a[i]}]) continue;
        if(b[i]>=0){
            ans=ans*(powmod(2,mp[{a[i],b[i]}],mod)+powmod(2,mp[{b[i],-a[i]}],mod)-1+mod)%mod;
            used[{b[i],-a[i]}]=true;
        } else {
            ans=ans*(powmod(2,mp[{a[i],b[i]}],mod)+powmod(2,mp[{-b[i],a[i]}],mod)-1+mod)%mod;
            used[{-b[i],a[i]}]=true;
        }
        used[{a[i],b[i]}]=true;
    }
    cout << (ans-1+zs+mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 56696
#include<stdio.h>
#define NIL -1

int A[2000002];
int heap_size;
int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}
void swap(int x,int y){
  int temp;
  temp=A[x];
  A[x]=A[y];
  A[y]=temp;
}
void maxHeapify(int i){
  int l = left(i);
  int r = right(i);
  int largest;
  if (l <= heap_size && A[l] > A[i])largest = l;
  else largest = i;
  if (r <= heap_size && A[r] > A[largest])largest = r;
  if (largest != i){
    swap(i,largest);
    maxHeapify(largest);
  }
}

void heapIncreaseKey(int i,int key){
  if (key < A[i])return;
    // then error 新しいキーは現在のキーより小さい
  A[i] = key;
  while(i > 1 && A[parent(i)] < A[i]){
    swap(i,parent(i));
    i = parent(i);
  }
}
void maxHeapInsert(int key){
  heap_size = heap_size + 1;
  A[heap_size] = -100000000;
  heapIncreaseKey(heap_size, key);
}
int heapExtractMax(){
  int max;
  if ( heap_size < 1)
    return;// error ヒープアンダーフロー
  max = A[1];
  A[1] = A[heap_size];
  heap_size = heap_size - 1;
  maxHeapify(1);
  return max;
}

/*void buildMaxHeap(){
  int i;
  for(i=heap_size/2;i!=0;i--)maxHeapify(i);
  }*/


int main(){
  int i;
  char c[10];
  int a;

  for(i=0;i<2000002;i++){
    A[i]=NIL;
  }
  for(i=1;;i++){
    scanf("%s ",c);
    //   printf("%s",c);
    if(c[0]=='i'){
      scanf("%d",&a);
      maxHeapInsert(a);
      //   printf("insert\n");
    }
    else if(c[1]=='x'){
      a=heapExtractMax();
      printf("%d\n",a);
    }
    else break;
  }
  return 0;
}
  

Measured memory_bytes: 8232
from collections import Counter
n = int(input())
list_S = [input() for _ in range(n)]
dic_S = Counter(list_S)
m = 0
for i in dic_S.values():
    m = max(m, i)
ans = []
for k, v in dic_S.items():
    if v == m:
       ans.append(k)
ans.sort()
for s in ans:
    print(s)

Measured memory_bytes: 35572
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#define MAXN (int)3 * 1e+5
using namespace std;
int A[300000 + 5];
int B[300000 + 5];
int S[300000 + 5];
int S2[300000 + 5];
int main(){
	int n;
	scanf("%d",&n);
	char t;
	scanf("%d",&t);
	for(int i = 1;i <= n;i++){
		char t;
		scanf("%c",&t);
		if(t == 'W') A[i] = 1;
		else B[i] = 1;
	}
	for(int i = 1;i <= n;i++){
		S[i] = S[i - 1] + A[i];
	}
	for(int i = n;i >= 1;i--){
		S2[i] = S2[i + 1] + B[i];
	}	
	int ans = 0x3f3f3f3f;
	for(int i = 1;i <= n;i++){
		int t = S[i - 1] + S2[i + 1];
		ans = min(ans,t);
	}
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)

using namespace std;

void solve(int N, vector<int> a) {

  unordered_map<int, int> rate(8);
  REP(i, N)
    rate[min(a[i] / 400, 8)]++;

  int num = 0;
  REP(i, 8)
    if (rate[i])
      num++;

  int wildcard = rate[8];
  cout << max(1, num) << " " << num + wildcard << endl;
}

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

  int N;
  cin >> N;

  vector<int> a(N);
  REP(i, N)
    cin >> a[i];

  solve(N, move(a));

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  string a[h];
  for(int i=0;i<h;i++){
      cin>>a[i];
  }
  for(int i=0;i<w+2;i++){
    printf("#");
  }
  printf("\n");
  for(int i=0;i<h;i++){
      printf("#");
       cout<<a[i];
    printf("#\n");
  }
  for(int i=0;i<w+2;i++){
    printf("#");
  }
  printf("\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);
    StringBuilder ans = new StringBuilder();
    for (int i = 0; i < 3; i++) {
      String s = sc.next();
      ans.append(s.charAt(0));
    }
    System.out.println(ans.toString());
  }
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}


int main() {
  int N;
  cin >> N;
  map< int, int > mp;
  bool all = false;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    mp[x]++;
    all |= x > 0;
  }
  if(!all) {
    cout << "Yes" << endl;
  } else if((mp.size() != 2 && mp.size() != 3) || N % 3 != 0) {
    cout << "No" << endl;
  } else if(mp.size() == 2) {
    vector< int > vv;
    for(auto &p : mp) {
      if(p.second == N / 3 * 2 || p.second == N / 3) {
        if(p.second == N / 3 * 2) vv.emplace_back(p.first);
        vv.emplace_back(p.first);
      }
    }
    if(vv.size() == 0) {
      cout << "No" << endl;
      return 0;
    }
    for(int i = 0; i < 30; i++) {
      int add = 0;
      for(auto &p : vv) {
        if((p >> i) & 1) ++add;
      }
      if(add == 1) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  } else {
    for(auto &p : mp) {
      if(p.second != N / 3) {
        cout << "No" << endl;
        return 0;
      }
    }
    for(int i = 0; i < 30; i++) {
      int add = 0;
      for(auto &p : mp) {
        if((p.first >> i) & 1) ++add;
      }
      if(add == 1) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3840
import sys
input = sys.stdin.readline
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]
aa = [0]*(n+1)
bb = [0]*(n+1)
cc = [0]*(n+1)
for i in range(1,n+1):
  I = i-1
  front = abc[I]
  aa[i] = front[0] + max([bb[I],cc[I]])
  bb[i] = front[1] + max([aa[I],cc[I]])
  cc[i] = front[2] + max([bb[I],aa[I]])
print(max([aa[n],bb[n],cc[n]]))

Measured memory_bytes: 42356
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	static void doit(){
		Scanner scan = new Scanner(System.in);
		Player player[]=new Player[24];
		Player[] f_player=new Player[8];
		Player[] memo=new Player[6];
		for(int i=0;i<24;i++){
			player[i]=new Player(scan.nextInt(),scan.nextDouble());
		}
		Arrays.sort(player,0,8);
		Arrays.sort(player,8,16);
		Arrays.sort(player,16,24);
		int k=0;
		for(int i=0;i<=16;i+=8){
			f_player[k]=player[i];
			f_player[k+1]=player[i+1];
			memo[k]=player[i+2];
			memo[k+1]=player[i+3];
			k+=2;
		}
		Arrays.sort(memo);
		f_player[6]=memo[0];
		f_player[7]=memo[1];
		for(int i=0;i<f_player.length;i++){
			System.out.printf("%d %s\n", f_player[i].num,f_player[i].time);
		}
	}
	public static void main(String[] args) {
		new Main().doit();
	}

}
class Player implements Comparable<Player>{
	int num;
	Double time;
	public Player(int num,Double time){
		this.num=num;
		this.time=time;
	}
	@Override
	public String toString(){
		return num+" "+time;
	}
	@Override
	public int compareTo(Player p){
		return time.compareTo(p.time);
	}	
}

Measured memory_bytes: 28604
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,w;
    double ans=0,rest=0;
    cin>>n>>w;
    pair<double,pair<double,double> > a[n];
    for(int i=0;i<n;i++){
        cin>>a[i].second.first>>a[i].second.second;
        a[i].first=a[i].second.first/a[i].second.second;
    }
    sort(a,a+n);
    reverse(a,a+n);
    for(int i=0;i<n;i++){
        if(w-rest<=a[i].second.second){
            ans += a[i].second.first*(double)(w-rest)/a[i].second.second;
            break;
        }
        else{
            ans += a[i].second.first;
            rest += a[i].second.second;
        }
    }
    cout<<fixed << setprecision(12)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5556
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
vvi G;
pii dp[50][50][50][50];
int n,m,q,sum;
pii f(int a,int b,int c,int d){
	if(dp[a][b][c][d].first!=inf)return dp[a][b][c][d];
	dp[a][b][c][d]=pii(0,0);
	dp[a][b][c][d].second=G[c][d]-G[a][d]-G[c][b]+G[a][b];
//	cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<dp[a][b][c][d].second<<endl;
//	loop(i,a,c)loop(j,b,d)dp[a][b][c][d].second+=G[i][j];
	rep(i,c-a-1){
		pii ta=f(a,b,a+i+1,d);
		pii tb=f(a+i+1,b,c,d);
		if(min(ta.second,tb.second)==-inf)continue;
		if(dp[a][b][c][d].first<1+ta.first+tb.first){
			dp[a][b][c][d].first=1+ta.first+tb.first;
			dp[a][b][c][d].second=min(ta.second,tb.second);
		}else if(dp[a][b][c][d].first==1+ta.first+tb.first){
			dp[a][b][c][d].second=max(dp[a][b][c][d].second,min(ta.second,tb.second));
		}
	}
	rep(i,d-b-1){
		pii ta=f(a,b,c,b+i+1);
		pii tb=f(a,b+i+1,c,d);
		if(min(ta.second,tb.second)==-inf)continue;
		if(dp[a][b][c][d].first<1+ta.first+tb.first){
			dp[a][b][c][d].first=1+ta.first+tb.first;
			dp[a][b][c][d].second=min(ta.second,tb.second);
		}else if(dp[a][b][c][d].first==1+ta.first+tb.first){
			dp[a][b][c][d].second=max(dp[a][b][c][d].second,min(ta.second,tb.second));
		}
	}
	if(dp[a][b][c][d].second<sum)dp[a][b][c][d]=pii(-inf,-inf);
//	cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
//	cout<<dp[a][b][c][d].first<<" "<<dp[a][b][c][d].second<<endl;
	return dp[a][b][c][d];
}
int main(){
	while(cin>>n>>m>>q,n+m+q){
		sum=-q;
		G=vvi(n+1,vi(m+1));
		rep(i,n)rep(j,m)cin>>G[i+1][j+1];
		rep(i,n)rep(j,m)G[i+1][j+1]+=G[i][j+1]+G[i+1][j]-G[i][j];
		sum=G[n][m]-q;
		rep(i,50)rep(j,50)rep(k,50)rep(l,50)
			dp[i][j][k][l]=pii(inf,inf);
		f(0,0,n,m);
		cout<<1+dp[0][0][n][m].first<<" "<<dp[0][0][n][m].second-sum<<endl;
	}
}

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

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


using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main(){
  string s,t;
  cin >> s >> t;
  int n = s.size()-t.size()+1;
  int T = t.size();
  int S = s.size();
  
  int ans = 10001;
  rep(i, n){
    int sum = 0;
    rep(j, T){
      if(s[i+j]!=t[j]){
        sum++;
      }
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;
      
    
}



Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	double ma,mi;
	double x;
	cin>>x;
	ma=mi=x;
	while(cin>>x){
		ma=max(ma,x);
		mi=min(mi,x);
	}
	cout<<ma-mi<<endl;
	
	return 0;
}

Measured memory_bytes: 0
// from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
    n: i32,
    aa: [i32; n]
    }
    let mut ans = 0;
    for &x in aa.iter() {
        ans ^= x;
    }
    println!("{}", if ans == 0 { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
# 1-index
from sys import stdin
N, M = [int(x) for x in stdin.readline().rstrip().split()]
adj_matrix = [[0]*(N+2) for i in range(N+2)]

edges = []

for i in range(M):
    a, b = [int(x) for x in stdin.readline().rstrip().split()]
    edges.append((a, b))
    adj_matrix[a][b] = 1
    adj_matrix[b][a] = 1

def dfs(i):
    if is_visited[i]:
        return False

    is_visited[i] = True

    for node,bi in enumerate(adj_matrix[i][:-1]):
        if bi == 1:
            dfs(node)

ans = 0
for j, k in edges:
    is_visited = [False for i in range(N+1)]
    adj_matrix[j][k] = 0
    adj_matrix[k][j] = 0
    dfs(1)
    if not all(is_visited[1:]):
        ans += 1
    adj_matrix[j][k] = 1
    adj_matrix[k][j] = 1
        
print(ans)

Measured memory_bytes: 3064
package main

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

func main() {
	a := nextInt()
	if a%10 == 9 || a/10 == 9 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

// -------- Library --------
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	v, _ := strconv.Atoi(next())
	return v
}

func nextIntArray(size int) []int {
	res := make([]int, size)
	for i := 0; i < size; i++ {
		res[i] = nextInt()
	}
	return res
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef long long llong;
llong mod=1e9+7;
typedef pair<int,int> P;
int h,w,cnt;
char s[51][51];
int d[51][51];

int bfs(){
  int nx,ny;
  queue<P> ss;
  P tt;
  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  d[1][1]=1;
  tt={1,1};
  ss.push({1,1});
  while(ss.size()){
    if(tt.first==h&&tt.second==w)break;
    tt=ss.front();
    ss.pop();
    for(int i=0;i<4;i++){
      nx=tt.first+dx[i];
      ny=tt.second+dy[i];
      if(nx>0&&nx<=h&&ny>0&&ny<=w&&d[nx][ny]==-1&&s[nx][ny]!='#'){
        ss.push({nx,ny});
        d[nx][ny]=d[tt.first][tt.second]+1;
      }
    }
    /*for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++)cout<<setw(2)<<d[i][j];
      cout<<endl;
    }
    cout<<endl;*/
  }
  return d[h][w];
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cnt=0;
  cin>>h>>w;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>s[i][j];
      d[i][j]=-1;
      if(s[i][j]=='#')cnt++;
    }
  }
  int m=bfs();
  if(m==-1){
    cout<<-1<<endl;
    return 0;
  }
  cout<<(h*w-cnt-m)<<endl;
  return 0;
  }


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(15000)
n = int(sys.stdin.readline())

def lcs(X,Y):
  n_y = len(Y)
  n_x = len(X)
  #dp = [[0]*(n_x+1) for _ in range(n_y+1)]
  dp = [0]*(n_x+1)
  for i_y in range(n_y):
    ndp = dp.copy()
    for i_x in range(n_x):
      if X[i_x] == Y[i_y]:
        #dp[i_y+1][i_x+1] = dp[i_y][i_x] + 1
        ndp[i_x+1] = dp[i_x] + 1
      elif dp[i_x+1] < ndp[i_x]:
        #dp[i_y+1][i_x+1] = max(dp[i_y+1][i_x],dp[i_y][i_x+1])
        ndp[i_x+1] = ndp[i_x]
    dp = ndp
    #print(dp)
    #return(dp[-1][-1])
  return(dp[-1])

ret = []
inp = sys.stdin.readlines()
for i in range(n):
  X = inp[2*i].rstrip()#[:-1]#input()
  Y = inp[2*i+1].rstrip()#[:-1]#input()
  ret.append(lcs(X,Y))
  #print

print(*ret,sep="\n")


Measured memory_bytes: 5648
#include<iostream>
#include<string>
#include<stack>

int main()
{
    std::string s ;
    std::stack<int> st ;

    while(std::cin >> s)
    {
        if(s == "+")
        {
            int a = st.top() ;
            st.pop() ;
            int b = st.top() ;
            st.pop() ;
            st.push(a+b) ;
        }
        else if(s == "-")
        {
            int a = st.top() ;
            st.pop() ;
            int b = st.top() ;
            st.pop() ;
            st.push(b-a) ;
        }
        else if(s == "*")
        {
            int a = st.top() ;
            st.pop() ;
            int b = st.top() ;
            st.pop() ;
            st.push(a*b) ;
        }
        else
        {
            st.push(std::stoi(s)) ;
        }
        

    }

    std::cout << st.top() << std::endl ;
}



Measured memory_bytes: 3172
import math
x = int(input())
limit = 10**5
i = x
while True:
  for j in range(2, int(math.sqrt(i))+1):
    if (i%j)==0:
      break
  else:
    # すべてのjで割り切れなかった場合
    print(i)
    break
  i += 1

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

int main() {
	// your code goes here
	string s;
	cin>>s;
	int l = s.size();
	if(l ==1||l==2||l==3)
	{cout<<"No"; return 0;}
	if(s[0]=='Y'&&s[1]=='A'&& s[2]=='K'&&s[3]=='I')
	{cout<<"Yes";}
	else 
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
a,b,m=map(int,input().split())
aa=[0]*a
bb=[0]*b
x=[0]*m
y=[0]*m
c=[0]*m
aa=list(map(int,input().split()))
bb=list(map(int,input().split()))
ans=[min(aa)+min(bb)]
for i in range(m):
  x[i],y[i],c[i]=map(int,input().split())
  ans.append(aa[x[i]-1]+bb[y[i]-1]-c[i])
  
print(min(ans))

Measured memory_bytes: 27392
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll k, x;
  cin >> k >> x;
  rep2(i, x - k + 1, x) cout << i << ' ';
  rep2(i, x, x + k) cout << i << ' ';
  cout << endl;
}

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

struct UnionFind
{
    vector<int> par; //par[i]:iの親の番号

    //初めは全てが根であるとして初期化する
    UnionFind(int N): par(N)
    {
        for (int i=0; i<N; i++) par[i]=i;
    }

    int root(int x)
    {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> P(N);
    for (int i=0; i<N; i++) cin >> P[i];
    
    UnionFind Tree(N);

    for (int i=0; i<M; i++)
    {
        int x, y;
        cin >> x >> y;
        Tree.unite(x-1, y-1);
    }
    int answer = 0;
    for (int i=0; i<N; i++)
    {
        if (i+1==P[i]) answer++;
        else if (Tree.same(i, P[i]-1)) answer++;
    }
    cout << answer << endl;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define ll long long
#define fprint(v) for(auto x : v) cout << x << ' ';
using namespace std;
const int N = 2e5 + 2;
const int M = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
  	cin >> n;
  	cout << n / 2 + n % 2;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define Check system("pause")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

int w[100005],d[100005];

int main()
{
	ios::sync_with_stdio(false);
	int a,b,m,ans=0,l,r,x,y,c,k;
	cin>>a>>b>>m;
	l=r=1e9;
	for(int i=1;i<=a;i++)
	{
		cin>>w[i];
		l=min(l,w[i]);
	}
	for(int i=1;i<=b;i++)
	{
		cin>>d[i];
		r=min(r,d[i]);
	}
	ans=l+r;
	for(int i=1;i<=m;i++)
	{
		cin>>x>>y>>c;
		k=w[x]+d[y]-c;
		ans=min(ans,k);
	}
	cout<<ans;
	return 0;
}




Measured memory_bytes: 1024
N,K=map(int,input().split())
V=list(map(int,input().split()))
R=min(N,K)
ans=0
for i in range(R+1):
	for j in range(R-i+1):
		if i==0 and j==0:continue
		L=sorted(V[:i]+V[N-j:])
		k=min(K-i-j,len(L)-1)
		for p in range(k):
			if L[p]>=0:
				k=p
				break
		ans=max(ans,sum(L[k:]))
print(ans)

Measured memory_bytes: 3064