akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<61;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vi a;
vp b;

int main(){
	cin>>n;
	a=vi(n);
	int M=-1,I;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(M<abs(a[i])){
			M=abs(a[i]);
			I=i;
		}
	}
	if(a[I]==0){
		cout<<0<<endl;
		return 0;
	}
	for(int i=0;i<n;i++) if(a[i]!=0&&(a[I]>0^a[i]>0)) b.push_back({I,i});
	if(a[I]>0){
		for(int i=0;i<n-1;i++) b.push_back({i,i+1});	
	}
	else{
		for(int i=n-1;i>0;i--) b.push_back({i,i-1});
	}
	int N=b.size();
	cout<<N<<endl;
	for(int i=0;i<N;i++) cout<<b[i].first+1<<' '<<b[i].second+1<<endl;
}

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

int main() {
  int n;
  cin >> n;
  long long ans = 0, s = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a == 0) {
      ans += s / 2;
      s = 0;
    }
    else {
      s += a;
    }
  }
  ans += s / 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter as co
from operator import mul
from functools import reduce

def combinations_count(n, r):
  r = min(r, n - r)
  numer = reduce(mul, range(n, n - r, -1), 1)
  denom = reduce(mul, range(1, r + 1), 1)
  return numer//denom


n=int(input())
a=0
l=[''.join(list(map(str,sum(sorted(list(map(list,co(input()).items()))),[])))) for i in range(n)]
for d,s in co(l).items():
  if s>=2:a+=combinations_count(s, 2)
print(a)

Measured memory_bytes: 20708
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N;
    static int[] p;
    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
        p = new int[N];
        p = cin.ArrayInt(N);
    }
    static void solve()
    {
        input();
        bool isFinished = true;
        for(int i = 0; i < N - 1; i++)
            if(p[i] >= p[i + 1])
            {
                isFinished = false;
                break;
            }

        for(int i = 0; i < N - 1; i++)
        {
            if (isFinished)
                break;
            for (int j = i + 1; j < N; j++)
            {
                int[] tmp = (int[])p.Clone();
                int t = tmp[i];
                tmp[i] = tmp[j];
                tmp[j] = t;

                bool isAsc = true;
                for(int k = 0; k < N - 1; k++)
                {
                    if(tmp[k] >= tmp[k + 1])
                    {
                        isAsc = false;
                        break;
                    }
                }
                if (isAsc)
                {
                    isFinished = true;
                }
            }
        }
        WriteLine(isFinished ? "YES" : "NO");
    }

    
    class Scanner
    {
        string[] s;
        int i;

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

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

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

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

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

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

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

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

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;


int main(){
  int r;cin>>r;
  cout << fixed << setprecision(3) << 2*r*3.141592;
}


Measured memory_bytes: 3792
#include "bits/stdc++.h"
using namespace std;

#define S second
#define F first
#define all(a) a.begin() , a.end()
#define pb push_back 
#define DBG cout<<"debug\n";

typedef long long ll;

const int N = 2 * 1e5 + 10;
const ll inf = 9e18 + 9; 

ll res;
ll a[N];


void solve(){
    ll n;
    cin>>n;
    vector<double> x;
    for(int i = 0; i < n ; i++) {
        ll xl ;
        cin>>xl;
        double v = (double)1/xl;
        x.pb(v);
    }

    double xm = 0;
    for(int i = 0; i < x.size(); i++) {
        xm += x[i];
    }

    xm = 1/xm;
    cout<<xm<<"\n";
}

int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    REP(i,n)cin >> a[i];
    int answer = 0,count = 0;
    REP(i,n-1){
        if(a[i]==a[i+1]){
            count++;
        }else{
            answer += (count+1)/2;
            count = 0;
        }
    }
    answer += (count+1)/2;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N, C[3<<17], D[3<<17], F[3<<17];

int main(){
    cin>>N;
    for(int i = 0;i < N; i++){
        int x; cin>>x;
        C[x]++;
    }
    for(int i = 0; i <= N; i++)D[C[i]]++;
    ll L = 0, R = 0;
    for(int i = 1; i <= N; i++) R+=D[i];
    for(int x = 1; x <= N; x++){
        R -= D[x];
        L += x*D[x];
        F[x]=(L+R*x)/x;
    }
    int id = N;
    for(int K = 1; K <= N; K++){
        while(id>0 && F[id]<K) id--;
        cout<<id<<endl;
    }
    return 0;
}

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

#define INF INT_MAX
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,a,n) for(int i=0;i<n;i++)

using namespace std;

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

	int N,Q;
	string s;
	cin >> N >> Q;
	cin >> s;
	vector<int> cnt(N,0);
	int temp = 0;
	for(int i = 1;i < s.size();i++){
		if(s[i-1] == 'A' && s[i] == 'C'){
			temp++;
		}
		cnt[i] = temp;
	}
	for(int i = 0;i < Q;i++){
		int l,r;
		cin  >> l >> r;
		cout << cnt[r-1] - cnt[l-1] << endl;
	}
   
	return 0;
}


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

