akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int n ; cin >> n ;
	string a,b,c ;
	cin >> a >> b >> c ;
	int cnt = 0 ;
	for(int i=0;i<n;i++){
		if(a.at(i)==b.at(i)&&b.at(i)==c.at(i)) continue ;
		if(a.at(i)!=b.at(i)&&b.at(i)!=c.at(i)&&c.at(i)!=a.at(i)) cnt += 2 ;
		else cnt++ ;
	}
	cout << cnt << endl ;
}


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

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

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

template<typename Iter>
inline bool next_combination(Iter first, Iter k, Iter last)
{
  if ((first == last) || (first == k) || (last == k))
    return false;
  Iter it1 = first, it2 = last;
  ++it1;
  if (last == it1)
    return false;
  it1 = last;
  --it1;
  it1 = k;
  --it2;
  while (first != it1) {
    if (*--it1 < *it2) {
      Iter j = k;
      while (!(*it1 < *j))
        ++j;
      std::iter_swap(it1, j);
      ++it1, ++j;
      it2 = k;
      std::rotate(it1, j, last);
      while (last != j) {
        ++it2, ++j;
      }
      std::rotate(k, it2, last);
      return true;
    }
  }
  std::rotate(first, k, last);
  return false;
}

void solve()
{
  int N;
  cin >> N;
  map<string, int> mp;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    mp[s]++;
  }
  dump(mp);
  vector<ll> a(256);
  for (auto& m : mp) {
    a[m.first[0]]++;
  }
  ll ans = 0;
  vector<char> v{'M', 'A', 'R', 'C', 'H'};
  sort(v.begin(), v.end());
  do {
    ans += (a[v[0]] * a[v[1]] * a[v[2]]);
    dump(v, ans);
  } while (next_combination(v.begin(), v.begin() + 3, v.end()));

  cout << ans << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 11264
S = input()
# sを最後に残す文字にして全探索してみる
cnt = 10 ** 9
for s in S:
    nex = list(S)
    tmp = 0
    while len(set(nex)) > 1:
        tmp += 1
        L = len(nex)
        now = nex
        nex = []
        for i in range(L-1):
            if s in now[i:i+2]:
                nex.append(s)
            else:
                nex.append(now[i])
    cnt = min(cnt, tmp)
print(cnt)



Measured memory_bytes: 42220
#include <cstdio>
#include <cstring>
#define MAXN 2010
#define LL long long

const LL P=1000000007;

int n,m,l,K;
LL **f;

void dp(){
	f=new LL* [l];
	for(int i=0;i<=l;i++){
		f[i]=new LL[n+1];
		memset(f[i],0,sizeof(LL)*(n+1));
	}
	f[0][0]=1;
	for(int i=1;i<=l;i++){
		for(int j=0;j<=n;j++)
			for(int k=0;k<K;k++)
				f[i][j]=(f[i][j]+(j>=k?f[i-1][j-k]:0))%P;
		if(i==1) f[i][0]=0;
	}
}

LL calc(){
	LL ans=0;
	for(int j=n;j>0;j-=K-1){
		for(int i=l;i;i--)
			if((K-1)*i+1-j<=m)
				ans=(ans+f[i][j])%P;
	}
	return ans;
}

int main(){
#ifdef DEBUG
	freopen("E.in","r",stdin);
#endif
	scanf("%d%d%d",&m,&n,&K);
	l=(n+m-1)/(K-1);
	dp();
	printf("%lld\n",calc());
	return 0;
}



Measured memory_bytes: 62848
#include<iostream>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<list>
#include<set>
#include<stack>
using namespace std;
//pck2012_3?? 絎九梱?
static const int N = 100;

bool isSequence(vector<int> v);


int main(){
  vector<int> A;
  int n,x;

  while(cin >> n && n){
    A.resize(n+1);
    for(int i=0;i<n+1;i++){
      cin >> A[i];
    }

    for(int i=0;i<n+1;i++){
      vector<int> tmp = A;
      tmp.erase(tmp.begin()+i);
      if(isSequence(tmp)){
        cout << A[i] << endl;
        break;
      }
    }
  }

  return 0;
}

bool isSequence(vector<int> v){
  int d = v[1] - v[0];
  for(int i=1;i<v.size();i++){
    if(v[i] - v[i-1] != d)return false;
  }
  return true;
}




