akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int n, m, h[100005], ans=0;
vector<int> r[100005];
int main() {
    cin >> n >> m;
    for (int i=1; i<=n; i++) cin >> h[i];
    for (int i=0; i<m; i++) {
        int a, b; cin >> a >> b;
        r[a].push_back(b);
        r[b].push_back(a);
    }
    bool ok=1;
    for (int i=1; i<=n; i++) {
        ok=1;
        for (int j=0; j<r[i].size(); j++) {
            if (h[i]<=h[r[i][j]]) ok=0;
        }
        if (ok) ans++;
    }
    
    cout << ans;
}

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

int main() {
    int a,b;
    cin >> a;
    cin >> b;
    if(a<b) {
    cout << "a < b" << endl;
    }
    if(a>b) {
    cout << "a > b" << endl;
    }
    if(a==b) {
    cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { return a = b; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { return a = b; } return false; }

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
   
    int n,ans=0; cin>>n; int x[n],y[n]; map<P,int> ed;
    for (int i = 0; i < n; i++)cin>>x[i]>>y[i];
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++)if(i!=j)ed[P(x[i]-x[j],y[i]-y[j])]++;
    }
    for (auto i = ed.begin(); i != ed.end(); i++)chmax(ans,i->second);
    cout<<max(1,n-ans)<<'\n';
}

Measured memory_bytes: 384
import sys
import numpy as np
# from numba import njit#,i8

#@njit(cache=True)
# @jit(返り値の型(引数1の型,引数2の型,．．．,引数nの型))
#@jit(i8[:](i8,i8,i8[:],i8[:,:],i8[:],i8[:],i8[:]))
def main(N,Q,C,queries,orderByR,mostRightColorIndex,bitArray):

	def add(itemCount, items, i, value):
		while i <= itemCount:
			items[i] += value
			i += (i & (-i))

	def sumFromStart(items, end):
		summary = 0
		i = end
		while i > 0:
			summary += items[i]
			i -= (i & (-i))
		return summary

	def sum(items, start,end):
		summary = sumFromStart(items, end) - sumFromStart(items, start-1)
		return summary

	# 答え配列
	ans=np.zeros(Q, dtype=np.int64)
	#ans=[0]*Q
	# 左からBITと現在色の更新をしながら、クエリのrightに到達したときにBITにクエリ発行する
	qindex = 0

	for n in range(N):
		# 外側のループでは、全部の色をループ

		if Q <= qindex:
			break

		if 0 < mostRightColorIndex[C[n]]:
			# ループ中の場所の色のindexが既にある場合(=過去に、同じ色が登録されていた場合)
			# 今回で、同じ色の一番右側の要素はループ中の要素になる
			# 前登録したこの色の一番右のindexを一度BITから抜く(↓で再度登録される)
			add(N,bitArray,mostRightColorIndex[C[n]], -1 )

		# この要素の色の一番右のindexを、BITに登録
		mostRightColorIndex[C[n]] = n+1
		add(N,bitArray,n+1, 1)

		# while qindex < Q and n+1 == queries[qindex][2]:
		while qindex < Q and n+1 == queries[orderByR[qindex]][1]:
			# 今のBITが次のクエリ発行するための状態(n==query.right)だったら、クエリ発行
			tmpIndex = orderByR[qindex]
			start = queries[tmpIndex][0]
			end = queries[tmpIndex][1]
			ans[tmpIndex]=sum(bitArray,start,end)
			# print(tmpIndex,start,end,ans[tmpIndex])
			qindex += 1

	return ans

if sys.argv[-1]=='ONLINE_JUDGE':
	from numba.pycc import CC
	cc=CC('my_module')
	cc.export('main','i8[:](i8,i8,i8[:],i8[:,:],i8[:],i8[:],i8[:])')(main)
	cc.compile()
	exit(0)
#from my_module import main
from numba import njit
main=njit('i8[:](i8,i8,i8[:],i8[:,:],i8[:],i8[:],i8[:])', cache=True)(main)



def input(): return sys.stdin.readline()

N,Q = map(int,input().split())

C=np.array(input().split(), int)

# Query取得-rightでソート
# dtypeQuery = [("index", int), ("start", int), ("end", int)]
queries=np.empty((Q,2),int)
# #rights=[[] for _ in range(N+1)]

for q in range(Q):
	l,r=map(int,input().split())
	#queries[q] = (q,l,r)
	queries[q][0] = l
	queries[q][1] = r
	#queries=np.sort(queries,order="end")

#queries=np.array(sys.stdin.buffer.read().split(),int).reshape(Q,2)

orderByR=np.argsort(queries[:,1])

# 各色の現在の一番右のindex
mostRightColorIndex = np.zeros(N+1, int)
# bit indexed tree
bitArray=np.zeros(N+1,int)

for a in main(N,Q,C,queries,orderByR,mostRightColorIndex,bitArray):
	print(a)


Measured memory_bytes: 170688
using System;
using System.Collections.Generic;
using System.Linq;

