akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
  int K; cin >> K; K--;
  cout << a[K] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    ll x,y;
    cin>>x>>y;
    
    ll res=1LL<<60;
    if(x<=y) res=min(res,y-x);
    if(-x<=y) res=min(res,y+x+1);
    if(x<=-y) res=min(res,-y-x+1);
    if(-x<=-y) res=min(res,-y+x+2);

    cout<<res<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    set<int>se;
    int q,n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>q;
        se.insert(q);
    }
    cout<<se.size()<<endl;
    return(0);
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
double ans;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    vector<ll> t,lv;
    rep(i, 0, n) {
        ll x; cin >> x;
        t.pb(x);
    }
    rep(i, 0, n) {
        ll x; cin >> x;
        lv.pb(x);
    }

    vector<ll> v;
    v.pb(0);
    rep(i, 0, n-1) {
        ll val = min(lv[i], lv[i+1]);
        v.pb(val);
    }
    v.pb(0);

    rep(i, 0, v.size()-1) {
        if (v[i] < v[i+1])
            v[i+1] = min(v[i]+t[i], v[i+1]);
    }
    eper(i, v.size()-1, 1) {
        if (v[i-1] > v[i])
            v[i-1] = min(v[i-1], v[i]+t[i-1]);
    }

    rep(i, 0, v.size()-1) {
        double l = v[i], r = v[i+1], limit = lv[i];
        if (l > r) swap(l, r);
        if (limit == r) {
            ans += (l + (l + t[i])) * t[i] * 0.5 - (l + t[i] - r) * (l + t[i] - r) * 0.5;
        } else {
            double x = 0.5 * (t[i] + r - l);
            double y = 0.5 * (t[i] - r + l);
            double peak = l + x - lv[i];
            if (peak < 0) peak = 0;
            x -= peak, y -= peak;
            peak *= 2;
            if (peak > 0)
                ans += ((l + l + x) * x * 0.5 + (r + r + y) * y * 0.5 + peak * lv[i]);
            else
                ans += ((l + l + x) * x * 0.5 + (r + r + y) * y * 0.5);
        }
    }
    printf("%.16f\n", ans);
    return 0;
}


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

struct binary_tree{
  int parent,sibling,degree,depth,height;
  std::string type;
  int left,right;
  static int decide_type(binary_tree [],int);
  static void give(binary_tree [],int);
  static void enter_from_root(binary_tree [],int);
  static int return_maxdep(binary_tree [],int,int);
};

int binary_tree::decide_type(binary_tree T[],int n){
  int root=-2;
  for(int i=0;i<n;i++){
    if(T[i].parent==-1){
      T[i].type="root";
      root=i;
    }else if(T[i].degree==0){
      T[i].type="leaf";
    }else{
      T[i].type="internal node";
    }
  }
  return root;
}

void binary_tree::give(binary_tree T[],int i){
  int left=T[i].left;
  int right=T[i].right;
  if(T[i].degree==2){
    T[left].depth=T[i].depth+1;
    T[right].depth=T[i].depth+1;
    give(T,left);
    give(T,right);
  }else if(T[i].degree==0){
    //do nothing
  }else if(left==-1){
    T[right].depth=T[i].depth+1;
    give(T,right);
  }else{
    T[left].depth=T[i].depth+1;
    give(T,left);
  }
}

int binary_tree::return_maxdep(binary_tree T[],int i,int max_depth){
  if(T[i].depth>max_depth)max_depth=T[i].depth;
  int left=T[i].left;
  int right=T[i].right;
  if(T[i].degree==2){
    int maxl=return_maxdep(T,left,max_depth);
    int maxr=return_maxdep(T,right,max_depth);
    if(maxl>max_depth)max_depth=maxl;
    if(maxr>max_depth)max_depth=maxr;
  }else if(T[i].degree==0){
    //do nothing
  }else if(left==-1){
    int max=return_maxdep(T,right,max_depth);
    if(max>max_depth)max_depth=max;
  }else{
    int max=return_maxdep(T,left,max_depth);
    if(max>max_depth)max_depth=max;
  }
  return max_depth;
}

int main(){
  int n;
  std::cin>>n;
  binary_tree T[n];
  for(int i=0;i<n;i++){
    T[i].parent=-1;
    T[i].sibling=-1;
  }
  //初期化 以下入力
  for(int i=0;i<n;i++){
    int x,left,right;
    std::cin>>x>>left>>right;
      T[x].left=left;
      T[x].right=right;
      if(left==-1&&right==-1){
        T[x].degree=0;
      }else if(left==-1){
        T[x].degree=1;
        T[right].parent=x;
      }else if(right==-1){
        T[x].degree=1;
        T[left].parent=x;
      }else{
        T[x].degree=2;
        T[left].parent=x;
        T[right].parent=x;
        T[left].sibling=right;
        T[right].sibling=left;
      }
  }
  int root=binary_tree::decide_type(T,n);
  T[root].depth=0;
  binary_tree::give(T,root);
  for(int i=0;i<n;i++){
    int max_depth=0;
    int height=binary_tree::return_maxdep(T,i,max_depth)-T[i].depth;
    T[i].height=height;
  }
  //node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root
  for(int i=0;i<n;i++){
    std::cout<<"node "<<i<<": parent = "<<T[i].parent<<", sibling = "<<T[i].sibling
    <<", degree = "<<T[i].degree<<", depth = "<<T[i].depth<<", height = "<<T[i].height
    <<", "<<T[i].type<<std::endl;
  }
}