int main() {
    int A,B;
    cin >> A >> B;
    int count = 0;
    
    for(int i = A; i <= B; i++)
    {
        string buf = to_string(i);
        
        if(buf[0] == buf[4] && buf[1] == buf[3])
        {
            count++;
        }
    }
    
    cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const int i_INF = 2147483647;

int main() {
	string s;
	int min = i_INF;
	cin >> s;
	rep(i, 0, s.size() - 2) {
		int a;
		a = stoi(s.substr(i, 3));
		int d = abs(a - 753);
		if (d < min)min = d;
	}
	cout << abs(min) << endl;
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	string s;
	cin >> s;
	int l = s.length();
	string ans;
	for (int i = 0; i < l; i += 2) {
		ans += s[i];
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main()
{
    long A,B;
    cin >>A>>B;
    long l,r;

    if(A>B)
    {
        l=B;
        r=A; 
    }
    else
    {
        r=B;
        l=A; 
    }

    long mid; 
    
    while(l<=r)
    { 
        mid = l+ (r-l)/2;
        //cout<<"mid " <<mid<<endl; 
        
        if(abs(A-mid)==abs(B-mid))
        {
            cout<<mid<<endl;
            return 0; 
        }
        else if(abs(A-mid)>abs(B-mid))
        {
            r=mid-1;
        }
        else if(abs(A-mid)<abs(B-mid))
        {
            l=mid+1; 
        }
    }
    cout<< "IMPOSSIBLE" <<endl; 

    return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int k,s{9};
    in>>k;
    vector<ll> v(9),vv;
    iota(v.begin(),v.end(),1);
    while(s<k){
        vv.clear();
        for(auto&i:v){
            if(i%10) vv.emplace_back(i*10+i%10-1);
            vv.emplace_back(i*10+i%10);
            if(i%10<9) vv.emplace_back(i*10+i%10+1);
        }
        s+=vv.size();
        v.swap(vv);
    }
    s-=v.size();
    cout<<v[k-s-1]<<endl;
}

Measured memory_bytes: 1880
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template<typename t1, class t2>
void input(t1 count,t2 array) {
	for(t1 i = 0;i < count;i++) {
		cin >> array[i];
	}
}

template<typename t1, class t2>
void output(t1 count,t2 array) {
	for(t1 i = 0;i < count;i++) {
		cout << array[i];
		if(i != count - 1) cout << " ";
	}
	cout << endl;
}

constexpr double rate = 1.0 / (2 * sqrt(3));

void dfs(double x1,double y1,double x2,double y2,int depth) {
	if(depth == 0) {
		cout << setprecision(10) << x1 << " " << y1 << endl;
	}
	else {
		double x[5],y[5];
		x[0] = x1; y[0] = y1;
		x[1] = (x1 * 2 + x2) / 3; y[1] = (y1 * 2 + y2) / 3;
		x[4] = x2; y[4] = y2;
		x[3] = (x2 * 2 + x1) / 3; y[3] = (y2 * 2 + y1) / 3;
		x[2] = (x1 + x2) / 2 + (y1 - y2) * rate;
		y[2] = (y1 + y2) / 2 + (x2 - x1) * rate;
		for(int i = 0;i < 4;i++) dfs(x[i],y[i],x[i+1],y[i+1],depth-1);
	}
}

int main(void) {
	int n;
	cin >> n;
	dfs(0,0,100,0,n);
	cout << setprecision(10) << "100.0 0.0" << endl;
}



Measured memory_bytes: 3280
s = gets.chomp.split("").map(&:to_i)
def int(arr)
  sum = 0 
  r = 1 
  arr.reverse.each do |i| 
    sum += i * r 
    r *= 10
  end 
  sum 
end
dp = []
(0...s.length).each do |i| 
  sum = int(s[0..i])
  (1..i).each do |j| 
    sum += dp[j - 1] + (1 << j - 1) * int(s[j..i])
  end 
  dp[i] = sum 
end
puts dp[-1]

Measured memory_bytes: 1788
w = int(input())
n = int(input())
l = list(range(1,w+1))

for i in range(n):
  a, b = map(int, input().split(","))
  l[a-1], l[b-1] = l[b-1], l[a-1]
  
for i in range(w):
    print(l[i])


Measured memory_bytes: 5600
import java.util.Scanner;

/**
 * Main
 */
public class Main {

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

        int N = sc.nextInt();
        int M = sc.nextInt();

        int[] P = new int[M];
        String[] result = new String[M];

        for(int i=0; i<M; i++){
            P[i] = sc.nextInt();
            result[i] = sc.next();
        }

        int countAC = 0;
        int[] pena = new int[N];
        int countPena = 0;
        int[] clearFlg = new int[N];
        int[] answeredFlg = new int[N];
        for(int i=0; i < M; i++){
            if(answeredFlg[P[i]-1] == 0){
                answeredFlg[P[i]-1] = 1;
                if(result[i].equals("AC")){
                    countAC += 1;
                    clearFlg[P[i]-1] = 1;
                }else if(result[i].equals("WA")){
                    pena[P[i]-1] +=1;
                }
            }else if(answeredFlg[P[i]-1] == 1){
                if(result[i].equals("AC") && clearFlg[P[i]-1] == 0){
                    countAC += 1;
                    clearFlg[P[i]-1] = 1;
                    countPena += pena[P[i]-1];
                }else if(clearFlg[P[i]-1] == 0 && result[i].equals("WA")){
                    pena[P[i]-1] +=1;
                }
            }
        }
        System.out.println(countAC+" "+countPena);
    }
}

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

N, M, Q = inpl()
cumsum = [0]*((N+1)**2)
ans = [0]*((N+1)**2)

for i in range(M):
    L, R = inpl()
    cumsum[L*(N+1)+R] += 1

for l in range(1,N+1):
    for r in range(1,N+1):
        cumsum[l*(N+1)+r] += cumsum[(l-1)*(N+1)+r] + cumsum[l*(N+1)+r-1] - cumsum[(l-1)*(N+1)+r-1]

for l in range(1,N+1):
    for r in range(l,N+1):
        ans[l*(N+1)+r] = cumsum[r*(N+1)+r] - cumsum[(l-1)*(N+1)+r] - cumsum[r*(N+1)+l-1] + cumsum[(l-1)*(N+1)+l-1]

for i in range(Q):
    p, q = inpl()
    print(ans[p*(N+1)+q])

Measured memory_bytes: 19028
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e6+10;
int main()
{
    FASTINOUT;
    int a,b;
    cin>>a>>b;
    if (a==2 ||b==2)
        cout<<"No\n";
    else
        cout<<"Yes\n";
    return 0;
}


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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

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

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}    
const int N = 601;

char s[N][N];

int n;

int d[N][N][2]; 

bool check (int x, int y) {
  for (int k = 1; k <= 2*n - 1; k++) {
    if (k > 1) {
      if (k & 1)  x++; else y++;
    }    
    int minr = (min (k, 2*n - k) + 1) / 2;
    if (d[x][y][k & 1] < minr)
      return 0;               
  }
  return 1;
}
                   
int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> s[i][j];
      s[i][j + n] = s[i][j];
    }
  }    
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 2*n; j++)
      s[i + n][j] = s[i][j];

  for (int i = 1; i <= 2*n; i++) {  
    for (int j = 1; j <= 2*n; j++) {
      int r = 0;     
      while (1 <= i - r && i + r <= 2*n && 1 <= j - r && j - r <= 2*n && s[i - r][j + r] == s[i + r][j - r])
        r++;
      d[i][j][1] = r;
      r = 0;
      while (1 <= i - r && i + r + 1 <= 2*n && 1 <= j - r - 1 && j - r <= 2*n && s[i - r][j + r] == s[i + r + 1][j - r - 1])
        r++;
      d[i][j][0] = r;
    }    
  }
  int ans = 0;

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (check (i, j)) {
        ans++;
      }
    }     
  }                 
  cout << ans;
    
  return 0;
}






