akhauriyash/Code-Regression huggingface dataset:
import math
from fractions import Fraction

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

n,k=input2()
ans=0
for i in range(1,n+1):
	point=i
	if point>=k:
		ans+=Fraction(n-point+1,n)
		break
	else:
		tmp=math.ceil(math.log2((k/point)))
		ans+=Fraction(1,n)*Fraction(1,2**tmp)
print(float(ans))

Measured memory_bytes: 10576
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes(){
  cout << "YES" << endl;
  exit(0);
}

void no(){
  cout << "NO" << endl;
  exit(0);
}

int main(){
  vector<char> s(4);
  REP(i,4) cin >> s[i];
  sort(ALL(s));
  string t = "1479";
  REP(i,4){
    if(s[i]!=t[i]) no();
  }
  yes();
}

Measured memory_bytes: 256
/*
    なせば大抵なんとかなる！
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int>
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a>=c ; a--)
#define UPC(oo) (oo>='A' && oo<='Z')
#define LWC(oo) (oo>='a' && oo<='z')

inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void sctlld(LL &a,LL &b,LL &c){scanf("%I64d %I64d %I64d",&a,&b,&c);}
inline void scdlld(LL &a,LL &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(LL &a){scanf("%I64d",&a);}

inline void prd(int a){printf("%d",a);};
inline void prdd(int a,int b){printf("%d %d",a,b);};
inline void prtd(int a, int b, int c){printf("%d %d %d",a,b,c);};
inline void prtlld(LL a, LL b, LL c){printf("%I64d %I64d %I64d",a,b,c);};
inline void prdlld(LL a, LL b){printf("%I64d %I64d",a,b);};
inline void prtlld(LL a){printf("%I64d",a);};

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	char a[200000],b[200000],c[200000];
	scanf("%s %s %s",a,b,c);
	if(LWC(a[0]))
	a[0]-=32;
	
	if(LWC(b[0]))
	b[0]-=32;
	
	if(LWC(c[0]))
	c[0]-=32;
	
	printf("%c%c%c\n",a[0],b[0],c[0]);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

int main(void){
    int nums[3];
    cin >> nums[0] >> nums[1] >> nums[2];
    std::sort(nums,3 + nums);
    
    cout << nums[0] << " " << nums[1] << " " << nums[2] << endl;
    return 0;
}



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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

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

    return gcd(b, a%b);
}

const ll L = 1e5+5;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll n;
    cin >> n;

    vector <ll> d;

    for(ll i=0; i<n; i++)
    {
        ll t;
        cin >> t;

        d.pb(t);
    }    

    sort(all(d));

    cout << d[n/2] - d[(n/2)-1] << endl;


    return 0;
}

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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  bool v[6][6];
  rep (i, h) {
    rep (j, w) {
      char c;
      cin >> c;
      v[i][j] = c == '#';
    }
  }
  int ans = 0;
  rep (i, 1<<h) {
    rep (j, 1<<w) {
      int cnt = 0;
      rep(l, h) {
        if ((i>>l) & 1) continue;
        rep (m, w) {
          if ((j>>m) & 1) continue;
          if (v[l][m]) cnt++;
        }
      }
      if (cnt == k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <cstdlib>
#include <iostream>

using namespace std;

void insertion_sort(int arr[], int length);
void print_array(int array[],int size);

int main() {
    
    
    int l=0,i=0;
    cin>>l;
    int array[l];
    while(cin>>array[i] && i < l-1)
    {
        
        cout<<array[i]<<" ";
        i++;
    }
    cout<<array[l-1];
    
    cout<<endl;
    insertion_sort(array,l);
    
    return 0;
}

void insertion_sort(int arr[], int length) {
    int i, j ,tmp;
    for (i = 1; i < length; i++) {
        j = i;
        while (j > 0 && arr[j - 1] > arr[j]) {
            tmp = arr[j];
            arr[j] = arr[j - 1];
            arr[j - 1] = tmp;
            j--;
        }
        print_array(arr,length);
    }
}

void print_array(int array[], int size){
    int j;
    for (j=0; j<size;j++)
        for (j=0; j<size;j++)
            if(j==size-1)
                cout <<array[j];
            else
            cout <<array[j]<<" ";
            
    
    cout << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
    int h, w, d;
    cin >> h >> w >> d;
    vector <string> s(h);
    rep (i, h) cin >> s[i];

    int ans = 0;

    rep (i, h) {
        int renzoku = 0;
        rep (j, w) {
            if (s[i][j] == '#') {
                if (renzoku > 0) ans += max(0, renzoku - d + 1), renzoku = 0;
            }
            else renzoku++;
        }
        if (renzoku > 0) ans += max(0, renzoku - d + 1);
    }

    rep (i, w) {
        int renzoku = 0;
        rep (j, h) {
            if (s[j][i] == '#') {
                if (renzoku > 0) ans += max(0, renzoku - d + 1), renzoku = 0;
            }
            else renzoku++;
        }
        if (renzoku > 0) ans += max(0, renzoku - d + 1);
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
    int K, N, ans = 0;
    std::cin >> N >> K;
    std::vector<int> p(N);
    for(int i = 0; i < N; i++) {
        std::cin >> p.at(i);
    }

    std::sort(p.begin(), p.end());

    for(int i = 0; i < K; i++) {
        ans += p.at(i);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3616
N = int(input())
W = []
for _ in range(N):
    W.append(input())

if len(W) != len(set(W)):
    print('No')
    quit()

for i in range(len(W)-1):
    if W[i][-1] != W[i+1][0]:
        print('No')
        quit()
print('Yes')


Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
#include <deque>
#include <queue>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[])
{
	int i, n, j, k;
	cin >> n;
	vector<int> length(n);
	int a, b;
	ll answer = 0;
	for (i = 0; i < n; i++)
		cin >> length[i];
	sort(length.begin(), length.end());

	for (i = 0; i < n - 2; i++) {
		a = length[i];
		for (j = i + 1; j < n - 1; j++) {
			b = length[j];
			for (k = j + 1; k < n; k++) {
				if (length[k] < a + b) {
					answer++;
				} else
					break;
			}
		}
	}
				
	cout << answer << endl;	

	return 0;
}


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

/*変数の宣言*/
string saffix;
int N;