Measured memory_bytes: 3228
use std::io::*;
use std::str::*;
use std::cmp::min;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let k: usize = read().unwrap();
    let n: usize = read().unwrap();
    let mut a: Vec<usize> = Vec::new();
    for _ in 0..n {
        a.push(read().unwrap());
    }

    let mut res: usize = 1000000000;
    let mut ans: usize = 0;
    let mut dist: Vec<usize> = Vec::new();
    for n_i in 0..n {
        if n_i == 0 {
            dist.push(k - a[n - 1] + a[0]);
        } else {
            dist.push(a[n_i] - a[n_i - 1]);
        }
    }
    for n_i in 0..n {
        if n_i < n - 1 {
            if dist[n_i] >= dist[n_i + 1] {
                ans = k - dist[n_i];
            } else {
                ans = k - dist[n_i + 1];
            }
        } else {
            if dist[n - 1] >= dist[0] {
                ans = k - dist[n - 1];
            } else {
                ans = k - dist[0];
            }
        }
        res = min(res, ans);
    }
    println!("{}", res);
}

Measured memory_bytes: 10492
#include<iostream>
using namespace std;
int main() {
	int kaisu, tasu, ans = 1;
	cin >> kaisu >> tasu;
	for (int i = 0; i < kaisu; i++) {
		if (ans < tasu)
			ans = ans * 2;
		
		else
			ans += tasu;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 21.02.2019 13:12:15       
**/
#include <bits/stdc++.h>

using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> skip;
  vector<int> afford;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] = min(a[i], k + 1);
    int cc = (k + 1) - a[i];
    if (cc > (k + 1) / 2) {
      cout << -1 << '\n';
      return 0;
    }
    for (int j = 0; j < cc; j++) {
      skip.push_back(i);
    }
    for (int j = cc; j < (k + 1) / 2; j++) {
      afford.push_back(i);
    }
  }
  if ((int) skip.size() > k) {
    cout << -1 << '\n';
    return 0;
  }
  debug(skip);
  debug(afford);
  while ((int) skip.size() < k) {
    skip.push_back(afford.back());
    afford.pop_back();
  }
  map<int, int> in_skip;
  for (int x : skip) {
    in_skip[x]++;
  }
  vector<int> order;
  int last = -1;
  for (int i = 0; i < k; i++) {
    int mx = -1, mid = -1;
    for (auto& p : in_skip) {
      if (p.first != last && p.second > mx) {
        mx = p.second;
        mid = p.first;
      }
    }
    order.push_back(mid);
    in_skip[mid]--;
    last = mid;
  }
  debug(order);
  vector<int> ret;
  for (int i = 0; i <= k; i++) {
    int skip_now = -1;
    if (i > 0) skip_now = order[i - 1];
    int place_last = -1;
    if (i < k) place_last = order[i];
    for (int j = 0; j < n; j++) {
      if (j != skip_now && j != place_last) ret.push_back(j);
    }
    if (place_last != -1) ret.push_back(place_last);
  }
  int sz = (int) ret.size();
  cout << sz << '\n';
  for (int i = 0; i < sz; i++) {
    if (i > 0) cout << " ";
    cout << ret[i] + 1;
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 256
W = input()
cnt = 0
if W[0]=="R":
  if W[1]=="R":
    if W[2]=="R": cnt=3
    else: cnt=2
  else: cnt=1
else:
  if W[1]=="R":
    if W[2]=="R": cnt=2
    else: cnt=1
  else:
    if W[2]=="R": cnt=1
    else: cnt=0
print(cnt)

Measured memory_bytes: 9056
#include <stdio.h>

int main(void)
{
	float m, hm, lm;
	int first = 0;
	while (scanf("%f", &m) != EOF){
		if (first == 0){
			first = 1;
			hm = lm = m;
		}
		if (hm < m) hm = m;
		else if (lm > m) lm = m;
	}
	
	printf("%.1f\n", hm - lm);
	return(0);
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	int ans = 0;
	for (int ii = 0; ii < N; ++ii){
		int H;
		cin >> H;
		if (H >= K){
			ans++;
		}
	}


		cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

    int digits[3];
    digits[2] = n / 100;
    digits[1] = (n-digits[2]*100) / 10;
    digits[0] = (n-digits[2]*100-digits[1]*10);

    for(int i=0;i<3;i++){
        if(digits[i]==1)digits[i] = 9;
        else digits[i] = 1;
    }

    cout << digits[2]*100 + digits[1]*10 + digits[0] << endl;

    return 0;
}

Measured memory_bytes: 256
S=input()
L=len(S)-1

from itertools import product

def divid_S(p):
    S_=[]
    p_s=0
    p_e=0

    for p_idx in range(len(p)):
        if p[p_idx] == 1:
            p_e = p_idx+1
            S_.append(S[p_s:p_e])
            p_s = p_idx+1

    S_.append(S[p_e:])
    
    return S_

def get_one_ans(S_):
    ans=0
    for s_ in S_:
        ans+=int(s_)
        
    return ans

ans = 0
for p in product(range(2),repeat=L):
    S_=divid_S(p)
    ans += get_one_ans(S_)
    
print(ans)

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ar array

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const int maxn = 2e5 + 5;

int N, M, suf, pref;
vector<int> add[maxn];

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  #endif // LOCAL
  cin >> N >> M;
  for(int i = 1; i <= N; ++i){
    int l, r; cin >> l >> r;
    add[l].eb(r);
  }
  priority_queue<int> pq;
  for(int i = M; i >= 1; --i){
    for(int j : add[i])
      pq.push(j);
    if(pq.size()){
      pq.pop();
      ++pref;
    }
  }
  for(int i : add[0]) pq.push(i);
  int ans = pref; suf = M;
  while(pq.size()){
    int now = pq.top(); pq.pop();
    if(now <= suf && suf > pref){
      ++ans;
      --suf;
    }
  }
  cout << N - ans;
}


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

