akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
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; }


ll DP[3010][3010];
int N;
ll a[3000];
ll solve(int i, int j){//i:jから始めたときのX-Yを求める関数。
    if (DP[i][j] != -1) {
        return DP[i][j];
    }
    if (j-i == 1){
        return a[i];
    }
    ll st = a[i];
    ll en = a[j-1];
    if ((N - (j-i)) % 2 == 0){//X-Yを最大化する。今から求めるのはX。
        if (j-i == 2){
            DP[i][j] = max(st - en, en - st);
        }else{
            DP[i][j] = max(st + solve(i+1, j), solve(i, j-1) + en);
        }
    }else{//X-Yを最小化する。今から取るのはY。
        if (j-i == 2){
            DP[i][j] = min(st - en, en - st);
        }else{
            DP[i][j] = min(solve(i+1, j) - st, solve(i, j-1) - en);
        }
    }
    return DP[i][j];
}
int main() {
    cin >> N;
    REP(i, N) {
        cin >> a[i];
    }
    REP(i, N+1) {
        REP(j, N+1) {
            DP[i][j] = -1;
        }
    }
    cout << solve(0, N);

}

Measured memory_bytes: 70912
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    int64 N;
    int64 tmp=0,num=0;
    cin>>N;
    vector<int64> a(N+1);
    vector<int64> b(N+1);
    
    for(int64 i=1;i<=N;i++){
        cin>>a[i];
        b[i]=0;
    }

    for(int64 i=N;i>0;i--){
        tmp=0;
        for(int64 j=N/i+1;j>1;j--){
            if(j*i<=N) tmp+=b[j*i];
        }
        if(tmp%2!=a[i]){
            b[i]=1;
            num++;
        }
    }

    cout<<num<<endl;

    for(int64 i=1;i<=N;i++){
        if(b[i]==1) cout<<i<<" ";
    }

    // cout<<endl;
    return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
#include <cstring>

#define MOD 1000000007

using namespace std;

typedef long long LL;

const int MAXN = 2000 + 10;
const int MAXM = MAXN * MAXN;

int N, K;

LL fact[MAXM]= {0}, invfact[MAXM]= {0};
void init () {
	fact[0] = fact[1] = invfact[0] = invfact[1] = 1;
	for (int i = 2; i <= N * K; i ++) {
		fact[i] = fact[i - 1] * i % MOD;
		invfact[i] = (MOD - MOD / i) * invfact[MOD % i] % MOD;
	}
	for (int i = 1; i <= N * K; i ++)
		invfact[i] = invfact[i - 1] * invfact[i] % MOD;
}
inline LL C (int n, int m) {
	if (n < 0) return 0;
	if (m == 0) return 1;
	return fact[n] * invfact[m] % MOD * invfact[n - m] % MOD;
}

LL f[MAXN][MAXN]= {0};

int main () {
	scanf ("%d%d", & N, & K);
	if (K == 1) {
		puts ("1");
		return 0;
	}
	init ();
	f[0][0] = 1;
	for (int i = 1; i <= N; i ++)
		for (int j = 0; j <= i; j ++) {
			LL delta = f[i][j - 1] * (N - j + 1) % MOD * C (N * K - i - (K - 1) * (j - 1) - 1, K - 2) % MOD;
			if (j == 0) delta = 0;
			f[i][j] = (f[i][j] + f[i - 1][j] + delta) % MOD;
		}
	cout << f[N][N] << endl;

	return 0;
}

/*
2 2
*/

/*
3 1
*/

/*
2 3
*/

/*
2000 2000
*/

Measured memory_bytes: 93184
#include <cstdio>
#include <iostream>

using namespace std;

int main(void) {
  string s;

  cin >> s;

  for(int i = 0; i < s.length(); i++) {
    if(s[i] == 'B') {
      if(i != 0) {
	s.erase(s.begin() + i-1);
	s.erase(s.begin() + i-1);
	i -= 2;
      }
      else {
	s.erase(s.begin());
	i = 0;
      }
    }
  }

  cout << s << endl;
}

Measured memory_bytes: 256
// D - Disjoint Set of Common Divisors
#include <bits/stdc++.h>

using namespace std;

#ifdef	__clang__
long long __gcd(long long a, long long b)
{
	while (a) { long long tmp = b % a; b = a; a = tmp; }
	return b;
}
#endif

template<class T>
int divisors(T x, vector<T> &d)
{
	T i, j, k, t, sq, n;
	vector<pair<T, int> > p;

	if (x % 2 == 0) {
		for (n = 0; x % 2 == 0; n++) x /= 2;
		p.push_back(make_pair(2, n));
	}

	for (i = 3, sq = sqrt(x); i <= sq; i += 2)
		if (x % i == 0) {
			for (n = 0; x % i == 0; n++) x /= i;
			p.push_back(make_pair(i, n));
			sq = sqrt(x);
		}

	if (x > 1)
		p.push_back(make_pair(x, 1));

	n = 1;
	for (i = 0; i < p.size(); i++)
		n *= p[i].second + 1;

	d.assign(n, 1);
	for (i = 0; i < n; i++)
		for (t = i, j = 0; t && j < p.size(); t /= p[j].second + 1, j++)
			for (k = 0; k < t % (p[j].second + 1); k++)
				d[i] *= p[j].first;

	sort(d.begin(), d.end());
	return (int) n;
}

