akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;

int main () {
    int N;
    cin >> N;
    int color[8] = {0};
    int a[N+3] = {};

    int ans = 0;

    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }

    for (int i = 0; i < N; ++i)
    {
        if (a[i] < 400) ++color[0];
        else if (a[i] < 800) ++color[1];
        else if (a[i] < 1200) ++color[2];
        else if (a[i] < 1600) ++color[3];
        else if (a[i] < 2000) ++color[4];
        else if (a[i] < 2400) ++color[5];
        else if (a[i] < 2800) ++color[6];
        else if (a[i] < 3200) ++color[7];
        else  ++color[8];
    }

    for (int i = 0; i < 8; ++i)
    {
        // cont << color[i] << endl;
        if(color[i] != 0) {
            // cout << color[i];
            ++ans;
        }
    }

    if (ans != 0)
        cout << ans << ' ' << ans+color[8] << endl;
    else
        cout << 1 << ' ' << ans + color[8] << endl;
}

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

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  static const double pi = 3.141592653589793;
  
  double rad = 2 * pi * (H / 12.0 + M / 60.0 / 12.0 - M / 60.0);
  
  double C = sqrt(A * A + B * B - 2 * A * B * cos(rad));
  cout << fixed << setprecision(10);
  cout << C << endl;
}



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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    long long X, Y;
    cin >> X >> Y;
    long long g = __gcd(X, Y);
    if (X % Y == 0)
        cout << "-1" << endl;
    else
        cout << X << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned int uii;
const int maxn=100005;
int n,a,b;
ll A[maxn];
vector<int> tr[maxn];
ll dfs(int u,int fa) {
    if (tr[u].size()==1)
        return A[u];
    ll tot=0,x2=0,x1=0,mm,tm=0;
    for (uii i=0;i<tr[u].size();++i) {
        if (tr[u][i]==fa)
            continue;
        mm=dfs(tr[u][i],u);
        tm=max(tm,mm);
        tot+=mm;
    }
    x2=tot-A[u];
    x1=A[u]-x2;
    if (x1<0||x2<0||A[u]<tm||(x1>0&&fa==-1)) {
        puts("NO");
        exit(0);
    }
    return x1;
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;++i)
        scanf("%lld",&A[i]);
    if (n==1) {
        puts(A[1]?"NO":"YES");
        return 0;
    }
    for (int i=0;i<n-1;++i) {
        scanf("%d%d",&a,&b);
        tr[a].push_back(b);
        tr[b].push_back(a);
    }
    if (n==2)
        puts(A[1]==A[2]?"YES":"NO");
    else {
        for (int i=1;i<=n;++i)
            if (tr[i].size()>1) {
                dfs(i,-1);
                break;
            }
        puts("YES");
    }
    return 0;
}

Measured memory_bytes: 13184
# Header {{{
def assert(p)
  raise 'Assertion Failed' unless p
end

# Constants {{{
INF = 10**9
# }}}

# IO {{{
class MyIO
  def initialize
    @input = $stdin
    @output = $stdout
  end

  # @param filename [String]
  def set_input(filename)
    @input = File.open(filename, 'r')
  end

  def set_output(filename)
    @output = File.open(filename, 'w')
  end

  def intl
    splitl.map(&:to_i)
  end

  def splitl
    @input.gets.chomp.split(' ')
  end

  def gets
    @input.gets.chomp
  end

  def puts(*args)
    @output.puts(*args)
  end
end

io = MyIO.new
# }}}

# }}}

# io.set_input('inputs/1.txt')
# io.set_output('my_outputs/1.txt')

while true
  n, d = io.intl
  break if n == 0

  missiles = Array.new(n) { [] }
  sums = Array.new(n) { [] }
  n.times do |i|
    c = io.intl
    c.shift
    missiles[i] = c
    sums[i] = c.reduce(:+) || 0
  end

  disposed = true
  while disposed
    disposed = false
    n.times do |i|
      next if missiles[i].empty?
      popped = missiles[i].pop
      sums[i] -= popped
      if sums.max - sums.min > d
        missiles[i].push(popped)
        sums[i] += popped
        next
      end
      disposed = true
    end
  end

  if missiles.all? { |m| m.empty? }
    io.puts "Yes"
  else
    io.puts "No"
  end