int a;
int cnt=0;
ll num(int k,ll n,int n3,int n5,int n7,bool f){
    if(k<=0){
        if(n>0 && n<=a && n3>=1 && n5>=1 && n7>=1) cnt++;
        return 0;
    }
    if(f==false) num(k-1,0,n3,n5,n7,false);
    num(k-1,n*10+3,n3+1,n5,n7,true);
    num(k-1,n*10+5,n3,n5+1,n7,true);
    num(k-1,n*10+7,n3,n5,n7+1,true);
}

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,pair<int,int>>> py(m);
    vector<string> p(m);
    rep(i,m){
        cin>>py[i].first>>py[i].second.first;
        py[i].second.second=i;
    }
    sort(py.begin(),py.end());
    int a,b=1;
    rep(i,m){
        if(i!=0){
            if(py[i].first!=py[i-1].first) a=py[i].first,b=1;
            else b++;
        }else a=py[i].first;
        string sa=to_string(a);
        string sb=to_string(b);
        while(sa.size()<6){
            sa = "0"+sa;
        }
        while(sb.size()<6){
            sb = "0"+sb;
        }
        p[py[i].second.second]=sa+sb;
    }
    rep(i,m) cout<<p[i]<<endl;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
const int N=100005,mod=1000000007;
int a[N],b[N],dp[N];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x;
		scanf("%d",&x);
		b[x]=1;
	}
	dp[0]=1;
	dp[1]=b[1]^1;
	for(int i=2;i<=n;i++)
	{
		if(b[i])
			continue;
		dp[i]=(dp[i-1]+dp[i-2])%mod;
	}
	printf("%d\n",dp[n]);
	return 0;
}


Measured memory_bytes: 1024
n = int(input())
A=[]
B=[]
for i in range(n):
    a,b = map(str,input().split())
    a = float(a)
    A.append(a)
    B.append(b)
    
for j in range(n):
    if B[j] == 'BTC':
        A[j] *=380000.0
print(sum(A))
    
 

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

using namespace std;

typedef long long ll;

const ll MOD = 1LL << 32;
const ll INF = 1e18+7;

