akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    ll n,m,ans=1;
	cin >> n >> m;

	vint oka(n+2,true);
	int a;
	rep(i,m){
		cin >> a;
		oka[a] = false;
	}

	vector<ll> d(n+2,0);
	d[0] = 1;
	rep(i,n){
		if(oka[i+1]){
			d[i+1] += d[i];
			d[i+1] %= 1000000007;
		}
		if(oka[i+2]){
			d[i+2] += d[i];
			d[i+2] %= 1000000007;
		}
	}

	cout << d[n] << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
	int n,m;
	int d[200005] = {},t[200005] = {};

	cin >> n;
	rep(i,0,n)cin >> d[i];
	cin >> m;
	rep(i,0,m)cin >> t[i];

	sort(d,d+n);
	sort(t,t+m);

    int dd = 0,tt = 0;
	while(1){
        if(d[dd] == t[tt]){
            dd++;
            tt++;
            if(tt >= m)break;
            if(dd >= n){
                NO;
                ret 0;
            }
        }else if(d[dd] < t[tt]){
            dd++;
            if(dd >= n){
                NO;
                ret 0;
            }
        }else{
            NO;
            ret 0;
        }
	}
	YES;

	return  0;
}

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

using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	if(a+b>a-b && a+b>a*b)
		cout<<a+b<<endl;
	else if(a*b>a-b && a*b>a+b)
		cout<<a*b;
	else
		cout<<a-b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define se second
#define fi first
#define rep(i, l, r) for (ll i = (ll)(l); i < (ll)(r); i++)
#define print(v) for (const auto itr : v){cout << itr << ' ';} cout << endl;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define inf 1e18
using namespace std;
const ll INF = 1e18L + 5;
const ll maxn = 1e5+5, maxn1=202;
ll ceel(ll a, ll b)
{
   if (a % b == 0)
       return a / b;
   return a / b + 1;
}
ll modneg(ll a,ll m)
{
    a = a % m;
    if(a<0)
        a=a+m;
    return a;
}
ll powermod(ll x, unsigned ll y, ll p){ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); };
ll csb(ll n){ ll count = 0;while (n){ count += n & 1; n >>= 1; } return count;}


int main()
{

ll t,i,j,k,n,m,a,b,x,y,u,temp;
cin>>a>>b>>n;
n = min(b - 1, n);
cout<< (a * n) / b - a * (n / b) << endl;

return 0;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x7fffffff;
#define mp(a,b) make_pair(a,b)
int n;

int main(){
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<n;i++){
		ans+=(n-1)/i;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>

const long long INF = 1LL<<60;
const int inf = 1 << 30;
const int mod = 1e9+7;


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

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

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> maze(h);
  rep(i, 0, h){
    cin >> maze[i];
  }

  vector<vector<int>> dist(h, vector<int> (w, -1));
  queue<pair<int, int>> q;
  q.push({0, 0});

  dist[0][0] = 0;

  while(!q.empty()){
    int x = q.front().first;
    int y = q.front().second;

    q.pop();

    if (x == h-1 && y == w-1){
      break;
    }

    for (int k=0; k<4; k++){
      int nx = x + dx[k];
      int ny = y + dy[k];
      if (0<=nx && nx <h && 0<=ny && ny < w && dist[nx][ny] == -1 && maze[nx][ny] != '#'){
        q.push({nx, ny});
        dist[nx][ny] = dist[x][y] + 1;
      }
    }
  }
  if (dist[h-1][w-1] == -1){
    cout << -1 << endl;
    return 0;
  }
  int black = 0;
  rep(i, 0, h){
    rep(j, 0, w){
      if (maze[i][j] == '#'){
        black++;
      }
    }
  }
  int ans = h * w - black - (dist[h-1][w-1] + 1);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int H,W;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0){
            break;
        }
        int i,j;
        for(i=0;i<H;i++){
            for(j=0;j<W;j++){
                printf("#");
            }
        printf("\n");
    }
    printf("\n");
    }
    
    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll s;
	ll tmp=1000000000;
	cin >> s;
	ll x3=(tmp-s%tmp)%tmp;
	ll y3=(s+x3)/tmp;
	cout << 0 << " " << 0 << " " << tmp << " " << 1 << " " << x3 << " " << y3 << endl;
	return 0;
}

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

int main()
{
    int h, w, mine = 0;
    std::cin >> h >> w;
    char grid[h][w];
    char newgrid[h][w];
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++) { std::cin >> grid[i][j]; }
    }

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            mine = 0;
            if (grid[i][j] == '#')
            {
                newgrid[i][j] = '#';
                continue;
            }
            for (int a = -1; a <= 1; a++)
            {
                for (int b = -1; b <= 1; b++)
                {
                    
                    if (a == 0 && b == 0) { continue; }
                    if (i + a < 0 || h - 1 < i + a || j + b < 0 || w - 1 < j + b) { continue; }
                    if (grid[i + a][j + b] == '#') { mine++; }
                }
            }
            newgrid[i][j] = '0' + mine;
        }
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++) { std::cout << newgrid[i][j]; }
        std::cout << std::endl;
    }

    return 0;
}

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


