akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

pii xr[20],yr[20];
ll x[20],y[20],p[20],ans[20],px[20],py[20];
ll dp[20];

ll n;

void rec(int i,int mx,int my)
{
	if(i == n+1)
	{
		ll j,k,ax,ay;
		k = 0;
		for(j=1;j<=n;++j)
			ans[j] = p[j]*min(abs(x[j]),abs(y[j]));
		ax = -100000;
		for(j=1;j<=n;++j)
		{
			if((mx>>j)&1)
				ax = xr[j].ff;
			ans[xr[j].ss.ss] = min(ans[xr[j].ss.ss],(xr[j].ff-ax)*p[xr[j].ss.ss]);
		}

		ax = 100000;
		for(j=n;j>=1;j--)
		{
			if((mx>>j)&1)
			{
				k++;
				ax = xr[j].ff;
			}
			ans[xr[j].ss.ss] = min(ans[xr[j].ss.ss],(ax-xr[j].ff)*p[xr[j].ss.ss]);
		}

		ay = -100000;
		for(j=1;j<=n;++j)
		{
			if((my>>j)&1)
				ay = yr[j].ff;
			ans[yr[j].ss.ss] = min(ans[yr[j].ss.ss],(yr[j].ff-ay)*p[yr[j].ss.ss]);
		}

		ay = 100000;
		for(j=n;j>=1;j--)
		{
			if((my>>j)&1)
			{
				k++;
				ay = yr[j].ff;
			}
			ans[yr[j].ss.ss] = min(ans[yr[j].ss.ss],(ay-yr[j].ff)*p[yr[j].ss.ss]);
		}

		ll cost = 0;
		for(j=1;j<=n;++j)
			cost += ans[j];
		dp[k] = min(dp[k],cost);
		return;
	}
	rec(i+1,mx,my);
	rec(i+1,mx+(1<<px[i]),my);
	rec(i+1,mx,my+(1<<py[i]));
}

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

	ll i;

	cin >> n;
	for(i=1;i<=n;++i)
	{
		cin >> x[i] >> y[i] >> p[i];
		xr[i] = pii(x[i],pi(y[i],i));
		yr[i] = pii(y[i],pi(x[i],i));
	}

	sort(xr+1,xr+1+n);
	sort(yr+1,yr+1+n);

	for(i=1;i<=n;++i)
		px[xr[i].ss.ss] = i;
	for(i=1;i<=n;++i)
		py[yr[i].ss.ss] = i;

	for(i=0;i<n;++i)
		dp[i] = 1e18;

	rec(1,0,0);

	for(i=0;i<=n;++i)
		cout << dp[i] << "\n";
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int square(int x) {
	return x * x;
}
int R[] = { 0,1,2,3,4,5,6,7 };
int x[10], y[10];