Measured memory_bytes: 3152
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

a, b, x = map(int, input().split())
if x >= (a ** 2 * b) / 2:
    print(math.atan(2 / a ** 3 * (a ** 2 * b - x)) * (180 / math.pi))
else:
    print(math.atan(a * b ** 2 / (2 * x)) * (180 / math.pi))


Measured memory_bytes: 5088
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long



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

    double total = 0;
    for (int i=0; i < n; i++){
        double f;
        cin >> f;
        string s;
        cin >> s;

        if (s == "JPY") {
            total += f;
        } else {
            total += f * 380000;
        }
    }

    cout << total << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	string odd, even;
	cin >> odd >> even;
	for (int i = 0; i < (int)odd.size(); i++) {
		printf("%c", odd.at(i));
		if(i < (int)even.size())printf("%c", even.at(i));
	}
	cout << endl;
}

Measured memory_bytes: 256
X = int(input())
if X == 1:
    print(1)
    exit()
result = 1
for i in range(2,int(X**0.5)+1):
    j = 2
    t = 0
    while i ** j <= X:
        t = i ** j
        j += 1
    result = max(result,t)
print(result)
        

Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#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 REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main () {

    ll N; cin >> N;
    vector < ll > A(N);
    REP(i,N) cin >> A[i];

    ll sum = 0;
    REP(i,N) sum += A[i] - 1;

    cout << sum << endl;
 
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# A

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

x = int(input())
if x <= 599:
    print(8)
elif x <= 799:
    print(7)
elif x <= 999:
    print(6)
elif x <= 1199:
    print(5)
elif x <= 1399:
    print(4)
elif x <= 1599:
    print(3)
elif x <= 1799:
    print(2)
else:
    print(1)


Measured memory_bytes: 65188
#include <stdio.h>

