akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string>
#include <algorithm>
#include <map>
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	int H, W, sum[60][60] = { 0 };
	string S[60];
	cin >> H >> W;
	for (int i = 0; i < H; i++)cin >> S[i];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '#') {
				for (int k = -1; k <= 1; k++) {
					for (int l = -1; l <= 1; l++) {
						if (i + k >= 0 && j + l >= 0)sum[i + k][j + l]++;
					}
				}
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '.')cout<<sum[i][j];
			else cout << S[i][j];
		}
		cout << endl;
	}
}


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

int main(){
    int n;
    cin >> n;
    vl a(n+1), b(n);
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];
    ll ans = 0;
    rep(i, n) {
        ll k = min(b[i], a[i]);
        ans += k;
        b[i] -= k;
        a[i] -= k;

        k = min(b[i], a[i+1]);
        ans += k;
        b[i] -= k;
        a[i+1] -= k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N,M;
	cin>>N>>M;
	vector<vector<int>> A(N,vector<int>(M));
	int i,j;
	for (i=0;i<N;i++){
		for (j=0;j<M;j++){
			cin>>A[i][j];
		}
	}
	map<int,int> FindMap;
	for (i=1;i<=M;i++){
		FindMap[i]=i;
	}
	vector<int> Sport(M);
	map<int,int>::iterator Fit;
	int minPeople=N;
	while (FindMap.size()>0){
		for (i=0;i<M;i++){
			Sport[i]=0;
		}
		for (i=0;i<N;i++){
			for (j=0;j<M;j++){
				Fit=FindMap.find(A[i][j]);
				if (Fit!=FindMap.end()){
					Sport[A[i][j]-1]++;
					break;
				}
			}
		}
		int maxPeople=0;
		int maxSport=1;
		for (i=0;i<M;i++){
			if (maxPeople<Sport[i]){
				maxPeople=Sport[i];
				maxSport=i+1;
			}
		}
		if (minPeople>maxPeople){
			minPeople = maxPeople;
		}
		Fit=FindMap.find(maxSport);
		if (Fit!=FindMap.end()){
			FindMap.erase(Fit);
		}
	}
	cout<<minPeople<<endl;

	return 0;
}

Measured memory_bytes: 640
n=int(input())
a,b=[],[]
for i in range(n):
  aa,bb=map(int,input().split())
  a.append(aa)
  b.append(bb)

