akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    string A,B,C;
    cin >> N >> A >> B >> C;
    ll ans = 0;
    rep(i,0,N){
        if(A[i] == B[i] && B[i] == C[i]){
        }else if(A[i] == B[i] && B[i] != C[i]){
            ans++;
        }else if(B[i] == C[i] && A[i] != B[i]){
            ans++;
        }else if(A[i] == C[i] && A[i] != B[i]){
            ans++;
        }else{
            ans += 2;
        }
    }
    print(ans);
}


Measured memory_bytes: 256
#coding: utf-8

import sys

N = int(sys.stdin.readline().rstrip())

if N % 2 != 0:
	print(0)
else:
	two = 0
	enu = N
	while enu > 0:
		enu //= 2
		two += enu
	five = 0
	enu = N // 2
	while enu > 0:
		enu //= 5
		five += enu
	answer = two
	if five < answer:
		answer = five
	print(answer)

"""
Nが奇数のとき → 素因数に2が含まれない
→ 2ずつ引いていっても素因数に2が含まれない
→ 答えは0

Nが偶数のとき → 素因数に2はいっぱい含まれる
2の倍数 → 2が1個
4の倍数 → 2がもう1個
8の倍数 → 2がさらに1個
…

5についても同様に求める
ただし、奇数はカウントしない
"""


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;