int main(){

    int i=0;
    int x[9999];


    do{
        scanf("%d",&x[i]);
        
        if(x[i] == 0){
            break;
        }

        i++;

    }while(i < 100000);

    i = 0;
    do{
        if(x[i] != 0){
            printf("Case %d: %d\n",i+1,x[i]);
        }else{
            break;
        }

        i++;

    }while(i < 10000);

    return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int INF = 0x3f3f3f3f; constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
#define db(x) { cerr << #x << " = " << x << endl; }
template <typename T> void _dbarr(T* a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
template <typename T> void _dbarr(vector<T> a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
#define dbarr(x, n) {cerr << #x << ": "; _dbarr((x),(n));}
#define all(x) begin(x), end(x)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fs first
#define sn second
const int MM = 2e5+5;
int n,m;
bool vis[MM];
vector<int> adj[MM];
int main()
{
	cin.tie(0)->sync_with_stdio(0);
    cin >> n >>m;
    for(int i = 0; i < m; i++)
    {
        int a,b;
        cin >> a >> b;
        adj[a].eb(b);
        adj[b].eb(a);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        if(!vis[i])
        {
            queue<int> q;
            q.push(i);
            vis[i] = 1;
            int cnt = 0;
            while(!q.empty())
            {
                cnt++;
                int u = q.front(); q.pop();
                for(int& v : adj[u])
                {
                    if(!vis[v])
                    {
                        vis[v] = 1;
                        q.push(v);
                    }
                }
            }
            ans = max(ans,cnt);
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 15112
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int N;
    cin >> N;
    vi A(N);
    map<int, int> mp;
    rep(i, N) {
        cin >> A[i];
        mp[A[i]] = i;
    }
    SORT(A);

    int res = 0;
    rep(i, N) {
        if(i%2==0 && mp[A[i]]%2) res++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 7296
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
p=p[:x]
q=q[:y]
p[x:x]=q
p[x+y:x+y]=r
p.sort(reverse=True)
p=p[:x+y]
print(sum(p))

Measured memory_bytes: 23328
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std; 
int main(){
	int N; 
	string S, T; 
	cin >> N >> S >> T; 
	int ans = N * 2; 
	for(int i = N; i >= 1; i--){
		if(T.substr(0, i) == S.substr(N-i, i)){
			ans = N * 2 - i; 
			break; 
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 256
N=gets.to_i
edges=Array.new(N){Array.new}
(N-1).times do
    a,b=gets.split.map(&:to_i)
    a-=1
    b-=1
    edges[a] << b
    edges[b] << a
end
dist_from_1=Array.new(N)
dist_from_last=Array.new(N)

def dfs(edges,start,dists)
    used=Array.new(edges.size,false)
    used[start]=true
    dists[start]=0
    stack=[start]
    while !stack.empty?
        v=stack.pop
        edges[v].each do |vv|
            next if used[vv]
            used[vv]=true
            dists[vv]=dists[v]+1
            stack << vv
        end
    end
end

dfs(edges,0,dist_from_1)
dfs(edges,N-1,dist_from_last)


b_count=0
w_count=0
N.times do |i|
    b_count+=1 if dist_from_1[i]<=dist_from_last[i]
    w_count+=1 if dist_from_1[i]>dist_from_last[i]
end

puts b_count>w_count ? "Fennec" : "Snuke"

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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i, k , n) for(int i = k; i <= n; i++)
typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;


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

   int a[3], k;
   cin >> a[0] >> a[1] >> a[2] >> k;
   sort(a, a+3);

   cout << a[2]*pow(2,k) + a[1] + a[0]  << nl;
   return 0;
}


Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
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; }

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

const int INF = 1001001001;

 
int main(){
    int n;
    cin >> n;
    int h[n];
    rep(i, n) cin >> h[i];
    vec<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    rep(i, n-2) dp[i+2] = min(dp[i]+abs(h[i]-h[i+2]) , dp[i+1]+abs(h[i+1]-h[i+2]));
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		for (int i=0;i<q;i++) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			long rt = (long) Math.floor(Math.sqrt(a*b));
			long ans = 0;
			if (rt*(rt+1) < a*b) {
				ans = 2*rt-1;
			} else if (rt*rt < a*b){
				ans = 2*rt-2;
			} else {
				ans = 2*rt-3;
				if(rt == a && rt == b) {
					ans++;
				}
			}
			System.out.println(ans);
		}

	}

}


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	double a, b, c, d, e, f, x, y;
  while(cin >> a >> b >> c >> d >> e >> f) {
    x = (c * e - b * f) / (a * e - b * d) + 0.0000;
    y = (c * d - a * f) / (b * d - a * e) + 0.0000;
    cout << fixed << setprecision(3) << x << " " << y << endl;
  }
	return 0;
}


Measured memory_bytes: 3188
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a + 1): # 500
    if i * 500 == x:
        count += 1
        continue

    for j in range(b + 1): # 100
        if i * 500 + j * 100 == x:
            count += 1
            continue

        if 0 <= x - i * 500 - j * 100 <= 50 * c:
            count += 1

print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int n, i, ra[100003] = {}, rc[100003] = {}, rht1[100003] = {}, rht2[100003] = {}, ans;
    string s;
    ll pa, pc, pow3[100003] = {};

    cin >> s;

    n = s.size();

    pow3[0] = 1;
    for (i = 0; i < n; i++) {
        pow3[i + 1] = pow3[i] * 3 % mod;
    }

    for (i = 0; i < n; i++) {
        if (s[i] == 'A') {
            ra[i + 1] = 1;
        }
        if (s[i] == 'C') {
            rc[i + 1] = 1;
        }
        if (s[i] == '?') {
            rht1[i + 1] = rht2[i + 1] = 1;
        }
    }

    for (i = 1; i <= n + 1; i++) {
        ra[i] += ra[i - 1];
        rht1[i] += rht1[i - 1];
    }
    for (i = n + 1; i >= 0; i--) {
        rc[i] += rc[i + 1];
        rht2[i] += rht2[i + 1];
    }

    ans = 0;
    for (i = 0; i < n; i++) {
        if (s[i] == 'B' || s[i] == '?') {
            pa = ((ll)ra[i] * pow3[rht1[i]] % mod + (ll)rht1[i] * pow3[max(0, rht1[i] - 1)] % mod) % mod;
            pc = ((ll)rc[i + 2] * pow3[rht2[i + 2]] % mod + (ll)rht2[i + 2] * pow3[max(0, rht2[i + 2] - 1)] % mod) % mod;
            ans = (ans + pa * pc % mod) % mod;
        }
    }

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

    return 0;
}

Measured memory_bytes: 2816
//CODE FESTIVAL 2016 qual A B
#include <bits/stdc++.h>
using namespace std;

int main(){
	int ans = 0;
	long long n;
	scanf("%lld", &n);
	int a[n];
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	for(int i=0; i<n; i++){
		if(a[a[i]-1] == i+1 && i+1 < a[i]){
			ans++;
		}
	}
	printf("%d", ans);
}

Measured memory_bytes: 640
<?php
  $s = trim(fgets(STDIN));
  $counter = 0;
  $max = 0;
  for($i = 0; $i < strlen($s); $i++){
    if(in_array($s[$i],["A","T","C","G"])){
      $counter++;
      $max = max($counter, $max);
    }else{
      $counter = 0;
  	}
  }
  echo $max;
    

Measured memory_bytes: 4856
s=input()
a=0
n=len(s)
for i in range(2,n-1):
    a=1
    if s[i]=="C":
        a=0
        break
if s[0]!="A":
    a=1
t=list(s.lower())
k=list(s)
b=0
for i in k:
    if i not in t:
        b+=1
if b==2 and a==0:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> V(N);
  for (int i = 0; i < N; i++) cin >> V[i];
  
  long long m = 0;
  for (int i = 0; i <= K/2; i++) {  //push i回、pop K-i回
    for (int j = 0; j <= min(K-i, N); j++) {  //pop 左からj(<=N)個、右からK-i-j個
      vector<int> hand;
      if (j >= N - K + i + j) hand = V;
      else {
        for (int k = 0; k < j; k++) hand.push_back(V[k]);
        for (int k = 0; k < K - i - j; k++) hand.push_back(V[N-1-k]);
      }
      sort(hand.begin(), hand.end());
      //for (int i : hand) cout << i << " "; cout << endl;
      long long s = accumulate(hand.begin(), hand.end(), 0);
      for (int k = 0; k < i; k++) {
        if (hand[k] >= 0) break;
        s -= hand[k];
      }
      if (s > m) m = s;
    }
  }
  cout << m << endl;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
  ll n, k; cin >> n >> k;
  Vi v(n); REP(i, n) cin >> v[i];

  ll ans = 0;
  for(ll i1 = 0; i1 <= n; i1++){
    for(ll i2 = 0; i1 + i2 <= n; i2++){
      for(ll j = 0; j <= i1 + i2 && i1 + i2 + j <= k; j++){
        Vi w(v.begin(), v.begin() + i1);
        w.insert(w.end(), v.rbegin(), v.rbegin() + i2);
        RSORT(w);
        ll temp = 0;
        REP(l, i1 + i2 - j) temp += w[l];
//        printf("i1 = %lld, i2 = %lld, j = %lld, w.size() = %lld, temp = %lld\n", i1, i2, j, (ll)w.size(), temp);
        chmax(ans, temp);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
(* O(n) *)
let rec fold_btw f a i n = if i >= n then a else fold_btw f (f a i) (i + 1) n
let fold_int f a n = fold_btw f a 0 n

(* O(1) *)
let is_acgt_char = function
| 'A' | 'C' | 'G' | 'T' -> true
| _ -> false

(* O(|s|) *)
let solve s =
  fold_int
    (fun (acc_max, count) i ->
      if is_acgt_char s.[i] then
        max acc_max (count + 1), count + 1
      else
        acc_max, 0)
    (0, 0)
    (String.length s) |> fst

let _ = read_line () |> solve |> string_of_int |> print_endline

Measured memory_bytes: 384
//【ライブラリここから】
// 1. 入力の容易化（https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8）
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)*}
    };
}

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")
    };
}
//【ライブラリここまで】