class F
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var n = h[0];
		var rs = new int[h[1]].Select(_ => read()).ToArray();
		var map = rs.GroupBy(x => x[0]).ToDictionary(g => g.Key, g => g.Select(x => x[1]).ToArray());

		var u = new bool[n + 1];
		var t = new bool[n + 1];
		var q = new Stack<int>();
		var qi = new int[n + 1];
		var ps = rs.Select(x => x[1]).Distinct().ToArray();
		foreach (var sp in ps)
		{
			if (u[sp]) continue;
			u[sp] = t[sp] = true;
			q.Push(sp);
			while (q.Any())
			{
				var p = q.Pop();
				if (!map.ContainsKey(p)) continue;
				foreach (var np in map[p])
				{
					if (u[np])
					{
						if (t[np])
						{
							var closed = true;
							var l = new List<int> { p };
							var xp = p;
							while (xp != np)
							{
								if (qi[xp] == 0) { closed = false; break; }
								l.Add(xp = qi[xp]);
							}
							if (!closed) continue;

							var cs = new HashSet<int>(l);
							if (rs.Count(x => cs.Contains(x[0]) && cs.Contains(x[1])) == cs.Count)
							{
								Console.WriteLine(cs.Count);
								Console.WriteLine(string.Join("\n", cs));
								return;
							}
							else continue;
						}
						else
						{
							t[np] = true;
							continue;
						}
					}

					u[np] = t[np] = true;
					qi[np] = p;
					q.Push(np);
				}
			}
			Array.Clear(t, 0, n + 1);
		}
		Console.WriteLine(-1);
	}
}


Measured memory_bytes: 14048
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
ll INF = 1000000007;
ll mod = 1000000007;

// a^n % mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}


long C(int N, int K)
{
	long x = 1, y = 1;
	for (int i = 1; i <= K; i++)
	{
		x = x * (N - i + 1) % mod;
		y = y * i % mod;
	}
	return x * modpow(y, mod - 2,mod) % mod;
}



int main() {
	int x, y;
	cin >> x >> y;
	if ((x + y) % 3 != 0) {
		cout << 0 << endl;
		return 0;
	}
	int a = max(x, y);
	int b = min(x, y);
	int c = a - b;
    if(c<0){
       cout<<0<<endl;
       return 0;
    }
	int d = (b - c) / 3;
    c+=d;
	int e = c + d;
	cout << C(e, c) << endl;
}

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

using Complex = complex<double>;

using Complex = complex<double>;

ll pow_2_at_least(ll n){
    ll ret = 1;
    while(ret < n){ ret *= 2; }
    return ret;
}

void dft(const vector<Complex>& f, const vector<Complex>& cs,
         vector<Complex>& out, bool is_inv=false, ll h=1){
    const ll n = f.size();
    if(n == 1){
        out.resize(1);
        out.at(0) = f.at(0);
        return;
    }
    vector<Complex> f0(n / 2, 0), f1(n / 2, 0);
    REP(i, n / 2){
        f0.at(i) = f.at(2 * i);
        f1.at(i) = f.at(2 * i + 1);
    }
    vector<Complex> f02, f12;
    dft(f0, cs, f02, is_inv, 2 * h);
    dft(f1, cs, f12, is_inv, 2 * h);

    out.resize(n);
    REP(i, n){
        if(!is_inv){
            out.at(i) = f02.at(i % (n / 2)) + cs.at(h * i) * f12.at(i % (n / 2));
        }else{
            out.at(i) = f02.at(i % (n / 2)) + conj(cs.at(h * i)) * f12.at(i % (n / 2));
        }
    }
}

void idft(const vector<Complex>& f,
          const vector<Complex>& cs,
          vector<Complex>& out){
    const ll n = f.size();
    dft(f, cs, out, true);
    REP(i, n){ out.at(i) /= n; }
}

void multiply(
        vector<Complex>& g,
        vector<Complex>& h,
        vector<Complex>& out){
    const ll n = pow_2_at_least((ll)(g.size() + h.size()) - 1LL);
    vector<Complex> cs(n);
    REP(i, n){
        cs.at(i) = Complex(cos(2 * M_PI * i / n), sin(2 * M_PI * i / n));
    }
    g.resize(n, 0);
    h.resize(n, 0);

    vector<Complex> g2, h2, f2;
    dft(g, cs, g2);
    dft(h, cs, h2);
    f2.resize(n);
    REP(i, n){ f2.at(i) = g2.at(i) * h2.at(i); }
    idft(f2, cs, out);
}


