akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}
int main()
{
    int a,b,c,d; cin >> a >> b >> c >> d;
    cout << min(a,b)+min(c, d) << endl;


}



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

int main()
{
	int n;
	int ans = 0;
	std::string s;
	std::cin >> n;
	std::cin >> s;
	for (int i = 0; i < 1000; i++)
	{
		int c[3] = {i / 100, (i / 10) % 10, i % 10};
		int find = 0;
		for (int x = 0; x < n; x++)
		{
			if (s[x] == (c[find] + '0'))
				find++;
			if (find == 3)
				break;
		}
		if (find == 3)
			++ans;
	}
	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll INF = 1e18;

int main() {
    int n, m;
    cin >> n >> m;
    VVI e(n);
    REP(i,m){
        int u = in() - 1, v = in() - 1;
        e[u].push_back(v);
    }
    int s, t;
    cin >> s >> t;
    s--;
    t--;

    VL d(3 * n, INF);
    d[s] = 0;
    queue<ll> que;
    que.push(s);
    while (!que.empty()){
        int x = que.front();
        que.pop();
        int now = x % n;
        for (int next : e[now]){
            ll dd = d[x] + 1;
            int y = next + n * (dd % 3);
            if (d[y] != INF) continue;
            d[y] = dd;
            que.push(y);
        }
    }

    cout << (d[t] == INF ? -1 : d[t] / 3) << endl;

    return 0;
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
#define ll long long
 using namespace std;
 int main(){
 	ll n;
 	cin>>n;
 	ll a[n],b[n],sum1=0,sum2=0;
 	for(int i=0;i<n;i++)
 		cin>>a[i];
 	for(int i=0;i<n;i++)
 		cin>>b[i];
 	for(int i=0;i<n;i++){
 		if(a[i]>=b[i])
 			sum1+=a[i] - b[i];
 		else
 			sum2+=(b[i]-a[i])/2;
 	}
 	if(sum2>=sum1)
 		cout<<"Yes"<<"\n";
 	else
 		cout<<"No"<<"\n";
 	return 0;
 }

Measured memory_bytes: 384
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  for(var i = 1; i <= N - 1; i++){
    var output = new Array(N - i);
    for(var j = i + 1; j <= N; j++){
      for(var k = 0; k < 10; k++){
        if(((i ^ j) >> k) % 2 != 0){
          output[j - i - 1] = k + 1;
          break;
        }
      }
    }
    myout(myconv(output, 8));
  }
  
}


Measured memory_bytes: 34696
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> o_tree;

void solve()
{
   ll n;
   cin>>n;
   ll res=0;
   ll i;
   for(i=0;i<n;i++)
   {
       res+=(i+1)*(n-i);
   }
   for(i=1;i<n;i++)
   {
       ll x,y;
       cin>>x>>y;
       x--,y--;
       ll mini = min(x,y);
       ll maxi = max(x,y);
       res-=(mini+1)*(n-maxi);
   }
   cout<<res<<"\n";
}

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

    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    cout << setprecision(20);

    ll t = 1;

    // cin >> t;

    while (t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3660
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
#define EPS 1e-10
const double PI=acos(-1.0);
double add(double a, double b){
    if(abs(a+b)<EPS*(abs(a)+abs(b))) return 0;
    return a+b;
}
struct P{
    double x, y;
    P() {}
    P(double x, double y): x(x), y(y){
    }
    P operator+ (P p){
        return P(add(x, p.x), add(y, p.y));
    }
    P operator- (P p){
        return P(add(x, -p.x), add(y, -p.y));
    }
    P operator* (double d){
        return P(x*d, y*d);
    }
    double dot(P p){
        return add(x*p.x, y*p.y);
    }
    double det(P p){
        return add(x*p.y, -y*p.x);
    }
};
double dist(P p1, P p2){
  return sqrt((p1-p2).dot(p1-p2));
}
int n;
int x[55], y[55];
P p[55];
bool check(double r){
	for(int i=0; i<n; i++){
		for(int j=0; j<i; j++){
			double d=dist(p[i], p[j]);
			if(r<d/2) return false;
			P q1=p[i]-p[j];
			P q=P(q1.y, -q1.x);
			double t=sqrt(r*r-d*d/4);
			double a=sqrt(q.dot(q));
			q=q*(1.0/a*t);
			P m=(p[i]+p[j])*0.5;
			P c1=m+q, c2=m-q;
			bool ok=1;
			for(int k=0; k<n; k++){
				if(k==i || k==j) continue;
				if(dist(c1, p[k])>r){
					ok=0; break;
				}
			}
			if(ok) return true;
			ok=1;
			for(int k=0; k<n; k++){
				if(k==i || k==j) continue;
				if(dist(c2, p[k])>r){
					ok=0; break;
				}
			}
			if(ok) return true;
		}
	}
	return false;
}
int main()
{
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>x[i]>>y[i];
		p[i]=P(x[i], y[i]);
	}
	double l=0, r=1000;
	for(int loop=0; loop<50; loop++){
		double mid=(l+r)/2;
		if(check(mid)) r=mid;
		else l=mid;
	}
	printf("%.7lf\n", r);
	return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> edge[N];
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<int> dp(N);
    for(int i = 0;i < edge[0].size(); i++){
        dp[edge[0][i]]++;
    }
    for(int i = 0;i < edge[N-1].size(); i++){
        dp[edge[N-1][i]]++;
    }
    bool judge = false;
    for(int i = 1;i < N-1;i++){
        if(dp[i] >= 2) judge = true;
    }
    string ans = "";
    if(judge) ans = "POSSIBLE";
    else ans = "IMPOSSIBLE";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15776
N = int(input())
s = [int(input()) for i in range(N)]
s.sort()
ans = 0
manten = sum(s)
if manten%10 != 0:
    ans = manten
else:
    for i in range(N):
        if (manten - s[i])%10 != 0:
            ans = (manten - s[i])
            break
print(ans)

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

using namespace std;
vector<int> dp(50, -1);

int fib(int n) {
    if (0 <= dp[n])
        return dp[n];
    if (n == 0 || n == 1)
        return dp[n] = 1;
    return dp[n] = fib(n - 1) + fib(n - 2);
}

int main(void) {
    int n;
    scanf("%d", &n);

    cout << fib(n) << endl;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using P = pair<ll,ll>;
const ll INF = ll(1e18)+5;
ll H,W;

bool onBoard(ll y,ll x){
    if(y>=0 && y<H && x>=0 && x<W){
        return true;
    }else{
        return false;
    }
}

int main() {
    cin >> H >>W;
    ll d[H][W];
    for(int i=0;i<H;i++)for(int j=0;j<W;j++){
        d[i][j] = INF;
    }

    ll Cy,Cx,Dy,Dx;
    cin >> Cy >> Cx >> Dy >>Dx;
    --Cx;--Cy;--Dx;--Dy;
    vector<string> S(H);
    for(int i=0;i<H;i++){
        cin >> S[i];
    }
    priority_queue<P,vector<P>,greater<P>> pq;
    pq.push(P(0,Cy*W+Cx));
    d[Cy][Cx] == 0;

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


    while(!pq.empty()){
        P p = pq.top();
        pq.pop();
        ll y = p.second/W;
        ll x = p.second%W;
        // cerr <<"y=" << y <<"x=" << x << "val=" << p.first << endl;
        if(d[y][x] < p.first){
            continue;
        }
        for(int i=0;i<4;i++){
            ll ny = y + dy[i];
            ll nx = x + dx[i];
            if(onBoard(ny,nx) && S[ny][nx] == '.'){
                if(d[ny][nx] > p.first){
                    d[ny][nx] = p.first;
                    pq.push(P(p.first,ny*W+nx));
                }
            }
            for(int j=-2;j<3;j++)for(int k=-2;k<3;k++){
                ll ny = y + j;
                ll nx = x + k;
                if(onBoard(ny,nx) && S[ny][nx] == '.'){
                    if(d[ny][nx] > p.first+1){
                        d[ny][nx] = p.first+1;
                        pq.push(P(p.first+1,ny*W+nx));
                    }
                }

            }
        }
    }
    if(d[Dy][Dx] < INF){
        cout << d[Dy][Dx] << endl;
        return 0;
    }
    cout << -1 <<endl;
    return 0;
}

Measured memory_bytes: 13456
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        const long MOD = 1000000007;
        var sc = new Scanner();
        int k = sc.nextInt();
        int x = sc.nextInt();

        Console.SetOut(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        for (int i = x - (k - 1); i <= x + (k - 1); i++)
        {
            Console.Write(i + " ");
        }
        Console.Write("\n");
        Console.Out.Flush();
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <set>
#include <cctype>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <cstdio>
#include <iomanip> 
#include <cstring>
#include <iterator>
#include <limits>
#include <cmath>
#include <numeric>
#include <typeinfo>
 
using namespace std; 
	

int main() { 
    int m = 0, n = 0;
    cin >> m >> n;
    if(m == n)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2000000001)
n,ar,dp = 0,0,0

def solve(d,pi):
	global n,ar,dp
	if d>=n: return 0
	if dp[d][pi]:
		# print(f'final day=>({dp[d][pi]}),{d},prev = {pi}')
		return dp[d][pi]

	# print('day = ',d,';','prev job = ',pi,';')	##########################################
	# print('j=',[j for j in range(3) if not j is pi])	##############

	m = 0
	for j in range(3):
		if not j is pi:
			tmp = solve(d+1,j)
			# print('tmp=',ar[d][j], '+', tmp,'; d=',d,';pi=',pi)
			m = max(m,ar[d][pi] + tmp)
	# tmp = [ar[d][j] + solve(d+1,j) for j in range(3) if not j is pi]
	dp[d][pi] = m	#max(tmp)

	# print('m=',m)	##############################################
	# for i in range(n):print(dp[i])	##################################
	# print('-----')		##############################################

	return dp[d][pi]

def main():
	global n,ar,dp
	I = lambda:map(int,sys.stdin.readline().split())
	pr = lambda x:sys.stdout.write(f'{x}\n')
	n, = I()
	ar = [[*I()] for _ in range(n)]
	dp = [[0,0,0] for _ in range(n-1)]+[ar[-1]]
	pr(max(solve(0,0),solve(0,1),solve(0,2)))
	# pr('')
	# for i in range(n):print(dp[i])

main()

Measured memory_bytes: 193624
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define N 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))
ll s[200010];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll n;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> s[i];
    map<ll,ll>q;
    for(int i = 0; i < n; i++) q[s[i]]++;
    ll sum = 0;
    for(map<ll,ll>:: iterator it = q.begin(); it != q.end(); it++){
        if(it->second>1){
            ll x = it->second;
            sum += x*(x-1)/2;
        }
    }
    for(int i = 0; i < n; i++){
        if(q[s[i]]>1){
            cout << sum-q[s[i]]+1 << endl;
        }else{
            cout << sum << endl;
        }
    }

    return 0;
}






Measured memory_bytes: 12928
#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    lli t,sum=0,n;
    cin>>t;
    n=t;
    while(t!=0){
        sum+=(t%10);
        t/=10;
    }
    if((n%sum)==0){
        cout<<"Yes";
    }
    else
    cout<<"No";
	return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        long num = long.Parse(Reader.ReadLine());
        long[] ans = GetNum(num);
        Console.WriteLine(ans.Length);
        Console.WriteLine(string.Join(" ", ans));
    }

    private long[] GetNum(long target) {
        if(target == 0) {
            long[] tmp = new long[50];
            tmp = tmp.Select(a => (long)49).ToArray();
            tmp[0] = 0;
            return tmp;
        } else if(target % 50 == 0) {
            long num = target / 50;
            long[] tmp = GetNum(0);
            tmp = tmp.Select(a => a + num).ToArray();
            return tmp;
        } else {
            long[] tmp = GetNum(target - 1).Select(a=>a-1).OrderBy(a=>a).ToArray();
            tmp[0] += 51;
            return tmp;
        }
    }


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"

