akhauriyash/Code-Regression huggingface dataset:
A, B, Q = [int(x) for x in input().split()]
s = [-10 ** 10] + [None] * A + [2 * (10 ** 10)]  # s[0], s[A+1]はダミー
t = [-10 ** 10] + [None] * B + [2 * (10 ** 10)]  # t[0], t[B+1]はダミー
x = [0] * Q
for i in range(1, A + 1):
    s[i] = int(input())
for j in range(1, B + 1):
    t[j] = int(input())
for k in range(Q):
    x[k] = int(input())

for i in range(Q):
    # Find s[j] such that s[j] <= x[i] < s[j+1]
    ok = 0       # s[0] < x[i]
    ng = A + 1   # x[i] < s[A+1]
    while ng - ok > 1:
        mid = (ng + ok) // 2
        if s[mid] < x[i]:
            ok = mid
        else:
            ng = mid
    j = ok

    ok = 0      # t[0] < x[i]
    ng = B + 1  # x[i] < t[A+1]
    while ng - ok > 1:
        mid = (ng + ok) // 2
        if t[mid] < x[i]:
            ok = mid
        else:
            ng = mid
    k = ok
 
    ans = min(  max(s[j + 1], t[k + 1]) - x[i], # 右
                x[i] - min(s[j], t[k]),         # 左
                2 * s[j + 1] - t[k] - x[i],     # 右 s[j+1] -> 左 t[k]
                s[j + 1] - 2 * t[k] + x[i],     # 左 t[k] -> 右 s[j+1]
                -s[j] + 2 * t[k + 1] - x[i],    # 右 t[k+1] -> 左 s[j]
                -2 * s[j] + t[k + 1] + x[i])    # 左 s[j] -> 右 t[k+1]

    print(ans)


