akhauriyash/Code-Regression huggingface dataset:
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE Strict #-}
{-# LANGUAGE StrictData #-}
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.Array.Unboxed
import Data.Array.ST
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List
import Data.Char

modulus :: Int
modulus = 1000000007

main :: IO ()
main = do
    (n,k) <- (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    let f :: [Int] -> Int
        f []     = 0
        f (x:xs) = (-x^2+(n+1)*x+1 + f xs) `mod` modulus
    print $ f [0..n+1-k]

Measured memory_bytes: 10088
n = int(input())
s = input()

r_count=0
g_count=0
b_count=0

ans = 0

for i in range(n):
    if s[i]=="R":
        r_count+=1
    if s[i]=="G":
        g_count+=1
    if s[i]=="B":
        b_count+=1
ans+=r_count*g_count*b_count

t=int(n-(0.1)//2)
for i in range(1,t):
    for j in range(n-2*i):
        s_1 = s[j]
        s_2 = s[j+i]
        s_3 = s[j+i+i]
        if s_1 !=s_3 and s_2!=s_3 and s_1!=s_2:
            ans-=1
print(ans) 

Measured memory_bytes: 68176
from itertools import combinations

def main():
    n, x, y = [int(e) for e in input().split()]

    A = [0]*(n - 1)
    for c in combinations(range(1, n + 1), 2):
        cnt = min(abs(c[1] - c[0]), abs(c[1] - y) + abs(c[0] - x) + 1, abs(c[1] - x) + abs(c[0] - y) + 1)
        A[cnt - 1] += 1

    for a in A:
        print(a)

if __name__ == "__main__":
    main()


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

#define N 100

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int b[ N ] = { };
    int n, q;
    int res;

    scanf ( "%d%d", &n, &q );
    if ( n == 0 && q == 0 ) break ;

    while ( n-- )
    {
      int m;

      scanf ( "%d", &m );
      while ( m-- )
      {
        int d;

        scanf ( "%d", &d );
        ++b[ d ];
      }
    }

    res = 1;
    for ( i = 2; i < N; ++i )
    {
      if ( b[ i ] > b[ res ] )
        res = i;
    }
    printf ( "%d\n", b[ res ] >= q ? res : 0 );
  }

  return ( EXIT_SUCCESS );
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fr first
#define sc second
#define memset(X,Y) memset(X,Y,sizeof X)
#define all(X) X.begin(),X.end()
#define SZ size()
#define mp make_pair
#define pb push_back
#define Pb pop_back

template<class A, class B> ostream& operator <<(ostream &out, const pair<A, B> &p) {
    return out << "(" << p.fr << ", " << p.sc << ")";
};

template<class A> ostream& operator <<(ostream &out, const vector<A> &v) {
    out << "[";
    for(int i=0;i<(int)v.SZ;i++) {
        if(i)
            out << ", ";
        out << v[i];
    }
    return out << "]";
}

#define error(args...){vector<string> _v = split(#args,','); err(_v.begin(),args); cerr<<endl;}
vector <string> split(const string &s,char c)
{
    vector<string> v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}
void err(vector<string>:: iterator it) {}
template<typename T,typename ... Args>
void err(vector<string>::iterator it, T a, Args ... args)
{
    cerr << it->substr((*it)[0] == ' ',it->length())
         << " = " << a <<" " ;
    err(++it,args...);
}

template <typename T>
using order_set = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
double pi = acos(-1),eps=1e-8;
const ll N = (1e5) + 10 , M = (1e6)+10 , mod = 1e9 + 7 , K = 4 * N;
ll OOL = 1e18;
ll OO = 1e9;

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

}
/*

*/


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int nax = 1e6 + 1;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    vector<int> spf(nax);
    for (ll i = 2; i < nax; ++i) {
        if (!spf[i]) {
            spf[i] = i;
            for (ll j = i * i; j < nax; j += i) {
                if (!spf[j]) spf[j] = i;
            }
        }
    }
    int n; cin >> n;
    int pc = 1, sc = 0;
    bitset<nax> f;
    vector<int> v;
    auto fail = [&] (int x) {
        v.clear();
        while (x > 1) {
            int t = spf[x];
            // cout << t << ' ';
            if (f[t]) return 1;
            v.emplace_back(t);
            x /= t;
        }
        for (auto p : v) f[p] = 1;
        return 0;
    };
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        // cout << i << ": ";
        if (fail(a)) pc = 0;
        sc = gcd(sc, a);
        // cout << '\n';
    }
    if (pc) cout << "pairwise coprime\n";
    else if (sc == 1) cout << "setwise coprime\n";
    else cout << "not coprime\n";
}

