akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

// ------ // ------ //

const ll MOD = 1e9+7;
int n;
ll k, ans = 0;

// ------ // ------ //

vector <vector <ll>> g;

// ------ // ------ //

vector <vector <ll>> func(ll k);
vector <vector <ll>> mult(vector <vector <ll>>& a, vector <vector <ll>>& b);

// ------ // ------ //


vector <vector <ll>> func(ll k)
{

    if (k == 0)
    {
        vector <vector <ll>> v(n, vector <ll> (n));
        for (int i=0; i<n; ++i)
            v[i][i] = 1;
        return v;
    }

    vector <vector <ll>> matrix = func(k/2);
    vector <vector <ll>> res(n, vector <ll> (n));
    res = mult(matrix, matrix);
    if (k%2)
        res = mult(res, g);
    return res;
}

vector <vector <ll>> mult(vector <vector <ll>>& a, vector <vector <ll>>& b)
{
    vector <vector <ll>> res(n, vector <ll> (n));
    for (int i=0; i<n; ++i)
        for (int j=0; j<n; ++j)
            for (int k=0; k<n; ++k)
            {
                res[i][j] += a[i][k] * b[k][j];
                res[i][j] %= MOD;
            }
    return res;
}

int main()
{
    cin >> n >> k;
    g.resize(n, vector <ll> (n));
    for (int i=0; i<n; ++i)
        for (int j=0; j<n; ++j)
            cin >> g[i][j];

    vector <vector <ll>> matrix = func(k);
    for (int i=0; i<n; ++i)
    {
        for (int j=0; j<n; ++j)
        {
            ans += matrix[i][j];
            ans %= MOD;
        }
    }


    cout << ans;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;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>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; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    string N;
    cin >> N;
    int ans = 0;
    reverse(N.begin(), N.end());
    int base = 10 % 9;
    for (int i = 0; i < N.length(); i++) {
        int now = N[i] - '0';
        ans += now * base;
        ans %= 9;
        base *= 10;
        base %= 9;
    }
    cout << (ans == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3680
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    char b;
    cin >> b;

    if (b == 'A') {
        cout << "T" << endl;
    } else if (b == 'G') {
        cout << "C" << endl;
    } else if (b == 'T') {
        cout << "A" << endl;
    } else if (b == 'C') {
        cout << "G" << endl;
    }


    return 0;
}

 

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n = read();
  vi a(n);
  int sum = 0;
  REP(i, n) a[i] = read(), sum += a[i];
  int lv = 0, ans = LONG_MAX;
  REP(i, n - 1) {
    lv += a[i];
    chmin(ans, abs(lv - (sum - lv)));
  }
  print(ans);
}


Measured memory_bytes: 1792
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

//#include "math/modulo.h"

template<class T, T M>
struct modulo {
	T n;
	modulo(T n): n(n<0? n%M+M: n%M)   { }
	operator T() const                { return n;             }
	modulo operator-() const          { return modulo(-n);    }
	modulo operator+(const modulo &o) const { return modulo(n+o.n); }
	modulo operator-(const modulo &o) const { return modulo(n-o.n); }
	modulo operator*(const modulo &o) const { return modulo(n*o.n); }
	bool  operator< (const modulo &o) const { return n< o.n; }
	bool  operator<=(const modulo &o) const { return n<=o.n; }
	bool  operator> (const modulo &o) const { return n> o.n; }
	bool  operator>=(const modulo &o) const { return n>=o.n; }
	bool  operator==(const modulo &o) const { return n==o.n; }
	bool  operator!=(const modulo &o) const { return n!=o.n; }

	modulo pow(T n) const {
		if (n==0) return 1;
		modulo y = pow(n/2);
		y = y*y;
		if (n%2) y = y * (*this);
		return y;
	}
	modulo inv() const {
		return pow(M-2);
	}
	modulo operator/(const modulo &o) const {
		return (*this) * o.inv();
	}

	T gcd_ext(T a, T b, T *x, T *y) {
		if (a == 0) {
			*x = 0;
			*y = 1;
			return b;
		}
		T x1, y1;
		T gcd = gcd_ext(b%a, a, &x1, &y1);
		*x = y1 - (b/a) * x1;
		*y = x1;
		return gcd;
	}
	modulo div(const modulo &o) const {
		T x, y;
		T g = gcd_ext(o.n, M, &x, &y);
		if (g != 1) return 0;
		else return modulo(n * (x % M));
	}

	friend ostream &operator<<(ostream &os, const modulo &x) {
		return os << x.n;
	}
};

typedef modulo<long,998244353> T;
//#include "math/comb.h"