a.sort()
b.sort()
if n%2==1:
  print(b[n//2]-a[n//2]+1)
else:
  a_cnt=a[n//2]+a[n//2-1]
  b_cnt=b[n//2]+b[n//2-1]
  print(b_cnt-a_cnt+1)

Measured memory_bytes: 25416
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int a, b, c, d;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> a >> b >> c >> d;
	int p = c - a, q = d - b;
	rep(i, q)cout << 'U';
	rep(i, p)cout << 'R';
	rep(i, q)cout << 'D';
	rep(i, p)cout << 'L';
	cout << 'L';
	rep(i, q + 1)cout << 'U';
	rep(i, p + 1)cout << 'R';
	cout << 'D' << 'R';
	rep(i, q + 1)cout << 'D';
	rep(i, p + 1)cout << 'L';
	cout << 'U';
	ggr
}

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

using namespace std;

struct edge {
    int a, b;
    double w;
};

class BellmanFord {
    int n;
    vector<edge> edges;
    vector<double> d;

public:
    BellmanFord(int n) : n(n), edges(n), d(n, numeric_limits<double>::infinity()) {}

    void add_edge(int a, int b, double w) {
        assert(0 <= a && a < n && 0 <= b && b < n);
        edges.push_back({a, b, w});
        edges.push_back({b, a, w});
    }

    void add_arc(int a, int b, double w) {
        assert(0 <= a && a < n && 0 <= b && b < n);
        edges.push_back({a, b, w});
    }

    // return true if has negative loop
    bool run(int a) {
        d[a] = 0;
        for (int i = 0; i < n; i++) {
            bool change = false;
            for (edge e: edges) {
                if (d[e.a] != numeric_limits<double>::infinity()) {
                    if (d[e.b] > d[e.a] + e.w) {
                        d[e.b] = d[e.a] + e.w;
                        change = true;
                    }
                }
            }
            if (!change) {
                return false;
            }
        }
        return true;
    }

    double dist(int a) {
        return d[a];
    }
};

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

    int n, m, p;
    cin >> n >> m >> p;

    BellmanFord bf(n);
    vector<vector<int>> adj(n);
    vector<tuple<int, int, int>> es;

    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        es.emplace_back(a, b, c);
        adj[b].push_back(a);
    }

    vector<bool> visited(n);

    function<void(int)> dfs = [&](int v) {
        visited[v] = true;
        for (int a : adj[v]) {
            if (!visited[a]) {
                dfs(a);
            }
        }
    };
    dfs(n - 1);
    assert(visited[0]);

    for (int i = 0; i < m; i++) {
        int a = get<0>(es[i]), b = get<1>(es[i]), c = get<2>(es[i]);
        if (visited[a] && visited[b]) {
            bf.add_arc(a, b, p - c);
        }
    }

    if (bf.run(0)) {
        cout << -1 << endl;
        return 0;
    }
    cout << max(0, (int) -bf.dist(n - 1)) << endl;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
using namespace std;
typedef long long int ll;
using mpi = mp::cpp_int;
typedef pair<int, int> P;
//typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};
const mpi mod = (int)1e9 + 7;

using namespace boost::numeric;
using imatrix = ublas::matrix<mpi>;

void modulo(imatrix &mat, mpi mod) {
  for (size_t i = 0; i < mat.size1(); i++) {
    for (size_t j = 0; j < mat.size2(); j++) {
      mat(i, j) %= mod;
    }
  }
}

int main() {
  // use scanf in CodeForces!

  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N; ll K; cin >> N >> K;
  imatrix mat(N, N);
  REP(i, N) REP(j, N) cin >> mat(i, j);

  imatrix pow2 = mat, ans(N, N);
  REP(i, N) REP(j, N) ans(i, j) = (ll)(i == j);
  while (K) {
    mpi count = 0;
    if (K & 1LL) {
      ans = ublas::prod(ans, pow2);
      modulo(ans, mod);
    }
    pow2 = ublas::prod(pow2, pow2);
    modulo(pow2, mod);
    K >>= 1;
  }

  mpi count = 0;
  REP(i, N) REP(j, N) count = (count + ans(i, j)) % mod;
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	for (int i = 0; i < a.size(); i++) {
		cout << a[i];
		if (i < b.size()) {
			cout << b[i];
		}
	}
	cout << endl;
	return 0;
}

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

int main(){
	int A,B,C;
  	int X,Y,ans;
	cin >> A >> B >> C;
	X = A*B;
  	Y = C;
  	if(X >= Y){
     ans = Y;
    }else{
      ans = X;
    }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    if (A[0] != 0) {
        cout << -1 << endl;
        return 0;
    }
    int h = A[N-1];
    int ans = h;
    REPR(i, N-1) {
        if (A[i] < h) {
            cout << -1 << endl;
            return 0;
        } else if (h < A[i]) {
            chmax(h, A[i]);
            ans += A[i];
        }
        h--;
    }
    cout << ans << endl;
    return 0;
}



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

namespace AOJHelloWorld1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str =Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            Console.WriteLine(a*b+" "+2*(a + b));
        }
    }
}