// Coded by Z..



Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<int,int> > p(M);//(終点、始点)のペア
  for(int i=0; i<M; i++){
    cin >> p[i].second >> p[i].first;
  }
  sort(p.begin(),p.end());//終点の順にソート
  /*for(int i=0; i<M; i++){
    cout << p[i].first << " " << p[i].second << endl;
  }*/
  int ans=0,x=0;
  for(int i=0; i<M; i++){//左から順に見ていく
    if(p[i].second >= x){//見ていない区間が見つかったら橋を架ける
      ans++;
      x = p[i].first;//今見た区間より始点が左にある区間はもう見ない
    }
    //cout << x << " " << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define ROF(i,a,b) for (int i = (b-1); i >= a; --i)
#define REP(i,a,b) for (int i = a; i <= b; ++i)
#define PER(i,a,b) for (int i = b; i >= a; --i)
#define F0R(i,b) FOR(i,0,b)
#define R0F(i,b) ROF(i,0,b)
#define R1P(i,b) REP(i,1,b)
#define P1R(i,b) PER(i,1,b)
using namespace std;

const int N = 1<<20;

int n, Q, V[N], w[N], ans[N];
vector<pair<int,int> > q[N], v[2];

void dfs(int u, int dep = 0) {
	sort(q[u].begin(), q[u].end());
	vector<pair<int,int> > old = v[dep>=9];
	FOR(i,0,(int)old.size()) {
		v[dep>=9].pb(mp(old[i].fi+w[u], old[i].se+V[u]));
	}
	sort(v[dep>=9].begin(), v[dep>=9].end());
//	printf("%d\n", u);
//	FOR(k,0,2) {
//		printf(" %d:\n", k);
//		FOR(i,0,(int)v[k].size()) cout << '\t' << v[k][i].fi << ' ' << v[k][i].se << endl;
//		cout << endl;
//	}
	FOR(k,0,(int)q[u].size()) {
		int pt = 0, mx = 0;
		ROF(i,0,(int)v[0].size()) {
			if (v[0][i].fi > q[u][k].fi) continue;
			while (pt+1 < (int)v[1].size() && v[1][pt+1].fi+v[0][i].fi <= q[u][k].fi) ++pt, mx = max(mx, v[1][pt].se);
			ans[q[u][k].se] = max(ans[q[u][k].se], mx+v[0][i].se);
		}
	}
	FOR(i,0,2) if (2*u+i <= n) dfs(2*u+i, dep+1);
	v[dep>=9] = old;
}

signed main() {
	cin >> n;
	FOR(i,1,n+1) cin >> V[i] >> w[i];
	int Q;
	cin >> Q;
	FOR(i,0,Q) {
		int u, l;
		cin >> u >> l;
		q[u].pb(mp(l, i));
	}
	FOR(i,0,2) v[i].pb(mp(0,0));
	dfs(1);
	FOR(i,0,Q) cout << ans[i] << endl;
}


Measured memory_bytes: 33772
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long
#define MAX 25 * 1e13
#define N  200010

#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define EB(X) emplace_back(X)
#define REP(i,a) for(int i=0;i<(a);++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
#define VI vector<int>;

using namespace std;
int MOD = 1000000007;

char s[20];
int dfs(int k,int n,int maxc){
  if( k == n ){
      printf("%s\n",s);
      return 0;
  }
  int len = s[k-1] - 'a' + 1;
  for( int i = 0 ; i <= maxc; i++ ){
    s[k] = ( 'a' + i );
    if( i == maxc) dfs(k+1,n,maxc+1);
    else dfs(k+1,n,maxc);
  }
  return 0;
  
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  s[0] = 'a';
  dfs(1,n,1);
  return 0;
}



Measured memory_bytes: 1536
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

struct Edge{
  int to, cost;

  Edge(int t, int c): to(t), cost(c)
  {}
  bool operator>(const Edge& rhs) const{
	return cost > rhs.cost;
  }
};

typedef vector< vector<Edge> > Graph;

int N, M, L, K, A, B;
int prv[101];
int ans = 123456789;
Graph g;
vector<bool> lb;
int shortest[101][101];
int dfs(int now, int ttl, int cost){
  if(ans <= cost) return -1;
  if(lb[now]){
	ttl = M;	
	if(shortest[ttl][now] <= cost) return -1;
	shortest[ttl][now] = cost;
  }
  
  if(ttl < 0) return -1;
  if(now == B){
	cost += max(0, cost - M);
	ans = min(ans, cost);
	return cost;
  }

  for(auto& e: g[now]){
	int ttl_ = ttl - e.cost;
	int cost_ = cost+e.cost;
	if(ttl_ < 0 || shortest[ttl_][e.to] <= cost_) continue;
	prv[e.to] = now;
	shortest[ttl_][e.to] = cost_;
	dfs(e.to, ttl_, cost_);
  }
}

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

  while(cin>>N>>M>>L>>K>>A>>B, N){
	VI dp(N, 0);
	lb.assign(N, false);
	fill((int*)shortest, (int*)shortest+101*101, 123456789);
	REP(i,L){
	  int x; cin >> x;
	  lb[x] = true;
	}
	ans = 123456789;
	g.assign(N, vector<Edge>());
	REP(i,K){
	  int a, b, t; cin >> a >> b >> t;
	  g[a].PB(Edge(b,t));
	  g[b].PB(Edge(a,t));
	}
	dfs(A, M, 0) ;
	if(ans >= 123456789) cout << "Help!" << endl;
	else cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1384
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define isvisiblechar(c) (0x21 <= (c) && (c) <= 0x7E)
#define cin scanner
#define cout printer
namespace {
class MaiScanner {
  public:
    template <typename T> void input_integer(T &var) {
        var = 0;
        T sign = 1;
        int cc = getchar_unlocked();
        for (; cc < '0' || '9' < cc; cc = getchar_unlocked())
            if (cc == '-')
                sign = -1;
        for (; '0' <= cc && cc <= '9'; cc = getchar_unlocked())
            var = (var << 3) + (var << 1) + cc - '0';
        var = var * sign;
    }
    inline int c() { return getchar_unlocked(); }
    inline MaiScanner &operator>>(int &var) {
        input_integer<int>(var);
        return *this;
    }
    inline MaiScanner &operator>>(long long &var) {
        input_integer<long long>(var);
        return *this;
    }
    inline MaiScanner &operator>>(string &var) {
        int cc = getchar_unlocked();
        for (; !isvisiblechar(cc); cc = getchar_unlocked())
            ;
        for (; isvisiblechar(cc); cc = getchar_unlocked())
            var.push_back(cc);
        return *this;
    }
    template <typename IT> void in(IT begin, IT end) {
        for (auto it = begin; it != end; ++it)
            *this >> *it;
    }
};
class MaiPrinter {
  public:
    template <typename T> void output_integer(T var) {
        if (var == 0) {
            putchar_unlocked('0');
            return;
        }
        if (var < 0)
            putchar_unlocked('-'), var = -var;
        char stack[32];
        int stack_p = 0;
        while (var)
            stack[stack_p++] = '0' + (var % 10), var /= 10;
        while (stack_p)
            putchar_unlocked(stack[--stack_p]);
    }
    inline MaiPrinter &operator<<(char c) {
        putchar_unlocked(c);
        return *this;
    }
    inline MaiPrinter &operator<<(int var) {
        output_integer<int>(var);
        return *this;
    }
    inline MaiPrinter &operator<<(long long var) {
        output_integer<long long>(var);
        return *this;
    }
    inline MaiPrinter &operator<<(char *str_p) {
        while (*str_p)
            putchar_unlocked(*(str_p++));
        return *this;
    }
    inline MaiPrinter &operator<<(const string &str) {
        const char *p = str.c_str();
        const char *l = p + str.size();
        while (p < l)
            putchar_unlocked(*p++);
        return *this;
    }
    template <typename IT> void join(IT begin, IT end, char sep = ' ') {
        for (bool b = 0; begin != end; ++begin, b = 1)
            b ? *this << sep << *begin : *this << *begin;
    }
};
} // namespace
MaiScanner scanner;
MaiPrinter printer;

int main(void) {
    int N, cnt = 0;
    cin >> N;

    REP(i, 26) REP(j, 16) {
        if (4 * i + 7 * j == N)
            cnt++;
    }
    cout << (cnt > 0 ? "Yes" : "No") << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long

int comp(const void *a, const void *b)
{ //昇順
    return *(int *)a - *(int *)b;
}

int main(void)
{
    int n, k;
    int p[1002];
    int i, j, ans;
    ans = 0;
    scanf("%d %d", &n, &k);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &p[i]);
    }
    qsort(p, n, sizeof(int), comp);
    for (i = 0; i < k; i++)
    {
        ans += p[i];
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1748
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
	  //もちの枚数
      int n = sc.nextInt();
      //もちの直径
      Set<Integer> num = new HashSet<>();
      for(int i = 0; i < n; i++){
        int di = sc.nextInt();
        num.add(di);
      }
      System.out.println(num.size());
      
    }
}

Measured memory_bytes: 23508
// B.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1e5 + 200;

int n, k;

int main()
{
    scanf("%d%d", &n, &k);
    int ans = 0, tmp;
    while (n--)
        scanf("%d", &tmp), ans += (tmp >= k);
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	const double PI = 3.14159265358979;
	double a, b, x; cin >> a >> b >> x;
	double lo = 0., hi = 90.;
	for (int i = 0; i < 10000; i++) {
		double mid = lo + (hi - lo) / 2.;
		double theta = (90 - mid) / 180 * PI;
		double r = sqrt(2*x / (a * tan(theta)));
		double t = r * tan(theta);
		if (t > a) {
			double k = t - a;
			double v = a * k * k / tan(theta) / 2;
			double u = v / (a * a);
			r += u;
		}
		if (r > b) hi = mid;
		else lo = mid;
	}
	printf("%.15f\n", lo);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = INT_MAX-5;
int filter(int x) {return (x < 0? INF:x);}
int main(){
  int x,y;
  cin >> x >> y;
  cout << min({filter(y-x), filter(y-(-x))+1, filter((-y)-x)+1, filter((-y)-(-x))+2}) << endl;
}

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

using namespace std;

int main()
{

    int n, d;
    int ans = 0, num;

    cin >> n >> d;

    num = d * 2 + 1;

    while (n > 0) {
        n -= num;
        ans++;
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
program both_sides_merger
  implicit none
  integer :: n, i, j, k, x, w(1000)
  integer(8) :: a(1000), odd, evn, m
  w = 0
  a = 0_8
  odd = 0_8
  evn = 0_8
  read(*,*) n
  read(*,*) a(1:n)
  do i = 1, n
    if (a(i).gt.0_8) then
      if (mod(i,2).eq.1) then
        odd = odd+a(i)
      else
        evn = evn+a(i)
      end if
    end if
  end do
  if (odd.eq.0_8.and.evn.eq.0_8) then
    j = maxloc(a(1:n),1)
    write(*,'(i0)') a(j)
    write(*,'(i0)') n-1
    do i = n, j+1, -1
      write(*,'(i0)') i
    end do
    do i = 1, j-1
      write(*,'(i0)') 1
    end do
    stop
  end if
  write(*,'(i0)') max(odd,evn)
  k = n
  x = 0
  if (evn.gt.odd) then
    a(1:k-1) = a(2:k)
    k = k-1
    x = x+1
    w(x) = 1
  end if
  do while (k.gt.1)
    if (k.eq.2) then
      k = k-1
      x = x+1
      w(x) = 2
      cycle
    end if
    if (a(1).lt.0_8) then
      a(1:k-2) = a(3:k)
      k = k-2
      x = x+2
      w(x-1:x) = 1
      cycle
    end if
    if (a(3).ge.0_8) then
      a(3) = a(1)+a(3)
      a(1:k-2) = a(3:k)
      k = k-2
      x = x+1
      w(x) = 2
      cycle
    end if
    if (k.eq.3) then
      k = k-1
      x = x+1
      w(x) = 3
      cycle
    end if
    a(4) = a(2)+a(4)
    a(2:k-2) = a(4:k)
    k = k-2
    x = x+1
    w(x) = 3
  end do
  write(*,'(i0)') x
  do i = 1, x
    write(*,'(i0)') w(i)
  end do
  stop
end program both_sides_merger

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int Maxn=5010;
const int inf=0x3f3f3f3f;
struct node{int x,y,next;}edge[1010]; int len,first[1010];
void ins(int x,int y){len++; edge[len].x=x; edge[len].y=y; edge[len].next=first[x]; first[x]=len;}
int dp[1010]; int N; int X[1010]; int G[Maxn],F[1010][Maxn];
void Dfs(int x,int f)
{
  int s=0; for(int k=first[x];k!=-1;k=edge[k].next)
  {
    int y=edge[k].y;
    if(y==f) continue;
    else s++;
  }
  if(s==0){dp[x]=0; return ;}

  memset(F[x],63,sizeof(F[x])); F[x][0]=0; dp[x]=inf;
  for(int k=first[x];k!=-1;k=edge[k].next)
  {
    int y=edge[k].y;
    if(y==f) continue;
    Dfs(y,x);
    for(int i=0;i<=X[x];i++) G[i]=inf;
    for(int i=0;i<=X[x];i++) if(F[x][i]<inf)
    {
      if(i+dp[y]<=X[x]) G[i+dp[y]]=min(G[i+dp[y]],F[x][i]+X[y]);
      if(i+X[y]<=X[x]) G[i+X[y]]=min(G[i+X[y]],F[x][i]+dp[y]);
    }
    for(int i=0;i<=X[x];i++) F[x][i]=G[i];
  }
  for(int i=0;i<=X[x];i++) dp[x]=min(dp[x],F[x][i]);
}
int main()
{
  scanf("%d",&N); len=0; memset(first,-1,sizeof(first));
  for(int i=2;i<=N;i++){int x; scanf("%d",&x); ins(x,i);}
  for(int i=1;i<=N;i++) scanf("%d",&X[i]);
  Dfs(1,0);
  if(dp[1]==inf) printf("IMPOSSIBLE\n");
  else printf("POSSIBLE\n");
  return 0;
}

Measured memory_bytes: 19328
def main():
    import sys
    input = sys.stdin.readline
    
    s = input()[:-1]
    n = len(s)
    arr = [0] * n
    for i in range(n - 1):
        if s[i] == 'R' and s[i + 1] == 'L':
            arr[i] = arr[i + 1] = -1
            j = i - 1
            while j >= 0 and s[j] == 'R':
                arr[j] = i
                j -= 1
            j = i + 2
            while j < n and s[j] == 'L':
                arr[j] = i + 1
                j += 1
    
    ans = [0] * n
    for i in range(n):
        if arr[i] == -1:
            ans[i] += 1
        else:
            d = abs(i - arr[i])
            if d & 1:
                if s[arr[i]] == "L":
                    ans[arr[i] - 1] += 1
                else:
                    ans[arr[i] + 1] += 1
            else:
                ans[arr[i]] += 1
    
    print(*ans)
    
    return 0

main()

Measured memory_bytes: 8704
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
        System.out.println(Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
    }
}


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

int main(){
  int N,K,i,x;
  cin >> N >> K;
  i = 0;
  x = 1;
  while (x < K and i < N){
    x*=2;
    i++;
  }
  for(int j =i; j<N; j++){
    x+=K;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <numeric>
using namespace std;


int main(){
    char C[3][3];

    for(int i = 0;i<3;i++){
        for(int j = 0;j<3;j++){
            cin >> C[i][j];
        }
    }

    cout << C[0][0] << C[1][1] << C[2][2] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<vector>
#include<climits>
#define ll long long int
using namespace std;
int main(void) {
  int a[55556];
  for(int i=0; i<55556; i++) {
    a[i]=1;
  }
  a[0]=0;
  a[1]=0;
  for(ll i=2; i<55556; i++) {
    if(a[i]==1) {
      for(ll j=i; j<55556 and i*j<55556; j++) {
	a[i*j]=0;
      }
    }
  }
  int p[55];
  int ans=0;
  for(int i=2; ans<55; i++) {
    if(a[i]==1 and i%5==1) {
      p[ans]=i;
      ans++;
    }
  }
  int n;
  cin>>n;
  for(int i=0; i<n; i++) {
    cout<<p[i]<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e9)
using namespace std;
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
std::vector<ll> enum_div(ll n)//nの約数を列挙
{
	std::vector<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    vector<ll> rr = enum_div(M);
    rr.push_back(M);
    ll ans = 0;
    for(auto i :rr){
        ll ans_tmp = i;
        ll val = M/i;
        if(val >= N){
            ans = max(ans, ans_tmp);
        }
    }
    print(ans);


    //ll l = -1;
    //ll r = 1e12;
    //ll val[100010] = {};
    //ll a = 2;
    //ll m = M;
    //while(a * a <= M){
    //    while(m % a == 0){
    //        m /= a;
    //        val[a]++;
    //    }
    //    a++;
    //}
    //ll ans = 0;
    //if(m != 1){
    //    ll num = M/m;
    //    if(num >= N){
    //        ans = m;
    //    }
    //}
    //rep(i,0,100010){
    //    if(val[i] != 0){
    //        print(i);
    //    }
    //}
    //rep(i,0,100010){
    //    ll n = i;
    //    if(val[n] != 0){
    //        ll num = M/n;
    //        if(num >= N){
    //            ans = max(ans, n);
    //        }
    //    }

    //}
    //print(ans);

}


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

namespace PaizaSkillCheck
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            int n = int.Parse(line[0]);
            int m = int.Parse(line[1]);

            int nm1 = n - 1 + m;

            Tree[] trees = new Tree[n];
            Tree.trees = trees;
            for (int i = 0; i < trees.Length; i++)
            {
                trees[i] = new Tree(i);
            }

            for (int i = 0; i < nm1; i++)
            {
                line = Console.ReadLine().Split(' ');

                int from = int.Parse(line[0]) - 1;
                int to = int.Parse(line[1]) - 1;

                trees[to].parentList.Add(from);
            }

            foreach (Tree t in trees)
            {
                t.TreeDepth();
                Console.WriteLine(t.parent);
            }

            Console.ReadLine();
        }

        public class Tree
        {
            public static Tree[] trees;

            public int depth;
            public int index;
            public bool done;
            public int parent;
            public List<int> parentList;

            public Tree(int index)
            {
                this.index = index;
                this.parentList = new List<int>();
            }

            public int TreeDepth()
            {
                if (this.done) return this.depth;
                if (this.parentList.Count == 0) return 0;

                foreach (int t in this.parentList)
                {
                    int d = trees[t].TreeDepth() + 1;
                    if(this.depth < d)
                    {
                        this.depth = d;
                        this.parent = (t + 1);
                    }
                }

                this.done = true;

                return this.depth;
            }
        }
    }

}


Measured memory_bytes: 36608
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll a[10000005];
ll sol[10000005];
int main(){
    
    ll n;
    cin>>n;
    a[1]=1;
    for(ll i=1;i<=n;i++){
    	if(a[i]==0){
    	for(ll j=i;j<=n;j+=i)
    	a[j]=i;
		}
	}
	sol[1]=1;
	ll ans=1;
	for(ll i=2;i<=n;i++){
		ll c=0;
		ll k=i;
		while(k%a[i]==0){
			k/=a[i];
			c++;
		}
		
		sol[i]=sol[k]*(c+1ll);
	
		ans+=i*sol[i];
		
	}
	cout<<ans;
	 
	
}
    


	
	
    



Measured memory_bytes: 159868
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0) {
				break;
			}
			StringBuilder sb1 = new StringBuilder();
			StringBuilder sb2 = new StringBuilder();
			for(int i = 0; i < W; i++) {
				sb1.append("#");
				if(i == 0 || i == W - 1) {
					sb2.append("#");
				}else {
					sb2.append(".");
				}
			}
			for(int i = 0; i < H; i++) {
				if(i == 0 || i == H - 1) {
					System.out.println(sb1.toString());
				}else {
					System.out.println(sb2.toString());
				}
			}
			System.out.println();
		}
		scan.close();
	}
}