void comb_inc_k(T &r, int n, int &k) {
        //C(n,k+1) = C(n,k) * (n-k) / (k+1)
	r = r * T(n-k) / T(k+1);
	k++;
}

void comb_dec_k(T &r, int n, int &k) {
        //C(n,k-1) = C(n,k) * k / (n-k+1)
	r = r * T(k) / T(n-k+1);
	k--;
}

void comb_inc_n(T &r, int &n, int k) {
        //C(n+1,k) = C(n,k) * (n+1) / (n+1-k)
	r = r * T(n+1) / T(n+1-k);
	n++;
}

void comb_dec_n(T &r, int &n, int k) {
        //C(n-1,k) = C(n,k) * (n-k) / n
	r = r * T(n-k) / T(n);
	n--;
}

T comb(int n, int k) {
    if (k*2 > n) k = n-k;
    if (n==0) return 0;
    T r = 1; //C(n,0)
    int i = 0;
    while (i<k) comb_inc_k(r, n, i);
    return r;
}


#define MAXN 100000

int n;


int input() {
	if (scanf("%d", &n) < 0) return 0;
	return 1;
}

void init() {
}

int solve() {
	T r = T(3).pow(n);
	int k = n/2;
	T e = comb(n, k);
	while (k+1<=n) {
		comb_inc_k(e, n, k);
		r = r - e*T(2).pow(n-k)*T(2);
	}
	return r;
}

void output(int ans) {
	printf("%d\n", ans);
}

