akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
  int ans;
  char str[3];

  scanf("%s", str);
  
  char p = str[0];
  char q = str[1];
  char r = str[2];

  if(p == 'R' && q == 'R' && r == 'R') ans = 3;
  if(p == 'R' && q == 'R' && r == 'S') ans = 2;
  if(p == 'R' && q == 'S' && r == 'R') ans = 1;
  if(p == 'R' && q == 'S' && r == 'S') ans = 1;
  if(p == 'S' && q == 'R' && r == 'R') ans = 2;
  if(p == 'S' && q == 'R' && r == 'S') ans = 1;
  if(p == 'S' && q == 'S' && r == 'R') ans = 1;
  if(p == 'S' && q == 'S' && r == 'S') ans = 0;

  printf("%d\n", ans);
  return 0;
 

}

Measured memory_bytes: 1724
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<numeric>
#include<math.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    ll l, r;
    cin >> l >> r;
    int min_num = 2020;
    if ( r - l >= 2019 ) {
        cout << 0 << endl;
        return 0;
    }
    for ( ll i = l; i < r; ++i ) {
        for ( ll j =  i + 1 ; j <= r; ++j ) {
            if ( ( i * j ) % 2019 == 0 ) {
                cout << 0 << endl;
                return 0;
            }
            min_num = min( min_num, (int)(( i * j ) % 2019) );
        }
    }
    cout << min_num << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,doe,root;
int pre[202020],son[202020],now[101010],du[101010];
int g[101010],size[101010];
bool br[101010];
void add(int x,int y)
{
	++x; ++y;
	++doe;
	pre[doe]=now[x];
	now[x]=doe;
	son[doe]=y;
}
void dfs(int x,int fa)
{
	int p=now[x];
	br[x]=1;
	if (du[x]==1)
	{
		g[x]=1;
		return;
	}
	int dog=0;
	while (p)
	{
		int y=son[p];
		if (y!=fa)
		{
			dfs(y,x);
			g[x]+=g[y];
			if (br[y]) dog=max(dog,g[y]);
			br[x]&=br[y];
		}
		p=pre[p];
	}
	if (du[x]>2) br[x]=0,g[x]-=dog;
}
int main()
{
	scanf("%d",&n);
	int x,y;
	for (int i=1;i<n;++i)
		scanf("%d%d",&x,&y),add(x,y),add(y,x),++du[x+1],++du[y+1];
	for (int i=1;i<=n;++i) if (du[i]>2) root=i;
	if (!root)
	{
		printf("1\n");
		return 0;
	}
	int p=now[root];
	int dog=0;
//	printf("%d\n",root);
	while (p)
	{
		y=son[p];
		dfs(y,root);
		g[root]+=g[y];
		if (br[y]) dog=max(dog,g[y]);
		p=pre[p];
	}
//	for (int i=1;i<=n;++i) printf("%d ",g[i]);
//	printf("\n");
	printf("%d\n",g[root]-dog);
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 998244353;


int main() {
    int h1, m1, h2, m2, k; 
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t1 = 60*h1+m1, t2=60*h2+m2;
    if (t1 >= t2) t2 += 60*24;
    int ret = max(t2 - t1 - k, 0);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,K;cin >> N >> K;
  vector<PLL> v(N),w(N*N);
  rep(i,N) cin >> v[i].first >> v[i].second;
  rep(i,N) rep(j,N) w[i*N+j] = PLL(v[i].first,v[j].second);
  sort(all(w));
  w.erase(unique(all(w)),w.end());

  int M = w.size();
  //rep(i,M) cout << w[i].first SP w[i].second << endl;
  ll Rect_S = MAX_LL;
  rep(i,M)repp(j,i+1,M){
    ll x_l = w[i].first, x_u = w[j].first;
    ll y_l = w[i].second, y_u = w[j].second;
    if(y_l>y_u)swap(y_l,y_u);
    ll rect = (y_u - y_l)*(x_u - x_l);
    if(rect == 0)continue;
    int count = 0;
    rep(k,N){
      if(x_l<= v[k].first &&
          v[k].first <= x_u &&
          y_l <= v[k].second &&
          v[k].second <= y_u ) ++count;
    }
    if(count>=K) Rect_S = min(Rect_S, rect);
  }

  cout << Rect_S << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size())cout << a[i] << " "
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;string S;
    cin >> N >> S;
    map<char,ll> ma;
    rep(i,N){
        ma[S[i]]++;
    }
    ll ans = 1;
    for(char c = 'a';c <= 'z';c++){
        ans *= (ma[c] + 1);
        ans %= mod;
    }
    cout << (ans - 1 + mod) % mod << endl;
}


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

