akhauriyash/Code-Regression huggingface dataset:
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let mut a: Vec<i32> = sc.vec(n);
    a.sort();
    for x in a.windows(2) {
        if x[0] == x[1] {
            println!("NO");
            return;
        }
    }
    println!("YES");
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

const int MAX_N=51;
vector<int> par(MAX_N);
vector<vector<int>> G(MAX_N);

void dfs(int v,int p){
    for(int u:G[v]){
        if (u==p) continue;
        par[u]=v;
        dfs(u,v);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    map<Pii,int> m;
    rep(i,N-1){
        int a,b; cin >> a >> b; --a,--b;
        m[{a,b}]=m[{b,a}]=i;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    int M; cin >> M;
    vector<int> u(M),v(M);
    rep(i,M){
        cin >> u[i] >> v[i];
        --u[i],--v[i];
    }
    vector<vector<int>> list(M);
    rep(i,M){
        rep(i,N) par[i]=-1;
        dfs(u[i],-1);
        int t=v[i];
        while(t!=u[i]){
            list[i].emplace_back(m[{t,par[t]}]);
            t=par[t];
        }
    }
    vector<ll> po(N,1);
    rep(i,N-1) po[i+1]=po[i]*2;
    ll ans=0;
    rep(bit,1<<M){
        vector<int> cnt(N-1,0);
        int flag=0;
        rep(i,M){
            if (bit&1<<i){
                ++flag;
                for (int e:list[i]) ++cnt[e];
            }
        }
        int c=0;
        rep(i,N-1) if (cnt[i]==0) ++c;
        if (flag%2==0) ans+=po[c];
        else ans-=po[c];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define x first
#define y second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

int a[210];

int main()
{
	int n;scanf("%d",&n);
	for (int i=1;i<=2*n;i++) scanf("%d",&a[i]);
	sort(a+1,a+2*n+1);
	int ans=0;
	for (int i=1;i<=2*n;i+=2) ans+=a[i];
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define CL clear()







int main()
{
    map<string, ll> b, r;
    ll n, m;
    b.CL;
    r.CL;
    cin >> n ;
    string s;
    while(n--)
    {
        cin >> s;
        if(b.count(s)==0)
        {
            b[s] = 0;
        }
        b[s]++;
    }
    cin >> n;
    while(n--)
    {
        cin >> s;
        if(r.count(s)==0)
        {
            r[s] = 0;
        }
        r[s]++;
    }
    map<string, ll> ::iterator it;
    m = 0;
    for(it = b.begin(); it!= b.end(); it++)
    {
        if(r.count(it->F))
            m = max(m, it->S - r[it->F]);
        else
            m = max(m, it->S);
    }
    cout << m ;

    return 0;
}


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

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

    int l, i = 0, a[n];
    while (std::cin >> l) {
        a[i] = l;
        i++;
        if (i >= n) {
            break;
        }
    }

    std::sort(a, a + SIZE_OF_ARRAY(a));
    int halfN = n/2;

    std::cout << (a[halfN]-a[halfN-1]) << std::endl;
    

    return 0;
}

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

using namespace std;
int main()
{
    long long a,b,sum,fun,cnt;
    while(cin>>a>>b)
    {
        cnt=0;
        sum=a+b;
        for(;;)
        {
            fun=sum;
            sum=fun/10;
            cnt++;
            if(sum<=0) break;
        }
        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

#define KANMA string(",")

int main(void) {
	int w, n;

	cin >> w;
	cin >> n;

	int *ary = new int[w];
	int i;
	for (i = 0; i < w; i++) {
		ary[i] = i + 1;
	}

	cin >> ws;
	for (i = 0; i < n; i++){
		int a, b;
		string str;
		string::size_type pos = 0;

		getline(cin, str);
		
		pos = str.find(KANMA, pos);
		a = atoi(str.substr(0, pos).c_str());
		pos += KANMA.length();
		b = atoi(str.substr(pos).c_str());

		int c = ary[a - 1];
		ary[a - 1] = ary[b - 1];
		ary[b - 1] = c;
	}

	for (i = 0; i < w; i++) {
		cout << ary[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3028
A, B, C, D, E, F = map(int, input().split())
water = []
sugar = []
for i in range(F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        if i == 0 and j == 0:
            continue
        w = A * 100 * i + B * 100 * j
        if w > F:
            continue
        water.append(w)
water = sorted(list(set(water)))

for k in range(F // C + 1):
    for l in range(F // D + 1):
        s = C * k + D * l
        if s > F:
            continue
        sugar.append(s)
sugar = sorted(list(set(sugar)))

ans_list = [100 * A, 0]  # 初期値の設定

for m in water:
    for n in sugar:
        total = m + n
        if total > F:  # ビーカーの上限
            continue
        c = 100 * n / (m + n)
        if c > E * 100 / (100 + E):  # 濃度の上限
            continue
        if c > ans_list[1] * 100 / sum(ans_list):  # できる限り高濃度
            ans_list = [m, n]  # リストの更新
print(sum(ans_list), ans_list[1])  # 砂糖水と砂糖の量を出力

Measured memory_bytes: 12456
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        System.out.println(cal(n, k));
    }

    private static long cal(final int n, final int k) {
        long res = k;
        for (int i = 1; i < n; i++) {
            res *= k-1;
        }
        return res;
    }
}


Measured memory_bytes: 9804
#include <iostream>

using namespace std;

int main(void)
{
	int a, b;

	cin >> a >> b;

	int x = a + b, y = a - b, z = a * b;

	if (x > y)
	{
		if (x > z)
		{
			cout << x << endl;
		}
		else
		{
			cout << z << endl;
		}
	}
	else
	{
		if (y > z)
		{
			cout << y << endl;
		}
		else
		{
			cout << z << endl;
		}
	}

	return 0;
}

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;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multi_set;

#define mod         1000000007
#define pi          3.1415926535898
#define eps         1e-9


#define fast       ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define vt vector
#define ar array
#define fs          first
#define sc          second
#define pb         push_back
#define sp          printf(" ")
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define unique(c) (c).resize(unique(all(c)) - (c).begin())
#define sz(x) (int)(x).size()
#define revsort(x) sort(all(x));reverse(all(x))

#define set0(a)     memset(a,0,sizeof(a))
#define setneg(a)   memset(a,-1,sizeof(a))
#define setinf(a)   memset(a,126,sizeof(a))

#define REP(i,start,end) for (int i = start; i <=end; i++)
#define RREP(i,end,start) for (int i=end; i>=start ;i--)
#define EACH(x, a) for (auto& x: a)

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef vector<double> vd;
typedef vector<vector<LL> > matrix;
typedef vector<vector<int> > graph;
LL INF=1e9;


 
template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
	cin >> x;
}
void read(double& d) {
	string t;
	read(t);
	d=stod(t);
}
void read(long double& d) {
	string t;
	read(t);
	d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
	read(h);
	read(t...);
}
template<class A> void read(vt<A>& x) {
	EACH(a, x)
		read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
	EACH(a, x)
		read(a);
}

LL powm(LL x, LL y,LL m)
{
    if(y==0)
        return 1;
    if(y==1)
        return x%m;
    if(y&1)
        return (x*(powm((x*x)%m,y/2,m)))%m;
    return powm((x*x)%m,y/2,m)%m;
}

LL inv(LL x, LL m)
{
    return powm(x,m-2,m);
}

int add(int var1, int var2){
    return (((((LL)(var1)) % mod + (LL)(var2)) % mod) + mod) % mod;
}


int mul(int var1, int var2){
    return (((LL)(var1)) % mod * (LL)(var2)) % mod;
}

void solve()
{
    int n;
    read(n);
    vll a(n);
    read(a);
    LL ans=0;
    REP(i,1,n-1)
    {
        if(a[i]<a[i-1])
        {
            ans+=a[i-1]-a[i];
            a[i]=a[i-1];
        }    
    }
    cout<<ans<<nl;
}
int main()
{
    fast;
        solve();
}


Measured memory_bytes: 4772
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;



int main(){
    ll n,k,mod;
    cin>>n>>k>>mod;
    map<pair<deque<int>,int>, ll> dp[222];
    dp[0][{{0,1},1}]=1;
    rep(i,2*n-1){
        int nxt = i+2;
        for(auto& e : dp[i]){
            deque<int> f = e.first.first;
            int s = e.first.second;
            if(f.size()==1){
                if(f[0]+k<nxt)continue;
                f.push_back(nxt);
                dp[i+1][{f,s}]+=e.second%mod;   
            }
            else{
                if(s+k<nxt)continue;
                if(f[1]+k<nxt)continue;
                f.push_back(nxt);
                dp[i+1][{f,s}]+=e.second%mod;
                f.pop_back();
                f.pop_front();
                dp[i+1][{f,nxt}]+=e.second%mod;
            }
        }
        dp[i].clear();
    }
    ll ans = 0;
    rep(i,k){
        deque<int> f;
        f.push_back(2*n-1-i);
        ans += dp[2*n-1][{f,2*n}]%mod;
    }
    cout<<ans%mod<<endl;
    return 0;
}


Measured memory_bytes: 6136
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;

    vector<vector<ll>> alpha(26);
    rep(i, s.size()) {
        int c = s[i] - 'a';
        alpha[c].push_back(i);
    }

    ll ans = 0;
    ll now = -1;
    rep(i, t.size()) {
        int tc = t[i] - 'a';
        while (1) {
            auto it = upper_bound(ALL(alpha[tc]), now);
            if (it != alpha[tc].end()) {
                ans += *it - now;
                now = *it;
                break;
            } else {
                if (now == -1) {
                    cout << -1 << endl;
                    return 0;
                } else {
                    ans += s.size() - now - 1;
                    now = -1;
                }
            }
            // cout << "i:" << i << " t[i]:" << t[i] << " now:" << now << " *it:" << *it << " ans:" << ans << endl;  //
            // debug
        }
    }

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


Measured memory_bytes: 1724
/*
ID: jerrywcy
TASK: AtCoder ABC 108 Problem A
LINK: https://abc108.contest.atcoder.jp/tasks/abc108_a
LANG: C++
*/
#include <bits/stdc++.h>

using namespace std;

int k;

int main()
{
	cin>>k;
	cout<<(k/2)*((k+1)/2)<<endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	string s;
	cin>>s;
	if(s=="SUN")puts("7");
	if(s=="MON")puts("6");
	if(s=="TUE")puts("5");
	if(s=="WED")puts("4");
	if(s=="THU")puts("3");
	if(s=="FRI")puts("2");
	if(s=="SAT")puts("1");
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;


int search(int lim,int money)
{
	money=money*1.05;
	
	if(money%1000>0)
	{
		money/=1000;
		money*=1000;
		money+=1000;
//		cout << "in " << money << endl;
	}
	if(lim==1)
		return money;
	
	
	search(lim-1,money);
}

int main()
{
	int n;
	
	cin >> n ;
	
	int ans = search(n,100000);
	
	cout << ans << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    long long int x,y,ans;
    cin>>x>>y;
    if(x%y==0)ans=-1;
    else{
        ans=x*y+x;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n, k = sc.nextInt()
  val h = Array.fill(n)(sc.nextInt()).sorted
  var ans = Int.MaxValue
  for (i <- 0 to h.length - k) yield {
    val h2 = h.slice(i, i+k)
    val diff = h2(k-1) - h2(0)
    if (diff < ans) ans = diff
  }
  println(ans)
}

Measured memory_bytes: 61024
#include <stdio.h>

typedef long long int64;
typedef unsigned long long uint64;

int main()
{
	uint64 x, a = 100, b = 0;
	scanf("%llu", &x);

	while (1) 
	{
		b++;
		a *= 1.01;
		if (a >= x) 
		{
			printf("%llu", b);
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1728
import java.util.*;

public class Main {    
    
   public static void main(String[] args){
       
       Scanner sc = new Scanner(System.in);
    
       int A = sc.nextInt();
       String op = sc.next();
       int B = sc.nextInt();
       
       if(op.equals("+")){
           System.out.println(A + B);
       }else if(op.equals("-")){
           System.out.println(A - B);
       }              
       
   }
}
        
        
        
        

Measured memory_bytes: 21844
def main():
    from itertools import product
    h, w, k = map(int, input().split())
    c = [input() for _ in range(h)]

    ans = 0
    for x in product([0, 1], repeat=h):
        for y in product([0, 1], repeat=w):
            res = 0
            for i, xx in enumerate(x):
                for j, yy in enumerate(y):
                    if xx and yy and c[i][j] == "#":
                        res += 1
            if res == k:
                #print(x, y, xx, yy, c[i][j])
                ans += 1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9200
//write：Sakura
//id：
//problem：
//note：

#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long ll;

int n;
int a[2*100005];
int b[2*100005]; 
ll ans=0;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i]-(i+1);
	}
	sort(b,b+n);
	for(int i=0;i<n;i++){
		ans+=abs(b[(n-1)/2]-b[i]);
	}
	printf("%lld\n",ans);
	return 0;
}


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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> mat;

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

int n;
vector<pair<string, int>> p;

void solve() {
  cin >> n;
  p.resize(n);
  rep(i, 0, n) cin >> p[i].fi >> p[i].se;

  vi ans;
  rep(i, 0, n) ans.pb(i);
  sort(ALL(ans), [&](int a, int b) {
    if (p[a].fi != p[b].fi) return p[a].fi < p[b].fi;
    return p[a].se > p[b].se;
  });

  rep(i, 0, n) { cout << ans[i]+1 << endl; }
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    set<int> s;
    vector<ll> ms(200005); 
    rep(i,n){
        ms[a[i]]++;
        s.insert(a[i]);
    }
    ll sum = 0;
    
    for(auto x: s){
        ll num = ms[x];
        sum = sum + ((num * (num-1)) /2); 
    }
    vector<ll> ans(n);
    rep(i,n){
        ll t = a[i];
        ll num = ms[t];
        ll ta = sum - ((num * (num-1)) /2) + (((num-1) * (num-2)) /2);
        ans[i] = ta;
    }
    rep(i,n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long inf=2147483647;
const long long maxn=100005;
int n,m,c,f[maxn];
int find(int x){
	if(x==f[x])return x;
	else return f[x]=find(f[x]);
} 
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		f[i]=i;
	while(m--){
		int x,y,z;
		cin>>x>>y>>z;
		int fatherx=find(x);
		int fathery=find(y);
		if(fatherx!=fathery){
			f[fatherx]=fathery;
			c++;
		}
	}
	cout<<n-c<<endl;
	return 0; 
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3+7 , mz = 1e9+7;

int main(){
    int n;
    cin>>n;
    int a[N] = {0};
    for(int i = 2 ; i <= n ; i++)   cin>>a[i];
    a[1] = a[2];
    a[n+1] = a[n];
    int sum = 0;
    for(int i = 1 ; i <= n ; i++){
        sum += min(a[i], a[i+1]);
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;
int main() {
  string s;
  cin >>s;
  int n=3;

  for(int bit=0; bit<(1<<n);bit++){
    int sum=s[0]-'0';
    int b[3]={0};
    for(int i=0 ; i<n ; i++){
        if(bit&(1<<i)) {sum+=s[i+1]-'0';b[i]=1;}
        else  {sum-=s[i+1]-'0';b[i]=0;}
    }
    if(sum==7){
      for(int i=0;i<n;i++){
        cout<<s[i];
        if(b[i]) cout<<"+" ;
        else cout<<"-";
      }
      cout<<s[3]<<"="<<"7"<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
B,M,S = 13,9,5
dx = [ 0, 0, 1, 0,-1, 1, 1,-1,-1, 0, 2, 0,-2]
dy = [ 0,-1, 0, 1, 0,-1, 1, 1,-1, 2, 0,-2, 0]
def isOnCloth(x,y):
    return 0<=x<10 and 0<=y<10
def soak(cloth,x,y,ink):
    for i in xrange(ink):
        cloth[y+dy[i]][x+dx[i]] -= 1
def drop(cloth,x,y,ink):
    for i in xrange(ink):
        cloth[y+dy[i]][x+dx[i]] += 1
def canSoak(cloth,x,y,ink):
    return all([isOnCloth(x+dx[i],y+dy[i]) and cloth[y+dy[i]][x+dx[i]]>0 for i in xrange(ink)])
def DFS(cloth,ink_set,cur):
    if len(ink_set)==0:
        #print "SUCCESS!"
        return []
    #print "\n".join(map(str,cloth))
    for i in xrange(cur,100):
        #print i
        if not cloth[i/10][i%10] == 0:
            break
        cur += 1
    for ink in set(ink_set):
        #print ink,cur
        for i in xrange(ink):
            cx,cy = cur%10+dx[i],cur/10+dy[i]
            if isOnCloth(cx,cy) and cloth[cy][cx]>0:
                #print cx,cy
                if canSoak(cloth,cx,cy,ink):
                    soak(cloth,cx,cy,ink)
                    ink_set.remove(ink)
                    result = DFS(cloth,ink_set,cur)
                    if not result == False:
                        result.append([cx,cy,ink])
                        return result
                    ink_set.append(ink)
                    drop(cloth,cx,cy,ink)
    return False
ink_set = [B,S]
clothA = [[0,0,0,0,0,0,0,0,0,0],
         [0,0,1,0,0,0,0,0,0,0],
         [0,1,1,1,0,0,0,0,0,0],
         [1,1,1,1,1,0,0,0,0,0],
         [0,1,1,1,0,0,0,0,0,0],
         [0,0,1,0,0,0,0,0,0,0],
         [0,0,0,0,0,0,0,0,0,0],
         [0,0,0,0,0,0,1,0,0,0],
         [0,0,0,0,0,1,1,1,0,0],
         [0,0,0,0,0,0,1,0,0,0],
         [0,0,0,0,0,0,0,0,0,0],]
clothB = [[0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0],
          [0,0,1,0,0,0,0,0,0,0],
          [0,1,1,1,0,0,0,0,0,0],
          [0,0,1,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0],
          [0,0,0,0,0,0,0,0,0,0],]
import itertools
n = input()
cloth = []
for u in xrange(10):
    cloth.append(map(int,raw_input().split(" ")))
#print "\n".join(map(str,cloth))
#print 
su = sum([sum(cloth[i]) for i in xrange(10)])
ink_sets = [list(a) for a in itertools.combinations_with_replacement([0,13,9,5],n) if sum(a) == su]
#print ink_sets
for ink_set in ink_sets:
    pass
    result = DFS(cloth,ink_set,0)
    if not result == False:
        break
dic = {B:3,M:2,S:1}
for r in result:
    print "{} {} {}".format(r[0],r[1],dic[r[2]])

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

typedef long long ll;
typedef pair<int, int> pii;
#define f(i , n) for (int i = 0; i < (int)(n); ++i)
#define f1(i, x, n) for (int i = x; i < (int)(n); ++i)
const int mod = 1000000007;
const int inf = 2012345678;
const double PI = acos(-1);
const ll infl = 9012345678901234567;
const double eps = 1e-8;
const int N = 1e5;
vector<int> vi[N];
bool vis[N] , vis2[N];
int arr[N];
vector<int> xx;
void dfs(int u){
	vis[u] = true;
	xx.push_back(u);
	f(i,vi[u].size())if(!vis[vi[u][i]])dfs(vi[u][i]);
}
int calc(int u){
	int ans = 0;
	xx.clear();
	memset(vis2 , 0 , sizeof vis2);
	dfs(u);
	f(i,xx.size())vis2[arr[xx[i]]]=true;
	f(i,xx.size())if(vis2[xx[i]] == true)++ans;
	return ans;
}
int main(){
	int n , m;
	scanf("%d%d" , &n , &m);
	f(i,n)scanf("%d" , arr + i);
	f(i,n)--arr[i];
	f(i,m){
		int a , b;
		scanf("%d%d" , &a , &b);
		--a , --b;
		vi[a].push_back(b);
		vi[b].push_back(a);
	}
	int ans = 0;
	f(i,n)if(!vis[i])ans+=calc(i);
	printf("%d\n",ans);
}

Measured memory_bytes: 9980
n = int(input())
import collections
co = collections.Counter()
for i in range(n):
    s = input()
    co[s] +=1
print(f"AC x {co['AC']}")
print(f"WA x {co['WA']}")
print(f"TLE x {co['TLE']}")
print(f"RE x {co['RE']}")


Measured memory_bytes: 9484
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        string s = ins();
        int up2 = (s[0] - '0') * 10 + (s[1] - '0');
        int low2 = (s[2] - '0') * 10 + (s[3] - '0');

        if (low2 == 0) {
            if (up2 >= 1 && up2 <= 12) cout << "MMYY" << endl;
            else cout << "NA" << endl;

        } else if (up2 == 0) {
            if (low2 <= 12) cout << "YYMM" << endl;
            else cout << "NA" << endl;

        } else if (up2 <= 12) {
            if (low2 <= 12) cout << "AMBIGUOUS" << endl;
            else cout << "MMYY" << endl;

        } else {
            if (low2 <= 12) cout << "YYMM" << endl;
            else cout << "NA" << endl;
        }


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string s;
int main()
{
    cin >> s;
    unsigned len=s.size();
    bool(s[0]==s[len-1])?(bool(len%2)?cout << "Second\n":cout << "First\n"):(bool(len%2)?cout << "First\n":cout << "Second\n");
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>
int main()
{
    long N,M;
    std::cin >> N >> M;
    std::vector<std::vector<long> > ship(200000+1);
    for(long i=0; i<M; i++){
        long a,b;
        std::cin >> a >> b;
        ship[a].push_back(b);
    }
    bool flag=0;
    std::vector<long> root;
    for(long i=0; i<ship[1].size();i++){
        root.push_back(ship[1][i]);
    }
    for(long i=0; i<root.size(); i++){
        for(long j=0; j<ship[root[i]].size(); j++){
            if(ship[root[i]][j]==N){
                flag=1;
                break;
            }
        }
    }
    if(flag){
        std::cout << "POSSIBLE" << std::endl;
    }else{
        std::cout << "IMPOSSIBLE" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 13048
#include <stdio.h>
int main()
{
    int N;
    int a,b;
    int sum;
    scanf("%d %d %d",&N,&a,&b);
    sum = N * a;
    if(sum > b)
        printf("%d\n",b);
    else
        printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){
  string S; cin >> S;
  map <char, int> M;

  bool flag = true;
  for (int i = 0; i < S.length(); i++){
    M[S[i]]++;
    if (M[S[i]] == 2){
      flag = false;
      break;
    }
  }
  
  if (flag == true){
    cout << "yes" << endl;
  }else{
    cout << "no" << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

ll f[123456], s[123456];//first, second
signed main() {
	ll n, u, v, a, b; cin >> n >> u >> v;
	vector<vector<ll>> G(123456);
	rep(i, n - 1) {
		cin >> a >> b; G[a].push_back(b); G[b].push_back(a);
	}

	f[u] = 0; s[v] = 0;
	queue<ll> que1, mae1, cnt1;
	for (int i = 0; i < G[u].size(); i++) {
		que1.push(G[u][i]); mae1.push(u); cnt1.push(1);
	}
	while (que1.size()) {
		f[que1.front()] = cnt1.front();
		for (int i = 0; i < G[que1.front()].size(); i++) {
			if (G[que1.front()][i] != mae1.front()) {
				que1.push(G[que1.front()][i]); mae1.push(que1.front()); cnt1.push(cnt1.front() + 1);
			}
		}
		que1.pop(); mae1.pop(); cnt1.pop();
	}

	queue<ll> que2, mae2, cnt2;
	for (int i = 0; i < G[v].size(); i++) {
		que2.push(G[v][i]); mae2.push(v); cnt2.push(1);
	}
	while (que2.size()) {
		s[que2.front()] = cnt2.front();
		for (int i = 0; i < G[que2.front()].size(); i++) {
			if (G[que2.front()][i] != mae2.front()) {
				que2.push(G[que2.front()][i]); mae2.push(que2.front()); cnt2.push(cnt2.front() + 1);
			}
		}
		que2.pop(); mae2.pop(); cnt2.pop();
	}

	ll go = 0;
	rep2(i, n) {
		//cout << f[i] << ' ' << s[i] << endl;
		if (f[i] < s[i]) { go = max(go, f[i] + (s[i] - f[i] - 1)); }
	}
	cout << go << endl;
	return 0;
}

Measured memory_bytes: 12456
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		int a, b, c;

		Scanner scan = new Scanner(System.in);

		a = Integer.parseInt(scan.next());
		b = Integer.parseInt(scan.next());
		c = Integer.parseInt(scan.next());

		if ((a < b) && (b < c)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 25924
#include <bits/stdc++.h>
using namespace std;
void oj()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}

int main()
{
	// oj();
	int n;
	cin>>n;
	if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9){
		cout<<"hon";
	}else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
		cout<<"pon";
	}else{
		cout<<"bon";
	}
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int m,d; cin >> m >> d;
    int res = 0;
    for(int i=4;i<=m;i++){
        for(int j= 22;j<=d;j++){
            int k=j/10;
            int x=j%10;
            if(i == x*k && x>=2 && k>=2)res++;
        }
    }
    cout << res << endl;
}


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

int main() {
	
	int N;
	cin >> N;
	
	long long int ans = 0;
	
	for(int i = 0; i < N; i++){
		long long int A, K;
		cin >> A >> K;
		while(true){
			if(A % K == 0){
				ans ^= (A / K);
				break;
			}
			if(A < K){
				break;
			}
			if(A / K + 1 < K){
				long long int rem = A % (A / K + 1);
				A = A / K * K / (A / K + 1) * (A / K + 1) + rem;
				if(A % K == 0){
					ans ^= (A / K);
					break;
				}
			}
			A -= A / K + 1;
			//cout << A << endl;
		}
		//cout << ans << endl;
	}
	
	if(ans != 0){
		cout << "Takahashi" << endl;
	}else{
		cout << "Aoki" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A[3];
    int sum=0;
    rep(i,3){
        cin >>A[i];
        sum+=A[i];
    }
    sort(A,A+3);
    cout << sum-A[1]*2<<endl;




}


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

int main(){
  int N;
  cin >> N;
  vector<int> P(N+10),Q(N+10);
  for(int i=1;i<=N;i++){cin >> P[i]; Q[P[i]]=i;}
  int M=0;
  for(int i=1;i<=N;i++){
    int cnt=1;
    while(i+1<=N && Q[i]<Q[i+1]){cnt++; i++;}
    M=max(M,cnt);
  }
  cout << N-M << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
    string N;
    cin>>N;
    int a=N.size();
    int ans=0;
    rep(i,a){
        if(N[i]=='2'){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
 
using namespace std;
 
int n;
char cs[105];
vector<int> parens;
int inserts[100];// 場所
int insert;
int depth;
int main() {
	scanf("%d",&n);
	scanf("%s",cs);
	for(int i=0;i<n;i++){
		if(cs[i]=='(')depth++;
		else depth--;
		if(depth<0){
			insert++;
			depth++;
		}
	}
	while(insert--)printf("(");
	for(int i=0;i<n;i++){
		printf("%c",cs[i]);
	}
	while(depth--)printf(")");
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
  int N;
  // string op;
  cin >> N;
  int p = 0, w = 0, g = 0, y = 0;

  rep(i, N)
  {
    string s;
    cin >> s;
    // cout << s << endl;
    if (s == "P")
    {

      p = 1;
    }
    else if (s == "W")
    {

      w = 1;
    }
    else if (s == "G")
    {

      g = 1;
    }
    else if (s == "Y")
    {
      y = 1;
    }
  }
  // cout << p << w << g << y << endl;

  if ((p + w + g + y) == 3)
  {
    cout << "Three" << endl;
  }
  else
  {
    cout << "Four" << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string s; cin>>s;
	if(s=="SUN") cout<<7;
	else if(s=="MON") cout<<6;
	else if(s=="TUE") cout<<5;
	else if(s=="WED") cout<<4;
	else if(s=="THU") cout<<3;
	else if(s=="FRI") cout<<2;
	else cout<<1;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846264338327950L

ll res;

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

    vector<ll> data(3);
    for(int i = 0; i < 3; i++ )
    {
        cin >> data[i];
    }
    sort(data.begin(), data.end());
    if(data[2]%2==0){
        res = 0;
    }else{
        res = data[0] * data[1];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll a[100005];
int main() {
	ll n, m;
	cin >> n >> m;
	ll ans = 0,count= 0;
	vector<pair<ll, ll>>q(n);
	ll a, b;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		q[i] = make_pair(a, b);
	}
	sort(q.begin(), q.end());
	for (int i = 0; i < n; i++) {
		if (count+q[i].second< m) {
			ans += q[i].first * q[i].second;
			count += q[i].second;
		}
		else {
			ans += (m - count) * q[i].first;
			count = m;
		}
		
	}
	cout << ans << endl;
	return 0;
}


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

def main():
    x = int(input())
    primes = sieve(300000)
    for p in primes:
        if x <= p:
            print(p)
            return
    raise ValueError

# O(nloglogn) https://mathtrain.jp/eratosthenes
def sieve(n):  # exclusive
    s = [True] * n
    for x in range(2, int(n**0.5) + 1):
        if s[x]:
            for i in range(2 * x, n, x):
                s[i] = False
    return [i for i in range(2, n) if s[i]]

if __name__ == "__main__":
    main()


Measured memory_bytes: 6432
#include <iostream>
#include <vector>
//#include <fstream>	// require freopen

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.sugoroku", "r", stdin );
	int n, m;
	int i,j;

	while (cin >> n >> m && n && m){

		vector <int> board (n+1, 0 );

		for (i = 1; i <= n; ++i ){
			cin >> board[i];
		} // end for

		vector <int> dice (m+1, 0 );

		for (j = 1; j <= m; ++j ){
			cin >> dice[j];
		} // end for

		int res = 1;
		int pos = 1;

		while (1){
			pos += dice[res];
			pos += board[pos];

			if (pos >= n ){
				break;
			} // end if

			++res;
		} // end while

		cout << res << endl;
	} // end loop
	
	return 0;
}

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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int inf = (int) 1e9;
const int mod = (int) 1e9 + 7;

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 gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	int x[m], y[m];
	rep(i, m) {
		cin >> x[i] >> y[i];
		x[i]--;
		y[i]--;
	}
	
	int num[n];
	rep(i, n) num[i] = 1;
	bool red[n];
	rep(i, n) {
		if (i == 0) red[i] = true;
		else red[i] = false;
	}
	
	rep(i, m) {
		if (num[x[i]] >= 2 and red[x[i]] == true) {
			red[y[i]] = true;
		}
		if (num[x[i]] == 1 and red[x[i]] == true) {
			red[x[i]] = false;
			red[y[i]] = true;
		}
		num[x[i]]--;
		num[y[i]]++;
//		rep(i, n) cout << num[i] << " " << red[i] << endl;
	}
	
	int cnt = 0;
	rep(i, n) {
		if (red[i]) cnt++;
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>

using namespace std;

int main(){
  int H,W;
  string str[100];
  cin  >> H >> W;
  for(int i=0;i<H;i++){
    cin >> str[i];
  }
  for(int i=-1;i<W+1;i++){
    cout << "#";
  }
  cout << endl;
  for(int i=0;i<H;i++){
    cout << "#" + str[i] + "#" << endl;
  }
  for(int i=-1;i<W+1;i++){
    cout << "#";
  }
  cout << endl;
}


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

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

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

int main()
{
    ll d, n;
    cin >> d >> n;

    if (n == 100)
        n = 101;
    cout << (ll)(powl(100,d) * n) << endl;
    return 0;
}


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

int main()  {
 int size;
 string str;

 cin >> str;

 size = str.length();

 int sum = 0;
 for(int i = 0; i < size; i++) {
   if(str[i] == '1') {
     sum++;
   }
 }

 cout << sum << endl;

 return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	int n = 1;
	for (int i = 0; i < M; i++) {
		n *= 2;
	}

	int ans = 1900 * M + 100 * (N - M);
	ans *= n;

	cout << ans << endl;
}

Measured memory_bytes: 3588
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

int A[400020], nxt[400020], idx[200020];
int a[60][200020];//a[k][i]=A[i]の数字を先頭とする2^k個のブロックの要素数
int N, K;
int func(int k, int i) {
	if (a[k][i] > 0)return a[k][i];
	int res = func(k - 1, i) + func(k - 1, (i + func(k - 1, i)) % N);
	a[k][i] = res;
	return res;
}

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

	//clock_t start = clock();

	cin >> N >> K;
	REP(i, N) {
		cin >> A[i]; A[i + N] = A[i];
	}


	REP(i, 200020)idx[i] = -1;
	REPR(i, N * 2 - 1) {
		if (idx[A[i]] == -1) {
			idx[A[i]] = i;
		}
		else {
			nxt[i] = idx[A[i]];
		}
		nxt[i] = idx[A[i]];
		if (i < N) {
			a[0][i] = nxt[i] - i + 1;
		}
		idx[A[i]] = i;
	}
	/*REP(i, N) {
		pe(a[0][i]);
	}cout << endl;*/

	ll nex = 0;
	ll pos = 0;
	while (pos < (N)*(K-1)) {	
		REP(k, 60) {
			if (pos+func(k, pos%N) > N*K) {
				pos = pos+func(k - 1, pos%N);
				break;
			}
		}
		//print(pos);
	}
	pos %= N;
	//print(pos);
	REP(i, N) {
		nxt[i] %= N;
	}
	vector<int>ans;
	for (int i = pos; i < N; i++) {
		if (nxt[i] <= i) {
			ans.pb(A[i]);
		}
		else {
			i = nxt[i];
		}
	}
	REP(i, ans.size()) {
		pe(ans[i]);
	}cout << endl;
}


Measured memory_bytes: 99840
#include <iostream>

using namespace std;

void solve()
{
	char a, b;
	cin >> a >> b;
	if ((a == 'H' && b == 'H') || (a == 'D' && b == 'D'))
	{
		cout << 'H' << endl;
	}
	else
	{
		cout << 'D' << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String str = sc.next();
		int Rcount = 0;
		int Bcount = 0;

		for (int i = 0; i < N; i++) {
			String str2 = String.valueOf(str.charAt(i));
			if(str2.equals("R")){
				Rcount++;
            }else{
				Bcount++;
            }
		}
		if(Rcount>Bcount){
			System.out.println("Yes");
        }else{
			System.out.println("No");
        }
	}
}


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

//#define int long long
typedef long long ll;
const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    clock_t start = clock();
    int D;
    cin >> D;
    vector<int> c(26);
    for (int i=0;i<26;i++) cin >> c[i];
    vector<vector<int>> s(D,vector<int>(26));
    for (int i=0;i<D;i++){
        for (int j=0;j<26;j++){
            cin >> s[i][j];
        }
    }
    vector<int> t(D);
    //初期t[i]の決定
    for (int i=0;i<D;i++) {
        t[i] = i % 26;
    }

    ll oldsum = -INF;
    while (clock() - start < 1.9 * CLOCKS_PER_SEC) {
        //ここでt[i]を更新していく
        int process = rand()%2;
        if (process == 0){
            int dd = rand()%D;
            int qq = rand()%26;
            int oldval = t[dd];
            t[dd] = qq;
            ll sum = 0;
            vector<int> last(26);
            for (ll i=0;i<D;i++){
                sum += s[i][t[i]];
                last[t[i]] = i+1;
                for (int j=0;j<26;j++){
                    sum -= c[j]*(i+1-last[j]);
                }
            }
            if (sum > oldsum) {
                oldsum = sum;
            } else {
                t[dd] = oldval;
            }
        } else {
            int dd1 = rand()%(D-1);
            int dd2 = dd1 + 1 + rand()%min(D-dd1-1,16);
            int qq1 = t[dd1];
            int qq2 = t[dd2];
            t[dd1] = qq2;
            t[dd2] = qq1;
            ll sum = 0;
            vector<int> last(26);
            for (ll i=0;i<D;i++){
                sum += s[i][t[i]];
                last[t[i]] = i+1;
                for (int j=0;j<26;j++){
                    sum -= c[j]*(i+1-last[j]);
                }
            }
            if (sum > oldsum) {
                oldsum = sum;
            } else {
                t[dd1] = qq1;
                t[dd2] = qq2;
            }
        }
        //=======================       
    }
    for (int i=0;i<D;i++){
        cout << t[i]+1 << "\n";
    }
}

Measured memory_bytes: 3720
/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
typedef long long Long;

const int N = 1e5;

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int tc, ca = 0;
  int n, el;
  cin >> n;
  vector <int> mark(n+1, 0);
  for (int i = 0;i < n-1;i++){
    cin >> el;
    mark[el]++;
  }
  for (int i = 1;i <= n;i++){
    cout << mark[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 3988