akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>


using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int mi=0;
long long int N,res=0,abssum=0;
long long int A,B,C,K;
string S;

pll clo[200020],revclo[200020];
int main()
{
    cout << fixed << setprecision(18);
    cin>>K>>A>>B;
    if(A+2>=B){
        cout<<K+1<<endl;
        return 0;
    }else{
        K-=(A-1);
        res=A;
        res+=(K/2)*(B-A)+K%2;

    }
    cout<<res<<endl;
}    


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

int gcd(int a,int b){
	if(a==b||a==0) return b;
	else if(a<b) return gcd(b%a,a);
	else return gcd(b,a);
}

int main(){
	int n,k;
	int a[100000];
	int ma = -1;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",a+i);
	int g = a[0];
	for(int i=0;i<n;i++) ma = max(ma,a[i]);
	for(int i=0;i<n;i++) g = gcd(g,a[i]);
	if(ma>=k&&k%g==0) printf("POSSIBLE\n");
	else  printf("IMPOSSIBLE\n");
}


Measured memory_bytes: 512
H,W=map(int,input().split())
N=int(input())
A=list(map(int,input().split()))
k=1
L=[]
for i in range(N):
	for j in range(A[i]):
		L.append(k)
	k=k+1
k=0
c=1
for j in range(H):
	if c==-1:
		tmp=L[k:k+W]
		ans=tmp[::-1]
	else:
		ans=L[k:k+W]
	for i in ans:
		print(i,end=" ")
	print()
	k+=W
	c=-1*c

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

int main() {
  string s, t;
  cin >> s >> t;
  int sizes = s.size();
  int sizet = t.size();

  vector<vector<int>> dp(3001, vector<int> (3001));

  rep(i, 0, sizes) {
    char x = s[i];
    rep(j, 0, sizet) {
      char y = t[j];
      if (x == y) {
        dp[i+1][j+1] = dp[i][j]+1;
      } else {
        dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
      }
    }
  }

  string ans;
  int i = sizes, j = sizet;
  while(true) {
    if (i == 0 || j == 0) break;
    if (dp[i][j] == dp[i-1][j]) {
      i--;
    } else if (dp[i][j] == dp[i][j - 1]) {
      j--;
    } else {
      i--;
      j--;
      ans+=s[i];
    }
  }

  reverse(All(ans));

  cout << ans << endl;
};


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  LL a,b,c;
  cin>>a>>b>>c;
  cout << c SP a SP b << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int n,T;string S;double dp[2001][2001];
int main(){
	while(true){
		cin>>n>>T;if(n==0 && T==0)break;
		for(int i=0;i<=T;i++){for(int j=0;j<n;j++)dp[i][j]=0;}
		dp[0][0]=1.0;
		for(int i=0;i<T;i++){
			for(int j=0;j<n;j++){
				int c=j;
				for(int k=0;k<6;k++){
					c++;if(c==n)c=0;
					dp[i+1][c]+=dp[i][j]/6.0;
				}
			}
		}
		cin>>S;double maxn=0;
		for(int i=0;i<n;i++){
			double cnt=0;int c=i;
			for(int j=0;j<n;j++){
				if(S[c]=='R')cnt+=dp[T][j];
				c++;if(c==n)c=0;
			}
			maxn=max(maxn,cnt);
		}
		printf("%.15lf\n",maxn);
	}
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:
char ans[1010][1010];

int main(void) {
	int n, m, a, b;
	cin >> n >> m >> a >> b;
	rep(i, n)rep(j, m) ans[i][j] = '.';

	if (n % 2 == 1) {
		int j = 0;
		while (a > 0 and j + 1 < m) {
			ans[n - 1][j] = '<';
			ans[n - 1][j + 1] = '>';
			a--, j += 2;
		}
	}

	if (m % 2 == 1) {
		int i = 0;
		while (b > 0 and i + 1 < n) {
			ans[i][m - 1] = '^';
			ans[i + 1][m - 1] = 'v';
			b--, i += 2;
		}
	}

	if (n % 2 == 1 and m % 2 == 1 and a % 2 == 1 and b % 2 == 1) {
		const string pattern[3] = {"<>^", "^.v", "v<>"};
		rep(i, 3)rep(j, 3) ans[n - 3 + i][m - 3 + j] = pattern[i][j];
		a--, b--;
	}


	rep(i, n / 2)rep(j, m / 2) {
		if (ans[2 * i][2 * j] != '.') continue;
		if (a > 0) {
			rep(d, 2) {
				if (a > 0) {
					ans[2 * i + d][2 * j + 0] = '<';
					ans[2 * i + d][2 * j + 1] = '>';
					a--;
				}
			}
		} else if (b > 0) {
			rep(d, 2) {
				if (b > 0) {
					ans[2 * i + 0][2 * j + d] = '^';
					ans[2 * i + 1][2 * j + d] = 'v';
					b--;
				}
			}
		}
	}

	//cerr << a << " " << b << endl;
	if (a == 0 and b == 0) {
		puts("YES");
		rep(i, n) {
			rep(j, m) cout << ans[i][j];
			cout << endl;
		}
	} else {
		puts("NO");
	}

	return 0;
}

Measured memory_bytes: 2176
n = int(input())
dic = dict()

for i in range(n):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

ans = []
val = max(dic.values())
for kv in dic.items():
    if kv[1] == val:
        ans.append(kv[0])

ans = sorted(ans)
for a in ans:
    print(a)

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

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

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

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

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

ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  else return gcd(b, a % b);
  // return (b == 0) ? a : gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
  ll g = gcd(a, b);
  return a / g * b;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;
}


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

