akhauriyash/Code-Regression huggingface dataset:
// Contest: AtCoder Beginner Contest 176 (https://atcoder.jp/contests/abc176)
// Problem: A: Takoyaki (https://atcoder.jp/contests/abc176/tasks/abc176_a)


// region boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion

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

    int n, x, t; cin >> n >> x >> t;
    cout << ((n + x - 1) / x * t) << '\n';

    return 0;
}


Measured memory_bytes: 3540
from os import path
if(path.exists('C:/Users/prana/Desktop/sublime/input.txt')):
    import sys
    sys.stdin = open("C:/Users/prana/Desktop/sublime/input.txt","r")
    sys.stdout = open("C:/Users/prana/Desktop/sublime/output.txt","w")

from math import gcd
def solve():
    ans = 0
    a = int(input()) 
    for i in range(a):
        for j in range(a):
            for k in range(a):
                ans += gcd(k+1,gcd(i+1,j+1))
    print(ans)

test_case = 1
while(test_case):
    solve()
    test_case -= 1

Measured memory_bytes: 9164
#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 = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;
int n;
int calc(VL &x, VL &y, ll dx, ll dy)
{
    map<pair<int, int>, int> mp;

    rep(i, n)
    {
        mp[{x[i], y[i]}] = i;
    }
    VI next(100, -1);
    VI par(100, -1);
    rep(i, n)
    {
        if (mp.count({x[i] + dx, y[i] + dy}) != 0)
        {
            int q = mp[{x[i] + dx, y[i] + dy}];
            next[i] = q;
            par[q] = i;
        }
    }
    int ret = 0;
    map<int, bool> used;
    rep(i, n)
    {
        int cur = i;
        while (par[cur] != -1)
        {
            cur = par[cur];
        }
        assert(cur != -1);
        if (used[cur])
            continue;
        used[cur] = true;
        ret++;
    }
    return ret;
}