#define ll long long

int main() {
  ll n, a;
  // num : 比較する数字、cnt : レンガを壊したカウント
  ll num = 1, cnt = 0;
  cin >> n;
  for(ll i = 0; i < n; i++) {
      cin >> a;
      // 満足するブロックか
      if(a == num) num++;
      // 壊すブロックか
      else cnt++;
  }
  cout << fixed << (cnt == n ? -1 : cnt);
}

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

using namespace std;

int main() {
  int n,k; cin >> n >> k;
  vector<int> as(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> as[i];
  }
  n -= k;
  int ans = 1;
  while (n > 0) {
    n -= (k - 1);
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
//~ const ll inf = 1e18+5;
ll n, k, fw[100100];
const ll mod = 1e9+7;
ll add(ll a, ll b){
	return (a%mod+b%mod + mod)%mod;
}
ll sub(ll a, ll b){
	return (a%mod -b%mod + mod)%mod;
}
void upd(ll p, ll v){
	for (ll i= p; i <= k+5; i+=(i&(-i)))fw[i] = add(fw[i], v);
}
ll qry(ll p){
	ll res = 0;
	for (ll i= p; i > 0; i -= (i&(-i)))res  = add(res, fw[i]);
	return res%mod;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> k;
	ll sumai = 0;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++){
		cin >> a[i];
		sumai += a[i];
	}
	if (sumai < k){
		cout << 0; return 0;
	}
	ll cursum = 0;
	//fw[1] = 1;
	upd(1, 1);
	upd(2, -1);
	//~ dp[0] = 1;
	//RUPQ
	for (ll i= 0; i < n; i++){
		for (ll j = k; j >= 0; j--){
				//im essentially doing the same thing here, i can add values to all using a fenwick
				//~ for (ll kk = 1; kk <= min(a[i], k-j); kk++){
					//~ dp[kk+j] += dp[j];
				//~ }
				ll qq = qry(j+1)%mod;
				ll L = j+1+1, R = min(a[i], k-j)+j+1;
				if (R >= L ){upd(L, qq);upd(min(R+1, k+2), -qq);}
				//~ else {upd(L+j, qq);upd(k+1, -qq);}
				
			//~ cursum += a[i];
		}
	}
	//~ cout << dp[k];
	//~ for (ll i = 0; i <= k; i++)cout << dp[i] << ' ';
	//~ ll ans = qry(k+1)-qry(k);
	//cout << qry(k+1);
	//~ for (ll i = 1; i <= k+1; i++)cout << qry(i) << ' ';
	cout << qry(k+1)%mod;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define N_PRIME 1000000007
#define ll int64_t

vector<int> a;

void solve(){
    int n ;
    cin >> n;
    
    if(  n == 1 )exit(0);
    
    cout << n << ":";
    
    int x;
    for(int i = 0 ; i < a.size() ; i++ ){
        if( n % a[i] == 0 ){
            cout <<" "<< a[i];
        }
    }
    
    cout << endl;
}

int main(void){
    bool p[400000];
    for(int i = 0 ; i < 4e5 ; i++ ){
        p[i] = true;
    }
    p[0] = false;
    p[1] = false;
    for(int i = 2 ; i < 4e5 ; i++ ){
        if( (i % 7 == 1 || i % 7 == 6) && p[i] ){
            a.push_back(i);
            for(int j  = i * 2 ; j < 4e5 ; j+= i ){
                p[j] = false;
            }
        }
    }
    
    //cout << p[299998] << endl;
    
    /*
    cout << a.size() << endl;
    for(int i = 0 ; i < 100 ; i++ ){
        cout << a[i] << endl;
    }*/
    while(true)solve();
    
    return 0;
}

Measured memory_bytes: 3620
#include<stdlib.h>
#include<stdio.h>

int compare_ascending(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    int x[m];
    for(int i=0; i<m; i++){
        scanf("%d", &x[i]);
    }
    qsort(x, m, sizeof(int), compare_ascending);
    int len[m-1];
    for(int i=0; i<m-1; i++){
        len[i] = x[i+1] - x[i];
    }
    qsort(len, m-1, sizeof(int), compare_ascending);
    int ans = 0;
    n--;
    for(int i=m-2; i>=0; i--){
        if(n > 0){
            n--;
        }else{
            ans += len[i];
        }
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 1396
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vec<int>a(N);
  REP(i,N){
    cin>>a[i];
  }
  sort(ALL(a));
  cout<<a[N-1]-a[0]<<"\n";
  return 0;
}

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

const int N = 100;
const int L = 1000;
const int INF = 1e+8 + 10;
const int MAX_V = L * 2 + 2;

struct data{
  int p, t;
  data(int p=0, int t=0):p(p),t(t){}
  bool operator < (const data &d) const {
    return t < d.t;
  }
};

struct edge{
  int to, cap, rev;
  edge(int t=0, int c=0, int r=0):to(t),cap(c),rev(r){}
};
  
void add_edge(const int &from, const int &to, const int &cap, vector<edge> G[MAX_V]){
  G[from].push_back(edge(to, cap, G[to].size()));
  G[to].push_back(edge(from, 0, G[from].size()-1));
}
 
int dfs_f(int v, int t, int f, vector<edge> G[MAX_V], bool used[MAX_V]){
  if(v == t) return f;
  used[v] = true;
  for(int i=0;i<G[v].size();i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs_f(e.to, t, min(f, e.cap), G, used);
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}
 
int max_flow(int s, int t, vector<edge> G[MAX_V]){
  int flow = 0;
  while(1){
    bool used[MAX_V];
    fill(used, used+MAX_V, false);
    int f = dfs_f(s, t, INF, G, used);
    if(f == 0) return flow;
    flow += f;
  }
}



int n, m, l, G[N][N];
vector<data> v;

int solve(){
  vector<edge> fG[MAX_V];

  for(int i=0;i<n;i++) G[i][i] = 0;
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }

  sort(v.begin(), v.end());
  for(int i=0;i<l;i++){
    add_edge(l*2, i, 1, fG);
    add_edge(l+i, l*2+1, 1, fG);
    //add_edge(i, l+i, 1, fG);
    for(int j=i+1;j<l;j++){
      if(G[v[i].p][v[j].p] < INF && v[i].t + G[v[i].p][v[j].p] <= v[j].t) {
        add_edge(j, l+i, 1, fG);
      }
    }
  }

  // ?????§???????????? = V - ????°?????????????
  return l - max_flow(l*2, l*2+1, fG);
}

int main(){
  int x, y, d;
  while(cin >> n >> m >> l && (n|m|l)){
    fill(G[0], G[n], INF);
    v.clear();
    for(int i=0;i<m;i++){
      cin >> x >> y >> d;
      G[x][y] = min(G[x][y], d);
      G[y][x] = min(G[y][x], d);
    }
    for(int i=0;i<l;i++){
      cin >> x >> y;
      v.push_back(data(x,y));
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 17064
#include <cstdio>

int main() {
  int a[120];
  int n;
  
  
  scanf("%d", &n);
  for (int i=0; i<n; i++) {
    scanf("%d", &a[i]);
  }


  int count = 0;
  for (int i=0; i<n; i++) {
    int minj = i;

    for (int j=i; j<n; j++) {
      if (a[j] < a[minj]) {
	minj = j;
      }
    }

    if (a[i] != a[minj]) {
      int tmp = a[i];
      a[i] = a[minj];
      a[minj] = tmp;
      count++;
    }
  }
  
 
  for (int i=0; i<n-1; i++) {
    printf("%d ", a[i]);
  }
  printf("%d\n", a[n-1]);
  printf("%d\n", count);
}

Measured memory_bytes: 2712
N, M = map(int, input().split())
num = [None] * N
FLG = True

for _ in range(M):
    i, digit = map(int, input().split())
    i -= 1
    if num[i] is not None and num[i] != digit:
        FLG = False
    else:
        num[i] = digit

if FLG:
    for i,digit in enumerate(num):
        if i == 0 and digit is None:
            if N == 1:
                num[i] = "0"
            else:
                num[i] = "1"
        elif i != 0 and digit is None:
            num[i] = "0"
        else:
            num[i] = str(digit)

    ans = "".join(num)
    if ans == str(int(ans)):
        print(int(ans))
    else:
        print(-1)

else:
    print(-1)


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

using namespace std;

int main() {
  string str;
  getline(cin, str);

  int pos = -1;
  while (pos = str.find(',', pos + 1), pos != string::npos)
    str.replace(pos, 1, " ");
  pos = -1;
  while (pos = str.find('.', pos + 1), pos != string::npos)
    str.replace(pos, 1, " ");

  stringstream ss(str);
  vector<string> ans;
  string tmp;
  while (ss >> tmp) {
    if (3 <= tmp.length() && tmp.length() <= 6)
      ans.push_back(tmp);
  }

  if (ans.size() != 0) {
    cout << ans[0];
    for (auto itr = ans.begin() + 1; itr != ans.end(); ++itr)
      cout << " " << *itr;
    cout << endl;
  }
}


Measured memory_bytes: 3076
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define ull unsigned long long
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;
const int MOD=1e9+7;

int main()
{
    long double a, b, h, m;
    in a>>b>>h>>m;
    long double kakudo = M_PI*2*((long double)h/12+(long double)m/60/12-(long double)m/60);

    long double yogen = (long double)(a*a+b*b)-(long double)(2*a*b*cosl(kakudo));

    printf("%.20Lf\n",sqrt(yogen));
}


Measured memory_bytes: 4164
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N;
    cin >> N;
    vector<ll> a(N);
    ll prev = -INF, sum = 0, cnt = 0, ans = INF;
    // 偶数番目が正
    rep(i, N) {
        cin >> a[i];
        sum += a[i];
        if (prev <= 0 && sum <= 0) {
            cnt += (1 - sum);
            sum = 1;
        } else if (prev >= 0 && sum >= 0) {
            cnt += (abs(-1 - sum));
            sum = -1;
        }
        prev = sum;
    }

    ans = min(ans, cnt);

    prev = INF, sum = 0, cnt = 0;
    //偶数番目が負
    rep(i, N) {
        sum += a[i];
        if (prev <= 0 && sum <= 0) {
            cnt += (1 - sum);
            sum = 1;
        } else if (prev >= 0 && sum >= 0) {
            cnt += (abs(-1 - sum));
            sum = -1;
        }
        prev = sum;
    }

    ans = min(ans, cnt);

    cout << ans << endl;
}

Measured memory_bytes: 1024
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var m = int.Parse(spl[1]);

        long c = Factorial(n);
        c *= Factorial(m);
        c %= Mod;

        if (Math.Abs(n - m) > 1) return 0;
        if (n == m) return (c * 2) % Mod;
        return c;
    }

    static long Factorial(long n) {
        long ans = 1;
        for (long i = n; i > 0; i--) {
            ans *= i;
            ans %= Mod;
        }
        return ans;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13140
import string

count = {x: 0 for x in string.ascii_lowercase}
lines = ''

while True:
    try:
        lines += input().lower()
    except EOFError:
        break

for c in lines:
    if 'a' <= c <= 'z':
        count[c] += 1

for key in string.ascii_lowercase:
    print("{0} : {1}".format(key, count[key]))

Measured memory_bytes: 7996
n = int(input())

R = [int(input()) for _ in range(n)]

ans = -float('inf')
min_r = R[0]

for i in range(1, n):
    if ans < R[i] - min_r:
        ans = R[i] - min_r
    if R[i] < min_r:
        min_r = R[i]

print(ans)


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

struct UnionFind {
  vector<int> data;

  UnionFind(int size) {
    data.assign(size, -1);
  }

  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }

  int find(int k) {
    if (data[k] < 0) return k;
    return data[k] = find(data[k]);
  }

  bool is_same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
  int N, Q;
  cin >> N >> Q;
  UnionFind uf = UnionFind(N);
  while (Q--) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0) {
      uf.unite(x, y);
    } else {
      cout << uf.is_same(x, y) * 1 << endl;
    }
  }
}


Measured memory_bytes: 3148
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;

    bool ans = false;
    for (int i=0; i<=25; i++) {
        for (int j=0; j<=15; j++) {
            if (4*i + 7*j == n) ans = true;
        }
    }
    cout << (ans? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int s=sc.nextInt();
  	int w=sc.nextInt();
  	if(s>w){
  		System.out.print("safe");
  	}else{
  		System.out.print("unsafe");
  	}
  }
}

Measured memory_bytes: 35728
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n; cin>> n;
	vector<int> a(n);
	REP(i, n) cin >> a[i];
	bool ch = true;
	while(ch){
		REP(i, n){
			if(a[i] % 2 == 1) ch = false;
			else a[i] /= 2;
		}
		if(ch)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
int main(){
    ll n,m;
    cin>>n>>m;
    ll cnt = 0;
    if(2*n>=m){
        cnt+=m/2;
    }else{
        cnt+=(m-2*n)/4 + n;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  for(int i=0;i<N;i++){
    int K,P;
    cin>>K>>P;
    if(K%P==0) cout<<P<<endl;
    else cout<<K%P<<endl;
    
    }
  return 0;
}


Measured memory_bytes: 3048
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d);
    
}



Measured memory_bytes: 256
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
SP = [sr().split() for _ in range(N)]
SP = [(s, 100 - int(p), i) for i, (s, p) in enumerate(SP, 1)]
SP.sort(key=lambda x: (x[0], x[1]))
for s, p, i in SP:
    print(i)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ll N, K;
ll R, S, P;
string T;

ll X[100100][3];
ll Y[100100];
ll DP[100100][3];

int main(){
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;

    REP(k,K){
        for(int i = k; i < N; i+=K){
            char c = T[i];
            ll dp[3];
            REP(j,3) dp[j] = DP[k][j];

            DP[k][0] = max(dp[1], dp[2]);
            DP[k][1] = max(dp[0], dp[2]);
            DP[k][2] = max(dp[0], dp[1]);

            //gu
            if(c == 'r'){
                DP[k][0] += P;
            }
            //tyoki
            else if(c == 's'){
                DP[k][1] += R;
            }
            //pa
            else{
                DP[k][2] += S;
            }
            ////gu
            //if(c == 'r'){
            //    DP[k][0] += P + max(DP[k][1], DP[k][2]);
            //}
            ////tyoki
            //else if(c == 's'){
            //    DP[k][1] += R + max(DP[k][0], DP[k][2]);
            //}
            ////pa
            //else{
            //    DP[k][2] += S + max(DP[k][0], DP[k][1]);
            //}
        }
    }

    ll ans = 0;
    REP(i,K){
        ll tmp = 0;
        REP(j,3){
            chmax(tmp, DP[i][j]);
        }
        ans += tmp;
    }

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


Measured memory_bytes: 4608
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    var sum = 1
    var ans = 0
    while (sum < b) {
        sum = sum + a - 1
        ans++
    }
    println(ans)
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    int s,w;
    cin >> s >> w;
    if(w>=s){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
}


Measured memory_bytes: 3636
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        Map<Integer, Integer> valueToCount = new HashMap<>();
        for (int i = 0; i < N; i++) {
            int value = sc.nextInt();
            if (valueToCount.containsKey(value)) {
                valueToCount.put(value,  valueToCount.get(value)+ 1);
            } else {
                valueToCount.put(value, 1);
            }
        }

        List<Integer> counts = new ArrayList<>();
        for (Integer count : valueToCount.values()) {
            counts.add(count);
        }
        Collections.sort(counts);

        int ans = 0;
        for (int i = 0; i < counts.size() - K; i++) {
            ans += counts.get(i);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 101552
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>  //for bool
#include <stdlib.h> // abs,labs,llabs
#include <limits.h>
#include <ctype.h>

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld; //%Lf

int main(void) {
  int m, d, i = 0, j = 0, ans = 0, f = 0, l = 0, x = 0;
  scanf("%d %d", &m, &d);
  for (i = 1; i <= m; i++) {
    for (j = 1; j <= d; j++) {
      if (j < 22) {
        continue;
      } else {
        x = j;
        f = x % 10;
        x = x / 10;
        l = x % 10;
        if (f * l == i && f >= 2 && l >= 2) {
          ans++;
          // printf("%d %d\n", (f * l), j);
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn combination_two(n: usize) -> usize {
    if n == 2 {
        return 1;
    }
    if n < 2 {
        return 0;
    }
    n * (n - 1) / 2
}

fn main() {
    input! {
        n: usize,
        m: usize,
    }
    println!("{}", combination_two(n) + combination_two(m));
}

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

int main(){
    long long a,b,c=0,d,x=0,y=0,z=0;
    cin>>a>>b>>c;
    z=b+c;
    if(a>=z){cout<<0; return 0;}
    if(a<z){z-=a; cout<<z;}
    return 0;
}


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

//Algorithm
#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define ALL(a) (a).begin(), a.end()

std::string S, T;
int main() {
    std::cin >> S;
    std::cin >> T;

    std::set<std::string> pattern;

    int slen = S.length(), tlen = T.length();
    for(int i=0; i+tlen<=slen; ++i) {
        bool f = true;
        std::string str = S;
        for(int j=0; j<tlen; ++j) {
            str[i+j] = T[j];
            if(S[i+j] != '?' && S[i+j] != T[j]) {
                f = false;
                break;
            }
        }
        if(f) {
            pattern.insert(str);
        }
    }

    if(pattern.size() > 0) {
        std::string ans = *std::min_element(ALL(pattern));
        EACH(c, ans) {
            std::cout << (*c == '?' ? 'a' : *c);
        }
        std::cout << std::endl;
    } else {
        std::cout << "UNRESTORABLE" << std::endl;
    }
}

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

#define swap(type,a,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(int i=0;i<n;i++)
#define forS(i,start,n) for(int i=start;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}
#define DOUBLE fixed << setprecision(10)

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

int main(){
    int n,m,i=0,j=0,cnt=0;
    
    cin >> n >> m;
    vector<vector<int>> k(m);
    forN(i,m){
        int tmp;cin >> tmp;
        k[i] = vector<int>(tmp);
        forN(j,k[i].size()){
            cin >> k[i][j];
            k[i][j] -= 1;
        }
    }
    vi p(m);
    forN(i,m){
        cin >> p[i];
    }
    vector<int> s(n);
    forN(i,pow(2,n)){
        bool res=true;
        int tmp = i;
        for(int j=0; j<n; j++){
            s[j] = (int)(tmp&1);
            tmp >>= 1;
        }
        forN(j,m){
            int tmp = 0;
            forN(l,k[j].size()){
                tmp += s[k[j][l]];
            }
            tmp+=(p[j]+1);
            res&=(tmp&1);
        }
        if(res)cnt++;
    }
    cout << cnt << endl;
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

int main(){
	// int a,b,c,d,e; cin>>a>>b>>c>>d>>e;
	// vi o(5);
	int ans = 0;
	int max_dif = 0;
	int a;
	rp(i,5){
		cin>>a;
		int dif = (a/10 + bool(a%10)) * 10 - a;
		if(max_dif<dif){
			max_dif = dif;
		}
		ans += a + dif;
	};
	ans -= max_dif;
	ote(ans);
}


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

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

fn main() {
    let s: String = read();
    let x: Vec<char> = s.chars().collect();
    println!("{}{}{}", x.first().unwrap(), s.len() - 2, x.last().unwrap());
}

Measured memory_bytes: 2076
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;

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


Measured memory_bytes: 5164
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		long[] L = new long[N];
		long[] R = new long[N];
		int a, al, ar;
		for(int i = 0; i < N; i++) {
			a = scanner.nextInt();
			al = i + a; if(al < N) L[al]++;
			ar = i - a; if(ar > -1) R[ar]++;
		}
		long count = 0;
		for(int i = 0; i < N; i++) {
			count += L[i] * R[i];
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 53308
n=int(input())
arr=list(map(int,input().split()))
suma=sum(arr)
suff=[suma]*n
mod=1000000007
suff[n-1]=arr[n-1]
for i in range(n-2,-1,-1):
    suff[i]=suff[i+1]+arr[i]
ans=0
for i in range(1,n):
    ans+=arr[i-1]*suff[i]
    ans%=mod
print(ans)

Measured memory_bytes: 94160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x;
  cin >> x;
  
  if (x <= 599) {
    cout << "8" << endl;
  }
  else if (x <= 799) {
    cout << "7" << endl;
  }
  else if (x <= 999) {
    cout << "6" << endl;
  }
  else if (x <= 1199) {
    cout << "5" << endl;
  }  
  else if (x <= 1399) {
    cout << "4" << endl;
  }
  else if (x <= 1599) {
    cout << "3" << endl;
  }
  else if (x <= 1799) {
    cout << "2" << endl;
  }
   else if (x <= 1999) {
    cout << "1" << endl;
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

int maxN = 2'000'005;
int k, x;
vector<int> p(maxN);

void input() {
    cin >> k >> x;
}

void solve() {
    for(int i = -k + 1; i < k; i++ ) {
        //p.push_back(x + i);
        cout << x + i << endl;
    }

}


int main() {
    input();
    solve();

}


Measured memory_bytes: 8064
#include <stdio.h>


int main(){
	int a, b, t, x=0, i=0, k;
	scanf("%i %i %i", &a, &b, &t);
	if(a>t){
		printf("0\n");
		return 0;
	}
	else{
		k=t/a;
		while(k--){
		x=x+b;
		}	
	}
	printf("%i\n", x);

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N; cin >> N;
    vector<Int> A(N); for (auto &a : A) cin >> a;
    sort(begin(A), end(A));
    Int ans = 0;
    if (N % 2 == 0) {
        Int a = 0;
        for (int i = 0; i < N/2; i++) a -= 2*A[i];
        for (int i = N/2; i < N; i++) a += 2*A[i];
        a += A[N/2-1] - A[N/2];
        ans = a;
    } else {
        Int a = 0;
        for (int i = 0; i < N/2; i++) a -= 2*A[i];
        a += A[N/2];
        for (int i = N/2+1; i < N; i++) a += 2*A[i];
        ans = a - A[N/2+1];
        a = 0;
        for (int i = 0; i < N/2; i++) a -= 2*A[i];
        a -= A[N/2];
        for (int i = N/2+1; i < N; i++) a += 2*A[i];
        ans = max(ans, a + A[N/2-1]);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int inf=1e9;
const ll INF=1e18;
const double pi=3.1415926535897932384626433832;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int h,w,c[15][15]={},a[205][205]={},ans=0;
  cin >> h >> w;
  for(int i=0; i<10; i++) {
    for(int j=0; j<10; j++) {
      cin >> c[i][j];
    }
  }
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      cin >> a[i][j];
    }
  }
  for(int i=0; i<10; i++) {
    for(int j=0; j<10; j++) {
      for(int k=0; k<10; k++) {
        if(i!=j&&i!=k&&j!=k) {
          c[j][k]=min(c[j][k],c[j][i]+c[i][k]);
        }
      }
    }
  }
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      if(a[i][j]!=-1&&a[i][j]!=1) {
        ans+=c[a[i][j]][1];
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

const int maxn = 100010;

int n, m, l[maxn], e = 0;

int A[maxn], B[maxn], C[maxn], ind[maxn], vis[maxn];
ll val[maxn], sum[maxn];

struct Edge {
	int v, x;
} E[maxn << 1];

inline void addEdge(int u, int v) {
	E[e].v = v; E[e].x = l[u]; l[u] = e++;
}

int fa[maxn];

int getroot(int x) {
	if (x == fa[x]) return x;
	return fa[x] = getroot(fa[x]);
}

bool cmp(int x, int y) {
	return C[x] < C[y];
}

int main() {
	memset(l, -1, sizeof(l));
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) scanf("%d%d", &A[i], &B[i]);
	for (int i = 1; i <= m; i++) {
		int u, v; scanf("%d%d", &u, &v);
		addEdge(u, v); addEdge(v, u);
	}
	for (int i = 1; i <= n; i++) fa[i] = ind[i] = i, C[i] = max(A[i] - B[i], 0), sum[i] = B[i];
	sort(ind+1, ind+n+1, cmp);
	for (int _ = 1; _ <= n; _++) {
		vector<int> vec;
		int i = ind[_];
		vis[i] = 1;
		for (int p = l[i]; p >= 0; p = E[p].x) if (vis[E[p].v]) vec.push_back(getroot(E[p].v));
		sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end());
		val[i] = C[i];
		for (int x = 0; x < vec.size(); x++) {
			int v = vec[x];
			// sum[v] + ? >= C[i]
			// ? >= C[i] - sum[v];
			// ? >= val[v]
			val[i] = min(val[i], max(C[i] - sum[v], val[v]));
			fa[v] = i; sum[i] += sum[v];
		}
	}
	printf("%lld\n", val[getroot(1)]+sum[getroot(1)]);
	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
const ll MOD=1e9+7;
const int INF = 0x3f3f3f3f;

int main(){
    ll n,t;
    cin>>n>>t;
    if(n<=t){
    	cout<<0<<endl;
		return 0;	
	} 
    ll a[maxn];
    ll sum=0;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    for(int i=n-t-1;i>=0;i--) ans+=a[i];
    cout<<ans<<endl;
	return 0;
}



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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif

#define MAX 300005
#define ff first
#define ss second
#define FOR(i, x, y) for(int i = x; i < y; i++)
#define ROF(i, x, y) for(int i = x; i >= y; i--)
#define sf scanf

struct Node{
    int ff, ss;
    bool operator<(const Node &a)const{
        return ff>a.ff;
    }
};
priority_queue<Node> Q;

inline void insertToSet(int val, int cnt){
    if(Q.empty() or (Q.top().ff > val)) Q.push({val, cnt});//, debug("inserting", val, cnt);
    else {
        auto now = Q.top();
        Q.pop();
        Q.push({val, now.ss + cnt});
        // debug("inserting", val, now.ss + cnt);
    }
}

inline void addToSet(int add){
    // debug("adding", add);
    while(add){
        auto now = Q.top();
        Q.pop();
        // debug("now", add, now.ff, now.ss);
        if(now.ss <= add){
            if(Q.empty()) insertToSet(now.ff + 1, now.ss), add -= now.ss;
            else{
                auto nxt = Q.top();
                int canRaiseUpto = min(nxt.ff, now.ff + add / now.ss);
                insertToSet(canRaiseUpto, now.ss);
                add -= (canRaiseUpto - now.ff)*now.ss;
            }
        }
        else{
            insertToSet(now.ff + 1, add);
            insertToSet(now.ff, now.ss - add);
            add = 0;
        }
    }
}

int ar[MAX];
int f[MAX];
int ff[MAX];
int ans[MAX];

int main(){
    #ifdef VAMP
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    memset(ans, -1, sizeof(ans));
    int n; sf("%d", &n);
    FOR(i, 0, n){
        sf("%d", &ar[i]);
        ++f[ar[i]];
    }
    sort(f+1, f+n+1);
    FOR(i, 1, n+1){
        ++ff[f[i]];
    }
    FOR(i, 0, n+1){
        if(ff[i]){
            // debug(i, ff[i]);
            Q.push({i, ff[i]});
        }
    }
    ROF(i, n, 1){
        if(Q.empty()) continue;
        auto now = Q.top();
        Q.pop();
        ans[i-1] = now.ff;
        // debug(i, ar[i-1]);
        if(i == 1) break;
        if(now.ss - 1 > 0) Q.push({now.ff, now.ss - 1});
        if(now.ff) addToSet(now.ff);
    }
    FOR(i, 0, n) printf("%d\n", ans[i]);

    return 0;
}

Measured memory_bytes: 4736
A, B, M = map(int, input().split())
As = list(map(int,input().split()))
Bs = list(map(int,input().split()))
Ms = [input().split() for i in range(M)]

no_discount_min_plice = min(As) + min(Bs)

buy_list = [no_discount_min_plice]

for i in range(0, M):
    discount_plice = As[int(Ms[i][0])-1] + Bs[int(Ms[i][1])-1] - int(Ms[i][2])
    buy_list.append(discount_plice)

print(min(buy_list))


Measured memory_bytes: 50220
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    ll A, B;
    cin >> A >> B;
    cout << max({A + B, A - B, A * B}) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int t = 1;
    //cin >> t;
    while(t--){
        int n;
        cin >> n;
        int temp;
        vector<int> arr;
        for(int i = 0; i < 2*n; i++){
            cin >> temp;
            arr.push_back(temp);
        }
        sort(arr.begin(), arr.end());
        reverse(arr.begin(), arr.end());
        int sum = 0;
        for(int i = 2*n - 1; i >= 0; i--){
            if(i % 2 != 0){
                sum += arr[i];
            }
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 3604
using System;

namespace AOJ
{
	class Program
	{
		public static void Main(string[] args)
		{
			var i = int.Parse(Console.ReadLine());
			long f = 1;
			do
			{
				f *= i;
			}
			while(i-- > 1);
			Console.WriteLine(f);
		}
	}
}

Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    vector<pair<int, int>> x, y;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < s.size(); j++) {
            if (s[j] == '(') {
                a[i]++;
            } else {
                a[i]--;
            }
            b[i] = min(b[i], a[i]);
        }
        if (a[i] >= 0) {
            x.emplace_back(b[i], a[i]);
        } else {
            a[i] = b[i] = 0;
            for (int j = s.size() - 1; j >= 0; j--) {
                if (s[j] == ')') {
                    a[i]++;
                } else {
                    a[i]--;
                }
                b[i] = min(b[i], a[i]);
            }
            y.emplace_back(b[i], a[i]);
            a[i] = -a[i];
        }
    }
    debug(x, y);
    if (accumulate(a.begin(), a.end(), 0) != 0) {
        cout << "No" << '\n';
        return 0;
    }
    sort(x.rbegin(), x.rend());
    int sum = 0;
    for (auto p : x) {
        if (sum + p.first < 0) {
            cout << "No" << '\n';
            return 0;
        }
        sum += p.second;
    }
    sort(y.rbegin(), y.rend());
    sum = 0;
    for (auto p : y) {
        if (sum + p.first < 0) {
            cout << "No" << '\n';
            return 0;
        }
        sum += p.second;
    }
    cout << "Yes" << '\n';
    return 0;
}

Measured memory_bytes: 18984