signed main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto& x : a)
        cin >> x;
    int c = 0;
    for(int i = 0; i < 150; ++i){
        bool flag = false;
        for(auto& x : a){
            if(x > i){
                c += !flag;
                flag = true;
            }else
                flag = false;
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int i,l=s.length(),sum,m=l-2,a,b,c;
    int ar[m],j=0;
    for(i=0;i<m;i++)
    {
        a=s[i]-'0';
        b=s[i+1]-'0';
        c=s[i+2]-'0';
        sum=(a*100)+(b*10)+(c*1);
        ar[j]=fabs(sum-753);
        j++;

    }
    sort(ar,ar+m);
    cout<<ar[0]<<endl;
    return 0;
}



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

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

using namespace std;
 
typedef long long int ll;

const ll INF=(ll)1e18;

int s[6000][6000];
int b[2000][2000];


int main(){
    int N,K;

    cin >> N >> K;

    REP(i,6000)REP(j,6000)s[i][j] = 0;
    REP(i,2000)REP(j,2000)b[i][j] = 0;

    REP(i,N){
        ll x,y;
        char c;
        cin >> x >> y >> c;

        if(c == 'W') y += K;
        b[x%(2*K)][y%(2*K)] += 1;
    }
    REP(i,2*K)REP(j,2*K){
        if(b[i][j] == 0)continue;

        REP(k,2)REP(l,2){
            s[i+1+2*K*k][j+1+2*K*l] += b[i][j];
            s[i+K+1+2*K*k][j+K+1+2*K*l] += b[i][j];
            s[i+K+1+2*K*k][j+1+2*K*l] -= b[i][j];
            s[i+1+2*K*k][j+K+1+2*K*l] -= b[i][j];
        }
    }

    REP(i,6000)FOR(j,1,6000)s[i][j] += s[i][j-1];
    REP(i,6000)FOR(j,1,6000)s[j][i] += s[j-1][i];

    ll ans = 0;
    FOR(i,1,5000)FOR(j,1,5000){
        ll tmp = 0;
        tmp += s[i][j];
        tmp += s[i+K][j+K];
        ans = max(ans,tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 156544
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int [][] data = new int[m][2];
			for(int i = 0; i < m; i++){
				data[i][0] = sc.nextInt();
				data[i][1] = sc.nextInt();
			}
			
			boolean [][] ans = new boolean[n+1][2];
			boolean flg = false;
			for(int i = 0; i < m;i++){
				if(data[i][0] == 1){
					ans[data[i][1]][0] = true;
				}
				if(data[i][1] == 1){
					ans[data[i][0]][0] = true;
				}
				if(data[i][0] == n){
					ans[data[i][1]][1] = true;
				}
				if(data[i][1] == n){
					ans[data[i][0]][1] = true;
				}
			}

			for(int i = 0; i < ans.length; i++){
				if(ans[i][0] && ans[i][1]){
					flg = true;
					break;
				}
			}
			
			if(flg){
				System.out.println("POSSIBLE");
			}
			else{
				System.out.println("IMPOSSIBLE");
			}
		}
	}


	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 111864
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int W, a, b;
    cin >> W >> a >> b;
    cout << max(0, max(b - a - W, a - b - W)) << endl;
    return 0;
}

Measured memory_bytes: 3604
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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


    int N; cin >> N;
    vs S(N); REP(i, N) cin >> S[i];

    vi h(26, INF);
    REP(i,N) {
        map<char, int> mp;
        for(char c : S[i]) {
            mp[c]++;
        }
        for(char c = 'a'; c<= 'z'; c++) {
            h[c - 'a'] = min(h[c - 'a'], mp[c]);
        }
    }

    string ans = "";
    for(char c = 'a'; c<= 'z'; c++) {
        if (h[c - 'a'] >= INF) continue;
        ans += string(h[c - 'a'], c);
    }

    cout <<  ans << endl;

    return 0;
}

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