Measured memory_bytes: 27564
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == T.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll N, K;
    cin >> N >> K;
    vec a(N);
    Rep (i, N) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    ll ok = N, ng = -1;
    while (abs(ok-ng) > 1) {
        ll mid = (ok+ng)/2;
        // cout << ok << " " << ng << "\n";
        vec dp(5010, 0);
        dp[0] = 1;
        Rep (i, N) {
            if (i == mid) continue;
            for (ll j = 5009; j >= 0; j--) {
                if (j+a[i] < 5010 and dp[j]) dp[j+a[i]] = 1;
            }
        }

        bool check = false;
        for (ll i = max<ll>(K-a[mid], 0); i < K; i++) {
            if (dp[i]) {
                check = true;
                break;
            }
        }

        if (check) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;
}

Measured memory_bytes: 3704
import math
#入力
N = int(input())
maxmembers={}
for i in range(5):
    maxmembers[i] = int(input())

#シミュレーション
'''
citypeople = [N,0,0,0,0,0]
flag = bool(False)
time = 0

for i in range(6):
    print(citypeople[i],end=' ')
print('')

while True:
    for i in reversed(range(1,6)):
        if citypeople[i-1] > maxmembers[i-1]:
            citypeople[i] += maxmembers[i-1]
            citypeople[i-1] -= maxmembers[i-1]
        else:
            citypeople[i] += citypeople[i-1]
            citypeople[i-1] = 0
    time += 1
    
    for i in range(6):
        print(citypeople[i],end=' ')
    print('')
    
    if citypeople[5] == N:
        break

print(time)
'''
#ボトルネックを全部に適用する
mintransportation = maxmembers[0]
for i in range(1,5):
    if maxmembers[i] < mintransportation:
        mintransportation = maxmembers[i]

    time = math.ceil(N / mintransportation) + 4
