akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long int ld;
typedef unsigned long long int lu;
typedef vector< int > vi;
typedef vector < ld > vd;
typedef set <ld> sd;
typedef vector< vi > vvi;
typedef vector< vd > vvd;
typedef pair< int,int > ii;
typedef pair< ld,ld > id;
#define sz(a) ld((a).size())
#define test(t) ll t;cin>>t;while(t--)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define Vi vector
#define pr pair
#define mpr make_pair
#define fi first
#define se second
#define isnum(a) (a>=48 && a<=57)
#define isS(a) (a>='a' && a<='z')
#define isU(a) (a>='A' && a<='Z')
#define toS(a) (isU(a)?a+32:a)
#define toU(a) (isS(a)?a-32:a)
#define toC(a) a&15

set <ld> s[100005];
ld d[100005];

vector<char> prime (100000+1, true);
void sieve(ld n)
{	
	//O(nloglogn) time
	prime[0] = prime[1] = false;
	for (ld i=2; i<=n; ++i)
	{
		if (prime[i])
		{
			s[i].insert(i);			
			for (ld j=2*i; j<=n; j+=i)
			{
				prime[j] = false;
				s[j].insert(i);
			}
		}
	}
}
#define forn(i,e) for(int i = 0; i < e; i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define reprev(i,a,b) for(i=a;i>=b;i--)

#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
#define sp cout<<" "
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
ld gcd(ld a, ld b) { if(b == 0) return a; return gcd(b, a % b); }
ld fastpowMOD(ld a, ld p,ld MOD){ if(p==0) return 1; ld z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }
ld fastpow(ld a, ld p){ if(p==0) return 1; ld z = fastpow(a,p/2); z = (z*z); if(p%2) z = (z*a); return z; }
ld a,b;

ld search1(ld a[], ld f,ld n)
{
	ld left=1;
	ld right=n+1;
	while(right-left>1)
	{
		ld mid = left + (right-left)/2;
		if(a[mid]<f)
		{
			left=mid;
		}
		else right=mid;
	}
	return a[left];
}

int main(){
	ld n,i,j,d;
	cin >> n;
	vd v;
	rep(i,0,n){cin >> j;v.pb(j);}
	ld dp[n][n];
	memset(dp,0,sizeof(dp));
	rep(d,1,n)
	{
		rep(i,0,n-d)
		{
			ld fulsum=0;
			REP(j,i,i+d)
			{
				fulsum += v[j];
			}
			ld mins=1e17+7;
			rep(j,i,i+d)
			{
				mins = min(mins,dp[i][j]+dp[j+1][i+d]);
			}
			dp[i][i+d] = fulsum+mins;
		}
	}
	cout << dp[0][n-1] << endl;
	return 0;
}

Measured memory_bytes: 6272
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
template<class T>
int print(T& x){ cout << x << '\n'; return 0;}
#define debug(x) cerr << #x << ": " << x << '\n'

class UnionFind
{
    std::vector<int> data;