int main() {

  int a,b,c,d,sum;
  string s,t;
  cin>>a;
sum=0;
  b=0;
  vector<int> vec(a);
  for(int i=0;i<a;i++){
  	cin>>vec.at(i);
    b = max(b,vec.at(i));
    sum+=vec.at(i);
  }
  
  cout<<sum-b/2<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    char input[4]="";
    scanf("%s",input);
    bool ans = false;
    char before = input[0];
    for(int i=1;i<4&&ans==false;i++){
        if(input[i]==before){
            ans = true;
            goto END;
         }
        before = input[i];
    }
END:
    if(ans)printf("Bad\n");
    else printf("Good\n");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
#define Endl endl
const int INF=100000000;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(i%2==0){
			cout<<s[i];
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define L 1000000000000000000
#define ll long long int
#define ld long double
using namespace std;
int main(void){
	ll n,i;
	cin>>n;
	if(n==1)
	cout<<0<<endl;
	else{
		ll ans=0,lans;
		ld k;
		set<ll>s;
		map<ll,int>mp;
		while(n%2==0){
			mp[2]++;
			s.insert(2);
			n/=2;
		}
		k=floor((pow(1.0+8.0*mp[2],0.5)-1.0)/2.0);
		lans=(ll)k;
		ans+=k;
		//cout<<mp[2]<<endl;
		for(i=3;i*i<=n;i+=2){
			while (n % i == 0)  
			{  
				mp[i]++;  
				n = n/i;
				s.insert(i);  
			}
		//	cout<<i<<" "<<mp[i]<<endl;
			k=floor((pow(1.0+8.0*mp[i],0.5)-1.0)/2.0);
			lans=(ll)k;
			ans+=k;  
		}
		if (n > 2){  
			s.insert(n);
			mp[n]++;
		}
		k=floor((pow(1.0+8.0*mp[n],0.5)-1.0)/2.0);
			lans=(ll)k;
			ans+=k;  
		//ans+=s.size();
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 35352
#define ll long long
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
ll z = 1000000007 ;
ll inf = 100000000000000000 ;
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll power(ll a ,ll b){if(b == 0) return 1 ; ll c = power(a , b/2) ; if(b%2 == 0) return ((c*c)%z) ; else return ((((c*c)%z)*a)%z) ;}
ll inverse(ll a ,ll n){return power(a , n-2) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;


void solve()
{
	ll a , b ;
	cin >> a >> b ;
	for(ll i = 1 ; i <= 2000 ; i++)
	{
		ll ans_a = (((double)i)*0.08) ;
		ll ans_b = (((double)i)*0.10) ;
		if(ans_a == a && ans_b == b)
		{
			cout << i << endl ;
			return ;
		}
	}
	cout << -1 << endl ;
	return ;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	ll t ;
	//cin >> t ;
	t = 1 ;
	while(t--)
	{
		solve() ;
	}
	return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
from decimal import *
        
#再帰バージョン
N = INT()

def DFS(n):
    if len(n) == N:
        print(n)
    else:
        for i in range(len(set(n))+1):
            m = n+ascii_lowercase[i]
            DFS(m)

DFS("a")



Measured memory_bytes: 10480
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl; 
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;
const int maxn =200000+10;
int A[maxn],B[maxn];
int main(void)
{
 
 	int N;cin>>N;
 	for(int i = 1;i <= N;++i)
 		cin>>A[i],B[i] = A[i];
 	sort(B+1,B+N+1);
 	for(int i = 1;i <= N; ++i){
 		cout<<(B[N] == A[i]?B[N-1]:B[N])<<endl;
 	}


   	return 0;
}

Measured memory_bytes: 3200
# -*- coding: utf-8 -*-

import sys
from math import atan2, degrees, hypot

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -9

N = INT()

degs = []
XY = []
for i in range(N):
    x, y = MAP()
    XY.append((x, y))
    deg = degrees(atan2(y, x))
    if deg < 0:
        # 負の数なら時計回り側にあるので逆向きにする
        deg += 360
    degs.append((deg, i))
# 角度でソート
degs.sort()
# 2周目をつける
degs += [(deg+360, i) for deg, i in degs]

ans = 0
for i in range(N):
    deg, idx = degs[i]
    xsm, ysm = XY[idx]
    ans = max(ans, hypot(xsm, ysm))
    j = i + 1
    # 始点から180度未満の方向に向かうものを全て追加しながら最大を取る
    while degs[j][0] < deg+180:
        _, idx = degs[j]
        x, y = XY[idx]
        xsm += x
        ysm += y
        ans = max(ans, hypot(xsm, ysm))
        j += 1
print(ans)


Measured memory_bytes: 3188
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    int[] dp=new int[n];
    dp[1]=Math.abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
      dp[i]=Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]),dp[i-2]+Math.abs(a[i]-a[i-2]));
    }
    System.out.print(dp[n-1]);
  }
}

Measured memory_bytes: 50096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
ll N,A,B;
  cin>>N>>A>>B;
  
  ll ans;

  ll m;
  m=N/(A+B);
  ll n;
  n=std::min(N%(A+B),A);
  ans=m*A+n;
  //  ans=((int)(N/(A+B)))*A+min(N%(A+B),A);
  
cout<<ans<<endl;
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

vector<ll> yak;
void yakusuu(ll x){
    for(ll i=1;i*i<=x;i++){
        if(x%i==0){
            yak.push_back(i);
            if(i*i!=x){
                yak.push_back(x/i);
            }
        }
    }
    sort(yak.begin(),yak.end());
}

int main(){fastio
    ll n;cin>>n;
    ll x=n;
    yakusuu(n);
    ll ans=0;
    rep(i,0,yak.size()-1){
        if(yak[i]==1)continue;
        x=n;
        while(x%yak[i]==0){
            x/=yak[i];
        }
        if(x%yak[i]==1){
            ans++;
        }
    }
    
    yak.clear();
    yakusuu(n-1);
    ans+=yak.size()-1;
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
    int K[33],n;
    K[1]=1,K[2]=1,K[3]=1,K[4]=2,K[5]=1,K[6]=2,K[7]=1,K[8]=5,K[9]=2,K[10]=2,K[11]=1,K[12]=5,K[13]=1,K[14]=2,K[15]=1,K[16]=14,K[17]=1,K[18]=5,K[19]=1,K[20]=5,K[21]=2,K[22]=2,K[23]=1,K[24]=15,K[25]=2,K[26]=2,K[27]=5,K[28]=4,K[29]=1,K[30]=4,K[31]=1,K[32]=51;
    cin>>n;
    cout<<K[n]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int a,b,h;
	scanf("%d %d %d",&a,&b,&h);
	printf("%d\n",(a + b) * h / 2);
	return 0;
}


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

const int N = 1e5 + 5;

int S[N][22] , ans[N] , n , m , x , y , res , Tay[N][22];

vector <int> G[N];

