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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

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

    k = min(k, a + b);

    ll nokori = a + b - k;
    ll an = max(0ll, nokori - b);
    ll bn = min(nokori, b);
    printf("%lld %lld\n", an, bn);

}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<stack>
#include<queue>
const int infty = 100000000;
const int vmax = 100000;
struct vertex;
struct edge {
	int weight;
	vertex *to;
	edge(int w, vertex *v) :weight(w), to(v) {};
};
struct vertex {
	std::vector<edge> adj;
	int distance;
	bool visited;
	int name;
	vertex(int s) :name(s) {}
};
class graph {
public:
	int vertexsize, edgesize;
	typedef std::map<int, vertex*> vmap;
	vmap work;
	void addvertex(const int& name) {
		vmap::iterator itr = work.find(name);
		if (itr == work.end()) {
			vertex *v;
			v = new vertex(name);
			work[name] = v;
			return;
		}
	}
	void addedge(const int& from, const int& to, int cost) {
		vertex *f = work[from];
		vertex *t = work[to];
		f->adj.push_back(edge(cost, t));
	}
};
int main() {
	graph g;
	int a, b, d, i;
	scanf("%d%d", &g.vertexsize, &g.edgesize);
	for (i = 1; i <= g.vertexsize; i++) {
		g.addvertex(i);
		g.work[i]->visited = false;
	}
	for (i = 0; i < g.edgesize; i++) {
		std::cin >> a >> b >> d;
		g.addedge(a, b, d);
		g.addedge(b, a, -d);
	}
	for (i = 1; i <= g.vertexsize; i++) {
		vertex *start = g.work[i];
		if (!start->visited) {
			start->visited = true;
			start->distance = 0;
			std::stack<vertex *> st;
			st.push(start);
			while (!st.empty()) {
				vertex *v = st.top();
				st.pop();
				for (auto e : v->adj) {
					if (!e.to->visited) {
						e.to->visited = true;
						e.to->distance = v->distance + e.weight;
						st.push(e.to);
					}
					else {
						if (e.to->distance != v->distance + e.weight) {
							printf("No");
							return 0;
						}
					}
				}
			}
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 21888
A,B = [int(i) for i in input().split()]
ans = []
for _ in range(50):
    ans.append(["."]*100)
for _ in range(50):
    ans.append(["#"]*100)

for i in range(B-1):
    ans[2*int(i/50)][2*(i%50)] = "#"
for j in range(A-1):
    ans[-1-2*int(j/50)][2*(j%50)] = "."
print("100 100")
for po in ans:
    print(*po,sep="")

Measured memory_bytes: 4468
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }
    
    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var a     = int.Parse(spl[0]);
        var b     = int.Parse(spl[1]);
        var c     = int.Parse(spl[2]);

        return a + b + c >= 22 ? "bust" : "win";
    }
}


Measured memory_bytes: 13140
// E - Friendships

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	if (K > (N-1) * (N-2) / 2) {
		cout << -1 << endl;
		return 0;
	}

	int M = (N-1) + ((N-1) * (N-2) / 2 - K);

	cout << M << endl;
	for (int i=2; i<=N; i++) {
		cout << 1 << " " << i << endl;
		M--;
	}

	for (int i=2; i<=N; i++) {
		for (int j=i+1; j<=N; j++) {
			if (M == 0) break;

			cout << i << " " << j << endl;
			M--;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
    int n, t, minv, maxv, sum;
    for (;; ) {
        scanf("%d", &n);
        if (n == 0) break;
        sum = 0;
        for (int i = 0; i < 5; i++) {scanf("%d", &t); sum += t; }
        maxv = minv = sum;
        for (int i = 1; i < n; i++) {
            sum = 0;
            for (int j = 0; j < 5; j++) { scanf("%d", &t); sum += t; }
            minv = min(minv, sum);
            maxv = max(maxv, sum);
        }
        printf("%d %d\n", maxv, minv);
    }
    return 0;
}



Measured memory_bytes: 2692
/*      西江月·证明
	即得易见平凡，仿照上例显然。
   留作习题答案略， 读者自证不难。

	反之亦然同理，推论自然成立。
	略去过程QED，由上可知证毕。*/
# pragma GCC optimize (1)
# pragma GCC optimize (2)
# pragma GCC optimize (3)
# pragma GCC optimize ("Ofast")
#define mod 10
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstdio>
#define kkk register
#define ll long long
#define inf 2147098934832ll
using namespace std;
ll read(){ll ans=0,f=1;char a=getchar();while(a>'9'||a<'0'){if(a=='-')f=-1;a=getchar();}while(a>='0'&&a<='9')ans=(ans<<3)+(ans<<1)+a-'0',a=getchar();return ans*f;}
//一条long long的黄金分割线-----------------------------------------------------------------------------------------------------------------------------------
ll n,a[1000005];
int main(){
	n=read();ll k=read();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+1+n);
	ll ans=0;
	for(int i=1;i<=k;i++)ans+=a[i];
	cout<<ans;
	return 0; 
} 

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  ll ans=0;
  if(a==b&&b==c&&a%2==0){
    cout << -1 << endl;
    return 0;
  }
  while(a%2==0&&b%2==0&&c%2==0){
    ll a_=a/2,b_=b/2,c_=c/2;
    a=b_+c_;
    b=a_+c_;
    c=a_+b_;
    ans++;
  }
  cout << ans << endl;
}

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