Measured memory_bytes: 83772
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] input = new int[n];
        for (int i = 0; i < n; i++) {
            input[i] = sc.nextInt();
        }

        System.out.print(input[n - 1]);
        for (int i = n - 2; i >= 0; i--) {
            System.out.print(" " + input[i]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 26496
val= input()
val_list=list(map(int,val.split()))
n=val_list[0]
k=val_list[1]
n= n % k
judge=[]
while True:
    n = abs(n-k)
    if n in judge:
        break
    else:
        judge.append(n)
min= judge[0]
for i in range(0,len(judge)):
    if min > judge[i]:
       min= judge[i]

print(min)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    string S;
    cin >> S;
    write(string(S.size(), 'x'));
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    long long Y;
    cin >> Y;

    bool res = false;
    vector<int> ans{-1, -1, -1};
    for (int i = 0; i <= n && !res; ++i) {
        for (int j = 0; i + j <= n && !res; ++j) {
            int k = n - i - j;
            long long cnt = i * 10000LL + j * 5000LL + k * 1000LL;
            if (cnt == Y) {
                res = true;
                ans = {i, j, k};
                break;
            }
        }
    }

    cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << '\n';
    

    return 0;
}

Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
X=int(int(input())//50)
count=0
for i in range(A+1):
  for j in range(B+1):
    rest=X-i*10-j*2
    if rest>=0 and rest-C<=0:
      count=count+1
print(count)
  

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

const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

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

// テーブルを作る前処理
void COMinit() {
    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;
    }
}

// 二項係数計算
ll COM(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;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};

const int D = 80 * 160 + 10;
const int D2 = D*2;
typedef bitset<D2> bs;
int a[100][100];
bs dp[90][90];

int main(){
    int n,m; cin >> n >> m;
    vector<string> v[n];
    rep(i,m) {
        int p; cin >> p;
        p--;
        string s; cin >> s;
        v[p].push_back(s);
    }

    int ac = 0;
    int wa = 0;
    rep(i,n) {
        int tmpWa = 0;
        rep(j,v[i].size()) {
            if (v[i][j] == "AC") {
                ac++;
                wa += tmpWa;
                break;
            } else {
                tmpWa++;
            }
        }
    }

    cout << ac << " " << wa << endl;


    return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


signed main() {
    ll n;
    cin >> n;
    
    
    queue <ll> q;
    
    rrep(i, 9) q.push(i);
    
    ll x;
    ll cnt = 0;
    while(true) {
        x = q.front();
        q.pop();
        
        if (x % 10 != 0) {
            q.push((10*x) + (x%10) -1);
        }
        q.push((10*x) + (x%10));
        if (x % 10 != 9) {
            q.push((10*x) + (x%10) +1);
        }
        cnt++;
        if (cnt == n) {
            mes(x);
            re0;
        }
    }
    
    
    
    
}

Measured memory_bytes: 5132
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    let a : usize = read();
    let b : usize = read();
    let mut f : bool = false;
    for i in 0..100000 {
        if i * 8 / 100 == a && i * 10 / 100 == b {
            println!("{}", i);
            f = true;
            break;
        }
    }
    if !f {
        println!("-1");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef double ld;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
const ll MOD = 4000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

ll digit(ll n){
	string s=to_string(n);
	ll ret=0;
	for(int i=0;i<s.size();i++){
		ret+=(s[i]-'0');
		
	}
	return ret;
}


int main(){
	init();
	ll a,b;cin>>a>>b;
	cout<<(a+b+1)/2<<endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	x := nextInt()

	x3 := x * x * x

	fmt.Println(x3)
}



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

int map[256][256];
int w;
int dx[8]={0,0,1,-1,-1,-1,1,1};
int dy[8]={1,-1,0,0,-1,1,-1,1};

int dfs(int x,int y){
	int res=0;
	for(int i=0;i<8;i++){
		int re2=0;
		int cx=x,cy=y;
		while(map[cx][cy]==1 && cx>=0 && cx<w && cy>=0 && cy<w){
			re2++;
			cx+=dx[i];
			cy+=dy[i];
		}
		res=max(res,re2);
	}
	return res;
}

int main(void){
	while(1){
		scanf("%d",&w);
		if(w==0)break;
		memset(map,0,sizeof(map));
		for(int i=0;i<w;i++){
			string str;
			cin >> str;
			for(int j=0;j<w;j++){
				map[j][i]=str[j]-'0';
			}
		}
		int ans=0;
		for(int i=0;i<w;i++){
			for(int j=0;j<w;j++){
				if(map[i][j]==1)ans=max(ans,dfs(i,j));
			}
		}
		printf("%d\n",ans);
	}
    return 0;
}

Measured memory_bytes: 1216
from itertools import accumulate as acc
N=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a1=list(acc(a1))
a2=[0]+list(acc(a2))
ans=0
for i in range(N):
    ans=max(a1[i]+a2[N]-a2[i],ans)

print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
void __dump(long long x){cerr << x;}
void __dump(long double x){cerr << fixed << setprecision(3) << x;}
void __dump(int x){cerr << x;}
void __dump(char x){cerr << '\'' << x << '\'';}
void __dump(const string &x){cerr << '"' << x << '"';}
void __dump(const char *x){cerr << '"' << x << '"';}
void __dump(bool x){cerr << (x ? "true" : "false");}
void _dump(){cerr << "\n";}
template <typename T, typename U> void __dump(const pair<T, U> &x){cerr << '{'; __dump(x.first); cerr << ','; __dump(x.second); cerr << '}';}
template <typename T, typename U, typename V> void __dump(const tuple<T, U, V> &x){cerr << '{'; __dump(get<0>(x)); cerr << ',';  __dump(get<1>(x)); cerr << ',';  __dump(get<2>(x)); cerr << '}';}
template <typename T> void __dump(const T& x){int f=0; cerr << '{'; for(auto&i:x) cerr << (f++ ? "," : ""), __dump(i); cerr << "}";}
template <typename T, typename ... U> void _dump(T t, U ... u){__dump(t); if(sizeof...(u)) cerr << ", "; _dump(u...);}
#define dump(x ...) cerr  <<  "|| "  <<  # x  <<  " = ", _dump(x) 
//#define int long long
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define size(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define ln '\n'
#define __ ' '
#define LL long long
#define LD long double
#define pii pair<int,int>
const int INF = 2e9;
const int NN = 1e5;
int n;
vector<int> adj[NN+1];
int dist[NN+1];
int a,b;
int perm1[NN+1], perm2[NN+1];

void findDists(int u, int prv, int d){
	dist[u] = d;
	for(int v: adj[u]) if(v!=prv) findDists(v, u, d+1);
}

void findPerm(int u, int prv, int perm[], int id, int p){
	assert(size(adj[u]) > 1 || prv == -1);

	vector<int> leaves;
	int notLeaf=-1;
	for(int v: adj[u]) if(v!=prv){
		if(size(adj[v]) == 1) leaves.emplace_back(v);
		else notLeaf = v;
	}

	for(int i=0; i<size(leaves); ++i){
		perm[id+i] = 1+p+i;
	}

	if(notLeaf != -1){
		perm[id+size(leaves)] = 1+p+size(leaves);
		perm[id+size(leaves)+1] = p;
		swap(perm[id+size(leaves)], perm[id+size(leaves)+1]);
		findPerm(notLeaf, u, perm, id+size(leaves)+1, 1+p+size(leaves));
	}
	else{
		perm[id+size(leaves)] = p;
		swap(perm[id+size(leaves)-1], perm[id+size(leaves)]);
	}
}

int32_t main(){ FAST;
	cin >> n;
	for(int i=1; i<=n-1; ++i){
		int u,v; cin >> u >> v;
		adj[u].emplace_back(v);
		adj[v].emplace_back(u);
	}

	for(int u=1; u<=n; ++u){
		int leaves = 0;
		for(int v: adj[u]) leaves += (size(adj[v])==1);
		if(size(adj[u])-leaves > 2){
			cout << -1 << ln;
			return 0;
		}
	}

	findDists(1,-1,0);
	a = max_element(dist+1, dist+n+1) - (dist);
	findPerm(a,-1,perm1,1,1);

	findDists(a,-1,0);
	b = max_element(dist+1, dist+n+1) - (dist);
	findPerm(b,-1,perm2,1,1);
	
	vector<int> ans = min(vector<int>(perm1+1,perm1+n+1), vector<int>(perm2+1,perm2+n+1));
	for(int p: ans) cout << p << __;
	cout << ln;
}

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

int main(void) {
	const int max = 50;
	int N, M;
	char A[max][max], B[max][max];

	cin >> N >> M;

	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			cin >> A[i][j];

	for (int i = 0; i < M; i++)
		for (int j = 0; j < M; j++)
			cin >> B[i][j];

	bool ans = false;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i + M - 1 > N || j + M - 1>N) continue;

			bool match = true;
			for (int a = 0; a < M; a++) {
				for (int b = 0; b < M; b++) {
					if (A[i + a][j + b] != B[a][b]) match = false;
				}
			}
			if (match) ans = true;
		}
	}

	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

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

    sort(d.begin(), d.end());
    auto itr = unique(d.begin(), d.end());
    d.erase(itr, d.end());

    cout << d.size() << endl;

    
}

Measured memory_bytes: 256
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
ans = 'No'

for i in range(N):
    if x[i]==y[i] and N-2>i:
        if x[i+1]==y[i+1] and N-1>i:
            if x[i+2]==y[i+2] :
                ans = 'Yes'

print(ans)

Measured memory_bytes: 9188
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a*b;
        int length = a+a+b+b;
        System.out.println(area + " " + length);
    }
}