2

";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 13524
K,S=(int(x) for x in input().split())
if(3*K<S):
    print("0")
else:
    count=0
    for i in range(K+1):
        for j in range(K+1):
            if(S-i-j<K+1 and 0<=S-i-j):
                count+=1

    print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      (int)1e9+7
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;

int main(){
	int n;
	cin>>n;
	
	vi cnt((int)1e5+2,0);
	REP(i,n){
		int a;
		cin>>a;
		REP(j,3) cnt[a+j]++;
	}
	
	int ans=0;
	for(auto &elem:cnt) ans=max(ans,elem);
	
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  //入力
  int64_t N,M;
  cin>>N>>M;
  vector<int64_t> A(N);
  for(int i=0;i<N;++i){
    cin>>A.at(i);
  }

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

  //S.at(i)はA.at(i-1)までの和
  vector<int64_t> S(N+1);
  S.at(0)=0;
  for(int i=1;i<=N;++i){
    S.at(i)=S.at(i-1)+A.at(i-1);
  }

  //二分探索で#{(x,y)|A[x]+A[y]>=X}>=MなるXの最大値を求める
  int X;
  int left,right;
  //leftはいつでも条件を満たし、rightは満たさない
  left=2;
  right=2*100010;
  while(right-left>1){
    int mid=(right+left)/2;
    //sum=#{(x,y)|A[x]+A[y]>=mid}を計算する
    int64_t sum=0;
    for(int i=0;i<N;++i){
      sum += A.end()-lower_bound(A.begin(),A.end(),mid-A.at(i));
    }
    //sumが条件を満たすならleft、満たさないならrightにする
    if(sum>=M){
      left=mid;
    }
    else{
      right=mid;
    }

    //最後ならXを求める
    if(right-left==1){
    X=left;
    }
  }

  //求める答えはX*(M-#{(x,y)|A[x]+A[y]>=X+1})と{(x,y)|A[x]+A[y]>=X+1}を渡るΣ(A[x]+A[y])の和
  int64_t ans=0;
  int64_t count=0;
  for(int i=0;i<N;++i){
    int64_t index=A.end()-lower_bound(A.begin(),A.end(),(X+1)-A.at(i));
    ans += index*A.at(i)+(S.at(N)-S.at(N-index));
    count += index;
  }
  ans += X*(M-count);

  //出力
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <numeric>
#include <cstring>
#include <cmath>
#include <set>
#include <queue>
#include <stack>

const int MOD = 1e9 + 7;
const int iINF = 100000000;
const long long int llINF = 1 << 30;
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using edge = struct
{
    int to;
    int cost;
};

vector<edge> graph[1000000];
ll dist[1000000];


int V, E, start;

void dijkstra(int s)
{
    priority_queue<P, vector<P>, greater<P>> que;
    fill(dist, dist + V, llINF);
    dist[s] = 0;
    que.push(P(0, s));

    while(!que.empty())
    {
        P p = que.top(); que.pop();
        int v = p.second;
        if(dist[v] < p.first)   
            continue;
        for(auto e : graph[v])
        {
            if(dist[e.to] > dist[v] + e.cost)
            {
                dist[e.to] = dist[v] + e.cost;
                que.push(P(dist[e.to], e.to));
            }
        }
    }

}

int main()
{

    cin >> V >> E >> start;
    rep(i, E)
    {
        int a, t, d;
        cin >> a >> t >> d;
        graph[a].push_back({t, d});
    }

    dijkstra(start);

    rep(i, V)
    {
        if (dist[i] != llINF)
            cout << dist[i] << endl;
        else 
            cout << "INF" << endl;
    }
    return 0;
}


Measured memory_bytes: 34428
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    if N % 2 == 1:
        print(0)
    else:
        N //= 2
        count = 0
        while N > 1:
            N //= 5
            count += N
        print(count)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		D_DoubleLandscape solver = new D_DoubleLandscape();
		solver.solve(1, in, out);
		out.close();
	}

	static class D_DoubleLandscape {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			final int MOD = (int) (1e9 + 7);
			int n = in.nextInt();
			int m = in.nextInt();
			int[] a = new int[n];
			int[] cntA = new int[n * m];
			for (int i = 0; i < a.length; i++) {
				a[i] = in.nextInt() - 1;
				++cntA[a[i]];
			}
			int[] b = new int[m];
			int[] cntB = new int[n * m];
			for (int i = 0; i < b.length; i++) {
				b[i] = in.nextInt() - 1;
				++cntB[b[i]];
			}
			long ans = 1;
			int effN = 0;
			int effM = 0;
			for (int i = n * m - 1; i >= 0; i--) {
				if (cntA[i] > 1 || cntB[i] > 1) {
					ans = 0;
					break;
				}
				if (cntA[i] == 1 && cntB[i] == 1) {
					++effN;
					++effM;
					continue;
				}
				if (cntA[i] == 1 && cntB[i] == 0) {
					ans = ans * effM % MOD;
					++effN;
					continue;
				}
				if (cntA[i] == 0 && cntB[i] == 1) {
					ans = ans * effN % MOD;
					++effM;
					continue;
				}
				if (cntA[i] == 0 && cntB[i] == 0) {
					ans = ans * Math.max(0, (effN * effM - (n * m - i - 1))) % MOD;
					continue;
				}
				throw new AssertionError();
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 30292
#include <bits/stdc++.h>
using namespace std;
#define oo 666666666
#define ll long long
#define ld long double

ll DP[100005];
ll A[100005];

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    for(int i=1; i<=n; i++)
        cin>>A[i],DP[i]=1e9+1;

    DP[0]=1e9+1;
    DP[1]=0;
    for(int i=2; i<=n; i++)
        for(int j=1; j<=k && i-j>=1; j++)
        DP[i]=min(DP[i], DP[i-j]+abs(A[i]-A[i-j]));

    cout<<DP[n];
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

struct UnionFind {
	std::vector<int> data, color;
	
	UnionFind(int n) {
		data.assign(n, -1);
		color.assign(n, -1);
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if(color[x] != -1 and color[y] != -1 and color[x] != color[y]) return false;
		if(x == y) return true;
		if(data[x] > data[y]) std::swap(x, y);
		data[x] += data[y];
		data[y] = x;
		color[x] = (color[y] == -1 ? color[x] : color[y]);
		return true;
	}	
	int find(int k) {
		if(data[k] < 0) return k;
		if(color[k] != -1) {
			if(color[data[k]] != -1 and color[data[k]] != color[k]) return false;
			color[data[k]] = color[k];
		}
		return data[k] = find(data[k]);
	}
	bool setColor(int k, int c) {
		int root = find(k);
		if(color[root] != -1 and color[root] != c) return false;
		color[root] = c;
		return true;
	}
};

int main() {
	int n, m, k; scanf("%d%d%d", &n, &m, &k);
	UnionFind uf(n);
	for(int i = 1; i <= k; i++) {
		int type; scanf("%d", &type);
		int x, y; scanf("%d%d", &x, &y);
		
		if(type == 1) {
			if(!uf.unite(x - 1, y - 1)) {
				printf("%d\n", i);
				return 0;
			}
		} else {
			if(!uf.setColor(x - 1, y - 1)) {
				printf("%d\n", i);
				return 0;
			}
		}
		
	}
	printf("0\n");
	return 0;
}



Measured memory_bytes: 3616
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    if ((A-B) % 2 != 0) {
      System.out.println("IMPOSSIBLE");
      return;
    }
    if (A > B) {
      System.out.println(B + (A-B)/2);
    } else {
      System.out.println(A + (B-A)/2);
    }
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  if (N % 2 == 0){
    vector<vector<long long>> dp(N / 2 + 1, vector<long long>(2, 0));
    //0: left 1: right
    for (int i = 0; i < N / 2; i++){
      dp[i + 1][0] = dp[i][0] + A[i * 2];
      dp[i + 1][1] = max(dp[i][0], dp[i][1]) + A[i * 2 + 1];
    }
    cout << max(dp[N / 2][0], dp[N / 2][1]);
  } else {
    vector<vector<long long>> dp(N / 2 + 1, vector<long long>(3, 0));
    for (int i = 0; i < N / 2; i++){
      dp[i + 1][0] = dp[i][0] + A[i * 2];
      dp[i + 1][1] = max(dp[i][0], dp[i][1]) + A[i * 2 + 1];
      dp[i + 1][2] = max({dp[i][0], dp[i][1], dp[i][2]}) + A[i * 2 + 2];
    }
    cout << max({dp[N / 2][0], dp[N / 2][1], dp[N / 2][2]});
  }
}

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

#define x first
#define y second
#define mkp make_pair
#define pb push_back
typedef pair<int, int> pii;
const int MAXN = 510;
int n, m;
char s[MAXN][MAXN], A[MAXN][MAXN], B[MAXN][MAXN];

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

	for(int i = 1; i <= n; i++) scanf("%s", s[i]+1);
	
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			if(j == 1) {
				A[i][j] = '#';
				B[i][j] = '.';
			}
			else if(j == m) {
				A[i][j] = '.';
				B[i][j] = '#';
			}
			else {
				if(i & 1) {
					A[i][j] = '#';
					B[i][j] = '.';
				}
				else {
					A[i][j] = '.';
					B[i][j] = '#';
				}
			}
		}
	}

	for(int i = 1; i <= n; i++) 
		for(int j = 1; j <= m; j++) 
			if(s[i][j] == '#') {
				if(A[i][j] == '.') A[i][j] = '#';
				else B[i][j] = '#';
			}
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++)putchar(A[i][j]);
		printf("\n");
	}
	printf("\n");
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++)putchar(B[i][j]);
		printf("\n");
	}
	return 0;
}


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