end

# vim: foldmethod=marker

Measured memory_bytes: 6152
#include <stdio.h>

int main() {
  int n, m, i, j;
  int s[200];
  int t_sum, h_sum;
  int flag;

  while(1) {
    t_sum = 0;
    h_sum = 0;
    flag = 0;
    scanf("%d %d", &n, &m);
    if(n == 0 && m == 0)
      break;
    else if(n < 0 || n > 100 || m < 0 || m > 100)
      scanf("%d %d", &n, &m);
    for(i = 0; i < n; i++){
      scanf("%d", &s[i]);
      t_sum += s[i];
    }
    for(i = 0; i < m; i++){
      scanf("%d", &s[n+i]);
      h_sum += s[n+i];
    }
    for(i = 0; i < n; i++){
      for(j = 0; j < m; j++){
        if((t_sum - s[i] + s[n+j]) == (h_sum - s[n+j] + s[i])) {
          printf("%d %d\n", s[i], s[n+j]);
          flag = 1;
          break;
        }
      }
      if(flag == 1)
        break;
    }
    if(flag == 0)
      printf("-1\n");
  }
  return 0;
}

Measured memory_bytes: 612
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
#define mod  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define int long long
    
template<typename T>
T gcd(T a, T b)
{
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a,T b)
{
    return  a / gcd(a,b) * b;
}