Measured memory_bytes: 26140
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls signed
#define give main()
const int mod = 1000000007;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

#pragma endregion

const int N = 500005, BLK = 707;

int n, q, arr[N], ans[N], freq[N];
pair<pair<int, int>, int> que[N];

bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
    if (a.first.first / BLK != b.first.first / BLK) return a.first.first / BLK < b.first.first / BLK;
    else return a.first.second < b.first.second;
}

pls give {
    AC;
    cin >> n >> q;
    for (int i=0; i<n; i++) cin >> arr[i];
    for (int i=0; i<q; i++) {
        cin >> que[i].first.first >> que[i].first.second;
        que[i].first.first--; que[i].first.second--;
        que[i].second = i;
    }
    sort(que, que+q, cmp);

    int l=0, r=-1;
    int x = 0;
    for (int i=0; i<q; i++) {
        int lx = que[i].first.first, rx = que[i].first.second;
        while (r < rx) {
            r++;
            if (!freq[arr[r]]) x++;
            freq[arr[r]]++;
        }
        while (r > rx) {
            freq[arr[r]]--;
            if (!freq[arr[r]]) x--;
            r--;
        }
        while (l > lx) {
            l--;
            if (!freq[arr[l]]) x++;
            freq[arr[l]]++;
        } 
        while (l < lx) {
            freq[arr[l]]--;
            if (!freq[arr[l]]) x--;
            l++;
        }
        ans[que[i].second] = x;
    }
    for (int i=0; i<q; i++) cout << ans[i] << nl;
}

