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

// clang-format off
#define range(i, l, r) for (int i = (int)l; i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = ((int)(r) - 1); i >= (int)l; --(i))

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

inline void br(ostream &os = cerr) { os << endl; }

using int32 = int;
using int64 = long long;

const int mod     = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

struct UnionFind {
  UnionFind(size_t size) : v(size, -1) {}
  vector<int> v;

  int root(int x) {
    return (v[x] < 0 ? x : v[x] = root(v[x]));
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (v[x] > v[y]) swap(x, y);
      v[x] += v[y];
      v[y] = x;
    }
  }

  int size(int x) {
    return -v[root(x)];
  }
};

void solver() {
  int N = input(), K = input(), L = input();

  UnionFind s(N), t(N);
  range(i, 0, K) s.unite(input() - 1, input() - 1);
  range(i, 0, L) t.unite(input() - 1, input() - 1);

  map<pair<int, int>, int> cnt;
  range(i, 0, N) {
    cnt[make_pair(s.root(i), t.root(i))]++;
  }

  range(i, 0, N) {
    cout << cnt[make_pair(s.root(i), t.root(i))] << (i + 1 == N ? "\n" : " ");
  }
}

signed main(int argc, char *argv[]) {
  solver();
}

Measured memory_bytes: 13568
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
  
n,m = map(int,input().split())
chk = factorization(m)
from scipy.misc import comb

mod = 10**9+7
ans = 1
if m > 1:
  for i in chk:
    ans *= comb(i[1]+n-1,i[1],mod)
    ans %= mod
print(ans)

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

bool check(vector<int> &ch) {
  ll tmp = ch[1] - ch[0];
  FOR(i, 1, ch.size() - 1) {
    if(ch[i + 1] - ch[i] != tmp) return false;
  }
  return true;
}

signed main() {
  ll n, s[101];
	while(1) {
    cin >> n;
    if(n == 0) break;
    rep(i, n + 1) cin >> s[i];
    rep(i, n + 1) {
      vector<int> ch;
      rep(j, n + 1) {
        if(i == j) continue;
        ch.pb(s[j]);
      }
      if(check(ch)) {
        cout << s[i] << endl;
        break;
      }
    }
  }
	return 0;
}


Measured memory_bytes: 3148
/* be name Khoda */
#include <bits/stdc++.h>
using namespace std;

int n;
string s;

string _mul(string s, int m) {
	string res;
	reverse(s.begin(), s.end());
	int sz = s.size();
	int remain = 0;
	s[n] = '0';
	for (int i = 0; i <= sz; i++) {
		int t = (s[i] - '0') * m;
		int k = t / 10;
		t %= 10;
		t += remain;
		k += t / 10;
		t %= 10;
	//	cout << t << " OOPO \n";
		remain = k;
		res += char(t + '0');
	}
//	cout << res << "   " << s << "  " << m << "\n";
	while (res[(int)res.size() - 1] == '0')
		res.pop_back();
	reverse(res.begin(), res.end());
	return res;
}

string _sum(string s, int m) {
	string ss = to_string(m);
//	cout << m << "\n";
	reverse(ss.begin(), ss.end());
	reverse(s.begin(), s.end());
	string res;
	int remain = 0;
	int sz1 = s.size();
	int sz2 = ss.size();
	if (sz1 < sz2)
		for (int i = sz1; i < sz2; i++)
			s += '0';
	if (sz1 > sz2)
		for (int i = sz2; i < sz1; i++)
			ss += '0';
	int sz = s.size();
	s += '0', ss  += '0';
	for (int i = 0; i <= sz; i++) {
		int t = (s[i] - '0') + (ss[i] - '0');
		int k = t / 10;
		t %= 10;
		t += remain;
		k += t / 10;
		t %= 10;
		remain = k;
		res += char(t + '0');
	}
	while (res[(int)res.size() - 1] == '0')
		res.pop_back();
	reverse(res.begin(), res.end());
	return res;
}


bool solve(int m) {
	string ss = _mul(s, 9);
	ss = _sum(ss, 9 * m);
	long long s = 0;
	for (int i = 0; i < ss.size(); i++)
		s += (ss[i] - '0');
	return (s <= 9 * m);
}