int main(){
  string S;
  cin >> S;
  if(S== "RRR"){
    cout << 3 << endl;
  }
  else if(S== "SRR"||S== "RRS"){
    cout << 2<< endl;
  }
  else if(S== "SSS"){
    cout << 0<< endl;
  }
  else {
    cout << 1<< endl;
  }


}

Measured memory_bytes: 3632
import Control.Monad
import qualified Data.Map as Map
import Data.List

f2::Int->[Int]->Map.Map Int [Int]->Map.Map Int [Int]
f2 _ [] ms=ms
f2 n (e:es) ms=f2 n es (Map.insertWith (++) e [n] ms)

f::Int->[[Int]]->Map.Map Int [Int]->Map.Map Int [Int]
f _ [] ms=ms
f n (e:es) ms=f (n+1) es (f2 n e ms)

g2::Int->[Int]->[Int]->[Int]
g2 _ _ [] =[]
g2 no [] (x:xs)=x:g2 (no+1) [] xs 
g2 no (t:ts) (x:xs)
          |no==t=(x+1):(g2 (no+1) ts xs)
          |otherwise=x:(g2 (no+1) (t:ts) xs)

g::[[Int]]->[Int]->[Int]->Int
g [] xs ans=foldl1 (*) $ [if (mod x 2)==(mod y 2) then 1::Int else 0::Int|(x,y)<-(zip xs ans)]
g (e:es) xs ans=(g es xs ans)+(g es (g2 1 e xs) ans)