print(time)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  unordered_map<int, int> um{};
  REP(i, N) cin >> A[i], um[A[i]]++;
  int tmp = 0;
  for (auto s : um) {
    if (s.second >= 2) {
      tmp += s.second - 1;
    }
  }
  if (tmp % 2 == 0) {
    cout << N - tmp << endl;
  } else {
    cout << N - tmp - 1 << endl;
  }
}

Measured memory_bytes: 7520
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const int OFF = 13000;

signed main(){
    int N;
    cin >> N;
    vector<int> P(N), Q(N);

    for (int i = 0; i < N; ++i) cin >> P[i];
    for (int i = 0; i < N; ++i) cin >> Q[i];

    if (P > Q) swap(P, Q);

    int res = 0;
    while(true) {
        if (P == Q) break;
        ++res;
        next_permutation(ALL(P));
    }

    cout << res << endl;
}


Measured memory_bytes: 256
from fractions import gcd

N, M = tuple(int(i) for i in input().split())
S = input()
T = input()

lcm = N * M // gcd(N, M)
min_s = min((N, M))
S_ = S[::lcm//M]
T_ = T[::lcm//N]

if S_ == T_:
    print(lcm)
else:
    print(-1)


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  bool ans = false;
  for (int i = 0; i <= n / 4; ++i) {
    if ((n - i * 4) % 7 == 0) {
      ans = true;
      break;
    }
  }

  cout << (ans ? "Yes" : "No") << '\n';
  return 0;
}

Measured memory_bytes: 3632
using System;

namespace oasobi
{
    static class MainClass
    {
        public static void Main()
        {
            string input = Console.ReadLine();

            if(input == "AAA" | input == "BBB")
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }
}

Measured memory_bytes: 13140
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

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

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


#line 2 "abc162_f.cpp"

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

  int n;
  cin >> n;
  int m = n / 2;
  vl a(n);
  REP(i, n) { cin >> a[i]; }

  if (n % 2 == 0) {
    vector<ll> left(m, -1e10), right(m, -1e10);
    left[0] = a[0];
    right[0] = a[1];
    FOR(i, 1, m) {
      left[i] = left[i - 1] + a[2 * i];
      right[i] = max(right[i - 1], left[i - 1]) + a[2 * i + 1];
    }
    cout << max(left[m - 1], right[m - 1]) << endl;
  } else {
    vector<ll> left(m, -1e10), right(m, -1e10), center(m, -1e10);
    left[0] = a[0];
    center[0] = a[1];
    right[0] = a[2];

    FOR(i, 1, m) {
      left[i] = left[i - 1] + a[2 * i];
      center[i] = max(left[i - 1], center[i - 1]) + a[2 * i + 1];
      right[i] = max({left[i - 1], center[i - 1], right[i - 1]}) + a[2 * i + 2];
    }
    cout << max({left[m - 1], center[m - 1], right[m - 1]}) << endl;
  }
}


Measured memory_bytes: 7144
#include <iostream>

using namespace std;

int main()
{
  const int lastBill = 4280;
  const int basicBill = 1150;
  int bill;
  int w;
  
  while (1) {
    cin >> w;
    if (w == -1) break;
    if (w <= 10) {
      bill = basicBill;
    } else if (w <= 20) {
      bill = basicBill + (w - 10) * 125;
    } else if (w <= 30) {
      bill = basicBill + 1250 + (w - 20) * 140;
    } else {
      bill = basicBill + 1250 + 1400 + (w - 30) * 160;
    }

    cout << lastBill - bill << endl;
  }
}
    



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

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

  return 0;
}



Measured memory_bytes: 3108
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

using namespace std;

typedef long long LL;

struct edge {
	int to;
	int cost;
};

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

int main(void) {
	int n, x;
	cin >> n >> x;
	vector<int>a(n + 1);
	for (int i = 0; i < n; i++)cin >> a[i];
	a[n] = x;
	sort(a.begin(), a.end());
	LL ans = a[1] - a[0];
	for (int i = 1; i <= n; i++) {
		ans = gcd(ans, a[i] - a[i - 1]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 640