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

#define int long long

using namespace std;

const int mod = 998244353;
const int N = 300005;

int fact[N], inv_fact[N];

int binPow (int x, int y) {
    int ans = 1;
    while (y) {
        if (y & 1) ans = (ans * x) % mod;

        x = (x * x) % mod;
        y /= 2;
    }

    return ans;
}

int C (int n, int k) {
    if (k > n) return 0;
    if (k < 0) return 0;

    int ans = 1;
    ans *= fact[n]; ans %= mod;
    ans *= inv_fact[k]; ans %= mod;
    ans *= inv_fact[n - k]; ans %= mod;

    return ans;
}

signed main(){
    int n, a, b, k;
    scanf("%lld %lld %lld %lld", &n, &a, &b, &k);

    fact[0] = inv_fact[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = (i * fact[i - 1]) % mod;
        inv_fact[i] = binPow(fact[i], mod - 2);
    }

    int ans = 0;
    for (int i = 0; i <= n && a * i <= k; i++) {
        if ((k - a * i) % b == 0) {
            int j = (k - a * i) / b;
            ans = ans + C(n, i) * C(n, j);
            ans %= mod;
        }
    }

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


Measured memory_bytes: 4992
def abc088b_card_game_for_two():
    n = int(input())
    a = sorted(list(map(int, input().split())))
    alice = bob = 0
    for i in range(len(a)):
        if i % 2 == 0:
            alice += a.pop()
        else:
            bob += a.pop()
    print(alice - bob)
abc088b_card_game_for_two()

Measured memory_bytes: 9100
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll M, N;
    cin >> N >> M;
    vector<Pll> man(N), check(M);

    ll a, b;
    rep(0, i, N)
    {
        cin >> a >> b;
        man.at(i) = make_pair(a, b);
    }

    ll c, d;
    rep(0, i, M)
    {
        cin >> c >> d;
        check.at(i) = make_pair(c, d);
    }

    rep(0, i, N)
    {
        ll dis = 10000000000;
        ll point;
        rep(0, j, M)
        {
            if (dis > abs(man.at(i).first - check.at(j).first) + abs(man.at(i).second - check.at(j).second))
            {
                dis = abs(man.at(i).first - check.at(j).first) + abs(man.at(i).second - check.at(j).second);
                point = j;
            }
        }
        cout << point + 1 << endl;
    }
}

Measured memory_bytes: 3636
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define mk make_pair
const int maxn=3e5+100;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
int vis[100][100];
bool flag[100];
int n,m,x,y;
bool ck(){
    for(int i=0;i<n;i++){
        if(flag[i])
        {
            for(int j=0;j<n;j++){
                if(vis[i][j]==2)
                    continue;
                if(vis[i][j]==1&&!flag[j])
                {
                    return false;
                }
                if(vis[i][j]==0&&flag[j]){
                    return false;
                }
            }
        }
    }
    return true;
}
int main()
{

    //cout<<(1<<15)<<endl;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)
            vis[i][j]=2;
    }
    for(int i=0;i<n;i++){
        scanf("%d",&m);
        for(int j=0;j<m;j++){
            scanf("%d%d",&x,&y);
            vis[i][--x]=y;
        }
    }
    int maxe=0;
    //cout<<(1<<3)<<endl;
    for(int i=1;i<(1<<n);i++){
        memset(flag,0,sizeof(flag));
        int num=0,pos=0,now=i;
        while(now){
            if(now%2)
                num++,flag[pos]=1;
            now/=2;
            pos++;
        }
        if(ck()){
            maxe=max(maxe,num);
        }

    }
    cout<<maxe<<endl;
}
/*
17
AAAAABBBCCBBBBCCC
100 1 10
*/


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var k, s int
	fmt.Scan(&k, &s)

	c := 0
	for x := 0; x <= k; x++ {
		for y := 0; y <= k; y++ {
			t := s - (x + y)
			if 0 <= t && t <= k {
				c++
			}
		}
	}
	fmt.Println(c)
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
  int N;
  cin>>N;
  int a[100];
  int Ap=0,Bp=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  sort(a,a+N);
  for(int i=0;i<N;i++){
    if(i%2) Ap+=a[i];
    else Bp+=a[i];
  }  
  cout<<abs(Ap-Bp)<<endl;
  
  return 0;
}

Measured memory_bytes: 256
is_prime = [False,False]

for i in range(2,1000000):
    is_prime.append(True)

for i in range(2,1000000):
    if is_prime[i]:
        for j in range(i*i,1000000,i):
            is_prime[j] = False

while 1:
    try:
        a = int(0)
        b = int(0)
        n = int(input())
        for i in range(n-1,0,-1):
            if is_prime[i]:
                a = i
                break
        
        for i in range(n+1,50022):
            if is_prime[i]:
                b = i
                break
                
        print("%s %d"%(a,b))
    except:
        break