  public:
    UnionFind(int size) : data(size, -1) {}
    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x != y)
        {
            if (data[y] < data[x])
                std::swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find(int x, int y)
    {
        return root(x) == root(y);
    }
    int root(int x)
    {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    ll size(int x)
    {
        return -data[root(x)];
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int a, b, q;
    cin >> a >> b >> q;
    vl s, t;
    s.push_back(-10000000000001);
    t.push_back(-10000000000001);
    rep(i,a){
      ll l;
      cin >> l;
      s.push_back(l);
    }
    rep(i,b){
      ll l;
      cin >> l;
      t.push_back(l);
    }
    s.push_back(10000000000001);
    t.push_back(10000000000001);

    rep(i,q){
      ll ans;
      ll x;
      cin >> x;
      int s_min = lower_bound(s.begin(), s.end(), x) - s.begin();
      int t_min = lower_bound(t.begin(), t.end(), x) - t.begin();
      int s_man = upper_bound(s.begin(), s.end(), x) - s.begin();
      int t_man = upper_bound(t.begin(), t.end(), x) - t.begin();
      s_min--;
      t_min--;
      if(s[s_min] < t[t_min]){
        ans = min(x - s[s_min], s[s_man] + x - 2 * t[t_min]);
      }else{
        ans = min(x - t[t_min], t[t_man] + x - 2 * s[s_min]);
      }
      if(s[s_man] < t[t_man]){
        ll temp = min(t[t_man] - x, 2 * s[s_man] - x - t[t_min]);
        if(temp < ans) ans = temp;
      }else{
        ll temp = min(s[s_man] - x, 2 * t[t_man] - x - s[s_min]);
        if(temp < ans) ans = temp;
      }
      print(ans);
    }
    return 0;
}


Measured memory_bytes: 3060
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	
	int n;
	cin >> n;
	
	int a[100100] = {};
	for(int i = 1;i <= n;i++)cin >> a[i];

	int cnt = 0;
	int c = 1;
	rep(i,n+1){
		c = a[c];
		cnt++;
		if(c == 2){
			cout << cnt << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	


	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://abc065.contest.atcoder.jp/tasks/abc065_b

Measured memory_bytes: 4408
#include<bits/stdc++.h>
using namespace std;
#define MAX 10000000
#define ull  unsigned  long long int

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
		cin >> B[i];
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	if (N % 2)
	{
		int x = A[N / 2], y = B[N / 2];
		cout << (y - x + 1) << endl;
	}
	else
	{
		int x1=A[N/2], x2=A[(N-1)/2], y1=B[N/2], y2=B[(N-1)/2];
		ull mid1 = (x1 + x2);
		ull mid2 = (y1 + y2);

		cout <<( (mid2-mid1)+1) << endl;
	}
	return 0;
}

Measured memory_bytes: 4784
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 998244353 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

ll robot(vector<pll> &a,vll &use,ll r,ll &right){
	if(use.at(r)) return 1 ;
	use.at(r) = 1 ;
	ll res = 1 ;
	for(int i=max(r+1,right);i<a.size();i++){
		if(a.at(i).first>=a.at(r).first+a.at(r).second) break ;
		res = res*robot(a,use,i,right)%mod ;
		i = right ;
	}
	right = max(right,r) ;
//	cout << r << " " << res << endl ;
	return (res+1)%mod ;
}

int main(){
	ll n ; cin >> n ;
	vector<pll> a(n) ;
	for(int i=0;i<n;i++) cin >> a.at(i).first >> a.at(i).second ;
	sort(all(a)) ;
	vll use(n,0) ;
	ll ans = 1 ;
	ll right = 0 ;
	for(int i=0;i<n;i++){
//		cout << ans << endl ;
		if(use.at(i)) continue ;
		ans = ans*robot(a,use,i,right)%mod ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 20608
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n),con(n,0);
    int expo = 1;

    for(int i = 1; i <= n; i++){
        expo *= i;
        con[i - 1] = i;
    }
    for(int i = 0; i < n; i++)
    cin >> a[i];
    for(int i = 0; i < n; i++)
    cin >> b[i];
    int j = 1,cnt1 = 0,cnt2 = 0;
    sort(con.begin(),con.end());
   
   do{
       bool ans1 = true,ans2 = true;
       for(int i = 0; i < n; i++)
       {
           if(a[i] != con[i])
           ans1 = false;
           if(b[i] != con[i])
           ans2 = false;
       }
       if(ans1)
        cnt1 = j;
        if(ans2)
        cnt2 = j;
        j++;
   }
    while(next_permutation(con.begin(),con.end()));
    cout << abs(cnt1 - cnt2) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> N >> D;
    vector<ll> arr(N);
    vector<ll> brr(N);
    for (int i = 0; i < N; i++) cin >> arr.at(i) >> brr.at(i);

    D *= D;

    for (int i = 0; i < N; i++)
    {
        if(D<(arr[i]*arr[i]+brr[i]*brr[i]))continue;
        C++;
    }
    cout << C;
    
    
    return 0;
}

Measured memory_bytes: 6408
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
void chmin(int &a, int b) { if (a > b) a = b; }

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
char da[4] = { 'R', 'L', 'D', 'U' };
char dax[4] = { -1, 1, -1, 1 };
char dax2[4] = { 1, -1, 1, -1 };
ll min(ll a, ll b)
{

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


template<typename T, T MOD = 1000000007>
struct Mint {
	T v;

	Mint() : v(0) {}
	Mint(signed v) : v(v) {}
	Mint(ll t) { v = t % MOD; if (v < 0) v += MOD; }

	Mint pow(ll k) {
		Mint res(1), tmp(v);

		while (k) {

			if (k & 1) res *= tmp;

			tmp *= tmp;
			k >>= 1;
		}



		return res;
	}

	Mint inv() { return pow(MOD - 2); }

	Mint& operator=(Mint a) { if (a.v >= MOD) a.v %= MOD; v = a.v; return *this; }
	Mint& operator+=(Mint a) { v += a.v; if (v >= MOD) v -= MOD; return *this; }
	Mint& operator-=(Mint a) { v += MOD - a.v; if (v >= MOD) v -= MOD; return *this; }
	Mint& operator*=(Mint a) { v = 1LL * v * a.v % MOD; return *this; }
	Mint& operator/=(Mint a) { return (*this) *= a.inv(); }
	Mint operator+(Mint a) const { return Mint(v) += a; }
	Mint operator-(Mint a) const { return Mint(v) -= a; }
	Mint operator*(Mint a) const { return Mint(v) *= a; }
	Mint operator/(Mint a) const { return Mint(v) /= a; }

	Mint operator-() { return v ? MOD - v : v; }
	bool operator==(const Mint a) const { return v == a.v; }
	bool operator!=(const Mint a) const { return v != a.v; }
	bool operator < (const Mint a) const { return a < a.v; }


};

vector<ll> A;
int main() {
	ll N;

	cin >> N;
	A.resize(N+1);

	rep(i, N)
		cin >> A[i];
	ll index = 0;
	ll ans = 0;
	ll mode = 0;
	while (index <= N-1) {

		while (index <= N-2 && A[index] == A[index + 1]) {
			index++;
		}

		if (A[index] < A[index + 1]) {
			mode = 0;
			index++;
		}

		else {
			mode = 1;
			index++;
		}

		while (index <= N - 2 && mode == 0 && A[index] <= A[index + 1]) {
			index++;
			
		}

		while (index <= N - 2 && mode == 1 && A[index] >= A[index + 1]) {
			index++;
		}

		ans += 1;
		index++;

	}


	cout << ans << endl;
	return 0;

}

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

using namespace std;

map<string,int> mp;

int main(){

	int n,mx = 0;

	cin >> n;

	for(int i=0;i<n;++i){
		string s;
		cin >> s;
		mp[s]++;
		mx = max(mx,mp[s]);
	}

	for(auto &m:mp){
		if(m.second == mx)
			cout << m.first << '\n';
	}

	return 0;
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265359
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
ll power(ll x,ll y,ll p) 
{ 
    ll res=1;  
    x=x%p;
    while (y > 0) 
    { 
        if(y&1) 
            res=(res*x)%p; 
        y=y>>1;
        x=(x*x)%p;   
    } 
    return res; 
}
const ll L = 2e5 + 5;
ll arr[L];
ll flow[L];
ll tree[4 * L];
ll h[L];
void make(ll l, ll r, ll i)
{
	if(l == r)
	{
		tree[i] = arr[l];
		return;
	}
	ll mid = (l + r) >> 1;
	make(l, mid, 2 * i + 1);
	make(mid + 1, r, 2 * i + 2);
	tree[i] = max(tree[2 * i + 1], tree[2 * i + 2]);
}
ll query(ll l, ll r, ll s, ll e, ll i)
{
	if(s <= l && r <= e)
		return tree[i];
	if(r < s || e < l)
		return INT_MIN;
	else
	{
		ll mid = (l + r) >> 1;
		ll a = query(l, mid, s, e, 2 * i + 1);
		ll b = query(mid + 1, r, s, e, 2 * i + 2);
		return max(a, b);
	}
}
void update(ll l, ll r, ll i, ll id, ll val)
{
	if(l == r)
	{
		arr[id] = val;
		tree[i] = val;
		return;
	}
	ll mid = (l + r) >> 1;
	if(id <= mid)
		update(l, mid, 2 * i + 1, id, val);
	else
		update(mid + 1, r, 2 * i + 2, id, val);
	tree[i] = max(tree[2 * i + 1], tree[2 * i + 2]);
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll i,n,q;
 	cin >> n;
 	for(i=0;i<n;i++)
 	{
 		cin >> h[i];
 		h[i]--;
 	}
 	for(i=0;i<n;i++)
 		cin >> flow[h[i]];
 	for(i=0;i<n;i++)
 		arr[i] = 0;
 	make(0,n-1,0);
 	for(i=0;i<n;i++)
 	{
 		if(h[i] == 0)
 		{
 			update(0,n-1,0,h[i],flow[h[i]]);
 			continue;
 		}
 		ll temp = query(0,n-1,0,h[i]-1,0);
 		update(0,n-1,0,h[i],temp+flow[h[i]]);
 	}
 	cout << query(0,n-1,0,n-1,0) << endl;
	return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
//cout << fixed << setprecision(0)
int main() { 
  int n;cin >> n;
  int s,a =n;
  while(a){
    s += a%10;
    a /= 10;
  }
  cout << ((n%s==0)?"Yes":"No") << endl;
}


Measured memory_bytes: 256
n,x=map(int,input().split())
l=list(map(int,input().split()))
dp=[0]*(n+1)
for i in range(1,n+1):
  dp[i]=dp[i-1]+l[i-1]
ans=0
for j in range(n+1):
  if dp[j]<=x:
    ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll k;
  cin >> k;
  if(k <= 9) {
    cout << k << endl;
    return 0;
  }
  queue<ll> q;
  ll cnt = 9, ans;
  rep2(i, 1, 10) q.push(i);
  while(true) {
    ll x = q.front();
    q.pop();
    ll d = x % 10;
    if(d != 0) {
      ll m = x * 10 + d - 1;
      q.push(m);
      cnt++;
      ans = m;
      if(cnt == k) break;
    }
    ll m = x * 10 + d;
    q.push(m);
    cnt++;
    ans = m;
    if(cnt == k) break;
    if(d != 9) {
      ll m = x * 10 + d + 1;
      q.push(m);
      cnt++;
      ans = m;
      if(cnt == k) break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4124
/*
[abc106] C - To Infinity
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

string S;
int K;

char solve() {
    int pos = S.find_first_not_of('1');
    if (pos == string::npos || K <= pos) {
        return '1';
    }
    return S[pos];
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define REV(v) reverse(v.begin(),v.end())
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
#define v1out(v) FOR(j,0,v.size()){cout<<v[j]; if(j!=(ll)v.size()-1)cout<<" ";else cout<<endl; }
#define v2out(v) FOR(i,0,v.size())v1out(v[i]);

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

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

int main() {
  int N;
  int a;
  int b;
  
  cin >> N ;
  a=N/1000;
  b=(N-1000*a)/100;
  
  if (N-1110*a < 10 && N-1110*a > 0){
    cout << "Yes" << endl;
  }
  else if((N-111*b)%1000 == 0 ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int x;
  int y;
  int z;
  int max;
  int min;
  int tmp;
  scanf("%d %d %d", &x, &y, &z);
  if (y < z) {
    max = y;
  } else {
    max = z;
  }
  if (x < y + z) {

    min = (y + z) - x;
  } else {
    min = 0;
  }
  printf("%d %d\n", max, min);
}

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

#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define phi 3.1415926535
 
using namespace std;
 
ll tc, cnt = 0, number, many, total = 0;
int rmove[4] = {0, 0, -1, 1};
int cmove[4] = {1, -1, 0, 0};



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt","r", stdin);
    // freopen("output.txt","w", stdout);
    // g++ -std=c++11 Default.cpp  -o test

    ll arr[2];
    cin >> arr[0] >> arr[1];

    ll sum = arr[0] + arr[1];
    if(sum % 2 == 0)
        cout << sum / 2;
    else
        cout << "IMPOSSIBLE";
    cout << endl;
    
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
/*int N;
int main(){
    cin>>N;
    cout<<(N-2)*180;
}*/

string s;
int main(){
    cin>>s;
    int a=0;
    for(auto c:s){
        if(c=='x'){
            a++;
        }
    }
    string ans=(a<=7?"YES":"NO");
    cout<<ans;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	a := sc.Text()

	s := Stack{}
	for _, v := range strings.Split(a, " ") {
		switch v {
		case "+":
			right, _ := strconv.Atoi(s.pop())
			left, _ := strconv.Atoi(s.pop())
			sum := left + right
			s.push(strconv.Itoa(sum))
		case "-":
			right, _ := strconv.Atoi(s.pop())
			left, _ := strconv.Atoi(s.pop())
			sum := left - right
			s.push(strconv.Itoa(sum))
		case "*":
			right, _ := strconv.Atoi(s.pop())
			left, _ := strconv.Atoi(s.pop())
			sum := left * right
			s.push(strconv.Itoa(sum))
		default:
			s.push(v)
		}
	}

	fmt.Println(s.pop())

}

type Stack struct {
	stack []string
}

func (stack *Stack) push(val string) {
	stack.stack = append(stack.stack, val)
}

func (stack *Stack) pop() string {
	val := stack.stack[len(stack.stack)-1]
	stack.stack = stack.stack[0 : len(stack.stack)-1]
	return val
}



Measured memory_bytes: 1124
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int t,n,k;
    int x[100000],diff[100000];
    cin >> t;
    for(int i=0; i < t; i++)
    {
        cin >> n >> k;
        for(int j=0; j < n; j++)
        {
            cin >> x[j];
        }

        
        for(int j=0; j < n-1; j++)
        {
            diff[j] = x[j+1] - x[j]; 
        }

        sort(diff,diff+n-1);
        int ans = 0;

        if(n <= k)
        {
            cout << ans << endl;
        }
        else
        {
            for(int j=0; j < n-1-(k-1); j++)
            {
                ans += diff[j];
            }

            cout << ans << endl;
        }
    }

    return 0;

}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

int n, m;
int p[N];

map <int, int> wa;
map <int, bool> ac;

int main() {

	FAST;
	cin >> n >> m;
	int ans1 = 0, ans2 = 0;
	for (int i = 0; i < m; i ++) {
		cin >> p[i];
		string s;
		cin >> s;
		if (s == "AC") {
			if (!ac[p[i]]) {
				ac[p[i]] = true;
				ans1 ++;
				ans2 += wa[p[i]]; 
			}
		}
		else {
			wa[p[i]] ++;
		}
	}
	cout << ans1 << ' ' << ans2 << '\n';
	return 0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  string s;
  cin >> s;
  int64_t q;
  cin >> q;
  string s1;
  string s2;
  bool inversed = false;
  rep(i,q){
    int qtype;
    cin >> qtype;
    if(qtype == 1){
      inversed = !inversed;
    }else{
      int64_t f;
      char c;
      cin >> f >> c;
      if(!inversed){
        if(f == 1){
          s1.push_back(c);
        }else{
          s2.push_back(c);
        }
      }else{
         if(f == 1){
          s2.push_back(c);
        }else{
          s1.push_back(c);
        }
      }
    }
    /*if(!inversed){
          reverse(s.begin(),s.end());
    reverse(s1.begin(),s1.end());
      cout << s1 << s << s2 << endl;
          reverse(s.begin(),s.end());
    reverse(s1.begin(),s1.end());
    }else{
reverse(s2.begin(),s2.end());
      cout << s2 << s << s1 << endl;
reverse(s2.begin(),s2.end());
    }*/
  }
  if(!inversed){
    reverse(s1.begin(),s1.end());
    cout << s1 << s << s2 << endl;
  }else{
    reverse(s2.begin(),s2.end());
    reverse(s.begin(),s.end());
    cout << s2 << s << s1 << endl;
  }
    
        
        
}
      
    

Measured memory_bytes: 1088
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        Scanner scan =  new Scanner(System.in);
        int n = scan.nextInt();
        double s2 = 0;
        double D1 = 0;
        double D2 = 0;
        double D3 = 0;
        double Di = 0;
        int[] x = new int[n];
        int[] y = new int[n];
        for(int i = 0; i < n; i++){
            x[i] = scan.nextInt();
        }
        for(int j = 0; j < n; j++){
            y[j] = scan.nextInt();
        }

        //マンハッタン距離
        for(int z = 0; z < n; z++){
            if((x[z] - y[z]) > 0){
                D1 += x[z] - y[z];
            }else{
                D1 += y[z] - x[z];
            }
        }
        System.out.println(D1);

        //ユークリッド距離
        for(int z = 0; z < n; z++){
            D2 += Math.pow(x[z]-y[z],2);
        }
        D2 = Math.sqrt(D2);
        System.out.println(D2);

        //3乗
        for(int z = 0; z < n; z++){
            if((x[z] - y[z]) > 0){
                D3 += Math.pow(x[z]-y[z],3);
            }else{
                D3 += Math.pow(y[z]-x[z],3);
            }
        }
        D3 = Math.cbrt(D3);
        System.out.println(D3);


        //チェビシェフ　1/p -> ０　に収束し、最大値の要素 xk0 - yk0 が残る
        Di = x[0] - y[0];
        //そもそもの初期値である　Di　が絶対値で最大を取っていたが、負の値で合った為、maxとして抽出されなかった。
        //従って、for 文においても0から比べないといけない
        for(int i = 0; i < n; i++){
            if(x[i]-y[i] > 0){
                Di = Math.max(Di,x[i]-y[i]);
            }else{
                Di = Math.max(Di,y[i]-x[i]);
            }
        }
        System.out.println(Di);
    }
}



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

int main() {
  int n, d;
  cin >> n >> d;
  
  int x, y;
  int cnt=0;
  for(int i=0; i<n; i++){
    cin >> x >> y;
    if(sqrt((long long)x*x+(long long)y*y) <= d)
      cnt++;    
  }
  
  cout << cnt << endl;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long  

int32_t main(){

        IOS;
        int a;
        cin >> a;
        cout << a + a*a + a*a*a << endl;
    
    return 0;
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<vector<int>> a(3,vector<int>(3,0));
    vector<vector<bool>> boo(3,vector<bool>(3,false));
    rep(i,3){
        rep(j,3){
            cin>>a[i][j];
        }
    }
    int n; cin>>n;
    for(int i=0; i<n; i++){
        int b; cin>>b;
        for(int j=0; j<3; j++){
            for(int k=0; k<3; k++){
                if(a[j][k]==b){
                    boo[j][k]=true;
                }
            }
        }
    }

    bool bingo = false;
    for(int i=0; i<3; i++){
        if(boo[i][0]&&boo[i][1]&&boo[i][2])bingo=true;
    }
    for(int j=0; j<3; j++){
        if(boo[0][j]&&boo[1][j]&&boo[2][j])bingo=true;
    }
    if(boo[0][0]&&boo[1][1]&&boo[2][2])bingo=true;
    if(boo[2][0]&&boo[1][1]&&boo[0][2])bingo=true;
    if(bingo)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
# nabc123_b.py
# 調理時間%10=0 をとった後、調理時間%10 が大きい順にとって行く
dishes = [int(input()) for i in range(5)]
lest_time = 0
ans = 0
for dish in dishes:
    if dish%10==0:
        ans += (dish)
    else:
        ans += (dish+10-dish%10)
    if lest_time < 10-dish%10 and dish%10!=0:
        lest_time = 10-dish%10
print(ans-lest_time)    


Measured memory_bytes: 2940
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n < 1000) {
            System.out.println("ABC");
        } else {
            System.out.println("ABD");
        }
        
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
typedef long long LL;

const int MaxN = 100;
int n, m, a[MaxN * MaxN + 5], C;
int ans[MaxN + 5][MaxN + 5];

pair <int, int> Nxt(pair <int, int> now) {
	pair <int, int> res;
	if (now.first & 1) {
		res = now;
		if (now.second < m) res.second++;
		else res.first++;
	}
	else {
		res = now;
		if (now.second > 1) res.second--;
		else res.first++;
	}
	return res;
}

int main()
{
	while (~scanf("%d%d", &n, &m)) {
		scanf("%d", &C);
		for (int i = 1; i <= C; i++) scanf("%d", &a[i]);
		pair <int, int> now; now = make_pair(1, 0);
		for (int t = 1; t <= C; t++) {
			while (a[t] > 0) a[t]--, now = Nxt(now), ans[now.first][now.second] = t;
		}
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++)
				printf("%d ", ans[i][j]);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;
int main(void)

{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, 0, n) cin >> v[i];
    vector<vector<ll>> dp(n + 1, vector<ll>(2));
    dp[0][0] = 0;
    dp[0][1] = -INF;
    rep(i, 0, n)
    {
        dp[i + 1][0] = max(dp[i][0] + v[i], dp[i][1] - v[i]);
        dp[i + 1][1] = max(dp[i][0] - v[i], dp[i][1] + v[i]);
    }
    cout << dp[n][0] << endl;
}


Measured memory_bytes: 9536
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

const int64_t mod = 1000000007;

// i 段目まで確定, j 個保留, 値が最低でも l
int64_t dp[55][55][55 * 55];

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

    dp[0][0][0] = 1;

    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= i; j++)
        {
            for (int k = 0; k <= score; k++)
            {
                // 同じ
                {
                    const int nj = j;
                    dp[i + 1][nj][k + nj * 2] += dp[i][j][k];
                    dp[i + 1][nj][k + nj * 2] %= mod;
                }

                // 両方保留
                {
                    const int nj = j + 1;
                    dp[i + 1][nj][k + nj * 2] += dp[i][j][k];
                    dp[i + 1][nj][k + nj * 2] %= mod;
                }

                // 片方結ぶ
                {
                    const int nj = j;
                    dp[i + 1][nj][k + nj * 2] += dp[i][j][k] * j * 2;
                    dp[i + 1][nj][k + nj * 2] %= mod;
                }

                // 両方結ぶ
                if (j >= 1)
                {
                    const int nj = j - 1;
                    dp[i + 1][nj][k + nj * 2] += dp[i][j][k] * j * j;
                    dp[i + 1][nj][k + nj * 2] %= mod;
                }
            }
        }
    }
    cout << dp[n][0][score] << endl;
}

Measured memory_bytes: 65920
S = input()

fr_half = int(S[0:2]) 
se_half = int(S[2::])

if se_half > 0 and se_half <= 12:
  if fr_half  > 0 and fr_half <= 12:
    print('AMBIGUOUS')
  else:
    print('YYMM')
else:
  if fr_half  > 0 and fr_half <= 12:
    print('MMYY')
  else:
   	print('NA')


Measured memory_bytes: 2940
#include<iostream>
#include <math.h>
#include<vector>
#include<algorithm>
using namespace std;
int n,ans=0,a;
vector<int> v;
int main() {
	cin >> n;
	for (size_t i = 0; i < 2*n; i++)
	{
		cin >> a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	for (size_t j = 0; j < n; j++)
	{
		ans += v[2 * j];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
const int INF = 1e18;

signed main(){
    int x, y; cin >> x >> y;
    bool flg = false;
    REP(i,x+1)if(i*2+(x-i)*4 ==y)flg=true;
    cout<<(flg?"Yes":"No")<<endl;
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N), B(N), S(N);
    rep(i, 0, N){
        cin >> A[i] >> B[i];
        S[i] = A[i] + B[i];
    }
    sort(S.begin(), S.end(), greater<ll>());
    ll taka = 0;
    rep(i, 0, N){
        if(i % 2 == 0) taka += S[i];
    }
    
    ll ans = taka - accumulate(B.begin(), B.end(), 0LL);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define double long double
#define INF INT_MAX
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int m, node[5000010], lazy[5000010];
bool lazyflag[5000010];
void init(int n_) {
	m = 1;
	while (m <= n_)m *= 2;
	rep(i, 2 * m)node[i] = INF;
}

void eval(int k, int l, int r) {
	if (lazyflag[k]) {
		node[k] = lazy[k];
		if (r - l > 1) {
			lazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k];
			lazyflag[k * 2 + 1] = lazyflag[k * 2 + 2] = true;
		}
		lazyflag[k] = false;
	}
}

void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
	if (r < 0)r = m;
	eval(k, l, r);
	if (b <= l || r <= a)return;
	if (a <= l && r <= b) {
		lazy[k] = x;
		lazyflag[k] = true;
		eval(k, l, r);
	}
	else {
		update(a, b, x, 2 * k + 1, l, (l + r) / 2);
		update(a, b, x, 2 * k + 2, (l + r) / 2, r);
		node[k] = min(node[2 * k + 1], node[2 * k + 2]);
	}
}

int query(int a, int b, int k = 0, int l = 0, int r = -1) {
	if (r < 0)r = m;
	eval(k, l, r);
	if (b <= l || r <= a)return INF;
	if (a <= l && r <= b)return node[k];
	int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
	int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
	return min(vl, vr);
}
int n, q, s[200010], t[200010], x[200010], d[200010];
tuple<int, int, int> tp[200010];
map<int, int> zaatu, g;
signed main() {
	int n, q;
	cin >> n >> q;
	zaatu[0] = 0;
	zaatu[INF] = 0;
	rep(i, n) {
		cin >> s[i] >> t[i] >> x[i];
		s[i] -= x[i]; t[i] -= x[i];
		s[i] = max(0, s[i]);
		if (t[i] <= s[i])continue;
		zaatu[s[i]] = zaatu[t[i]] = 0;
	}
	rep(i, q) {
		cin >> d[i];
		zaatu[d[i]] = 0;
	}
	int cnt = 0;
	for (auto ite = zaatu.begin(); ite != zaatu.end(); ite++) {
		(*ite).second = cnt;
		g[cnt] = (*ite).first;
		cnt++;
	}
	init(zaatu.size());
	int num = 0;
	rep(i, n) {
		if (t[i] <= s[i])continue;
		s[i] = zaatu[s[i]];
		t[i] = zaatu[t[i]];
		tp[num] = make_tuple(x[i], s[i], t[i]);
		num++;
	}
	sort(tp, tp + num, greater<tuple<int, int, int>>());
	rep(i, num) {
		update(get<1>(tp[i]), get<2>(tp[i]), get<0>(tp[i]));
	}
	rep(i, q) {
		int p = zaatu[d[i]];
		if (query(p, p + 1) == INF)cout << -1 << endl;
		else cout << query(p, p + 1) << endl;
	}
}

Measured memory_bytes: 84096
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, p[100005];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> p[i];
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (p[i] == i) {
			swap(p[i], p[i+1]);
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
using namespace std;

const static int MAX = 100;

void printData(int *a, int n)
{
    int i = 0;
    while (i < n - 1)
    {
        printf("%d ", a[i]);
        i++;
    }
    printf("%d", a[n - 1]);
}

int main()
{
    int data[MAX];
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &data[i]);
    }

    printData(data, N);
    printf("\n");
    for (int i = 1; i < N; i++)
    {
        int temp = data[i];
        int j = i - 1;
        while(j>=0&&data[j]>temp)
        {
            data[j+1] = data[j];
            j--;
        }
        
        // while (j >= 0) //这里最好使用while循环，j-1放在if语句里
        // {
        //     if (data[j] >= temp)
        //     {
        //         data[j + 1] = data[j];
        //         j--;
        //     }
        //     else
        //     {
        //         break;
        //     }
        // }
        data[j + 1] = temp;
        printData(data, N);
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 3196
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, *lst = map(int, read().split())
al = lst[:n]
bl = lst[n:]


def convert(A):
    return [x ^ y for x, y in zip(A, A[1:])] + [A[-1] ^ A[0]]


a = convert(al)
b = convert(bl)


def Z_algorithm(s):
    n = len(s)
    z = [0] * n
    l, r = 0, 0
    for i in range(1, n):
        if i <= r:
            z[i] = z[i - l] if z[i - l] < r - i else r - i - 1
        while i + z[i] < n and s[z[i]] == s[i + z[i]]:
            z[i] += 1
        if i + z[i] - 1 > r:
            l, r = i, i + z[i] - 1
    return z


Z = Z_algorithm(b + [-1] + a + a)[n + 1:n + n + 1]

K = [i for i, x in enumerate(Z) if x == n]
X = [al[k] ^ bl[0] for k in K]

print('\n'.join('{} {}'.format(k, x) for k, x in zip(K, X)))

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

const long long MOD = 1000000007;

const int MAX = 5100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void solve(std::vector<long long> r, std::vector<long long> c){
    COMinit();
    ll ans =0;
    for(ll y=c[0];y<=c[1];y++){
        ans += (COM(y+r[1]+1,r[1]) - COM(y+r[0],r[0]-1)+ MOD);
        ans %= MOD;
    }
    cout << ans << endl;


}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::vector<long long> r(2);
    std::vector<long long> c(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&r[i]);
        scanf("%lld",&c[i]);
    }
    solve(std::move(r), std::move(c));
    return 0;
}


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

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(a>=b&&a>=c)
    cout << a*pow(2,k)+b+c << endl;
  else if(b>=a&&b>=c)
    cout << b*pow(2,k)+a+c << endl;
  else
    cout << c*pow(2,k)+a+b << endl;
  return 0;
}

Measured memory_bytes: 4116
import java.io.*;
import java.util.*;

public class Main {
public static void main(String[] args) throws IOException {
  Scanner sc = new Scanner(System.in);
  PrintWriter pw = new PrintWriter(System.out);
  int n = sc.nextInt();
  pw.println(n*n*n);
  sc.close();
  pw.close();
}
}

Measured memory_bytes: 22228
a,b,c = gets.split.map(&:to_f)
s = a * b * Math.sin(c/180*Math::PI) / 2
l = a + b + Math.sqrt(a**2 + b**2 - 2*a*b*Math.cos(c/180*Math::PI))
h = b * Math.sin(c/180*Math::PI)

puts [s,l,h]

Measured memory_bytes: 8960
// ------------------------------------
// Date:2018/ 3/31
// Problem:Move to Win 020.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  string ans;
  CIN(N, A, B);
  if (N == 2) ans = "Borys";
  else {
    if ((B - A) & 1) ans = "Borys";
    else ans = "Alice";
  }

  cout << ans << endl;
  return 0;
}



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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,m;
	cin >> n >> m;
	vector<bool> ac(n);
	vector<int> pen(n);
	int res=0;
	int sei=0;
	for(int i=0;i<m;i++){
		int p;
		string str;
		cin >> p >> str;
		p--;
		if(ac[p]) continue;
		if(str=="AC"){
			ac[p]=true;
			res+=pen[p];
			sei++;
		}else{
			pen[p]++;
		}
	}
	cout << sei << " " << res << "\n";
	return 0;
}

