akhauriyash/Code-Regression huggingface dataset:
n =  str(input())

a = n[0:2]
b = n[2:]

c = int(a)
d = int(b)
yymm = False
mmyy = False
ambiguous = False
na = False

if (c < 1) or (12 < c):
    if (d < 1) or (12 < d):
        na = True

if (1 <= c) and (c <= 12):
    if (d < 1) or (12 < d):
        mmyy = True

if (1 <= d) and (d <= 12):
    if (c < 1) or (12 < c):
        yymm = True

if na == False and mmyy == False and yymm == False:
    ambiguous = True

if na == True:
    print("NA")
if mmyy == True:
    print("MMYY")
if yymm == True:
    print("YYMM")
if ambiguous == True:
    print("AMBIGUOUS")


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

using namespace std;

int main() {
    int N, D;
    int E = 0;

    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for(int n = 0;n < N; ++n){
        for(int d = 0;d < D; ++d){
            cin >> X[n][d];
        }
    }
    int A = 0;
  

    for(int n = 0;n < N; ++n){
        for(int o = n + 1;o < N; ++o){
            int C = 0;
            for(int d = 0;d < D; ++d){
                int B = abs(X[n][d] - X[o][d]);
                C += B * B;
                // cout << C << endl;
            };
            bool flag = false;
            for(int n = 0;n  <= C; ++n){
                if(n * n == C){
                  ++E;
                }
            }

        }



        

    }
    cout << E <<endl;
}

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

long int paty(int l){
	return ((long int)pow(2,l+1)) - 1;
}

long int all(int l){
	return ((long int)pow(2,l+2)) - 3;
}

long int ans(int n, long int x){
	if (n == 0)
		return 1;
	long int alpha = all(n-1);
	if (x <= 1)
		return 0;
	else if (x < alpha + 1)
		return ans(n-1,x-1);
	else if (x == alpha + 1)
		return paty(n-1);
	else if (x == alpha + 2)
		return paty(n-1) + 1;
	else if (x < 2 * alpha + 2)
		return paty(n-1) + 1 + ans(n-1, x - alpha - 2);
	else 
		return paty(n);
}

int main(){
	int N;
	long int X;
	cin >> N >> X;
	cout << ans(N,X) << endl;
}

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

using namespace std;

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<ll>
#define vl vector<ll>
#define pb push_back
#define INF 1000000007
#define PI 3.141592653
#define inf 100007
#define pll pair<ll,ll>
#define pii pair<int,int>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

int main(){
    ll n,a,b,ans=0;
    cin>>n>>a>>b;
    vl v(n);
    pan(i,n)
        cin>>v[i];
    pans(i,n,1)
        ans+=(((v[i]-v[i-1])*a)>=b) ? b:(v[i]-v[i-1])*a;
    cout<<ans;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  if(n%k != 0) {
    cout << 1 << endl;
  } 
  else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 764
#include <iostream>

using namespace std;

int main()
{
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x-r<0||y-r<0||x+r>W||y+r>H){
        cout<<"No"<<endl;}
        else{cout<<"Yes"<<endl;}

    return 0;
}



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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    string s; cin >> s;
    string sun = "Sunny";
    string clo = "Cloudy";
    string rai = "Rainy";
    string ans;
    if(s == sun){
        ans = clo;
    }
    else if(s == clo){
        ans = rai;
    }
    else{
        ans = sun;
    }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
using ll = long long;
/*
    g++ -std=c++11 test.cpp -o test.out && ./test.out
*/
void solve(){
    int n; cin >> n;
    vector<ll> a(n);

    unordered_map<ll,ll> count;

    ll sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        count[a[i]]++;
        sum += a[i];
    }

    int q; cin >> q;
    for(int i = 0; i < q; i++){
        ll b, c; cin >> b >> c;

        int cnt = count[b];
        sum -= (b * cnt);
        sum += (c * cnt);
        cout << sum << endl;

        count.erase(b);
        count[c] += cnt;
    }
}   
 
int main()
{    
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    solve();
    
    return 0;
}