int main() {
	double n;
	cin>>n;
	if(int(n)%2==0)
	cout<<0.5;
	else if(n==1)
	cout<<1.0;
	else
	cout<<(int(n)/2+1)/n;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n){
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int ans = 0;
    ans = d[n/2] - d[n/2 - 1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include<stdio.h>

int main(){
    int i,j,k,n,x,sum=0,count=0;
    while(1){
        scanf("%d %d",&n,&x);
        if(n == 0 && x == 0)break;

        for(i = n; i >= 1; i--){
            for(j = n; j >= 1; j--){
                for(k = n; k >= 1; k--){
                    if(i == j || j == k || k == i)continue;

                    sum = i + j + k;
                    if(sum == x)count++;
                }
            }
        }

        printf("%d\n",count/6);
        count = 0;
    }
return 0;
}


Measured memory_bytes: 1992
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define mkp make_pair
//# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

using namespace std;

ll q , w , e , z ;


int main()
{
	speed;

    string s ;
    cin >> s ;
    sort(s.begin(),s.end());
    for(int i = 1 ; i < s.size(); i ++ ){
        if(s[i]!=s[i-1]){
            z++;
        }
    }
    if(z+1==2){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

	time;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d;
    while(scanf("%lld",&a)==1)
    {
        cin>>b;
        c=a*a;
        d=c-b;
        cout<<d<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<complex>
using namespace std;

typedef complex<double> P;

#define X real()
#define Y imag()
typedef int kz;

kz gcd(kz a,kz b) { if(b==0) return a; else gcd(b,a%b); }

int main(){
    int mod=1000000007;
    string s;
    getline(cin, s);
    for (int i=0;i<s.size()-4;++i) {
        string t=s.substr(i,5);
        if(t=="apple") s.replace(s.begin()+i,s.begin()+i+5,"peach");
        if(t=="peach") s.replace(s.begin()+i,s.begin()+i+5,"apple");
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 2964
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
		{
			cnt++;
		}	

	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
N,W=map(int,input().split())

#vもwもdpも全て1-indexedみたいにした。わかりやすいので。
v=[0]*(N+1)
w=[0]*(N+1)
for i in range(1,N+1):
  w_i,v_i=map(int,input().split())
  w[i]=w_i
  v[i]=v_i


dp=[[0]*(W+1) for i in range(N+1)] #初期化もこの段階で済んでいる

for i in range(1,N+1):
  for j in range(1,W+1):
    if dp[i][j] < dp[i-1][j]:
      dp[i][j] = dp[i-1][j]
    if j >= w[i]:
      if dp[i][j] < dp[i-1][j-w[i]]+v[i]:
        dp[i][j] = dp[i-1][j-w[i]]+v[i]

print(dp[N][W])

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

int f(int x,int y,int z){
    return x*x+y*y+z*z+x*y+y*z+z*x;
}

int main(){
    int n;
    cin >> n;
    vector<int> ans(n+1);
    for(int x=1;x*x<=n;x++){
        for(int y=1;x*x+y*y<=n;y++){
            for(int z=1;f(x,y,z)<=n;z++){
                ans[f(x,y,z)]++;
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>

using namespace std;

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

  int n;
  cin >> n;

  if ((int)((int)(n / 1.08) * 1.08) == n) {
    cout << (int)(n / 1.08) << endl;
  } else if ((int)((int)(n / 1.08 + 1) * 1.08) == n) {
    cout << (int)(n / 1.08) + 1 << endl;
  } else {
    cout << ":(" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashSet;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

class Main{

    static Set<Integer> edges[];
    static boolean[] isWhite;
    static boolean[] used;
    static boolean[] stamped;
    static int path=Integer.MIN_VALUE;

    static int dfs1(int v){
        used[v]=true;
        int res=0;
        int cnt=0;
        for(int u : edges[v]){
            if(used[u])continue;
            int d = dfs1(u);
            if(d>=0){
                res+=d+2;++cnt;
            }
        }
        if(cnt==0&&!isWhite[v])return -1;
        if((isWhite[v]&&cnt%2==1) || (!isWhite[v]&&cnt%2==0)){
            stamped[v]=true;++res;
        }
        return res;
    }
    static int longest(int v){
        used[v]=true;
        PriorityQueue<Integer> que = new PriorityQueue<>(Collections.reverseOrder());
        que.add(0);que.add(0);
        for(int u:edges[v]){
            if(used[u])continue;
            que.add(longest(u));
        }
        int res = que.peek() + (stamped[v] ? 2:0);
        path = Math.max(path, que.poll() + que.poll() + (stamped[v] ? 2:0));
        return res;
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N =scan.nextInt();
        edges = new HashSet[N];
        isWhite = new boolean[N];
        used = new boolean[N];
        stamped = new boolean[N];
        for(int i=0;i<N;++i)edges[i]=new HashSet<>();
        for(int i=0;i<N-1;++i){
            int x = scan.nextInt()-1;
            int y = scan.nextInt()-1;
            edges[x].add(y);
            edges[y].add(x);
        }
        String C = scan.next();
        for(int i=0;i<N;++i)isWhite[i]=C.charAt(i)=='W';
        int root = -1;
        for(int i=0;i<N;++i)if(isWhite[i])root=i;
        if(root==-1){
            System.out.println(0);return;
        }
        int ans = 0;
        int cnt = 0;
        used[root]=true;
        for(int u : edges[root]){
            int d = dfs1(u);
            if(d>=0){
                ans+=d+2;++cnt;
            }
        }
        if((!isWhite[root]&&cnt%2==1) || (isWhite[root]&&cnt%2==0)){
            stamped[root]=true;++ans;
        }
        if(ans==1){
            System.out.println(1);return;
        }
        Arrays.fill(used, false);
        longest(root);
        System.out.println(ans - path);


    }
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ;
  cin >> n; 
  vector<int> v(n) ;
  
  rep(i,n) 
    cin >> v.at(i) ;
  
  int ans = INF ;
  
  rep(i,100){
    int now = 0;
    rep(j,n){
      int a =  v.at(j)-i ;
      now += a*a ;
    }
    ans = min(now,ans) ;
  }
  
  cout << ans ;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    const ll MOD = 1e9+7;
    ll n;
    cin >> n;
    vector<vector<ll>> a(n,vector<ll>(n));
    for(i = 0;i < n;++i){
        rep(j,n){
            cin >> a.at(i).at(j);
        }
    }
    vector<vector<ll>> dp(n+1,vector<ll>(1ll << n, 0));
    dp.at(0).at(0) = 1;
    for(i = 0;i < n;++i){
        for(int bit = 0;bit < (1ll << n);++bit){
            if(dp.at(i).at(bit) == 0) continue;
            for(j = 0;j < n;++j){
                if(a.at(i).at(j) && (bit & (1 << j)) == 0){
                    dp.at(i+1).at(bit | (1 << j)) += dp.at(i).at(bit)%MOD;
                    dp.at(i+1).at(bit | (1 << j)) %= MOD;
                }
            }
        }
    }
    cout << dp.at(n).at((1 << n)-1) << endl;
    return 0;
}

Measured memory_bytes: 377216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int N =scan.nextInt();
		int[] A = new int[N];

		for(int i=0;i<N;i++){
			A[i]=scan.nextInt();
		}

		int pm = 0;
		int bef = A[0];

		int num = 1;


		for(int i=1;i<N;i++){
			if(pm==0){
				pm = (A[i]-bef);
				bef = A[i];
				continue;
			}else{
				pm/=Math.abs(pm);
				int temp = (A[i]-bef)*pm;
				if(temp<0){
					num++;
					pm = 0;
				}
				bef = A[i];
			}

		}

		System.out.println(num);



	}

}


Measured memory_bytes: 50616
/**
 *   author: sahushivam
 *   created: 12 April 2020 (Sunday)  17:44:51
**/
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int long long

void solve(){
    int n; cin>>n;
    int s=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                int t=__gcd(i,j);
                int t1=__gcd(k,t);
                s+=t1;
            }
        }
    }
    cout<<s;
}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int t=1; while(t--) solve();
    return 0;
}

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

typedef long long ll;
#define PB push_back

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	double v[n];
	for (int i = 0; i < n; ++i) cin >> v[i];
	sort(v, v + n);
	double ans = v[0];;
	for (int i = 0; i < n - 1; ++i) {
		ans = (ans + v[i + 1]) / 2;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int x,y;
	cin>>x>>y;
	cout<<x+(y/2)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e7;
#define ll long long
#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)

class comp {

public:
    bool operator()(pair<int, int> a,
                    pair<int, int> b)
    {
        if(a.first!=b.first)
        return a.first>b.first;
    }
};
int main()
{

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
     ll a1=a*c;
     ll a2=a*d;
     ll a3=b*c;
     ll a4=b*d;
     cout<<max(a1,max(a2,max(a3,a4)))<<endl;

   // getch();
    return 0;
}

Measured memory_bytes: 3592
N, X = map(int, raw_input().split())

M = []

for i in range(N):
    M.append(int(raw_input()))

#print N, X, M

sum = 0
mini_M = M[0]

for i in range(N):
    X -= M[i]
    sum += 1
    if M[i] < mini_M:
        mini_M = M[i]

while X >= mini_M :
    X -= mini_M
    sum += 1

print sum


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

const auto CHARS = 64;
using Bit = bitset<800>;

int to_i(char c) {
  if(isdigit(c)) return c - '0';
  if(islower(c)) return c - 'a' + 10;
  if(isupper(c)) return c - 'A' + 36;
  return 63;
}

int main() {
  int AW, AH, BW, BH;
  cin >> AW >> AH >> BW >> BH;
  vector<string> a(AH), b(BH);
  for(auto v: {&a, &b}) for(auto& i: *v) cin >> i;

  vector<vector<int>> A(AH), B(BH);
  for(auto i = 0; i < AH; ++i) for(auto c: a[i]) A[i].emplace_back(to_i(c));
  for(auto i = 0; i < BH; ++i) for(auto c: b[i]) B[i].emplace_back(to_i(c));

  vector<vector<Bit>> T(CHARS, vector<Bit>(AH));
  for(auto i = 0; i < AH; ++i) for(auto j = 0; j < AW; ++j) {
    if(A[i][j] == to_i('?')) for(auto& k: T) k[i].set(j);
    else                     T[A[i][j]][i].set(j);
  }

  vector<Bit> ok(AH);
  for(auto& i: ok) i.set();
  for(auto i = 0; i < AH - BH + 1; ++i) {
    for(auto y = 0; y < BH; ++y) for(auto x = 0; x < BW; ++x) {
      auto c = B[y][x];
      if(c == to_i('?')) continue;
      ok[i] &= T[c][i+y] >> x;
    }
  }

  auto res = 0;
  for(auto i = 0; i < AH - BH + 1; ++i) for(auto j = 0; j < AW - BW + 1; ++j) if(ok[i][j]) ++res;
  cout << res << endl;
}



Measured memory_bytes: 12380
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float("inf")
mod = 10 ** 9 + 7

N = INT()
A = LIST()

dp = [[0]*3 for _ in range(N+1)]
dp[0][0] = -INF
dp[1][0] = -INF
dp[1][2] = A[0]
for i in range(2, N+1):
	if i%2 == 1:
		dp[i][0] = max(dp[i-1][0], dp[i-2][0]+A[i-1])
		dp[i][1] = max(dp[i-1][1], dp[i-2][1]+A[i-1])
		dp[i][2] = dp[i-2][2]+A[i-1]
	else:
		dp[i][0] = max(dp[i-1][1], dp[i-2][0]+A[i-1])
		dp[i][1] = max(dp[i-1][2], dp[i-2][1]+A[i-1])

print(dp[N][1])


Measured memory_bytes: 64556
import java.util.*;
import java.io.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int w = sc.nextInt();
    int[] weights = new int[n];
    long[] values = new long[n];
    for(int i = 0; i<n; i++) {
        weights[i] = sc.nextInt();
        values[i] = sc.nextInt();
    }
    long[][] dp = new long[n+1][w+1];
    for(int i = 1; i<=n; i++) {
        for(int j = 1; j<=w; j++) {
            int currWeight = weights[i-1];
            dp[i][j] = dp[i-1][j];
            if(j-currWeight>=0)
                dp[i][j] = Math.max(dp[i][j], dp[i-1][j-currWeight]+values[i-1]);
        }
    }
    System.out.println(dp[n][w]);
  }
}

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

using namespace std;

#define Rep(i,a,b)  for (int i=(a);i<(b);i++)
#define rep(i,n)    for (int i=0;i<(n);i++)
#define all(x)      (x).begin(), (x).end()

#define ll long long

ll gcd(ll a, ll b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

int main()
{
	ll n, x, v;

	cin >> n >> x >> v;
	ll ans = abs(x - v);
	rep (i, n - 1) {
		cin >> v;
		ans = gcd(ans, abs(x - v));
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
N = input()
n=len(N)-1
S = [0 for _ in range(n)]
combi = []

def makeCombination():
    rec(0)
    
def rec(i):
    if i == n:
        combi.append(S[:])
        return
    rec(i + 1)
    S[i] = 1
    rec(i + 1)
    S[i] = 0
    
makeCombination()

sum_N = 0
for l in combi:
    pre = 0
    for i in range(n):
        if l[i] == 1:
            sum_N += int(N[pre:i+1])
            pre = i+1
    
    sum_N += int(N[pre:])

print(sum_N)

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

int main ( void ) {
    
    char str[1000], str2[1000], str3[1000], s[7];
    int q, a, b;

    scanf ( "%s %d", str, &q );

    for ( int i = 0; i < q; i++ ) {

        scanf ( "%s", s );

        if ( strcmp ( s, "print" ) == 0 ) {
            scanf ( "%d %d", &a, &b );
            for ( int j = a; j < b + 1; j++ ) {
                printf ( "%c", str[j] );
            }
            printf ( "\n" );
        }

        else if ( strcmp ( s, "reverse" ) == 0 ) {
            scanf ( "%d %d", &a, &b );
            for ( int j = a, k = b; j < b + 1; j++, k-- ) {
                str2[k] = str[j];
            }
            for ( int j = a; j < b + 1; j++ ) {
                str[j] = str2[j];
            }
        }

        else if ( strcmp ( s, "replace" ) == 0 ) {
            scanf ( "%d %d %s", &a, &b, str3 );
            for ( int j = a, k = 0; j < b + 1; j++, k++ ){
                str[j] = str3[k];
            }
        }

    }
    
    return 0;
}


Measured memory_bytes: 2696
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <functional>
using namespace std;

int main(void) {
	int N,Y,a,b,c;
	int d[100] = { 0 };
	cin >> N >>Y;
	for (a = 0;a <= N;a++) {
		for (b = 0;b <= N-a;b++) {
			c = N - a - b;
			if (a * 10000 + b * 5000 + c * 1000 == Y) {
				cout << a << " " << b << " " << c << endl;
				return 0;
			}
		}

	}
	a = -1;
	b = -1;
	c = -1;
	cout << a << " " << b << " " << c << endl;
	return 0;
}


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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) \
    for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, pair<T1, T2> P) {
    return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream& operator<<(ostream& s, vector<T> P) {
    for (int i = 0; i < P.size(); ++i) {
        if (i > 0) {
            s << " ";
        }
        s << P[i];
    }
    return s;
}
template <class T>
ostream& operator<<(ostream& s, vector<vector<T> > P) {
    for (int i = 0; i < P.size(); ++i) {
        s << endl << P[i];
    }
    return s << endl;
}
template <class T>
ostream& operator<<(ostream& s, set<T> P) {
    EACH(it, P) { s << "<" << *it << "> "; }
    return s << endl;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, map<T1, T2> P) {
    EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; }
    return s << endl;
}
template <class T>
void show(vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        cerr << v[i] << " ";
    }
    cerr << "\n";
}
typedef long long ll;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x;
    cin>>x;
    for (int i = 0; i < 10; i++)
    {
        if(400+200*i <= x && x<=400+200*(i+1) -1){
            cout<<8-i<<endl;
            return 0;
        }
    }
    

    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(int T)
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(max(a*c,a*d),max(b*c,b*d));
}



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

Measured memory_bytes: 3640
#![allow(unused_imports)]
#![allow(unused_macros)]
// use proconio::input;
use std::cmp::{Ordering::*, Reverse};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};
use std::io::{self, BufWriter, Write};
use std::str::{self, SplitAsciiWhitespace};

// I have no idea what I'm doing

macro_rules! answer {
    ($out:ident, $ans:expr) => {
        writeln!($out, "{}", $ans)
    };
}

fn main() -> Result<(), io::Error> {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = UnsafeScanner::new(stdin.lock());
    let mut out = BufWriter::new(stdout.lock());

    let n: usize = scan.token();
    let mut s: Vec<usize> = scan
        .token::<String>()
        .chars()
        .map(|c| if c == 'R' { 0 } else { 1 })
        .collect();

    let (mut l, mut r) = (0i32, (n - 1) as i32);

    let mut ans = 0;
    loop {
        while l < n as i32 && s[l as usize] == 0 {
            l += 1;
        }
        while r >= 0 && s[r as usize] == 1 {
            r -= 1;
        }

        if l <= r {
            ans += 1;
            s.swap(l as usize, r as usize);
        } else {
            break;
        }
    }

    answer!(out, ans)
}

///////////////////////////////////////////////////////////////////////////////////////////////////

/// Mostly copied from https://github.com/EbTech/rust-algorithms/blob/master/src/scanner.rs
/// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts
/// **REQUIRES** Rust 1.34 or higher
pub struct UnsafeScanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: SplitAsciiWhitespace<'static>,
}

impl<R: io::BufRead> UnsafeScanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buf_str: vec![],
            buf_iter: "".split_ascii_whitespace(),
        }
    }

    /// This function should be marked unsafe, but noone has time for that in a
    /// programming contest. Use at your own risk!
    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse [Scanner]");
            }
            self.buf_str.clear();
            self.reader
                .read_until(b'\n', &mut self.buf_str)
                .expect("Failed read");
            self.buf_iter = unsafe {
                let slice = str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_ascii_whitespace())
            }
        }
    }

    pub fn pair<T: str::FromStr>(&mut self) -> (T, T) {
        (self.token(), self.token())
    }
}