main = do
       t1<-getLine
       let n:m:[]=map read (words t1)::[Int]
       ts<-replicateM m getLine
       ks<-getLine
       let ts2=map tail $ map (map read . words) ts::[[Int]]
           ks2=map read (words ks)::[Int]
           ts3=map sort $ Map.elems $ f 1 ts2 (Map.fromList [])
       print $ (2^(n-(length ts3))) * ( g ts3 [0|e<-[1..m]] ks2)

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

int main(){
  int an, bn, t, ai, bi;  cin >> an >> bn >> t;
  vector<long> a(an+1, 0), b(bn+1, 0);
  for(int i=1; i<=an; i++){
    cin >> ai;
    a[i] = a[i-1] + ai;
  }
  for(int j=1; j<=bn; j++){
    cin >> bi;
    b[j] = b[j-1] + bi;
  }

  long ans = 0, nowt = 0;  ai = 1, bi = bn;
  for(int i=0; i<=an; i++){
    nowt = a[i];
    if(nowt > t)  continue;
    long count = i;
    while(bi >= 0 && nowt + b[bi] > t)  bi--;
    if(nowt + b[bi] > t)  break;
    ans = max(ans, count + bi);
  }

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


Measured memory_bytes: 6416
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		/*
		 ** Constraint* *
		    1 ≤ x ≤ 10000
		 	The number of datasets ≤ 10000
		 */
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String streamLine;
		for (int i = 1;  ; i++) {
			streamLine = br.readLine();
			if ( streamLine.equals("0")) break;
			System.out.println("Case " + i + ": " + streamLine);
		} 
	}
}