h=list(map(int,input().split()))
INF=10**10
dp=[INF]*N
dp[0]=0
for i in range(N):
  if i-1>=0:
    dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
  if i-2>=0:
    dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

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

int main() {
  string s, t, u;
  cin >> s >> t >> u;
  cout << s[0] << t[1] << u[2] << endl;
}

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

using namespace std;

int div[17];
int memo[290][18];

int dfs(int num, int s)
{
    int ret = 0;

    if (num == 0)
        return 1;
    else if (num < 0)
        return 0;
    if (memo[num][s] != -1)
        return memo[num][s];

    for (int i = s; i < 17; i++) {
        if (num < div[i])
            break;
        ret += dfs(num - div[i], i);
    }
    return memo[num][s] = ret;
}

int main()
{
    int n;

    memset(memo, -1, sizeof(memo));
    for (int i = 1; i <= 17; i++)
        div[i - 1] = i * i;

    while (cin >> n, n) {
        int ans = 0;

        cout << dfs(n, 0) << endl;
    }

    return 0;
}

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 2000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	vi h(n);
	rep(i, n)cin >> h[i];

	int ans = 0, k = 0;
	rep(i, n - 1) {
		if (h[i] >= h[i+1])k++;
		else {
			ans = max(ans, k);
			k = 0;
		}
	}
	ans = max(ans, k);

	cout << ans << endl;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    if a[i]%2 == 0:
        if a[i]%3 == 0 or a[i]%5 == 0:
            continue
        else:
            print("DENIED")
            exit()

print("APPROVED")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
int a[200005];
const int mod=1e9+7;
int fastpow(int a,int n)
{
    int res=1;
    int temp=a;
    while(n)
    {
        if(n&1)
            res=(1LL*res*temp)%mod;
        temp=(1LL*temp*temp)%mod;
        n>>=1;
    }
    return res%mod;
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    if(n==1)
        cout<<(1LL*2*a[0])%mod;
    else
    {
        sort(a,a+n);
        int res=0;
        int ans=fastpow(4,n-1);
        /*int ens=(1LL*ans*2)%mod;
        int rns=(1LL*ens*2)%mod;*/
        int temp=2;
        for(int i=n-1;i>=0;i--)
        {
            res=(1LL*res+(1LL*a[i]*temp)%mod)%mod;
            temp++;
        }
        res=(1LL*res*ans)%mod;
        cout<<res;
    }
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split(" ")))
ans = 0
for i in range(n):
    if i != 0:
        if a[i] < a[i-1]:
            ans += a[i-1]
            ans -= a[i]
            a[i] = a[i-1]

print(ans)

Measured memory_bytes: 32240
#include <iostream>
#include <atcoder/fenwicktree>
using namespace std;
using namespace atcoder;
using ll = long long;