int main(int argc, char *argv[])
{
	long long a, b;
	cin >> a >> b;
	long long g = __gcd(a, b);

	vector<long long> d;
	int n = divisors(g, d);
	vector<int> f(n);
	for (int i = 1; i < n; i++) {
		if (f[i]) continue;
		for (int j = i + 1; j < n; j++)
			if (d[j] % d[i] == 0) f[j] = 1;
	}
	int ans = 0;
	for (int i = 0; i < n; i++)
		if (f[i] == 0) ans++;
	cout << ans << endl;

	return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vector<pii> arr (N);
	F0R(i, N) {
		int X, D; cin >> X >> D;
		arr[i] = {X + D, X - D};
	}
	sort(arr.begin(), arr.end());

	int ans = 0;
	int last = -1e9;
	for (pii seg : arr) {
		if (seg.second >= last) {
			last = seg.first;
			++ans;
		}
	}
	print(ans);
}

Measured memory_bytes: 3988
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int mod = 1000000007;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
int c[500];
int s[500];
int f[500];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n - 1; i++)
        cin >> c[i] >> s[i] >> f[i];
    ll t[n];
    for (int i = 0; i < n - 1; i++)
    {
        t[i] = 0;
        for (int j = i; j < n - 1; j++)
        {
            if (t[i] <= s[j])
            {
                t[i] = s[j] + c[j];
            }
            else
            {
                if (t[i] % f[j] != 0)
                    t[i] += (f[j] - t[i] % f[j]);
                t[i] += c[j];
            }
        }
    }
    t[n - 1] = 0;
    for (int i = 0; i < n; i++)
    {
        cout << t[i] << "\n";
    }
}

