akhauriyash/Code-Regression huggingface dataset:
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-22 14:08:36
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n;
  vector<int> h(n); cin >> h;

  --h[0];

  for (int i = 1; i < n; ++i) {
    if (h[i] - 1 >= h[i -1]) --h[i];
  }

  debug(h);

  for (int i = 0; i < n - 1; ++i) {
    if (h[i] > h[i + 1]) {
      cout << "No" << endl; return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

int main() 
{
    int ans = 0;
    int n,m,c; cin >> n >> m >> c;
    vector<int> b(m); rep(i,m) { cin >> b[i]; }

    rep(i,n) {
        ll sum = 0;
        rep(j,m) {
            int a;
            cin >> a; 
            sum += a*b[j];
        }
        sum += c;
        if(sum > 0) { ans++; }
    }

    cout << ans << endl;

    return 0;
}




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

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>> s(H,vector<char>(W));
  vector<vector<int>> masu(H,vector<int>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>s.at(i).at(j);
      if(s.at(i).at(j)=='#'){
        masu.at(i).at(j)=-100;
      }else{
        masu.at(i).at(j)=0;
      }
    }
  }
  for(int i=1;i<H-1;i++){
    for(int j=1;j<W-1;j++){
      if(masu.at(i).at(j)<0){
        masu.at(i-1).at(j-1)++;
        masu.at(i).at(j-1)++;
        masu.at(i+1).at(j-1)++;
        masu.at(i-1).at(j)++;
        masu.at(i+1).at(j)++;
        masu.at(i-1).at(j+1)++;
        masu.at(i).at(j+1)++;
        masu.at(i+1).at(j+1)++;
      }
    }
  }
  for(int i=1;i<H-1;i++){
    if(masu.at(i).at(0)<0){
      masu.at(i-1).at(0)++;
      masu.at(i+1).at(0)++;
      if(W>1){
      masu.at(i).at(1)++;
      masu.at(i-1).at(1)++;
      masu.at(i+1).at(1)++;
      }
    }
    if(W>1){
    if(masu.at(i).at(W-1)<0){
      masu.at(i-1).at(W-1)++;
      masu.at(i+1).at(W-1)++;
      if(W>1){
      masu.at(i).at(W-2)++;
      masu.at(i-1).at(W-2)++;
      masu.at(i+1).at(W-2)++;
      }
    }
  }
  }
  for(int i=1;i<W-1;i++){
    if(masu.at(0).at(i)<0){
      masu.at(0).at(i-1)++;
      masu.at(0).at(i+1)++;
      if(H>1){
      masu.at(1).at(i)++;
      masu.at(1).at(i+1)++;
      masu.at(1).at(i-1)++;
      }
    }
    if(H>1){
    if(masu.at(H-1).at(i)<0){
      masu.at(H-1).at(i-1)++;
      masu.at(H-1).at(i+1)++;
      if(H>1){
      masu.at(H-2).at(i)++;
      masu.at(H-2).at(i-1)++;
      masu.at(H-2).at(i+1)++;}
    }
  }
  }
  if(masu.at(0).at(0)<0){
    if(W>1)masu.at(0).at(1)++;
    if(H>1)masu.at(1).at(0)++;
    if(H>1&&W>1)masu.at(1).at(1)++;
  }
  if(H>1&&W>1){
  if(masu.at(H-1).at(W-1)<0){
    if(H>1)masu.at(H-2).at(W-1)++;
    if(W>1)masu.at(H-1).at(W-2)++;
    if(H>1&&W>1)masu.at(H-2).at(W-2)++;
  }
  }
  if(H>1){
  if(masu.at(H-1).at(0)<0){
    if(H>1)masu.at(H-2).at(0)++;
    if(W>1){
    masu.at(H-1).at(1)++;
    if(H>1)masu.at(H-2).at(1)++;
    }
  }}
  if(W>1){
  if(masu.at(0).at(W-1)<0){
    if(W>1)masu.at(0).at(W-2)++;
    if(H>1){
    masu.at(1).at(W-1)++;
    if(W>1)masu.at(1).at(W-2)++;
    }
  }}
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(masu.at(i).at(j)>=0){
        cout<<masu.at(i).at(j);
      }else{
        cout<<'#';
      }
    }
    cout<<endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}

int dp[222222];
int S[222222];
int a[222222];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	dp[0]=1;
	S[a[1]]=1;
	for(int i=1;i<=n;i++)
	{
		dp[i]=S[a[i]];
		if(i<n&&a[i+1]!=a[i])
		{
			S[a[i+1]]=add(S[a[i+1]],dp[i]);
		}
	}
	cout<<dp[n]<<'\n';
}