Measured memory_bytes: 640
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

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

	if (D == 0) {
		if (N != 100) cout << N << endl;
		else cout << 101 << endl;
	}
	else if (D == 1) {
		if (N != 100) cout << N * 100 << endl;
		else cout << 10100 << endl;
	}
	else if (D == 2) {
		if (N != 100) cout << N * 10000 << endl;
		else cout << 1010000 << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N, M;
	cin >> N >> M;
	vector<int>a(N);
	int LCM1 = 0, LCM2 = 0;
	int judge;
	rep(i, N)
	{
		cin >> a[i];
		if (!i)
		{
			LCM1 = a[i];
			LCM2 = a[i] / 2;
		}
		else
		{
			LCM1 = lcm(LCM1, a[i]);
			LCM2 = lcm(LCM2, a[i] / 2);
		}
		if (LCM2 > M)
		{
			cout << 0;
			return 0;
		}
	}
	rep(i, N)
	{
		if ((LCM2 / (a[i] / 2)) % 2 == 0)
		{
			cout << 0;
			return 0;
		}
	}
	int ans = (M - LCM2) / LCM1 + 1;
	cout << ans;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<ctype.h>
int main(void){
    int i;
    char str[100];
    gets(str);
    for(i=0;i<strlen(str);i++){
        if(islower(str[i]))
            str[i]-=32;
    }
    printf("%s\n",str);
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
//get the biggest element.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  int x, y;
  cin >> x >> y;

  bool ok = false;
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      int q = y;
      q -= 2 * i;
      q -= 4 * j;
      if (q == 0 && i + j == x) ok = true;
    }
  }

  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