Measured memory_bytes: 256
/* 実行時間1s制限の場合
  10^6 1,000,000   : 余裕をもって間に合う
  10^7 10,000,000  : おそらく間に合う
  10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
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; }

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    std::ifstream in("a.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

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

    cout << (t/a)*b;

    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<cmath>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void sort(int &a,int &b)
{
	if(a>b)
		swap(a,b);
}
void open(const char *s)
{
#ifndef ONLINE_JUDGE
	char str[100];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
	sprintf(str,"%s.out",s);
	freopen(str,"w",stdout);
#endif
}
int rd()
{
	int s=0,c;
	while((c=getchar())<'0'||c>'9');
	do
	{
		s=s*10+c-'0';
	}
	while((c=getchar())>='0'&&c<='9');
	return s;
}
int upmin(int &a,int b)
{
	if(b<a)
	{
		a=b;
		return 1;
	}
	return 0;
}
int upmax(int &a,int b)
{
	if(b>a)
	{
		a=b;
		return 1;
	}
	return 0;
}
vector<pll> a[100];
ll inf=1000000000000000000ll;
ll f[100];
ll p=1000000007;
void init()
{
	f[0]=f[1]=1;
	int n=1;
	while(1)
	{
		f[n+1]=f[n-1]+f[n];
		if(f[n+1]>inf)
			break;
		n++;
	}
	a[1].push_back(pll(1,2));
	a[1].push_back(pll(1,3));
	a[1].push_back(pll(1,4));
	int i;
	ll x,y;
	for(i=1;i<=n-3;i++)
		for(auto v:a[i])
		{
			x=v.first;
			y=v.second;
			for(x+=y;x<=f[i+3]+f[i];x+=y)
				a[i+1].push_back(pll(y,x));
		}
}
int main()
{
	init();
	int t;
	ll n,m,x,y;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%lld%lld",&n,&m);
		if(n>m)
			swap(n,m);
		int s=1;
		while(f[s+1]<=n&&f[s+2]<=m)
			s++;
		printf("%d ",s);
		if(s==1)
			printf("%lld\n",n*m%p);
		else
		{
			ll ans=0;
			for(auto v:a[s-1])
			{
				x=v.first;
				y=v.second;
				if(y<=n)
					ans+=(m-x)/y%p;
				if(y<=m)
					ans+=(n-x)/y%p;
				ans%=p;
			}
			printf("%lld\n",ans);
		}
	}
	return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> pii;
const int N = 2e6 + 100;

int a[5], ans, maxi;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
		ans += ((a[i] + 9) / 10) * 10;
		if(a[i] % 10)
			maxi = max(maxi, 10 - a[i] % 10);
	}
	cout << ans - maxi;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

template<typename T>
class SegTree {
public:
  int n;
  vector<T> data;
  SegTree(int m){
    n=1;
    while(n<m) n*=2;
    data.resize(2*n, INF);
  }
  T query(int l, int r){
    T ret = INF;
    for(l+=n, r+=n; l<r; l/=2, r/=2){
      if(l&1) ret = min(ret, data[l++]);
      if(r&1) ret = min(ret, data[--r]);
    }
    return ret;
  }
  void update(int k, T a){
    k+=n;
    data[k]=a;
    while(k>0){
      k = k/2;
      data[k] = min(data[k*2], data[k*2+1]);
    }
  }
  inline T operator[](int idx){ return data[idx+n]; }
};

int main(){
  int n;
  cin>>n;
  vector<int> b(n+1);
  rep(i,n) cin>>b[i+1];
  b[0] = 1;
  vector<int> acc(n+1,0);
  acc[0] = 0;
  rep(i,n) acc[i+1] = acc[i] + (!b[i+1]);

  int q;
  cin>>q;
  vector<pair<int,int>> v(q);
  rep(i,q) cin>>v[i].fi >> v[i].se;

  sort(all(v));

  vector<int> dp(n+1, INF);
  dp[0] = 0;
  SegTree<int> st(n+1);

  int j = 0;
  rep(i,1,n+1){
    dp[i] = min(dp[i-1], st[i-1] + acc[i-1]) + b[i];
    for(; j<q && v[j].fi==i; j++){
      int pr = v[j].se;
      int nv = min(dp[i-1] + acc[pr] - acc[i-1], st.query(i-1, pr) + acc[pr]);
      if(nv - acc[pr] < st[pr]) st.update(pr, nv - acc[pr]);
      // dbg(i,pr,nv,st[pr]);
    }
  }

  cout << min(dp[n], st[n] + acc[n]) << endl;


  return 0;
}


Measured memory_bytes: 6272
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1, i##_end_ = (n); i <= i##_end_; ++i)
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;



const double eps = 1e-10;
int sgn(double x) {
    if(fabs(x) < eps) return 0;
    return x < 0 ? -1 : 1;
}
struct Point {
    double x, y;
    Point(double xp=0, double yp=0): x(xp), y(yp) { }
    Point operator + (const Point& rhs) const { return Point(x+rhs.x, y+rhs.y); }
    Point operator - (const Point& rhs) const { return Point(x-rhs.x, y-rhs.y); }
    Point operator * (const double& k) const { return Point(x*k, y*k); }
    Point operator / (const double& k) const { return Point(x/k, y/k); }
    bool operator < (const Point& rhs) const {
        return x < rhs.x || (x==rhs.x && y<rhs.y);
    }
};

double dot(Point x, Point y) { return x.x*y.x + x.y*y.y; }
double length(Point x) { return sqrt(dot(x, x)); }
double cross(Point A, Point B) { return A.x*B.y - A.y*B.x; }


Point GetLineProjection(Point P, Point A, Point B) {
    Point v = B - A;
    return A + v * (dot(P-A, v) / dot(v, v));
}

int main() {
    Point a, b, p, ans;
    scanf("%lf%lf%lf%lf", &a.x, &a.y, &b.x, &b.y);
    int q; scanf("%d", &q);
    while(q--) {
        scanf("%lf%lf", &p.x, &p.y);
        ans = GetLineProjection(p, a, b);
        printf("%.12f %.12f\n", ans.x, ans.y);
    }
    
    return 0;
}


Measured memory_bytes: 3208
#include<stdio.h>
#include<string.h>

#define M 1000000
#define L 14

char H[M][L];

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M;}
int h2(int key){ return 1 + (key % (M - 1));}

int find(char str[]){
    /* your task */
  
  long long key, i, h;
  
  key = getKey(str);
  
  for ( i = 0;; i++){   
    h = (h1(key) + i * h2(key)) % M;
    if( strcmp(H[h],str) == 0 ){  
    return 1;
      
    }
    else if ( strlen(H[h]) == 0 ) {
      
     return 0;   
    }
  }
  return 0;
}

int insert(char str[]){
  long long key, i, h;
  key = getKey(str);
  
  for ( i = 0; ; i++ ){ 
    h = (h1(key) + i * h2(key)) % M; 
    if( strcmp(H[h],str) == 0 ) {  
      return 1;  
    }
    else if ( strlen(H[h]) == 0 ){
      
      strcpy(H[h], str);
      return 0;   
    }
  }
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }
    return 0;
}

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

int main() {
	long long A;
	long double B, N;
	cin >> A >> B >> N;
	long double x;
	if (N < B) {
		x = N;
	} else {
		x = B - 1;
	}

	long long ans = A * (x / B);
	ans -= A * (long long)(x / B);

	cout << ans << endl;
}

Measured memory_bytes: 3728
n = int(input())
b = list(map(int, input().split()))
ans = []
while b:
    for i, j in enumerate(reversed(b)):
        if j==len(b)-i:
            ans.append(j)
            del b[len(b)-i-1]
            break
    else:
        print(-1)
        break
else:
    for i in reversed(ans):
        print(i)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