typedef long long ll;

int N,M,H,W,K,A,B,S,T;
int a,b;

using namespace std;


int main() {
  cin >> N;
  ll ans = 0;
  vector<ll> a(N,0),b(N,0);
  for(int i =0;i < N;i++) cin >> a.at(i);
  sort(a.begin(),a.end());
  for(int i =0;i < N;i++){
    b.at(i) = a.at(i);
    if(a.at(i) < 0)b.at(i) = (-1) * a.at(i);
    ans += b.at(i);
  }
  sort(b.begin(),b.end());
  
  for(int i =0;i < N;i++) {
    //cout << a.at(i) << endl;
    if(a.at(i) >= 0){
      if(i%2 == 0) break;
      ans -= 2*b.at(0);
    }
    if(i%2 == 0 && i == N-1) ans -= 2*b.at(0);
  }
  
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
  char a[7],b[7];
  char *X;
  int x;
  int c;
  // 整数の入力
  scanf("%s %s", a, b);
  
  X = strcat(a, b);
  x = atoi(X);
  
  c = (int)sqrt((double)x);
  
  if (c * c == x) {
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}

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

int main(void){
		
  	int A,B,C;
  	cin >> A >> B >> C;
  	int sum = A+B+C;
  	if (sum >= 22) cout << "bust" << endl;
  	else cout << "win" << endl;
  	
  	
	return 0;
  
}

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	string s, t;
	cin >> s >> t;
	rep(i, s.size()) {
		if (s[i] != t[i]) {
			print("No");
			return 0;
		}
	}
	print("Yes");

}


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

using namespace std;

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

/*   点  */
struct Point{
    double x,y;

    Point(double x=0,double y=0):x(x),y(y){}

    Point operator + (Point p) { return Point(x+p.x,y+p.y); }
    Point operator - (Point p) { return Point(x-p.x,y-p.y); }
    Point operator * (double k) { return Point(k*x,k*y); }
    Point operator / (double k) { return Point(x/k,y/k); }

    //向量的大小
    double abs(){ return sqrt(norm()); }
    double norm() { return x*x+y*y; }

    bool operator < (const Point & p) const{
        return x!=p.x?x<p.x:y<p.y;
    }

    bool operator == (const Point & p) const {
        return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
    }
};

/*   向量  */
typedef Point Vector;

//向量a和b的内积
double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}
//向量a和b的外积
double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

/*   线段  */
struct Segment{
    Point p1,p2;
};

/*   直线  */
typedef Segment Line;

/* 直线正交
 * 判断向量a，b是否正交 =》a，b的内积为0
 */