int main() {
	cin >> s;
	n = s.size();
	int l = 0, r = n;
//	cout << l << "  " << r << "\n";
//	cout << _mul(s, 9) << "\n";
//	cout << _sum(_mul(s, 9), 315) << " popo \n";
	while (r - l > 1) {
		int mid = (r + l) / 2;
	//	cout << mid <<  " OPOPOPOPO \n";
		if (solve(mid))
			r = mid;
		else
			l = mid;
	}
	cout << r << "\n";
}




Measured memory_bytes: 7216
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma optimize("JARU SOSISONI")

using namespace std;

#define int long long
#define fast cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define geometry cout.setf(ios::fixed); cout.precision(15);
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;

const int INF = 1e9 + 100;
const int MOD = 998244353;
const int MOD1 = 1e9 + 7;
const int N = 52;
const int nul = 0;
const int SIZE = 1e6 * 3;



signed main() {
#ifdef parasha
    freopen("A.in", "r", stdin);
#endif // parasha
    fast;
    int n;
    cin >> n;
    vector<int> a;
    a.push_back(-1);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }
    a.push_back(-1);
    n += 2;
    vector<int> left(n);
    vector<int> right(n);
    vector<int> q = {0};
    for (int i = 1; i < n - 1; i++) {
        while (a[q.back()] >= a[i]) q.pop_back();
        left[i] = q.back();
        q.push_back(i);
    }
    q = {n - 1};
    for (int i = n - 2; i >= 1; i--) {
        //cout << a[i] << endl;
        while (a[q.back()] >= a[i]) q.pop_back();
        right[i] = q.back();
        q.push_back(i);
    }
    int ans = 0;
    for (int i = 1; i < n - 1; i++) {
        int l = i - left[i];
        int r = right[i] - i;
        ans += a[i] * (l * r);
    }
    cout << ans << endl;

}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