int main()
{
  int n, q;
  cin >> n >> q;
  fenwick_tree<ll> ft(n);
  for (int i = 0; i < n; i++)
  {
    int ai;
    cin >> ai;
    ft.add(i, ai);
  }
  for (int j = 0; j < q; j++)
  {
    int qi;
    cin >> qi;
    if (qi == 0)
    {
      int p, x;
      cin >> p >> x;
      ft.add(p, x);
    }
    else
    {
      int l, r;
      cin >> l >> r;
      cout << ft.sum(l, r) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 8236
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<set>
#include<queue>
// #include<stack>
using namespace std;
typedef long long ll;
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2;
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
//vector<vector<ll>> vec(1000,vector<ll>(1000));
vector<pair<double, double>> vec1(100);
int main(){
  ll n;
  cin >> n;
  vector<pair<double,double>> radi(n);
  double ans = 0.0;
  rep(i,n){
    cin >> tmp1 >> tmp2;
    vec1[i] = make_pair(tmp1,tmp2);
    radi[i] = make_pair(atan2(tmp1,tmp2),i);
  }
  sort(all(radi));
  double tmpx,tmpy;
  rep(i,n){//size
    rep(j,n){//start
      tmpx = 0.0;tmpy=0.0;
      REP(k,j,j+i+1){
        tmpx += vec1[radi[k%n].second].first;
        tmpy += vec1[radi[k%n].second].second;
      }
      //cout << tmpx << " " << tmpy << endl;
      double tmp = sqrt((double)(tmpx*tmpx+tmpy*tmpy));
      // if(tmp > 18){
      //   cout << tmp << " " << i << " " << j << " " << endl;
      // }
      chmax(ans,tmp);
    }
  }
  printf("%.20lf",ans);
}


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

#define PB emplace_back

using namespace std;

const int N = 5e5+100;

int par[N], sz[N];

int fat(int x) {
    while(x != par[x]) x = par[x];
    return x;
}

void add(int u, int v) {
    u = fat(u);
    v = fat(v);
    if(u != v) {
        if(sz[u] < sz[v]) swap(u, v);
        sz[u] += sz[v];
        par[v] = u;
    }
}

int main () {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n, m;
    cin >> n >> m;
    iota(par, par + n , 0);
    fill(sz, sz + n, 1);
    while(m--) {
        int t, u1, u2;
        cin >> t >> u1 >> u2;
        if(t) cout << (fat(u1) == fat(u2)) << '\n';
        else add(u1, u2);
    }
}


Measured memory_bytes: 5028
h, w = gets.split.map(&:to_i)
maze = []
h.times do
  maze << gets.chomp.chars
end
 
dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]
ans = 0
queue = []
(0..h-1).each do |j|
  (0..w-1).each do |i|
    next if maze[j][i] == "#"
 
    queue << [j, i]
    d = Array.new(h) { Array.new(w, 0) }
    visited = Array.new(h) { Array.new(w, false) }
    d[j][i] = 0
    visited[j][i] = true
    while !queue.empty? do
      y, x = queue.shift
      (0..3).each do |k|
        ny = y + dy[k]
        nx = x + dx[k]
        next if ny < 0 || nx < 0 || ny >= h || nx >= w || maze[ny][nx] == "#" || visited[ny][nx]
 
        d[ny][nx] = d[y][x] + 1
        visited[ny][nx] = true
        queue << [ny, nx]
      end
    end
    # puts d.inspect
    ans = [ans, d.flatten.max].max
  end
end
puts ans

#他の人のコードをメモ用に提出

Measured memory_bytes: 2428
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define LLINF 1e18
#define INF (int)1e9+1

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

const llong MOD = 998244353;
const double PI = acos(-1);

int main() {
	IOS;
	int n, l; cin >> n >> l;
	vector<string> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
}

Measured memory_bytes: 3616
#include <iostream>

constexpr int MAX_N=(int)1e5;

int n;

int a[MAX_N],b[MAX_N];

int main() {
	std::cin>>n;
	for(int i=0;i<n;++i)
		std::cin>>a[i]>>b[i];
	long long int ans=0;
	for(int i=n-1;i>=0;--i) {
		if(((long long int)a[i]+ans)%b[i]!=0)
			ans+=b[i]-((long long int)a[i]+ans)%b[i];
	}
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;

int main()
{
	int N, Y;
	int found = false;

	cin >> N >> Y;
	rep1(b10000, 0, N) {
		rep1(b5000, 0, N - b10000) {
			int b1000 = N - b10000 - b5000;
			if (Y == 10000 * b10000 + 5000 * b5000 + 1000 * b1000) {
				printf("%d %d %d\n", b10000, b5000, b1000);
				found = true;
				break;
			}
		}
		if (found) break;
	}
	if (!found) cout << "-1 -1 -1" << endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << H * W - (h * W) - (w * H) + (h * w) << endl;
}


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

int main() {
  int A, B, C, D, E;
  cin >> A >> B >> C >> D;
  E = A + B - C - D;
  if (E == 0) {
    cout << "Balanced" << endl;
  }
  else if (E < 0) {
    cout << "Right" << endl;
  }
  else {
    cout << "Left" << endl;
  }
  return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

//少数点表示
//cout <<std::fixed << std::setprecision(14)

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

    string s,t;
    cin >> s >> t;

    cout <<t+s;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

signed main(){
	string s, t; cin >> s >> t;
	vector<vector<int> > data(26);
	ll n = s.size(), m = t.size();
	for(int i = 0; i < n; i++) data[s[i] - 'a'].push_back(i + 1);
	for(int i = 0; i < m; i++){
		if(!data[t[i] - 'a'].size()){
			cout << -1 << endl;
			return 0;
		}
	}
	for(int i = 0; i < 26; i++) data[i].push_back(INF);
	
	ll ans = 0, now = 0;
	for(int i = 0; i < m; i++){
		int num = t[i] - 'a';
		ll next = *upper_bound(data[num].begin(), data[num].end(), now);
		if(next == INF) ans += data[num][0] + (n - now), now = data[num][0];
		else ans += (next - now), now = next;
	}
	cout << ans << endl;
}
	


Measured memory_bytes: 1216
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sun Jan 21 21:22:57 2018
//
package main

import "fmt"
import "strconv"

func main() {
	var a, b string
	fmt.Scan(&a, &b)

	val, _ := strconv.Atoi(a + b)
	for i := 1; i <= 1000; i++ {
		if val == i*i {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std ;

#define MAXN 107

int n ;
int a[ MAXN ] ;

double ans = 0.0 ;

void input ( ) {
    scanf ( "%d" , &n ) ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        scanf ( "%d" , &a[ i ] ) ;
        ans += ( 1.0 / a[ i ] ) ;
    }
}

void solve ( ) {
    ans = ( 1.0 / ans ) ;
    printf ( "%.12lf\n" , ans ) ;
}

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


Measured memory_bytes: 256
use std::io;
fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input);
    let nums = input.trim().split(" ").map(|x| x.parse().unwrap()).collect::<Vec<i32>>();
    if nums[0] == nums[1] {
        print!("Yes");
    }
    else { print!("No"); }
}


Measured memory_bytes: 4352
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    ll n=in();
    vector<vector<ll>>edge(n);
    vector<pair<ll,ll>>iedge(n-1);
    for(ll i=0;i<n-1;++i){
        ll a=in()-1,b=in()-1;
        edge[a].push_back(b);
        edge[b].push_back(a);
        iedge[i]=make_pair(a,b);
    }

    queue<ll>nodes;
    vector<ll>parent(n);
    map<pair<ll,ll>,ll>ans;
    nodes.push(0);
    parent[0]=-1;
    while(!nodes.empty()){
        ll node=nodes.front();nodes.pop();
        ll color=1;
        for(auto child:edge[node]){
            if(child!=parent[node]){
                nodes.push(child);
                parent[child]=node;
                auto foo=minmax(node,parent[node]);
                if(ans.count(foo)&&color==ans[foo])++color;
                ans[minmax(child,node)]=color++;
            }
        }
    }

    using anst=decltype(ans)::value_type;
    cout<<max_element(ans.begin(),ans.end(),[](const anst p1,const anst p2){return p1.second<p2.second;})->second<<endl;
    for(auto i:iedge){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 15104
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;

int a,b;

int main()
{
    cin>>a>>b;
    cout<<max(max(2*a-1,2*b-1),a+b)<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		for(;sc.hasNext();){
			String s = sc.next();
			String t = sc.next();
			SuffixArray sa = new SuffixArray(s);
			int left=-1,right=t.length()+1;
			while(left<right-1){
				int len= (left+right)/2;
				
//				System.out.println(left+" "+right+" "+len);
				boolean f = false;
				for(int i=0;i<t.length();i++){
					if(i+len>t.length())break;
					String sub = t.substring(i,i+len);
					if(sa.contain(sub)){
						f=true;
						break;
					}
				}
				if(f){
					left=len;
				}
				else{
					right=len;
				}
					
			}
			System.out.println(left);			
		}

	}

	static class SuffixArray {
		int n,k=1;
		Integer[] sa,rank,tmp;
		String s;

		SuffixArray(String _s) {
			s=_s;
			n = s.length();
			String[] S = new String[n+1];
			S[n]="";
			for(int i=n-1;i>=0;i--){
				S[i] = s.charAt(i)+S[i+1];
			}
			rank=new Integer[n+1];
			sa=new Integer[n+1];
			tmp=new Integer[n+1];
			for(int i=0;i<n;i++){
				sa[i]=i;
				rank[i]=(int) s.charAt(i);
			}
			sa[n]=n;
			rank[n]=-1;

			for(k=1;k<=n;k<<=1){
				Arrays.sort(sa,new Comparator<Integer>(){
					@Override
					public int compare(Integer o1, Integer o2) {
						int r1=rank[o1];
						int r2=rank[o2];
						if(r1!=r2)return -(r1-r2);
						int r11=o1+k <= n ? rank[o1+k] : -1;
						int r22=o2+k <= n ? rank[o2+k] : -1;

						return -(r11-r22);
					}
				});
				tmp[sa[0]]=0;
				for(int i=1;i<=n;i++){
					tmp[sa[i]]=tmp[sa[i-1]]+ (compare(sa[i-1],sa[i])>0?1:0);
				}
				for(int i=0;i<=n;i++){
					rank[i]=tmp[i];
				}
			}
		}
		boolean contain(String t){
			return contain(s,sa,t);
		} 
		private boolean contain(String s,Integer[] sa,String t){
			int a=0,b=s.length();
			while(b-a>1){
				int c = (a+b)/2;
				String sub = s.substring(sa[c], Math.min(sa[c]+t.length(), s.length()));
				//			System.out.println(sub);
				//			System.out.println(a+" "+c+" "+b);
				if(sub.compareTo(t)<0){
					a=c;
				}
				else{
					b=c;
				}
			}
//			return s.substring(sa[b], Math.min(sa[b]+t.length(), s.length())).compareTo(t)==0;
			return compare(s,sa[b], Math.min(sa[b]+t.length(), s.length()),t)==0;
		}

		/*
		 * s.substring(i1,i2).compare(t)と同じ。メモリ節約
		 */
		private int compare(String s,int i1,int i2,String t){
			for(int i=i1;i<i2;i++){
				if(i-i1>=t.length()){
					return 1;
				}
				if(s.charAt(i)!=t.charAt(i-i1)){
					return s.charAt(i)-t.charAt(i-i1);
				}
			}
			return (i2-i1)-t.length();
		}

		private int compare(String s,int i1,int i2,String t,int j1,int j2){
			int slen=i2-i1;
			int tlen=j2-j1;
			for(int i=0;i<slen;i++){
				if(i>=tlen){
					return 1;
				}
				if(s.charAt(i+i1)!=t.charAt(i+j1)){
					return s.charAt(i+i1)-t.charAt(i+j1);
				}
			}
			return slen-tlen;
		}

		private int compare(Integer o1, Integer o2) {
			int r1=rank[o1];
			int r2=rank[o2];
			if(r1!=r2)return (r1-r2);
			int r11=o1+k <= n ? rank[o1+k] : -1;
			int r22=o2+k <= n ? rank[o2+k] : -1;

			return (r11-r22);
		}

	}

}

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

int main(void){
    ll a, b, k;
    cin >> a >> b >> k;

    ll ans = 0;
    ll count = 0;
    for(int i = min(a, b); i >= 0; i--){
        if(a % i == 0 && b % i == 0){
            count++;
            if(count == k){
                ans = i;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
int main(){
	int n; cin>>n;
	string s; cin>>s;
	char r = '1';
	ll co = 0;
	for(auto xx : s){
		if(xx != r) { co++; r = xx;}
		
	}
	cout<<co<<"\n";
	
	
}


Measured memory_bytes: 512
s=input()
if s=='SAT':
    print("1")
elif s=="FRI":
    print("2")
elif s=="THU":
    print("3")
elif s=="WED":
    print("4")
elif s=="TUE":
    print("5")
elif s=="MON":
    print("6")
elif s=="SUN":
    print("7")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <stack>

using namespace std;

stack<int> array;
int calc(string);

int main(){
	string input;
	while(cin>>input){
		if(input == "+" || input == "-" || input == "*" || input == "/")
			array.push(calc(input));
		else array.push(stoi(input));
		if(getchar() == '\n'){
			cout << array.top() << endl;
			break;
		}
	}
	return 0;
}

int calc(string input){
	int b = array.top(); array.pop();
	int a = array.top(); array.pop();
	if(input == "+") return a+b;
	else if(input == "-") return a-b;
	else if(input == "*") return a*b;
	else if(input == "/") return a/b;
	return 0;
}


Measured memory_bytes: 3176
#include <iostream>
using namespace std;
bool p_judge(int x) {
    for(int i=2; i<=x/2; i++) {
        if(x%i==0)
            return false;
    }
    return true;
}
 
int main(void) {
    int n, i, j=1;
    cin >> n;
    for(i=11; j<=n; i+=10) {
        if(p_judge(i)) {
            printf("%d ", i);
            j++;
        }
    }
}

Measured memory_bytes: 256
public class Main {

  private static void solve() {
    int n = ni();
    char[] s = ns();
    int ret = 0;
    for (int i = 0; i < 1000; i++) {
      int x = i;
      int[] a = new int[3];
      a[0] = x / 100;
      x %= 100;
      a[1] = x / 10;
      x %= 10;
      a[2] = x;

      int ptr = 0;
      for (char c : s) {
        int d = c - '0';
        if (d == a[ptr]) {
          ptr++;
          if (ptr == 3) {
            break;
          }
        }
      }
      if (ptr == 3) {
        ret++;
      }
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 22996
#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 = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    cout << (n/(a+b))*a + min(n%(a+b), a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 301000
using namespace std;
typedef long long ll;
ll s[maxn],ls[maxn],t[maxn],a[maxn],dpl[maxn],dpr[maxn],f[maxn];
int m,n,sta[maxn],tp;
ll cal(ll*dp,int i,int j){return -1ll*i*j+a[j];}
void pre(ll* dp){
	tp=0;
	sta[++tp]=0;
	for(int i=1;i<=n;++i){
		s[i]=s[i-1]+t[i];
		while(tp>1&&cal(dp,i,sta[tp])<cal(dp,i,sta[tp-1]))tp--;
		dp[i]=max(cal(dp,i,sta[tp])-s[i]+1ll*i*(i+1)/2,dp[i-1]),a[i]=1ll*i*(i-1)/2+s[i]+dp[i];
		while(tp>1&&1ll*(i-sta[tp-1])*(a[sta[tp]]-a[sta[tp-1]])<=1ll*(sta[tp]-sta[tp-1])*(a[i]-a[sta[tp-1]]))tp--;
		sta[++tp]=i;
	}
}
void solve(int l,int r,int ty){
	if(l==r){
		f[l]=max(f[l],dpl[l-1]+dpr[l+1]+1-t[l]);
		return ;
	}
	int mid=l+r-ty>>1,tp=0;
	solve(l,mid,ty),solve(mid+1,r,ty);
	for(int i=l-1;i<=mid;++i){
		a[i]=1ll*i*(i-1)/2+s[i]+dpl[i];
		while(tp>1&&1ll*(i-sta[tp-1])*(a[sta[tp]]-a[sta[tp-1]])<=1ll*(sta[tp]-sta[tp-1])*(a[i]-a[sta[tp-1]]))tp--;
		sta[++tp]=i;
	}
	for(int i=mid+1;i<=r;++i){
		while(tp>1&&cal(dpl,i,sta[tp])<cal(dpl,i,sta[tp-1]))tp--;
		ls[i]=dpr[i+1]+cal(dpl,i,sta[tp])+1ll*i*(i+1)/2-s[i];
	}
	for(int i=r;i>=mid+1;--i){
		if(i!=r)ls[i]=max(ls[i],ls[i+1]);
		f[i]=max(f[i],ls[i]);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%lld",&t[i]),f[i]=-1ll<<60;
	pre(dpl),reverse(t+1,t+n+1);
	pre(dpr),reverse(t+1,t+n+1);
	reverse(dpr+1,dpr+n+1);
	for(int i=1;i<=n;++i)s[i]=s[i-1]+t[i];
	solve(1,n,0);
	reverse(f+1,f+n+1);
	reverse(t+1,t+n+1);
	reverse(dpl+1,dpl+n+1);
	reverse(dpr+1,dpr+n+1);
	swap(dpl,dpr);
	for(int i=1;i<=n;++i)s[i]=s[i-1]+t[i];
	solve(1,n,1);
	reverse(f+1,f+n+1);
	reverse(t+1,t+n+1);
	reverse(dpl+1,dpl+n+1);
	reverse(dpr+1,dpr+n+1);
	swap(dpl,dpr);
	scanf("%d",&m);
	for(int i=1,p,nx;i<=m;++i)
		scanf("%d%d",&p,&nx),printf("%lld\n",max(dpl[p-1]+dpr[p+1],f[p]-nx+t[p]));
}

Measured memory_bytes: 19072
import re

class bintree():
    def __init__(self, str1):
        self.str1 = str1
        if self.str1[1] != ",":
            c = 0
            counter = 0
            for s in str1[1:]:
                counter += 1
                if s == "(":
                    c += 1
                elif s == ")":
                    c -= 1
                if c == 0:
                    break
            self.left = bintree(str1[1:counter+1])
                
            #match1 = re.search("\((\(.*\)),.*\)",str1)
            #if match1 != None:
            #    self.left = bintree(str(match1.group(1)))
        else:
            self.left = ""
        if self.str1[-2] != ",":
            str1 = str1[0]+str1[1+len(str(self.left)):]
            match2 = re.search("\(,(\(.*\))\)",str1)
            if match2 != None:
                self.right = bintree(str(str1[2:-1]))
        else:
            self.right = ""
    def __str__(self):
        return self.str1
        
def inter(bin1, bin2):
    if bin1.left != "" and bin2.left != "":
        strleft = inter(bin1.left, bin2.left)
    else:
        strleft = ""
    if bin1.right != "" and bin2.right != "":
        strright = inter(bin1.right, bin2.right)
    else:
        strright = ""
    return "(" + strleft + "," + strright + ")"

def union(bin1, bin2):
    if bin1.left != "" or bin2.left != "":
        if bin1.left == "":
            strleft = str(bin2.left)
        elif bin2.left == "":
            strleft = str(bin1.left)
        else:
            strleft = union(bin1.left, bin2.left)
    else:
        strleft = ""
    if bin1.right != "" or bin2.right != "":
        if bin1.right == "":
            strright = str(bin2.right)
        elif bin2.right == "":
            strright = str(bin1.right)
        else:
            strright = union(bin1.right, bin2.right)
    else:
        strright = ""
        #print("(" + strleft + "," + strright + ")")
    return "(" + strleft + "," + strright + ")"



while True:
    
    try:
        inputs = map(str,input().split())
        order = next(inputs)
        if order == "i":
            t1 = bintree(next(inputs))
            t2 = bintree(next(inputs))
            #print(t1.left,t1.right)
            print(inter(t1, t2))#  == "((((((,),),),),),)")
            
        elif order == "u":
            t1 = bintree(next(inputs))
            t2 = bintree(next(inputs)) 
            #print(t1.left,t1.right)
            #print(t1.left,t1.right)
            print(union(t1,t2))# == "((((,),(,)),((,),(,))),(((,),(,)),((,),(,))))")
    except EOFError as exception:
        break


Measured memory_bytes: 6676
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#define db double
#define ui unsigned int
#define ll long long
#define ull unsiged ll
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, r, l) for (int i = r; i >= l; i--)
#define boots     ios::sync_with_stdio(0); cin.tie(0)
#define pb push_back
#define pp pop_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mod 998244353
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define inf 0x3f3f3f3f
#define lnf LLONG_MAX
#define mii map<int, int>
#define mll map<ll, ll>
#define mil map<int, ll>
#define umii unordered_map<int, int>
#define umll unordered_map<ll, ll>
#define umcc unordered_map<char, char>
#define si(n) scanf("%d", &n)
#define sl(n) scanf("%lld", &n)
#define pf(n) printf("%lld\n", n)
#define sz size
using namespace std;
const db pi = 3.1415926535898;
const int MX = 1e5 + 7;
const int maxn = 1e6 + 7;
const int esp = 1e-6;
bool ji[MX];
int top;
//unordered_map<pair<int, int>, int>mp;
//ll modulo(ll num, ll MOD = mod) { return ((num%MOD) + MOD) % MOD; }
ll gcd(ll a, ll b) { return ((b == 0) ? a : gcd(b, a % b)); }
//void prime() { rep(i, 2, MX - 1) { if (!ji[i])pri[++top] = i; for (int j = 2; j*i < MX; j++)ji[j*i] = 1; } }
const int N = 1e6 + 5;
umii mp;
ll p[MX];
vector<int> pri;
vector<bool> isp(MX, false);
int n;
int vj(int a) {
	if (mp[a] == 0)
		return 0;
	else {
		int b = vj(a + mp[a]);
		mp[a] += b;
		return mp[a];
	}
}
int a[30], b[30], c[30];
int main() {
	boots;
	int n;
	cin >> n;
	rep(i, 1, n)cin >> a[i];
	rep(i, 1, n)cin >> b[i];
	rep(i, 1, n-1)cin >> c[i];
	int ans = 0;
	rep(i, 1, n)
	{
		ans += b[a[i]];
		if (a[i] == a[i - 1] + 1&&i>1)
		{
			ans += c[a[i - 1]];
		}
	}

	cout <<ans << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
int main(){
    long long a,b,c;
    cin>>a>>b>>c;
    long long d=c;
    c=max(c-a,0ll);
    a=max(a-d,0ll);
    b-=c;
    b=max(b,0ll);
    cout<<a<<' '<<b;
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W, K;
	cin >> H >> W >> K;
	int X1, Y1, X2, Y2;
	cin >> X1 >> Y1 >> X2 >> Y2;
	X1--;
	Y1--;
	X2--;
	Y2--;
	vector<string> S(H);
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	int INF = (int)1 << 60;
	vector<vector<vector<int> > > D(H, vector<vector<int> >(W, vector<int>(4, INF)));
	priority_queue<pair<int, pair<pair<int, int>, int> > > pq;
	for (int k = 0; k < 4; k++) {
		pq.emplace(0, make_pair(make_pair(X1, Y1), k));
		D[X1][Y1][k] = 0;
	}
	int dx[4] = {0, 1, 0, -1};
	int dy[4] = {1, 0, -1, 0};
	while (pq.size() > 0) {
		int x = pq.top().second.first.first;
		int y = pq.top().second.first.second;
		int dir = pq.top().second.second;
		if (D[x][y][dir] != -pq.top().first) {
			pq.pop();
			continue;
		}
		pq.pop();
		int nd = (((D[x][y][dir] + K - 1) / K) * K) + 1;
		for (int k = 0; k < 4; k++) {
			int xx = x + dx[k];
			int yy = y + dy[k];
			if (xx >= 0 && xx < H && yy >= 0 && yy < W) {
				if (S[xx][yy] == '.') {
					if (k == dir) {
						if (D[xx][yy][k] > D[x][y][dir] + 1) {
							D[xx][yy][k] = D[x][y][dir] + 1;
							pq.emplace(-D[xx][yy][k], make_pair(make_pair(xx, yy), k));
						}
					} else {
						if (D[xx][yy][k] > nd) {
							D[xx][yy][k] = nd;
							pq.emplace(-D[xx][yy][k], make_pair(make_pair(xx, yy), k));
						}
					}
				}
			}
		}
	}
	int res = INF;
	for (int k = 0; k < 4; k++) {
		res = min(res, D[X2][Y2][k]);
	}
	if (res == INF) {
		cout << -1 << endl;
	} else {
		cout << ((res + K - 1) / K) << endl;
	}
}

Measured memory_bytes: 144928
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string disp(bool x){
    return x ? "Yes" : "No";
}

int main(){
    int n; cin >> n;
    double x[n],y[n];
    rep(i,n) cin >> x[i];
    rep(i,n) cin >> y[i];
    
    double md = 0;
    double yd = 0;
    double td = 0;
    double cd = 0;

    rep(i,n){
        double dxy = abs(x[i]-y[i]);
        cd = max(cd,dxy);
        md += dxy;
        yd += pow(dxy,2);
        td += pow(dxy,3);
    }
    
    yd = sqrt(yd);
    td = pow(td,1.0/3.0);
    cout << fixed;
    cout << setprecision(5) << md << endl;
    cout << setprecision(5) << yd << endl;
    cout << setprecision(5) << td << endl;
    cout << setprecision(5) << cd << endl;
    
}
    
    







Measured memory_bytes: 3408
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll l,r;
	cin>>l>>r;
	if(l%2019==0 || r%2019==0 || l==0)
	{
		cout<<0;
		return 0;
	}
	if(r/2019-l/2019>0)
	{
		cout<<0;
		return 0;
	}
	ll m=mod;
	for(ll i=l;i<r;i++)
	{
		for(ll j=i+1;j<=r;j++)
		{
			if((i*j)%2019<m)
			{
				m=(i*j)%2019;
			}
		}
	}
	cout<<m%2019;	
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

// #define TEST

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define ll long long

constexpr ll mod = 1000000007LL;

ll fact(ll k, int sgn = 0) {
	static vector<ll> fac(2, 1LL);
	static vector<ll> inv(2, 1LL);
	static vector<ll> finv(2, 1LL);
	static ll nx = 2LL;
	while (nx <= k) {
		fac.push_back(fac[nx - 1] * nx % mod);
		inv.push_back(mod - inv[mod % nx] * (mod / nx) % mod);
		finv.push_back(finv[nx - 1] * inv[nx] % mod);
		++nx;
	}
	if (sgn == 0)
		return fac[k];
	return finv[k];
}

ll comb(ll a, ll b) {
	if (b < 0 || b > a) return 0;
	return fact(a) * fact(b, 1) % mod * fact(a - b, 1) % mod;
}

int N, K;
vector<vector<int>> g;

void input(void){
    cin >> N >> K;
    g.resize(N);
    for (int i = 0; i < N - 1; ++i){
        int a, b; cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
}

vector<int> cnt_children;

void dfs(int s = 0, int p = -1){
    int cnt = 0;
    for (auto c : g[s])
        if (c != p){
            ++cnt; dfs(c, s);
        }
    cnt_children[s] = cnt;
}

ll solve(void){
    ll res = K;
    cnt_children.resize(N);
    dfs();
#ifdef TEST
    cout << "-----cnt_children-----" << endl;
    for (auto ci : cnt_children)
        cout << ci << " ";
    cout << endl;
#endif
    for (int i = 0; i < N; ++i){
        int c = cnt_children[i];
        ll tmp = fact(c);
        tmp *= comb(K - (i == 0 ? 1LL : 2LL), c);
        tmp %= mod;
        res = (res * tmp) % mod;
    }
    return res;
}

int main(void){
    input();
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
int head[3005],pnt[6005],nxt[6005],val[3005],E=0,check[3005];
int n;
void add_edge(int a,int b)
{
	pnt[E]=b;
	nxt[E]=head[a];
	head[a]=E++;
}
void dfs(int u,int pre)
{
	check[u]=0;
	for(int i=head[u];i!=-1;i=nxt[i])
	{
		int v=pnt[i];
		if(v==pre)continue;
		if(val[v]<val[u])
		{
			dfs(v,u);
			if(!check[v])check[u]=1;
		}
	}
}
int main()
{
	memset(head,-1,sizeof(head));
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&val[i]);
	}
	for(int i=1;i<n;++i)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		add_edge(a,b);
		add_edge(b,a);
	}
	for(int i=1;i<=n;++i)
	{
		dfs(i,0);
		if(check[i])printf("%d ",i);
	}
	return 0;
}

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

int main(){
    int N,K; cin >> N >> K;
    string s;
    cin >> s;
    vector<int> res;
    int tmp=1;
    for(int i=0;i<N-1;i++){
        if(s[i]==s[i+1]){
            tmp++;
            continue;
        }
        res.push_back(tmp);
        tmp=1;
    }
    res.push_back(tmp);
    int ans=0;
    int M=res.size();
    int sum[M+1]={};
    for(int i=0;i<M;i++){
        sum[i+1]=sum[i]+res[i];
    }
    bool flag=true;
    if(s[0]=='0') flag=false;
    for(int i=1;i<=M;i++){
        if(flag){
            if(i%2==1){
                int right=i+2*K;
                if(right>=M) right=M;
                ans=max(ans,sum[right]-sum[i-1]);
            }else{
                int right=i+2*K-1;
                if(right>=M) right=M;
                ans=max(ans,sum[right]-sum[i-1]);
            }
        }else{
            if(i%2==0){
                int right=i+2*K;
                if(right>=M) right=M;
                ans=max(ans,sum[right]-sum[i-1]);
            }else{
                int right=i+2*K-1;
                if(right>=M) right=M;
                ans=max(ans,sum[right]-sum[i-1]);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1272
#include <iostream>
#include <set>
#include <algorithm>

using namespace std;

int main() {
  set<set<int> > surfaces;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    set<int> surface;
    int a, b, c;
    cin >> a >> b >> c;
    surface.insert(a);
    surface.insert(b);
    surface.insert(c);
    surfaces.insert(surface);
  }
  cout << (n - surfaces.size()) << endl;
}

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	ll N;
	cin >> N;

	ll A[50];
	rep(i, N) cin >> A[i];

	ll kaisuu = 0;
	while (*max_element(A, A + N) > 2 * N) {
		rep(i, N) {
			if (A[i] > 2 * N) {
				ll kari = (A[i] - 2 * N) / N + 1;
				A[i] -= kari * (N + 1);
				rep(ii, N) A[ii] += kari;
				kaisuu += kari;
			}
		}
	}

	while (*max_element(A, A + N) >= N) {
		*max_element(A, A + N) -= N + 1;
		rep(ii, N) A[ii] += 1;
		kaisuu++;
	}

	co(kaisuu);

	Would you please return 0;
}

Measured memory_bytes: 256