akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int64)1e9
#define REP(i, n) for(int64 i = 0; i < (n); i++)
#define FOR(i, a, b) for(int64 i = (a); i < (b); i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint32_t;
using int64 = int64_t;
using uint64 = uint64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

template<typename A, typename B> inline void chmin(A &a, B b) { if (a > b) a = b; }
template<typename A, typename B> inline void chmax(A &a, B b) { if (a < b) a = b; }

int main(void) {
  int64 n;
  cin >> n;
  vector<PLL> ival(n);
  using T = tuple<int64, int64, int64>;
  vector<T> ps(2*n);
  vector<int64> imos(112345, 0);
  REP(i, n) {
    cin >> ival[i].fs >> ival[i].sc;
    imos[ival[i].fs]++; imos[ival[i].sc]--;
    ps[2*i] = T(2*ival[i].fs+1, -ival[i].sc, i+1);
    ps[2*i+1] = T(2*ival[i].sc, -ival[i].fs, -i-1);
  }
  sort(all(ps));
  int64 r2 = 0;
  REP(i, imos.size()-1) {
    imos[i+1] += imos[i];
    chmax(r2, imos[i+1]);
  }
  multiset<PLL> st;
  int64 cmp = 0;
  vector<int64> r1(n+1, 0), sav(n+1, 0);
  REP(i, ps.size()) {
    int64 p, id, ot;
    tie(p, ot, id) = ps[i];
//    cout << abs(id) << " " << p/2 << endl;
//    cout << "debug " << id << ": ";
//    REP(j, r1.size()) cout << r1[j] << " ";
//    cout << endl;
    if (p%2 == 0) {
      p /= 2;
      id = -id;
      r1[id] += cmp-sav[id]-r1[id];
      st.erase(st.find(PLL(ival[id-1].fs, id)));
      r1[id] += st.size();
//      cout << r1[id] << " " << st.size() << " " << cmp << " " << sav[id] << " " << st.begin()->fs << endl;

      if (st.size() && st.begin()->fs <= ival[id-1].fs) r1[id] = 0;
      cmp++;
    } else {
      p /= 2;
//      cout << p << " " << id << " " << st.size() << " insert" << endl;
      r1[id] += st.size();
      sav[id] = cmp;
      st.emplace(p, id);
    }
  }
//  REP(i, r1.size()) cout << r1[i] << " ";
//  cout << endl;
  cout << *max_element(all(r1))+1 << " " << r2 << endl;
}



Measured memory_bytes: 31864
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;
typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<' '<<y<<endl
#define p3(x,y,z)               out<<x<<' '<<y<<' '<<z<<endl
#define p4(x,y,z,w)             out<<x<<' '<<y<<' '<<z<<' '<<w<<endl
#define pl(x)                   out<<x
#define pll(x)                  out<<x<<' '
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

#define EACH(x, a) for (auto& x: a)
template<class T> void read_v(T& x, std::istream& in) {
    in >> (x);
}
template<class A> void read_vec(vector<A>& x, std::istream& in) {
    EACH(a, x)
        read_v(a, in);
}