Measured memory_bytes: 31444
#include <iostream>
#include <vector>

using namespace std;

typedef long long int ll;

int main()
{
  int n, W;

  cin >> n >> W;

  vector <int> w(n+1, 0);
  vector <int> v(n+1, 0);

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

  ll dp[W+1][n+1];

  for (int i = 0; i <= W; i++)
  {
    for (int j = 0; j <= n; j++)
    {
      dp[i][j] = 0;
    }
  }

  for (int i = 0; i <= W; i++)
  {
    for (int j = 1; j <= n; j++)
    {
      if (w[j] <= i)
        dp[i][j] = max(dp[i][j], dp[i-w[j]][j-1] + v[j]);
      
      dp[i][j] = max(dp[i][j], dp[i][j-1]);
    }
  }

  cout << dp[W][n] << "\n";

  return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <math.h>
#include <string>

using namespace std;
int main()
{
    int k,a,b,sum;
    cin>>k>>a>>b;
    sum = (b / k)* k;
    if(a <= sum){
        cout<<"OK";
    }
    else{
        cout<<"NG";
    }
    return 0;
}


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

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(b-a)<=d&&abs(c-b)<=d||abs(a-c)<=d)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int D;
int c[26];
ll s[365][26];

int last[26];

set<int> st[26];
vector<int> ret;
vector<int> ans;