class UnionFind {
private:
    int sz;
    vector<int> par, size_;
public:
    UnionFind(){}
    UnionFind(int node_size) : sz(node_size), par(sz), size_(sz, 1){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x,int y){
        x = find(x), y = find(y);
        if(x == y) return;
        if(size_[x] < size_[y]) swap(x,y);
        par[y] = x;
        size_[x] += size_[y];
    }
    int size(int x){
        x = find(x);
        return size_[x];
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
};

template<typename T> class segtree{
private:
    int n,sz;
    vector<T> node;
public:
    segtree(const vector<T>& v) : n(1), sz((int)v.size()){
        while(n < sz) n *= 2;
        node.resize(2*n-1, 1);
        for(int i = 0; i < sz; i++){
            node[i+n-1] = v[i];
        }
        for(int i=n-2; i>=0; i--){
            node[i] = lcm(node[i*2+1], node[i*2+2]);
        }
    }
    void update(int k,T a){
    	k += n-1;
    	node[k] = a;
    	while(k>0){
            k = (k-1)/2;
            node[k] = lcm(node[2*k+1],node[2*k+2]);
    	}
    }
    T query(int a,int b,int k=0,int l=0,int r=-1){
        if(r < 0) r = n;
    	if(r <= a || b <= l){
            return 1;
    	}
    	if(a <= l && r <= b){
            return node[k];
    	}else{
            T vl = query(a,b,2*k+1,l,(l+r)/2);
            T vr = query(a,b,2*k+2,(l+r)/2,r);
            return lcm(vl,vr);
    	}
    }
    void print(){
        for(int i = 0; i < sz; i++){
            cout<<query(i,i+1)<< " ";
        }
        cout<<endl;
    }
};

ll a[200000];
ll sz[200000];
long long mod_pow(long long a,long long b)
{
    a %= mod;
    long long res = 1;
    while(b){
        if(b & 1){
            res = res * a % mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}
signed main(){
    int n,q;
    cin >> n >> q;
    vector<int>p(n+1);
    rep(i,n)cin >> p[i+1];
    UnionFind uf(n+1);
    for(int i=1;i<=n;i++){
        uf.unite(i,p[i]);
    }
    vector<ll> v(n+1,1);
    for(int i=1;i<=n;i++){
        a[uf.find(i)]+=i;
        sz[i] = uf.size(i);
        v[i] = sz[i];
    }
    segtree<ll> sg(v);
    vector<ll>qq(n+1);
    rep(i,n+1){
        if(i==0)continue;
        qq[i] = a[uf.find(i)];
        qq[i]%=mod;
        qq[i] *= mod_pow(v[i],mod-2);
        qq[i]%=mod;
    }
    rep(i,n){
        qq[i+1] += qq[i];
        qq[i+1] %= mod;
    }
    rep(zz,q){
        int l,r;
        cin >> l >> r;
        ll pt = sg.query(l,r+1)%mod;
        //cerr << pt << endl;
        ll res = (mod+qq[r]-qq[l-1])%mod;
        cout << res*pt%mod << endl;
    }
    return 0;
}


Measured memory_bytes: 10204
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  string s,t;
  cin >> s >> t;
  cout << t + s << endl;
  return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
int grid[5003][5003];
void solve() {
	int n, m;
	cin >> n >> m;
	map<int, int> x, y;
	vector<pair<int, int>> inputs;
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		inputs.push_back(mp(a, b));
		x[a] = 1;
		y[b] = 1;
	}
	x[2e9] = 1;
	y[2e9] = 1;
	int cnt = 1;
	for (auto i = x.begin(); i != x.end();++i) {
		i->second = cnt;
		cnt++;
	}
	cnt = 1;
	for (auto i = y.begin(); i != y.end(); ++i) {
		i->second = cnt;
		cnt++;
	}
	REP(i, inputs.size()) {
		grid[x[inputs[i].first]][y[inputs[i].second]]++;
	}
	REP(i, 5002) {
		REP(q, 5002) {
			grid[i][q + 1] += grid[i][q];
		}
	}
	REP(i, 5002) {
		REP(q, 5002) {
			grid[q + 1][i] += grid[q][i];
		}
	}
	REP(i, m) {
		pair<int, int> go[2];
		REP(q, 2) {
			cin >> go[q].first >> go[q].second;
			go[q].first += q;
			go[q].second += q;

			go[q].first = (*(x.lower_bound(go[q].first))).second;
			go[q].second = (*(y.lower_bound(go[q].second))).second;

			go[q].first -= q;
			go[q].second -= q;
		}
		int ans = grid[go[1].first][go[1].second];
		ans -= grid[go[0].first - 1][go[1].second];
		ans -= grid[go[1].first][go[0].second - 1];
		ans += grid[go[0].first - 1][go[0].second - 1];
		cout << ans << endl;
	}
}
#undef int

int main() {
	solve();
}


Measured memory_bytes: 199276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int M, D;
	cin >> M >> D;

	int kotae = 0;

	for (int i = 21; i <= D; i++) {
		if (i % 10 < 2) continue;
		if ((i / 10) * (i % 10) <= M) kotae++;
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int x;
    cin >> x;
    FOR(a,1,800){
        if ((x * a) % 360 == 0){
            cout << a << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3592
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int n;

int main() {
    fastio();

    cin >> n;
    map<int, int, greater<int>> cnt;

    forn(i, n) {
        int a;
        cin >> a;
        cnt[a]++;
    }

    ll l1 = 0, l2 = 0;
    for (auto p : cnt) {
        if (p.snd >= 4) {
            if (l1 == 0) {
                l2 = l1 = p.fst;
            } else if (l2 == 0) {
                l2 = p.fst;
            }
        } else if (p.snd >= 2) {
            if (l1 == 0) {
                l1 = p.fst;
            } else if (l2 == 0) {
                l2 = p.fst;
            }
        }
    }

    cout << l1 * l2 << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


signed main(){
  int n;cin>>n;set<int> s;
  rep(i,n){
    int a;cin>>a;
    s.insert(a);
  }
  cout << s.size() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int a, b;
	cin >> a >> b;

	a--;
	b--;

	cout << a * b << endl;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll N,A[30],B[30],C[30];

ll i, j, k,ans;
int main(){
    scanf("%lld",&N);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
    }
    fornum(i,0,N){
        scanf("%lld", &B[i]);
        ans += B[i];
    }
    fornum(i,1,N){
        scanf("%lld", &C[i]);
    }
    fornum(i,1,N){
        //printf("%lld:%lld\n", i, ans);
        if(A[i-1]+1==A[i])
            ans += C[A[i]-1];
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define INF 1000000007
using namespace std;
ll f[1000003];

ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}

ll C(ll n, ll r, ll MOD)
{

 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
int main(){
//freopen("test.in","r",stdin);
ll x,y;
cin>>x>>y;
	f[0] = 1;
	for(int i = 1 ; i <= 1000001 ; i++)
		f[i] = (f[i-1]*i)%INF;
    ll ans=0;
for(int k=0;k<=x;k++){
    if(x-(k*2)>=0){
        int t=(x-(k*2));
        if((y-t*2)==k){
               //cout<<x-k<<' '<<k<<endl;
            ans+=C(x-k,k,INF)%INF;
            ans%=INF;
        }
    }
}
cout<<ans%INF;
return 0;
}


Measured memory_bytes: 8064
#!/usr/bin/env ruby

if __FILE__ == $0 then
	s = gets.chomp
	q = gets.chomp.to_i

	q.times do
		op = gets.split
		a, b = op[1,2].map(&:to_i)
		p  = op[3]

		case op[0]
		when 'print' then
			puts s[a..b]
		when 'reverse'
            s = s[0,a] + s[a..b].reverse + s[b+1..-1]
		when 'replace'
            s = s[0,a] + p + s[b+1..-1]
		end
	end
end


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

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

bool AC[100010];
int WA[100010];
int ans = 0;
int pena = 0;
for(int i = 0; i < 100010; i++){
    AC[i] = 0;
    WA[i] = 0;
}

for(int i = 0; i < M; i++){
    int p; string s;
    cin >> p >> s;
    --p;

if(s == "AC"){
if(AC[p] == 0){
ans++;
pena += WA[p];
AC[p] = 1;
}
}
else{
    WA[p]++;
}
}

cout << ans << " " << pena << endl;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int x;
    cin >> x;
    if (x == 0)
        cout << 1 << endl;
    else
    {
        cout << 0 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3608
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)1e9+7;
//}}}

int main(){
  int N;
  cin >> N;
  bool ans = false;
  rep(i, 100){
    rep(j, 100){
      if(i * 4 + j * 7 == N) ans = true;
    }
  }
  puts(ans ? "Yes" : "No");
  return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) rep(ghf,SZ(a)){rep(kjh,SZ(a[ghf])){cout<<(a[ghf][kjh]<10?" ":"")<<a[ghf][kjh]<<" ";}ENDL;}
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

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

  str s,t;
  cin>>s>>t;
  int n=SZ(s);
  bool can=true;
  map<char,char> st,ts;
  rep(i,n){
    if(st.count(s[i]))if(st[s[i]]!=t[i])can=false;
    if(ts.count(t[i]))if(ts[t[i]]!=s[i])can=false;
    st[s[i]]=t[i];
    ts[t[i]]=s[i];
  }
  YN(can);

  
  
  return 0;
}



Measured memory_bytes: 916
n,y = map(int,input().split())

y = y//1000
flag = False
ans = [-1,-1,-1]
for a in range(n+1):
    for b in range(n+1):
        t = y-(a*10+b*5)
        if t >= 0 and n == a+b+t:
            ans = [a,b,t]
            flag = True
            break
    if flag:
        break
print("{} {} {}".format(ans[0],ans[1],ans[2]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,a,b;
  cin>>n>>a;
  for(int i=0;i<4;i++){
    cin>>b;
    if(b<a)
      a=b;
  }
  cout<<(n+a-1)/a+4<<endl;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Folia
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef long long ll;

/* global variables */

int as[MAX_N + 1];
ll ls[MAX_N + 1], rs[MAX_N + 1];

/* subroutines */

/* main */

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

  if (n == 0) {
    printf("%d\n", (as[0] == 1) ? 1 : -1);
    return 0;
  }

  ls[n] = rs[n] = as[n];
  for (int i = n - 1; i >= 0; i--) {
    ls[i] = (ls[i + 1] + 1) / 2 + as[i];
    rs[i] = rs[i + 1] + as[i];
  }

  ll sum = 1, e = 1;
  for (int i = 0; i < n; i++) {
    ll e0 = e - as[i], e1 = e0 * 2;
    if (e1 < ls[i + 1] || rs[i + 1] < e0) {
      puts("-1");
      return 0;
    }
    e = min(e1, rs[i + 1]);
    sum += e;
  }

  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 5184
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimize("02")
#define pb push_back
#define F first
#define S second
using namespace std;
using ll =long long;
const ll maxn=1e5+5,inf=1e18+18;
ll n,m,t;
bool b;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n>>m;
	for(int i=0;i<=n;i++){
		if(i*2+(n-i)*4==m)b=1;
	}
	if(b)cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 3648
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x,y;
    while(true){
      x = sc.nextInt();
      y = sc.nextInt();
      if(x == 0 && y == 0){
        break;
      }
      if(x < y){
        System.out.println(x + " " + y);
      }
      else{
        System.out.println(y + " " + x);
      }
    }
  }
}

Measured memory_bytes: 36428
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
using namespace std;


int main(){
    int n, m;
    cin >> n >> m;
    int k[m + 1], s[m + 1], p[m + 1], tmp;
    for (int i = 1; i <= m; i++){
        cin >> k[i];
        s[i] = 0;
        for (int j = 1; j <= k[i]; j++){
            cin >> tmp;
            s[i] += pow(2, tmp - 1);
        }
    }
    for (int i = 1; i <= m; i++){
        cin >> p[i];
    }

    bool success;
    int result = 0;
    for (int i = 0; i < (1 << n); i++){
        success = true;
        for (int j = 1; j <= m; j++){
            if (__builtin_popcount(i & s[j]) % 2 != p[j]){
                success = false;
                break;
            }
        }
        if (success){
            result++;
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = sorted((int(x) for x in input().split()))
 
parent = [A[-1]]
rest = A[:-1]
bl = True
for _ in range(N):
    next_parent = []
    next_rest = []
    for p in parent[::-1]:
        while rest:
            x = rest.pop()
            if x < p:
                next_parent.append(x)
                break
            else:
                next_rest.append(x)
                continue
    parent += next_parent
    parent.sort()
    rest = rest + next_rest[::-1]
 
bl = len(parent) == (2**N)
answer = 'Yes' if bl else 'No'
print(answer)
 

Measured memory_bytes: 34404
#include<stdio.h>
int main(){
  int sx,sy,tx,ty;
  scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
  int i,num;
  for(num=0;num<2;num++){
    if(num==1)
      printf("L");
    for(i=sy;i<ty+num;i++)
      printf("U");
    for(i=sx;i<tx+num;i++)
      printf("R");
    if(num==1)
      printf("DR");
    for(i=sy;i<ty+num;i++)
      printf("D");
    for(i=sx;i<tx+num;i++)
      printf("L");
    if(num==1)
      printf("U");
  }
  puts("");
  return 0;
}

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

int main () {
  int N , K;
  cin >> N >> K;
  int i=1, Hiyayakko=0;
  while (i < K && Hiyayakko < N){
    i*=2,Hiyayakko++;;;;;;;;;;;;;;;;;;;;
  }
  cout << (N-Hiyayakko)*K+i<< endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
string x,s[55];
int n,ans,ab,t[55];
int main(){
	n=read();
	for(int i=0;i<n;i++)
		cin >> s[i] >> t[i];
	cin >> x;
	for(int i=0;i<n;i++){
		ans+=t[i]*ab;
		if(s[i]==x)ab=1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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 int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX / 10000;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };


int main()
{
	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;
}


Measured memory_bytes: 3624
N,A,B = map(int,input().split())
goukei = 0

for i in range(N+1):
    c = 0
    t = i
    while t > 0:
        c += t % 10
        t //= 10
    if c >= A and c <=B:
        goukei += i
print(goukei)

Measured memory_bytes: 39536
N = int(input())
A = [int(c) for c in input().split()]

X = [None]*N
X[0] = sum(A) - sum(A[1::2])*2

for i in range(N-1):
    X[i+1] = 2*A[i]-X[i]

print(' '.join([str(x) for x in X]))

Measured memory_bytes: 19144
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		Console.WriteLine("{0}",s[2]*60+s[3]-s[0]*60-s[1]-s[4]);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 27568
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


int main() {
    char a, b; cin >> a >> b;

    int na = a - '0';
    int nb = b - '0';

    string sa = "";
    for (int i=0; i<nb; i++) sa += a;
    string sb = "";
    for (int i=0; i<na; i++) sb += b;

    vector<string> ss = {sa, sb};
    sort(ss.begin(), ss.end());

    cout << ss[0] << endl;
    return 0;
}



Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main(){
  int H,N,cnt;
  cin>>H>>N;
  vector <int> A(N,0);
  for(int i = 0;i<N;i++){
    cin>>A[i];
  }
  int sum = accumulate(A.begin(),A.end(),0);
    
  if(H>sum) 
    cout<<"No\n";
  else
    cout<<"Yes\n";

return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {

        static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        public static void main(String[] args) throws Exception{

            int cnt = 0;
            String row;

            while ((row = reader.readLine()) != null) {
                if (isPalindrome(row)) {
                    cnt++;
                }
            }

            System.out.println(cnt);

        }

        public static boolean isPalindrome(String row) {
            if (row.length() == 1) return true;

            int half = row.length() / 2;
            for (int i=0; i<half; i++) {
                if (row.charAt(i) != row.charAt(row.length() - i - 1)) {
                    return false;
                }
            }
            return true;
        }

}

Measured memory_bytes: 16864
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll num = 0;
  rep(i,n) num = num ^ a[i];
  bool can = true;
  if (num == 0) {
    sort(a.begin(), a.end());
    if (n % 3 == 0) {
      rep(i,n) {
        if (i < n/3) {
          if (a[i] != a[0]) can = false;
        } 
        else if (i < 2*n / 3) {
          if (a[i] != a[n/3]) can = false;
        } 
        else {if (a[i] != a[2*n/3]) can = false;}
      }
      if (((a[0]^a[n/3])^a[2*n/3]) != 0) can = false;
      
    } else {
      rep(i,n) if (a[i] != 0) can = false;
    }
  } 
  else can = false;
  
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 4012
#include<bits/stdc++.h>
#define REP(i, a, b) for(int i(a); i <= (b); ++i)

#define gc getchar()
struct Reader {
	template <class T> inline operator T() {
		T w; char c, p = 0;
		for(; !isdigit(c = gc); c == '-' && (p = 1));
		for(w = c & 15; isdigit(c = gc); w = w * 10 + (c & 15));
		return p ? -w : w;
	}
} rd;

template <class T> inline bool smin(T&x, const T&y) { return y < x ? x = y, 1 : 0; }
template <class T> inline bool smax(T&x, const T&y) { return x < y ? x = y, 1 : 0; }

typedef long long ll;

const int N(1e5 + 5);
int n, k, a[N], f[N];

int main() {
	n = rd, k = rd;
	REP(i, 1, n) a[i] = rd;
	REP(i, 2, n){
		f[i] = f[i - 1] + abs(a[i] - a[i - 1]);
		for (int j = 2; j < i && j <= k; ++j)
			smin(f[i], f[i - j] + abs(a[i] - a[i - j]));
	}
	std::cout << f[n];
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int main() {
    int n,k;
    cin>>n>>k;
    int a[n],i,j;
    for(i=0;i<n;i++)
    cin>>a[i];
    bool v[k+1]={false};
    for(i=0;i<=k;i++)
    {
        for(j=0;j<n;j++)
        {
            if(i>=a[j])
            {
                bool z=v[i-a[j]];
                if(z==false)
                v[i]=true;
            }
        }
    }
    if(v[k]==true)
    cout<<"First";
    else
    cout<<"Second";
}

Measured memory_bytes: 3744
#include<stdio.h>
int main()
{
	int i,m,r,a,b;
	for(;;printf("%c %d\n",m+'A',r))
		for(i=m=r=0;i<5;i++)
		{
			scanf("%d%d",&a,&b);
			if(!a&&!b)return 0;
			if(r<a+b)
				r=a+b,m=i;
		}
}

Measured memory_bytes: 600
n=int(input())
aM=0
am=10**9
bm=10**9
for _ in range(n):
    a,b = map(int,input().split())
    if a>aM:
        aM=a
        bm=b
    if a<am:
        am=a
ans=aM-am+1
if bm>0:
    ans+=bm
ans+=am-1
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	
	if(a>c) swap(a,c);
	if(b>c) swap(b,c);
	if(a>b) swap(a,b);
	
	int cnt=0;
	if(c-a>1){
		cnt+=(c-a)/2;
		a+=2*cnt;
	}
	if(c-b>1){
		int tmp=(c-b)/2;
		cnt+=tmp;
		b+=2*tmp;
	}
	
	if(a<c and b<c) cnt++;
	else if(a==c and b==c) cnt+=0;
	else cnt+=2;
	
	cout<<cnt<<endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  int N;
  string S;
  cin >> N;
  cin >> S;
  int ans=0;
  int t=0;
  REP(i,N){
    if(S[i]=='I')t++;
    else t--;
    ans=max(ans,t);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
*h,=map(int,input().split())
dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 13928
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next() {
			while(st==null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
					
				}
				catch(IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
	public static void main(String[] args) {
		FastReader ob = new FastReader();
		int n = ob.nextInt(),k=ob.nextInt();
		System.out.println((int)Math.floor(Math.log((double)n)/Math.log((double)k)) + 1);
				
	}

}


Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

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


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, K; std::cin >> N >> K;
  std::vector<int> h(N); rep(i,N) std::cin >> h[i];

  int ans = 0;
  rep(i,N){
    if ( h[i] >= K ) ans++;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(i,a,b) for (int i = a; i <= (b); ++i) 
typedef long long ll;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
/*
	　　　  　 ,ﾍ／L──- 、
	　　　   　Lﾆ)r_」=＝= ｲ
	　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
	　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
	　　 .i　　 >〈(つ,i!と)　　i
	　　  vﾍγk´_/___i,ゝﾍノ
	　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
*/
int n;
ll ans = 0;
ll anssum = 0;
cin >> n;
vector<ll>a(n - 1);
vector<ll>anser(n);
rep0(i, n - 2) {
	cin >> a[i];
}
if (n == 2) {
	cout << a[0] * 2 << endl;
	return 0;
}
else {
	if(a[0] >= a[1])
	anser[0] = max(a[0], a[1]);
	else
	anser[0] = min(a[0], a[1]);
	rep0(j, n - 3) {
		anser[j + 1] = min(a[j], a[j + 1]);
	}
	anser[n - 1] = a[a.size()-1];
}
rep0(ii, n - 1) {
	anssum += anser[ii];
}
cout << anssum << endl;
return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
int N,M;
int kazu[100001];
int aka[100001];
int main(){
  int i,j;
  int x,y;
  int ans=0;
  scanf("%d %d",&N,&M);
  for(i=1;i<=N;i++)kazu[i]=1;
  aka[1]=1;
  for(i=0;i<M;i++){
    /*
    for(j=1;j<=N;j++)printf("%d ",kazu[j]);
    printf("\n");
    for(j=1;j<=N;j++)printf("%d ",aka[j]);
    printf("\n");
    */
    scanf("%d %d",&x,&y);
    if(kazu[x]>1){
      if(aka[x]==1){
	kazu[x]--;
	kazu[y]++;
	aka[y]=1;
      }
      else{
	kazu[x]--;
	kazu[y]++;
      }
    }
    else if(kazu[x]==1){
      if(aka[x]==1){
	kazu[x]--;
	kazu[y]++;
	aka[y]=1;
	aka[x]=0; 
      }
      else{
	kazu[x]--;
	kazu[y]++;
      }
    }
  }
  for(i=1;i<=N;i++){
    if(aka[i]==1)ans++;
  }
  printf("%d\n",ans);
  return 0;
}


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

int N;
double p;
vector<double> P;
vector<vector<double>> dp;

int center(int n){
  if(n & 1) return (n/2+1);
  else return n/2;
}

int main(){
  cin >> N;
  dp.resize(N+1, vector<double>(N+1, 0));
  dp[0][0] = 1.;

  for(int i = 0; i < N; i++){ cin >> p; P.push_back(p); }
  for(int i = 1; i <= N; i++){
    dp[i][0] = dp[i-1][0] * (1-P[i-1]);
    for(int j = 1; j <= i; j++) dp[i][j] = dp[i-1][j-1] * P[i-1] + dp[i-1][j] * (1-P[i-1]);
  }

  double p = 0;
  for(int i = center(N); i <= N; i++) p += dp[N][i];
  printf("%.10f\n", p);
  
  return 0;
}

    

Measured memory_bytes: 70784
#include <iostream>
#include <algorithm>
#include <stack>
using namespace std;
#define MAX 100005
int a[MAX];
stack<int> s;

int main(){
	int n, k, tmp, f, maxt = 0, maxa = 0;
	while(cin >> n >> k, n){
		fill(a, a+MAX, MAX+1);
		for(int i = 0;i < k;i++){cin >> tmp;a[i] = tmp;}
		sort(a, a+MAX);
		f = !a[0];tmp = a[f]-1;
		for(int i = f;i < k+1;i++){
			if(tmp+1 != a[i]){
				maxa = max(maxa, maxt);
				s.push(maxt);
				if(a[i-1]+2 == a[i])s.push(-1);
				else s.push(-2);
				maxt = 0;
			}
			tmp = a[i];maxt++;
		}
		if(!f){cout << maxa << endl;continue;}
		s.pop();maxt = s.top();s.pop();
		while(!s.empty()){
			if(s.top() == -1){
				s.pop();
				int g = s.top();
				maxa = max(maxa, maxt+g+1);
			}else s.pop();
			maxt = s.top();s.pop();
		}
		cout << maxa << endl;
	}
	return 0;
}

Measured memory_bytes: 3552
fn main() {
    let s: String = read();
    let cs: Vec<char> = s.chars().collect();
    let n = cs.len();
    print!("{}", cs[0]);
    print!("{}", n-2);
    println!("{}", cs[n-1]);
}

// 以下関数


use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 1_000_000_007;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

pub fn factorial(n: u32) -> u32 {
    if n == 0 {
        return 1
    }
    let mut r = n;
    for i in 0..n-1{
        r *= n-i-1;
    }
    r
}

pub fn combination(n: u32, m: u32) -> u32 {
    factorial(n) / factorial(m) / factorial(n-m)
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
constexpr const int INF=1<<30,MOD=1000000007;constexpr const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
#ifndef LOCAL
struct osd{template<class T>osd&operator<(const T&t){return*this;}template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;template<class...T>void _print(osd&a,T&&...t){}
#define cerr cer_
#endif
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}template<class T>istream&operator>(istream&i,T&t){return i>>t;}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<t<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}template<class...T>void dprint(T&&...t){_print(cerr,t...);}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<p.F<' '<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>p.F>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>queue<T>&operator<<(queue<T>&q,const T&t){q.push(t);return q;}template<class T>queue<T>&operator<<(T&t,queue<T>&q){t=q.front();q.pop();return q;}
template<class T>deque<T>&operator>>(const T&t,deque<T>&q){q.push_front(t);return q;}template<class T>deque<T>&operator<<(T&t,deque<T>&q){t=q.front();q.pop_front();return q;}
template<class T>deque<T>&operator<<(deque<T>&q,const T&t){q.push_back(t);return q;}template<class T>deque<T>&operator>>(deque<T>&q,T&t){t=q.back(t);q.pop_back();return q;}
template<class T>stack<T>&operator<<(stack<T>&s,const T&t){s.push(t);return s;}template<class T>stack<T>&operator>>(stack<T>&s,T&t){t=s.top();s.pop();return s;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int r;
    cin>>r;cout<<3*r*r<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int M = 1e9+7;

long long memo[100100];

long long mpow(long long a, int n)
{
  if (n % 2) return mpow(a, n-1)*a%M;
  if (not n) return 1;
  return mpow(a*a%M, n/2);
}

int main()
{
  int n, k; cin >> n >> k;
  
  long long ans = 0;
  for (int i = k; i > 0; --i) {
    long long sum = 0;
    for (int j = 2; i*j <=k; ++j) sum = (sum + memo[i*j]) % M;
    memo[i] = (mpow(k/i, n) - sum + M) % M;
    ans = (ans + memo[i] * i) % M;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4412