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

int main(void)
{
	int n,a,i,max=-1000000,min=1000000;
	long sum=0;
	scanf("%d",&n);
	for(i=0 ; i<n ; i++){
		scanf("%d",&a);
		sum+=a;
		if(a<min)min=a;
		if(a>max)max=a;
	}
	printf("%d %d %ld\n",min ,max ,sum);
	return 0;
}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007
#define iP pair<int,int>
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define inf 1e15
#define mod1 998244353
#define pi 3.141592653589793238
int32_t main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(20);
    int n;
    cin>>n;
    vector<int> cnt(n+1);
    vector<int> v(n);
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v[i]=x;
        cnt[x]++;
    }
    int ctr=0;
    for(int i=0;i<=n;i++){
        ctr+=(cnt[i]*(cnt[i]-1ll))/2ll;
    }
    for(int i=0;i<n;i++){
        cout<<ctr-(cnt[v[i]]*(cnt[v[i]]-1ll))/2ll+((cnt[v[i]]-1ll)*(cnt[v[i]]-2ll))/2ll<<"\n";
    }
}

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

int main() {
    string S;
    cin >> S;
    if(S[2]==S[3] && S[4]==S[5]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.14159265358979323846;

void solve() {
    ll n;
    cin >> n;
    cout << ((n-1)/111+1)*111 << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    S[K - 1] = S[K - 1] - 'A' + 'a';
    cout << S << endl;
}


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

using ll = long long;
ll modinv(ll a, ll m) {
	assert(m > 0);
	if (m == 1) return 0;
	a %= m;
	if (a < 0) a += m;
	assert(a != 0);
	if (a == 1) return 1;
	return m - modinv(m, a) * m / a;
}

template <int MOD_> struct modnum {
private:
	int v;
public:
	static const int MOD = MOD_;

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int () const { return v; }
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum operator ~ () const {
		modnum res;
		res.v = modinv(v, MOD);
		return res;
	}

	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= (~o);
	}

	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }

	friend modnum pow() {}
};
using num = modnum<998244353>;

template <typename T> T pow(T a, long long b) {
	assert(b >= 0);
	T r = 1; while (b) { if (b & 1) r *= a; b >>= 1; a *= a; } return r;
}

vector<num> fact;
vector<num> ifact;

void init(){
	fact = {1};
	for(int i = 1; i < 21000000; i++) fact.push_back(i * fact[i-1]);
	ifact.resize(fact.size());
	ifact.back() = 1 / fact.back();
	for(int i = (int)ifact.size() - 1; i > 0; i--) ifact[i-1] = i * ifact[i];
}

num ncr(int n, int k){
	if(k < 0 || k > n) return 0;
	return fact[n] * ifact[k] * ifact[n-k];
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	init();
	int n, a, b;
	cin >> n >> a >> b;

	num ans = 0;
	for(int i = 0; i + b <= n; i++){
		int nreset = i;
		int nup = n - b - nreset;
		int nright = b;
		num ways = 0;
		if(nright == 0 && nup == 0){
			ways = 1;
		} else if(nright <= nup || b - a > nright - nup){
			ways = 0;
		} else {
			num path = ncr(nright + nup - 1, nup) / nright * (nright - nup);
			int z = (nright - nup) - (b - a);
			if(z > 0){
				if(nreset == 0) continue;
				nreset -= 1;
			}
			num mult = ncr(z + nreset, nreset);
			ways = path * mult;
		}
		ans += ways;
	}
	cout << (int)ans << '\n';
}

Measured memory_bytes: 166488
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;

int main() {
	int a;
	cin >> a;
	double MAX = 0;
	int b[1000];
	for (int c = 0; c < a; c++)cin >> b[c];
	sort(b, b + a);
	for (int d = 0; d < a-1; d++) {
		for (int e = d+1; e < a; e++) {
			double sum = 0, k = 0;
			for (int f = a - 1; f != -1; f--) {
				if (f != d&&f != e) {
					sum += b[f];
					k++;
					if (k == 2)break;
				}
			}
			MAX = max(MAX, sum / abs(b[d] - b[e]));
		}
	}
	printf("%.10lf\n", MAX);
}

Measured memory_bytes: 3268
N = int(input())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


factors = factorization(N)
l = []
for factor in factors:
    for i in range(factor[1]):
        l.append(factor[0]**(i + 1))
l.sort()

ans = 0
for val in l:
    if N == 1:
        break

    if N % val == 0:
        N /= val
        ans += 1

print(ans)