Measured memory_bytes: 27144
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a,const void *b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{   int n;
    scanf("%d",&n);
    int x[n];
    for(int i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    qsort(x,n,sizeof(int),compare);
    
    long long ans=1000000000;
    for(int i=1;i<=100;i++){
        long long prean=0;
        for(int j=0;j<n;j++){
            prean+=(x[j]-i)*(x[j]-i);
        }
        ans=prean<ans?prean:ans;
    }
    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 128
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        String str = s.next();
        char[] ch = str.toCharArray();
        for(int i=0; i<ch.length; i++)
        {
            if(ch[i]=='?')
            {
                if(i>0&&i<ch.length-1)
                {
                    ch[i]='D';
                }
                else
                {
                    if(i==0&&ch.length>1)
                    {
                        if(ch[1]=='P'||ch[1]=='?')
                            ch[0]='D';
                        else
                            ch[0]='P';
                    }
                    else
                        ch[i]='D';
                }
            }
            System.out.print(ch[i]);
        }
    }
}


Measured memory_bytes: 58096
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define MOD 1000000007;
using namespace std;

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

    int n {}; 
    cin >> n;

    vector<int> v (n);
    vector<int> c (n);

    for (auto &val: v) cin >> val;
    for (auto &val: c) cin >> val;

    int ans {};
    for (int i {}; i < n; ++i) {
    	if ((v.at(i)-c.at(i)) >= 0) ans += (v.at(i)-c.at(i));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	x := getNextInt64(scanner)
	y := getNextInt64(scanner)

	ans := "Brown"
	if win(x, y) {
		ans = "Alice"
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}

func win(x, y int64) bool {
	if x < y {
		x, y = y, x
	}

	if x-y < 2 {
		return false
	}

	return true
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=11e4;
map<int,int> cha;

int n,m,j,k,l,i,o;
int fa[N],a[N],b[N],aa[N],bb[N],done[N];

inline int gf(int o)
{return fa[o]==o?o:fa[o]=gf(fa[o]);}

int main()
{
	cin>>n;
	fo(i,1,n)scanf("%d",&a[i]),a[n+1]^=a[i],aa[i]=a[i];
	fo(i,1,n)scanf("%d",&b[i]),b[n+1]^=b[i],bb[i]=b[i];
	++n; aa[n]=a[n]; bb[n]=b[n];
	sort(aa+1,aa+n+1); sort(bb+1,bb+n+1);
	fo(i,1,n)if(aa[i]!=bb[i]){
		puts("-1"); return 0;
	}
	int t=0; aa[0]=bb[0]=-1;
	fo(i,1,n)t+=(aa[i]!=aa[i-1]),cha[aa[i]]=t;
	fo(i,1,t)fa[i]=i;
	int ans=-1;
	fo(i,1,n)if(i==n||a[i]!=b[i]){
		ans+=(i<n);
		int x=cha[a[i]],y=cha[b[i]];
		fa[gf(x)]=gf(y);
		done[x]=done[y]=1;
	}
	fo(i,1,n)if(gf(i)==i&&done[i])++ans;
	cout<<(ans<0?0:ans);
}

Measured memory_bytes: 8192
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
//const int N = ;
int t,n;
int main(){
//	freopen("1.txt","r",stdin);
	string s;
	cin>>s;
	if(s[s.size()-1]!='s') s+='s';
	else s+="es";
	cout<<s<<endl;
	return 0;
}




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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Read();
            WriteLine(s.Replace("2017", "2018"));
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
import math
import scipy.optimize

a, b, x = [int(i) for i in input().split()]

def func_a(theta):
    S = 0.5 * b**2 / math.tan(theta)
    V = S * a
    equal = V - x

    return equal

def func_b(theta):
    S = a * b - 0.5 * a**2 * math.tan(theta)
    V = S * a
    equal = V - x

    return equal

if x <= 0.5 * a**2 * b:
    result = scipy.optimize.bisect(func_a, math.atan(b/a), math.pi/2 - 10**(-6))
else:
    result = scipy.optimize.bisect(func_b, 0, math.atan(b/a))

print(math.degrees(result))


Measured memory_bytes: 17436
#include <stdio.h>

int main(void){
  int N, i, count=0;
  long int D, x, y;
  scanf("%d%ld",&N, &D);
  
  D = D*D;
  
  for(i = 0; i < N; i++){
    scanf("%ld%ld",&x, &y);
    if(x*x + y*y <= D) count += 1;
  }
  printf("%d\n",count);
  return 0;
}

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

count=[[0]*10 for i in range(10)]


for i in range(1,N+1):
    s=str(i)
    count[int(s[0])][int(s[-1])]+=1


ans=0

for i in range(10):
    for j in range(10):
        
        ans=ans+(count[i][j]*count[j][i])
    
print(ans)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
    int n, t, a;
    cin >> n >> t >> a;

    int p = -1;
    double p_diff = 1000;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;

        double tmp = t - h * 0.006;
        if (p_diff > (a > tmp ? a - tmp : tmp - a)) {
            p_diff = (a > tmp ? a - tmp : tmp - a);
            p = i + 1;
        }
    }

    cout << p << endl;
}


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

