akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

vector<ll> v;
vector<ll> w;

void dfs(int i, int end, ll vTemp, ll wTemp, vector<P> &x)
{
    if (i == end)
    {
        x.push_back(make_pair(wTemp, vTemp)); //wでソートしたい
        return;
    }
    dfs(i + 1, end, vTemp, wTemp, x);
    dfs(i + 1, end, vTemp + v[i], wTemp + w[i], x);
}

int main(void)
{
    int n;
    ll w_max;
    cin >> n >> w_max;

    v.resize(n);
    w.resize(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i] >> w[i];
    }

    vector<P> a;
    vector<P> b;
    dfs(0, n / 2, 0, 0, a);
    dfs(n / 2, n, 0, 0, b);
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    ll temp_v = -1;
    for (auto ib = b.begin(); ib < b.end(); ++ib)
    {
        if(ib->second <= temp_v){
            auto ib_erase = ib;
            ib->second = temp_v;
        }else{
            temp_v = ib->second;  
        }  
    }

     long long score = 0;
    for (auto ia = a.begin(); ia < a.end(); ++ia)
    {
        if(w_max < ia->first) break;
        auto ib = upper_bound(b.begin(), b.end(), P(w_max - ia->first, 0), [](const P l, const P r){return l.first < r.first;}) - 1;
        score = max(score, ia->second + ib->second);
    }

    cout << score << endl;
    return 0;
}



Measured memory_bytes: 43740
#include <bits/stdc++.h>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (signed)(a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define MOD 1000000007
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
#define tp(a, b, c) make_tuple(a, b, c)
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
#define bitcnt(a) (ll) __builtin_popcount((a))
using namespace std;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
//------------------変数-----------------------//
//-------------------関数----------------------//