int main(){
	std::cin >> N;
	N = N%10;
	if(N == 3){
		saffix = "bon";
	}else if(N == 0||N == 1||N == 6||N == 8){
		saffix = "pon";
	}else{
		saffix = "hon";
	}
	
	std::cout << saffix;
}


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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 200010, M = 110;

LL h, t = 1;
LL res;

int main()
{
	cin >> h;
	while (h)
	{
		h /= 2;
		res += t;
		t *= 2;
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
info=[]
for i in range(m):
    info.append(list(map(int,input().split())))
    info[i].append(i)
info2=sorted(info,key=lambda x:x[1])
info3=sorted(info2)
#print(info3)

num=info3[0][0] #県の番号
city=0 #県numにある市の数

for i in range(m):
    number=""
    if info3[i][0]==num:
        city+=1
        l1=6-len(str(num)) #上６桁のうち、０の数
        l2=6-len(str(city)) #下６桁のうち、０の数
        number+=str(0)*l1+str(num)+str(0)*l2+str(city)
        info3[i].append(number)
    else: #県が変わる場合
        num=info3[i][0]
        city=1
        l1=6-len(str(num)) #上６桁のうち、０の数
        l2=6-len(str(city)) #下６桁のうち、０の数
        number+=str(0)*l1+str(num)+str(0)*l2+str(city)
        info3[i].append(number)

info4=sorted(info3,key=lambda x:x[2])
for i in range(m):
    print(info4[i][3])

Measured memory_bytes: 40824
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N, K;
    cin >> N >> K;
    vec<vec<int>> bk(4 * K, vec<int>(4 * K));
    rep(i, N) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'B') x += K;
        ++bk[x % (2 * K)][y % (2 * K)];
    }
    rep(i,4*K)rep(j,4*K){
        bk[i][j] = bk[i%(2*K)][j%(2*K)];
    }

    rep(i, 4 * K-1) rep(j, 4 * K) {
        bk[i + 1][j] += bk[i][j];
    }
    rep(i, 4 * K) rep(j, 4 * K-1) {
        bk[i][j+1] += bk[i][j];
    }


    int ans = 0;
    rep(i,2*K)rep(j,2*K){
        int tmp = 0;
        tmp+=bk[i+K-1][j+K-1];
        if(i>0) tmp-=bk[i-1][j+K-1];
        if(j>0) tmp-=bk[i+K-1][j-1];
        if(i>0&&j>0) tmp+=bk[i-1][j-1];

        tmp+=bk[i+2*K-1][j+2*K-1];
        tmp-=bk[i+K-1][j+2*K-1];
        tmp-=bk[i+2*K-1][j+K-1];
        tmp+=bk[i+K-1][j+K-1];

        ans = max(ans,tmp);
    }
    cout << ans << endl;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto x : v) cerr << x << ' '; cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const int N = 1e5 + 5;
ll n, m;
int a[N];
ll ps[N];

bool good(int mid) {
	ll r = 0;
	for (int i = n-1; i >= 0; i--) {
		int x = mid - a[i];
		int y = lower_bound(a, a+n, x) - a;
		int z = i - y;
		if (z < 0) break;
		r += 2 * z + 1;
		if (r >= m) return true;
	}
	return false;
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	scanf("%lld%lld", &n, &m);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(a, a+n);
	for (int i = 1; i <= n; i++) ps[i] = ps[i-1] + a[i-1];

	int low = a[0] + a[0], high = a[n-1] + a[n-1] + 1;
	while (low + 1 < high) {
		int mid = (low + high) / 2;
		if (good(mid))
			low = mid;
		else
			high = mid;
	}
	//printf("low = %d\n", low);

	ll ans = 0;
	for (int i = n-1; i >= 0; i--) {
		int x = low - a[i];
		int y = upper_bound(a, a+n, x) - a;
		int z = i - y;
		if (z < 0) break;
		ans += 2 * ((ll)z * a[i] + (ps[i] - ps[y])) + 2 * a[i];
		m -= 2 * z + 1;
		if (m == 0) break;
		assert(m > 0);
	}
	ans += (ll)low * m;
	printf("%lld\n", ans);
}


