akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#define ll long long int
using namespace std;

int main(){
  int X,Y,A,B,C,n,i;
  cin >> X >> Y >> A >> B >> C;
  
  vector<int> p,q,r,mix;
  p.clear();
  q.clear();
  r.clear();
  mix.clear();
  for( i=0 ; i<A ; i++){
    cin >> n;
    p.push_back(n);
  }
  for( i=0 ; i<B ; i++){
    cin >> n;
    q.push_back(n);
  }
  for( i=0 ; i<C ; i++){
    cin >> n;
    r.push_back(n);
  }
  sort(p.begin(),p.end(),greater<int>());
  sort(q.begin(),q.end(),greater<int>());
  sort(r.begin(),r.end(),greater<int>());
  
  for( i=0 ; i<X ; i++ )
    mix.push_back(p[i]);
  for( i=0 ; i<Y ; i++ )
    mix.push_back(q[i]);
  for( i=0 ; i<C ; i++ )
    mix.push_back(r[i]);
  
  sort(mix.begin(),mix.end(),greater<int>());
  ll sum=0;
  for( i=0 ; i<(X+Y) ; i++ ){
    sum = sum + mix[i];
  }
  
  cout << sum <<endl;
  
  return 0;
}


Measured memory_bytes: 3572
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define MP make_pair
#define fs first
#define sc second
#define F first
#define S second
#define nl "\n"
#define asche cerr<<"Ekhane asche\n";
#define pf printf
#define sf scanf
#define mem(a,x) memset(a,x,sizeof(a))
#define SZ(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define one(x) __builtin_popcount(x)
#define fout(x) fixed<<setprecision(x)
#define BeatMeScanf ios_base::sync_with_stdio(false)
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); deb(_it, args); }
void deb(istream_iterator<string> it) {}
template<typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    deb(++it, args...);
}
//template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
namespace IO
{
    #define in() ( { int a ; scanf("%d",&a); a; } )
    #define LL() ( { ll a ; scanf("%lld",&a); a; } )
       #define ULL() ( { ull a ; scanf("%llu",&a); a; } )
    #define DD() ({ double a; scanf("%lf", &a); a;})
    #define CC() ( { char a ; scanf("%c",&a); a; } )
    #define pf1(a) printf("%d\n",a)
    #define pf1ll(a) printf("%lld\n",a)
}
using namespace IO;

const int mod=1e9+7;
const int N=3e5+9;
const double eps=1e-9;
const double PI=acos(-1.0);
ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}

ll a[N],b[N],c[N];
int32_t main()
{
    int n=in();
    ll k=LL();
    for(int i=1;i<=n;i++) a[i]=in();
    for(int i=1;i<=n;i++) b[i]=in();
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    ll l=0,r=1e14,ans=0;
    while(l<=r){
        ll mid=(l+r)/2;
        for(int i=1;i<=n;i++) c[i]=mid/b[i];
        sort(c+1,c+n+1);
        ll nw=0;
        for(int i=1;i<=n;i++) nw+=max(0LL,a[i]-c[i]);
        if(nw<=k) ans=mid,r=mid-1;
        else l=mid+1;
    }
    cout<<ans<<nl;
    return 0;
}
///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1



Measured memory_bytes: 6016
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;