Measured memory_bytes: 13376
#include <cstdio>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;

typedef pair<int, int> pii;

bool sumComp(const pii &left, const pii &right) {
    return (long)left.first + (long)left.second >= (long)right.first + (long)right.second;
}

int main()
{
    int N, A, B;
    scanf("%d",&N);
    long P[N];
    long sum = 0;
    for (int i=0; i<N; i++) {
        scanf("%d %d", &A, &B);
        P[i] = A + B;
        sum -= B;
    }
    sort(P,P+N,greater<int>());
    for (int i=0; i<N; i++) {
        if (i%2 == 0) sum += P[i];
    }
    printf("%ld\n",sum);
    return 0;
}

Measured memory_bytes: 896
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, M = map(int, read().split())

ans = 0
if N >= 2:
    ans += N * (N - 1) // 2
if M >= 2:
    ans += M * (M - 1) // 2

print(ans)


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    string s;
    cin >> s;
    int year = stoi(s.substr(0,4)),month = stoi(s.substr(5,2)),day = stoi(s.substr(8,2));
    ll sum = (year *100 + month)*100 + day;
    if (sum <= 20190430) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }


    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  int n;
  cin >> n;
  int maybe = n/1.08;
  for (int i = -5; i < 5; i++){
    int ans = maybe + i;
    if (floor(ans*1.08) == n) {
      cout << ans << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

// compare function to sort vector<pair<int, int>> in descending order
bool compare(const pair<int, int>& p1, const pair<int, int>& p2) {
    return p1.second > p2.second;
}

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

    vector<int> v(n);
    for (int i = 0; i < n; ++i)
        cin >> v[i];

    const int MAX = 10e5 + 1;
    vector<pair<int, int>> a(MAX), b(MAX);
    for (int i = 0; i < MAX; ++i) {
        a[i] = make_pair(i, 0);
        b[i] = make_pair(i, 0);
    }

    for (int i = 0; i < n - 1; i += 2) {
        ++a[v[i]].second;
        ++b[v[i + 1]].second;
    }

    sort(a.begin(), a.end(), compare);
    sort(b.begin(), b.end(), compare);

    int count;
    int half = n / 2;
    if (a[0].first != b[0].first) {
        count = half - a[0].second;
        count += half - b[0].second;
    } else {
        int c1 = half - a[0].second;
        c1 += half - b[1].second;
        int c2 = half - a[1].second;
        c2 += half - b[0].second;
        count = min(c1, c2);
    }
    cout << count << '\n';
}


Measured memory_bytes: 16256
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<string.h>


using namespace std;
void insertionsort(int a[],int b);
int n;



int main()
{
	int a[101];
	while(cin>>n)
	{
	for(int i=0;i<n;i++)
		cin>>a[i];
	insertionsort(a,n);
	
	




	}
	
	


	
	
	
	



}
void insertionsort(int a[],int b)
{
	for(int i=0;i<b;i++)
		{
			int v=a[i];
		int j=i-1;
			while(j>=0&&a[j]>v)
				{
					a[j+1]=a[j];
					j--;}

						a[j+1]=v;
					for(int k=0;k<n;k++)
							{
								cout<<a[k];
					if(k!=n-1)
						cout<<" ";
					else
						cout<<endl;
					}




			
			
	}
	






}

Measured memory_bytes: 3100
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
from collections import Counter

n = int(input())
a = [int(item) for item in input().split()]
total = sum(a)
cnt = Counter(a)

q = int(input())
for _ in range(q):
    b, c = map(int, input().split())
    if b in cnt:
        total -= cnt[b] * b
        total += cnt[b] * c
        cnt[c] += cnt[b]
        cnt[b] = 0
    print(total)

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define inf 1000000100

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> student;
    vector<pair<int, int>> cp;
    vi answer(n);
    while(n--)
    {
        int a, b;
        cin >> a >> b;
        student.pb(make_pair(a, b));
    }
    while(m--)
    {
        int c, d;
        cin >> c >> d;
        cp.pb(make_pair(c, d));
    }
    for(int i = 0; i < student.size(); i++)
    {
        int mini = inf;
        for(int j = 0; j < cp.size(); j++)
        {
            if(min(mini, abs(student[i].first - cp[j].first)+abs(student[i].second - cp[j].second)) != mini)
            {
                mini = min(mini, abs(student[i].first - cp[j].first)+abs(student[i].second - cp[j].second));
                answer[i] = j+1;
            }
        }
    }

    for(int i = 0; i < answer.size(); i++)
    {
        cout << answer[i] << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int32_t main() {
	int n, total = 0; cin>>n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin>>a[i];
		total += a[i];
	}
	int ans = INT_MAX, sum = 0;
	for(int i = 0; i < n; i++){
		sum += a[i];
		ans = min(ans, abs(sum - (total - sum)));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
N = ri()
print('ABC' if N < 1000 else 'ABD')

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

const int N = 200010; 

using namespace std;

multiset< int > s; 
multiset< int > :: iterator it; 

int n, m, d[N], t[N];

int main() {

	scanf("%d", &n);
	for(int i=1; i<=n; ++i) scanf("%d", &d[i]);	
	scanf("%d", &m);
	for(int i=1; i<=m; ++i) scanf("%d", &t[i]), s.insert(t[i]);

	for(int i=1; i<=n; ++i) {
		it = s.find(d[i]);
		if(it != s.end()) s.erase(it); 
	}

	if(s.empty()) printf("YES\n");
	else printf("NO\n"); 

	return 0; 

}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,k;
int main(){
	cin>>a>>b>>c>>k;
	if (k<=a)
		cout<<k<<endl;
	else if (k<=a+b)
		cout<<a<<endl;
	else
		cout<<a-(k-a-b);
	return 0;
}

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

using namespace std;
const long long MOD = 1e9+7;
int n,a[25][25],pos[25];
long long ans=0,f[25][1<<22];
void trau()
{
    for(int i=1;i<=n;i++) pos[i]=i;
    do
    {
        bool ok=true;
        for(int i=1;i<=n;i++)
            if (!a[i][pos[i]])
                ok=false;
        ans+=(int)ok;
        if (ans>MOD) ans-=MOD;
    }while (next_permutation(pos+1,pos+n+1));
    cout<<ans;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            cin>>a[i][j];
    //trau();
    memset(f,-1,sizeof(f));
    f[0][0]=1;
    for(int mask = 0; mask< (1<<n); mask++)
    {
        for(int i=1;i<=n;i++)
        {
            if (f[i-1][mask]==-1) continue;
            for(int j=1;j<=n;j++)
                if (a[i][j] && !(mask & (1<<(j-1))))
                    if (f[i][mask | (1<<(j-1))]==-1)
                        f[i][mask | (1<<(j-1))]=f[i-1][mask]%MOD;
                    else
                    {
                        f[i][mask | (1<<(j-1))]+=f[i-1][mask];
                        f[i][mask | (1<<(j-1))]%=MOD;
                    }

        }
    }
    if (f[n][(1<<n)-1]==-1) cout<<0;
    else   cout<<f[n][(1<<n)-1];
    return 0;
}


Measured memory_bytes: 819584
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define YES(n) cout << (n?"YES":"NO")<<endl;
#define Yes(n) cout << (n?"Yes":"No")<<endl;

int main() {
    string s, t;
    cin >> s >> t;
    YES(s[0] == t[2] && s[1] == t[1] && s[2] == t[0]);
}

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

int main() {
 string s, t;
 cin >> s >> t;
  
 sort(s.begin(), s.end());
 sort(t.begin(), t.end());
 reverse(t.begin(), t.end());
  
   if( s < t ) cout << "Yes" << endl;
   else cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  string s;
  cin >> s;
  int cnt = 0;
  REP(i,s.size()){
    if(s.at(i)=='1'){
      cnt++;
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 3612
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    bool ok = true;
    ll N = S.size();
    if(N % 2 == 1){
        print("No");
        return 0;
    }
    rep(i,0,N/2){
        if(S[2*i] == 'h' && S[2*i+1] == 'i'){
            
        }else{
            ok = false;
        }
    }
    if(ok){
        print("Yes");
    }else{
        print("No");
    }
    

}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007

#+++++

def mk(a,b):
	if a == 0:
		return 0,1
	if b==0:
		return 1,0
		
	c = -1 if a < 0 else 1
	r = math.gcd(abs(a),abs(b))
	ra = (a //r)*c
	rb = (b //r)*c
	
	return ra, rb
	
def mh(a,b):
	return str(a)+'_'+str(b)
	
def mv(s):
	a,b = map(int, s.split('_'))
	return a,b
	
def ty(s):
	a, b = mv(s)
	sign = 1 if b > 0 else -1
	return mh(b*sign, -a*sign)
	

def main():
	n = int(input())
	dd = defaultdict(lambda : 0)
	zero_fish_num=0
	for _ in range(n):
		a,b=tin()
		if a== 0 and b == 0:
			zero_fish_num += 1
			continue
		a,b = mk(a,b)
		dd[mh(a,b)] += 1
		
	cc = set()
	ret = 1
	for k in dd:
		if k in cc:
			continue
		v = dd[k]
		if ty(k) in dd:
			tv = dd[ty(k)]
			r = pow(2,v,mod)+pow(2,tv,mod)-1
			#pa((r,k, ty(k)))
			ret *= r
			ret %= mod
			cc.add(ty(k))
		else:
			#pa(('v',v,k, ty(k)))
			ret *= pow(2,v,mod)
			ret %= mod
			
	ret -= 1
	ret += zero_fish_num
	ret %= mod
	print(ret) 
			
		
		
	#b , c = tin()
	#s = input()
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 135616
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << 0; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

vector <int> prefix_f(vector <int> & s) {
    int n = s.size();
    vector <int> ans(n);
    loop1(i, n - 1) {
        int j = ans[i - 1];
        while (j && s[i] != s[j])
            j = ans[j - 1];
        ans[i] = (s[i] == s[j] ? j + 1 : 0);
    }
    return ans;
}

void solve() {
    int n; cin >> n;
    vector <int> a(n), b(n), ax, bx;
    loop(i, n) {
        cin >> a[i];
        if (i)
            ax.pb(a[i] ^ a[i - 1]);
    }
    loop(i, n) {
        cin >> b[i];
        if (i)
            bx.pb(b[i] ^ b[i - 1]);
    }
    ax.pb(a[n - 1] ^ a[0]);
    bx.pb(b[n - 1] ^ b[0]);
    /*for (int x : ax)
        cout << x << " ";
    cout << "\n";
    for (int x : bx)
        cout << x << " ";
    cout << "\n";*/
    loop(i, n)
        bx.pb(bx[i]);
    ax.pb(-1);
    for (int x : bx)
        ax.pb(x);
    vector <int> pf = prefix_f(ax), ans;
    loop(i, pf.size())
        if (pf[i] == n)
            ans.pb((3 * n - i) % n);
    sort(all(ans));
    ans.resize(unique(all(ans)) - ans.begin());
    b.pb(b[0]);
    for (int i : ans)
        cout << i << " " << (a[0] ^ b[n - i]) << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 24060
n,y = map(int,input().split())

for i in range(n+1):
    for j in range(n-i+1):
        k = n-i-j
        if i+j+k == n and i*10000 + j*5000 + k*1000 ==y:
            print(i,j,k)
            quit()
print(-1,-1,-1)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>

using namespace std;

int getint()
{
    char ch=getchar();
    int f=1,x=0;
    while(!isdigit(ch)){if(ch=='-') f=-1; ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0'; ch=getchar();}
    return f*x;
}

const int N=3030;
const int MOD=1000000007;

int n,m;
long long f[N][N][2];

void upd(long long &a,long long b)
{
    a=(a+b)%MOD;
}

void init()
{
    n=getint(),m=getint();
    for(int i=1; i<=n; i++){
        f[0][i][0]=1;
    }
    f[0][0][1]=1;
}

int main()
{
    init();
    for(int i=1; i<=m; i++){
        for(int j=0; j<=n; j++){
            if(j+1>1) upd(f[i][j][0],f[i-1][j+1][0]);
            if(j>1) upd(f[i][j][0],f[i-1][j][0]);
            if(j<n) upd(f[i][j][0],f[i-1][j][0]);
            if(j-1<n) upd(f[i][j][0],f[i-1][j-1][0]);

            if(j+1>0) upd(f[i][j][1],f[i-1][j+1][1]);
            if(j>0) upd(f[i][j][1],f[i-1][j][1]);
            if(j<n) upd(f[i][j][1],f[i-1][j][1]);
            if(j-1<n) upd(f[i][j][1],f[i-1][j-1][1]);

            if(j+1==1) upd(f[i][j][1],f[i-1][j+1][0]);
            if(j==1) upd(f[i][j][1],f[i-1][j][0]);
            //if(j==n-1) upd(f[i][j][1],f[i-1][j][0]);
            //if(j-1==n-1) upd(f[i][j][1],f[i-1][j-1][0]);
        }
    }
    long long ans=0;
    for(int i=0; i<=n; i++){
        upd(ans,f[m][i][1]);
    }
    printf("%d\n",(int)ans);
    return 0;
}


Measured memory_bytes: 143488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<vector<pair<ll, ll>>> g(n);
    rep(i, n - 1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(make_pair(b, i));
        g[b].push_back(make_pair(a, i));
    }
    queue<ll> q;
    q.push(0);
    vector<ll> ans(n - 1, -1);
    while(!q.empty()) {
        ll v = q.front(); q.pop();
        set<ll> used;
        for(auto u : g[v]) {
            if (ans[u.second] != -1) {
                used.insert(ans[u.second]);
            }
        }
        ll cv = 0;
        for(auto u : g[v]) {
            if (ans[u.second] == -1) {
                while(used.count(cv) > 0) {
                    cv++;
                }
                ans[u.second] = cv;
                used.insert(cv);
                q.push(u.first);
            }
        }
    }
    cout << (*max_element(all(ans)) + 1) << endl;
    rep(i, n - 1) cout << (ans[i] + 1) << endl;
    return 0;
}


Measured memory_bytes: 8832
import math

NUM = input().split()

A = float(NUM[0])
B = float(NUM[1])
H = float(NUM[2])
M = float(NUM[3])

rad_A = H * 2*math.pi / 12. + M * 2*math.pi / 12. / 60.
rad_B = M * 2*math.pi / 60.

X_A = A * math.cos(rad_A)
Y_A = A * math.sin(rad_A)
X_B = B * math.cos(rad_B)
Y_B = B * math.sin(rad_B)

D = math.sqrt((X_A - X_B)**2. + (Y_A - Y_B)**2.)

print(D)

Measured memory_bytes: 9408
n,q=map(int,input().split())
s=input()
f=[0,0]
g=[0]
x=0
for i in range(n-1):
  if s[i:i+2]=='AC':
    x+=1
  f.append(x)
  g.append(x)
g.append(x)
for i in range(q):
  l,r=map(int,input().split())
  print(f[r]-g[l-1])


Measured memory_bytes: 6968
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		if(d==25) {
			System.out.println("Christmas");
		}
		if(d==24) {
			System.out.println("Christmas Eve");
		}
		if(d==23) {
			System.out.println("Christmas Eve Eve");
		}
		if(d==22) {
			System.out.println("Christmas Eve Eve Eve");
		}
	}
}

Measured memory_bytes: 21204
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()

res = n
for i in range(n+1):
    cash = 0
    t = i
    while t > 0: # 0 ~ iを6で表す
        cash += t % 6
        t //= 6
    t = n - i
    while t > 0: # n-i ~ nを9で表す
        cash += t % 9
        t //= 9
    if res > cash: # cash最小値
        res = cash

print(res)

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var p = ReadArrayInt();
            var cnt = p[0] == 1 ? 1 : 0;
            if (p[0] == 1)
            {
                p[0] = p[1];
                p[1] = 1;
            }
            var chk = p[1];
            for (int i = 1; i < N - 1; i++)
            {
                if (p[i] == (i + 1))
                {
                    var tmp = p[i + 1];
                    p[i + 1] = p[i];
                    p[i] = tmp;
                    cnt++;
                }
            }
            if (p[N - 1] == N) cnt++;

            Console.WriteLine(cnt);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 18016
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

ll pow(ll a, ll b) {
	if (b == 0) return 1;
	ll d = pow(a, b / 2);
	ll z = 1;
	if (b % 2) z = a;
	return (((d * d) % MOD) * z) % MOD;
}
string s;
int main() {
	ios_base::sync_with_stdio(0);
	cin >> s;
	REP(i, 3) {
		REP(j, 3) {
			if (s[i] != s[j]) {
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int N = S.size();
  int cnt = 0;
  int prev = 0;
  int ans = 0;
  for (int i = 0; i < N; i++){
    if (S[i] == 'R'){
      cnt++;
    }
    if (S[i] == 'L'){
      cnt--;
    }
    if (cnt % 4 == 0){
      if (cnt == prev + 4){
        ans++;
      }
      prev = cnt;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3220
import collections

n = int(input())
mod = 10**9+7

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

d = collections.defaultdict(int)
for i in range(2,n+1):
    for j in factorization(i):
        d[j[0]] += j[1]

ans = 1
for v in d.values():
    ans *= (v+1)
print(ans%mod)

Measured memory_bytes: 9684
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in();
    vec t(n);
    int sum=0;
    rep(i,n)sum+=t[i]=in();
    int m=in();
    rep(i,m)cout<<sum-t[in()-1]+in()<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Dice {
	private int[] d = new int[6];
	
	public void setDice(int index, int dnum) {
		this.d[index] = dnum;
	}
	
	void diceroll(String direction) {
		char[] dire = direction.toCharArray();
		for (char c : dire) {
			rool(c);
		}
	}
	
	void printDiceTop() {
		System.out.println(this.d[0]);
	}
	
	private void rool(char di) {
		int temp = 0;
		temp = this.d[0];
		if (di == 'E') {
			this.d[0] = this.d[3];
			this.d[3] = this.d[5];
			this.d[5] = this.d[2];
			this.d[2] = temp;
		} else if (di == 'W') {
			this.d[0] = this.d[2];
			this.d[2] = this.d[5];
			this.d[5] = this.d[3];
			this.d[3] = temp;
		} else if (di == 'S') {
			this.d[0] = this.d[4];
			this.d[4] = this.d[5];
			this.d[5] = this.d[1];
			this.d[1] = temp;
		} else if (di == 'N') {
			this.d[0] = this.d[1];
			this.d[1] = this.d[5];
			this.d[5] = this.d[4];
			this.d[4] = temp;
		} else;
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		Dice dice = new Dice();
		for (int i = 0; i < 6; i++) {
			dice.setDice(i, scan.nextInt());
		}
		dice.diceroll(scan.next());
		dice.printDiceTop();
	}
}

Measured memory_bytes: 26388
// https://atcoder.jp/contests/abc151/tasks/abc151_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

vector<vector<int>> grid_bfs(vector<string> &s, char start,
                             const string &wall = "#") {
    const int vx[] = {0, 1, 0, -1}, vy[] = {1, 0, -1, 0};
    vector<vector<int>> min_cost(s.size(), vector<int>(s[0].size(), -1));
    queue<pair<int, int>> que;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < s[i].size(); j++) {
            if (s[i][j] == start) {
                que.emplace(i, j);
                min_cost[i][j] = 0;
            }
        }
    }
    while (!que.empty()) {
        auto p = que.front();
        que.pop();
        for (int i = 0; i < 4; i++) {
            int ny = p.first + vy[i], nx = p.second + vx[i];
            if (nx < 0 || ny < 0 || nx >= s[0].size() || ny >= s.size())
                continue;
            if (min_cost[ny][nx] != -1)
                continue;
            if (wall.find(s[ny][nx]) != string::npos)
                continue;
            min_cost[ny][nx] = min_cost[p.first][p.second] + 1;
            que.emplace(ny, nx);
        }
    }
    return min_cost;
}

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

    int h, w;
    cin >> h >> w;
    vector<string> vs(h);
    for (int i = 0; i < h; i++) {
        cin >> vs[i];
    }

    // 最大値を探す
    int maxv = 0;
    REP(i, h) REP(j, w) {
        if (vs[i][j] == '.') {
            vector<string> t = vs;
            t[i][j] = 'S';
            vector<vector<int>> ret = grid_bfs(t, 'S');
            for (auto &x : ret) {
                for (auto &y : x) {
                    maxv = max(maxv, y);
                }
            }
        }
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/
bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

bool pairCompare2(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}

int main() {
    ll N;
    cin>>N;
    vector<P> X(N);
    REP(i,N){
        ll x;
        cin>>x;
        X[i]=P{i,x};
    }
    sort(X.begin(),X.end(),pairCompare);
    ll med2=X[N/2-1].second;
    ll med1=X[N/2].second;
    vector<P> ans(N);
    REP(i,N){
        if(i<N/2)
            ans[i]=P{X[i].first,med1};
        else
            ans[i]=P{X[i].first,med2};
    }
    sort(ans.begin(),ans.end(),pairCompare2);
    REP(i,N){
        cout<<ans[i].second<<endl;
    }
    return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
int main() {
    int d = 100000;
    int n; cin >> n;
    for(int i = 0 ; i < n ; i++){
        d = d * 105 / 100;
        if( d % 1000 > 0 ) d += 1000 - d % 1000;
    }
    cout << d << endl;
}


Measured memory_bytes: 3000
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


using namespace std;

// vector<vector<int>> mat(N, vector<int>(M, 0));

int main(int argc, const char *argv[])
{
    //
    int N,D;
    cin>>N>>D;
    vector<vector<int>> mat(N, vector<int>(D, 0));

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < D; j++)
        {
            cin>>mat[i][j];
        }
    }

    double distance = 0;
    int i_d = 0;
    int sum = 0;
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if(i != j)
            {
                sum = 0;
                for (int k = 0; k < D; k++)
                {
                    sum +=pow(mat[i][k]-mat[j][k],2);
                }
                distance = sqrt(double(sum));
                i_d = int(distance);
                if((distance - double(i_d)) == 0)
                {
                    count++;
                }
            }
        }
    }
    count = count/2;

    cout<<count;
    

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
struct Node {
	int key;
	Node *l, *r, *p;
};
Node *root, *NIL; 
inline void pre(Node *u) {

	cout << " " << u->key;
	if (u->l != NIL) pre(u->l);
	if (u->r != NIL) pre(u->r);
}
inline void in(Node* u) {
	if(u->l != NIL)in(u->l);
	cout << " " << u->key;
	if (u->r != NIL) in(u->r);

}
inline void insert(int k) {
	Node *x = root;
	Node *y = NIL;
	Node *z;
	int cnt = 0;
	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->l = NIL;
	z->r = NIL;
	while (x != NIL) {
		y = x;
		if (x->key > z->key)
			x = x->l;
		else
			x = x->r;
	}
	z->p = y;
	if (y == NIL) {
		root = z;
	}
	else if (y->key > z->key) {
		y->l = z;
	}
	else if (y->key < z->key) {
		y->r = z;
	}
}
int main(){
	int m;
	cin >> m;
	string com;
	int n;
	for (int i = 0; i < m; i++) {
		cin >> com;
		if (com == "insert") {
			scanf("%d", &n);
			insert(n);
		}
		else {
			in(root);
			cout << endl;
			pre(root);
			cout << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 26684
#include <iostream>

int sumOfIntegers(int min, int num, int sum);

int main()
{
    int num, sum;

    while (true) {
        std::cin >> num >> sum;

        if (num == 0 && sum == 0) {
            break;
        }

        std::cout << sumOfIntegers(0, num, sum) << std::endl;
    }

    return 0;
}

int sumOfIntegers(int min, int num, int sum)
{
    if (min > sum || min > 9 || num == 0) {
        return 0;
    }

    if (min == sum && num == 1) {
        return 1;
    }

    return (sumOfIntegers(min + 1, num, sum) + sumOfIntegers(min + 1, num - 1, sum - min));
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, ye = 0, ye2 = 0;
    cin >> n;
    for(int i = 0; i < n; ++i){
        long long x;
        cin >> x;
        if (x%4 ==0){
            ye++;
        } else if (x%2 == 0){
            ye2++;
        }
    }
    if (ye >= n/2){
        cout <<"Yes\n";
    } else {
        n = n - ye2;
        if (ye >= (n+1)/2){
            cout<<"Yes\n";
        } else {
            cout  << "No\n";
        }
    }
}

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

const int N=5;

int n,m,s,c,dp[N];
bool ok=true;

int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++) dp[i]=-1;
	while(m--)
	{
		cin>>s>>c;
		if(dp[s]==-1) dp[s]=c;
		else if(dp[s]!=c) ok=false;
	}
	if(dp[1]!=-1)
	{
		if(dp[1]==0 and n>1) ok=false;
	}
	if(dp[1]==-1)
	{
		if(n==1) dp[1]=0;
		else dp[1]=1;
	}
	for(int i=1;i<=n;i++)
		if(dp[i]==-1) dp[i]=0;

	if(ok)
	{
		for(int i=1;i<=n;i++) cout<<dp[i];
	}
	else cout<<"-1";
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    graph = [[[] for _ in range(N)] for _ in range(N)]
    path = [[0 for _ in range(N)] for _ in range(N)]
    for i in range(N):
        A = list(map(int, input().split()))
        for n in range(1, N-1):
            a, b = min(i, A[n]-1), max(i, A[n]-1)
            c, d = min(i, A[n-1]-1), max(i, A[n-1]-1)
            graph[c][d].append((a, b))
            path[a][b] += 1

    q = []
    for i in range(N-1):
        for j in range(i+1, N):
            if path[i][j] == 0:
                q.append((i, j))

    checked = [[False for _ in range(N)] for _ in range(N)]
    for i, j in q:
        checked[i][j] = True

    c = 0
    while q:
        c += 1
        qq = []
        for x, y in q:
            for nx, ny in graph[x][y]:
                path[nx][ny] -= 1
                if path[nx][ny] == 0:
                    checked[nx][ny] = True
                    qq.append((nx, ny))
        q = qq

    ok = True
    for i in range(N-1):
        for j in range(i+1, N):
            if not checked[i][j]:
                ok = False


    if not ok:
        print(-1)
    else:
        print(c)


if __name__ == "__main__":
    main()

Measured memory_bytes: 136584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
 
	double rate, maxrate=-1.0;
	int water,sugar,maxsugar;
	int x,y;
	for(int i=0; i*a*100<=f; i++) {
		for(int j=0; j*b*100<=f; j++) {
			water=i*a*100+j*b*100;
			maxsugar=(i*a+j*b)*e;
			for(int k=0; k*c<=maxsugar; k++) {
				for(int l=0; l*d<=maxsugar; l++) {
					sugar=k*c+l*d;
					if((water+sugar)==0) continue;
					else rate=(double)100*sugar/(water+sugar);
					if(maxrate<rate&&sugar<=maxsugar&&water+sugar<=f) {
						maxrate=rate;
						x=water;
						y=sugar;
					}
				}
			}
		}
	}
	
	cout<<x+y<<' '<<y<<endl;
 
	return 0;
}


Measured memory_bytes: 256
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

void solve()
{
    IN(a, b, k);
    if (k <= a)
    {
        cout << a-k << " " << b << endl;
    }
    else
    {
        cout << "0 " << max(b-(k-a), 0LL) << endl;
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int N = Integer.parseInt(str[0]);
		int W = Integer.parseInt(str[1]);

		int w[] = new int[110];
		int v[] = new int[110];

		for (int i = 0; i < N; i++) {
			str = br.readLine().split(" ");
			w[i] = Integer.parseInt(str[0]);
			v[i] = Integer.parseInt(str[1]);
		}

		long dp[][] = new long[110][100100];
		for (int i = 0; i < 110; i++) {
			for (int j = 0; j < 100100; j++) {
				dp[i][j] = Integer.MAX_VALUE;
			}
		}

		dp[0][0] = 0;

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 100100; j++) {
				if (j - v[i] >= 0)
					dp[i + 1][j] = Math.min(dp[i][j], dp[i][j - v[i]] + w[i]);

				dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j]);
			}
		}

		int ans = 0;
		for (int i = 0; i < 100100; i++) {
			if (dp[N][i] <= W) {
				ans = i;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 128852
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXW = 16, W = 0, O = 1, J = 2;

int tile[MAXW][MAXW+ 5];
int dp[MAXW][MAXW];
int dx[3] = {0, -1, 1};

int main()
{
    int x, y;
    while(cin >> x >> y && x)
    {
        memset(dp, 0, sizeof(dp));
        memset(tile, W, sizeof(tile));
        rep(j,y)rep(i,x) cin >> tile[i][j];
        rep(i,x){ if(tile[i][0] == W) dp[i][0] = 1; }

        rep(i,x)
            if(tile[i][1] == W)
            {rep(k,3)if(i+dx[k]>=0 && i+dx[k]<x && tile[i+dx[k]][0] == W)dp[i][1] += dp[i + dx[k]][0];}
            else if(tile[i][1] == J && tile[i][0] == W) dp[i][1] += dp[i][0];
        for(int j=2;j<y;j++)rep(i,x)
        {

            if(tile[i][j] == O){ continue;}
            if(tile[i][j] == J)
            {
                if(tile[i][j-1] == W) dp[i][j] += dp[i][j-1];
                if(tile[i][j-2] == J) dp[i][j] += dp[i][j-2];
                continue;
            }
            rep(k,3)if((i+dx[k]>=0 && i+dx[k]< x)&& tile[i+dx[k]][j-1] == W)
                dp[i][j] += dp[i+dx[k]][j-1];
            if(tile[i][j-2] == J) dp[i][j] += dp[i][j-2];

        }
        //rep(j,y) { rep(i,x) cout << dp[i][j] << "\t"; cout << endl;}

        int ans = 0;
        REP(x){ ans += dp[i][y-1] ; if(tile[i][y-2] ==J) ans+= dp[i][y-2];}
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  long a, b, c=0, d=0, e, f, g, h, m, n;
  bool q=false;
  cin >> n >> m;
  char x[n][n], y[m][m];
  rep(i,0,n){
    rep(j,0,n){
      cin >> x[i][j];
    }
  }
  
  rep(i,0,m){
    rep(j,0,m){
      cin >> y[i][j];
    }
  }
  
  rep(i,0,n-m+1){
    rep(j,0,n-m+1){
      rep(k,i,i+m){
        rep(l,j,j+m){
          if(x[k][l]==y[k-i][l-j]) c++;
        }
      }
      if(c==m*m) q=true;
      if(q==1) break;
      else c=0;
    }
    if(q==1) break;
  }
  
  if(q==1) co("Yes");
  else co("No");
    
  return 0;
}


Measured memory_bytes: 256
//#pragma  GCC optimize("Ofast")

//#ifdef  DEBUG
//#define _GLIBCXX_DEBUG
//#endif

// -Ofast
// -O3
// -O2
// -fsanitize=address
// -fsanitize=undefined

// add_compile_options()

#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include <iomanip>
#include <unordered_map>
#include <cmath>
#include <cassert>
#include <random>
using namespace std;
//using namesparsace __gnu_pbds;

mt19937 rnd;

void solve();

int main()
{
    srand(time(0));
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    solve();
    return 0;
}

#define int long long

int max(int a, int b) {
    return a > b ? a : b;
}

const int maxN = 2e5 + 10, inf = 2e18;

string s;

int f(int n) {
    int res = 0;
    while (n > 0) {
        res += n % 10;
        n /= 10;
    }
    return res;
}

void solve() {
    cin >> s;
    /*int u = 0;
    for (int i = 0; i < s.size(); i++) {
        u = u * 10 + s[i] - '0';
    }
    int mn = inf;
    int gi = 0;
    for (int i = u; i < 10000000; i++) {
        if (mn > f(i - u) + f(i)) {
            mn = f(i - u) + f(i);
            gi = i;
        }
    }
    cout << gi << " " << mn << endl;*/
    int ans = 0;
    int e = 0;
    for (int i = s.size() - 1; i >= 0; i--) {
        if (s[i] > '5' || (s[i] == '5' && (e > 0 || (i > 0 && s[i - 1] >= '5'))) || (s[i] == '4' && i > 0 && s[i - 1] >= '5' && e > 0)) {
            if (e == 0) e += 10 - (s[i] - '0');
            else e += 9 - (s[i] - '0');
        } else {
            ans += s[i] - '0';
            if (e > 0) {
                ans += e + 1;
                e = 0;
            }
        }
    }
    if (e > 0) {
        ans += e + 1;
    }
    cout << ans;
}

Measured memory_bytes: 1948
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    string s; cin >> s;
    if((s[0] == s[s.size() - 1]) == (s.size() % 2 == 0))
    cout << "First";
    else cout << "Second";
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 512