Measured memory_bytes: 1408
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
int n;
int main()
{
	n=read();
	ll sum=0,len=0;
	for(int i=1;i<=n;i++){
		ll d=read(),c=read();
		sum+=d*c; len+=c;
	}
	writeln((sum-1)/9+len-1);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int ans=0;
	for(int i=0;i<4;i++)
		cin >> s[i];
	for(int i=0;i<4;i++)
	{
		for(int j=0;j<4;j++)
			if(s[i]==s[j])
				ans++;
		if(ans != 2)
		{	puts("No");
			return 0;} 
		ans=0; 
	} 
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, w;
    cin>>n>>w;
    int arr[n][2];
    int val = 0;
    for(int i = 0; i < n; i++) {
        cin>>arr[i][0]>>arr[i][1];
        val += arr[i][1];
    }
    long long int dp[2][val + 1];

    dp[0][0] = 0;
    
    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= val; j++) {
            if(i != 0 || j != 0) dp[i%2][j] = 1e18;
            if(i > 0) dp[i%2][j] = dp[(i - 1)%2][j];
            if(i > 0 && j >= arr[i][1]) {
                dp[i%2][j] = min(dp[i%2][j], dp[(i - 1)%2][j - arr[i][1]] + arr[i][0]);
            } else if ( i == 0 && j == arr[i][1]) {
                dp[i%2][j] = arr[i][0];
            }
        }
    }
    
    int ans = 0;
    for(int i = val; i >= 0; i--) {
        if(dp[(n - 1)%2][i] <= w) {
            ans = i;
            break;
        }
    }
    
    cout<<ans<<"\n";
    
    return 0;
}


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

int main() {
   ll N, A, B;
   cin >> N >> A >> B;
    if ((A-B)%2 == 0)
    {
        cout <<abs( (A-B)/2) << endl;
    }
    else
    {
        ll one = min(A, B) - 1;
        ll hasamu = abs((A-B-1)/2);
        
        ll n = N - max(A, B);
        
        ll ans = min(one, n);
        cout << ans + hasamu << endl;
    }
    

    
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	char t[10];
	while(scanf("%s",t)!=EOF){
		bool o[10],x[10];
		int i;
		for(i=0;i<9;++i){
			o[i]=(t[i]=='o')?true:false;
			x[i]=(t[i]=='x')?true:false;
		}
		int ans = 2;
		for(i=0;i<3;++i){
			if(o[i*3]&&o[i*3+1]&&o[i*3+2]||o[i]&&o[3*1+i]&&o[3*2+i]) ans=0;
			if(x[i*3]&&x[i*3+1]&&x[i*3+2]||x[i]&&x[3*1+i]&&x[3*2+i]) ans=1;
		}
		if(o[0]&&o[4]&&o[8]||o[2]&&o[4]&&o[6]) ans=0;
		if(x[0]&&x[4]&&x[8]||x[2]&&x[4]&&x[6]) ans=1;
		printf("%c\n",((ans<2)?((ans)?'x':'o'):'d'));
	}
	return 0;
}

Measured memory_bytes: 968
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// ll dp[]

int main(){
  ll r;

  if(scanf("%lld", &r) != 1) return 0;

  printf("%f", 2.0*PI*(float)r);

  return 0;
}

Measured memory_bytes: 1748
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;
using vd = vector<double>;

int H, W;
vector<int> moveh = {1, 0, -1, 0};
vector<int> movew = {0, 1, 0, -1};
v3 bord(0, vector<char>(0));
v2 group(0, vector<int>(0));
ll check(int h, int w, int gr){
	ll black = 0;
	ll white = 0;
	stack<pair<int, int>> S;
	S.push(make_pair(h, w));
	while(!S.empty()){
		h = S.top().first;
		w = S.top().second;
		S.pop();
		bool color;
		if(bord[h][w] == '#') color = true;
		else if(bord[h][w] == '.') color = false;
		else continue;
		bord[h][w] = '+';
		group[h][w] = gr;
		if(color) black++;
		if(!color) white++;
		rep(i, 4){
			int nh = h + moveh[i];
			int nw = w + movew[i];
			if(nh < 0 || nw < 0 || nh >= H || nw >= W) continue;
			if(bord[nh][nw] == '+') continue;
			if(color){
				if(bord[nh][nw] == '.'){
					S.push(make_pair(nh, nw));
				}
			}else{
				if(bord[nh][nw] == '#') S.push(make_pair(nh, nw));
			}
		}
	}
	return black*white;
}