Measured memory_bytes: 2560
#include<stdio.h>
int main()
{
	int n, k, s;
	scanf("%d %d %d", &n, &k, &s);
	int i;
	if (k == 0)
	{
		if (s < 1000000000)
		{
			printf("%d", s + 1);
			for (i = 1; i < n; i++)
				printf(" %d", s + 1);
		}
		else
		{
			printf("1");
			for (i = 1; i < n; i++)
				printf(" 1");
		}
		printf("\n");
	}
	else
	{
		printf("%d", s);
		for (i = 1; i < k; i++)
			printf(" %d", s);
		if (s < 1000000000)
			for (i = k; i < n; i++)
				printf(" %d", s + 1);
		else
			for (i = k; i < n; i++)
				printf(" 1");
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
string debug_string(const string& s){
	return '"' + s + '"';
}
string debug_string(bool b){
	return (b ? "true" : "false");
}
string debug_string(const char* s){
	return debug_string((string)s);
}
template<class T, class U>
string debug_string(const pair<T, U>& p);
template<class U>
struct can_be_string{
	template<typename...>
	static int f(...){
		return 0;
	}
	template<typename T>
	static char f(decltype(to_string(T()), char())) { 
		return 'a';
	}
	static const bool value = sizeof(f<U>(char())) == sizeof(char);
};
template<class T> 
typename enable_if<can_be_string<T>::value, string>::type debug_string(const T& a){
	string s = to_string(a);
	return s;
}
template<class T>
typename enable_if<!can_be_string<T>::value, string>::type debug_string(const T& a){
	bool first = true;
	string s = "{";
	for(const auto& x : a){
		if(!first){
			s += ", ";
		}
		first = false;
		s += debug_string(x);
	}
	s += "}";
	return s;
}
template<class T, class U>
string debug_string(const pair<T, U>& p){
	string s = "[";
	s += debug_string(p.first);
	s += ", ";
	s += debug_string(p.second);
	s += "]";
	return s;
}
void debug_out(){cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail){
	cerr << ' ' << debug_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18l + 100;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b / a, c) << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

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

ll gcd(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    while (m != n)
    {
        if (m > n)
            m = m - n;
        else
            n = n - m;
    }
    return m;
}

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int main(){
    double T,X;
    cin >> T >> X;

    double ans;

    ans = T/X;

    printf("%lf\n", ans);

    return 0;
}

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

n = int(input())

ans = 0
for i in range((len(str(n))+1)//2):
    num = 10**(2*i)
    line = num*10-1
    # print(num)
    # print(line)
    # print()

    if n-line >= 0:
        ans += num*9
    else:
        ans += n-num+1

print(ans)
# n-num
# 9, 900
# if
# 1, 100, 10000


Measured memory_bytes: 2940
h, w = map(int, input().split())
s = [[''] * (w + 2)]
s += [[''] + list(input()) + [''] for _ in range(h)]
s += [[''] * (w + 2)]
m = [[1] * (w + 2)]
m += [[1] + [0] * w + [1] for _ in range(h)]
m += [[1] * (w + 2) for _ in range(h + 2)]
ans = 0
for i in range(1, h + 1):
    for j in range(1, w + 1):
        if m[i][j] == 1:
            continue
        m[i][j] = 1
        qs = [[i, j]]
        white = 0
        black = 0
        while len(qs) != 0:
            q = qs.pop(0)
            if s[q[0]][q[1]] == '.':
                white += 1
            else:
                black += 1
            m[q[0]][q[1]] = 1
            for k in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
                if m[q[0] + k[0]][q[1] + k[1]] == 0 and s[q[0]][q[1]] != s[q[0] + k[0]][q[1] + k[1]]:
                    m[q[0] + k[0]][q[1] + k[1]] = 1
                    qs.append([q[0] + k[0], q[1] + k[1]])
        ans += black * white
print(ans)

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

using namespace std;

int main() {
  int n, k, s, cnt = 0;
  cin >> n >> k >> s;

  for (int i = 0; i < n; i++) {
    if (cnt < k) {
      cout << s << " ";
    } else {
      if (s == 1e9) {
        cout << 1 << " ";
      } else {
        cout << s + 1 << " ";
      }
    }
    cnt++;
  }
  cout << endl;

  return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ;
  cin >> n;
  int a[100100] = {0};
  int b[100100] = {0};
  rep(i,n/2){
    int c1, c2 ;
    cin >> c1 >> c2  ;
    a[c1] ++;
    b[c2] ++;
  }
  
  int a_MAX = 0;
  int a_now = 0;
  int b_MAX = 0;
  int b_now = 0;
  
  rep(i,100100){
    if(a_MAX < a[i]){
      a_now = i;
      a_MAX = a[i];
    }
    if(b_MAX < b[i]){
      b_now = i;
      b_MAX = b[i];
    }
  }
  
  int ans = n - a_MAX - b_MAX ;
  
  if(a_now == b_now){
    a[a_now] = 0;
    b[b_now] = 0;
    int a_second = 0;
    int b_second = 0; 
    rep(i,100100){
     if(a_second < a[i]){
      a_now = i;
      a_second = a[i];
    }
     if(b_second < b[i]){
      b_now = i;
      b_second = b[i];
    }
      
    ans = n - max(a_MAX + b_second,a_second + b_MAX);  
  }
  }
    
    cout << ans ;
  
    
  
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

const int maxN = 2 * 1e5 + 2;
int cnt[maxN];
int add[maxN];

void dfs(int node, int c, vector<vi> &graph) {
  c += add[node];
  cnt[node] = c;
  for (auto &index : graph[node])
    dfs(index, c, graph);
}

signed main() {
  int n, q;
  std::cin >> n >> q;
  vector<vi> graph(n + 1);
  REP(i, n - 1) {
    int a = read();
    int b = read();
    graph[a].PB(b);
  }
  REP(i, q) {
    int p = read();
    int x = read();
    add[p] += x;
  }
  dfs(1, 0, graph);
  FOR(i, 1, n + 1) print(cnt[i], 2);
}


Measured memory_bytes: 26624
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

const int64_t kMod = 1000000007LL;
// const int64_t kMod = 998244353LL;
struct Mint {
  int64_t value;
  Mint(int64_t value = 0LL) : value((value % kMod + kMod) % kMod) {}
  Mint operator-() const {
    return Mint(-value);
  }
  Mint &operator+=(const Mint rhs) {
    if ((value += rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator-=(const Mint rhs) {
    if ((value += kMod - rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator*=(const Mint rhs) {
    (value *= rhs.value) %= kMod;
    return *this;
  }
  Mint operator+(const Mint rhs) const {
    return Mint(*this) += rhs;
  }
  Mint operator-(const Mint rhs) const {
    return Mint(*this) -= rhs;
  }
  Mint operator*(const Mint rhs) const {
    return Mint(*this) *= rhs;
  }
  Mint Pow(int64_t p) const {
    if (p == 0LL) {
      return 1LL;
    } else if (p < 0LL) {
      return Pow(-p).Pow(kMod - 2LL);
    }
    Mint temp = Pow(p >> 1LL);
    temp *= temp;
    if (p & 1LL) {
      temp *= (*this);
    }
    return temp;
  }
  Mint Inv() const {
    return Pow(kMod - 2LL);
  }
  Mint &operator/=(const Mint a) {
    return *this *= a.Inv();
  }
  Mint operator/(const Mint a) const {
    return Mint(*this) /= a;
  }
};
std::ostream &operator<<(std::ostream &os, const Mint &a) {
  os << a.value;
  return os;
}

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

  int64_t n, a, b;
  cin >> n >> a >> b;
  Mint result = 2;
  result = result.Pow(n);
  result -= 1;

  Mint nca = 1;
  {
    for (int64_t i = 0; i < a; ++i) {
      nca *= (n - i);
    }
    Mint afact = 1;
    for (int64_t i = 1; i <= a; ++i) {
      afact *= i;
    }
    nca /= afact;
  }

  Mint ncb = 1;
  {
    for (int64_t i = 0; i < b; ++i) {
      ncb *= (n - i);
    }
    Mint bfact = 1;
    for (int64_t i = 1; i <= b; ++i) {
      bfact *= i;
    }
    ncb /= bfact;
  }

  result -= nca;
  result -= ncb;
  cout << result.value << endl;
  return 0;
}


Measured memory_bytes: 3700
import scala.io.StdIn._

/**
 * ABC108B
 */
object Main extends App {
  import scala.math._

  val Seq(x1, y1, x2, y2) = readLine().split(" ").toSeq.map(_.toInt)
  val r = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2))
  val rcos = x2 - x1
  val rsin = y2 - y1

  val x3 = ((rcos - rsin) + x1).toInt
  val y3 = ((rsin + rcos) + y1).toInt
  val x4 = -rsin + x1
  val y4 = rcos + y1

  println(x3 + " " + y3 + " " + x4 + " " + y4)

}

Measured memory_bytes: 25288
#include <iostream>
using namespace std;
int main(){
    char num[1001];
    while(true){
        int sum=0, i=0;
     
        cin >> num;
        if(num[0]=='0') break;
     
        while(num[i]!='\0'){
            sum += num[i]-'0';
            ++i;
        }
         
        cout << sum << endl;
    }
     
    return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
int n;
typedef long double db;
db ans;
struct point
{
    db x;
    db y;
};
point v[1001];
db epsilon=0.0001;
db dist(point a, point b)
{
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
void solve(point p1, point p2, point p3)
{
    if(!(p1.x==p2.x&&p2.x==p3.x)&&!(p1.y==p2.y&&p2.y==p3.y))
    {
        point M1,M2;
        M1.x=(p1.x+p2.x)/2;
        M1.y=(p1.y+p2.y)/2;
        M2.x=(p1.x+p3.x)/2;
        M2.y=(p1.y+p3.y)/2;
        db a=p2.y-p1.y;
        db b=p1.x-p2.x;
        db c=-(a*p1.x+b*p1.y);
        db a1=-b;
        db b1=a;
        db c1=-(a1*M1.x+b1*M1.y);
        a=p3.y-p1.y;
        b=p1.x-p3.x;
        c=-(a*p1.x+b*p1.y);
        db a2=-b;
        db b2=a;
        db c2=-(a2*M2.x+b2*M2.y);
        point centre;
        centre.y=(-a1*c2+a2*c1)/(-a2*b1+a1*b2);
        if(a1!=0)
            centre.x=-(c1+b1*centre.y)/a1;
        else
            centre.x=-(c2+b2*centre.y)/a2;
        db raza=dist(centre, p1);
        bool ok=1;
        for(int t=1;t<=n;t++)
            if(dist(centre,v[t])-raza>epsilon)
            {
                ok=0;
                break;
            }
        if(ok)
           if(ans>raza)
                ans=raza;
    }
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>v[i].x>>v[i].y;
    cout<<fixed<<setprecision(8);
    if(n==1)
    {
        cout<<0;
        return 0;
    }
    if(n==2)
    {
        cout<<dist(v[1],v[2])/2;
        return 0;
    }
    ans=1000000000000;
    for(int i=1;i<=n-1;i++)
        for(int j=1;j<=n;j++)
        {
            point centre;
            point p1=v[i],p2=v[j];
            centre.x=(p1.x+p2.x)/2;
            centre.y=(p1.y+p2.y)/2;
            db raza=dist(centre, p1);
            bool ok=1;
            for(int l=1;l<=n;l++)
                if(dist(centre,v[l])>raza)
                {
                    ok=0;
                    break;
                }
            if(ok)
                if(ans>raza)
                    ans=raza;
        }
    for(int i=1;i<=n-2;i++)
        for(int j=i+1;j<=n-1;j++)
            for(int l=j+1;l<=n;l++)
    {
        point p1,p2,p3;
        p1=v[i];
        p2=v[j];
        p3=v[l];
        solve(p1,p2,p3);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static int gcd(int a, int b) {
		if (a < b) {
			int tmp = a;
			a = b;
			b = tmp;
		}
		if (b == 0)
			return a;
		int r = a % b;
		return gcd(b, r);
	}

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		int gcd[] = new int[n + 1];
		int gcdrear[] = new int[n + 1];
		for(int i = 0; i < n; ++i){
			a[i] = sc.nextInt();
			gcd[i + 1] = gcd(gcd[i], a[i]);
		}
		for(int i = n; i >= 1; --i){
			int index = n - i + 1;
			gcdrear[index] = gcd(gcdrear[index - 1], a[i - 1]);
		}
		sc.close();
		int ans = 0;
		for(int i = 0; i < n; ++i){
			int tmp = gcd(gcdrear[n - i - 1], gcd[i]);
			ans = Math.max(ans, tmp);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 61048
#include <iostream> 
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <fstream>
using namespace std;
#define ll long long int


int main( ) {
  string s;
  cin >> s;
  int k_one = 0,k_zero = 0,g_one = 0,g_zero = 0;
  for ( int i = 0; i < s.size(); ++i ) {
    if (i % 2 == 0) {
      if(s[i] == '1') g_zero++;
      else g_one++;   
    }else {
      if(s[i] == '1') k_zero++;
      else k_one++;  
    }
  }

  int ans = min(k_zero + g_one, g_zero + k_one);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
def gcd(a, b):
    if(a == 0):
        return b
    return gcd(b % a, a)
def lcm(a, b):
    return a // gcd(a, b) * b
t = int(input())
ans = 1
while(t != 0):
    t -= 1
    n = int(input())
    ans = lcm(ans, n)
print(int(ans))


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

void call(int n)
{
  for (int i = 1; i <= n; i++)
  {
    int x = i;
    if (x % 3 == 0)
    {
      cout << " " << i;
    }
    else
    {
      while (x)
      {
        if (x % 10 == 3)
        {
          cout << " " << i;
          break;
        }
        x /= 10;
      }
    }
  }
  cout << endl;
}

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


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main() {
  int H,W,ans=0; cin>>H>>W;
  vector<vector<char>> S(H,vector<char>(W));
  queue<pair<int,int>> Q;
  vector<vector<bool>> seen(H,vector<bool>(W,false)); 
  rep(i,H){
    rep(j,W){
      cin>>S.at(i).at(j);
      if(S.at(i).at(j)=='#'){
        Q.push(make_pair(i,j));
        seen[i][j]=true;
      }
    }
  }
  Q.push(make_pair(-1,-1));
  while(!Q.empty()){
    int x=Q.front().first,y=Q.front().second;
    Q.pop();
    if(x==-1&&y==-1){
      if(Q.empty())continue;
      ans++;
      Q.push(make_pair(-1,-1));
      continue;  
    }
    rep(j,4){
      int nx=x+dx[j],ny=y+dy[j];
      if(nx<0 || nx>= H || ny<0 || ny>=W) continue;
      if(seen[nx][ny]==false){
      Q.push(make_pair(nx,ny));
      seen[nx][ny]=true;
      }
    }
  }
  cout<<ans;
}


Measured memory_bytes: 12452
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n;
    cin >> n;
    vector <string > inp(n);
    map <string ,ll > mp;
    for(ll i=0;i<n;i++)
    {
        cin >> inp[i];
        sort(inp[i].begin(),inp[i].end());
        mp[inp[i]]++;

    }
    ll ans=0;
    for( auto x:mp )
    {
        ans+=(x.second*(x.second-1))/2;

    }
    cout << ans<<"\n";
}


Measured memory_bytes: 14296
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
//////////////////

void solve(){
  ini(N);
  vi a(N); in(a);
  each(x , a) x--;
  vi inv(N);
  rep(i , N) inv[a[i]] = i;
  trc(inv);
  vi s(N) , t(N);
  s[0] = 1 , t[0] = 1000000000;
  rep1(i , N - 1){
    int d = inv[i] - inv[i - 1];
    s[i] = s[i - 1] + 1;
    t[i] = t[i - 1] - 1;
    if(d > 0) s[i] += d;
    else t[i] += d;
  }
  out(s);
  out(t);


}

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

int main(){
	int a[6][2];
	for(int i=0; i<6; ++i)
		for(int j=0; j<2; ++j) a[i][j]=-1;
	a[0][0]=1; a[0][1]=2; a[1][1]=3; a[2][0]=1; a[3][0]=4; a[3][1]=5; a[4][0]=5; a[4][1]=2; a[5][0]=2; a[5][1]=1;	
	
	while(1){
		string s;
		cin >> s;
		if(s=="#") break;
		
		int now=0;
		for(int i=0; i<s.size(); ++i){
			now=a[now][(int)(s[i]-'0')];
			//printf(":::%dnow=%d\n",s[i]-'0',now);
			if(now==-1) break;
		}
		
		if(now==5) printf("Yes\n");
		else printf("No\n"); 
	}
	return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
char s[10];
main()
{
     int n,i,p=0,a=0,b=0,c=0,d=0;
     cin>>n;
     for(i=1;i<=n;i++)
     {
         cin>>s;
         if(s[0]=='A')
         {
             a++;
         }
         else if(s[0]=='W')
         {
             b++;
         }
         else if(s[0]=='T')
         {
             c++;
         }
         else
         {
             d++;
         }
     }
     printf("AC x %d\n",a);
     printf("WA x %d\n",b);
     printf("TLE x %d\n",c);
     printf("RE x %d\n",d);
}


Measured memory_bytes: 3764
n,l=map(int,input().split())
f=1
as_=[]
m=float('inf')
for i in range(n):
    a=l+i
    as_.append(a)
    m=min(m,abs(a))
    if a<0:
        f=-1
    else:
        f=1
print(sum(as_)-f*m)


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

const double EPS = 1e-8;

int dcmp(double d) {
    if (fabs(d) < EPS) {
        return 0;
    }
    else {
        return d < 0? -1 : 1;
    }
}

struct Vector {
    double x, y;
    Vector(double x = 0, double y = 0): x(x), y(y){
    }
    
    bool operator<(const Vector& other) const {
        return dcmp(x - other.x) < 0 || (dcmp(x - other.x) == 0 && dcmp(y - other.y) < 0);
    }
};

typedef Vector Point;

double dot(const Vector& a, const Vector& b) {
    return a.x * b.x + a.y * b.y;
}

double cross(const Vector& a, const Vector& b) {
    return a.x * b.y - a.y * b.x; 
}

Vector operator+(const Vector& a, const Vector& b) {
    return Vector(a.x + b.x, a.y + b.y);
}

Vector operator-(const Vector& a, const Vector& b) {
    return Vector(a.x - b.x, a.y - b.y);
}

Vector operator*(const Vector& a, const double& p) {
    return Vector(a.x * p, a.y * p);
}

double angle(const Vector& a) {
    return atan2(a.y, a.x);
}

double length(const Vector& a) {
    return sqrt(dot(a, a));
}

struct Circle {
    Point c;
    double r;
    Circle(double x = 0, double y = 0,  double r = 0): c(Point(x, y)), r(r){}
    
    Point point(double rad) {
        return Point(c.x + r * cos(rad), c.y + r * sin(rad));
    }
};


vector<Point> interSect(const Circle& c, const Point& a, const Point& b) {
    Vector u = b - a;
    Vector v = c.c - a;
    
    double distance = fabs(cross(u, v) / length(u));
    
    Point x = a + u * (dot(v, u)/dot(u, u));
    
    double y = sqrt(c.r * c.r - distance * distance);
    
  
    Point p1 = x + u * (y/length(u));
    Point p2 = x + u * (-y/length(u));
    
    vector<Point> results{p1, p2};
    sort(results.begin(), results.end());
    
    return results;
}

int main() {
    double x, y, r;
    cin >> x >> y >> r;
    Circle c(x, y, r);
    
    int q;
    cin >> q;
    
    for (int i = 0; i < q; i++) {
        double x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        vector<Point> ans = interSect(c, Point(x1, y1), Point(x2, y2));
        cout << fixed << setprecision(8) << ans[0].x << " " << ans[0].y 
        << " " << ans[1].x << " " << ans[1].y << endl;
    }
    
    return 0;
    
}

Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
int main()
{
	double a, b; cin >> a >> b;
	double x = ceil(a / 0.08);
	while(true)
	{
		int tmp = (double)(x * 0.08);
		if(tmp > a) break;
//		cout << x << '\n';
		int t = (double)x * 0.1;
		if(t == b)
		{
			cout << x << '\n';
			return 0;
		}
		x ++;
	}
	cout << "-1";
	return 0;
}

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

int main() {
    int D;
    cin >> D;
    switch(D) {
        case 22:
            cout << "Christmas Eve Eve Eve" << endl;
            break;
        case 23:
            cout << "Christmas Eve Eve" << endl;
            break;
        case 24:
            cout << "Christmas Eve" << endl;
            break;
        case 25:
            cout << "Christmas" << endl;
            break;
    }
}


Measured memory_bytes: 764
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

vector<int> to[200005];
vector<int> ans;

void dfs(int v, int p = -1)
{
  for (int u : to[v])
  {
    if (u == p)
      continue;
    ans[u] += ans[v];
    dfs(u, v);
  }
}

int main()
{
  int n, q;
  cin >> n >> q;
  rep(i, n - 1)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  rep(i, q)
  {
    int p, x;
    cin >> p >> x;
    --p;
    ans[p] += x;
  }
  dfs(0);
  rep(i, n)
  {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 23552
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()


def get_sieve_of_eratosthenes(n):
    """
    エラトステネスの篩
    """
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        return []
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit < p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return deque(data)

def main():
    N = int(input())

    """
    小さい素数から順に題意を満たすものを列挙するのはそもそも不可能らしい。
    結論は構成問題でした。５で割ってあまり１の素数を列挙すれば良いという、、、
    """

    ans = []
    cnt = 0
    for p in get_sieve_of_eratosthenes(55555):
        if cnt == N: break
        if p % 5 == 1:
            ans.append(p)
            cnt += 1
    print(" ".join(map(str, ans)))



if __name__ == "__main__":
    main()


Measured memory_bytes: 75360
#include<stdio.h>
int sosuu(int);
int main(){
  int i,n,sosu,hantei;
  int count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&sosu);
    hantei = sosuu(sosu);
    if(hantei == 1) count++;
  }
  printf("%d\n",count);
  return 0;
}
int sosuu(int sosu){
  int i;
  if(sosu<2)return 0;
  else if(sosu==2)return 1;
  else if(sosu%2==0)return 0;
  else{
    for(i=3;i*i<=sosu;i+=2){
      if(sosu%i==0)return 0;
    }
    return 1;
  }
}



Measured memory_bytes: 2000
=begin
－－－－－－－－－－－－－－
  N = 入力値
  cnt = 桁数
  ans = 答え
－－－－－－－－－－－－－－
  digitsメソッドを作成(num)
    1: cnt += 1
    2: num /10
    3. num < 0 になったら cnt を返す
  メソッド－－－－－－－－－－

  1: 1 ~ N まで繰り返す(i)
  2: digits(i) % 2 が 0 以外なら ans += 1
  3: ans を出力
=end

def digits(num)
  cnt = 0;
  while num > 0
    cnt += 1;
    num /= 10;
  end
  return cnt;
end

N = gets.to_i;
ans = 0;
(1..N).each do |i|
  ans += 1 unless digits(i) % 2 == 0
end

puts ans

Measured memory_bytes: 1788
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n; int x; int count = 0;
		while (true) {
			count = 0;
			n = scan.nextInt();
			x = scan.nextInt();
			if (n == 0 && x == 0) break;
			for (int i = 1; i <= n - 2; i++) {
				for (int j = i + 1; j <= n - 1; j++) {
					for (int k = j + 1; k <= n; k++) {
						if (i + j + k == x) count++;
					}
				}
			}
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 26824
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[] a = new String[H + 2];
		for(int i = 1; i < H + 1; i++) {		
                a[i] = sc.next();				
			
		 }
		for(int i = 0; i < H + 2; i++) {
			System.out.print("#");
				if(i == 0 || i == H + 1 ) {
					for(int j = 0; j < W; j++) {
					    System.out.print("#");
					}
				}else System.out.print(a[i]);
                System.out.println("#");
		}
	}
}


Measured memory_bytes: 22740
A = int(input())
B = int(input())
C = int(input())
X = int(input())


def patern(A,B,C,X):
	res = 0;
	for a in range(A+1):
		for b in range(B+1):
			for c in range(C+1):
				total = 500*a + 100*b + 50*c
				if total == X: res += 1
	print(res)

patern(A,B,C,X)




Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int a, b;
    cin >> a >> b;
    if(a > b){
        cout << "safe";
    }else{
        cout << "unsafe";
    }
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }

int main()
{
	int n, b_before, b_after, temp;
	
	cin >> n;
	vector<pair<int, int>> x(n);
	for (int i = 0; i < n; i++)
	{
		cin >> temp;
		x[i] = make_pair(temp, i);
	}
	sort(x.begin(), x.end());
	b_before = x[(n - 1) / 2].first;
	b_after = x[(n - 1) / 2 + 1].first;
	for (int i = 0; i < n / 2; i++)
		x[i] = make_pair(x[i].second, b_after);
	for (int i = n / 2; i < n; i++)
		x[i] = make_pair(x[i].second, b_before);
	sort(x.begin(), x.end());
	for (int i = 0; i < n; i++)
		cout << x[i].second << '\n';
}


Measured memory_bytes: 4720
def linear_search(search_list, target):
    i = 0
    search_list.append(target)
    while search_list[i] != target:
        i += 1
    if i == len(search_list) - 1:
        return -1
    else:
        return i

if __name__ == '__main__':
    n = int(input())
    S = [int(x) for x in input().split()]
    q = int(input())
    T = [int(x) for x in input().split()]
    count = 0

    for x in T:
        if linear_search(S, x) > -1:
            count += 1
    print(count)


Measured memory_bytes: 6560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 105;
int n;
int a[N], b[N];
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int i = 1; i < n; i++) cin >> b[i];
    int ans = 0;
    for(int i = 2; i < n; i++) {
        ans += min(b[i - 1], b[i]);
    }
    ans += b[1] + b[n - 1];
    cout << ans;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

cnt = 0
for i in range(N):
    mini = i
    for j in range(i,N):
        if A[j] < A[mini]:
            mini = j
    if mini != i:
        tmp = A[i]
        A[i] = A[mini]
        A[mini] = tmp
        cnt += 1

result = [str(i) for i in A]
print(' '.join(result))
print(cnt)



Measured memory_bytes: 5600
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a>b)
	swap(a,b);
	if(b>c)
	swap(b,c);
	if(a>b)
	swap(a,b);
    cout<<a<<" "<<b<<" "<<c<<endl;
}



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

int MAX=100001;
int main() {
  int n,m;
  cin >> n >> m;
  
  vector<int> sb(MAX),tb(MAX);
  rep(i,n){
    int s,t,c;
    cin >> s >> t >> c;
    --c;
    sb[s] |= 1<<c;
    tb[t] |= 1<<c;
  }
  int ans = 1, x = 0;
  rep(i,MAX){
    x ^= sb[i];
    ans = max(ans,__builtin_popcount(x)-__builtin_popcount(sb[i]&tb[i]));
    x ^= tb[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  long long sum=0;
  for(int i=0;i<s.size();i++)
    sum+=s[i]-'0';
  if(sum%9==0)
    cout<<"Yes\n";
  else
    cout<<"No\n";
}

Measured memory_bytes: 3716
#include <stdio.h>
#include <string.h>
char s[1010];
char r[1010];
int main(){
	scanf("%s",s);
	int n;
	scanf("%d",&n);
	while(n--){
		char t[10];
		int a,b;
		char x;
		scanf("%s%d%d",t,&a,&b);
		switch(t[2]){
			case 'p':
				scanf("%s",r);
				for(int i=a;i<=b;i++)s[i]=r[i-a];
				break;
			case 'v':
				memcpy(r,s+a,b-a+1);
				for(int i=a;i<=b;i++)s[b-(i-a)]=r[i-a];
				break;
			case 'i':
				x=s[b+1];
				s[b+1]=0;
				puts(s+a);
				s[b+1]=x;
				break;
		}
	}
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_N = 100000;

int N;
ll L;
string s[MAX_N];

vi trie[MAX_N + 1];
char c[MAX_N + 1];

bool used[MAX_N + 1];

ll ans = 0;

ll divide(ll n){
  int k = 1;
	while(n % 2 == 0){
		k++;
		n /= 2;
	}
	return k;
}

void dfs(int v, ll d) {
  used[v] = true;
  if(trie[v].size() == 1) ans ^= divide(L - d);

  REP(i, trie[v].size()) {
    if(!used[trie[v][i]]) dfs(trie[v][i], d + 1);
  }
  return;
}

int main(){
  cin >> N >> L;
  int k = 0;
  REP(i, N) {
    cin >> s[i];
    int y = 0;
    REP(j, s[i].size()) {
      bool flag = false;
      REP(l, trie[y].size()) {
        if(c[trie[y][l]] == s[i][j]) {
          y = trie[y][l];
          flag = true;
          break;
        }
      }
      if(!flag) {
        k++;
        trie[y].push_back(k);
        c[k] = s[i][j];
        y = k;

      }
    }
  }

  REP(i, MAX_N) used[i] = false;
  dfs(0, 0);

  if(ans == 0) cout << "Bob" << endl;
  else cout << "Alice" << endl;

  return 0;
}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    Int(n);
    vi ans(100004, 0);
    ans[0]++;
    rep(i, n) {
        Int(a);
        Int(b);
        ans[a]++;
        ans[b+1]--;
    }
    int ret = 0;
    Rep(i, n+2) {
        ans[i] += ans[i-1];
        if (ans[i] >= i) {
            ret = i;
        }
    }
    cout << ret -1 << endl;

    return 0;
}

Measured memory_bytes: 3620
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from heapq import heappop, heapify, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
ans = 0
i = 0
while i < N:
    if A[i] == i + 1:
        ans += 1
        i += 1
    i += 1
print(ans)



# for i in range(N):
#     if A[i] == i + 1:
#         ans += 1
#         if i < N - 1:
#             if A[i + 1] == i + 2:
#                 tmp += 1
#                 ans -= 1
# print(ans)
# print(tmp)

Measured memory_bytes: 15928
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main(void){

    int a, b;
    cin >> a >> b;
    
    int result = 0;
    for(int i=0; i<2; i++) {
        if(a > b) {
            result += a;
            a--;
        }
        else {
            result += b;
            b--;
        }
    }
    
    cout << result << endl;

    return 0;

}


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

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

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

  for(int i=(n-2);i>=0;i--){

for(int j=0;j<3;j++){
int l=-1;
int r=-1;
for(int k=0;k<3;k++){
if(k==j)
continue;
if(l==-1){
l=k;
continue;}
r=k;
}
dp[i][j]=hp[i][j]+max(dp[i+1][l],dp[i+1][r]);
  }}
  int maxm;
  maxm=max(dp[0][0],dp[0][1]);
  maxm=max(maxm,dp[0][2]);
  cout<<maxm;


    return 0;}


Measured memory_bytes: 5940
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n;
  cin >> n;
  vi x(n);
  REP(i,n) cin >> x[i];
  int m;
  cin >> m;
  vi mp(2020,0);
  REP(i,n){
    mp[x[i]] = 1;
  }
  REP(i,m){
    int a;
    cin >> a;
    a--;
    if(x[a]+1<2020&&!mp[x[a]+1]){
      x[a]++;
      mp[x[a]] = 1;
      mp[x[a]-1] = 0;
    }
  }
  for(auto i:x) cout << i << endl;
}



Measured memory_bytes: 3112
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int n, x;
	cin >> n >> x;
	vector<int> ans;
	if (x > 1 && x < 2 * n - 1) {
		if (n == 2) {
			ans = {1, 2, 3};
		} else {
			ans.resize(2 * n - 1);
			if (x == 2) {
				ans[n - 2] = 3;
				ans[n - 1 ] = 1;
				ans[n   ] = 2;
				ans[n + 1] = 4;
			} else {
				ans[n - 2] = x - 1;
				ans[n - 1] = x;
				ans[n    ] = x + 1;
				ans[n + 1] = x - 2;
			}
			set<int> s(ans.begin(), ans.end());
			int seq = 1;
			for (int i = 0; i < 2 * n - 1; ++i) {
				if (!ans[i]) {
					while (s.find(seq) != s.end()) {
						++seq;
					}
					s.insert(seq);
					ans[i] = seq;
				}
			}
		}
	}
	if (ans.empty()) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
		for (int a : ans) {
			cout << a << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 11648