//a,b x
int main(){
	ll N; cin>>N;
	vector<ll> A(N);
	vector<bool> color(8,false);
	rep(i,N) cin>>A[i];
	ll i=0;
	ll cnt=0;
	while(i<=N-1){
		if(A[i]<400){
			color[0]=true;
		}
		else if(A[i]<800){
			color[1]=true;
		}
		else if(A[i]<1200){
			color[2]=true;
		}
		else if(A[i]<1600){
			color[3]=true;
		}
		else if(A[i]<2000){
			color[4]=true;
		}
		else if(A[i]<2400){
			color[5]=true;
		}
		else if(A[i]<2800){
			color[6]=true;
		}
		else if(A[i]<3200){
			color[7]=true;
		}else{
			cnt++;
		}
		i++;
	}
	ll C=0;
	rep(i,8){
		if(color[i]==true) C++;
	}
	printf("%lld %lld",max((ll)1,C),C+cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  int l, r;
  while(input(l,r)) {
    vector<int> v;
    for (int i=l; i<=min(r,l+2040); i++) {
      v.push_back(i % 2019);
    }
    int ans = INF;
    REP(i,v.size()) {
      REP(j,i) {
        chmin(ans, v[i]*v[j]%2019);
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long d = sc.nextLong();
		long t = sc.nextLong();
		long s = sc.nextLong();

		if (d <= t * s) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();

	}

}


Measured memory_bytes: 35696
#include <stdio.h>

int main (){
	int n;
	scanf("%d", &n);
	
	char kata[10001];
	scanf ("%s", kata);
	
	for (int i =0; kata[i] != '\0'; i++){
		if (kata[i] + n > 'Z'){
			printf("%c", kata[i] + n - 26);
		}
		else {
			printf("%c", kata[i] + n);
		}
	}
	
	return 0;
}

Measured memory_bytes: 1656
def resolve():
	a, b, c, x = [int(input()) for _ in range(4)]
	ans = 0
	for i in range(a+1):
		for j in range(b+1):
			for k in range(c+1):
				if 500*i + 100*j + 50*k == x:
					ans += 1
	print(ans)
resolve()

Measured memory_bytes: 38896
# Still TBD
import sys
import datetime

S = datetime.datetime.strptime(input(), "%Y/%m/%d")

def check(date):
    a = datetime.datetime.strptime('2019/04/30', "%Y/%m/%d")
    if date <= a :
        return "Heisei"
    else :
        return "TBD"

print(check(S))

Measured memory_bytes: 4336
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    long long n;
    cin >> n;
    if(n % 2 != 0){
        cout << 0 << endl;
        return 0;
    }

    long long ans = 0;
    for(long long x=10; x<=n; x*=5)
        ans += n / x;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <math.h>

using namespace std;

int main()
{
	int N, M, sum = 0;
	int* A;

	cin >> N >> M;
	A = new int[M];

	for (int i = 0; i < M; i++)
	{
		cin >> A[i];
		sum += A[i];
	}
	int rest = N - sum;

	if (rest < 0)
		cout << "-1";
	else
		cout << rest;


	return 0; 
}

Measured memory_bytes: 3564
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
#define i64 long long int
char s[99];int n;
map<pair<string,string>,int> Map;
int main(){
	scanf("%d%s",&n,s);
	for(int mask=0; mask<(1<<n); mask++){
		string r = "", b = "";
		for(int i=0; i<n; i++)if(mask&(1<<i))
			r += s[i];
		else
			b += s[i];
		reverse(b.begin(), b.end());
		Map[make_pair(r,b)]++;
	}
	i64 res = 0;
	for(int mask=0; mask<(1<<n); mask++){
		string r = "", b = "";
		for(int i=0; i<n; i++)if(mask&(1<<i))
			r += s[i+n];
		else
			b += s[i+n];
		reverse(b.begin(), b.end());
		auto tmp = make_pair(b,r);
		if(Map.count(tmp))
			res += Map[tmp];
	}
	cout << res << endl;
	return 0;
}


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

typedef long long ll;

int main() {
    ll N, u, v, w;
    cin >> N;
    vector<pair<int, ll>> e[100000];
    rep(i, N - 1) {
        cin >> u >> v >> w;
        e[u - 1].push_back(make_pair(v - 1, w));
        e[v - 1].push_back(make_pair(u - 1, w));
    }
    vector<bool> done(N, false);
    done[0] = true;
    queue<pair<int, ll>> q;
    vector<ll> d(N, 0);
    q.push(make_pair(0, 0));
    while (!q.empty()) {
        auto f = q.front();
        q.pop();
        v = f.first;
        w = f.second;
        rep(i, e[v].size()) {
            auto p = e[v][i];
            int v1 = p.first;
            if (done[v1]) continue;
            ll w1 = p.second;
            q.push(make_pair(v1, w + w1));
            done[v1] = true;
            d[v1] = w + w1;
        }
    }
    rep(i, N) cout << d[i] % 2 << endl;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int64_t x, ans;
  cin >> x;
  int64_t R=x%11, Q=x/11;
  if (R==0) {
    ans=2*Q;
  }
  else if (R==1||R==2||R==3||R==4||R==5||R==6) {
    ans=2*Q+1;
  }
  else {
    ans=2*Q+2;
  }
  cout << ans << endl;
}

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

int main() {
  int h,w,hh;
  string m,s,s2;
  cin >> h >> w;
  hh=h;
  for (int i=0; i<w; i++) m+='.';
  cin >> s;
  for (int i=0; i<h; i++) {
    if (hh>1) cin >> s2;
    else {
      s2="";
      for (int j=0; j<w; j++) s2+='.';
    }
    hh-=1;
    for (int j=0; j<w; j++) {
      int c=0;
      if (j!=0&&m.at(j-1)=='#') c+=1;
      if (m.at(j)=='#') c+=1;
      if (j!=w-1&&m.at(j+1)=='#') c+=1;
      if (j!=0&&s.at(j-1)=='#') c+=1;
      if (j!=w-1&&s.at(j+1)=='#') c+=1;
      if (j!=0&&s2.at(j-1)=='#') c+=1;
      if (s2.at(j)=='#') c+=1;
      if (j!=w-1&&s2.at(j+1)=='#') c+=1;
      if (s.at(j)=='#') cout << '#';
      else cout << c;
    }
    m=s;
    s=s2;
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

struct edge {
    int from, to;
    string lab;

    edge() {}
    edge(int a, int b, string s): from(a), to(b), lab(s) {}
};

int N, A, S, G;
vector<edge> edges;

string solve() {
    const string NO = "NO";
    vector<string> best(N, NO);
    best[G] = "";

    bool updated = true;
    vector<int> updated_at(N, 0);
    for (int j = 0; updated && j <= 7*N; ++j) {
        updated = false;
        fill(begin(updated_at), end(updated_at), 0);

        for (const edge& e: edges) {
            if (best[e.to] == NO) continue;
            if (best[e.from] == NO || e.lab + best[e.to] < best[e.from]) {
                updated = true;
                updated_at[e.from] = true;
                best[e.from] = e.lab + best[e.to];
            }
        }
    }

    return best[S].size() <= 6*(N-1) ? best[S] : NO;
}


int main() {
    while (true) {
        cin >> N >> A >> S >> G;
        if (N == 0 && A == 0 && S == 0 && G == 0) {
            break;
        }
        edges.clear();
        for (int j = 0; j < A; ++j) {
            int x, y; string lab;
            cin >> x >> y >> lab;
            edges.emplace_back(x, y, lab);
        }
        cout << solve() << endl;
    }
    return 0;
}

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

int H, W;
string s[55];

queue<pair<int, int> > Q;

int dis[55][55];

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

int main(void) {

	cin >> H >> W;
	string tmp;
	for (int i = 1; i <= H; i++) {
		cin >> tmp;   s[i] = "#" + tmp + "#";
	}

	for (int i = 0; i <= W + 1; i++) {
		s[0] += "#";
		s[H + 1] += "#";
	}
	int INF = 999999;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			dis[i][j] = INF;
		}
	}



	int num = 0;

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (s[i][j] == '.') { num++; }
		}
	}

	dis[1][1] = 0;
	Q.push(make_pair(1, 1));

	while (Q.size() > 0) {
	pair<int,int> P = Q.front();
		Q.pop();
		int u = P.first; 
		int v = P.second;
		for (int j = 0; j <= 3; j++) {
			int nu = u + dx[j];
			int nv = v + dy[j];

			if (dis[nu][nv] == INF && s[nu][nv] == '.') { dis[nu][nv] = dis[u][v] + 1; Q.push(make_pair(nu, nv)); }
		}

	}

	if (dis[H][W] == INF) { cout << -1 << endl; return 0; }
	else { cout << num - (dis[H][W] + 1) << 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++)

int main() {
  int N;
  cin >> N;
  
  int P = 0, W = 0, G = 0, Y = 0;
  string S;
  rep(i, N) {
    cin >> S;
    if (S == "P") {
      P = 1;
    } else if (S == "W") {
       W = 1;
    } else if (S == "G") {
      G = 1;
    } else {
      Y = 1;
    }
  }
    
    int cnt = P + W + G + Y;
    if (cnt == 3) {
      cout << "Three" << endl;
    } else {
      cout << "Four" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}


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

Measured memory_bytes: 3620
Q, H, S, D = map(int, input().split())
N = int(input()) * 4

order = [(Q, 1), (H, 2), (S, 4), (D, 8)]
order.sort(key=lambda x: x[0] / x[1])

ret = 0
for i in range(4) :
  ret += (N // order[i][1]) * order[i][0]
  N %= order[i][1]
  
print(ret)

Measured memory_bytes: 38384
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

int main(void)
{
    string S;

    cin>>S;

    stringstream sS{S};

    string buf;
    vector<int> day;
    while(getline(sS, buf, '/'))
    {
        day.push_back(stoi(buf));
    }

    if(day[0]>2018 && day[1]>4)
    {
        cout<<"TBD"<<endl;
    }
    else
    {
        cout<<"Heisei"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  int a;
  scanf("%d", &a);
  std::cout << a*a*a+a*a+a << std::endl;
  return 0;
}
 

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

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

    int s, t, d;
    cin >> s >> t >> d;
    vector<int> ws(d);
    for (int i = 0; i < d; i++) {
        cin >> ws[i];
    }

    long long dif = 0;
    long long nin = 0;
    for (int i = 0; i < d; i++) {
        dif += ws[i];
        nin = min(nin, dif);
    }
    long long cnt = 0;
    long long ss = s;
    for (int i = 0; i < d; i++) {
        ss += ws[i];
        if (ss <= t) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    if (dif >= 0) {
        cout << -1 << endl;
        return 0;
    }
    int l = -1, r = 1e9;
    while (l < r - 1) {
        int m = (l + r) / 2;
        if (s + dif * m + nin <= t) {
            r = m;
        } else {
            l = m;
        }
    }
    cnt = 1LL * d * r;
    s += dif * r;
    for (int i = 0; i < d; i++) {
        s += ws[i];
        cnt++;
        if (s <= t) {
            cout << cnt << endl;
            return 0;
        }
    }
}



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

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

    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R')
    {
        cout << 3 << endl;
    }
    else if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R'))
    {
        cout << 2 << endl;
    }
    else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  ll x, n;
  cin >> x >> n;
  vector<ll> p(n);  rep(i, 0, n) cin >> p[i];
  vector<ll> a;
  rep(i, 0, 102) {
    bool flag = true;
    rep(j, 0, n) {
      if(i == p[j]) flag = false;
    }
    if(flag) a.push_back(i);
  }
  ll mini = 100000;
  rep(i, 0, (ll)a.size()) {
    if(abs(x-a[i]) >= mini) break;
    else mini = abs(x-a[i]);
  }
  ll ans = x+mini;
  rep(i, 0, (ll)a.size()) {
    if(a[i] == x-mini) ans = a[i];
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3656
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if(t == nil)return;
  deleteNode(t);
}

void delete(int key){
  NodePointer t = listSearch(key);
  if(t == nil)return;
  deleteNode(t);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 33020
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
#define MAX 50000
#define INF 100000000
using namespace std;
typedef long long ll;
int t[MAX+1],c[21];
struct bags{
	int value;
	int weight;
};
vector<bags> B;
int dp[102][10002];
int main()
{	
	int n,m; 
	struct bags tian;
	cin>>n>>m;
	B.push_back(tian);
	for(int i=1;i<=n;i++)
	{
		struct bags tmp;
		cin>>tmp.value>>tmp.weight;
		B.push_back(tmp);
	}
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=0;
		dp[0][i]=0;
	}
	dp[0][0]=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(j<B[i].weight)
				dp[i][j]=dp[i-1][j];
			else{
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-B[i].weight]+B[i].value);
			}
		}
	cout<<dp[n][m]<<endl;
}


Measured memory_bytes: 7076
#include <iostream>
#include <queue>


std::queue<char> init_player(std::string &input) {
	std::queue<char> player;
	for (auto i = input.begin(); i != input.end(); i++) {
		player.emplace(*i);
	}
	return player;
}

char game(std::queue<char> &turn_player, char player_label) {
	if (turn_player.empty()) {
		std::cout << player_label << std::endl;
		return 'Z';  // ゲーム終了
	}
	char card = turn_player.front();
	turn_player.pop();
	return card;
}

int main(int argc, char *argv[]) {
	std::string player1_cards;
	std::string player2_cards;
	std::string player3_cards;
	std::cin >> player1_cards;
	std::cin >> player2_cards;
	std::cin >> player3_cards;

	std::queue<char> player1(init_player(player1_cards));
	std::queue<char> player2(init_player(player2_cards));
	std::queue<char> player3(init_player(player3_cards));

	int turn = 0;
	char current_card;

	for (;;) {
		if (turn == 0) {
			current_card = game(player1, 'A');
		}
		switch(current_card) {
		case 'a':
			current_card = game(player1, 'A');
			break;
		case 'b':
			current_card = game(player2, 'B');
			break;
		case 'c':
			current_card = game(player3, 'C');
			break;
		}
		if (current_card == 'Z') {
			break;
		}
		turn++;
	}

	return 0;
}


Measured memory_bytes: 256
a, b, c=input().split()
a=int(a)
b=int(b)
c=int(c)

if a<b :
    if a>c :
        print(c,a,b)
    elif b<c:
        print(a,b,c)
    else :
        print(a,c,b)
else :
    if b>c:
        print(c,b,a)
    elif a<c:
        print(b,a,c)
    else :
        print(b,c,a)
        


Measured memory_bytes: 5596
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int X, Y;
	cin >> X >> Y;

	cout << X + (Y / 2);

	return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

long long dp[400][400] = {};
long long rec(const vector<int> &a, const vector<long long> &s, int l, int r) {
	if(dp[l][r] != 0) return dp[l][r];
	if(l == r) return 0;
	if(l + 1 == r) return dp[l][r] = a[l] + a[r];

	long long res = LLONG_MAX;
	for(int k = l; k < r; k++) {
		long long ss = rec(a, s, l, k) + rec(a, s, k + 1, r);
		res = min(ss, res);
	}
	dp[l][r] = l > 0 ? res + s[r] - s[l - 1] : res + s[r];
	//cout << l << " " << r << " " << dp[l][r] << endl;
	return dp[l][r];
}
int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	vector<long long> s(N);
	for(int i = 0; i < N; i++) {
		cin >> a[i];
		s[i] = i == 0 ? a[i] : a[i] + s[i - 1];
	}

	cout << rec(a, s, 0, N - 1) << endl;

}


Measured memory_bytes: 1536
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
long long n,sum;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				sum+=__gcd(i,__gcd(j,k));
			}
		}
	}
	cout<<sum;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <utility>