void solve(long long N, long long M, std::vector<long long> A){
    const ll max_a = *max_element(A.begin(), A.end());

    vector<Complex> f(max_a + 1, 0);
    for(auto x : A){ f.at(x) += 1; }
    vector<Complex> g(f), fg;

    multiply(f, g, fg);

    ll ans = 0;
    ll rest = M;
    for(ll i = fg.size() - 1; i >= 0; --i){
        const ll c = static_cast<ll>(fg.at(i).real() + 0.5);
        ans += i * min(c, rest);
        rest -= min(c, rest);
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


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

int main(){
    int n,x;

    while(1){
        cin >> n >> x;
        int count = 0;
        if(n == 0 && x == 0)break;
        for(int i = 1; i <= n-2; i++){
            for(int j = i+1; j <= n-1; j++){
                for(int k = j+1; k <= n; k++){
                    if(i + j + k == x)count++;
                }
            }
    }
    cout << count << endl;
}
    return 0;
}

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

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


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


int numberOfDigits (int x) {
    int nod = 0;
    int tmp = x;
    while (1) {
        tmp /= 10;
        nod++;
        if (tmp == 0) break;
    }
    return nod;
}

bool checkDigit (int m, int nod, int x, int s[], int c[]) {
    int digit;
    rep (i, m) {
        int tmp = x;
        for(int j = 0; j < nod - s[i] + 1; j++) {
            digit = tmp % 10;
            tmp /= 10;
        }
        if (digit != c[i]) return true;
    }
    return false;
}

int main() {
    int n, m;
    cin >> n >> m;
    int s[m+10], c[m+10];
    rep(i, m) cin >> s[i] >> c[i];

    int ans = 0;
    for (int x = 0; x < 1001; x++) {
        if (x == 1000) {
            cout << -1 << endl;
            return 0;
        }
        int nod = numberOfDigits(x);
        if (nod != n) continue;
        if (checkDigit(m, nod, x, s, c)) continue;
        ans = x; break;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(){
  int n,m,res = 0;
  cin >> n >> m;
  vector<vector<int>> v(m);
  vector<int> p;
  for(int i = 0;i < m;i++){
    int k;cin >> k;
    for(int j = 0;j < k;j++){
      int l;cin >> l;
      v[i].push_back(l-1);
    }
  }
  for(int i = 0;i < m;i++){
    int k;cin >> k;
    p.push_back(k);
  }
  for(int bit = 0;bit < (1 << n);bit++){
    bool flag[n];fill(flag,flag+n,0);
    bool okswitch = true;
    for(int i = 0;i < n;i++){
      if(bit & (1 << i))flag[i] = true;
    }
    for(int i = 0;i < m;i++){
      int switches = 0;
      for(auto au : v[i]){
        if(flag[au])switches++;
      }
      if(switches % 2 != p[i])okswitch = false;
    }
    if(okswitch)res++;
  }
  cout << res;
  return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
map<long long,int>mp;

void eratos(long long n){
    long long l=n;
    for(long long i=2;i<=sqrt(n);i++){
        int cnt=0;
        while(l%i==0){
            l/=i;
            cnt++;
        }
        if(cnt>0){
            mp.emplace(make_pair(i,cnt));
        }
    }
    if(l!=1){
        mp.emplace(make_pair(l,1));
    }
}
long long  div(int cnt){

    //bool used[cnt]={};
    int k=1;
    long long  ret=0;
    while(1){
        cnt-=k;
        k++;
        if(cnt>=0)ret++;
        else {
            break;
        }
    }
    return ret;
}
int main(){
    long long n;
    cin>>n;

    eratos(n);

    auto it=mp.begin();
    long long ans=0;
    while(it!=mp.end()){
        int now=it->second;
        ans+=div(now);
        it++;
    }
    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 3684
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    if(n<10)
    {
        n=n+0;
    }
    else if(n<100)
    {
        n=9;
    }
    else if(n<1000)
    {
        n=n-90;
    }
    else if(n<10000)
    {
        n=909;
    }
    else if(n<100000)
    {
        n=n-9090;
    }

    else
    {
        n=90909;
    }
    printf("%d\n",n);
    return 0;

}


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

#define ntest 0

using namespace std;
int k;
string s;
void solve() {
    cin >> k >> s;
    if (s.size() <= k) cout << s;
    else cout << s.substr(0,k) << "...";
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    if(ntest){
        int t;
        cin >> t;
        while(t--) solve();
    } else {
        solve();
    }

}




Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    int n = s.size();
    ll num[n + 1] = {};
    if(s[0] == '<'){
        num[0] = 0;
        int i = -1;
        ll cnt = 0;
        while(s[i + 1 + cnt] == '<' && s[i + 2 + cnt] == '<' && i + 2 + cnt <= n){
            num[i + 2 + cnt] = cnt + 1;
            cnt++; 
        }
    }
    if(s[n - 1] == '>'){
        num[n] = 0;
        int i = n - 1;
        ll cnt = 0;
        while(0 <= i - 1 - cnt && s[i - 1 - cnt] == '>' && s[i - cnt] == '>'){
            num[i - cnt] = cnt + 1; 
            cnt++;
        }
    }
    REP(i,n - 1){
        if(s[i] == '>' && s[i + 1] == '<'){
            num[i + 1] = 0;
            ll cnt = 0;
            while(0 <= i - 1 - cnt && s[i - 1 - cnt] == '>' && s[i - cnt] == '>'){
                num[i - cnt] = cnt + 1; 
                cnt++;
            }
            cnt = 0;
            while(s[i + 1 + cnt] == '<' && s[i + 2 + cnt] == '<' && i + 2 + cnt <= n){
                num[i + 2 + cnt] = cnt + 1;
                cnt++; 
            }
        }
    }
    REP(i,n - 1){
        if(s[i] == '<' && s[i + 1] == '>'){
            num[i + 1] = max(num[i], num[i + 2]) + 1;
        }
    }
    if(s[0] == '>'){
        num[0] = num[1] + 1;
    }
    if(s[n - 1] == '<'){
        num[n] = num[n - 1] + 1;
    }
    ll ans = 0;
    REP(i,n + 1){
        ans += num[i];
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    char c;
    cin>>c;
    switch (c)
    {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u': cout<<"vowel"<<endl; break;
        default:
            cout<<"consonant"<<endl; break;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N,K;cin>>N>>K;
    vector<ll> A(N);
    REP(i,N) cin>>A[i],A[i]--;
    map<ll,int> mp;
    ll s=0,sl=0,ans=0;
    REP(i,min(K-1,N)){
        mp[s]++;
        s+=A[i];
        s%=K;
        ans+=mp[s];
    }
    rep(i,K-1,N){
        mp[sl]--;
        mp[s]++;
        s+=A[i];
        s%=K;
        sl+=A[i-K+1];
        sl%=K;

        ans+=mp[s];
    }
    cout<<ans<<endl;
}


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


int main(){
    ll n,k,ans;
    cin>>n>>k;
    ans = pow((n/k),3);
    if(k%2==0){
        ans += pow((n+k/2)/k,3);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  sort(a.begin(),a.end());
  ll res = 0;
  if(n % 2 == 1){
    ll now = 0;
    for(int i = 0;i < n / 2;i++)now -= a[i] * 2;
    for(int i = 0;i < n / 2 + 1;i++){
      now += a[a.size() - 1 - i] * 2;
      if(i >= n / 2 - 1)now -= a[a.size() - 1 - i];
    }
    res = max(res,now);
    now = 0;
    for(int i = 0;i < n / 2;i++)now += a[a.size() - 1 - i] * 2;
    for(int i = 0;i < n / 2 + 1;i++){
      now -= a[i] * 2;
      if(i >= n / 2 - 1)now += a[i];
    }
    res = max(res,now);
  }
  else{
    ll now = 0;
    for(int i = 0;i < n / 2;i++)now += a[a.size() - 1 - i] * 2;
    now -= a[a.size() - n / 2];
    for(int i = 0;i < n / 2;i++)now -= a[i] * 2;
    now += a[n / 2 - 1];
    res = max(res,now);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
	int N,a,b;
	scanf("%d",&N);
	if(N<1000)
	{
		a=1000-N;
		printf("%d",a);
	}
	else if(N>1000&&N%1000!=0)
	{
		b=N/1000;
		a=(b+1)*1000-N;
		printf("%d",a);
	}
	else
	printf("0");
	return 0;
 } 

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

using namespace std;

void A_500_Yen_Coins(void) {

	int K, X;
	cin >> K >> X;
	cout << ((500 * K >= X) ? "Yes" : "No") << flush;
	return;
}

void B_Count_ABC(void) {

	int N;
	string S;
	cin >> N >> S;

	int counter = 0;
	for (int loop = 0; loop < N - 2; loop++) {
		if (S[loop] == 'A' && S[loop + 1] == 'B' && S[loop + 2] == 'C') counter++;
	}
		
	cout << counter << flush;
	return;
}

int main(void) {

	//A_500_Yen_Coins();
	B_Count_ABC();
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) throws IOException{
		KagamiMochi solver = new KagamiMochi();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}

	static class KagamiMochi {

		private int n;
		private Set<String> d;
		private Scanner scanner;
		private int output;

		public KagamiMochi() {
			scanner = new Scanner(System.in);
			d = new HashSet<>();
		}
		public void readInput() {
			n = scanner.nextInt();
			for(int i=0; i<n; i++) {
				d.add(scanner.next());
			}
		}
		public void solve() {
			output = d.size();
		}

		public void writeOutput() {
			System.out.println(output);
		}
	}
}


Measured memory_bytes: 21588
#include "bits/stdc++.h"
using namespace std;
int a[111];

int main(int argc, char const *argv[])
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	vector <int> v;
	int len = n;
	while(len > 0) {
		int id = 0;
		int pos = -1;
		for(int i = 1; i <= n; i++) {
			if(a[i] != -1) ++id;
			if(a[i] == id) {
				pos = i;
			}
		}
		if(pos == -1) {
			printf("-1\n");
			exit(0);
		}
		v.push_back(a[pos]);
		a[pos] = -1;
		--len;
	}
	reverse(v.begin(), v.end());
	for(int i : v) {
		printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include<chrono>
#define ll long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define mt make_tuple
#define tc  ll t; cin>>t; while(t--)
#define io ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define F first
#define S second
#define vi vector<ll>
#define pii pair<ll,ll>
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define vii vector<pair<ll,ll>>
ll gcd(ll n,ll m)
{
    if(n==0)
            return m;
    return gcd(m%n,n);
}
bool ifprime(ll n)
{
if(n==1)
return false;
    ll i;
for(i=2;i*i<=n;i++)
{
if(n%i==0)
return false;
 
}
return true;
}
void disp(vi v)
{
    for(auto u:v)
    cout<<u<<" ";
    cout<<"\n";
}
void remleadzero(vector<int> &v)
{
    vector<int> u;
    int i=0;
    while(v[i]==0)
        i++;
    while(i<v.size())
    {
        u.push_back(v[i]);
        i++;
    }
    v=u;
}
#define mod 1000000007LL
/*
void myscanf(long long *n)
{
    register long long c=getchar_unlocked();
    *n=0;
    for(;(c<48 ||c>57);c=getchar_unlocked())
        ;
    for(;(c>47 && c<58);c=getchar_unlocked())
    {
        *n=(*n<<1)+(*n<<3)+(c&15);
    }
 
}
void fastscan(long long &number)
{
    bool negative = false;
    register long long c;
 
    number = 0;
 
    c = getchar_unlocked();
    if (c=='-')
    {
 
        negative = true;
 
        c = getchar_unlocked();
    }
 
 
    for (; (c>47 && c<58); c=getchar_unlocked())
        number = number *10 + c - 48;
 
 
    if (negative)
        number *= -1;
}
*/
ll fast_expo(ll n,ll m, ll md)
{
    ll a=1;
    while(m>0)
    {
        if(m&1) a=(a*n)%md;
        n=(n*n)%md;
        m/=2;
    }
    return a%md;
}
long long sqroot(long long n){
    long double N = n;
    N = sqrtl(N);
    long long sq = N-2;
    sq = max(sq,0LL);
    while(sq*sq<n){
        sq++;
    } 
    if((sq*sq)==n)
        return sq;
    return -1;
}

int main()
{
    io;
    ll n,k;
    cin>>n>>k;
    ll h[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
    sort(h,h+n);
    reverse(h,h+n);
    for(ll i=0;i<min(k,n);i++)
        h[i]=0;
    ll move = 0;
    for(int i=0;i<n;i++)
        move+=h[i];
    cout<<move;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int x[110];
int y[110];
int zx[110];
int zy[110];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d%d",x+i,y+i);
		zx[i]=x[i];
		zy[i]=y[i];
	}
	std::sort(zx,zx+a);
	std::sort(zy,zy+a);
	long long ans=inf*4;
	for(int i=0;i<a;i++){
		for(int j=i+1;j<a;j++){
			for(int k=0;k<a;k++){
				for(int l=k+1;l<a;l++){
					int tmp=0;
					for(int m=0;m<a;m++){
						if(zx[i]<=x[m]&&x[m]<=zx[j]&&zy[k]<=y[m]&&y[m]<=zy[l])tmp++;
					}
					if(tmp>=b)ans=min(ans,(long long)(zx[j]-zx[i])*(zy[l]-zy[k]));
				}
			}
		}
	}
	printf("%lld\n",ans);
}


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

int n;
int m;
int l[300010];
int r[300010];

typedef pair<int,int> P;
typedef pair<int,P> P2;

vector<P2> lenght;

void input()
{
	cin >> n >> m;

	for(int i = 0;i < n;i++)
	{
		cin >> l[i] >> r[i];

		lenght.push_back(P2(r[i] - l[i] + 1 , P(l[i] , r[i])));
	}

	sort(lenght.begin(),lenght.end());
}


struct BIT
{
	vector<int> bit;
	int n;

	BIT(int N)
	{
		N++;
		n = N;
		bit.resize(n , 0);
	}

	int sum(int i)
	{
		if(!i) return 0;
		return bit[i] + sum(i - (i & -i));
	}

	void add(int i ,int x)
	{
		if(i > n) return;
		bit[i] += x;

		add(i + (i & -i), x);
	}
};



int main()
{
	input();
	int i = 0;

	BIT bit_a(m + 2);

	for(int d = 1;d <= m;d++)
	{
		int ans = 0;
		
		for(;i < lenght.size();i++)
		{
			if(lenght[i].first > d)
			{
				break;
			}
			bit_a.add(lenght[i].second.first,1);
			bit_a.add(lenght[i].second.second + 1,-1);
		}
		for(int now = d;now <= m;now += d)
		{
			ans += bit_a.sum(now);
		}

		ans += n - i;
		cout << ans << endl;
	}
	return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

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

  int n;
  while (cin >> n) {
    vector<int> v(n);
    each (i, v) cin >> i;

    const int N = 100 * 100 + 1;
    bool dp[N];
    fill(dp, dp + N, false);
    dp[0] = true;

    each (i, v) {
      for (int j = N - 1; 0 <= j; --j) {
        if (dp[j]) {
          dp[j + i] = true;
        }
      }
    }
    
    lli mx = 0;
    for (int i = 0; i < N; ++i) {
      if (i % 10 && dp[i]) mx = i;
    }
    cout << mx << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    if s[0] != 'A':
        t = 'A' + s
    else:
        t = s
    if t[1:4] != 'KIH':
        print('NO')
        exit()
    if t[4] != 'A':
        u = t[4:]
    else:
        u = t[5:]
    if u[0] != 'B':
        print('NO')
        exit()
    if u[1] != 'A':
        v = u[1:]
    else:
        v = u[2:]
    if v == 'R' or v == 'RA':
        print('YES')
    else:
        print('NO')


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int N;
VI dp, H;

int rec(int n){
    if(dp[n] != -1) return dp[n];
    if(n == N-1) return 0;
    else if(H[n] < H[n+1]) return 0;
    else return dp[n] = rec(n+1) + 1;
}

int main(void){
    cin >> N;
    dp.assign(N,-1);
    H.assign(N,0);
    REP(i,N) cin >> H[i];
    REP(i,N){
        if(dp[i] != -1) continue;
        dp[i] = rec(i);
    }
    int ans = 0;
    REP(i,N) chmax(ans,dp[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <unordered_map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
using namespace std;

inline int mex(unordered_set<int> st)
{
	int m = 0;
	while (st.find(m) != st.end())
	{
		m += 1;
	}
	return m;
}
inline int calculateGrundy(int n)
{
	if (n == 1)
		return 0;
	unordered_set<int> mexi;
	for (int i = 1; i <= sqrt(n); i += 1)
	{
		if (n % i == 0)
		{
			if (n / i != n)
				mexi.insert(calculateGrundy(n / i));
			mexi.insert(calculateGrundy(i));
		}
	}
	return mex(mexi);
}
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
inline ll power(ll base, ll exp)
{
	ll ans = 1;
	while (exp > 0)
	{


		if (exp % 2 != 0)
			ans = (ans * base) % N;

		base = (base * base) % N;
		exp /= 2;
	}
	return ans % N;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int x, y, z;
	cin >> x >> y >> z;
	int temp = x;
	x = y;
	y = temp;
	temp = x;
	x = z;
	z = temp;
	cout << x << " " << y << " " << z;
	return 0;
}

Measured memory_bytes: 256
a = input()
continuous = 0


if a[0] == "R" and a[1] == "R":
  if a[2] == "R":
    continuous = 3
  else:
    continuous = 2
elif a[1] == "R" and a[2] == "R":
  continuous = 2
elif a[0] == "R" or a[1] == "R" or a[2] =="R":
  continuous = 1
  
print(continuous)

Measured memory_bytes: 9056
import java.util.Scanner;

class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
                int area = a*b;
 		int peri = 2*a + 2*b;
                System.out.println(area+" "+peri);
	}
}
		


Measured memory_bytes: 26084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e6+10,mod=1e9+7,inf=0x3f3f3f3f3f3f3f3f;
struct sc
{
    ll id,dis;
    bool operator<(const sc &a)const
    {
        return a.dis<dis;
    }
}p[N];
vector<sc>link1[N],link2[N];
ll n,m,val1[N],val2[N],dis1[N],dis2[N],vis[N],a[N],b[N],c[N];
void dij(ll s,vector<sc>link[],ll dis[],ll val[])
{
    priority_queue<sc>q;
    for(ll i=1;i<=n;i++)dis[i]=inf,vis[i]=0,val[i]=0;
    dis[s]=0;
    val[s]=1;
    vis[s]=1;
    q.push({s,0});
    while(!q.empty())
    {
        sc tep=q.top();q.pop();
        //if(tep.dis>dis[tep.id])continue;
        vis[tep.id]++;
        for(sc p:link[tep.id])
        {
            if(tep.dis+p.dis==dis[p.id])
            {
                val[p.id]=(val[p.id]+val[tep.id])%mod;
            }
            if(!vis[p.id]&&tep.dis+p.dis<dis[p.id])
            {
                dis[p.id]=tep.dis+p.dis;
                q.push({p.id,tep.dis+p.dis});
                val[p.id]=val[tep.id];
            }
        }
    }
}
int main()
{
    //freopen("i.txt","r",stdin);
    scanf("%lld %lld",&n,&m);
    for(ll i=0;i<m;i++)
    {
        scanf("%lld %lld %lld",&a[i],&b[i],&c[i]);
        link1[a[i]].push_back({b[i],c[i]});
        link2[b[i]].push_back({a[i],c[i]});
    }
    dij(1,link1,dis1,val1);
    dij(2,link2,dis2,val2);
    for(ll i=0;i<m;i++)
    {
        if(dis1[b[i]]+dis2[a[i]]+c[i]<dis1[2])puts("HAPPY");
        else if(dis1[a[i]]+dis2[b[i]]+c[i]==dis1[2]&&val1[a[i]]*val2[b[i]]%mod==val1[2])puts("SAD");
        else puts("SOSO");
    }
}



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

int main(){
  int a,k=0;
  cin >> a ;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
    if(a==i*j) k = 1;
    }
  }
  if(k==1){
  cout << "Yes" << endl;
  }
  else{
  cout << "No"<<endl;
  }

}


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

int main()
{
    int N, K;
    cin >> K >> N;
    vector<int> A(N);
    rep(i, N)
    {
        cin >> A[i];
    }

    int longest = 0;
    rep(i, N - 1)
    {

        int diff = A[i + 1] - A[i];
        if (diff > longest)
        {
            longest = diff;
        }
    }

    int diff = K - A[N - 1] + A[0];
    if (diff > longest)
    {
        longest = diff;
    }

    cout << K - longest << endl;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V 10000

typedef pair<ll, ll> P;
set<int> st;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    REP(i, n) cin >> h[i];

    if(n <= k) {
        cout << 0 << endl;
        return 0;
    }

    n -= k;
    ll ans = 0;
    sort(h.begin(), h.end());
    REP(i, n) {
        ans += h[i];
    }

    cout << ans << endl;

}


Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);


	Int a, b, c;
	cin >> a >> b >> c;

	if (a==b) {
		cout << c << "\n";
	}
	else if (a == c) {
		cout << b << "\n";
	}
	else {
		cout << a << "\n";
	}
}


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

int main() {
    int n; cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    sort(s.begin(),s.end());
    vector<pair<int,string>> v;
    vector<string> ans;
    rep(i,n){
        if(i == 0) v.push_back(make_pair(1,s[0]));
        else{
            if(s[i-1] == s[i]) v[v.size()-1].first++;
            else v.push_back(make_pair(1,s[i]));
        }
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    int m = v[0].first;
    rep(i,n){
        int c = v[i].first;
        if(c == m) ans.push_back(v[i].second);
        else break;
    }
    sort(ans.begin(),ans.end());
    for(string a : ans) cout << a << endl;
}


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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000001;
using namespace std;
typedef long long ll;


string s, t;
int a[30],b[30];


int main(){
  std::cin >> s >> t;
  rep(i,0,s.size()){
    a[s[i]-'a']++;
    b[t[i]-'a']++;
  }
  sort(a,a+26); sort(b,b+26);
  bool flag = true;
  rep(i,0,26){
    if(a[i]!= b[i]) flag = false;
  }
  std::cout << (flag ? "Yes":"No") << '\n';
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
const long long int mod=1e9+7;
int n;
char c[2][55];

int main(){
    cin >> n;
    if(n==1){
        cout << 3;
        return 0;
    }
    char c[2][n];
    long long int ans=1;
    for(int i=0;i<2;i++)for(int j=0;j<n;j++)cin >> c[i][j];
    int j=0;
    while(j<n){
        if(j==0){
            if(c[0][0]==c[1][0]){
                ans*=3;
                j++;
            }
            else{
                ans*=6;
                j+=2;
            }
        }
        else{
            if(c[0][j]==c[1][j]){
                if(c[0][j-1]==c[1][j-1]){
                    ans*=2;
                    ans%=mod;
                    j++;
                }
                else j++;
            }
            else{
                if(c[0][j-1]==c[1][j-1]){
                    ans*=2;
                    ans%=mod;
                    j+=2;
                    }
                else{
                    ans*=3;
                    ans%=mod;
                    j+=2;                           
                    }
            }
        }
    }
    cout << ans;
}

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

int main(){
    string s;
    cin >> s;
    int ss = -2, e = -2;
    for(int i = 0; i < s.size() - 1; i++){
        if(s[i] == s[i + 1]){
            ss = i, e = i + 1;
            break;
        }
        if(i < s.size() - 2 && s[i] == s[i + 2]){
            ss = i, e = i + 2;
            break;
        }
    }
    cout << ss + 1 << " " << e + 1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <stdlib.h>
#include<algorithm>
using namespace std;

int main()
{
	vector<int> lnum;
	vector<int> rnum;
	int n, m, bl, br,ans;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> bl >> br;
		lnum.emplace_back(bl);
		rnum.emplace_back(br);
	}
	ans = *min_element(rnum.begin(), rnum.end()) - *max_element(lnum.begin(), lnum.end()) + 1;
	if (ans < 0) {
		cout << 0;
	}
	else {
		cout << ans;
	}
	return 0;
}

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

int main(){
  long long x;
  cin >> x;
  if ( x % 11 > 6){
    cout << 2 * (x/11) + 2 << endl;
  } else if ( x % 11 > 0) {
    cout << 2 * (x/11) + 1 << endl;
  } else {
    cout << 2 * (x/11) << endl;
  }

  return 0;
}

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

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    long long int min_value = 100000000000000;
    int max_C = max(X, Y);
    for(int i = 0; i <= max_C; i++) {
        long long int tmp = 2 * i * C + max(X-i, 0) * A + max(Y-i, 0) * B;
        min_value = min(min_value, tmp);
    } 
    cout << min_value << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;
 
#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())
 
ll inf = 1e9;
ll INF = inf * 1ll * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a > mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}

//only for variables and vectors; 
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

/*...................................................*/

main()
{
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);

  ll t, n, m, i, j, k, q, u, v;
  // cin >> t;
  // ll tc = t;
  t = 1;
  while (t--)
  {
    cin >> n;
    m = n + 1 >> 1;
    
    printf("%.9lf", double(m) / double(n));
    // cout << "Case #" << tc - t << ": ";
  }
}

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

using namespace std;

struct pos_t {
    double x;
    double y;
};

float deg2rad(double degree)
{
    return 2. * M_PI * degree / 360.;
}

pos_t rotateRad(pos_t& vec, double rad)
{
    pos_t ret = {
        .x = vec.y * sin(rad),
        .y = -vec.y * cos(rad)
    };
    return ret;
}

pos_t rotate(pos_t& vec, double degree)
{
    double rad = deg2rad(degree);

    return rotateRad(vec, rad);
}

int main(int argc, const char * argv[]) {
    int A, B, H, M; // A:hour cm, B:min cm, H:M
    cin >> A >> B >> H >> M;

    pos_t a = {0., (double)A};
    pos_t b = {0., (double)B};

    // angle for vec a in radians
    double hr    = (double)(H%12) + (double)M/60.;
    double a_rad = hr * 2.0 * M_PI / 12.0;

    // angle for vec b in radians
    double b_rad = (double)M/60. * 2.0 * M_PI;

    pos_t rot_a = rotateRad(a, a_rad);
    pos_t rot_b = rotateRad(b, b_rad);

    double len = sqrt(pow(rot_b.x - rot_a.x, 2.0) + pow(rot_b.y - rot_a.y,2.0));

    printf("%1.10f\n", len);

    return 0;
}

/**
cheat sheet

vector<int> v{ 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };
sort(v.begin(), v.end());
=> 0 1 2 3 4 5 6 7 8 9

vector<int> v{ 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };
sort(v.begin(), v.end(), greater<int>());
=> 9 8 7 6 5 4 3 2 1 0

struct A { int x, y; };
bool comp(A i1, A i2) { return (i1.y < i2.y); }
vector<A> v { { 6, 8 }, { 1, 9 }, { 2, 4 }, { 4, 7 } };
sort(v.begin(), v.end(), comp);
=> [1, 9] [2, 4] [4, 7] [6, 8]

*/


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<int> h(N);
  rep(i,N) cin >> h[i];
  int ans=0;
  bool allzero = true;
  rep(i,100){
    int last=0;
    rep(j,N){
      if(last==0 && h[j]) ans++;
      last = ((h[j])?1:0);
      if(h[j]) h[j]--;
    }
    rep(j,N){
      if(h[j]!=0)allzero=false;
    }
    if(allzero){cout << ans << endl; return 0;}
    allzero=true;
    //rep(j,N) cout << h[j] << " ";
    //cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N,M,K=map(int,input().split())

mod=998244353

ans=0

comb=[1]
for i in range(K):
    comb_temp=comb[i]*(N-1-i)*pow(i+1,-1,mod)
    comb_temp%=mod
    comb.append(comb_temp)

for k in range(K+1):
    ans_temp=M*(comb[k])*pow(M-1,N-1-k,mod)
    ans+=ans_temp
    ans%=mod

print(ans)

Measured memory_bytes: 16932
#import<cstdio>
#import<map>
#define I(M,A)for(i=1;i<=M;i++)scanf("%d",A+i),A[i]+=A[i-1];
main(){for(int n[1501],m[1501],o,a,b,i,j;scanf("%d%d",&a,&b),a;printf("%d\n",o)){std::map<int,int>z;*n=*m=o=0;I(a,n)I(b,m)for(i=0;i<=a;i++)for(j=0;j<=b;)z[n[i]+m[j++]]++;for(typeof(z.begin())p=z.begin();p!=z.end();)o+=p->second*(p++->second-1)/2;}}

Measured memory_bytes: 18000
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    string s; cin >>s;

    string t = "";
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'B' && t.length() > 0) {
            t.erase( --t.end() );
        } else if (s[i] != 'B') {
            t += s[i];
        } 
    }

    cout << t << endl;
    return 0;
}



Measured memory_bytes: 504
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n)  for(int i=0;i<n;i++)
#define ll long long
int main()
{
int k;
cin>>k;
vector <ll> a;
for (int i=1;i<=9;i++)a.push_back(i);
while(1)
{
if(a.size()>=k)
{
cout <<a[k-1];
return 0;
}
k-=a.size();
vector<ll>old;
swap(old,a);
for(ll x:old)
{
    int d=x%10;    
for (int i=-1;i<=1;i++)
{
if(d+i>9 ||d+i<0)continue;
a.push_back(x*10+d+i);

}


}

}
}

Measured memory_bytes: 1712
#include<stdio.h>
#include<stdlib.h>
 
#define NIL -1
#define MAX 101
 
void BFS(int, int);
void Enqueue(int*,int);
int Dequeue(int*);
 
int Adj[MAX][MAX];
int D[MAX], F[MAX];
int C[MAX]={0};
int count = 1;
int head = 0, tail = 0;
 
int main(void){
  int i, j, n, u, k, v;
 
  scanf("%d", &n);
  for(i=1; i<n+1; i++){
    for(j=1; j<n+1; j++){
      Adj[i][j] = 0;
    }
  }
 
  for(i=1; i<n+1; i++){
    scanf("%d%d", &u, &k);
    for(j=1; j<k+1; j++){
      scanf("%d", &v);
      Adj[i][v] = 1;
    }
  }
 
  /* A.c
  for(i=1; i<n+1; i++){
    for(j=1; j<n+1; j++){
      if(j == n) printf("%d\n", Adj[i][j]);
      else printf("%d ", Adj[i][j]);
    }
    }*/
 
  BFS(1,n);
 
  for(i=1; i<n+1; i++) printf("%d %d\n", i, D[i]);
 
  return 0;
}
 
void BFS(int i, int n){
  int j, u;
 
  for(j=1; j<n+1; j++){
    C[j] = 0;
    D[j] = NIL;
  }
 
  C[i] = 1; D[i] = 0;
  Enqueue(F, i);
 
  while(head != tail){
    u = Dequeue(F);
    for(j=1; j<n+1; j++){
      if(Adj[u][j] == 1){
        if(C[j] == 0){
          C[j] = 2;
          D[j] = D[u]+1;
          Enqueue(F, j);
        }
      }
    }
    C[u] = 1;
  }
 
  return;
}
 
void Enqueue(int *F, int i){
 
  F[tail]=i;
  tail++;
 
  return;
}
 
int Dequeue(int *F){
 
  head++;
  return F[head-1];
}

Measured memory_bytes: 636
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef __int128 ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    vc<int> son[N],len[N];
    int solve(int x)
    {
    	for(auto y:son[x]) len[x].PB(solve(y));sort(all(len[x]));
    	int ans=0;fo(t,0,sz(len[x])-1) chmax(ans,len[x][t]+sz(len[x])-t);
		return ans;
	}
    void main()
    {
		int n=qread();fo(i,2,n) son[qread()].PB(i);
		write(solve(1));
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}

Measured memory_bytes: 59648
// AOJ 1574: Gossip
// 2017.10.23 bal4u@uu

#include <stdio.h>

int main() 
{
	int n, m, d, a, a0, a1;

	scanf("%d%d", &n, &m);
	scanf("%d", &a1), a0 = a1, d = 0;
	while (--m) {
		scanf("%d", &a);
		if (a - a0 > d) d = a - a0;
		a0 = a;
	}
	d /= 2;
	if (a1 - 1 > d) d = a1 - 1;
	if (n - a0 > d) d = n - a0;
	printf("%d\n", d);
	return 0; 
}

Measured memory_bytes: 1860
#include <stdio.h>

int main(int argc, char *args[])
{
	int n;
	int card[52];
	unsigned char suite;
	int rank;
	int i;

	for( i=0; i<52; i++ ) {
		card[i] = 0;
	}

	scanf("%d", &n);

	for( i=0; i<n; i++ ) {

		scanf(" %c %d", &suite, &rank);

		switch (suite) {
			case 'S':
				card[rank-1] = 1;
				break;
			case 'H':
				card[13+rank-1] = 1;
				break;
			case 'C':
				card[26+rank-1] = 1;
				break;
			case 'D':
				card[39+rank-1] = 1;
				break;
		}

	}

	for( i=0; i<52; i++ ) {
		if( card[i] == 0 ) {
			if( i<=12 ) {
				printf("S ");
				printf("%d\n", i+1);
			}
			else if( 13<=i && i<=25 ) {
				printf("H ");
				printf("%d\n", i+1-13);
			}
			else if( 26<=i && i<=38 ) {
				printf("C ");
				printf("%d\n", i+1-26);
			}
			else if( 39<=i ) {
				printf("D ");
				printf("%d\n", i+1-39);
			}
		}
	}


	return 0;

}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int N, C;
int S[100001], T[100001], CH[100001];
int ans;
int t[30];
int c[30];
vector<pair<int, int>> order;
int main(void) {
	cin >> N >> C;
	for (int n = 0; n < N; ++n) {
		cin >> S[n] >> T[n] >> CH[n];
		order.emplace_back(S[n], n);
	}
	sort(order.begin(), order.end());
	for (size_t o = 0U; o < order.size(); ++o) {
		pair<int, int> cur = order[o];
		int cs = S[cur.second], ct = T[cur.second], cc = CH[cur.second];
		int next = 0;
		for (int ch = 0; ch < 30; ++ch) {
			if (t[ch] < cs || (t[ch] == cs && c[ch] == cc)) {
				next = ch;
				break;
			}
		}
		t[next] = ct;
		c[next] = cc;
		ans = max(ans, next);
	}
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 2292