//#define INF (1LL<<31)-1
//#define MOD 998244353
#define MOD 1000000007

int main(){
    string str;
    cin>>str;
    int s[10];
    ll ans=0;
    int siz=str.length();
    rep(i,0,siz)s[i]=str[i]-48;
    
    for(int bit=0;bit<(1<<siz-1);bit++){
        bool f[9]={};
        rep(i,0,siz-1)if(bit&(1<<i))f[i]=1;
        
        ll t=0,p=s[0];
        rep(i,1,siz){
            if(f[i-1]){
                p*=10;
                p+=s[i];
            }else{
                t+=p;
                p=s[i];
            }
        }
        t+=p;
        ans+=t;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
N=int(input())
D=list(map(int,input().split()))
mod=998244353
ans=1
count=[0 for i in range(0,N)]
for i in range(0,N):
    count[D[i]]+=1

able=True
if D[0]!=0 or count[0]!=1:
    able=False
for i in range(0,N-1):
    if count[i]==0 and count[i+1]!=0:
        able=False

if able:
    for i in range(0,N-1):
        ans=(ans*pow(count[i],count[i+1],mod))%mod
    print(ans)
else:
    print(0)

Measured memory_bytes: 56620
#include<bits/stdc++.h>
using namespace std;
int k;
int get(int a, int n)
{
    if(n==0) return a;
    return min(get(a*2,n-1),get(a+k,n-1));
}
int main()
{
    int n;
    cin>>n>>k;
    int k=1;
    cout<<min(get(2,n-1),get(1+k,n-1))<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

int main(){
    int n; cin >> n;
    vector<int> count(100010, 0);
    rep(i, n){
        int a; cin >> a;
        count[a]++;
    }

    int ans;
    int ans_max = 0;
    rep(i, 100000){
        ans = count[i] + count[i + 1] + count[i + 2];
        ans_max = max(ans, ans_max);
    }
    cout << ans_max << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> void chmax(Type_a &a,const Type_b &b){if(a<b)a=b;}
template<class Type_a,class Type_b> void chmin(Type_a &a,const Type_b &b){if(a>b)a=b;}
template<class Type> Type igcd(Type x,Type y){if(x==0||y==0)return (x>y)?x:y;return (y%x)?igcd(y%x,x):x;}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n,m;
	cin>>n>>m;
	
	bool s[n+1]={};
	bool g[n+1]={};
	s[1]=g[n]=true;
	REP(i,m){
		int a,b;
		cin>>a>>b;
		if(a==1) s[b]=true;
		if(b==n) g[a]=true;
	}
	
	for(int i=1;i<=n;++i){
		if(s[i] and g[i]){
			cout<<"POSSIBLE"<<endl;
			return 0;
		}
	}
	
	cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 640