Measured memory_bytes: 15964
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> M;
	vector< pii > A(M);
	rep(i, M) {
		cin >> A[i].first >> A[i].second;
	}
	if (N == 1 && M == 0) {
		cout << 0 << endl;
		return 0;
	}
	K = 1;
	rep(i, N) K *= 10;
	rep(j, K) {
		if (!j)
			continue;
		if (j < K / 10)
			continue;
		bool f = false;
		rep(i, M) {
			int ten = 1;
			rep(l, N - A[i].first) ten *= 10;
			//ten /= 10;
			if (j / ten % 10 != A[i].second) {
				f = true;
				break;
			}
		}
		if (f)
			continue;
		cout << j << endl;
		return 0;
	}
	if (N == 1) {
		rep(i, M) {
			if (A[i].second != 0) {
				cout << -1 << endl;
				return 0;
			}
		}
		cout << 0 << endl;
		return 0;
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
module.exports=function(r){var e={};function t(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return r[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var i in r)t.d(n,i,function(e){return r[e]}.bind(null,i));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=1)}([function(r,e,t){"use strict";r.exports=class{constructor(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=r.length,this.items=r,this.ind=0}enq(r){this.size+=1,this.items.push(r)}deq(){var r=this.items[this.ind];return this.size-=1,this.ind+=1,r}clear(){this.items=[],this.size=0,this.ind=0}}},function(r,e,t){"use strict";var n=t(2),i=new(t(3))(n.readFileSync("/dev/stdin","utf8").trim().split(/\s+/g));t(4)(i)},function(r,e){r.exports=require("fs")},function(r,e,t){"use strict";var n=t(0);r.exports=class{constructor(r){this.inp=new n(r)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(r,e,t){"use strict";t(0);r.exports=function(r){for(var e=r.in(),t=new Array(e),n=0;n<e;n++){for(var i=new Array(10),o=0;o<10;o++)i[o]=r.in();t[n]=i}for(var s=new Array(e),u=0;u<e;u++){for(var a=new Array(11),f=0;f<11;f++)a[f]=r.in();s[u]=a}for(var c=-9999999999,l=1;l<1024;l++){for(var d=0,p=new Array(10),v=0;v<10;v++)p[v]=(l>>9-v)%2;for(var h=0;h<e;h++){for(var y=0,b=0;b<10;b++)1==p[b]&&1==t[h][b]&&y++;d+=s[h][y]}d>c&&(c=d)}console.log(c)}}]);

Measured memory_bytes: 7628
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<stack>
#include<vector>
//#include<conio.h>
#include<string>
#include<map>
#include<cstdlib>
#include<queue>
#include<math.h>
#include<time.h>
#include<set>
#include<cstdio>
#include<stdio.h>
#include<algorithm>
using namespace std;
string s;
int main(){
	cin>>s;
	if(s[0]=='9'||s[1]=='9') cout<<"Yes\n";
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    long double bitc=0.0,yen=0.0;
    for(int i=1;i<=n;i++){
        double x;
        string type;
        cin>>x>>type;
        if(type=="JPY"){
            yen+=x;
        }
        else{
            bitc+=x;
        }
    }
    long double ans=bitc*380000.0+yen;
    cout<<ans<<endl;
}


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 all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

struct mint {
   ll x;
   mint(ll x = 0) { (this->x = (x + MOD)) %= MOD; }
   mint& operator+=(const mint a) {
      if ((this->x += a.x) >= MOD) x -= MOD;
      return *this;
   }
   mint& operator-=(const mint a) {
      if ((this->x += MOD - a.x) >= MOD) this->x -= MOD;
      return *this;
   }
   mint& operator*=(const mint a) {
      (this->x *= a.x) %= MOD;
      return *this;
   }
   mint operator+(const mint a) const {
      mint res(*this);
      return res += a;
   }
   mint operator-(const mint a) const {
      mint res(*this);
      return res -= a;
   }
   mint operator*(const mint a) const {
      mint res(*this);
      return res *= a;
   }
   mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t >> 1);
      a *= a;
      if (t & 1) a *= *this;
      return a;
   }
   mint inv() const { return pow(MOD - 2); }
   mint& operator/=(const mint a) { return *this *= a.inv(); }
   mint operator/(const mint a) const {
      mint res(*this);
      return res /= a;
   }
};

mint c[4005][4005];
void init() {
   c[0][0] = 1;
   rep(i, 0, 4000) {
      rep(j, 0, i + 1) {
         c[i + 1][j] += c[i][j];
         c[i + 1][j + 1] += c[i][j];
      }
   }
}
mint comb(int n, int k) { return c[n][k]; }
mint f2(int n, int k) { return comb(n + k - 1, k - 1); }
mint f(int n, int k) {
   if (n < k) return 0;
   if(n == 0 && k == 0) return 1;
   if(k < 1) return 0;
   return f2(n - k, k);
}
int main() {
   init();
   int n, k;
   cin >> n >> k;
   rep(i, 1, k + 1) {
      mint blue = f(k, i);
      mint red = 0;
      red += f(n - k, i - 1);
      red += f(n - k, i);
      red += f(n - k, i);
      red += f(n - k, i + 1);
      mint ans = blue * red;
      printf("%lld\n", ans.x);
   }
   return 0;
}

Measured memory_bytes: 125696
dice = list(map(int, input().split()))
q = int(input())

class Dice():
    def __init__(self, dice, top, front):
        self.dice = dice
        self.top = top
        self.front = front

    def get_right(self):
        right_list =[
            (1, 2, 4, 3), #0
            (0, 3, 5, 2), #1
            (0, 1, 5, 4), #2
            (0, 4, 5, 1), #3
            (0, 2, 5, 3), #4
            (1, 3, 4, 2)  #5
        ]

        for i in range(6):
            if self.dice[i] == self.top:
                for j in range(4):
                    if self.dice[right_list[i][j]] == self.front:
                        print(self.dice[right_list[i][j-3]])

for i in range(q):
    top, front = map(int, input().split())
    dice_right = Dice(dice, top, front)
    dice_right.get_right()


Measured memory_bytes: 5600
//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

//二項係数
const int MAX = 2010000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 前処理 COMinit();
// 計算例 cout << COM(100000, 50000) << endl;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N; cin>>N;
  vector<ll> X(N),Y(N); rep(i,N) cin>>X[i]>>Y[i];
  
  ll ans=0;
  vector<ll> vec(N); rep(i,N) vec[i]=X[i]+Y[i];
  sort(vec.begin(),vec.end());
  chmax(ans,vec[N-1]-vec[0]);
  
  rep(i,N) vec[i]=X[i]-Y[i];
  sort(vec.begin(),vec.end());
  chmax(ans,vec[N-1]-vec[0]);
  
  rep(i,N) vec[i]=Y[i]-X[i];
  sort(vec.begin(),vec.end());
  chmax(ans,vec[N-1]-vec[0]);
  
  cout<<ans<<'\n';
  
  return 0;
}

Measured memory_bytes: 7948
#include <stdio.h>
int main()
{
    int n,j;
    scanf("%d", &n);
    float v[n],sum=0,tmp;
    for(int i=0;i<n;i++)
        scanf("%f",&v[i]);
    for(int i=1;i<n;i++){
        tmp=v[i];
        j=i-1;
        while(j>=0&&v[j]>tmp){
            v[j+1]=v[j];
            j--;
        }
        v[j+1]=tmp;
    }
    for(int i=0;i<n-1;i++){
        v[i+1]=(v[i]+v[i+1])/2;
    }
    printf("%f\n",v[n-1]);
    return 0;
}

Measured memory_bytes: 128
N = int(input())
K = int(input())
x_list = list(map(int,input().split()))
ans = 0
for x in x_list:
	A = abs(x)
	babs = K - x
	B = abs(babs)
	mindis = min(A,B)
	ans += (mindis * 2)
print(ans)

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

#define PI acos(-1)
#define int long long int
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fir first
#define sec second
#define MAXN 501
#define MAXL 20
#define mod 1000000007

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

Measured memory_bytes: 3640
import bisect
import time
import heapq


# N: バイトの種類
# M: 日数の最大
N,M = map(int,input().split(" "))

# A 日数
# b バイト代
A = []
B = []
for _ in range(N):
    a,b = map(int,input().split(" "))
    A.append(a)
    B.append(-b)

# 日数でソート
ind_sorted = sorted(range(N), key = lambda x:A[x])
tmp_a = 0
tmp_b_ls = [0]
money = 0
tmp_ind = 0
for i in range(N):
    if A[ind_sorted[i]] > M:
        break
    if tmp_a != A[ind_sorted[i]]:
        # 空いている日数
        # print(d)
        # print(tmp_b_ls)
        d = A[ind_sorted[i]]-tmp_a
        for _ in range(d):
            if tmp_b_ls == []:
                break
            money -= heapq.heappop(tmp_b_ls)
        tmp_a = A[ind_sorted[i]]
    heapq.heappush(tmp_b_ls,B[ind_sorted[i]])

d = M+1-tmp_a
# print(d)
# print(tmp_b_ls)

for _ in range(d):
    if tmp_b_ls == []:
        break
    money -= heapq.heappop(tmp_b_ls)
print(money)

Measured memory_bytes: 16692
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  cin >>N;
  vector<int> T(N);
  rep(i,N) {
cin >>T.at(i);
  }
  
  int M;
  cin >>M;
  vector<int>P(M);
  vector<int>X(M);
  rep(i,M) {
    cin >>P.at(i)>>X.at(i);
  }
  
  int sum=0;
  rep(i,N) {
    sum +=T.at(i);
  }
  
  rep(i,M) {
    int y=sum-T.at(P.at(i)-1)+X.at(i);
    cout<<y<<endl;
  }
  
  
}



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

