akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int r = Integer.parseInt(sc.next());
		int g = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		
		int n = Integer.parseInt(sc.next());
		
		long ans = 0;
		
		for(int i = 0 ; i * r <= 3000 ; i++) {
			for(int j = 0 ;j * g <= 3000 ; j++) {
				int temp = n - r*i - j*g;
				
				if(temp >= 0 && temp % b == 0) {
					ans++;
				}
			}
		}
		
		System.out.println(ans);

	}

}


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

int main(){
  int64_t A,B,N,ans;
  cin >> A >> B >> N;
  int64_t x;
  if(N < B - 1) x = N;
  else x = B - 1;
  ans = (A*(x % B) - (A * (x % B)) % B) / B;
  cout << ans << endl;
}


Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  
  int r = 0;
  for(int i=a;i<=b;i++){
    int s = i % 10 , t = i / 10000 % 10;
	int u = i / 10 % 10 , v = i / 1000 % 10; 
    if( s == t&&u == v) r++;
  }
  
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3") 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
#define __USE_MINGW_ANSI_STDIO 0
#include<bits/stdc++.h>                               
using namespace std;

#define PI acos(-1)
#define pb push_back
#define x first
#define y second
#define sz(a) (int)(a).size()
#define all(c) (c).begin(), (c).end()
#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi> vvi;
typedef vector <pii> vpii;
typedef vector<string> vs;

const int MAXN = 1e5 + 9;
const int MOD = (int)(1e9 + 7);
const int INF = 100500;

void input() {

}

void solve() {
	ll A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	ll ans = 0, sugar_ans = 0;
	pll coef(0, 1);
	for(ll a = 0; a < 1000; a++) {
		for(ll b = 0; b < ((F - A * a * 100) / (B * 100)) + 30; b++) {
			for(ll c = 0; c < ((F - 100 * A * a - 100 * B * b) / C) + 30; c++) {
				for(ll d = 0; d < ((F - 100 * A * a - 100 * B * b -  C * c) / D) + 30; d++) {
					ll X = 100 * A * a + 100 * B * b, Y = C * c + D * d;
					if(X + Y > F || Y * 100 > X * E) continue;
					pll cur_coef(100 * Y, X + Y);
					if(cur_coef.x * coef.y >= cur_coef.y * coef.x) {
						coef = cur_coef;
						ans = X + Y;
						sugar_ans = Y;
					}
				}
			}
		}
	}
	cout << ans << ' ' << sugar_ans << endl;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef LOCAL
	freopen("xxx.in", "r", stdin);
	freopen("xxx.out", "w", stdout);
#else
	//freopen("xxx.in", "r", stdin);
	//freopen("xxx.out", "w", stdout);
#endif	
	input();
	solve();
	TIMESTAMP;
	return 0;
}

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

using namespace std;

string s, t;

int ans, ss, ts, temp;

int main() {
	cin >> s >> t;
	ss = s.size();
	ts = t.size();
	ans = 10000;
	for (int i = 0; i < ss - ts + 1; i++) {
		temp = 0;
		for (int j = 0; j < ts; j++) {
			if (s[i + j] != t[j]) temp++;
		}
		ans = min(ans, temp);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3620
using System;

namespace question3
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Run();
        }

        void Run()
        {
            var s = Console.ReadLine();

            var a = 0;
            var b = 0;
            for (int i = 0; i < s.Length; i++)
            {
                var n = int.Parse(s.Substring(i,1));
                if (n != i % 2)
                {
                    a++;
                }
                if (n != (i + 1) % 2)
                {
                    b++;
                }
            }

            Console.WriteLine(Math.Min(a,b));
        }
    }
}


Measured memory_bytes: 13280
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ld A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
sc(n);
f1(i,n)sc(A[i]);
sort(A+1,A+1+n);
c=1;
ld aa=0;
fd(i,n,1){
	if(i>1)c*=2;	
	aa+=(ld)A[i]/c;
}
pr(aa);
	re 0;
	// Hack it if you can :)
}