ll sum = 0, MAX;

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

    srand((unsigned)time(NULL));

    rep(i, 26) st[i].insert(-1);

    cin >> D;
    rep(i, 26) cin >> c[i];
    rep(i, D) rep(j, 26) cin >> s[i][j];

    rep(d, D) {
        ll a = -1, mx = -1;
        rep(i, 26) if(chmax(mx, (d - *st[i].rbegin()) * c[i] + s[d][i])) a = i;
        ans.push_back(a);
        st[a].insert(d);
        sum += s[d][a];
        rep(i, 26) sum -= c[i] * (d - *st[i].rbegin());
    }

    MAX = sum;
    ret = ans;

    rep(i, 26) st[i].insert(D);

    while(clock() < CLOCKS_PER_SEC * 1.9) {
        int x = rand() % D;
        ll a = -1, mx = -inf;
        rep(i, 26) if(i != ans[x]) {
            auto it1 = st[i].upper_bound(x);
            auto it2 = st[i].lower_bound(x);
            it2--;
            ll y = s[x][i] + (*it1 - *it2) * (*it1 - *it2 - 1) / 2 * c[i];
            y -= (*it1 - x) * (*it1 - x - 1) / 2 * c[i];
            y -= (x - *it2) * (x - *it2 - 1) / 2 * c[i];
            if(chmax(mx, y)) a = i;
        }
        auto it1 = st[ans[x]].upper_bound(x);
        auto it2 = st[ans[x]].lower_bound(x);
        it2--;
        ll y = s[x][ans[x]] + (*it1 - *it2) * (*it1 - *it2 - 1) / 2 * c[ans[x]];
        y -= (*it1 - x) * (*it1 - x - 1) / 2 * c[ans[x]];
        y -= (x - *it2) * (x - *it2 - 1) / 2 * c[ans[x]];
        if(mx >= y) {
            sum += mx - y;
            st[a].insert(x);
            st[ans[x]].erase(x);
            ans[x] = a;
            if(chmax(MAX, sum)) ret = ans;
        } else if(rand() % 1000 == 0) {
            sum += mx - y;
            st[a].insert(x);
            st[ans[x]].erase(x);
            ans[x] = a;
        }
    }

    rep(i, D) cout << ret[i] + 1 << endl;

    return 0;

    cout << endl;

    sum = 0;
    rep(d, D) {
        int x = ret[d];
        last[x] = d + 1;
        sum += s[d][x];
        rep(i, 26) sum -= (d + 1 - last[i]) * (c[i]);
        cout << sum << "\n";
    }

    return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s[7]={"SUN", "MON", "TUE", "WED", "THU", "FRI","SAT" };