bool sortpairbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
template <typename T>
T factmod(T a, T modulus){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=modulus;} return res; }
template <typename T>
int powmod(T a,T b,int m){ int ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
int power(T a, T b){ int ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}


void ssolve(std::istream& in, std::ostream& out){
    int ans = 0;
    string st;
    s(st);
    int aux = 0;
    for (int c: st){
        if(c=='R'){
            aux++;
        }else{
            ans = max(ans, aux);
            aux = 0;
        }
    }
    ans = max(ans, aux);
    p(ans);
    return;
}

class ARainySeason {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(nullptr);out.tie(nullptr);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    ARainySeason solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 3612
module Main where

consecLength :: Eq a => a -> [a] -> Integer
consecLength a xs = maximum $ f 0 a xs
	where   f :: Eq a => Integer -> a -> [a] -> [Integer]
		f _ _ [] = []
		f n a (x:xs)
			| a == x = n + 1 : (f (n + 1) a xs)
			| otherwise = 0 : (f 0 a xs)

main :: IO ()
main = getLine >>= putStrLn . show . consecLength 'R'

Measured memory_bytes: 3796
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  [h, w] <- f
  solve <$> replicateM h getLine >>= mapM_ putStrLn
  where
    f = map read <$> words <$> getLine

solve :: [String] -> [String]
solve xs = transpose . filter (not . all (=='.')) . transpose . filter (not . all (=='.')) $ xs


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

struct node{
    int parent;
    int left;
    int right;
    node(){
        parent = 0;
        left   = 0;
        right  = 0;
    }
};

void restore(vector<int>& pre_o, vector<int>& in_o, vector<node>& T){
    if (pre_o.size() <= 2) return;
    int parent = pre_o[1];
    vector<int> left_in_o;
    left_in_o.push_back(0);
    vector<int> right_in_o;
    right_in_o.push_back(0);
    int id;
    for (id = 1; in_o[id] != parent; id++) {
        left_in_o.push_back(in_o[id]);
    }
    for (id++; id < in_o.size(); id++) {
        right_in_o.push_back(in_o[id]);
    }

    vector<int> left_pre_o;
    left_pre_o.push_back(0);
    vector<int> right_pre_o;
    right_pre_o.push_back(0);
    for (id = 2; id <= left_in_o.size(); id++) {
        left_pre_o.push_back(pre_o[id]);
    }
    for (; id < pre_o.size(); id++) {
        right_pre_o.push_back(pre_o[id]);
    }

    restore(left_pre_o , left_in_o , T);
    restore(right_pre_o, right_in_o, T);

    if (left_pre_o.size() > 1) {
        T[parent].left  = left_pre_o[1];
        T[left_pre_o[1]].parent  = parent;
    }
    if (right_pre_o.size() > 1) {
        T[parent].right = right_pre_o[1];
        T[right_pre_o[1]].parent = parent;
    }
}

int find_root(vector<node>& T){
    for (int i = 1; i < T.size(); i++) {
        if (T[i].parent == 0) return i;
    }
}

void do_post_order(int id, vector<node>& T, queue<int>& Q){
    if (id == 0) return;
    do_post_order(T[id].left , T, Q);
    do_post_order(T[id].right, T, Q);
    Q.push(id);
}

int main(){
    int n;
    cin >> n;
    vector<int> pre_o(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> pre_o[i];
    }
    vector<int> in_o(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> in_o[i];
    }

    vector<node> T(n + 1);
    restore(pre_o, in_o, T);

    int root = find_root(T);
    queue<int> Q;
    do_post_order(root, T, Q);
    cout << Q.front();
    Q.pop();
    while (!Q.empty()) {
        cout << " " << Q.front();
        Q.pop();
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
using namespace std;

long long sum;
vector<long long> v;

void F(string s) {
    if (s.length() == 0) {
        for (int i = 0; i < v.size(); ++ i) {
            sum += v[i];
            //cout << v[i] << " ";
        }
        //cout << endl;
        return;
    }

    long long xx;
    stringstream stream;
    for (int i = 1; i <= s.length(); ++ i) {
        string x = s.substr(0, i);
        //cout << x << "===" << endl;
        stream.clear();
        stream.str("");
        stream.str(x);
        stream >> xx;
        //cout << xx << "---" << endl;
        v.push_back(xx);
        string ss = s.substr(i);
        F(ss);
        v.pop_back();
    }
}

int main() {

    string s;
    cin >> s;

    sum = 0;
    F(s);
    cout << sum << endl;

    return 0;
}


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

int N,K;
string S;
vector<string> V;

int main()
{
    cin >> S;
    N = S.size();
    scanf("%d",&K);

    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < 5 && i + j < N; j++)V.push_back(S.substr(i,j + 1));
    }

    sort(V.begin(),V.end());

    string ans;
    int id = 0;
    while(K)
    {
        if(id == 0 || V[id - 1] != V[id])
        {
            K--;
            ans = V[id];
        }
        id++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    rep(i, 0, m) cin >> x[i];
    sort(x.begin(), x.end());
    if(n >= m){
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    vector<int> a(m - 1);
    rep(i, 0, m - 1) a[i] = x[i + 1] - x[i];
    sort(a.begin(), a.end());
    rep(i, 0, m - n) ans += a[i];
    cout << ans << endl;
}

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

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

    // replace order
    if (a > b)
    {
        swap(a, b);
    }

    if (b > c)
    {
        swap(b, c);
    }

    if (a > b)
    {
        swap(a, b);
    }

    // output
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <queue>
#include <math.h>
using namespace std;
#define lol long long

int main()
{
	string S;
	cin >> S;
	vector<int> A(26,0);
	for (int i = 0; i < 4; i++) {
		A[(int)(S[i] - 'A')]++;
	}
	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());
	if (A[0] == 2 && A[1] == 2) {
		cout << "Yes" << endl;
	
	}
	else {
		cout << "No" << endl;
	}
}

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

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    string S;
    cin >> S;

    if (S == "ABC") cout << "ARC" << endl;
    else cout << "ABC"<< endl;
    
    return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	vector<int> V=vecin(N);
	int X=V[0];
	REP(i,N-1){
		X^=V[i+1];
	}
	if(X){
		out("No");
	}
	else{
		out("Yes");
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N,M;

vector<i64> a,b,c;
int main(){
  cin >> N >> M;
  a.resize(N);
  b.resize(N);
  c.resize(N);
  rep(i,0,N - 1) cin >> a[i] >> b[i] >> c[i];

  i64 ans;
  int d[] = {1,-1};
  rep(x,0,1) rep(y,0,1) rep(z,0,1){
    vector<i64> vec;
    rep(i,0,N - 1){
      vec.push_back(a[i] * d[x] + b[i] * d[y] + c[i] * d[z]);
    }
    sort(vec.rbegin(),vec.rend());
    i64 sum = 0;
    rep(i,0,M - 1){
      sum += vec[i];
    }
    if(x == 0 && y == 0 && z == 0){
      ans = sum;
    }
    else{
      ans = max(sum,ans);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define int long long

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

struct edge{int from, to, coin;};
edge es[5500];

int d[3000], dd[3000];
int N, M, P;

pair<int, bool> shortest_path(int s) {
    rep(i, N) {
        d[i] = INF;
    }
    d[s] = 0;
    int cnt = 0;
    while(true) {
        cnt ++;
        bool update = false;
        rep(i, M) {
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.coin) {
                d[e.to] = d[e.from] + e.coin;
                update = true;
                if(cnt > N - 1 && e.to == N - 1) return make_pair(-1, false);
            }
        }
        if(!update) break;
        if(cnt > 4 * N + 1) break;
    }
    return make_pair(d[N - 1] * (-1), true);
}

bool find_negativeloop() {
    memset(dd, 0, sizeof(dd));
    rep(i, N) {
        rep(j, M) {
            edge e = es[j];
            if(d[e.to] > d[e.from] + e.coin) {
                d[e.to] = d[e.from] + e.coin;
                if(i == N - 1) return true;
            }
        }
    }
    return false;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    cin >> N >> M >> P;
    rep(i, M) {
        int a, b, c; cin >> a >> b >> c;
        a --; b --;
        es[i] = edge{a, b, (-1) * (c - P)};
    }
    pair<int, bool> ans = shortest_path(0);
    if(ans.sc == false) {
        cout << -1 << endl;
    } else {
        int res = ans.fr;
        if(res < 0) res = 0;
        cout << res << endl;
    }
    
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int a[n+1],b[n];
  for(int i=0;i<n+1;i++){
    scanf("%d",&a[i]);
  }
  for(int i=0;i<n;i++){
    scanf("%d",&b[i]);
  }
  long long int ans=0;
  for(int i=0;i<n;i++){
    if(a[i]>0){
      if(a[i]>=b[i]){
        ans += b[i];
        continue;
      }else{
        ans+=a[i];
        b[i] -= a[i];
      }
    }
    if(a[i+1]>b[i]){
      ans+=b[i];
      a[i+1] -= b[i];
    }else{
      ans += a[i+1];
      a[i+1] = 0;
    }
  }
  printf("%lld",ans);

  return 0;
}


Measured memory_bytes: 896
// ABC 160-C
// 2020.3.28 bal4u

#include <stdio.h>

#define gc() getchar_unlocked()
int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int A[200005]; int N;
int main()
{
	int i, K, t, ans;

	K = in(), N = in();
	ans = 0;
	A[0] = in();
	for (i = 1; i < N; ++i) {
		A[i] = in();
		if (A[i]-A[i-1] > ans) ans = A[i]-A[i-1];
	}
	if (K-A[N-1]+A[0] > ans) ans = K-A[N-1]+A[0];
	printf("%d\n", K-ans);
	return 0;
}


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

using namespace std;

int main() {
    int A, B, K;
    vector<int> v;
    cin >> A >> B >> K;
    for(int i = 1; i <= A; ++i) {
        if(A%i == 0 && B%i == 0){
            v.emplace_back(i);
        }
    }
    cout << v.at(v.size()-K) << endl;
    return 0;
}

Measured memory_bytes: 256
from heapq import heapify,heappop,heappush
N,M=map(int,input().split())
item=[list(map(int,input().split())) for i in range(N)]
item.sort(key=lambda x:x[0])
que=[]
heapify(que)
ans=0
j=0
for i in range(1,M+1):
    while(j<N and item[j][0]<=i):
        heappush(que,-item[j][1])
        j+=1
    if que:
        ans+=-heappop(que)
print(ans)

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	string S; cin >> S;

	if(S <= "2019/04/30") cout << "Heisei" << endl;
	else cout << "TBD" << endl;

	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
struct D{int t,u,k,l,c;};main(){for(int X,Y,t,u,k,l,d[50][50],a[4]={1,0,-1,0};std::cin>>X>>Y>>t>>u>>k>>l,X;~k?printf("%d\n",k):puts("NA")){std::queue<D>q;D p={t-1,u-1,k-1,l-1,0},r;q.push(p);for(u=0;u<Y;u++)for(t=0;t<X;t++)std::cin>>d[t][u];bool v[50][50][50][50]={0};for(k=-1;q.size();){p=q.front();q.pop();if(p.t==p.k&&p.u==p.l){k=p.c;break;}v[p.t][p.u][p.k][p.l]=1;for(t=4;t-->0;){r=p;r.t+=a[t];r.u+=a[(t+3)%4];r.k+=a[(t+2)%4];r.l+=a[(t+1)%4];r.c++;if(r.t<0|X<=r.t|r.u<0|Y<=r.u|d[r.t][r.u]){r.t=p.t;r.u=p.u;}if(r.k<0|X<=r.k|r.l<0|Y<=r.l|d[r.k][r.l]){r.k=p.k;r.l=p.l;}if(!v[r.t][r.u][r.k][r.l])q.push(r);v[r.t][r.u][r.k][r.l]=1;}}}}

Measured memory_bytes: 7284
use proconio::*;

fn run() {
    input! {
        a: u64,
        b: u64,
        n: u64,
    }
    let x = std::cmp::min(b - 1, n);
    let ans = a * x / b - a * (x / b);
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 2148
use std::io::*;
use std::str::FromStr;

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    if s.len() < 2 {
        println!("0");
        return;
    }
    
    let mut ans: usize = 0;
    let mut rena = 0;
    let mut i = 0;
    while i < s.len() {
        if s[i] == 'A' {
            rena += 1;
            i += 1;
        } else if i < s.len()-1 && s[i] == 'B' && s[i+1] == 'C' {
            ans += rena;
            i += 2;
        } else {
            rena = 0;
            i += 1;
        }
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL inf = 11234567890;

int main()
{
	LL N, K;
	in >> N >> K;
	std::vector<LL>t(N), d(N);
	rep(i, N) in >> t[i] >> d[i];

	std::vector<std::pair<LL, LL>>sushi;
	std::vector<std::vector<LL>>val(N + 1);
	LL max_idxs = 0;
	rep(i, N) sushi.push_back(std::make_pair(d[i], t[i]));
	std::sort(sushi.rbegin(), sushi.rend());
	for (auto s : sushi) val[s.second].push_back(s.first);
	for (LL i = 1; i <= N; ++i)
	{
		std::sort(val[i].rbegin(), val[i].rend());
		if (val[i].size() > 0) ++max_idxs;
	}

	LL res = 0;
	std::set<LL>idxs;
	std::priority_queue<LL, std::vector<LL>, std::greater<LL>>min_queue;
	std::priority_queue<LL, std::vector<LL>>max_queue;
	rep(i, K)
	{
		res += sushi[i].first;
		if (idxs.find(sushi[i].second) != idxs.end()) min_queue.push(sushi[i].first);
		idxs.insert(sushi[i].second);
	}
	for (LL i = 1; i <= N; ++i) if (idxs.find(i) == idxs.end() && val[i].size() > 0) max_queue.push(val[i][0]);

	LL ans = res + (LL)idxs.size()*(LL)idxs.size(), cnt = idxs.size();
	max_idxs = std::min<LL>(max_idxs, cnt + min_queue.size());
	while (cnt < max_idxs)
	{
		LL min_n = min_queue.top(); min_queue.pop();
		LL max_n = max_queue.top(); max_queue.pop();
		res -= min_n;
		res += max_n;
		++cnt;
		ans = std::max(ans, res + cnt * cnt);
	}

	out << ans << std::endl;
}


Measured memory_bytes: 12144
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i <<= 1)
    ans = i;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
const int INF = 0x3f3f3f3f;

signed main() {
	cout << fixed << setprecision(8);
	for (int D, E; cin >> D >> E && D;) {
		double mini = INF;
		rep(x, 0, D + 1) {
			int y = D - x;

			double d = abs(sqrt(x * x + y * y) - E);
			if (d < mini) {
				mini = d;
			}

		}
		cout << mini << endl;
	}
	return 0;
}


Measured memory_bytes: 3248
import bisect as bi
import collections as cc
I=lambda:list(map(int,input().split()))
d=cc.defaultdict(int)
n,=I()
l=I()
ans=0
for i in range(n):
    d[l[i]+i]+=1
    ans+=d[i-l[i]]
print(ans)
    
    
    

Measured memory_bytes: 151224
def main():
    S = input()
    if S[0] != "A":
        return "WA"
    elif S[2:-1].count("C") != 1:
        return "WA"
    else:
        alf = "abcdefghijklmnopqrstuvwxyz"
        flag = "AC"
        for s in S[1:len(S)]:
            if (not s == "C") and (not s in alf):
                flag = "WA"
    return flag

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


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

double dp[310][310][310];
int main(){
  int N; cin >> N; int a[3]={0};
  rep(i, N){
    int x; cin >> x; x--; a[x]++;
  }
  double tmp = 1.0;
  rep(k, N+1){
    rep(j, N+1){
        rep(i, N+1){
        if(i+j+k>N) continue;
        if(i>0) dp[i][j][k] += dp[i-1][j][k]*i/N;
        if(j>0) dp[i][j][k] += dp[i+1][j-1][k]*j/N;
        if(k>0) dp[i][j][k] += dp[i][j+1][k-1]*k/N;
        if(i+j+k>0) {(dp[i][j][k] += 1) *= 1.0 * N / (i + j + k);}
      }
    }
  }
  printf("%.12lf\n", dp[a[0]][a[1]][a[2]]);
}

Measured memory_bytes: 225536
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+10;
bool vis[N];
int in[N];
int dp[N];
int n,m;
vector<vector<int >> g;
void dfs(int u){
    vis[u]=1;
    for(int i=0;i<g[u].size();i++){
        dp[g[u][i]]=max(dp[g[u][i]],dp[u]+1);
        in[g[u][i]]--;
        if(in[g[u][i]]==0)dfs(g[u][i]);
    }
}
main()
{
    cin>>n>>m;
    g.resize(n+1);
    while(m--){
        int a,b;
        scanf("%lld%lld",&a,&b);
        g[a].push_back(b);
        in[b]++;
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(!vis[i]&&!in[i])dfs(i);
    }
    for(int i=1;i<=n;i++){
        ans=max(ans,dp[i]);
    }
    cout<<ans;
}


Measured memory_bytes: 10496
use std::io;

fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().split(' ').flat_map(str::parse).collect()
}

fn main() {
    let l1 = read::<u32>();

    let a = l1.get(0).unwrap();
    let b = l1.get(1).unwrap();

    println!("{} {}", a * b, a * 2 + b * 2);
}



Measured memory_bytes: 5024
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

    int a, b; cin>>a>>b;

    for(int i=1; i<=10000; i++){
        int ca = i * 0.08;
        int cb = i * 0.10;

        if(ca == a && cb == b){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var XYZ = Console.ReadLine().Split(' ')
                .Select(str => int.Parse(str))
                .ToList();
            var X = XYZ[0];
            var Y = XYZ[1];
            var Z = XYZ[2];
            var n = (X - Z) / (Y + Z);
            Console.WriteLine(n);
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

const int MAX = 1e5+10;
const int MOD = 1e9+7;

int main(){
    int N,M; cin >> N >> M;
    vector<ll> x(N), y(M);
    for(int i=0;i<N;i++) cin >> x[i];
    for(int i=0;i<M;i++) cin >> y[i];

    ll x_sum = 0ll;
    ll y_sum = 0ll;
    for(int i=1;i<N;i++){
        ll x_tmp = x[i] - x[i-1];
        x_sum += x_tmp * i * (N-i);
        x_sum %= MOD;
    }

    for(int j=1;j<M;j++){
        ll y_tmp = y[j] - y[j-1];
        y_sum += y_tmp * j * (M-j);
        y_sum %= MOD;
    }

    cout << (x_sum * y_sum) % MOD << endl;

    return 0;
}

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

using namespace std;

#define ge getchar()
#define Re read()

inline int read() {
	int x = 0, t = 0, ch;
	while(!isdigit(ch = ge)) ;
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = ge;
	return t ? -x : x;
}

const int MAXN = 2000;
const int mod = 1000000007;

int a[MAXN + 1];
int ct[MAXN + 1];

int Mod(int x) { return x >= mod ? x - mod : x; }

int main() {
	int n = Re, k = Re, res = 0;
	for(int i = 1; i <= n; i++) ++ct[a[i] = Re];
	// for(int i = 1; i <= MAXN; i++) ct[i] += ct[i - 1];
	// for(int i = 1; i <= n; i++) res = (res + 1LL * (k * (k - 1) / 2) % mod * (n - ct[a[i]])) % mod;
	for(int i = 1; i <= n; i++)
		for(int j = i - 1; j; --j)
			if(a[j] > a[i]) res = (res + 1LL * k * (k + 1) / 2) % mod;
			else if(a[j] < a[i]) res = (res + 1LL * k * (k - 1) / 2) % mod;
	cout << res << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

const ll infll = (ll)1e18;
const int N = (int)505;
int n;
ll p_sum_pos[N][N], p_sum_neg[N][N], f[N][N], ans = infll;

ll get_p_sum_pos (int x_1, int x_2, int y_1, int y_2) { return p_sum_pos[x_2][y_2] + p_sum_pos[x_1 - 1][y_1 - 1]
                                                               - p_sum_pos[x_2][y_1 - 1] - p_sum_pos[x_1 - 1][y_2]; }

ll get_p_sum_neg (int x_1, int x_2, int y_1, int y_2) { return p_sum_neg[x_2][y_2] + p_sum_neg[x_1 - 1][y_1 - 1]
                                                               - p_sum_neg[x_2][y_1 - 1] - p_sum_neg[x_1 - 1][y_2]; }

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

//    freopen("test.INP", "r", stdin);

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j < i; ++j) cin >> p_sum_pos[i][j];
        for (int j = i + 1; j <= n; ++j) cin >> p_sum_neg[i][j];
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            p_sum_neg[i][j] += p_sum_neg[i - 1][j] + p_sum_neg[i][j - 1] - p_sum_neg[i - 1][j - 1];
            p_sum_pos[i][j] += p_sum_pos[i - 1][j] + p_sum_pos[i][j - 1] - p_sum_pos[i - 1][j - 1];
        }
    }

    for (int i = 1; i < n; ++i) ans = min(ans, get_p_sum_neg(1, i, 1, i) + get_p_sum_neg(i + 1, n, i + 1, n) );

    for (int i = 1; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            f[i][j] = get_p_sum_pos(j + 1, n, 1, i) + get_p_sum_neg(i + 1, j, i + 1, j) + get_p_sum_neg(1, i, 1, i);
        }
    }

    for (int k = 1; k < n; ++k) {
        for (int i = k + 1; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                f[i][j] = min(f[i][j], f[k][i] + get_p_sum_pos(j + 1, n, k + 1, i) + get_p_sum_neg(i + 1, j, i + 1, j) );
            }
        }
    }

    for (int i = 1; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            ans = min(ans, f[i][j] + get_p_sum_neg(j + 1, n, j + 1, n) );
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
ll Z[100005]={0};

int main(){
  ll n,k,R,S,P;
  cin>>n>>k>>R>>S>>P;
  char c;
  for(int i=1;i<=n;i++){
    cin>>c;
    if(c=='r')Z[i]=1;
    else if(c=='s')Z[i]=2;
    else Z[i]=3;
  }
  ll add[4]={0};
  add[1]=P;add[2]=R;add[3]=S;
  ll ans=0;
  for(int i=1;i<=k;i++){
    int j=i;
    int r=0;
    while(j<=n){
      if(j<=k){ans+=add[Z[j]];r++;}
      else{
        if(Z[j]!=Z[j-k]){r=1;ans+=add[Z[j]];}
        else{
          r++;
          if(r%2==1)ans+=add[Z[j]];
        }
      }
      j+=k;
    }
  }
  cout<<ans<<endl;
}


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


int main(){
  ll k;
  cin>>k;
  priority_queue<ll, vector<ll>, greater<ll> > q;
  if (k<=10){
    cout<<k;
    return 0;
  }

  for(ll i=1;i<10;i++)q.push(i);
  ll cnt=0;
  ll now;
  while (cnt<k){
    now=q.top();
  //  cout<<now<<endl;
    q.pop();
    cnt++;
    if ((now%10)==0) {
      q.push(now*10);
      q.push(now*10+1);
    }
    else if ((now%10)==9) {
      q.push(now*10+8);
      q.push(now*10+9);
    }
    else{
      q.push(now*10+now%10);
      q.push(now*10+now%10-1);
      q.push(now*10+now%10+1);
    }
  }
  cout<<now;


  }


Measured memory_bytes: 2420
#include<iostream>
using namespace std;
int main(){
    int n,x;
    cin>>n>>x;
    int l[n];
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    int d=l[0];
    int c=1;
    while(d<=x&&c<n+1){
        d+=l[c];
        c++;
    }
    cout<<c<<endl;
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    // Fast_IO();
    ll x, y; cin >> x >> y;
    ll Y = y;
    y -= 2 * x;
    if(y < 0) {
    	cout << "No" << endl;
    	return 0;
    }
    if(y & 1) {
    	cout << "No" << endl;
    	return 0;
    }
    y /= 2;
    ll a = x - y;
    ll b = y;
    if(b < 0 || a < 0 || a + b != x) {
    	cout << "No" << endl;
    	return 0;
    }
    cout << "Yes";
    return 0;
}

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

int main(){
  int n,k,a[26];
  fill(a,a+26,0);
  scanf("%d %d",&n,&k);
  for(int i=0;i<n;i++){
    char s[20];
    scanf("%s",s);
    a[s[0]-65]++;
  }
  priority_queue<int> q;
  int ans = 0;
  for(int i=0;i<26;i++) if(a[i]!=0) q.push(a[i]);
  while(q.size()>=k){
    int b[k];
    for(int i=0;i<k;i++){
      b[i] = q.top();
      q.pop();
      b[i]--;
    }
    for(int i=0;i<k;i++){
      if(b[i]!=0){
        q.push(b[i]);
      }
    }
    ans++;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);

		int r = scanner.nextInt();
		int D = scanner.nextInt();
		int x = scanner.nextInt();

		for(int i = 1; i <= 10; i++){
			x = r*x -D;
			System.out.println(x);
		}
		scanner.close();
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
typedef pair<ii, ii> pii;

int main(int argc, char ** argv) {
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", (a<10 && b <10) ? a*b : -1);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  map<int, int> mp;
  rep(i, n) {
    int c = 0;
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      c++;
    }
    mp[c]++;
  }
  ll ans = 0;
  for (auto e : mp) ans += 1LL * e.F * e.S;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main()
{
	double x1,y1,x2,y2,x3,y3,xp,yp;
	double s,s1,s2,s3;
	double ab,bc,ca,ap,bp,cp;
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
	ab=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	bc=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
	ca=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
	ap=sqrt((x1-xp)*(x1-xp)+(y1-yp)*(y1-yp));
	bp=sqrt((x2-xp)*(x2-xp)+(y2-yp)*(y2-yp));
	cp=sqrt((x3-xp)*(x3-xp)+(y3-yp)*(y3-yp));
	s=sqrt(((ab+bc+ca)*(-ab+bc+ca)*(ab-bc+ca)*(ab+bc-ca))/16);
	s1=sqrt(((ap+ab+bp)*(-ap+ab+bp)*(ap-ab+bp)*(ap+ab-bp))/16);
	s2=sqrt(((bp+bc+cp)*(-bp+bc+cp)*(bp-bc+cp)*(bp+bc-cp))/16);
	s3=sqrt(((cp+ca+ap)*(-cp+ca+ap)*(cp-ca+ap)*(cp+ca-ap))/16);
	if(fabs(s1+s2+s3-s)<0.000000001)puts("YES");
	else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 612
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N; cin >> N;
	int A[15];
	int x[15][15];
	int y[15][15];
	REP(i, N) {
		cin >> A[i];
		REP(j, A[i]) {
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}
	int res = 0;
	int ok[15];
	for (int bit = 0; bit < (1 << N); ++bit) {
		int cnt = 0;
		bool can = true;
		for (int i = 0; i < N; ++i) {
			if (bit & (1 << i))ok[i] = 1;
			else ok[i] = 0;
		}
		for (int i = 0; i < N; ++i) {
			if (ok[i]==1) {
				cnt++;
				for (int j = 0; j < A[i]; ++j) {
					if (ok[x[i][j]] != y[i][j]) {
							can = false;
					}
				}
			}
		}
		if (can)res = max(res, cnt);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#define m 1000000007
int main()
{
	long long sum;
	int n;
	while(~scanf("%d",&n)&&n)
	{
		sum=1;
		for(int i=1;i<=n;i++)
		{
			sum*=i;
			sum=sum%m;
		}
		printf("%lld\n",sum);
	}
}

Measured memory_bytes: 128
let s = read_line ()
let f x = let n = ref 0 in String.iter (fun c -> if c = x then incr n) s; !n
let a, b, c = f 'a', f 'b', f 'c'
let m = max a @@ max b c
let _ = print_endline @@ if max (m - a) @@ max (m - b) (m - c) > 1 then "NO" else "YES"

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n){
        int num[2000]={},co=n;
        for(int i=0;i<n;i++)cin>>num[i];
        for(int i=0;;i++){
            bool kawa=1;
            if(i==10000){
                cout<<-1<<endl;
                break;
            }
            for(int j=0;j<co&&kawa;j++)if(num[j]!=j+1)kawa=0;
            if(kawa){
                cout<<i<<endl;
                break;
            }
            num[co]=co+1;
            for(int j=0;j<=co;j++){
                if(num[j]==1)for(int k=j+1;k<=co&&num[j]==1;k++)if(num[k]!=1)swap(num[j],num[k]);
                num[j]--;
            }
            for(int j=co+1;j>=0;j--){
                if(num[j]!=0){
                    co=j+1;
                    break;
                }
            }
        }
    }
}

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

int main(){
    string str;
    int total=0;
    cin >> str;;
    int c = str.size();
    for(int i=0;i<c/2;i++){
        int b=str.size();
        if(str[i]!=str[b-i-1]) total++;
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a, b;
string s;
int main() {
    cin >> a >> b;
    cin >> s;
    if (s.length() != a + b + 1) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < a; ++i) {
        if (s[i] < '0' || s[i] > '9') {
            cout << "No" << endl;
            return 0;
        }
    }
    if (s[a] != '-') {
        cout << "No" << endl;
        return 0;
    }
    for (int i = a + 1; i <= a + b; ++i) {
        if (s[i] < '0' || s[i] > '9') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
  int n, m;
  scanf("%i %i", &n, &m);
  
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%i", &a[i]);
  }
  
  long long tot = 0;
  for (int i = 1; i < n; i++) {
    tot += (m+a[i]-a[i-1]) % m;
  }
  
  vector<int> open(m+1);
  vector<vector<int>> close(m+1);
  for (int i = 1; i < n; i++) {
    open[a[i-1]%m+1]++;
    close[a[i]].push_back(a[i-1]%m+1);
  }
    
  long long dec = 0;
  
  int count = 0;
  for (int i = 0; i+1 < n; i++) {
    if (a[i] > a[i+1]) {
      count++;
      dec += m+1 - a[i] - 1;
    }
  }  
  long long ans = tot - dec;
  for (int e : close[1]) {
    count--;
    dec -= (m+1 - e) % m;
  }
  
  for (int i = 2; i <= m; i++) {
    dec += count;
    ans = min(ans, tot - dec);
    count += open[i];
    for (int e : close[i]) {
      count--;
      dec -= (m+i - e) % m;
    }
  }
  
  printf("%lld\n", ans);
  
  return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int n,a[100010],b[100010],nn,cnt;
int main()
{
	cin>>n;nn=n;
	for(int i=1;i<=n;i++)
		cin>>b[i];
	for(int i=1;i<=n;i++)
		{
		int j=nn;
		for(;j>=1;j--)
			if(b[j]==j)
				break;
		if(!j){puts("-1");return 0;}
		a[++cnt]=j;
		for(int k=j+1;k<=nn;k++)
			b[k-1]=b[k];
		nn--;
		}
	for(int i=cnt;i>=1;i--)
		cout<<a[i]<<'\n';
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    a: [usize; n]
    }
    let p = 1_000_000_007;
    let mut sum_a = a.iter().sum::<usize>();
    let mut ans = 0;
    for i in 0..n {
        sum_a -= a[i];
        ans += sum_a % p * a[i];
        ans %= p;
    }
    println!("{}", ans);
}


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

int main () {
    int a, b;
    cin >> a >> b;
    string ans;
    if(a < b) ans = "a < b";
    else if (a > b) ans = "a > b";
    else ans = "a == b";

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3168
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N, M, D = map(int, input().split())

ans = (M - 1) * 2.0 * (N - D) / N ** 2
if D == 0:
    ans /= 2.0
print("{:.15f}".format(ans))



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

int main(){

    char num1[200000];

    int num2=0;

    int nagasa;

    scanf("%s", num1);

    nagasa = strlen(num1);

    for(int i=nagasa-1;i!=-1;i--){
        num2+=num1[i]-48;
    }

    if(num2%9==0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 2240
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  int a[n+1]={};
  int ans=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  for(int i=2;i<=n;i++){
    if(a[i]==a[i-1]){
      ans++;
      i++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll N = 100005;

ll n, ind[N], mis[N], ans, mx;
pll dt[N][2];

char col[N];
bool out[N], bl[N];

vector<ll> adj[N];
queue<ll> q;

void upd (ll C, ll V, ll T) {
	if(dt[C][0].X < V) {
		if(dt[C][0].Y != T) dt[C][1] = dt[C][0];
		dt[C][0] = {V, T};
	}
	else if(dt[C][0].Y != T && dt[C][1].X < V) {
		dt[C][1] = {V, T};
	}
}

ll get (ll C, ll T) {
	return dt[T][dt[T][0].Y == C].X;
}

void solve (ll C, ll P) {
	if(mis[C] == -1) return;
	if(!mis[C]) {
		for(auto &T : adj[C]) {
			if(T == P || out[T]) continue;
			solve(T, C);
			upd(C, get(C, T)+2-2*bl[C], T);
		}
		mis[C] = P;
	}
	else if(mis[C] != P) {
		solve(mis[C], C);
		upd(C, get(C, mis[C])+2-2*bl[C], mis[C]);
		mis[C] = -1;
	}
}

int main()
{
	scanf("%lld",&n);
	for(ll i=1;i<n;i++) {
		ll A, B;
		scanf("%lld%lld",&A,&B);
		adj[A].push_back(B); ind[B]++;
		adj[B].push_back(A); ind[A]++;
	}
	scanf("%s",col+1);
	for(ll i=1;i<=n;i++) {
		bl[i] = (col[i] == 'B');
		if(ind[i] == 1 && bl[i]) {
			out[i] = true; q.push(i);
		}
	}
	while(!q.empty()) {
		ll C = q.front(); q.pop();
		for(auto &T : adj[C]) {
			if(--ind[T] <= 1 && bl[T] && !out[T]) {
				out[T] = true; q.push(T);
			}
		}
	}
	for(ll i=1;i<=n;i++) {
		if(out[i]) continue;
		bl[i] ^= ind[i]%2;
		ans += ind[i] + !bl[i];
	}
	if(ans == 0) {puts("0"); return 0;}
	for(ll i=1;i<=n;i++) {
		if(out[i]) continue;
		solve(i, -1);
		mx = max(mx, dt[i][0].X);
	}
	printf("%lld\n", ans-mx);
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

string S;
void input(){
    cin>>S;
    string ans;
    if(S=="Sunny") ans="Cloudy"; 
    if(S=="Cloudy") ans="Rainy"; 
    if(S=="Rainy") ans="Sunny"; 
    cout<<ans<<endl;
    return;
}

void solve(){

    return;
}

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

Measured memory_bytes: 256
#include<stdio.h>
#define N 100000

int G[N] = {0};

void init() {
  int i;
  for(i=0;i<N;++i) G[i]=i;
}

int find(int x) {
  if(x == G[x]) return x;
  return G[x] = find(G[x]);
}

int eq(int a, int b) {
  if(find(a) == find(b)) return 1;
  else return 0;
}

void cone(int a,int b) {
  a = find(a);
  b = find(b);

  if(a == b) return;
  G[b] = a;
}

int main() {
  int i,j,m,v,k,s;
  init();
  scanf("%d %d\n", &s,&m);

  for(i=0;i<m;++i) {
    scanf("%d %d\n", &j,&v);
   cone(j,v);
 }
    scanf("%d\n", &k);

    for(i=0;i<k;i++) {
      scanf("%d %d\n", &j,&v);
      if(eq(j,v)){
        printf("yes\n");
      }
      else printf("no\n" );
    }

  return 0;
}

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

int main(void){
    int c;
    cin >> c;
    int a = 1;
    int tmp = 0;
    int b = 0;
    //a = 360 / c;
    //cout << a << endl;
    for (int i=1;i++;i <= 1000){
        b = a * 360;
        if (b % c == 0){
            tmp = 360 * a / c;
            break;
        }
        a++;
    }
    cout << tmp << endl;
}

Measured memory_bytes: 3592