int main() {
  int n;
  cin>>n;
  int a[n],b[n],c[n],fc[n],fb[n],fa[n];
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  fc[0]=c[0];
  fb[0]=b[0];
  fa[0]=a[0];
 
  for(int i=1;i<n;i++){
    fc[i]=c[i]+max(fb[i-1],fa[i-1]);
    fb[i]=b[i]+max(fa[i-1],fc[i-1]);
    fa[i]=a[i]+max(fb[i-1],fc[i-1]);

  }
  cout<<max(max(fc[n-1],fb[n-1]),fa[n-1])<<endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

int main(){
    ll N;
  	cin>>N;
    vector<ll> A(N);
    vector<ll> C(N, 0);
    rep(i, N){
        cin>>A[i];
        C[A[i]-1]++;
    }
    ll Sum=0;
    rep(i, N){
        Sum+=C[i]*(C[i]-1)/2;
    }
    rep(i, N){
        ll Y=C[A[i]-1];
        cout<<Sum-Y*(Y-1)/2+(Y-1)*(Y-2)/2<<endl;
    }
    return 0;
}



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

/**
 * A Popular Ice-cream Shop
 */
public class Main {

	final static char ASTER_ = '*';
	final static char HYPHEN = '-';
	final static char RETURN = '\n';
	final static int KINDS = 10;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		StringBuilder sb = new StringBuilder();
		while ((line = br.readLine()) != null) {

			if (line.isEmpty()) {
				continue;
			}

			int[] ices = new int[KINDS];
			int n = Integer.parseInt(line);
			if (n == 0) {
				break;
			}

			for (int i = 0; i < n; ++i) {
				++ices[Integer.parseInt(br.readLine())];
			}
			for (int i = 0; i < KINDS; ++i) {
				if (ices[i] > 0) {
					for (int j = 0; j < ices[i]; ++j) {
						sb.append(ASTER_);
					}
				} else {
					sb.append(HYPHEN);
				}
				sb.append(RETURN);
			}
		}
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 25424
N,M=map(int,input().split())
War=[[int(i) for i in input().split()] for i in range(M)]
War.sort(key=lambda x:x[1])

cut=0
ans=0
for i in range(M):
  if War[i][0]>=cut:
    ans+=1
    cut=War[i][1]
print(ans)

Measured memory_bytes: 22820
import sys
input = sys.stdin.readline

def main():
    s = input().strip()
    N = len(s)
    left = [0] * N
    right = [0] * N
    # left
    if s[0] == "<":
        left[0] = 1
    for i in range(1, N):
        if s[i] == "<":
            left[i] = left[i-1] + 1
    # right
    if s[-1] == ">":
        right[-1] = 1
    for i in range(N-2, -1, -1):
        if s[i] == ">":
            right[i] = right[i+1] + 1
    # ans
    ans = right[0] + left[-1]
    for i in range(N-1):
        ans += max(left[i], right[i+1])
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 27296
import java.util.*

fun main(args: Array<String>) {
   val sc = Scanner(System.`in`)
   val n = sc.nextInt()
   val m = sc.nextInt()
   val nums = IntArray(n)

   for(i in 0 until n){
      nums[i] = -1
   }

   for(i in 0 until m) {
      val s = sc.nextInt() -1
      val c = sc.nextInt()



      if(nums[s] != -1 && nums[s] != c){
         println(-1)
         return
      }

      if(s == 0 && c == 0 && n  != 1) {
         println(-1)
         return
      }

      nums[s] = c
   }

   if(nums[0] == -1 && n == 1){
      nums[0] = 0
   }

    if(nums[0] == -1 ){
       nums[0] = 1
    }

   for(i in 0 until n){
      if(nums[i] == -1) nums[i] = 0
   }

   var ans: String = ""
   for(i in 0 until n){
      ans += nums[i].toString()
   }

   println(ans)

}




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

#define F first
#define S second
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << endl;}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]";cout<<endl;}

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

	string s; cin >> s;
	int n = s.length();
	vector<ii> f(3);
	FOR (i, 0, sz(s)-1) f[s[i]-'a'].F++;
	FOR (i,0,2) f[i].S=i+'a';
	sort(all(f)); reverse(all(f));
	s = "";
	while (sz(s) < n) {
		FOR (i, 0, 2)
		if (f[i].F) s += (char)f[i].S, f[i].F--;
	}
	int g = 1;
	FOR (i, 1, n-1) {
		g &= s[i] != s[i-1];
		if (i + 1 < n) g &= (s[i-1]!=s[i+1]);
	}
	cout << (g?"YES\n":"NO\n");


	return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