Measured memory_bytes: 11116
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine().Trim().Split(' ');
            Console.WriteLine(S.Distinct().Count() == 3 ? "Three" : "Four");
        }
    }
}


Measured memory_bytes: 13280
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<int>cnt(n);
  for(int i=0;i<n;i++){
    cnt.at(i)=0;
  }
  for(int i=1;i<n;i++){
    int a;
    cin >> a;
    cnt.at(a-1)++;
  }
  for(int i=0;i<n;i++){
    cout << cnt.at(i) << endl;
  }
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N, Q;
  cin >> N >> Q;
  int a[N - 1], b[N - 1];
  // 隣接リスト
  vector<int> adj[N];
  for (int i = 0; i < N - 1; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    adj[a[i]].push_back(b[i]);
    adj[b[i]].push_back(a[i]);
  }
  int p[Q];
  ll x[Q];
  ll c[N]{};
  for (int i = 0; i < Q; i++) {
    cin >> p[i] >> x[i];
    p[i]--;
    c[p[i]] += x[i];
  }
  ll t = 0;
  deque<int> q;
  q.push_back(0);
  int vis[N]{};
  vis[0] = 1;
  while(!q.empty()) {
    int u = q.front();
    q.pop_front();
    for (int i : adj[u]) {
      if (vis[i] == 1) continue;
      vis[i] = 1; 
      c[i] += c[u];
      q.push_back(i);
    }
  }
  for (int i = 0; i < N; i++) {
    if (i == N - 1) {
      cout << c[i] << "\n";
    } else {
      cout << c[i] << " ";
    }
  }
  return 0;
}


Measured memory_bytes: 20980
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int n, r;
	cin >> n >> r;
	if (n < 10) r += 100 * (10 - n);
	cout << r << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 100001;

int n, dp[2 * N], mod = 1e9 + 7;
vector <int> a;