int main(){
  int n,t1=0,x1=0,y1=0;
  cin>>n;
  vector<int> time(n),x(n),y(n);
  for(int i=0;i<n;i++){
    cin>>time[i]>>x[i]>>y[i];
  }
  for(int i=0;i<n;i++){
    int d=abs(x[i]-x1)+abs(y[i]-y1);
    int t=time[i]-t1;
    if(!(d<=t && t%2 == d%2)){
      cout<<"No"<<endl;
      return 0;
    }
    x1=x[i]; y1=y[i]; t1=time[i];
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	string s;
	cin>>s;
	map<char,int> M;
	rb(i,0,3){
		M[s[i]]++;
	}
	map<char,int>:: IT ite=M.begin();
	for(ite;ite!=M.end();ite++){
		if(ite->SEC!=2){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }

int f(ll a, ll b) {
  ll m = max(a,b);
  int res = 0;
  while(m > 0) {
    res++;
    m /= 10;
  }
  return res;
}

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

  ll n;
  cin >> n;
  int ans = inf;
  for(ll a = 1; a*a <= n; a++) {
    if(n % a != 0) continue;
    ll b = n/a;
    chmin(ans, f(a,b));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

vector<long long> divisor(long long n)
{
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end()); // 昇順に並べる
  return ret;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  vector<ll> c = divisor(M);
  ll ans = 0;
  for (auto it : c)
  {
    if ((M / it) >= N)
      ans = max(ans, it);
  }
  cout << ans << endl;
  return 0;
}

// 約数列挙をしてそれらの値でMを割っていく．Mを割った値がNを超えたらansを更新していく．このようにして最大になったものが答え．


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    cout << s.substr(0,3) << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string s,t;
	cin>>s>>t;
	bool tmp=false;
	for(int i=s.size()-t.size();i>=0;i--){
		bool check=true;
		rep(j,t.size()){
			if(s[i+j]=='?' or s[i+j]==t[j])continue;
			check=false;
			break;
		}
		if(check && !tmp){
			rep(j,t.size())s[i+j]=t[j];
			tmp=true;
		}
	}
	rep(i,s.size())if(s[i]=='?')s[i]='a';
	cout<<((tmp)?s:"UNRESTORABLE")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
vector<string> ans;

void dfs(int pos, int N, int can, string cur) {
    if (pos == N + 1) {
        ans.push_back(cur);
        return;
    }
    for (int i = 1; i <= can; i++) {
        string tmp = cur;
        tmp += (i + 'a' - 1);
        dfs(pos + 1, N, can, tmp);
    }
    cur += (can + 'a');
    dfs(pos + 1, N, can + 1, cur);
}

int main() {
    int N;
    scanf("%d", &N);
    dfs(1, N, 0, "");
    sort(ans.begin(), ans.end());
    for (auto i : ans)
        cout << i << endl;
    return 0;
}


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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string s;
    cin >> s;

    // 処理
    // 出力
    if (s[0] == s[1] && s[1] == s[2] || s[1] == s[2] && s[2] == s[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int L , A , B , C , D;
  cin >> L >> A >> B >> C >> D;

  int days_jp , days_mt , days;
  days_jp = (A % C == 0) ? (A / C) : (A / C) + 1;
  days_mt = (B % D == 0) ? (B / D) : (B / D) + 1;
  days = (days_jp > days_mt) ?  days_jp : days_mt;

  cout << L - days << endl;

  return 0;
}

Measured memory_bytes: 3084
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#define FOR(i, n) for(int i = 0; i < n; i++) 
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

const int MAXN = 100100;

int q;
int l[MAXN], r[MAXN];

void load() {
	scanf("%d", &q);
	FOR(i, q) scanf("%d%d", l + i, r + i);
}

bool primer[MAXN];
bool like2017[MAXN];
int sum[MAXN];

void solve() {
	for (int i = 2; i < MAXN; i++) {
		primer[i] = true;
		for (int j = 2; j * j <= i; j++) {
			if (i % j == 0) primer[i] = false;
		}
	}
	for (int i = 1; i < MAXN; i++) {
		if (primer[i] && primer[(i + 1) / 2]) like2017[i] = true;
	}
	for (int i = 1; i < MAXN; i++) {
		sum[i] = sum[i-1] + like2017[i];
	}
	FOR(i, q) {
		printf("%d\n", sum[r[i]] - sum[l[i]-1]);
	}
}

int main() {
	load();
	solve();
	return 0;
}


Measured memory_bytes: 1920
#include<cstdio>
int a[200005];

int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
    for(int i = k+1; i <= n; i++){
        int last = a[i-k];
        if(a[i]>last) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2440
import Data.List (group)


primes =
    let
        f (p : ps) = p : (filter $ (/= 0) . (`mod` p)) ps
    in
        f [ 2 .. ]

primeFactors n = [ x | x <- takeWhile (\y -> y * y <= n) primes, n `mod` x == 0 ]

factorize 1 = []
factorize n =
    let
        x = case primeFactors n of
            []     -> n
            p : ps -> p
    in
        x : factorize (n `div` x)

toInt :: String -> Int
toInt = read

steps' (n, count) set =
    let
        acc = n - head set
    in
        if acc >= 0
            then steps' (acc, count + 1) (tail set)
            else count

steps n = steps' (n, 0) [ 1 .. ]

main = do
    n <- toInt <$> getLine

    print . sum . map steps . map length . group $ factorize n


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


int main()
{
    int n, l;
    cin >> n >> l;
    vector<string> vs(n);
    for (int i = 0; i < n; i++) cin >> vs[i];
    sort(vs.begin(), vs.end());
    for (const auto &s : vs) cout << s;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int n;
	cin >> n;
	string s1, s2;
	cin >> s1 >> s2;

	ll res;
	int start;
	if (s1[0] == s2[0]) {
		res = 3;
		start = 1;
	} else {
		res = 3 * 2;
		start = 2;
	}
	for (int i = start; i < n; i++) {
		if (s1[i - 1] == s2[i - 1]) {
			res *= 2;
			res %= MOD;
			if (s1[i] != s2[i]) i++;
		} else {
			if (s1[i] != s2[i]) {
				res *= 3;
				res %= MOD;
				i++;
			}
		}
	}

	cout << res << '\n';
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

long long power_mod(long long x, long long y, long long m){
    long long res = 1 ;
    if(y>0){
        res = power_mod(x,y/2,m) ;
        if(y%2==0){
            res = (res*res)%m ;
        }
        else{
            res = (((res*res)%m)*x)%m ;
        }
    }
    return res ;
}
//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    int n ;
    cin >> n ;
    ll ans = 1 ;
    if(n%2==1){
        vint cnt(n,0) ;
        REP(i,n){
            if(i%2==0){
                cnt[i] = 2 ;
            }
        }
        cnt[0] = 1 ;
        REP(i,n){
            int  a;
            cin >> a ;
            cnt[a]-- ;
            if(cnt[a]<0){
                cout << 0 <<endl;
                return 0 ;
            }
        }
        cout << power_mod(2,(n-1)/2,MOD) <<endl;
    }
    else{
        vint cnt(n,0) ;
        REP(i,n){
            if(i%2==1){
                cnt[i] = 2 ; 
            }
        }
        REP(i,n){
            int a ;
            cin >> a ;
            cnt[a]-- ;
            if(cnt[a]<0){
                cout << 0 <<endl;
                return 0 ;
            }
        }
        cout << power_mod(2,n/2,MOD)  <<endl;

    }





    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <math.h>
#include <algorithm>
using namespace std;

int n,ten[1003],ans;

int main(){
while(1){
	
	
	scanf("%d",&n);
	if(n == 0)break;
	for(int i = 0;i < n;i++){
		scanf("%d",&ten[i]);
	}
	
	ans = abs(ten[0]-ten[1]);
	
	for(int i = 0;i < n;i++){
		for(int j = i + 1;j < n;j++){
			ans = min(ans,abs(ten[i]-ten[j]));
		}
	}
	
	printf("%d\n",ans);
	
}

return 0;

} 
	
	
	


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

#define  MOD 998244353

int main(int argc, char const *argv[]) {
    int n, k;
    cin >> n >> k;
    vector<pair<int, int> > section(k);
    for (int i = 0; i < k; i++) {
        int l, r;
        cin >> l >> r;
        section[i] = make_pair(l, r);
    }

    vector<long long> dp(n+1);
    dp[1] = 1;
    dp[2] = -1;
    for (int i = 1; i < n; i++) {
        if (i > 1) dp[i] += dp[i-1];
        for (int j = 0; j < k; j++) {
            if (i+section[j].first <= n) dp[i+section[j].first] += dp[i]%MOD;
            if (i+section[j].second + 1 <= n) dp[i+section[j].second + 1] -= dp[i]%MOD;
        }
    }

    dp[n] += dp[n-1];
    dp[n] %= MOD;
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 4800
#include <cmath>

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

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

constexpr int sz = 3;

vi a(sz);

int n;

void input() {
  for (auto&& i : a)
    cin >> i;

  cin >> n;
}

void solve() {
  // sort(a.rbegin(), a.rend());

  int ans = 0;

  constexpr int bound = 3001;

  for (int i = 0; i < bound; ++i) {
    const int y1 = a[0] * i;

    if (y1 > n)
      break;

    for (int j = 0; j < bound; ++j) {
      const int y2 = a[1] * j;

      if (y1 + y2 > n)
        break;

      if ((n - y1 - y2) % a[2] != 0)
        continue;

      ++ans;
    }
  }

  cout << ans << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  _times = 2;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
pair<pair<string, int>, int> p[101];

int main(void){
    int n = 0; 
    char s[101][11];
    int t;

    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%s%d", s[i], &t);
        p[i] = make_pair(make_pair(s[i], -t), i);
    }

    sort(p, p + n);

    for(int i = 0; i < n; i++){
        printf("%d\n", p[i].second + 1);
    }

    // 辞書順に並び替える

    // 複数のレストランがある場合、点数が高い方を先に出力

    return 0;

} 


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String a ="Sunny";
    String b ="Cloudy";
    String c ="Rainy";
    if(s.equals(a)){
      System.out.println(b);
    }else if(s.equals(b)){
      System.out.println(c);
    }else if(s.equals(c)){
      System.out.println(a);
    }
  }
}


Measured memory_bytes: 22100
#include <iostream>
using namespace	std;
int main(){

  int n,n0,r=0;
  cin>>n;
  n0=n;
  for(;n0;){
    r+=n0%10;
    n0/=10;
  }
  if(n%r) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;

}






Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (-1 * (1 << 29))
using namespace std;

struct Clothes{
    int low, up, glitz;
};

int dp[205][205], t[205];
Clothes c[205];

void update(int day, int now, int before){
    if(c[now].low <= t[day] && c[now].up >= t[day]){
        if(day == 0) dp[day][now] = 0; //テ・ツ按敕ヲツ猟・テ」ツ?ォテァツ敖?」ツつ凝ヲツ慊?
        else if(dp[day - 1][before] != INF){
            dp[day][now] = max(dp[day][now], dp[day - 1][before] + abs(c[before].glitz - c[now].glitz)); 
        }
    }
}

int solve(int d, int n){
    rep(day,d){
        rep(now,n){
            rep(before,n){
                update(day, now, before);
            }
        }
    }

/*
    rep(i,d){
        rep(j,n){
            cout << dp[i][j] << ' ';
        }
        cout << endl;
    }
*/

    int retval = 0;
    rep(i,n) retval = max(retval, dp[d - 1][i]);
    return retval;
}

int main(){
    int d, n;

    cin >> d >> n;
    rep(i,d) cin >> t[i];
    rep(i,n) cin >> c[i].low >> c[i].up >> c[i].glitz;
    rep(i,205) rep(j,205) dp[i][j] = INF;
    cout << solve(d, n) << endl;
}

Measured memory_bytes: 1328
import re

Sp = list(input())
T=list(input())
Sp = Sp[::-1]
T = T[::-1]
isOK=0
for n in range(len(Sp)-len(T)+1):
    count=0
    for m in range(len(T)):
        if Sp[n+m] == '?':
          count += 1
        elif Sp[n+m] == T[m]:
          count += 1

    if count == len(T):
        Sp[n:n+len(T)] = T
        isOK=1
        break

Sp = "".join(Sp[::-1])
Sp = Sp.replace("?", "a")

if isOK == 1:
    print(Sp)
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3316
#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
 
const int N = 15;
 
int n, m, x;
int c[N];
int a[N][N];
int cur[N];
 
int32_t main()
{
	IOS;
	cin >> n >> m >> x;
	for(int i = 0; i < n; i++)
	{
		cin >> c[i];
		for(int j = 1; j <= m; j++)
			cin >> a[i][j];
	}
	int ans = 1e18;
	for(int mask = 0; mask < (1 << n); mask++)
	{
		memset(cur, 0, sizeof(cur));
		int cost = 0;
		for(int i = 0; i < n; i++)
		{
			if(mask >> i & 1)
			{
				cost += c[i];
				for(int j = 1; j <= m; j++)
					cur[j] += a[i][j];
			}
		}
		int flag = 1;
		for(int i = 1; i <= m; i++)
			flag &= (cur[i] >= x);
		if(flag)
			ans = min(ans, cost);
	}
	if(ans > 1e15)
		ans = -1;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3616
N, M = map(int, input().split())
K = [[int(_) for _ in input().split()] for _ in range(N)]

L = []

for i in range(N):
    L += K[i][1:]
    
cnt = 0
for i in range(M+1):
    if L.count(i) == N:
        cnt += 1

print(cnt)

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

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

    int ans = 1e9;
    for (int i = 0; i < n; i++) {
        int c, t;
        cin >> c >> t;
        if (c < ans && t <= T)
            ans = c;
    }

    if (ans == 1e9)
        cout << "TLE" << endl;
    else
        cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
List = list(map(int,input().split()))
counter = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if List[i] != List[j] and List[j] != List[k] and List[k] != List[i]:
        if abs(List[j] - List[i]) < List[k] < List[i] + List[j]:
          if abs(List[k] - List[j]) < List[i] < List[k] + List[j]:
            #if abs(List[k] - List[i]) < List[j] < List[k] + List[i]:
            counter += 1
print(counter)

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

int main()
{
	int a[3];
	cin.tie(0);
	for (int i = 0; i < 3; i++) cin >> a[i];
	sort(a, a + 3);
	cout << a[0] << " " << a[1] << " " << a[2] << "\n";
}


Measured memory_bytes: 3128
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		
		int [] list = new int[10];
		int i,j;
		
		for(i=0;i<10;i++){
			list[i] = sc.nextInt();
		}
		Arrays.sort(list);
		
		for(j=0;j<3;j++){
			System.out.println(list[9-j]);
		}
	}

}

Measured memory_bytes: 17240
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const int MAXN = 1e5 + 10 ;
int main(){
	string s , t ;
	cin >> s >> t ;
	int cnt1[26] ;
	memset(cnt1,0,sizeof cnt1) ;
	int cnt2[26] ;
	memset(cnt2,0,sizeof cnt2) ;
	for(char c : s){
		cnt1[c-'a']++;
	}
	for(char c : t){
		cnt2[c-'a']++;
	}
	int n = (int)s.size() ;

    for(int i=0;i<n;i++){
        if ( cnt1[s[i]-'a'] != cnt2[t[i]-'a'] ){
            cout << "No" << endl;
            return 0 ;
        }
    }
    cout << "Yes" << endl;



	return 0 ;
}


Measured memory_bytes: 776
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    s64 a;
    cin >> a;
    string b;
    cin >> b;

    s64 c = 0;
    int idx = 0;
    for (; idx < b.size(); ++idx)
    {
        if (b[idx] == '.')
        {
            b += string(MAX(0, 2 - b.size() + idx + 1), '0');
            break;
        }
    }

    if (idx == b.size())
    {
        c = stoi(b) * 100;
    }
    else
    {
        rep (i, b.size())
        {
            if (b[i] == '.') continue;
            c = c * 10 + b[i] - '0';
        }
    }

    cout << (s64)(a * c) / 100 << "\n";

    return 0;
}



Measured memory_bytes: 3656
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
LL n,x; 
LL solve (LL x,LL y)
{
	if (x==y) return x;
	if (x==0&&y==0) return 0;
	if (x>y) swap(x,y);
		if (y%x==0)
		{
			LL t=y/x-1;
			return 2*x*t+solve(y-t*x,x);
		}
		else
		{
			LL t=(y-x)/x+1;
			return 2*x*t+solve(y-t*x,x);
		}
}
int main()
{
	scanf("%lld%lld",&n,&x);
	printf("%lld\n",n+solve(x,n-x));
	return 0;
}

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

void dfs(int s, vector<vector<int>>&adj, vector<bool>&visited, vector<int>&dp){
    visited[s] = true;
    
    for(int i=0;i<adj[s].size();i++){
        if(!visited[adj[s][i]])
            dfs(adj[s][i], adj, visited, dp);
            
        dp[s] = max(dp[s], 1+dp[adj[s][i]]);
    }
}

int main() {
	int N,M,x,y;
	cin >> N >> M;
	
	vector<vector<int>>adj(N+1);
	
	for(int i=0;i<M;i++){
	    cin >> x >> y;
	    adj[x].push_back(y);
	}
	
	vector<bool>visited(N+1, false);
	vector<int>dp(N+1,0);
	
	for(int i=1;i<=N;i++){
	    if(!visited[i])
	        dfs(i, adj, visited, dp);
	}
	
// 	cout << "here wqe"<<endl;
	int ans = 0;
	
	for(int i=0;i<=N;i++){
	    ans = max(dp[i], ans);
	}
	
	cout << ans << endl;
	return 0;
}


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

void solve()
{
    int n;
    cin >> n;
    int a[n], dp[n];
    for (int i=0;i<n;i++)
        cin >> a[i];
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);

    for(int i=2;i<n;i++)
       dp[i] = min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
       
    cout << dp[n-1];
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 4320
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef long long ll;

int main(){
	string s;
  int n;
  cin>>n;
	cin>>s;
  int x = 0, masi = 0;
  for(int i=0; i<n; i++){
    if(s[i]=='I'){
      x++;
    }
    if(s[i]=='D'){
      x--;
    }
    masi = max(x, masi);
  }
  cout<<masi;
	
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	if N == 1 {
		fmt.Println("Hello World")
	} else if N == 2 {
		var A, B, sum int
		fmt.Scan(&A)
		fmt.Scan(&B)
		sum = A + B
		fmt.Println(sum)
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

void test_case() {
    vector<long long> a;
    int n;
    long long res=1, inf = 1e18;
    cin >> n;
    a.resize(n);
    for(auto &i: a)
        cin >> i;
    sort(a.begin(), a.end());
    for(const auto &i: a) {
        if(i == 0) {
            cout << 0 << "\n";
            return;
        }
        if(i*res < res || i*res > inf) {
            cout << -1 << "\n";
            return;
        }
        res*=i;
    }
    cout << res << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int q=1;
    //cin >> q;
    while(q--) {
        test_case();
    }
    return 0;
}


Measured memory_bytes: 3996
s=input()
n=len(s)
f=True
if s[0]!='A':
    f=False
if s[2:n-1].count('C')!=1:
    f=False
for ss in s:
    if ss!='A' and ss!='C' and ss.isupper():
        f=False
print('AC' if f else 'WA')

Measured memory_bytes: 8928
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(int)(n);i++)
#define foi(i,k,n) for(int i=(k); i<(int)(n); i+=1)
#define fod(i,n,k) for(int i=k; i>=(int)n; i-=1)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define endl "\n"

#define int long long
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long llint;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<llint> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
llint toint(string s) {stringstream ss(s); llint x; ss >> x; return x;}
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//gp_hash_table<string, llint> table;


//int mpow(llint base, llint exp) {
  //base %= MOD;
  //llint result = 1;
  //while (exp > 0) {
    //if (exp & 1) result = ((llint)result * base) % MOD;
    //base = ((llint)base * base) % MOD;
    //exp >>= 1;
  //}
  //return result;
//}


//void makegraph(int n, int m){
	//int i, u, v;
	//while(m--){
		//cin>>u>>v;
		//u--, v--;
		//g[u].pb(v);
		//g[v].pb(u);
	//}
//}

//void dfs(int u, int par){
	//for(int v:g[u]){
		//if (v == par) continue;
		//dfs(v, u);
	//}
//}


// ------------------------------------------------------------------ILB----------------------------------------------------------------  //



void solve(){
	int d, t, s;
	cin >> d >> t >> s;
	if ((d + s - 1) / s <= t) cout << "Yes";
	else cout << "No";
}




int32_t main() {
	fast_io;
    int t = 1;
    //cin >> t;
    //int xx = 0
    while(t--) {
		//xx++;
		//cout << "Case ";
      solve();
    }
    return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ALL(a)  (a).begin(),(a).end()
int main(){
  string S;
  cin >> S;
  int N = S.size();
  bool flag = true;
  for(int i = 0; i < N; i += 2){
   if(!(S.at(i) == 'R' || S.at(i) == 'U' || S.at(i) == 'D')) flag = false;
  }
  for(int i = 1; i < N; i += 2){
   if(!(S.at(i) == 'L' || S.at(i) == 'U' || S.at(i) == 'D')) flag = false;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  ll i,j=1,N,M;
  cin>>N>>M;
  string s;cin>>s;
  vec term(N+1,-1),par(N+1,-1);
  term[0]=0;
  rep(i,N){
    if(s[i]=='1'||term[i]<0){term[i]=-1;continue;}
    while(j<=i+M&&j<=N){
      term[j]=term[i]+1;
      j++;
    }
  }
  if(term[N]<0){
    cout<<-1<<endl;
    return 0;
  }
  vec ans;
  j=N;
  while(j>0){
    for(i=min(M,j);i>0;i--){
      if(term[j-i]+1==term[j]){
        ans.pb(i);
        j-=i;
        break;
      }
    }
  }
  M=0;
  brep(i,ans.size()){
    if(M)cout<<" ";
    M=1;
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{   
    int n, m, k;
    cin >> n >> m >> k;
    vll a(n+1), b(m+1);
    rep(i, n) {
        int x;
        cin >> x;
        a[i+1]=a[i]+x;
    }
    rep(i, m) {
        int x;
        cin >> x;
        b[i+1]=b[i]+x;
    }
    
    int ans = 0;
    rep(i, n+1) {
        if(a[i]>k) continue;
        auto itr = upper_bound(all(b), k-a[i]);
        int t = (itr-b.begin())-1;
        ans = max(ans, i + t);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6428
def main():
  n,m = input_list()
  sc = {}
  for i in range(m):
    s, c = input_list()
    if s in sc and sc[s] != c:
      print(-1)
      exit()
    sc[s] = c
  for i in range(1000):
    si = str(i)
    if len(si) != n:
      continue
    ok = True
    for keta, num in sc.items():
      index = keta-1
      if si[index] != str(num):
        ok = False
    if ok:
      print(si)
      exit()
  print(-1)
  

def input_list():
  return map(int, input().split())

import math
import fractions
import itertools
main()

Measured memory_bytes: 64876
# include <bits/stdc++.h>
# define ll long long
# define pb push_back
# define fi first
# define se second
# define mp make_pair
# define gcd(m,n)  __gcd(m, n)
# define pr_double(x) cout << fixed << setprecision(10) << x
using namespace std;

int main() {
  ll d,t,s;
  cin>>d>>t>>s;
  if((double(d)/double(s))<=double(t)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
int n, m;
char S[N], T[N];
inline int calc(int st)
{
	st--;
	int cnt = 0;
	for (int i = 1; i <= m; i++)
	if (S[i + st] != T[i]) cnt++;
	return cnt;
} 
int main(){
	scanf ("%s", S + 1); n = strlen(S + 1);
	scanf ("%s", T + 1); m = strlen(T + 1);
	
	int ans = 1e9;
	for (int i = 1; i <= n - m + 1; i++) ans = min(ans, calc(i));
	printf ("%d\n", ans);
  return 0;
}

Measured memory_bytes: 3840
n,m=map(int,input().split())
dataset=sorted([tuple(map(int,input().split())) for i in range(n)])
ans=0
for data in dataset:
  if m==0:
    print(ans)
    exit()
  tmp=min(data[1],m)
  ans+=tmp*data[0]
  m-=tmp
print(ans)

Measured memory_bytes: 17752
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>

using namespace std;

const int MAX = 100;
const int INF = 1 << 30;

int main() {
	int N, X;
	int m = INF;

	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		X -= n;
		m = min(m, n);
	}

	cout << X / m + N << endl;
	
	return 0;
}

Measured memory_bytes: 764
import java.io.PrintWriter
import java.util.*

fun main(args: Array<String>) {
    val out = PrintWriter(System.out)
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    val m = sc.nextLong()
    val py = mutableListOf<City113>()
    (0 until m).forEach { i ->
        py.add(City113(i, sc.next().toInt(), sc.next().toLong()))
    }
    out.println(problem113c(n, m, py))
    out.flush()
}

fun problem113c(n: Long, m: Long, py: MutableList<City113>): String {
    var current = 0
    var count = 0
    py.sorted().forEachIndexed { i, city ->
        if (current != city.p) {
            count = 0
            current = city.p
        }
        count++
        var ps = current.toString()
        while (ps.length < 6) {
            ps = "0$ps"
        }
        var cs = count.toString()
        while (cs.length < 6) {
            cs = "0$cs"
        }
        city.ans = ps + cs
    }
    return py.sortedBy { it.city }.joinToString("\n") { it.ans }
}

class City113(val city: Long, val p: Int, val y: Long, var ans: String = "") : Comparable<City113> {
    override fun compareTo(other: City113): Int {
        val diff = this.p - other.p
        if (diff != 0) return diff
        return (this.y - other.y).toInt()
    }
}

Measured memory_bytes: 92024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N, M;
    string S;
    cin >> N >> M >> S;
    if( S[ N ] != '-' )
    {
        cout << "No" << endl;
        return 0;
    }
    S.erase( begin( S ) + N );
    for( auto &x : S )
    {
        if( !iswdigit( x ) )
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int x, y, key1, key2;

  scanf("%d%d",&x,&y);

  if(x < y)
    {
      key1 = x;
      x = y;
      y = key1;
    }

  key2 = x % y;

  while(key2 != 0)
    {
      x = y;
      y = key2;
      key2 = x % y;
    }

  printf("%d\n",y);

  return 0;
}


Measured memory_bytes: 2084
def main():
    N = int(input())
    ni = 0
    yon = 0
    ans = "No"
    for a in input().split():
        a = int(a)
        if a % 4 == 0:
            yon += 1
        elif a % 2 == 0:
            ni += 1

    if int(N / 2) <= yon:
        ans = "Yes"
    elif (N-2*yon) <= ni:
        ans = "Yes"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 11096
import fractions
a, b, c, d=map(int, input().split())

saishou=(c*d)//fractions.gcd(c, d)#最小公倍数
warikiri_a=[]
warikiri_b=[]
amari_a=[]
amari_b=[]
warikiri_a.append(a//c)
warikiri_a.append(a//d)
warikiri_a.append(a//saishou)
warikiri_b.append(b//c)
warikiri_b.append(b//d)
warikiri_b.append(b//saishou)
amari_a.append(a%c)
amari_a.append(a%d)
amari_a.append(a%saishou)
amari_b.append(b%c)
amari_b.append(b%d)
amari_b.append(b%saishou)
list=[]
for i in range(3):
    if amari_a[i]==0:
        list.append(warikiri_b[i]-warikiri_a[i]+1)
    else:
        list.append(warikiri_b[i]-warikiri_a[i])

for i in range(3):
    if list[i]<0:
        list[i]=0
print((b-a+1)-(list[0]+list[1]-list[2]))


Measured memory_bytes: 66156
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define NCK_MAX 510000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  int a,b,ans=0;
  std::cin >> a >> b;
  if (b > a) REP(i,b) ans+=a*pow(10,i);
  else REP(i,a) ans+=b*pow(10,i);
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
	int H,W;
	while(1){
	cin >> H >> W;
	if(H==0 && W==0) return 0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if((i+j)%2==1) cout << ".";
			else cout << "#";
		}
		cout << endl;
	}
	cout << endl;
	}
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
using namespace std;
vector<int> v[100100];
long long n,k,w[100100],ans=1,a,b;
void f(int x,int y)
{
	if(w[x]==1)
		return ;	
	w[x]=1;
	ans*=y;
	ans%=1000000007;
	int h=0;
	for(int i=0;i<v[x].size();i++)
	{
		if(w[v[x][i]]==0)
		{
			f(v[x][i],k-2-h);
			h++;
		}
	}	
}
int main()
{
	cin>>n>>k;
	for(int i=0;i<n-1;i++)
	{
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	cout<<endl;
	w[a]=1;
	ans*=k;
	for(int i=0;i<v[a].size();i++)
	{
		f(v[a][i],k-1-i);
	}
	cout<<ans%1000000007<<endl;
}

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

#define N 8
#define FREE -1
#define NOT_FREE 1

vector<int> row( N, FREE );
vector<int> col( N, FREE );
vector<int> dpos( N*2-1, FREE );
vector<int> dneg( N*2-1, FREE );
vector<vector<int>> X( N, vector<int>( N ) );

void printBoard()
{
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) {
			if( X[i][j] ) {
				if( row[i] != j ) return;
			}
		}
	}
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) {
			char a = '.';
			if( row[i] == j ) a = 'Q';
			cout << a;
		}
		cout << endl;
	}
}

void dfs( int i )
{
	if( i == N ) {
		printBoard();
		return;
	}
	for( int j = 0; j < N; j++ ) {
		if( col[j] != FREE ||
			dpos[i + j] != FREE ||
			dneg[i - j + N - 1] != FREE )
			continue;
		row[i] = j;
		col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
		dfs( i + 1 );
		row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
	}
}

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

	for( int i = 0; i < k; i++ ) {
		int r, c;
		cin >> r >> c;
		X[r][c] = 1;
	}
	dfs( 0 );
}



Measured memory_bytes: 3156
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;

/** ワーシャル・フロイド法による全点対最短路探索

    経路を逐次最小化していく。

    知らないパスにはコスト大きめを設定しておくこと。
    O(|V|^3)

    @param[in] V  頂点数
    @param[in, out] distance[i][j]: 頂点i -> jのコスト
*/
template<typename T, typename M>
void warshall_floyd(T V, M& distance)
{
    for (T k = 0; k < V; ++k) {
        for (T i = 0; i < V; ++i) {
            for (T j = 0; j < V; ++j) {
                distance[i][j] = std::min(distance[i][j],
                                          distance[i][k] + distance[k][j]);
            }
        }
    }
}


int main()
{
    int H, W;
    std::cin >> H >> W;

    boost::multi_array<int, 2> C(boost::extents[10][10]);
    for (auto p = C.data(); p < (C.origin() + C.num_elements()); ++p) {
        std::cin >> *p;
    }

    warshall_floyd(10, C);

    int64_t count = 0;
    for (size_t i = 0; i < H * W; ++i) {
        int v;
        std::cin >> v;
        if (v != -1) {
            count += C[v][1];
        }
    }

    std::cout << count << std::endl;

    #if 0

    boost::multi_array<int, 2> mat(boost::extents[H][W]);
// const auto Y = mat.shape()[0];
// const auto X = mat.shape()[1];

// std::fill(mat.data(), mat.data() + mat.num_elements(), almost_max<int>());

    for (auto p = mat.data(); p < (mat.origin() + mat.num_elements()); ++p) {
        std::cin >> *p;
    }

    #endif

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int N=100;
int n,m,tail;
char AA[N][N];
bool flag,IGN[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%s",AA[tail]);
		flag=true;
		for(int j=0;j<m&&flag;++j)
			if(AA[tail][j]=='#')flag=false;
		if(!flag)++tail;
	}
	for(int j=0;j<m;++j){
		flag=true;
		for(int i=0;i<tail&&flag;++i)
			if(AA[i][j]=='#')flag=false;
		IGN[j]=flag;
	}
	for(int i=0;i<tail;++i){
		for(int j=0;j<m;++j)
			if(!IGN[j])printf("%c",AA[i][j]);
		printf("\n");
	}
}

Measured memory_bytes: 256