akhauriyash/Code-Regression huggingface dataset:
while 1:
    n = int(input())
    if n == 0:
        break

    data = list(input())

    ba = 0
    hand = [0] * n
    for i in range(100):
        turn = i % n
        card = data[i]
        if card == "M":
            hand[turn] += 1
        elif card == "S":
            ba += hand[turn] + 1
            hand[turn] = 0
        else:
            hand[turn] += ba + 1
            ba = 0

    hand.sort()
    hand.append(ba)
    print(' '.join(str(h) for h in hand))



Measured memory_bytes: 5612
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

ll x[100001] = {};
ll d_sum(ll k) {
	ll sum = 0;
	while (k) {
		sum += k % 10;
		k /= 10;
	}
	return sum;
}
int main() {
	ll n; cin >> n;
	repe(i, 1, n) {
		x[i] = d_sum(i);
	}
	ll minV = 1 << 29;

	rep(i, 1, n) {
		minV = min(minV, x[i] + x[n - i]);
	}
	cout << minV << endl;

	return 0;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string S; lint K;
    cin >> S >> K;
    lint num_suffix_1s = 0;
    while (num_suffix_1s < S.size() and S.at(num_suffix_1s) == '1') num_suffix_1s++;
    cout << (K <= num_suffix_1s ? '1' : S.at(num_suffix_1s)) << "\n";
}

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

int n, q;

int binary_Sort(vector<int> &s, int key){
    
    int left = 0;
    int right = n;
    
    while(left < right){
        int middle = (left + right) / 2;
        //cout << left << " " << middle << " "<<  right << " " << key << endl;
        if(s[middle] == key) return 1;
        else if(s[middle] > key) { right = middle; }
        else { left = middle + 1; }
    }
    
    return 0;
}


int main(void){
    
    cin >> n;
    vector<int> S(n);
    for(int i = 0; i < n; i++){
        cin >> S[i];
    }
    
    
    cin >> q;
    int ans = 0;
    for(int i = 0; i < q; i++){
        int T;
        cin >> T;
        ans += binary_Sort(S, T);
        //cout << ans << endl;
    }
    
   cout << ans << endl;
    
    
    
}



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

int main(){
    int N;
    cin>>N;
    long long T,A;
    long long x,y;
    x=1;
    y=1;
    rep(i,N){
        cin>>T>>A;
        long long b=max((x-1)/T+1,(y-1)/A+1);
        x=b*T;
        y=b*A;
    }
    cout<<x+y<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int A[1000000],n;
int main(){
  int i,q,k,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(linearSearch(k)==1){
      sum++;
    }
  }
  printf("%d\n",sum);
  return 0;
}
 
int linearSearch(int key){
  int a=0,b=n;
  while(a < b){
    if(key==A[a]){
      return 1;
    }
    a++;
  }
  return 0;
}

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

int main() {
    int n,k; cin>>n>>k;
    priority_queue<P> q;
    priority_queue<P,vector<P>,greater<P>> q2;
    vector<int> f(n+10);

    for (int i=0;i<n;i++) {
        int t,d; cin>>t>>d;
        q.push(P(d,t));
    }

    ll s=0,x=0;
    for (int i=0;i<k;i++) {
        P p = q.top(); q.pop();
        q2.push(p);
        s += p.first;
        if(f[p.second]==0) x++;
        f[p.second]++;
    }
    ll sum=s+x*x;

    while(!q.empty()) {
        P p = q.top(); q.pop();
        if (f[p.second]) continue;
        int m=-1;
        while(!q2.empty()) {
            P p2 = q2.top(); q2.pop();
            if (f[p2.second] > 1) {
                f[p2.second]--;
                m=p2.first;
                break;
            }
        }
        if (m==-1) break;
        x++;
        f[p.second]++;
        s += p.first-m;
        sum = max(sum,s+x*x);
    }
    cout << sum << endl;
}


Measured memory_bytes: 5232
#include <cstdio>
#include <queue>
using namespace std;

int h, w;
char field[1000][1001];
typedef pair<int, int> pos;
queue<pos> q;
int d[4][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1} };

