akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>

using namespace std;
using ll = long long int;

int n, m;
vector<pair<ll, int>> drink;

bool comp(const pair<ll, int>& a, const pair<ll, int>& b) {
	return a.first < b.first;
}

int main(void) {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		ll ai;
		int bi;
		cin >> ai >> bi;
		drink.emplace_back(ai, bi);
	}

	sort(drink.begin(), drink.end(), comp);
	ll ret = 0;
	for (int i = 0; i < n;i++) {
		if (m > 0) {
			ret += drink[i].first * min(m, drink[i].second);
			m -= min(m, drink[i].second);
		}
		else break;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 2420
#include <stdio.h>
#include <math.h>

int isPrimeNumber(int v)
{
	int i, cnt;

	cnt = 0;
	if (v == 0 || v == 1) {
		return 0;
	}
	else if (v == 2 || v == 3) {
		return 1;
	}
	else if (v % 2 == 0) {
		return 0;
	}
	else {
		for (i = 1; i <= sqrt((double)v); i += 2) {
			if (v % i == 0) {
				cnt++;

				if (cnt > 1) {
					return 0;
				}
			}
		}
	}
	return 1;
}

int main(int argc, char** argv)
{
	int N, i, innum, result;
	result = 0;

	scanf("%d", &N);

	for (i = 0; i < N; i++) {
		scanf("%d", &innum);

		if (isPrimeNumber(innum)) {
			result++;
		}
	}

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

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<ll> t(2),a(2),b(2),l(2);
	cin>>t[0]>>t[1]>>a[0]>>a[1]>>b[0]>>b[1];
	l[0]=a[0]*t[0]+a[1]*t[1];
	l[1]=b[0]*t[0]+b[1]*t[1];
	ll x=a[0]*t[0],y=a[1]*t[1],z=b[0]*t[0],w=b[1]*t[1];
	if(l[0]==l[1]){
		cout<<"infinity"<<endl;
		return 0;
	}else if(l[0]<l[1]){
		ll ret=l[1]-l[0];
		if(z>=x) cout<<0<<endl;
		else{
			ll ans=(x-z+ret-1)/ret*2-1;
			if((x-z)%ret==0) ans++;
			cout<<ans<<endl;
		}
	}else{
		ll ret=l[0]-l[1];
		ll ans=0;
		if(x>=z) cout<<0<<endl;
		else{
			swap(x,z);
			ll ans=(x-z+ret-1)/ret*2-1;
			if((x-z)%ret==0) ans++;
			cout<<ans<<endl;
		}
	}
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dij geo2 kruskal graph uf lca BIT

signed main()
{
    Int(n);

    std::cout << (n / 15) * (800 * 15 - 200) + 800 * (n % 15) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N; cin >> N;
    VI p(N);
    REP(i,N)
    {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    LL ans = 0;
    REP(i,N)
    {
        if(i == N-1) ans += p[i]/2;
        else ans += p[i];
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	double T, X;
	cin >> T >> X;

	cout << setprecision(10) << T / X << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const int N = 200200;

int n;
int vis[N], val[N], outdeg[N], p[N];
set<int> vs[N];
int la;

int mex(set<int> &s) {
	set<int>::iterator it=s.begin();
	int ret=0;
	while (it != s.end()) {
		if (*it != ret) break;
		it++;
		ret++;
	}
	return ret;
}

void dfs(int u) {
	vis[u] = 1;
	val[u] = mex(vs[u]);
	vs[p[u]].insert(val[u]);
	outdeg[p[u]]--;
	if (outdeg[p[u]]==0) dfs(p[u]);
}

bool ok(int u, int vv) {
	int v = u;
	val[u] = vv;
	while (p[v] != u) {
		set<int> st = vs[p[v]];
		st.insert(val[v]);
		int vc = mex(st);
		val[p[v]] = vc;
		vis[v] = 1;
		v = p[v];
	}
	la = v;
	return val[u] != val[v];
}

int main() {
	scanf("%d", &n);
	FOR(i,n) scanf("%d", &p[i]);
	FOR(i,n) p[i]--;
	FOR(i,n) outdeg[p[i]]++;
	FOR(i,n) if (!vis[i] && outdeg[i]==0) dfs(i);
	FOR(i,n) if (!vis[i]) {
		int v1 = mex(vs[i]);
		if (!ok(i, v1)) {
			vs[i].insert(v1);
			int v2 = mex(vs[i]);
			if (!ok(i, v2) || val[la] != v1) {
				printf("IMPOSSIBLE\n");
				return 0;
			}
		}
	}
	printf("POSSIBLE\n");
	return 0;
}


Measured memory_bytes: 21376
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n;
    cin>>n;
    ll a[200020];
    ll s=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        s^=a[i];
    }
    for(int i=0; i<n; i++){
        cout<<(s^a[i])<<" ";
    }
    cout<<endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    vector<vector<int>> a(3, vector<int>(3));
    vector<vector<bool>> check(3, vector<bool>(3, false));
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }

    int n;
    cin >> n;
    int b;
    for (int i = 0; i < n; ++i) {
        cin >> b;
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (a[j][k] == b) check[j][k] = true;
            }
        }
    }

    bool flag = false;
    for (int i = 0; i < 3; ++i) {
        if (check[i][0] && check[i][1] && check[i][2]) flag = true;
    }
    for (int i = 0; i < 3; ++i) {
        if (check[0][i] && check[1][i] && check[2][i]) flag = true;
    }
    if (check[0][0] && check[1][1] && check[2][2]) flag = true;
    if (check[2][0] && check[1][1] && check[0][2]) flag = true;

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
from sys import stdin

N = int(stdin.readline().rstrip())
d_lst = []
for x in range(N):
  d_lst.append(int(stdin.readline().rstrip()))
  
d_lst = list(set(d_lst))
d_lst.sort(reverse=True)

count = 1
max_val  = d_lst[0]

for d in d_lst[1:]:
  if d < max_val:
    count += 1
    max_val = d
    
print(count)

Measured memory_bytes: 3060
N = int(input())
d = list(map(int, input().split()))
sum = 0
for i in range(N):
    for j in range(N-i-1):
        # print("{0}×{1}".format(d[i], d[j+i+1]))
        sum += d[i]*(d[j+i+1])

print(sum)

Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e6; int n;
const lli mod = 1e9 + 7;

lli memo[maxN][2][2];
lli solve(int i = 0, bool hasZero = false, bool hasNine = false)
{
  if (i == n) return hasZero && hasNine;
  if (memo[i][hasZero][hasNine] != -1) return memo[i][hasZero][hasNine];

  lli ans = 8LL * solve(i + 1, hasZero, hasNine) % mod;
  ans = (ans + solve(i + 1, true, hasNine)) % mod;
  ans = (ans + solve(i + 1, hasZero, true)) % mod;
  return memo[i][hasZero][hasNine] = ans;
}

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    memset(memo, -1, sizeof(memo));
    lli ans = solve();
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 111100
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if sum(a) == x:
  print(n)
elif sum(a) < x:
  print(n-1)
else:
  total = 0
  for i in range(n):
    total += a[i]
    if total == x:
      print(i+1)
      break
    elif total > x:
      print(i)
      break

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a%3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

//long long a[1002];

int main() {
	long long N, K, cnt = 0, tmp, ans = 0;
	long long A, B;

	cin >> A >> B;

	if (A < 6) {
		cout << 0;
	}
	else if (6 <= A && A <= 12) {
		cout << B / 2;
	}
	else {
		cout << B;
	}

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod;
ll N;
ll Factorial[10000];
ll Inv[10000];
ll FactorialInv[10000];
ll dp[2005][2005];
ll beki2[5000000];
ll invbeki2[5000000];
ll beki(ll a, ll b) {
    a %= mod;
    if (a < 0) a += mod;
    if(b < 0) {
        ll inverse = beki(a, -b);
        return beki(inverse, mod - 2);
    }
    if(b == 0) return 1;
    ll ans = beki(a, b/2);
    ans = ans * ans % mod;
    if(b % 2 == 1) ans = ans * a % mod;
    return ans;
}

void init() {
    Inv[1] = 1;
    FactorialInv[1] = 1;
    Factorial[1] = 1;
    for(ll i = 2; i < 10000; i++) {
        Inv[i] = beki(i, mod - 2);
        Factorial[i] = Factorial[i-1] * i % mod;
        FactorialInv[i] = FactorialInv[i-1] * Inv[i] % mod;
    }
    beki2[0] = 1;
    invbeki2[0] = 1;
    for(int i = 1; i < 5000000; i++) {
        beki2[i] = beki2[i - 1] * 2 % mod;
        invbeki2[i] = invbeki2[i - 1] * Inv[2] % mod;
    }
    for(int y = 0; y <= 2000; y++) {
        ll Factor = (1 - invbeki2[y] + mod) % mod;
        dp[y][0] = 1;
        for(int z = 1; z <= 2000; z++) {
            dp[y][z] = dp[y][z-1] * Factor % mod;
        }
    }
}

ll combination(ll a, ll b) {
    if((a == b) || (b == 0)) return 1;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a-b] % mod;
    return ans;
}

int main() {
    cin >> N >> mod;
    //cerr << beki(2, -2) << endl;
    init();
    ll ans = 0;
    for(ll R = 0; R <= N; R++) {
        ll B = N - R;
        for(ll r = 0; r <= R; r++) {
           ll now = combination(R, r);
           now = now * beki2[N*(N-1)/2-r*B] % mod;
           //ll sub = 1 - invbeki2[R-r];
           //sub = (sub + mod) % mod;
           //sub = beki(sub, B);
           ll sub = dp[R-r][B];
           now = now * sub % mod;
           now = now * combination(N, R) % mod;
           if(r % 2 == 1) now = -now;
           //cout << R << " " << r << " " << now << endl;
           ans = (ans + now + mod) % mod;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 112828
#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 INF = 1000000000;
const ll MOD = 1000000007;

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;}

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

  int rate = pow(2, m);
  int a = 1900 * m;
  int b = (n - m) * 100;
  int ans = (a + b) * rate;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<math.h>
#include<functional>
#include<bitset>
#include<cassert>
using namespace std;
using lint = long long;
using ld = long double;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define MOD 998244353LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(lint i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

#define MAX_N 1000000
long long extgcd(long long a, long long b, long long& x, long long& y) {
	long long d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1; y = 0;
	}
	return d;
}
long long mod_inverse(long long a, long long m) {
	long long x, y;
	if(extgcd(a, m, x, y) == 1) return (m + x % m) % m;
	else return -1;
}
vector<long long> fact(MAX_N+1, INF);
long long mod_fact(long long n, long long& e) {
	if(fact[0] == INF) {
		fact[0]=1;
		if(MAX_N != 0) fact[1]=1;
		for(lint i = 2; i <= MAX_N; ++i) {
			fact[i] = (fact[i-1] * i) % MOD;
		}
	}
	e = 0;
	if(n == 0) return 1;
	long long res = mod_fact(n / MOD, e);
	e += n / MOD;
	if((n / MOD) % 2 != 0) return (res * (MOD - fact[n % MOD])) % MOD;
	return (res * fact[n % MOD]) % MOD;
}
// return nCk
long long mod_comb(long long n, long long k) {
	if(n < 0 || k < 0 || n < k) return 0;
	long long e1, e2, e3;
	long long a1 = mod_fact(n, e1), a2 = mod_fact(k, e2), a3 = mod_fact(n - k, e3);
	if(e1 > e2 + e3) return 0;
	return (a1 * mod_inverse((a2 * a3) % MOD, MOD)) % MOD;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, x;
	cin >> n >> x;
	if(x == 2) {
		cout << 1 + n << endl;
		return 0;
	}
	lint ans = 1;
	FOR(m, 1, n + 1) {
		if(x == 1) {
			ans += mod_comb(n, m); ans %= MOD;
			continue;
		}
		lint tmp = 0;
		REP(i, m + 1) {
			if(i * 2 + (m - i) * 1 >= x) break;
			tmp += mod_comb(m, i); tmp %= MOD;
		}
		FOR(i, 1, m) {
			if(i < m - i) {
				if(2 * i == x - 1) tmp++;
			} else {
				tmp += mod_comb(m - 2 * (m - i), x - 1 - 2 * (m - i) - (i - (m - i)));
				tmp %= MOD;
			}
		}
		// cerr << tmp << endl;
		ans += tmp * mod_comb(n, m); ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}
/* --------------------------------------- */


Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long ll;
const int inf=1e15;
int n;
int main()
{
    cin>>n;
    cout<<!n<<endl;
    return 0;
}
////刷题！！！！！！！！！！！！！！！！


Measured memory_bytes: 3624
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

int main ()
{
    int a,b,st[3];
    scanf("%d%d",&a,&b);
    st[0] = a-b;
    st[1] = a+b;
    st[2] = a*b;
    
    sort(st,st+3);
    
    cout<<st[2];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int ceil(int i) {
    while (true) {
        if (i % 10 == 0) return i;
        ++i;
    }
}

int main() {
    int dishes[5];
    for (int & i : dishes) cin >> i;
    int d[5];
    int fastest = 1000;
    for (d[0] = 0; d[0] < 5; ++d[0]) {
        for (d[1] = 0; d[1] < 5; ++d[1]) {
            if (d[1] == d[0]) continue;
            for (d[2] = 0; d[2] < 5; ++d[2]) {
                if (d[2] == d[0] || d[2] == d[1]) continue;
                for (d[3] = 0; d[3] < 5; ++d[3]) {
                    if (d[3] == d[0] || d[3] == d[1] || d[3] == d[2]) continue;
                    for (d[4] = 0; d[4] < 5; ++d[4]) {
                        if (d[4] == d[0] || d[4] == d[1] || d[4] == d[2] || d[4] == d[3]) continue;
                        int time = 0;
                        for (int i = 0; i < 5; ++i) {if (d[i] == 0) {time += ceil(dishes[i]);}}
                        for (int i = 0; i < 5; ++i) {if (d[i] == 1) {time += ceil(dishes[i]);}}
                        for (int i = 0; i < 5; ++i) {if (d[i] == 2) {time += ceil(dishes[i]);}}
                        for (int i = 0; i < 5; ++i) {if (d[i] == 3) {time += ceil(dishes[i]);}}
                        for (int i = 0; i < 5; ++i) {if (d[i] == 4) {time += dishes[i];}}
                        if (time < fastest) fastest = time;
                    }
                }
            }
        }
    }
    cout << fastest << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n, h;
	cin >> n >> h;
	vi a(n), b(n);
	rep(i, 0, n) {
		cin >> a[i] >> b[i];
	}
	int ans = 0;
	int x = *max_element(all(a));
	sort(all(b));
	reverse(all(b));
	rep(i, 0, n) {
		if (b[i] < x || h <= 0) {
			break;
		}
		h -= b[i];
		ans++;
	}
	if (h > 0) {
		ans += (h%x == 0) ? (h / x) : (h / x) + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)


struct Problem {

	void Solve() {
		bitset<2000001> V;
		UL N; cin >> N;
		V.set(0, true);
		UL S = 0;
		rep(i, N) {
			UL a; cin >> a;
			V |= (V << a);
			S += a;
		}
		UL ans = 0;
		for (UL i = S / 2; i != -1; i--) {
			if (V.test(i)) { ans = i; break; }
		}
		ans = S - ans;
		cout << ans << endl;
	}
	
	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 1024
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]
'''
from queue import PriorityQueue
n,k = ip()
x = ip()
pq = PriorityQueue()
for i in x:
    pq.put((-1)*i)
print(sorted(x,reverse=True))
for i in range(k):
    ele = abs(pq.get())
    print(ele)
    if ele%2:
        pq.put((-1)*(ele//2))
        pq.put((-1)*((ele//2) +1))
    else:
        pq.put((-1)*(ele//2))
        pq.put((-1)*(ele//2))
print(abs(pq.get()))
'''
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

# Python3 code to find number of 
# distinct numbers in a subarray 
MAX = MAX = 1000001

# structure to store queries 
class Query: 
	def __init__(self, l, r, idx): 
		self.l = l 
		self.r = r 
		self.idx = idx 

# updating the bit array 
def update(idx, val, bit, n): 
	while idx <= n: 
		bit[idx] += val 
		idx += idx & -idx 

# querying the bit array 
def query(idx, bit, n): 
	summ = 0
	while idx: 
		summ += bit[idx] 
		idx -= idx & -idx 
	return summ 

def answeringQueries(arr, n, queries, q): 

	# initialising bit array 
	bit = [0] * (n + 1) 

	# holds the rightmost index of 
	# any number as numbers of a[i] 
	# are less than or equal to 10^6 
	last_visit = [-1] * MAX

	# answer for each query 
	ans = [0] * q 

	query_counter = 0
	for i in range(n): 

		# If last visit is not -1 update -1 at the 
		# idx equal to last_visit[arr[i]] 
		if last_visit[arr[i]] != -1: 
			update(last_visit[arr[i]] + 1, -1, bit, n) 

		# Setting last_visit[arr[i]] as i and 
		# updating the bit array accordingly 
		last_visit[arr[i]] = i 
		update(i + 1, 1, bit, n) 

		# If i is equal to r of any query store answer 
		# for that query in ans[] 
		while query_counter < q and queries[query_counter].r == i: 
			ans[queries[query_counter].idx] = query(queries[query_counter].r + 1, bit, n) - query(queries[query_counter].l, bit, n) 
			query_counter += 1

	# print answer for each query 
	for i in range(q): 
		print(ans[i]) 

# Driver Code 
if __name__ == "__main__": 
    n,q = ip()
    a = ip()
    queries = []
    for i in range(q):
        l,r = ip()
        queries.append(Query(l-1,r-1,i))
    queries.sort(key = lambda x: x.r) 
    answeringQueries(a, n, queries, q) 





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

int main() {
    int A,B;
    cin >> A >> B;

    if(A >= 13) {
        cout << B;
    }else if(6 <= A && A <= 12) {
        cout << B / 2;
    }else{
        cout << 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 2e6 + 5;
const int mod = 1e9 + 7;
int x , y,fac[maxn];
int Pow(int x , int y){
    if(y == 0)return 1;
    int r = Pow(x , y / 2);
    if(y & 1)return (ll)r * r % mod * x % mod;
    return (ll)r * r % mod;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    fac[0] = 1;
    for(int i = 1 ; i < maxn ; ++i){
        fac[i] = (ll)fac[i - 1] * i % mod;
    }
    cin >> x >> y;
    if((x + y) % 3)return cout << 0 , 0;
    int res = 0;
    for(int i = 0 ; i <= x ; ++i){
        int a = i;
        int b = (x - i) / 2;
        if(a + b * 2 == x && a * 2 + b == y){
//            cout << a << " " << b << endl;
            res += (ll)fac[a + b] * Pow((ll)fac[a] * fac[b] % mod , mod - 2) % mod;
            if(res >= mod)res -= mod;
        }
    }
    cout << res;
}


Measured memory_bytes: 8064
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

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

  int n;
  cin >> n;
  vector<int> a(n + 1 , 0);
  for(int i = 1; i <= n; i++) {
      cin >> a[i];
  }
  vector<int> dp(n + 1, 0);
  vector<int> pre(n + 1, 0);

  for(int i = 1; i <= n; i++ ) {
     pre[i] = pre[i - 1];
     if(i % 2){
         pre[i] += a[i];
     }
  }
  //dp[1] = (a[1] > 0 ? a[1] : 0);
  for(int i = 2; i <= n; i++) {

      if(i % 2) {
          dp[i] = max(dp[i - 1] , dp[i - 2] + a[i]);
      } else{
          dp[i] = max(pre[i - 1] , dp[i - 2] + a[i]);
      }
  }
  cout << dp[n] << '\n';
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 3e3;
int n, a[nsz + 5];
num dp[nsz + 5][nsz + 5][2], ans;

int main() {
    ios::sync_with_stdio(0);
    cin >> n;
    cont (i, n) {
        cin >> a[i];
        dp[i][i][1] = a[i];
    }
    circ (len, 2, n) {
        for (int l = 1, r = len; r <= n; ++l, ++r) {
            if (len & 1) {
                dp[l][r][1] = max(dp[l + 1][r][0] + a[l], dp[l][r - 1][0] + a[r]);
            } else {
                dp[l][r][0] = min(dp[l + 1][r][1] - a[l], dp[l][r - 1][1] - a[r]);
            }
        }
    }
    ans = (n & 1) ? dp[1][n][n & 1] : -dp[1][n][n & 1];
    cout << ans << ln;
}


Measured memory_bytes: 139776
#include<stdio.h>
#define N 100
#define INF 1000
#define WHITE 0
#define GRAY 1
#define BLACK 2
  
int n, graph[N][N], d[N];

int main(){
  int i, j, l, m, in;
 
  init();
  scanf("%d", &n);
  for(i = 0; i < n; i++){      
    scanf("%d%d", &l, &m);
    for(j = 0; j < m; j++){
      scanf("%d", &in);
      graph[l - 1][in - 1] = 1;
    }
  }
   
  bfs();
  print();
   
  return 0;
}

void bfs(void){
  int i, v;
  int head, tail;
  int que[N*N], color[N];
   
  head = -1;
  tail = 1;
 
  for(i = 0; i < n; i++){
    d[i] = INF;
    color[i] = WHITE;
  }
 
  color[0] = GRAY;
  que[++head] = 0;
  d[0] = 0;
   
  while(head != tail){
    v = que[head++];
    for(i = 0; i < n; i++){
      if(graph[v][i] == 1 && color[i] == WHITE){
	color[i] = GRAY;
	que[tail++] = i;
	d[i] = d[v] + 1;
      }
    }
    color[v] = BLACK;
  }
}

void init(void){
  int i, j;
   
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      graph[i][j] = 0;
    }
  }
  return ;
}

void print(void){
  int i;
  for(i = 0; i < n; i++){
    printf("%d ", i + 1);
    if(d[i] == INF) printf("-1\n");
    else             printf("%d\n", d[i]);
  }
  return ;
}

Measured memory_bytes: 636
K = gets.chomp.to_i

A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
puts A[K-1]


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

int main(){
  int n;
  cin>>n;
  long long L[n+1];
  L[0]=2;
  L[1]=1;
  for(int i=2;i<=n;i++){
    L[i]=L[i-1]+L[i-2];
  }
  cout<<L[n];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k, s;
  cin >> n >> k >> s;
  rep(i, n){
    if(i < k) cout << s << ' ';
    else {
      if(s == 1000000000ll) cout << s-1 << ' ';
      else cout << s + 1 << ' ';
    }
  }
  cout << endl;

}


Measured memory_bytes: 1280
/**
       **********    ************
	  Author : Avi J Patel
	  University : DAIICT
       **********    ************
**/
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 1844674407370955161
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define min_heap priority_queue<int, vector<int>, greater<int>>
#define max_heap priority_queue<int>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define pp pair<pair<int,int>,pair<int,int>>
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> 

bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    if(a.ss < b.ss) return true; 
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.ff>b.ff) return true;
	else if(a.ff==b.ff) return a.ss<b.ss;
	else return false;
} 
bool sortff_resortss(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.ff<b.ff) return true;
	else if(a.ff==b.ff) return a.ss>b.ss;
	else return false;
}
bool sortbystring(const string &a, const string &b)
{
	string c=a+b;
	string d=b+a;
	if(c>=d) return true;
	else return false;
}

ll modi(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 
ll Logn(ll  n, ll r) 
{ 
    return (n > r - 1) ? 1 + Logn(n / r, r) : 0; 
} 

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 


int main()
{
	FAST
	int t=1;
//	cin>>t;
	while(t--)
	{	
		ll k,n;
		cin>>k>>n;
		vector<ll> a(n);
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
		}
		vector<ll> b(n);
		ll sum=0;
		for(int i=0;i<n;i++)
		{
			if(i!=n-1)
			{
				b[i]=a[i+1]-a[i];
			}
			else
			{
				b[i]=k-a[i]+a[0];
			}
			sum+=b[i];
		}
//		cout<<sum<<endl;
		sort(b.begin(),b.end());
		sum-=b[n-1];
		cout<<sum;
		
	}
	return 0;
}
















Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
const int N=300005;
int n,a[N],s[N];
int check(int x){
	int v=0;
	for (int i=1;i<=n;i+=2)
		if (s[i]-v>=x)v=min(v,s[i+1]);
	return s[n]-v>=x;
}
signed main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
		if (i&1)s[i]=s[i-1]+a[i];
		else s[i]=s[i-1]-a[i];
	if (n%2==0){
		int s1=0,s2=0;
		for (int i=1;i<=n;i++)
			if (i&1)s1+=a[i];
			else s2+=a[i];
		printf("%d %d\n",max(s1,s2),min(s1,s2));
		return 0;
	}
	int l=0,r=1000*n;
	while (l<r){
		int mid=(l+r+1)/2;
		if (check(mid))l=mid;
		else r=mid-1;
	}
	int s1=l,s2=0;
	for (int i=1;i<=n;i++)
		if (i%2==0)s1+=a[i];
	for (int i=1;i<=n;i++)s2+=a[i];
	printf("%d %d\n",s1,s2-s1);
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int[] x = new int[5];
        for(int i = 0; i < 5; i++){
            x[i] = Integer.parseInt(sc.next());
        }
        
        int y;
        int min = 11;
        int last = 0;
        for(int i = 0; i < 5; i++){
            y = x[i] % 10;
            if(y == 0){
                y =10;
            }
            if(y < min){
                last = i;
                min = y;
            }
        }
        
        int time = 0;
        for(int i = 0; i < 5; i++){
            if(i == last){
                time += x[i];
            }else{
                if(x[i] % 10 == 0){
                    time += x[i];
                }else{
                    time += x[i] + (10 - (x[i] % 10));
                }
            }
        }
        
        System.out.println(time);
    }
}

Measured memory_bytes: 23764
state = 1
while(state):
    a = [[0 for i in range(12)] for j in range(12)]
    for i in range(12):
        a[i] = [int(i) for i in list(input())]
    try:
        _ = input()
    except EOFError:
        state = 0

    def erase(y,x):
        if a[y][x] != 0:
            a[y][x] = 0
            if x-1 > -1:
                erase(y,x-1)
            if x+1 < 12:
                erase(y,x+1)
            if y-1 > -1:
                erase(y-1,x)
            if y+1 < 12:
                erase(y+1,x)

    count = 0
    for i in range(12):
        for j in range(12):
            if a[i][j] != 0:
                count += 1
                erase(i,j)
    print(count)



Measured memory_bytes: 5616
#include<iostream>
#include<string>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,l;
	cin>>n>>l;
	string s[n];
	rep(i,n)cin>>s[i];
	sort(s,s+n);
	string ans="";
	rep(i,n)ans+=s[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
 
 
def main():
    N = int(input())
    S = input().strip()
    ans = 0
    x = 0
    for c in S:
        if c == "#":
            x += 1
        else:
            if x > 0:
                ans += 1
                x = max(x-1, 0)
    print(ans)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K; cin>>N>>K;
  vector<int>A(N);
  vector<int>B(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
    B[A[i]-1]++;
  }
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
  int count=0;
  int ans=0;
  for(int i=0;i<N;i++){
    if(B[i]==0)break;
    count++;
    if(count>K)ans+=B[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4844
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> doup;

int main(void) {
    ll N, C;
    cin >> N >> C;
    ll i, imos[30][MAX]={0};
    ll a, b ,c;
    for(i=0; i<N; i++) {
        cin >> a >> b >> c;
        a--; c--;
        imos[c][a]++;
        imos[c][b]--;
    }
    
    for(c=0; c<C; c++) {
        for(i=1; i<MAX; i++) {
            imos[c][i]+=imos[c][i-1];
        }
    }
    
    for(c=0; c<C; c++) {
        for(i=0; i<MAX; i++) {
            if(imos[c][i]) imos[c][i]=1;
        }
    }
    ll ans=0, cnt;
    for(i=0; i<MAX; i++) {
        cnt=0;
        for(c=0; c<C; c++)
            cnt+=imos[c][i];
        
        ans=max(ans, cnt);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 23680
using System;
using System.Linq;

namespace diverta2019_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = NK[0];
            var K = NK[1];
            Console.WriteLine(N - K + 1);
        }
    }
}


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

using namespace std;

int N, Q;
string s;
char unde[200007], cum[200007];

bool prost(int pos, int left)
{
    for( int i = 1;  i <= Q;  ++i ) {
        if( unde[i] == s[pos] ) {
            if( cum[i] == 'L' )
                --pos;
            else ++pos;

            if( pos < 1 && left ) return 1;
            if( pos > N && !left ) return 1;

            if( pos < 1 || pos > N ) return 0;
        }
    }
    return 0;
}

int main()
{
    cin >> N >> Q;
    cin >> s;
    s = "#" + s;

    for( int i = 1;  i <= Q;  ++i ) cin >> unde[i] >> cum[i];

    ///for( auto c : s ) assert( 'A' <= c && c <= 'Z' );

    int bad_left = 0, bad_right = N + 1;
    int step = (1 << 18);
    while(step) {
        if( bad_left + step <= N && prost(bad_left + step, 1) )
            bad_left += step;
        if( bad_right - step > 0 && prost(bad_right - step, 0) )
            bad_right -= step;
        step >>= 1;
    }
   /// cout << bad_left << ' ' << bad_right << '\n';
    if( bad_left >= bad_right ) {
        cout << "0\n";
        return 0;
    }
    cout << bad_right - bad_left - 1 << '\n';
    return 0;
}


Measured memory_bytes: 984
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();

		if(s.equals("ABC") ) {
			System.out.println("ARC");
		}else if(s.equals("ARC") ) {
			System.out.println("ABC");
		}
		sc.close();
	}

}

Measured memory_bytes: 35588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
int main() {
    int N,A,B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    int size = S.size() ;
    int cnt_A = 0;
    int cnt_B = 0;
    for(int i=0;i<size;i++){
        int total=cnt_A+cnt_B;
        if(S[i]=='a'){
            if(total<(A+B)){
                cout << "Yes" <<endl;
                cnt_A++;
            }
            else{
                cout << "No" <<endl;
            }
        }
        else if(S[i]=='b'){
            if( (total < (A+B)) && (cnt_B < B) ){
                cout << "Yes" << endl;
                cnt_B++;
            }
            else{
                cout << "No" <<endl;
            }
        }
        else if(S[i]=='c'){
            cout << "No" <<endl;
        }
    }
}

Measured memory_bytes: 3756
N=int(input())
A,B,C,D=[0]*N,[0]*N,[0]*N,[0]*N
for i in range(N):
  A[i],B[i]=map(int,input().split())
for i in range(N):
  C[i],D[i]=map(int,input().split())
R=[0]*N
for i in range(N):
  R[i]=A[i]*1000+B[i]
B=[0]*N
for i in range(N):
  B[i]=C[i]*1000+D[i]
B.sort()
X=[0]*N
ans=0
for i in range(N):
  BX,BY=B[i]//1000,B[i]%1000
  M=-1
  for j in range(N):
    if(X[j]==0):
      RX,RY=R[j]//1000,R[j]%1000
      if(RX<BX and RY<BY):
        if(M==-1):
          M=j
        elif(RY>R[M]%1000):
          M=j
  if(M!=-1):
    X[M]=1
    ans+=1
print(ans)

Measured memory_bytes: 3064
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
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;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N;
int C[510], S[510], F[510];

signed main() {
    cin >> N;
    rep(i,0,N-1) {
        cin >> C[i] >> S[i] >> F[i];
    }

    rep(i,0,N-1) {
        int tm = 0;
        rep(k,i,N-1) {
            int cur_t = tm, nxt_t = -1;

            // printf("cur_t = %lld, S[%lld] = %lld, div = %lld\n", cur_t, k, S[k], (cur_t - S[k] + F[k] - 1) / F[k]);
            if(cur_t < S[k]) nxt_t = S[k];
            else nxt_t = S[k] + (cur_t - S[k] + F[k] - 1) / F[k] * F[k];
            tm = nxt_t + C[k];
        }
        cout << tm << endl;
    }
    cout << 0 << endl;
    return 0;
}

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

typedef pair<int,int> P;
const int N=305;
const ll mod=1e9+7;
int n,m;
ll dp[N][N][N];
vector<P> r[N];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<m;++i){
		int L,R,x;
		cin>>L>>R>>x;
		r[R].emplace_back(L,x);
	}
	dp[0][0][0]=1;
	for(int i=0;i<=n;++i)
		for(int j=0;j<=n;++j)
			for(int k=0;k<=n;++k){
				int t=max({i,j,k});
				for(P p:r[t]){
					int l=p.first;
					int x=p.second;
					if((l<=i)+(l<=j)+(l<=k)!=x) 
						dp[i][j][k]=0;
				}
				if(t==n||!dp[i][j][k]) continue;
				(dp[t+1][j][k]+=dp[i][j][k])%=mod;
				(dp[i][t+1][k]+=dp[i][j][k])%=mod;
				(dp[i][j][t+1]+=dp[i][j][k])%=mod;
			}
	ll res=0;
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j){
			(res+=dp[n][i][j])%=mod;
			(res+=dp[i][n][j])%=mod;
			(res+=dp[i][j][n])%=mod;
		}
	cout<<res<<'\n';
}




