akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 1000000000
#define MOD 1000000007
#define ll long long int

using namespace std;



int main(){
	int N;
	cin>>N;
	int dp1[1000] = {};
	dp1[0] = 0;
	int dp2[1000] = {};
	dp2[0] = 0;

	for(int i=1;i<=N;i++) {
		int a;
		cin>>a;
		dp1[i] = a + dp1[i-1];

	}

	for(int i=1;i<=N;i++){
		int a;cin>>a;
		dp2[i] = max(dp1[i],dp2[i-1]) + a;
	}
cout<<dp2[N]<<endl;



	return 0;
}

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

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

//  -d
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int mxval = 0;
    // int mnpos  = 0;
    bool mnext = false;
    vector<int> valpos;
    rep(i, 0, n) {
        cin >> a[i];
        if (a[i] == mxval + 1) {
            valpos.push_back(i);
            mnext = true;
            mxval++;
        }
    }

    // そもそも1がない
    if (mnext == false) {
        cout << -1 << endl;
        return 0;
    }

    cout << n - valpos.size() << endl;
}



Measured memory_bytes: 2168
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, j) for (long long i = 0; i < j; i++)
#define int long long

using namespace std;

signed main()
{
    double N;
    cin >> N;
    cout << ((double)((int)(N + 1) / 2) / N) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static String map[][];
	static int h, w;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		h = sc.nextInt();
		w = sc.nextInt();
		map = new String[h][];
		for(int i = 0;i < h;i++){
			map[i] = sc.next().split("");
		}

		if(search(0,0) == w+h-1){
			System.out.println("Possible");
		}else{
			System.out.println("Impossible");
		}

	}

	static int search(int a, int b){
		int res = 0;
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				if(map[i][j].equals("#")){
					res++;
				}
			}
		}
		return res;
	}
}

Measured memory_bytes: 9812
from collections import deque

N = int(input())
adj = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)


def dfs(adj, start):
    que = deque()
    que.append(start)
    depth = [0] * len(adj)
    visited = [0] * len(adj)
    while que:
        v = que.pop()
        visited[v] = 1
        for u in adj[v]:
            if visited[u] == 0:
                que.append(u)
                depth[u] = depth[v] + 1
    return depth


depth1 = dfs(adj, 1)
temp = 0
max_i = 0
for i, x in enumerate(depth1):
    if x > temp:
        max_i = i
        temp = x
longest_path = max(dfs(adj, max_i)) + 1
if longest_path % 3 == 2:
    print('Second')
else:
    print('First')


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