int main()
{
	int num = 0;
	int ans = 0;
	scanf("%d %d", &h, &w);

	for (int i = 0; i < h; i++)
		scanf("%s", field[i]);

	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (field[i][j] == '#')
			{
				q.push({ i, j });
				num++;
			}

	while (num != h * w)
	{
		ans++;

		for (int i = q.size(); i > 0; i--)
		{
			pos p = q.front();
			q.pop();
			int y = p.first;
			int x = p.second;

			for (int j = 0; j < 4; j++)
			{
				if (y + d[j][0] < 0 || y + d[j][0] >= h || x + d[j][1] < 0 || x + d[j][1] >= w)
					continue;

				if (field[y + d[j][0]][x + d[j][1]] == '.')
				{
					field[y + d[j][0]][x + d[j][1]] = '#';
					q.push({ y + d[j][0], x + d[j][1] });
					num++;
				}
			}
		}
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 9360
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
ll parent[200010];

ll root(ll x){
    if(x == parent[x]){
        return x;
    }else{
        return parent[x] = root(parent[x]);
    }
}

void unite(ll a, ll b){
    a = root(a);
    b = root(b);
    if(a == b){
        return;
    }
    parent[a] = b;
}

void same(ll a, ll b){
    if(root(a) == root(b)){
        print("Yes");
    }else{
        print("No");
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K,L;
    cin >> N >> K >> L;
    ll p[100010], q[100010], r[100010], s[100010];
    rep(i,0,K){
        cin >> p[i] >> q[i];
        p[i]--; q[i]--;
    }
    rep(i,0,L){
        cin >> r[i] >> s[i];
        r[i]--; s[i]--;
    }
    rep(i,0,N){
        parent[i] = i;
    }
    rep(i,0,K){
        unite(p[i], q[i]);
    }
    ll root_a[200010], root_b[200010];
    rep(i,0,N){
        root_a[i] = root(i);
    }
    rep(i,0,N){
        parent[i] = i;
    }
    rep(i,0,L){
        unite(r[i], s[i]);
    }
    rep(i,0,N){
        root_b[i] = root(i);
    }
    map<lpair,ll> mp;
    rep(i,0,N){
        mp[make_pair(root_a[i], root_b[i])]++;
    }
    rep(i,0,N){
        cout << mp[make_pair(root_a[i], root_b[i])];
        if(i != N-1) cout << " ";
    }
    cout << endl;

}


Measured memory_bytes: 19712
#include<iostream>
#include<string>
using namespace std;
int main(){
    int m,h;
    while(1){
        char tmp[400];
        string str;
        cin>>str;
        if(str=="-"){break;}
        for(int i=0;i<str.size();i++){
            tmp[i]=str[i];
            tmp[str.size()+i]=str[i];
        }
        cin>>m;
        int sum=0;
        for(int i=0;i<m;i++){
            cin>>h;
            sum+=h;
        }
        int count=0;
        for(int i=sum%str.size();;i++){
            cout<<tmp[i];
            count++;
            if(count==str.size()){
                break;
            }
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3160
def main(N, B):
    A = [-1 for _ in range(N)]
    A[0], A[-1] = B[0], B[-1]

    for i in range(1, N-1):
        A[i] = min(B[i-1], B[i])

    return(sum(A))


if __name__ == "__main__":
    N = int(input())
    B = list(map(int, input().split()))
    ans = main(N, B)
    print(ans)


Measured memory_bytes: 3064
r, c = map(int, input().split())

table = []
for _ in range(r):
    temp = [int(x) for x in input().split()]
    temp.append(sum(temp))
    table.append(temp)
    
c_sum = [0 for _ in range(c + 1)]
for i in range(r):
    for j in range(c + 1):
        c_sum[j] += table[i][j]
table.append(c_sum)

for i in range(r + 1):
    for j in range(c + 1):
        print(table[i][j], end="")
        if j < c:
            print(" ", end="")
    print()        


Measured memory_bytes: 6664
#include <stdio.h>
int main (){
	int a,b,k;
	scanf("%d",&k);
	scanf("%d %d",&a,&b);
	
	for(int i=a; i<=b; i++){	
	    if (i%k==0){
		printf("OK");	
		return 0;		
		}
		
	}
	printf("NG");	
	return 0;
}

Measured memory_bytes: 1704
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val K = in.next().toLong
  val _A = new Array[Int](N)
  val _F = new Array[Int](N)
  for (i <- 0 until N)
    _A(i) = in.next().toInt
  for (i <- 0 until N)
    _F(i) = in.next().toInt


  //
  val A = _A.sorted
  val F = _F.sorted.reverse



  def check(n: Long): Boolean = {
    var cnt = K
    breakable {
      for (i <- 0 until N) {
        val need = n / F(i)
        cnt -= Math.max(0L, A(i) - need)
      }
    }

    cnt >= 0
  }

  // 条件を満たす最小の値を返す
  def binarySearch(min: Long, max: Long): Long = {
    val mid: Long = (max + min) / 2
      (max - min) match{
      case 0 | 1 =>
        check(min) match{
          case true  => min
          case false => max
        }
      case _ =>
        (check(mid)) match{
          case true  => binarySearch(min, mid)
          case false => binarySearch(mid, max)
        }
    }
  }



  val ans = binarySearch(0L, 1e12.toLong)

  println(ans)
}


class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}


Measured memory_bytes: 80188
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#define MAXN 10
using namespace std;

char S[MAXN+5];

int main()
{
    scanf("%s",S+1);
    int cnt=0;
    for(int i=1;i<=6;i++)
        if(S[i]=='1')
            cnt++;
    printf("%d\n",cnt);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 1000000.0
#define EPS 1e-10
#define PI 3.1415926535897932384626433832795028841971
#define MOD 1000000007
using namespace std;
typedef pair<int,double> P;

int n;
double d, t;
double x[20], y[20];
double dp[10001][20][20];
vector<P> edge[20][20];

int main(){
	rep(i,10001) rep(j,20) rep(k,20) dp[i][j][k] = INF;
	cin >> n;
	cin >> d >> t;
	t = t*2*PI/360;
	rep(i,n){
		cin >> x[i] >> y[i];
	}
	rep(i,n) rep(j,n) rep(k,n){
		if(i == j || j == k || i == k) continue;
		double x1 = x[j]-x[i], x2 = x[k]-x[j];
		double y1 = y[j]-y[i], y2 = y[k]-y[j];
		double g1 = atan2(y1,x1), g2 = atan2(y2,x2);
		g1 = abs(g1-g2);
		while(g1 > 2*PI+EPS) g1 -= 2*PI;
		if(g1 > PI+EPS) g1 = 2*PI-g1;
		if(g1 < t){
			double dis = sqrt(pow(x[j]-x[k],2)+pow(y[j]-y[k],2));
			edge[i][j].push_back(P(k,dis));
		}
	}
	dp[1][0][0] = 0.0;
	for(int i = 1; i < n; i++){
		if(d < sqrt(pow(x[i]-x[0],2)+pow(y[i]-y[0],2))) continue;
		dp[2][0][i] = sqrt(pow(x[i]-x[0],2)+pow(y[i]-y[0],2));
	}
	
	for(int i = 3; i <= 10000; i++){
		rep(j,20) rep(k,20){
			if(j == k) continue;
			if(dp[i-1][j][k] > d) continue;
			rep(l,edge[j][k].size()){
				P p = edge[j][k][l];
				dp[i][k][p.first] = min(dp[i][k][p.first],dp[i-1][j][k]+p.second);
			}
		}
	}
	int ans = 0;
	rep(i,10001) rep(j,20) rep(k,20){
		if(dp[i][j][k] < d){
			ans = max(ans,i);
		}
	}
	cout << ans-1 << endl;
}

Measured memory_bytes: 32772
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 233333;
int n,a[N],b[N];
int main() {
	read(n);rep(i,1,n)read(a[i]);
	per(i,n,1){
		int p=0;rep(j,1,i)if(a[j]==j)p=j;
		if(!p){puts("-1");return 0;}
		b[i]=p;
		rep(j,p,i-1)a[j]=a[j+1];
	}
	rep(i,1,n)printf("%d\n",b[i]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    if (v.size() > 0) {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int main() {
    int t;
    cin>>t;
    REP(i,t){
        int n;
        cin>>n;
        vll k(n), l(n), r(n);
        vector<pll> vals_l, vals_r;
        ll ans = 0;
        unordered_map<ll, vll> ma_l, ma_r;
        REP(i, n) {
            cin >> k[i] >> l[i] >> r[i];
            ll now = min(l[i],r[i]);
            ans += now;
            ll val = max(l[i],r[i]) - now;
            if (l[i] > r[i]){
                vals_l.push_back(make_pair(val, k[i] - 1));
            } else if (l[i] < r[i]) {
                if (k[i] < n) vals_r.push_back(make_pair(val, n - 1 - k[i]));
            }
        }
        set<int> se;
        REP(i, n) { se.insert(i); }
        sort(ALL(vals_l));
        reverse(ALL(vals_l));
        REP(i,vals_l.size()){
            int idx = vals_l[i].second;
            auto ite = se.upper_bound(idx);
            if (ite != se.begin()){
                --ite;
                ans += vals_l[i].first;
                se.erase(ite);
            }
        }

        sort(ALL(vals_r));
        reverse(ALL(vals_r));
        se.clear();
        REP(i, n) { se.insert(i); }
        REP(i, vals_r.size()) {
            int idx = vals_r[i].second;
            auto ite = se.upper_bound(idx);
            if (ite != se.begin()) {
                --ite;
                ans += vals_r[i].first;
                se.erase(ite);
            }
        }
        cout << ans << endl;
    }
}

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

int main()
{
	int n,a,b;
	char str[16];
	
	cin >> n;
	while(n--)
	{
		cin >> str;
		vector<int> v;
		for(int i=0; str[i]; i++)
		{
			v.push_back(str[i]-'0');
		}
		
		a=b=0;
		sort(v.begin(), v.end());
		for(int i=0; i<v.size(); i++)
		{
			a*=10; a+=v[i];
		}
		reverse(v.begin(), v.end());
		for(int i=0; i<v.size(); i++)
		{
			b*=10; b+=v[i];
		}

		cout << b-a << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

vector<pair<double, double> > inter(double x1, double y1, double r1, double x2, double y2, double r2) {
    if(r1 > r2) {
        swap(r1, r2);
        swap(x1, x2);
        swap(y1, y2);
    }
    double sr = r1 + r2;
    double dx = x1 - x2, dy = y1 - y2;
    double ds = dx * dx + dy * dy;
    vector<pair<double, double> > ans;
    if(ds <= sr * sr) {
        double d = sqrt(ds);
        if(d + r1 >= r2) {
            double a = (r1 * r1 - r2 * r2 + ds) / (2 * d);
            double h = sqrt(r1 * r1 - a * a);
            double mx = x1 + a * (x2 - x1) / d;
            double my = y1 + a * (y2 - y1) / d;
            double x3 = mx + h / d * (y1 - y2);
            double y3 = my - h / d * (x1 - x2);
            double x4 = mx - h / d * (y1 - y2);
            double y4 = my + h / d * (x1 - x2);
            ans.pb({x3, y3});
            ans.pb({x4, y4});
        }
    }
    return ans;
}

bool contains(double cx, double cy, double r, double px, double py) {
    double dx = px - cx, dy = py - cy;
    double ds = dx * dx + dy * dy;
    return ds <= r * r + 1e-6;
}

const int N = 66;
double x[N], y[N], c[N], r[N];
int n, k;

bool solve(double t) {
    vector<pair<double, double> > pts;
    rep(i, 1, n) {
        r[i] = t / c[i];
        pts.pb(make_pair(x[i], y[i]));
    }
    rep(i, 1, n) {
        rep(j, i + 1, n) {
            vector<pair<double, double> > in = inter(x[i], y[i], r[i], x[j], y[j], r[j]);
            rall(p, in) {
                pts.pb(p);
            }
        }
    }
    rall(p, pts) {
        int cnt = 0;
        rep(i, 1, n) {
            cnt += contains(x[i], y[i], r[i], p.fi, p.se);
        }
        if(cnt >= k) {
            return true;
        }
    }
    return false;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    rep(i, 1, n) {
        cin >> x[i] >> y[i] >> c[i];
    }
    double lo = 0, hi = 1e6;
    rep(o, 1, 60) {
        double mid = lo + (hi - lo) / 2;
        if(solve(mid)) {
            hi = mid;
        } else {
            lo = mid;
        }
    }
    cout << setprecision(10) << fixed << lo << endl;
    return 0;
}


Measured memory_bytes: 384
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a,b=map(int,input().split())
print(a/b)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ar array
#define f(i,x,n) for(int i=x;i<n;++i)
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;cin>>n>>k;
    double a[n];
    f(i,0,n)
    {
    	cin>>a[i];
    	a[i]+=1;
    	a[i]/=2;
    }
    double s=0;
    double mx=-1;
    f(i,0,k)
    s+=a[i];
    mx=max(mx,s);
    f(i,k,n){
        s-=a[i-k];
        s+=a[i];
        mx=max(mx,s);    
    }
   cout << fixed << setprecision(10) << mx <<endl; 
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>

using namespace std;

int main()
{
    int n, digit1, digit2, digit3;

    scanf("%d", &n);
    digit3 = n%10;
    digit2 = n/10%10;
    digit1 = n/100%100;

    if(digit1 == 9)
        printf("1");
    else
        printf("9");
    if(digit2 == 9)
        printf("1");
    else
        printf("9");
    if(digit3 == 9)
        printf("1");
    else
        printf("9");
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！

a,b=map(int,input().split())
if a<b:
    print(0)
else:
    print(10)

Measured memory_bytes: 5580
from sys import stdin, setrecursionlimit
from collections import defaultdict
input = stdin.readline
setrecursionlimit(200000)
N, M = map(int, input().split())
# d = [0] * (N + 1)
adj = defaultdict(set)
for _ in range(M):
    x, y = map(int, input().split())
    adj[x].add(y)
    # d[y] += 1

dp = [-1] * (N + 1)


def lp(x: 'int') -> 'int':
    if dp[x] >= 0:
        return dp[x]
    else:
        dp[x] = 0
        for y in adj[x]:
            dp[x] = max(dp[x], lp(y) + 1)
        return dp[x]


print(max(lp(i) for i in range(1, N + 1)))


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

struct Pos {
    ll x, y;
};

void solve() {
    ll H, W, K;
    cin >> H >> W >> K;
    Pos s, t;
    cin >> s.x >> s.y >> t.x >> t.y;
    --s.x, --s.y, --t.x, --t.y;
    vector<Vi> cell(H, Vi(W));
    for (ll i = 0; i < H; i++) {
        string S;
        cin >> S;
        for (ll j = 0; j < W; j++) {
            if (S[j] == '@') cell[i][j] = 1;
        }
    }

    if (cell[s.x][s.y] == 1) {
        cout << -1 << "\n";
        return;
    }

    constexpr Pos step[] = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}};

    using Tup = tuple<ll, ll, ll, ll>;  // cost, x, y, v
    vector<vector<Vl>> dp(H, vector<Vl>(W, Vl(4, L_INF)));
    priority_queue<Tup, vector<Tup>, greater<Tup>> q;
    q.emplace(0, s.x, s.y, 0);
    dp[s.x][s.y][0] = 0;
    while (!q.empty()) {
        auto [c, x, y, v] = q.top();
        q.pop();
        if (c > dp[x][y][v]) continue;
        ll xn, yn;
        ll cn;
        // 前進
        xn = x + step[v].x;
        yn = y + step[v].y;
        if (xn >= 0 && xn < H && yn >= 0 && yn < W) {
            if (cell[xn][yn] == 0) {
                cn = c + 1;
                if (cn < dp[xn][yn][v]) {
                    dp[xn][yn][v] = cn;
                    q.emplace(cn, xn, yn, v);
                }
            }
        }
        // 回転
        v = (v + 1) % 4;
        xn = x;
        yn = y;
        if (xn >= 0 && xn < H && yn >= 0 && yn < W) {
            if (cell[xn][yn] == 0) {
                cn = (c + K - 1) / K * K;
                if (cn < dp[xn][yn][v]) {
                    dp[xn][yn][v] = cn;
                    q.emplace(cn, xn, yn, v);
                }
            }
        }
    }

    ll ans = L_INF;
    for (ll i = 0; i < 4; i++) {
        if (ll tmp = dp[t.x][t.y][i]; tmp != L_INF) {
            ans = min(ans, (tmp + K - 1) / K);
        }
    }

    if (ans != L_INF)
        cout << ans << "\n";
    else
        cout << -1 << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 147732
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNextInt()){
			int a=sc.nextInt();
			int v=1;
			while(a>1){
				int b=a%2;
				if(b==1){a-=1;}a/=2;
				if(b==1){
				System.out.print(b*v+" ");}//System.out.println(b);
				v*=2;
			}if(a==1)System.out.println(a*v);
		}
	}
}

Measured memory_bytes: 17212
#include <bits/stdc++.h>
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))
#define abs(x) ((x) < 0 ? (-(x)) : (x))
#define rep(i,a,m) for((i) = (a) ; (i) < (m) ; ++(i))
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.end(),x.begin()
#define sz(x) ((int)x.size())
#define PI 3.14159265

using namespace std;
/*
#ifdef JUDGE
#include <fstream>
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
#else
#include <iostream>
using std::cin;
using std::cout;
#endif
*/
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pi;
int a, b, c, i, j, k;
long long ans = 0LL;
long double eps = 1.0E-14;
long long MOD = 1000000007;
/*
bool comparator(const MyStruct& lhs, const MyStruct& rhs) {
   return lhs.key < rhs.key;
}
*/
int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int T,t;
    cin >> T;
    vector<vector<int>> vec(T+1, vector<int>());
    rep(i,0,T-1) {
        cin >> t;
        vec[t].pb(i+2);
    }
    rep(i,1,T+1) {
        cout << vec[i].size() << endl;
    }	
	return 0;
}

Measured memory_bytes: 14224
n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
t[0],x[0],y[0]=0,0,0
for i in range(1,n+1):
  t[i],x[i],y[i]=map(int, input().split())
d='Yes'
for i in range(n):
  a=t[i+1]-t[i]-abs(x[i+1]-x[i])-abs(y[i+1]-y[i])
  if a<0 or a%2==1:
    d='No'
    break
print(d)

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

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define pll pair<ll, ll>

class UnionFind {
public:
  vector<ll> par,siz;

  UnionFind(ll sz_): par(sz_), siz(sz_,1) {
    for(int i=0; i<sz_; ++i) par[i]=i;
  }
  void init(ll sz_) {
    par.resize(sz_);
    siz.assign(sz_, 1);
    for(ll i=0; i<sz_; ++i) par[i]=i;
  }

  ll root(ll x) {
    while(par[x]!=x) {
      x = par[x] = par[par[x]];
    }
    return x;
  }

  void merge(ll x, ll y) {
    x = root(x);
    y = root(y);
    if(x!=y) {
      if(siz[x]<siz[y]) swap(x,y);
      siz[x]+=siz[y];
      par[y]=x;
    }
  }

  bool issame(ll x, ll y) {
    return root(x) == root(y);
  }

  ll size(ll x) {
    return siz[root(x)];
  }
};

int main() {
  ll N,K,L; cin>>N>>K>>L;
  UnionFind road(N), rail(N);
  for(int i=0; i<K; ++i) {
    ll x,y; cin>>x>>y;
    road.merge(x-1,y-1);
  }
  for(int i=0; i<L; ++i) {
    ll x,y; cin>>x>>y;
    rail.merge(x-1,y-1);
  }

  // 道路でも電車でも連結してる
  // 道路の根が同じで、線路の根も同じならよい
  map<pair<ll, ll>,ll> mp;
  for(int i=0; i<N; ++i) mp[{road.root(i),rail.root(i)}]++;
  for(int i=0; i<N; ++i) cout<<mp[{road.root(i),rail.root(i)}]<<" ";
  cout << endl;
}


Measured memory_bytes: 20612
# Vector 2018/06/02
# job hunting (*_*)

class Vector(object):
    def __init__(self):
        self.A = list()

    def pushBack(self, x):
        self.A.append(x)

    def randomAccess(self, p):
        print self.A[p]

    def popBack(self):
        del self.A[-1]

A = Vector()
q = int(raw_input())
for i in range(q):
    line = [int(i) for i in raw_input().split()]
    if line[0] == 0:
        A.pushBack(line[1])
    elif line[0] == 1:
        A.randomAccess(line[1])
    else:
        A.popBack()



Measured memory_bytes: 17244
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N);
    for(size_t i = 0; i < N; i++)
    {
        ll temp;
        cin >> temp;
        a[i] = temp - i - 1;
    }
    sort(a.begin(), a.end());
    ll median = a[N/2];
    ll ret = 0;
    for(size_t i = 0; i < N; i++)
    {
        ret += abs(a[i] - median);
    }
    cout << ret << endl;
    
    return 0;
}

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

#define rep(i, n) for(int i = 0 ; i < n ; i ++)
#define vi vector<int>
int main(void){
  int n;
  cin>>n;
  vi v(n);
  rep(i,n)cin>>v[i];
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  int ret = 0;
  rep(i,n){
    ret += (i % 2 ? -1 : 1) * v[i];
  }
  cout<<ret<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include<list>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n, m, q; cin >> n >> m >> q;
    list<int> stu;
    rep(i,n){
        stu.push_back(i);
    }
    vector<bool> life(n,true);
    auto now = stu.begin();
    rep(i,m) {
        int a; cin >> a;
        if(a%2==0) {
            rep(i,a) {
                if(++now == stu.end()) now = stu.begin();
            }
            life[*now] = false;
            now = stu.erase(now);
            if(now==stu.end()) now = stu.begin();
        }else {
            rep(i,a) {
                if(now == stu.begin()) now = stu.end();
                --now;
            }

            life[*now] = false;
            now = stu.erase(now);
            if(now==stu.end()) now = stu.begin();
        }
    }

    rep(i,q) {
        int b; cin >> b;
        if(life[b]) cout << 1 << endl;
        else cout << 0 << endl;
    }

    return 0;
}



Measured memory_bytes: 9032
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N=2000;

struct Seg{
  typedef int T;
  const T e = 0;
  void merge(const T &a, const T &b, T &c){
    c = a+b;
  }

  int n;
  vector<T> d;

  void init(int m){
    n = 1<<(32-__builtin_clz(m-1));
    d = vector<T>(2*n, e);
  }
  void init(vector<T> &v){
    init(v.size());
    FOR(j, 0, v.size()) d[j+n] = v[j];
    for(int k=n-1;k>0;k--) merge(d[k*2], d[k*2+1], d[k]);
  }
  void update(int k, T a){
    k+=n;
    d[k]=a;
    while(k){
      k >>= 1;
      merge(d[k*2], d[k*2+1], d[k]);
    }
  }
  T query(int L, int R) {
    L += n; R += n;
    T l=e, r=e;
    while (L < R) {
      if (L & 1) merge(l, d[L++], l);
      if (R & 1) merge(d[--R], r, r);
      L >>= 1; R >>= 1;
    }
    merge(l, r, l);
    return l;
  }
  T get(int a){
    return d[n+a];
  }
} seg;
int n, a[N];
ll k;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  seg.init(N);
  ll ans = 0;
  FOR(i, 0, n){
    cin >> a[i];
    a[i]--;
    ans += seg.query(a[i]+1, N);
    seg.update(a[i], seg.get(a[i])+1);
  }
  ans = ans * k % MOD;
  ll c = 0;
  FOR(i, 0, n) c += seg.query(a[i]+1, N);
  ans += c * (k*(k-1)/2%MOD);
  cout << ans%MOD << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
INF = 10**9

edges = []

for i in range(M):
    edges.append(list(map(int, input().split())))

dist = [[INF for j in range(N)] for i in range(N)]

for i in range(N):
    dist[i][i] = 0

for i in range(M):
    a, b, c = edges[i]
    a, b = a - 1, b - 1
    dist[a][b] = c
    dist[b][a] = c
    
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j])