int main(){
	cin >> H >> W;
	rep(i, H){
		vector<char> a(W);
		vector<int> b(W, 0);
		rep(j, W){
			char c;
			cin >> c;
			a[j] = c;
		}
		bord.push_back(a);
		group.push_back(b);
	}
	ll ans = 0;
	int gr = 0;
	rep(i, H){
		rep(j, W){
			gr++;
			bool color;
			ans += check(i, j, gr);
		}
	}
	cout << ans << endl;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N);
    for (int i=0;i<N;++i) cin >> A[i],--A[i];
    vector<ll> cnt(N,0);
    for (int i=0;i<N;++i) ++cnt[A[i]];
    ll sum=0;
    for (int i=0;i<N;++i) sum+=cnt[i]*(cnt[i]-1)/2;
    for (int i=0;i<N;++i){
        cout << sum-cnt[A[i]]+1 << '\n';
    }
}

Measured memory_bytes: 4992
#include<iostream>
#include<set>
#include<string.h>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n; 
signed main(){
    scanf("%d", &n);
    printf("%d\n", n & 1 ? n << 1 : n);
}

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

int main(){
	
	int i;
	char s[1000];
	
    while(scanf("%s",s)!=EOF){
        for(i=0;i<strlen(s);i++){
            if(s[i]=='@'){
                while(s[i+1]!='0'){
                    printf("%c",s[i+2]);
                    s[i+1]--;
                }
                i=i+2;
            }
			else	printf("%c",s[i]);
        }
        printf("\n");
    }
     
    return 0;
}

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

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

int N;

int main()
{
	vector<int> src,dup;
	int num,i;

	cin>>N;

	while(N-- > 0)
	{
		cin>>num;
		src.push_back(num);
		dup.push_back(num);
	}

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

	rep(i,src.size()){
		if(src[i] == dup[src.size() - 1]){
			cout << dup[src.size() - 2];
		}else cout << dup[src.size() - 1];
		
		cout << '\n';
	}

	return 0;
}

Measured memory_bytes: 3436
INF = 1001001001

N, M = map(int, input().split())
key = []
for i in range(M):
    a, b = map(int, input().split())
    s = 0
    c = list(map(int, input().split()))
    for j in range(b):
        c[j] -= 1
        s |= 1<<c[j]
    key.append([s, a])
dp = [INF] * (1<<N)
dp[0] = 0
for s in range(1<<N):
    for i in range(M):
        t = s | key[i][0]
        cost = dp[s] + key[i][1]
        dp[t] = min(dp[t], cost)
ans = dp[-1]
if ans == INF:
    ans = -1
print(ans)

Measured memory_bytes: 45800
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)*}
    };
}

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)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

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::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        s:chars,
    }
    let mut zero_s = 0;
    let mut one_s = 0;
    for (j,&c) in s.iter().enumerate() {
        if j % 2 == 0 {
            if  c == '1' {
                zero_s += 1;
            } else {
                one_s += 1;
            }
        } else {
            if c == '1'{
                one_s += 1;
            } else {
                zero_s += 1;
            }
        }
    }
    let ans = min(zero_s,one_s);
    println!("{}",ans);
}

Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 2019;

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    int r = x%y;
    if (r == 0) {
        return y;
    }
    return gcd(y, r);
}

ll mypow(ll x, ll n) {
    if (n == 0) return 1;
    if (n%2 == 0) return mypow(((x%mod)*(x%mod))%mod, n/2);
    else return ((x%mod) * mypow(((x%mod)*(x%mod))%mod, (n-1)/2))%mod;
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> ab(M);
    bool flag = false;
    for (int r=1, l=N-1, i=0; i<M; r++, l--, i++) {
        if (!flag && N%2 == 0 && l - r <= N/2) {
            l--;
            flag = true;
        }
        ab.at(i).first = r + 1;
        ab.at(i).second = l + 1;
    }
    for (auto p : ab) {
        cout << p.first << " " << p.second << endl;
    }
}

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

using namespace std;

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

	if (a >= k) {
		cout << k << endl;
	} else if (a + b >= k) {
		cout << a << endl;
	} else {
		int ans = a;
		k -= a;
		k -= b;
		cout << ans - k << endl;
	}

	return 0;
}

Measured memory_bytes: 3636
def c_switches(N, M, Switches, P):
    import numpy as np

    def rank_matrix(matrix):
        """mod2 上で行列の階数を求める"""
        num_row, num_col = matrix.shape[0], matrix.shape[1]
        rank = 0

        for col in range(num_col):
            # ピボット探し
            pivot = -1
            max_element = 0  # 最大の要素(1しかないが)がある場所を探す
            for row in range(rank, num_row):
                if matrix[row][col] > max_element:
                    max_element = matrix[row][col]
                    pivot = row
            if pivot == -1:
                continue  # ピボットが見つからない。次の列へ

            tmp = matrix[pivot, :].copy()
            matrix[pivot, :] = matrix[rank, :]
            matrix[rank, :] = tmp

            # (行列の要素は0または1しかないので、ピボットの値を1にする操作は不要)
            # ピボットのある列の値がすべて0となるように、掃き出しを行う
            for row in range(num_row):
                if row != rank and matrix[row][col] == 1:
                    for col2 in range(num_col):
                        matrix[row][col2] = (matrix[row][col2] + matrix[rank][col2]) % 2
            rank += 1
        return rank

    # 電球iがスイッチjとつながっているとき a_{ij}=1, そうでないなら0とする
    a = np.zeros((M, N), dtype='int8')
    for t, (_, *switches) in enumerate(Switches):
        for s in switches:
            a[t][s - 1] = 1
    p = np.reshape(P, (-1, 1))
    ap = np.concatenate((a, p), axis=1)  # 拡大係数行列
    rank_a, rank_ap = rank_matrix(a), rank_matrix(ap)
    return 2**(N - rank_a) if rank_a == rank_ap else 0
    # 参考: http://drken1215.hatenablog.com/entry/2019/03/20/202800