int main(void){
    int n, k, q;
    cin >> n >> k >> q;

    vector<int> firstPoints(n);
    for(int i = 0; i < n; i++){
      firstPoints.at(i) = k - q;
    }

    for(int i = 0; i < q; i++){
        int a;
        cin >> a;

        firstPoints.at(a-1)++;
    }

    for(int i = 0 ; i < n; i ++){
        if(firstPoints.at(i) > 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll a,b,m;cin>>a>>b>>m;
    vi v(a),u(b);
    rep(i,a)cin>>v[i];
    rep(i,b)cin>>u[i];
    ll mi1=inf,mi2=inf;
    rep(i,a)chmin(mi1,v[i]);
    rep(i,b)chmin(mi2,u[i]);
    ll ans=mi1+mi2;
    rep(i,m){
        ll x,y,c;cin>>x>>y>>c;
        chmin(ans,v[x-1]+u[y-1]-c);
    }
    out(ans);
}

Measured memory_bytes: 1792
s = int(input())
s1 = s // 100
s2 = s % 100
if 1 <= s1 <= 12 and 1 <= s2 <= 12:
    print("AMBIGUOUS")
elif 1 <= s2 <= 12:
    print("YYMM")
elif 1 <= s1 <= 12:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3060
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

fn solve() {
    let s = read!(String);
    let t = read!(String);
    let sc = s.chars().collect::<Vec<char>>();
    let st = t.chars().collect::<Vec<char>>();
    if sc.len()+1!=st.len() {
        println!("No");
        return;
    }
    for i in 0..sc.len() {
        if sc[i]!=st[i]{
            println!("No");
            return;
        }
    }
    println!("Yes");
}

fn run() {
    solve();
}


Measured memory_bytes: 2232
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
const int mod = 1000000007;
 
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll ans = 0;
  rep(i,60) {
    ll x = 0;
    rep(j,n) if (a[j]>>i&1) ++x;
    ll now = x*(n-x)%mod;
    rep(j,i) now = now*2%mod;
    ans += now;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
using namespace std;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    string a[4] = {"dream", "dreamer", "erase" , "eraser"};

    for (int i = 0; i < 4; i++){
        reverse(a[i].begin(), a[i].end());
    }

    bool ans = true;
    for (int i = 0; i < s.size();){
        bool divide = false;
        for (int k = 0; k < 4; k++){
            string divi = s.substr(i,a[k].size());
            if (divi == a[k]){
                divide = true;
                i+= a[k].size();
            }
        }
        if (!divide){
            ans = false;
            break;
        }
    }
    if (ans){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }


        



}


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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP(x) cerr << #x << " = " << (x) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent=false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);

template<typename T = int> inline T in() { T x; cin >> x; return x; }
template<typename T = int> inline vector<T> in(int n) { vector<T> xs(n); rep(i, n) cin >> xs[i]; return xs; }
template<typename T = int> inline vector<vector<T>> in(int n, int m) { vector<vector<T>> xs(n, vector<T>(m)); rep(i, n) rep(j, m) cin >> xs[i][j]; return xs; }

int main(void) {
    int h, w;
    cin >> h >> w;
    VVS ts = in<string>(h, w);
    
    int x = 0, y = 0;
    rep(i, h) rep(j, w) if (ts[i][j] == "snuke") {
        y = i;
        x = j;
    }

    cout << (char)('A' + x) << (y + 1) << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
main(){
ll a,b,v,w,t;
cin>>a>>v>>b>>w>>t;
if(t*(v-w)>=abs(b-a)) puts("YES");
else puts("NO");
}
//const int N=5e5+5;
//vector<int>g[N],;
//int vis[N]={0};
//main(){
//    int n,m,u,v,c;
//    cin>>n>>m;
//    while(m--){
//        cin>>u>>v;
//        g[u].push_back(v);
//        g[v].push_back(u);
//    }
//    for(int i=1;i<=n;i++){
//        cin>>c;
//        in[c].push_back(i);
//        if(c>n){
//            puts("-1");
//            exit(0);
//        }
//    }
//    vector<int>ans;
//
//}


Measured memory_bytes: 3588
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main() {
  int N, M, a, b;
  cin >> N >> M;
  vector<set<int>> v(N + 1);
  for (int i = 0; i != M; ++i) {
    cin >> a >> b;
    v[a].insert(b);
    v[b].insert(a);
  }

  cout << (any_of(begin(v[1]), end(v[1]), [&](int s) { return v[s].count(N); })
               ? "POSSIBLE"
               : "IMPOSSIBLE")
       << endl;
}


Measured memory_bytes: 31436
S = list(input())
a = [0]*(len(S)+1)
yama = 0
tani = 0

for i in range(len(S)):
    if S[i] == ">":
        a[i+1] = a[i] - 1
    elif S[i] == "<":
        a[i+1] = a[i] + 1
    if i > 0:
        if S[i-1] == "<" and S[i] == ">":
            yama = i
        if S[i-1] == ">" and S[i] == "<":
            tani = i
            val = a[tani]
        if a[tani] < 0:
#            print(a)
            for j in range(yama, tani+2):
                a[j] = a[j] - val
#            print(a)
        elif a[tani] > 0:
            for j in range(yama+1, tani+2):
                a[j] = a[j] - val
last = len(a) -1
val = a[last]
if a[last] < 0:
#    print(a)
    for j in range(yama, last+1):
        a[j] = a[j] - val
#    print(a)

#print(a)
print(sum(a))

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

using namespace std;

struct cww{cww(){
    ios::sync_with_stdio(false);cin.tie(0);
    cout<<fixed<<setprecision(10);
}}init;

inline bool isWall(char c){return c=='#';}
inline bool isSpring(char c){return c=='*';}
inline bool isFloor(char c){return c=='.'||c=='s';}
inline bool isStart(char c){return c=='s';}
inline bool isGoal(char c){return c=='g';}
template<typename T>
istream& operator>>(istream& is,vector<T>& v){
    for(auto &it:v)is>>it;
    return is;
}
typedef long long LL;
using P=pair<int,int>;
typedef vector<LL> V;
typedef vector<V> VV;
const LL INF=1e12;
const int dir4[]={0,1,0,-1,0};
int main(){
    int R,C;
    cin>>C>>R;
    vector<string> maze(R);
    int sr,sc,gr,gc,M=0;
    cin>>maze;
    
    queue<P> que;
    VV dG(R,V(C,INF));
    VV dB(R,V(C,INF));
    for(int r=0;r<R;r++)
        for(int c=0;c<C;c++){
            if(isSpring(maze[r][c])){
                dB[r][c]=0;
                que.push(P(r,c));
            }
            if(isFloor(maze[r][c])){
                M++;
            }
            if(isStart(maze[r][c])){
                sr=r,sc=c;
            }
            if(isGoal(maze[r][c])){
                gr=r,gc=c;
            }
        }
    while(que.size()){
        int r,c;
        tie(r,c)=que.front();
        for(int i=0;i<4;i++){
            int nr=r+dir4[i];
            int nc=c+dir4[i+1];
            if(isWall(maze[nr][nc]))continue;
            if(dB[nr][nc]>dB[r][c]+1){
                dB[nr][nc]=dB[r][c]+1;
                que.push(P(nr,nc));
            }
        }
        que.pop();
    }
    que.push(P(gr,gc));
    dG[gr][gc]=0;
    while(que.size()){
        int r,c;
        tie(r,c)=que.front();
        for(int i=0;i<4;i++){
            int nr=r+dir4[i];
            int nc=c+dir4[i+1];
            if(isWall(maze[nr][nc])||isSpring(maze[nr][nc]))continue;
            if(dG[nr][nc]>dG[r][c]+1){
                dG[nr][nc]=dG[r][c]+1;
                que.push(P(nr,nc));
            }
        }
        que.pop();
    }
    vector<P> fs;
    auto b=[&](P p){return max(0ll,min(INF,dG[p.first][p.second]-dB[p.first][p.second]));};
    for(int r=0;r<R;r++)
        for(int c=0;c<C;c++)
            if(isFloor(maze[r][c])){
                fs.push_back(P(r,c));
            }
    sort(fs.begin(),fs.end(),[&](P p,P q){return b(p)<b(q);});
    LL K=0;
    int B=M;
    for(int i=0,sz=fs.size();i<sz;i++){
        K+=dB[fs[i].first][fs[i].second];
    }
    double res=INF;
    K-=dB[fs[0].first][fs[0].second];
    K+=dG[fs[0].first][fs[0].second];
    B--;
    LL prev=b(fs[0]);
    for(int i=1,sz=fs.size();i<sz;i++){
        LL now=b(fs[i]);
        if(now!=prev){
            double b=1.0-B/(double)M;
            b=(K/(double)M)/b;
            if(prev<=b&&b<=now){
                res=min(res,b);
            }
        }
        K-=dB[fs[i].first][fs[i].second];
        K+=dG[fs[i].first][fs[i].second];
        B--;
        prev=now;
    }
    if(prev<INF){
        double b=1.0-B/(double)M;
        b=(K/(double)M)/b;
        if(prev<=b&&b<=INF){
            res=min(res,b);
        }
    }
    cout<<min((double)dG[sr][sc],dB[sr][sc]+res)<<endl;
    return 0;
}

Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  int sum=0;
  
  for(int i=0;i<n;i++)
    cin>>a[i];
  
  sort(a,a+n);
  for(int i=0;i<k;i++)
    sum+=a[i];
  
  cout<<sum<<"\n";
  return 0;
}

Measured memory_bytes: 3624
def sort(array)
  puts array.join(" ")
  for i in 1..(array.size - 1)
    x = array[i]
    j = i
    while(j > 0 && array[j-1] >= x)
      array[j] = array[j-1]
      j -= 1
    end
    array[j] = x
    puts array.join(" ")
  end
end

#input
n = gets.chomp
n = gets.chomp
n = n.split().map(&:to_i)

#output
sort(n)

Measured memory_bytes: 8796
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <numeric>
#define rep(i,s,n) for (int i = s; i < n; ++i)
#define drep(i,s,n) for (int i = n; i >= s; --i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a, int b)
{
   if (a%b == 0) return(b);
   else          return(gcd(b, a%b));
}
int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
void printvv(vector<vector<auto>> vv, int n)
{
  cout << '[' << endl;
  rep(q, 0, n)
  {
    cout << '[';
    rep(p, 0, n)
    {
      cout << vv.at(q).at(p) << ',';
    }
    cout << ']' << endl;
  }
  cout << ']' << endl;
}

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

//------------------------------------------------------------
void solve() {
  ll sum=0,pos=0,n=0;
  string s;
  vector<ll> v;
  cin>>s;

  rep(tmp,0,(1<<(s.size()-1)))
  {
    bitset<9> b(tmp);
    pos=0;n=1;v={};

    rep(j,0,s.size()-1)
    {
      if(b.test(j))
      {
        v.push_back(stoll(s.substr(pos,n)));
        pos=j+1; n=1;
      }
      else
      {++n;}
    }
    v.push_back(stoll(s.substr(pos,n)));
    sum+=accumulate(all(v),0LL);
  }

  print(sum);
  return;
}


Measured memory_bytes: 256
// A C++ program to find convex hull of a set of points. Refer
// http://www.geeksforgeeks.org/orientation-3-ordered-points/

#include <bits/stdc++.h>
using namespace std;
int main()
{
   // freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
    long long Q,H,S,D;
    cin >> Q >> H >> S >> D;
    long long N;
    cin >> N;
    long long L1 = Q * 8;
    long long L2 = H * 4;
    long long L3 = S * 2;
    long long L4 = D;
    if(N % 2 == 0)
    {
        cout << (N / 2) * min(min(L1,L2),min(L3,L4));
        return 0;
    } else {
        long long FirstP = (N - 1) / 2;
        long long secondP = FirstP * min(min(L1,L2),min(L3,L4));
        cout << secondP + min(Q * 4,min(H*2,S));
    }
    return 0;
}


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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N;
    if(N==3) {
        cout << " " << 2;
        cout << " " << 5;
        cout << " " << 63;
        return 0;
    }
    if(N==4) {
        cout << " " << 2;
        cout << " " << 5;
        cout << " " << 20;
        cout << " " << 63;
        return 0;
    }
    ans = N/8;
    ans *= 8;
    tmp = N%8;
    ll ct=0;
    A.push_back(0);
    if(ct<ans) {
        for(int i=2;i<=30000;i++) {
            if(i%2==0||i%3==0) {
                A.push_back(i);
                ct++;
                if(ct==ans) break;
            }
        }
    }
    if(tmp<0) tmp += 8;
    ll num = A.back();
    if(tmp==1) {
        A.push_back(num+6);
    }
    if(tmp==2) {
        A.push_back(num+6);
        A.push_back(num+12);
    }
    if(tmp==3) {
        A.push_back(num+3);
        A.push_back(num+6);
        A.push_back(num+9);
    }
    if(tmp==4) {
        A.push_back(num+3);
        A.push_back(num+6);
        A.push_back(num+9);
        A.push_back(num+12);
    }
    if(tmp==5) {
        A.push_back(num+2);
        A.push_back(num+3);
        A.push_back(num+4);
        A.push_back(num+9);
        A.push_back(num+12);
    }
    if(tmp==6) {
        A.push_back(num+2);
        A.push_back(num+3);
        A.push_back(num+4);
        A.push_back(num+6);
        A.push_back(num+9);
        A.push_back(num+12);
    }
    if(tmp==7) {
        A.push_back(num+2);
        A.push_back(num+3);
        A.push_back(num+4);
        A.push_back(num+6);
        A.push_back(num+8);
        A.push_back(num+9);
        A.push_back(num+10);
    }
    for(int i=1;i<A.size();i++) {
        cout << " " << A[i];
    }
    return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	int a, b;
	cin >> a >> b;

	if (a + b < 10)
		cout << a + b;
	else
		cout << "error";

	cout << 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>
#define ll long long int
using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f(i,p,n) for(ll i=p;i<n;i++)
#define debug(x) cout<<"["<<#x<<": "<<x<<"]"<<endl
typedef pair<ll,ll> pl;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
 
ll exp(ll a,ll b,ll m);
 
int main()
{
 ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 /*
 	#ifndef ONLINE_JUDGE
        freopen("/home/savish/Desktop/2019/io/input.txt", "r", stdin);
        freopen("/home/savish/Desktop/2019/io/output.txt", "w", stdout);
    #endif
 */
    ll n;
    cin>>n;

    ll a[n];

    f(i,0,n) cin>>a[i];

    ll co[3]={0};

    f(i,0,n) co[a[i]-1]++;

    double dp[2][302][302];

    f(i,0,n+1)
    {
    	for(ll j = i;j>=0;j--)
    	{
    		for(ll k = j;k>=0;k--)
    		{
    			ll a = k , b = j-k, c = i-a-b;

    			ll sa = i%2;
    			ll di = 1-sa;
    			if(i==0) dp[0][b][c] = 0;
    			else
    			{
    				double curr = 0;

    				if(a>0) curr += dp[di][b][c]*double(a);
    				if(b>0) curr += dp[sa][b-1][c]*double(b);
    				if(c>0) curr += dp[sa][b+1][c-1]*double(c);
    				curr+=n;
    				dp[sa][b][c] = curr/double(a+b+c);
    			} 
    		}
    	}
    }
    cout<<fixed;
    cout<<setprecision(12);
    cout<<dp[n%2][co[1]][co[2]]<<endl;
    
return 0;
}
 
ll exp(ll a,ll b,ll m)
{
	if(b==0)
	{
		return 1;
	}
	ll temp =exp(a,b/2,m);
	temp=(temp*temp)%m;
	if(b&1)
	{
		return (temp*(a%m))%m;
	}
	return temp;
}


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

int main(int argc, char *argv[]) 
{
    std::string s;
    std::cin >> s;

    int count = 0;
    if (s[0] == '1') {
        count++;
    } else {
        ;
    }
    if (s[1] == '1') {
        count++;
    } else {
        ;
    }
    if (s[2] == '1') {
        count++;
    } else {
        ;
    }

    std::cout << count;
    
    return 0;
}

Measured memory_bytes: 256
/*
 * a.cc: 
 */

#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 = 20;

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

bool check(int k, int n, int sum) {
  if (sum == 0) return true;
  if (k >= n) return false;

  if (as[k] <= sum && check(k + 1, n, sum - as[k])) return true;
  return check(k + 1, n, sum);
}

/* main */

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

  for (int i = 0; i < n; i++) cin >> as[i];

  int q;
  cin >> q;
  while (q--) {
    int mi;
    cin >> mi;
    cout << (check(0, n, mi) ? "yes" : "no") << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
n, m, l = map(int,input().split())
A = []
B = []
AB = [[0]*l for _ in range(n)]

for i in range(n):
    A.append(list(map(int,input().split()[:m])))

for i in range(m):
    B.append(list(map(int,input().split()[:l])))

for i in range(n):
    for j in range(m):
        for k in range(l):
            AB[i][k] += A[i][j] * B[j][k]

for i in AB:
    print(*i)


Measured memory_bytes: 7060
#include<bits/stdc++.h>
using namespace std;
long long dp[100000][4];
long long a[100000][5];
int n;
long long solve(int i,int prev) {
   if(i==n)
       return 0;
   if(dp[i][prev]!=-1)
       return dp[i][prev];

   if(prev!= 1){
       dp[i][prev] = max(a[i][0]+solve(i+1,1),dp[i][prev]);
   }
   if(prev!= 2){
       dp[i][prev] = max(a[i][1]+solve(i+1,2),dp[i][prev]);
   }
   if(prev != 3){
       dp[i][prev] = max(a[i][2]+ solve(i+1,3),dp[i][prev]);
   }
   return dp[i][prev];
}
int main() {
    memset(dp,-1,sizeof dp);
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        for(int j=0;j<3;j++){
            scanf("%lld",&a[i][j]);
        }
    }
    printf("%lld",solve(0,0));
}

Measured memory_bytes: 20172
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

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

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val S = sc.next()
        val T = sc.next()
        pw.println(if (T.substring(0, S.length) == S) "Yes" else "No")
    }
}