res = M
for i in range(M):
    a, b, c = edges[i]
    a, b = a - 1, b - 1
    shortest = False
    for j in range(N):
        if dist[j][a] + c == dist[j][b]:
            shortest = True
            break
    if shortest:
        res -= 1

print(res)


Measured memory_bytes: 3572
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int num1 = sc.nextInt();
            int num2 = sc.nextInt();
            int sum = num1 + num2;
            int minus = num1 - num2;
            int multi = num1 * num2;
            if(sum >= minus && sum >= multi){
              System.out.println(sum);
            } else if(minus >= sum && minus >= multi){
              System.out.println(minus);
            } else {
              System.out.println(multi);
            }
      }
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,k[109];
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b;
	for(i=1; i<=a; i++){
		cin>>c;
		for(j=1; j<=c; j++){
			cin>>d;
			k[d]=1;
		}
	}
	for(i=1; i<=a; i++) if(k[i]==0) e++;
	cout<<e;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>

using namespace std;

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

  if ( (a < c && c < b) || (b < c && c < a) ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,x,y;
    int amax=-100;
    int bmin=100;
    cin >> n >> m >> x >> y;
    vector<int> a(n),b(m);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
        if(amax<a.at(i))amax=a.at(i);
        }
    for(int i=0;i<m;i++){
        cin >> b.at(i);
        if(bmin>b.at(i))bmin=b.at(i);
        }
    if((x>=y)||(amax>=bmin)){
        cout << "War" << endl;
        return 0;
    }
    if(max(x,amax)>=min(y,bmin)){
        cout << "War" << endl;
        return 0;
    }
    cout << "No War" << endl;

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    set<int> st1, st2;
    map<int, int> mp1, mp2;
    int b = true;
    imfor(i, n) {
        int v;
        cin >> v;
        if (b) {
            b = false;
            if (st1.find(v) != st1.end()) {
                mp1[v]++;
            }
            else {
                st1.insert(v);
                mp1[v] = 1;
            }
        }
        else {
            b = true;
            if (st2.find(v) != st2.end()) {
                mp2[v]++;
            }
            else {
                st2.insert(v);
                mp2[v] = 1;
            }
        }
    }
    int max1 = 0;
    int maxnum1;
    for (int i : st1) {
        if (mp1[i] > max1) {
            max1 = mp1[i];
            maxnum1 = i;
        }
    }
    int max2 = 0;
    int maxnum2;
    for (int i : st2) {
        if (mp2[i] > max2) {
            max2 = mp2[i];
            maxnum2 = i;
        }
    }
    if (maxnum1 == maxnum2) {
        if (max1 > max2) {
            max2 = 0;
            for (int i : st2) {
                if (mp2[i] > max2 && i != maxnum1) {
                    max2 = mp2[i];
                }
            }       
        }
        else if (max1 < max2) {
            max1 = 0;
            for (int i : st1) {
                if (mp1[i] > max1 && i != maxnum2) {
                    max1 = mp1[i];
                }
            }
        }
        else {
            int max1s = 0;
            int maxnum1s;
            for (int i : st1) {
                if (mp1[i] > max1s && i != maxnum2) {
                    max1s = mp1[i];
                    maxnum1s = i;
                }
            }
            int max2s = 0;
            int maxnum2s;
            for (int i : st2) {
                if (mp2[i] > max2s && i != maxnum1) {
                    max2s = mp2[i];
                    maxnum2s = i;
                }
            }

            if (max1s >= max2s) {
                max1 = max1s;
            }
            else {
                max2 = max2s;
            }
        }
    }
    cout << n - max1 - max2 << endl;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define loop(n,i) for(register int i=1;i<=(n);++i)
