akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
#include<bitset>
using namespace std;

typedef long long int64;
typedef int int32;
typedef char int8;

#define rep(i,j) for(int i=0;i<j;i++)
#define repeat(i,j,k) for(i=(j),i<(k);i++)
#define repeat_eq(i,j,k) for(i=(j),i<=(k);i++)
#define rev_rep(i,j,k) for(i=(j)-1;i>=k;i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
  int to;
  int cost;
};
struct State{
  int node;
  int t;
  double time;
  bool operator>(const State &r)const{
    return time>r.time;
  }
};

int n,m,p,a,b;
int t_data[8];
vector<Edge> G[31];

void Dig(){
  priority_queue<State,vector<State>,greater<State> > que;
  bool flg[31][257]={};//[点][残りチケット]
  rep(i,m)rep(j,257)flg[i][j]=false;
  que.push((State){a,0xFF,0});
  
  while(!que.empty()){
    State now=que.top();que.pop();
    if(now.node==b){
      printf("%.4f\n",now.time);
      return;
    }
    if(flg[now.node][now.t])continue;
    flg[now.node][now.t]=true;
    rep(i,G[now.node].size()){
      rep(j,n){
	if(now.t&(1<<j)){
	  que.push((State){G[now.node][i].to,now.t&~(1<<j),now.time+G[now.node][i].cost/(double)t_data[j]});
	}
      }
    }
  }
  cout<<"Impossible"<<endl;
  return;
}