Measured memory_bytes: 33980
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  ll N;

  cin >> N;

  unordered_map<int, int> um;
  for (int i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    if (tmp <= 399) {
      um[0]++;
    } else if (tmp <= 799) {
      um[1]++;
    } else if (tmp <= 1199) {
      um[2]++;
    } else if (tmp <= 1599) {
      um[3]++;
    } else if (tmp <= 1999) {
      um[4]++;
    } else if (tmp <= 2399) {
      um[5]++;
    } else if (tmp <= 2799) {
      um[6]++;
    } else if (tmp <= 3199) {
      um[7]++;
    } else {
      um[8]++;
    }
  }  // for

  int cnt = 0;
  for (int i = 0; i <= 7; i++) {
    if (um[i] > 0) cnt++;
  }

  cout << max(1, cnt) << " " << cnt + um[8] << endl;

  return 0;
}


Measured memory_bytes: 256
// デバッグ実行：Ctrl+F5

using System;

class Program
{
    static void Main(string[] args)
    {
        String line;
        line = Console.ReadLine();
        String[] words = line.Split(' ');

        int A, B, K;
        A = int.Parse(words[0]);
        B = int.Parse(words[1]);
        K = int.Parse(words[2]);
        for(int i = 0; i < K; i++)
        {
            if (i % 2 == 0)
            {
                // 高橋君
                if (A % 2 == 1) A--;
                B += A / 2;
                A = A / 2;
            }
            else
            {
                // 青木君
                if (B % 2 == 1) B--;
                A += B / 2;
                B = B / 2;
            }
        }
        Console.WriteLine(A + " "  + B);
    }
}