using namespace std;

int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i <n; ++i)
	{
		cin >> arr[i];
	}
	for (int i = 0; i <30; ++i)
	{
		sort(arr,arr+n);
		for (int i = 0; i <n; ++i)
		{
			if (arr[i]%arr[0]==0)
			{
				arr[i]=arr[0];
			}else{
				arr[i]=arr[i]%arr[0];
				if (arr[i]==1)
				{
					cout << 1 << '\n';
					return 0;
				}
			}
		}
	}
	sort(arr,arr+n);
	cout << arr[0] << '\n';
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
 
const ll oo=1e18;
const int MOD=1000000007;
const int INF=1000000000;
const ld EPS=0.000000001;
 
int dp[100005][3],n,a,b,c;
 
signed main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    cin>>a>>b>>c;
    dp[1][0]=a;
    dp[1][1]=b;
    dp[1][2]=c;
    for(int i=2;i<=n;++i) {
        cin>>a>>b>>c;
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
using namespace std;
const ll inf = 1e18;
const int maxN = 2e5 + 10;
int n;
ll a[maxN];
 
int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    ll ans = inf, total_sum = 0, cur_sum = 0;
    for (int i = 1; i <= n; ++i)
    {
        total_sum += a[i];
    }
    for (int i = 1; i <= n; ++i)
    {
        cur_sum += a[i];
        if (i < n)
        {
            ans = min(ans, abs(cur_sum - (total_sum - cur_sum)));
        }
    }
    cout << ans<< endl;
    return 0;
}
  