Measured memory_bytes: 7400
N = int(input())
VG = []
for i in range(N//2):
  VG.append([i+1,(N//2)*2-i])
if N % 2 == 1:
  VG.append([N])
#print(VG)

E = []
for i in range(len(VG)-1):
  for v in VG[i]:
    for j in range(i+1,len(VG)):
      for u in VG[j]:
        E.append([v,u])
#print(E)

print(len(E))
for e in E:
  print(*e)

Measured memory_bytes: 43632
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
   return 0;
}





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

int main() {
  string S , A , B;
  cin >> S;
  A = "vowel";
  B = "consonant";
  if (S == "a"){
    cout << A << endl;
  }
  else if (S == "e"){
    cout << A << endl;
  }
  else if (S == "i"){
    cout << A << endl;
  }
  else if (S == "o"){
    cout << A << endl;
  }
  else if (S == "u"){
    cout << A << endl;
  }
  else {
    cout << B << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define cinn(a) for(auto &_k:(a)) cin >> _k
#define coutt(a) for(auto &_k:(a)) cout << _k << ' '
inline int cint() { int temp; cin>>temp; return temp; }

int main(){
    int n, m; cin >> n >> m;
    multiset<int, greater<int>> ms;
    while(n--){
        ms.insert(cint());
    }
    while(m--){
        int a = *ms.begin();
        ms.erase(ms.begin());
        a >>= 1;
        ms.insert(a);
    }
    cout << accumulate(ms.begin(),ms.end(),(ll)0);
    return 0;
}

Measured memory_bytes: 4992
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < (up); ++i)
#define repp(i, up) for (ll i = 0; i <= (up); ++i)
#define rrep(i, lo, up) for (ll i = (lo); i < (up); ++i)
#define rrepp(i, lo, up) for (ll i = (lo); i <= (up); ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))
#define feach(it, vec) for (auto it = (vec).begin(); it != (vec).end(); ++it)
#define emax(l, r) l = max(l, r)
#define vmin(l, r) l = min(l, r)

template<class T, class U>
bool contains(const T & vec, const U & value) {
    return vec.find(value) != vec.end();
}

ll gcd(ll a, ll b);

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

#endif  // end of use_templates


int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ac = a * c;
    ll ad = a * d;
    ll bc = b * c;
    ll bd = b * d;
    cout << max(max(ac, ad), max(bc, bd)) << endl;
    return 0;
}


Measured memory_bytes: 3216
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,m,ans;

signed main(){
	string s;
	cin>>s;
	if(s[0]=='7' || s[1]=='7' || s[2]=='7')cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 3620
A,B,C,D,E,F = map(int,input().split())
def FS():
    ans = (100*A,0)
    for a in range(0,F,100*A):
        for b in range(0,F,100*B):
            for c in range(0,F,C):
                for d in range(0,F,D):
                    wat,sug = (a + b),(c + d)
                    if wat == 0 or wat+sug > F or 100*sug > E*wat:
                        break
                    elif 100*sug == E*wat:
                        return (wat,sug)
                    elif sug*ans[0] > ans[1]*wat:
                        ans = (wat,sug)  
    return ans
ans = FS()
print(sum(ans),ans[1])

Measured memory_bytes: 3064
import java.util.Scanner;

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

		a = sc.nextInt();
		b = sc.nextInt();

		if ( a < b ) {
			System.out.println("a < b");
		} else if ( a > b ) {
			System.out.println("a > b");
		} else {
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 26308
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char ch = '0';
		for(char c : s.toCharArray()) {
			if(ch=='A' && c=='A') {
				System.out.println("NO");
				return;
			} else {
				ch = c;
			}
		}
		if(s.startsWith("A") || s.startsWith("KIH")) {

		} else {
			System.out.println("NO");
			return;
		}
		s = s.replaceAll("A", "");
		String str = "KIHBR";
		if(s.equals(str)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 22740
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        Work[] list = new Work[n];
        for (int i = 0; i < n; i++) {
            list[i] = new Work(sc.nextLong(), sc.nextLong());
        }
        Arrays.sort(list, ((a, b) -> Math.toIntExact(a.limit - b.limit)));
        long now = 0;
        String ans = "Yes";
        for (int i = 0; i < list.length; i++) {
            if (now + list[i].need <= list[i].limit) {
                now += list[i].need;
            } else {
                ans = "No";
                break;
            }
        }
        System.out.println(ans);
    }

    private static class Work {
        private long need;
        private long limit;

        private Work(long need, long limit) {
            this.need = need;
            this.limit = limit;
        }
    }
}

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

int main(){
    long long int n, a, b, ans=0;
    cin >> n >> a >> b;

    long long int c=a+b;

    ans += (n/c)*a; 

    if(a>n%c){
        ans += n%c;
    }
    
    else if(a<=n%c){
        ans += a;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
r,g,b,n=map(int,input().split())
l=[r,g,b]
m=max(l)
l.remove(m)
m2=max(l)
l.remove(m2)
m3=l[0]
cnt = 0
for i in range(n//m + 1):
    n_ = n - m*i
    for j in range(n_//m2 + 1):
        if (n_ - m2*j)%m3==0:
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
s = input().strip()

f1 = s[:2]
f2 = s[2:]

def vm(s):
    if s != '00' and s <= '12':
        return True
    return False

def vd(s):
    return True

if vm(f1) and vm(f2):
    print('AMBIGUOUS')
elif vm(f1) and vd(f2):
    print('MMYY')
elif vd(f1) and vm(f2):
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int h1,m1,h2,m2,k;
   cin >> h1 >> m1 >> h2 >> m2 >> k;
   int hrs = k/60;
   int min = k%60;
   h1 += hrs;
   m1 += min;
   h1 += m1/60;
   m1 %= 60;
   h1 %= 24;

   int ff = h1*60+m1,ss = h2*60+m2;
   if(ff<=ss){
      cout << ss-ff << '\n';
   }else{
      cout << 24*60-(ff-ss) << '\n';
   }
   return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  int i = 0;
  while (i < n) {
    int tmp = a[i];
    int cnt = 1;
    int j = i + 1;
    while (true) {
      if (a[j] != tmp || j >= n) {
        break;
      }
      else {
        cnt++;
      }
      j++;
    }
    ans += cnt/2;
    i = j;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import collections
N=int(input())
A=list(map(int,input().split()))

cc=collections.Counter(A)
L=list(cc.values())

total=0
for i in range(len(L)):
    total+=L[i]*(L[i]-1)//2

ans=0
for a in A:
    temp=cc[a]*(cc[a]-1)//2
    ttemp=(cc[a]-1)*(cc[a]-2)//2
    ans=total-temp+ttemp
    print(ans)

Measured memory_bytes: 34036
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i ++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i --)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return 1;}return 0;}

constexpr ll INF = (1ll << 60);
constexpr ll MOD = 1000000007ll;

ll llgcd(ll a, ll b){
    if(b == 0)
        return a;
    return llgcd(b, a % b);
}

ll llpow(ll a, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

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

    for (ll i = a; i <= b; i ++){
        if(i % k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll a,b;
	cin>>a>>b;
	cout << a+b/2 << endl;
	return 0;
}

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

int main () {
  int N,X;
  cin >> N >> X;
  vector<int> m(N);
  int msum = 0;
  
  for (int i=0; i<N; i++) {
    cin >> m[i];
    msum += m[i];
  }
  //cout << msum <<endl;
  int bal = X - msum;
  int max = -1;
  for (int i=0; i<N; i++) {
    int counter = bal / m[i];
    if (counter > max) {
      max = counter;
    }
  }
  cout << max + N <<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s];i;i=e[i].nxt)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
typedef double db;
const db pi=acos(-1.0);
int main()
{
	int r; si(r);
	printf("%.20lf\n",2*pi*r);
	return 0;
}

Measured memory_bytes: 3788
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
  // cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
        
       ll x;
       cin>>x;
       if(x>=30)
        cout<<"Yes";
      else
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll N;
  cin>>N;
 vector<ll> vec(N);
  for(ll i=0;i<N;i++) {
cin>>vec[i];
  }
  
  sort(all(vec));
  ll sum=0;
  for(ll i=0;i<N-1;i++) {
    sum+=vec[i];
  }
  
  if(sum>vec.back()) {
cout<<"Yes"<<endl;
  }
  
  else {
cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3528
import java.util.Scanner;

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

		String line = sc.nextLine();
		String[] lines = line.split(" ");

		int A = Integer.parseInt(lines[0]);
		int B = Integer.parseInt(lines[1]);
		int C = Integer.parseInt(lines[2]);

		int swap = A;
		A = C;
		C = B;
		B = swap;

		System.out.println(A + " " + B + " " + C);
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

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

typedef long long ll;

int main()
{
    int n, a[212345];
    ll sum[212345];

    cin >> n;

    sum[0] = 0;
    REP(i, n)
    cin >> a[i + 1], sum[i + 1] = sum[i] + a[i + 1];

    ll res = LLONG_MAX;

    ll l[212345], r[212345];

    l[2] = 1;
    int q = 1;
    for (int i = 3; i <= n; i++)
    {
        ll tmp = abs(sum[i] - sum[q] - sum[q]);
        ll tmp_ = tmp;

        while (q < i && tmp_ >= tmp)
        {
            tmp_ = tmp;
            tmp = abs(sum[i] - sum[q] - sum[q]);
            q++;
        }

        q -= 2;
        if (tmp < tmp_)
            q++;

        l[i] = q;

    }

    r[n - 1] = n;
    q = n;
    for (int i = n - 2; i >= 1; i--)
    {
        ll tmp = abs(sum[n] - sum[i - 1] - 2 * (sum[n] - sum[q - 1]));
        ll tmp_ = tmp;

        while (q > i && tmp_ >= tmp)
        {
            tmp_ = tmp;
            tmp = abs(sum[n] - sum[i - 1] - 2 * (sum[n] - sum[q - 1]));
            q--;
        }

        q += 2;
        if (tmp < tmp_)
            q--;
        r[i] = q;
    }

    res = LLONG_MAX;

    for (int i = 2; i <= n - 2; i++)
    {
        ll t[4];
        t[0] = sum[l[i]];
        t[1] = sum[i] - sum[l[i]];
        t[2] = sum[r[i + 1] - 1] - sum[i];
        t[3] = sum[n] - sum[r[i + 1] - 1];

        sort(t, t + 4);

        res = min(res, t[3] - t[0]);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 6016
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, m, L;
    cin >> n >> m >> L;
    yukari<pair<int, i64>> g(n);
    yukari<i64> dp(n, akari<i64>(n, 1e15)), dp2(dp);
    while (m--)
    {
        int a, b, c;
        cin >> a >> b >> c;
        if (L < c)
        {
            continue;
        }
        a--, b--;
        g[a].push_back(make_pair(b, c));
        g[b].push_back(make_pair(a, c));
        dp[a][b] = dp[b][a] = c;
    }
    for (int k = 0; k < n; k++)
    {
        dp[k][k] = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
            {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
        {
            if (dp[i][j] <= L)
            {
                dp2[i][j] = 1;
            }
        }
    for (int k = 0; k < n; k++)
    {
        dp2[k][k] = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
            {
                dp2[i][j] = min(dp2[i][j], dp2[i][k] + dp2[k][j]);
            }
    }

    int q;
    cin >> q;
    while (q--)
    {
        int s, t;
        cin >> s >> t;
        s--, t--;
        cout << (dp2[s][t] == 1e15 ? -1 : dp2[s][t] - 1) << '\n';
    }
}

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


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

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  int n;
  cin >> n;
  const int SZ = 100001;
  vector<int> cnt(SZ * 2, 0);
  for (int i = 0; i < n; i += 2) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    cnt[x]++;
    cnt[y + SZ]++;
  }
  int c[4] = { 0, 0, 0, 0 };
  int v[4] = { -1, -1, -1, -1 };
  for (int i = 0; i < SZ; i++) {
    if (c[0] < cnt[i]) {
      c[1] = c[0];
      v[1] = v[0];
      c[0] = cnt[i];
      v[0] = i + 1;
    } else if (c[1] < cnt[i]) {
      c[1] = cnt[i];
      v[1] = i + 1;
    }
  }
  for (int i = SZ; i < SZ * 2; i++) {
    if (c[2] < cnt[i]) {
      c[3] = c[2];
      v[3] = v[2];
      c[2] = cnt[i];
      v[2] = i - SZ + 1;
    } else if (c[3] < cnt[i]) {
      c[3] = cnt[i];
      v[3] = i - SZ + 1;
    }
  }
  dumpv(c, 4);
  dumpv(v, 4);
  if (v[0] != v[2]) {
    cout << n - c[0] - c[2] << endl;
  } else {
    if (v[1] == -1 && v[3] == -1) {
      cout << n - c[0] << endl;
    } else {
      int a1 = n - c[0] - c[3];
      int a2 = n - c[1] - c[2];
      cout << min(a1, a2) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

struct mint {
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  /* 変数名.pow(n) */
  mint pow(ll t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // 以降はMODが素数のみ
  mint inv() const {
    return pow(MOD - 2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

const int MAX = 1e+5 + 5;
long long fac[MAX], finv[MAX], inv[MAX];

/* 前処理 O(n) */
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

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

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  sort(all(A));

  COMinit();
  mint mx = 0;
  mint mn = 0;

  rep(i, N) {
    if (i >= K - 1)
      mx += A[i] * COM(i, K - 1);
    if ((N - 1 - i) >= K - 1)
      mn += A[i] * COM(N - 1 - i, K - 1);
  }

  mint ans = mx - mn;
  cout << ans.x << endl;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <algorithm>
#include <cstdlib>
using namespace std;
 
void Fail(){
	printf("No\n");
	exit(0);
}
 
int n, a[100100], lo, hi, lc;
 
int main(){
	scanf("%d", &n);
	for ( int i = 0; i < n; i++ )
		scanf("%d", a + i);
	
	lo = n; hi = 0;
	for ( int i = 0; i < n; i++ ){
		hi = max(hi, a[i]);
		lo = min(lo, a[i]);
	}
	
	if ( lo < 1 || hi >= n ) Fail();
	if ( hi - lo > 1 ) Fail();
	
	for ( int i = 0; i < n; i++ )
		if ( a[i] == lo )
			++lc;
	
	if ( lo == hi ){
		if ( 2 * lo > n && lo < n - 1 ) Fail();
		printf("Yes\n");
	}
	else{
		// Imas LC boja, plus ostalih (n - lc) se moze raspodijeliti u grupe po 2 ili vise
		if ( hi > int((n - lc) / 2) + lc ) Fail();
		if ( lo < lc ) Fail();
		printf("Yes\n");
	}
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define mod 1000000007
#define vll vector<ll>

double ti[3001][3001];ll n;
double arr[30001];

double func(ll head,ll len)
{
    if(len==0)
    {
        if(head>=(n/2+1))
            return 1;
        else return 0;
    }

    if(ti[head][len]!=-1) return ti[head][len];


    return ti[head][len]=arr[len-1]*func(head+1,len-1)+((1.0-arr[len-1])*func(head,len-1));
}


int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//ll n;
	cin>>n;

	//double pro[n];
	for(ll i=0;i<n;i++)
        cin>>arr[i];

  for(ll i=0;i<=n;i++)
  {
      for(ll j=0;j<=n;j++)
        ti[i][j]=-1;
  }
   double ans=func(0,n);

      // cout<<ans<<endl;
      printf("%.10f",ans);
      cout<<endl;

	return 0;
}



Measured memory_bytes: 70784
#include <iostream>
#include <unordered_set>
#include <cmath>
using namespace std;

unordered_set<long long> ans;

bool check(long long x, int y) {
	while (!(x%y)) x /= y;
	if (x%y == 1) return true;
	else return false;
}

void f(long long n) {
	if (n == 2) {
		ans.insert(2);
		return;
	}
	ans.insert(n), ans.insert(n - 1);
	for (int i = 2; i < sqrt(n - 1) + 1; i++) {
		if ((n - 1)%i == 0) {
			ans.insert(i), ans.insert((n - 1)/i);
		}
	}
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0) {
			if (check(n, i)) ans.insert(i);
		}
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	long long n;
	cin >> n;
	f(n);
	cout << ans.size();
}

Measured memory_bytes: 3596
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            //cout<<x<<"/"<<y;
            cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////



#define N 100005

ll cnt[N];
int main(){fastio
    ll n;cin>>n;
    ll ans=0;
    rep(i,1,n){
        ll c;cin>>c;
        ans+=c;
        cnt[c]++;
    }
    ll q;cin>>q;
    while(q--){
        ll b,c;cin>>b>>c;
        ans+=cnt[b]*(c-b);
        cout<<ans<<endl;
        cnt[c]+=cnt[b];
        cnt[b]=0;
    }
    
    return 0;
}






Measured memory_bytes: 4408
import numpy as np
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,T = IL()
t = IL()

ans = 0
for i in range(N-1):
  ans += min(t[i+1]-t[i], T)
else:
  ans += T

print(ans)

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

int main() {
	// your code goes here
	
	int x, y;
	cin>>x>>y;
	
	int b = 0;
	if ((y - 2*x) % 2 == 0) {
		b = (y - 2*x)/2;
	} else {
		cout << "No"<<endl;
		return 0;
	}
	
	
	if(b < 0) {
		cout<<"No"<<endl;
		return 0;
	}
	
	int a = x - b;
	
	if ( a < 0) {
		cout<<"No"<<endl;
		return 0;
	}
	
	
	cout<<"Yes"<<endl;
	
	
	return 0;
}

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

ll gcd(ll a, ll b){
    if (a%b == 0) return(ll(b));
    else return(ll(gcd(b, a%b)));
}

ll lcm(ll a, ll b){
    return ll(a * b / gcd(a, b));
}

int main(){
    ll a,b;
    cin >>a>>b;
    cout << ll(lcm(a,b)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll g[202][202];
ll r[16];
ll N,M,R;

int main(){
    rep(i,202) rep(j,202) g[i][j] = LINF;
    cin >> N >> M >> R;
    rep(i,R){
        cin >> r[i];
        r[i]--;
    }
    rep(i,M){
        ll a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        g[a][b] = g[b][a] = c;
    }

    rep(k,N) rep(i,N) rep(j,N){
        g[i][j] = min(g[i][j],g[i][k]+g[k][j]);
    }

    ll ans = LINF;

    sort(r,r+R);
    do{
        ll p = 0;
        for(int i=0;i<R-1;i++){
            ll s = r[i] , t = r[i+1];
            p += g[s][t];
        }
        ans = min(ans,p);
    }while(next_permutation(r,r+R));
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N = 1000010, P = 1e9 + 7;
int add(int a, int b) {
    return (a += b) >= P ? a - P : a; 
}
typedef long long ll;
int n;
int dp[N], sum[N];
int main() {
    cin >> n;
    dp[0] = 1;
    sum[0] = 1;
    dp[1] = n;
    sum[1] = n + 1;
    for (int k = 2; k <= n; ++k) {
        dp[k] = (ll)(n - 1) * (n - 1) % P;
        dp[k] = add(dp[k], (sum[k - 1] - dp[k - 2] + P) % P);
        dp[k] = add(dp[k], n - k + 1);
        sum[k] = add(sum[k - 1], dp[k]);
    }
    cout << dp[n] << '\n';
    return 0;
}

Measured memory_bytes: 11384
#include <bits/stdc++.h>
#define y1 yy1
using namespace std;

int n, val[1 << 19], x1, y1, x2, y2;
pair<int, int> a[1 << 18];

void Upd(pair<int, int> x, pair<int, int> &y) {
  tie(x1, y1) = x;
  tie(x2, y2) = y;
  y.first = val[x1] > val[x2] ? x1 : x2;
  y.second = val[y1] > val[y2] ? y1 : y2;
  if(x1 != x2) {
    if(val[x1] > val[x2]) swap(x1, x2);
    y.second = val[y.second] > val[x1] ? y.second : x1;
  }
}

int main(void) {
  scanf("%d", &n);
  for(int i = 0; i < (1 << n); i++) {
    scanf("%d", &val[i]);
    a[i].first = i;
    a[i].second = 1 << n;
    for(int j = 0; j < n; j++)
      if(i >> j & 1)
	Upd(a[i ^ (1 << j)], a[i]); 
  }
  int ans = 0;
  for(int i = 1; i < (1 << n); i++) {
    ans = max(ans, val[a[i].first] + val[a[i].second]);
    printf("%d\n", ans);
  }
  return 0;
}


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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c,k; cin>>a>>b>>c>>k;
	int ret=0;
	ret+=min(a,k);
	k-=min(a,k);
	k-=min(b,k);
	ret-=min(c,k);
	cout<<ret<<endl;
	return 0;
}


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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define _sort(a) sort(a.begin(), a.end())
#define _sortd(a) sort(a.rbegin(), a.rend())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

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

  for (int i = 0; i <= 15; ++i) {
    if (i * 7 > n) break;
    if ((n - i * 7) % 4 == 0) {
      py();
      return 0;
    }
  }
  pn();
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    long  a;
    long b;
    unsigned long long c;
    while(cin>>a>>b){
        c=a*b;
        while(a%b!=0&&b%a!=0){
            if(a>b){
                a=a%b;
            }
            else if(b>a){
                b=b%a;
            }
        }
        if(a>b) cout<<b<<" "<<c/b<<endl;
        else cout<<a<<" "<<c/a<<endl;
        c=0;
    }
    return 0;
}

Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long int lint;
typedef unsigned long long int ulint;

//#define DEBUG

#ifdef DEBUG
#	define dump(i) cout << "[*] " #i " : " << i << endl;
#	define debug(i) i
#else
#	define dump(i)
#	define debug(i)
#endif
#define rep(i, MAX) for (int i = 0; i < (MAX); ++i)

inline void solve() {
	int n, x;
	cin >> n >> x;
	int tmp;
	int min_m = 1001;
	rep(i, n) {
		cin >> tmp;
		min_m = min(min_m, tmp);
		x -= tmp;
	}
	cout << n + x / min_m << endl;
}

int main() {
	//*
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	// */
#ifdef DEBUG
	const auto start = chrono::high_resolution_clock::now();
#endif
	solve();
#ifdef DEBUG
	const auto stop = chrono::high_resolution_clock::now();
	cerr << "[*] time: " << chrono::duration_cast<chrono::milliseconds>(stop-start).count()
		<< " [ms]" << endl;
#endif
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long int ll;

int N;
int X,Y;

int a[20005];

int main(){
    cin>>N>>X>>Y;
    for(int i=1;i<=N-1;++i){
        for(int j=i+1;j<=N;++j){
            int dist=min(j-i,abs(X-i)+1+abs(Y-j));
            a[dist]++;
        }
    }
    for(int k=1;k<N;++k)cout<<a[k]<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N;
  cin >> N;
  // vector <string> S(N);
  // rep(i,N) cin >> S[i];
  set<string> st;
  rep(i,N){
    string S;
    cin >> S;
    st.insert(S);
  }
  cout << st.size() << endl;
  return 0;
}


Measured memory_bytes: 19236
package main

import (
  "fmt"
)

func absInt(x int) int {if x >= 0 {return x}; return -x}
func gcd(a, b int) int {if (b == 0) {return absInt(a)}; return gcd(b, a % b)}
func lcm(a, b int) int {return absInt(a / gcd(a, b) * b)}

func main() {
  var a, b, c int 
  fmt.Scan(&a, &b, &c)
  g := gcd(a, b)
  ans := "NO"
  if c % g == 0 {ans = "YES"}
  fmt.Println(ans)
}

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

int primeFactors(int n)
{
    int ret=0;
    while (n % 2 == 0)
    {
        ret++;
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            ret++;
            n = n/i;
        }
    }
    if (n > 2)
        ret++;

    return ret;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("maxflow.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector<int> v;
    for(int i=1;i<100005;i++){
        if(i%2==0){
            continue;
        }
        if(primeFactors(i)==primeFactors((i+1)/2)&&primeFactors(i)==1){
            v.push_back(i);
        }
    }
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        int lo=lower_bound(v.begin(),v.end(),l)-v.begin();
        int up=upper_bound(v.begin(),v.end(),r)-v.begin();
        cout<<up-lo<<endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;


void solve(){
    int n,k;
    cin>>n>>k;
    vector<ll>dp(n+5,INF);
    vector<int>h(n);
    rep(i,n)cin>>h[i];
    dp[0]=0;
    rep(i,n){
        ll minv=INF;
        for(int j=1;j<=k;++j){
            if(i-j<0)continue;
            chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n-1]<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n, m;
	while (cin >> n >> m) {
		if (n == 0)break;
		int t, s, d;
		int infe[20001] = {}; infe[1] = 1;
		pair<int,P> p[20000];
		for (int i = 0; i < m; i++) {
			cin >> t >> s >> d;
			p[i].first = t;
			p[i].second.first = s;
			p[i].second.second = d;
		}
		sort(p, p + m);
		for (int i = 0; i < m; i++) {
			if (infe[p[i].second.first]) {
				infe[p[i].second.second] = 1;
			}
		}
		int cnt = 0;
		for (int i = 1; i <= n; i++) {
			if (infe[i])cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 3408
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
using namespace std;
int main() {
	string s;
	vector<bool> n(26,true);
	cin >> s;
	for (auto& a : s) {
		n[a - 'a'] = false;
	}
	for (int i = 0; i < 26;i++) {
		if (n[i]) {
			cout << char('a' + i) << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}



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

using namespace std;

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


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

bool check(int x) {
  vector<bool> f(10, false);
  while (x > 0) {
    int d = x % 10;
    f[d] = true;
    x /= 10;
  }

  return f[7] && f[5] && f[3];
}

ll dfs(ll x, int n) {
  if (x > n) return 0;
  ll ret = dfs(10 * x + 7, n) + dfs(10 * x + 5, n) + dfs(10 * x + 3, n);
  if (check(x)) ret++;
  return ret;
}

int main() {
  int n;
  cin >> n;
  ll ans = dfs(0, n);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>

using namespace std;
int main(int argc, char *argv[]) {
	int n, q;
	int time = 0;
	cin >> n >> q;
	queue< pair<string, int> > Q;
	pair<string, int> work[n];
	pair<string, int> result[n];
	for(int i = 0; i < n; i++){
		cin >> work[i].first >> work[i].second;
		Q.push(work[i]);
	}
	int i = 0;
	while(!Q.empty()){
		pair<string, int> p;
		p = Q.front();
		Q.pop();
		if(p.second-q > 0){
			p.second = p.second - q;
			Q.push(p);
			time += q;
		}else{
			time += p.second;
			result[i].first = p.first;
			result[i].second = time;
			i++;
		}
	}
	for(int i = 0; i < n; i++){
		cout << result[i].first << " " << result[i].second << endl;
	}
	return 0;
}


Measured memory_bytes: 7864
#include "bits/stdc++.h"
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define int long long int
#define tc int t; cin>>t; while(t--)
#define fora(i,n) for(int i=0;i<n;i++)
#define forb(i,a,n) for(int i=a;i<n;i++)
#define mod 1000000007

template<class T> T power(T N,T P){ return (P==0)?  1: N*power(N,P-1);}

int32_t main()
{
    fastio
    int n;
    cin>>n;
    map<int,int> mp;
    int arr[n];
    fora(i,n) {
        cin>>arr[i];
        mp[arr[i]]++;
    }
    sort(arr,arr+n,greater<int>());
    int ans=0;
    // ans+=arr[0]*mp[[0]];
    // int curr=arr[0];
    // int ptr=0;
    // ptr+=mp[arr[0]];
    // map<int,int> gaps;
    // gaps[arr[0]]=mp[arr[0]];
    // int gaps=mp[arr[0]];
    // while(ptr<n) {
    //     int freq=mp[arr[ptr]];

    // }
    int ptr=0,l=0;
    while(l<n&&ptr<n) {
        if(ptr==0) {
            ans+=arr[ptr];
            ptr++;
            l+=2;
        }
        else {
            ans+=min(2LL,n-l)*arr[ptr];
            l+=2;
            ptr++;
        }
    }
    cout<<ans;
    return 0;


}

Measured memory_bytes: 17700