Measured memory_bytes: 11092
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            string A = Console.ReadLine();
            Char B = Convert.ToChar(A);
            if (Char.IsUpper(B) == true)
            {
                Console.WriteLine("A");
            }
            else
                Console.WriteLine("a");
        }
    }
}

Measured memory_bytes: 17416
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	long long a[n+5];
	long long sum=0;
	for(int i=0;i<n;i++)
	{
	cin>>a[i];
	}
	sort(a,a+n);
	sum=sum+a[n-1];
	int j=n-2;
	int flag=0;
	for(int i=n-3;i>=0;i--)
	{
		if(flag==0)
		{
			sum=sum+a[j];
			flag=1;
			continue;
		}
		if(flag==1)
		{
			sum=sum+a[j];
			flag=0;
			j--;
			continue;
		}
	}
	cout<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  string S;
  cin >> S;
  S[3] = '8';
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
//ABC162_A
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s;
	cin >> s;
	bool ok = 0;
	for(int i = 0;i < s.size();i++)if(s[i] == '7')ok = 1;
	if(ok)cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 3576
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  string s;
  cin >> s;

  int n = s.size();
  while (1) {
    n -= 2;
    bool flag = true;
    rep(i, n / 2) {
      if (s[i] != s[i + n / 2]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      cout << n << endl;
      return 0;
    }
  }


  
  return 0;
}

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