Measured memory_bytes: 5156
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef pair<ll, ll> lpair;
typedef tuple<int, int, int> ituple;

// const int INF = INT_MAX;
// const ll INF = LLONG_MAX;
// const int MOD = ((int)1e9 + 7);
// const ld EPS = (1e-10);
#define PI acosl(-1)
#define MAX_N (100000 + 2)

void exec(){
  int n;

  cin >> n;
  vector<string> ss[11];

  ss[0].push_back("a");

  for (int i = 1; i < 10; i++) {
    for (int j = 0; j < ss[i - 1].size(); j++) {
      int chars = 0;
      for (int l = 0; l < ss[i-1][j].size(); l++) {
        chars = max(chars, (int)(ss[i-1][j][l] - 'a'));
      }
      // if (i == n-1) {
      // printf("chars[%s] = %d\n", ss[i-1][j].c_str(), chars);
      // }

      for (int k = 0; k <= min(i, chars + 1); k++) {
        ss[i].push_back(ss[i-1][j] + (char)('a' + k));
      }
    }
  }


  sort(ss[n-1].begin(), ss[n-1].end());

  for (int i = 0; i < ss[n-1].size(); i++) {
    cout << ss[n-1][i] << endl;
  }


}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 11380
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  bool flag=true;
  while(flag){
    c-=b;
    if(c<=0){ cout<<"Yes"; return 0; }
    a-=d;
    if(a<=0){ cout<<"No"; return 0; }
  }
}


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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;


void bfs(v2& a, v2& b){
	queue<int> q;
	q.push(a[0][0]);
	while(!q.empty()){
		int x = q.front()-1;
		int t = b[x][1];
		q.pop();
		rep(i, a[x][1]){
			int y = a[x][2+i]-1;
			if(a[y][0] != -1 && a[y][0] != -2){
				b[y][1] = t+1;
				a[y][0] = -1;
			}
			if(a[y][0] != -2) q.push(y+1);
		}
		a[x][0] = -2;
	}
}