using namespace std;
#define fol(i,n) for (int i=0;i<n;i++)
 
int main(){
    int a,b,c;
    cin >>a>>b>>c;
cout << (a+b)*c/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {
	int N,c=0;
	string s,an="No";
	cin >> N>>s;

	rep(i, N) {
		if (s.at(i) == 'R') {
			c++;
		}
		else {
			c--;
		}
	}
	if (c > 0) {
		an = "Yes";
	}

	cout << an<< endl;
	
}

Measured memory_bytes: 256
char Tag[99][99]={"OUT OF MAIN PANEL"};
X[99],Y[99],V[99],W[99],c[99],w;
P(p){
	char t[99],d[99];
	c[p]=0;
	for(;w++,scanf("%[^/>]>%d,%d,%d,%d<",Tag[w],X+w,Y+w,V+w,W+w,d);){
		c[p]++;
		P(w);
		if(scanf("%[^>]>%[<]",t,d)!=2){
			w++;
			break;
		}
	}
	w--;
}
main(n,x,y,i){
	for(;scanf("%d\n<",&n)*n;){
		P(w=0);
		for(;n--;){
			scanf("%d%d",&x,&y);
			for(i=w+1;--i;){
				if(x>=X[i]&&y>=Y[i]&&x<=V[i]&&y<=W[i])
					break;
			}
			printf("%s %d\n",Tag[i],c[i]);
		}
	}
}

Measured memory_bytes: 0
S = input()
YY=int(S[:2])
MM=int(S[2:])
if(((1<=MM and MM<=12) and (1<=YY and YY<=12))):
    print("AMBIGUOUS")
elif(1<= MM and MM<=12):
    print("YYMM")
elif(1<=YY and YY <=12):
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3060
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                count +=1
print(count)

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n, m := io.NextInt(), io.NextInt()
	a := io.NextInts(n)
	sort.Ints(a)
	sum := 0
	for i := range a {
		sum += a[i]
	}
	for i := 0; i < m; i++ {
		if a[n-1-i]*4*m < sum {
			io.Println("No")
			return
		}
	}
	io.Println("Yes")
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>

int main() {
	long long int n, k;
	std::cin >> n >> k;
	long long int ans = 0;
	ans += k * std::pow((k - 1), (n - 1));
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
const int mx = 1e5 +5;
vector<int> graph[mx];
vector<bool> visited(mx);
vector<int> in_degree(mx);
vector<int> dist(mx);
void dfs(int root) {
    visited[root] = true;
    for(int child: graph[root]) {
        --in_degree[child];
        dist[child] = max(dist[child], dist[root] + 1);
        if(!in_degree[child]) {
            dfs(child);
        }
    }
}
int main() {
    int n, m, from, to;
    cin >> n >> m;
    for(int i = 0; i < m; ++i) {
        cin >> from >> to;
        ++in_degree[to];
        graph[from].pb(to);
    }
    for(int i = 1; i <= n; ++i) {
        if(!visited[i] && !in_degree[i]) {
            dfs(i);
        }
    }
    int mx = 0;
    for(auto num: dist) {
        mx = max(mx, num);
    }
    cout << mx << endl;
}


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

const long long MAX = 1e18;

int main() {
    int N;
    cin >> N;
    long long *A = new long long[N];
    
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    
        if (A[i] == 0) {
            cout << 0;
            return 0;
        }
    }
    
    long long sum = 1;
    long long sum_old = 1;
    for (int i = 0; i < N; i++) {
        sum_old = sum;
        sum *= A[i];

        if (sum > MAX || sum / A[i] != sum_old || sum <= 0) {
            cout << -1;
            return 0;
        }

        /*
        if (MAX / sum < A[i]) {
            cout << -1;
            return 0;
        } else {
            sum *= A[i];
        }
        */
    }
    
    cout << sum;
    return 0;
}

Measured memory_bytes: 4408
s=input()

first = int(s[:2])
second = int(s[2:])

if (first>0) and (first<13) and (second>0) and (second<13):
    print("AMBIGUOUS")
elif (first>0) and (first<13) and ((second==0) or (second>=13)):
    print("MMYY")
elif (second>0) and (second<13) and ((first==0) or (first>=13)):
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 9204
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <array>
#include <cmath>
#include <random>
#include <functional>
#include <climits>
#include <iomanip>
using namespace std;
using lint=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  double ans=0;
  for(int i=1;i<=n;i++){
    double co=(double)1/n;
    int mm=i;
    for(int j=0;mm<k;j++){
      mm*=2;
      co*=(double)(0.5);
    }
    ans+=co;
  }
  cout<<fixed<<setprecision(16)<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a[5],i,m=10,n=0;
	for(i=0;i<5;i++){
		scanf("%d",&a[i]);
		if(a[i]%10==0)n+=a[i];
		else {
			n+=(a[i]/10+1)*10;
			a[i]=a[i]%10;
			if(m>a[i])m=a[i];
		}
	}
	if(m!=10){
		n=n+m-10;
	}
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	solve()
}