int main()
{
	int N; cin >> N;
	int num = 1;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
		num *= i + 1;
	}
	double ans = 0.0;
	do{
		for (int i = 0; i < N - 1; i++) {
			ans += sqrt(square(x[R[i + 1]] - x[R[i]]) + square(y[R[i + 1]] - y[R[i]]));
		}
	} while (next_permutation(R, R + N));
	ans /= num;
	printf("%.7f\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
map<ll, ll> mp;

int main() {
	cin >> s;
	cout << s.substr(0, 5) << " " << s.substr(6, 7) << " " << s.substr(14, 5) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

ll mod = 1000000007;

ll mypow(ll a, ll b)
{
    if (b == 1)
    {
        return a;
    }
    else
    {
        return a * mypow(a, b - 1);
    }
}

signed main()
{
    int n;
    cin >> n;
    map<ll, ll> m1;
    map<ll, ll> m2;
    rep(i, n)
    {
        int v;
        cin >> v;
        if (i % 2 == 0)
        {
            m1[v]++;
        }
        else
        {
            m2[v]++;
        }
    }
    pair<ll, ll> m1_1st = {-1, 0};
    pair<ll, ll> m1_2nd;
    pair<ll, ll> m2_1st = {-1, 0};
    pair<ll, ll> m2_2nd;
    for (auto &i : m1)
    {
        if (i.second >= m1_1st.second)
        {
            m1_2nd = m1_1st;
            m1_1st = i;
        }
        else if (i.second >= m1_2nd.second)
        {
            m1_2nd = i;
        }
    }
    for (auto &i : m2)
    {
        if (i.second >= m2_1st.second)
        {
            m2_2nd = m2_1st;
            m2_1st = i;
        }
        else if (i.second >= m2_2nd.second)
        {
            m2_2nd = i;
        }
    }
    // cout<<m1_1st.first<<" "<<m1_1st.second<<" "<<m1_2nd.first<<" "<<m1_2nd.second<<" "<<
    // m2_1st.first<<" "<<m2_1st.second<<" "<<m2_2nd.first<<" "<<m2_2nd.second<<endl;
    if (m1_1st.first != m2_1st.first)
    {
        cout << n - m1_1st.second - m2_1st.second << endl;
    }
    else
    {
        ll ans = min(n - m1_1st.second - m2_2nd.second, n - m1_2nd.second - m2_1st.second);
        cout << ans << endl;
    }
 
    return 0;
}

Measured memory_bytes: 9804
#include <iostream>

using namespace std;

int main(void){

  int la = 0,ra = 0;
  int lb = 0,rb = 0;
  int lc = 0,rc = 0;
  int ld = 0,rd = 0;

  double l,r;

  while( cin >> l >> r ){

    if( l < 0.2 ) ld++;
    else if( 0.2 <= l && l < 0.6 ) lc++;
    else if( 0.6 <= l && l < 1.1 ) lb++;
    else la++;

    if( r < 0.2 ) rd++;
    else if( 0.2 <= r && r < 0.6 ) rc++;
    else if( 0.6 <= r && r < 1.1 ) rb++;
    else ra++;

  }

  cout << la << " " << ra << endl;
  cout << lb << " " << rb << endl;
  cout << lc << " " << rc << endl;
  cout << ld << " " << rd << endl;

  return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#define N 5000005
#define sag (root+root+1)
#define sol (root+root)
#define ort  ((bas+son)/2)
#define mod 1000000007

using namespace std;
typedef long long ll;
map <string, int> mp;
int mx = -1;
int main() {
    int n;
    cin>>n;
    string arr[n];
    for(int i = 0;i<n;i++)cin>>arr[i];
    for(int i = 0;i<n;i++){
        mp[arr[i]]++;    
    }
    set <string> ans;
    for(int i=0; i<n; i++){
    	//cout << mp[arr[i]] << endl;
        if(mp[arr[i]] >= mx){
            if(mp[arr[i]] != mx)
                ans.clear();
            ans.insert(arr[i]);
			mx = mp[arr[i]];
			}
    }
    for(auto i:ans) cout << i << endl;
    return 0;
}

Measured memory_bytes: 36096
#include <iostream>
#include <vector>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#define REP(i, n) for(int i = 0; i < n; i++)
//#define REPR(i, n) for(int i = n; i >= 0; i--)
//#define FOR(i, m, n) for(int i = m; i < n; i++)
//#define INF 1e9
//#define ALL(v) v.begin(), v.end()

using namespace std;
//typedef long long ll;

int main() { //int argc, const char * argv[]
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b;
    string s, t, u;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if (u.compare(s) == 0){
        int at = a-1;
        cout << at << " " <<  b << endl;
    } else {
        int bt = b-1;
        cout << a << " " << bt << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
const int INF  = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
bool vis[MAXN];
int n, L, inc, ans;
int x[MAXN], t[MAXN];
int main() {
	read(n), read(L);
	int mid = 0;
	for (int i = 1; i <= n; i++) {
		read(x[i]);
		if (x[i] <= L - x[i]) mid = i;
	}
	for (int i = 1; i <= n; i++) {
		read(t[i]);
		inc += t[i] / (2 * L), t[i] %= 2 * L;
		if (t[i] > 2 * max(x[i], L - x[i])) inc++, t[i] = 0;
	}
	int l = 0, m = 0, r = 0;
	bool fl = false, fr = false, fm = false;
	for (int i = mid; i >= 1; i--) {
		if (t[i] == 0) continue;
		if (t[i] <= 2 * min(x[i], L - x[i])) {
			if (l == 0) m++;
			else l--, inc++, fl |= l == 0;
		} else l++;
	}
	for (int i = mid + 1; i <= n; i++) {
		if (t[i] == 0) continue;
		if (t[i] <= 2 * min(x[i], L - x[i])) {
			if (r == 0) m++, fr = false;
			else r--, inc++, fr = true;
		} else r++;
	}
	fm = m >= 2;
	inc += m / 2, m %= 2;
	if (r != 0) ans = l + m + r + 1;
	else {
		ans = l + m + r;
		if (t[n] == 0 || fr) ans++;
		else if (m == 0 && (fm || fl)) ans++;
	}
	writeln(2ll * (ans + inc) * L);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

struct E {
    int to, w;
};

const ll INF = 1e18;
const int N = 1e6 + 5;
vector<E> g[N];
int ch[N][2];
ll d[N];
int cv;

int build(int L, int R) {
    int v = cv++;
    if (L == R) {
        g[v].push_back({L, 0});
    }
    else {
        int m = (L + R) >> 1;
        ch[v][0] = build(L, m);
        ch[v][1] = build(m + 1, R);
        g[v] = {{ch[v][0], 0}, {ch[v][1], 0}};
    }
    return v;
}

int build_r(int L, int R) {
    int v = cv++;
    if (L == R) {
        g[L].push_back({v, 0});
    }
    else {
        int m = (L + R) >> 1;
        ch[v][0] = build_r(L, m);
        ch[v][1] = build_r(m + 1, R);

        g[ch[v][0]].push_back({v, 0});
        g[ch[v][1]].push_back({v, 0});
    }
    return v;
}

vector<int> ver, ver_r;

void que(int l, int r, int x, int v, int v_r, int L, int R) {
    if (l > r)
        return;
    if (l == L && r == R) {
        ver.push_back(v);
        ver_r.push_back(v_r);
    }
    else {
        int m = (L + R) >> 1;
        que(l, min(m, r), x, ch[v][0], ch[v_r][0], L, m);
        que(max(m + 1, l), r, x, ch[v][1], ch[v_r][1], m + 1, R);
    }
}

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

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

    cv = n;

    int rt = build(0, n - 1),
        rt_r = build_r(0, n - 1);

    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        ver.clear();
        ver_r.clear();
        que(a, b, c, rt, rt_r, 0, n - 1);

        for (const int &x : ver_r) {
            for (const int &y : ver) {
                g[x].push_back({y, c});
            }
        }
    }

    // for (int i = 0; i < cv; i++) {
    //     for (E e : g[i]) {
    //         cout << i << " " << e.to << " " << e.w << "\n";
    //     }
    // }

    priority_queue<pair<ll, int>,
        vector<pair<ll, int>>,
        greater<pair<ll, int>>> q;

    fill(d, d + N, INF);
    d[0] = 0;

    q.push({0, 0});

    while (!q.empty()) {
        int node = q.top().second;
        ll cd = q.top().first;
        q.pop();

        if (cd != d[node])
            continue;

        for (const E &e : g[node]) {
            if (d[e.to] > d[node] + e.w) {
                d[e.to] = d[node] + e.w;
                q.push({d[e.to], e.to});
            }
        }
    }

    if (d[n - 1] < INF) {
        cout << d[n - 1];
    }
    else {
        cout << "-1";
    }
    return 0;
}

Measured memory_bytes: 278448
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		sc.close();
		System.out.println(k == 1 ? 0 : n - k);
	}

	public int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  int x,n;
  cin >> x >> n;
  vector<int> d(102);
  for(int i = 0; i < n; i++){
    int p;
    cin >> p;
    d[p] = 1;
  }
  P ans(99999,-1);
  for(int i = 0; i <= 101;i++){
    if(d[i] == 1) continue;
    int dif = abs(x-i);
    ans = min(ans,P(dif,i));
  }
  cout << ans.second << endl;
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define ten(n) ((int)1e##n)
#define fst first
#define snd second
using ll=long long;
using pii=pair<int,int>;using pll=pair<ll,ll>;using pil=pair<int,ll>;using pli=pair<ll,int>;
using vs=vector<string>;using vvs=vector<vs>;using vvvs=vector<vvs>;
using vb=vector<bool>;using vvb=vector<vb>;using vvvb=vector<vvb>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<class T> bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
ll ri(){ll l;cin>>l;return l;} string rs(){string s;cin>>s;return s;}
template<class T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<'('<<p.fst<<", "<<p.snd<<')';}
ostream&operator<<(ostream&o,const vb&t){forr(e,t)o<<"#."[e];return o;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&t){o<<"{";forr(e,t)o<<e<<",";o<<"}"<<endl;return o;}
#ifdef LOCAL
vs s_p_l_i_t(const string&s,char c){vs v;stringstream ss(s);string x;while(getline(ss,x,c))v.emplace_back(x);return move(v);}
void e_r_r(vs::iterator it){cerr<<endl;}
template<class T,class... Args>void e_r_r(vs::iterator it,T a,Args... args){cerr<<it->substr((*it)[0]==' ',it->length())<<" = "<<a<<", ";e_r_r(++it,args...);}
#define out(args...){vs a_r_g_s=s_p_l_i_t(#args,',');e_r_r(a_r_g_s.begin(),args);}
#else
#define out(args...)
#endif

void panic() {
  cout << "inf" << endl;
  exit(0);
}

ll solve() {
  int n = ri();
  int m = ri();

  vvpii E(n);
  rep(i, m) {
    int u = ri() - 1;
    int v = ri() - 1;
    ll w = -ri();
    E[u].emplace_back(v, w);
  }

  const ll inf = 1e18;
  vl D(n, inf);
  D[0] = 0;

  rep(i, n) {
    rep(u, n) {
      forr(vw, E[u]) {
        amin(D[vw.fst], D[u] + vw.snd);
      }
    }
  }

  rep(u, n) {
    forr(vw, E[u]) {
      if (D[vw.fst] > D[u] + vw.snd) {
        // 負閉路検出
      }
    }
  }

  ll dd = D[n-1];

  rep(i, n) {
    rep(u, n) {
      forr(vw, E[u]) {
        amin(D[vw.fst], D[u] + vw.snd);
      }
    }
  }

  ll dd2 = D[n-1];
  if (dd != dd2) panic();

  return -D[n-1];
}

void Main() {
  cout << solve() << endl;
}

int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <utility>
#include <list>
#include <ctime>
#include <memory>

using namespace std;

int n,visit[100010]={},dis[100010]={},dis2[100010]={};
vector<int> tree[100010];

void BFS(int x,int d)
{
	visit[x]=1;
	dis[x]=d;
	for(int i=0;i<tree[x].size();i++){
		if(!visit[tree[x][i]]){
			//cout << "BFS on x="<<tree[x][i]<<"    d="<<d+1<<endl; 
			BFS(tree[x][i],d+1);
		}
	}
}

int main()
{	
	//input yabbi
	cin >> n;

	for(int i=1;i<n;i++){
		int a,b;
		cin >> a >> b;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	
	
	//bfs yabbi
	BFS(1,0);
	for(int i=1;i<=n;i++){
		dis2[i]=dis[i];
		visit[i]=0;
	}
		//cout <<"I am a line...."<<endl;
	BFS(n,0);

	int w=0,b=0;
	for(int i=1;i<=n;i++){
		if(dis2[i]>dis[i])w++;
		else b++;
	}
	
	if(w>=b)cout << "Snuke" << endl;
	else cout << "Fennec" << endl;
	
	return 0;
}


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

int main() {
    long long N;
    cin >> N;
    
    long long A[N+1], B[N];
    rep(i,N+1){
        cin >> A[i];
    }
    rep(i,N){
        cin >> B[i];
    }
    
    long long c, count=0;
    
    rep(i,N){
        c = min(A[i],B[i]);
        count += c;
        A[i] -= c;
        B[i] -= c;
        c = min(A[i+1], B[i]);
        count += c;
        A[i+1] -= c;
    }

    cout << count << endl;
    
    return 0;
}


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

int main(){
    ll T1, T2;
    cin >> T1 >> T2;
    ll A1, A2, B1, B2;
    cin >> A1 >> A2 >> B1 >> B2;
    if (A1 > B1 && A2 > B2) {
        cout << 0 << endl;
        return 0;
    }
    if (A1 < B1 && A2 < B2) {
        cout << 0 << endl;
        return 0;
    }
    
    if (A1 < B1) {
        swap(A1, B1);
        swap(A2, B2);
    }
    if (A1*T1+A2*T2 == B1*T1+B2*T2) {
        cout << "infinity" << endl;
        return 0;
    }
    if (A1*T1+A2*T2 > B1*T1+B2*T2) {
        cout << 0 << endl;
        return 0;
    }
    
    ll ans = 1;
    ll P = B1*T1+B2*T2 - (A1*T1+A2*T2);
    //cout << B1*T1 << " " << B2*T2 << endl;
    //cout << A1*T1 << " " << A2*T2 << endl;
    //cout << P << endl;
    if ((A1*T1-B1*T1) % P == 0) ans += 2 * ((A1*T1-B1*T1) / P) - 1;
    else ans += 2 * ((A1*T1-B1*T1)/ P);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())

if a == b:
    if c % a == 0:
        print(1)
    elif a > c:
        print(0)

else:
    n = 0
    for i in range(a,b+1):
        if c % i == 0:
            n += 1

    print(n)


Measured memory_bytes: 5596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest
{
	class Program
	{
		static void Main(string[] args)
		{
			var NT = Console.ReadLine().Split().Select(int.Parse);
			int N = NT.First(), T = NT.Last();
			int[] t = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int ans = 0;
			for (int i = 0; i < N - 1; i++)
			{
				ans += Math.Min(T, t[i + 1] - t[i]);
			}
			Console.WriteLine(ans + T);
#if DEBUG
			Console.ReadKey();
#endif
		}
	}
}


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

int n, k, a[100100], dp[100100];

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

    cin >> n >> k;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        dp[i] = 1e9;
    }
    dp[1] = 0;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= min(k, n-i); j++)
            dp[i+j] = min(dp[i+j], dp[i] + abs(a[i]-a[i+j]));
    }
    cout << dp[n];

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=3e5+10;
int a[]= {399,799,1199,1599,1999,2399,2799,3199};
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    int y[x];
    for (int i=0; i<x; i++)
        cin>>y[i];
    set<int>s;
    int c=0;
    for (int i=0; i<x; i++)
    {
        bool b=false;
        for (int j=0; j<8; j++)
        {
            if (y[i]<=a[j])
            {
                b=true;
                s.insert(j);
                break;
            }
        }
        if (!b)
                c++;
    }
    int m;
    if (s.empty())
        m=0;
    else
        m=s.size();
    cout<<max(1,m)<<" "<<m+c<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import os
import re
import datetime

N = int(input())
S = input()

maxCount = 0
for i in range(1, len(S) - 1):
	sl = S[:i] #// 左文字列
	sr = S[i:] #// 右文字列
	
	setl = set(sl)
	setr = set(sr)
	setAnd = setl & setr
	
	maxCount = max(len(setAnd), maxCount)

print(maxCount)

Measured memory_bytes: 3444
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int n;
    while(cin >> n){
        int ans = 0;
        for(int a = 0 ; a < 10 ; ++a){
            for(int b = 0 ; b < 10 ; ++b){
                for(int c = 0 ; c < 10 ; ++c){
                    for(int d = 0 ; d < 10 ; ++d){
                        if(a + b + c + d == n){
                            ++ans;
                        }
                    }
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <stdlib.h>
#include <numeric>
#include <cmath>
#define mod 1000000007
typedef unsigned long long int ll;
using namespace std;



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a[3];
    for(int i=0;i<3;i++)
    cin>>a[i];
    sort(a,a+3);
    cout<<a[0]+a[1]<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b,c,d;
  int ans = 0;
  cin>>a>>b>>c>>d;
  if(a > b) {
    ans += b;
  } else {
    ans += a;
  }
  if(c > d){
    ans += d;
  } else{
    ans += c;
  }
  cout << ans << endl;

  return 0;
}


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

const double PI = acos(-1);

int main(){
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	double th = double(h*60+m)/720 * 2*PI; 
	double tm = double(m)/60 * 2*PI;
	double xh = a*cos(th), yh = a*sin(th);
	double xm = b*cos(tm), ym = b*sin(tm);
	double dx = xh-xm, dy = yh-ym;
	double ans = sqrt(dx*dx + dy*dy);
	cout << fixed << setprecision(10) << ans << endl;

	return 0;
}

Measured memory_bytes: 4092
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(n)]
dp = [[0 for _ in range(m)] for _ in range(n)]
dp[0][0] = (1 << (a[0][0] - b[0][0] + 12880)) | 1 << (b[0][0] - a[0][0] + 12880)
mxs = (1 << (12880 * 2 + 1)) - 1
for i in range(n):
	for j in range(m):
		if not i and not j:
			continue
		d = abs(a[i][j] - b[i][j])
		if i:
			u = (dp[i - 1][j] << d) & mxs
			v = (dp[i - 1][j] >> d)
			dp[i][j] |= u
			dp[i][j] |= v
		if j:
			u = (dp[i][j - 1] << d) & mxs
			v = (dp[i][j - 1] >> d) & mxs
			dp[i][j] |= u
			dp[i][j] |= v

c = dp[n - 1][m - 1] >> 12880
for i in range(12880):
	if c & 1:
		print(i)
		break
	c >>= 1


Measured memory_bytes: 59228
n=int(input())
L=[[0]*9 for i in range(9)]

for i in range(1,n+1):
    a=int(str(i)[0])
    b=int(str(i)[-1])
    if a!=0 and b!=0:
        L[a-1][b-1]+=1

r=0
for j in range(9):
    for k in range(9):
        if j==k:
            r+=L[j][j]*L[j][j]
        else:
            r+=L[j][k]*L[k][j]
print(r)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, k;
  cin >> n >> k;
  cout << n - k + 1 << endl;
  return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/python3

(x, y, a, b, c) = map(int, input().split())

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
p = p[0:x]
q.sort(reverse=True)
q = q[0:y]

t = p + q + r

t.sort(reverse=True)
print(sum(t[0:x + y]))

Measured memory_bytes: 23328
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $s = <STDIN>);
my ($f, $c) = (0, 0);
my @p;
for my $i (0..length($s)-1) {
  if (substr($s, $i, 1) eq 'R') {
    if ($f == 1) {
      push @p, $c;
      $f = 0;
      $c = 0;
    }
  } else {
    if ($f == 0) {
      push @p, $c;
      $f = 1;
      $c = 0;
    }
  }
  $c++;
  push @p, $c if $i == length($s) - 1;
}
my $ans;
while (@p) {
  my $x = shift @p;
  my $y = shift @p;
  $ans .= "0 " x ($x - 1);
  if (($x + $y) % 2 == 0) {
    $ans .= ($x + $y) / 2;
    $ans .= ' ';
    $ans .= ($x + $y) / 2;
    $ans .= ' ';
  } elsif ($x % 2 == 0) {
    $ans .= int(($x + $y) / 2);
    $ans .= ' ';
    $ans .= int(($x + $y) / 2) + 1;
    $ans .= ' ';
  } else {
    $ans .= int(($x + $y) / 2) + 1;
    $ans .= ' ';
    $ans .= int(($x + $y) / 2);
    $ans .= ' ';
  }
  $ans .= "0 " x ($y - 1);
}
say substr($ans, 0, length($ans) - 1);

Measured memory_bytes: 4864
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>


//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin(), (v).end());

typedef unsigned long long int ull;
typedef long long lint;

using namespace std;




int main(){
    int N, M;
    int temp;
    lint ans=0;


    //入力
    cin >> N >> M;

    priority_queue<int> A;
    rep(i, N) {
        cin >> temp;
        A.push(temp);
    }
    


    while(M>0){
        int i;

        temp = A.top() / 2;
        A.pop();
        A.push(temp);
        M--;

        //rep(j,N) cout << A[j] << " ";
        //cout << endl;
        //cout << M << endl;
    }
    
    //rep(i,N) cout << A[i] << " "; 


    rep(i, N) { ans += A.top();A.pop(); }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin >> x;
  bool t=false;
  for(int64_t b=-150;b<150;b++){
      for(int64_t a=-150;a<150;a++){
        if((a-b)*((a-b)*(a-b)*(a-b)*(a-b)+5*a*b*((a-b)*(a-b)+a*b))==x){
          cout << a << " " << b << endl;
          t=true;
          return 0;
        }
      }
  }
}
  


Measured memory_bytes: 3640
#include<iostream>
#include<stdio.h>

using namespace std;

int main()
{
	int input;
	while(cin >> input)
	{
		int count = 0;
		int i, j, k, l;
		for(i = 0; i < 10; i++)
		{
			for(j = 0; j < 10; j++)
			{
				for(k = 0; k < 10; k++)
				{
					for(l = 0; l < 10; l++)
					{
						if(i + j + k + l == input)	count++;
					}
				}
			}
		}
		cout << count << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
from collections import deque

N = int(input())

neighbors = [[] for _ in range(N)]

for _ in range(N - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    neighbors[a].append(b)
    neighbors[b].append(a)
c = list(map(int, input().split()))
sorted_c = sorted(c)
max_c = sorted_c[-1]

closed = [0 for _ in range(N)]
use = [0 for _ in range(N)]
q = deque()
q.append(0)
use[0] = sorted_c.pop()
M = 0


while len(q) > 0:
    parent = q.pop()
    closed[parent] = use[parent]
    for neighbor in neighbors[parent]:
        if closed[neighbor] == 0:
            c2 = use[neighbor] = sorted_c.pop()
            c1 = closed[parent]
            w = c1 if c1 < c2 else c2
            M += w
            q.append(neighbor)

print(M)
print(*use)


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,n,x;
    cin >> n;
    int ans[n+2];
    for(i=1;i<=n;i++)
    {
        cin >> x;
        ans[x]=i;
    }
    for(i=1;i<=n;i++)cout << ans[i] << ' ';
    return 0;
}


Measured memory_bytes: 1280
w,h,n=map(int,input().split())
x=[]
for i in range(n):
    a,b,c=map(int,input().split())
    if c<3:
        x.append([a,c])
    else:
        x.append([b,c])
def get_unique_list(seq):
    seen=[]
    return [x for x in seq if x not in seen and not seen.append(x)]
X=get_unique_list(x)
a=[];b=[];c=[];d=[]
for i in range(len(X)):
    if X[i][1]==1:
        a.append(X[i][0])
    elif X[i][1]==2:
        b.append(X[i][0])
    elif X[i][1]==3:
        c.append(X[i][0])
    else:
        d.append(X[i][0])
if len(b)>0:
    w=min(b)
if len(a)>0:
    w-=max(a)
if len(d)>0:
    h=min(d)
if len(c)>0:
    h-=max(c)
print([h*w,0][h<1 or w<1])

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

int main(){
  string N;
  cin >> N;
  if (N[0] == N[1] && N[1] == N[2]){
    cout << "Yes" << endl;
  }
  else if (N[1] == N[2] && N[2] == N[3]){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n))
typedef bitset<13> MASK;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<vector<int>> vvi;

//set iterator can be increamnted and decreamnted
void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}


int main() {
    fast();
    string s;cin>>s;
    if(s[s.size()-1]!='s')cout<<(s+'s');
    else cout<<(s+"es");
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2157583657         〜2E+9
// long long  最大値9223372036855775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  vector<int> a(5);
  rep(i, 5) cin >> a[i];
  int k; cin >> k;
  if(MAX(a)-MIN(a)<=k){
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
  ret;
}


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

int main() {
	int N, D;
	cin >> N >> D;
	double X, Y;
	int count = 0;
	for (int i = 0; i < N; i++) {
		cin >> X >> Y;
		if (sqrt(pow(X,2) + pow(Y,2)) <= D) {
			count++;
		}
	}
	cout << count;
}

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

int main(){
	
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	rep(i,n)cin >> p[i];
	sort(p.begin(),p.end());
	int ans = 0;
	rep(i,k) ans += p[i];
	cout << ans << endl;

}













Measured memory_bytes: 3620
# https://atcoder.jp/contests/abc145/tasks/abc145_d

def mod_pow(x, n, mod)
  ret = 1
  while n > 0
    ret = ret * x % mod if n & 1 > 0
    x = x * x % mod
    n >>= 1
  end
  ret
end

def mod_inverse(x, mod)
  mod_pow(x, mod - 2, mod)
end

def mod_fact(n, mod)
  (1..n).reduce(1) { |a, e| a * e % mod }
end

def mod_comb(n, k, mod)
  return 0 if n < 0 || k < 0 || n < k
  return 1 if k.zero? || k == n
  a = mod_fact(n, mod)
  b = mod_fact(k, mod) * mod_fact(n - k, mod) % mod
  a * mod_inverse(b, mod) % mod
end

MOD = 10**9+7

X, Y = gets.split.map(&:to_i)
x, y = [2 * X - Y, 2 * Y - X]
ans =
  if x < 0 || y < 0
    0
  elsif x % 3 > 0 || y % 3 > 0
    0
  else
    x, y = [x / 3, y / 3]
    mod_comb(x + y, x, MOD)
  end

puts ans


Measured memory_bytes: 1788
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;

    class Program
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            var a = double.Parse(input[0]);
            var b = double.Parse(input[1]);
            var h = double.Parse(input[2]);
            var m = double.Parse(input[3]);
            var h_kakudo = 30 * h + (m / 60) * 30;
            var m_kakudo = 6 * m;
            var angleRAdianH = h_kakudo * Math.PI / 180; //度からラジアン角度を求める
            var angleRAdianM = m_kakudo * Math.PI / 180; //度からラジアン角度を求める

            var x1 = a * Math.Cos(angleRAdianH);
            var x2 = a * Math.Sin(angleRAdianH);
            var y1 = b * Math.Cos(angleRAdianM);
            var y2 = b * Math.Sin(angleRAdianM);

            var ans = Math.Sqrt((y2 - x2) * (y2 - x2) + (y1 - x1) * (y1 - x1));
            Console.WriteLine(ans.ToString());
        }
    }

Measured memory_bytes: 18756
// ABC161F - Division or Substraction

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

bool check(long long int N, long long int K) {
	while (N >= K) {
		if (N % K == 0) {
			N /= K;
		} else {
			N %= K;
		}
	}

	return N == 1;
}

int main() {
	long long int N;
	cin >> N;

	int ans = 0;

	if (N > 2) {
		ans++; // K = N - 1 は少なくとも満たす。
		// N - 1の約数の個数を求める
		for (long long int i = 2; i <= (long long int)sqrt(N - 1); i++) {
			if ((N - 1)% i == 0) {
				if (i * i == N - 1) {
					ans++;
				} else {
					ans += 2; /* この場合はa*bのaとbが約数となるため2個増やす必要がある。*/
				}
			}
		}
	}

	// N の約数について調べる。
	ans++; // K = N は少なくとも満たす。
	for (long long int i = 2; i <= (long long int)sqrt(N); i++) {
		if (N % i == 0) {
			if (i * i == N) {
				ans += check(N, i);
			} else {
				/* この場合はa*bのaとbが約数となるため2回調べる必要がある。*/
				ans += check(N, i);
				ans += check(N, N / i);
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
/*
  ___    ___             ___    __                   _     _   _
 |   \  /   |           |   \  |  |                 | |   (_) | |
 |    \/    |  _ __     |    \ |  |   __ _   _____  | |_   _  | | __
 |  |\  /|  | | '__|    |  |\ \|  |  / _' | |  ___) | __| | | | |/ /
 |  | \/ |  | | |    _  |  | \    | | (_| | |___  | | \_  | | |   /
 |__|    |__| |_|   (_) |__|  \___|  \__,_| (_____|  \__| |_| |_|\_\

 */

 #include<bits/stdc++.h>
 using namespace std;
 #define ll long double
 #define M 1000000007

 int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,ans=0;
    long long n,i,j;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>t;
        t=1/t;
        ans+=t;
    }
    ans=1/ans;
    cout<<ans<<endl;
 }



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

using namespace std;

int main() {
	double N;
	cin >> N;
	double x[100];
	string u[100];

	for (int i = 0; i < N; i++) {
		cin >> x[i] >> u[i];
	}
	double sum = 0;
	for (int i = 0; i < N; i++) {
		if (u[i] == "BTC") {
			x[i] = x[i]*380000.0;
		}
		sum += x[i];
	}
	cout << fixed << setprecision(10) << sum << endl;

	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [None] * H

for i in range(H):
    S[i] = list(input())


def count_bomb_num(S, h, w):
    bomb_num = 0

    for i in range(-1, 2):
        ni = h + i
        if ni < 0 or H <= ni:
            continue
        for j in range(-1, 2):
            nj = w + j
            if nj < 0 or W <= nj:
                continue
            if S[ni][nj] == "#":
                bomb_num += 1

    return bomb_num


for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            continue
        S[h][w] = str(count_bomb_num(S, h, w))

for s in S:
    print("".join(s))


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

using namespace std;

int main() {
    char c;
    int ans[26];
    for (int i = 0; i < 26; ++i) ans[i] = 0;
    while (cin >> c) {
        if ('a' <= c && c <= 'z') {
            ans[c - 'a']++;
        }
        if ('A' <= c && c <= 'Z') {
            ans[c - 'A']++;
        }
    }
    for (int i = 0; i < 26; ++i) {
        cout << (char)(i + 'a') << " : " << ans[i] << endl;
    }
    //cout << (char)(25 + 'a') << " : " << ans[25];
    return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string>
#include<string.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (c < a) {
		if (d < a) {
			cout << 0 << endl;
		}
		else if (d <= b) {
			cout << d - a << endl;
		}
		else {
			cout << b - a << endl;
		}
	}
	else if (c <= b) {
		if (d <= b) {
			cout << d - c << endl;
		}
		else {
			cout << b - c << endl;
		}
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int x;
    cin >> x;
    int h, m, s;
    h = x / 3600;
    x -= h * 3600;
    m = x / 60;
    x -= m * 60;
    s = x;

    printf("%d:%d:%d\n", h, m, s);
}


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

int main(){
  int N;
  cin >> N;
  
  vector<string> sr(N);
  cin >> sr.at(0);
  
  bool judge = true;
  for ( int i = 1 ; i < N ; i++ ){
  	cin >> sr.at(i);
    int last_c = sr.at(i-1).length()-1;
  	if ( sr.at(i).substr(0,1) != sr.at(i-1).substr(last_c))
      judge = false; 
  }
  sort ( sr.begin(),sr.end());
  for ( int i = 0 ; i < N-1 ; i++ ){
  	if ( sr.at(i) == sr.at(i+1) )
      judge = false;
  }
  
  if(judge)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}  

Measured memory_bytes: 256
from sys import stdin


def main():
    N, M = [int(x) for x in stdin.readline().rstrip().split()]
    result = ['*'] * N
    for i in range(M):
        s, c = [int(x) for x in stdin.readline().rstrip().split()]
        if result[s - 1] == '*' or result[s - 1] == str(c):
            result[s - 1] = str(c)
        else:
            print(-1)
            return
    if result[0] == '0' and N != 1:
        print(-1)
        return
    if result[0] == '*' and N == 1:
        result[0] = '0'
    if result[0] == '*':
        result[0] = '1'
    for i in range(N):
        if result[i] == '*':
            result[i] = '0'
    print(''.join(result))


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  cin>>n;
  set<pii> S;
  // 1.
  {
    int i=0;
    int j=0;
    while(++i<n){
      if((i+j)%2==1){
        S.insert(pii(i,j));
      }
    }
  }
  // 2.
  {
    int i=1;
    while(i<n){
      REP(j,n){
        if((i+j)%2==1){
          S.insert(pii(i,j));
        }
      }
      i+=3;
    }
  }
  // 3.
  {
    int i=n-1;
    REP(j,n){
      if((i+j)%2==1){
        S.insert(pii(i,j));
      }
    }
  }
  printf("%d\n",S.size());
  for(auto P:S){
    printf("%d %d\n",P.first, P.second);
  }
  return 0;
}


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

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

  if (a+b+c >= 22) {
    cout << "bust" << endl;
  }
  else{
    cout << "win" << endl;
  }
}

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

using namespace std;

int main() {
	int N, K;
  	cin >>N >> K ;
    int H[N], i, j;
  	for (i = 0; i < N; i++) cin >> H[i];
  	long long D[N];
 	for (i = 0; i < N; i++){
      D[i] = -1;
    }
  	D[0] = 0;
	for (i = 0; i < N ; i++){
      for (j = 1;  j <= K; j ++){
        if (i+j > N) break;
        if (D[i+j] >= 0){
        	D[i+j] = min(D[i+j], D[i] + abs(H[i] - H[i+j]));
        }else{
        	D[i+j] = D[i] + abs(H[i] - H[i+j]);
        }
      }
    }
  	printf("%lld", D[N-1]%MOD);
}


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

map<int64_t, int> prime_factor(int64_t n) {
  map<int64_t, int> ret;
  for (int64_t i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}

int64_t lcm(int64_t n, int64_t m) {
  map<int64_t, int> n_prime = prime_factor(n);
  map<int64_t, int> m_prime = prime_factor(m);
  for (auto& prime : m_prime) {
    n_prime[prime.first] = max(n_prime[prime.first], prime.second);
  }
  int64_t ret = 1;
  for (auto& prime : n_prime) {
    for (int i = 0; i < prime.second; ++i) ret *= prime.first;
  }
  return ret;
}

int main(void) {
  int64_t N, M;
  cin >> N >> M;
  string S, T;
  cin >> S >> T;
  if (M < N) {
    swap(N, M);
    swap(S, T);
  }

  int64_t L = lcm(N, M);
  int64_t LN = L / N;
  int64_t LM = L / M;

  map<int, char> parse;
  for (int i = 0; i < N; ++i) {
    int idx = i * LN + 1;
    parse[idx] = S[i];
  }
  for (int i = 0; i < M; ++i) {
    int idx = i * LM + 1;
    if (parse.count(idx) && parse[idx] != T[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << L << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int h, w; cin >> h >> w;

    int c[10][10];
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            cin >> c[i][j];
        }
    }

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

    //ワーシャルフロイド
    for (int k = 0; k < 10; ++k) {
        for (int i = 0; i < 10; ++i) {
            for (int j = 0; j < 10; ++j) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (a[i][j] == -1 || a[i][j] == 1) {
                continue;
            } else {
                ans += c[a[i][j]][1];
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.*;

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

		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int m = sc.nextInt();

			ArrayList<ArrayList<Edge>> graph = new ArrayList<ArrayList<Edge>>();
			for(int i=0;i<n;i++) graph.add(new ArrayList<Edge>());

			while(m-- > 0){
				String[] s = sc.next().split(",");
				int a = Integer.parseInt(s[0]);
				int b = Integer.parseInt(s[1]);
				int cost = Integer.parseInt(s[2]) / 100 - 1;

				graph.get(a).add(new Edge(b,cost));
				graph.get(b).add(new Edge(a,cost));
			}

			System.out.println(prim(graph));
		}
	}

	private static int prim(ArrayList<ArrayList<Edge>> graph){
		PriorityQueue<Edge> open = new PriorityQueue<Edge>();
		HashSet<Integer> closed = new HashSet<Integer>();
		int total = 0;

		open.add(new Edge(0,0));
		while(closed.size() != graph.size()){
			Edge st = open.poll();
			if(closed.contains(st.to)){
				continue;
			}
			closed.add(st.to);
			total += st.cost;
			for(Edge e : graph.get(st.to)){
				if(!closed.contains(e.to)){
					open.add(e);
				}
			}
		}

		return total;
	}
}

class Edge implements Comparable<Edge>{
	int to, cost;

	Edge(int to,int cost){
		this.to = to;
		this.cost = cost;
	}

	public int compareTo(Edge e){
		return this.cost - e.cost;
	}
}

Measured memory_bytes: 13000