// aka #![feature(bool_to_option)]
trait BoolThen {
    fn then_<T>(self, f: impl FnOnce() -> T) -> Option<T>;
}

impl BoolThen for bool {
    fn then_<T>(self, f: impl FnOnce() -> T) -> Option<T> {
        if self {
            Some(f())
        } else {
            None
        }
    }
}

trait BoolToYes {
    fn yes(self) -> &'static str;
}

impl BoolToYes for bool {
    fn yes(self) -> &'static str {
        match self {
            true => "Yes",
            false => "No",
        }
    }
}


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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15

 int main(){

 long long a,b,c,k;
 cin>>a>>b>>c>>k;


   if(k%2 == 1)
    cout<<b-a<<endl;
   else
    cout<<a-b<<endl;

  return 0;
 }


Measured memory_bytes: 3628
#include <stdio.h>
#include <ctype.h>
int main(){
	int i;
	char s[1200];
	scanf("%[^\n]",s);

	for(i=0;s[i]!='\0';i++){
		if(isupper(s[i]))s[i]=tolower(s[i]);
		else s[i]=toupper(s[i]);
	}
	printf("%s\n",s);
}

Measured memory_bytes: 952
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 1e6 + 7;
const int mod = 1e9 + 7;
inline int add(int x, int y) {int res = x + y; if (res >= mod) res -= mod; return res;}
inline int sub(int x, int y) {int res = x - y; if (res < 0) res += mod; return res;}
inline int mul(int x, int y) {ll res = (ll)x * y; res -= res / mod * mod; return res;}
int dp[MAXN], sum[MAXN];
int main()
{
    int n; scanf("%d", &n);
    dp[1] = sum[1] = n;
    dp[2] = sum[2] = mul(n, n); sum[2] += sum[1];
    for (int i = 3; i <= n; i++)
    {
        dp[i] = sub(sum[i - 1], dp[i - 2]);
        dp[i] = add(dp[i], mul(n - 1, n - 1));
        dp[i] = add(dp[i], n - i + 2);
        sum[i] = add(sum[i - 1], dp[i]);
    }
    printf("%d\n", dp[n]);
    return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<vector>
#include<limits.h>
#include<string>
using namespace std;

int LCS(string a, string b){
	int n=a.size();
	int m=b.size();
	int T[n+1][m+1];
	int i,j;
	for (i=0;i<n+1;i++) T[i][0]=i;
	for (j=0;j<m+1;j++) T[0][j]=j;
	for (i=1;i<n+1;i++){
		for (j=1;j<m+1;j++){
			int min=T[i-1][j]+1;
			if (min>T[i][j-1]+1){
				min=T[i][j-1]+1;
			}
			if ((a[i-1]==b[j-1])&&(min>T[i-1][j-1]+1)){
				min=T[i-1][j-1]+1;
			}
			T[i][j]=min;
		}
	}
	return n+m-T[n][m];
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,i;
	cin >> n;
	
	string a,b;
	for (i=0;i<n;i++){
		cin >> a >> b;
		cout << LCS(a,b) << endl;
	}
	return 0;
}

Measured memory_bytes: 5132
//last updated : 11.04.2020
#include <bits/stdc++.h>
#pragma GCC optimization ("O3")
using namespace std;

#define ll              long long
#define ld              long double
#define pll             pair <ll, ll>
#define plll            pair <ll, pll>

#define fa(i, n, N)     for (ll i = n; i <= N; ++i)
#define fac(i, n, b, N) for (ll i = n; i <= N && b; ++i)
#define fd(i, n, N)     for (ll i = n; i >= N; --i)

#define mp              make_pair
#define pb              push_back
#define pob             pop_back
#define pf              push_front
#define pof             pop_front
#define fi              first
#define se              second

#define ms(arr,t)       memset (arr, t, sizeof(arr));
#define all(x)          x.begin(), x.end()
#define len             length()
#define endl            '\n'

#define isss(x, s)      istringstream x (s)
#define db(x)           cout << ">>>>>> " << #x << " -> " << x << endl
#define AAAA            cout << "\t------" << endl;

//urgent cases only!
#define get_rt		cerr << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms.\n"

const ll inf = INT_MAX;
const ll inf2 = 1e18;
const ll MAX = 1e5+5;
const ll MOD = 1e9+7;
const double pi = acos(-1.0);
const double EPS = 1e-9;

void init(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

inline void iofile (){
	freopen ("input.txt", "r", stdin);
	// freopen ("output.txt", "w", stdout);
}


ll n, k, arr[MAX*2];

int main() {
    init(10);
    //iofile();
	
	cin >> n;
	fa (i,2,n){
		cin >> k;
		arr[k] ++;
	}
	
	fa (i,1,n){
		cout << arr[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 5204
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

const ll mod=1000000007;

ll Pow_mod(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

ll Fact(ll n){
	ll ans=1;
	for(ll i=2;i<=n;i++) ans=ans*i%mod;
	return ans;
}

ll Division_mod(ll n,ll m){
	return n*Pow_mod(m,mod-2)%mod;
}

ll Combination(ll n,ll k){
	return Division_mod(Fact(n),Fact(n-k)*Fact(k)%mod);
}

ll h,w,a,b,ans;

int main(){
	cin>>h>>w>>a>>b;
	h--;w--;
	ans=Combination(h-a+b,b)*Combination(w-b+a-1,a-1)%mod;
	ll tmp=ans;
	for(;b<w;b++){
		tmp=Division_mod(((tmp*(h-a+b+1))%mod*(w-b))%mod,(b+1)*(w-b+a-1)%mod);
		ans=(ans+tmp)%mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,n,w,h,i,j;
    // cin>>T;
    while(T--)
    {
        cin>>w>>h>>n;
        ll led=0,leu=h,brl=0,brr=w;
        ll x[n],y[n],a[n];
        FOR(i,0,n)  cin>>x[i]>>y[i]>>a[i];
        FOR(i,0,n)
        {
            if(a[i]==1)
                brl = max(brl,x[i]);
            if(a[i]==2)
                brr = min(brr,x[i]);
            if(a[i]==3)
                led = max(led,y[i]);
            if(a[i]==4)
                leu = min(leu,y[i]);
        }
        if(leu>=led&&brr>=brl){
            ll ans = (leu-led)*(brr-brl);
            cout<<ans<<endl;
        }
        else
            cout<<0<<endl;
    }
}

Measured memory_bytes: 3608
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
import sys
gcd = math.gcd
nmax = 10**5
mod = 10**9+7

fac = [1]*nmax
finv = [1]*nmax
inv = [1]*nmax
def ncr_pre():
    for i in range(2,nmax):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) %mod
        finv[i] = finv[i-1] * inv[i] %mod

def ncr(n,r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fac[n]* (finv[r] * finv[n-r] %mod) %mod
ncr_pre()
s = ni()
ans= 0
for i in range(1,1000):
    if s-i*3 <0:
        break
    t=s-i*3
    #print(t)
    #print(ncr(t+i-1,i-1))
    #print()
    ans +=ncr(t+i-1,i-1)
    ans%=mod
print(ans)


Measured memory_bytes: 70252
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> v(h, vector<int>(w, 0));
    auto visited = v;
    queue<tuple<int, int, int>> Q;
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j) {
            if(s[j] != '.') {
                v[i][j] = s[j] - '0';
                Q.emplace(i, j, 1);
                visited[i][j] = 1;
            }
        }
    }
    array<int, 8> dx{1, 1, 1, 0, 0, -1, -1, -1}, dy{1, 0, -1, 1, -1, 1, 0, -1};
    int ans = 0;
    int m = 0;
    stack<pair<int, int>> S;
    while(!Q.empty()){
        int i, j, n; tie(i, j, n) = Q.front(); Q.pop();

        int cnt = 0;
        if(n > m){
            m = n;
            while(!S.empty()){
                int p, q; tie(p, q) = S.top(); S.pop();
                v[p][q] = 0;
            }
        }
        if(!v[i][j]) continue;
        for (int k = 0; k < 8; ++k) {
            if(!v[i+dy[k]][j+dx[k]]) cnt++;
        }
        if(cnt >= v[i][j]){
            S.emplace(i, j);
            ans = max(ans, n);
            for (int k = 0; k < 8; ++k) {
                if(v[i+dy[k]][j+dx[k]] && visited[i+dy[k]][j+dx[k]] < n+1) {
                    visited[i+dy[k]][j+dx[k]] = n+1;
                    Q.emplace(i+dy[k], j+dx[k], n+1);
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


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

int		main(void)
{
	int K, S;
	cin >> K >> S;
	int cnt = 0;
	for (int i = 0; i <= K; i++)
	{
		for (int j = 0; j <= K; j++)
		{
			if (S - i - j <= K && S - i - j >= 0)
				cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,a,b;
signed main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	if (a>b||(a!=b&&n==1)){
		puts("0");
		return 0;
	}
	printf("%lld\n",(n-2)*(b-a)+1);
}

Measured memory_bytes: 256
INF = float('inf')
N = int(input())
d = {'R':[[],[]],'L':[[],[]],'U':[[],[]],'D':[[],[]]}
for i in range(N):
    x,y,f = input().split()
    x = int(x)
    y = int(y)
    d[f][0].append(x)
    d[f][1].append(y)

Ts = []

xM = max(max(d['U'][0]+[-INF]),max(d['D'][0]+[-INF]))
xMr = max(d['R'][0]+[-INF])
xMl = max(d['L'][0]+[-INF])

def xmax(T):
    return max(xM,xMr+T,xMl-T)

Ts += [max(0,xMl-xM),max(0,xM-xMr),max(0,(xMl-xMr)/2)]

xm = min(min(d['U'][0]+[INF]),min(d['D'][0]+[INF]))
xmr = min(d['R'][0]+[INF])
xml = min(d['L'][0]+[INF])

def xmin(T):
    return min(xm,xmr+T,xml-T)

Ts += [max(0,xml-xm),max(0,xm-xmr),max(0,(xml-xmr)/2)]

yM = max(max(d['R'][1]+[-INF]),max(d['L'][1]+[-INF]))
yMu = max(d['U'][1]+[-INF])
yMd = max(d['D'][1]+[-INF])

def ymax(T):
    return max(yM,yMu+T,yMd-T)

Ts += [max(0,yMd-yM),max(0,yM-yMu),max(0,(yMd-yMu)/2)]

ym = min(min(d['R'][1]+[INF]),min(d['L'][1]+[INF]))
ymu = min(d['U'][1]+[INF])
ymd = min(d['D'][1]+[INF])

def ymin(T):
    return min(ym,ymu+T,ymd-T)

Ts += [max(0,ymd-ym),max(0,ym-ymu),max(0,(ymd-ymu)/2)]

ans = INF

for T in Ts:
    ans = min(ans,(xmax(T)-xmin(T))*(ymax(T)-ymin(T)))

print(ans)

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

int main(){
  int x = 0, top = 0, stack[100];
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      stack[top-2] = stack[top-2] + stack[top-1];
      top -= 1;
    } else if ( s[0] == '-' ){
      stack[top-2] = stack[top-2] - stack[top-1];
      top -= 1;
    } else if ( s[0] == '*' ){
      stack[top-2] = stack[top-2] * stack[top-1];
      top -= 1;
    } else {
      stack[top] = atoi(s);
      top += 1;
    }
  }

  printf("%d\n",stack[top-1]);

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
using namespace std;
#define N 100009
#define ll long long

int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    ll a_ans,b_ans;
    if (a>=k){
        a_ans=a-k;
        b_ans=b;
    }
    else{
        a_ans=0;
        if (a+b>=k){
            b_ans=a+b-k;
        }
        else b_ans=0;
    }
    cout<<a_ans<<" "<<b_ans<<endl;

}

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

vi dx = {1, 0, -1, 0, 1, -1, -1, 1}, dy = {0, 1, 0, -1, 1, 1, -1, -1};

main()
{
  while(1){
    int w,h; cin >> w >> h;
    if(w == 0) break;

    vs maze(h); rep(i,h) cin >> maze[i];
    vvi look(h,vi(w));
    int sx, sy;
    rep(i,h) rep(j,w) if(maze[i][j] == '@'){
      sx = i; sy = j;
    }
    
    queue<pii> q;

    q.push(pii(sx,sy));
    int ans = 1;
    look[sx][sy] = 1;

    while(not q.empty()){
      pii p = q.front();
      q.pop();

      //if(p.fst == gx and p.snd == gy) break;

      rep(i, 4){
	int nx = p.fst + dx[i], ny = p.snd + dy[i];
	if(0 <= nx and nx < h and 0 <= ny and ny < w and maze[nx][ny] != '#' and look[nx][ny] == 0){
	  q.push(pii(nx, ny));
	  look[nx][ny] = 1;
	  ans++;
	}
      }
    }
    cout << ans << endl;
  }
}


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

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		Array.Sort(a);
		long ans = a[N - 1] - a[0];
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11988
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<string> vo,ve;

    REP(i,n) {
        string x; cin >> x;
        if (i % 2 == 0) ve.push_back(x);
        else vo.push_back(x);
    }
    reverse(ALL(vo));
    vo.insert(vo.end(),ALL(ve));
    if (n % 2 == 1) reverse(ALL(vo));

    string ans = "";
    REP(i,n-1) {
        ans += vo[i] + " ";
    }
    ans += vo[n-1];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15964
#include<iostream>
using namespace std;
int main(void){
  	long long N, A, B, ans;
  	cin >> N >> A >> B;
	long long Div = A + B;
  	long long Number = N / Div;
  	long long Mod = N % Div;
  	ans = Number * A;
  	if ( Mod < A ) ans += Mod;
  	else ans += A;
  	cout << ans << endl;
	return 0;
}

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

using namespace std;
int main(){
  int a;
  cin >> a;
  if(-1<a && a<4){
    cout << "No" << endl;
  }
  else if(4<a && a<7){
    cout << "No" << endl;
  }
  else if(8<a && a<11){
    cout << "No" << endl;
  }
  else if(a==13){
    cout << "No" << endl;
  }
  else if(a==17){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


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

int main(){
  int n, m, c;
  cin >> n >> m >> c;
  int a[n][m], b[m];
  for (int i = 0; i < m; i++){
    cin >> b[i];
  }
  for (int i = 0; i < n; i++){
    for (int j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  int count = 0;
  for (int i = 0; i < n; i++){
    int sum = c;
    for (int j = 0; j < m; j++){
      sum += a[i][j] * b[j];
    }
    if (sum > 0){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


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


void solve(long long N, long long A, long long B){
	long long int set;
	set = N/(A+B);
	long long int remain = N -((A+B)*set);
	long long int ans = (A*set)+min(A,remain);
	cout << ans << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

using namespace std;

ll n, k;

int main()
{
	cin >> n >> k;
	cout << min(n % k, k - (n % k));
	return 0;
}


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

#define ll long long
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
const int N = 1000 + 5;
int dp[N][N * 10], a[N], b[N];
int n, h;
int solve(int idx, int h) {
    if (h <= 0)
        return 0;
    if (idx == n)
        return 1e9;
    int &ret = dp[idx][h];
    if (~ret)
        return ret;
    ret = solve(idx + 1, h);
    ret = min(ret, solve(idx, h - a[idx]) + b[idx]);
    return ret;
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    memset(dp,-1,sizeof dp);
    cin >> h >> n;
    for(int i = 0 ; i < n ; i++)
        cin >> a[i] >> b[i];
    cout << solve(0, h);
    return 0;
}


Measured memory_bytes: 40192
function main(input) {
  var splited = input.split(" ")
  var a = Number(splited[0])
  var b = Number(splited[1])
  var c = a + b
  var d = a - b
  var e = a * b
  console.log(Math.max(c, d, e))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  for(int i=a;i<=b;i++){
    if(i<a+k || b-k<i){
      cout << i << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;


int main(){
	ll n,m,a[M];
	P p[M];
	ll ans=0;
	cin>>n>>m;
	rep(i,0,n)cin>>a[i];
	rep(i,0,m){
		ll a,b;
		cin>>a>>b;
		p[i].first=b;
		p[i].second=a;
	}
	sort(p,p+m,greater<>());
	sort(a,a+n);
	bool zettai=false;
	rep(i,0,m){
	bool f=false;
	if(zettai==true)break;
		ll cnt=0;
		rep(j,0,n){
			if(a[j]<p[i].first){
				if(cnt==p[i].second)break;
				f=true;
				cnt++;
				a[j]=p[i].first;
			}
		}
		if(f==false)zettai=true;
	}
	rep(i,0,n)ans+=a[i];
	print(ans);

}


Measured memory_bytes: 2560