int main()
{
    cin >> n;
    VL x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    if (n == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    int ans = IINF;
    rep(i, n) rep(j, n)
    {
        if (i == j)
            continue;
        ll dx = x[i] - x[j];
        ll dy = y[i] - y[j];
        chmin(ans, calc(x, y, dx, dy));
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



//----------//


int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    ll h, w;
    cin >> h >> w;
    vector<vector<ll> > vv(h, vector<ll>(w));
    rep(i, h){
        rep(j, w){
            cin >> vv[i][j];
        }
    }



    ll ans = 0;
    vector<vector<ll> > ans2;
    rep(i, h){
        if(i % 2 == 0){
            rep(j, w){
                if(i==h-1 && j==w-1)break;
                if(vv[i][j] % 2 == 1){
                    ans++;
                    vv[i][j]--;
                    vector<ll> tmp;
                    if(j != w-1){
                        vv[i][j+1]++;
                        tmp.push_back(i+1);
                        tmp.push_back(j+1);
                        tmp.push_back(i+1);
                        tmp.push_back(j+2);
                    }else{
                        vv[i+1][j]++;
                        tmp.push_back(i+1);
                        tmp.push_back(j+1);
                        tmp.push_back(i+2);
                        tmp.push_back(j+1);
                    }
                    ans2.push_back(tmp);
                }
            }
        }
        else{
            for(ll j=w-1LL; j>=0; j--){
                if(i==h-1 && j==0)break;
                if(vv[i][j] % 2 == 1){
                    ans++;
                    vv[i][j]--;
                    vector<ll> tmp;
                    if(j != 0){
                        vv[i][j-1]++;
                        tmp.push_back(i+1);
                        tmp.push_back(j+1);
                        tmp.push_back(i+1);
                        tmp.push_back(j);
                    }else{
                        vv[i+1][j]++;
                        tmp.push_back(i+1);
                        tmp.push_back(j+1);
                        tmp.push_back(i+2);
                        tmp.push_back(j+1);
                    }
                    ans2.push_back(tmp);
                }
            }
        }
    }

    print(ans);
    print(ans2);
    
    
    return 0;
}


Measured memory_bytes: 21680
S = list(input())

pat1 = 0
pat2 = 1
ans1 = 0
ans2 = 0

for s in S:

    if not s == str(pat1):
        ans1 += 1
    elif not s == str(pat2):
        ans2 += 1
    pat1 = abs(pat1-1)
    pat2 = abs(pat2-1)
print(min(ans1,ans2))

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

int main(){
  int n;cin>>n;
  bitset<30> su;
  vector<bitset<30>> a(n);
  for(int i=0;i<n;i++){
    int an;cin>>an;
    bitset<30> ab(an);
    su^=ab;
    a[i]=ab;
  }
  
  for(int i=0;i<n;i++){
    bitset<30> aaa;
    aaa=a[i];
    aaa^=su;
    cout<<aaa.to_ullong()<<" ";
  }
  cout<<endl;
  
  return 0;
}

Measured memory_bytes: 4672
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define itn int
using ll = long long;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


const int MAX = 100005;
const int NIL = -1;

struct Node {
	int parent;
	int left;
	int right;
};


Node T[MAX];
int n, D[MAX];

void print(int u) {
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].parent << ", ";
	cout << "depth = " << D[u] << ", ";
	if (T[u].parent == NIL) cout << "root, ";
	else if (T[u].left == NIL)cout << "leaf, ";
	else cout << "internal node, ";

	cout << '[';
	for (i = 0, c = T[u].left; c != NIL; i++, c = T[c].right) {
		if (i) cout << ", ";
		cout << c;
	}
	cout << ']' << endl;
}

void rec(int u, int p) {
	D[u] = p;
	if (T[u].right != NIL) rec(T[u].right, p);
	if (T[u].left != NIL) rec(T[u].left, p + 1);
}

signed main() {
	int i, j, d, v, c, l, r;
	cin >> n;
	rep(i, n) T[i].parent = T[i].left = T[i].right = NIL;
	rep(i, n) {
		cin >> v >> d;
		rep(j, d) {
			cin >> c;
			if (j == 0) T[v].left  = c;
			else T[l].right = c;
			l = c;
			T[c].parent = v;
		}
	}
	rep(i, n) {
		if (T[i].parent == NIL) r = i;
	}
	rec(r, 0);
	rep(i, n) print(i);
	return 0;
}




Measured memory_bytes: 7780
import sys
input = sys.stdin.buffer.readline

N = int(input())
A = list(map(int, (input().split())))

lst = []
small, large = 0, 0
for i in range(N):
    if i==0:
        small = A[i]
        large = A[i]
    else:
        if A[i] < large:
            if small < large:
                lst.append((small,large))
            small = A[i]
            large = A[i]
        else:
            large = A[i]
else:
    if small < large:
        lst.append((small,large))
# print(lst)
ans = 1000
for s, l in lst:
    stock, ans = divmod(ans, s)
    ans += stock * l
print(ans)

Measured memory_bytes: 9268
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int n, p[22], a[3];

void solve()
{
    cin >> n; for (int i=0; i<n; i++) cin >> p[i];
    int ans=0;
    for (int i=1; i<n-1; i++) {
        a[0] = p[i-1];
        a[1] = p[i];
        a[2] = p[i+1];
        sort(a,a+3);
        if (a[1]==p[i]) {
            //sout(p[i]);
            ans++;
        }
    }nout(ans);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
/* 
 * Project: AtCoder Beginners Contest 086 B - Two Anagrams
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/06/01
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string s;
string t;

void solve() {

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if (s < t)
        printf("Yes\n");
    else
        printf("No\n");

}

int main() {

    cin >> s >> t;

    solve();

}

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

int main()
{
    priority_queue<pair<int, int> > pq;
    int n, m;
    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        int coin, num;
        scanf("%d %d", &coin, &num);

        pq.push({-coin, num});
    }

    ll cnt = 0;
    ll koyta_nilam = 0;
    while (!pq.empty()) {
        auto tmp = pq.top();
        pq.pop();

        int curcoin = -tmp.first;
        int curnum = tmp.second;

        if (curnum + koyta_nilam > m) cnt += ((m - koyta_nilam) * (ll)curcoin), koyta_nilam = m;
        else cnt += (ll)curnum * curcoin, koyta_nilam += curnum;

        if (koyta_nilam == m) break;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 1400
import sys 
import math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 **18
A,B = read().split()
#Bをint型にする
B = int(float(B)*100 + 0.5)
ans = int(A)*B
print(ans//100)

Measured memory_bytes: 9036
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int N, X;
vector<int> vec;

//解法
void solve() {

	int minn = 1001;
	rep(i, N) {
		X -= vec[i];
		minn = min(minn, vec[i]);
	}
	cout << N + X / minn;

	return;
}

int main() {
	//入力
	cin >> N >> X;
	vec.resize(N);
	rep(i, N) cin >> vec[i];
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int n,a,b;
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	if(abs(a-b)&1)printf("Borys\n");
	else printf("Alice\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,d;cin>>n>>d;
    ll ans = 0;
    rep(i,n){
        ll x,y;cin>>x>>y;
        if(x*x+y*y<=d*d)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <set>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;

const int ms = 200005;
int n;
string s;

bool check(int m)
{
    map<string, int>t;
    for (int i = 0; i + m <= n; ++i)
    {
        string st = s.substr(i, m);
        if (t.count(st) == 1)
        {
            if (t[st] <= i)
                return  true;
            continue;
        }
        t[st] = i + m;
    }
    return false;
}
int main()
{
    cin >> n;
    cin >> s;
    int l = 0, r = n + 1, mid, res = 0;
    while (l <= r)
    {
        mid = (l + r) / 2;
        if (check(mid))
        {
            res = max(res, mid);
            l = mid + 1;
        }
        else
        {
            r = mid - 1;
        }
    }
    cout << res;
}

Measured memory_bytes: 6672
#include<iostream>
#include<algorithm>
#include<vector>
#include<limits>
#include<cmath>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin >> N;
	vector<int>X(N);
	for (int i = 0; i < N; i++){
		cin >> X[i];
	}
	int ans = 1e9;
	for (int i = 1; i <= 100; i++){
		int tmp = 0;
		for (int j = 0; j < N; j++) {
			tmp += pow(X[j] - i, 2);
		}
		ans = min(ans, tmp);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=55;
const int mo=1000000007;
int f[N][N*2];
int C[N][N];
int n;
int main(){
	scanf("%d",&n);
	For(i,0,N-1) C[i][0]=1;
	For(i,1,N-1) For(j,1,i)
		C[i][j]=(C[i-1][j]+C[i-1][j-1])%mo;
	f[1][N]=f[1][N-1]=1;
	For(i,1,n) For(j,-i,i) if (f[i][N+j])
		For(k,0,n-i) For(l,0,n-i-k) if (k+l>=abs(j)&&(j-k+l)%2==0&&(k+l)!=0)
			f[i+k+l][(j-k+l+2*N)/2]=(f[i+k+l][(j-k+l+2*N)/2]+1ll*f[i][N+j]*C[i+k+l][k]%mo*C[i+l][l])%mo;
	printf("%d\n",f[n][N]);
}

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

using namespace std;

int main()
{
    string S;
    string T;
    cin >> S >> T;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] != T[i]) {
            cout << "No" << '\n';
            return 0;
        }
    }
    cout << "Yes" << '\n';
    return 0;
}

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

class Root {
    public:
    char ob;
    bool mitou = false;
};

class Zahyo {
    public:
    int x,y;
    void set(int x, int y) {
        this->x = x;
        this->y = y;
    }
};

int main() {
    int H,W,Ch,Cw,Dh,Dw,warp = 0;
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    vector<vector<Root>> S(H,vector<Root>(W));
    list<Zahyo> next1,next2;
    Zahyo k;
    vector<Zahyo> move(4);
    move.at(0).set(1,0); move.at(1).set(0,1); move.at(2).set(-1,0); move.at(3).set(0,-1);

    for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j){
            char c;
            cin >> c;
            S.at(i).at(j).ob = c;
        }
    }

    --Ch; --Cw; --Dh; --Dw;
    k.set(Cw, Ch);
    S.at(Ch).at(Cw).mitou = true;
    next1.push_back(k);

    while(!next1.empty()) {
        bool goal = false;
        
        while(!next1.empty()) {
            
            list<Zahyo>::iterator itr = next1.begin();
            for(int i = 0; i < 4; ++i) {
                int X,Y;
                X = (*itr).x + move.at(i).x; Y = (*itr).y + move.at(i).y;
                if(X == Dw && Y == Dh) {
                    goal = true;
                    S.at(Y).at(X).mitou = true;
                    break;
                }
                if(X >= 0 && X < W && Y >= 0 && Y < H) {
                    
                    if(S.at(Y).at(X).ob == '#') {
                        Zahyo k2 = *itr;
                        next2.push_back(k2); 
                    } else if(S.at(Y).at(X).ob == '.' && S.at(Y).at(X).mitou == false) {
                        Zahyo k2; k2.x = X; k2.y = Y;
                        next1.push_back(k2);
                        S.at(Y).at(X).mitou = true;
                    }
                }
            }
            next1.pop_front();
            if(goal) break;
        }

        if(goal) break;

        for(list<Zahyo>::iterator itr = next2.begin(); itr != next2.end(); ++itr) {
            for(int i = -2; i < 3; ++i) {
                for(int j = -2; j < 3; ++j) {
                    
                    int X = (*itr).x + j, Y = (*itr).y + i;
                    if(X == Dw && Y == Dh) {
                        goal = true;
                        S.at(Y).at(X).mitou = true;
                        break;
                    }
                    if(X >= 0 && X < W && Y >= 0 && Y < H) {
                        if(S.at(Y).at(X).ob == '.' && S.at(Y).at(X).mitou == false) {
                            Zahyo k2; k2.x = X; k2.y = Y;
                            next1.push_back(k2);
                            S.at(Y).at(X).mitou = true;
                        }
                    }
                }
                if(goal) break;
            }
            if(goal) break;
        }
        ++warp;
        if(goal) break;
        next2.clear();
    }

    
    if(S.at(Dh).at(Dw).mitou) cout << warp << endl;
    else cout << -1 << endl;
}

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

using namespace std;

pair<uint64_t, uint64_t> farthest(uint64_t N, map<uint64_t, set<uint64_t>> &edges, uint64_t src)
{
  vector<bool> visited(N, false);
  
  stack<pair<uint64_t, uint64_t>> s;
  s.emplace(src, 0);
  
  uint64_t max_len = 0, max_len_node = 0;
  while (!s.empty()) {
    pair<uint64_t, uint64_t> p = s.top(); s.pop();
    
    if (visited[p.first]) { continue; }
    
    visited[p.first] = true;
    
    if (max_len < p.second) {
      max_len_node = p.first;
      max_len      = p.second;
    }
    
    for (uint64_t next : edges[p.first]) {
      if (!visited[next]) {
        s.emplace(next, p.second + 1);
      }
    }
  }
  return make_pair(max_len_node, max_len);
}

int main()
{
  uint64_t N;
  cin >> N;
  
  map<uint64_t, set<uint64_t>> edges;
  for (uint64_t n = 0; n < N; ++n) {
    edges.emplace(n, set<uint64_t>());
  }
  
  for (uint64_t n = 0; n < N - 1; ++n) {
    uint64_t a, b;
    cin >> a >> b;
    
    edges[a - 1].insert(b - 1);
    edges[b - 1].insert(a - 1);
  }
  
  pair<uint64_t, uint64_t> pu = farthest(N, edges, 0);
  pair<uint64_t, uint64_t> pv = farthest(N, edges, pu.first);
  
  uint64_t diameter = pv.second;
  
  cout << ((diameter % 3) != 1 ? "First" : "Second") << endl;
  
  return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n;cin >>n;
    ll ans;
    ans=n*(n-1)/2;
    cout <<ans <<endl;
    return 0;
}



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

int main() {
	
	string s,t;
    cin >> s >> t;
    int maximam = 0;
    for(int i = 0;i <= s.size() - t.size(); ++i) {
        int c = 0;
        for(int j = 0; j < t.size(); j++) {
            if(s[i+j] == t[j]) c++;
        }
        maximam = max(maximam, c);
    }
    cout << t.size() - maximam << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, ns, ne) for (int i = ns; i < ne; ++i)
using namespace std;

int main() {
  string s;
  cin >> s;
  unsigned long long sum;
  rep(i, 0, s.size()) { sum += s[i] - '0'; }
  cout << ((sum % 9) ? "No" : "Yes") << endl;
  getchar();
}

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

int main(){
  int t,d,l;
  while(cin >> t >> d >> l,t){
    int wave[t];
    for(int i=0; i<t; ++i){
      cin >> wave[i];
    }
    int ans=0,last=-1;
    for(int i=0; i<t; ++i){
      if(i-d <= last && last >=0)ans++;
      if(wave[i]>=l)last = i;
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3496
#include<iostream>
using namespace std;
#define FILEIN freopen("input.txt", "r", stdin)
 
int main(){
    // FILEIN;
 	int n; cin>>n;
  	int ar[n] = {};
  	for(int i = 0; i<n; i++){
     	 cin>>ar[i];
    }
  	int max1 = ar[0];
  	int dp[n] = {};
  	dp[0] = 1;
  	for(int i = 1; i<n; i++){
    	if(ar[i] <= max1){
          	dp[i] = dp[i-1] + 1;
        }else{
          dp[i] = dp[i-1];
        }
      	max1 = min(max1, ar[i]);
  	}
  	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pi 3.14159265358979
using namespace std;

void C() {
	double A, B, H, M; cin >> A >> B >> H >> M;

	double vhour_hand, vmin_hand;
	vhour_hand = 2 * pi / 12 / 60;
	vmin_hand = 2 * pi / 60;
	double time = 60 * H + M;

	double temp = vmin_hand * time - vhour_hand * time;
	temp = max(temp, -temp);
	temp = fmod(temp, 2 * pi);
	double diff = min(temp, 2 * pi - temp);

	double ans = sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(diff));

	
	printf("%.10f\n", ans);
}

void B() {
	int K; cin >> K;
	string s; cin >> s;

	if (s.size() > K) {
		string temp = s.substr(0, K);
		temp += "...";
		cout << temp << endl;
	}
	else {
		cout << s << endl;
	}
}

void A() {
	int N; cin >> N;
	int dig = N % 10;
	if (dig == 3) {
		cout << "bon" << endl;
	}
	else if (dig == 0 or dig == 1 or dig == 6 or dig == 8) {
		cout << "pon" << endl;
	}
	else {
		cout << "hon" << endl;
	}
}
int main() {
	C();
}

Measured memory_bytes: 4232
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = F()
    nn = n**2
    r = n * (2**0.5)
    for i in range(int(n)+1):
        kk = nn - i**2
        if kk < 0:
            break
        k = kk ** 0.5
        tr = i + k
        if k < 1:
            tr += 1-k
        if r < tr:
            r = tr

    return r


print(main())




Measured memory_bytes: 9044
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n;
		n = sc.nextInt() + 2;
		int[] a = new int[n];
		for (int i = 1; i < n - 1; i++) {
			a[i] = sc.nextInt();
		}
		a[0] = 0;
		a[n - 1] = 0;
		/*
		for(int b : a) {
			System.out.print(b);
		}*/
		int dist = 0;
		for (int i = 1; i < n; i++) {
			dist += Math.abs(a[i - 1] - a[i]);
		}
		//System.out.print(dist);

		for (int i = 1; i < n - 1; i++) {
			System.out.println(dist - Math.abs(a[i - 1] - a[i]) - Math.abs(a[i] - a[i + 1]) + Math.abs(a[i + 1] - a[i - 1]));
		}
	}
}