const int N = 1e5 + 5;

int n, m, dp[N], in[N];
vector<int> adj[N];

void dfs(int u, int p) {
  for(auto v : adj[u]) {
    if(v == p) continue;
    if(!dp[v]) dfs(v, u);
    dp[u] = max(dp[u], dp[v]+1);
  }
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  int a, b;
  for(int i = 0; i < m; i++) {
    cin >> a >> b;
    adj[a].push_back(b), in[b]++;
  }

  for(int i = 1; i <= n; i++) if(!in[i]) dfs(i, -1);
  int mx = 0;
  for(int i = 1; i <= n; i++) mx = max(mx, dp[i]);
  cout << mx << "\n";
}


Measured memory_bytes: 12800
import sys

N = int(input())
S = list(str(input()))

if(N%2==1 or N==0):
    print("No")
    sys.exit()

if(N==2 and S[0]!=S[1]):
    print("No")
    sys.exit()

for x in range(0, N//2-1):
    if(S[x]!=S[N//2+x]):
        print("No")
        sys.exit()

print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    ll n, k;
    cin >> n >> k;
    int a[n]; for (auto &ai:a) {
        cin >> ai;
        ai--;
    }
    int city = 0;
    ll visited[n]; fill(visited, visited+n, -1);
    vector<int> loop;
    ll offset;
    for (int i=0; i<n; i++) {
        loop.push_back(city + 1);
        visited[city] = i;
        city = a[city];
        if (visited[city] >= 0) {
            offset = visited[city];
        }
    }
    if (k < offset) {
        cout << loop[k] << '\n';
        return 0;
    }
    int looplen = loop.size() - offset;
    cout << loop[(k - offset) % looplen + offset]  << '\n';
    return 0;
}

Measured memory_bytes: 6664
package main

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

func main() {
	nextReader = NewScanner()
	line := nextString()

	input, _ := time.Parse("2006/01/02", line[0])
	heisei := time.Date(2019, 4, 30, 0, 0, 0, 0, time.UTC)

	if heisei.Before(input) {
		fmt.Println("TBD")
	} else {
		fmt.Println("Heisei")
	}
}

// ------ Mathライブラリ ---------------------------------//
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func maxIdx(a ...int) int {
	r := a[0]
	index := 0
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
			index = i
		}
	}
	return index
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minIdx(a ...int) int {
	r := a[0]
	index := 0
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
			index = i
		}
	}
	return index
}