void dfs(int x , int f) {
  for(int i = 0;i < (int) G[x].size();++ i) {
    int V = G[x][i];
    if(V == f)  continue;
    dfs(V , x);
    ++ S[x][ans[V]];
    for(int i = ans[V] + 1;i < 22;++ i) S[x][i] += S[V][i];
  }
  
  for(int i = 21;i >= 0;-- i) if(S[x][i]){
      if(S[x][i] >= 2) {
        for(int j = i;j >= 0;-- j) Tay[x][j] = 1;
        break;
      }
      else Tay[x][i] = 1;
  }
  for(ans[x] = 0;Tay[x][ans[x]];++ ans[x]);
  res = max(res , ans[x]);
}

int main(void) {
  //freopen("jas.in" , "r" , stdin);
  //freopen("jas.out" , "w" , stdout);
  cin.sync_with_stdio(0);
  cin >> n;
  for(int i = 1;i < n;++ i) {
    cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs(1 , 0);
  cout << res << endl;
}


Measured memory_bytes: 29056
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> mp[100001];
int maxdepth(int k)
{
	vector<int> deps;
	for (size_t i=0;i<mp[k].size();++i)
		deps.push_back(maxdepth(mp[k][i]));
	sort(deps.begin(),deps.end());
	reverse(deps.begin(),deps.end());
	int ret=0;
	for (size_t i=0;i<mp[k].size();++i)
		ret=max(ret,int(i)+deps[i]);
	return ret+1;
}
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=2;i<=n;++i)
	{
		int tmp;
		scanf("%d",&tmp);
		mp[tmp].push_back(i);
	}
	printf("%d",maxdepth(1)-1);
	return 0;
}


Measured memory_bytes: 15104
#include<iostream>
#define mod 1000000007
using namespace std;
int h,w,f[1001][1001];
main()
{
	cin>>h>>w;
	char a[1001][1001];
	for(int i = 1;i <= h;i++)
	for(int j = 1;j <= w;j++)
		cin>>a[i][j];
	f[1][0] = 1;
	for(int i = 1;i <= h;i++)
	for(int j = 1;j <= w;j++)
	if(a[i][j] == '#')continue;
	else
	f[i][j] = (f[i-1][j]+f[i][j-1])%mod;
	cout<<f[h][w];
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int t = 0;
    int a = n;
    while(a / 10 != 0)
    {
        t += a % 10;
        a /= 10;
    }
    t += a % 10;

    if(n % t == 0)
    {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 256
S = list(input())
T = S[::-1]
l = len(S)
P = ["j"]*20
T.extend(P)
start = 0
j = 0

while(True):
    five = "".join(T[start:start+5])
    six = "".join(T[start:start+6])
    seven = "".join(T[start:start+7])
    if five == "esare" or five == "maerd":
        start += 5
    elif six == "resare":
        start += 6
    elif seven == "remaerd":
        start += 7
    else:
        j = 1
    if j == 1 or start == l:
        break

if j == 1:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 51312
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String a = (br.readLine());
		String b = (br.readLine());
		String c = (br.readLine());

		String a2 = a.substring(0, 1);
		String b2 = b.substring(1, 2);
		String c2 = c.substring(2, 3);

		System.out.println(a2 + b2 + c2);
	}

}

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

