akhauriyash/Code-Regression huggingface dataset:
fn solve() {
    let n: usize = read();
    let mut rc = vec![(0, 0); n];
    for i in 0..n {
        rc[i] = (read::<usize>(), read::<usize>());
    }
    let mut memo = vec![vec![std::usize::MAX; n]; n];
    for i in 0..n {
        memo[i][i] = 0;
    }
    // jは幅
    for j in 1..n {
        for i in 0..n - j {
            // 分割点
            for k in 0..j {
                memo[i][i + j] = min(
                    memo[i][i + j],
                    memo[i][i + k] + memo[i + k + 1][i + j] + rc[i].0 * rc[i + k].1 * rc[i + j].1,
                );
            }
        }
    }
    println!("{}", memo[0][n - 1]);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========



Measured memory_bytes: 9080
using System;

class AOJ
{
	public static void Main(string[] args)
	{
		int len = int.Parse(Console.ReadLine().Trim());
		var input = Console.ReadLine().Trim().Split(' ');
		var num = new int[len];
		for(int i = 0; i < len; i++){ num[i] = int.Parse(input[i]); }
		int counter = 0;
		for(int i = 0; i < len; i++)
		{
			int min_pos = i;
			for(int j = i; j < len; j++)
			{
				if(num[j] < num[min_pos]){ min_pos = j; }
			}
			if(min_pos != i)
			{
				counter++;
				int tmp = num[i];
				num[i] = num[min_pos];
				num[min_pos] = tmp;
			}
		}
		string output = "";
		for(int i = 0; i < len; i++){ output += num[i].ToString() + " "; }
		output = output.Trim();
		Console.WriteLine(output);
		Console.WriteLine(counter);
	}
}

Measured memory_bytes: 7636
#pragma GCC optimze("Ofast")
#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;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll inf=1e18, N=3005;
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (1LL*x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll powMod(ll base,ll expo){
	if(base==0)return 0;
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base); 
		expo>>=1;
	}
	return ans;
}
void solve(){
	string a, b;
	cin>>a>>b;
	rep(i,0,sz(a)){
		if(a[i]!=b[i]){
			cout<<"No";
			return;
		}
	}
	cout<<"Yes";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 3644
/**
 *      ABC 77 C
 *      author  : kyomukyomupurin
 *      created : 2018-09-04 01:31:20
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    int A[N] = {}; int B[N] = {}; int C[N] = {};
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> B[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> C[i];        
    }

    long long count = 0;

    //j を固定するとO(N^2)まで落とせる さらにソートして二分探索して計算量を落とす

    sort(A, A + N); sort(C, C + N);

    for (int i = 0; i < N; ++i) {
        count += distance(A, lower_bound(A, A + N, B[i])) * (N - distance(C, upper_bound(C, C + N, B[i])));//初めてbの二分探索
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			string s = Console.ReadLine();
			string p = Console.ReadLine();

			bool isOK = false;
			if (s.Contains(p)) {
				isOK = true;
			} else {
				for (int i = 1; i < s.Length; ++i) {
					string newStr = s.Substring(i, s.Length - i) + s.Substring(0, i);
					if (newStr.Contains(p)) {
						isOK = true;
						break;
					}
				}
			}

			string str = isOK ? "Yes" : "No";
			Console.WriteLine($"{str}");
			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 17948
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

char g[505][505];

int vert(int N){
  int ret = 0;
  REP(j, 0, N){
    REP(i, 0, N){
      if(g[i][j] == '.'){
        ret++;
        break;
      }
    }
  }
  return ret;
}

int make_line(int N){
  int ret = N;
  REP(i, 0, N){
    int curr = N;
    int w = 0;
    bool p = false;
    REP(j, 0, N){
      if(g[j][i] == '#'){
        p = true;
      }
      if(g[i][j] == '.'){
        w++;
      }
    }
    if(p){
      curr = min(curr, w);
    } else {
      curr = min(curr, w+1);
    }
    ret = min(curr, ret);
  }
  return ret;
}

int main(){
  int N;
  cin >> N;
  bool f = false;
  REP(i, 0, N){
    REP(j, 0, N){
      cin >> g[i][j];
      if(g[i][j] == '#'){
        f = true;
      }
    }
  }

  if(!f){
    cout << -1 << endl;
  } else {
    int ex = make_line(N);
    cout << ex + vert(N) << endl;
  }

  return 0;
}


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

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

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

  int count = 0;
  // 0 <= a, b, c <= 50. bruteforce is ok.
  // O(n^3)
  for (int i = 0; i <= a; ++i) {
    for (int j = 0; j <= b; ++j) {
      for (int k = 0; k <= c; ++k) {
        if (500*i+100*j+50*k == x) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<string ,int>m;
    int i,j,k,mx=0,n;
    cin>>n;
    string x;
    for(i=0;i<n;i++)
    {
        cin>>x;
        m[x]+=1;
    }
    map<string,int >::iterator it;
    for(it=m.begin();it!=m.end();it++)
    {
        j=it->second;
        if(j>mx) mx=j;
    }
    for(it=m.begin();it!=m.end();it++)
    {
        if(it->second==mx) cout<<it->first<<endl;
    }

    return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
#include <string>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PL;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll N, M, V, P;
ll a[MAX];

ll ok(ll K) {
  if(K<P) return 1;
  if(a[K]+M<a[P-1]) return 0;
  
  ll tot=(P-1)*M+(N-K)*M;
  for(ll i=P-1; i<K; i++) tot+=min(M, a[K]+M-a[i]);
  return tot>=M*V;
}


int main(void) {
  ll i, j, k;
  
  cin >> N >> M >> V >> P;
  
  for(i=0; i<N; i++) cin >> a[i];
  sort(a, a+N);
  reverse(a, a+N);
  
  ll l=-1, r=N;
  while(l+1<r) {
    ll m=(l+r)/2;
    if(ok(m)) l=m;
    else r=m;
  }
  
  pt(r);
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>

typedef long double ld;
typedef long long ll;

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec; }
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

int main()
{
  ll N, K, Q;
  std::cin >> N >> K >> Q;

  std::vector< ll > vp(N, K);
  std::map<ll, ll> mq;
  for (ll i = 0; i < Q; i++) {
    ll x;
    std::cin >> x;
    mq[x-1]++;
  }

  for (ll i = 0; i < N; i++) {
    std::string judge = "Yes";
    vp[i] += mq[i] - Q;
    if (vp[i] <= 0) judge = "No";
    print(judge);
  }

  return 0;
}


Measured memory_bytes: 7680
sub i{split/ /,<>;}@c=i;for($j=0;$j<$c[2];$j++){@d=i;$d[1]<=$d[0]?${$s[$d[1]]}[@{$s[$d[1]]}]=$d[0]:0;}$e=$c[0]+1;$f=1;for($j=1;$j<=$c[1];$j++){for(sort{$a<=>$b}@{$s[$j]}){$f++if$f==$_;$e=$_ if$f<$_&&$e>$_;}$f++;}print$e-1;

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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 1e5 + 5;
ll dp[N];
ll mod = 1e9 + 7;
ll binpow(ll x, ll p){
        if (p == 0) return 1;
        if (p == 1) return x;
        ll t = binpow(x, p/2) % mod;
        if (p % 2 == 0) return t * t % mod;
        else return t * t % mod * x % mod;
}
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (fopen("VLJUM.INP", "r")){
                freopen("VLJUM.INP", "r", stdin);
                freopen("VLJUM.OUT", "w", stdout);
        }
        ll n, k;
        cin >> n >> k;
        ll ans = 0;
        for (int i = k; i >= 1; i--){
                dp[i] = binpow(k / i, n) % mod;
                for (int j = i + i; j <= k; j += i){
                        dp[i] = (dp[i] - dp[j] + mod) % mod;
                }
                ans = (ans + dp[i] * i) % mod;
        }
        cout << ans;
}
/*
*/


Measured memory_bytes: 4420
def gcd(a, b):
  if b == 0:
    return a
  else:
    return(gcd(b, a % b))
  
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
  if i == 0:
    ans = A[i]
  else:
    ans = gcd(ans, A[i])
print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#define LL long long
#define pii pair<int, int>
#define MAXN ()
using namespace std;
int main()
{
	int d, n;
	scanf("%d%d", &d, &n);
	int st = (d == 1 ? 100 : 10000), ans = 0;
	if (!d)
		st = 1;
	for (int i = 1; i <= n; i++)
	{
		ans += st;
		while ((ans / st) % 100 == 0)
			ans += st;
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

A,B = inpl()
N = 1
ans = 0
while N < B:
    N += -1 + A
    ans += 1

print(ans)


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

int main(void)
{
    string s;

    cin >> s;

    int ans = 0;
    char nc = s[0];
    for(int i = 1; i < s.size(); ++i)
    {
        if(s[i] != nc)
        {
            ++ans;
            nc = s[i];
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 100000;
vector<int> G[N];
int n,k;

int sz[N],dp[N],ed[N];
int dfs(int x, int p)
{
    int ret = 0;

    sz[x] = 1;
    for(int nx:G[x])if(nx!=p)
    {
        ret = max(ret,dfs(nx,x));
        sz[x] += sz[nx];
    }
    if(sz[x]==1) dp[x] = -1;

    int ct = 0;
    for(int nx:G[x])if(nx!=p)
    {
        dp[x] = max(dp[x],dp[nx]);
        ed[x] = max(ed[x],ed[nx]);
        ct += (sz[nx]>=k);
    }
    ed[x] = max(ed[x],ct);

    int g0=-1, g1=-1;
    for(int nx:G[x])if(nx!=p)
    {
        int tmp = ct - (sz[nx]>=k);
        dp[x] = max(dp[x],ed[nx]+tmp);
        ed[x] = max(ed[x],ed[nx]+tmp);

        int tg = ed[nx]-(sz[nx]>=k);
        if(g1<tg) g1=tg;
        if(g0<g1) swap(g0,g1);
    }
    dp[x] = max(dp[x],ct+g0+g1);

    ret = max(ret,dp[x]+(n-sz[x]>=k));
    return ret;
}

int main()
{
    cin >>n >>k;
    rep(i,n-1)
    {
        int u,v;
        cin >>u >>v;
        --u; --v;
        G[u].pb(v);
        G[v].pb(u);
    }

    cout << dfs(0,-1) << endl;
    return 0;
}

Measured memory_bytes: 15856
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

const int MAX_N = 200005;

int n, m;
vector<int> g[MAX_N];
bool used[MAX_N];
int currCnt;

void dfs(int u)
{
	currCnt++;
	used[u] = true;
	for (int v : g[u])
		if (!used[v])
			dfs(v);
}

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

	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	int result = 0;
	for (int i = 0; i < n; i++)
		if (!used[i])
		{
			currCnt = 0;
			dfs(i);
			result = max(result, currCnt);
		}
	cout << result << '\n';

	return 0;
}

Measured memory_bytes: 24004
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    int A,B,M;
    cin>>A>>B>>M;
    int a[A],b[B],X[M],Y[M],C[M];
    for(int i=0;i<A;i++)    cin>>a[i];
    for(int i=0;i<B;i++)    cin>>b[i];
    for(int i=0;i<M;i++)    cin>>X[i]>>Y[i]>>C[i];
    
    int minimum = 200000;
    for(int i=0;i<M;i++){
        minimum = min(minimum, (a[X[i]-1]+b[Y[i]-1]-C[i]));
    }
    int A_min=100000;
    int B_min=100000;
    for(int i=0;i<A;i++){
        A_min = min(A_min, a[i]);
    }
    for(int i=0;i<B;i++){
        B_min = min(B_min, b[i]);
    }
    cout<<min(minimum, A_min+B_min);
    return 0;
}

Measured memory_bytes: 2176
n = int(input())
klist = list(map(int,input().split()))
plist = []
i = 0
k = 1
a = 2**i-1
while 1:
    if klist[a:a+2**i] != []:
        plist.append(klist[a:a + 2**i])
    else: break
    a += 2**i
    i += 1
for i in range(len(plist)):
    for j in range(len(plist[i])):
        try:
            if i==0:
                print("node "+str(k)+": key = "+str(plist[0][0])+
                      ", left key = "+str(plist[1][0])+
                      ", right key = "+str(plist[1][1])+", ")
            else :
                l = int(j/2)
                print("node "+str(k)+": key = "+str(plist[i][j])+
                      ", parent key = "+str(plist[i-1][l])+", left key = "+
                      str(plist[i+1][2*j]),end="")
                try:
                    print(", right key = "+str(plist[i+1][2*j+1])+", ")
                except:
                    print(", ")
        except:
            l = int(j/2)
            print("node "+str(k)+": key = "+str(plist[i][j])+
                  ", parent key = "+str(plist[i-1][l])+", ")
        k += 1


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;

vector<vector<int>> f(vector<int> a, vector<int> b) {
	int N = a.size();
	vector<vector<int>> c(N, vector<int>(N + 1));
	rep(x, N) rep(y, N) c[x][y + 1] = c[x][y] + (a[x] < b[y]);
	return c;
}

int main() {
	int N; cin >> N;
	vector<int> a(N), b(N);
	rep(t, N * 2) {
		string s; cin >> s;
		int i; cin >> i, i--;
		if (s == "W") a[i] = t;
		if (s == "B") b[i] = t;
	}
	vector<vector<int>> aa = f(a, a), ab = f(a, b), ba = f(b, a), bb = f(b, b);
	vector<vector<int>> dp(N + 1, vector<int>(N + 1, INT_MAX));
	dp[0][0] = 0;
	rep(x, N + 1) rep(y, N + 1) {
		if (x < N) dp[x + 1][y] = min(dp[x + 1][y], dp[x][y] + aa[x][x] + ab[x][y]);
		if (y < N) dp[x][y + 1] = min(dp[x][y + 1], dp[x][y] + bb[y][y] + ba[y][x]);
	}
	cout << dp[N][N] << endl;
}


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


using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for(auto &x: A) cin >> x;

	int a = -1, b = -1, c = -1;
	int an = 0, bn = 0, cn= 0;

	for(auto x: A) {
		if(x != a && x != b && x != c) {
			if(a == -1) a = x, an++;
			else if(b == -1) b = x, bn++;
			else if(x == (a ^ b)) c = x, cn++;
			else {
				cout << "No" << endl;
				return 0;
			}
		} else {
			if(x == a) an++;
			if(x == b) bn++;
			if(x == c) cn++;
		}
	}

	if((an == bn && bn == cn) || (c == -1 && (((a ^ a) == b && an == 2 * bn) ||((b ^ b) == a && 2 * an == bn))))
		cout << "Yes" << endl;
	else if(a == 0 && b == -1 && c == -1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


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

int main() { /* ここに書く */
  
  string S;
  int A;
  char X,add;
  add = '0';
  
  cin >> S;
  
  A = S.size();
  
  for(int i = 0; i<A ; i++){
    
    X = S.at(i);
    X = X - '0';
    add = add + X;
    
    if(add > '9'){
      add = add - '9';
      add = add + '0';
    }
    
  }
  
  if(add == '9' || add == '0'){ 
  cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3724
# https://atcoder.jp/contests/abc123/tasks/abc123_a


a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
k = gets.to_i

mi, mx = [a, b, c, d, e].minmax

puts mx - mi > k ? ':(' : 'Yay!'


Measured memory_bytes: 1788
import math
import sys
import numpy as np
a,b,h,m=map(int,input().split())
h=h*30+m*0.5
m=m*6
ma=max(h,m)
mi=min(h,m)
kakudo=abs(ma-mi)
if kakudo>180:
    kakudo=360-kakudo
elif kakudo == 0:
    print(abs(a-b))
    exit()
elif kakudo==180:
    print(a+b)
    exit()
#print(kakudo)
c=math.cos(math.radians(kakudo))
#print(c)
ans=math.pow(a,2)+math.pow(b,2)-2*a*b*c
ans=math.sqrt(ans)
print(ans)

Measured memory_bytes: 27116
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
#define ll long long
void test_case()
{
	int d, t, s;
	cin >> d >> t >> s;
	int t_t = 0;
	for (int i = 0; i < d; i += s, ++t_t);
	if (t_t <= t)
	{
		cout << "Yes";
	}
	else cout << "No";
}
int main()
{
	
	ios::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	test_case();
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const ll MOD = 1E9+7;
 
ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
const ll mod = 1e9 + 7;
int n;
ll a[100000+10];
ll fact[1010], fact_inv[1010], inv[1010];

long long mod_pow(long long x, long long n){
    if(n == 0) return 1;
    long long res = mod_pow(x * x % mod, n / 2);
    if(n & 1) res = res * x % mod;
    return res;
}

long long combination(long long n, long long k){
    return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod;
}

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

    sort(a, a+n);

    int cou = min(3, n/2), lc = n-1;
    ll mem;
        ll low = upper_bound(a, a+n, a[lc]/2) - a;
        if(low >= 1){
            if(abs((double)a[lc]/2 - a[low]) >= abs((double)a[lc]/2 - a[low-1])){
                low--;
            }
        }
        cout << a[n-1] << ' ' <<  a[low] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;
int n;
void dfs(string s, int x){
    if(s.size()==n){cout<<s<<endl;return;}
    for(int i=0; i<x; i++){
        dfs(s+char('a'+i),x);
    }
    dfs(s+char('a'+x),x+1);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    dfs("",0);
    return 0;
}

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

int main(){
	int N,i,mnum=0;
	long long minn=pow(10,9)+1;
	//vector<long long> minn;
	cin >> N;
	long long A[N],ans=0;
	for(i=0;i<N;i++){
		cin >> A[i];
	}
	for(i=0;i<N-1;i++){
		if(A[i]<0){
			A[i]=A[i]*-1;
			A[i+1]=A[i+1]*-1;
			//cout << A[i]<<  endl;
		}
		//cout << i << "回目A=" << abs(A[i]) << " minn=" << minn << " mnum=" << mnum << endl;
		if (minn>abs(A[i])){
          minn=A[i];mnum=i;
        }
	}
	if (minn>abs(A[N-1])) mnum=N-1;
		A[mnum]=A[mnum]*-1;
      	A[N-1]=A[N-1]*-1;
  	if (A[N-1]<0){
    	A[N-1]=A[N-1]*-1;
    	A[mnum]=A[mnum]*-1;
    }
	for(i=0;i<N;i++){
		ans+=A[i];
		//cout << A[i] << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = a - 1; i >= b; i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,K;
    cin >> N >> K;
    vP p(K);
    rep(i,K){
        cin >> p[i].first >> p[i].second;
        p[i].second++;
    }
    vl dp(N,0);
    vl acc(N,0);
    dp[0]=1;
    acc[0]=1;
    FOR(i,1,N){
        rep(j,K){
            if(i>=p[j].second){
                dp[i]+=acc[i-p[j].first]-acc[i-p[j].second];
            }
            else if(i>=p[j].first){
                dp[i]+=acc[i-p[j].first];
            }
            dp[i]%=MOD2;
        }
        acc[i]=acc[i-1]+dp[i];
        acc[i]%=MOD2;
    }
    /*rep(i,N){
        cout << i << ' ' << dp[i] << '\n';
    }*/
    cout << (dp[N-1]+MOD2)%MOD2 << '\n';
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 6336
#include <iostream>

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  int c[M+1];
  for (int i = 1; i < M+1; i++){
    c[i] = 0;
  }
  
  for (int i = 0; i < N; i++){
    int K;
    cin >> K;
    for (int j = 0; j < K; j++){
      int tmp;
      cin >> tmp;
      c[tmp]++;
    }
  }
  
  int ans = 0;
  for (int i = 1; i < M+1; i++){
    if (c[i]==N) ans++;
  }
  printf("%d\n",ans);
}


Measured memory_bytes: 3760
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;
typedef long long LL;
const int maxn = 5005;
const int maxm = 205;

int b[maxn][maxm];
int d[maxn],a[maxn],n,m,ord[maxn];
int l[maxn],r[maxn],cov[maxn];
LL f[maxn][maxn],s[maxn];

bool comp(int u,int v) {return a[u]<a[v];}
int main()
{
	#ifdef Amberframe
		freopen("arc067f.in","r",stdin);
		freopen("arc067f.out","w",stdout);
	#endif
	scanf("%d %d",&n,&m);
	for (int i=1;i<n;i++) scanf("%d",&d[i]);
	for (int i=1;i<=n;i++) ord[i]=i;
	for (int i=1;i<=n;i++) s[i+1]=s[i]+d[i];
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
		scanf("%d",&b[i][j]);
	for (int j=1;j<=m;j++)
	{
		for (int i=1;i<=n;i++)
			a[i]=b[i][j],cov[i]=0;
		sort(ord+1,ord+n+1,comp);
		for (int i=1;i<=n;i++)
		{
			int x=ord[i],L=x,R=x,w=a[x];cov[x]=true;
			if (cov[x-1])
				f[l[x-1]][x-1]-=w,L=l[x-1];
			if (cov[x+1])
				f[x+1][r[x+1]]-=w,R=r[x+1];
			r[L]=R;l[R]=L;f[L][R]+=w;
		}
	}
	for (int d=n-1;d>=0;d--)
	for (int l=1,r=1+d;r<=n;l++,r++)
		f[l][r]+=f[l-1][r]+f[l][r+1]-f[l-1][r+1];
	LL ans=0;
	for (int l=1;l<=n;l++)
	for (int r=l;r<=n;r++)
		ans=max(ans,f[l][r]-s[r]+s[l]);
	printf("%lld",ans);
	return 0;
}

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

int main (){
    string T;
    cin >> T;
    for( int i = 0; i < T.size(); i++){
        if(T.at(i) == '?'){
        cout << 'D' ;
        }
        else{
            cout << T.at(i) ;
        }
    }
    cout << endl;
    

}

Measured memory_bytes: 3724
dxy = zip([1,1,0,-1,-1,-1,0,1],[0,1,1,1,0,-1,-1,-1])
A = [list(raw_input()) for i in xrange(8)]
for i in xrange(64):
    hand = ["o","x"][i%2]
    d = [1,-1][i%2]
    mx,nd = 0,[]
    for y in range(8)[::d]:
        for x in range(8)[::d]:
            if A[y][x] == ".":
                tmp,td = 0,[]
                for dx,dy in dxy:
                    nx,ny = x+dx,y+dy
                    while 0 <= min(nx,ny) and max(nx,ny) < 8:
                        if   A[ny][nx] == hand:
                            get = max(abs(nx-x),abs(ny-y))-1
                            if get > 0:
                                tmp += get
                                td.append([dx,dy])
                            break
                        elif A[ny][nx] == ".":
                            break
                        nx += dx; ny += dy
                if tmp > mx:
                    mx,nd = tmp,td
                    px,py = x,y
    if mx == 0: continue
    A[py][px] = hand
    for dx,dy in nd:
        nx,ny = px+dx,py+dy
        while 0 <= min(nx,ny) and max(nx,ny) < 8:
            if A[ny][nx] == hand: break
            A[ny][nx] = hand
            nx += dx; ny += dy
for a in A:
    print "".join(a)

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

int main(){
  char s[10];cin>>s;
  int sum=0,mx=0;
  rep(i,10){
    if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')sum++;
    else sum=0;
    mx=max(mx,sum);
  }
  cout<<mx;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
//#include "debug.cpp"
const int inf=1e9;
int32_t main()
{
	boost;
	int n,d,s;
	cin>>n>>d>>s;
	vector<PI>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i].ff>>a[i].ss;
	}

	sort(a.begin(),a.end());
	int ans=0;
	int dp[n+1]={0};
	for(int i=0;i<n;i++){
		if(i>0)
			dp[i]+=dp[i-1];
		a[i].ss-=dp[i]*s;
		//cout<<a[i].ss<<" "<<dp[i]<<endl;
		if(a[i].ss<=0)
			continue;
		int c=a[i].ss/s;
		if(a[i].ss%s!=0)
			c++;
		dp[i]+=c;
		int l=i,r=n-1,aa=i;
		while(l<=r){
			int m=(l+r)/2;
			if(a[m].ff<=a[i].ff+2*d){
				l=m+1;
				aa=m;
			}
			else
				r=m-1;
		}
		//cout<<aa<<endl;
		dp[aa+1]-=c;
		ans+=c;
	}
	cout<<ans<<endl;
}


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

int main(){
    int n;
    cin >> n;
    int t[n+1],x[n+1],y[n+1];
    t[0]=x[0]=y[0]=0;
    for(int i=1;i<n+1;i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    for(int i=1;i<n+1;i++){
        int td=t[i]-t[i-1];
        if(td<(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))){
            cout << "No" << endl;
            return 0;
        }else if(td%2!=(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
static int[] segttt = new int[(1<<21)];
static int segkkk = 0;
static int seglll = 0;
static int segrrr = (1<<20);
static int[] segValue = new int[800005];

static void Main()
{    
  string[] input = Console.ReadLine().Split(' ');
	int n = int.Parse(input[0]);
	int q = int.Parse(input[1]);
  segValue[0] = 2147483647;//初期化
  for(int i = 1; i <= q; i++)
  {
    int[] inputa = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    if(inputa[0] == 0)
    {
      segValue[i] = inputa[3];
      AreaChangePointGetSeg(inputa[1], inputa[2], i);
    }else
    {
      int answer = AreaChangePointGetSegAnswer(inputa[1]);
      Console.WriteLine(segValue[answer]);
    }
  }
}

static void AreaChangePointGetSeg(int a, int b, int x)
{
  AreaChangePointGetSegSub(a,b+1,x,segkkk,seglll,segrrr);
}
  
static void AreaChangePointGetSegSub(int a, int b, int x, int segkkk, int seglll, int segrrr)
{//区間以上以下の値を全てchangeNumに変更し、ある１点の値を求める。入力側
  if(b <= seglll || segrrr <= a)
  {
    b = b;
  }
  else if(a <= seglll && segrrr <= b)
  {
    segttt[segkkk] = Math.Max(segttt[segkkk],x);
  }else
  {
    int m = (seglll+segrrr)/2;
    AreaChangePointGetSegSub(a, b, x, segkkk*2+1, seglll, m);
    AreaChangePointGetSegSub(a, b, x, segkkk*2+2, m, segrrr);
  }
}
  
static int AreaChangePointGetSegAnswer(int i)
{//区間以上以下の値を全てchangeNumに変更し、ある１点の値を求める。出力側。
  i += (1<<20)-1;
  int res = segttt[i];
  while(i != 0)
  {
    i = (i-1)/2;
    res = Math.Max(res,segttt[i]);
  }
  return res;
}

}


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

using namespace std;

constexpr int MAX = 100;

char s[MAX + 2];
char t[MAX + 2];
char u[MAX + 2];
map<string, int> freq;

int main() {
	int a, b;

	scanf(" %s %s", s, t);
	scanf("%d%d", &a, &b);
	freq[string(s)] = a;
	freq[string(t)] = b;

	scanf(" %s", u);
	freq[string(u)]--;

	printf("%d %d\n", freq[string(s)], freq[string(t)]);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define last Last
#define int long long
const int N=1e6+5;
int n,a[N],sum[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
signed main()
{
    n=read();
    for(int i=1;i<=n;i++)a[read()]++;
    sort(a+1,a+n+1);
//    cout<<a[1]<<" "<<a[2]<<" "<<a[3]<<endl;
    for(int i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];
    for(int i=1;i<=n;i++)
    {
        int l=0,r=n/i;
        while(l<r)
        {
            int mid=(l+r+1)/2;
            if(mid>a[n])
            {
                if(i*mid<=sum[n])l=mid;
                else r=mid-1;
            }
            else{
                int x=lower_bound(a+1,a+n+1,mid)-a;
                x--;
                if(mid*(i-(n-x))<=sum[x])l=mid;
                else r=mid-1;
            }
        }
        printf("%lld\n",l);
    }
}

Measured memory_bytes: 9088
import java.util.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun main() {
	abc000X()
}

fun abc000X() {
	val day = int()
	val penalty = list().toIntArray()
	val advantage = Array(day) {list().toIntArray()}

	val last = Array(26) {TreeSet<Int>()}
	last.forEach {it.add(-1)}

	var r = 0L
	for(d in 0 until day) {
		val t = (0..25).maxBy {
			advantage[d][it]+penalty[it]*(d-last[it].last())
		}!!
		last[t].add(d)
		r += advantage[d][t]

		for(i in 0..25)
			r -= penalty[i]*(d-last[i].last())
		println(t+1)
	}
	System.err.println(r)
}


Measured memory_bytes: 40436
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    dp = [0] * (N+1)
    for i in range(1, N+1):
        gold, silver, copper = 0, 0, 0
        if i >= A[0]:
            gold = dp[i-A[0]] + B[0]
        if i >= A[1]:
            silver = dp[i-A[1]] + B[1]
        if i >= A[2]:
            copper = dp[i-A[2]] + B[2]
        dp[i] = max(i, gold, silver, copper)

    M = dp[N]
    dp = [0] * (M+1)
    for i in range(1, M+1):
        gold, silver, copper = 0, 0, 0
        if i >= B[0]:
            gold = dp[i-B[0]] + A[0]
        if i >= B[1]:
            silver = dp[i-B[1]] + A[1]
        if i >= B[2]:
            copper = dp[i-B[2]] + A[2]
        dp[i] = max(i, gold, silver, copper)

    return dp[M]


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 230168
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define REP(i,m,n) for(int i=(m); i<(n); i++)
#define RREP(i,n,m) for(int i=(n);i>=(m); i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int sum = 0;
    REP(i,0,m)
    {
        int tmp;
        cin >> tmp;
        sum += tmp;
    }
    if(sum>n) cout << -1 << endl;
    else cout << n-sum << endl;
    return 0;
}



Measured memory_bytes: 3640
INF = 10 ** 20

def search(rest, now, goal, dp, edges):
  if now == goal:
    return 0
  if rest == ():
    if now == goal:
      return 0
    else:
      return INF

  if (rest, now) in dp:
    return dp[(rest, now)]

  ret = INF
  for i, t in enumerate(rest):
    for dist, to in edges[now]:
      ret = min(ret, search(tuple(v for j, v in enumerate(rest) if i != j), to, goal, dp, edges) + dist / t)
  dp[(rest, now)] = ret
  return ret

def main():
  while True:
    n, m, p, a, b = map(int, input().split())
    if n == 0:
      break
    a -= 1
    b -= 1
    tlst = list(map(int, input().split()))
    edges = [[] for _ in range(m)]
    for _ in range(p):
      x, y, z = map(int, input().split())
      x -= 1
      y -= 1
      edges[x].append((z, y))
      edges[y].append((z, x))
    tlst.sort()
    rest = tuple(tlst)
    dp = {}
    ans = search(rest, a, b, dp, edges)
    if ans == INF:
      print("Impossible")
    else:
      print(ans)
main()   


Measured memory_bytes: 7516
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.HashSet;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Double A=sc.nextDouble();
    Double B=sc.nextDouble();
    Double H=sc.nextDouble();
    Double M=sc.nextDouble();
    Double kakudo=Math.abs(H*30+30*(M/60)-M*6);
    if(kakudo>360-kakudo){
      kakudo=360-kakudo;
    }


    System.out.println(Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(kakudo))));

  }
}


Measured memory_bytes: 37368
def calc(x,y):
    z = x+y
    b.append(z)
    return z
from functools import reduce
import numpy as np
N = int(input())
a = list(map(int, input().split()))
s = sum(a)
b = [a[0]]
reduce(calc ,a)
print(min(abs(2 * np.array(b[0:N-1]) -s )))

Measured memory_bytes: 33024
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;

int main(void){
    string a,b;
    cin>>a>>b;
    int c;
    c = pow(stoi(a+b),0.5);
    cout<<((c*c == stoi(a+b))?"Yes":"No")<<endl;

}

Measured memory_bytes: 384
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Float x[] = new Float[N];
    String u[] = new String[N];
    for (int i = 0; i < N; i++) {
      x[i] = sc.nextFloat();
      u[i] = sc.next();
    }
    float ans = 0;
    for (int i = 0; i < N; i++) {
      if (u[i].equals("BTC")) {
        ans += x[i] * 380000.0000;
      }
      ans += x[i];
    }
    System.out.println(ans);
  }
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<long long> anss;
  long long ans = 0;
  map<int,int> mp;

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

  int q;
  cin >> q;
  for (int i = 0; i < q; i++)
  {
    int b,c;
    cin >> b >> c;
    long long sub = c-b;
    sub*=mp[b];
    ans+=sub;
    mp[c]+=mp[b];
    mp[b]=0;
    anss.push_back(ans);
  }
  for(long long an:anss){
    cout << an << endl;
  }
}

Measured memory_bytes: 8700
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M, K = (int(i) for i in input().split())
    par = [i for i in range(N)]
    rank = [0 for i in range(N)]

    def find_root(x):
        if par[x] == x:
            return x
        else:
            par[x] = find_root(par[x])
            return par[x]

    def is_same_group(x, y):
        return find_root(x) == find_root(y)

    def unite(x, y):
        x = find_root(x)
        y = find_root(y)
        if x == y:
            return
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1
    edge = [set() for _ in range(N)]
    for i in [0]*M:
        a, b = (int(i) for i in input().split())
        edge[a-1].add(b-1)
        edge[b-1].add(a-1)
        unite(a-1, b-1)
    from collections import Counter
    for i, x in enumerate(par):
        unite(i, x)
    c = Counter(par)  # 頂点iの連結成分のサイズ
    for i in [0]*K:
        a, b = (int(i) for i in input().split())
        if is_same_group(a-1, b-1):
            edge[a-1].add(b-1)
            edge[b-1].add(a-1)
    for i in range(N):
        cur = c[par[i]] - len(edge[i]) - 1
        print(cur, end=" ")
    print()


if __name__ == '__main__':
    main()


Measured memory_bytes: 117792
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll getmin(ll i,vector<ll> &v,ll n,vector<ll> &dp)
{
    if(i==n-1)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    ll l=INT_MAX,r=INT_MAX;
    if(i+2 < n)
        l = abs(v[i+2]-v[i]) + getmin(i+2,v,n,dp);
    if(i+1 < n)
		r = abs(v[i+1]-v[i]) + getmin(i+1,v,n,dp);
    
    return dp[i]=min(l,r);
}

int main()
{
  ll n,i,tmp;
  cin>>n;
  vector<ll> v;
  for(i=0;i<n;i++)
  {
    cin>>tmp;
    v.pb(tmp);
  }
  vector<ll> dp(n,-1);
  cout<<getmin(0,v,n,dp)<<"\n";
  return 0;
}

Measured memory_bytes: 8004
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <iomanip>
#define ll long long
using namespace std;

int main(void){
    ll h, w;
    cin >> h >> w;
    ll a[10][10], b[h][w];
    for(ll i = 0; i < 10; i++)
        for(ll j = 0; j < 10; j++)
            cin >> a[i][j];
    for(ll i = 0; i < h; i++)
        for(ll j = 0; j < w; j++)
            cin >> b[i][j];
    for(ll k = 0; k < 10; k++){
        for(ll i = 0; i < 10; i++){
            for(ll j = 0; j < 10; j++){
                a[i][j] = min(a[i][j], a[i][k]+a[k][j]);
            }
        }
    }
    ll ans = 0;
    for(ll i = 0; i < h; i++){
        for(ll j = 0; j < w; j++){
            if(b[i][j]!=-1){
                ll check = b[i][j];
                ans+=a[check][1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
    int n;
    long long a;
    long long minValue=1000000;
    long long maxValue=-1000000;
    long long sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a<minValue)minValue=a;
        if(a>maxValue)maxValue=a;
        sum+=a;
    }
    cout<<minValue<<" "<<maxValue<<" "<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll MOD = 1000000007;

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double minutes = double(M) / 60;
    double hour = double(60 * H + M) / (12 * 60);
    printf("%.12f\n", sqrt(A * A + B * B - 2 * A * B * cos(abs(minutes - hour) * 2 * M_PI)));
    return 0;
}

Measured memory_bytes: 4136
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};

/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/


int main(){
    string sa,sb,sc; cin >> sa >> sb >> sc;
    int ia = 0,ib = 0,ic = 0,na = sa.size(),nb = sb.size(), nc = sc.size();
    int st = 0;
    while(true){
        if (st == 0){
            if (ia == na){
                cout << 'A' << endl;
                return 0;
            }
            if (sa[ia] == 'b'){
                st = 1;
            } else if (sa[ia] == 'c'){
                st = 2;
            }
            ia++;
        } else if (st == 1){
            if (ib == nb){
                cout << 'B' << endl;
                return 0;
            }
            if (sb[ib] == 'a'){
                st = 0;
            } else if (sb[ib] == 'c'){
                st = 2;
            }
            ib++;
        } else if (st == 2){
            if (ic == nc){
                cout << 'C' << endl;
                return 0;
            }
            if (sc[ic] == 'a'){
                st = 0;
            } else if (sc[ic] == 'b'){
                st = 1;
            }
            ic++;
        }
    }
}

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

#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)

using ll = long long;
#define INF 1e9

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

  ll cnta, cntb;
  cnta = (a-1)/x;
  cntb = b/x;
  if(a == 0){
    cnta = 0;
    cntb++;
  }
  cout << cntb - cnta << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int G[100][100],d[100],v[100];
int getMST(int);

int main(){
  int n,i,j;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&G[i][j]);
    }
  }
  printf("%d\n",getMST(n));

  return 0;
}

int getMST(int n){
  int i,j,k=1,min,minp,sum=0;
  
  d[0]=0;
  v[0]=1;

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

  while(1){
    min = 2001;
    for(i=0;i<k;i++){
      for(j=0;j<n;j++){
	if(G[d[i]][j]<min && G[d[i]][j] != -1 && v[j] != 1){
	  min = G[d[i]][j];
	  minp = j;
	}
      }
    }
    
    if(k==n) break;
    d[k] = minp;
    v[minp] = 1;
    sum += min;
    k++;
  }

  return sum;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){

int N, x, i, a[100], k, j, c;

scanf("%d %d", &N, &x);
for(i=0; i<N; i++){
 scanf("%d", &a[i]);
}

for(i=0; i<N; i++){
for(j=N-1; j>i; j--){
 if(a[j]<a[j-1]){
  k=a[j];
  a[j]=a[j-1];
  a[j-1]=k;
 }
}
}

c=0;
k=x;
for(i=0; i<N; i++){
 if(k>=a[i]){
  if(k==a[i]){
   c++;
   break;
  }
  else if(k>a[i]&&i<N-1)
   c++;

  else
   break;
 }
 else
  break;

 k=k-a[i];
}

printf("%d\n", c);


return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[7],b[7];
int degree[7];
int main(){
    for(int i=1;i<=3;i++){
        scanf("%d%d",&a[i],&b[i]);
        degree[a[i]]++;
        degree[b[i]]++;
    }
    for(int i=1;i<=4;i++){
        if(degree[i]>=3){
            printf("NO");
            return 0;
        }
    }
    printf("YES");
	return 0;
}


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

int main() {
    list<int> v;
    list<int>::iterator itr = v.end();
    int n, q;

    cin >> n;
    //auto itr = v.end();
    for(int i = 0; i < n; i++){
        cin >> q;
        int x;
        
        //vector<int>::iterator itr = v.end();
        if(q == 0){
            cin >> x;
            itr=v.insert(itr, x);
        }
        else if(q == 1){
            cin >> x;
            if(x < 0){
                for(int j = 0; j < abs(x); j++){
                    itr--;
                }
            }
            else {
                for(int j = 0; j < x; j++){
                    itr++;
                }
            }
        }
        else {
            itr = v.erase(itr);
        }
        
    }

    for(itr = v.begin(); itr != v.end(); itr++){
        cout << *itr << endl;
    }
    return 0;
}



Measured memory_bytes: 18640