using namespace std;
long long l,ans=0,pre[200000+5],x[200000+5];
int main(){
    int n;
    scanf("%lld%d",&l,&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&x[i]);
    x[n+1]=l;
    for(int i=1;i<=n;i++)
        pre[i]=pre[i-1]+x[i];
    for(int i=1,j=n-1;i<=n;i++,j--){
        long long t1=i*l+2*pre[(i-1)/2]+x[(i+1)/2]-2*(pre[i]-pre[i-(i+1)/2]);
        long long t2=j*l+2*(pre[i+j/2]-pre[i-1])-x[i+(j+1)/2]-2*(pre[n]-pre[i+(j+1)/2]);
        ans=max(ans, max(t1, t2));
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3328
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }

    if (m <= n) {
        print(0)
        return
    }
    val input = readLine()!!.split(" ").map { it.toInt() }

    // 1. コマを n 個配置する
    // 2. コマを １つずつ動かした場合に最小コストで m 個の地点を制覇したい

    // 入力を座標順にソート
    val inputSorted = input.sorted()

    // 左隣りとの差分を計算, index との Pair として格納
    val ld = Array(input.size) {Pair(0, 0)}
    ld[0] = Pair(0, 0)

    for (i in 1 until inputSorted.size) {
        val distance = inputSorted[i] - inputSorted[i - 1]
        ld[i] = Pair(i, distance)
    }

    // 距離の値を元にしてインデックスソート
    val ldSorted = ld.sortedByDescending { it.second }

    // 置き場所を決定
    val startPosIndex = Array(n) {0}
    startPosIndex[n-1] = 0
    for (i in 0 until n-1) {
        startPosIndex[i] = ldSorted[i].first
    }

    // 置き場所を決めた場合の移動コストを計算
    // それぞれ，隣のスタート位置につくまでの移動コストを計算
    var cost = 0
    val startPosIndexSorted = startPosIndex.sorted()

    for (i in 0 until startPosIndexSorted.size) {

        if (i == startPosIndexSorted.size-1) {
            cost += inputSorted[inputSorted.lastIndex] - inputSorted[startPosIndexSorted[i]]
        } else {
            // 隣だったら0 になるので OK
            cost += inputSorted[startPosIndexSorted[i + 1] - 1] - inputSorted[startPosIndexSorted[i]]
        }
    }
    print(cost)
}