int solve(int idx, int open){
    if(idx == 2 * n) return open == 0;
    if(open < 0) return 0;
    if(dp[idx] != -1) return dp[idx];
    if(((open & 1) ^ a[idx]) == 0) return 1LL * open * solve(idx + 1, open - 1) % mod;
    return solve(idx + 1, open + 1);
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(dp, -1, sizeof dp);
    cin >> n;
    for(int i = 0 ; i < 2 * n ; i++){
        char c;
        cin >> c;
        a.push_back(c == 'W' ? 0 : 1);
    }
    int ans = solve(0, 0);
    for(int i = 1 ; i <= n ; i++){
        ans = 1LL * ans * i % mod;
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}

// 素数判定
bool isPrime(ll n) {
    ll i = 2;
    while (i*i <= n) {
        if(n%i==0) return false;
        i++;
    }
    return true;
}

// ll(1e18)でちゃんと型指定しないと後ろの+5が誤差で無視されるらしい
const ll INF = 1001001001;
ll dp[1000005][2];

int main() {
    string s; cin >> s;
    reverse(s.begin(), s.end());
    // やりやすいように頭に0をつける(リバースしてるので末尾)
    s += '0';
    int n = s.size();

    // dpテーブル初期化
    rep(i, n+1) rep(j, 2) dp[i][j] = INF;
    // 最初は0
    dp[0][0] = 0;
    rep(i, n) rep(j, 2) {
        // xはi桁目の金額
        int x = s[i]-'0';
        // 繰り下がりの計算
        x += j; // aを1引く == xに1足す

        // aはi桁目で支払う枚数
        // 0~9枚を確認する
        rep(a, 10) {
            // dpテーブルの遷移先
            // niは次のi, njは繰り下がりの管理
            int ni = i+1, nj = 0;
            // bはi桁目のお釣り金額
            int b = a-x;

            // bが0未満の場合は繰り下がりが必要
            if(b < 0) {
                // 次の桁は繰り下がりをするというフラグ
                nj = 1;
                b += 10;
            }
            // 遷移先は今の最小値+この桁で払う枚数(a)ともらうお釣りの枚数(b)
            dp[ni][nj] = min(dp[ni][nj], dp[i][j]+a+b);
        }


    }
    int ans = dp[n][0];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 17028
S_A, S_B, S_C = [list(input()) for i in range(3)]
S = S_A[0]
while True:
  if S == 'a':
    if len(S_A) == 0:
      break
    else:
      S = S_A.pop(0)
  elif S == 'b':
    if len(S_B) == 0:
      break
    else:
      S = S_B.pop(0)
  else:
    if len(S_C) == 0:
      break
    else:
      S = S_C.pop(0)
if S == 'a':
  print('A')
elif S == 'b':
  print('B')
else:
  print('C')

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

#define FOR(i, a, b) for (int i = a; i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define fst first
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define INIT                                                                   \
    cin.tie(0);                                                                \
    ios::sync_with_stdio(false)
#define int long long

using namespace std;

template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}

template <class T> void print(T &x) { cout << x << '\n'; }

int ceil(int a, int b) { return (a + b - 1) / b; }

signed main() {
    INIT;
    int n = in();
    string s = in<string>();

    int cost = 0;
    FOR(i, 1, n) {
        if (s[i] == 'E') {
            cost++;
        }
    }

    int ans = cost;
    FOR(i, 1, n) {
        if (s[i] == 'E') {
            cost--;
        }
        if (s[i - 1] == 'W') {
            cost++;
        }
        ans = min(ans, cost);
    }
    print(ans);
}

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

int main() {
  string s;
  cin >> s;
  int i=0, j=s.length();
  while(i<j && s[i]!='A') i++;
  while(j>i && s[j-1]!='Z') j--;
  cout << j-i << endl;
  return 0; 
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int n,m,p,a,b;
int t[8];
double dp[256][33];
double z[33][33];
main()
{
	while(cin>>n>>m>>p>>a>>b,n)
	{
		for(int i=0;i<n;i++)cin>>t[i];
		for(int i=0;i<m;i++)
		{
			for(int j=0;j<m;j++)z[i][j]=0;
			for(int k=0;k<1<<n;k++)dp[k][i]=1e18;
		}
		a--,b--;
		for(;p--;)
		{
			int x,y,Z;cin>>x>>y>>Z;
			x--,y--;
			z[x][y]=z[y][x]=Z;
		}
		dp[0][a]=0;
		for(int i=0;i<1<<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				for(int k=0;k<m;k++)
				{
					if(z[j][k]>0)
					{
						for(int l=0;l<n;l++)if(!(i>>l&1))
						{
							dp[i|1<<l][k]=min(dp[i|1<<l][k],dp[i][j]+z[j][k]/t[l]);
						}
					}
				}
			}
		}
		double ans=1e18;
		for(int i=0;i<1<<n;i++)ans=min(ans,dp[i][b]);
		if(ans<1e18)cout<<fixed<<setprecision(9)<<ans<<endl;
		else cout<<"Impossible"<<endl;
	}
}



Measured memory_bytes: 3344
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
 
using namespace std;
 
int main(){
int N,A,B;
  
  cin >> N;
  cin >> A;
  cin >> B;
  
  if((A * N) > B){
  cout << B;
  }else{
  cout << (A * N);
  }
 
return 0;
 
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
	char S[3]={};
	for(int i=0;i<3;i++){
		cin>>S[i];
	}
	int ans=0;
	for(int i=0;i<3;i++){
		char tmp;
		cin>>tmp;
		if(tmp==S[i]){
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

class UnionFind {
public:
	vector<ll> par;//親の番号
  vector<ll> rank;//木の深さ
  vector<ll> size;
 
	UnionFind(ll n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(1);
            size.push_back(1);
        }
	}
 
	ll find(ll x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(ll x,ll y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
            size[y]+=size[x];
        }else{
            par[y]=x;
            size[x]+=size[y];
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(ll x,ll y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }

    ll count(ll x,ll n){//頂点xが存在する木の要素数をカウント
      ll ans=par[x];
      ll ret=0;
      rep(i,n){
        if(par[i]==ans){
          ret++;
        }
      }
      return ret;
    }
};

template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    vector<P> a(m);
    UnionFind uf(n);
    rep(i,m){
      cin>>a[i].first>>a[i].second;
      a[i].first--;
      a[i].second--;
    }
    vector<ll> ans(m);
    ans[m-1]=comb(n,ll(2));
    //cout<<ans[m-1]<<'\n';
    for(int i=m-2;i>=0;i--){
      if(uf.same(a[i+1].first,a[i+1].second)){//もともと連結だったら
        ans[i]=ans[i+1];
      }else{
        ans[i]=ans[i+1]-uf.size[uf.find(a[i+1].first)]*uf.size[uf.find(a[i+1].second)];
      }
      uf.unite(a[i+1].first,a[i+1].second);
    }
    for(auto itr:ans){
      cout<<itr<<'\n';
    }
}

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

int main() {
  int N;
  cin>>N;
  int odd;
  int even;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(a%2==0) even++;
    else odd++;
  }
  if(odd%2==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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

using ll = long long;
const int MAX_V = 100000;
// const int MAX_V = 6;

int par[MAX_V];
int p_rank[MAX_V];

void init(int n) {
    for (int i = 0; i < n; ++i) {
        par[i] = i;
        p_rank[i] = 0;
    }
}

int find_root(int x) {
    if (par[x] == x) {
        return x;
    } else {
        // update parent
        return par[x] = find_root(par[x]);
    }
}

pair<int, int> unite(int x, int y) {
    int x_root = find_root(x);
    int y_root = find_root(y);
    if (x_root == y_root)
        // return make_pair(x_root, y_root);
        return make_pair(-1, -1);

    if (p_rank[x_root] < p_rank[y_root]) {
        par[x_root] = y_root;
    } else {
        par[y_root] = x_root;
        if (p_rank[x_root] == p_rank[y_root]) p_rank[x_root]++;
    }
    return make_pair(x_root, y_root);
}

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

    ll n, m;
    cin >> n >> m;

    init(n);
    int a[m], b[m];
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
    }

    ll res[m];
    memset(res, 0, sizeof(res));
    ll parents[n];
    fill(parents, parents + n, 1);

    res[m - 1] = n * (n - 1) / 2;
    for (int i = m - 1; i > 0; --i) {
        auto p = unite(a[i], b[i]);
        ll diff = 0;
        if (p.first != -1){
            ll pair1 = parents[p.first];
            ll pair2 = parents[p.second];
            ll new_pair = pair1 + pair2;
            parents[p.first] = parents[p.second] = new_pair;
            diff = new_pair * (new_pair - 1)
                      - pair1 * (pair1 - 1) - pair2 * (pair2 - 1);
            diff /= 2;
        }
        res[i - 1] = res[i] - diff;
    }

    for (auto r: res) {
        cout << r << '\n';
    }


    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N, L, s = 0, m = 1e9;
    cin >> N >> L;
    rep(i, N) {
        int t = L + i;
        s += t;
        if (abs(t) < abs(m)) m = t;
    }
    cout << s - m << "\n";
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = input()
t = input()
if sorted(s) < sorted(t, reverse=True):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 10564
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def main():
    N, X = map(int, input().split())
    x = list(map(int, input().split()))

    ans = abs(x[0] - X)
    for i in range(1, N):
        ans = gcd(ans, abs(x[i] - X))
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define N 100005

string s;
int toL[N],toR[N];
int num[N];

int main()
{
	
	cin>>s;
	memset(toL,0,sizeof(toL));
	memset(toR,0,sizeof(toR));
	for(int i=s.size()-1;i>=0;i--)
		if(s[i]=='L') toR[i]=i;
		else toR[i]=toR[i+1];
	for(int i=0;i<s.size();i++)
		if(s[i]=='R') toL[i]=i;
		else toL[i]=toL[i-1];
	for(int i=0;i<s.size();i++)
	{
		int p;
		if(s[i]=='L') p=i-toL[i]+1;
		else p=toR[i]-i+1;
		if(p%2==0)
		{
			if(s[i]=='L') num[toL[i]+1]++;
			else num[toR[i]-1]++;
		}
		else
		{
			if(s[i]=='L') num[toL[i]]++;
			else num[toR[i]]++;
		}
	}
	for(int i=0;i<s.size();i++)
		cout<<num[i]<<" ";
	cout<<'\n'; 
	
	return 0;
}

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

const int T = 26;

int main()
{
    int D;
    cin >> D;
    vector<int> c(T);
    rep(i, T) cin >> c[i];
    vector<vector<long>> s(D);
    rep(i, D) {
        s[i] = vector<long>(T);
        rep(j, T) cin >> s[i][j];
    }
    vector<int> Inputs(D);
    rep(i, D) { int a; cin >> a; Inputs[i] = a - 1; }
    long M;
    cin >> M;
    vector<pair<int, int>> dq(M);
    rep(i, M) { cin >> dq[i].first; cin >> dq[i].second; }

    rep(i, M) {
        Inputs[dq[i].first - 1] = dq[i].second - 1;

        long ans = 0;
        vector<long> cc(T);
        rep(i, T) cc[i] = -1;
        rep(i, D) {
            ans += s[i][Inputs[i]];
            cc[Inputs[i]] = i;
            rep(j, T) {
                ans -= c[j] * (i - cc[j]);
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < n;i++)
 
int main(){
 
    string S;
    cin >> S;
    if(S.at(0)=='A'&&S.at(1)=='A'&&S.at(2)=='A'||S.at(0)=='B'&&S.at(1)=='B'&&S.at(2)=='B')
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

            return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#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;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, s; cin >> k >> s;
    int ans = 0;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k&&x+y<=s;y++){
            int z;
            z = s-x-y;
            if(0<=z && z<= k) ans++;
        }
    }
    cout << ans;
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
//                                 Alisher_2211
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        # include <bits/stdc++.h>
# define  long          long long
# define  all(vc)       vc.begin(),vc.end()
# define  allr(vc)      vc.rbegin(),vc.rend()
# define  pb            push_back
# define  fi            first 
# define  se            second
# define  pi            pair <long, long>    
# define  lcm(a, b)     (a * b) / __gcd(a, b)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        using namespace std;
void read(){freopen("input.txt" , "r" , stdin );freopen("output.txt", "w" , stdout );}
long f(long n){
    return n * (n - 1) / 2;
}
void solve(){
      long l, r = 0, d;
      cin >> l;
      for (int i = 0; i < l; ++i){
            long j;
            cin >> j;
            if( i % 2 == 0 && j % 2 == 1 ) r ++;
      }
      cout << r;
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
        long T = 1;
        //cin >> T;
        while( T-- ){
            solve();
            cout<<'\n';
        }
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}

Measured memory_bytes: 3828
import io.{StdIn => in}
import scala.collection.mutable.HashSet

object Main extends App {
  val Array(a, b, c) = in.readLine.split(" ").map(_.toInt)
  val set = HashSet.empty[Int]
  set += a
  set += b
  set += c
  val ans = set.size
  println(ans)
}

Measured memory_bytes: 27324
#include <iostream>
#define MIN(X,Y) ((X)<(Y)?(X):(Y))
using namespace std;


int main(void){
  int n,x,ans;
  
  cin >> n;
  ans = 0; x = n;
  for (int i=0; i<3; i++) ans+=x, x*=n;
  cout << ans << endl;
  return 0;
}
    

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

int main() {
    int n;
    cin >> n;
    int a[5][150] = {0};
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }

    long long mx = 0;
    for (int i = 0; i < n; i++) {
        long long sum = 0;
        for (int j = 0; j <= i; j++) {
            sum += a[0][j];
        }
        for (int k = i; k < n; k++) {
            sum += a[1][k];
        }
        mx = max(mx, sum);
    }

    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;

int main()
{
    int n,i;
    string s;
    cin >> n >> s;
    int temp = 0;
    for(i = 0;i < n;++i){
        if(s.at(i) == '.'){
            ++temp;
        }
    }
    int ans = temp;
    for(i = 0;i < n;++i){
        if(s.at(i) == '.'){
            --temp;
        }else{
            ++temp;
        }
        if(ans > temp){
            ans = temp;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var N = intShift();
  var S = strShift().split(NOSP);
  var K = intShift();
  
  var taget = S[K-1];
  
  for(var i = 0 ; i < N ; i++){
  	if(S[i]!=taget)S[i] = "*";
  }
  
  S = S.join(NOSP);
  
  return S;
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
9
education
7
`);

Measured memory_bytes: 22332
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
//ll mod=1000000007;
ll mod;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int n,a,b;cin>>n>>a>>b;
    cout<<min(b,n*a)<<endl;
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n; scan(n);
      LI xs(n); for(auto &x : xs) scan(x);
      long ys[10] = {};
      long s = 0;
      for(auto x : xs) {
         if( x >= 3200 ) { s += 1; continue; }
         ys[x/400] += 1;
      }
      long res = 0;
      for(long i = 0; i < 10; ++i) {
         if( ys[i] != 0 ) res += 1;
      }
      printf("%ld %ld\n", std::max((long)1, res), res + s);
   }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define maxn 500010
int c[30][maxn],n;
char s[maxn];
int lowbit(int x){
	return x&-x;
}
void update(int x,int delta,int *a){
	for(int i=x;i<=n;i+=lowbit(i))a[i]+=delta;
}
int sum(int x,int *a){
	int ret=0;//此处错写成int ret;查了好久
	for(int i=x;i>=1;i-=lowbit(i))ret+=a[i];
	return ret;
}
int main(){
	int i,q,cmd,p,l,r,cnt,j;
	char b[3];
	scanf("%d%s%d",&n,s+1,&q);
	for(i=1;i<=n;i++)update(i,1,c[s[i]-'a']);
	while(q--){
		scanf("%d",&cmd);
		if(cmd==1){
			scanf("%d%s",&p,b);
			update(p,-1,c[s[p]-'a']);//此处错写成update(p,-1,c[s[i]-'a']);查了好久
			s[p]=b[0],update(p,1,c[b[0]-'a']);//此处错写成update(p,1,c[b[0]-'a']);
		}else if(cmd==2){
			scanf("%d%d",&l,&r),cnt=0;
			for(i=0;i<26;i++)cnt+=sum(r,c[i])-sum(l-1,c[i])>0;
			printf("%d\n",cnt);
		}
	}
}

Measured memory_bytes: 53504
from operator import itemgetter

def main():
    n = int(input())
    works =[]
    for i in range(n):
        works.append(tuple(map(int,input().split(" "))))
    sortworks = sorted(works, key=itemgetter(1))
    
    time = 0
    flag = True
    for i in sortworks:
        time += i[0]
        if time > i[1]:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 33388
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <numeric>
#include <string>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    cout << n*(n-1)/2+m*(m-1)/2 << endl;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <cctype>
#include <iostream>
using namespace std;

typedef long long LL;
typedef stringstream strstm;
#define PI acos(-1.0)
#define E 2.718281829459
#define pb push_back
#define lowbit(x) (x & (-x))
#define DBG(x) cout << (x) << " ";
#define MST(a,b) memset(a,b,sizeof(a));
#define _for(i,a,b) for(int i = (a); i < (b); ++i)
#define _rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define _ech(x,z) for(auto x = z.begin(); x != z.end(); ++x)

struct FastIO {
    static const int S = 1310720;
    int wpos;
    char wbuf[S];
    FastIO() : wpos(0) {}
    inline int xchar() {
        static char buf[S];
        static int len = 0, pos = 0;
        if (pos == len)
            pos = 0, len = fread(buf, 1, S, stdin);
        if (pos == len) return -1;
        return buf[pos ++];
    }
    inline int xuint() {
        int c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x;
    }
    inline int xint() {
        int s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline LL xlongint() {
        LL s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline void xstring(char *s) {
        int c = xchar();
        while (c <= 32) c = xchar();
        for (; c> 32; c = xchar()) * s++ = c;
        *s = 0;
    }
    inline void wchar(int x) {
        if (wpos == S) fwrite(wbuf, 1, S, stdout), wpos = 0;
        wbuf[wpos ++] = x;
    }
    inline void wint(LL x) {
        if (x < 0) wchar('-'), x = -x;
        char s[24];
        int n = 0;
        while (x || !n) s[n ++] = '0' + x % 10, x /= 10;
        while (n--) wchar(s[n]);
    }
    inline void wstring(const char *s) {
        while (*s) wchar(*s++);
    }
    ~FastIO() {
        if (wpos) fwrite(wbuf, 1, wpos, stdout), wpos = 0;
    }
} io;



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

    string str; cin >> str;
    str[3]='8';
    cout << str <<endl;


}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define MN 110000
#define int long long
using namespace std;

int read_p,read_ca;
inline int read(){
    read_p=0;read_ca=getchar();
    while(read_ca<'0'||read_ca>'9') read_ca=getchar();
    while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
    return read_p;
}
int n,m,X,K,T[MN],la=0,Q,t,a,l[MN],r[MN],L[MN],R[MN];
signed main(){
	X=read();
	K=read();
	l[0]=0;L[0]=0;r[0]=X;R[0]=X;
	for (int i=1;i<=K;i++){
		a=read();
		T[i]=a;
		l[i]=l[i-1];r[i]=r[i-1];
		L[i]=L[i-1]-(a-la);
		R[i]=R[i-1]-(a-la);
		if (L[i]<=R[i])
		if (R[i]<=0){
			l[i]=0;L[i]=X;r[i]=0;R[i]=X;
		}else{
			if (L[i]<0)
			l[i]-=L[i],
			L[i]=0;
			
			L[i]=X-L[i];R[i]=X-R[i];
		}else
		if (L[i]<=0){
			l[i]=0;L[i]=X;r[i]=0;R[i]=X;
		}else{
			if (R[i]<0)
			r[i]+=R[i],
			R[i]=0;
			
			L[i]=X-L[i];R[i]=X-R[i];
		}
		la=a;
	}
	
	/*for (int i=0;i<=K;i++)
	printf("%d %d %d %d %d\n",i,l[i],r[i],L[i],R[i]);*/
	Q=read();
	for (int i=1;i<=Q;i++){
		t=read();a=read();
		int _l=0,_r=K,mid;
		while (_l<_r){
			if (T[mid=_l+_r+1>>1]<=t) _l=mid;else _r=mid-1;
		}
		t-=T[_l];
		if (a<=l[_l]) a=L[_l];else if (a>=r[_l]) a=R[_l];else if (L[_l]==R[_l]) a=L[_l];else
		if (L[_l]<R[_l]) a=L[_l]+(a-l[_l]);else a=L[_l]-(a-l[_l]);
		
		a-=t;
		if (a<0) a=0;
		
		if (_l&1) a=X-a;
		
		printf("%lld\n",a);
	}
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

const int MAX_N = 210;
ll d[MAX_N][MAX_N];

int main(){
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> v(r);
    rep(i, r) {
        cin >> v[i];
        --v[i];
    }
    sort(all(v));

    rep(i, MAX_N) rep(j, MAX_N) d[i][j] = INF;
    rep(i, MAX_N) d[i][i] = 0;
    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        d[a][b] = d[b][a] = min(d[a][b], c);
    }

    rep(k, n) rep(i, n) rep(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    ll ans = INF;
    do {
        ll tmp = 0;
        rep(i, r-1) {
            tmp += d[v[i]][v[i+1]];
        }
        ans = min(ans, tmp);
    }while(next_permutation(all(v)));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <iomanip>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    llint n;
    cin>>n;
    vector<double> v(n);
    REP(i,n){cin>>v[i];}

    vector<vector<double>> dp(n+1, vector<double>(n+1,0));
    //何枚目まで三鷹 表の数
    dp[0][0] = 1;

    REP(i,n){
        REP(j,n){
            dp[i + 1][j] += dp[i][j] * (1 - v[i]);

            dp[i + 1][j+1] += dp[i][j] * (v[i]);
        }
    }
    double result = 0;
    REP(i,n+1){
        if(i>n/2){
            result += dp[n][i];
        }
    }
    cout <<fixed<<setprecision(100)<< result << endl;
    return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)x.size()
#define int ll

const int N = 1e5 + 10;
bool can[N];
int cnt[N];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	can[1] = true;
	for (int i = 1; i <= n; i++) {
		cnt[i] = 1;
	}
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		if (!can[u]) {
			cnt[u]--;
			cnt[v]++;
		}
		else {
			can[v] = true;
			if (cnt[u] == 1) {
				can[u] = false;
			}
			cnt[v]++;
			cnt[u]--;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (can[i]) {
			ans++;
		}
	}
	cout << ans << '\n';
}	

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

int main()
{
  string s;
  cin>>s;
  int w;
  cin>>w;

  string ans;
  int len=s.size();

  for(int i=0;i<len;i++)
  {
    if(i%w==0) cout<<s.at(i);
  }


}

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


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    vector<int>temp(3,0);
    string s; cin>>s;
    int ns = 0;
    for(int i = 0; i<3; i++){
        int prev = 0;
        if(i){
            prev = temp[i-1];
        }
        if(s[i]=='R'){
            temp[i] = prev+1;
            ns = max(ns,temp[i]);
        }
    }
    cout << ns;
    return 0;
}


Measured memory_bytes: 3572
#include<iostream>
using namespace std ;
int main( void )
{
	short n ;
	short kiji ,top ;
	short kijical ;
	short cal[ 101 ] = { 0 } ;
	short tmp ;
	short m ;
	short best = 0 ;
	short i ,j ;
	cin >> n ;
	cin >> kiji >> top ;
	cin >> kijical ;
	for( i = 1 ; i <= n ; i++ )
	{
		cin >> cal[ i ] ;
		for( j = 0 ; j < i ; j++ )
		{
			if( cal[ j ] < cal[ i ] )
			{
				tmp = cal[ i ] ;
				cal[ i ] = cal[ j ] ;
				cal[ j ] = tmp ;
			}
		}
	}
	for( i = n - 1 ; i >=0 ; i-- )
	{
		int calm = 0 ;
		for( j = 0 ; j <= i ; j++ )
		{
			calm += cal[ j ] ;
		}
		m = kiji + ( top * j ) ;
		calm = ( kijical + calm ) / m ;
		if( best < calm )
		{
			best = calm ;
		}
	}
	cout << best << endl ;
	return 0 ;
}

Measured memory_bytes: 3108
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

#UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = inpm()
AB = inplt(m)

uf = UnionFind(n)
for a,b in AB:
    uf.union(a-1,b-1)

print(uf.group_count()-1)

Measured memory_bytes: 46848
#include <iostream>
using namespace std;
#define mod 1000000007
int main()
{
    int n;
    cin>>n;
    long long int arr[n+1],sum[n+1],prod=1,ans=0;
    sum[n]=0;
     for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        arr[i]= arr[i]%mod;
    }
    for(int i=n-1;i>0;i--)
    {
       sum[i]=arr[i]+sum[i+1];
       sum[i]%=1000000007;
     }
   // cout<<total<<endl;
    for(int i=0;i<n-1;i++)
    {
           prod = (arr[i]*sum[i+1])%mod;
           prod = prod%mod;
           ans = ans + prod;
           ans = ans%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6736
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();
		int[] B = new int[M];
		int res = 0;

		for(int i = 0;i<M;i++) {
			B[i] = sc.nextInt();
		}
		for(int j = 0;j<N;j++) {
			int judge = C;
			for(int i = 0;i<M;i++) {
				judge += sc.nextInt()*B[i];
			}
			if(judge > 0) {
				res++;
			}
		}



		System.out.println(res);
	}
}

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

//#define DEBUG 1

//#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define iter2(c) for(auto it2=c.begin(); it2!=c.end(); it2++)
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define pmod(x,m) (((x)%(m)+m)%m)
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define priter(v) iter(v) {pr(*it)} nl
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define priter(v)
#define debug
#endif
#define MAXN 2000
#define MAX_SUM 4000000

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int arr[MAXN+5];

int32_t main()
{
    #ifdef DEBUG
    //freopen("C.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    int n;
    cin >> n;
    int sum = 0;
    for0(i,n) {
        read(arr[i]);
        sum += arr[i];
    }
    
    bitset<MAX_SUM+1> poss_sums;
    poss_sums.reset();
    poss_sums.set(0);
    for (int i=0; i<n; i++) {
        bitset<MAX_SUM+1> poss_sums_copy = poss_sums<<arr[i];
        poss_sums |= poss_sums_copy;        
        /*for (int j=0; j<=sum; j++) {
            if (poss_sums.test(j))
                pr(j) 
        }
        nl*/
    }
    
    for (int i=(sum+1)/2; ; i++) {
        if (poss_sums.test(i)) {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


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

int main() {
    int N;
    string S;
    int K;
    cin >> N >> S >> K;

    for (int i = 0; i < N; i++) {
        if (S[i] != S[K - 1]) {
            S[i] = '*';
        }
    }

    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    a, op, b = input().split(" ")
    a = int(a)
    b = int(b)
    
    if op == "?":
        break
        
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    else:
        print("Error")
        


Measured memory_bytes: 5596