akhauriyash/Code-Regression huggingface dataset:
n, h = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
a.sort()
x = a[-1][0]
a = sorted(a, key=lambda x:x[1])
y = 0
for i in range(1, n+1):
    if a[-i][1] <= x:
        h -= 0.5
        print(int(y+h//x+1))
        break
    h -= a[-i][1]
    y += 1
    if h <= 0:
        print(y)
        break
else:
    h -= 0.5
    print(int(y+h//x+1))

Measured memory_bytes: 30064
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

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

    if (a >= b) swap(a, b);
    if (a == 1) {
        cout << 1 << endl;
        return 0;
    }

    int out = 1;
    int p_max = (int)sqrt(a);

    for (int i = 2; i <= p_max; i++) {
        bool fa = false, fb = false;
        if (a % i == 0) {
            fa = true;
            while (a % i == 0) a /= i;
        }
        if (b % i == 0) {
            fb = true;
            while (b % i == 0) b /= i;
        }
        if (fa && fb) out++;
        if (a == 1 || b == 1) break;
    }
    if (a > 1 && b % a == 0) out++;

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
nab = [list(map(int, input().split())) for x in range(n)]
mab = [list(map(int, input().split())) + [x + 1] for x in range(m)]
print("\n".join(map(str, [min(mab, key=lambda x: abs(x[0] - a) + abs(x[1] - b))[-1] for a, b in nab])))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main(){
    ll r = 0, g = 0, b = 0, res = 0;
    ll n; cin >> n;
    string s; cin >> s;
    rep(i,n){
        if(s[i] == 'R')r++;
        if(s[i] == 'G')g++;
        if(s[i] == 'B')b++;
    }
    res = r*g*b;
    REP(d,1,n+1)rep(j,n){
        int i = j - d;
        int k = j + d;
        if(i < 0 || k >= n)continue;
        if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i])res--;
    }
    cout << res << endl;
    return 0;
}


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


int main() {
  ll n;
  cin >> n;
  vector<ll> a(3*n);
  rep(i, 3*n) cin >> a[i];
  sort(a.begin(), a.end());
  
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[n + 2*i];
  }
  cout << ans << endl;
}



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

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc == '-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

int main(){
	int a=rd(),b=rd();
	printf("%d",a-b+1);
	return 0;
}

Measured memory_bytes: 256
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    N, M = map(int, line_input())
    gate = [0 for n in range(N+1)]
    for i in range(M):
        l, r = map(int, line_input())
        gate[l-1] += 1
        gate[r] -= 1
    ans = (1 if gate[0] == M else 0)
    for i in range(1, N):
        gate[i] = gate[i] + gate[i-1]
        if gate[i] == M: ans += 1
    print(ans)
    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 7436
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
using namespace std;

#define re_ return
#define in_ inline
#define op_ operator
#define inc(l, i, r) for(i=l; i<r; ++i)
#define st_ static
typedef long long ll;

const int mxn=1<<9;

int n, m, a[mxn], b[mxn<<1], cnt[2], h[mxn<<1];
struct edge{int v, o;} e[1<<20];

in_ ll dP(ll a, ll b, ll p)
{
    st_ ll r;
    for(r=1; b; a=a*a%p, b>>=1)
        b&1? r=r*a%p: 0;
    re_ r;
}

in_ char chk(ll a, ll p)
{
    st_ ll s, r, i;
    for(r=p-1, s=0; ~r&1; ++s, r/=2);
    if(i=dP(a, r, p), i==1 || i==p-1) re_ 1;
    for(;s--;)
        if((i=i*i%p)==p-1) re_ 1;
    re_ 0;
}

in_ char isP(int p)
{
    if(p==2) re_ 1;
    if(p==1 || ~p&1) re_ 0;
    st_  int i;
//    inc(0, i, 48)
//        if(!chk(rand()%(p-2)+1, p))
//            re_ 0;

    for(i=2; i*i<=p; ++i)
        if(p%i==0)
            re_ 0;
    re_ 1;
}

in_ void aE(int u, int v)
{
    st_ int tot;
    e[++tot]=(edge){v, h[u]}, u[h]=tot;
}

char vis[mxn<<1];
char Hun(int u)
{
    st_ int f[mxn<<1];
    int i, v;
    for(i=u[h]; v=i[e].v; i=i[e].o)
        if(!vis[v])
            if(vis[v]=1, !f[v] || Hun(f[v]))
            re_ f[v]=u, 1;
    re_ 0;
}

int main()
{
    srand(998244353);
    int i, j;
    scanf("%d", &n);
    inc(0, i, n)
        scanf("%d", a+i);
    sort(a, a+n);
    inc(0, i, n)
    {
        if(!i || a[i]>a[i-1]+1)
            b[++m]=a[i], ++cnt[a[i]&1];
        if(i>n-2 || a[i]<a[i+1]-1)
            b[++m]=a[i]+1, ++cnt[a[i]+1&1];
    }
    inc(1, i, m+1)
        if(b[i]&1)
            inc(1, j, m+1)
                if(~b[j]&1 && isP(abs(b[i]-b[j])))
                    aE(i, j);

    j=0;
    inc(1, i, m+1)
        if(b[i]&1)
            memset(vis, 0, sizeof(vis)),
                j+=Hun(i);

    printf("%d\n", cnt[0]+cnt[1]-j+(cnt[0]-j&1));
//    printf("%d\n", m);
//    for(;;) scanf("%d", &i), printf("%d\n", isP(i));
    0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int M, N , x ;
  cin >> N;
  x = 0;
  M = N;
 for (int i = 0; i < 8; i++) {
   x += M % 10;
   M = M / 10;
 }

  if ( N % x == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
/**
 * Author: Martin Leshko (leshko.martin@gmail.com)
 */
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  double dist = 0;
  vector<int> ind;
  for (int i = 0; i < n; i++) {
    ind.push_back(i);
  }
  auto ddd = [&](int i, int j) {
#define sqr(x) (1.0 * (x) * (x))
    return sqrt(1.0 * sqr(1.0 * x[j] - x[i]) + 1.0 * sqr(1.0 * y[j] - y[i]));
  };
  double cnt = 0;
  do {
    double sum = 0;
    for (int i = 1; i < n; i++) {
      sum += ddd(ind[i], ind[i - 1]);
    }
    dist += sum;
    cnt++;
  } while (next_permutation(ind.begin(), ind.end()));
  dist /= cnt;
  cout << fixed << setprecision(7) << dist << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
static const int MAX =200000;

int main(){
int R[MAX],n;

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

int maxv = -2000000000;
int minv = R[0];

for(int i=1;i<n;i++){
maxv = max(maxv,R[i]-minv);
minv = min(minv,R[i]);
}
cout << maxv << endl;

return 0;
}


Measured memory_bytes: 3868
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int p, q, r; cin >> p >> q >> r;
    cout << (p + q + r) - max({p, q, r}) << endl;
    return 0;
}


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

using namespace std;

int main()
{
  int N; cin >> N;
  int T, A; cin >> T >> A;
  vector<int> H(N);
  for (int i = 0; i < N; ++i) {
    cin >> H[i];
  }

  double mymin = 1e5+7;
  int ans;
  for (int i = 0; i < N; ++i) {
    double tmp = abs(T - H[i] * 0.006 - A);
    if (mymin > tmp) {
      mymin = tmp;
      ans = i+1;
    }
  }

  cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int i;
	long long int a[200005];
	for(i=0;i<n;i++)
		scanf("%lld",&a[i]);
	long long int sum[200005],xsum[200005];
	sum[0]=0;
	for(i=0;i<n;i++)
		sum[i+1]=sum[i]+a[i];
	xsum[0]=0;
	for(i=0;i<n;i++)
		xsum[i+1]=xsum[i]^a[i];
	long long int l,r;
	l=r=0;
	long long int ans=0;
	while(l<n)
	{
		if(r<n-1)
		{
			while((xsum[r+2]^xsum[l])==(sum[r+2]-sum[l]))
			{
				r++;
				if(r==n-1)
					break;
			}
		}
		ans+=r-l+1;
		l++;
		if(r<l)
			r++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
const int maxn = 301;

double n, dp[maxn][maxn][maxn];
bool vis[maxn][maxn][maxn];

double dfs(int x, int y, int z)
{
    if (x == -1 || y == -1 || z == -1)
        return 0.0;
    if (vis[x][y][z])
        return dp[x][y][z];
    vis[x][y][z] = 1;
    double denom = x + y + z;
    return dp[x][y][z] = (dfs(x - 1, y, z) * x + dfs(x + 1, y - 1, z) * y + dfs(x, y + 1, z - 1) * z + n) / denom;
}

int main()
{
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#endif
    int t, tmp[3] { 0, 0, 0 };
    scanf("%d", &t), n = t;
    for (int i = t; i--;)
        scanf("%d", &t), ++tmp[t - 1];
    vis[0][0][0] = 1;
    printf("%.9f\n", dfs(tmp[0], tmp[1], tmp[2]));
}

Measured memory_bytes: 239872
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> void Max(T &m, const T q) { if (m < q) m = q; }
template<typename T> void Min(T &m, const T q) { if (m > q) m = q; }
template<typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

string S;
string T = "CODEFESTIVAL2016";

int main()
{
    cin >> S;
    int n = 0;
    REP(i, S.length()) n += (S[i] != T[i]);
    cout << n << endl;
}


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

#define REP(i,N) for(int i=0;i<N;++i)

int main(){
    while(true){
        int n;
        cin>>n;
        if(n==0){
            break;
        }
        int lv=0;//深さレベル
        vector<int> mode(0);//0:plane, 1:sum, 2:prod
        vector<vector<int>> args(1,vector<int>());
        //int ans=0;
        REP(i,n){
            string s;
            cin>>s;
            int dots=0;
            //cout<<s<<endl;
            while(s[dots]=='.'){
                //cout<<"hoge";
                dots++;
            }
            char c=s[dots];//本体
            //cout<<(c=='+')<<endl;
            //計算が走る
            while(lv>dots){
                if(mode.back()==1){
                    int a=0;
                    //cout<<"sum ";
                    REP(j, args.back().size()){
                        a += args.back()[j];
                        //cout<<args.back()[j]<<" ";
                    }
                    args.pop_back();
                    args.back().push_back(a);
                } else if(mode.back()==2){
                    int a=1;
                    //cout<<"prod ";
                    REP(j, args.back().size()){
                        //cout<<args.back()[j]<<" ";
                        a *= args.back()[j];
                    }
                    args.pop_back();
                    args.back().push_back(a);
                }
                //cout<<endl;
                mode.pop_back();
                lv--;
            }
            //lv==dots
            if(c=='+'){
                //cout<<"hoge";
                lv++;
                mode.push_back(1);
                args.push_back(vector<int>());
            } else if(c=='*'){
                lv++;
                mode.push_back(2);
                args.push_back(vector<int>());
            } else {
                int a= c-'0';
                args.back().push_back(a);
            }
        }
        while(lv>0){
            if(mode.back()==1){
                int a=0;
                //cout<<"sum ";
                REP(j, args.back().size()){
                    a += args.back()[j];
                    //cout<<args.back()[j]<<" ";
                }
                args.pop_back();
                args.back().push_back(a);
            } else if(mode.back()==2){
                int a=1;
                //cout<<"prod ";
                REP(j, args.back().size()){
                    //cout<<args.back()[j]<<" ";
                    a *= args.back()[j];
                }
                args.pop_back();
                args.back().push_back(a);
            }
            //cout<<endl;
            mode.pop_back();
            lv--;
        }
        cout<<args.back()[0]<<endl;
    }
}



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

int FirstDigit(int num){
    while(num > 9){
        num /= 10;
    }
    return num;
}

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

    int n;
    cin >> n;

    map<pair<int, int>, int> mp;
    for(int i = 1; i <= n; i++){
        if(i % 10 == 0) continue;
        int fd = FirstDigit(i);
        int ld = i % 10;
        mp[make_pair(fd, ld)]++;
    }

    int ans = 0;
    for(auto x: mp){
        int fd = x.first.first;
        int ld = x.first.second;
        ans += x.second * (mp[make_pair(ld, fd)]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip> 
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
ll n , a[N] , d[N] , sum = 0;
int main(){
fcin;
	cin >> n;
	for(ll i = 1 ; i <= n ; i++){
		cin >> a[i];
		d[a[i]]++;
		sum += a[i];
	}
	ll q;
	cin >> q;
	while(q--){
		ll x , y;
		cin >> x >> y;
		sum -= (d[x]*x);
		// d[x] = 0;
		sum += (d[x]*y);
		d[y] += d[x];
		d[x] = 0;
		cout << sum << '\n';
		}
 
 
}

Measured memory_bytes: 4740
#include<stdio.h>
#include<string.h>
main(){
  char str[100],str1[100];
  int cnt=0,i,l,j;
 
  while(scanf("%s",str)!=EOF){
    l=strlen(str);
    for(i=0,j=l-1;j>=0;i++,j--) str1[i]=str[j];
    str1[l]='\0';
    if(strcmp(str,str1)==0)cnt++;
  }
 
  printf("%d\n",cnt);
  return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
typedef long long LL;
const int maxn = 100000+10;
int color[maxn][15];
int v[maxn];
int d[maxn];
int c[maxn];
vector <int> node[maxn];
void paint(int v1, int d1, int c1)
{
    if(d1==-1)  return;
    if(color[v1][d1] ) return;
    color[v1][d1] = c1;
    for(int i =0;i<node[v1].size();i++)
        paint(node[v1][i], d1-1, c1);
}
int main()
{
    ios::sync_with_stdio(0);
    memset(color, 0, sizeof color);
    int N, M;
    cin >> N >>M;
    for(int i=1;i<=M;i++){
        int a, b;
        cin >> a >> b;
        node[a].push_back(b);
        node[b].push_back(a);
    }
    ///自己指向自己
    for(int i=1;i<=N;i++)
        node[i].push_back(i);
    int q;
    cin >> q;
    for(int i=1;i<=q;i++)
        cin >> v[i] >> d[i] >> c[i];
    for(int i=q;i>=1;i--)
        paint(v[i], d[i], c[i]);
    for(int i=1;i<=N;i++)
        cout << color[i][0] << endl;
    return 0;
}


Measured memory_bytes: 13560
#include<bits/stdc++.h>
using namespace std;long long a[5],s,n,p,i,b[4]={0,0,1,3};main(){cin>>n;for(i=0;i<n;i++){cin>>a[i];s+=a[i];}sort(a,a+n);if(n<4){p=b[n];}if(n==4){if(s<9){p=4;}else if(a[0]<3){p=5;}else{p=6;}}if(n==5){if(s<12){p=6;}else if(a[1]<3){p=7;}else if(a[0]<3||a[3]<4){p=8;}else if(a[0]<4){p=9;}else{p=10;}}cout<<s-p<<endl;}

Measured memory_bytes: 1172
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    int a,b;cin>>a>>b;
    string s1="",s2="";
    for(int i=0;i<b;i++)s1+=to_string(a);
    for(int i=0;i<a;i++)s2+=to_string(b);
    cout<<mmin(s1,s2)<<Endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------








































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); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

const long long INF = 1LL << 60;
#define N 3

int main(){
  int a[N][N];
  rep(i, N) rep(j, N) cin >> a[i][j];

  int n; cin >> n;
  bool open[N][N];
  rep(i, N) rep(j, N) open[i][j] = false;
  rep(k, n){
    int b; cin >> b;
    rep(i, N) rep(j, N){
      if(a[i][j] == b) open[i][j] = true;
    }
  }

// bool ok = false;
// if(open[0][0] && open[0][1] && open[0][2]) ok = true;
// if(open[1][0] && open[1][1] && open[1][2]) ok = true;
// if(open[2][0] && open[2][1] && open[2][2]) ok = true;
// if(open[0][0] && open[1][0] && open[2][0]) ok = true;
// if(open[0][1] && open[1][1] && open[2][1]) ok = true;
// if(open[0][2] && open[1][2] && open[2][2]) ok = true;
// if(open[0][0] && open[1][1] && open[2][2]) ok = true;
// if(open[0][2] && open[1][1] && open[2][0]) ok = true;
//
// cout << (ok ? "Yes" : "No") << endl;

  bool ok;
  rep(i, N){
    ok = true;
    rep(j, N) if(!open[i][j]) ok = false;
    if(ok){ cout << "Yes" << endl; return 0; }
  }
  rep(j, N){
    ok = true;
    rep(i, N) if(!open[i][j]) ok = false;
    if(ok){ cout << "Yes" << endl; return 0; }
  }
  ok = true;
  rep(i, N) rep(j, N) if(i == j){
    if(!open[i][j]) ok = false;
  }
  if(ok){ cout << "Yes" << endl; return 0; }
  
  ok = true;
  rep(i, N) rep(j, N) if(i+j == N-1){
    if(!open[i][j]) ok = false;
  }
  if(ok){ cout << "Yes" << endl; return 0; }
  
  cout << "No" << endl;
  
  return 0;
}


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

int main()
{
    int n, m, c, ans = 0, b[20];
    cin >> n >> m >> c;

    for (int in = 0; in < m; in++)
    {
        cin >> b[in];
    }

    for (int i = 0; i < n; i++)
    {
        int temp = 0;
        int a[20];
        for (int in = 0; in < m; in++)
        {
            cin >> a[in];
            temp += b[in] * a[in];
        }

        if (temp + c > 0) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

bool pos_x[8000][16001];
bool pos_y[8000][16001];

int main()
{
	string s;
	int x, y, len, f = 0, xlen, ylen;
	bool firstF = true, ans = false, direct_x = true;
	vector<int> go_x, go_y;

	cin >> s >> x >> y;
	len = s.length();

	rep(i, len) {
		if (firstF && s[i] == 'F') {
			x--;
			continue;
		}
		firstF = false;

		if (s[i] == 'T') direct_x = !direct_x;
		else {
			f++;
			if (i == len - 1 || s[i + 1] != 'F') {
				if (direct_x) go_x.push_back(f);
				else go_y.push_back(f);
				f = 0;
			}
		}
	}

	x += 8000;
	y += 8000;
	pos_x[0][8000] = true;
	pos_y[0][8000] = true;
	xlen = go_x.size();
	ylen = go_y.size();

	rep(i, xlen) {
		int d = go_x[i];
		repc(j, 0, 16000) {
			if (j + d <= 16000 && pos_x[i][j + d]) pos_x[i + 1][j] = true;
			if (j - d >= 0 && pos_x[i][j - d]) pos_x[i + 1][j] = true;
		}
	}

	rep(i, ylen) {
		int d = go_y[i];
		repc(j, 0, 16000) {
			if (j + d <= 16000 && pos_y[i][j + d]) pos_y[i + 1][j] = true;
			if (j - d >= 0 && pos_y[i][j - d]) pos_y[i + 1][j] = true;
		}
	}

	if (pos_x[xlen][x] && pos_y[ylen][y]) ans = true;

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 64256
#include <bits/stdc++.h>
using namespace std;
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; }

const long long INF = 1LL << 60;

long long h[100010];

long long dp[100010];

int main() {
  int n; cin>>n;
  for(int i=0; i<n;i++){
    cin>>h[i];
  }
  for(int i=0;i<100010;i++){
    dp[i]=INF;
  }
  
  dp[0]=0;
  for(int i=1;i<n;i++){
    chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
    if(i>1) chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>
#include<numeric>

using namespace std;


long long gcd(long long a, long long b){
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)){
    a = b;
    b = r;
  }
  return b;
}

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

  long long gcd2;
  long long gcd3;
  long long ans = 0;

  for(int i=1; i<=K; i++){
    for(int j=1; j<=K; j++){
      gcd2 = gcd(i, j);
      for(int k=1; k<=K; k++){
        ans += gcd(gcd2, k);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;
typedef pair<int,int> P;

int main()
{

    lint W,H,x,y;
    cin >> W >> H >> x >> y;





	long double ans=W*H/2.0;
	int ans2;
	if(W==x*2 && H==y*2) ans2 = 1;
	else ans2 = 0;


	cout << ans << " " << ans2 << endl;





}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


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


    int n;
    cin >> n;

    int f = 0, s = 0;
    if (n % 100 <= 12 && n % 100) {
        f = 1;
    }

    if (n / 100 <= 12 && n / 100) {
        s = 1;
    }

    if (f == 1 && s == 1) {
        cout << "AMBIGUOUS";
    }

    else if (f == 0 && s == 0) {
        cout << "NA";
    }

    else if (f == 0) {
        cout << "MMYY";
    }

    else {
        cout << "YYMM";
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long int ll;
int N;
ll P[100000];
ll J[100000];
ll ans;
ll Psum;
int main()
{
	while (true){
		Psum = 0;
		ans = -1;
		scanf("%d", &N);
		if (N == 0)break;
		for (int i = 0; i < N; i++)scanf("%lld", &P[i]);
		for (int i = 0; i < N - 1; i++)scanf("%lld", &J[i]);
		sort(J, J + N - 1);
		reverse(J, J + N - 1);
		for (int i = 0; i < N; i++)Psum += P[i];
		for (int i = 0; i < N - 1; i++){
			ans = max(ans, Psum*(N - i));	
			Psum += J[i];
		}
		ans = max(ans, Psum);
		printf("%lld\n", ans);
	}
	return 0;
}
//scanf_s

Measured memory_bytes: 2228
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
using namespace std ;

int n , m ;

void input ( ) {
    scanf ( "%d%d" , &n , &m ) ;
}

void solve ( ) {
    int ans = 0 ;
    for ( int i = 1 ; i <= m ; ++ i ) {
        int x = ( i % 10 ) ;
        int y = ( i / 10 ) ;
        if ( x >= 2 && y >= 2 && x * y <= n ) {
            ++ ans ;
        }
    }
    printf ( "%d\n" , ans ) ;
}

int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
const int INF = 1e9 + 7;

using namespace std;

#define MAX_V 101
int d[MAX_V][MAX_V];
int V;

int main(){
    scanf("%d",&V);
    int v = V+1,e,a[1000],b[1000],c[1000],ans=0;
    FOR(i,1,v) FOR(j,1,v) d[i][j] = INF;
    REP(i,v) d[i][i] = 0;
    scanf("%d",&e);
    REP(i,e) scanf("%d%d%d",a+i,b+i,c+i);
    REP(i,e) d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];

    FOR(k,1,v) FOR(i,1,v) FOR(j,1,v) d[i][j] = min(d[i][j],d[i][k] + d[k][j]);

    bool used;
    REP(i,e){
        used = true;
        FOR(s,1,v) if(d[s][a[i]] + c[i] == d[s][b[i]]) used = false;
        if(used) ++ans;
    }

    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#define PLL pair<ll, ll>
#define F first
#define S second

using namespace std;

typedef long long ll;

ll n;
ll a[200005], b[200005];
priority_queue<PLL> pq;
ll cnt;

int main()
{
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &b[i]);
        pq.push(make_pair(b[i], i));
    }
    while(!pq.empty())
    {
        ll t1 = pq.top().F, t2 = pq.top().S;
        pq.pop();
        if(a[t2] == b[t2]) continue;
        if(b[t2] < a[t2])
        {
            printf("-1\n");
            return 0;
        }
        if(b[t2] <= b[(t2 + n - 1) % n] || b[t2] <= b[(t2 + 1) % n]) continue;
        ll t3 = b[t2] - a[t2];
        ll t4 = b[(t2 + n - 1) % n] + b[(t2 + 1) % n];
        ll t5 = (t3 + t4 - 1) / t4;
        ll t6 = b[t2] - t5 * t4;
        cnt += t5;
        if(t6 < a[t2]) t6 += t4, cnt--;
        if(t6 == b[t2]) continue;
        b[t2] = t6;
        pq.push(make_pair(b[t2], t2));
    }
    for(ll i = 0; i < n; i++)
    {
        if(b[i] != a[i])
        {
            printf("-1\n");
            return 0;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

// definitions
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define pb push_back
#define mod1 998244353
#define mod 1000000007
#define MAX_CHAR 256

using namespace std;
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dq;
typedef long long int lli;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;


// standard functions
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 
 


ll modexp(ll x, ll ex, ll modp) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x)%modp;
        ex >>= 1ll;
        x = (x * x)%modp;
    }
    return ans;
} 
 
ll nCrModp(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
    for (ll i = 1; i <= n; i++) 
    { 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
}
 
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true;  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
vl countFreq(ll arr[], ll n) 
{ 
    unordered_map<ll, ll> mp; 
    vector <ll> v;
    
    for (ll i = 0; i < n; i++) 
        mp[arr[i]]++; 
   
    for (auto x : mp) 
        v.pb(x.second);
    
    return v;
}

ll binarySearch(ll arr[], ll l, ll r, ll x) 
{ 
    while (l <= r) 
    { 
        ll m = l + (r - l) / 2; 
        if (arr[m] == x) 
            return m; 
        if (arr[m] < x) 
            l = m + 1; 
        else
            r = m - 1; 
    }
    return -1; 
}

const ll MAXSIEVE=(1e3);
ll spf[MAXSIEVE];
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXSIEVE; i++) 
        spf[i] = i; 

    for (ll i=4; i<MAXSIEVE; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXSIEVE; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXSIEVE; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}

// code beigns in main
int main()
{
    
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    
    while(t--)
    {
        ld r;
        cin >> r;

        ld area=M_PI*r*2;
        cout << area << endl;
    }
}



Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
bool flag = true;
bool flag2 = true;

const int MAX = 510000;
ll fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
	fac[0] = fac[1] = 1;//階乗
	finv[0] = finv[1] = 1;//階乗の逆元
	inv[1] = 1;//逆元(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;//inv[i] = iの逆元(mod mod)
		finv[i] = finv[i - 1] * inv[i] % mod;//階乗の逆元の計算
	}
}

ll mod_pow(ll x,ll n){
	ll res = 1;
	while(n > 0){
		if(n & 1){
			res = res * x % mod;
		}
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}



int main(){
	ll n,a,b;cin>>n>>a>>b;
	COMinit();
	ll c1 = 1LL;
	for(ll i = 1; i <= a; i++) {
		c1 *= (n - i + 1LL);
		c1 %= mod;
	}
	c1 *= finv[a];
	c1 %= mod;
	ll c2 = 1LL;
	for(ll i = 1; i <= b; i++) {
		c2 *= (n - i + 1LL);
		c2 %= mod;
	}

	c2 *= finv[b];
	c2 %= mod;
	ll ans = mod_pow(2,n) - 1LL;
	ans -= c1; 
	ans %= mod;
	if (ans < 0LL){
		ans += mod;
	}
	ans -= c2; 
	ans %= mod;
	if (ans < 0LL){
		ans += mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12160
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();

        int ans = 0;

        for(int i = 0; i <= A;i++){
            for(int j = 0;j <= B;j++){
                for(int k=0;k <= C;k++){
                    if((X - 500*i - 100*j - 50*k) == 0){
                        ans++;
                    }    
                }
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23892
import numpy as np

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

b = [0] * M
c = [0] * M
for i in range(M):
    b[i], c[i] = map(int, input().split())

lst = np.array([c, b]).T.tolist()
lst.sort(reverse=True)
c = np.array(lst).T.tolist()[0]
b = np.array(lst).T.tolist()[1]

k = 0
judge = 0
for i in range(M):
    if k+b[i]-1 < N:
        if A[k+b[i]-1] < c[i]:
            A[k:k+b[i]] = [c[i]] * b[i]
            k += b[i]
        else:
            for j in range(b[i]):
                if k < N:
                    if A[k] < c[i]:
                        A[k] = c[i]
                        k += 1
                    else:
                        judge = 1
                        break
            if judge == 1:
                break
    elif k < N:
        for j in range(b[i]):
            if k < N:
                if A[k] < c[i]:
                    A[k] = c[i]
                    k += 1
                else:
                    judge = 1
                    break
        if judge == 1:
            break
    else:
        break

print(sum(A))

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

using namespace std;

typedef long long ll;

int main()
{
    int n;

    cin >> n;

    int a[n];

    cin >> a[0];

    ll xorV = a[0];

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

        xorV = (xorV ^ a[i]);
    }

    for(int i = 0; i < n; i++)
    {
        cout << (xorV ^ a[i]) << " ";
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 4236
n = int(input())
ta = 0
ha = 0

for i in range(n):
    taha = list(map(str, input().split()))
    jud = sorted(taha)
    #print(taha)
    #print(jud)
    if taha[0] == taha[1]:
        ta += 1
        ha += 1
    
    elif taha[0] == jud[0]:
        ha += 3

    else:
        ta += 3

print("{} {}" .format(ta, ha))


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>

lli dp[200100];
bool flag;
bool vis[200100];
lli n,m;
string s;

void func(lli now){
	if(now>n)return;
	if(DEBUG)cout<<"now="<<now<<"s.at(now="<<s.at(now)<<endl;
	if(s.at(now)=='1')return;
	if(vis[now])return;
	if(now==n){
		flag = true;
		return;
	}
	vis[now]=true;
	for(lli i=m;i>=1;i--){
		func(now+i);
		if(flag){
			cout<<i<<" ";
			return;
		}
	}
}

signed main(){

	cin>>n>>m;
	cin>>s;
	reverse(s.begin(),s.end());

	func(0);
	if(!flag){
		cout<<-1<<endl;
	}
	else cout<<endl;

	return 0;
}

Measured memory_bytes: 3840
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] a = new int[n]; 
		for (i = 0; i < a.length; i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		int top=0;
		int bottom=0;
		boolean up=false;
		boolean down=false;
		for (i = 1; i < a.length; i++) {
			if(a[i-1]<a[i]) {
				if(down) {
					bottom++;
					up=false;
				} else {
					up=true;
				}
				down=false;
			} else if(a[i-1]>a[i]) {
				if(up) {
					top++;
					down=false;
				} else {
					down=true;
				}
				up=false;
			}
		}
		out.println(top+bottom+1);
	}
}


Measured memory_bytes: 48408
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

#define INF LLONG_MAX/5
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define enld endl

//(x^n)%mを返す
int power(int x, int n, int m) {
	int res = 1;
	x %= m;
	while (n > 0) {
		if (n % 2 == 1) {
			res = res * x % m;
		}
		x = x * x % m;
		n /= 2;
	}
	return res;
}

//nの逆元を返す
int invmod(int n, int m) {
	int ret = 0;
	ret = power(n, m - 2, m);
	return ret;
}

//nCk%MODを返す
//O(k)
int comb(int n, int k, int m) {
	int ans = 1;
	rep(i, k) {
		ans *= n - i;
		ans %= m;
		ans *= invmod(k - i, m);
		ans %= m;
	}
	return ans;
}

signed main() {
	int S;
	cin >> S;
	int ans = 0;
	for (int size = 1; size <= S / 3; size++) {
		int a = S - 3 * size;
		int b = size;
		ans += comb(a + b - 1, a, MOD);
		ans %= MOD;
	}
	cout << ans << endl;
}

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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int a1=fsc.nextInt(), a2=fsc.nextInt(), a3=fsc.nextInt();
        fsc.close();
        System.out.println(a1+a2+a3>=22?"bust":"win");
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 22484
// ARC用の問題数　＝＝　ABC用の問題数
// は
// N/2番目に難しい問題がARC用の問題，
// N-1/2番目に難しい問題がABC用の問題であるは同義
//
//なので
//ソートし，N/2番目の要素から，N-1/2番目の要素を引いたものを出力

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

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

    sort(v.begin(), v.end());

    int ans = v[N/2] - v[(N-1)/2];

    cout << ans;
}

Measured memory_bytes: 640
N, M = map(int,input().split())
ac = [False] * N
wa = [0] * N
for _ in range(M):
    p_, s_ = map(str,input().split())
    p = int(p_)-1
    if s_ == 'AC':
        ac[p] = True
    else:
        if not ac[p]:
            wa[p] += 1

ans_ac,ans_wa = 0,0
for  i in range(N):
    if ac[i]:
        ans_ac += 1
        ans_wa += wa[i]
print(ans_ac,ans_wa)

Measured memory_bytes: 4596
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define rep(i,a,b,k) for(register ll i=a;i<=b;i+=k)
#define drep(i,a,b,k) for(register ll i=a;i>=b;i-=k)
#define ll long long
#define mod 1000000007
using namespace std;
char a[100005];
int len;
bool flag=1;
int main()
{
	scanf("%s",&a);
	len=strlen(a)-1;
	if(!(len&1))
		puts("No"),exit(0);
	for(int i=0,j=len;i<j;i++,j--)
	{
		if((a[i]=='p'&&a[j]=='q')||(a[i]=='q'&&a[j]=='p')||(a[i]=='d'&&a[j]=='b')||(a[i]=='b'&&a[j]=='d'));
		else
		{
			flag=0;
			break;
		}
	}
	if(flag)
		puts("Yes"),exit(0);
	puts("No");
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
using ll = long long;



int main() {
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(),a.end());
	cout << abs(a[1] - a[0]) + abs(a[2] - a[1]) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()

using namespace std;

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

    int n,k,q;
    cin >> n >> k >> q;

    vector<int> a(q),b(n);
    rep(i,q) cin >> a[i];

    rep(i,q){
        a[i]--;
        b[ a[i] ]++;
    }

    
    rep(i,n){
        bool ok = false;
        if(b[i]+k-q>0) ok = true;
        cout << ( ok ? "Yes" : "No" ) << endl;
    }

    
    return 0;
}

Measured memory_bytes: 1408
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  long n, t;
  readf("%s %s\n", &n, &t);
  auto ts = readln.chomp.split.to!(long[]);
  long sum = t;
  long c = t;
  foreach (e; ts[1..$]) {
    if (e < c) {
      sum -= c - e;
    }
    sum += t;
    c = e + t;
  }
  sum.writeln;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int INF = 1 << 27;
const ll LLINF = (ll)1 << 60;
const ll MOD = 1e9+7;

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

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }

  vector<ll> dp(n + 1, 0);
  for (int len = 1; len <= n; len++) {
    for (int i = 0; i <= n; i++) {
      // [i, j)
      int j = i + len;
      if (j > n) {
        dp[i] = 0;
      } else {
        dp[i] = max(a[i] - dp[i + 1], a[j - 1] - dp[i]);
      }
    }
  }

  printf("%lld\n", dp[0]);
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main(){
	long long N, M;
	long long work, work1;
	long long cnt = 0;
	cin >> N >> M;

	work = N;
	work1 = M;
	work1 -= work * 2;
	if(work1 < 0){
		cout << (M / 2) << endl;
		return 0;
	}
	cnt = work;
	cnt += work1 / 4;
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
	#include<vector>
	#include<algorithm>
	#include<string>
	#include<cmath>
	#include<map>
	#include<cstdio>
	#include<stack>
	#include<queue>
	#include<fstream>
	#include<cstdio>
	#include<deque>
	#include<iomanip>
	#include <numeric>
	//#include<bits/stdc++.h>

	using namespace std;
	#define ok1 printf("ok1\n");
	#define ok2 printf("ok2\n");
	#define M 1000000000000000000LL
	#define rep(i,n) for(int i=0;i<n;i++)
	#define REP(i,s,n) for(int i=(s);i<(n);i++)
	#define repr(i,n) for(int i=n-1;i>=0;i--)
	#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
	#define all(a) (a).begin(),(a).end()
	#define reall(a) (a).rbegin(),(a).rend()
	#define pb push_back
	#define pf push_front
	#define MIN(a,b) a=min((a),(b))
	#define MAX(a,b) a=max((a),(b))
	#define SIZE(v) (int)v.size()
	const double pi = acos(-1.0);

	typedef vector<int> vi;
	typedef vector<string> vs;
	typedef long long ll;
	typedef vector<ll> vll;
	typedef vector<vi> vvi;
	typedef vector<vll> vvll;
	typedef deque<ll> dll;
	typedef pair<ll, ll> P;
	const ll mod = 1e9 + 7;
	ll dx[4] = {1,0,-1,0};
	ll dy[4] = {0,1,0,-1};


	int main() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		
		ll n, l;
		cin >> n >> l;
		vs s(n);
		rep(i, n) {
			cin >> s[i];
		}
		sort(all(s));
		rep(i, n) {
			cout << s[i];
		}
		cout << endl;
		return 0;
	}	
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	bool c=0,f=0;
	getline(cin,s);
	int n=s.size();
	for(int a=0;a<n;a++)
	{
		if(s[a]=='C')
			c=1;
		if(s[a]=='F'&&c==1)
			f=1;
	}
	if(c==1&&f==1)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256