func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ------ Mathライブラリ ---------------------------------//

// ----- 標準入力用の関数 ----------------------------------//
var nextReader func() []string

func NewScanner() func() []string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	return func() []string {
		r.Scan()
		return strings.Fields(r.Text())
	}
}

func nextString() []string {
	return nextReader()
}

func nextInt() []int {
	var intArray []int
	strArray := nextReader()
	for _, v := range strArray {
		i, _ := strconv.Atoi(v)
		intArray = append(intArray, i)
	}
	return intArray
}

func nextFloat64() []float64 {
	var floatArray []float64
	strArray := nextReader()
	for _, v := range strArray {
		f, _ := strconv.ParseFloat(v, 64)
		floatArray = append(floatArray, f)
	}
	return floatArray
}

// ------ 標準入力用の関数 ---------------------------------//

// ------ あまり使わない -----------------------------------//
func nextInt64() []int64 {
	var int64Array []int64
	strArray := nextReader()
	for _, v := range strArray {
		i, _ := strconv.ParseInt(v, 10, 64)
		int64Array = append(int64Array, i)
	}
	return int64Array
}

// ------ あまり使わない -----------------------------------//


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;

#define x first
#define y second

typedef pair<double,double> pdd;
static const double EPS = 1e-9;

template<class T>
T sqr(T obj0) {
	return obj0 * obj0;
}

int is_cross(pdd l0, pdd l1, pdd p, double r) {
	pdd a,b,c;

	a.x = l0.x - p.x; a.y = l0.y - p.y;
	b.x = l1.x - p.x; b.y = l1.y - p.y;
	c.x = a.x - b.x; c.y = a.y - b.y;

	double d0, d1, d2, dist;
	double h;

	h = abs(a.x * b.y - a.y * b.x) / abs(sqrt(c.x * c.x + c.y * c.y));

	d0 = sqrt(sqr(c.x) + sqr(c.y));
	d1 = sqrt(sqr(a.x) + sqr(a.y) - sqr(h));
	d2 = sqrt(sqr(b.x) + sqr(b.y) - sqr(h));

	if(fabs(d0 - (d1 + d2)) < EPS)
		dist = h;
	else
		dist = min(sqrt(sqr(a.x) + sqr(a.y)), sqrt(sqr(b.x) + sqr(b.y)));

	if(fabs(dist - r) < EPS && dist <= r && r <= max(sqrt(sqr(a.x) + sqr(a.y)), sqrt(sqr(b.x) + sqr(b.y))))
		return 2;
	if(dist <= r && r <= max(sqrt(sqr(a.x) + sqr(a.y)), sqrt(sqr(b.x) + sqr(b.y))))
		return 1;
	return 0;
}

bool in_triangle(vector<pdd> tri, pdd p) {
	double s, t;
	pdd a, b, c;

	a.x = tri[1].x - tri[0].x; a.y = tri[1].y - tri[0].y;
	b.x = tri[2].x - tri[0].x; b.y = tri[2].y - tri[0].y;
	c.x = p.x - tri[0].x; c.y = p.y - tri[0].y;

	s = (c.x * b.y - c.y * b.x) / (a.x * b.y - a.y * b.x);
	t = (c.y * a.x - c.x * a.y) / (a.x * b.y - a.y * b.x);

	if(0 <= s + t && s + t <= 1 && 0 <= s && 0 <= t)
		return true;
	return false;
}