int main() {
  ll a, b;
  cin >> a >> b;
  REP(i, a) {
    char c;
    cin >> c;
    if (c - '0' >= 0 && c - '0' <= 9) {

    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  char cc;
  cin >> cc;
  if (cc != '-') {
    cout << "No" << endl;
    return 0;
  }
  REP(i, b) {
    char c;
    cin >> c;
    if (c - '0' >= 0 && c - '0' <= 9) {

    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

typedef long long ll;
template <typename T> T gcd(T a, T b) {
	if (b == 0) return abs(a);
	T r; while ((r = a % b) != 0) a = b, b = r;
	return abs(b);
}

#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define D(a) cout<<#a<<":"<<a<<endl;

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

    ll A, B; cin >> A >> B;
    
    ll d = gcd(A, B);
    ll ans = 1;
    ll stop = sqrt(d);
    for (ll i = 2; i <= stop && d > 1; i++) {
        if (d % i == 0) {
            ans++;
            while (d % i == 0) d /= i;
        }
    }
    if (d > 1) ans++;
    
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int a = 0;
		int b = 0;
		
		for (int i = 1; i <= n; i++) {
			if (i % 2 == 0) {
				a++;
			} else {
				b++;
			}
		}
		
		System.out.println(a * b);
	}
}

Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  int n;
  cin >> n;
  int s;
  for (int i = 0; i < 26; i++){
    for (int j = 0; j < 15; j++){
      s = 4 * i + 7 * j;
      if (s == n){
        cout << "Yes" << endl;
        return 0;
      }
      else {
        continue;
      }
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int n;
    cin>>n;
    auto d=make_vec<int>(n,n);
    rep(i,n) rep(j,n) cin>>d[i][j];
    
    ll ans=0;
    rep(i,n) {
        rep(j,n) {
            if(i==j) continue;
            
            bool add=true;
            rep(k,n) {
                if(i==k || j==k) continue;
                if(d[i][j]>d[i][k]+d[k][j]) {
                    cout<<-1<<endl;
                    return 0;
                }
                
                if(d[i][j]==d[i][k]+d[k][j]) {
                    add=false;
                }
            }
            if(add) ans+=(ll)d[i][j];
            
        }
    }
    
    cout<<ans/2<<endl;
    
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int a[100000];
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", a + i);
    }
    llong ans = 0;
    for (int i = 0; i < n; ++i) {
        int m = a[i] / 2;
        ans += m;
        a[i] -= (m << 1);
        
        if (i + 1 < n) {
            m = min(a[i], a[i + 1]);
            ans += m;
            a[i] -= m;
            a[i + 1] -= m;
        }
    }
    printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 640
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    r, g, b, n = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    for i in range(n+1):
        for j in range(n+1):
            if r * i + g * j > n:
                break
            else:
                if (n - r * i - g * j) % b == 0:
                    cnt += 1
    print(cnt)


if __name__ == '__main__':
    solve()


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

#define int long long

int n, m;

signed main() {
	cin >> n >> m;
	int ans = (n * 2 <= m) ? (n + (m - n * 2) / 4) : (m / 2);
	cout << ans << endl; 
	return 'k', 'o', 'a', 'l', 'a', ~~(0-0);
}                                                                                                                                                                                

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;cin>>s;
    int k;cin>>k;
    int idx = 0;
    while(idx<s.size()&&s[idx]=='1')idx++;
    if(k>idx)cout<<s[idx]<<endl;
    else cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

long long mo=1e9+7;

long long doing(long long num1,long long num2)
{
	long long keep=1;
	num1=num1%mo;
	while (num2)
	{
		if (num2&1)
		{
			keep=keep*num1%mo;
			num2--;
		}
		num2=num2/2;
		num1=num1*num1%mo;
	}
	return keep;
}

long long quick(long long num1,long long num2)
{
	if (num2>num1) return 0;
	long long keep=1;
	int i;
	for (i=1;i<=num2;i++)
	{
		long long x=(num1+i-num2)%mo;
		long long y=i%mo;
		keep=keep*(x*doing(y,mo-2)%mo)%mo;
	}
	return keep;
}

long long lucas(long long num1,long long num2)
{
	if (num2==0) return 1;
	else return quick(num1%mo,num2%mo)*lucas(num1/mo,num2/mo)%mo;
}


int main()
{
	long long n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	long long answer;
	answer=doing(2,n)-1-lucas(n,a)-lucas(n,b);
	while (answer<0) answer=answer+mo;
	printf("%lld",answer);
	return 0;
}



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

int main() {
  int r, D, x;
  cin >> r >> D >> x;
  vector<int> ans(11);
  ans[0] = x;
  rep(i, 10) {
    ans[i+1] = r * ans[i] - D;
  }
  rep(i, 10) {
    cout << ans[i+1] << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	string s;
	cin >> s;
	string t = s;
    reverse(s.begin(), s.end());
	bool fast = false;
	if (s == t) {
		fast = true;
	}
	string u = t;
	string kk = t.substr(0, (s.size() - 1) / 2);
	string kp = kk;
	reverse(kk.begin(), kk.end());
	bool second = false;
	if (kp == kk) {
		second = true;
	}
	string v = u;
	string lp = u.substr((s.size() + 1) / 2, (s.size() - 1) / 2);
	string lk = lp;
	reverse(lp.begin(), lp.end());
	bool thrid = false;
	if (lp == lk) {
		thrid = true;
	}
	if (fast&&second&&thrid) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N;
	while(cin>>N){
		int *num=new int[N];
		for(int i=0;i<N;i++){
			cin>>num[i];
		}
		int sum=0;//得数
		int f=0;
		int f1=0,f2=0,f3=0,f4=0,f5=0,f6=0,f7=0,f8=0;
		for(int i=0;i<N;i++){
			if(num[i]>=1&&num[i]<=399&&f1==0){
				sum++;
				f1=1;
			}else if(num[i]>=400&&num[i]<=799&&f2==0){
				sum++;
				f2=1;
			}else if(num[i]>=800&&num[i]<=1199&&f3==0){
				sum++;
				f3=1;
			}else if(num[i]>=1200&&num[i]<=1599&&f4==0){
				sum++;
				f4=1;
			}else if(num[i]>=1600&&num[i]<=1999&&f5==0){
				sum++;
				f5=1;
			}else if(num[i]>=2000&&num[i]<=2399&&f6==0){
				sum++;
				f6=1;
			}else if(num[i]>=2400&&num[i]<=2799&&f7==0){
				sum++;
				f7=1;
			}else if(num[i]>=2800&&num[i]<=3199&&f8==0){
				sum++;
				f8=1;
			}else if(num[i]>=3200){
				f++;
			}
		} 
		if(sum==0){
			cout<<"1"<<" "<<f<<endl;
		} else{
			cout<<sum<<" "<<sum+f<<endl;
		}
		
	}
	return 0;
}


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

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

    int tower = 1000;
    vector<int> A(tower, 0);
    for (int i = 1; i < tower; i++) {
        A[i+1] += A[i] + i;
        if (A[i+1] - A[i] == b - a) {
            cout << A[i] - a << endl;
            return 0;
        }   
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int count=0;
void bubblesort(int a[], int n)
{
  int i,flag=0;
  
  while(flag<n-1){
    int last=n-1;//これ分からん
    for(i=n-1; i>flag; i--){//右端から大きいのと交換して一回目で左端を最小にする
      if(a[i-1]>a[i]){
	count++;
	int tmp=a[i-1];
	a[i-1]=a[i];
	a[i]=tmp;
	last=i;
      }
    }
    /* for(i=0; i<n; i++)
      printf("%d ",a[i]);
      putchar('\n');*/
    flag=last;//結局1,2,3,,,,とやってるだけ
  }
}
int main()
{
  int i,n;
  scanf("%d",&n);
  int a[n];
  for(i=0; i<n; i++)
    scanf("%d",&a[i]);

  bubblesort(a,n);
  for(i=0; i<n; i++)
    if(i==n-1)
      printf("%d",a[i]);
    else
      printf("%d ",a[i]);
  putchar('\n');
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>

int main(){
	std::string s; std::cin >> s;
	std::fill(s.begin(), s.end(), 'x');
	std::cout << s << '\n';
}


Measured memory_bytes: 760
import bisect
N = int(input())
A = list(map(int, input().split()))
A.sort()
B = list(map(int, input().split()))
C = list(map(int, input().split()))
C.sort()

ans = 0
for i in range(N):
    cnta = bisect.bisect_left(A, B[i])
    cntc = bisect.bisect_right(C, B[i])
    ans += cnta * (N - cntc)

print(ans)


Measured memory_bytes: 23360
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	int ans = (n+2-1)/2;
	cout << ans << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;

const int INF = 1 << 29;
typedef long long LL;
typedef pair<int, int> P;

int n, r, l;
LL times[100010];
LL scores[100010];

priority_queue<P> que;

P getNewest()
{
	P p;
	do
	{
		p = que.top(); que.pop();
	} while (scores[-p.second] != p.first);
	que.push(p);
	return p;
}

int main(void)
{
	while(cin >> n >> r >> l && n)
	{
		memset(times, 0, sizeof(times));
		memset(scores, 0, sizeof(scores));
		que = priority_queue<P>();
		que.push(P(0, -1));
		int pret = 0;
		P ans = P(-INF, -INF);

		for (int i = 0; i < r; i++)
		{
			int d, t, x;
			cin >> d >> t >> x;

			P p = getNewest();
			times[-p.second] += t - pret;
			ans = max(ans, P(times[-p.second], p.second));
			pret = t;

			scores[d] += x;
			que.push(P(scores[d], -d));
		}
		P p = getNewest();
		times[-p.second] += l - pret;
		ans = max(ans, P(times[-p.second], p.second));
		cout << -ans.second << endl;
	}
	return 0;
}

Measured memory_bytes: 12716
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<pd> vpd; 

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MX  = 2e5+5; 
const int MOD = 1e9+7; // 998244353;
const ll  INF = 1e18; 
const ld  PI  = acos((ld)-1);

const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 

template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; 
}
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; 
} 

constexpr int pct(int x) { return __builtin_popcount(x); } // number of ones 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
template<class T> T cdiv(T a, T b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 

int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}

template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); 
}

// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); 
}
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

// FILE I/O
void setIn(str S) { freopen(S.c_str(),"r",stdin); }
void setOut(str S) { freopen(S.c_str(),"w",stdout); }
void setIO(str S = "") {
	ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(S)) { setIn(S+".in"), setOut(S+".out"); } // for USACO
}

map<int,bool> m;

int32_t main() { 
	
	setIO();

    int K; cin >> K;

    int num = 0, i = 1;
    while(true) {
        num = (num*10+7)%K;

        if (m[num]) {
            cout << "-1\n";
            exit(0);
        }

        if (num == 0) {
            cout << i << "\n";
            exit(0);
        }

        i++; m[num] = 1;
    }

}	

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

using namespace std;

#define SpeedForce ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"
#define loop(i,a,b) for(int i = a; i < b; i++)

const int N = 1e5+5;
int a[N];

int32_t main()
{
	SpeedForce;
	double t,x;
	cin >> t >> x;
	cout.precision(20);
	cout << t/x;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define EM 1000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
LL mod = 1e9+7;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0;i < 3;i++)    if(s[i] == t[i])    ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void sft(vector<long int>& x){
  int sz = x.size();
  for(int i = 0;i < sz;i++){
    x.push_back(x[i]*10+3);
    x.push_back(x[i]*10+5);
    x.push_back(x[i]*10+7);
  }
  sort(x.begin(),x.end());
  x.erase(unique(x.begin(), x.end()), x.end());
}  

int main(){
  long int n;
  cin >> n;
  vector<long int> x = {0};
  for(int i = 0;i < 10;i++){
    sft(x);
  }
  int answer = 0;
  for(int i = 0;;i++){
    int I = x[i];
    if(I > n) break;
	bool three, five, seven;
    three = false;
    five = false;
    seven = false;
    while(I != 0){
      if(I % 10 == 3){
        three = true;
      }else if(I % 10 == 5){
        five = true;
      }else if(I % 10 == 7){
        seven = true;
      }
      I /= 10;
    }
    if(three == true && five == true && seven == true){
      answer++;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 1400
from collections import deque
N = int(input())
E = {}
for i in range(N):
  E[i] = []
  
for i in range(N-1):
  a,b = list(map(int, input().split()))
  a,b = a-1, b-1
  E[a].append(b)
  E[b].append(a)

# DFS for tree

def dfs(startp, depth):
  visited = [False for i in range(N)]
  d = deque()
  d.append(startp)

  while len(d) > 0:
    p = d.pop()
    visited[p] = True
    for q in E[p]:
      if visited[q]:
        continue
      d.append(q)
      depth[q] = depth[p] + 1

distf = [0 for i in range(N)]
dists = [0 for i in range(N)]

dfs(0, distf)
dfs(N-1, dists)

#print(distf)
#print(dists)
cntf, cnts = 0,0
for i in range(N):
  if distf[i] <= dists[i]:
    cntf += 1
  else:
    cnts += 1
    
print("Fennec" if cntf > cnts else "Snuke")

Measured memory_bytes: 72292
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-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;
}


struct Edge{
    int to;
};
ll mod;
template<class T>
class Rerooting{
    int n;
    T def;
    function<T(T,T)> merge;
    function<T(T)> addroot;
    vector<vector<Edge>> g;
    vector<vector<T>> dp;
    public:
    vector<T> ans;
    Rerooting(int _n,T _def,function<T(T,T)> _merge,function<T(T)> _addroot)
    :n(_n),def(_def),merge(_merge),addroot(_addroot)
    {
        g=vector<vector<Edge>>(n);
        dp=vector<vector<T>>(n);
        ans=vector<T>(n,def);
    }
    void add_edge(int a,Edge e){
        g[a].pb(e);
    }

    T dfs(int v,int par=-1){
        T ret=def;
        dp[v].resize(g[v].size());
        rep(i,g[v].size()){
            if(g[v][i].to==par){
              continue;
            }
            dp[v][i]=dfs(g[v][i].to,v);
            ret=merge(ret,dp[v][i])%mod;
        }
        return addroot(ret);
    }

    void bfs(int v,T val,int par=-1){
        int deg=g[v].size();
        rep(i,deg){
            if(g[v][i].to==par)dp[v][i]=val;
        }
        vector<T> dpl(deg+1,def),dpr(deg+1,def);
        rep(i,deg)dpl[i+1]=merge(dpl[i],dp[v][i])%mod;
        per(i,deg)dpr[i]=merge(dpr[i+1],dp[v][i])%mod;
        ans[v]=dpl[deg];
        rep(i,deg){
            int nv=g[v][i].to;
            if(nv==par)continue;
            bfs(nv,addroot(dpl[i]*dpr[i+1]%mod),v);
        }
    }
};


int main(){
  ll n;cin >> n >>mod;
  Rerooting<ll> rt(n,1,[](ll a,ll b){return a*(b+1);},[](ll a){return a;});
  rep(i,n-1){
    ll a,b;cin >> a >> b;a--;b--;
    Edge e;e.to=b;rt.add_edge(a,e);
    e.to=a;rt.add_edge(b,e);
  }
  rt.dfs(0);
  rt.bfs(0,1);
  rep(i,n)cout << rt.ans[i] <<endl;
}

Measured memory_bytes: 30876
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int d[55];

int main(void){
	int n,i,ans=0,j;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> d[i];
		for(j=0; j<i; ++j){
			ans += d[i]*d[j];
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;

namespace ConsoleApp2
{
    class Program {
        static void Main(string[] Args) {
            long N = long.Parse(ReadLine());
            long sN = (long)Math.Sqrt(N);

            List<int> res = new List<int>();

            for(long A = 1;A <= sN; A++) {
                if(N % A == 0) {
                    long B = N / A;
                    res.Add(Math.Max(A.ToString().Length, B.ToString().Length));
                }
            }

            WriteLine(res.Min());

            ReadLine();
        }
    }
}


Measured memory_bytes: 13268
import java.io.*;
import java.util.*;
//import java.util.Map.Entry;
//import java.util.stream.*;
//import java.math.*;

public class Main {

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        long MOD = (long) (Math.pow(10, 9) + 7);
        int n = sc.nextInt();
        int array[] = new int[n];
        forl_0(n, array, sc);
        for (int i = n - 1; i >= 0; i -= 2) {
            System.out.printf("%d ", array[i]);
        }
        for (int i = n % 2; i <= n - 1; i += 2) {
            System.out.printf("%d ", array[i]);
        }
        bw.write("\n");
        bw.flush();
    }
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//

    static class Pair implements Comparable<Pair> {

        int a, b;

        public Pair(int x, int y) {
            a = x;
            b = y;
        }

        @Override
        public int compareTo(Pair p) {
            return a - p.a;
        }
    }

    static void forl_0(int n, int[] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void forl_1(int n, int[] array, Scanner sc) {
        for (int i = 1; i <= n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void two_d(int n, int m, int[][] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                array[i][j] = sc.nextInt();
            }
        }
    }

    static boolean isPrime(long n) {
        if (n < 2) {
            return false;
        } else if (n == 2 || n == 3) {
            return true;
        } else if (n % 2 == 0 || n % 3 == 0) {
            return false;
        }
        long sqrtN = (long) Math.sqrt(n) + 1;
        for (long i = 6L; i <= sqrtN; i += 6) {
            if (n % (i - 1) == 0 || n % (i + 1) == 0) {
                return false;
            }
        }
        return true;
    }

    public static long gcd(long a, long b) {
        return (b == 0) ? a : gcd(b, a % b);
    }

    public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }
}


Measured memory_bytes: 60196
n, m = map(int, input().split())

safe_out = [True] * (n + 1)
for i in range(m):
    a = int(input())
    safe_out[a] = False
    
way_cnt = [0] * (n + 1)
way_cnt[0] = 1
way_cnt[1] = 1

for i in range(2, n + 1):
    if safe_out[i - 1]:
        way_cnt[i] += way_cnt[i - 1]
    
    if safe_out[i - 2]:
        way_cnt[i] += way_cnt[i - 2]
        
    way_cnt[i] %= (10**9 + 7)

print(way_cnt[n])

Measured memory_bytes: 7768
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;


int main(){
    
    int n; cin>>n;
    string s; cin>>s;
    int cnt=0;
    int ans=0;
    REP(i,s.size()){
        if(s[i]=='I')cnt++;
        else cnt--;
        ans=max(ans,cnt);
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
using namespace  std;
char stone[200005];
vector<int> posr;
int main(){
    ios::sync_with_stdio(0);
    int n;cin>>n;
    int cntw = 0,cntr = 0;
    int lastr;
    rep(i,1,n){
        cin>>stone[i];
        if(stone[i] == 'W'){
            cntw++;
        }else{
            cntr++;posr.push_back(i);
        }
    }
    if(!cntw||!cntr){
        cout<<0;return 0;
    }
    int step=0;
    rep(i,1,n){

        if(stone[i] == 'W'){
            int flag =  0;
            if(*posr.rbegin()>i){
                stone[i] ='R';stone[posr[posr.size()-1]] = 'W';
                posr.pop_back();++step;
            }else{
                cout<<step;return 0;
            }
        }
    }
}


Measured memory_bytes: 4536
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N = int(input())
    l = [list(map(int, input().split())) for _ in range(N)]
    dp = [[0]*3 for _ in range(N+1)]
    dp[1] = l[0]
    
    for i in range(1, N):
        for j in range(3):
            a = (j+1)%3
            b = (j+2)%3
            dp[i+1][j] = max(dp[i][a], dp[i][b]) + l[i][j]
    print(max(dp[N]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 47620
#include<bits/stdc++.h>
using namespace std;
int n,b=0,r=0;
char s[110];
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	for (int i=1;i<=n;i++) 
		if (s[i]=='R') r++;
		else b++;
	if (r>b) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int a = 1 << 30, b = 0, c = 1 << 30;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		a = min(x, a);
		b = max(x, b);
		c = min(y, c);
	}
	cout << (b - a + 1) + a - 1 + c << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define fout(x) cout << fixed << setprecision(10) << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  vector<int> ans(n, 0);
  rep(i, n) rep(j, i) {
    int d = min(abs(i - j), min(abs(x - j) + 1 + abs(y - i), abs(x - i) + 1 + abs(y - j)));
    ans[d]++;
  }
  FOR(i, 1, n) {
    out(ans[i]);
  }
  return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())

s=[0]*n

for i in range(k):
  d=int(input())
  a=list(map(int,input().split()))
  for j in range(d):
    s[a[j]-1]+=1
#print(s)
cnt=0
for i in range(n):
  if s[i]==0:
    cnt+=1
print(cnt)

Measured memory_bytes: 67812
import java.io.*;
        import java.math.BigDecimal;
        import java.math.BigInteger;
        import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    static final int MOD = 1_000_000_007;

    public static void main(String[] args) {
        long N = in.nextInt();
        long K = in.nextInt();
        long ans = 0;
        for (long k = K; k <= N + 1; k++)
            ans = (ans + (N + 1 - k) * k + 1) % MOD;
        out.println(ans);
        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}

Measured memory_bytes: 32740
program q_e
        implicit none

        INTEGER(8) :: N, K
        INTEGER(8) :: Asum
        INTEGER(8) :: i, j
        INTEGER(8) :: x, mid
        INTEGER(8) :: left = -1_8, right = 10_8**13
        INTEGER(8), ALLOCATABLE, DIMENSION(:) :: A, F, FR, C

        READ(*,*) N, K
        
        ALLOCATE(A(N))
        ALLOCATE(F(N))
        ALLOCATE(FR(N))
        ALLOCATE(C(N))
        READ(*,*) A(1:N)
        READ(*,*) F(1:N)

        call heapsort(N, A)
        call heapsort(N, F)
        do i = 1, N
          FR(i) = F(N-i+1)
        end do
        
        Asum = SUM(A)

        do while (left+1 < right)
          mid = (left+right)/int(2, kind=8)
          do j = 1, N
            C(j) = MIN(A(j), mid/FR(j))
            ! C(j) = MIN(A(j)*FR(j), mid)
          end do
          if (Asum - SUM(C).le.K) then
            right = mid
          else
            left = mid
          end if
        end do
        
        write(*,*) right

      contains
            
      ! http://slpr.sakura.ne.jp/qp/sortf90/
        subroutine heapsort(n, array)
          implicit none
          integer(8), intent(in) :: n
          ! double precision, intent(inout) :: array(1:n)
          integer(8), intent(inout) :: array(1:n)

          integer(8) :: i, j, k, l
          double precision :: t

          if (n.le.0) then
            stop
          end if
          if (n.eq.1) return

          l = n/2 + 1
          k = n
          do while (k.ne.1)
            if (l.gt.1) then
              l = l - 1
              t = array(L)
            else
              t = array(k)
              array(k) = array(1)
              k = k - 1
              if (k.eq.1) then
                array(1) = t
                exit
              end if
            end if
            i = l
            j = l + l
            do while(j.le.k)
              if (j.lt.k) then
                if ( array(j).lt.array(j+1)) j = j + 1
              end if
              if (t.le.array(j)) then
                array(i) = array(j)
                i = j
                j = j + j
              else
                j = k + 1
              end if
            end do
            array(i) = t
          end do

          return
        end subroutine
      end program 


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

int n;
vector<int> h, m;
int ans;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	h.resize(n); m.resize(n);
	for(auto &i:h) cin >> i;
	m[0] = h[0];
	for(int i=1; i<n; ++i) m[i] = max(m[i-1], h[i]);
	for(int i=0; i<n; ++i)
		if(m[i] == h[i])
			++ans;
	cout << ans << "\n";
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, l) = readLine()!!.split(" ").map { it.toInt() }

    val apples = (1..n).map {
        l + it -1
    }

    val sum = apples.sum()

    val min = apples.minBy { Math.abs(it) }!!

    println(sum - min)

}


Measured memory_bytes: 38000
//
// Created on 2020/06/08.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


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

    int ans = min(b/a,c);
    cout<<ans<<endl;

    return 0;
}


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

struct RollingHash {
	static const int base1 = 1007, base2 = 2009;
	static const int mod1 = 1000000007, mod2 = 1000000009;
	vector<ll> hash1, hash2, power1, power2;

	RollingHash(const string &S) {
		int n = (int)S.size();
		hash1.assign(n+1, 0);
		hash2.assign(n+1, 0);
		power1.assign(n+1, 1);
		power2.assign(n+1, 1);
		for(int i=0;i<n;i++) {
			hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
			hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
			power1[i+1] = (power1[i] * base1) % mod1;
			power2[i+1] = (power2[i] * base2) % mod2;
		}
	}

	// get hash of S[left: right) (0から見る)
	inline pair<ll,ll> get(int l, int r) const {
		ll res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
		if(res1 < 0) res1 += mod1;
		ll res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
		if(res2 < 0) res2 += mod2;
		return {res1, res2};
	}

	// S[a:]とS[b:]のLCP(最長共通接頭辞)を求める
	inline int getLCP(int a, int b) const {
		int len = min((int)hash1.size() - a ,(int)hash1.size() - b);
		int low = 0, high = len;
		while(high - low > 1) {
			int mid = (high + low) >> 1;
			if(get(a, a + mid) == get(b, b + mid)) low = mid;
			else high = mid;
		}
		return low;
	}
};

signed main() {
	int N; string S;
	cin >> N >> S;
	RollingHash rh(S);
	int ans = 0;
	for(int i=0;i<N;i++) {
		for(int j=i+1;j<N;j++) {
			int lcp = rh.getLCP(i, j);
			lcp = min(lcp, j - i);
			ans = max(ans, lcp);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

// author:Swastik Banerjee

using namespace std;

typedef long long ll;
#define MOD 1000000007

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



  ll arr[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};

  ll K;
  cin >> K;

  cout << arr[K - 1];
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int s,i,j;
    scanf("%d",&s);
      j=s/100;
      i=s%100 ;
        if(i<=12 && j<=12 && i>=1 && j>=1) {
            printf("AMBIGUOUS\n");
        }
        else if(i<=12 &&  i > 0) {
            printf("YYMM\n");
        }
        else if(j>0 && j<=12) {
            printf("MMYY\n");
        }
        else { printf("NA\n"); }
return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  while (true) {
    string s;
    getline(cin, s);
    if (s == ".") return;
    stack<char> st;
    int n = s.size();
    bool f = true;
    rep(i, n) {
      if (s[i] == '(') st.push('(');
      if (s[i] == '[') st.push('[');
      if (s[i] == ')') {
        if (st.size() == 0 || st.top() != '(') { f = false; break; }
        st.pop();
      }
      if (s[i] == ']') {
        if (st.size() == 0 || st.top() != '[') { f = false; break; }
        st.pop();
      }
    }
    if (!f || st.size() > 0) {
      cout << "no" << '\n';
    } else {
      cout << "yes" << '\n';
    }
  }
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=100005;
int a[N];
int n;
int main()
{
    // scanf("%d",&n);
    string s;
    cin>>s;
    for(int i=0;i<s.length()-1;i++)
	{
		if(s[i]==s[i+1])
		{
			cout<<"Bad"<<endl;
			return 0;
		}
	}
	cout<<"Good"<<endl;
	return 0;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for(int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if(k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  ll r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  combination c(2e6 + 10);
  mint ans = c(r2 + c2 + 2, r2 + 1) - c(r2 + c1 + 1, c1) - c(r1 + c2 + 1, r1) +
             c(r1 + c1, r1);
  cout << ans << endl;
}

Measured memory_bytes: 34396
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,tot,a[3010],head[3010],to[6010],nxt[6010];
void add_edge(int u,int v){
	nxt[++tot]=head[u];
	to[tot]=v;
	head[u]=tot;
	return;
}
bool dfs(int u,int father){
	for(int i=head[u];~i;i=nxt[i]){
		int v=to[i];
		if(v!=father)
			if(a[v]<a[u]&&!dfs(v,u))
				return 1;
	}
	return 0;
}
int main(){
	memset(head,-1,sizeof(head));
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",a+i);
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		add_edge(u,v);
		add_edge(v,u);
	}
	for(int i=1;i<=n;i++)
		if(dfs(i,0))
			printf("%d ",i);
	return 0;
}

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

int price[15];

int main() {
//    freopen("./input.txt", "r", stdin);
    int N;
    scanf("%d", &N);
    for (int i = 0;i < N; i++){
        scanf("%d", &price[i]);
    }
    sort(price, price+N);
    int sum = 0;
    for(int i = 0; i<N-1; i++){
        sum += price[i];
    }
    
    printf("%d\n", price[N-1]/2 +sum);
    
    return 0;
}



Measured memory_bytes: 256