#define zxc(x) cerr<<(#x)<<'='<<(x)<<'\n'
#define zxcv(x) cerr<<(#x)<<'='<<(x)<<','
#define zcx zxc
#define MAX 5000009
#define int long long
#define P 1000000007
using namespace std;
typedef pair<int,int> pr;
inline int icin(){
	char c=getchar();int s=0;bool sign=0;
	while(!isdigit(c)&&c^'-')c=getchar();
	if(c=='-')c=getchar(),sign=1;
	while(isdigit(c))s=(s<<1)+(s<<3)+c-'0',c=getchar();
	return sign?-s:s;
}
int n,k;
inline int Quick(int a,int m){int ans=1;for(;m;m>>=1,a=a*a%P) if(m&1) ans=ans*a%P;return ans;}
int fact[MAX],ifact[MAX];
inline int binom(int n,int m){return n<m||m<0?0:fact[n]*ifact[m]%P*ifact[n-m]%P;}
int f[2009][2009];
main(){
	n=icin(),k=icin();
	if(k==1) return cout<<1,0;
	int bound=n*k+k;
	fact[0]=1;loop(bound,i) fact[i]=fact[i-1]*i%P;
	ifact[bound]=Quick(fact[bound],P-2);for(register int i=bound;i;--i) ifact[i-1]=ifact[i]*i%P;
	for(register int i=0;i<=n;++i) f[0][i]=1;
	for(register int i=1;i<=n;++i){
		for(register int j=i;j<=n;++j){
			f[i][j]=(f[i][j-1]+f[i-1][j]*binom((n-i+1)*(k-1)+n-j-1,k-2)%P*(n-i+1))%P;
		}
	}cout<<f[n][n];
}