int main(){
	int n;
	cin >> n;
	v2 a(n, v1(0));
	v2 b(n, v1(2, 0));
	rep(i, n){
		int m;
		cin >>m;
		a[i].push_back(m);
		b[i][0] = m;
		int x;
		cin >> x;
		a.at(i).push_back(x);
		rep(j, x){
			int y;
			cin >> y;
			a.at(i).push_back(y);
		}
	}
	bfs(a, b);
	for(int i = 1;i<n; i++){
		if(b[i][1] == 0) b[i][1] = -1;
	}
	rep(i, n){
		rep(j, 2){
			cout << b[i][j];
			if(j != 1) cout << " ";
			else cout << endl;
		}
	}
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long INF=INT_MAX/4;
const long long MOD=998244353;
const double EPS=1e-14;
const bool DEBUG=false;

const string YES = "YES";
const string NO = "NO";
const string Yes = "Yes";
const string No = "No";

template<class T>
void debug(T head){
    if(DEBUG){
        cout<<head<<endl;
    }
}

template <class Head, class... Body>
void debug(Head head, Body... body){
    if(DEBUG){
        cout<<head<<" ";
        debug(body...);
    }
}

/////
ll gcd(ll x, ll y) {
    // C = GCD(X, Y)
    // return C
    ll a = x, b = y;
    ll r;

    r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll pow(ll a, ll n){
    if(n == 0){
        return 1ll;
    }
    if(n == 1){
        return a;
    }
    if(n % 2 == 0){
        ll p = pow(a, n/2);
        return p * p % MOD;
    }else{
        ll p = pow(a, (n-1)/2);
        ll tmp = p * p % MOD;
        return tmp * a % MOD;
    }
}

void answer(ll N, vector<ll>& D){
    if(D[0] != 0){
        cout<<0<<endl;
        return;
    }

    vector<ll> count(N, 0);
    for(auto d : D){
        count[d]++;
    }
    if(count[0] != 1){
        cout<<0<<endl;
        return;
    }


    int max_idx = N-1;
    for(int i=N-1; i>=0; --i){
        if(count[i] == 0){
            max_idx = i-1;
        }else{
            break;
        }
    }
    ull answer = 1;
    for(int i=max_idx; i>0; --i){
        answer *= pow(count[i-1], count[i]);
        answer %= MOD;
    }

    cout<<answer<<endl;

    return;
}

/////

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

    ll N;
    cin>>N;
    vector<ll> D(N, 0);
    for(auto &d : D){
        cin>>d;
    }
    answer(N, D);

    return 0;
}


Measured memory_bytes: 4780
//cod2017_qualC_a.cpp
//Sat Oct 20 22:39:02 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int flag = 0;
	for (int i=0;i<s.size()-1;i++){
		if (s[i] == 'A' && s[i+1] == 'C'){
			flag = 1;
		}
	}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int h = scanner.nextInt();
        final int w = scanner.nextInt();
        final int d = scanner.nextInt();

        final Point[] points = new Point[h * w + 1];
        for (int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                points[scanner.nextInt()] = new Point(i, j);
            }
        }

        final int[][] movingMap = new int[d + 1][h * w / d + 1];
        for (int i = 1; i <= d; i++) {
            int tmp = 0;
            for (int j = i + d; j <= h * w; j += d) {
                final Point previousPoint = points[j - d];
                final Point currentPoint = points[j];
                tmp += Math.abs(previousPoint.x - currentPoint.x) + Math.abs(previousPoint.y - currentPoint.y);
                movingMap[i][j / d] = tmp;
            }
        }

        final int q = scanner.nextInt();
        for (int i = 0; i < q; i++) {
            final int l = scanner.nextInt();
            final int r = scanner.nextInt();
            final int begin = l % d == 0 ? d : l % d;

            System.out.println(movingMap[begin][r/d] - movingMap[begin][l/d]);
        }
    }

    static class Point {
        final int x;
        final int y;

        Point(final int x, final int y) {
            this.x = x;
            this.y = y;
        }
    }
}


Measured memory_bytes: 108616
int main(int argc, char** argv) {
    int c1;
    int c5;
    int c10;
    int c50;
    int c100;
    int c500;
    scanf("%d %d %d %d %d %d", &c1, &c5, &c10, &c50, &c100, &c500);

    if (c1*1 + c5*5 + c10*10 + c50*50 + c100*100 + c500*500 >= 1000) {
        printf("%d\n", 1);
    } else {
        printf("%d\n", 0);
    }

    return 0;
}

Measured memory_bytes: 600
N=int(input())
K=int(input())
k=0
x=list(map(int,input().split()))
for i in range(len(x)):
  if x[i]>abs(K-x[i]):
    k=k+2*abs(K-x[i])
  elif x[i]<abs(K-x[i]):
    k=k+2*x[i]
  else:
    k=k+2*x[i]
print(k)


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

// factorial(階乗)の計算

ll fac[101] ={};

ll c_fac(int n) {
  if (fac[n]!=0) return fac[n];
  if (n==0) return fac[n]=1;
  return fac[n] = (c_fac(n-1)*n)%MOD;
}

// inverse(逆元)の計算

ll inv(ll a,ll m) {
  ll b = m, x = 1, y = 0;
  while (b!=0) {
    ll d = a/b;
    a -= b*d; swap(a, b);
    x -= y*d; swap(x, y);
  }
  return x>=0 ? x : x+m;
}

