akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  ll r;
  cin >> r;
  if (2800 <= r)
    cout << "AGC" << endl;
  else if (1200 <= r)
    cout << "ARC" << endl;
  else
    cout << "ABC" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>

int main() {
	int n, a[100000];
	std::cin >> n;
	for (int i = 0;i < n;i++) {
		std::cin >> a[i];
	}
	std::sort(a, a + n);
	int ans = 0;
	for (int i = 0;i < n;i++) {
		if (a[i] <= 100000) {
			int sum = 0;
			for (int j = i+1;j < n+1;j++) {
				sum += 1;
				if (a[i] != a[j])
					break;
			}
			if (sum < a[i])
				ans += sum;
			else if (sum > a[i])
				ans += sum - a[i];
			i += sum-1;
		}
		else {
			ans += 1;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
    int a;
    int b;
    
    scanf("%d %d", &a, &b);
    
    if(a > b){
        printf("a > b\n");
    }else if(a < b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
        
    }
    
    return 0;
}


Measured memory_bytes: 2052
import java.util.Scanner;
// import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String[] scan = scanner.nextLine().split(" ");
		scanner.close();
		int a = Integer.parseInt(scan[0]);
		int b = Integer.parseInt(scan[1]);

		int count = 0;
		if(a <= b) count++;
		count += a - 1;
		System.out.println(count);
	}
}


Measured memory_bytes: 19796
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c, d);
    Cout(a*b);
}

Measured memory_bytes: 3636
Q, H, S, D = map(int, input().split())
N = int(input())
r = 0
if D*1<=Q*8 and D*1<=H*4 and D*1<=S*2:
    r += (N//2)*D
    N = N % 2

if S*2 <= H*4 and S*2 <= Q*8:
    r += N*S
    N = 0
if H*4 <= S*2 and H*4 <= Q*8:
    r += N*H*2
    N = 0
if Q*8 <= S*2 and Q*8 <= H*4:
    r += N*Q*4
    N = 0

print(r)


Measured memory_bytes: 9236
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
    ll n;cin>>n;
    vector<ll>arr(n),brr(n); 
    rep(i,0,n)cin>>arr[i]>>brr[i];
    sort(arr.begin(),arr.end());
    sort(brr.begin(),brr.end());
    //rep(i,0,n)cout<<brr[i]<<" ";
    if(n%2==1)
    cout<<brr[(n-1)/2]-arr[(n-1)/2]+1;
    else {
       cout<< brr[(n-1)/2]+brr[n/2]-arr[(n-1)/2]-arr[n/2]+1;
    }
 
return 0;
}