Measured memory_bytes: 59636
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(void){
  long long N;
  long long K;
  if(scanf("%lld %lld",&N,&K)==1);
  long long S;
  S=N%K;
  long long A;
    A=K-S;
    if(A<S){
      printf("%lld",A);
    }
    else{
      printf("%lld",S);
    }
  return 0;
}

Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int sum=0;
  int i = 0;
  
  while(i < N){
    int l;
  	int r;
    cin >> l >> r;
    sum = sum + r -l + 1;
    i++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int temp=a;
    a=b;
    b=temp;
    temp=c;
    c=a;
    a=temp;
    cout<<a<<" "<<b<<" "<<c;

    return 0;
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=25;
int n,a[N];
ll dfs(int l,int r,ll xl,ll xr){
	if(l+1==r)return 0;
	R ll res=1e18;
	fp(m,l+1,r-1)cmin(res,dfs(l,m,xl,xl+xr)+dfs(m,r,xl+xr,xr)+(xl+xr)*a[m]);
	return res;
}
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d",&a[i]);
	printf("%lld\n",dfs(1,n,1,1)+a[1]+a[n]);
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
    
const int INF = 1001001001;

int f(int x, vi a, int n){
    int ans = 0;
    rep(i, n){
        ans += (a[i]+x-1)/x - 1;
    }
    return ans;
}

void Main(){
    int n, k; cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(rall(a));
    if(k == 0) {
        cout << a[0] << endl;
        return;
    }
    // x 等分するには (x-1) 回かかる
    int l = 0, r = INF;
    while(l + 1 != r){
        int m = (l + r) / 2;
        if(f(m, a, n) > k) l = m;
        else r = m;
    }

    cout << r << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 4828
#include<bits/stdc++.h>
#include<math.h>
#include<string.h>
#include<vector>
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define MAX_BIT 35
char S[MAX];
vector<int>first,second,third;
int counter[MAX];
int main()
{
    int N,K,C,i;
    scanf("%d %d %d ",&N,&K,&C);
    for(i=0;i<N;i++)
    {
        scanf("%c",&S[i]);
    }
    for(i=0;i<N&&first.size()<K;i++)
    {
        if(S[i]=='x') continue;
        if(first.size()==0)
        {
            first.push_back(i+1);
        }
        else if(i-first[first.size()-1]>=C)
        {
            first.push_back(i+1);
        }
    }
    //printf("L1 done!\n");
    for(i=N-1;i>=0&&second.size()<K;i--)
    {
        if(S[i]=='x') continue;
        if(second.size()==0)
        {
            second.push_back(i+1);
        }
        else if(second[second.size()-1]-i-2>=C)
        {
            second.push_back(i+1);
        }
    }
    //printf("L2 done %d %d!\n",first.size(),second.size());
    for(i=0;i<K;i++)
    {
        if(first[i]==second[K-1-i])
        {
            printf("%d\n",first[i]);
        }
    }
    //printf("L3 done!\n");
    /*for(i=1;i<MAX;i++)
    {
        if(counter[i]>1)
        {
            printf("%d\n",i);
        }
    }*/
    return 0;
}


Measured memory_bytes: 3444
/*
 *  連立方程式
        ax + by = c
        dx + ey = f
	の解、x, y を出力して終了するプログラムを作成して下さい。
	a, b, c, d, e, f はそれぞれ、 -1000 以上 1000 以下の実数とし、連立方程式の解が一意に存在するように与えれれるものとします。
	
	Input
	複数のデータセットが与えられます。入力の最後まで処理して下さい。１つのデータセットが１行に与えられます。
	１つのデータセットに a, b, c, d, e, f が１つのスペースで区切られて与えられます。
	
	Output
	各データセットに対して、x, y を１つのスペースで区切って１行に出力して下さい。
	各値は小数点以下第３位まで出力して下さい。小数点以下第４位を四捨五入して下さい。 
	
	ｘ，ｙは以下の解法で求める
	x = (ce - fb) / (ae -bd)
	y = (cd - fa) / (bd - ae)

 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;


public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = null;
		
		try {
			while((line = br.readLine()) != null) {
				line = line.trim();
				String[] values = line.split("\\s");
				if(values.length != 6) System.exit(-1);
				double[] value = new double[6];
				int i = 0;
				for(String s : values) {
					value[i] = Integer.parseInt(s);
					if(value[i] < -1000 || value[i] > 1000) System.exit(-1);
					i++;
				}
				
				double a = value[0];
				double b = value[1];
				double c = value[2];
				double d = value[3];
				double e = value[4];
				double f = value[5];
				
				double x = (c*e - f*b) / (a*e - b*d);
				double y = (c*d - f*a) / (b*d - a*e);
				
				BigDecimal bdX = new BigDecimal(x);
				BigDecimal bdY = new BigDecimal(y);
				bdX = bdX.setScale(3, BigDecimal.ROUND_HALF_UP);
				bdY = bdY.setScale(3, BigDecimal.ROUND_HALF_UP);

				System.out.println(bdX + " " + bdY);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}

}

Measured memory_bytes: 16968
import java.util.Scanner;

public class Main  {

	public static  void main(String[] args) {
		Scanner sc = new Scanner(System.in); 
		double a, b, h, m;
	        a = sc.nextDouble();
	        b = sc.nextDouble();
	        h = sc.nextDouble();
	        m = sc.nextDouble();
	        
	        double a2 = 30 * h + m * 0.5;
	        double b2 = 6 * m;
	        
	        double c2 = Math.min(Math.abs(a2 - b2) , Math.abs(360 - (a2 - b2)));
	        double pi = c2 / 180 * Math.PI;
	        double tou = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi));
	        System.out.println(tou);
	
	}

}

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

using namespace std;

const int INF = 100000;

int dp[410][410], a[50], b[50], c[50];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, ma, mb;
	cin >> n >> ma >> mb;
	int asum = 0, bsum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
		asum += a[i];
		bsum += b[i];
	}

	for (int i = 0; i <= asum; i++) {
		for (int j = 0; j <= bsum; j++) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;

	for (int i = 0; i < n; i++) {
		for (int j = asum; j >= a[i]; j--) {
			for (int k = bsum; k >= b[i]; k--) {
				if (dp[j - a[i]][k - b[i]] == INF) continue;
				dp[j][k] = min(dp[j][k], dp[j - a[i]][k - b[i]] + c[i]);
			}
		}
	}

	int ans = INF;
	for (int i = 1; ma * i <= asum && mb * i <= bsum; i++) {
		if (dp[ma * i][mb * i] == -1) continue;
		ans = min(ans, dp[ma * i][mb * i]);
	}
	cout << (ans == INF ? -1 : ans) << endl;
	return 0;
}

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

int main() {
	int x, y;

	//input
	std::cin >> x >> y;

	int max = std::max(x, y);
	int min = std::min(x, y);
	int count = 0;

	for (int L10 = min; L10 <= max; L10++)
	{
		std::string str = std::to_string(L10);

		if (str[1] != str[3])
			continue;
		if (str[0] != str[4])
			continue;
		//is same!
		count++;
	}
	std::cout << count << std::endl;
	
}

Measured memory_bytes: 256
use std::cmp::min;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let s: Vec<Vec<_>> = (0..n).map(|_| sc.chars()).collect();
    if s.iter().all(|s| s.iter().all(|&c| c == '.')) {
        println!("-1");
        return;
    }

    let mut r_min = n;
    for r in 0..n {
        let white = s[r].iter().filter(|&&c| c == '.').count();
        let filler = if (0..n).find(|&i| s[i][r] == '#').is_some() {
            0
        } else {
            1
        };
        r_min = min(r_min, white + filler);
    }

    let mut c_count = 0;
    for c in 0..n {
        if (0..n).any(|r| s[r][c] == '.') {
            c_count += 1;
        }
    }

    println!("{}", r_min + c_count);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
while True:
    m, f, r = map(int, input().split())
    if m == f == r ==-1:
        break
    s = m+f
    if m == -1 or f == -1 or s <30:
        print("F")
    elif s>= 80:
        print("A")
    elif 65<=s<80:
        print("B")
    elif 50<=s<65:
        print("C")
    elif 30<=s<50:
        if r>=50:
            print("C")
        else:
            print("D")


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_ ; ++i)
#define drep(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_ ; --i)
#define clear(a, b) memset((a), (b), sizeof(a))
typedef long long LL;
int read() {
	int x = 0, flag = 1;
	char ch = getchar();
	while(!isdigit(ch)) {
		if(ch == '-') flag = -1;
		ch = getchar();
	}
	while(isdigit(ch)) {
		x = (x << 3) + (x << 1) + (ch - 0x30);
		ch = getchar();
	}
	return flag * x;
}
 
#define Maxn 100009
int n, p[Maxn];
int c[Maxn], a[Maxn], b[Maxn];
int main() {
#ifdef Qrsikno
	freopen("j.in","r",stdin);
	freopen("j.out","w",stdout);
#endif
	n = read();
	rep(i, 1, n) c[read()] = i;
	rep(i, 1, n) printf("%d ", n * i);
	puts("");
	rep(i, 1, n) printf("%d ", n * (n - i) + c[i]);
	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <algorithm>

int main() {
	int N;
	scanf("%d\n", &N);
	int L[2 * 10 * 10 * 10];
	for (int i = 0; i < N; i++) {
		scanf("%d", &L[i]);
	}
	std::sort(L, L + N, [](const int& x, const int& y) {return x > y; });
	//L[0]が最も大きい


	int count = 0;

	for (int i = 0; i < N; i++) {
		int a = L[i];
		for (int j = 0; j < i; j++) {
			int b = L[j];
			for (int k = j-1; 0 <= k; k--) {
				int c = L[k];
				//常にk<j<iよりc>b>a
				//kはだんだん小さくなり、cはだんだん大きくなる

				if (c >= a + b)break;
				//if (a >= b + c)continue; 不要
				//if (b >= a + c)continue; 不要

				count++;

			}
		}
	}

	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

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

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

int main()
{
    ll n, X;
    cin >> n >> X;
    vector<ll> x(n);
    ll res = 0;
    rep(i,n) {
        ll x;
        cin >> x;
        res = gcd(res, abs(x - X));
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m,c = LI()
b = LI()
ans = 0
for i in range(n):
    a = LI()
    tmp = c
    for j in range(m):
        tmp += a[j]*b[j]
    if tmp > 0:
        ans += 1
print(ans)

Measured memory_bytes: 38384