fn main() {
    input! {n: i64, s: [String; n]};
    let mut c_ac: i64 = 0;
    let mut c_wa: i64 = 0;
    let mut c_tle: i64 = 0;
    let mut c_re: i64 = 0;
    for item in s {
        if item == "AC" {
            c_ac += 1;
            continue;
        }
        if item == "WA" {
            c_wa += 1;
            continue;
        }
        if item == "TLE" {
            c_tle += 1;
            continue;
        }
        if item == "RE" {
            c_re += 1;
            continue;
        }
    }
    println!("AC x {}", c_ac);
    println!("WA x {}", c_wa);
    println!("TLE x {}", c_tle);
    println!("RE x {}", c_re);
}


Measured memory_bytes: 7548
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
//#define mod 998244353
#define inf 1000000000
#define pr1(a) cout << a << "\n"
#define pr2(a,b)cout << a <<  " " <<b<< "\n"
#define pr3(a,b,c) cout << a <<" " << b << " " << c << "\n"

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

int gcd(int a, int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
const int maxn = 2*1e5 + 10;


void solve(){

    int k, a,b;
    cin >> k >> a >> b;

    int x = a/k;
    if(a%k==0 || b%k==0){
        cout << "OK" << endl;
    }
    else{

        if(k*(x+1)<=b){
            cout << "OK" << endl;

        }
        else cout << "NG" <<endl;
    }
    
    

} 

signed main() 
{   
    IOS;
    int t = 1;
    // cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 

Measured memory_bytes: 3640
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')

x, a = map(int,input().split())
if x < a:
    print(0)
else:
    print(10)

Measured memory_bytes: 5368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<double, P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;
#define INF (ll)10000000000000000

int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll>A(N);
  rep(i,N){cin>>A[i];}
  for(int i=K;i<N;i++){
    if(A[i-K]<A[i]){
      cout<<"Yes"<<endl;
    }
    else{
       cout<<"No"<<endl;
     }
  }
}


Measured memory_bytes: 4844
Q = int(input())
query = [list(map(int, input().split())) for _ in range(Q)]
prime = [True for _ in range(10**5 + 1)]
prime[0] = prime[1] = False
for i in range(2, 320):
    if prime[i]:
        for j in range(i * 2, 10 ** 5 + 1, i):
            prime[j] = False
counter = [0 for _ in range(10 ** 5 + 1)]
for i in range(1, 10 ** 5 + 1):
    if prime[i] and prime[(i + 1) // 2]:
        counter[i] = counter[i - 1] + 1
    else:
        counter[i] = counter[i - 1]
for q in query:
    l, r = q
    print(counter[r] - counter[l - 1])

Measured memory_bytes: 29800
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

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

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

    int n;
    cin >> n;
    int a[n];
    REP(i,n) cin >> a[i];
    vector<int> L(n), R(n);

    REP(i, n) {
        if(i==0) L[i] = a[i];
        else {
            L[i] = gcd(a[i], L[i-1]);
        }
    }

    for(int i=n-1; i>=0; i--) {
        if(i==n-1) R[i] = a[i];
        else {
            R[i] = gcd(a[i], R[i+1]);
        }
    }

    int ans = max(R[1], L[n-2]);
    for(int i=1; i<n-1; i++) {
        chmax(ans, gcd(L[i-1], R[i+1]));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int h,w,n;
  cin>>h>>w>>n;
  int ans=max(h,w);
  ans=(n+ans-1)/ans;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
lower = 1
upper = 100000
for i in range(m):
    l, r = map(int, input().split())
    if l >= lower:
        lower = l
    if r <= upper:
        upper = r
        
if lower > upper:
    print(0)
else:    
    if n < upper:
        upper = n
    print(upper - lower + 1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(a, max(b, c))
#define MIN(x, y, z) min(a, min(b, c))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  string N;
  cin >> N;

  if (N[0] == N[1] && N[1] == N[2]) {
    COUT("Yes");
    return 0;
  }

  if (N[1] == N[2] && N[2] == N[3]) {
    COUT("Yes");
    return 0;
  }

  COUT("No");
  return 0;
}

Measured memory_bytes: 3600
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::collections::{HashSet,HashMap};
#[allow(unused_imports)]
use std::cmp::{min,max};

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

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin 
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input!(s:String);
    let mut s = s.chars().collect::<Vec<char>>();
    let mut st = HashSet::new();
    for c in s {
        st.insert(c);
    }
    let mut ans = None;
    for c in b'a'..b'z'+1 {
        let c = char::from(c);
        if !st.contains(&c) {
            ans = Some(c.to_string());
            break;
        }
    }
    println!("{}", ans.unwrap_or("None".to_string()));
}


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

int main() {
    int n;
    cin >> n;
    vector<vector<P>> graph(n);
    vector<int> ans(n-1);
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        --a; --b;
        graph[a].emplace_back(b, i);
        graph[b].emplace_back(a, i);
    }


    queue<int> q;
    vector<bool> visit(n);

    q.push(0);
    visit[0] = true;
    while(!q.empty()){
        int node = q.front(); q.pop();
        int parent_color = -1;
        for(auto v : graph[node]){
            int fi = v.first;
            int se = v.second;
            if(visit[fi]){
                parent_color = ans[se];
                break;
            }
        }

        int color = 1;
        for(auto v : graph[node]){
            int fi = v.first;
            int se = v.second;
            if(visit[fi]){
                continue;
            }
            visit[fi] = true;
            if(color == parent_color){
                ++color;
            }
            ans[se] = color;
            ++color;
            q.push(fi);
        }
    }

    int k = 0;
    for(auto m : graph){
        k = max(k, (int)m.size());
    }
    cout << k << endl;
    rep(i, n-1){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

void solve(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    if(d<b || a<b){
        cout << "No\n";
    }
    else{
        ll gcd = __gcd(b, d);
        ll max = (b-gcd + (a%b)%gcd);
        if(max <= c){
            cout << "Yes\n";
        }
        else{
            cout << "No\n";
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T; cin >> T;
    for(int i = 0; i < T; ++i){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include<cmath>
#include<string.h>
#include<vector>
#include<queue>
#include<deque>

using namespace std;

int main(){
	int kt[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51} , a;
	scanf("%d",&a);
	printf("%d\n",kt[a-1]);
	return 0;
}

Measured memory_bytes: 256
def merge(A, left, mid, right):

    n1 = mid-left
    n2 = right-mid
    #L = [0 for i in range(n1+1)]
    #R = [0 for i in range(n2+1)]
    #for i in range(n1):
    #    L[i] = A[left+i]
    #for i in range(n2):
    #    R[i] = A[mid+i]
    L = A[left:mid]
    R = A[mid:right]
    L.append(float('inf'))
    R.append(float('inf'))
    i = 0
    j = 0
    global cnt

    for k in range(left, right):
        cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i+1
        
        else:
            A[k] = R[j]
            j = j+1
    return cnt

def mergeSort(A, left, right):
    if left+1 < right:
         mid = (left+right) // 2
         mergeSort(A, left, mid)
         mergeSort(A, mid, right)
         merge(A, left, mid, right)
    else:
        return 0

n = input()
A = list(map(int, input().split()))
cnt = 0
mergeSort(A, 0, len(A))
print(*A)
print(str(cnt))

Measured memory_bytes: 63572
def make_yakusuu(n):
    r_list = []
    i = 1
    while i * i <= n:
        if n % i == 0:
            r_list.append(i)
            r_list.append(n // i)
        i += 1
    return sorted(r_list)
n = int(input())
tmp = make_yakusuu(n)
out = []
for i in tmp:
    m = n
    if i == 1:
        continue
    while m % i == 0:
        m //= i
    if m % i == 1 or m % i == 0:
        out.append(i)

out += make_yakusuu(n - 1)
print(len(set(out)) - 1)

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

int main() {
    int n,m,l;
    cin >> n >> m >> l;
    vector<vector<int>> a(n,vector<int>(m));
    vector<vector<int>> b(m,vector<int>(l));
    vector<vector<long>> c(n,vector<long>(l,0));
    
    for (int i = 0; i < n; i++) {
         for (int j = 0; j < m; j++) {
             cin >> a[i][j];
           }
    }
   
    for (int i = 0; i < m; i++) {
         for (int j = 0; j < l; j++) {
             cin >> b[i][j];
           }
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            for (int k = 0; k < m; k++) {
                c[i][j] += a[i][k] *b [k][j];
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            cout  << c[i][j];
            if(j!=l-1) cout <<' ';
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}


signed main(){
  int n,m;cin>>n>>m;vector<int> ac(1,0);
  int ans = 0, bcsum = 0;
  rep(i,n){
    int a;cin>>a;ac.push_back(a);
    ans += a;
  }
  sort(ac.begin(), ac.end());
  rep(i,n)ac[i+1] += ac[i];

  vector<pair<int,int>> ps;
  rep(i,m){
    int b,c;cin>>b>>c;
    ps.push_back(make_pair(c,b));
  }
  sort(ps.begin(), ps.end(), greater<pair<int,int>>());
  int ind = 0;
  rep(i,m){
    bool end = false;
    rep(j,ps[i].second){
      ind++;
      if(ind > n){
        end = true;
        break;
      }
      bcsum += ps[i].first;
      //cout << bcsum << " " << ac[n] << " " << ac[ind] << " " << bcsum + ac[n] - ac[ind] << endl;
      if(ans > bcsum + ac[n] - ac[ind]){
        end = true;
        break;
      }else{
        ans = bcsum + ac[n] - ac[ind];
      }
    }
    if(end)break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3188
package main

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


func main() {
	var n,k int
	fmt.Scan(&n, &k)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	mod := 998244353
	l := make([]int, n)
	r := make([]int, n)
	for i := 0; i < k; i++ {
		sc.Scan()
		l[i], _ = strconv.Atoi(sc.Text())
		sc.Scan()
		r[i], _ = strconv.Atoi(sc.Text())
	}
	dp := make([]int, n+1)
	dp[1] = 1
	dpSum := make([]int, n+1)
	dpSum[1] = 1



	for i := 2 ; i <= n; i++{
		// [l[i], r[i]]
		for j := 0; j < k; j++ {
			li := i - r[j]
			ri := i - l[j]
			if ri < 0 {
				continue
			}
			li = max(li, 1)
			dp[i] +=dpSum[ri] - dpSum[li-1] // dp[li]~dp[ri]
			dp[i] %= mod
		}
		dpSum[i] = dpSum[i-1] + dp[i]
	}
	fmt.Println(dp[n])
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		if res < nums[i] {
			res = nums[i]
		}
	}
	return res
}


Measured memory_bytes: 5236
N, X = map(int, input().split())
m = sorted([int(input()) for _ in range(N)])

minimum = m[0]
x = X
cnt = 0
for i in m:
    x -= i
    if x >= 0:
        cnt += 1
while x >= 0:
    x -= minimum
    if x >= 0:
        cnt += 1

print(cnt)


Measured memory_bytes: 38512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a-c) <= d){
        cout << "Yes" << endl;
    }else{
        if(abs(a-b)<=d && abs(b-c) <= d){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>

using namespace std;

const long long N = 1e5 + 5;
const long long mod = 1e9 + 7;
long long d1[N];
long long d2[N];
long long dp1[N];
long long dp2[N];

vector<pair<long long, long long>> graph[N];
long long n, m;
long long s, t;
long long ans;

void solver(long long v, long long dp[N], long long d[N])
{
	set<pair<long long, long long>> s;
	d[v] = 0;
	dp[v] = 1;
	s.insert({d[v], v});
	while (s.size())
	{
		v = (*s.begin()).second;
		s.erase(s.begin());
		for (auto nei: graph[v])
		{
			long long u = nei.first;
			long long w = nei.second;
			if (d[u] == d[v] + w)
			{
				dp[u] += dp[v];
				dp[u] = dp[u] % mod;
			}
			if (d[u] > d[v] + w)
			{
				s.erase({d[u], u});
				d[u] = d[v] + w;
				dp[u] = dp[v];
				dp[u] = dp[u] % mod;
				s.insert({d[u], u});
			}
		}
	}
} 

int main() 
{
	cin >> n >> m >> s >> t;
	s--;
	t--;
	for (long long i = 0; i < m; i++)
	{
		long long u , v, w;
		cin >> u >> v >> w;
		graph[u - 1].push_back({v - 1, w});
		graph[v - 1].push_back({u - 1, w});
	}
	memset(d1, 127, sizeof d1);
	memset(d2, 127, sizeof d2);
	solver(s, dp1, d1);
	solver(t, dp2, d2);
	long long dist = dp1[t] % mod;
	ans = (dist * dist) % mod;
	for (long long i = 0; i < n; i++)
	{
		for (long long j = 0; j < graph[i].size(); j++)
		{
			long long u = graph[i][j].first;
			long long w = graph[i][j].second;
			if (d1[i] < d1[t] / 2 && d2[u] < d1[t] / 2 && d1[i] + d2[u] + w == d1[t])
			{
				ans -= (((dp1[i] * dp1[i]) % mod) * ((dp2[u] * dp2[u]) % mod)) % mod;
			}
		}
		if (d1[i] == d2[i] && d1[i] == d1[t] / 2)
		{
			ans -= (((dp1[i] * dp1[i]) % mod) * ((dp2[i] * dp2[i]) % mod)) % mod;
		}
	}
	cout << ((ans % mod) + mod) % mod << endl;

}



Measured memory_bytes: 21232
#include <iostream>

int main()
{
  int n, a, b, sum = 0;
  int i, wa;

  std::cin >> n >> a >> b;
  for (i = 1; i <= n; i++)
  {
    wa = i / 10000 + ((i % 10000) / 1000) + ((i % 1000) / 100) + ((i % 100) / 10) + (i % 10);
    if (wa >= a && wa <= b)
    {
      sum += i;
    }
  }
  std::cout << sum << std::endl;
  return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N, K = map(int, readline().split())
    R, S, P = map(int, readline().split())
    T = readline().rstrip().decode()
    ans = 0

    def getPoint(letter):
        if letter == 'r':
            return P
        if letter == 's':
            return R
        if letter == 'p':
            return S

    for i in range(K):
        seq = T[i::K] + 'o'
        
        cnt = 0
        nowLetter = seq[0] 
        for j in seq:
            if j != nowLetter:
                #精算をする
                ans += ((cnt+1)//2)*getPoint(nowLetter)
                cnt = 0
            cnt += 1
            nowLetter = j
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll N; cin >> N;
  ll m = 1e15;
  ll w;
  for(ll h=1; h<=sqrt(N); h++){
    //整数の範囲でwを計算する
    if (N%h==0){
        w=N/h;
        m = min(m,(h-1)+(w-1));
        //cout << h << " " << w << endl;
    }
  }
 
  cout << m << endl;
  return 0;
}

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

for i in range(N):
    A[i] = A[i] - i - 1

median = statistics.median(A)

ans = 0
for i in range(N):
    ans += abs(A[i] - median)

print(int(ans))

Measured memory_bytes: 27244
#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = 0; i < k; ++i) {
        if (i % 2) {
            a += b / 2;
            b /= 2;
        }
        else {
            b += a / 2;
            a /= 2;
        }
    }
    cout << a << " " << b << "\n";
    return 0;
}


Measured memory_bytes: 256
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, K = ZZ()
    A = ZZ()
    if K == 0:
        print(sum(A))
        return

    bK = format(K, 'b')
    msb = len(bK)
    plus = [0] * msb

    for a in A:
        for i, b in enumerate(format(a, '0{}b'.format(msb))[::-1][:msb]): plus[i] += int(b)
    e = 1
    for i in range(msb):
        plus[i] = e * (N - 2 * plus[i])
        e *= 2

    dp = [[0] * 2 for _ in range(msb)]
    dp[0][0] = plus[i]
    plus = plus[::-1]

    for i in range(msb-1):
        dp[i+1][0] = max(dp[i+1][0], dp[i][0] + plus[i+1] * int(bK[i+1]))
        if int(bK[i+1]) == 1: dp[i+1][1] = max(dp[i+1][1], dp[i][0])
        dp[i+1][1] = max(dp[i+1][1], dp[i][1], dp[i][1] + plus[i+1])
    print(max(dp[msb-1]) + sum(A))

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 14148
def inpl(): return list(map(int, input().split()))

MOD = 10**9 + 7
S = input()[::-1]
x = 1

DP = [0]*13
DP[0] = 1
for i in range(len(S)):
    DP2 = [0]*13
    if S[i] != "?":
        s = int(S[i])
        for i in range(13):
            DP2[(i + s*x)%13] = DP[i]%MOD
    else:
        for j in range(10):
            for i in range(13):
                DP2[(i + j*x)%13] = (DP2[(i + j*x)%13] + DP[i])%MOD
    x = x*10%13
    DP = DP2

print(DP[5]%MOD)

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


int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  // 入力部分
  ll n,d,a;cin>>n>>d>>a;
  vector<pair<ll, ll> > vp(n);
  for(int i=0;i<n;i++){
    ll x,h;cin>>x>>h;vp[i] = {x,h};
  }
  sort(vp.begin(), vp.end());
  queue<pair<ll, ll> > memo;

  ll ruiseki=0;
  ll res=0;
  for(int i=0;i<n;i++){
    auto x = vp[i].first;
    auto h = vp[i].second;
    while(!memo.empty()){
      auto pos = memo.front().first;
      auto damage = memo.front().second;
      if(pos<=x){
        ruiseki += damage;
        memo.pop();
      }else {
        break;
      }
    }
    h -= ruiseki;
    ll cnt=0;
    if (h>0) cnt = (h+a-1)/a;
    res += cnt;
    ll damage = cnt * a;
    ruiseki += damage;
    memo.push({x + 2 * d+1, -damage});
  }

  cout<<res<<endl;
  
  return 0;
}


Measured memory_bytes: 6656