Measured memory_bytes: 6376
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<int>A(3);
  for(int i=0;i<3;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  cout<<A.at(2)-A.at(0)<<endl;
  return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();
		String t = br.readLine();

		int len = s.length();
		int count=0;
		for (int i = 0; i < len; i++) {
			if (t.charAt(i) == s.charAt(i)) {
				continue;
			}else {
				char temp='0';
				char tchar=t.charAt(i);
				t=t.replace(t.charAt(i), temp);
				t=t.replace(s.charAt(i), tchar);
				t=t.replace(temp, s.charAt(i));
				if(++count > 26) {
					break;
				}
			}
		}

		if (s.equals(t)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 46264
/*
      THINK  TWICE  CODE  ONCE
        KEEP   GOING   BI*CH
           NEVER GIVE UP
               3 R B
                . .
                 .
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define pb push_back
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-14;
const ll MOD = 1e9+7;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    int n;
    cin>>n;
    set<string>st;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        st.insert(s);
    }
    cout<<st.size();
}


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

const int SIZE=2000010;
template<typename T> class PriorityQueue
{
 private:
    T heap[SIZE];
    int sz;
 public:
    PriorityQueue():sz(0){};
    void push(T val){
        heap[sz++]=val;
        for(int i=sz-1;i>0;){
            int par=(i-1)/2;
            if(heap[par]>=heap[i]) break;
            swap(heap[i],heap[par]);
            i=par;
        }
    }
    void pop(){
        heap[0]=heap[--sz];
        for(int i=0;2*i+1<sz;){
            int chi=2*i+1;
            if(chi+1<sz and heap[chi+1]>heap[chi]) chi++;
            if(heap[i]>=heap[chi]) break;
            swap(heap[i],heap[chi]);
            i=chi;
        }
    }
    T top(){return heap[0];}
    bool empty(){return sz==0;}
};

int main()
{
    PriorityQueue<int> Q;
    string s;
    while(cin>>s,s!="end"){
        if(s=="insert"){
            int x; cin>>x;
            Q.push(x);
        }else{
            cout<<Q.top()<<endl;
            Q.pop();
        }
    }
    return 0;
}


Measured memory_bytes: 6964
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX = 200000;

int main()
{
	int n, R[MAX];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> R[i];
	}
	int maxv = R[1] - R[0];
	int minv = R[0];
	for (int i = 1; i < n; i++)
	{
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	cout << maxv << endl;
//	system("pause");
	return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		ans += !(a % 2);
	}
	cout << ans << endl;
	
	return 0;	
}



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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  if (N % 2 == 0) return Pow(A * A % MOD, N / 2);
  return Pow(A * A % MOD, N / 2) * A % MOD;
}

ll N, M;
ll fac[int(5e5+5)], rev[int(5e5+5)];
ll nCi[int(5e5+5)], mCi[int(5e5+5)];
ll DP[int(5e5+5)];

int main(){
  cin >> N >> M;
  fac[0] = 1; rev[0] = 1;
  for (ll i = 1; i <= M; i++){
    fac[i] = fac[i-1] * i % MOD;
    rev[i] = Pow(fac[i], MOD - 2);
  }

  for (ll i = 0; i <= N; i++){
    nCi[i] = fac[N] * rev[N-i] % MOD;
    nCi[i] *= rev[i]; nCi[i] %= MOD;

    mCi[i] = fac[M] * rev[M-i] % MOD;
    mCi[i] *= rev[i]; mCi[i] %= MOD;
  }

  for (ll i = 0; i <= N; i++){
    DP[i] = nCi[i] * mCi[i] % MOD;
    DP[i] *= Pow(fac[M-i]*rev[M-N]%MOD, 2);
    DP[i] %= MOD;
    DP[i] *= fac[i]; DP[i] %= MOD;
  }

  ll ans = 0;
  for (int i = 0; i <= N; i++){
    if (i % 2 == 0) ans += DP[i];
    else ans -= DP[i];
    ans %= MOD;
  }
  if (ans < 0) ans += MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 22944
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;

int main() {
	long long n;
	long long years;
	long long money = 100;
	cin >> n;
	for (int i = 0;;i++) {
		money += money * 0.01;
		if (money >= n) {
			years = i + 1;
			break;
		}
	}
	cout << years << endl;

	return 0;
}

Measured memory_bytes: 3624
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Long> numberInfo = new ArrayList<Long>();
		for(int i =0;i <n;i++) {
			if(i ==0) {
				numberInfo.add(sc.nextLong());
				continue;
			}
			numberInfo.add(numberInfo.get(i-1) + sc.nextLong());
		}
		long answer = Long.MAX_VALUE;
		for(int i=0;i <n-1;i++) {
			long sunuke = numberInfo.get(i);
			long arai =  numberInfo.get(numberInfo.size()-1) -sunuke;
			long xy = Math.abs(sunuke-arai);
			if(answer >xy) {
				answer = xy;
			}
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 88348
import sys
from math import ceil
RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
 
# for i in range(int(ri())):
n,m = RI()
a = RI()
summ = sum(a)
cnt = ceil(summ/(4*m))
tot = 0
for i in range(len(a)):
    if a[i] >= cnt:
        tot+=1
if tot >= m:
    Yes()
else:
    No()

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cctype>
using namespace std;
int main()
{
	int n,l,r,ans=0,i;
	cin>>n;
	for(i=1;i<=n;i++){cin>>l>>r;ans+=r-l+1;}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

bool match(const string s, const string t, unsigned int begin, unsigned int end)
{
	for (unsigned int i = begin; i < end; ++i) {
		if (s[i] != t[i - begin]) {
			return false;
		}
	}
	return true;
}

int main(int argc, char * argv[])
{
	unsigned int n = 0;
	while (cin >> n) {
		string s;
		string t;
		cin >> s >> t;

		unsigned int c = n;
		for (unsigned int i = 0; i < n; ++i) {
			if (match(s, t, i, n)) {
				break;
			}
			else {
				c--;
			}
		}
		cout << 2 * n - c << endl;
	}
	return 0;
}

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

typedef long long ll;

int main() {
  int A, B;
  cin >> A >> B;
  bool f=false;
  if(A%2==0 || B%2==0) f=false;
  else f=true;

  cout << (f?"Yes":"No") << endl;
}

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

using namespace std;

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

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

	int N, M; cin >> N >> M;
	vector<string> A(N, string(N, '.'));
	vector<string> B(M, string(M, '.'));

	rep (i, N) cin >> A[i];
	rep (j, M) cin >> B[j];

	bool match = false;
	for (int i = 0; i < N - M + 1; ++i){
		for (int j = 0; j < N - M + 1; ++j){
			bool curr = true;
//			cerr << i << " rows: " << j << " cols:" << endl;
			for (int k = 0; k < M; ++k){
				for (int l = 0; l < M; ++l){ 
					if (A[i+k][j+l] != B[k][l]){
						curr = false;
						break;
					} // end if
				} // end for
				if (!curr) break;
			} // end for
			match |= curr;
		} // end for
	} // end for

	cout << (match ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define MID ((l+r)>>1)
#define lc (rt<<1)
#define rc (rt<<1|1)
#define ls lc,l,MID
#define rs rc,MID+1,r
#define st 1,1,n
#define PII pair<int,int>
#define PLL pair<LL,LL>
using namespace std;
//LL pw(LL a, LL b,LL M) { return b ? b & 1 ? a*pw(a, b - 1,M) % M : pw(a*a%M, b>>1,M) : 1; }
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
const int N=1e5+1;
const LL M=1e18;
int main(){Accel
	int n,x;
	cin>>n;
	set<int>s;
	REP(i,n)cin>>x,s.insert(x);
	cout<<s.size()<<endl;
	
	
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b;
    
    scanf("%d %d",&a,&b);
    
    if(a > b){
        printf("a > b\n");
    }else if(a < b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
    
    return 0;
}


Measured memory_bytes: 2600
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;

	int ss = s.size();
	int ts = t.size();

	int ans = 1000;
	for (int i = 0; i < ss - ts + 1; ++i) {
		int cnt = ts;
		for (int j = 0; j < ts; ++j) {
			if (s[i + j] == t[j]) {
				--cnt;
			}
		}
		ans = min(ans, cnt);
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
inline int min(int a,int b){return a<b?a:b;}
int n,m,cnt,ans;
int dfn[100005];
vector<int>G[100005];
int Tarjan(int u,int fa){
    int child=0,lowu;
    lowu=dfn[u]=++cnt;
    for(int i=0,v;i<G[u].size();i++){
        v=G[u][i];
        if(v!=fa){
            if(!dfn[v]){
                child++;
                int lowv=Tarjan(v,u);
                lowu=min(lowu,lowv);
                if(lowv>dfn[u])
                    ans++;
            }
            else
                lowu=min(lowu,dfn[v]);
        }
    }
    return lowu;
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0,u,v;i<m;i++){
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for(int i=1;i<=n;i++) 
        if(!dfn[i])
            Tarjan(i,-1);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

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

		int n = sc.nextInt(), m = sc.nextInt();

		String[] ga = new String[n];
		String[] gb = new String[m];

		sc.nextLine();

		for (int i = 0; i < n; ++i)
		{
			ga[i] = sc.nextLine();
		}

		for (int i = 0; i < m; ++i)
		{
			gb[i] = sc.nextLine();
		}

		sc.close();

		boolean flag = true;

		// たて(始点)
		for (int i = 0; i <= n - m; ++i)
		{
			// よこ
			for (int j = 0; j <= n - m; ++ j)
			{
				// mのループ
				// 盾
				for (int k = 0; k < m; ++k)
				{
					if (! ga[i + k].substring(j, j + m).equals(gb[k]))
					{
						flag = false;

						break;
					}
				}

				if (flag)
				{
					System.out.println("Yes");
					return;
				}

				flag = true;
			}
		}

		System.out.println("No");
	}
}


Measured memory_bytes: 21972
D,N=[int(i) for i in input().split()]
if N==100:
    if D==0:
        print(N+1)
    elif D==1:
        print(100**2+100)
    else:
        print(100**3+100**2)

else:
    if D==0:
        print(N)
    else:
        print(100**D*N)

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n,m; cin>>n>>m;
  priority_queue<int> q;
  rep(i,n){
    int a; cin>>a;
    q.push(a);
  }
  rep(i,m){
    int b = q.top(); q.pop();
    q.push(b/2);
  }
  ll ans = 0;
  rep(i,n){
    ans += q.top(); q.pop();
  }
  cout << ans << endl;




  return 0;
}


Measured memory_bytes: 892
unittest
{
	assert( [ "1000" ].parse.expand.solve == "ABC" );
	assert( [ "2000" ].parse.expand.solve == "ARC" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto x = input.front.to!( long );
	return tuple( x );
}

auto solve( long x )
{
	return ( x < 1200 ) ? "ABC" : "ARC";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	for (int a = 0; a <= n; ++ a) {
		for (int b = 0 ; b <= m; ++ b) {
			if (a * b + (n - a) * (m - b) == k) {
				return 0 * puts("Yes");
			}
		}
	}
	puts("No");
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
int a[MAXN];
bool vis[MAXN];

int main() {

    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int cnt=0,pre=-1;
        memset(vis,false,sizeof(vis));
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            if(a[i]==i) cnt++,vis[i]=true;
        }
        int ans=0;
        bool flag=false;
        for(int i=1;i<n;i++)
        {
            if(vis[i]&&vis[i+1]) {ans++;if(i==n-1) flag=true;i=i+1;}
            else if(vis[i]) ans++;
        }
        if(!flag&&vis[n]) ans++;
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 768
package main

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

func main() {

	sc := NewScanner()
	N, M := sc.NextInt(), sc.NextInt()
	edge := make([][]int, N+1)
	for i := 1; i < N; i++ {
		edge[i] = make([]int, 0)
	}
	for i := 0; i < M; i++ {
		A, B := sc.NextInt(), sc.NextInt()
		edge[A] = append(edge[A], B)
		edge[B] = append(edge[B], A)
	}

	short := make([]int, N+1)
	queue := make([]int, 1)
	short[1] = 1
	queue[0] = 1
	for {
		current := 0
		nextQueue := make([]int, 0)
		for len(queue) > current {
			c := queue[current]
			for _, v := range edge[c] {
				if short[v] > 0 {
					continue
				}
				short[v] = c
				nextQueue = append(nextQueue, v)
			}
			current++
		}
		queue = nextQueue
		if len(nextQueue) == 0 {
			break
		}
	}
	fmt.Println("Yes")
	for i := 2; i < N+1; i++ {
		fmt.Println(short[i])
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 19648
#include<bits/stdc++.h>
using namespace std;
long long int binomialCoeff(int n, int k) 
{ 
    long long int C[n + 1][k + 1]; 
    int i, j; 
  
    // Caculate value of Binomial Coefficient 
    // in bottom up manner 
    for (i = 0; i <= n; i++) 
    { 
        for (j = 0; j <= min(i, k); j++) 
        { 
            // Base Cases 
            if (j == 0 || j == i) 
                C[i][j] = 1; 
  
            // Calculate value using previously 
            // stored values 
            else
                C[i][j] = C[i - 1][j - 1] + 
                          C[i - 1][j]; 
        } 
    } 
  
    return C[n][k]; 
} 
int main()
{int n,m;
cin>>n>>m;
long long ans=0;
if(n<=1 and m>1)
ans=binomialCoeff(m,2);
else if(n<=1 and m<=1)
ans=0;
else if(n>1 and m>1)
ans=binomialCoeff(n,2)+binomialCoeff(m,2);
else
{
  ans=binomialCoeff(n,2);
}
cout<<ans;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <climits>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int l[200001];
int r[200001];
int main() {
    int N;
    string S;
    cin >> N >> S;
    l[0] = 0;
    r[N] = 0;
    for (int i = 1; i < N+1; i++) {
        l[i] = l[i-1] + (S[i-1] == '#');
        r[N-i] = r[N-i+1] + (S[N-i] == '.');
    }
    int m = N;
    REP(i, N+1) {
        m = min(m, l[i] + r[i]);
    }
    cout << m << endl;
}


Measured memory_bytes: 2180
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>

using namespace std;

const int INF=1000000000;

int mincost;
bool usable[1100];
int N;

void dfs(int nowNum,int ccost,int maxv){
  if(ccost>=mincost)return;
  else if(nowNum==N){
    mincost=ccost;
    return;
  }
  else if(1024<nowNum)return;
  int cnt=0;
  int tmp=nowNum;
  while(tmp<N){
    cnt++;
    tmp*=2;
  }
  if(cnt+ccost>=mincost)return;
  for(int i=1;i<=maxv;i++){
    if(nowNum+i>=1024&&nowNum-i<=1)break;
    if(usable[i]){
      int nxtNum=nowNum+i;
      if(nxtNum<=1024&&!usable[nxtNum]){
	usable[nxtNum]=true;
	dfs(nxtNum,ccost+1,max(nxtNum,maxv));
	usable[nxtNum]=false;
      }
      nxtNum=nowNum-i;
      if(nxtNum>=2&&!usable[nxtNum]){
	usable[nxtNum]=true;
	dfs(nxtNum,ccost+1,max(nxtNum,maxv));
	usable[nxtNum]=false;
      }
    }
  }
}

int main(){
  while(cin>>N&&N){
    memset(usable,0,sizeof(usable));
    usable[1]=true;
    int popCnt=0;
    int maxBitPos=0;
    for(int i=0;i<12;i++){
      if((N>>i)&1){
	popCnt++;
	maxBitPos=i;
      }
    }
    // initialized with upper bound value
    mincost=maxBitPos+popCnt-1;
    dfs(1,0,1);
    cout<<mincost<<endl;
  }
  return 0;
}

Measured memory_bytes: 864
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
	
	private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
	
	public static void main(String[] args) {
		List lst=new ArrayList();
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt(),D=sc.nextInt();
		double[][] X=new double[D][N];
		for(int i=0;i<N;i++) {
			for(int j=0;j<D;j++) {
				X[j][i]=sc.nextDouble();
			}
			
		}
		double result;
		for(int i=0;i<N-1;i++) {
			for(int j=i+1;j<N;j++) {
				result=0;
				for(int k=0;k<D;k++) {
					result+=Math.pow(X[k][i]-X[k][j],2.0);
									}
				result=Math.sqrt(result);
				lst.add(result);
				
				
			}
			
		}
		int count=0;
		for(int i=0;i<lst.size();i++) {
			double temp=(double)lst.get(i)-((Double)lst.get(i)).intValue();
			if(temp==0.0) {
				count++;
			}
		}
		System.out.println(count);
		
		
		
		
		
		
		
		
		
	
		
		
}
}


Measured memory_bytes: 25172
def prmry_num_li(mx_int = 10**5):
    li = [True for i in range(mx_int+1)]
    li[0] = False
    li[1] = False

    for i in range(2,int(mx_int**0.5)+1):
        if (li[i]):
            j = 2
            while (i*j <= mx_int):
                li[i*j] = False
                j+= 1
    lis = []
    for i in range(len(li)):
        if li[i]:
            lis.append(i)

    return lis


n = int(input())
li = prmry_num_li(n)
cnt = [0 for _ in range(len(li))]

for i in range(1,n+1):
    num = i
    plc = 0
    while(num!=1):
        if num%li[plc]==0:
            num/=li[plc]
            cnt[plc] += 1
        else:
            plc+=1

mod = 10**9+7
ans = 1 
for j in range(len(cnt)):
    ans = (ans*(cnt[j]+1))%mod

print(ans%mod)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;

using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}

int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector <string> a(n);
	deque <string> b;
	string ans;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		if ((n % 2) == (i % 2))
		{
			b.push_back(a[i]);
		}
		else
		{
			b.push_front(a[i]);
		}
		
		
	}
	for (int i = 0; i < n; i++)
	{
		cout << b[i] << " ";
	}
	
	return 0;

	


}

Measured memory_bytes: 14848
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    int n, k, x, y; cin >> n >> k >> x >> y;
    if(n < k) cout << n * x << endl;
    else cout << k * x + (n - k) * y << endl;
    return 0;
}

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

using namespace std;

int main() {
	int n; cin >> n;
	bool card[4][13] = { false };

	for (int i = 0; i < n; i++) {
		char c; cin >> c;
		int num; cin >> num;

		if (c == 'S') card[0][num-1] = true;
		if (c == 'H') card[1][num-1] = true;
		if (c == 'C') card[2][num-1] = true;
		if (c == 'D') card[3][num-1] = true;

	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (!card[i][j]) {

				if (i == 0) cout << "S" << " " << j + 1 << endl;
				if (i == 1) cout << "H" << " " << j + 1 << endl;
				if (i == 2) cout << "C" << " " << j + 1 << endl;
				if (i == 3) cout << "D" << " " << j + 1 << endl;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
 
int main(){
    ll a,b;
    cin>>a>>b;
    if(a==1 || b==1){
        cout<<"1";
        return 0;
    }
    ll k = a*b;
    if((k)%2==1) cout<<(k)/2+1;
    else cout<<(k)/2;
}

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

int main()
{
  string s;
  
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (i % 2 == 0) {
      cout << s[i];
    }
  }
  cout << endl;

  return (0);
}


Measured memory_bytes: 512
#include<stdio.h>
#define MAX 100000

int main()
{
        char str[MAX];
        int i;

        scanf("%s", str);

        for(i=0; str[i]!='\0'; i++)
        {
                if(i%2==0)printf("%c", str[i]);
        }

        printf("\n");

        return 0;
}

Measured memory_bytes: 256
N,*A=`dd`.split.map(&:to_i)
X,Y = A.max,A.min
puts (case X-Y
     when 1
       as = X
       ss = A.count(Y)
       ds = as - ss
       N > [as, ss, ds].max && [ss,ds].min > 0 && N - ss >= 2*ds
     when 0
       X == N-1 || 2*X <= N
     else false
     end) ? "Yes" : "No"


Measured memory_bytes: 8976
N=int(input())
a=list(map(int,input().split()))
M=int(input())
t=list(map(int,input().split()))
import collections
ac=collections.Counter(a)
tc=collections.Counter(t)

for task in tc.items():
  if task[0] not in ac:
    print("NO")
    exit(0)
  elif ac[task[0]]<task[1]:
    print("NO")
    exit(0)
print("YES")

Measured memory_bytes: 56788
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int ans[N];
  bool prime[60000];
  for(int i=0;i<60000;++i) {
    prime[i] = true;
  }
  prime[0] = false;
  prime[1] = false;
  for(int i=2;i<60000;++i) {
    if(prime[i]){
      for(int j=2;i*j<60000;++j) {
        prime[i*j] = false;
      }
    }
  }
  int index = 2;
  for(int i=0;i<N;++i){
    while(true) {
      if(prime[index] && index%5==1) {
        ans[i] = index;
        index++;
        break;
      }
      index++;
    }
  }
  for(int i=0;i<N;++i) {
    cout<<ans[i]<<" ";
  }
  cout<<endl;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int64_t mod=1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using Graph = vector<vector<int>>;

int main() {
  int N,M; cin>>N>>M;
  Graph G(N);
  rep(i,M){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
    vector<int> dist(N, -1); 
    queue<int> q;  
    dist[0] = 0;
    q.push(0);
  while(!q.empty()){
    int v=q.front();
    q.pop();
    for(auto nv:G[v]){
      if (dist[nv] != -1) continue;
      dist[nv]= v+1;
      q.push(nv);
    }
  }
  cout<<"Yes"<<endl;
  rep(i,N-1){
    cout<<dist[i+1]<<endl;
  }
}

Measured memory_bytes: 10232
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int a,n,b;
  cin >> n >> a >> b;
  cout << min(a*n,b) << endl;

  return 0;
}

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

int main(){
  int n, a, c[8] = {};
  cin >> n;
  int gold = 0;
  for(int i = 0; i < n; i++){
    cin >> a;
    if(1 <= a && a < 400) c[0] = 1;
    if(400 <= a && a < 800) c[1] = 1;
    if(800 <= a && a < 1200) c[2] = 1;
    if(1200 <= a && a < 1600) c[3] = 1;
    if(1600 <= a && a < 2000) c[4] = 1;
    if(2000 <= a && a < 2400) c[5] = 1;
    if(2400 <= a && a < 2800) c[6] = 1;
    if(2800 <= a && a < 3200) c[7] = 1;
    if(a >= 3200) gold++;
  }
  int sum = 0;
  for(int i = 0; i < 8; i++) sum += c[i];
  cout << (sum == 0 && gold >= 1 ? 1 : sum) << " " << sum + gold << endl;
  return 0;
}


Measured memory_bytes: 256
// D
// DeP
#include <cstdio>

const int P = 1e9+7;

int fpow(int base, int b) {
    int ret = 1;
    while (b > 0) {
        if (b & 1) ret = 1LL * ret * base % P;
        base = 1LL * base * base % P, b >>= 1;
    }
    return ret;
}

inline int C(int n, int m) {
    if (m > n) return 0;
    int fac = 1;
    for (int i = 1; i <= m; ++i) fac = 1LL * fac * i % P;
    int ret = 1;
    for (int i = 0; i < m; ++i) ret = 1LL * ret * (n - i) % P;
    return 1LL * ret * fpow(fac, P-2) % P;
}

int main() {
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    printf("%lld\n", (((1LL * fpow(2, n) - 1 + P) % P - C(n, a) - C(n, b) + P) % P + P) % P);
    return 0;
}

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

int main(){
    int R,G,B,N;
    cin>>R>>G>>B>>N;
    int ans =0;
    for(int r=0;r*R<=N;r++){
        for(int g=0;r*R+g*G<=N;g++){
            if((N-r*R-g*G)%B==0) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
pluslist=[]
minuslist=[]
cnt=0
ms=0
for i in range(N):
    if A[i]-B[i]<0:
        minuslist.append(A[i]-B[i])
    elif A[i]-B[i]>0:
        pluslist.append(A[i]-B[i])
#print(minuslist,pluslist)
ms=sum(minuslist)
cnt=cnt+len(minuslist)
pluslist.sort(reverse=True)
idx=0
#print(ms,cnt)
while (ms<0)and(idx<len(pluslist)):
    ms=ms+pluslist[idx]
    cnt=cnt+1
    idx=idx+1
if ms<0:
    print("-1")
else:
    print(cnt)

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

typedef int Weight;
struct Edge {  //src:辺の始点,dst:辺の終点,weight:辺の重さ
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : //辺は重さが重いものを"小さい"と定義する
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
//引数 g:隣接リスト,r:最小全域木の始点
//戻値 total:最小全域木の重み,T:最小全域木の辺集合
pair<Weight, Edges> prim(const Graph &g, int r = 0) {
  int n = g.size();
  Edges T;
  Weight total = 0;
  vector<bool> visited(n);
  priority_queue<Edge> Q;
  Q.push( Edge(-1, r, 0) );    //始め、-1とrを結ぶ辺があると考える
  while (!Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (visited[e.dst]) continue;
    T.push_back(e);
    total += e.weight;
    visited[e.dst] = true;
    for(auto f=g[e.dst].begin();f!=g[e.dst].end();++f) if(!visited[f->dst]) Q.push(*f);
  }
  return pair<Weight, Edges>(total, T);
}

int main(){
  int v; cin >> v;
  Graph g(v);    //頂点数vの空隣接リストgを生成
  int e; cin >> e;
  for(int i=0;i<e;i++){
      int s,t,w; cin >> s >> t >> w;
      g[s].push_back(Edge(s,t,w));    //隣接リストgにsからtに向かう重さwの辺を追加
      g[t].push_back(Edge(t,s,w));
  }
  pair<Weight,Edges>ans=prim(g);    //ansにgに対しての最小全域木の重さと辺集合のpairが入る
  cout << ans.first << endl;
}



Measured memory_bytes: 8708
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
0 0 3 4
1
2 5

output:
3.1200000000 4.1600000000
"""

import sys


class Segment(object):
    __slots__ = ('source', 'target')

    def __init__(self, source, target):
        self.source = complex(source)
        self.target = complex(target)


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def project(s, p):
    base_vector = s.target - s.source
    prj_ratio = dot(p - s.source, base_vector) / pow(abs(base_vector), 2)
    return s.source + base_vector * prj_ratio


def solve(_prj_points):
    for point in _prj_points:
        xp, yp = map(int, point)
        p = xp + yp * 1j
        prj = project(prj_segment, p)
        print('{real:.10f} {imag:.10f}'.format(real=prj.real, imag=prj.imag))

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()

    line = tuple(map(int, _input[0].split()))
    p1, p2 = (x + y * 1j for x, y in zip(line[::2], line[1::2]))
    prj_segment = Segment(p1, p2)

    q_num = int(_input[1])
    prj_points = map(lambda x: x.split(), _input[2:])

    solve(prj_points)

Measured memory_bytes: 7860
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

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

	LL N;
	vector<LL> A;
	cin >> N;
	for(int i=0; i<N; i++){
		LL a;
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end());

	LL ans = A[A.size()-1] - A[0];
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 3716
#include<stdio.h>
#define TEL 10

int main(void)
{
   int x,y;
   int a[TEL][TEL][TEL];
   int b,f,r,v;
   
   scanf("%d", &x);
   
   for(b=1;b<=4;b++){
      for(f=1;f<=3;f++){
         for(r=1;r<=10;r++){
            a[b][f][r] = 0;}}}
	
	for(y=0;y<x;y++){
	 scanf("%d", &b); scanf("%d", &f);
	 scanf("%d", &r); scanf("%d", &v);  
      a[b][f][r] += v;}
   
   for(b=1;b<=4;b++){
      for(f=1;f<=3;f++){
         for(r=1;r<=10;r++){
            printf(" %d", a[b][f][r]);}
            printf("\n");}
         if(!(b==4)){ printf("####################\n");}}
         
   return 0;
}


Measured memory_bytes: 2028
class Dice:
  def __init__(self, list = map(str, range(1, 7))):
    self.top = list[0]
    self.front = list[1]
    self.right = list[2]
    self.left = list[3]
    self.back = list[4]
    self.bottom = list[5]

  def print_all(self):
    print "top = " + self.top
    print "front = " + self.front
    print "right = " + self.right
    print "left = " + self.left
    print "back = " + self.back
    print "bottom = " + self.bottom

  def roll_N(self):
    temp = self.top
    self.top = self.front
    self.front = self.bottom
    self.bottom = self.back
    self.back = temp

  def roll_S(self):
    temp = self.top
    self.top = self.back
    self.back = self.bottom
    self.bottom = self.front
    self.front = temp

  def roll_W(self):
    temp = self.top
    self.top = self.right
    self.right = self.bottom
    self.bottom = self.left
    self.left = temp

  def roll_E(self):
    temp = self.top
    self.top = self.left
    self.left = self.bottom
    self.bottom = self.right
    self.right = temp

my_dice = Dice(raw_input().split(" "))
order = raw_input()
for i in xrange(len(order)):
  if order[i] == "E":
    my_dice.roll_E()
  elif order[i] == "N":
    my_dice.roll_N()
  elif order[i] == "S":
    my_dice.roll_S()
  elif order[i] == "W":
    my_dice.roll_W()
  else:
    continue

print my_dice.top

Measured memory_bytes: 6488
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_DAY_MAX		100										// 最大日数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1Stock[D_DAY_MAX];									// 株価
static int siDCnt;												// 日数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 上昇日 - 取得
int
fGetUDay(
	int piNow					// <I> 現在日
)
{
	int i;

	int liUDay = -1;
	for (i = piNow + 1; i < siDCnt; i++) {
		if (si1Stock[i] > si1Stock[i - 1]) {
			liUDay = i;
		}
		else {
			break;
		}
	}

	return liUDay;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 日数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siDCnt);

	// 株価 - 取得
	for (i = 0; i < siDCnt; i++) {
		fscanf(szpFpI, "%d", &si1Stock[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 実行
	long long llMoney = 1000;
	int liNow = 0;
	while (liNow < siDCnt) {

		// 上昇日 - 取得
		int liUDay = fGetUDay(liNow);
		if (liUDay < 0) {
			liNow++;
			continue;
		}

		// 売買
		long long llSCnt = llMoney / (long long)si1Stock[liNow];
		llMoney += (long long)(si1Stock[liUDay] - si1Stock[liNow]) * llSCnt;

		// 翌日へ
		liNow = liUDay + 1;
	}

	// 出力
	sprintf(lc1Buf, "%lld\n", llMoney);
	fOutLine(lc1Buf);

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 1732
#include<stdio.h>
int main(){
  int N;
  scanf("%d",&N);
  if(N == 1){
    printf("Hello World\n",N);
  }else if(N == 2){
    int A,B;
    scanf("%d %d",&A,&B);
    printf("%d",A + B);
  }
  return 0;
}

Measured memory_bytes: 128
from collections import Counter
n=int(input())
*a,=map(int, input().split())
sa=Counter(a)

if 1 in sa:
    if sa[1]>1:
        print(0)
    else:
        print(1)
    exit()

# def fct(x):
#     f1=[1]
#     f2=[]
#     for i in range(2,min(int(x**(1/2)+7),x)):
#         if x%i==0:
#             f1.append(i)
#             f2.append(x//i)
#     return (set(f1+f2))
ans=0
for ai in sa:
    if sa[ai]>1:
        continue
    
    ans+=1
    if ai%2==0:
        for i in range(2,min(int(ai**(1/2)+7),ai)):
            if ai%i==0:
                if i in sa or ai//i in sa:
                    ans-=1
                    break
    else:
        for i in range(3,min(int(ai**(1/2)+7),ai),2):
            if ai%i==0:
                if i in sa or ai//i in sa:
                    ans-=1
                    break
print(ans)


Measured memory_bytes: 133924
N, M = map(int, input().split())
A = list(map(int, input().split()))
b = float(sum(A)/(4*M))
num = 0
for i in range(N):
    if A[i] >= b:
        num += 1
        
if num >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
def insertionSort(a, n)
  puts a.join(' ')
  for i in 1..(n-1)
    v = a[i]
    j = i - 1
    while j >= 0 && a[j] > v
      a[j+1] = a[j]
      j -= 1
      a[j+1] = v
    end
    puts a.join(' ')
  end
end

input = []
2.times do |i|
  input[i] = gets
end
n = input[0].to_i
a = input[1].split(' ').map(&:to_i)
insertionSort(a, n)

Measured memory_bytes: 8768
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int l=s.size();
  int count=0;
  for(int i=0,j=l-1;i<=l/2,j>=l/2;i++,j--)
    if(s[i]!=s[j])
      count++;
  cout<<count;
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
#input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

N = int(input())
#N, M = map(int, input().split())
#A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
#ABC = [list(map(int, input().split())) for _ in range(N)]
#S = input()
#S = [input() for _ in range(N)]

if N >= 30:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 65184