int main() {
	int n;cin>>n;int a[n];
	int max=0;int min=0;int maxnum=0;int minnum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(max<a[i]){
			max=a[i];maxnum=i;
		}
		if(min>a[i]){
			min=a[i];minnum=i;
		}
	}
	int big=1;
	int num=maxnum;
	cout<<2*n-1<<endl;
	if(max<(min*(-1))){
		big=0;
		num=minnum;
	}
	for(int i=0;i<n;i++){
		if(i!=num){
			cout<<num+1<<' '<<i+1<<endl;
		}
	}
	cout<<num+1<<' '<<num+1<<endl;
	if(n!=1){
		if(big){
			cout<<num+1<<" 2"<<endl;
			for(int i=3;i<=n;i++){
				cout<<i-1<<' '<<i<<endl;
			}
		}else{
			cout<<num+1<<' '<<n-1<<endl;
			for(int i=n-2;i>0;i--){
				cout<<i+1<<' '<<i<<endl;
			}

		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main() {
  int n,k;
  cin >> n >> k;
  vector<ll> x(n),y(n);
  rep(i,n) cin >> x[i] >> y[i];
  auto a = x, b = y;
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());

  ll ans = longinf*4;
  rep(i,n)REP(j,i+1,n)rep(p,n)REP(q,p+1,n){
    int cnt=0;
    rep(k,n)if(a[i]<=x[k] && x[k]<=a[j] && b[p]<=y[k] && y[k]<= b[q]) cnt++;
    if(cnt >= k){ 
      ll tmp = (a[j]-a[i])*(b[q]-b[p]);
      ans = min(ans, tmp);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int go[100005] = {};

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

    for(int i = 0; i < n; i++){
        cin >> a >> b;
        go[a]++;
        go[b+1]--;
    }

    int ans = 0, sum = 1;
    for(int i = 2; i < 100005; i++){
        sum += go[i];
        if(sum >= i)    ans = i;
    }

    cout << max(0, ans-1) << endl;

    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

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

ll mod = 998244353;

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

  int s,w;
  cin >> s >> w;
  if(w >= s)cout << "unsafe" << endl;
  else cout << "safe" << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define F first
#define S second
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define PICK(N,m,p) (N/(int)(pow(p,m-1))-(N/(int)(pow(p,m)))*p)
using lint = long long;
using ld = long double;
using namespace std;

//ユークリッド互除法
lint gcd(lint x,lint y){
    lint a=MAX(x,y);
    lint b=MIN(x,y);
    if(b==0) return a;
    else {
        lint q=a/b;
        lint g=gcd(b,a-q*b);
        return g;
    }
}

int main(){
    int A, B;
    cin >> A >> B;
    cout << (lint)(A)*(lint)(B)/gcd((lint)A,(lint)B) << endl;
	return 0;
}

Measured memory_bytes: 3596
x,N=map(int,input().split())
p=list(map(int,input().split()))
ans=101
if x in p:
    for i in range(102):
        if i in p:
            continue
        ans=min(ans,abs(i-x))
    if x-ans in p:
        ans*=-1
else:
    ans=0
print(x-ans)


Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

const int mod = 1e9+7;
int ar[2005];
int before[2005];
int after[2005];
int n,k;

int mult(int n,int m){
	if(n>m){
		swap(n,m);
	}
	if(n==0 || m==0){
		return 0;
	}
	if(m==1){
		return n;
	}
	int k = mult(n,m/2);
	int ans = k+k;
	ans %= mod;
	if(m&1){
		ans += n;
	}
	ans %= mod;
	return ans;
}

int32_t main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<i;j++){
			before[i]+=(ar[i]>ar[j]);
		}
		for(int j=i+1;j<=n;j++){
			after[i]+=(ar[i]>ar[j]);
		}
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		ans += after[i]*k;
		ans %= mod;
		ans += mult(((k)*(k-1)/2),(before[i]+after[i]));
		ans %= mod;
		//cout<<ans<<"\n";
	}
	/*for(int i=1;i<=n;i++){
		cout<<before[i]<<" "<<after[i]<<"\n";
	}*/
	cout<<ans;
}


Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n");
  var card = input[1].split(" ");
  var alice = 0;
  var bob = 0;
  var turn = 0;
  card = card.map((a)=>Number(a));
  function p(card){
    if(turn==0){
      alice+=Math.max.apply(null,card);
      turn=1;
    }else{
      bob+=Math.max.apply(null,card);
      turn=0;
    }
    card.splice(card.indexOf(Math.max.apply(null,card)),1);
    if(card==''){
      console.log(alice-bob);
    }else{
      return p(card);
    }
  }
  p(card);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7484
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N, dist[100], dis[100];
bool vis[100];
vector<int>v[100];

void dfs(int x) {
	vis[x] = true;
	for (int i : v[x]) {
		if (!vis[i]) {
			dist[i] = dist[x] + 1;
			dfs(i);
		}
	}
}

int main() {
	cin >> N;
	for (int i = 1; i < N; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(0);
	pair<int, int>Max;
	for (int i = 0; i < N; i++) {
		Max = max(Max, make_pair(dist[i], i));
		dist[i] = 0;
		vis[i] = false;
	}
	dfs(Max.second);
	Max = make_pair(-1, -1);
	for (int i = 0; i < N; i++) {
		Max = max(Max, make_pair(dist[i], i));
		dis[i] = dist[i];
		dist[i] = 0;
		vis[i] = false;
	}
	dfs(Max.second);
	for (int i = 0; i < N; i++) {
		vis[i] = false;
	}
	if (Max.first & 1) {
		cout << Max.first / 2 + 1 << sp;
		queue<int>q;
		ll p = 2;
		for (int i = 0; i < N; i++) {
			if ((dis[i] == Max.first / 2 && dist[i] == Max.first / 2 + 1) || (dis[i] == Max.first / 2 + 1 && dist[i] == Max.first / 2)) {
				q.push(i);
				vis[i] = true;
			}
		}
		while (!q.empty()) {
			int n = q.size();
			int a = 1;
			for (int i = 0; i < n; i++) {
				a = max(a, (int)v[q.front()].size() - 1);
				for (int j : v[q.front()]) {
					if (!vis[j]) {
						vis[j] = true;
						q.push(j);
					}
				}
				q.pop();
			}
			p *= a;
		}
		cout << p << endl;
	}
	else {
		cout << Max.first / 2 + 1 << sp;
		int t;
		for (int i = 0; i < N; i++) {
			if (dis[i] == Max.first / 2 && dist[i] == dis[i]) {
				t = i;
				break;
			}
		}
		queue<int>q;
		ll res;
		ll p = 1;
		q.push(t);
		vis[t] = true;
		while (!q.empty()) {
			int n = q.size();
			int a = 1;
			for (int i = 0; i < n; i++) {
				if (q.front() == t) {
					a = v[t].size();
				}
				a = max(a, (int)v[q.front()].size() - 1);
				for (int j : v[q.front()]) {
					if (!vis[j]) {
						vis[j] = true;
						q.push(j);
					}
				}
				q.pop();
			}
			p *= a;
		}
		res = p;
		for (int i : v[t]) {
			for (int j = 0; j < N; j++) {
				vis[j] = false;
			}
			p = 2;
			q.push(t);
			q.push(i);
			vis[t] = vis[i] = true;
			while (!q.empty()) {
				int n = q.size();
				int a = 1;
				for (int j = 0; j < n; j++) {
					a = max(a, (int)v[q.front()].size() - 1);
					for (int k : v[q.front()]) {
						if (!vis[k]) {
							vis[k] = true;
							q.push(k);
						}
					}
					q.pop();
				}
				p *= a;
			}
			res = min(res, p);
		}
		cout << res << endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int x_1, x_2, x_3, x_4, x_5;

    scanf("%d %d %d %d %d", &x_1, &x_2, &x_3, &x_4, &x_5);

    if(x_1 == 0){
        printf("1");
    }else if(x_2 == 0){
        printf("2");
    }
    else if(x_3 == 0){
        printf("3");
    }
    else if(x_4 == 0){
        printf("4");
    }else{
        printf("5");
    }
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}


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

  deque<char> dq;
  for(int i=0;i<(int)s.size();i++) { dq.push_back(s[i]); }

  int check=1;
  for(int i=0;i<q;i++) {
    int t; cin >> t;

    if(t == 1) {

      if(check == 1) { check = -1; }
      else { check = 1; }

    } else {

      int f; cin >> f;
      char c; cin >> c;
      if(f == 1) {
        if(check == 1) { dq.push_front(c); }
        else { dq.push_back(c); }
      } else {
        if(check == 1) { dq.push_back(c); }
        else { dq.push_front(c); }
      }

    }
  }

  if(check == -1) { reverse(dq.begin(),dq.end()); }
  for(deque<char>::iterator i=dq.begin();i!=dq.end();i++) { cout << *i; }
  cout << endl;
  return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

template <typename T> // T : type of cost
struct BellmanFord {
    T inf = numeric_limits<T>::max(); // initial value, reused when clear() is called
    int n;                            // number of nodes
    vector<T> dist;                   // distance from start node
    vector<bool> negative;
    struct edge {
        int from, to;
        T cost;
        edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
    };
    vector<edge> edges;

    BellmanFord(int n) : n(n), dist(n, inf), negative(n, false){};
    // 0-indexed!
    void addEdge(int from, int to, T cost) { edges.emplace_back(from, to, cost); }
    // calculate dist[i] as a shortest distance from start to each node
    void build(int start) {
        dist[start] = 0;
        for (int i = 0; i < n; ++i) {
            for (auto &e : edges) {
                if (dist[e.from] != inf && dist[e.to] > dist[e.from] + e.cost) {
                    dist[e.to] = dist[e.from] + e.cost;
                }
            }
        }
    }
    // check whether there are negative loops along the path of interest
    bool has_negativeloop(int end = -1) {
        for (int i = 0; i < n; ++i) {
            for (auto &e : edges) {
                if (dist[e.from] != inf && dist[e.to] > dist[e.from] + e.cost) {
                    dist[e.to]     = dist[e.from] + e.cost;
                    negative[e.to] = true;
                }
                negative[e.to] = negative[e.to] || negative[e.from];
            }
        }
        if (end != -1)
            return negative[end];
        else {
            bool neg = false;
            for (int i = 0; i < n; ++i) {
                neg |= negative[i];
            }
            return neg;
        }
    }
};

int main() {
    int n, m, p;
    cin >> n >> m >> p;
    BellmanFord<ll> g(n);
    for (int i = 0; i < m; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        g.addEdge(a, b, -(c - p));
    }
    g.build(0);
    if (g.has_negativeloop(n - 1)) {
        cout << -1 << "\n";
        return 0;
    } else {
        cout << max(0LL, -g.dist[n - 1]) << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cmath>
using std::cout;
using std::cin;
using std::endl;
using std::fixed;
using std::setprecision;

int main()
{
	double x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << fixed << setprecision(8);
	cout << sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2)) << endl;
	return 0;
}

Measured memory_bytes: 1284
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!(x:i64);
    for i in -1000..1001 as i64 {
        for j in -1000..1001 as i64 {
            let a:i64 = i.pow(5);
            let b:i64 = j.pow(5);
            if a-b == x {
                println!("{} {}",i,j);
                return;
            }
        }
    }
}




Measured memory_bytes: 2172
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl



signed main() {

	int r, D, x;
	cin >> r >> D >> x;

	rep(i, 10) {
		x = r * x - D;
		cout << x << endl;
	}




	return 0;
}


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

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    ld L;
    cin >> L;
    printf("%llf\n", L * L * L / 27);
    // cout <<  << "\n";
    return 0;
}

Measured memory_bytes: 256