Measured memory_bytes: 63212
#include <iostream>
using namespace std;
int main(void){
	string a;
	int b; b=0;
	cin>>a;
	if (a[0]=='1'){
		b++;
	}
	if (a[1]=='1'){
		b++;
	}
	if (a[2]=='1'){
		b++;
	}
	cout<<b<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	vector<pair<int, int>> a(n);
	rep(i,n){
		int x;
		cin >> x;
		a[i] = make_pair(x, i + 1);
	}
	sort(all(a));

	rep(i,n){
		if(i) cout << ' ';
		cout << a[i].second;
	}
	cout << endl;
}


Measured memory_bytes: 2432
/*
      author  : nishi5451
      created : 15.08.2020 10:42:10
*/

#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,x;
    cin >> n >> x;
    int now = 0;
    for(int i=1; i<=n; i++){
        int l;
        cin >> l;
        if(now+l > x){
            cout << i << endl;
            return 0;
        }
        now += l;
    }
    cout << n+1 << endl;
    return 0;
}

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

using namespace std;
using i64 = std::int_fast64_t;

const i64 INF = (i64)1 << 59;

template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, W;
  cin >> N >> W;
  vector<i64> weight(N), value(N);
  for (int i = 0; i < N; i++) {
    cin >> weight[i] >> value[i];
  }

  vector<vector<i64>> dp(N + 1, vector<i64>((int)1e5 + 1, INF));
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < (int)1e5 + 1; j++) {
      if (j - value[i] >= 0)
        chmin(dp[i + 1][j], dp[i][j - value[i]] + weight[i]);
      chmin(dp[i + 1][j], dp[i][j]);
    }
  }

  int res = 0;
  for (int i = 0; i < (int)1e5 + 1; i++) {
    if (dp[N][i] <= W) res = max(res, i);
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
signed main() {
    int n,k;
    cin >> n>>k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int cnt =0;
    rep(i,n) {
        FOR(j,i+1,n) {
            if(a[i]>a[j]) {
                cnt++;
            }
        }
    }
    int ans = cnt*k;
    ans %=mod;
    cnt=0;
    rep(i,n) {
        rep(j,n) {
            if(a[i]<a[j]) {
                cnt++;
            }
        }
    }
    int tmp = k*(k-1)/2;
    tmp %= mod;
    tmp *= cnt;
    tmp %= mod;
     ans += tmp;
    cout << ans%mod << endl;



  return 0;
}



Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

using namespace std;

int ans,ans2;
int n,m;

signed main(){

    cin>>n>>m;
    for(int i=m-n+1;i<=m+n-1;i++){
        cout<<i<<" ";
    }
    cout<<endl;

}

Measured memory_bytes: 256
import sys
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.sort()
y.sort()
for i in range(x[-1]+1,y[0]+1):
    if X<i and Y>=i:
        print("No War")
        sys.exit()
print("War")

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

signed main(){
	int H, W, K;
	scanf("%d %d %d", &H, &W, &K);
	vector<vector<char> > c(H, vector<char> (W));
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++) cin >> c[i][j];
	}
	vector<vector<char> > c1 = c;
	int ans = 0;

	for(int tate = 0; tate < (1 << H); tate++){
		for(int yoko = 0; yoko < (1 << W); yoko++){
			for(int i = 0; i < H; i++){
				if(tate & (1 << i)){
					for(int j = 0; j < W; j++) c[i][j] = 'x';
				}
			}
			for(int j = 0; j < W; j++){
				if(yoko & (1 << j)){
					for(int i = 0; i < H; i++) c[i][j] = 'x';
				}
			}
			int tmp = 0;
			for(int i = 0; i < H; i++){
				for(int j = 0; j < W; j++) if(c[i][j] == '#') tmp++;
			}
			if(tmp == K) ans++;
			c = c1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3700
use std::io::*;
use std::str::FromStr;

fn parse_line<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn parse_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let line = parse_line::<String>();
    let mut iter = line.split_whitespace();
    (
        iter.next().unwrap().parse().ok().unwrap(),
        iter.next().unwrap().parse().ok().unwrap(),
    )
}

fn println<T: ToString>(s: T) {
    println!("{}", s.to_string());
}

// ------------------------------------------------------------------------

use std::cmp::min;

fn main() {
    let (a, b) = parse_pair::<i32, i32>();

    let diff = (a - b).abs();

    if diff & 1 == 1 {
        println("IMPOSSIBLE");
    } else {
        println(min(a, b) + diff / 2);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <algorithm>
#include <tuple>

int main()
{
	int n[4] = { 0, 0, 0, 0 };
	for (int i = 0; i < 6; ++i) {
		int x;
		std::cin >> x;
		++n[x-1];
	}

	int num1 = 0;
	int num2 = 0;
	for (int m : n) {
		if (m == 1)
			++num1;
		else if (m == 2)
			++num2;
	}

	if (num1 == 2 && num2 == 2)
		std::cout << "YES\n";
	else
		std::cout << "NO\n";
}


Measured memory_bytes: 256
N = gets.chomp.to_i
Hn = gets.chomp.split(' ').map(&:to_i)[0...N]

(N-1).downto(1) do |i|
  Hn[i-1] -= 1 if Hn[i-1] > Hn[i]
end

top = 0
is_ng = false
Hn.reduce do |prev, curr|
  break is_ng = true if curr < prev
  top = prev
  curr
end
 
puts is_ng ? 'No' : 'Yes'


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

struct Dat{
	int x; double d;
	bool operator<(const Dat &oth) const {
		return d > oth.d;
	}
};

const double inf = 1e10;
int n, x[1010], y[1010], r[1010];
double c[1010][1010], md[1010];
priority_queue<Dat> pq;

int main(){
	scanf("%d%d%d%d%d", x, y, x + 1, y + 1, &n);
	x[n + 1] = x[1]; y[n + 1] = y[1];
	for(int i = 1; i <= n; i++) scanf("%d%d%d", x + i, y + i, r + i);
	for(int i = 0; i <= n; i++){
		for(int j = i + 1; j <= n + 1; j++){
			c[i][j] = c[j][i] = max(0.0, hypot(x[i] - x[j], y[i] - y[j]) - r[i] - r[j]);
		}
	}
	fill(md + 1, md + n + 2, inf);
	pq.push({0, 0});
	while(!pq.empty()){
		Dat cur = pq.top(); pq.pop();
		for(int i = 0; i <= n + 1; i++){
			if(md[i] > cur.d + c[cur.x][i]){
				md[i] = cur.d + c[cur.x][i];
				pq.push({i, md[i]});
			}
		}
	}
	printf("%.12f\n", md[n + 1]);
}

Measured memory_bytes: 13808
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll a, b, c;
    cin >> a >> b >> c;
    if (c - a - b <= 0) {
        cout << "No\n";
        return 0;
    }

    ll d = c - a - b;
    if (4*a*b < d*d) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

X = int(input())

while not is_prime(X):
    X += 1

print(X)

Measured memory_bytes: 38768
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<bitset>
#include<map>
#include<vector>
#include<set>
#define ll long long
#define db double
#define si short int
#define mem(a) memset(a,0,sizeof(a))
#define maxn 300005
#define maxm
#define inf 0x7fffffff
#define mod 1000000007
#define eps
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
using namespace std;
ll read(){
	ll a=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){a=a*10+c-'0';c=getchar();}
	return a*f;
}
ll n,a[maxn],v[65][maxn],s[65][maxn];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	for(int i=0;i<60;i++){
		for(int j=1;j<=n;j++){
			v[i][j]=(a[j]>>i)&1;
		}
	}
	for(int i=0;i<=60;i++){
		for(int j=n;j>=1;j--){
			s[i][j]=s[i][j+1]+v[i][j];
		}
	}
	ll tmp,ans=0;
	for(int i=0;i<=60;i++){
		tmp=(1LL<<i)%mod;
		for(int j=1;j<n;j++){
			if(v[i][j]==1){
				(ans+=(n-j-s[i][j+1])*tmp)%=mod;
			}
			else {
				(ans+=s[i][j+1]*tmp)%=mod;
			}
		}
	}
//	for(int i=0;i<=2;i++){
//		for(int j=1;j<=n;j++){
//			cout<<s[i][j]<<" ";
//		}
//		cout<<endl;
//	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 290944
#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;

vector<int>E[700];
double dp[700];

int main(){
	int n,m;cin>>n>>m;
	rep(i,m){
		int s,t;scanf("%d%d",&s,&t);s--;t--;
		E[s].push_back(t);
	}
	double Min=INFINITY;
	rep(i,n-1){
		dp[n-1]=0;
		for(int j=n-2;j>=0;j--){
			double sum=0,Max=0;
			int cnt=0;
			for(int u:E[j]){
				sum+=dp[u]+1;
				Max=max(Max,dp[u]+1);
				cnt++;
			}
			if(j==i&&cnt>1){
				sum-=Max;cnt--;
			}
			dp[j]=sum/cnt;
		}
		Min=min(Min,dp[0]);
	}
	printf("%.12lf\n",Min);
}

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

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

    vector<pair<long long int,int>> x(n);
    for(int i=0; i<n; i++){
        cin >> x[i].first;
        x[i].first -= 1;
        x[i].second = i+1;
    }
    sort(x.begin(),x.end());

    vector<int> ans(n*n);
    long long int pos = 0;
    for(int i=0; i<n; i++){
        ans[x[i].first] = x[i].second;
        for(int j=1; j<x[i].second; j++){
            while(ans[pos] != 0) pos += 1;
            if(pos > x[i].first){
                cout << "No" << endl;
                return 0;
            }
            ans[pos] = x[i].second;
        }
    }

    reverse(x.begin(),x.end());
    pos = n*n-1;
    for(int i=0; i<n; i++){
        for(int j=0; j<n-x[i].second; j++){
            while(ans[pos] != 0) pos -= 1;
            if(pos < x[i].first){
                cout << "No" << endl;
                return 0;
            }
            ans[pos] = x[i].second;
        }
    }

    cout << "Yes" << endl;
    for(int i=0; i<n*n; i++){
        cout << ans[i];
        if(i == n*n-1) break;
        cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4288
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0
for i in range(n):
    if a[i] < b[i]:
        if a[i] + a[i + 1] <= b[i]:
            res += a[i] + a[i + 1]
            a[i + 1] = 0
        else:
            res += b[i]
            a[i + 1] -= b[i] - a[i]
    else:
        res += b[i]
print(res)


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  ll sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  sum/=n;
  ll ans=0;
  
  rep(i,n){
    ans+=(a[i]-sum)*(a[i]-sum);
  }
  sum++;
  ll tmp=0;
  rep(i,n){
    tmp+=(a[i]-sum)*(a[i]-sum);
  }
  chmin(ans,tmp);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) = abc159a()

fun abc159a() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }

    var answer = 0

    for (i in 0 until n) answer += i
    for (i in 0 until m) answer += i

    println(answer)
}