using LL = long long;

int main() {
    LL x;
    cin >> x;

    std::pair<LL, LL> ans;
    for(LL i = -200; i <= 200; ++i) {
        for(LL j = -200; j <= 200; ++j){
            if(i*i*i*i*i - j*j*j*j*j == x) {
                ans = {i, j};
            }
        }
    }

    cout << ans.first << " " << ans.second << endl;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    int H, W; cin >> H >> W;
    vector<vc> A(H, vc(W)) ;
    rep(i, H) rep(j, W) cin >> A[i][j];

    vi x;
    rep(i, H) {
        int cnt = 0;
        rep(j, W) {
            if (A[i][j] == '.') cnt++;
        }
        if (cnt != W) {
            x.push_back(i);
        }
    }

    vi y;
    rep(j, W) {
        int cnt = 0;
        rep(i, H) {
            if (A[i][j] == '.') cnt++;
        }
        if (cnt != H) {
            y.push_back(j);
        }
    }

    rep(i, x.size()) {
        rep(j, y.size()) {
            cout << A[x[i]][y[j]];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3656
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  string s;cin>>s;
  if(s.at(2)==s.at(3) && s.at(4)==s.at(5))
    cout<<"Yes";
  else
    cout<<"No";
}

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

int main(void){
    double n, m;
    std::cin >> n >> m;
    double sum = 0;
    std::vector<double> a(n);

/*
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
        sum += a[i];
    }
    std::cout << sum << std::endl;
    double border = sum * 1 / 4 / m;

    std::sort(a.rbegin(), a.rend());
    for(auto i : a){
        std::cout << i << " ";
    }
    std::cout << std::endl;
    if( a[m-1] >= border ){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    */


   for(int i = 0; i < n; i++){
        std::cin >> a[i];
        sum += a[i];
    }

    int cnt = 0;
    double border = sum * 1 / 4 / m;

    for(int i = 0; i < n; i++){
        if(a[i] < border){
            
        }else{
            cnt++;
        }
    }
    
    if(cnt >= m){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<iostream> 
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define ll long long
#define ull unsigned long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define eps 1e-18
#define maxn 100010
inline ll read(){ll tmp=0; char c=getchar(),f=1; for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1; for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0'; return tmp*f;}
inline ll power(ll a,ll b){ll ans=1; for(;b;b>>=1){if(b&1)ans=ans*a%mod; a=a*a%mod;} return ans;}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void swap(int &a,int &b){int tmp=a; a=b; b=tmp;}
using namespace std;
int k;
int main()
{
	k=read()*read();
	if(k&1)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 764
#include<iostream>
using namespace std;
#define int long long int
int32_t main()
{
	int n;
	cin>>n;
	int arr[n+1]={0};
	int j;
	for(j=2;j<=n;j++)
    {
		int x;
		cin>>x;
		arr[x]++;
	}
	for(j=1;j<=n;j++)
	  cout<<arr[j]<<endl;
}


Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1000000000000005;
const int maxn=1e6+5;
ll n,m,p;
char s[maxn],t[maxn];
int main()
{
    scanf("%lld",&n);
    scanf("%s%s",s+1,t+1);
    for(int i=1;i<=n;i++)
        printf("%c%c",s[i],t[i]);
    return 0;
}


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

#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second

using namespace std;
typedef pair<int,int>P;
typedef pair<P,P>P2;

struct Dinic{
  const int INF=1<<28;
  
  struct edge {
    int to,cap,rev;
    edge(){}
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
  };

  int n;
  vector<vector<edge> > G;
  vector<map<int,int> > M;
  vector<int> level,iter;

  Dinic(){}
  Dinic(int sz):n(sz),G(n),M(n),level(n),iter(n){}
  
  void add_edge(int from,int to,int cap){
    M[from][to]=G[from].size();
    M[to][from]=G[to].size();
    G[from].push_back(edge(to,cap,G[to].size()));
    // undirected
    //G[to].push_back(edge(from,cap,G[from].size()-1));
    // directed
    G[to].push_back(edge(from,0,G[from].size()-1));
  }
  
  void bfs(int s){
    fill(level.begin(),level.end(),-1);
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
      int v=que.front();que.pop();
      for(int i=0;i<(int)G[v].size();i++){
        edge &e = G[v][i];
        if(e.cap>0&&level[e.to]<0){
          level[e.to]=level[v]+1;
          que.push(e.to);
        }
      }
    }
  }
  
  int dfs(int v,int t,int f){
    if(v==t) return f;
    for(int &i=iter[v];i<(int)G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[v]<level[e.to]){
        int d = dfs(e.to,t,min(f,e.cap));
       if(d>0){
         e.cap-=d;
         G[e.to][e.rev].cap+=d;
         return d;
       }
      }
    }
    return 0;
  }
  
  int flow(int s,int t,int lim){
    int fl=0;
    for(;;){
      bfs(s);
      if(level[t]<0||lim==0) return fl;
      fill(iter.begin(),iter.end(),0);
      int f;
      while((f=dfs(s,t,lim))>0){
       fl+=f;
       lim-=f;
      }
    }
  }

  int flow(int s,int t){
    return flow(s,t,INF);
  }

  //cap==1 only
  bool back_edge(int s,int t,int from, int to){
    for(int i=0;i<(int)G[from].size();i++) {
      edge& e=G[from][i];
      if(e.to==to) {
        if(e.cap==0&&flow(from,to,1)==0) {
          flow(from,s,1);
          flow(t,to,1);
          return 1;
        }
      }
    }
    return 0;
  }
};

int n,m,S,T,s[3000],t[3000],d[3000],w[3000];
vector<int>v;
int di[100009];


int g[201][201];

int main(){
  r(i,200)r(j,200)g[i][j]=i==j?0:1e8;
  cin>>n>>m>>S>>T;S--;T--;
  r(i,m){
    cin>>s[i]>>t[i]>>d[i]>>w[i];
    s[i]--;
    t[i]--;
    g[s[i]][t[i]]=d[i];
  }
  r(o,n)r(i,n)r(j,n)g[i][j]=min(g[i][j],g[i][o]+g[o][j]);
  Dinic D(n);
  r(i,m){
    int flag=0;
    if(g[S][s[i]]+g[t[i]][T]+d[i]==g[S][T])flag++;
    if(flag)D.add_edge(s[i],t[i],w[i]);//cout<<1<<endl;
  }
  cout<<D.flow(S,T,1e9)<<endl;
}


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



int main() {
    
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }

    ll ans=INT_MAX;

    for(ll i=-1000;i<=1000;i++){
        ll ans1=0;
        for(ll j=0;j<n;j++){
            ans1+=(a[j]-i)*(a[j]-i);
        }
        ans=min(ans,ans1);
    }
    cout<<ans<<endl;
}


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

#define INF 1LL << 60
#define pb push_back
#define loop_type int
#define REP(i, n) for (loop_type i = 0; i < (loop_type)(n); i++)
#define REPR(i, b, e) for (int i = (b); i <= (e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

ll L[3], K, A[3][1005];
vector<ll> res;

int main() {
    cin.tie(0);
    cin >> L[0] >> L[1] >> L[2] >> K;
    REP(i, 3) {
        REP(j, L[i]) cin >> A[i][j];
        sort(A[i], A[i] + L[i], greater<ll>());
    }

    typedef pair<ll, vi> P;
    priority_queue<P> Q;
    set<P> S;

    Q.push(make_pair(A[0][0] + A[1][0] + A[2][0], vi({0, 0, 0})));
    REP(k, K) {
        auto p = Q.top(); Q.pop();
        cout << p.first << endl;

        REP(i, 3) {
            // 添字が X, Y, Z を超えない範囲
            if (p.second[i] + 1 < L[i]) {
                ll sum = p.first - A[i][p.second[i]] + A[i][p.second[i] + 1];

                // 今考えてる添字だけ1増やす
                vi v = p.second; v[i]++;
                P ptmp = make_pair(sum, v);

                // まだpushされていなければpush
                if (!S.count(ptmp)) {
                    S.insert(ptmp);
                    Q.push(ptmp);
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 1408
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a=Integer.parseInt(sc.next());
int b=Integer.parseInt(sc.next());
int k=Integer.parseInt(sc.next());
for(int i=a;i<=b;i++){if(i<a+k||b-k<i)System.out.println(i);}
}}

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

int main(){
    int H, W, N, sr, sc;
    string S, T;
    cin >> H >> W >> N >> sr >> sc >> S >> T;

    int left = 0, right = W+1, down = H+1, up = 0;
    for(int i=N-1; i>=0; i--){
        if(T[i]=='L') right = min(right+1, W+1);
        if(T[i]=='R') left = max(left-1, 0);
        if(T[i]=='U') down = min(down+1, H+1);
        if(T[i]=='D') up = max(up-1, 0);
        if(S[i]=='L') left++;
        if(S[i]=='R') right--;
        if(S[i]=='U') up++;
        if(S[i]=='D') down--;

        if(right - left <= 1 || down - up <= 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    if(left < sc && sc < right && up < sr && sr < down){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 776
void main() {
	auto ip = readAs!(long[]), N = ip[0], K = ip[1];
	
	ulong res;
	if(K == 0) {
		writeln(N^^2);
		return;
	}
	foreach(b; 1..N+1) {
		auto p = N / b, r = N % b;
		res += max(b-K, 0) * p;
		res += max(0, r-K+1);
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

#define debug(x) cout << #x" = " << x;

#define st first
#define nd second

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

const int MAXN = 1E5 + 10;

ll a[MAXN], b[MAXN];

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%lld", a + i);
	ll s = accumulate(a, a + n, 0ll);
	ll n0 = n * (n + 1ll) / 2;
	if (n == 1)
		puts("YES");
	else if (s % n0)
		puts("NO");
	else{
		ll m = s / n0;
		a[n] = a[0];
		bool flag = true;
		for (int i = 0; i < n; ++i){
			ll t = m - (a[i + 1] - a[i]);
			b[i] = t / n;
			flag &= 0 <= b[i] && b[i] <= m && t % n == 0;
		}
		puts(flag && accumulate(b, b + n, 0ll) == m ? "YES" : "NO");
	}
	
	return 0;
}


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

#define sc second
#define fr first

#define ll long long
#define pi pair<int,int>
#define ppi pair<pi,pi>
#define mp make_pair
using namespace std;



int arr[100010];
int Gcd1[100010],Gcd2[200200];
int __gcd(int x, int y)
{
	if (x < y)swap(x, y);
	if (y == 0)return  x;
	return __gcd(y, x % y);
}
int main()
{

	ios::sync_with_stdio(0);
    cin.tie(0) , cout.tie(0);

	
	int n; cin >> n;
	vector<int>v;
	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i];
		Gcd1[i] = __gcd(Gcd1[i - 1], arr[i]);
	}
	for (int i = n; i >= 1; i--)
	{
		Gcd2[i] = __gcd(Gcd2[i + 1], arr[i]);
	}
	int asn = 0;
	for (int i = 1; i <= n; i++)
	{
		asn = max(asn, __gcd(Gcd1[i - 1], Gcd2[i + 1]));
	}
	cout << asn << '\n';

	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N;
	cin >> N;
	int cnt = 0, r = 0;
	for (int i = 0; i < N; ++ i) {
		int x, y;
		cin >> x >> y;
		if (x == y) {
			r = max(r, ++ cnt);
		} else {
			cnt = 0;
		}
	}
	cout << (r >= 3 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000
#define MAX 200001
#define PI 3.141592653589793

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    int color_1 = -1;
    int color_2 = -1;
    int color_3 = -1;
    vector<int> dp(N+1,0);
    dp[0] = 1;
    rep(i,N){
        ll ka = 0;
        int now = A[i];
        if(color_1 == now-1){
            ka++;
            color_1++;
            if(color_2 == now-1) ka++;
            if(color_3 == now-1) ka++;
        } 
        else if(color_2 == now-1){
            ka++;
            color_2++;
            if(color_3 == now-1) ka++;
        }
        else if(color_3 == now-1){
            ka++;
            color_3++;
        }
        dp[i+1] = dp[i] * ka % MOD;
        dp[i+1] %= MOD;
    }
    //cout << color_1 << color_2 << color_3 << endl;
    cout << dp[N] << endl;
}

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

using namespace std;


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

    vector<int> h(n,0);
    vector<int> b(n,0);

    for(int i=0;i<n;i++){
        cin>>h.at(i);
    }

    int l=0,d=0;
    int co=0;
    while(d==0){
        d=1;
        for(int i=0;i<n;i++){
            if(h.at(i)==0){
                if(l==1){
                    l=0;
                    co++;
                    d=0;
                }
            }else{
                if(l==0){
                    h.at(i)--;
                    l=1;
                }else{
                    h.at(i)--;
                }
            }
            if(i==(n-1)&&(l==1)){
                l=0;
                co++;
                d=0;
            }
        }
    }

    cout<<co<<endl;



}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

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

int main()
{
    cout << fixed << setprecision(15);
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    cout << max(A*B, C*D) << endl;
    return 0;
}

Measured memory_bytes: 3564
H , W = map(int,input().split())
matrix = [list(input()) for _ in range(H)]
delete_column = []
delete_row = []
ans = []
for row in range(H):
    if not "#" in matrix[row]:
        delete_row.append(row)
for column in range(W):
    columnFlag = True
    for row in range(H):
        if matrix[row][column] == "#":
            columnFlag = False
            break
    if columnFlag:
        delete_column.append(column)
for row in range(H):
    tmp_list = []
    for column in range(W):
        if row in delete_row or column in delete_column:
            continue
        tmp_list.append(matrix[row][column])
    if not tmp_list == []:
        ans.append(tmp_list)
for a in ans:
    print("".join(a))

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

int main(){
  
  int A,B;
  cin >> A >> B;
  double T;
  cin >> T;
  
  int ans = 0;
  
  while(1){
    
    T -= A;
    if (T < 0) break;
    ans += B;
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
n = int(input())
s = input()
ans = 0
for i in range(n-1):
  cnt = 0
  for alp in range(ord('a'),ord('z')+1):
    if chr(alp) in s[:i+1] and chr(alp) in s[i+1:]:
      cnt += 1
  ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  set<int> d;
  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    d.insert(a);
  }
  cout << d.size() << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int a[] = new int[m];

		int left = 0;
		int right = 0;
		for (int i = 0; i < m; i++) {
			a[i] = sc.nextInt();
			if (a[i] < x) left++;
			if (x < a[i]) right++;
		}

		if (left < right) {
			System.out.println(left);
		} else {
			System.out.println(right);
		}

		sc.close();
	}

}


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

long long n, ans = 0;

int main() {
	cin >> n;
	for (int i = 1; (long long) i * (i + 2) <= n; i++)
		if (!(n % i))
			ans += n / i - 1;
	cout << ans << endl;
}


Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
signed main()
{
	int n,m,x;
	cin>>n>>m>>x;
	int a[n][m+1];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=m;j++)
			cin>>a[i][j];
	}
	int res=INT_MAX;
	for(int i=0;i<(1<<n);i++)
	{
		int cost=0;
		int level[m+1]={0};
		for(int j=0;j<n;j++)
		{
			if(i & (1 << j))
			{
				cost+=a[j][0];
				for(int k=1;k<=m;k++)
				{
					level[k]+=a[j][k];
				}
			}
		}
		bool ans=true;
		for(int l=1;l<=m;l++)
		{
			if(level[l]<x)
			{
				ans=false;
				break;
			}
		}
		if(ans)
			res=min(cost,res);
	}
	if(res==INT_MAX	)
		cout<<"-1"<<endl;
	else
		cout<<res<<endl;
}












Measured memory_bytes: 3644
import sys
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def main():
    H,W = LI()
    A = [LI() for _ in range(H)]
    B = [LI() for _ in range(H)]
    D = [[abs(A[h][w]-B[h][w]) for w in range(W)] for h in range(H)]
    dp=[[0]*W for _ in range(H)]
    dp[0][0]=1<<D[0][0]<<20000

    for h in range(H):
        for w in range(W):
            if(h>0):
                dp[h][w] |= dp[h-1][w]<<D[h][w]
                dp[h][w] |= dp[h-1][w]>>D[h][w]
            if(w>0):
                dp[h][w] |= dp[h][w-1]<<D[h][w]
                dp[h][w] |= dp[h][w-1]>>D[h][w]
    for i in range(81):
        bit = 1<<(20000+i)
        bit |= 1<<(20000-i)
        if dp[H-1][W-1]&bit:
            return(i)
 
if __name__ == "__main__":
    print(main())


Measured memory_bytes: 63196
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define f first
#define s second
using namespace std;
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;
typedef pair<int,int> pii;
typedef vector<int> vi;

void solve() {
	string s; cin >> s;
	for (auto& it : s) {
		if (it == '?') it = 'D';
	}
	cout << s << '\n';
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int q = 1;
	//cin >> q;
	while (q--) {
		solve();
	}
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)
const int MAX_N = 100005;
int L[MAX_N], R[MAX_N], st[MAX_N];

ll renctangle_in_histgram(vector<ll> &h){
    int N = h.size();
    int t = 0;
    REP(i, N){
        while(t>0 && h[st[t-1]]>=h[i]) t--;
        L[i] = t == 0 ? 0 : (st[t-1]+1);
        st[t++] = i;
    }

    t = 0;
    for(int i=N-1;i>=0;i--){
        while(t>0 && h[st[t-1]]>=h[i]) t--;
        R[i] = t == 0 ? N : st[t-1];
        st[t++] = i;
    }

    ll res = 0;
    REP(i, N) res = max(res, (ll)h[i]*(R[i] - L[i]));
    return res;
}

int main(){
    int N;
    cin >> N;
    vector<ll> h(N);
    REP(i, N) cin >> h[i];
    printf("%lld\n", renctangle_in_histgram(h));
    return 0;
}

Measured memory_bytes: 4624
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	int D, N;
	cin >> D >> N;
	int ans = 0;
	if (N < 100) {
		ans = pow(100, D)*N;
	}
	else {
		ans = pow(100, D)*101;
	}
	cout << ans;
	system("pause");
	return 0;
}

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

int main(){
        int h,w;    
    while(1){

        cin >> h >> w;
        
        if (h == 0 && w == 0){ break; }
       
        for (int i=0; i < h; i++){
            for (int j=0; j < w; j++){
                if ((j+i) % 2 == 0){
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f

int main()
{
    long long s;    cin>>s;

    long long y3=s/1000000000;
    long long x3=1000000000*y3-s;
    if(x3<0)
        y3++;
   cout<<"0 0 1000000000 1 "<<1000000000*y3-s<<" "<<y3<<endl;
    return 0;
}


Measured memory_bytes: 256
using System.Linq;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var aw = new List<int>();
        var hw = new List<int>();
        var bw = new List<int>();
        var a = new int[n, 6];
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            for (int j = 0; j < 6; j++)
            {
                var w1 = int.Parse(line[j * 2]);
                var w2 = int.Parse(line[j * 2 + 1]);
                a[i, j] = w1 * 60 + w2;
                if (j == 0 | j == 1) aw.Add(a[i, j]);
                else if (j == 2 | j == 3) hw.Add(a[i, j]);
                else bw.Add(a[i, j]);
            }
        }
        var aw2 = aw.Distinct().OrderBy(x => x).ToArray();
        var hw2 = hw.Distinct().OrderBy(x => x).ToArray();
        var bw2 = bw.Distinct().OrderBy(x => x).ToArray();
        Console.WriteLine(getAns(a, aw2, hw2, bw2));
    }
    public static int getAns(int[,] w, int[] a, int[] b, int[] c)
    {
        var ret = 0;
        for (int i = 0; i < a.Length; i++)
            for (int j = 0; j < b.Length; j++)
                for (int k = 0; k < c.Length; k++)
                {
                    var count = 0;
                    for (int m = 0; m < w.GetLength(0); m++)
                        if (a[i] >= w[m, 0] && a[i] <= w[m, 1] && b[j] >= w[m, 2] && b[j] <= w[m, 3] && c[k] >= w[m, 4] && c[k] <= w[m, 5])
                        {  count++; }
                    if (count > ret) { ret = count;  }
                }
        return ret;
    }
}




Measured memory_bytes: 10268
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		long sum = (b/x + 1);
		if(a!=0)sum -=(a - 1)/x + 1;
		System.out.println(sum);
		sc.close();
	}
}


Measured memory_bytes: 21844
a = 0
max_dish = 0
sum_dish = 0
for _ in range(5):
    dish = int(input())
    x = dish % 10
    if x != 0:
        x = 10 - x
    a += x
    sum_dish += dish
    max_dish = max(x, max_dish)
print(sum_dish + a - max_dish)

Measured memory_bytes: 3060
#include <stdio.h>
int main(void)
{
    int n, k, i=0;
    char s[11], c[2];
    scanf("%d", &n);
    scanf("%s", s);
    scanf("%d", &k);

    while(s[i]!='\0'){
        if(i==k-1) c[0]=s[i];
        i++;
    }
    i=0;
    while(s[i]!='\0'){
        if(s[i]!=c[0]){
            s[i]='*';
        }
        i++;
    }
    printf("%s\n",s);    
    return 0;
}


Measured memory_bytes: 128
N, M = gets.split.map(&:to_i)
SWITCH = M.times.map { gets.split.map(&:to_i) }
P = gets.split.map(&:to_i)

def all_on?(list)
  i = -1
  SWITCH.all? do |k, *s|
    cnt = 0

    s.each do |idx|
      cnt += 1 if list[idx - 1]
    end

    i += 1
    cnt % 2 == P[i]
  end
end

ans = 0

[true, false].repeated_permutation(N).each do |list|
  ans += 1 if all_on?(list)
end

puts ans

Measured memory_bytes: 3836
n=int(input())
A=list(float(i) for i in input().split())
dp=[[0.0 for i in range(n+1)]for j in range(n+1)]
for i in range(n+1):
    for j in range(n+1):
        if i==0:
            if j>i:
                dp[i][j]=0
            else:
                dp[i][j]=1
        elif j==0:
            if i>1:
                dp[i][j]=dp[i-1][j]*(1-A[i-1])
            else:
                dp[i][j]=1-A[i-1]
        if i!=0 and j!=0:
            dp[i][j]=dp[i-1][j-1]*A[i-1]+dp[i-1][j]*(1-A[i-1])
sum=0
for s in range(n//2+1,n+1):
        sum+=dp[-1][s]
print(sum)


Measured memory_bytes: 121948
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n,x[4],sum=0;
    cin>>n;

    for(int i=3;i>=0;i--)
    {
        x[i]=n%10;
        n/=10;
        sum+=x[i];
    }
    if(sum-2*x[1]==7)cout<<x[0]<<"-"<<x[1]<<"+"<<x[2]<<"+"<<x[3]<<"=7"<<endl;
    else if(sum-2*x[2]==7)cout<<x[0]<<"+"<<x[1]<<"-"<<x[2]<<"+"<<x[3]<<"=7"<<endl;
    else if(sum-2*x[3]==7)cout<<x[0]<<"+"<<x[1]<<"+"<<x[2]<<"-"<<x[3]<<"=7"<<endl;
    else if(sum-2*x[1]-2*x[2]==7)cout<<x[0]<<"-"<<x[1]<<"-"<<x[2]<<"+"<<x[3]<<"=7"<<endl;
    else if(sum-2*x[1]-2*x[3]==7)cout<<x[0]<<"-"<<x[1]<<"+"<<x[2]<<"-"<<x[3]<<"=7"<<endl;
    else if(sum-2*x[2]-2*x[3]==7)cout<<x[0]<<"+"<<x[1]<<"-"<<x[2]<<"-"<<x[3]<<"=7"<<endl;
    else if(sum-2*x[1]-2*x[2]-2*x[3]==7)cout<<x[0]<<"-"<<x[1]<<"-"<<x[2]<<"-"<<x[3]<<"=7"<<endl;
    else cout<<x[0]<<"+"<<x[1]<<"+"<<x[2]<<"+"<<x[3]<<"=7"<<endl;

    return 0;
}


Measured memory_bytes: 256