int main()
{

  while(true)
    {
      cin>>n>>m>>p>>a>>b;
      a--;b--;
      if(n==0)break;

      rep(i,n)
	cin>>t_data[i];
      rep(i,p){
	int x,y,z;cin>>x>>y>>z;
	x--;y--;
	G[x].push_back((Edge){y,z});
	G[y].push_back((Edge){x,z});
      }
      Dig();
      rep(i,m)
	G[i].clear();
    }
  return 0;
}

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

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

    while (1) {
        int n, m;
        cin >> n >> m;
        if (n + m == 0) break;
        long long ans = 0;
        for (int i = 0; i < n; i++) {
            int a;
            cin >> a;
            if (a < m / n)
                ans += a;
            else
                ans += m / n;
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3148
my ($N, $M);
my ($c, $d) = split(/ /,<STDIN>);
chomp($d);
if ($c > $d){
        $N = $d;
        $M = $c;
} else {
        $N = $c;
        $M = $d;
}
if ($N == 1 && $M == 1){
        print 1;
} elsif ($N == 1 && $M == 2){
        print 0;
} elsif ($N == 1 && $M > 2){
        print $M-2;
} else {
        my $nn = ($M-2) * ($N-2);
        print $nn;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(1000000)

N=int(input())

n=[[]for i in range(N+1)]

for i in range(N-1):
    u,v,w=map(int,input().split())
    n[u].append([v,w])
    n[v].append([u,w])
L=[-1 for i in range(N+1)]
L[1]=0
def dfs(x):
    for i in n[x]:
        if L[i[0]]==-1:
            L[i[0]]=L[x]+i[1]
            dfs(i[0])
dfs(1)
#print(n)
#print(L)
for i in range(1,N+1):
    if L[i]%2==0:
        print(0)
    else:
        print(1)


Measured memory_bytes: 88108
# utf-8:
def main():
    x, y, z = map(int, raw_input().split())
    a = y + z
    b = x - z
    n = 0

    while True:
        if (n * a) <= b:
            n += 1
        else:
            break

    print(n-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2568
N = int(input())

t = 50
w = []
while True:
    x = N // t
    if x == 0:
        break
    else:
        w.append(x)
    t *= 5

if N % 2 == 1:
    ans = 0
else:
    ans = N // 10
    for wi in w:
        ans += wi
print(ans)

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

int main() {
    long long a,b,c,k;
    
    cin>>a>>b>>c>>k;
    
    if(a>=k){
        cout<<k<<endl;
    }
    else if(a+b>=k){
        cout<<a<<endl;
    }
    else 
        cout<<a-(k-a-b)<<endl;

    
    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ll n, w;
	cin >> n >> w;

	//ll maximumValue = n * 1005;
	ll maximumValue = n * 1005;

	vector<pll> weightValue;
	FOR(i, 0, n) {
		ll a, b; cin >> a >> b;
		weightValue.pb(mp(a, b));
	}

	// DP for minimum weight according to reachable value and last used block
	ll dp[maximumValue][n + 1];
	FOR(i, 0, maximumValue) FOR(j, 0, n + 1) dp[i][j] = oo;
	
	dp[0][0] = 0;	

	FOR(j, 1, n + 1) {
		FOR(i, 0, maximumValue) {
			pll nextPair = weightValue[j - 1];			
			
			dp[i][j] = dp[i][j - 1];						
			if(i - nextPair.yy >= 0) {
				dp[i][j] = min(dp[i][j - 1], dp[i - nextPair.yy][j - 1] + nextPair.xx);
			}
		}
	}

	ll maxi = 0;
	FOR(i, 0, maximumValue) {
		FOR(j, 0, n + 1) {
			//cerr << i << " " << j << ": " << dp[i][j] << endl;
			if(dp[i][j] <= w) {
				maxi = max(maxi, i);
			}
		}
	}

	cout << maxi << endl;

	return 0;
}

Measured memory_bytes: 79488
N = int(input())
a = 0

for i in range(N):
    if (((i+1) % 3) == 0) and (((i+1) % 5) == 0):
        pass
    elif (((i+1) % 3) == 0):
        pass
    elif (((i+1) % 5) == 0):
        pass
    else:
        a += (i+1)

print(a)



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

int main(){
  double A, B, X;
  const double PI = 3.1415926535897;
  cout << fixed << setprecision(10);
  
  cin >> A >> B >> X;
  
  if (B < 2 * X / (A * A)){
    
  	cout << atan((B - X / (A * A)) * 2 / A) * 180 / PI << endl;
    
  }
  else{
    
    cout << atan(A * B * B / (2 * X)) * 180 / PI << endl;
    
  }
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % 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 main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);

    int N, M, Q;
    cin >> N >> M >> Q;

    int memo[N+1][N+1] = {0};
    int sum_memo[N+1][N+1] = {0};

    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            memo[i][j] = 0;
            sum_memo[i][j] = 0;
        }
    }

    int tmp_l, tmp_r;
    for(int i = 0; i < M; i++){
        cin >> tmp_l >> tmp_r;
        memo[tmp_l][tmp_r] += 1;
    }
    for(int l = 0; l < N; l++){
        
        // まず横に
        for(int j = l; j < N; j++){
            sum_memo[l+1][j+1] = memo[l+1][j+1] + sum_memo[l][j+1]
            + sum_memo[l+1][j] - sum_memo[l][j];
        }

        // 次にたてに
        for(int i = l; i < N; i++){
            sum_memo[i+1][l+1] = memo[i+1][l+1] + sum_memo[i][l+1]
            + sum_memo[i+1][l] - sum_memo[i][l];
        }
    }


    vector<int> p(Q), q(Q);
    for(int i = 0; i < Q; i++){
        cin >> p[i] >> q[i];
    }

    // for(int i = 0; i <= N; i++){
    //     for(int j = 0; j <= N; j++){
    //         cout << memo[i][j];
    //     }
    //     cout << endl;
    // }

    // for(int i = 0; i <= N; i++){
    //     for(int j = 0; j <= N; j++){
    //         cout << sum_memo[i][j];
    //     }
    //     cout << endl;
    // }

    int tmp_p, tmp_q;

    for(int i = 0; i < Q; ++i){
        tmp_p = p[i];
        tmp_q = q[i];
        cout << sum_memo[tmp_q][tmp_q] - sum_memo[tmp_q][tmp_p-1]
        - sum_memo[tmp_p-1][tmp_q] + sum_memo[tmp_p-1][tmp_p-1] << endl;
    }

    
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> P(N), Q(N);
  for (int i=0; i<N; i++) cin >> P.at(i);
  for (int i=0; i<N; i++) cin >> Q.at(i);
  // 1からNまでの自然数の順列
  vector<int> national(N);
  for (int i=0; i<N; i++) national.at(i) = i+1;
  int a=1, b=1;
  while (true) {
    if (P!=national) {
      a++;
      next_permutation(national.begin(), national.end());
    }
    else break;
  }
  for (int i=0; i<N; i++) national.at(i) = i+1;
  while (true) {
    if (Q!=national) {
      b++;
      next_permutation(national.begin(), national.end());
    }
    else break;
  }
  cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
int n,h,w,a,b,c,i;
int main()
{
	int n,a,b,p,c[3]={0};
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)
	{
		cin>>p;
		if(p<=a)c[0]++;
		else if(p<=b)c[1]++;
		else c[2]++;
	}
	sort(c,c+3);
	cout<<c[0]<<endl;
}

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N; cin >> N;
	vector<LL> X(N),Y(N);
	repp(i,0,N){
		cin >> X[i] >> Y[i];
		if(i > 0 && (X[i]+Y[i]+X[i-1]+Y[i-1])%2 != 0) return cout << -1 << endl, 0;
	}
	cout << ((X[0]+Y[0])%2==0?40:39) << endl;
	LL m = 1;
	repp(i,0,19){
		cout << m << ' ' << m << ' ';
		m *= 3;
	}
	if((X[0]+Y[0])%2==0) cout << m << ' ' << m << endl;
	else cout << m << endl;
	repp(i,0,N){
		char c = 0;
		if((X[i]+Y[i])%2!=0){
			if(abs(X[i]) < abs(Y[i])){
				if(Y[i] < 0){
					Y[i] += m;
					c = 'D';
				} else {
					Y[i] -= m;
					c = 'U';
				}
			} else {
				if(X[i] < 0){
					X[i] += m;
					c = 'L';
				} else {
					X[i] -= m;
					c = 'R';
				}
			}
		}
		repp(k,0,20){
			if(k == 19 && c!=0) break;
			LL a = ((X[i]%3)+3)%3;
			LL b = ((Y[i]%3)+3)%3;
			if(a == 0 && b == 0){
				cout << "LR";
			} else if(a == 0 && b == 1){
				X[i] += 0; Y[i] += 2;
				cout << "DD";
			} else if(a == 0 && b == 2){
				X[i] += 0; Y[i] += -2;
				cout << "UU";
			} else if(a == 1 && b == 0){
				X[i] += 2; Y[i] += 0;
				cout << "LL";
			} else if(a == 1 && b == 1){
				X[i] += -1; Y[i] += -1;
				cout << "RU";
			} else if(a == 1 && b == 2){
				X[i] += -1; Y[i] += 1;
				cout << "RD";
			} else if(a == 2 && b == 0){
				X[i] += -2; Y[i] += 0;
				cout << "RR";
			} else if(a == 2 && b == 1){
				X[i] += 1; Y[i] += -1;
				cout << "LU";
			} else{
				X[i] += 1; Y[i] += 1;
				cout << "LD";
			}
			X[i] /= 3;
			Y[i] /= 3;
		}
		assert(X[i] == 0 && Y[i] == 0);
		if(c!=0) cout << c;
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int n, x;
bool dp[200002];
int main() {
    DAU
    cin >> n;
    dp[0] = 1;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        dp[x] |= dp[x-1];
    }
    for (int i = n; i; --i)
        if (dp[i]) {
            cout << n - i;
            PLEC
        }
    cout << -1;
    PLEC
}

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

# define ll long long 

const int md = 1e9+7;

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

    vector<ll> v(n);
    vector<ll> pos(n+1,0);

    for(int i=0;i<n;i++)
    {
    	cin>>v[i];
    }

    for(int i=n-1;i>=0;i--)
    {
    	pos[i]=((pos[i+1]%md) + (v[i]%md))%md;
    }

    // for(int i=0;i<n;i++)
    // {
    // 	cout<<pos[i]<<" "<<endl;
    // }

    ll sum=0;
    for(int i=0;i<n-1;i++)
    {
    	sum = (((v[i]%md)*(pos[i+1]%md))%md + (sum%md))%md;

    }

    cout<<sum<<endl;

  return 0;
}