string ss;
cin >> ss;
for(int i = 0 ; i < 7 ; i++){
    if (ss==s[i] ){cout << (7-i ) <<endl; }
}

    return 0;
}


Measured memory_bytes: 256
n = int(input())

c = [0,0,0,0]

for i in range(n):
    s = str(input())

    if s == "AC":
        c[0] += 1
    elif s == "WA":
        c[1] += 1
    elif s == "TLE":
        c[2] += 1
    elif s == "RE":
        c[3] += 1

print("AC x " + str(c[0]))
print("WA x " + str(c[1]))
print("TLE x " + str(c[2]))
print("RE x " + str(c[3]))

Measured memory_bytes: 9196
def main():
    import sys
    input=sys.stdin.readline
    n=int(input())
    A=[list(map(int,input().split())) for i in range(n)]
    mod=10**9+7

    dp=[0]*(1<<n)
    dp[0]=1
    for s in range(1<<n):
        i=format(s,'b').count('1')
        for j in range(n):
            if (s>>j)&1 and A[i-1][j]==1:
              dp[s]+=dp[s^(1<<j)]
              dp[s]%=mod   
              
    print(dp[-1])
if __name__=='__main__':
    main()

Measured memory_bytes: 58972
#include<bits/stdc++.h>
using namespace std;
main()
{
    long long h,w;
    while(scanf("%lld %lld",&h,&w)==2){
        if(h==1||w==1) cout<<1;
        else if((h*w)%2==0) cout<<(h*w)/2;
        else cout<<(h*w)/2+1;
    }
}


Measured memory_bytes: 256
import math
N, K = map(int, input().split())
total = 0.0

for n in range(1,N+1) :
    if n >= K :
        total += 1.0 / N
    else :
        total += (1.0 / N) * 0.5 ** math.ceil(math.log2(1.0 * K / n))
print(total)


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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);