// combinataionの計算

ll nck(ll n, ll k) { 
  c_fac(n);
  if (n<k) return 0;
  ll nume = fac[n];
  ll deno = ( inv(fac[n-k],MOD) * inv(fac[k],MOD) ) % MOD;
  return ( nume * deno ) % MOD;
}

int main() {
  ll N, P; cin >> N >> P;
  ll A[N]; rep(i,N) cin >> A[i];
  ll odd = 0, even = 0;
  rep(i,N) { if (A[i]%2==0) even++; else odd++; }
  ll oddsum = 0; for (ll i=P; i<=odd; i+=2) oddsum += nck(odd,i);
  ll result = oddsum * pow(2,even);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void solve () {
  string s, t;
  cin >> s >> t;
  int id = -1, sl = s.length(), tl = t.length();
  for (int i = sl - 1; i >= tl - 1; --i) {
    bool storable = true;
    for (int j = 0; j < tl; ++j) {
      if (t[tl-1-j] != s[i-j] && s[i-j] != '?') {
        storable = false;
        break;
      }
    }
    if (storable) {
      id = i - tl + 1;
      break;
    }
  }
  if (id == -1) cout << "UNRESTORABLE\n";
  else {
    for (int i = 0; i < id; ++i) cout << (s[i] == '?'?'a':s[i]);
    cout << t;
    for (int i = id + tl; i < sl; ++i) cout << (s[i] == '?'?'a':s[i]);
    cout << endl;
  }
}
int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){
    
    int cnt[101]={};
    int t;
    while(cin>>t){
        cnt[t]++;
    }
    
    int maxa=-1;
    REP(i,101)maxa=max(maxa,cnt[i]);
    
    REP(i,101){
        if(cnt[i]==maxa)cout<<i<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 2988
#include <stdio.h>
int main(void)
{
    int w,h,n;
    long long int ans;
    scanf("%d%d%d", &w,&h,&n);
    int x[n], y[n], a[n];
    for(int i=0; i<n; i++) scanf("%d%d%d", &x[i],&y[i],&a[i]);
    
    int p[2],q[2];
    p[0]=0;
    p[1]=0;
    q[0]=w;
    q[1]=h;
    for(int i=0; i<n; i++)
    {
        if(a[i]==1)
        {
            if(p[0]<x[i]) p[0]=x[i];
        }
        else if(a[i]==2)
        {
            if(q[0]>x[i]) q[0]=x[i];
        }
        else if(a[i]==3)
        {
            if(p[1]<y[i]) p[1]=y[i];
        }
        else
        {
            if(q[1]>y[i]) q[1]=y[i];
        }
    }
    ans=(q[0]-p[0])*(q[1]-p[1]);
    if(ans>0 && q[0]-p[0]>0 && q[1]-p[1]);
    else ans=0;

    printf("%lld", ans);
    
    return 0;
}

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

typedef long long ll;

/* メモリ食い過ぎ注意 */
#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int d, g;
    int p[10];
    int c[10];
    cin >> d >> g;
    REP(d)
    {
        cin >> p[i] >> c[i];
    }

    int mn = INF;
    for (int i = 0; i <= pow(2, d) - 1; i++)
    {
        int sum = 0;
        int tcnt = 0;
        // cout << bitset<10>(i) << endl;
        for (int j = 0; j < d; j++)
        {
            if (i & (1 << j))
            {
                for (int k = 0; k < p[d - j - 1]; k++)
                {
                    if (sum >= g)
                    {
                        mn = min(mn, tcnt);
                        break;
                    }
                    sum += 100 * (d - j);
                    tcnt++;

                    // cout << "=" << sum << endl;
                }
                sum += c[d - j - 1];
                if (sum >= g)
                {
                    mn = min(mn, tcnt);
                }
            }
        }
    }
    cout << mn << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a;
	cin>>a;
	set<char>s;
	for(int i=0;i<a;i++){
		char x;
		cin>>x;
		s.insert(x);
	}
	if(s.size()==3){
		cout<<"Three";
	}
	else cout<<"Four";
	return 0;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

// const int MAX = 510000;
const int MAX = 2000010;

ll fac[MAX], finv[MAX], inv[MAX];

void init_ncr() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll ncr(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll npr(ll val1, ll val2) {
  ll c = ncr(val1, val2);
  return c * fac[val2] % MOD;
}

ll cache8[MAX];
void init_cache8() {
  ll c = 1;
  for (ll i = 0; i < MAX; i++) {
    cache8[i] = c;
    c = (c * 8) % MOD;
  }
}

ll cache2[MAX];
void init_cache2() {
  ll c = 1;
  for (ll i = 0; i < MAX; i++) {
    cache2[i] = c;
    c = (c * 2) % MOD;
  }
}

int main() {
  init_ncr();
  init_cache2();
  init_cache8();

  // // std::cout << std::fixed << std::setprecision(10);

  ll N = 869121;
  scanf("%lld", &N);

  ll ans = 0;
  for (ll i = 2; i <= N; i++) {
    ll n = ncr(N, i);

    n %= MOD;
    // for (ll j = 0; j < i; j++) {
    //   n *= 2;
    // }

    ll n2 = cache2[i];
    n2 -= 2;

    n *= n2;
    n %= MOD;

    // for (ll j = 0; j < N - i; j++) {
    //   n *= 8;
    //   n %= MOD;
    // }

    n *= cache8[N - i];
    n %= MOD;

    ans += n;
    ans %= MOD;
  }

  ans %= MOD;
  cout << (ans) << endl;
}


Measured memory_bytes: 81888
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    VI x(3);
    cin>>x[0]>>x[1]>>x[2];
    SORT(x);
    PUTS((x[2]*10 + x[1])+x[0]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
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;}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll INF = 100000007;

int main() {
  IN(string,S);
  if("ABC" == S)
    OUT("ARC");
  else
    OUT("ABC");
}





Measured memory_bytes: 3624
#include <stdio.h>

int main(int argc,char *argv[])
{
	long a,b,c,tasty;
	char ret;

	ret = scanf("%ld %ld %ld",&a,&b,&c);

	if (b > c) {
		tasty = b + c;
	} else {
		tasty = 2*b;
		c -= b;

		if (a > c) {
			tasty += c;
		} else if (a == c){
			tasty += a;
		} else {
			tasty += a+1;
		}
	}

	printf("%ld\n",tasty);

	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
    
   int main(void){
       char x,y;
       scanf("%c %c",&x,&y);
       if(x>y){
           printf(">");
       }if(x<y){
           printf("<");
       }if(x==y){
           printf("=");
       }
   }

Measured memory_bytes: 128
N,M,C=map(int,input().split())
B=[i for i in map(int,input().split())]
ans=0
for i in range(N):
    A=[n for n in map(int,input().split())]
    if sum([A[n]*B[n] for n in range(M)])+C > 0 :
        ans += 1
print(ans)

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

h = list(map(int, input().split()))

i = n - 1

while i > 0:
    if h[i - 1] <= h[i]:
        i -= 1
    elif h[i - 1] - h[i] == 1:
        h[i - 1] -= 1
        i -= 1
    else:
        break

if i == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
import java.util.Scanner;

public class Main {
	static int F[] = new int[100];
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		System.out.println(Fibonacci(n));
		scanner.close();
	}

	public static int Fibonacci(int n) {
		if (n <= 1) {
			return F[n] = 1;
		}
		if(F[n] > 0)
			return F[n];
		else
			return F[n] = Fibonacci(n - 1) + Fibonacci(n - 2);
	}
}

Measured memory_bytes: 26292
package main

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

func main() {
	nextReader = newScanner()
	s := nextString()
	if s[2] == s[3] && s[4] == s[5] {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long ma=-10000000000,mi=1000000000,su=0,a;
  for(int i;i<n;++i){
    cin>>a;
    ma=max(ma,a);
    mi=min(mi,a);
    su+=a;
  }
  cout<<mi<<" "<<ma<<" "<<su<<endl;
}


Measured memory_bytes: 3092
using System;

namespace WA047B
{
    class MainProgram
    {
        static void Main(string[] args)
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            var C = int.Parse(Console.ReadLine());
            var X = int.Parse(Console.ReadLine());

            int total = 0; int count = 0;

            for(var i = 0; i <= A; i++)
            {
                for(var j = 0; j <= B; j++)
                {
                    for(var k = 0; k <= C; k++)
                    {
                        total = 500 * i + 100 * j + 50 * k;
                        if (total == X) count++;
                    }
                }
            }

            Console.WriteLine($"{count}");
        }
    }
}


Measured memory_bytes: 13140