void cleanup() {
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


const int dx[] = { 0, -1, 0, 1};
const int dy[] = {-1,  0, 1, 0};


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int H, W;

  std::cin >> H >> W;

  std::vector<std::string> a(H);

  for (auto& s : a) {
    std::cin >> s;

    s = '.' + s + '.';
  }

  a.insert(std::begin(a), std::string(W + 2, '.'));
  
  a.push_back(std::string(W + 2, '.'));

  for (int i = 1; i <= H; i ++)
    for (int j = 1; j <= W; j ++) {
      if (a[i][j] == '#') {
        for (int k = 0; k < 4; k ++) {
          int xx = j + dx[k], yy = i + dy[k];

          if (a[yy][xx] == '#')
            goto endloop;
        }

        std::cout << "No" << std::endl;
        
        return 0;
      }
      
    endloop: ;
    }

  std::cout << "Yes" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <map>

using ll = long long;

using namespace std;

int main() {
    int n, k;
    map<char, int> m;
    string s;
    cin >> n >> k >> m['s'] >> m['p'] >> m['r'] >> s;
    int ans=0;
    for (int i=0; i<n; i++) {
        if (i >= k && s[i] == s[i-k]) {
            s[i] = '-';
            continue;
        }
        ans += m[s[i]];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 512
abcd = input()
a = []
for i in range(len(abcd)):
    a.append(int(abcd[i]))
for i in range(8):
    sum = a[0]
    s = str(a[0])
    for j in range(3):
        if i & (1<<2-j):
            sum += a[j+1]
            s += '+'
            s += str(a[j+1])
        else:
            sum -= a[j+1]
            s += '-'
            s += str(a[j+1])
    if sum == 7:
        print(s + '=7')
        exit()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fname "A"
#define bug(x) cerr << (#x) << " = " << (x) << endl
#define ll long long
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define ARR0(a, n) {cerr <<(#a)<< ": ["; REP0(i, n) cerr<< ' ' << a[i] <<','; cerr<<']'<<endl;}
#define ARR1(a, n) {cerr <<(#a)<< ": ["; REP1(i, n) cerr<< ' ' << a[i] <<','; cerr<<']'<<endl;}
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define LB lower_bound
#define UB upper_bound
#define X first
#define Y second

using namespace std;
template<typename T, typename V>
inline void bugp(const pair<T, V> &x) {cerr << '{' << x.X << ", " << x.Y << '}' << endl;}
template<typename T, typename U, typename V>
inline void bugpp(const pair<T, pair<U, V> > &x) {cerr << '{' << x.X << ", {" << x.Y.X << ", " << x.Y.Y << "}}" << endl;}
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ll, int> li;
typedef pair<ll, ii> lii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
    string s;
    cin >> s;
    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') cout << 3;
    else if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) cout << 2;
    else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') cout << 1;
    else cout << 0;
	return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<queue>
#include<map>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
long long int tree[100007];
long long int cost[100007][2];
vector<pair<int,long long int> > path[100007];//??´????????????
typedef pair<long long int,pair<int,long long int> > P;
priority_queue<P,vector<P>,greater<P> > q1;//???????????´????????????
int main(){
	int n,m,x;
	int i,j,k;
	long long int a,b,c,d,e,f,g;
	cin>>n>>m>>x;
	for(i=0;i<n;i++){
		cin>>tree[i];
	}
	for(i=0;i<m;i++){
		cin>>a>>b>>c;
		a--,b--;
		path[a].push_back(make_pair(b,c));
		path[b].push_back(make_pair(a,c));
	}
	memset(cost,-1,sizeof(cost));
	q1.push(make_pair(0,make_pair(0,x)));
	P p1;
	while(!q1.empty()){
		p1=q1.top();
		q1.pop();
		a=p1.first;
		b=p1.second.first;
		c=p1.second.second;
		if(cost[b][0]!=-1)continue;
		cost[b][0]=a;
		cost[b][1]=c;
		for(i=0;i<path[b].size();i++){
			d=path[b][i].first;
			e=path[b][i].second;
			if(tree[b]<e)continue;
			if(tree[d]+e<c){
				f=a+(c-tree[d]);
				g=tree[d];
			}else if(c<e){
				f=a+(e-c)+e;
				g=0;
			}else{
				f=a+e,g=c-e;
			}
			q1.push(make_pair(f,make_pair(d,g)));
		}
	}
	if(cost[n-1][0]!=-1){
		cost[n-1][0]+=tree[n-1]-cost[n-1][1];
	}
	cout<<cost[n-1][0]<<endl;
}

Measured memory_bytes: 46960
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
// #define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
const int INF = 1e9 + 1;

void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}


void solve()
{	
	string s, t;
	cin >> s >> t;
	cout << t + s;
}
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;

struct team{
  int i,u,a,p;
  bool operator<(const team& t){
    if(a == t.a && p == t.p) return i < t.i;
    if(a == t.a) return p < t.p;
    return a > t.a;
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin >> n && n){
    vector<team> T(n);
    map<ll,ll> m;
    rep(i,n){
      cin >> T[i].i >> T[i].u >> T[i].a >> T[i].p;
      m[T[i].u] = 0;
    }
    sort(all(T));
    ll sum = 0;
    rep(i,n){
      if(sum < 10 && m[T[i].u] < 3){
        ++sum;
        cout << T[i].i << endl;
        m[T[i].u]++;
      }
      else if(sum < 20 && m[T[i].u] < 2){
        ++sum;
        cout << T[i].i << endl;
        m[T[i].u]++;
      }
      else if(sum < 26 && m[T[i].u] < 1){
        ++sum;
        cout << T[i].i << endl;
        m[T[i].u]++;
      }
      //     cout << T[i].i << ":" << T[i].u << ":" << T[i].a << ":" << T[i].p << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
    set<int> s;
    int a, b, c;
    cin >> a >> b >> c;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout << s.size();
    return 0;
}

Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a+b+c)>=22)
    {
        cout<<"bust"<<endl;
    }
    else cout<<"win"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #include <cstdio>
    #include <string>
    using namespace std;
     
     
    int main()
    {
    	int n,k,res=1;
    	scanf("%d%d",&n,&k);
        for(int i=0;i<n;i++)
        {
         if(res<k)
         res+=res;
         else
         res+=k;
         }
         printf("%d",res);
    	
    }

Measured memory_bytes: 256
#include <stdio.h>


int x[100010],check[100010];
int ans[100010],index[100010];
int main()
{
	int a;
	scanf("%d",&a);
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);
	
	int max = 1;
	for(int i=1;i<=a;i++)
	{
		int count = 1;
		for (int j=1;j<=a;j++)
		{
			if(check[j]) continue;
			index[j] = count++;
		}
		for(int j=a;j>=1;j--)
		{
			if(check[j]) continue;
			if(x[j]==index[j])
			{
				ans[a-i+1] = x[j];
				check[j] = 1;
				goto u;
			}
		}
		printf("-1");
		return 0;
		u:;
	}
	for(int i=1;i<=a;i++) printf("%d\n",ans[i]);
}

Measured memory_bytes: 128
# 0028
import collections
array = [0]*100
i = 0
while True:
    try:
        a = input()
        array[i] = int(a)
        i += 1
    except EOFError:
        break
array = filter(lambda a: a != 0, array)
counter = collections.Counter(array).most_common()
for a, count in counter:
    if count < counter[0][1]: break
    print(a)
    

Measured memory_bytes: 8052
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(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;
	}

	// for prime mod
	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;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

int main()
{
	int min = -1000000;
	int max = 1000000;
	int k, x;
	cin >> k >> x;
	bool t = false;
	for (int i = -k + 1; i <= k - 1; i++)
	{
		int num = i + x;
		if (num >= min && num <= max)
		{
			if (!t)
			{
				cout  << num;
				t = true;
			}
			else
			{
				cout << " " << num;
			}
		}
	}
}


Measured memory_bytes: 31488
#include<iostream>
using namespace std;
int main (void)
{
  int h,w,l,i,j,k;
  string s[50];
  char ns[100][100];
  int ans[51][51];
  
  cin>>h>>w;
  for(i=0;i<h;i++)
  {
    cin>>s[i];
  }
   
  for(i=0;i<w+2;i++)
  {
    ns[0][i]='.';
    ns[h+1][i]='.';
  }
  
  for(i=0;i<h;i++)
  { 
    ns[i+1][0]='.';
    ns[i+1][w+1]='.';
    
    
    for(j=0;j<w;j++)
    {
      ns[i+1][j+1]=s[i][j];
    }
  }
  
  for(i=1;i<=h;i++)
  {
    for(j=1;j<=w;j++)
    {
      ans[i][j]=0;
      
      for(k=i-1;k<=i+1;k++)
      {
        for(l=j-1;l<=j+1;l++)
        {
          if(ns[k][l]=='#')ans[i][j]++; 
        }   
      }
       if(ns[i][j]=='#')cout<<"#";
       else cout<<ans[i][j];   
    }
    cout<<endl;
  }    
}

Measured memory_bytes: 3648
n = int(input())
a = list(input())
b = list(input())
c = list(input())
count = 0
for i in range(n):
    if a[i]!=b[i] and b[i]!=c[i] and c[i]!=a[i]:
        count+=2
    elif a[i]==b[i] and b[i]==c[i]:
        count+=0
    else:
        count+=1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream&o,const pair<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
template<typename T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 2e5;
int n, q;
ll s[N], l, ans[N];
V<int> e[N];
void dfs(int a, int p){
  ans[a] = (l += s[a]);
  for(int b:e[a]) if(b!=p) dfs(b, a);
  l -= s[a];
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q;
  FOR(_, 1, n){
    int a, b;
    cin >> a >> b;
    a--; b--;
    e[a].pb(b);
    e[b].pb(a);
  }
  FOR(_, 0, q){
    int p, x;
    cin >> p >> x;
    s[p-1] += x;
  }
  dfs(0, -1);
  FOR(i, 0, n) cout << (i ? " " : "") << ans[i];
  cout << endl;
}

Measured memory_bytes: 25600
#include<iostream>
using namespace std;
static const int MAX_N = 1000;
static const int MAX_M = 1000;

int N, M;
int a[MAX_N + 1], b[MAX_M];

int main(){
	for(;;){
		cin >> N >> M;
		if(N == 0 || M == 0) break;
		a[0] = 0;
		for(int i = 0; i < N; i++) cin >> a[i];
		for(int i = 0; i < M; i++) cin >> b[i];
		int p = 0;
		for(int i = 0; i < M; i++){
			p += b[i];
			if(p >= N - 1){
				cout << i + 1 << endl;
				break;
			}
			p += a[p];
			if(p >= N - 1){
				cout << i + 1 << endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll m1[105][105];
ll m2[105][105];

int main()
{
	int n, m, l;
	cin >> n >> m >> l;
	REP(i, n)
	{
		REP(j, m)
		{
			cin >> m1[i][j];
		}
	}
	REP(i, m)
	{
		REP(j, l)
		{
			cin >> m2[i][j];
		}
	}

	REP(i, n)
	{
		REP(j, l)
		{
			ll sum = 0;
			REP(k, m)
			{
				sum += m1[i][k] * m2[k][j];
			}
			cout << sum;
			if (j < l - 1)cout << " ";
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,X,ans = 0;
    cin >> N >> X;
    vector<int> m(N);
    for(int i = 0;i < N;i ++){
        cin >> m[i];
    }
    sort(m.begin(),m.end());
    for(int i = 0;i < N;i ++){
        X -= m[i];
        ans ++;
    }
    while(X >= m[0]){
        X -= m[0];
        ans ++;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int w , h , x , y , r ;
    cin >> w >> h >> x >> y >> r ;
    if((x - r) < 0 || (x + r) > w || (y - r) < 0 || (y + r) > h) cout << "No" << endl ;
    else cout << "Yes" << endl ;
}


Measured memory_bytes: 3104
#方針
# 最大積載量pのとき、k台のトラックでどこまで積めるか探索していく
#二分探索していく。rightの初期値は10,000*100,000
# あるpを選んだときに、k台のトラックで積める個数がnよりも大きかったら探索テーブルの左
# あるpを選んだときに、k台のトラックで積める個数がnよりも小さかったら探索テーブルの右

$n, $k = gets.split.map(&:to_i)
$w = Array.new($n){gets.to_i}

#最大積載量pのとき、k台のトラックで何個の荷物を積めるか返す関数
def f(p)
  cur = 0 #積荷の何個目を積み込もうとしているか
  truck = Array.new($k){p} #各トラックにあと何キロ積めるか

  truck.each_with_index do |t, i|
    while $w[cur] && truck[i] - $w[cur] >= 0
      truck[i] = truck[i] - $w[cur]
      cur += 1
    end
  end
  return cur
end


def binary_search()
  left = 0
  right = 100000*10000
  while (right-1 > left)
    mid = (left+right)/2
    tmp = f(mid)
    if tmp >= $n
      right = mid
    else
      left = mid
    end
  end
  return right
end

p binary_search


Measured memory_bytes: 30200
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <vector>

int solve(int n, int k, std::vector<int>& prices)
{
  std::sort(prices.begin(), prices.end());
  return std::accumulate(prices.begin(), prices.begin() + k, 0);
}

int main()
{
  int n, k;
  std::cin >> n >> k;

  std::vector<int> prices(n);
  for (auto& p : prices) {
    std::cin >> p;
  }

  std::cout << std::setprecision(20);
  std::cout << solve(n, k, prices) << std::endl;
}


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

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  int ans;
  if (N % X == 0) {
    ans = N / X * T;
  } else {
    ans = (N / X + 1) * T;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{
	int P, Q, R;
	cin >> P >> Q >> R;

	vector<int> ans(6);

	ans[0] = P + Q;
	ans[1] = R + Q;
	ans[2] = P + R;
	ans[3] = Q + R;
	ans[4] = R + P;
	ans[5] = Q + P;

	cout << *min_element(ans.begin(), ans.end()) << endl;

	return 0;
}

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

void s(int *k,int n,int a,int b){
    int i,j=k[b];
    for(i=0;i<n;i++){
        if(k[i]==j){
            k[i]=k[a];
        }
    }
}

int main(void){
    int n,q,i;
    int a,b,l;
    int *k;
    scanf("%d %d",&n,&q);
    k = (int*)malloc(sizeof(int)*n);
    for(i=0;i<n;i++){
        k[i]=i;
    }
    for(i=0;i<q;i++){
        scanf("%d %d %d",&l,&a,&b);
        if(l==0){
            s(k,n,a,b);
        }else{
            if(k[a]==k[b]){
                printf("1\n");
            }else{
                printf("0\n");
            }
        }
    }
}


Measured memory_bytes: 2092
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;

int main () {
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int c_a = 0;
  int c_b = 0;
  for (int i = 0; i < n; i++){
    switch (s[i]){
      case 'a':
        if (c_a + c_b < a + b){
          c_a ++;
          cout << "Yes" << endl;
        }else{
          cout << "No" << endl;
        }
        break;
      case 'b':
        if (c_a + c_b < a + b && c_b <b){
          c_b ++;
          cout << "Yes" << endl;
        }else{
          cout << "No" << endl;
        }
        break;
      case 'c':
        cout << "No" << endl;
        break;
    }
    
  }

  return 0;
}

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

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int (i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int (i) = (int)(initial); (i) < (int)(n); ++(i))
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int (i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int (i) = (int)(initial); (i) > (int)(n); (i)--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
	vector< pair<ll, ll> > p;
	for(ll i = 2; i*i <= n; i++) {
		if ((n % i) != 0) continue;
		p.push_back(make_pair(i, 0));
		while((n % i) == 0) {
			n /= i;
			p[i].second += 1;
		}
		p.push_back(make_pair(n, 0));
	}

	if (n != 1) p.push_back(make_pair(n, 1));
	return p;
}
string alphabet() { return "abcdefghijklmnopqrstuvwxyz"; }

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

	map<ll, int> m;
	repeat(i, N) {
		ll n = 0;
		cin >> n;

		m[n] += 1;
	}

	ll result = 0;
	for(auto itr : m) {
		if (itr.second < itr.first) {
			result += itr.second;
		} else if (itr.first < itr.second) {
			result += abs(itr.first - itr.second);
		}
	}

	cout << result << endl;
	return 0;
}

Measured memory_bytes: 6272
# 初期入力
N,M = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))
A_sorted =sorted(A,reverse=True) #多い順にソート

#
pan_sum = sum(A)
if A_sorted[M-1] < pan_sum/4/M:
    print("No")
else:
    print("Yes")
"""
print(pan_sum)
print(A[M-1])
print(pan_sum/4/M)
"""

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 500005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;
ll pre[maxn];
ll inv[maxn];
ll prei[maxn];
void build(int n){
    pre[1] = pre[0] = 1, inv[1] = inv[0] = 1, prei[1] = prei[0] = 1;
    for(int i = 2 ; i <= n ; i++){
        pre[i] = pre[i-1] * i % mod;
        inv[i] = (mod - mod / i * inv[mod % i] % mod) % mod;
        prei[i] = prei[i-1] * inv[i] % mod;
    }
}
ll C(int n, int k){
   return pre[n] * prei[k] % mod * prei[n-k] % mod;
}
ll pm(int n,int p){
    ll ret = 1;
    ll now = n;
    while(p){
        if(p & 1){
            ret *= now;
            ret %= mod;
        }
        now *= now;
        now %= mod;
        p >>= 1;
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    build(500000);
    ll ans = 0;
    k = n - 1 - k;
    for (int i = k + 1 ; i <= n ; i++) {
        ll cl = m * pm(m - 1, i - 1) % mod;
        ll per = C(n-1,i-1);
        //cout << cl <<' '<<per << endl;
        ans += cl * per % mod;
        ans %= mod;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 15372
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N, M;
  cin >> N >> M;
  set<ll> g[N];
  REP(i, M) {
    ll a, b;
    cin >> a >> b;
    g[a - 1].insert(b - 1);
    g[b - 1].insert(a - 1);
  }
  for (ll x : g[0]) {
    if (g[x].count(N - 1)) {
      cout << "POSSIBLE";
      return 0;
    }
  }
  cout << "IMPOSSIBLE";
  return 0;
}

Measured memory_bytes: 28416
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;

int main() {
    int k;
    string s;
    cin >> k >> s;
    if(s.size() > k) {
        s = s.substr(0,k);
        cout << s << "..." << endl;
    }else cout << s << endl;

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
typedef long long ll;
const ll MOD = 1e+9+7;

int main(){
    double N,K;
    cin >> N >> K;
    double num;
    double ans=0;
    rep2(i,1,N+1){
        if(i<K){
            num=ceil(log2(K/(double)(i)));
        }else{
            num=0;
        }
        
        ans=ans+(pow((double)2,-num)/N);
    }
    printf("%.12f\n",ans);
    
}

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

int t,n;
int hate[10];

bool check(int m){
	while(m>0){
		if(hate[m%10]) return false;
		m/=10;
	}
	return true;
}

int main(){
	cin>>n>>t;
	for(int i=0;i<t;i++){
		int x;
		cin>>x;
		hate[x]=1;
	}
	while(!check(n)){
		n++;
	}
	cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <limits>

template <typename T>
void vc(T t) {
    std::cout << t << " ";
}

template<typename T, typename... Args>
void vc(T t, Args... args) {
// recursive variadic function
    std::cout << t << " ";
    vc(args...) ;
}

const int N = 100000;
// std::vector<std::vector<int> > dp(N + 1, std::vector<int>(N + 1, -1));
int dp[N + 1][3] = {0};
int dpf(const std::vector<std::vector<int> >& h, int r, int n, int t) {
  if (dp[r][t] != 0) {
    return dp[r][t];
  }
  if (r == n) {
    dp[r][t] = h[r][t];
    return dp[r][t];
  }
  // vc("- ", r, t, "\n");
  if (t == 0) {
    dp[r][t] = std::max(h[r][0] + dpf(h, r + 1, n, 1), h[r][0] + dpf(h, r + 1, n, 2));

  } else if (t == 1) {
    dp[r][t] = std::max(h[r][1] + dpf(h, r + 1, n, 0), h[r][1] + dpf(h, r + 1, n, 2));

  } else {
    dp[r][t] = std::max(h[r][2] + dpf(h, r + 1, n, 1), h[r][2] + dpf(h, r + 1, n, 0));
  }
  return dp[r][t];
}

void once() {
  int n;
  std::cin >> n;
  std::vector<std::vector<int> > h(n + 1, std::vector<int>(3));
  for (int i = 1; i <= n; ++i) {
    std::cin >> h[i][0] >> h[i][1] >> h[i][2];
  }
  auto ret = std::max(dpf(h, 1, n, 0),
    std::max(dpf(h, 1, n, 1),
            dpf(h, 1, n, 2)));
  std::cout << ret << std::endl;
}

int
main() {
  int n = 1;
  std::ios::sync_with_stdio(false);
  // std::cin >> n;
  while (n--) {
    once();
  }
}

Measured memory_bytes: 13184
n,k=map(int,input().split())
h=list(map(int,input().split()))

dp=[float('inf')]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    for j in range(max(i-k,0),i):
        dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]))
print(dp[-1])

Measured memory_bytes: 55008
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<P> v(n), x(n);
  rep(i, 0, n) {
    int a, b;
    cin >> a >> b;
    v[i] = make_pair(a, b);
  }
  rep(i, 0, n) {
    int c, d;
    cin >> c >> d;
    x[i] = make_pair(c, d);
  }
  sort(x.begin(), x.end());

  vector<bool> is_pair(n, false);
  rep(i, 0, n) {
    vector<P> t;
    rep(j, 0, n) {
      if (v[j].first < x[i].first && v[j].second < x[i].second && !is_pair[j]) {
        t.emplace_back(v[j].second, j);
      }
    }
    if (t.size() == 0)
      continue;
    sort(t.rbegin(), t.rend());
    is_pair[t[0].second] = true;
  }

  int ans = 0;
  rep(i, 0, n) if (is_pair[i]) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

A,B,M = LI()
a = LI()
b = LI()
x,y,c = LIR(M,3)

ans = min(a)+min(b)
for i in range(M):
    if a[x[i]-1]+b[y[i]-1]-c[i] < ans:
        ans = a[x[i]-1]+b[y[i]-1]-c[i]

print(ans)

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

using namespace std;

struct Item {
	int value, weight;
};

int dp[11][100001];
int knapsack(vector<Item>& items, int W) {
	fill(dp[0], dp[11], -1); dp[0][0] = 0;
	int N = items.size();
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= W; ++j) {
			if (dp[i][j] < 0) continue;
			int nj = j+items[i].weight;
			if (nj <= W) {
				dp[i][nj] = max(dp[i][nj], dp[i][j]+items[i].value);
			}
			dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
		}
	}
	int res = 0;
	for (int i = 0; i <= W; ++i) {
		res = max(res, dp[N][i]);
	}
	return res;
}

int main() {
	int N, D, X; cin >> N >> D >> X;
	vector< vector<int> > P(D, vector<int>(N));
	for (int i = 0; i < D; ++i) {
		for (int j = 0; j < N; ++j) {
			cin >> P[i][j];
		}
	}
	vector< vector<Item> > items(D-1, vector<Item>(N));
	for (int i = 0; i < D-1; ++i) {
		for (int j = 0; j < N; ++j) {
			items[i][j] = (Item){P[i+1][j]-P[i][j], P[i][j]};
		}
	}
	for (int i = 0; i < items.size(); ++i) {
		X += knapsack(items[i], X);
	}
	cout << X << endl;
}

Measured memory_bytes: 5512
n=int(input())
q=[]
for i in range(n):
  q.append(int(input()))
q.sort()
s=sum(q)
check=s%10
if check!=0:
  print(s)
else:
  r=max(q)
  cnt=0
  for i in q:
    if i%10!=0 and i<=r:
      r=i
      cnt+=1
  if cnt==0:
    print(0)
  else:
    print(s-r)


Measured memory_bytes: 3060
#include <cstring>
#include <cstdint>
#include <iostream>
#include <string>
#include <memory>
#include <queue>
#include <limits>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <sstream>
#include <random>
#include <functional>
#include<algorithm>
#include <array>
using namespace std;

struct Vertex {
	vector<pair<int, long long> > to;
	long long pos;
	bool flag;
};
long long invalidVal = 1000000005;
int main() {
	int N, M;
	cin >> N >> M;
	unordered_set<long long> segment;
	vector<Vertex> vertex;
	segment.reserve(M * 2);
	vertex.resize(N);
	long L, R, D;
	for (size_t i = 0; i < M; i++)
	{
		cin >> L >> R >> D;
		L -= 1;
		R -= 1;
		segment.emplace(min(L, R) * N + max(L, R));
		vertex[L].to.push_back(make_pair(R, D));
		vertex[R].to.push_back(make_pair(L, -D));
	}
	for (size_t i = 0; i < N; i++)
	{
		vertex[i].pos = invalidVal;
		vertex[i].flag = false;
	}

	queue<long> que;
	while (segment.size())
	{
		long nn = (*segment.begin()) / N;
		que.push(nn);
		vertex[nn].pos = 0;
		while (que.size())
		{
			long n = que.front();
			for (pair<int, long long> seg : vertex[n].to)
			{
				long m = seg.first;
				long long p = min(m, n) * N + max(m, n);
				if (segment.count(p)) {
					segment.erase(p);
					if (vertex[m].pos == invalidVal) {
						que.push(m);
						vertex[m].pos = vertex[n].pos + seg.second;
					}
					else {
						if (vertex[m].pos != vertex[n].pos + seg.second) {
							cout << "No";
							goto END;
						}
					}
				}
			}
			que.pop();
		}
	}
	cout << "Yes";
END:
	return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int N,K,h,ct=0;
    cin >> N >> K;
    rep(i,N){
        cin >> h;
        if(h >= K) ct++;
    }
    pr(ct);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a) for(i = 0 ; i < a ; i++)
#define whln(t) while(t--)
#define whlp(t) while(t++)
ll i=0,j=0;


int main(void){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
	// ll t;
	// cin>>t;
	// whln(t){
	
	// }
	string n;
	ll x=0;
	cin>>n;

	rep(i,n.length())
		x+=(n[i])-'0';
		

	if(x%9==0)
		cout<<"Yes";
	else
		cout<<"No";


	

}
//   *****  *******   !
//   *		     *    !
//   ***       *      !
//   *       *        !
//   *****  *******   !

Measured memory_bytes: 3672
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;
int main(){
    int a,b;
    cin >> a >>b;
    cout << a/b << " " << a%b << " ";
    cout << fixed << setprecision(7);
    cout << (double)a/b<<endl;
    return 0;
}


Measured memory_bytes: 3252
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    X = int(input())
    for A in range(-200, 200):
        for B in range(-200, 200):
            if A ** 5 - B ** 5 == X:
                print(A, B)
                exit()

if __name__ == '__main__':
    main()

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

int main()
{
  	int n, k;
  	cin>>n>>k;
  	int l[n];
  	for(int i = 0; i < n; i++)
      	cin>>l[i];
  	sort(l, l+n, greater<int>());
  	int sum = 0;
  	for(int i = 0; i < k; i++)
      	sum += l[i];
  	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#define N 100005
#define go(i,a,b) for (int i=a;i<=b;i++)
using namespace std;
int v[N];
struct node{
	int num,sum;
}a[N],b[N];
bool cmp(node x, node y){
	return x.sum>y.sum;
}
int main(){
	int  n;
	scanf("%d",&n);
	go(i,1,N-5) a[i].num=b[i].num=i;
	go(i,1,n){
		scanf("%d",&v[i]);
		if (i%2==0) b[v[i]].sum++;
		else a[v[i]].sum++;
	}
	sort(a+1,a+1+N-5,cmp);
	sort(b+1,b+1+N-5,cmp);
	int ans=0;
	go(i,1,N-5){
		go(j,1,N-5){
			if (a[i].num!=b[j].num){
				ans=max(ans,a[i].sum+b[j].sum);
				break;
			}
		}
	}
	printf("%d\n",n-ans);
} 

Measured memory_bytes: 2176
#include <stdio.h>
 
int main(){
 
  int	N;
  int	x;
   
  
  scanf("%d", &N);
  
  x = N % 100;
  x = x % 10;
  
  if	 ( x==2 || x==4 || x==5 || x==7 || x==9 ){ printf("hon"); }
  else if( x==0 || x==1 || x==6 || x==8 )		 { printf("pon"); }
  else											 { printf("bon"); }
  
  return 0;
  
}

Measured memory_bytes: 1680
#include <cstdio>
#include <iostream>
#include <algorithm>
#define N 220000
using namespace std;
int n;
struct node{
	int v,t;
	bool operator <(const node&_)const{
		return t<_.t;
	}
}a[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].v,&a[i].t);
		if(a[i].v>a[i].t){puts("No");return 0;}
	}
	sort(a+1,a+n+1);
	int ti=0;
	for(int i=1;i<=n;i++){
		ti+=a[i].v;
		if(ti>a[i].t){puts("No");return 0;}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
 // freopen("input.txt","r",stdin);
#endif

  ll n,a,b;
  cin>>n>>a>>b;
  if(a==0)
  {
    cout<<0<<endl;
  }
  else
  {
    ll t=a+b;
    ll ans=n/t;
    ll rem=n%t;
    if(rem>a)
    {
      cout<<ans*a+a<<endl;
    }
    else
    {
      cout<<ans*a+rem<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll n, k;
  cin >> n >> k;
  mint ans = 0;
  n++;
  rep2(i, k, n + 1) {
    ll a1 = i * (i - 1) / 2;
    ll an = (n - i + n - 1) * i / 2;
    ans += an - a1 + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632