int main(){
  faster();
  char c;
  cin >> c;
  c++;
  cout << c ;
}



























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define db double
#define dbg(x) cout<<#x<<"="<<x<<"\n"
int n,m; 
int main()
{
	scanf("%d%d",&n,&m);
	if(n>m) swap(n,m);
	if(n==1&&m==1) return !puts("1");
	if(n==1) return !printf("%d\n",m-2);
	else printf("%lld\n",1ll*(n-2)*(m-2));
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::LinkedList;

fn main() {
    input! {
        n: usize,
        a: [u64; n],
    };
    let mut vals = a;
    vals.sort();
    // println!("{:?}", vals);

    let mut ans = 0;
    let mut list: LinkedList<u64> = LinkedList::new();
    // ２つ目までは必ず存在する&特殊な動き方をする
    ans += vals.pop().expect("n always bigger than 2; i = 1"); // １つ目の要素は必ずたしていい
    let next_num = vals.pop().expect("n always bigger than 2; i = 2"); // ２つ目の要素は直ちに足すことはない
    list.push_back(next_num);
    list.push_back(next_num);
    // println!("{:?} => {:?}: {}", vals, list, ans);
    while let Some(val) = vals.pop() {
        list.push_back(val);
        list.push_back(val);
        ans += list.pop_front().expect("");
        // println!("{:?} => {:?}: {}", vals, list, ans);
    }
    println!("{}", ans);
}


Measured memory_bytes: 9764
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func sum(a []int) int {
	ret := 0
	for _, v := range a {
		ret += v
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	n, x := nextInt(), nextInt()
	m := make([]int, n)
	min := 1001
	for i := range m {
		m[i] = nextInt()
		if m[i] < min {
			min = m[i]
		}
	}

	ans := n + (x-sum(m))/min
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define eps 1e-9
#define PI 2 * acos (0.0)
using namespace std;

const int mod = 1000000000 + 7;

char ch[10][10];
bool bi[10][10];


int main()
{
  
    int a,b,c,d,e,x,y,z,n,m;

    scanf("%d %d", &n, &m);

    for(a=0; a<n; a++) scanf("%s", ch[a]);

    x = 0;
    y = 0;

    while(1)
    {
        bi[x][y]=true;
        //cout<<"now at "<<x<<","<<y<<endl;
        if(y+1>=m)
        {
            if(x+1>=n) break;
            if(ch[x+1][y]!='#') break;
            x++;
            continue;
        }
        if(ch[x][y+1]!='#')
        {
            if(x+1>=n) break;
            if(ch[x+1][y]!='#') break;
            x++;
            continue;
        }
        y++;
    }
    c=0;
    for(a=0;a<n;a++)
    {
        for(b=0;b<m;b++)
        {
            if(ch[a][b]=='#' && bi[a][b]==false) c++;
        }
    }

    if(!c) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
            var H = array[0];
            var N = array[1];

            var attack = Console.ReadLine().Split().Select(decimal.Parse).Sum();

            if (H <= attack)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 18272
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <functional>
#include "math.h"
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#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 inf INT_MAX/3
#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

VI A;
int N;

int main(){

	cin >> N;
	A.resize(N);
	long long ans=0;
	long long sum = 0;
	REP(i,N){
		cin >> A[i];
		if(A[i]==0){
			ans += sum/2;
			sum = 0;
		} else {
			sum+=A[i];
		}

	}
	ans += sum/2;
	cout << ans;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

/**
 * 先行は高橋くん
 *
 */
int main() {
  short takahashiRestPhysical, takahashiAttack, aokiRestPhysical, aokiAttack;
  char output[5];

  scanf("%hd %hd %hd %hd", &takahashiRestPhysical, &takahashiAttack, &aokiRestPhysical, &aokiAttack);

  // どっちかの体力が0以下になったら終わり（両方とも体力が1以上残っていたら継続）
  while (takahashiRestPhysical > 0 && aokiRestPhysical > 0) {
    // 高橋くんの攻撃
    aokiRestPhysical = aokiRestPhysical - takahashiAttack;
    // 高橋くんの勝ちパターン
    if (aokiRestPhysical <= 0) {
      strcpy(output, "Yes\n");
      break;
    }
    // 青木くんの攻撃
    takahashiRestPhysical = takahashiRestPhysical - aokiAttack;
    // 青木くんの勝ちパターン
    if (takahashiRestPhysical <= 0) {
      strcpy(output, "No\n");
      break;
    }
  }

  printf("%s", output);

  return 0;
}


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

int main(){
	long long int n,i,price = 100000;
	cin >> n;
	for(i=0;i<n;i++){
		price = price * 1.05;
		if(price % 1000 != 0){
			price -= price%1000;
			price += 1000;
		}
	}
	cout << price << endl;
	return 0;
}

Measured memory_bytes: 0
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }



int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	k = 2 * k + 1;
	cout << n / k + bool(n % k) << '\n';
	return 0;
}


Measured memory_bytes: 256
H,W,A,B = map(int, input().split())

mod = 10**9+7
fact = [1]
for i in range(1, H+W+1):
    fact.append ( fact[-1] * i % mod)

inv_fact = [0] * (H+W+1)
inv_fact[H+W] = pow(fact[H+W], mod-2, mod)

for i in range(H+W, 1, -1):
    inv_fact[i-1] = inv_fact[i] * i % mod

inv_fact[0] = 1

def C(a,b):
    if a <= 0 or b < 0:
        return 0
    if a==0 or b == 0:
        return 1
    return fact[a] * inv_fact[b] * inv_fact[a-b] % mod

ans = 0
for w in range(B+1, W+1):
    h = H-A - (w-B-1)
    if w == 0 or h == 0:
        break
    ans = (ans + C(h+w-2, w-1) * C(H+W-h-w, W-w) % mod) % mod
print(ans)

Measured memory_bytes: 18860