N, M = [int(i) for i in input().split()]
Switches = [[int(i) for i in input().split()] for j in range(M)]
P = [int(i) for i in input().split()]
print(c_switches(N, M, Switches, P))

Measured memory_bytes: 17712
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
//#define _GLIBCXX_DEBUG//only for debugging
/*BISMILLAH UR RAHMAN*/ 
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<fixed<<setprecision(10);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) int(x.size())
#define INF INT_MAX;
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> ii;
int arr[int(1e5+10)];
int cnt[int(1e5+10)];
int dp(int n)
{
  if(n<=0)return int(1e9+1);
  if(cnt[n]!=-1)return cnt[n];
  int ans=INF;
  ans=min(abs(arr[n]-arr[n-2])+dp(n-2),abs(arr[n]-arr[n-1])+dp(n-1));
  return cnt[n]=ans;

}
int main()
{  
  fast
  int n;
  cin>>n;
  for(int i=1;i<=n;++i)cin>>arr[i];
  memset(cnt,-1,sizeof(cnt));
  cnt[1]=0;
  cout<<dp(n);

  
  

}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long x,n,m,sum=0;
    cin>>n>>m;
    while(m--)
    {
	cin>>x;
	sum+=x;
    }
    if(n>=sum)
	cout<<n-sum;
    else
	cout<<-1;

    return 0;
}


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

int A[ 5010 ];

