akhauriyash/Code-Regression huggingface dataset:
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using INT=mp::cpp_int;
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
INT LCM(INT x,INT y){
  INT z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
INT modinv(INT a, INT m) {
    INT b = m, u = 1, v = 0;
    while (b) {
        INT t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main() {
  cout << fixed << setprecision(30);
  ll n,k;
  cin>>n>>k;
  vector<double> a(n);
  vector<double> b(n);
  loop(i,n)cin>>a[i];
  loop(i,n)b[i]=(1+a[i])/2;
  double ksum=0;
  double ans=0;
  loop(i,k)ksum+=b[i];
  if(n==1){
    putout(b[0]);
  }
  else{
    if(n==k)putout(ksum);
    else{
  Loop(i,1,n-k+1){
    ksum+=b[i+k-1];
    ksum-=b[i-1];
    ans=max(ans,ksum);
  }
    putout(ans);
      
    }
  }
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define testing 1
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9+500
#define oo (ll)1e18
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
inline string lts(ll a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}
inline ll stl(string a){
  char x[100]; ll res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN
#if !testing
#define cerr if(0)cout
#endif
unordered_map<ll,ll>memo;
ll ways(ll x) {
	if(x==1)return 1;
	if(x==2)return 3;
	if(memo.find(x)!=memo.end())return memo[x];
	else return memo[x]=2*ways(x/2)+1;
}

int32_t main() {
	IAMSPEED
	// set testing to 0 when submitting to judge
	ll h; cin >> h;
	cout << ways(h);
}


Measured memory_bytes: 256
// B - Buildings are Colorful!

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll a[15];

int count_bit(int bit, int N) {
	int result = 0;

	for (int i=0; i<N; i++) {
		if (bit & (1<<i)) result++;
	}

	return result;
}

ll solve(int bit, int N) {
	ll result = 0;
	ll min_height = a[0] + 1;

	for (int i=1; i<N; i++) {
		if (bit & (1<<i)) {
			if (a[i] < min_height) {
				result += (min_height - a[i]);
			}

			min_height = max(min_height + 1, a[i] + 1);
		} else {
			min_height = max(min_height, a[i] + 1);
		}
	}

	return result;
}

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

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

	ll ans = INF;

	for (int bit=0; bit < (1<<N); bit++) {
		if (count_bit(bit, N) == K) {
			//cout << bitset<15>(bit) << endl; // **** debug ****
			ans = min(ans, solve(bit, N));
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/* author   : mpily :-()
title : Competing.cpp
time :Sun Jun 14 13:11:23 2020

*/
#include<random>
#include<cassert>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<utility>
#include<cstdint>
#include<queue>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdio>
using namespace std;

void solve(int cnum){
	//for(int64_t i = 1;i < 100;++i){
	//cin >> n;
		int64_t n ;//= i;
		cin >> n;
		string ans;
		while(n){
			ans.push_back(n%26 + 'a' -1);
			if(ans.back() == 'a'-1){
				ans[ans.size()-1] = 'z';
			}
			n/=26;
			if(ans.back() == 'z')
				n-=1;
		}
		reverse(ans.begin(),ans.end());
		cout << ans <<"\n";
	//}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	//cout.tie(nullptr);
	int t;
	int count = 1;
	for(t = 1;t--; solve(count));
	return 0;
}

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

#define DRACARYS ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, -1, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define PI 3.14159265
const long long int MAXN = 1e3+10;
const long long int MINN = 1e5+10;
const long long int inf = 1e9+7;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi; 
typedef stack<int> st;
int r,c,dp[MAXN][MAXN];
char a[MAXN][MAXN];
int main(){ 
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    DRACARYS
    cin>>r>>c;
    repA(i,1,r) repA(j,1,c) cin>>a[i][j];
    dp[1][1]=1;
    repA(j,2,c) if(a[1][j]=='.') dp[1][j]=dp[1][j-1];
    repA(i,2,r) if(a[i][1]=='.') dp[i][1]=dp[i-1][1];
    repA(i,2,r) repA(j,2,c){
        if(a[i][j]=='.') dp[i][j]=(dp[i-1][j]+dp[i][j-1])%inf;
    }
    cout<<dp[r][c]<<endl;
    /*repA(i,1,r){
        repA(j,1,c) cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    return 0;
}

Measured memory_bytes: 5248
def main():
    N, Z, W = map(int, input().split())
    a = list(map(int, input().split()))
    retval = abs(a[-1] - W)
    if N >= 2:
        retval = max(retval, abs(a[-1] - a[-2]))
    print(retval)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38640
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int64_t n, m, v, p;
    cin >> n >> m >> v >> p;

    vector<int> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    vector<int64_t> asum(n + 1);
    asum[0] = 0;
    rep(i, n)
    {
        asum[i + 1] = asum[i] + a[i];
    }

    int result = 0;
    rep(i, n)
    {
        if (i >= n - p)
        {
            result++;
        }
        else if (a[i] + m >= a[n - p])
        {
            int offset = i + 1;
            int ub = n - p + 1;

            int64_t rect = (int64_t)(ub - offset) * (a[i] + m);
            int64_t cap = rect - (asum[ub] - asum[offset]);

            if (cap >= m * (v - (p - 1 + i + 1)))
            {
                result++;
            }
        }
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>

void cut(int k,int* cards,int ary_size){
  int pointer = 0;
  int result[ary_size];
  
  for(int i = k; i < ary_size; i++){
    result[pointer] = cards[i];
    pointer++;
  }

  for(int i = 0; i < k; i++){
    result[pointer] = cards[i];
    pointer++;
  }

  memcpy(cards,result,sizeof result);
}

void shuffle(int* cards,int ary_size){
  int half_size = ary_size / 2;
  int result[ary_size];
  int pointer = 0;
  
  int A[half_size];
  for(int i = 0; i < half_size; i++) A[i] = cards[i];

  int B[half_size];
  for(int i = half_size; i < ary_size; i++){
    B[pointer] = cards[i];
    pointer++;
  }
 
  pointer = 0;
  for(int i = 0; i < ary_size; i += 2){
    result[i] = A[pointer];
    result[i + 1] = B[pointer];
    pointer++;
  }

  memcpy(cards,result,sizeof result);
}

int main(){
  int cards,operations;
  scanf("%d",&cards);
  scanf("%d",&operations);

  cards = cards * 2;
  int cards_ary[cards];
  for(int i = 0; i < cards; i++) cards_ary[i] = i + 1; 

  int sort_process[operations];
  for(int i = 0; i < operations; i++){
    scanf("%d",&sort_process[i]);
  }
 
  for(int i = 0; i < operations; i++){
    if(sort_process[i] > 0) cut(sort_process[i],cards_ary,cards);
    else shuffle(cards_ary,cards); 
  }

  for(int i:cards_ary) printf("%d\n",i);
}

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

using namespace std;

vector<long long> fat(long long n){
    vector<long long> factor;

    for(long long i = 2; i*i <= n; i++){

        if(n%i == 0)
            factor.push_back(i);

        while(n%i == 0){
           n /= i;        
        }

    }
    if(n > 1)
        factor.push_back(n);

    return factor;
}

int main(){

    long long a, b;  
    vector<long long> fata, fatb;    
    vector<long long> final(10000);    

    cin >> a >> b;   
    
    fata = fat(a);
    fatb = fat(b);
    
    vector<long long>::iterator it = set_intersection(fata.begin(), fata.end(), fatb.begin(), fatb.end(), final.begin());  

    final.resize(it-final.begin()); 
  
    cout << final.size() + 1 << endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n= input.nextInt();
        int k = input.nextInt();
        String t="";
        while(n> 0){
       t = t+n%k;
       n = n/k;
     }
        System.out.println(t.length());
    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;

int main(){
    int k; cin >> k;
    string s; cin >> s;
    if(s.length() <= k){
        cout << s << endl;
    }else{
        rep(i, k){
            cout << s[i];
        }
        cout << "..." << endl;
    }
}
    

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	string o, e, out; cin >> o >> e; int n = o.length(); int m = e.length();
	rep(i, n) {
		out += o[i];
		if (i < m) {
			out += e[i];
		}
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main
{
		public static void main(String[] args)
        {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String str = S.substring(5, 7);

		int month = Integer.valueOf(str);
		if(month < 5) 
        {
			System.out.println("Heisei");
		}
        else
        {
			System.out.println("TBD");
		}
	}
}

Measured memory_bytes: 21588
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, i, j, tmp;
    int[] m;
    int[][] x, y;


    for(;;){
      n = sc.nextInt();
      if(n == 0)break;

      m = new int[n + 1];
      x = new int[n + 1][10]; y = new int[n + 1][10];
      for(i = 0;i < n + 1;i++){
        m[i] = sc.nextInt();
        for(j = 0;j < m[i];j++){
          x[i][j] = sc.nextInt(); y[i][j] = sc.nextInt();
        }
      }

      for(i = 1;i < n + 1;i++){
        if(m[0] == m[i]){
          if(isisom(x, y, m, i))out.println(i);
          for(j = 0;j < m[i] / 2;j++){
            tmp = x[i][j]; x[i][j] = x[i][m[i] - 1 - j];
            x[i][m[i] - 1 - j] = tmp;
            tmp = y[i][j]; y[i][j] = y[i][m[i] - 1 - j];
            y[i][m[i] - 1 - j] = tmp;
          }
          if(isisom(x, y, m, i))out.println(i);
        }
      }
      out.println("+++++");
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static boolean isisom(int[][] x, int[][] y, int[] m, int i){
    int j, s0, si, l0, li;
    for(j = 0;j < m[i] - 2;j++){
      s0 = (x[0][j + 1] - x[0][j]) * (y[0][j + 2] - y[0][j])
      - (x[0][j + 2] - x[0][j]) * (y[0][j + 1] - y[0][j]);
      si = (x[i][j + 1] - x[i][j]) * (y[i][j + 2] - y[i][j])
      - (x[i][j + 2] - x[i][j]) * (y[i][j + 1] - y[i][j]);
      l0 = (x[0][j + 1] - x[0][j]) * (x[0][j + 1] - x[0][j])
      + (y[0][j + 1] - y[0][j]) * (y[0][j + 1] - y[0][j]);
      li = (x[i][j + 1] - x[i][j]) * (x[i][j + 1] - x[i][j])
      + (y[i][j + 1] - y[i][j]) * (y[i][j + 1] - y[i][j]);
      if(s0 * si <= 0 || l0 != li)return false;
    }
    l0 = (x[0][j + 1] - x[0][j]) * (x[0][j + 1] - x[0][j])
    + (y[0][j + 1] - y[0][j]) * (y[0][j + 1] - y[0][j]);
    li = (x[i][j + 1] - x[i][j]) * (x[i][j + 1] - x[i][j])
    + (y[i][j + 1] - y[i][j]) * (y[i][j + 1] - y[i][j]);
    if(l0 == li)return true;
    return false;
  }
}

Measured memory_bytes: 29484
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		char a = sc.next().charAt(0);

		int ascii = (int) a;

		if(ascii>91) {
			System.out.println("a");
		}else {
			System.out.println("A");
		}


	}

}


Measured memory_bytes: 35496
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const ll mod=1e+9+7;
int main(void){
    int n;string s;cin>>n>>s;
    if(s[0]=='W'||s[s.size()-1]=='W'){
        cout<<0<<endl;
        return 0;
    }
    vector<int> t(s.size());
    t[0]=0;//0はL,1はR
    queue<int> que;
    rep(i,s.size()-1){
        if(s[i+1]==s[i]){
            t[i+1]=1-t[i];
        }else{
            t[i+1]=t[i];
        }
        if(t[i+1]==1)que.push(i+1);
    }
    if(que.size()!=n){
        cout<<0<<endl;
        return 0;
    }
    ll res=1;
    rep(i,n) res=(res*(i+1))%mod;
    rep(i,n){
        ll x=que.front();que.pop();
        res*=(x-2*i);
        res%=mod;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1668
#include<iostream>
#include<cstdio>
using namespace std;
int n,m;
int l[20],d[20];
int main()
{
    while(~scanf("%d%d",&n,&m),n+m)
    {
        for(int i=0;i<n;i++)
            scanf("%d",&l[i]);
        for(int i=0;i<m;i++)
            scanf("%d",&d[i]);
        int ans=0;
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
                if(l[i]==d[j]){ans+=l[i];l[i]=d[j]=0;break;}
        for(int i=0;i<n;i++)
            ans+=l[i];
        for(int i=0;i<m;i++)
            ans+=d[i];
        cout<<ans<<endl;
    }
    return 0;
}

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

using namespace std;

typedef pair<int, int> P;

P f(P a, P b)
{
	return P(b.first - a.first, b.second - a.second);
}

int main()
{
	int m, n;

	while (true) {
		cin >> m;
		if (m == 0) break;

		vector<P> seiza(m);

		for (int i = 0; i < m; ++i) cin >> seiza[i].first >> seiza[i].second;

		cin >> n;

		vector<P> image(n);

		for (int i = 0; i < n; ++i) cin >> image[i].first >> image[i].second;

		P s0 = seiza[0];

		for (int i = 0; i < n; ++i) {
			int cnt = 1;

			P amount_of_change = f(s0, image[i]);
			for (int j = 1; j < m; ++j) {
				P sj = seiza[j];
				for (int k = 0; k < n; ++k) {
					if (sj.first + amount_of_change.first == image[k].first && sj.second + amount_of_change.second == image[k].second) {
						cnt++;
					}
				}

				if (cnt == m) {
					printf("%d %d\n", amount_of_change.first, amount_of_change.second);
					goto end;
				}
			}
		}
end:;
	}
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
typedef double dd;
#define pb push_back
#define mp make_pair
#define endl "\n"
ll const M = 1000000007;
dd const pi = acos(-1);
ll const inf = 2e18;
ll const N = 200001;
vector<vector<ll> > g(N);
void bfs(ll sv,ll n)
{
  ll i,j;
  queue<ll> q;
  vector<bool> visited(n + 1,false);
  vector<ll> par(n + 1);
  for(i = 1; i <= n; i++)
    par[i] = i;
  q.push(sv);
  visited[sv] = true;
  while(!q.empty())
  {
    ll node = q.front();
    q.pop();
    for(auto x : g[node])
    {
      if(!visited[x])
      {
        par[x] = node;
        visited[x] = true;
        q.push(x);
      }
    }
  }
  vector<ll> ans;
  for(i = 2; i <= n; i++)
  {
    if(par[i] == i)
      break;
    else
      ans.pb(par[i]);
  }
  if(i == (n + 1))
  {
    cout<<"Yes"<<endl;
    for(auto x : ans)
      cout<<x<<endl;
  }
  else
    cout<<"No"<<endl;
}
int main()
{
    fast;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    ll i,j,t,n,m;
    cin >> n >> m;
    for(i = 1; i <= m; i++)
    {
      cin >> j >> t;
      g[t].pb(j);
      g[j].pb(t);
    }
    bfs(1,n);
    return 0;
}    

Measured memory_bytes: 16520
#include <iostream>
#include <vector>
#include <cstdio>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
vector<int> et[150000];
double dp[150000];
double dp2[150000];

double dfs(int p, int v) {
	if (et[v].size() == 1 && p != -1) return dp[v] = 0;
	
	int i;
	double ssum = 0;
	int cnt = 0;
	rep(i, et[v].size()) {
		int nv = et[v][i];
		if (nv == p) continue;
		ssum += dfs(v, nv);
		cnt++;
	}
	return dp[v] = ssum / cnt + 1;
}

void dfs2(double pDp, int p, int v) {
	int i, j;
	
	//vについて計算(dp[v]よりもう少し詳しい情報)
	double ssum = 0;
	rep(i, et[v].size()) {
		int nv = et[v][i];
		if (nv == p) continue;
		ssum += dp[nv];
	}
	if (p != -1) {
		ssum += pDp;
	}
	
	//ch(vの子)について計算→呼び出し
	rep(i, et[v].size()) {
		int ch = et[v][i];
		if (ch == p) continue;
		
		double sumCst = 0;
		double pCst;
		if (et[v].size() == 1) pCst = 0;
		else pCst = (ssum - dp[ch]) / (et[v].size() - 1) + 1;
		
		rep(j, et[ch].size()) {
			int nv = et[ch][j];
			double cst;
			if (nv == v) {
				cst = pCst;
			}
			else {
				cst = dp[nv];
			}
			sumCst += cst;
		}
		dp2[ch] = sumCst / et[ch].size() + 1;
		dfs2(pCst, v, ch);
	}
}

int main() {
	int i;
	
	cin >> n;
	rep(i, n - 1) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		et[u].push_back(v);
		et[v].push_back(u);
	}
	dp2[0] = dfs(-1, 0);
	dfs2(0, -1, 0);
	
	rep(i, n) {
		printf("%.14f\n", dp2[i]);
	}
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i = 0; i < n; ++i) cin >> a[i]; sort(all(a));
    for(int i = 0; i < n; ++i) cin >> b[i]; sort(all(b));
    for(int i = 0; i < n; ++i) cin >> c[i]; sort(all(c));

    LL res = 0;
    for(int i = 0; i < n; ++i) {
        LL ac, bc;
        ac = lower_bound(all(a), b[i]) - a.begin();
        bc = c.end() - upper_bound(all(c), b[i]);
        res += ac * bc;

    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N;
    cin >> N;

    string S = "";

    if (N % 2 == 1 || N < 10) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    N /= 2;
    ll st = 5;
    while (st <= N) {
        ans += N / st;
        st *= 5LL;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int Max=100+5;
int main(){
	int n;
	cin>>n;
	double sum=0;
	for(int i=0;i<n;i++){
		double t;
		cin>>t;
		sum+=1.0/t;
	}
	cout<<fixed<<setprecision(6)<<1.0/sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

long long a,b,c;

int main() {
	
	
	cin>>a>>b>>c;
	
	if(a%2==0||b%2==0||c%2==0) cout<<0;
	else {
		long long temp1=max(max(a,b),c);
		long long temp2=min(min(a,b),c);
		temp1=a+b+c-temp2-temp1;
		cout<<temp1*temp2;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1LL << 60;
constexpr int INF = 3000000007;
const double INFD = 1e100;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  ll A,B,K;
  cin >> A >> B >> K;
  if(K>A){
    K -= A;
    cout << 0 << " ";
    cout << max((ll)0,B-K) << endl;
  }else{
    cout << A-K << " " << B << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
st = 0
ans = 1
mod = 10**9 + 7
for x in l:
  st += 1
  if st*2 - 1 > x:
    ans = ans * st % mod
    st -= 1
for i in range(st):
  ans = ans * (i+1) % mod
print(ans)

Measured memory_bytes: 14060
#include<stdio.h>

int main(void){

  int N;

  scanf("%d", &N);

  switch(N % 10){
    case 0 : printf("pon\n"); break;
    case 1 : printf("pon\n"); break;
    case 2 : printf("hon\n"); break;
    case 3 : printf("bon\n"); break;
    case 4 : printf("hon\n"); break;
    case 5 : printf("hon\n"); break;
    case 6 : printf("pon\n"); break;
    case 7 : printf("hon\n"); break;
    case 8 : printf("pon\n"); break;
    case 9 : printf("hon\n"); break;
  }

  return 0;
}


Measured memory_bytes: 1620
n, a, b, c = map(int, input().split())
s = [input() for _ in range(n)]

is_possible = True
choice = []
ab = a + b
ac = a + c
bc = b + c

for i in range(n):
    if s[i] == 'AB':
        if ab == 0:
            is_possible = False
            break
        else:
            if ac > bc:
                choice.append('B')
                ac -= 1
                bc += 1
            elif ac == bc == 1 and i + 1 < n:
                if s[i + 1] == 'AC':
                    choice.append('A')
                    ac += 1
                    bc -= 1
                elif s[i + 1] == 'BC':
                    choice.append('B')
                    ac -= 1
                    bc += 1
                else:
                    choice.append('B')
                    ac -= 1
                    bc += 1
            else:
                choice.append('A')
                ac += 1
                bc -= 1
    elif s[i] == 'AC':
        if ac == 0:
            is_possible = False
            break
        else:
            if ab > bc:
                choice.append('C')
                ab -= 1
                bc += 1
            elif ab == bc == 1 and i + 1 < n:
                if s[i + 1] == 'AB':
                    choice.append('A')
                    ab += 1
                    bc -= 1
                elif s[i + 1] == 'BC':
                    choice.append('C')
                    ab -= 1
                    bc += 1
                else:
                    choice.append('C')
                    ab -= 1
                    bc += 1
            else:
                choice.append('A')
                ab += 1
                bc -= 1
    else:
        # BC
        if bc == 0:
            is_possible = False
            break
        else:
            if ab > ac:
                choice.append('C')
                ab -= 1
                ac += 1
            elif ab == ac == 1 and i + 1 < n:
                if s[i + 1] == 'AB':
                    choice.append('B')
                    ab += 1
                    ac -= 1
                elif s[i + 1] == 'AC':
                    choice.append('C')
                    ab -= 1
                    ac += 1
                else:
                    choice.append('C')
                    ab -= 1
                    ac += 1
            else:
                choice.append('B')
                ab += 1
                ac -= 1

if is_possible:
    print('Yes')
    print(*choice, sep='\n')
    # print('  ', 0, a, b, c)
    # for i in range(n):
    #     if s[i] == 'AB':
    #         if choice[i] == 'A':
    #             a += 1
    #             b -= 1
    #         else:
    #             a -= 1
    #             b += 1
    #     elif s[i] == 'AC':
    #         if choice[i] == 'A':
    #             a += 1
    #             c -= 1
    #         else:
    #             a -= 1
    #             c += 1
    #     else:
    #         # BC
    #         if choice[i] == 'B':
    #             b += 1
    #             c -= 1
    #         else:
    #             b -= 1
    #             c += 1
    #     print(s[i], choice[i], a, b, c)
else:
    print('No')


Measured memory_bytes: 18704
N,M=map(int,input().split())
H=list(map(int,input().split()))
GoodViewpoint=[1]*N
for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]>H[b-1]:
        GoodViewpoint[b-1]=0
    elif H[a-1]<H[b-1]:
        GoodViewpoint[a-1]=0
    else:
        GoodViewpoint[a-1]=0
        GoodViewpoint[b-1]=0
        pass
print(GoodViewpoint.count(1))

Measured memory_bytes: 19880
N, K = [int(_) for _ in input().split()]
V = [int(_) for _ in input().split()]

result = 0
for i in range(min(N + 1, K + 1)):
    for j in range(min(N - i + 1, K - i + 1)):
        xs = V[:i] + (V[-j:] if j else [])
        t = sum(xs)
        l = K - i - j
        xsm = list(sorted(x for x in xs if x < 0))[:l]
        r = t - sum(xsm)
        # print(i, j, l, xs, t, xsm, r)
        result = max(result, r)

print(result)


Measured memory_bytes: 43248
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
#define fu(i,a,b)   for(ll i=a;i<b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define ms(a,x) 	memset(a, x, sizeof a)
#define prec(n) 	fixed<<setprecision(n)
#define pb(i)	    push_back(i)
#define popb()    	pop_back()
#define sc(a) 	    cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)	    cout<<a<<" "
#define pr2(a,b)    cout<<a<<" "<<b<<" "
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)	lower_bound(a.begin(),a.end(),x) -a.begin()
#define all(x) 		(x).begin(), (x).end()
#define sz(a) 		(ll)a.size()
#define le(s)		(ll)s.length()						
#define re 			return 	
#define	mp(a,b)  	make_pair(a,b)
#define se			second
#define fi			first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
void inline minize(ll& a,ll b){a=(a>b?b:a);};
void inline maxize(ll& a,ll b){a=(a<b?b:a);};
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e5;

ll arr[MAXN+5],arrcnt[2*MAXN+5];
pll arrsort[MAXN+5];
class cmp_r{
	public: bool operator()(pll a,pll b){
		re a.se>b.se;
	}
};

ll Solves(){
//	INPUT;
	ll n,k,m,cnt=0,ans=oo,x,y,p=1,moreone=0,minus=0,sumpress=0;
	// PROCESSING IN HERE
	priority_queue<pll,vector<pll>,cmp_r> pq;
	sc2(n,m);
	fu(i,0,n){
		sc(arr[i]);
		if(i){
			if(arr[i]!=arr[i-1])moreone=1;
			if(arr[i]>=arr[i-1])arrsort[i]=mp(arr[i-1],arr[i]),sumpress+=arr[i]-arr[i-1];
			else arrsort[i]=mp(arr[i-1],arr[i]+m),sumpress+=arr[i]+m-arr[i-1];
		}
	}
	sort(arrsort+1,arrsort+n);
	
	fu(i,1,2*m){
		minus=0;
		while(pq.size() and pq.top().se<i)minus+=pq.top().se-pq.top().fi-1,pq.pop();
		arrcnt[i]=arrcnt[i-1]+pq.size()-minus;
		if(i>m)arrcnt[(i-1)%m+1]+=arrcnt[i];
		while(p<n and arrsort[p].fi+1==i)pq.push(arrsort[p++]);
	}
	fu(i,1,m+1)minize(ans,sumpress-arrcnt[i]);
	//if(ans==oo)ans=0;
	pr(ans);
	re 0;
	// Hack it if you can :)
}
int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	Solves();
}

Measured memory_bytes: 5872
K = int(input())

import heapq
def dijkstra(adj, n, start):
    dj = [10**6] * (n + 1)
    dj[start] = 0
    q = []
    heapq.heappush(q, (0, start))
    while q:
        fc, fn = heapq.heappop(q)
        if dj[fn] < fc: continue
        for tn, lc in adj[fn]:
            if dj[tn] > dj[fn] + lc:
                dj[tn] = dj[fn] + lc
                heapq.heappush(q, (dj[tn], tn))
    return dj

adj = {}
for i in range(K):
    t = adj.setdefault(i, [])
    t.append(((i + 1) % K, 1))
    t.append(((i * 10) % K, 0))

costs = dijkstra(adj, K - 1, 1)
print(costs[0] + 1)

Measured memory_bytes: 48416
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String result = null;

        if(a*b%2 !=0){
            result = "Odd";
        }else{
            result ="Even";
        }
        System.out.println(result);

    }
}


Measured memory_bytes: 20948
var
  i,x,y,t:longint;
  s:ansistring;
begin
  readln(s);
  x:=0;y:=0;t:=0;
  for i:=1 to length(s) do
   if x=y then
     begin
       x:=x+1;
       if s[i]='p' then t:=t-1;
     end
    else
     begin
       y:=y+1;
       if s[i]='g' then t:=t+1;
     end;
  writeln(t);
end.

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

using namespace std;

main()
{
    int A,B;
    scanf("%d%d",&A,&B);
    if ( A == B ) {
        printf("%s\n", "Draw");
    } else {
        if ( A == 1 || B == 1 ) {
            if ( A == 1 ) {
                printf("%s\n", "Alice");
            } else if ( B == 1 ) {
                printf("%s\n", "Bob");
            }
        } else {
            if ( A > B ) {
                printf("%s\n", "Alice");
            } else if ( A < B ) {
                printf("%s\n", "Bob");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
s = input()

ct1 = 0
for i in range(len(s)):
    
    if i%2==0:
        if s[i] != '0':
            ct1 += 1
    else:
        if s[i] != '1':
            ct1 +=1

ct2 = 0
for i in range(len(s)):
    
    if i%2==0:
        if s[i] != '1':
            ct2 += 1
    else:
        if s[i] != '0':
            ct2 +=1

if ct1 <= ct2:
    print(ct1)
else:
    print(ct2)

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

struct V {
  double x, y;
  V(double x=0, double y=0): x(x), y(y) {}
  V& operator+=(const V& v) { x += v.x; y += v.y; return *this;}
  V operator+(const V& v) const { return V(*this) += v;}
  V& operator-=(const V& v) { x -= v.x; y -= v.y; return *this;}
  V operator-(const V& v) const { return V(*this) -= v;}
  V& operator*=(double s) { x *= s; y *= s; return *this;}
  V operator*(double s) const { return V(*this) *= s;}
  V& operator/=(double s) { x /= s; y /= s; return *this;}
  V operator/(double s) const { return V(*this) /= s;}
  double dot(const V& v) const { return x*v.x + y*v.y;}
  double cross(const V& v) const { return x*v.y - v.x*y;}
  double norm2() const { return x*x + y*y;}
  double norm() const { return sqrt(norm2());}
  
  int ort() const { // orthant
    if (y > 0) return x>0 ? 1 : 2;
    else return x>0 ? 4 : 3;
  }
  bool operator<(const V& v) const {
    int o = ort(), vo = v.ort();
    if (o != vo) return o < vo;
    return cross(v) > 0;
  }
};
istream& operator>>(istream& is, V& v) {
  is >> v.x >> v.y; return is;
}
ostream& operator<<(ostream& os, const V& v) {
  os<<"("<<v.x<<","<<v.y<<")"; return os;
}

int main() {
  int n;
  cin >> n;
  vector<V> v(n);
  rep(i,n) cin >> v[i];
  sort(v.begin(), v.end());
  double ans = 0;
  rep(l,n) {
    int r = l;
    V now;
    rep(i,n) {
      now += v[r];
      ans = max(ans, now.norm());
      r = (r+1)%n;
    }
  }
  printf("%.12f\n", ans);
  return 0;
}

Measured memory_bytes: 256
module Main where

import Control.Applicative

getInt :: IO Int
getInt = head <$> getInts

getInts :: IO [Int]
getInts = map read . words <$> getLine

main :: IO ()
main = do
  {[a, b, c] <- getInts
  ; if a < b then if b < c then putStrLn "Yes"
                  else putStrLn "No"
    else putStrLn "No"
  }



Measured memory_bytes: 3608
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<utility>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int a,b;
int main(){
	cin>>a>>b;
	if(a<b)
		cout<<0;
	else
		cout<<10;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == 7 && b == 5 && c == 5){
        cout << "YES" << endl;
    }else if(a == 5 && b == 7 && c == 5){
        cout << "YES" << endl;
    }else if(a == 5 && b == 5 && c == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

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

int main() {
    int x, y;
    cin >> x >> y;
    int ans = 0;
    if (x <= 3){
        ans += (4 - x);
    }
    if (y <= 3){
        ans += (4 - y);
    }
    if (x == 1 && y == 1) ans += 4;
    ans *= 100000;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	S := sc.nextStr()
	ans := 0
	var str []rune
	for _, r := range S {
		if len(str) == 0 {
			str = append(str, r)
			continue
		}
		if str[len(str)-1] != r {
			ans += 2
			str = str[0 : len(str)-1]
		} else {
			str = append(str, r)
		}
	}
	fmt.Println(ans)
}


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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int64_t ans = max({a, b, c}) * pow(2, k);
    ans += a + b + c - max({a, b, c});
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main() {
    int N,M,r=0;
    cin >> N >> M;
    vector<int> X(M),d(M-1);

    if(N >= M) {
        cout << 0 << endl;
        return 0;
    }

    rep(i,M)
        cin >> X.at(i);
    sort(X.begin(), X.end());

    rep(i,M-1)
        d.at(i) = X.at(i+1)-X.at(i);
    sort(d.begin(), d.end());

    rep(i,min(M-N,M-1))
        r += d.at(i);
    cout << r << endl;
}

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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	vector<int> H(N);
	for(int i=0;i<N;i++)	cin >> H.at(i);

	int ans=0;
	for(int i=0;i<N;i++){
		bool flag=true;
		for(int j=0;j<=i;j++){
			if(H.at(i)<H.at(j))	flag=false;
		}
		if(flag)	ans++;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){

  int n;
  cin >> n;
  int a[n];
  int c[n];
  rep(i,n) c[i]=0;
  rep(i,n){
    cin >> a[i];
    c[--a[i]]++;
  }
  int pa[n+1];
  rep(i,n+1) pa[i]=0;
  rep(i,n){
    //    cout << c[i] << endl;
    pa[c[i]]++;
  }
  ll s[n+1];
  ll pn[n+1];
  pn[0]=0;
  s[0]=0;
  rep1(i,n){
    s[i]=s[i-1];
    s[i]+=pa[i]*i;
    pn[i]=pn[i-1];
    pn[i]+=pa[i];
  }
  ll ss[n+1];
  rep(i,n+1){
    ss[i]=s[i];
    ss[i]+=(pn[n]-pn[i])*i;
    //    cout << s[i] << " " << ss[i] << endl;
  }
  rep1(i,n){
    ll lb=0;
    ll ub=n+1;
    while(ub-lb>1){
      ll mid=(lb+ub)/2;
      if(i*1LL*mid<=ss[mid]){
	lb=mid;
      }
      else{
	ub=mid;
      }
    }
    cout << lb << endl;
  }
  
  return 0;

}


Measured memory_bytes: 11392
#include <stdio.h>
#include <stdlib.h>

int t8s_force_scan_int()
{
	int n;

	if (scanf("%d", &n) == EOF)
	{
		printf("expected int input but got EOF");
		exit(-1);
	}

	return n;
}

int t8s_force_read_int_array(size_t count, int** arr)
{
	*arr = (int*) malloc(count * sizeof(int));

	if (arr == NULL)
		return -1;

	for (int i=0; i<count;i++)
	{
		int n;
		scanf("%d ", &n);
		*(*arr+i) = n;
	}

	return 0;
}

void t8s_swap(int* l, int* r)
{
	int o = *l;
	*l = *r;
	*r = o;
}

int sort(int* arr, int count)
{
	bool needsSort = true;
	int swapCount = 0;
	while (needsSort)
	{
		needsSort = false;
		for (int i=count-1;i>=1;i--)
		{
			if (arr[i-1] > arr[i])
			{
				t8s_swap(&arr[i-1], &arr[i]);
				swapCount++;
				needsSort = true;
			}
		}
	}

	return swapCount;
}

void log(int* arr, int count)
{
	for (int i=0; i<count;i++)
	{
		printf("%d", arr[i]);
		if (i < count-1 )
			printf(" ");
	}
	printf("\n");
}

int main()
{
	size_t count = t8s_force_scan_int();

	int* arr;

	if (t8s_force_read_int_array(count, &arr) < 0)
		exit(-1);

	int swapCount = sort(arr, count);
	log(arr, count);
	printf("%d\n", swapCount);
	free(arr);

	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector <int> vec_a(n);
  
  for(int i= 0; i < n; i++){
    cin >> vec_a.at(i);
  }
  sort(vec_a.begin(), vec_a.end());
  reverse(vec_a.begin(), vec_a.end());
  
  int alice = 0, bob = 0;
  for(int i= 0; i < n; i++){
    if(i%2 == 0){
      alice += vec_a.at(i);
    }
    else{
      bob += vec_a.at(i);
    }
  }
  cout << alice - bob << endl;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp
const long double PI = (acos(-1));

int main() {
    std::cout << std::fixed << std::setprecision(15);
    double a, b, x;
    cin >> a >> b >> x;
    double theta;
    //theta = atan(x / a / b / b);

    if(a * a * b / 2 == x){
        cout << 45 << endl;
        return 0;
    }

    if(x < (a * a * b / 2)){
        theta = atan(2 * x / a / b / b);
        theta = theta * 180 / PI;
        cout << 90 - theta << "\n";
    }else{
        theta = atan((2 * b - (x / a * 2 / a )) / a);
        theta = theta * 180 / PI;
        cout << theta << "\n";
    }


}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
    int y,m,d;
    char a,b;
    cin >> y >> a >> m >> b >> d;

    if(m > 4 || y > 2019){
        cout << "TBD" << endl;
    }else{
        cout << "Heisei" << endl;
    }
}

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 REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)
//#define INF 1e9
constexpr ll INF = 1LL << 62;
constexpr int mod = 1e9+7;

int main(){
  int X, Y, Z;
  cin >> X >> Y >> Z;
  swap(X, Y);
  swap(X, Z);
  cout << X << " " << Y << " " << Z << endl; 
  return 0;
}


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

vector<bool> seen(50,false);

void dfs(Graph G,int v){
  seen[v]=true;
  for (auto nv : G[v]){
    if (seen[nv]){
      continue;
    }
    dfs(G,nv);
  }
}

int main(){
  int N,M;
  cin >> N >> M;
  Graph G(N);
  vector<pair<int,int>> rec(M);
  for (int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    rec[i]=make_pair(a-1,b-1);
  }
  int ans=0;
  for (int i=0;i<M;i++){
    Graph G(N);
    for (int j=0;j<M;j++){
      if (j!=i){
        G[rec[j].first].push_back(rec[j].second);
        G[rec[j].second].push_back(rec[j].first);
      }
    }
    dfs(G,0);
    for (int j=0;j<N;j++){
      if (!seen[j]){
        ans++;
        break;
      }
    }
    for (int j=0;j<N;j++){
      seen[j]=false;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <string.h>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>

#define DEBUG 0;
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
#ifdef DEBUG
//    std::ifstream in("resource/input.txt");
//    std::cin.rdbuf(in.rdbuf());
#endif

  int n,m;
  cin >> n >> m;

  vector <ll> a(n);
  REP(i,n)
  {
	  cin >>a[i];
  }

  vector <pair<ll,ll>> kae(m);
  REP(i,m)
  {
	  cin >> kae[i].second >> kae[i].first;
  }

  sort(a.begin(),a.end());
  sort(kae.begin(),kae.end(),greater<pair<ll,ll>>());

  ll cur = 0;
  ll cnt = 0;
  bool owa = false;

  REP(i,m)
  {
	  ll zan = kae[i].second;
	  cnt += zan;
	  for(int j = cur; j < n; ++j)
	  {
		if(zan <= 0)break;
		cur = j;
		if(a[j] < kae[i].first)
		{
			a[j] = kae[i].first;
			--zan;
		}
		else
		{
			if(j == n-1)
			{
				owa = true;
				break;
			}
		}
	  }
	  if(cnt >= n || owa)break;
  }

  ll res = 0;

  REP(i,n)
  {
	  res += a[i];
  }

  cout << res << endl;
	
  return 0;
}



Measured memory_bytes: 2560
// https://atcoder.jp/contests/abc138/tasks/abc138_d

#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

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

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

    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    // resizeすると0埋めされる
    ans.resize(n);

    rep(i, q) {
        int p, x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }

    dfs(0);

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

    return 0;
}


Measured memory_bytes: 23424