func solve() {
	const mod = 1000000007

	sc.Split(bufio.ScanWords)

	n := nextInt()
	m := nextInt()

	isBroken := make([]bool, n+2)
	for i := 0; i < m; i++ {
		isBroken[nextInt()] = true
	}

	dp := make([]int64, n+2)
	dp[0] = 1
	for i := 0; i < n; i++ {
		for to := i + 1; to <= i+2; to++ {
			if !isBroken[to] {
				dp[to] += dp[i]
				dp[to] %= mod
			}
		}
	}

	ans := dp[n]
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func anser(b bool, y string, n string) string {
	if b {
		return y
	}
	return n
}

Measured memory_bytes: 1792
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

string a, b;
main() {
  file("threesum");
  ios;
  cin >> a >> b;
  b.pop_back();
  cout<<(a == b ? "Yes" : "No");
  return 0;
}
/**

*/


Measured memory_bytes: 3660
#!/usr/bin/env python3.4

# abc127_d

import collections

def main():
    # Input
    n, m = [int(s) for s in input().split()]
    cards = [int(s) for s in input().split()]
    acts = [[int(s) for s in input().split()] for _ in range(m)]
    # Get ans
    cards = collections.deque(sorted(cards), n)
    acts.sort(key=lambda a: a[1], reverse=True)
    for b, c in acts:
        for _ in range(b):
            if cards[0] >= c:
                break
            cards.append(c)
    ans = sum(cards)
    # Output
    print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 27380
#include<bits/stdc++.h>
using namespace std;
const long long INF=1e18L +5;
int main()
{long long n,w,i,j,item,value,s=0,weight;
cin>>n>>w;
vector<long long> witem(n+1),p(n+1);
for(i=0;i<n;i++)
{cin>>witem[i]>>p[i];s+=p[i];
}
vector<long long> dp(s+1,INF);dp[0]=0;
//dp[i] - gives the minimum total weight for profit p[i]



	for(item=0;item<n;item++)
{	for(value=s;value>=0;value--)
		if(value-p[item]>=0)
		{
		dp[value]=min(dp[value-p[item]]+witem[item],dp[value]);
		}
	
	}
/*
	for(item=0;item<n;item++)
{	for(weight=w-witem[item];weight>0;weight--)
	
		dp[weight+witem[item]]=max(dp[weight]+p[item],dp[weight+witem[item]]);
		
	}

*/
long long ans=0;
for(i=0;i<=s;i++)
{
if(dp[i]<=w)
ans=max(ans,i);
}
cout<<"\n"<<ans;

return 0;
}
/*
3 8
3 30
4 50
5 60

*/

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

int main(){
    int n,m,x; cin>>n>>m>>x;
    vector<int> a(n+1);

    set<int> s;
    for(int i=0; i<m;i++){
        int k; cin>>k;
        s.insert(k);
    }    

    int cost1=0,cost2=0;

    for(int i=x; i<=n; i++){
        if(s.count(i))cost1++;
    }

    for(int i=x; i>=0; i--){
        if((s.count(i)))cost2++;
    }

    cout<<min(cost1,cost2)<<endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace ABC179
{
    class Program
    {
        static void Main(string[] args)
        {
            //var NXT = Console.ReadLine().Split().Select(double.Parse).ToArray();
            //var N = long.Parse(Console.ReadLine());
            //var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            // var CA = Enumerable.Repeat(0, (int)N).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            //var L = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();
            var S = Console.ReadLine();

            if (S[S.Length - 1] == 's') Console.WriteLine(S + "es");
            else Console.WriteLine(S + 's');
        }
    }
}


Measured memory_bytes: 25892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 10000000000000000
int main(void){
    ll r,d,x;cin>>r>>d>>x;
    rep(i,10){
        x=r*x-d;
        cout<<x<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

ll cnt[45][2],kbit[45];

ll calc(int x){
	ll ans=0,pow2=1;
	rep(i,x){
		if(cnt[i][0]>cnt[i][1])ans+=pow2*cnt[i][0];
		else ans+=pow2*cnt[i][1];
		pow2*=2;
	}
	return ans;
}

int main(void){
	ll n,k;
	cin>>n>>k;
	ll a[n];
	rep(i,n)cin>>a[i];

	ll pow2=1,pow=1;
	rep(i,42){
		pow2*=2;
		pow*=2;
		cnt[i][0]=0;
		cnt[i][1]=0;
		kbit[i]=0;
	}

	int idx=42;
	while(idx > -1){
		rep(i,n){
			if(a[i] >= pow2){
				cnt[idx][1]++;
				a[i]-=pow2;
			}
			else cnt[idx][0]++;
			if(k >= pow2){
				kbit[idx]=1;
				k-=pow2;
			}
		}
		pow2/=2;
		idx--;
	}

	/*
	rep(i,5)cout<<cnt[i][0];
	cout<<endl;
	rep(i,5)cout<<cnt[i][1];
	cout<<endl;
	rep(i,5)cout<<kbit[i];
	cout<<endl;*/

	ll val=0,maxf=0;
	for(int i=42;i>-1;i--){
		//cout<<"i:"<<i<<","<<"k:"<<kbit[i]<<","<<"c[0]:"<<cnt[i][0]<<","<<"c[1]:"<<cnt[i][1]<<endl;
		if(kbit[i]){
			if(cnt[i][1] >= cnt[i][0]){
				val+=cnt[i][1]*pow+calc(i);
				break;
			}
			ll tmp=calc(i);
			if(maxf < val+cnt[i][1]*pow+tmp)maxf=val+cnt[i][1]*pow+tmp;
			val+=cnt[i][0]*pow;
		}
		else val+=cnt[i][1]*pow;
		pow/=2;
	}

	if(val > maxf)maxf=val;

	cout<<maxf<<endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int L,R,d;
  cin >> L >> R >> d;
  int ans=0;
  for(int i=L; i<R+1; i++)
  {
    if(i%d==0)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double total = 0;
		for (int i = 0; i < N; i++) {
			double x = sc.nextDouble();
			String u = sc.next();
			if (u.contains("JPY")) {
				total += x;
			} else {
				total += x * 380000.0;
			}
		}
		System.out.println(total);
    }
  
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    ll n; cin >> n;
    vector<ll> so(1000100,1);
    so[0] = 0;
    so[1] = 0;
    repp(i,1000100,2){
        if (so[i] == 0) continue;
        else {
            ll cnt = i + i;
            while (cnt <= 100000){
                so[cnt] = 0;
                cnt += i;
            }
        }
    }
    vector<PL> ar;
    repl(i,1000010) if (so[i] == 1) ar.emplace_back(P(i,0LL));
    ll m = ar.size();
    map<ll,ll> mp;
    rep(i,m) mp[ar[i].first] = i;
    vector<ll> al(n);
    rep(i,n) cin >> al[i];
    bool t = true;
    rep(i,n){
        ll d = al[i];
        ll cn = 0;
        while (d != 1 && cn < m && ar[cn].first * ar[cn].first <= al[i]){
            ll kc = 0;
            while (d % ar[cn].first == 0){
                d /= ar[cn].first;
                kc++;
            }
            if (kc >= 1) ar[cn].second ++;
            cn++;
        }
        if (d != 1) ar[mp[d]].second++;
    }
    rep(i,m){
        if (ar[i].second >= 2){
            t = false;
            break;
        }
    }
    if (t) cout << "pairwise coprime" << endl;
    else {
        ll ans = al[0];
        rep(i,n){
            ans = gcds(ans,al[i]);
        }
        if (ans == 1) cout << "setwise coprime" << endl;
        else cout << "not coprime" << endl;
    }
    /*
    rep(i,m) cout << ar[i].first << " ";
    cout << endl;
    */
}

Measured memory_bytes: 90012