int main()
{
int i;
int iCnt;
int N, K;
int iSum;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> K;

	for( i = 0; i < N; i++ ) cin >> A[ i ];

	sort( A, A + N );

	iSum = 0;
	iCnt = 0;
	for( i = N - 1; i >= 0; i-- )
	{
		if( iSum + A[ i ] >= K )
			iCnt = 0;
		else
		{
			iCnt++;
			iSum += A[ i ];
		}
	}

	cout << iCnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int a[6];
    int i,j,k;
    for(i = 0; i < 5; i++) {
        cin >> a[i];
    }
    cin >> k;
    for(i = 0; i < 5; i++) {
        for(j = i + 1; j < 5; j++) {
            if(a[j]-a[i]>k) {
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    sort(s.begin(), s.end());

    vector<int> c(n);
    string t = "";
    int k = 0, l = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == t) {
            k++;
        } else {
            t = s[i];
            k = 1;
        }
        c[i] = k;
        l = max(l, k);
    }

    for (int i = 0; i < n; i++) {
        if (c[i] == l) {
            cout << s[i] << '\n';
        }
    }

    return 0;
}

Measured memory_bytes: 13824
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll M = 1e9+7;
ll self_add( ll x, ll y ){
	ll ret = x+y;
	if( ret >= M )
		ret -= M;
	return ret;
}
signed main(){
	ll n, m, i, j;
	cin >> n >> m;
	vector<vector<ll>> dp(n+1,vector<ll>(m+1,0));
	string s;
	for( i = 0 ; i < n ; i++ ){
		cin >> s;
		for( j = 0 ; j < m ; j++ ){
			if( s[j] == '.' ){
				if( i == j && i == 0 ){
					dp[i+1][j+1] = 1;
				}
				else{
					dp[i+1][j+1] = self_add( dp[i+1][j], dp[i][j+1] );
				}
			}
		}
	}
	cout << dp[n][m] << endl;
	return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <queue>
#define INF 9999999999
using namespace std;
typedef long long int ll;

int main() {
	int N;
	cin >> N;
	vector<string> names(N);
	ll num[5] = {};
	for (int i = 0; i < N; i++) {
		cin >> names[i];
		if (names[i][0] == 'M') num[0]++;
		if (names[i][0] == 'A') num[1]++;
		if (names[i][0] == 'R') num[2]++;
		if (names[i][0] == 'C') num[3]++;
		if (names[i][0] == 'H') num[4]++;
	}
	
	ll ans = 0;
	for (int i = 0; i < 5; i++) { //1
		for (int j = 0; j < 5; j++) { //2
			for (int k = 0; k < 5; k++) { //3
				if (j <= i || k <= i || k <= j) continue;
				ans +=  num[i] * num[j] * num[k];
			}
		}
	}
	
	cout << ans << endl;


	return 0;
}


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

int main()
{
	int rows, columns;
	cin >> rows >> columns;
	int **HW;
	HW = new int * [rows];
	for (int i = 0; i < rows; i++) {
		HW[i] = new int[columns];
	}
	for (int i = 0; i < rows; i++) {
		for (int j = 0; j < columns; j++) {
			HW[i][j] = 0;
		}
	}
	//填格子开始

	int Num;
	cin >> Num;
	int *a;
	a = new int[Num];
	for (int i = 0; i < Num; i++) {
		cin >> a[i];
	}
	int var = 0; int x = -1, y = 0;
	for (int i = 0; i < Num; i++) {
		for (int j = 0; j < a[i]; j++) {
			if (var == 0) {
				x++;
				if (x < columns && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					x--; j--; var++;
				}
			}else if (var == 1) {
				y++;
				if (y < rows && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					y--; j--; var++;
				}
			}else if (var == 2) {
				x--;
				if (x >= 0 && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					x++; j--; var++;
				}
			}else if(var == 3) {
				y--;
				if (y >= 0 && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					y++; j--; var = 0;
				}
			}
		}
	}
	//填格子结束
	for (int i = 0; i < rows; i++) {
		cout << HW[i][0];
		for (int j = 1; j < columns; j++) {
			cout << " " << HW[i][j];
		}
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 384
import Control.Monad (replicateM, forM_)

main = do
  [h,w] <- fmap read <$> words <$> getLine :: IO[Int]
  ss <- replicateM h getLine
  putStrLn . take (w + 2) . repeat $ '#'
  forM_ ss (\a -> putStrLn $ "#" ++ a ++ "#")
  putStrLn . take (w + 2) . repeat $ '#'


Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
const int ha=998244353;
const int N=1000000;
int fac[N+5],ifac[N+5];
int Pow(int a,int b)
{
    int ans=1;
    for(;b;b>>=1,a=1ll*a*a%ha)
        if(b&1) ans=1ll*ans*a%ha;
    return ans;
}
void Init()
{
    fac[0]=1;
    for(int i=1;i<=N;i++)
        fac[i]=1ll*fac[i-1]*i%ha;
    ifac[N]=Pow(fac[N],ha-2);
    for(int i=N-1;i>=0;i--)
        ifac[i]=1ll*ifac[i+1]*(i+1)%ha;
}
inline int C(const int &n,const int &m){return 1ll*fac[n]*ifac[m]%ha*ifac[n-m]%ha;}
inline int invC(const int &n,const int &m){return 1ll*ifac[n]*fac[m]%ha*fac[n-m]%ha;}
int main()
{
    int n,m;Init();
    cin>>n>>m;
    int t=min(n,m),ans=0;
    for(int i=1;i<=t;i++)
        ans=(ans+1ll*C(2*i,i)*C(n+m-2*i,n-i))%ha;
    ans=1ll*ans*invC(n+m,n)%ha*ifac[2]%ha;
    printf("%d\n",(ans+max(n,m))%ha);
    return 0;
}

Measured memory_bytes: 8064
N,M=map(int,input().split())
p_y=[]
for i in range(M):
    p,y=map(int,input().split())
    p_y.append([i+1,p,y])

p_count=[0]*N
p_y.sort(key=lambda x:x[2])
for num,a in enumerate(p_y):
    p_count[a[1]-1]+=1
    p_y[num].append(p_count[a[1]-1])
p_y.sort(key=lambda x:x[0])
for b in p_y:
    print(str(b[1]).zfill(6)+str(b[3]).zfill(6))





Measured memory_bytes: 31776
main :: IO ()
main = do
  n <- readLn :: IO Int
  putStrLn $ if isHarshad n then "Yes" else "No"

isHarshad n = n `mod` (digitSum n 0) == 0

digitSum n carry
  | n < 10 = carry + n
  | otherwise = digitSum (n `div` 10) (carry + n `mod` 10)


Measured memory_bytes: 508
#include<bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 2e7 + 9, M = 1e7, OO = 0x3f3f3f3f;
int main()
{
    int a[5],k;
    for(int i=0;i<5;i++){
        cin>>a[i];
    }
    cin>>k;
    sort(a,a+5);
    if(a[4]-a[0]>k){
        cout<<":("<<endl;
    }else{
        cout<<"Yay!"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
const int N_MAX = 100000;

vector<vector<int>> g;

int group[N_MAX];
int num_of_groups;
int size_of_group[N_MAX];

void dfs(int s, int k) {
	stack<int> st;
	st.push(s);
	group[s] = k;
	size_of_group[k]++;
	while (!st.empty()) {
		int v = st.top(); st.pop();
		for (int i : g[v]) {
			if (group[i] != -1) continue;
			st.push(i);
			group[i] = k;
			size_of_group[k]++;
		}
	}
	return;
}

void connected_component_decomposition() {
	const int V = g.size();
	num_of_groups = 0;
	fill(group, group+V, -1);
	for (int i = 0; i < V; i++) {
		if (group[i] == -1) {
			dfs(i, num_of_groups);
			num_of_groups++;
		}
	}
	return;
}

int main() {
	int n, m;
	cin >> n >> m;
	g.assign(n, vector<int>());
	for (int i = 0; i < m; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		x--; y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	connected_component_decomposition();
	cout << num_of_groups << endl;
	return 0;
}

Measured memory_bytes: 6904
#指定した値より大きい先頭のインデクスを返す
def upper_bound(arr, value)
  l = -1
  r = arr.size
  while l + 1 < r
    m = (l + r) / 2
    l = m if arr[m] <= value
    r = m if arr[m] >  value
  end
  r
end

N = gets.to_i
A = gets.split.map(&:to_i).sort!
B = gets.split.map(&:to_i).sort!
C = gets.split.map(&:to_i).sort!

sum = 0
bc = Hash.new { |h, k| h[k] = 0 }
(0..N-1).reverse_each do |i|
  sum += N - upper_bound(C, B[i])
  bc[B[i]] = sum
end

sum = 0
N.times do |i|
  sum += bc[B[upper_bound(B, A[i])]]
end
puts sum

Measured memory_bytes: 29304
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
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())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
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;}
// head

const int N=410;
int dp[N][N][N/3+10][2],dist[N][N];
int n,a[N],b[N],posa[N],posb[N];
ll ret,fac[N],pd[N][N];
void upd(int i,int j,int k,int p,int d) {
	dp[i][j][k][p]+=d;
	if (dp[i][j][k][p]>=mod) dp[i][j][k][p]-=mod;
}
ll ff() {
	pd[0][0]=1;
	rep(i,0,n/3+1) per(j,0,n/3*2+1) if (pd[i][j]) {
		pd[i+1][j+2]=(pd[i+1][j+2]+pd[i][j])%mod;
		if (j>0) pd[i][j-1]=(pd[i][j-1]+pd[i][j]*j)%mod;
	}
	return pd[n/3][0];
}
int main() {
	scanf("%d",&n);
	rep(i,1,n+1) scanf("%d",a+i),posa[a[i]]=i;
	rep(i,1,n+1) scanf("%d",b+i),posb[b[i]]=i;
	fac[0]=1;
	rep(i,1,n+1) fac[i]=fac[i-1]*i%mod;
	rep(i,0,n+1) {
		dist[i][0]=i;
		rep(j,1,n+1) {
			dist[i][j]=dist[i][j-1]+(posa[b[j]]>i);
		}
	}
	dp[0][0][0][0]=1;
	rep(i,0,n+1) rep(j,0,n+1) rep(k,0,n/3+1) {
		if (dp[i][j][k][0]&&i<n) {
			ll r=dp[i][j][k][0];
			if (posb[a[i+1]]<=j) {
				upd(i+1,j,k,0,r);
			} else {
				// i+1 by c
				if (k>0) upd(i+1,j,k-1,0,r*k%mod);
				// i+1 by self
				upd(i+1,j,k,1,r);
			}
		}
		if (dp[i][j][k][1]&&j<n&&b[j+1]!=a[i]) {
			ll r=dp[i][j][k][1];
			if (posa[b[j+1]]<=i) {
				upd(i,j+1,k,1,r);
			} else {
				if (k>0) upd(i,j+1,k-1,1,r*k%mod);
				if (dist[i][j+1]+k+1==n) {
					ret=(ret+r*fac[k+1])%mod;
				}
				else upd(i,j+1,k+1,0,r);
			}
		}
	}
	ret=ret*ff()%mod;
	printf("%lld\n",ret);
}


Measured memory_bytes: 187648
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int N;
ll A[200005], Count[200005];

int main(){
  scanf("%d", &N);
  for(int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
    Count[A[i]]++;
  }

  ll sum = 0;
  for (int i = 0; i < 2e5; i++){
    sum += Count[i] * (Count[i] - 1) / 2;
  }
  
  for (int i = 0; i < N; i++){
    printf("%lld\n", sum - Count[A[i]] + 1);
  }
  
  return 0;
}


Measured memory_bytes: 4736
mod = 1000000007

n = int(input())

a = 1
b = 1
c = 1
for i in range(n):
    a = a * 10 % mod
    b = b * 8 % mod
    c = c * 9 % mod


d = (a - 2 * c + b + mod) % mod
d = (d + mod) % mod
print(d)


Measured memory_bytes: 9112
N, X = map(int, input().split())

M = list(map(int, [input() for _ in range(N)]))
total = 0
min_m = 10 ** 9

for m in M:
    total += m
    if m < min_m:
        min_m = m
print(len(list(M)) + ((X - total) // min_m))

Measured memory_bytes: 3060
n,k=map(int,input().split())
s=0
for i in range(k,n+2):
	#0+...+i-1
	l=i*(i-1)//2
	#n+(n-1)+...+(n-i+1)
	h=(2*n-i+1)*i//2
	s+=h-l+1
print(s%(10**9+7))

Measured memory_bytes: 63432
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         998244353
#define mode        1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323

map<pll,ll>mp;
ll n;
vector<pll>ans;

void solve()
{
       //ll n;
       cin>>n;
       if(n==3)
       {
              cout<<2<<endl;
              cout<<"1 3"<<endl;
              cout<<"2 3"<<endl;
              exit(0);
       }
       ll nt=n;
       if(nt&1) n--;
       //vector<pll>ans;
             rep(i,1,n+1)
              {
                     rep(j,1,n+1)
                     {
                            if( (i!=j) && (i+j!=n+1)  )
                            {
                                   if( (!mp[{i,j}]) && (!mp[{j,i}]) )
                                          {
                                                 ans.pb({i,j});
                                                 mp[{i,j}]=1;
                                                 mp[{j,i}]=1;
                                          }
                            }
                     }
              }


       if(nt&1)
       {
              rep(i,1,n+1) ans.pb({i,nt});
       }
                     cout<<sz(ans)<<endl;
              for(pll x:ans) cout<<x.F<<" "<<x.S<<endl;
}

int main()
{
    speed_up
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
h = list(map(int, input().split()))

DP = [10**10 for _ in range(N)]
DP[0] = 0
DP[1] = abs(h[1]-h[0])

for i in range(2, N):
    DP[i] = min(DP[i-1]+abs(h[i-1]-h[i]), DP[i-2]+abs(h[i-2]-h[i]))
#print(DP)
print(DP[N-1])

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}


void solve(){
    int a;
  string s;
  cin >> a >> s;

  if(a >= 3200){
    cout << s << endl;
  }else{
    cout << "red" << endl;
  }
  return;
}

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

Measured memory_bytes: 256
import sys
import itertools as itr
readline = sys.stdin.buffer.readline



N=int(readline())
n=int(pow(N,0.5))
chk=list(itr.product(range(1,n),repeat=3))
cnt=[0]*(N+1)
for _ in range(len(chk)):
  i=chk[_][0]
  j=chk[_][1]
  k=chk[_][2]
  if pow(i,2)+pow(j,2)+pow(k,2)+i*j+j*k+k*i<=N:
    cnt[pow(i,2)+pow(j,2)+pow(k,2)+i*j+j*k+k*i]+=1
          

for i in range(1,N+1):
  print(cnt[i])

Measured memory_bytes: 78488
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<string> S(N);
  vector<ll> T(N);
  rep(i,N) cin>>S[i]>>T[i];
  string X;
  cin>>X;

  ll ans=0;
  for(int i=N-1;i>=0;i--){
    if(S[i]==X) break;
    ans+=T[i];
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
        int N;
        cin >> N;
        if(N<1200)        {cout << "ABC"<< endl;}else if(N<2800) {
                cout << "ARC"<< endl;
        }else{
                cout << "AGC"<< endl;

        }


        return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())

X = [list(map(int,input().split())) for _ in range(N)]

cheap = sorted(X, key=lambda X:X[0])

buy = M
cost = 0
for i in range(N):
	if cheap[i][1] <= buy:
		cost += cheap[i][0] * cheap[i][1]
		buy -= cheap[i][1]
	else:
		cost += cheap[i][0] * buy
		break

print(cost)

Measured memory_bytes: 29796
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt(); 
		int S = sc.nextInt(); 
		int cnt = 0, z = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				z = S-x-y;
				if(z>=0 && z <= K) cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k;
  cin >> n >> k;
  int m=0;
  int l=0;
  vector<int>a(k);
  vector<int>b(10000);
  vector<int>c(n);
  for(int i=0;i<k;i++){
    cin >> a.at(i);
    for(int j=0;j<a.at(i);j++){
      cin >> b.at(m);
      m++;
    }
  }
  for(int i=0;i<m;i++){
  c.at(b.at(i)-1)++;  
  }
  for(int i=0;i<n;i++){
    if(c.at(i)==0){
    l++;  
    }
  }
  cout << l << endl;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int N;
    cin >> N;

    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

const ll MD = 1e9+7;

inline ll MUL(ll a, ll b) {
	return (a * b) % MD;
}

inline ll ADD(ll a, ll b) {
	return (a + b) % MD;
}

inline ll SUB(ll a, ll b) {
	return ((a - b) % MD + MD) % MD;
}

inline ll powMod(ll a, ll p) {
	ll res = 1;
	for (; p; p >>= 1, a = MUL(a,a)) {
		if (p & 1) res = MUL(res,a);
	}
	return res;
}

inline ll DIV(ll a, ll b) {
	return MUL(a, powMod(b, MD-2));	
}

int main() {
	int N;
	sci(N);
	ll dat[N];
	ll sum = 0;
	ll sumSqr = 0;
	for (int i = 0; i < N; ++i) {
		scll(dat[i]);
		sum = ADD(sum, dat[i]);
		sumSqr = ADD(sumSqr, MUL(dat[i],dat[i]));
	}
	ll ans = DIV(SUB(MUL(sum, sum), sumSqr),2LL);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 5396
#include <iostream>
#include <string>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

string solve(string& s, int w) {
  string ans;
  for (size_t i = 0; i < s.size(); i += w) {
    ans += s[i];
  }
  return ans;
}

int main() {
  string s;
  int w;
  cin >> s >> w;
  cout << solve(s, w) << endl;
}


Measured memory_bytes: 256