Measured memory_bytes: 9496
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(void){

    long long N, K;
    long long ans(0);
    cin >> N >> K;

    constexpr long long  modulo = 1000000007;
        
    for(int i=K;i<=N+1;++i){
        ans += ( i*(N-i+1) + 1);
        ans %= modulo;
    }

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


Measured memory_bytes: 3608
/* created   : 2019-08-29 10:37:21
 * accepted  : 2019-08-29 10:56:25
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

const int N = 2e5 + 7;
vector<int> sub[N];
vector<int> g[N];
int ans[N];
int inc[N];

void dfs(int u, int pr, int val) {
  ans[u] += val + inc[u];
  for (auto v : g[u]) {
    if (v != pr) {
      dfs(v, u, val + inc[u]);
    }
  }
}

void solve() {
  int n, q; cin >> n >> q;
  for (int i = 0; i < n - 1; i++) {
    int x, y; cin >> x >> y;
    x--, y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 0; i < q; i++) {
    int p, x; cin >> p >> x;
    inc[--p] += x;
  }
  dfs(0, -1, 0);
  for (int i = 0; i < n; i++) {
    cout << ans[i] << (i == n - 1 ? '\n' : ' ');
  }
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


Measured memory_bytes: 31872
#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
const ll mod = 998244353;
ll N, K;
ll dp[201000];
ll dpsum[201000];
ll L[15], R[15];

int main() {
    cin >> N >> K;
    for(int i = 0; i < K; i++) {
        cin >> L[i] >> R[i];
    }
    dp[0] = 1;
    dpsum[1] = 1;
    for(ll i = 1; i < N; i++) {
        for(ll k = 0; k < K; k++) {
            ll l = max(i - R[k], 0LL);
            ll r = max(i - L[k]+1, 0LL);
            //cerr << l << " " << r << endl;
            dp[i] += dpsum[r] - dpsum[l];
        }
        dp[i] %= mod;
        dp[i] += mod;
        dp[i] %= mod;
        dpsum[i+1] = (dpsum[i] + dp[i]) % mod;
    }
    cout << dp[N-1] << endl;
    return 0;
}


Measured memory_bytes: 6760
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K; cin >> N >> K;
	int X = 100050;
	vector<int>v(X, 0);
	rep(i, 0, N) {
		int a, b; cin >> a >> b;
		v[a] += b;
	}
	rep(i, 0, X) {
		K -= v[i];
		if (K <= 0) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main()
{
   int n,i,j,ln,sum;
   char str[100];
   while(scanf("%s",str)!=EOF){
    ln=strlen(str);
    sum=0;
    for(i=1;i<ln-1;i++){
        if(str[i]>='a'||str[i]<='z'){
            sum=sum+1;
        }
    }
    str[ln]='\0';
    printf("%c%d%c\n",str[0],sum,str[ln-1]);
   }
   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {
  char c;
  cin >> c;
  cout << (isupper(c) ? 'A' : 'a') << endl;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
#include <vector>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

const int maxn(2e5 + 10);
int n, val[maxn], f[maxn], cnt[20], ans, S, sum[maxn];

int main()
{
	scanf("%d", &n);
	for (int i = 1, a, b, c; i < n; i++)
		scanf("%d%d%d", &a, &b, &c), val[a] ^= c, val[b] ^= c;
	for (int i = 0; i < n; i++) ++cnt[val[i]];
	for (int i = 1; i <= 15; i++) ans += (cnt[i] >> 1), S |= (cnt[i] & 1) << (i - 1);
	for (int i = 1; i < (1 << 15); i++) f[i] = f[i >> 1] + (i & 1);
	for (int i = 1; i < (1 << 15); i++) --f[i];
	for (int i = 1; i < (1 << 15); i++)
		for (int j = 0; j < 15; j++) if (i & (1 << j)) sum[i] ^= (j + 1);
	for (int i = 1; i < (1 << 15); i++) if (!sum[i])
		for (int j = (i - 1) & i; j; j = (j - 1) & i)
			if (!sum[j]) f[i] = std::min(f[i], f[j] + f[i ^ j]);
	printf("%d\n", ans + f[S]);
	return 0;
}
//

Measured memory_bytes: 768
#include <stdio.h>

int main(){
	int n, i, j, A, B, x, l;
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		A = 0;
		B = 0;
		l = 0;
		for(j = 0; j < 10; j++){
			scanf("%d", &x);
			if(x <= A && x <= B){
				l = 1;
			} else if(x > A && x <= B){
				A = x;
			} else if(x <= A && x > B){
				B = x;
			} else if(A < B){
				B = x;
			} else {
				A = x;
			}
		}
		if(l == 0){
				printf("YES\n");
			} else {
				printf("NO\n");
			}
	}
	return 0;
}

Measured memory_bytes: 580
#include <cstdio>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

const int maxn = 100005;

int n;
int dep[maxn];
vector<int> s[maxn];

inline void dfs(int now)
{
//	cout << now << endl;
	dep[now] = 0;
	priority_queue<int> q;
	for(auto to : s[now])
	{
		dfs(to);
		q.push(dep[to]);
	}
	int tmpp = 0;
	while(!q.empty())
	{
		int top = q.top();
		q.pop();
		dep[now] = max(dep[now], top + (++tmpp));
	}
}

int main()
{
	scanf("%d", &n);
	for(int i = 2, t; i <= n; ++i)
	{
		scanf("%d", &t);
		s[t].push_back(i);
	}
	dfs(1);
	int ans = 0;
	for(int i = 1; i <= n; ++i)
		ans = max(ans, dep[i]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 12288
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	
	if(a==2||a==4||a==16||a==32||a==64)cout<<a<<endl;
	if(a>2&&a<4)cout<<"2"<<endl;
	if(a>4&&a<16)cout<<"4"<<endl;
	if(a>16&&a<32)cout<<"16"<<endl;
	if(a>32&&a<64)cout<<"32"<<endl;
	if(a>64&&a<=100)cout<<"64"<<endl;
	if(a<2)cout<<"1"<<endl;
	return 0;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int nmax=1000;
char mp[nmax][nmax];
int dist[nmax][nmax];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(){
  int h,w;
  cin >> h >> w;
  for(int i=0;i<h;i++){
    cin >> mp[i];
  }
  queue<pair<int,int>> q;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(mp[i][j]=='#'){
        dist[i][j]=0;
        q.push(make_pair(i,j));
      }
      else{
        dist[i][j]=-1;
      }
    }
  }
  while(!q.empty()){
    pair<int,int> p=q.front();
    q.pop();
    for(int i=0;i<4;i++){
      int x=p.first+dx[i],y=p.second+dy[i];
      if(0<=x&&x<h&&0<=y&&y<w&&dist[x][y]==-1){
        dist[x][y]=dist[p.first][p.second]+1;
        q.push(make_pair(x,y));
      }
    }
  }
  int ret=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      ret=max(ret,dist[i][j]);
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 13328
#include <bits/stdc++.h>
 
#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0
 
#define putb push_back
#define f first
#define s second
 
#define putf push_front
#define gainb pop_back
 
#define gainf pop_front
#define len(x) (ll)x.size()
 
typedef double db;
typedef long long ll;
 
const ll ary=2e6+5;
const ll mod=1e9+7;
const ll inf=1e18;
 
using namespace std;
ll x,y,fact[ary];
ll binpow(ll a,ll b){
	if(!b){
		return 1;
	}
	if(b%2){
		return (binpow(a,b-1)*a)%mod;
	}
	ll t=binpow(a,b/2);
	return (t*t)%mod;
}
int main(){
	fact[0]=1;
	for(int i=1;i<=1000000;i++){
		fact[i]=fact[i-1]*i;
		fact[i]%=mod;
	}
	cin>>x>>y;
	ll n=(x+y)/3;
	ll k=(x-y+n)/2;
	if(n<k||k<0||n<0||(x+y)%3){
		cout<<0;
		return 0;
	}
	cout<<(fact[n]*binpow((fact[n-k]*fact[k])%mod,mod-2))%mod;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
//max=({});

int main() {
	int y, m, d;
	char c1, c2;
	cin >> y >> c1 >> m >> c2 >> d;
	if (m <= 4)puts("Heisei");
	else puts("TBD");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int a,b;
  cin>>a>>b;
  cout<<a*b<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=8010;
const ll mod=1e9+7;
 
int main(){
  string s;
  int x,y;
  cin >> s >> x >> y;
  int n = s.size();
  vector<int> f[2];
  int ty=0;
  int cnt=0;
  rep(i,n){
    if(s[i]=='T'){
      f[ty].emplace_back(cnt);
      cnt = 0;
      ty ^= 1;
    } else {
      cnt++;
    }
  }
  f[ty].emplace_back(cnt);

  vector<vector<bool>> dp(2, vector<bool>(mx*2,false));
  dp[0][mx] = dp[1][mx] = true;
  rep(k,2){
    int times = f[k].size();
    rep(i,times){
      vector<bool> tmp(mx*2,false);
      rep(j,mx*2)if(dp[k][j]){
        if(j-f[k][i]>=0 && (i!=0||k!=0)) tmp[j-f[k][i]] = true;
        if(j+f[k][i]<mx*2) tmp[j+f[k][i]] = true;
      }
      dp[k] = tmp;
    }
  }
  bool ans = (dp[0][x+mx] & dp[1][y+mx]);
  if(ans){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

int main()
{
    input in;
    output out;

    auto s = in.read<std::string>();
    auto s1 = s.substr(0, s.size() / 2);
    std::string s2;
    std::copy_n(s.rbegin(), s1.size(), std::back_inserter(s2));

    int n = 0;
    for (auto i : boost::irange<std::size_t>(0, s1.size())) {
        if (s1[i] != s2[i]) ++n;
    }
    out << n;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	string s;
	cin >> s;
	
  	cout << s.at(0) << s.size()-2 << s.at(s.size()-1) << endl;
	return 0;
}

Measured memory_bytes: 256
import copy
w,h,n=map(int,input().split())
W=[i for i in range(w+1)]
H=[i for i in range(h+1)]
for _ in range(n):
    x,y,a=map(int,input().split())
    WW=copy.deepcopy(W)
    HH=copy.deepcopy(H)
    if a==1:
        for i in WW:
            if i<x:
                W.remove(i)
    if a==2:
        for i in WW:
            if i>x:
                W.remove(i)            
    if a==3:
        for i in HH:
            if i<y:
                H.remove(i)            
    if a==4:
        for i in HH:
            if i>y:
                H.remove(i)  
if W==[] or H==[]:
    print(0)
else:    
    print((W[-1]-W[0])*(H[-1]-H[0]))    

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

#define _USE_MATH_DEFINES
#define ll long long
#define ins Not Needed Thing
#define ull unsigned long long
#define ld long double
#define Accepted 0
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define emp What is it
#define SORRY FUL Accepted 
#define dimash the top one
#define I wish 
#define you be a little more calm
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)

using namespace std;

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 5e3 + 123;                                          
const int NN = 5e5 + 123;
const int PRI = 555557;
const int pri = 997;

int tests = 1;
int n, m, k, a[NN], cnt, ans;
string s;

inline void Solve () {
	// easy
	cin >> n;
	for (int i = 1; i <= n * 2; i ++) {
		cin >> a[i];
	}

	sort(a + 1, a + n + n + 1);
	
	int ans = 0;
	for (int i = 1; i <= n * 2; i += 2) {
		ans += a[i];
	}

	cout << ans ;
}

int main () {
	SpeedForce;
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);	
	// cin >> tests;
	while(tests --) {
		Solve ();
		// Ee Zadrot
	}	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int n=s.size();
    int S=0;
    int ans=n;
    for(int i=0;i<n;i++){
        if(s[i]=='S'){
            S++;
        }
        if(s[i]=='T'&&S>0){
            ans-=2;
            S--;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(int argc, char const *argv[])
{
    int R[MAX], n;

    cin >> n;
    for (int i=0; i<n; i++) cin >> R[i];

    int maxv = -2000000000;  // 最大の利益
    int minv = R[0];  // j より左側(i<j) の最小の値

    for (int i=1; i<n; i++){
        maxv = max(maxv, R[i]-minv);  // max_v = max(現在の最大利益, R_j-現在までの最小値)
        minv = min(minv, R[i]);  // max_v = min(現在までの最小値, R_i)
    }

    cout << maxv << endl;

    return 0;
}



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

using namespace std;

int n;
vector<vector<int> > g;
vector<int> a;
vector<int> dep;

void dfs(int cur, int par, int depth = 0){
	dep[cur] = depth;
	for(int u : g[cur]){
		if(u == par) continue;
		dfs(u, cur, depth+1);
	}
}

typedef pair<int, int> ii;

bool ans = true;

ii merge(ii a, ii b){
	if(a.first == -1) return b;
	if(b.first == -1) return a;
	if(a.first > b.first) swap(a, b);
	if(a.second < b.first){
		//cout<<"SHITS "<<a.first<<" "<<a.second<<" "<<b.first<<" "<<b.second<<endl;
		cout<<"No"<<endl;
		exit(0);
	}
	return {b.first, a.second};
}

vector<ii> up;

ii propUp(int cur, int par){
	ii v = {a[cur], a[cur]};
	for(int u: g[cur]){
		if(u == par){
			continue;
		}
		
		ii c = propUp(u, cur);
		if(c.first != -1){
			c.first -= 1; c.second += 1;
		}
		v = merge(c, v);
	}
	up[cur] = v;
	return v;
}

void propDown(int cur, int par, ii val = {-1, -1}){
	up[cur] = merge(up[cur], val);
	for(int u: g[cur]){
		if(u == par) continue;
		ii temp = up[cur];
		if(temp.first != -1){
			temp.first -=1, temp.second += 1;
		}
		propDown(u, cur, temp);
	}
}

vector<int> as;

void assign(int cur, int par, int pval = -1){
	if(pval == -1){
		as[cur] = up[cur].first;
	}else{
		if(up[cur].first <= pval - 1 && up[cur].second >= pval - 1){
			as[cur] = pval - 1;
		}else if(up[cur].first <= pval + 1 && up[cur].second >= pval + 1){
			as[cur] = pval + 1;
		}else{
			assert(false);
		}
	}
	for(int u: g[cur])	{
		if(u == par) continue;
		assign(u, cur, as[cur]);
	}
}

signed main(){
	ios::sync_with_stdio(false); cin.tie(0);
	
	cin>>n;
	g = vector<vector<int>  > (n);
	a = vector<int>(n, -1);
	
	for(int i = 0; i < n-1; i++){
		int u, v; cin>>u>>v; u--, v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	int k; cin>>k;
	int off = 1e5;
	int root = 0;
	for(int i = 0; i < k; i++){
		int v, p; cin>>v>>p; v--;
		
		a[v] = p + off;
		root = v;
	}
	
	//root at 0, and check the parities
	dep = vector<int>(n);
	dfs(root, -1);
	
	bool works = true;
	int last = -1;
	for(int i = 0; i < n; i++){
		if(last == -1){
			if(a[i] != -1) last = i;
			continue;
		}
		if(a[i] == -1) continue;
		if(((dep[last]^a[last]^dep[i]^a[i])&1) != 0){
		//	cout<<"LAST "<<last<<" "<<i<<endl;
			works = false;
			break;
		}
	}
	if(!works){
		cout<<"No"<<endl;
		return 0;
	}
	//cout<<"LOL"<<endl;
	
	
	//prop up
	as = vector<int>(n);
	up = vector<ii>(n);
	propUp(root, -1);
	propDown(root, -1);
	
	//assign values
	
	assign(root, -1);
	cout<<"Yes"<<endl;
	for(int i = 0; i < n; i++){
		cout<<as[i] - off<<endl;
	}
	
}


Measured memory_bytes: 17024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var ABK = ReadLine().Split().Select(int.Parse).ToArray();
        var a = Enumerable.Range(ABK[0], ABK[2]);
        var b = Enumerable.Range(ABK[1] - ABK[2] + 1, ABK[2]);
        foreach (var i in a)
        {
           if(i<ABK[1]+1) WriteLine(i);
        }
        foreach (var i in b)
        {
            if (a.Last() < i && i <= ABK[1]) WriteLine(i);
        }
    }
}



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

namespace ABC128_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var N = int.Parse(input[0]);
            var M = int.Parse(input[1]);

            var s = new int[M][];
            var p = new int[M];

            for (int i = 0; i < M; i++)
            {
                var inputsw = Console.ReadLine().Split(' ');
                var k = int.Parse(inputsw[0]);
                s[i] = new int[k];
                for (int j = 1; j <= k; j++)
                {
                    s[i][j - 1] = int.Parse(inputsw[j]) - 1;
                }
            }
            var inputp = Console.ReadLine().Split(' ');
            for (int i = 0; i < M; i++)
            {
                p[i] = int.Parse(inputp[i]);
            }

            var ans = 0;
            for (int bit = 0; bit < (1 << N); bit++)
            {
                var ok = true;
                for (int i = 0; i < M; i++)
                {
                    var c = 0;
                    foreach (var item in s[i])
                    {
                        if ((bit >> item & 1) != 0)
                        {
                            c++;
                        }
                    }

                    c %= 2;
                    if (c != p[i])
                    {
                        ok = false;
                    }
                }
                if (ok)
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11220
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define inf 1e18
#define mm 998244353

void solve(){
	ll a,b,c,k; cin>>a>>b>>c>>k;
	ll ans = 0;
	ans = min(a,k);
	if(k > a+b){
		ll rem = k - a - b;
		ans -= rem;
	}
	cout<<ans<<endl;
}

int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

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

int main(){
	ll N, P;
	cin >> N >> P;
	ll i = 2;
	ll p = P;
	ll ans = 1;
	while(i*i<=p){
		if(P == 1){
			break;
		}
		ll cnt = 0;
		while(P%i == 0){
			P = P/i;
			cnt++;
		}
		cnt = cnt/N;
		for(int j=0; j<cnt; j++){
			ans = ans*i;
		}
		i++;
	}
	if(N == 1){
		cout << p << endl;
	}else{
		cout << ans << endl;
	}
	return 0;
}


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

using namespace std;

int main() {
	int N, R, L;
	cin >> N >> R >> L;
	vector<long long int> data(N+1, 0);
	vector<int> timet(N+1, 0);
	int maxteam = 1;
	int maxs = 0;
	int time = 0;
	int d, t, x;
	for (int i = 0; i < R; i++) {
		cin >> d >> t >> x;
		timet[maxteam] += t-time;
		data[d] += x;
		time = t;
		if (d == maxteam && x >= 0) {
			maxs = data[d];
		} else if (d != maxteam && data[d] < maxs){
		} else if (data[d] == maxs && d < maxteam){
			maxteam = d;
		} else {
			maxteam = 1;
			maxs = data[1];
			for (int j = 2; j <= N; j++) {
				if (data[j] > maxs) {
					maxs = data[j];
					maxteam = j;
				}
			}
		}
	}
	timet[maxteam] += L-time;
	int k, ktoku;
	k = 1;
	ktoku = timet[1];
	for (int i = 2; i <= N; i++) {
		if (timet[i] > ktoku) {
			ktoku = timet[i];
			k = i;
		}
	}
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 2324
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int d[maxn],e[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>d[i]>>e[i];
    for(int i=1;i<=n-2;i++)
    {
    	if(d[i]==e[i]&&d[i+1]==e[i+1]&&d[i+2]==e[i+2])
    	{
    		cout<<"Yes"<<endl;
    		exit(0);
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>
int calculate_point(char a[], char b[])
{
    int cmp = strcmp(a, b);
    if (cmp > 0) //a > b
    {
        return 3;
    }
    else if (cmp < 0) //a < b
    {
        return 0;
    }
    return 1; // a = b
}
int main(void)
{
    int turn;
    int taro_p = 0;
    int hana_p = 0;
    int i = 0;

    scanf("%d", &turn);
    while (i < turn)
    {
        char taro[101];
        char hana[101];
        scanf("%s %s", taro, hana);

        taro_p += calculate_point(taro, hana);
        hana_p += calculate_point(hana, taro);
        i++;
    }
    printf("%d %d\n", taro_p, hana_p);

    return 0;
}
//実行結果も正しいように思え、何がダメなのか分からない。


Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;

int main(){
  int n; cin >> n;
  char c[2][n]; rep(i, 2)rep(j, n) cin >> c[i][j];
  long ans = 1;
  long mod = 1e9 + 7;
  bool prev = true;
  rep(i, n){
    if(i == 0){
      if(c[0][i]==c[1][i]) ans = ans * 3 % mod, prev = true;
      else ans = ans * 6 % mod, prev = false, i++;
    }
    else{
      if(c[0][i]==c[1][i] && prev) ans = ans * 2 % mod, prev = true;
      else if(c[0][i]==c[1][i] && !prev) prev = true;
      else if(c[0][i]!=c[1][i] && prev) ans = ans * 2 % mod, prev = false, i++;
      else if(c[0][i]!=c[1][i] && !prev) ans = ans * 3 % mod, prev = false, i++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000000000
#define MAXN        10005
#define mod         1000000007  
#define pi          3.1415926535897932384626433
 
 ll fun(ll x,ll y){
     ll ans=1;
     while(y>0){
         if(y%2==1){
             ans=(ans*1ll*x)%mod;
         }
         y=y/2;
         x=(x*1ll*x)%mod;
     }
     return ans;
 }
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll fac[MAXN],infac[MAXN],i,z1,z2,z3,z4,x,pa;
    fac[0]=1;
    for(i=1;i<MAXN;i++){
        fac[i]=fac[i-1]*1ll*i;
        fac[i]%=mod;
    }
    for(i=0;i<MAXN;i++){
        infac[i]=fun(fac[i],mod-2);
    }
    ll n,ans=1;
    cin>>n;
    x=n/3;
    if(n==1 || n==2){
        cout<<0;
    }
    else{
        // cout<<ans<<endl;
        for(i=2;i<=x;i++){
            pa=n-i*3;
            z1=pa+(i-1);
            z2=(i-1);
            z3=infac[z2]*1ll*infac[z1-z2];
            // cout<<z1<<" "<<z2<<endl;
            z3%=mod;
            z4=fac[z1]*1ll*z3;
            z4%=mod;
            ans+=z4;
            ans%=mod;
        }
        cout<<ans;
    }
}

Measured memory_bytes: 3804
s = input()
length = len(s)
BASE = 100
MOD1 = 1000000007
MOD2 = 2147483647
acc1 = 0
acc2 = 0
hlst1 = [0]
hlst2 = [0]
for c in s:
  i = ord(c)
  acc1 = (acc1 * BASE + i) % MOD1
  acc2 = (acc2 * BASE + i) % MOD2
  hlst1.append(acc1)
  hlst2.append(acc2)

def calc_hash(left, right, xlen):
  return ((hlst1[right] - hlst1[left] * pow(BASE, xlen, MOD1)) % MOD1,
          (hlst2[right] - hlst2[left] * pow(BASE, xlen, MOD2)) % MOD2)

for i in range(length // 3, -1, -1):
  if (length - (i + 1) * 3) % 2:continue
  alen = i + 1
  blen = (length - (i + 1) * 3) // 2
  if blen <= 0:continue
  ha1 = calc_hash(0, alen, alen)
  ha2 = calc_hash(alen + blen, blen + alen * 2, alen)
  if ha1 != ha2:continue
  ha3 = calc_hash(blen * 2 + alen * 2, blen * 2 + alen * 3, alen)
  if ha1 != ha3:continue
  hb1 = calc_hash(alen, alen + blen, blen)
  hb2 = calc_hash(blen + alen * 2, blen * 2 + alen * 2, blen)
  if hb1 != hb2:continue
  print("Love {}!".format(s[:i + 1 + blen]))
  break
else:
  print("mitomerarenaiWA")



Measured memory_bytes: 87200
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int a, b, c; cin >> a >> b >> c;
  cout << min({a, b, c}) << " " << max({a, b, c}) << '\n';

  return 0;
}


Measured memory_bytes: 3208
#include "iostream"
#include "math.h"
#include "algorithm"
using namespace std;

int H, W;
int dp[101][101][4];
int ans;

int main() {
	for (int i = 1; i < 101; i++) {
		dp[1][i][0] = 1;
		dp[i][1][2] = 1;
	}
	for (int i = 2; i < 101; i++) {
		for (int j = 2; j < 101; j++) {
			dp[i][j][0] += dp[i][j - 1][0];
			dp[i][j][0] += dp[i][j - 1][1];
			dp[i][j][1] += dp[i][j - 1][2];
			dp[i][j][2] += dp[i - 1][j][2];
			dp[i][j][2] += dp[i - 1][j][3];
			dp[i][j][3] += dp[i - 1][j][0];
			for (int k = 0; k < 4; k++) {
				dp[i][j][k] %= 100000;
			}
		}
	}
	cin >> H >> W;
	while (H != 0) {
		for (int i = 0; i < 4; i++) {
			ans += dp[H][W][i];
			ans %= 100000;
		}
		cout << ans << "\n";
		ans = 0;
		cin >> H >> W;
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv){vprint(v)};

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

    ll N, X, M;
    cin >> N >> X >> M;

    unordered_map<ll, ll> m;
    vll a(M);
    a[0] = X;
    m[a[0]] = 0;

    ll last = 0;
    ll back = 0;
    REP(i, 1, M){
        a[i] = (a[i-1]*a[i-1]) % M;
        if(m.find(a[i])!=m.end()){
            back = m[a[i]];
            break;
        }
        m[a[i]] = i;
        ++last;
    }
    if(N<=last+1){
        ll s = 0;
        rep(i, N) s += a[i];
        cout << s << endl;
    }
    else{
        ll s = 0, t = 0;
        rep(i, last+1) s += a[i];
        REP(i, back, last+1) t += a[i];
        ll r = N - last - 1;
        ll total = s;
        total += t*(r/(last+1-back));
        r %= last+1-back;
        REP(i, back, back+r) total += a[i];
        cout << total << endl;
    }
}


Measured memory_bytes: 6112
#include <stdio.h>
int main(){
  int i,j,n,u,v,k,A[101][101];
  scanf("%d",&n);
  for(i = 1;i <= n;i++){
    for(j = 1;j <= n;j++){
      A[i][j] = 0;
    }
  }
  
  for(i = 1;i <= n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j = 1;j <= k;j++){
      scanf("%d",&v);
      A[u][v] = 1;
      }
  }
  for(i = 1;i <= n;i++){
    for(j = 1;j <= n;j++){
      if(j != 1)printf(" ");
    printf("%d",A[i][j]);
    }
    printf("\n");
  }
  return 0;
}



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

using namespace std;

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++) {
    cin >> C[i];
    for (int j = 0; j < M; j++) cin >> A[i][j];
  }

  int64_t answer = numeric_limits<int>::max();
  for (int i = 0; i < 1 << N; i++) {
    int64_t pay = 0;
    vector<int> Y(M);
    for (int j = 0; j < N; j++) {
      if (i & (1 << j)) {
        pay += C[j];
        for (int k = 0; k < M; k++) {
          Y[k] += A[j][k];
        }
      }
    }

    bool ok = true;
    for (int k = 0; k < M; k++) {
      if (X > Y[k]) {
        ok = false;
      }
    }

    if (ok) {
      answer = min(answer, pay);
    }
  }

  if (answer == numeric_limits<int>::max()) {
    cout << "-1" << endl;
  } else {
    cout << answer << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,x,y;cin >> n >> x >> y;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  if(n==1){
    cout << abs(a[0]-y) << endl;
  }
  else{
    cout << max(abs(a[n-1]-y),abs(a[n-1]-a[n-2])) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>

using namespace std;

using vi = vector<int>;

int busBin(int ini, int fin, int buscado, vi const& ends) {
	if (ini >= fin) return ini;
	else {
		int mitad = (ini + fin - 1) / 2;
		//if (ends[mitad] == buscado) return mitad;
		if (ends[mitad] >= buscado) return busBin(mitad + 1, fin, buscado, ends);
		else return busBin(ini, mitad, buscado, ends);
	}
}

bool res() {
	int n;
	cin >> n;
	if (!cin) return false;

	vi v(n);
	vector<bool> marcaje(n, true);
	for (int i = 0; i < n; ++i) cin >> v[i];

	vi nmaxcol; nmaxcol.push_back(-1);

	for (int i = 0; i < n; ++i) {
		int posb = busBin(0, nmaxcol.size(), v[i], nmaxcol);
		if (posb == nmaxcol.size()) {
			nmaxcol.push_back(v[i]);
		}
		else {
			nmaxcol[posb] = v[i];
		}
	}

	cout << nmaxcol.size() << '\n';

	return true;
}

int main() {
	while (res()) {}
	return 0;
}

Measured memory_bytes: 1280
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T read(T)(){ return read.to!T; }
T[] read(T)(long n){ return n.iota.map!(_ => read!T).array; }
T[][] read(T)(long m, long n){ return m.iota.map!(_ => read!T(n)).array; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

/*

終了後(ネタバレ見た)

xs[k][i]: i番目までを使い、赤の和がkである場合の数
ys[k][i]: i番目までを使い、赤の和がk、青の和が0である場合の数


求めるものは
s := sum(i; 0 .. n) a[i]
u = 3 sum(k: (s - 1) / 2 .. s + 1) xs[k][n - 1]
sが偶数の場合更に u -= 3 ys[s / 2][n - 1]

ans = 3 ** n - u

xs[0][0] = 2
xs[a[0]][0] = 1
xs[k][i] = xs[k][i - 1] * 2 + xs[k - a[i]][i - 1]

ys[0][0] = 1
ys[a[0]][0] = 1
ys[k][i] = ys[k][i - 1] + ys[k - a[i]][i - 1]

*/
const long mod = 998244353;

void solve(){
	long n = read!long;
	long[] as = read!long(n);
	
	long sum = as.sum;
	log("sum:", sum);
	
	long[][] xs = new long[][](sum + 1, n);
	long[][] ys = new long[][](sum + 1, n);
	foreach(k; 0 .. sum + 1) foreach(i; 0 .. n){
		if(i == 0){
			if(k == 0) xs[k][i] = 2, ys[k][i] = 1;
			else if(k == as[0]) xs[k][i] = 1, ys[k][i] = 1;
		}
		else{
			long x = (xs[k][i - 1] * 2) % mod;
			if(k - as[i] >= 0) x += xs[k - as[i]][i - 1], x %= mod;
			xs[k][i] = x;
			long y = ys[k][i - 1];
			if(k - as[i] >= 0) y += ys[k - as[i]][i - 1], y %= mod;
			ys[k][i] = y;
		}
	}
	log("xs:", xs);
	log("ys:", ys);
	log("xs[-][n - 1]:", xs.map!(q => q[$ - 1]));
	log("ys[-][n - 1]:", ys.map!(q => q[$ - 1]));
	
	long u;
	foreach(k; (sum + 1) / 2 .. sum + 1) u += 3 * xs[k][n - 1], u %= mod;
	if(sum % 2 == 0) u += mod - 3 * ys[sum / 2][n - 1], u %= mod;
	log("u:",u);
	
	long pow3 = 1;
	foreach(i; 0 .. n) pow3 *= 3, pow3 %= mod;
	log("pow3:", pow3);
	
	long ans = (pow3 + mod - u) % mod;
	ans.writeln;
}


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

int main() {
  string A;
  cin >> A;
  if(A=="G"){
    cout << "C" << endl;
  }
  else if(A=="C"){
	cout << "G" << endl;
  }
  else if(A=="A"){
    cout << "T" << endl;
  }
  else{
    cout << "A" << endl;
  }
}


Measured memory_bytes: 256
#coding: utf-8

def printCards(C, N):
    for i in range(N):
        if i > 0:
            print(' ', end = '')
        print(C[i][0], end = '')
    print('')
    return True

n = int(input())
cards0 = map(str, input().split())
cards1 = list()
for i in cards0:
    cards1.append((i, int(i[1])))
cards2 = cards1[:]
del cards0

# BubbleSort
for i in range(n):
    for j in range(n-1, i, -1):
        if cards1[j][1] < cards1[j-1][1]:
            temp = cards1[j]
            cards1[j] = cards1[j-1]
            cards1[j-1] = temp
printCards(cards1, n)
print('Stable')

# SelectionSort
for i in range(n-1):
    minj = i
    for j in range(i+1, n):
        if cards2[j][1] < cards2[minj][1]:
            minj = j
    temp = cards2[i]
    cards2[i] = cards2[minj]
    cards2[minj] = temp
printCards(cards2, n)

for i in range(n):
    if cards1[i] != cards2[i]:
        print('Not stable')
        exit()
print('Stable')


Measured memory_bytes: 5628
#include<bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<ll,pair<ll,ll>> ppl;
const int N=305, M=N*N;
vector<pair<int,int>>edges[N];
int dp[N][N];
int n,m,l;
struct cmp { 
    bool operator()(ppl const& p1, ppl const& p2) { 
        if(p1.first!=p2.first) return p1.first > p2.first; 
        if(p1.second.first!=p2.second.first) return p1.second.first<p2.second.first;
        return p1.second.second>p2.second.second;
    } 
}; 

void dijkstra(int s) {
	priority_queue<ppl, vector<ppl>, cmp>pq;
	pq.push({0ll,{l,s}});
	while(!pq.empty()) {
		auto x = pq.top();	pq.pop();
		ll u=x.second.second, capacity=x.second.first;
		ll cost = x.first;

		if(dp[s][u]!=-1)	continue;
		dp[s][u]=cost;

		for(auto x:edges[u]) {
			ll v=x.first, w=x.second;
			if(dp[s][v]==-1) {
				if(w<=capacity) {
					pq.push({cost,{capacity-w,v}});
				}else if((l-w)>=0){
					pq.push({cost+1,{l-w,v}});
				}
			}
		}
	}
}
int main()
{
	memset(dp,-1,sizeof(dp));
	cin>>n>>m>>l;
	for(int i=0;i<m;i++){
		ll u,v,w;cin>>u>>v>>w;
		u--;v--;
		edges[u].push_back({v,w});
		edges[v].push_back({u,w});
	}
	for(int i=0;i<n;i++) {
		dijkstra(i);
	}
	int q;cin>>q;
	while(q--){
		ll u,v;cin>>u>>v;
		u--;v--;
		cout<<dp[u][v]<<"\n";
	}
	return 0;
}


Measured memory_bytes: 7344
H = int(input())
W = int(input())
N = int(input())

if H <= W:
    if N % W == 0:
        print(int(N/W))
    else:
        print(int((N//W) + 1))
else:
    if N % H == 0:
        print(int(N/H))
    else:
        print(int((N//H) + 1))

Measured memory_bytes: 3060
# 比较冒泡排序和选择排序

def bubble_sort(arr):
    no_swap = True
    #swap_cnt = 0
    for i in range(len(arr), 0, -1):
        if not no_swap:
            break
        for j in range(0, i - 1):
            if arr[j] > arr[j + 1]:
                arr[j], arr[j + 1] = arr[j + 1], arr[j]
                #swap_cnt += 1
            no_swap = True
    #return swap_cnt

def selection_sort(arr):
    #swap_cnt = 0
    for i in range(0, len(arr)):
        min_index = i
        for j in range(i + 1, len(arr)):
            if arr[min_index] > arr[j]:
                min_index = j
        if min_index != i:
            arr[i], arr[min_index] = arr[min_index], arr[i]
            #swap_cnt += 1
    #return swap_cnt

# n^4 method
def is_stable(raw, sort_):
    N = len(raw)
    for i in range(N):
        for j in range(i + 1, N):
            for m in range(N):
                for n in range(m + 1, N):
                    if (raw[i].value == raw[j].value) and (raw[i] == sort_[n]) and (raw[j] == sort_[m]):
                        return 'Not stable'
    return 'Stable'

class Card:
    suit = ''
    value = 0

    def __init__(self, val):
        self.suit = val[0]
        self.value = int(val[1])

    def __lt__(self, rhv):
        return self.value < rhv.value

    def __eq__(self, rhv):
        return self.suit == rhv.suit and self.value == rhv.value

    def __ne__(self, rhv):
        return not (self == rhv)

    def __str__(self):
        return '%s%d'%(self.suit, self.value)

if __name__ == '__main__':
    N = int(input())
    raw = list(map(Card, input().split()))
    arr1 = []
    arr2 = []
    for i in raw:
        arr1.append(i)
        arr2.append(i)
    bubble_sort(arr1)
    result = is_stable(raw, arr1)
    print(' '.join(map(str, arr1)))
    # print('Stable')
    print(result)
    selection_sort(arr2)
    print(' '.join(map(str, arr2)))
    result = is_stable(raw, arr2)
    print(result)
    # for i in range(len(arr1)):
    #     if arr1[i] != arr2[i]:
    #         print('Not stable')
    #         break
    #     if i == len(arr1) - 1:
    #         print('Stable')



Measured memory_bytes: 5616