int main(){
//	INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x,a = LI()
if x < a:
    print(0)
else:
    print(10)

Measured memory_bytes: 38384
# https://atcoder.jp/contests/abc063/tasks/arc075_b

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


N, A, B = read_ints()
H, = read_col(N)
H.sort(reverse=True)

# 操作回数をcとして決め打ち二分探索をする
# 満たす条件→すべての魔物を消し去る。その中で最小のcを探したい
# cが与えられたときにすべての魔物を消しされるかはどうやって求める？
# すべての魔物にc*Bダメージしたあとに、(A-B)ダメージをc回使うことで全滅箚せられればok


def is_ok(c):
    # 魔物を全滅させられればok
    bias = c * B
    addit = (A - B)
    c_cnt = c  # こいつは0になるまで使える
    for h in H:
        h -= bias
        if h <= 0:
            return True  # 全滅(早期終了)
        else:
            c_cnt -= (h - 1) // addit + 1
            if c_cnt < 0:  # 全滅させられない
                return False
    return True  # 全滅


def meguru_bisect(ng, ok):
    '''
    define is_okと
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok


print(meguru_bisect(-1, 10**9 + 1))


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  string s; cin >> s;
  int n = s.size();
  int l = -1, r = -1;
  for (int i = 0; i + 1 < n; ++i) {
    if (s[i] == s[i + 1]) {
      l = i + 1;
      r = i + 1 + 1;
      break;
    }
    else if (i + 2 < n and s[i] == s[i + 2]) {
      l = i + 1;
      r = i + 2 + 1;
      break;
    }
  }
  printf("%d %d\n", l, r);
  return 0;
}


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

int N;
string S;
int se[1000010], sw[1000010];


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

    //累積和se i番目までのEの個数(0 - N-1)
    if(S[0] == 'E'){
        se[0] = 1;
        sw[0] = 0;
    } else {
        se[0] = 0;
        sw[0] = 1;
    }

    for (int i = 1; i < N; i++)
    {
        if(S[i] == 'E') se[i] = se[i-1] + 1;
        else se[i] = se[i-1];

        if(S[i] == 'W') sw[i] = sw[i-1] + 1;
        else sw[i] = sw[i-1];
    }

    int mi = 1000000000;
    for (int i = 0; i < N; i++)
    {
        int cnt = 0;
        cnt += sw[i-1];
        cnt += (se[N-1] - se[i]);

        mi = min(mi,cnt);
    }

    cout << mi << endl;
    
}


Measured memory_bytes: 5892
#include <bits/stdc++.h>
using namespace std;
class Fenwick{
  valarray<int> data;
  int size;
public:
  Fenwick(){}
  Fenwick(int n) : size(n){ data.resize(size, 0);}
  void add(int k, int val){while(k < size){data[k] += val;k |= k + 1;}}
  int get(int k){int res = 0; while(k >= 0){ res += data[k]; k = (k&(k+1))-1; }return res;}
  int range(int l, int r){if(r == -1)r = size - 1;return get(r) - get(l - 1);}
};
int main(){
  int n;
  string s;
  cin>>n>>s;
  vector<Fenwick> tree(26, n);
  for(int i = 0; i < n; ++i){
    tree[s[i]-'a'].add(i, 1);
  }
  int q;
  cin>>q;
  while(q){
    int TYPE;
    cin>>TYPE;
    if(TYPE==1){
      int i;
      char c;
      cin>>i>>c;
      i--;
      if(s[i]!=c){
	tree[s[i]-'a'].add(i,-1); // l at location i remove.
	s[i] = c;
	tree[s[i]-'a'].add(i, 1); // x at location i add.
      }
    }
    else{
      int l, r;
      cin>>l>>r;
      l--, r--;
      int res = 0;
      for(int i = 0; i < 26; ++i){
	if(tree[i].range(l, r)){
	  res++;
	}
      }
      cout<<res<<endl;
    }
    q--;
  }
  return 0;
}


Measured memory_bytes: 53636
#include <iostream>

int main(){
    int m, d, w;
    int days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    char *weekName[7] = {"Sunday", "Monday", "Tuesday", "Wednesday",
                         "Thursday", "Friday", "Saturday"};
    while(1){
        std::cin >> m >> d;
        if(!(m || d)){
            return 0;
        }
        w = 3;
        for(int i = 1; i < m; i++){
            w += days[i - 1];
        }
        w += d; 
        std::cout << weekName[w % 7] << std::endl;
    }
}

Measured memory_bytes: 1156
#include<stdio.h>
#include<math.h>

/*
 array = ソートしたいデータ
 begin = 要素の最初
 end = 要素の末尾
*/
void QuickSort(int array[], int begin, int end)
{
 int i = begin;
 int j = end;
 int pivot;
 int temp;
   
 pivot = array[ ( begin + end ) / 2 ];  // 中央の値をpivotにする
  
 while( 1 )
 {
  while( array[i] < pivot ){ ++i; }  /* 枢軸以上の値が見つかるまで右方向へ進めていく */
  while( array[j] > pivot ){ --j; }  /* 枢軸以下の値が見つかるまで左方向へ進めていく */
  if( i >= j )break;  // 軸がぶつかったらソート終了
   
  // 入れ替え
  temp = array[i];
  array[i] = array[j];
  array[j] = temp;
  i++;
  j--;
 }
  
 // 軸の左側をソートする
 if( begin < i - 1 ){ QuickSort( array, begin, i - 1 ); }
 // 軸の右側をソートする
 if( j + 1 < end ){ QuickSort( array, j + 1, end ); }
}

int main(void){
	int array[1000]={0};
	int n;
	int min;
	int tmp;
	int i;
	while ( 1 ) {
		scanf("%d", &n);
		if ( !n ) {
			break;
		}
		for ( i = 0; i < n; i++ ) {
			scanf("%d", &array[i]);
		}
		QuickSort(array, 0, n-1);
		min = abs(array[0]-array[1]);
		for ( i = 2; i < n; i++ ) {
			tmp = abs(array[i]-array[i-1]);
			if ( min > tmp ) {
				min = tmp;
			}
		}
		printf("%d\n", min);
	}
	return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
	
	
class Hoge{
			
		int iN,iK;
		//string s0,s1,stemp;
		long double* pd;
		long double dsum;
		public:
			Hoge(int);
		void prob();
									
		virtual ~Hoge(){	
						delete [] pd;
						}
};


Hoge::Hoge(int i0){
							iN=0;
							cin>>iN>>iK;
							pd=new long double[iN];
						
				}//end Hoge
void Hoge::prob(){
	
		long double dp0;
		int icount=0;
		
		for(int idise=1;idise<iN+1;idise++){
		int ipoint=idise;
		dp0=1;
	//	cout<<idise<<endl;
		while(ipoint<iK){
			
				icount++;
				ipoint=ipoint*2;
				dp0=dp0*0.5;
			//	cout<<"ipoint="<<ipoint<<endl;
				
					
				}//while	
		//dp0=dp0*0.5;
		//cout<<"icount="<<icount<<endl;
		//cout<<"ipoint="<<idise<<endl;
	//	cout<<"dp0="<<dp0<<endl;
		pd[idise-1]=dp0/iN;
					}//endffor
					
	for(icount=0;icount<iN;icount++){
					dsum=dsum+pd[icount];
			}
			
			cout<<setprecision(16)<<dsum<<endl;
}//end func





int main()
{
	
	Hoge* ph0=new Hoge(0);
	//ph0->convert();
	ph0->prob();
	//ph0->input();
	//ph0->output(3);
	//ph0->output0(3);
	
	

	
	//cout<<ph0->getichange()<<endl;
	
	
	delete ph0;
	
	
}

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

int main() {
  int a, b;
  cin >> a >> b;
    int average = (a + b) / 2;
    int reminder = (a - b) % 2;
    if (reminder > 0) {
      cout << average + reminder << endl;
    }
    if (reminder <= 0 ) {
      cout << average - reminder << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	while(cin>>n,n){
		vector<ll>in(n);
		rep(i,n)cin>>in[i];
		sort(all(in));
		in.erase(in.end()-1);
		rep(i,n-1)in[i+1]+=in[i];
		ll sum=0;
		rep(i,n-1)sum+=in[i];
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 1296
import sys
from functools import lru_cache
def input(): return sys.stdin.readline().strip()


def main():
    n = input()
    ans = ""
    for i in n:
        if i == '1': ans += '9'
        if i == '9': ans += '1'
    print(int(ans))



if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#pragma warning(disable:4996) 

#include <algorithm>
#include <bitset>
// #include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <chrono>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr ll LL2_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = { { typeid(int), "%d" },
{ typeid(ll), "%lld" },
{ typeid(double), "%lf" },
{ typeid(char), "%c" } };

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
// static boost::dynamic_bitset<> scan(char trueValue = 'o');

vector<ll> prime_factor(ll n);

int main(int argc, char *argv[]) {
	 //INFILE();

	 int i, count = 0;
	cin >> i;
	vector<ll> v(i);
	scan(v);

	bool state = false;

	vector<bool> results(i);
	for (int j = 0; j < i; j++) {
		bool result;
		if (v[j] % 2 == 0)
		{
			state |= false;
		}
		else
		{
			state |= true;
		}
	}

	if (state) {
		cout << "first" << endl;
	}
	else {
		cout << "second" << endl;
	}
	return 0;
}

template <class T> static void scan(vector<T> &v) {
	auto tFormat = scanType[typeid(T)];
	for (T &n : v) {
		scanf(tFormat, &n);
	}
}

static void scan(vector<string> &v, bool isWord) {
	if (isWord) {
		for (auto &n : v) {
			cin >> n;
		}
		return;
	}

	int i = 0, size = static_cast<int>(v.size());
	string s;
	getline(cin, s);

	if (s.size() != 0) {
		i++;
		v[0] = s;
	}

	for (; i < size; ++i) {
		getline(cin, v[i]);
	}
}

//static boost::dynamic_bitset<> scan(char trueValue) {
//	string s;
//	getline(cin, s);
//
//	if (s.size() == 0) {
//		getline(cin, s);
//	}
//
//	for_each(begin(s), end(s),
//		[trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
//	return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
//}

vector<ll> prime_factor(ll n) {
	if (n <= 1) {
		return { n };
	}

	vector<ll> v;

	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			n /= i;
			v.push_back(i);
		}
	}

	if (n > 1) {
		v.push_back(n);
	}

	return v;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define Sort(vec) sort(vec.begin(),vec.end())
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define all(st) st.begin(),st.end()
#define vpll vector<pair<lli,lli>>
#define vpii vector<pair<int,int>>
#define al vector<list<int>>
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<lli>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ulli unsigned long long int
#define pb push_back
#define lli long long int
#define inf INT_MAX
#define minf INT_MIN
#define f first
#define se second
#define mod 1000000007
#define mx 200001
using namespace std;
void add_me(lli &a,lli b){
    a+=b;
    if(a>=mod) a-=mod;
}   
void sub_me(lli &a,lli b){
    a-=b;
    if(a<0) a+=mod;
}
struct disjointset{
    int parent[mx];
   	disjointset(){
        for(int i=1;i<mx;i++) parent[i]=i;
    }
    int find(int x){
      	int par=parent[x];
        if(par==x) return x;
        return find(parent[x]);
    }
    void union_(int x,int y){
   	    int par1=find(x);
     	int par2=find(y);
       	if(par1==par2) return;
       	parent[par2]=par1;
    }
};
lli mi(lli n,lli m){
	lli pw=n;
	lli ex=m-2;
	lli ans=1;
	while(ex){
		if(ex&1) ans = ans*pw%m;
		pw = pw*pw%m;
		ex>>=1;
	}
	return ans;
}
int main(){
	FIO;
	lli a,b,c;cin>>a>>b>>c;
	if(a>=c){
		cout<<a-c<<" "<<b<<endl;
	}
	else{
		b-=(c-a);
		if(b<0) cout<<"0 0"<<endl;
		else cout<<0<<" "<<b<<endl;
	}
	
	
	
	
	
}

Measured memory_bytes: 384
from bisect import bisect_left, bisect_right, insort_left
from collections import deque


class BinarySearchTree:
    def __init__(self, ls: list = []):
        '''
        C++でいうsetを実装する。二分探索木をガチで実装しようとすると大変なので、ここでは配列二分法を用いる。
        pythonの標準ライブラリがヨイショに抱っこしてくれるおかげで楽に実装できる。
        https://docs.python.org/ja/3/library/bisect.html


        ls ... 渡す初期配列
        '''
        self.bst = deque(sorted(ls))  # insertをO(1)にするためにlistの代わりにdequeを用います

    def __repr__(self):
        return f'BST:{self.bst}'

    def __len__(self):
        return len(self.bst)

    def __getitem__(self, idx):
        return self.bst[idx]

    def size(self):
        return len(self.bst)

    def insert(self, x):
        idx=self.bisect_left(x)
        self.bst.insert(idx ,x)

    def remove(self, x):
        '''
        xを取り除く。xがself.bstに存在することを保証してください。
        同一のものが存在した場合は左から消していく
        '''
        del self.bst[self.find(x)]

    def bisect_left(self, x):
        '''
        ソートされた順序を保ったまま x を self.bst に挿入できる点を探し当てます。
        lower_bound in C++
        '''
        return bisect_left(self.bst, x)

    def bisect_right(self, x):
        '''
        bisect_left() と似ていますが、 self.bst に含まれる x のうち、どのエントリーよりも後ろ(右)にくるような挿入点を返します。
        upper_bound in C++
        '''
        return bisect_right(self.bst, x)

    def find(self, x):
        '''
        xのidxを探索
        '''
        idx = bisect_left(self.bst, x)
        if idx != len(self.bst) and self.bst[idx] == x:
            return idx
        raise ValueError

    def insert_replace_right(self, x):
        '''
        xを挿入して、xの右の数字(次に大きい)を削除する。idxがはみ出す場合は挿入だけ
        '''
        idx_del = self.bisect_left(x) + 1
        if idx_del - 1 == len(self.bst):  # xがどの要素よりも大きい
            self.insert(x)
        else:
            self.insert(x)
            del self.bst[idx_del]


# load data
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))


L = BinarySearchTree()
L.insert(A[0])
length = 0
for a in A[1:]:
    L.insert_replace_right(a)
    # # もし最長増加部分列の中身が知りたいなら、新たに長さが更新されたときに最適であることが保証されている
    # if len(L) > length:
    #     length = len(L)
    #     LIS = L.bst

# print(LIS)
print(len(L))


Measured memory_bytes: 11476
#include<bits/stdc++.h>
	using namespace std;
	#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 mp make_pair
	#define pb push_back
	#define st first
	#define nd second
	#define sz(w) (int) w.size()
	#define MOD 1e9+7
	#define inf 1e9+9
	#define int long long
	#define ld long double
	#define fast  ios_base::sync_with_stdio(false);  cin.tie(NULL);
	typedef vector<int> vi;
	typedef pair<int,int> pii; 


	void solve(){
		int n; cin>>n;
		int arr[n];
		for(int i=0;i<n;i++) 
			cin>>arr[i];
		int dp[n+1];
		dp[0]=0;
		dp[1]=0;
		dp[2]=abs(arr[1]-arr[0]);
		FOR(i,3,n)	{
			dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i-2]), dp[i-2]+abs(arr[i-1]-arr[i-3]));
		}
		cout << dp[n] << endl;
	}


	int32_t main(){
		fast
		int t;
		// cin>>t;
		t=1;
		while(t--){
			solve();
		}
	}

Measured memory_bytes: 5208
#include<iostream>
using namespace std;
int main(){
string S;
  cin>>S;
  if(S=="SAT"){cout<<1;}
  else if (S=="SUN"){cout<<7;}
   else if (S=="MON"){cout<<6;}
   else if (S=="TUE"){cout<<5;}
   else if (S=="WED"){cout<<4;}
   else if (S=="THU"){cout<<3;}
   else if (S=="FRI"){cout<<2;}



 return 0;
}


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

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

	std::string S;
	S.reserve(N + 2);
	std::cin >> S;

	std::vector<int> counts;
	counts.reserve(N);

	{
		char prevBit = S[0];

		counts.emplace_back(0);
		for (char bit : S)
		{
			if (bit != prevBit)
			{
				counts.emplace_back(0);
			}

			counts.back()++;
			prevBit = bit;
		}
	}

	for (int i = 1; i < counts.size(); i++)
	{
		counts[i] += counts[i - 1];
	}

	int maxSum = 0;
	for (int index = 0; index < counts.size(); index++)
	{
		const int numElems = [&] {
			if ((S[0] == '0') ^ (index % 2 == 0))
			{
				return 2 * K + 1;
			}
			else
			{
				return 2 * K;

			}
		}();

		int sum = counts[std::min(index + numElems - 1, (int)counts.size() - 1)];
		if (index - 1 >= 0) { sum -= counts[index - 1]; }

		maxSum = std::max(maxSum, sum);
	}

	std::cout << maxSum << std::endl;
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define REP(i,n) for(int i=0;i<n;i++)
#define pb push_back


// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

int main(void) {
	// cin, coutの結びつきを解除し、速くする
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int n; cin >> n;
	cout << (n%2==0?n:2*n) << endl;



}



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 {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String[] line = br.readLine().split(" ");
      int[] arrayS = new int[n];
      int i=0;
      for (String val : line) {
        arrayS[i++] = Integer.parseInt(val);
      }

      MergeSort merge = new MergeSort(arrayS);
      int cnt = merge.mergeSort(0, n);

      merge.dispIntArray();
      System.out.println(cnt);
    }
  }
}

class MergeSort {

  static private final int SENTINEL = Integer.MAX_VALUE;

  private int[] target;
  private int[] bufL;
  private int[] bufR;

  public MergeSort(int[] target) {
    this.target = target;
    bufL = new int[target.length/2+2];
    bufR = new int[target.length/2+2];

  }

  public int mergeSort(int left, int right) {
    int cnt =0;

    if(left+1 < right){
      int mid = (left + right) / 2;
      cnt += mergeSort(left, mid);
      cnt += mergeSort(mid, right);
      cnt += merge(left, mid, right);
    }

    return cnt;
  }

  private int merge(int left, int mid, int right) {
    int cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    
    for(int i=0; i<n1; i++)
      bufL[i] = target[left+i];
    bufL[n1] = MergeSort.SENTINEL;

    for(int i=0; i<n2; i++)
      bufR[i] = target[mid+i];
    bufR[n2] = MergeSort.SENTINEL;

    for(int i=0,j=0,k=left; k<right; k++) {
      if(bufL[i] <= bufR[j])
        target[k] = bufL[i++];
      else
        target[k] = bufR[j++];
      cnt++;
    }

    return cnt;
  }

  public int[] getArray() {
    return target;
  }

  public void dispIntArray() {
    StringBuilder s = new StringBuilder();

    for (int i : target) { s.append(i).append(" "); }
    s.setLength(s.length()-1);

    System.out.println(s);
  }
}


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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;

#define N 100010
#define M 200010
#define endl "\n"
#define mod 1000000007 

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	double d, t, s;
	
	cin >> d >> t >> s;
	
	double x = d / s;
	
	if(t >= x) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
long Gcd(long m, long n){
	long temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}
int main(){
    long n,m;
    cin>>n>>m;
    string s,t;
    cin>>s>>t;
    long g = Gcd(n,m);
    g = (m*n)/g;
    if(m>n){
        swap(n,m);
        swap(s,t);
    }
    for(int i=0; i<m; i++){
        if((i*g/m)%(g/n)==0){
            if(t[i]!=s[i*g/m/(g/n)]){
                cout<<"-1";
                return 0;
            }
        }
    }
    cout<<g;
}

Measured memory_bytes: 512
#include <stdio.h>
 
int main(){
  char c[4096];
  int i=0,j;
  while(1){
    scanf("%c",&c[i]);
    if(c[i]=='\n'){
      break;
    }
    i++;
  }
  for(j=0; j<i; j++){
    if(c[j]>='A'&&c[j]<='Z')c[j]+=32;
    else if(c[j]>='a'&&c[j]<='z')c[j]-=32;
    printf("%c",c[j]);
    if(j==i-1)printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2044
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    long long n, m, k;
    cin >> n >> m >> k;

    vector<long long> a(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] += a[i - 1];
    }

    vector<long long> b(m + 1, 0);
    for (int i = 1; i <= m; i++) {
        cin >> b[i];
        b[i] += b[i - 1];
    }

    int res = 0;
    for (int i = 0; i <= n && a[i] <= k; i++) {
        vector<long long>::iterator j = upper_bound(b.begin(), b.end(), k - a[i]);
        if (j != b.begin()) {
            res = max(res, i + static_cast<int>(j - b.begin()) - 1);
        }
    }

    cout << res << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	string s;
	int p = 0;
	cin >> s;
	REP(i, 0, (int)s.size()){
		char c = s[i];
		if(c == 'B'){
			if(p != 0) --p;
		}
		else{
			s[p] = s[i];
			++p;
		}
	}
	REP(i, 0, p) cout << s[i];

}


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

int toNum(char a){
	if (a == 'I')		return 1;
	else if (a == 'V')	return 5;
	else if (a == 'X')	return 10;
	else if (a == 'L')	return 50;
	else if (a == 'C')	return 100;
	else if (a == 'D')	return 500;
	else if (a == 'M')	return 1000;
	else return 0;
}

int solve(string in){
	int ans = 0;
	for (int i = 0; i < in.length(); i++){
		int first = toNum(in[i]);
		int second = -1;
		if (i < in.length() - 1){
			second = toNum(in[i + 1]);
		}
		if (first < second){
			ans += (second - first);
			i++;
		}
		else{
			ans += first;
		}
	}

	return ans;
}

int main(){
	string in;

	while (cin >> in, !cin.eof()){
		cout << solve(in) << endl;
	}

	return 0;
}

Measured memory_bytes: 1184
#入力dataの格納
input_list = list(map(str, input().split()))

#計算
i = 0
while len(input_list) > 1:
    if input_list[i] == "+":
        input_list.insert(i+1, int(input_list[i-2]) + int(input_list[i-1]))
        del input_list[i-2: i+1]
        i = 0
    elif input_list[i] == "-":
        input_list.insert(i+1, int(input_list[i-2]) - int(input_list[i-1]))
        del input_list[i-2: i+1]
        i = 0
    elif input_list[i] == "*":
        input_list.insert(i+1, int(input_list[i-2]) * int(input_list[i-1]))
        del input_list[i-2: i+1]
        i = 0
    i += 1

#計算結果の表示
print(input_list[-1])



Measured memory_bytes: 5600
#include<bits/stdc++.h>
        #define F first
        #define S second
        using ll = long long;
        const ll mod = 1000000007;
        const ll infi = 1000000000000000;
        const ll md = 998244353;
        using namespace std;
        using vl = vector<ll>;
        using pll =  pair<ll,ll>;
        
       
        void solve(){
           int n;
           cin>>n;
           string s;
           cin>>s;
           set<string> ss;
           vector<set<char>> pre(n),suf(n);
           pre[0].insert(s[0]);
           for(int i=1;i<n;i++){
               pre[i] = pre[i-1];
               pre[i].insert(s[i]);
           }
           suf[n-1].insert(s[n-1]);
           for(int i= n-2;i>=0;i--){
               suf[i] =suf[i+1];
               suf[i].insert(s[i]);
           }
           string temp = "333";
           for(int i=1;i<n-1;i++){
               for(auto it = pre[i-1].begin();it!=pre[i-1].end();it++){
                   for(auto it1 = suf[i+1].begin();it1!=suf[i+1].end();it1++){
                       temp[1] = s[i];
                       temp[2] = *it1;
                       temp[0] = *it;
                       ss.insert(temp);
                   }
               }
           }
           cout<<ss.size();
        }
        
        int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
            solve();
            return 0;
        } 

Measured memory_bytes: 31360
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = max(x, y) * c * 2;
    if(x < y){
    	ans = min(ans, x * c * 2 + (y - x) * b);
    }else{
    	ans = min(ans, y * c * 2 + (x - y) * a);
    }
    ans = min(ans, a * x + b * y);
    cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()
#define fst first
#define sec second
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef pair<long,long> P;

const int mod = 1e9 + 7;


int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

	int a, b;
	cin >> a >> b;
	int ans = 1;
	int res = a;
	if(b==1){
		cout << 0 << endl;
		return 0;
	}

	while(res < b){
		ans++;
		res--;
		res += a;
	}


	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
	int lin=0;
	int m,n;
	int summ=0;
	int sumn=0;
	while(scanf("%d,%d",&m,&n)!=EOF){
		summ += m*n;
		sumn += n;
		lin++;
	}
	cout << summ << endl;
	cout << (int)((double)sumn/lin+0.5) << endl;
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
int g[31][31];
int t[3][31];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++)for(int j=0;j<b;j++){
		scanf("%d",&g[i][j]);
	}
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		int p;scanf("%d",&p);
		p--;
		t[(i+j)%3][p]++;
	}
	int ret=mod;
	for(int i=0;i<b;i++)for(int j=0;j<b;j++)for(int k=0;k<b;k++){
		if(i==j||j==k||k==i)continue;
		int tmp=0;
		for(int l=0;l<b;l++){
			tmp+=t[0][l]*g[l][i];
			tmp+=t[1][l]*g[l][j];
			tmp+=t[2][l]*g[l][k];
			
		}
		ret=min(ret,tmp);
	}
	printf("%d\n",ret);
}


Measured memory_bytes: 128
void main()
{
    long n = rdElem;

    long[][] lists = new long[][](10, 10);
    foreach (i; 1 .. n+1)
    {
        long f = i;
        long b = f % 10;
        while (f > 9) f /= 10;
        ++lists[f][b];
    }

    long result;
    foreach (i; 0 .. 10)
    {
        foreach (j; 0 .. 10)
        {
            result += lists[i][j] * lists[j][i];
        }
    }

    result.writeln;
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
from math import sqrt
from collections import defaultdict
N = int(input())
divisors = []
ans = 0

for i in range(1, int(sqrt(N))+1):
    if N % i == 0:

        if i ** 2 != N:
            divisors.append(i)
            divisors.append(int(N/i))

        else:
            divisors.append(i)

for div in divisors[1:]:
    d = int(N//(div-1))
    
    if d == N - d * (div-1):
        ans += div-1
        
print(ans)

Measured memory_bytes: 3564
import java.util.*;

public class Main {
	public static void main(String[] args) {  
  		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
      	String[] ary = line.split(" ", 0);
      	Arrays.sort(ary, Collections.reverseOrder());
      	System.out.println(Integer.parseInt(
          ary[0] + ary[1]) + Integer.parseInt(ary[2]));
    }
}

Measured memory_bytes: 21332
// g++ temp.cpp
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <sstream>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3

#define MAX_N 1000

namespace patch
{
    template < typename T > std::string to_string( const T& n )
	{
		std::ostringstream stm ;
		stm << n ;
		return stm.str() ;
	}
}

int W,H,N;
int X1[1000],X2[1000],Y1[1000],Y2[1000];

bool fld[1000*6][1000*6];

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

int compress(int *x1,int *x2, int w){
	vector<int> xs;

	REP(i,N){
		for(int d=-1;d<=1;d++){
			int tx1=x1[i]+d, tx2=x2[i]+d;
			if(0<=tx1&&tx1<w) xs.push_back(tx1);
			if(0<=tx2&&tx2<w) xs.push_back(tx2);
		}
	}
	sort(all(xs));
	xs.erase(unique(xs.begin(),xs.end()),xs.end());

	REP(i,N){
		x1[i]=find(all(xs),x1[i])-xs.begin();
		x2[i]=find(all(xs),x2[i])-xs.begin();
	}
	return xs.size();
}

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>W>>H;
		if(W==0&&H==0) break;
		cin>>N;
		REP(i,N)cin>>X1[i]>>Y1[i]>>X2[i]>>Y2[i];
		W=compress(X1,X2,W);
		H=compress(Y1,Y2,H);
		memset(fld,0,sizeof(fld));
		REP(i,N){
			for(int y=Y1[i];y<Y2[i];y++){
				for(int x=X1[i];x<X2[i];x++){
					fld[y][x]=true;
				}
			}
		}
		//cout<<endl;
		//REP(y,H)REP(x,W) printf("%d%c", fld[y][x],(x==W-1?'\n':' '));

		int ans=0;
		REP(y,H)REP(x,W){
			if(fld[y][x]) continue;
			ans++;

			queue<P> que;
			que.push(mp(x,y));
			while(!que.empty()){
				int sx=que.front().first, sy=que.front().second;
				que.pop();
				REP(i,4){
					int tx=sx+dx[i], ty=sy+dy[i];
					if(tx<0||W<=tx||ty<0||H<=ty) continue;
					if(fld[ty][tx]) continue;
					que.push(mp(tx,ty));
					fld[ty][tx]=true;
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 38488
A, B, Q = map(int, input().split())
S = [-10**12]
for _ in range(A):
    S.append(int(input()))
S.append(10**12)
T = [-10**12]
for _ in range(B):
    T.append(int(input()))
T.append(10**12)
X = []
for _ in range(Q):
    X.append(int(input()))

import bisect
for x in X:
    i = bisect.bisect_left(S, x)
    ls, rs = abs(S[i-1]-x), abs(S[i]-x)
    j = bisect.bisect_left(T, x)
    lt, rt = abs(T[j-1]-x), abs(T[j]-x)
    result = min(max(lt, ls), max(rt, rs),
                 rt + 2*ls, ls + 2*rt,
                 rs + 2*lt, lt + 2*rs)
    print(result)

Measured memory_bytes: 16144
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9 + 7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};



int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
 
  
 
     string a,b,sa="",sb="";
     cin>>a>>b; 
     int xa=stoi(a),xb=stoi(b);
     for(int i=0;i<xb;i++)
     sa+=a;

     for(int i=0;i<xa;i++)sb+=b;
     cout<<min(sa,sb)<<"\n"; 
  
}


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

int main()
{
	while (true)
	{
		int count = 0;
		int ax[10000][3] = { 0 };
		int ai = 0;
		int n, x;
		cin >> n >> x;
		if (n == 0 && x == 0) break;
		else
		{
			for (int i = 1; i <= n; i++)
			{
				for (int j = 1; j <= n; j++)
				{
					if (i != j)
					{
						for (int k = 1; k <= n; k++)
						{
							if (i != k && j != k && i + j + k == x)
							{
								//cout << i << " " << j << " " << k << endl;
								int i2 = i;
								int j2 = j;
								int k2 = k;
								if (i2 > j2)
								{
									i2 = j;
									j2 = i;
								}
								if (j2 > k2)
								{
									k2 = j2;
									j2 = k;
								}
								if (i2 > j2)
								{
									int i3 = i2;
									i2 = j2;
									j2 = i3;
								}
								if (j2 > k2)
								{
									int k3 = k2;
									k2 = j2;
									j2 = k3;
								}
								bool is = true;
								for (int c = 0; c < 10000; c++)
								{
									if (ax[c][0] == i2 && ax[c][1] == j2 && ax[c][2] == k2)
									{
										is = false;
									}
								}
								if (is)
								{
									ax[ai][0] = i2;
									ax[ai][1] = j2;
									ax[ai][2] = k2;
									ai++;
									count++;
									//cout << i2 << " " << j2 << " " << k2 << endl;
								}
							}
						}
					}
				}
			}
		}
		cout << count << endl;
	}
}


Measured memory_bytes: 3212
A, B, C, X, Y = map(int, input().split())

least_price = float("inf")
less_list = sorted([X, Y])

for i in range(less_list[1]+1):
    num_A = X- i
    num_B = Y - i
    
    if num_A <= 0 :
        num_A = 0
    if num_B <= 0:
        num_B = 0

    total_price = C * 2*i +  A * num_A + B * num_B
    if least_price > total_price:
            least_price = total_price
    else:
        pass

print(least_price)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
char c[10][10] = {};

void view(){
	for(int i = 0 ; i < 8 ; i++){
		for(int j = 0 ; j < 8 ; j++)
			cout << c[i][j];
		cout << endl;
	}
}
int main(){
	for(int i = 0 ; i < 8 ; i++)
		for(int j = 0 ; j < 8 ; j++)
			cin >> c[i][j];
	for(int i = 1 ; i <= 3 ; i++){
		cout << i * 90 << endl;
		for(int j = 0 ; j < 8 ; j++)
			for(int k = j+1 ; k < 8 ; k++)
				swap(c[j][k],c[k][j]);
		for(int j = 0 ; j < 8 ; j++){
			for(int k = 0 ; k < 4 ; k++)
				swap(c[j][k],c[j][7-k]);
		}
		view();
	}
	
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
using namespace std;
int main(){
    #define int long long
    int n,m;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n,greater<int>());
    int wa[n+1];
    wa[0]=0;
    for(int i=1;i<=n;i++)wa[i]=wa[i-1]+a[i-1];
    int l=0,r=200001;//幸福度がx以上となる握手をm回出来るか？ l:出来る,r:出来ない
    while(r-l>1){
        int mid=(l+r)/2;
        int shake=0;
        for(int i=0;i<n;i++)shake+=upper_bound(a,a+n,mid-a[i],greater<int>())-a;
        if(shake>=m)l=mid;
        else r=mid;
    }
    int ans=0,shake=0;
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>q;
    for(int i=0;i<n;i++){
        int low=lower_bound(a,a+n,l-a[i],greater<int>())-a,up=upper_bound(a,a+n,l-a[i],greater<int>())-a;
        ans+=a[i]*up+wa[up];
        shake+=up;
        q.push({a[i]+a[low],up-low});
    }
    m=shake-m;
    while(m>0){
        ans-=q.top().first*min(m,q.top().second);
        m-=q.top().second;
        q.pop();
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6880
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define MAXCHAR 255

using namespace std;

vector<int> Height;
vector<vector<int>> NeighborIndexVector;
vector<int> output;

int main()
{
	int N = 0;
	int M = 0;
	cin >> N >> M;

	for (int i = 0; i < N; i++)
	{
		int input = 0;
		cin >> input;
		Height.push_back(input);
		NeighborIndexVector.push_back(vector<int>());
	}

	for (int i = 0; i < M; i++)
	{
		int input1 = 0;
		int input2 = 0;
		cin >> input1 >> input2;

		NeighborIndexVector[input1 - 1].push_back(input2 - 1);
		NeighborIndexVector[input2 - 1].push_back(input1 - 1);
	}

	for (int i = 0; i < N; i++)
	{
		bool tallest = true;
		for (int j = 0; j < NeighborIndexVector[i].size(); j++)
		{
			if (Height[i] <= Height[NeighborIndexVector[i][j]])
			{
				tallest = false;
				break;
			}
		}
		if (tallest)
		{
			output.push_back(i);
		}
	}

	cout << output.size() << endl;
	return 0;
}

Measured memory_bytes: 9276
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define loop(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string a;
	cin >> n >> a;
	int ans = 0;
	loop(i, n) {
		string str;
		cin >> str;
		string cnt = "";
		for (int i = 1; i < str.length(); i++) {
			for (int start = 0; start < str.length(); start++) {
				cnt = "";
				for (int j = start; j < str.length(); j += i)
				{
					cnt += str[j];
					if (cnt == a) 
					{
						ans++; goto H;
					}
				}
			}
		}
	H: {}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3172
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
typedef long long ll;
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=2e5+5;


int a[maxn],b[maxn],c[maxn];
int main()
{
    int x,y,na,nb,nc;
    ll sum=0;
    scanf("%d%d%d%d%d",&x,&y,&na,&nb,&nc);
    for(int i=1;i<=na;i++)scanf("%d",&a[i]);
    sort(a+1,a+1+na,[](int x,int y)->bool{return x>y;});
    for(int i=1;i<=nb;i++)scanf("%d",&b[i]);
    sort(b+1,b+1+nb,[](int x,int y)->bool{return x>y;});
    for(int i=1;i<=nc;i++)scanf("%d",&c[i]);
    sort(c+1,c+1+nc,[](int x,int y)->bool{return x>y;});
    for(int i=1;i<=x;i++)sum+=a[i];
    for(int i=1;i<=y;i++)sum+=b[i];
    int cnta=x,cntb=y,cntc=1;
    a[0]=inf;b[0]=inf;
    while(cntc<=nc)
    {
        if(a[cnta]>c[cntc]&&b[cntb]>c[cntc])break;
        if(a[cnta]<=b[cntb])
        {
            sum-=a[cnta];sum+=c[cntc];
            cnta--;cntc++;
        }
        else
        {
            sum-=b[cntb];sum+=c[cntc];
            cntb--;cntc++;
        }
    }
    printf("%lld\n",sum);
}

Measured memory_bytes: 1408