Measured memory_bytes: 220648
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

  if(n%2){
    cout<<"No"<<endl;
  }else{
    if(s.substr(0,n/2)==s.substr(n/2,n/2)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }

  return 0;
}

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

using namespace std;

int n,a[100000],l[100000],length;

int main(void) {
	for(int i = 0;i < 100000;i++) l[i] = 1000000001;
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 0;i < n;i++) {
		auto itr = lower_bound(l,l+n,a[i]);
		*itr = a[i];
	}
	for(int i = 0;i <= n;i++) {
		if(l[i] == 1000000001) {
			cout << i << endl;
			break;
		}
	}
#ifdef DEBUG
	for(int i = 0;i <= n;i++) cout << l[i] << " ";
#endif
}



Measured memory_bytes: 3868
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

    int ans = 0;
    FOR(i, 0, n)FOR(j, i + 1, n) {
        ans += d[i] * d[j];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c,d,z=0;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a<=b){
		z=z+a;
	}else if(a>b){
		z=z+b;
	}
	if(c<=d){
		z=z+c;
	}else if(c>d){
		z=z+d;
	}
	printf("%d\n",z);
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func fact(n int) int {
	ret := 1
	for i := 1; i <= n; i++ {
		ret *= i
	}
	return ret
}

func rank(n int, x []int) int {
	t := make([]int, n)
	ret := 0
	// xのi番目の数字
	for i := 0; i < n-1; i++ {
		for j := 1; j <= n; j++ {
			if t[j-1] == 0 && j != x[i] {
				ret += fact(n - 1 - i)
			} else if j == x[i] {
				t[j-1] = 1
				break
			}
		}
	}
	return ret
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	p := nextInts(n)
	q := nextInts(n)

	fmt.Println(abs(rank(n, p) - rank(n, q)))
}


Measured memory_bytes: 640