int main(){
	ll n, k;cin >> n >> k;
	vector<Pll> dt(n);
	set<ll> tst;
	rep(i,n){
		ll t,d;cin >> t >> d;
		t--;
		dt.at(i) = Pll(d,t);
		tst.insert(t);
	}
	ll tmax = tst.size();
	sort(dt.begin(), dt.end(), greater<Pll>());
	//vector<vector<ll>> dp(n, vector<ll>(k,-1));
	priority_queue<Pll, vector<Pll>, greater<Pll>> pq;
	vector<ll> num(n,0), p(n+10,0);
	ll count = 0, type = 0;
	ll sum = 0;
	rep(i,k){
		sum += dt.at(i).first;
		pq.push(dt.at(i));
		if(!num.at(dt.at(i).second))type++;
		num.at(dt.at(i).second)++;
		count++;
	}
	p.at(type) = sum + type * type;
	while(type < min(k, tmax)){
		Pll temp = pq.top();pq.pop();
		if(num.at(temp.second) == 1)continue;
		sum -= temp.first;
		while(count < n){
			if(num.at(dt.at(count).second)) count++;
			else{
				sum += dt.at(count).first;
				pq.push(dt.at(count));
				num.at(dt.at(count).second)++;
				count++;
				break;
			}
		}
		type++;
		p.at(type) = sum + type * type;
	}
	
	cout << *max_element(p.begin(), p.end()) << endl;
	return 0;
}

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

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    if(A == 5 && B == 7 && C == 5){
      cout << "YES" << endl;
    }
      else if(A == 5 && C == 7 && B == 5){
        cout << "YES" << endl;
      }
  else if (B == 5 && A == 7 && C == 5){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

int main() {
	int N; cin >> N;
	int a[51];
	int Max = -1e7;
	int Min = 1e7;
	int Maxnum;
	int Minnum;
	vector<pii>ans;
	REP(i, N) {
		cin >> a[i];
		if (Max < a[i]) {
			Maxnum = i;
			Max = a[i];
		}
		if (Min > a[i]) {
			Minnum = i;
			Min = a[i];
		}
	}
	if (abs(Max) > abs(Min)) {
		REP(i, N) {
			if (i == Maxnum)continue;
			ans.push_back({ Maxnum + 1,i + 1 });
			a[i] += Max;
		}
	}
	else {
		REP(i, N) {
			if (i == Minnum)continue;
			ans.push_back({ Minnum + 1, i + 1 });
			a[i] += Min;
		}
	}
	if (a[0] == 0) {
		cout << 0 << endl;
		return 0;
	}
	else if(a[0]<0){
		for (int i = N - 1; i > 0; --i) {
			ans.push_back({ i + 1,i });
		}
	}
	else {
		for (int i = 0; i < N - 1; ++i) {
			ans.push_back({ i + 1,i + 2 });
		}
	}
	cout << ans.size() << endl;
	REP(i, ans.size()) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> A(N);
  rep (i, N) cin >> A[i];

  long ans = 0;
  while (true) {
    rep (i, N) {
      if (A[i] % 2) {
        cout << ans << endl;
        return;
      }
      A[i] /= 2;
    }
    ans++;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int m, n, w[100];

int calc(int t){
    int sum=0, ret=1;
    for(int i=0; i<n; i++){
        if(w[i]>t) return 1500001;
        if(sum+w[i]>t){
            sum=0;
            ret++;
        }
        sum+=w[i];
    }
    return ret;
}

int main(){

    while(1){
        cin>> m>> n;
        if(m==0&&n==0) break;
        for(int i=0; i<n; i++){
            cin>> w[i];
        }

        int l=1, h=1500000;
        while(h-l>1){
            int md=(l+h)/2;
            if(calc(md)>m) l=md;
            else h=md;
        }

        cout<< h<< endl;

    }

    return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    i64 n,m;
    cin >> n >> m;
    vector<i64> a(n);
    rep(i,0,n){
        cin >> a[i];
        --a[i];
    }

    vector<queue<i64>> push(m);
    vector<i64> pop(a.size()-1);
    vector<i64> d(a.size()-1);
    rep(i,0,a.size()-1){
        if((a[i+1]-a[i]+m)%m<=1) continue;
        push[(a[i]+2)%m].push(i);
        pop[i]=(a[i+1]+1)%m;
        d[i]=(a[i+1]-a[i]+m)%m-1;
    }

    i64 ans=0,s=0;
    rep(i,0,a.size()-1){
        if(a[i]<a[i+1]) s+=a[i+1]-a[i];
        else s+=m-a[i]+a[i+1];
    }
    ans=s;

    vector<i64> k(m);
    vector<vector<i64>> erase_id(m);
    i64 c=0,cnt_id=0;
    rep(i_,0,2*m){
        i64 i=i_%m;
        while(!push[i].empty()){
            ++cnt_id;
            erase_id[pop[push[i].front()]].push_back(push[i].front());
            push[i].pop();
        }

        for(auto id:erase_id[i]){
            --cnt_id;
            c-=d[id];
        }
        erase_id[i].clear();

        c+=cnt_id;
        k[i]+=c;
        ans=min(ans,s-k[i]);
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 75264
// 2020-07-30 18:10:26
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

const int MX = 85;
int a[MX][MX], b[MX][MX], c[MX][MX];
void answer() {
  int h, w;
  cin >> h >> w;
  rep(hi, h) rep(wi, w) {
    cin >> a[hi][wi];
  }
  rep(hi, h) rep(wi, w) {
    cin >> b[hi][wi];
  }
  rep(hi, h) rep(wi, w) c[hi][wi] = a[hi][wi] - b[hi][wi];
  int lim = 80*160*2+10;
  vector<vector<int> > dp(w+1, vector<int>(lim, 0));
  dp[0][lim/2+c[0][0]] = 1;
  dp[0][lim/2-c[0][0]] = 1;
  rep(hi, h) {
    vector<vector<int> > p(w+1, vector<int>(lim, 0));
    swap(p, dp);
    rep(wi, w) {
      int xl = lim/2-80*(hi+wi+1);
      int xr = lim/2+80*(hi+wi+1);
      REPC(x, xl, xr) {
        p[wi+1][x+c[hi][wi+1]] |= p[wi][x];
        p[wi+1][x-c[hi][wi+1]] |= p[wi][x];
        dp[wi][x+c[hi+1][wi]] |= p[wi][x];
        dp[wi][x-c[hi+1][wi]] |= p[wi][x];
      }
    }
  }
  int ans = 1e9;
  rep(x, lim) if(dp[w-1][x]) {
    chmin(ans, abs(x-lim/2));
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  switch(a+b){
    case 3:
      cout<<3<<endl;
      break;
    case 4:
      cout<<2<<endl;
      break;
    case 5:
      cout<<1<<endl;
      break;
  }
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N; cin >> N;
  ll N, K; cin >> K >> N;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  
  ll ans = K - a[N - 1] + a[0];
  rep(i, N - 1) {
    chmax(ans, a[i + 1] - a[i]);
  }
  ans = K - ans;
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL A, B, C, D; cin >> A >> B >> C >> D;
	LL a = max(A, C);
	LL b = min(B, D);
	
	
	LL ans = max(0LL,b-a);
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
N=int(input())
D=[list(map(int,input().split())) for _ in range(N)]

for i in range(N-2):
    if D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1] and D[i+2][0]==D[i+2][1]:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 62460
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

int n;
void func(vector<int>& v){
  if(v.size() > n){
    return;
  }
  if(v.size() == n){
    //for(int i = 0; i < v.size(); i++) cout << v[i]; cout << endl;
    for(int i = 0; i < v.size(); i++) cout << (char)(97 + v[i]); cout << endl;
  }
  int maxv = 0;
  for(int i = 0; i < v.size(); i++) maxv = max(v[i], maxv);
  for(int i = 0; i <= maxv + 1; i++){
    v.push_back(i);
    func(v);
    v.pop_back();
  }
}

void solve(){
  cin >> n;
  vector<int> v;
  v.push_back(0);
  func(v);
}

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


Measured memory_bytes: 1536
n = input()

first_num = int(n[-1])

if first_num == 2 or first_num == 4 or first_num == 5 or first_num == 7 or first_num == 9:
    print("hon")
elif first_num == first_num == 0 or first_num == 1 or first_num == 6 or first_num == 8:
    print("pon")
else:
    print("bon")


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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: u32,
    }
    println!("{}", n.pow(3))
}



Measured memory_bytes: 4352
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
l = []
okikae = []

for i in range(m):
  b,c = map(int,input().split())
  l.append([c,b])
  
l.sort(reverse = True)

for c,b in l:
  for j in range(b):
    if len(okikae) < len(a):
      okikae.append(c)
    else:
      break
  if len(okikae) == len(a):
    break
    
    
for i in range(len(okikae)):
  if okikae[i] > a[i]:
    a[i] = okikae[i]
  else:
    break
    
print(sum(a))

Measured memory_bytes: 24880
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	v := make([]int, n)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&v[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&c[i])
	}
	rvs := 0
	rcs := 0
	r := 0
	for i := 0; i < n; i++ {
		if c[i] <= v[i] {
			rvs += v[i]
			rcs += c[i]
		}
	}
	r = rvs - rcs
	fmt.Println(r)
}

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

int main(void) {
  char s[11], t[11], u[11];
  int a, b;
  scanf("%s %s", s, t);
  scanf("%d %d", &a, &b);
  scanf("%s", u);
  strcmp(s, u) == 0 ? a-- : b--;
  printf("%d %d\n", a, b);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int d; scanf("%d", &d);
	
	if(d == 25) cout << "Christmas" << endl;
	if(d == 24) cout << "Christmas Eve" << endl;
	if(d == 23) cout << "Christmas Eve Eve" << endl;
	if(d == 22) cout << "Christmas Eve Eve Eve" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    cout<<a[a.size()-1]-a[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
using namespace std;
int app[110];

int main(){
    int x,n;
    scanf("%d%d",&x,&n);
    for(int i=1;i<=n;i++)
    {
        int b;
        scanf("%d",&b);
        app[b]=1;
    }
    int p1=x;
    while(app[p1])
        p1--;
    int d1=x-p1;
    int p2=x;
    while(app[p2])
        p2++;
    int d2=p2-x;
    if(d1<=d2)
        printf("%d\n",p1);
    else
        printf("%d\n",p2);
	return 0;
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
// https://beta.atcoder.jp/contests/arc090/tasks/arc090_c
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<ll, ll> ll_ll;
struct edge { int v, w; };
const ll INF = LLONG_MAX / 2;
const int MOD = 1e9 + 7;
const ll e18 = 1e18;

pair<vector<ll>, vector<ll>> dijkstra(int N, vector<vector<edge> >& G, int s) {
  vector<ll> d(N, INF); d[s] = 0;
  vector<ll> way(N, s); way[s] = 1;
  priority_queue<ll_i, vector<ll_i>, greater<ll_i> > pq;
  pq.push(ll_i(0, s));
  while (pq.size()) {
    ll_i p = pq.top(); pq.pop();
    int u = p.second;
    if (p.first > d[u]) continue;
    for (edge e: G[u]) {
      if (d[e.v] > d[u] + e.w) {
        d[e.v] = d[u] + e.w;
        way[e.v] = 0;
        pq.push(ll_i(d[e.v], e.v));
      }
      if (d[e.v] == d[u] + e.w)
        way[e.v] = (way[e.v] + way[u]) % MOD;
    }
  }
  return {d, way};
}

int main() {
  int N, M; cin >> N >> M;
  int s, t; cin >> s >> t, s--, t--;
  vector<vector<edge>> G(N);
  while (M--) {
    int u, v, w; scanf("%d%d%d", &u, &v, &w);
    u--, v--;
    G[u].pb({v, w}), G[v].pb({u, w});
  }
  vector<ll> ds = dijkstra(N, G, s).first;
  vector<ll> ws = dijkstra(N, G, s).second;
  vector<ll> dt = dijkstra(N, G, t).first;
  vector<ll> wt = dijkstra(N, G, t).second;
  ll D = ds[t];
  ll tot = 0;
  rep(u, N) if (ds[u] + dt[u] == D && ds[u] == dt[u]) {
    ll z = ws[u] * wt[u] % MOD;
    tot = (tot + z * z) % MOD;
  }
  rep(u, N) for (edge e: G[u]) {
    int v = e.v;
    if (ds[u] + e.w + dt[v] == D && ds[u] * 2 < D && dt[v] * 2 < D) {
      ll z = ws[u] * wt[v] % MOD;
      tot = (tot + z * z) % MOD;
    }
  }
  ll ans = (ws[t] * ws[t] - tot) % MOD;
  cout << (ans + MOD) % MOD << endl;
}


Measured memory_bytes: 15924
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	bool jadge = false, check = false;

	for (int i = (int)(s.length() - t.length()); i >= 0; --i){
		if (s[i] == t[0] || s[i] == '?'){
			for (int j = 0;j < (int)t.length(); ++j){
				if (s[i + j] != t[j] && s[i + j] != '?'){
					jadge = true;
					break;
				} // end if
			} // end for
			
			if (!jadge){
				check = true;
				for (int j = 0; j < (int)t.length(); ++j){
					s[i + j] = t[j];
				} // end for
				break;
			} // end if
			jadge = false;
		} // end if
	} // end for

	if (check == true){
		for (int i = 0; i < (int)s.length(); ++i){
			if (s[i] == '?'){
				s[i] = 'a';
			} // end if
		} // end for
		cout << s << endl;
	}else{
		cout << "UNRESTORABLE" << endl;
	} // end if

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 10000100
const int mod=998244353;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int fac[N],inv[N],n,ans,pw2[N];
inline int qpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}
	return ans;
}
void init(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i){
		fac[i]=1LL*fac[i-1]*i%mod;
	}
	inv[n]=qpow(fac[n],mod-2)%mod;
	for(int i=n-1;i>=0;--i){
		inv[i]=1LL*inv[i+1]*(i+1)%mod;
	}
}
inline int C(int n,int m){
	return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main(){
	n=read();
	init(n);
	ans=qpow(3,n);
	pw2[0]=1;
	for(int i=1;i<=n;++i){
		pw2[i]=(pw2[i-1]<<1)%mod;
	}
	for(int i=n/2+1;i<=n;++i){
		ans=(ans-2LL*C(n,i)*pw2[n-i]%mod+mod)%mod;
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 120788
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if((i%2==0&&j%2==0)||(i%2==1&&j%2==1))
	  cout << "#";
	else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}
   


Measured memory_bytes: 3084
#include <stdio.h>
#include <math.h>
 
int main(void)
{
    int n, i;
    int s[1000];
    double m, sum;
    double siguma;
     
    for(; ; ) {
        scanf("%d", &n);
        if(n==0) break;
        else {
            m=0; sum=0;
            for(i=0; i<n; i++) {
                scanf("%d", &s[i]);
                m+=s[i];
            }
            m=(double)m/n;
             
            for(i=0; i<n; i++)
                sum+=pow(s[i]-m, 2);
            sum/=n;
            siguma=sqrt(sum);
            printf("%f\n", siguma);
        }
    }
     
    return 0;
}


Measured memory_bytes: 2080
#include <iostream>
#include <vector>
#include <algorithm>
#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)

using namespace std;
using ll = long long;
int n;
const int INF = 1e9;
const int MAX_N = 1e5+1;
vector<int> graph[MAX_N];
vector<int> dis_b(MAX_N,INF) ,dis_w(MAX_N,INF);
vector<bool> check(MAX_N,false);

int dfs(int x,int to){//x 開始地点、to:目的地
    rep(i,graph[x].size()){
        int next = graph[x][i];//
        if(!check[next]){
            if(to == 0){//白い
                dis_w[next] = min(dis_w[next],dis_w[x] + 1);
            }else{//黒い
                dis_b[next] = min(dis_b[next],dis_b[x] + 1);
            }
            check[next] = true;
    
            dfs(next,to);
            check[next] = false;
        }
    }
    return 0;
}

int main(){
    cin >> n;
    //初期値
    dis_b[0] = 0;//マス1からの距離
    dis_w[n-1] = 0;//マスnからの距離
    int a,b;
    rep(i,n-1){
        cin >> a >>b;
        a--; b--; 
        graph[a].push_back(b);
        graph[b].push_back(a);
    }//グラフを作成


    check[0] = true;
    dfs(0,n-1);

    check[n-1] = true;
    dfs(n-1,0);

    //b >= wならbのかち
    int white = 0;
    int black = 0;
    rep(i,n){
        if(dis_b[i] <= dis_w[i]) black++;
        else white++;
    }

    if(black > white) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;

    return 0;
}

Measured memory_bytes: 14336
X, K, D = map(int, input().split())
tmp = abs(X) // D
if tmp >= K:
    print(abs(X) - K * D)
    exit()
X = abs(X) - tmp * D
K -= tmp
Kp = K - 1
Xp = abs(X - D)
K %= 2
Kp %= 2
if K:
    X = abs(X - D)
if Kp:
    Xp = abs(Xp - D)
print(min(X, Xp))

Measured memory_bytes: 61880
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;

int main(){
	int N;
	cin >> N;
	int cnt = 0;
	for(int i = 1; i <= N;  i++){
		string S = to_string(i);
		int n = S.size();
		if(n % 2 == 1) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String s = br.readLine();
 
		s=s.substring(0,s.lastIndexOf("FESTIVAL"));
		System.out.println(s);
 
	}
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String s = r.readLine();
		int num = Integer.valueOf(s);

		while (true) {
			boolean flag = isSosu(num);
			if (flag) {
				System.out.println(num);
				r.close();
				return;
			}
			++num;
		}
	}

	public static boolean isSosu(int value) {
		for (int i = 2; i < value; ++i) {
			if (value % i == 0) {
				return false;
			}
		}
		return true;
	}
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int h, w;
vector<string> s;
int used[20];
bool ans = false;
int cnt = 0;
bool equals(int x, int y) {
    for (int i = 0; i < h; i++) {
        if (s[i][x] != s[h-1-i][y]) return false;
    }
    return true;
}
bool check() {
    memset(used, 0, sizeof(used));
    bool f = false;
    for (int i = 0; i < w; i++) {
        if (used[i]) continue;
        bool ok = false;
        for (int j = i+1; j < w; j++) {
            if (used[j]) continue;
            if (equals(i, j)) {
                ok = true;
                used[j] = 1;
                break;
            }
        }
        if (!ok) {
            if (w % 2 == 0 || f) return false;
            f = true;
        }
    }
    return true;
}
void dfs(int cur, bool even) {
    if (cur >= (h-1) / 2) {
        //cout << "\n";
        //for (string &str : s) cout << str << "\n";
        ans |= check();
        return;
    }
    if (even) {
        swap(s[cur], s[h/2]);
        for (int j = cur + 1; j < h - cur; j++) {
            swap(s[j], s[h-1-cur]);
            dfs(cur+1, even);
            swap(s[j], s[h-1-cur]);
        }
        swap(s[cur], s[h/2]);
    }
    for (int j = cur + 1; j < h - cur; j++) {
        swap(s[j], s[h-1-cur]);
        dfs(cur+1, even);
        swap(s[j], s[h-1-cur]);
    }
}
int main() {
    cin >> h >> w;
    s.resize(h);
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }
    dfs(0, h % 2 == 1);
    if (ans) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


Measured memory_bytes: 256
s=list(input())
n=len(s)
l=[-1 for i in range(n+1)]
ct=0
ans=0
if s[0]=='<':l[0]=0
if s[n-1]=='>':l[n]=0
for i in range(n-1):
  if s[i]=='>' and s[i+1]=='<':
    l[i+1]=0
for i in range(n):
  if s[i]=='<':
    l[i+1]=l[i]+1
for i in range(n-1,-1,-1):
  if s[i]=='>':
    l[i]=l[i+1]+1

for i in range(n-1):
  if s[i]=='<' and s[i+1]=='>':
    l[i+1]=max(l[i]+1,l[i+2]+1)
print(sum(l))

Measured memory_bytes: 27452
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
vi a,b;

int main(){
	cin>>n>>m;
	a=vi(n);
	b=vi(m);
	for(auto &i:a) cin>>i;
	for(auto &i:b) cin>>i;
	vvl dp(n+1,vl(m+1));
	for(int i=0;i<n;i++) for(int j=0;j<m;j++){
		dp[i+1][j+1]=(dp[i+1][j]+dp[i][j+1]-dp[i][j]+mod)%mod;
		if(a[i]==b[j]) (dp[i+1][j+1]+=dp[i][j]+1)%=mod;
	}
	cout<<(dp[n][m]+1)%mod<<endl;
}

Measured memory_bytes: 31616
/* Author : tushar3105 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef pair<long long int,long long int> ii;					// Pair of integers
typedef vector<long long int> vi;                   				// Vector of integers
typedef vector<vector<long long int>> vvi;                 			// Vector of vi
typedef vector<pair<long long int, long long int>> vii;				// Vector of ii

#define pb push_back								// Push back to vectors
#define mp make_pair								// For pairs
#define ff first								// For pairs
#define ss second								// For pairs
#define all(c) (c).begin(),(c).end()						// Use in sorting
#define sz(a) ((long long int)(a).size())
#define lli long long int
#define ull unsigned long long int
#define ld long double
#define ref(i,x,y) for(long long int i=(x);i<=(y);++i)				// Loop to go forward
#define reb(i,x,y) for(long long int i=(x);i>=(y);--i)				// Loop to go backward
#define trf(c,it) for(auto it = (c).begin(); it != (c).end(); it++)		// Remember it is an iterator
#define trb(c,it) for(auto it = (c).end()-1; it != (c).begin()-1; it--)		// Remember it is an iterator
#define tc(t) long long int t; cin>>t;while(t--)				// Test cases
//fill (dist,dist+110000,pinf);							// For setting default

const long long int mod = 1e9+7;
const long long int pinf = 9223372036854775807;
const long long int ninf = -9223372036854775807;

/*-----------------------------Code begins----------------------------------*/

int main (void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	lli n, cnt=0, arr[110];
	
	cin>>n;
	
	ref(i,0,n-1)
		cin>>arr[i];
		
	ref(i,0,n-1)
	{
		ref(j,0,n-1)
		{
			ref(k,0,n-1)
			{
				if (arr[i]!=arr[j] && arr[j]!=arr[k] && arr[k]!=arr[i])
				{
					if (arr[i]+arr[j]>arr[k] && arr[j]+arr[k]>arr[i] && arr[k]+arr[i]>arr[j])
						cnt++;
				}
			}
		}
	}
	
	cout<<cnt/6<<endl;

	return 0;
}


Measured memory_bytes: 3652
// Bismillahirrahmanirrahim
#include<bits/stdc++.h>
using namespace std;
vector<int> vec;

int main() {
		int n;
		cin >> n;
		for(int i = 1; i < 10; i++) {
			if(n%i == 0) {
				if(n/i <= 9) {
					cout << "Yes" << endl;return 0;
				}
			}
		}
		cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#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)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
// const int N = 316330;

bool igc[55][55];
int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);

    int n,k;
    cin >> n >> k;

    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int cnt1 = k*(k+1)/2;
    int cnt2 = k*(k-1)/2;

    cnt1 %= MOD;
    cnt2 %= MOD;

    int inv1 = 0;
    rep(i,n) repA(j,i+1,n-1) {
    	if(a[i] > a[j]) inv1++;
    }
    int inv2 = 0;
    repD(i,n-1,0) repD(j,i-1,0) {
    	if(a[i] > a[j]) inv2++; 
    }
    int ans = ((inv1*cnt1)%MOD + (inv2*cnt2)%MOD)%MOD;
    cout << ans << '\n';
}

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

int a[5];

int main() {
	int x, y, n, m, a, b;
	scanf("%d%d%d%d", &n, &m, &x, &y);
	while (n--) scanf("%d", &a), x = std::max(x, a);
	while (m--) scanf("%d", &b), y = std::min(y, b);
	if (x + 1 <= y) puts("No War");
	else puts("War");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <utility>
#include <queue>

using namespace std;
typedef long long signed int ll;

constexpr int inf = INT32_MAX / 2;
constexpr int mod = 1000000007;
constexpr int maxn = 100000;

class djikstra {
private:
	ll* d = nullptr;
	map<int, map<int, ll>> p;
	int sz = 0;
public:
	void add_path(int from, int to, ll cost) {
		p[from][to] = cost;
	}
	void compute(int from,int nodes) {
		sz = nodes;
		if (d != nullptr) delete d;
		d = new ll[nodes];
		auto cmp = [this](int a, int b) {return d[a] > d[b]; };
		priority_queue <ll, vector<ll>, decltype(cmp)> q(cmp);
		for (int i = 0; i < nodes; i++) d[i] = INT64_MAX / 2;
		d[from] = 0;
		q.push(from);
		while (!q.empty()) {
			for (auto& e : p[q.top()]) {
				if (d[e.first] > d[q.top()] + e.second) {
					d[e.first] = d[q.top()] + e.second;
					q.push(e.first);
				}
			}
			q.pop();
		}
	}
	ll operator[](int node) {
		if (node >= sz) return INT64_MAX/2;
		return d[node];
	}
};

int h, w, a[500][500];

pair<int, int> next_pos(pair<int, int> p) {
	if (p.first % 2) {
		if (p.second == 0) return make_pair(p.first + 1, p.second);
		else return make_pair(p.first, p.second - 1);
	}
	else {
		if (p.second == w - 1) return make_pair(p.first + 1, p.second);
		else return make_pair(p.first, p.second + 1);
	}
}

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++)for (int j = 0; j < w; j++)cin >> a[i][j];
	pair<int, int> hold = make_pair(-1, 0);
	vector <pair<int, int>> r;
	for (pair<int, int> p = make_pair(0, 0); next_pos(p).first < h && next_pos(p).second < w; p = next_pos(p)) {
		if (a[p.first][p.second] % 2) {
			if (hold.first == -1) {
				hold = p;
			}
			else {
				hold.first = -1;
			}
		}
		if (hold.first != -1) r.push_back(p);
	}
	cout << r.size() << endl;
	for(auto& e:r) cout << e.first + 1 << " " << e.second + 1 << " " << next_pos(e).first + 1 << " " << next_pos(e).second + 1 << endl;
}


Measured memory_bytes: 4212
#Educational DP Contest
#G-LongestPath

#input
n,m = map(int,input().split())

#dp table
dp = [0]*n

#graph table
#頂点aから頂点bに向かう時、テーブルaに頂点bの情報を入れる。
#これを隣接リストという。(<>隣接行列)
edge = [[] for _ in range(n)]

#またこれに対し、頂点iに何本のノードが向かってきているかを保持
to = [0]*n

#process1(graph process)
#This graph is unweighted.
for i in range(m): #mノード
    a,b = map(int,input().split())
    a,b = a-1,b-1
    
    edge[a].append(b)
    to[b] += 1


#process2(search top process)
#toが0のノードをリストアップ
#toが0→始点or使わないということ
#ここから始めることで最長距離が求まることが証明できるので、これを回す
st = []
for i,j in enumerate(to):
    if j == 0:
        st.append(i)


#process3(dp process)
while len(st):
    go = st.pop()
    for e in edge[go]: #egde[go]=始点から向かっている方向のリスト
        to[e] -= 1 #向かってきているノードを一つ消す(これがdp[go]+1できる条件)
        if to[e] == 0: #toがなくなるということは、始点の対象になるということ
            st.append(e)
        dp[e] = max(dp[e],dp[go]+1) #go→eのeには、max(もともとの値,go+1の値)が入る
        #これをst(始点)がなくなるまで続けたときのdpの最大値がans


#output process
print(max(dp))

Measured memory_bytes: 60448
mod = 10 ** 9 + 7
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A.sort(reverse = True)
B.sort(reverse = True)

a_set = set(A)
b_set = set(B)

if len(a_set) != N or len(b_set) != M:
    print(0)
else:

    fact = [0] * 1000001

    fact[0] = 1
    for i in range(1, 1000001):
        fact[i] = (fact[i - 1] * i) % mod

    a_index = 0
    b_index = 0
    count_write = 0

    ans = 1

    for i in range(N * M, 0, -1):

        if a_index == N:
            temp_a = 0
        else:
            temp_a = A[a_index]
        
        if b_index == M:
            temp_b = 0
        else:
            temp_b = B[b_index]

        if temp_a < i and temp_b < i:
            choice = a_index * b_index - count_write
            if choice > 0:
                ans = (ans * choice) % mod
            else:
                print(0)
                exit()
        elif temp_a == i and temp_b == i:
            a_index += 1
            b_index += 1
        elif temp_a == i and temp_b < i:
            if b_index > 0:
                ans = (ans * b_index) % mod
                a_index += 1
            else:
                print(0)
                exit()
        elif temp_b == i and temp_a < i:
            if a_index > 0:
                ans = (ans * a_index) % mod
                b_index += 1
            else:
                print(0)
                exit()
        else:
            print(0)
            exit()

        count_write += 1

        if a_index == N and b_index == M:
            ans = (ans * fact[i - 1]) % mod
            break
            
    print(ans)

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

  int N=in();
  vector<double> v(N);
  REP(i,N){
    v[i]=in<double>();
    string s=in<string>();
    if(s=="BTC") v[i]*=380000.0;
  }
  sort(ALL(v));
  
  cout << accumulate(ALL(v),0.0) << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
a = []
b = [0,0,0,0]
for i in range(4):
    if not(S[i] in S[:i]):
        a.append(S[i])
    else:
        b[a.index(S[i])] += 1
if b == [1,1,0,0]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;


int main() {
	int N;
	int medians[2];
	vector<int> X,Y;
	cin >> N;

	X.resize(N);
	Y.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> X[i];
	}
	Y = X;
	sort(X.begin(), X.end());
	medians[0] = X[N / 2 -1];
	medians[1] = X[N  / 2 ];

	if (medians[0] == medians[1]) {
		for (int i = 0; i < N; i++) {
			cout << medians[1] << endl;
		}
		return 0;
	}

	for (int i = 0; i < N; i++) {
		if (Y[i] <= medians[0]) cout << medians[1] << endl;
		else cout << medians[0] << endl;
		
	}



	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w; cin>>h>>w;
    if (h%3==0 || w%3==0){
        cout<<"0\n";
        return 0;
    }
    ll ans=min(h,w);
    vll v(3);
    //yoko -> tate
    FOR(i,1,h-1){
        v[0] = (ll)i*w;
        ll rest = h-i;
        ll half = w/2;
        v[1] = rest*half;
        v[2] = rest*(w-half);
        sort(all(v));
        chmin(ans,v[2]-v[0]);
    }
    //tate -> yoko
    FOR(j,1,w-1){
        v[0] = (ll)j*h;
        ll rest = w-j;
        ll half = h/2;
        v[1] = rest*half;
        v[2] = rest*(h-half);
        sort(all(v));
        chmin(ans,v[2]-v[0]);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A=[[] for _ in range(N)]
for i in range(M):
  a,b=map(int,input().split())
  A[a-1].append(b-1)
  A[b-1].append(a-1)
for i in A[0]:
  if N-1 in A[i]:
      print("POSSIBLE")
      exit()
print("IMPOSSIBLE")

Measured memory_bytes: 38320
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip> 
#include <cstring>
#include <queue>
#include <stack> 
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
int k,n;
ll shun,ni;
int a[200005];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> k >> n;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
	}
	int minv = 0x3f3f3f3f;
	for(int i = 2;i <= n;i++){
		minv = min(minv,k - (a[i] - a[i - 1]));
	}
	minv = min(minv,a[n] - a[1]);
	cout << minv << endl;
	return 0;
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
int main(){
    int n,m=0,M=0,tmp;
    cin >> n;
    vector<int> vec(n);
    rep(i,n){
        cin >> tmp;
        m+=tmp;
        M+=tmp*tmp;
    }
    if((double)m/(double)n-m/n>0.5)tmp=m/n+1;
    else tmp=m/n;
    cout << n*tmp*tmp-2*m*tmp+M << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
vector<pipii> g[100005];
int ans[100005];
 
int par[17][100005], depth[100005], dp[100005];
void dfs(int u, int p, int d, int val){
    depth[u] = d;
    par[0][u] = p;
    dp[u] = val;
    for(int i=0;i<g[u].size();i++){
        int v = g[u][i].first, c = g[u][i].second.first, l = g[u][i].second.second;
        if(v == p) continue;
        dfs(v, u, d+1, val+l);
    }
}
int LCA(int a, int b){
    if(depth[b] > depth[a]) swap(a, b);
    int diff = depth[a] - depth[b];
    for(int i=17-1;i>=0;i--){
        if((diff>>i)&1) a = par[i][a];
    }
    if(a == b) return a;
    for(int i=17-1;i>=0;i--){
        if(par[i][a] != par[i][b]) a = par[i][a], b = par[i][b];
    }
    return par[0][a];
}
 
int dist(int a, int b){
    return dp[a] + dp[b] - 2*dp[LCA(a, b)];
}
 
vector<pipii> cur[100005];
int dis[100005], cnt[100005];
void dfs2(int u, int p){
 
    for(int i=0;i<cur[u].size();i++){
        int j = cur[u][i].first, x = cur[u][i].second.first, y = cur[u][i].second.second;
 
        if(j < 0){
            j = -j;
            ans[j] -= 2*(y*cnt[x] - dis[x]);
        }
        else{
            ans[j] += y*cnt[x] - dis[x];
        }
    }
 
    for(int i=0;i<g[u].size();i++){
        int v = g[u][i].first, c = g[u][i].second.first, d = g[u][i].second.second;
        if(v == p) continue;
 
        dis[c] += d;
        cnt[c]++;
        dfs2(v, u);
        dis[c] -= d;
        cnt[c]--;
    }
}
 
 
int main(){
    int n, q, a, b, c, d;
    scanf("%d%d", &n, &q);
    for(int i=1;i<=n-1;i++){
        scanf("%d%d%d%d", &a, &b, &c, &d);
        g[a].push_back(pipii(b, pii(c, d)));
        g[b].push_back(pipii(a, pii(c, d)));
    }   
    dfs(1, 0, 0, 0);
    for(int j=1;j<17;j++){
        for(int i=1;i<=n;i++){
            if(par[j-1][i] != 0) par[j][i] = par[j-1][par[j-1][i]];
        }
    }
    for(int i=1;i<=q;i++){
        int x, y, u, v, lca;
        scanf("%d%d%d%d", &x, &y, &u, &v);
        lca = LCA(u, v);
        ans[i] = dist(u, v);
 
        cur[lca].push_back(pipii(-i, pii(x, y)));
        cur[u].push_back(pipii(i, pii(x, y)));
        cur[v].push_back(pipii(i, pii(x, y)));
    }
    dfs2(1, 0);
    for(int i=1;i<=q;i++) printf("%d\n", ans[i]);
}

Measured memory_bytes: 28472
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
#include <fstream>
#include <climits>
 
  using namespace std;
   
 
//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
 
  typedef long long ll;
  typedef long double lld;
  typedef unsigned long long ull;
  ll INF = INT_MAX;
  ll mod = 1000000007;
  // lld PI = 3.141592653;
 
// const ll N = 2e5 + 5;
  

  

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

      string s;
      cin>>s;
      if (s.find("RRR")!=-1){
        cout<<"3\n";
      }else if (s.find("RR")!=-1){
        cout<<"2\n";
      }else if (s.find("R")!=-1){
        cout<<"1\n";
      }else{
        cout<<"0\n";
      }



}

Measured memory_bytes: 3136
a,b,c=map(int,input().split())
import math
d=math.sin(math.radians(c))
S=(a*b*d)/2
h=2*S/a
e = math.sqrt(a*a+b*b-2*a*b*math.cos(math.radians(c)))
L=a+b+e
print('{:.8f}'.format(S))
print('{:.8f}'.format(L))
print('{:.8f}'.format(h))



Measured memory_bytes: 5712