/*
bool in_circle(vector<pdd> t, pdd p, double r) {
	bool flg = true;
	for(int i = 0; i < 3; i++) {
		double tmp;
		tmp = sqr(t[i].x - p.x) + sqr(t[i].y - p.y);
		flg &= tmp <= r;
	}

	return flg;
}
*/

int main() {
	while(true) {
		vector<pdd> tri;
		pdd c;
		double r;

		for(int i = 0; i < 3; i++) {
			double tmpx, tmpy;
			cin >> tmpx >> tmpy;
			tri.push_back(pdd(tmpx, tmpy));
			if(i == 0 && tri[0].x == 0 && tri[0].y == 0)
				goto label;
		}
		cin >> c.x >> c.y >> r;

		bool flg0, flg1, flg2;
		flg0 = true;
		flg1 = false;
		flg2 = false;
		for(int i = 0; i < 3; i++) {
			flg0 &= ((sqr(c.x - tri[i].x) + sqr(c.y - tri[i].y)) <= r * r);
		}
		for(int i = 0; i < 3; i++) {
			int tmp;
			tmp = is_cross(tri[i % 3], tri[(i + 1) % 3], c, r);
			flg1 |= tmp;
			if(tmp == 2)
				flg2 = true;
		}

//		cout << boolalpha << flg0 << " " << flg1 << endl;

		if(flg0)
			cout << "b" << endl;
		else if((!flg1 || flg2)&& in_triangle(tri, c))
			cout << "a" << endl;
		else if(flg1)
			cout << "c" << endl;
		else
			cout << "d" << endl;
	}
label:;
}

Measured memory_bytes: 1212
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

h=INT()
cnt=0
while h>1:
    #print(h//2)
    cnt+=1
    h//=2
#print("cnt",cnt)

ans=1
for i in range(cnt):
    ans*=2
    ans+=1
print(ans)

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

int main(){
  string s;
  cin>>s;
  int plus=0,minus=0;
  for (int i=0 ;i<s.length() ;i++) {
      if(s[i]=='+'){
        plus++;
      }
      else{
        minus--;
      }
  }
  cout << minus+plus << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define SORT(c) sort(ALL((c)))
#define debug(x)                 \
    do {                         \
        std::cout << #x << ": "; \
        view(x);                 \
    } while (0)

template <typename T>
void view(T e) {
    std::cout << e << std::endl;
}
template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << ", ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

struct UnionFind {
    vector<ll> size, parents;
    UnionFind() {}
    UnionFind(ll n) {
        size.resize(n, 0);
        parents.resize(n, 0);
        for (ll i = 0; i < n; i++) {
            make(i);
        }
    }
    void make(ll x) {
        parents[x] = x;
        size[x] = 1;
    }
    bool same(ll x, ll y) { return root(x) == root(y); }
    bool union_(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (size[x] > size[y]) {
            parents[y] = x;
            size[x] += size[y];
        } else {
            parents[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    int root(ll x) {
        if (x != parents[x]) {
            parents[x] = root(parents[x]);
        }
        return parents[x];
    }
    ll size_(ll x) { return size[root(x)]; }
};

int main() {
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(M), B(M);
    vector<ll> C(K), D(K);
    UnionFind u(N);
    vector<ll> friend_block(N, 0);
    rep(i, M) {
        cin >> A[i] >> B[i];
        u.union_(A[i] - 1, B[i] - 1);
    }
    rep(i, K) { cin >> C[i] >> D[i]; }
    rep(i, M) {
        if (u.same(A[i] - 1, B[i] - 1)) {
            friend_block[A[i] - 1]++;
            friend_block[B[i] - 1]++;
        }
    }
    rep(i, K) {
        if (u.same(C[i] - 1, D[i] - 1)) {
            friend_block[C[i] - 1]++;
            friend_block[D[i] - 1]++;
        }
    }

    rep(i, N - 1) { cout << u.size_(i) - friend_block[i] - 1 << " "; }
    cout << u.size_(N - 1) - friend_block[N - 1] - 1 << endl;
    return 0;
}


Measured memory_bytes: 8716
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main(){
  double x,h,ans;
  while(cin>>x>>h){
    if(x==0&&h==0) break;
    ans = x * sqrt(4*h*h+x*x) + x * x;
    cout << fixed << setprecision(6) << ans << endl;
  }
  return 0;
}

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

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int n, ans = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		ans += i+1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n, q = gets.split.map(&:to_i)
s = gets.chomp
lr =
  q.times.map do |i|
    gets.split.map(&:to_i)
  end

idxs=[]
i=0
while i<n-1 do
  if s[i]=='A' && s[i+1]=='C'
    idxs<<i
  end
  i+=1
end
#puts idxs.to_s
q.times.map do |i|
  l = lr[i][0]
  r = lr[i][1]
  i1 = idxs.bsearch_index{|x|x>=l-1}
  i2 = idxs.bsearch_index{|x|x>=r-1}
  #puts "i:#{i1},#{i2}"
  if i1.nil?
    puts 0
    next
  end
  if i2.nil?
    i2 = idxs.size
  end
  puts (i2-1)-i1+1
end

Measured memory_bytes: 11572
i = 1
min = 10000000
N, T = map(int, input().split())

while True:
    c, d = map(int, input().split())
    if d <= T:
        if c < min:
            min = c
    if i == N:
        break
    i += 1


if min == 10000000:
    print("TLE")
else:
    print(min)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	int mean = sum / N;
	int ans = 0, ans2 = 0;
	for (int a : A) ans += (a - mean) * (a - mean);
	for (int a : A) ans2 += (a - mean - 1) * (a - mean - 1);
	cout << min(ans, ans2) << endl;

}


Measured memory_bytes: 256
n,m,c = map(int, input().split())
B = [int(b) for b in input().split()]
ans = 0
for _ in range(n):
    A = [int(a) for a in input().split()]
    D = [i*j for i,j in zip(A,B)]
    if sum(D)+c > 0:
        ans += 1
        
print(ans)

Measured memory_bytes: 3060
using System;
using System.Linq;

namespace s8pc_3_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            x[0] -= 2;
            int ret = x[0] / 11 * 5;
            x[0] %= 11;
            int[] a = new int[] { 4,2,0,9,7 };
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < x[0]; j++)
                {
                    if ((a[i] + 63 * j) % 11 == x[1])
                    {
                        ret++;
                    }
                }
            }
            Console.WriteLine(ret);
        }
    }
}

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