bool isOrthogonal(Vector a,Vector b){
    return equals(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
    return isOrthogonal(a1-a2,b1-b2);
}

/* 直线平行
 * 判断向量a，b是否平行 =》a，b的内积为0
 */
bool isParallel(Vector a,Vector b){
    return equals(cross(a,b),0.0);
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
    return isParallel(a1-a2,b1-b2);
}

struct Circle{
    Point c;
    double r;
    Circle(Point c = Point() ,double r = 0.0 ):c(c),r(r){}
};

/*   多边形  */
typedef vector<Point> Polygon;

int main(){
    Point p1,p2;
    scanf("%lf%lf%lf%lf",&p1.x,&p1.y,&p2.x,&p2.y);
    int t;
    scanf("%d",&t);
    while(t--){
        Point p;
        scanf("%lf%lf",&p.x,&p.y);
        double k1=dot(p2-p1,p-p1);
        double k2=(p2-p1).abs();
        k1/=k2;
        Point ans=(p2-p1)*(k1/k2)+p1;
        ans=ans-p+ans;
        printf("%.10f %.10f\n",ans.x,ans.y);
    }
    return 0;
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n,K,q;

int ar[2005],zip[2005];
int main(){
  cin>>n>>K>>q;
  REP(i,n) cin>>ar[i],zip[i]=ar[i];

  int res=1e9+10;
  REP(i,n){
    int lb=-1,ub=1e9;
    while(ub-lb>1){
      int md=(lb+ub)>>1;
      int tot=0;
      REP(j,n) if(ar[j]>=ar[i]){
        int k=j;
        int cnt=0;
        while(k<n && ar[k]>=ar[i]){
          if(ar[k]<=ar[i]+md) ++cnt;
          ++k;
        }
        int len=k-j;
        dump(len);dump(cnt);
        if(len>=K-1){
          tot+=min(len-K+1,cnt);
        }
        j=k;
      }
      dump(tot);
      if(tot>=q) ub=md;
      else lb=md;
    }
    dump(ar[i]);
    dump(ub);
    chmin(res,ub);
  }
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int num,sum=0;
  char str[1001];
  int i=0,j=0;
  int *p;
  while(1){
    sum = 0;
    int a,b,c,d;
    scanf("%s", str);
    if (str[0]=='0') break;
    else{
      int i = 0;
      while(*(str + i) != 0 && i < 1000) {
	char c = *(str + i);
	num = c - '0';
	sum += num;
	i++;
      }
    
    printf("%d\n",sum);
    }
  }
  return 0;
}

Measured memory_bytes: 536
package main

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

func lib_PowInt64(x, y int64) int64 {
	return int64(math.Pow(float64(x), float64(y)))
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var X int64
	scanner.Scan()
	X, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	solve(X)
}
func solve(X int64) {
	for A := int64(0); A < 120; A++ {
		for B := int64(-120); B < 120; B++ {
			if lib_PowInt64(A, 5)-lib_PowInt64(B, 5) == X {
				fmt.Println(A, B)
				return
			}
		}
	}
}


Measured memory_bytes: 1756
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll W;
    cin >> n >> W;
    vector<ll> v(n), w(n);
    rep(i, n) {
        cin >> v[i] >> w[i];
    }

    map<ll, ll> dp;
    rep(i, 1<<(n/2)) {
        ll nowv = 0, noww = 0;
        rep(j, n/2) if((i>>j)&1) {
            nowv += v[j];
            noww += w[j];
        }
        dp[noww] = max(dp[noww], nowv);
    }

    ll hhh = 0;
    vector<pair<ll, ll> > ddp(dp.size());
    int i = 0;
    for(auto nn:dp) {
        hhh = max(hhh, nn.second);
        ddp[i++] = make_pair(nn.first, hhh);
    }

    
    ll ans = 0;
    rep(i, 1<<((n+1)/2)) {
        ll nowv = 0, noww = 0;
        rep(j, (n+1)/2) if((i>>j)&1) {
            nowv += v[j+n/2];
            noww += w[j+n/2];
        }
        if(noww > W) continue;
        vector<pair<ll, ll> >::iterator itr = upper_bound(all(ddp), make_pair(W-noww+1, ll(-1)));
        ans = max(ans, (--itr)->second+nowv);
        //cout << noww << ' ' << nowv << ' ' << itr->second << endl;
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 84688
using System;

namespace ABC098C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            char[] x = new char[N];
            var target = Console.ReadLine();
            for(int i=0;i<N;i++) x[i] = target[i];
            int max = 0;
            for(int i=1;i<N;i++){
                if(x[i] == 'E') max++;
            }
            int tmp = max;
            for(int i=1;i<N;i++){
                if(x[i] == 'E') tmp--;
                if(x[i-1] == 'W') tmp++;
                if(tmp < max) max = tmp;
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 13232
<?php

$stdins = array();
$stdin = "nope";
while(true){
    $stdin = trim(fgets(STDIN));
    if ($stdin == "") {
        break;
    }else{
        $stdins[] = $stdin;   
    }
}


// $args = explode("\n",$get);

$args = $stdins;

// var_dump($args);

$x_month = $args[0];
$y_base = $args[1];
$y_max = $args[2];
$y_l = $args[3];
$joy = $args[4];


$x_result = floor($joy) * $x_month;


if ($joy >= $y_max) {
    $y_over = ($joy - $y_max) * $y_l;
}else{
    $y_over = 0;
}

$y_result = $y_base + $y_over;

if ($x_result >= $y_result) {
    $result = $y_result;
}else{
    $result = $x_result;
}

print($result);

?>

Measured memory_bytes: 15232
/*****Enigma_27*****/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pll         pair<ll,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define endl		'\n'
#define ios        	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,i,j,k,l,t=0,flag=1,x,m,a[4]={0};
vector<int> v;
int main()
{   ios
    cin>>n;
    for(i=0;i<n;i++)
        cin>>x,a[x%4]++;
    if(a[2]>0) a[2]=1;
    k=a[1]+a[2]+a[3];
    if(a[0]<k-1) cout<<"No\n";
    else cout<<"Yes\n";

	return 0;
}



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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 62);
constexpr ll MOD = 1000000007;// 10^9+7

string calc(const vector<set<string>>& level, stack<string>& sent) {
	for (auto ops : level) {
		stack<string> res;
		while (!sent.empty()) {
			string top = sent.top(); sent.pop();
			if (ops.find(top) == ops.end()) {
				res.push(top);
			}
			else {
				ll l = stoll(res.top()); res.pop();
				ll r = stoll(sent.top()); sent.pop();
				if (top == "+")res.push(to_string(l + r));
				if (top == "-")res.push(to_string(l - r));
				if (top == "*")res.push(to_string(l * r));
			}
		}
		while (!res.empty()) {
			sent.push(res.top());
			res.pop();
		}
	}
	if (sent.size() != 1)exit(1);
	return sent.top();
}

vector<string> separater(string q) {
	vector<string> res;
	string now;
	for (char c : q) {
		if (isalnum(c)) {
			now += c;
		}
		else {
			if (!now.empty()) {
				res.push_back(now);
				now = "";
			}
			res.push_back({ c });
		}
	}
	if (!now.empty())res.push_back(now);
	return res;
}

ll solve(vector<string> vs, vector<set<string>>& level) {
	stack<string> st;
	for (string s : vs) {
		if (s == ")") {
			stack<string> sent;
			while (true) {
				string top = st.top(); st.pop();
				if (top == "(")break;
				sent.push(top);
			}
			st.push(calc(level, sent));
		}
		else {
			st.push(s);
		}
	}
	stack<string> op;
	while (!st.empty()) {
		op.push(st.top());
		st.pop();
	}
	return stoll(calc(level, op));
}

int main()
{
	string s;
	cin >> s;
	auto vs = separater(s);

	vector<vector<set<string>>> levels = {
		// 1
		{{"+"},{"-"},{"*"}},
		{{"+"},{"*"},{"-"}},
		{{"-"},{"+"},{"*"}},
		{{"-"},{"*"},{"+"}},
		{{"*"},{"+"},{"-"}},
		{{"*"},{"-"},{"+"}},
		// 2
		{{"+"},{"-","*"}},
		{{"-"},{"+","*"}},
		{{"*"},{"+","-"}},
		{{"+","-"},{"*"}},
		{{"+","*"},{"-"}},
		{{"-","*"},{"+"}},
		// 3
		{{"+","-","*"}},
	};

	ll res = solve(vs, levels.front());
	FOR(i, 1, levels.size()) {
		res = max(res, solve(vs, levels[i]));
	}
	cout << res << endl;
	return 0;
}



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

// Union-Find
class DisjointSet {
public:
  vector<int> p, rank, size;
  int group_num;
  DisjointSet(int n) {
    p.assign(n, 0);
    rank.assign(n, 0);
    size.assign(n, 0);
    group_num = n;
    for (int i = 0; i < n; i++) {
      make_set(i);
    }
  }
 
  void make_set(int x) {
    p[x] = x;
    rank[x] = 0;
    size[x] = 1;
  }
 
  bool same(int x, int y) {
    return find_set(x) == find_set(y);;
  }
 
  int find_set(int x) {
    if (x != p[x]) {
      p[x] = find_set(p[x]);
    }
    return p[x];
  }
 
  int union_size(int x) {
    if (x != p[x]) {
      size[x] = union_size(find_set(x));
    }
    return size[x];
  }
 
  void link(int x, int y) {
    if(rank[x]  > rank[y]) {
      p[y] = x;
      size[x] = size[x] + size[y];
    }else if(rank[x] < rank[y]){
      p[x] = y;
      size[y] = size[x] + size[y];
    }else if(x != y) {
      p[y] = x;
      rank[x]++;
      size[x] = size[x] + size[y];
    }
  }
 
  void unite(int x, int y) {
    if (find_set(x) != find_set(y)) group_num--;
    link(find_set(x), find_set(y));
  }
};


int main() {
    int N, M;
    cin >> N >> M;
    int A[M], B[M];
    DisjointSet ds(N);
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
        ds.unite(A[i], B[i]);
    }
    cout << ds.group_num - 1 << "\n";
    return 0;
}

Measured memory_bytes: 5108
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int parent[100005];
int siz[100005];

int root(int x) {
  if(parent[x]==x) return x;
  else return parent[x] = root(parent[x]);
}

void unite(int a, int b) {
  a = root(a);
  b = root(b);
  if(siz[a]<siz[b]) swap(a, b);
  parent[b] = a;
  siz[a] += siz[b];
  return;
}

int main() {
  int N, M;
  cin>>N>>M;
  for(int i=0;i<N;++i) {
    parent[i] = i;
    siz[i] = 1;
  }
  int A, B;
  for(int i=0;i<M;++i) {
    cin>>A>>B;
    A--;
    B--;
    unite(A, B);
  }
  vector<int> arr;
  map<int, int> amap;
  for(int i=0;i<N;++i) {
    if(amap[root(i)]==0) arr.push_back(root(i));
    amap[root(i)]++;
  }
  cout<<arr.size()-1<<endl;
}



Measured memory_bytes: 8288
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
int main(){
	lli h,w;
	cin>>h>>w;
	char mat[h][w];
	for(lli i=0;i<h;i++){
		for(lli j=0;j<w;j++)
		cin>>mat[i][j];
	}
	lli dp[h][w];
	for(lli i=0;i<h;i++){
		for(lli j=0;j<w;j++)
		dp[i][j]=0;
	}
	dp[0][0]=1;
	for(lli i=0;i<h;i++){
		for(lli j=0;j<w;j++){
			if(mat[i][j]=='.'){
				if(i-1>=0 && mat[i-1][j]=='.')
				dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
				if(j-1>=0 && mat[i][j-1]=='.')
				dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
			}
		}
	}
	cout<<dp[h-1][w-1];
	return 0;
}


Measured memory_bytes: 9088
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int MOD=1e9+7;
int main()
{
	int n; string s; cin>>n>>s;
	int dp[3001];
	dp[0]=1;
	int sum[3001];
	sum[0]=1;
	for(int i=1; i<n; i++){
		for(int j=0; j<=i; j++){
			if(s[i-1]=='<'){
				if(j>0) dp[j]=sum[j-1];
				else dp[j]=0;
			}else{
				if(j>0) dp[j]=(sum[i-1]-sum[j-1]+MOD)%MOD;
				else dp[j]=sum[i-1];
			}
		}
		sum[0]=dp[0];
		for(int j=1; j<=i; j++){
			sum[j]=(sum[j-1]+dp[j])%MOD;
		}
	}
	cout<<sum[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
f x = do
    let hour = div x 3600
    let minute = div (x - hour * 3600) 60
    let sec = x - hour * 3600 - minute * 60
    (show hour) ++ ":" ++ (show minute) ++ ":" ++ (show sec)

main = do
    x <- readLn ::IO Int
    putStrLn $f x


Measured memory_bytes: 3464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int K;
  cin >> K;
  int ab;
  ll ans = 0;
  for (int i = 1; i <= K; ++i) {
    for (int j = 1; j <= K; ++j) {
      ab = __gcd(i, j);
      for (int k = 1; k <= K; ++k) {
        ans += __gcd(ab, k);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int N = 14, INF = 1000000009;

int n, m;

int dp[1 << N];

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i < (1 << n); ++i)
        dp[i] = INF;
    while (m--)
    {
        int g, q;
        scanf("%d%d", &g, &q);
        int x = 0;
        while (q--)
        {
            int i;
            scanf("%d", &i);
            --i;
            x = (x | (1 << i));
        }
        for (int y = 0; y < (1 << n); ++y)
        {
            dp[(x | y)] = min(dp[(x | y)], dp[y] + g);
        }
    }
    if (dp[(1 << n) - 1] == INF)
        cout << -1 << endl;
    else
        cout << dp[(1 << n) - 1] << endl;
    return 0;
}


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

ll choose(ll n) {
  return n*(n-1)/2;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n) a[i]--;
  vector<int> cnt(n);
  rep(i,n) cnt[a[i]]++;
  ll tot = 0;
  rep(i,n) {
    tot += choose(cnt[i]);
  }
  rep(i,n) {
    ll ans = tot;
    ans -= choose(cnt[a[i]]);
    ans += choose(cnt[a[i]]-1);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4732
//I am so vegetable
//#define err
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define pb push_back
#define in insert
#define er erase
#define ct count
#define ep empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = acos(-1.0);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

const int N = 2e5+5;
int a[N];
int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
    #ifdef err
	double be = clock();
    #endif
    int n;cin>>n;
    _for(i,0,n)cin>>a[i];
    sort(a,a+n);
    ll ans = a[n-1];
    if(n==1)cout<<0;
    else{
        int cnt = 0;
        int ind = n-2;
        _rfor(i,n-3,-1){
            ans+=a[ind];
            ++cnt;
            if(cnt==2)ind--,cnt=0;
        }
        cout<<ans;
    }
    #ifdef err
	double en = clock();
    cout<<"time: "<<fixed<<setprecision(8)<<en-be;
    #endif
	return 0;
}

Measured memory_bytes: 4432
n = int(input())
h = list(map(int, input().split()))

count = 0
go = []

for i in range(0, n-1):
    if h[i] >= h[i+1]:
        count += 1
    else:
        go.append(count)
        count = 0

go.append(count)

print(max(go))

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

int main(){
  int N;
  cin >> N;
  
  int count = N;
  vector<string> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  for(int i = 0; i < N - 1; i++){
    if(vec.at(i) == vec.at(i + 1)){
      count--;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 9524
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

I dp[3001][3001];
vector<vector<P>> p(3001);
string s,t;

int rec(I i, I j, I n, string st){
  REP(k,p.at(n).size()){
    P p1=p.at(n).at(k);
    if (p1.first < i && p1.second < j){
      if (n == 1){
        string stt = st+s.at(p1.first-1);
        REV(stt);
        cout << stt << endl;
        return 0;
      }else{
        return rec(p1.first, p1.second, n-1, st+s.at(p1.first-1));
      }
    }
  }
}

int main(){
  cin >> s >> t;
  REP(i,s.size()){
    REP(j,t.size()){
      if (s.at(i) == t.at(j)){
        dp[i+1][j+1] = dp[i][j]+1;
        p.at(dp[i][j]+1).push_back(P(i+1,j+1));
      }else{
        if (dp[i][j+1] > dp[i+1][j]){
          dp[i+1][j+1] = dp[i][j+1];
        }else{
          dp[i+1][j+1] = dp[i+1][j];
        }
      }
    }
  }
  string an;
  I c=dp[s.size()][t.size()];
  rec(MAX,MAX,c,"");
  return 0;
}



Measured memory_bytes: 245760
#include<bits/stdc++.h>
#define mkp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itii;
int main()
{
	int n,k;
	cin>>n>>k;
	map<int,int> hs; 
	for(int i=0;i<k;i++)
	{
		int d;
		cin>>d;
		for(int j=0;j<d;j++)
		{
			int a;
			cin>>a;
			a--;
			hs[a]++;
		}
	}
	cout<<n-hs.size()<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pl;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef set<ll> sl;
typedef vector<ll> vl;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll &b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll &b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 500010;
ll num, ans=0, count=0, sum=0;

ll TOP(priority_queue<ll> &q) {
  num = q.top();
  q.pop();
  return num;
}

int main() {
  ll X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vl p(A), q(B), r(C);
  rep(i, A) cin >> p[i];
  rep(i, B) cin >> q[i];
  rep(i, C) cin >> r[i];
  
  sort(all(p), greater<ll>());
  sort(all(q), greater<ll>());
  
  pql choose;
  rep(i, X) choose.push(p[i]);
  rep(i, Y) choose.push(q[i]);
  rep(i, C) choose.push(r[i]);
  
  rep(i, X+Y) ans += TOP(choose);
  cout << ans << endl;
  return 0;
}

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

int d[1010], p[1010], q[1010];
int f[5010][5];

bool cant(int d, int p, int q, int r) {
  if (d == 1) {
    for (int i = 0; i < p; i++) {
      if (f[r][q + i]) return true;
    }
  } else {
    if (f[r][q]) return true;
  }
  return false;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    memset(f, 0, sizeof(f));
    for (int i = 0; i < n; i++) {
      cin >> d[i] >> p[i] >> q[i];
      q[i]--;
    }
    for (int i = 0; i < n; i++) {
      for (int j = 4999; ; j--) {
        if (j < 0 || cant(d[i], p[i], q[i], j)) {
          if (d[i] == 1) {
            for (int k = 0; k < p[i]; k++) {
              f[j + 1][q[i] + k] = 1;
            }
          } else {
            for (int k = 0; k < p[i]; k++) {
              f[j + 1 + k][q[i]] = 1;
            }
          }
          break;
        }
      }
      bool update = true;
      while (update) {
        update = false;
        for (int j = 0; j < 5000; j++) {
          bool kieru = true;
          for (int k = 0; k < 5; k++) {
            kieru &= f[j][k];
          }
          if (kieru) {
            update = true;
            for (int k = 0; k < 5; k++) {
              f[j][k] = 0;
            }
            for (int k = j; k < 5000; k++) {
              for (int l = 0; l < 5; l++) {
                swap(f[k][l], f[k + 1][l]);
              }
            }
          }
        }
      }
    }
    int ans = 0;
    for (int i = 0; i < 5000; i++) {
      for (int j = 0; j < 5; j++) {
        ans += f[i][j];
      }
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3260
from bisect import bisect_left
import sys
def input():
    return sys.stdin.readline()[:-1]
A,B,Q=map(int,input().split())
s=[int(input()) for i in range(A)]
t=[int(input()) for i in range(B)]
for i in range(Q):
    x=int(input())
    si=bisect_left(s,x)
    ti=bisect_left(t,x)
    a=[]
    if si and si!=A:
        sl=s[si-1]
        sr=s[si]
    elif si:
        sl=s[-1]
        sr=0
    else:
        sl=0
        sr=s[0]
    if ti and ti!=B:
        tl=t[ti-1]
        tr=t[ti]
    elif ti:
        tl=t[-1]
        tr=0
    else:
        tl=0
        tr=t[0]
    if sl and tl:
        a.append(x-min(sl,tl))
    if sr and tr:
        a.append(max(tr,sr)-x)
    if sl and tr:
        a.append(tr-x+tr-sl)
        a.append(x-sl+tr-sl)
    if sr and tl:
        a.append(x-tl+sr-tl)
        a.append(sr-x+sr-tl)
    print(min(a))

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<char, int>;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e18;
const int MOD = 1e9 + 7;

signed main(){
    int N; cin >> N;
    int time[5];
    int bn = N;
    REP( i, 5 ){
        cin >> time[i];
        chmin( bn, time[i] );
    }

    bn = ( N + bn - 1 ) / bn - 1;

    cout << bn + 5 << endl;
}


Measured memory_bytes: 256
/**
 *    Created By:  PeekyBlinders
 **/
#include <bits/stdc++.h>

using namespace std;

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define double long double
#define endl '\n'

signed main() {
    fio;
    int N; cin >> N;
    map<pair<int , int> , int> cnt;
    for(int i = 1; i <= N; i++) {
        vector<int> dig;
        int cur = i;
        while(cur > 0) {
            dig.push_back(cur % 10);
            cur /= 10;
        }
        int first = dig[0] , last = dig.back();
        cnt[{first , last}]++;
    }

    int answer = 0;
    for(int firstB = 0; firstB <= 9; firstB++) {
        for(int lastB = 0; lastB <= 9; lastB++) {
            int lastA = firstB , firstA = lastB;
            answer += cnt[{firstA , lastA}] * cnt[{firstB , lastB}];
        }
    }
    
    cout << answer << endl;
 
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  long a = 0;
  
  for (int i = 0; i < n; i++){
    if ((i + 1) % 5 != 0 && (i + 1) % 3 != 0){
      a += i + 1;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
int main()
{
    int N,d[10000];
    scanf("%d",&N);
    for(int i=0;i<N;i++) scanf("%d",&d[i]);
    int sum=0;
    for(int i=0;i<N;i++)
    for(int j=i+1;j<N;j++) sum+=d[i]*d[j];
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 128
/*解説AC.必勝パターンを定式化出来ないかと色々考えたものの、うまく思いつかなかった.
操作のたびに全体の石の数は減少する.Nimのイメージで"上手く操作をすれば状態AからBに必ず
遷移させることが出来る、かつBからはどうあがいてもAに転んでしまう。さらにAないしBが必勝・
必敗状態である"という条件を満たす状態の抽出に対する感性を研ぎ澄ましていく必要がある.(?)*/
#include<iostream>
using namespace std;

int main(){
    long long x, y;
    cin >> x >> y;
    cout << (abs(x-y) <= 1 ? "Brown" : "Alice") << endl;
    return 0;
}

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

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)


sum = 0
for i in range(1,K+1):
  for j in range(i+1,K+1):
    for k in range(j+1,K+1):
      sum = sum + 6*gcd(i,j,k)
      
for i in range(1,K+1):
  for j in range(i+1,K+1):
     sum = sum + 6*math.gcd(i,j)
      
sum = sum + K*(K+1)//2

print(sum)

Measured memory_bytes: 9632
#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;
typedef vector<vector<int> > Graph;
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; }


const ll INF = 1e16;

int main(){
    int n,m;
    cin >> n >> m;
    int L=0;
    int R=100010;
    rep(i,m){
        int l,r;
        cin >> l >>r;
        L=max(l,L);
        R=min(r,R);
    }
    if(R<L||n<R){
        cout << 0 << endl;
        return 0;
    }
    cout << min(n,R)-L+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
//#define local
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    int n,T,t,ans=0,mina,maxp=0,i,a[100010];
    cin>>n>>T;
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    mina=a[0];
    for(i=1; i<n; i++)
    {
        maxp=max(maxp,a[i]-mina);
        mina=min(mina,a[i]);
    }
    for(i=1,t=a[0]; i<n; i++)
    {
        if(a[i]-t==maxp) ans++;
        t=min(t,a[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n,a,b,c;
int l[10];

int main(){
	cin>>n>>a>>b>>c;
	REP(i,n)
		cin>>l[i];
	int ans=INF;
	for(int i=0;i<(1<<(2*n));i++){
		int p=0,q=0,r=0;
		int tans=-30;
		for(int j=0;j<n;j++){
			int z=((i>>(j*2))&3);
			if(z==1){
				p+=l[j];
				tans+=10;
			}else if(z==2){
				q+=l[j];
				tans+=10;
			}else if(z==3){
				r+=l[j];
				tans+=10;
			}
		}
		if(p==0||q==0||r==0)continue;
		tans+=(abs(p-a)+abs(q-b)+abs(r-c));
		//cout<<ans<<endl;
		ans=min(ans,tans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  string a, b;
  cin >> a >> b;
  reverse(ALL(a));
  if (a==b) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    int m,f,r;
	char a;
	while(true){
		cin>>m>>f>>r;
		if(m==-1&&f==-1&&r==-1)
			break;
		if(m+f>=80)
			a='A';
		if(m+f>=65&&m+f<80)
			a='B';
		if(m+f>=50&&m+f<65)
			a='C';
		if(m+f>=30&&m+f<50){
			a='D';
			if(r>=50)
				a='C';
		}
		if(m+f<30)
			a='F';
		if(m==-1||f==-1)
			a='F';
		cout<<a<<endl;
	}
	return 0;
}



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

using namespace std;

using ll = long long;
using vll = vector<ll>;

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

    int n;
    cin >> n;

    vector<int> v(n);
    for (int& e : v) cin >> e;

    int cur = 0;
    for (int e : v) {
        if (e == cur + 1) {
            cur++;
        }
    }

    cout << (cur == 0 ? -1 : (n - cur)) << '\n';
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>

typedef struct box{
	int par;//親の接点番号
	int left;//子（左）
	int right;//子（右）
} Node;

void preorder(Node *node,int par)
{
	printf(" %d",par);
	if(node[par].left!=-1) preorder(node,node[par].left);
	if(node[par].right!=-1) preorder(node,node[par].right);
}

void inorder(Node *node,int par)
{
	if(node[par].left==-1&&node[par].right==-1) {
		printf(" %d",par);
		return;
	}
	if(node[par].left!=-1) inorder(node,node[par].left);
	printf(" %d",par);
	if(node[par].right!=-1) inorder(node,node[par].right);
	
}

void postorder(Node *node,int par)
{
	if(node[par].left==-1&&node[par].right==-1) {
		printf(" %d",par);
		return;
	}
	if(node[par].left!=-1) postorder(node,node[par].left);
	if(node[par].right!=-1) postorder(node,node[par].right);
	printf(" %d",par);
}

int main(void)
{
	int i,j,n;
	int box,s;
	int par;
	Node *node;
	
	scanf("%d",&n);
	node=(Node*)malloc(sizeof(Node)*n);
	for(i=0;i<n;i++) node[i].par=-1;//親の節点番号を初期化
	for(i=0;i<n;i++){
		scanf("%d",&box);
		scanf("%d",&node[box].left);
		node[node[box].left].par=box;
		scanf("%d",&node[box].right);
		node[node[box].right].par=box;
	}
	for(i=0;i<n;i++) if(node[i].par==-1) par=i;
	printf("Preorder\n");
	preorder(node,par);
	printf("\nInorder\n");
	inorder(node,par);
	printf("\nPostorder\n");
	postorder(node,par);
	printf("\n");
		
	free(node);
	
	return 0;
}


Measured memory_bytes: 2076
times = [int(input()) for _ in range(5)]
fractions = [10 - t % 10 for t in times if t % 10 != 0]
if fractions:
    fraction = max(fractions)
else:
    fraction = 0
print(sum([(t + 9) // 10 * 10 for t in times]) - fraction)


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
long long int i,n,k,a[200010],ans=0;
  cin >> n >> k;
  for(i=0;i<n;i++){
  cin >> a[i];
  }
  sort(a,a+n,greater<int>());
    for(i=k;i<n;i++){
    ans=ans+a[i];
    }     
  cout << ans << endl;
return 0;
}

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

// 辞書最小順というのが肝

int main(void){

	std::string s, t;
	std::cin >> s >> t;


	bool flag = false;
	for(int s_id = s.size() - 1; s_id >= 0; s_id--){

		for(int t_id = t.size() - 1; t_id >= 0; t_id--){

			// 置き換えたとしてはみ出すようなら考慮しない
			if(s_id - t_id < 0 ||
			   (t.size() - t_id) + s_id > s.size()){

				continue;
			}

			if(s.at(s_id) == t.at(t_id) || s.at(s_id) == '?'){

				int i;
				for(i = 0; i < (int)t.size(); i++){

					int elem = i - t_id + s_id;
					
					if(s.at(elem) != '?' && s.at(elem) != t.at(i)){
						break;
					}
				}

				if(i == t.size()){

					for(i = 0; i < (int)t.size(); i++){

						int elem = i - t_id + s_id;

						if(s.at(elem) == '?'){
							s[elem] = t.at(i);
						}
					}

					flag = true;
					break;
				}
			}

		}

		if(flag){ break; }
	}

	if(!flag){
		s = "UNRESTORABLE";
	}

	// ?の位置はaで埋める
	for(auto itr = s.begin(); itr != s.end(); itr++){
		if((*itr) == '?') (*itr) = 'a';
	}

	std::cout << s << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
using namespace std;

int INF=1e9;

int main(){  
    char a,b;
    cin>>a>>b;
    if(a=='H'){
        cout<<b<<endl;
    }
    else{
        if(b=='H'){
            cout<<'D'<<endl;
        }
        else{
            cout<<'H'<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256