Measured memory_bytes: 96512
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,d;
	scanf("%d%d",&n,&d);
	printf("%d\n", (n + d * 2) / (d * 2 + 1));
	return 0;
}


Measured memory_bytes: 128
import Data.List
main = interact $ unlines . return . unwords . map (exchange "apple" "peach") . words
exchange s1 s2 s = rewrite "" s
 where
  rewrite s' s
   | null s = s'
   | isPrefixOf s1 s = rewrite (s' ++ s2) (s \\ s1)
   | isPrefixOf s2 s = rewrite (s' ++ s1) (s \\ s2)
   | otherwise = rewrite (s' ++ [head s]) (tail s)


Measured memory_bytes: 3632
N = int(input())
p = []
if N > 0:
    for i in range(500):
        if (2**(2*i)-1)/3 < N <= (2**(2*(i+1))-1)/3:
            q = 2*i + 1
if N < 0:
    for i in range(1,500):
        if -(2**(2*i+1)-2)/3 <= N < -(2**(2*i-1)-2)/3:
            q = 2*i
if N == 0:
    q = 1
def cal(n,i):
    if i % 2 != 0:
        if (2**(i-1)-1)/3 < n <= (2**(i+1)-1)/3:
            p.append(1)
            n = n - (-2)**(i-1)
            i = i-1
            if i > 0:
                cal(n,i)
        else:
            p.append(0)
            i = i-1
            if i > 0:
                cal(n,i)
    elif n == 0:
        p.append(0)
        i = i-1
        if i > 0:
            cal(n,i)
    else:
        if -(2**(i+1)-2)/3 <= n < -(2**(i-1)-2)/3:
            p.append(1)
            n = n - (-2)**(i-1)
            i = i-1
            if i > 0:
                cal(n,i)
        else:
            p.append(0)
            i = i-1
            if i > 0:
                cal(n,i)
            
    return p
ans = cal(N,q)
for i in range(len(ans)):
    ans[i] = str(ans[i])
print(int(''.join(ans)))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>

int main(){
	
	int A, B, C;
	std::cin >> A >> B >> C;


	bool b =
		(A * 100 + B * 10 + C) % 4 == 0;

	if (b) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
string s;
long a[500050], b;
int main() {
  cin >> s;
  int n = s.size();
  for(int i = 0; i < n; ++i)
    if(s[i] == '<') a[i+1] = max(a[i+1], a[i] + 1);
  for(int i = n-1; i >= 0; --i)
    if(s[i] == '>') a[i] = max(a[i], a[i+1] + 1);
  for(int c : a) b += c;
  cout << b;
  return 0;
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int MOD = 1e9 + 7;

template <typename T, T MOD>
class ModuloCombination {
 private:
  std::vector<T> factrial, inverse_factrial;
  T Pow(T x, T y) {
    if (y == 0) return 1;
    if (y % 2 == 0) return Pow(x * x % MOD, y / 2);
    return x * Pow(x, y - 1) % MOD;
  }

 public:
  ModuloCombination(T n) : factrial(n + 1), inverse_factrial(n + 1) {
    inverse_factrial[0] = factrial[0] = 1;
    for (T i = 1; i <= n; i++) {
      factrial[i] = factrial[i - 1] * i % MOD;
      inverse_factrial[i] = Pow(factrial[i], MOD - 2);
    }
  }
  T operator()(T n, T k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return factrial[n] * inverse_factrial[k] % MOD * inverse_factrial[n - k] % MOD;
  }
};

int main() {
  int x, y;
  cin >> x >> y;

  if (!((x + y) % 3 == 0 && x <= 2 * y && y <= 2 * x)) {
    cout << 0 << endl;
    return 0;
  }
  int n = (x + y) / 3;
  int k = 2 * n - x;

  ModuloCombination<ll, MOD> c(n);
  cout << c(n, k) << endl;
}


Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
#define INF 9223372036854;
#define lli long long int


int main()
{
    int n;
    cin>>n;
    lli dp[n+1][n+1];
    memset(dp,-1,sizeof(dp));
    lli arr[n+1] = {0};
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
        arr[i] += arr[i-1];
    }

    lli i,j,k,l=1,mn = INF;

    for(j=1;j<=n;j++)
    {
        for(i=1;i<=n && j<=n;i++,j++)
        {
            if(i==j)
            {
                dp[i][j] = 0;
            }
            else
            {
                for(k=i;k<j;k++)
                {
                    mn = min(mn,dp[i][k]+dp[k+1][j]+arr[j]-arr[i-1]);
                }
                dp[i][j] = mn;
            }
            mn = INF;
        }
        j=l;
        l++;
    }

    cout << dp[1][n] << endl;
}


Measured memory_bytes: 1536
#include <cstdio>
#include <iostream>
#include <deque>
using namespace std;

int main(){
  deque<int> dq;
  int n; cin >> n;
  string s; cin >> s;
  int l = s.size();
  int t = 0;
  int c;
  for (int i = 0; i < l; i++) {
    if (s[i] == '(') {
      t++;
      c = 0;
    }
    else {
      t--;
      c = 1;
    }
    if (t < 0) {
      dq.push_front(0);
      t++;
    }
    dq.push_back(c);
  }
  for (; t > 0; t--) {
    dq.push_back(1);
  }
  for (int i = 0; i < dq.size(); i++) {
    if (dq[i] == 0) printf("(");
    else printf(")");
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[3], ans, cnt = 0;

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

    sort(a, a + 3);

    if ((a[2] - (a[2] - a[1] + a[0])) % 2 == 0)
    {
        ans = a[2] - a[1] + (a[2] - (a[2] - a[1] + a[0])) / 2;
    }

    else
    {
        a[0] += a[2] - a[1];
        cnt += a[2] - a[1];
        a[1] = a[2];
        a[2]++;
        a[1]++;

        cnt++;

        ans = (a[2] - a[0]) / 2 + cnt;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256