//const int mxH = 10, mxW = 1e3;
//int h, w, k, ans = 1e9;
//string g[mxH];
//vector<int> v[mxW];

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

	ll X;
  	cin >> X;
	// X = 500*Y + 5*Z + res;
	ll Y = (ll)(X / 500);
	ll Z = (ll)((X - Y * 500) / 5);
	cout << Y * 1000 + Z * 5;
}






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

int main(){
  int N,Y,tmp;
  cin >>N>>Y;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
      tmp=10000*i+5000*j+(N-i-j)*1000;
      if(tmp==Y){
        cout <<i<<" "<<j<<" "<<N-i-j<<endl;
        return 0;
      }
    }
  }
  cout <<-1<<" "<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io 
int x; cin>>x;
if(x<1200) cout<<"ABC";
else cout<<"ARC";
	
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"		// scanf -> unused return value

#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
#define CLOSEALL() fclose(stdin), fclose(stdout)

const int MAXN = 1e5 + 10;
typedef long long i64;

i64 K;
i64 N, M;
i64 answer[MAXN];
i64 a[MAXN], idx[MAXN];

i64 stk[MAXN], top;

bool vis[MAXN];

int main()
{
	//REDIRECT("rabbit");
	
	scanf("%lld", &N);
	for(int i = 1; i <= N; i++)
		scanf("%lld", &a[i]), idx[i] = i;
		
	for(int i = N; i >= 1; i--)
		a[i] -= a[i-1];
		
	scanf("%lld%lld", &M, &K);
	for(int i = 1;i <= M; i++)
	{
		int t;
		scanf("%d", &t);
		std::swap(idx[t], idx[t + 1]);
	}
	
	for(int i = 1; i <= N; i++)
		if(!vis[i])
		{
			int cur = i;
			top = 0;

			while(!vis[cur])
				stk[++top] = cur, vis[cur] = true, cur = idx[cur];

			for(int k = 1; k <= top; k++)
				answer[stk[k]] = a[stk[(K + k - 1) % top + 1]];
		}

	for(int i = 1; i <= N; i++)
		answer[i] += answer[i-1],
		printf("%lld\n", answer[i]);

	CLOSEALL();
	return 0;
}

#pragma GCC diagnostic pop


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define N 200005
#define pb push_back
using namespace std;

bool SG[N];
vector<int> g[N];
int len=0,dep[N],p;

void dfs(int x){
	if(dep[x]>len) len=dep[x],p=x;
	for(int i=0;i<g[x].size();++i){
		if(!dep[g[x][i]]){
			dep[g[x][i]]=dep[x]+1;
			dfs(g[x][i]);
		}
	}	
}


int main(){
	int n,i,a,b;
	scanf("%d",&n);
	for(i=1;i<n;++i){
		scanf("%d%d",&a,&b);
		g[a].pb(b),g[b].pb(a);
	}
	SG[1]=1,SG[2]=0,dep[1]=1;
	for(i=3;i<=n;++i){
		if(i%3==0) SG[i]=1;
		else SG[i]=(i%3)&1;
	}
	dfs(1);
	memset(dep,0,sizeof(dep)),dep[p]=1;
	dfs(p);
	if(SG[len]) puts("First");
	else puts("Second");
} 

Measured memory_bytes: 21504
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {

	double r;
	double s, l;

	cin >> r;

	s = r * r * M_PI;
	l = 2 * M_PI * r;

	cout << fixed;
	cout << setprecision(6) << s << " " << l << endl;

	return 0;
}


Measured memory_bytes: 3236