Measured memory_bytes: 6420
#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;
typedef long long ll;
string a,b;
ll k;
int n;
ll dp[105][2][2][5];
ll fun(int pos,int boro,int choto,int nw)
{
    if(nw>k)
    {
        return 0;
    }
    if(pos==n)
    {
        if(k==nw)
        {
            return 1LL;
        }
        return 0;
    }
    if(dp[pos][boro][choto][nw]!=-1)
        return dp[pos][boro][choto][nw];
    int lw=0;
    int hi=9;
    if(boro==0) lw=a[pos]-'0';
    if(choto==0) hi=b[pos]-'0';
    ll ret=0;
    for(int i=lw;i<=hi;i++)
    {
        if(i!=0) ret += fun(pos+1,boro|(i>lw),choto|(i<hi),nw+1);
        else ret += fun(pos+1,boro|(i>lw),choto|(i<hi),nw);
    }
    return dp[pos][boro][choto][nw]=ret;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(cin>>b>>k)
    {
        for(int i=0;i<b.size();i++)
        {
            a.push_back('0');
        }
        n=b.size();
        memset(dp,-1,sizeof dp);
        cout<<fun(0,0,0,0)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int alpha(char c)
{
    int array[26];
    array[0] = 'a';
    for(int i = 1; i < 26; i++)
    {
        array[i] = array[i - 1] + 1;
    }
    for(int j = 0; j < 26; j++)
    {
        if(array[j] == c)
        {
            return j;
        }
    }
}
int main()
{
    string s;
    int k;
    cin >> s;
    cin >> k;
    int n = s.length();
    int c[n];
    for(int t = 0; t < n; t++)
    {
        c[t] = 26 - alpha(s[t]);
        if(s[t] != 'a' && k >= c[t])
        {
            k = k - c[t];
            s[t] = 'a';
        }
        else
        {
        }
        
    }
    int l = alpha(s[n-1]);
    int m = (k + l) % 26;
    s[n-1] = 'a' + m;
    cout << s << endl;

}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
string str;
long long ans=0,res=0;
int main()
{
    cin>>str;
    for(int state=0;state<(1<<(str.length()-1));state++)
    {
        for(int i=0;i<str.length();i++)
        {
            res=res*10+str[i]-'0';
            if((state>>i)&1)
                ans+=res,
                res=0;
        }
        ans+=res;
        res=0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head
ll k, c = 0, ans = 0;

void recurse(ll s, ll l, ll num) {
    num *= 10;
    num += s;
    if (l == 1) {
        c++;
        if (c == k)
            ans = num;
        return;
    }

    if (s - 1 >= 0) {
        recurse(s-1, l-1, num);
        if (ans)
            return;
    }

    recurse(s, l-1, num);
    if (ans)
        return;

    if (s + 1 < 10) {
        recurse(s+1, l-1, num);
        if (ans)
            return;
    }

}

int main() {
    cin >> k;
    ll num = 0;
    for (ll i = 1; i <= 10; i++) {
        for (ll j = 1; j <= 9; j++) {
            num = 0;
            recurse(j, i, num);
            if (ans) {
                cout << ans << "\n";
                return 0;
            }
        }
    }
    if (ans) {
        cout << ans << "\n";
        return 0;
    }
}


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

ll ary[100010],jn[100010],in[100010];
int main(){
	int N;
	cin>>N;
	char ch;
	for(int i=1;i<=N;i++){
		cin>>ch;
		if(ch=='J') ary[i]=0;
		else if(ch=='O') ary[i]=1;
		else ary[i]=2;
	}
	ll cnt=0;
	for(int i=1;i<=N;i++){
		if(ary[i]==0) cnt++;
		jn[i]=cnt;
	}
	cnt=0;
	for(int i=N;i>=1;i--){
		if(ary[i]==2) cnt++;
		in[i]=cnt;
	}
	ll res[3]={};
	cnt=0;
	for(int i=1;i<=N;i++){
		if(ary[i]==1){
			res[0]+=((jn[i]+1)*in[i]);
			res[1]+=(jn[i]*in[i]);
			res[2]+=(jn[i]*(in[i]+1));
		}
		cnt=max(cnt,jn[i]*in[i]);
	}
	res[1]+=cnt;
	cout<<max(res[1],max(res[0],res[2]))<<endl;
	return 0;
}

Measured memory_bytes: 5420
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cerr<<x<<endl;
#define endl "\n"
#define pb push_back
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(10);
    //cout<<fixed;
    //cout.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    
    if(a+b>=c)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    string s;
    cin >> s;
    int N = s.size();
    int ans = 0;
    int g = 0;
    REP (i, N) {
        if (s[i] == 'g' && g > 0) {
            ans++;
            g--;
        } else if (s[i] == 'g' && g == 0) {
            g++;
        } else if (s[i] == 'p' && g >0) {
            g--;
        } else {
            ans--;
            g++;
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 512
N, K, *XY = map(int, open(0).read().split())

X, Y = zip(*sorted(zip(*[iter(XY)] * 2)))

cand = []
for k in range(K, N + 1):
    for i in range(N - k + 1):
        dx = X[i + k - 1] - X[i]
        YY = sorted(Y[i:i + k])
        cand += [min(dx * (YY[j + K - 1] - YY[j]) for j in range(k - K + 1))]

print(min(cand))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
#define ll long long
typedef unsigned long long ull;
typedef long double ld;

#define pii         pair<ll ,ll >
#define vi          vector<ll >
#define vii         vector<pii>
#define mi          map<ll ,ll >
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define pb          push_back
#define hell        1000000007
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define take        rep(i,0,n) cin>>v[i];
#define MAXN        1000005


#define allr(c) (c).rbegin(),(c).rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}


void solve()
{
	ll n;
	cin>>n;
	ll a=powr(10,n);
	ll b=powr(8,n);
	ll c=powr(9,n);
	ll d=add(c,c);
	ll z=sub(a,d);
	z=add(z,b);
	cout<<z<<endl;
}

int main()
    {
    	ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
      
        ll t;
        
        t=1;
        
    
   // cin>>t;
        while(t--)
        solve();
    }

Measured memory_bytes: 3628
import sys
from collections import Counter
from itertools import accumulate
read = sys.stdin.read

N, K, *A = map(int, read().split())
a = list(accumulate([0] + A))
a = [(a[i] - i) % K for i in range(N + 1)]


def cmb(x):
    return x * (x - 1) // 2


answer = 0
if N < K:
    for i in Counter(a).values():
        answer += cmb(i)
else:
    dic = Counter(a[:K])
    for i in dic.values():
        answer += cmb(i)
    here = K
    for i, x in enumerate(a[K:]):
        dic[a[i]] -= 1
        answer += dic[x]
        dic[x] += 1

print(answer)

Measured memory_bytes: 42124
//Date of submission: 14-06-2020

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e5 + 5;
const double E= 1e-9;

//------------------------------------------------------------------------------

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,n;
    cin>>x>>n;
    vector<ll> v(n);
    for(ll i=0; i<n; i++)
    cin>>v[i];
    sort(v.begin(),v.end());
    ll i=0;
    while(1)
    {
        if(!binary_search(v.begin(),v.end(),x-i))
        {
            cout<<x-i;
            break;
        }    
        if(!binary_search(v.begin(),v.end(),x+i))
        {
            cout<<x+i;
            break;
        }  
        ++i;
    }
    return 0;
}

//------------------------------------------------------------------------------


Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int maxn=1e5+5;
int n;
int a,b;
int main()
{
	while(cin>>a>>b)
	{
		int delta=b-a;
		cout<<(1+delta)*delta/2-b<<endl;
		
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int dp[1000][8],n,i,j,k,ans=0;
    char res[1001];
    scanf("%d",&n);
    scanf("%s",res);
    for(i=0; i<n; i++){
        switch(res[i]){
            case 'J':
                res[i]=4;
                break;
            case 'O':
                res[i]=2;
                break;
            case 'I':
                res[i]=1;
                break;
        }
    }
    for(i=0; i<8; i++){
        if((i&4) != 0 && (i&res[0]) != 0){
            dp[0][i]=1;
        }else{
            dp[0][i]=0;
        }
        for(j=1; j<n; j++){
            dp[j][i]=0;
        }
    }
    for(i=1; i<n; i++){
        for(j=0; j<8; j++){
            for(k=0; k<8; k++){
                if((j&k)!=0 && (res[i]&k)!=0){
                    dp[i][k] = (dp[i][k] + dp[i-1][j])%10007;
                }
            }
        }
    }
    n--;
    for(i=0; i<8; i++){
        ans += dp[n][i];
        ans %= 10007;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 628
#include <iostream>
#include <algorithm>
#include <queue>
#include <deque>
#include <string>
#include <map>
#include <utility>
using namespace std;

#define INF 1000000000

int N, M, cap;
string cityfrom, cityto;
string cityname[3000][2];
string citystat[300];
int d[3000];

typedef pair<int,int> pii;
typedef priority_queue<pii,deque<pii>,greater<pii> > pq_t;

int solve(){
	map<string,int> m_city;
	
	for( int i = 0; i < N; ++i ){
		m_city.insert( make_pair( cityname[i][0], m_city.size() ) );
		m_city.insert( make_pair( cityname[i][1], m_city.size() ) );
	}
	
	int n = m_city.size();
	vector< vector<pii> > road( n );
	
	for( int i = 0; i < N; ++i ){
		int a = m_city[ cityname[i][0] ];
		int b = m_city[ cityname[i][1] ];
		road[a].push_back( pii( b, d[i] ) );
		road[b].push_back( pii( a, d[i] ) );
	}
	
	
	vector<int> nstat( M + 2 );
		//スタンドの番号。
		//ただし最初2つは出発地と目的地の番号としておく。
	
	nstat[0] = m_city[ cityfrom ];
	nstat[1] = m_city[ cityto ];
	for( int i = 0; i < M; ++i ){
		nstat[i + 2] = m_city[ citystat[i] ];
	}

	cap *= 10;

	vector< vector<int> > dist( nstat.size(), vector<int>( n, INF ) );
	for( int from = 0; from < nstat.size(); ++from ){
		int n_from = nstat[from];
		dist[from][n_from] = 0;
		pq_t pq;
		pq.push( pii( 0, nstat[from] ) );
		while( !pq.empty() ){
			pii p = pq.top();
			pq.pop();

			int n_f = p.second;
			if( dist[from][n_f] != p.first ){
				continue;
			}

			for( int i = 0; i < road[n_f].size(); ++i ){
				int n_to = road[n_f][i].first;
				int ds = p.first + road[n_f][i].second;
				
				if( ds <= cap && dist[from][n_to] > ds ){
					dist[from][n_to] = ds;
					pq.push( pii( ds, n_to ) );
				}
			}
		}
	}


	vector<int> dp( nstat.size(), INF );
	dp[0] = 0;
	
	pq_t pq;

	pq.push( make_pair( 0, 0 ) );
	while( !pq.empty() ){
		pii p = pq.top();
		pq.pop();

		int from = p.second;
		if( dp[from] != p.first ){
			continue;
		}
		
		int n_from = nstat[from];
		for( int to = 0; to < nstat.size(); ++to ){
			int n_to = nstat[to];
			if( dist[from][n_to] <= cap && dp[to] > dp[from] + dist[from][n_to] ){
				dp[to] = dp[from] + dist[from][n_to];
				pq.push( make_pair( dp[to], to ) );
			}
		}
	}
	
	if( dp[1] == INF ){
		return -1;
	}
	return dp[1];
}

int main(){
	for( ; cin >> N >> M >> cap >> cityfrom >> cityto; ){
		for( int i = 0; i < N; ++i ){
			cin >> cityname[i][0] >> cityname[i][1] >> d[i];
		}
		for( int i = 0; i < M; ++i ){
			cin >> citystat[i];
		}
		
		cout << solve() << endl;
	}
}

Measured memory_bytes: 5052
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

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

int main()
{
    int a,b;
    cin >> a >> b;
    cout << gcd(a,b) << endl;
    return 0;
}


Measured memory_bytes: 3116
<?php

fscanf(STDIN, "%d", $n);

$s_count_list = [];
for ($i = 0; $i < $n; ++$i) {
    fscanf(STDIN, "%s", $s);
    if (!isset($s_count_list[$s])) {
        $s_count_list[$s] = 1;
    } else {
        ++$s_count_list[$s];
    }
}

$max_count = max($s_count_list);
$max_s_list = array_filter($s_count_list, function ($s_count) use ($max_count) {
    return $s_count === $max_count;
});

ksort($max_s_list);
echo implode(PHP_EOL, array_keys($max_s_list));


Measured memory_bytes: 51416
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug { 
    ($($a: expr),*) => { 
        println!(concat!($(stringify!($a)," = {:?}, "),*), $($a),*);
    } 
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

fn solve() {
    let n = get!(usize);
    let a = read::<i64>();

    let sums = a.into_iter().scan(0, |sum, e| {
        *sum += e;
        Some(*sum)
    }).collect::<Vec<_>>();

    let mut map = BTreeMap::new();
    for sum in sums {
        *map.entry(sum).or_insert(0u64) += 1;
    }

    let mut count = 0;
    for (k, v)  in map {
        count += if k == 0 {
            v*(v+1)/2
        } else {
            v*(v-1)/2
        };
    }
    println!("{}", count);
}


Measured memory_bytes: 14708
#include <bits/stdc++.h>
using namespace std;
long DEF = pow(10,9) + 7;
int N;
int p[1005];

void pf(int n){
    for(int i = 2; i <= n; i++){
        while(n % i == 0){
            n /= i;
            p[i]++;
        }
        if( n == 1 ){
            break;
        }
    }
}


int main(){
    cin >> N;
    for(int i = 2; i <= N; i++){
        pf(i);
    }
    
    long ans = 1;
    for(int i = 1; i <=1000; i++){
        ans *= p[i] + 1;
        ans %= DEF;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#10
N = int(input())
x = list(map(int,input().split()))
alis = 0
bob = 0
cou = 0

x.sort()

for i in reversed(range(N)):
    if cou %2 == 0:
        alis += x[i]
    else:
        bob += x[i]
    cou += 1

print(alis - bob)
    

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
 
using namespace std;
 
 
int main(){
  int e;
  while(cin>>e,e){
    vector<int> dp(e+1,e);
		vector<int> z;
        for(int i = 0;i*i*i<=e;i++){
					z.push_back(i*i*i);
				}
				int z_size = z.size();
				for(int i = 0;i<z_size;i++){
					for(int j = 0;z[i]+j*j<=e;j++){
							int yy = j*j;
							dp[z[i]+yy] = min(i+j,dp[z[i]+yy]);
							dp[e] = min(e-z[i]-yy+dp[z[i]+yy],dp[e]);
					}
				}
				cout << dp[e] << endl;
  }
  return 0;
}

Measured memory_bytes: 10456
import sys
sys.setrecursionlimit(10**5)

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n 
        self.size = [1] * n
    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
            
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] = self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1
                
n, m, k = map(int, input().split())
friends = [[] for _ in range(n)]
blocks = [[] for _ in range(n)]

for i in range(m):
    x, y = map(lambda x: int(x) - 1, input().split())
    friends[x].append(y)
    friends[y].append(x)

for i in range(k):
    x, y = map(lambda x: int(x) - 1, input().split())
    blocks[x].append(y)
    blocks[y].append(x)

uf = UnionFind(n)
for i in range(n):
    for f in friends[i]:
        uf.union(i, f)

# 自分を除くUnionFind木の大きさ
ans = [uf.size[uf.find(i)] - 1 for i in range(n)]
# 直接的な友達を引く
for i in range(n):
    ans[i] -= len(friends[i])

for i in range(n):
    for b in blocks[i]:
        if uf.same(i, b):
            ans[i] -= 1

print(*ans)


Measured memory_bytes: 54252
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
typedef  long long ll;
int N,T,A;
double x;
int in[(int)1e5+5];
double abs(double a){
if(a>=0)
    return a;
else return -1*a;
}

int main(){
    int ans=1;
    double tmp=int(1e6);
  scanf("%d",&N);
  scanf("%d%d",&T,&A);
  for(int i=1;i<=N;i++){
    scanf("%lf",&x);
    double t = T- x*0.006;
    if(tmp == (int)(1e6)){tmp = abs(A-t); ans = i;}
    if(tmp > abs(A-t)){
        tmp=abs(A-t);
        ans=i;
    }
  }
  printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split(" "))
temp = {}
cost = 0
count = 0

for i in range(N) :
    A, B = map(int, input().split(" "))
    if A in temp :
        temp[A] += B
    else :
        temp[A] = B

for k, v in sorted(temp.items()):
    cost += k*v
    M = M - v
    
    if M <= 0 :
        cost = cost + (k*M)
        break


print(cost)

Measured memory_bytes: 23000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N, M;
const ll DIV = 1000000007;
int as[100100];
ll dp[100100];

void solve() {
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int ai;
        cin >> ai;
        as[ai] = 1;
    }
    dp[0] = 1;

    for (int i = 1; i <= N; ++i) {
        if (as[i] == 1) {
            dp[i] = 0;
            continue;
        }
        ll one = dp[i - 1];
        ll two = (0 <= i - 2) ? dp[i - 2] : 0;
        dp[i] = one + two;
        dp[i] %= DIV;
    }
    cout << dp[N] << endl;
}

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


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	string s;
	cin >> s;
	if (s == "ABC")
	{
		cout << "ARC" << endl;
	}
	else
	{
		cout << "ABC" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define endl "\n"
#define sz(u) (int)(u.size())
#define L(x)(2*x)
#define R(x)(2*x+1)
#define M(x,y)((x+y)/2)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
unordered_map<string,int> ans;
void solve(){
    string s;
    cin>>s;
    ans[s]++;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    while(t--){
        solve();

    }
    cout<<"AC x "<<ans["AC"]<<endl;
    cout<<"WA x "<<ans["WA"]<<endl;
    cout<<"TLE x "<<ans["TLE"]<<endl;
    cout<<"RE x "<<ans["RE"]<<endl;
}


Measured memory_bytes: 3664
/*input
5
3 11 14 5 13
*/

#include <bits/stdc++.h>

using namespace std;

const int N = 200004;

typedef long long LL;

char s[N];

int main() {
  ios_base::sync_with_stdio(false);

  int n;
  map<int,int> cnt;
  vector<int> v;

  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    v.push_back(x);
  }

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

  for (auto a : v) {
    cnt[a]++;
  }

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

  int ans = 0;
  for (auto x : v) {
    if (!cnt[x]) continue;
    for (int j = 1<<30; j > x; j >>= 1) {
      int c = j - x;
      if (cnt[c]) {
        if (c == x && cnt[x] == 1) continue;
        cnt[x]--; cnt[c]--;
        ans++;
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 29812
(defun f (s)
  (let* ((n (read s))
         (ps (loop for i from 1 to n
                   for city = (read s)
                   for point = (read s)
                   collecting (list i city point)))
         (sorted1 (sort ps #'(lambda (p pp) (> (third p) (third pp)))))
         (sorted2 (sort sorted1 #'(lambda (p pp) (string< (second p) (second pp))))))
    (loop for p in sorted2
          do (format t "~A~%" (first p)))))
(f t)

Measured memory_bytes: 13280
my ($N,$X,$M) =split(/ /,<>);

my $A = $X;
my $sum = $A%$M;

my %DB;
#print "1 $A\n";
for(my $i=1;$i<$N;$i++){
    my $mod = ($A*$A) % $M;
    #print "$i $mod $sum\n";
    if(defined($DB{$mod}[0])){
      my $skip = $i - $DB{$mod}[0];
      my $B = int( ($N-$i-1-(($N-$i)%$skip))/$skip);
      $sum += ($sum-$DB{$mod}[1])*$B;
      $i += $skip * $B;
      
    }else{
      $DB{$mod}[0] = $i;
      $DB{$mod}[1] = $sum;
    }
    $sum += $mod;
    $A = $mod;
    
}
print "$sum";

Measured memory_bytes: 18152
package main

import (
	"fmt"
	"sort"
)

func main() {
	lists := make([]int, 3)
	for i:=0; i<3; i++{
		fmt.Scan(&lists[i])
	}
	sort.Ints(lists)
	fmt.Println(lists[2]*10 + lists[1] + lists[0])
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};



int main() {
    int n,x;cin>>n>>x;
    vector<int>m(n);cin>>m;
    rep(i,n) x-=m[i];
    sort(all(m));
    int count = n;
    while(x-m[0]>=0){
        x-=m[0];
        count++;
    }
    cout<<count<<endl;
    return 0;
}







Measured memory_bytes: 256
import java.util.*;
import java.util.function.BiConsumer;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[M];
		int[] B = new int[M];
		
		
		//部屋を結ぶ道をリストで管理
		List<Integer>[] edge = new ArrayList[N];
		for(int i = 0; i < N; i++)
		    edge[i] = new ArrayList<>();
		for (int i = 0; i < M; i++) {
		    int a = sc.nextInt()-1;
		    int b = sc.nextInt()-1;
		    edge[a].add(b);
		    edge[b].add(a);
		}

		int INF = 100000000;
		Queue<Integer> queue = new ArrayDeque<>(); //空のキューの用意
		int[] shirube = new int[N];
		//訪問済み&道標
		Arrays.fill(shirube, INF);

		//頂点vが未訪問のとき、訪問済みにしてvをキューに追加する
		//BiConsumer<T, V>は関数型
		//"->"はラムダ記法
		BiConsumer<Integer, Integer> push = (v, d) -> { 
			if (! (shirube[v]==INF)) return; //ノードに訪問済みの時は、関数を終了する

			/* 訪問済みにする操作を記述 */
			shirube[v] = d;
			queue.add(v);
		};
		//初期ノードを訪問
		push.accept(0, 0);

		//キューが空になるまで、キューから取り出し頂点と接続した頂点を訪問
		//訪問済みの場合は、push関数側が何もせずに終了する
		while(!queue.isEmpty()) {
			int v = queue.poll(); //キューから頂点取り出す

			/* 隣接する頂点にに対してpush関数を適用する　*/
			for(int i : edge[v]) { //隣接する頂点は、Listに入れたものを使う
					push.accept(i, v+1);
			}

		}

		System.out.println("Yes");
		for(int i = 1; i < N; i++) {
			System.out.println(shirube[i]);
		}
		
	}
}


Measured memory_bytes: 77656
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define eps 1e-8
using namespace std;
const ll maxn = 1e6 + 5;
ll a,b,c,d,k,n,m,t,num[maxn];
string ans = "Yes";
double sum;
bool cmp(ll a,ll b)
{
    return a > b;
}
int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        cin >> num[i],sum += num[i];
    sum /= 4 * m;
    sort(num + 1, num + n + 1,cmp);
    for(int i = 1; i <= m; i++)
    {
        if(num[i] < sum)
        {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
	string s;
	cin >> s;
	int c = 0;

	for (int i = 0; i < s.size(); i++) {
		for (int j = i + 1; j < s.size(); j++) {
			if (s[i] == s[j])c++;
		}
	}

	if (c == 0) {
		cout << "yes" << endl;
	}
	else {
		cout << "no" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    int N = S.size();
    int l = 0, r = N - 1;
    int res = 0;
    while(r >= l) {
        if(S[l] == S[r]) {
            l++;
            r--;
            continue;
        }
        if(S[l] == 'x' && S[r] != 'x') {
            res++;
            l++;
            continue;
        }
        if(S[l] != 'x' && S[r] == 'x') {
            res++;
            r--;
            continue;
        }
        if(S[l] != S[r]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
 
  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
  else if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  }
  else if ((A + B) < (C + D)) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define p pair<int,int>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>V(n);
	for(int i=0;i<n;i++)
		cin>>V[i];
	int sum=0;
	for(int i=0;i<n;i++){
		int temp;
		cin>>temp;
		V[i]-=temp;
		if(V[i]>0){
			sum+=V[i];
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
/* ****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);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll a,b,c;
        cin>>a>>b>>c;
        cout<<c<<" "<<a<<" "<<b;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int Max(int a, int b, int c) {
	if (a >= b) { return std::max(a, c); }
	else return std::max(b, c);
}
int main(void) {
	ll n; cin >> n;
	if (n % 2 == 0)cout << n << endl;
	else cout << n * 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 1e9 + 7;



string S;

ll N, D, ans = 1;
ll A[200005];
ll B[200005];

int main() {

	cin >> N;

	FOR(i, 0, N) {
		cin >> A[i];
		B[i] = A[i];
	}
	sort(A, A + N);
	ll ma = A[N - 1];
	FOR(i, 0, N) {
		if (B[i] == ma)cout << A[N - 2]<<endl;
		else cout << A[N - 1] << endl;
	}


	return 0;
}


Measured memory_bytes: 4736
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d,e,f,g,h,X,V;
    cin>>a>>b>>c>>d;
    cin>>e>>f>>g>>h;
    cin>>X>>V;
    X=a+b+c+d;
    V=e+f+g+h;
    if(X<V){
        cout<<V<<endl;
    }
    else{
        cout<<X<<endl;
    }
}



Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a <=b && b <= c) {
			System.out.println(a + " " + b + " " + c);
		} else if(a <= c && c <= b) {
			System.out.println(a + " " + c + " " + b);
		} else if(b <= a && a <= c) {
			System.out.println(b + " " + a + " " + c);
		} else if(b <= c && c <= a) {
			System.out.println(b + " " + c + " " + a);
		} else if(c <= a && a <= b) {
			System.out.println(c + " " + a + " " + b);
		} else {
			System.out.println(c + " " + b + " " + a);
		}
	}
}


Measured memory_bytes: 26332