Measured memory_bytes: 38128
def main():
    n,k = map(int,input().split())
    ls = list(input())
    now = ls[0]
    same = 0
    dif = 0
    for i in range(1,n):
        if now == ls[i]:
            same += 1
        else:
            dif += 1
        now = ls[i]
    ans = same + min(dif,k*2)
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 49392
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, n);

  cout << (n - 1) / 2 << endl;

  return 0;
}

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

int main(void) {
    for(int r = 1; r <= 9; r++) {
        for(int c = 1; c <= 9; c++) {
            //assert(c > 9);
            cout << r << "x" << c << "=" << r * c << endl;
        }
    }
    return(0);
}

Measured memory_bytes: 1116
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  for(int i=0;i<n;i++){
    cin >> s[i] >> t[i];
  }
  string x;cin >> x;
  bool f=false;
  int ans=0;
  for(int i=0;i<n;i++){
    if(!f){
      if(s[i]==x){
        f=true;
      }
    }
    else{
      ans+=t[i];
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct edge {
  int to, cost;
  edge(){}
  edge(int to, int cost):to(to), cost(cost){}
};

using Graph = vector<vector<edge> >;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, m, s, t;
  cin >> n >> m >> s >> t;
  --s, --t;
  Graph graph(n);
  rep(i, m) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    --a, --b, --c;
    graph[a].emplace_back(b, d);
    graph[b].emplace_back(a, d);

    graph[b].emplace_back(c, d);
    graph[c].emplace_back(b, d);

    graph[c].emplace_back(a, d);
    graph[a].emplace_back(c, d);
  }
  priority_queue<Pi, vector<Pi>, greater<Pi> > que;
  vint mincost(n, inf);
  mincost[s] = 0;
  que.emplace(0, s);
  while(!que.empty()) {
    Pi p = que.top(); que.pop();
    int v = p.second;
    if(v == t) break;
    if(mincost[v] < p.first) continue;
    for(edge& e : graph[v]) {
      if(mincost[v]+e.cost < mincost[e.to]) {
	mincost[e.to] = mincost[v]+e.cost;
	que.emplace(mincost[e.to], e.to);
      }
    }
  }
  cout << mincost[t] << endl;


  return 0;
}



Measured memory_bytes: 23636
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

int main(void){
  fast_io
  int n;cin>>n;
  ll a[n];
  ll sum=0;
  rep(i,n){
    cin>>a[i];
    sum += a[i];
  }
  double hoge = sum * 1.0 / n;
  int ans = -1;
  double ansd = LINF;
  rep(i,n){
    double dist = a[i]-hoge>0?a[i]-hoge:hoge-a[i];
    if(dist < ansd){
      ansd = dist;
      ans = i;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
ans = 11
for i in range(1,n+1):
    if i*i > n:
        break
    else:
        if n % i != 0:
            continue
        else:
            a = i
            b = n//i
            tmp = max(len(str(a)),len(str(b)))
            ans = min(ans,tmp)
print(ans)

Measured memory_bytes: 3060